summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rwxr-xr-xhtml/2col_leftNav.css307
-rwxr-xr-xhtml/ExportedData.php33
-rwxr-xr-xhtml/Exporter.php54
-rwxr-xr-xhtml/Frodo.php173
-rw-r--r--html/admin.php31
l---------html/admin/2col_leftNav.css1
-rw-r--r--html/admin/add_client.php67
-rw-r--r--html/admin/add_permission.php32
-rw-r--r--html/admin/admin_smarty.php42
-rw-r--r--html/admin/assign_permissions.php40
-rw-r--r--html/admin/create_clientgroup.php42
-rw-r--r--html/admin/create_user.php68
-rw-r--r--html/admin/create_usergroup.php42
-rw-r--r--html/admin/delete_client.php35
-rw-r--r--html/admin/delete_clientgroup.php54
-rw-r--r--html/admin/delete_permission.php41
-rw-r--r--html/admin/delete_user.php31
-rw-r--r--html/admin/delete_usergroup.php54
-rw-r--r--html/admin/edit_client.php42
-rw-r--r--html/admin/edit_clientgroup.php53
-rw-r--r--html/admin/edit_permission.php43
-rw-r--r--html/admin/edit_user.php35
-rw-r--r--html/admin/edit_usergroup.php53
-rw-r--r--html/admin/phpgacl_code.php28
-rw-r--r--html/admin/s.gifbin0 -> 51 bytes
l---------html/admin/tux_large.png1
-rwxr-xr-xhtml/gimli.php67
-rwxr-xr-xhtml/glimd.txt3
-rwxr-xr-xhtml/index.php67
-rwxr-xr-xhtml/index.tpl5
-rw-r--r--html/login.php65
-rw-r--r--html/phpgacl/AUTHORS5
-rw-r--r--html/phpgacl/CHANGELOG451
-rw-r--r--html/phpgacl/COPYING.lib458
-rw-r--r--html/phpgacl/CREDITS39
-rw-r--r--html/phpgacl/Cache_Lite/Hashed_Cache_Lite.php184
-rw-r--r--html/phpgacl/Cache_Lite/LICENSE458
-rw-r--r--html/phpgacl/Cache_Lite/Lite.php615
-rw-r--r--html/phpgacl/FAQ1
-rw-r--r--html/phpgacl/README60
-rw-r--r--html/phpgacl/TODO56
-rw-r--r--html/phpgacl/admin/about.php95
-rw-r--r--html/phpgacl/admin/acl_admin.php259
-rw-r--r--html/phpgacl/admin/acl_debug.php95
-rw-r--r--html/phpgacl/admin/acl_list.php274
-rw-r--r--html/phpgacl/admin/acl_test.php26
-rw-r--r--html/phpgacl/admin/acl_test2.php110
-rw-r--r--html/phpgacl/admin/acl_test3.php140
-rw-r--r--html/phpgacl/admin/admin.css279
-rw-r--r--html/phpgacl/admin/admin_functions.js232
-rw-r--r--html/phpgacl/admin/assign_group.php188
-rw-r--r--html/phpgacl/admin/edit_group.php118
-rw-r--r--html/phpgacl/admin/edit_object_sections.php122
-rw-r--r--html/phpgacl/admin/edit_objects.php131
-rw-r--r--html/phpgacl/admin/gacl_admin.inc.php80
-rw-r--r--html/phpgacl/admin/gacl_admin_api.class.php109
-rw-r--r--html/phpgacl/admin/group_admin.php80
-rw-r--r--html/phpgacl/admin/images/bot-l.pngbin0 -> 867 bytes
-rw-r--r--html/phpgacl/admin/images/bot-r.pngbin0 -> 2819 bytes
-rw-r--r--html/phpgacl/admin/images/div-l.pngbin0 -> 133 bytes
-rw-r--r--html/phpgacl/admin/images/div-r.pngbin0 -> 154 bytes
-rw-r--r--html/phpgacl/admin/images/logo.pngbin0 -> 8976 bytes
-rw-r--r--html/phpgacl/admin/images/mid-l.pngbin0 -> 604 bytes
-rw-r--r--html/phpgacl/admin/images/mid-r.pngbin0 -> 2494 bytes
-rw-r--r--html/phpgacl/admin/images/spacer.gifbin0 -> 43 bytes
-rw-r--r--html/phpgacl/admin/images/tab-off-l.pngbin0 -> 687 bytes
-rw-r--r--html/phpgacl/admin/images/tab-off-r.pngbin0 -> 1266 bytes
-rw-r--r--html/phpgacl/admin/images/tab-on-l.pngbin0 -> 638 bytes
-rw-r--r--html/phpgacl/admin/images/tab-on-r.pngbin0 -> 1251 bytes
-rw-r--r--html/phpgacl/admin/images/top-l.pngbin0 -> 1265 bytes
-rw-r--r--html/phpgacl/admin/images/top-r.pngbin0 -> 7689 bytes
-rw-r--r--html/phpgacl/admin/index.php3
-rw-r--r--html/phpgacl/admin/junktest.php44
-rw-r--r--html/phpgacl/admin/object_search.php102
-rw-r--r--html/phpgacl/admin/s.gifbin0 -> 51 bytes
-rw-r--r--html/phpgacl/admin/smarty_x/README80
-rw-r--r--html/phpgacl/admin/smarty_x/libs/Config_File.class.php389
-rw-r--r--html/phpgacl/admin/smarty_x/libs/Smarty.class.php1934
-rw-r--r--html/phpgacl/admin/smarty_x/libs/Smarty_Compiler.class.php2304
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.assemble_auto_filename.php56
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.assemble_plugin_filepath.php67
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.assign_smarty_interface.php43
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.create_dir_structure.php79
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.display_debug_console.php61
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.get_include_path.php44
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.get_microtime.php23
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.get_php_resource.php80
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.is_secure.php56
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.is_trusted.php50
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.load_plugins.php125
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.load_resource_plugin.php74
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.process_cached_inserts.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.process_compiled_include.php32
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.read_cache_file.php111
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.rm_auto.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.rmdir.php55
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.run_insert_handler.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.smarty_include_php.php50
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.write_cache_file.php73
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.write_cache_paths_file.php29
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_include.php79
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_resource.php36
-rw-r--r--html/phpgacl/admin/smarty_x/libs/core/core.write_file.php56
-rw-r--r--html/phpgacl/admin/smarty_x/libs/debug.tpl64
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.assemble_plugin_filepath.php67
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.assign_smarty_interface.php43
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.create_dir_structure.php79
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.display_debug_console.php61
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.get_include_path.php44
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.get_microtime.php23
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.get_php_resource.php80
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.is_secure.php56
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.is_trusted.php47
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.load_plugins.php125
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.load_resource_plugin.php74
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.process_cached_inserts.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.process_compiled_include.php32
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.read_cache_file.php111
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.rm_auto.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.rmdir.php55
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.run_insert_handler.php71
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.smarty_include_php.php50
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.write_cache_file.php96
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_include.php91
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_resource.php35
-rw-r--r--html/phpgacl/admin/smarty_x/libs/internals/core.write_file.php54
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/block.strip.php35
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/block.textformat.php102
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/compiler.assign.php38
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.assign.php38
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.assign_debug_info.php39
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.config_load.php140
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.counter.php79
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.cycle.php102
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.debug.php35
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.eval.php48
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.fetch.php220
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_checkboxes.php143
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_image.php139
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_options.php121
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_radios.php150
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_date.php316
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_time.php192
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.html_table.php137
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.mailto.php163
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.math.php83
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.popup.php117
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/function.popup_init.php39
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.capitalize.php42
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.cat.php33
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_characters.php31
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_paragraphs.php28
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_sentences.php28
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_words.php32
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.date_format.php48
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.debug_print_var.php56
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.default.php31
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.escape.php89
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.indent.php27
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.lower.php25
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.nl2br.php35
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.regex_replace.php33
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.replace.php29
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.spacify.php29
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.string_format.php28
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip.php33
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip_tags.php31
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.truncate.php43
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.upper.php25
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/modifier.wordwrap.php28
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/outputfilter.trimwhitespace.php75
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/shared.escape_special_chars.php30
-rw-r--r--html/phpgacl/admin/smarty_x/libs/plugins/shared.make_timestamp.php43
-rw-r--r--html/phpgacl/admin/templates/phpgacl/about.tpl86
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_admin.tpl180
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_admin_js.tpl4
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_debug.tpl112
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_list.tpl244
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_test.tpl24
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_test2.tpl98
-rw-r--r--html/phpgacl/admin/templates/phpgacl/acl_test3.tpl106
-rw-r--r--html/phpgacl/admin/templates/phpgacl/assign_group.tpl103
-rw-r--r--html/phpgacl/admin/templates/phpgacl/debug.tpl39
-rw-r--r--html/phpgacl/admin/templates/phpgacl/edit_group.tpl49
-rw-r--r--html/phpgacl/admin/templates/phpgacl/edit_object_sections.tpl77
-rw-r--r--html/phpgacl/admin/templates/phpgacl/edit_objects.tpl82
-rw-r--r--html/phpgacl/admin/templates/phpgacl/footer.tpl11
-rw-r--r--html/phpgacl/admin/templates/phpgacl/group_admin.tpl41
-rw-r--r--html/phpgacl/admin/templates/phpgacl/header.tpl7
-rw-r--r--html/phpgacl/admin/templates/phpgacl/navigation.tpl19
-rw-r--r--html/phpgacl/admin/templates/phpgacl/object_search.tpl62
-rw-r--r--html/phpgacl/admin/templates/phpgacl/pager.tpl18
-rw-r--r--html/phpgacl/admin/templates_c/%%1C^1C3^1C38C10C%%navigation.tpl.php22
-rw-r--r--html/phpgacl/admin/templates_c/%%45^45C^45CE9A26%%edit_objects.tpl.php175
-rw-r--r--html/phpgacl/admin/templates_c/%%4A^4AC^4AC2250D%%footer.tpl.php15
-rw-r--r--html/phpgacl/admin/templates_c/%%61^618^6182431B%%pager.tpl.php27
-rw-r--r--html/phpgacl/admin/templates_c/%%85^85D^85DD3D56%%edit_group.tpl.php73
-rw-r--r--html/phpgacl/admin/templates_c/%%8B^8BF^8BF9EC71%%assign_group.tpl.php173
-rw-r--r--html/phpgacl/admin/templates_c/%%98^980^980C056E%%acl_test2.tpl.php159
-rw-r--r--html/phpgacl/admin/templates_c/%%A5^A56^A56C2CDE%%acl_test3.tpl.php181
-rw-r--r--html/phpgacl/admin/templates_c/%%B2^B23^B23838E8%%acl_list.tpl.php322
-rw-r--r--html/phpgacl/admin/templates_c/%%B3^B37^B37111DC%%header.tpl.php10
-rw-r--r--html/phpgacl/admin/templates_c/%%C7^C72^C720F60D%%acl_admin_js.tpl.php6
-rw-r--r--html/phpgacl/admin/templates_c/%%C7^C7B^C7BBD6D2%%acl_admin.tpl.php234
-rw-r--r--html/phpgacl/admin/templates_c/%%CE^CEC^CECA437B%%acl_debug.tpl.php147
-rw-r--r--html/phpgacl/admin/templates_c/%%D2^D28^D28FA630%%group_admin.tpl.php83
-rw-r--r--html/phpgacl/admin/templates_c/%%D3^D36^D36362FF%%edit_object_sections.tpl.php166
-rw-r--r--html/phpgacl/admin/templates_c/%%DA^DAC^DAC67802%%acl_test.tpl.php38
-rw-r--r--html/phpgacl/admin/templates_c/%%EB^EBC^EBCFAB96%%about.tpl.php103
-rw-r--r--html/phpgacl/admin/test.php422
-rw-r--r--html/phpgacl/adodb/adodb-csvlib.inc.php312
-rw-r--r--html/phpgacl/adodb/adodb-datadict.inc.php778
-rw-r--r--html/phpgacl/adodb/adodb-error.inc.php258
-rw-r--r--html/phpgacl/adodb/adodb-errorhandler.inc.php79
-rw-r--r--html/phpgacl/adodb/adodb-errorpear.inc.php88
-rw-r--r--html/phpgacl/adodb/adodb-exceptions.inc.php80
-rw-r--r--html/phpgacl/adodb/adodb-iterator.inc.php84
-rw-r--r--html/phpgacl/adodb/adodb-lib.inc.php1002
-rw-r--r--html/phpgacl/adodb/adodb-pager.inc.php289
-rw-r--r--html/phpgacl/adodb/adodb-pear.inc.php374
-rw-r--r--html/phpgacl/adodb/adodb-perf.inc.php1053
-rw-r--r--html/phpgacl/adodb/adodb-php4.inc.php16
-rw-r--r--html/phpgacl/adodb/adodb-time.inc.php1287
-rw-r--r--html/phpgacl/adodb/adodb-xmlschema.inc.php2195
-rw-r--r--html/phpgacl/adodb/adodb.inc.php3876
-rw-r--r--html/phpgacl/adodb/contrib/toxmlrpc.inc.php157
-rw-r--r--html/phpgacl/adodb/cute_icons_for_site/adodb.gifbin0 -> 1091 bytes
-rw-r--r--html/phpgacl/adodb/cute_icons_for_site/adodb.pngbin0 -> 29024 bytes
-rw-r--r--html/phpgacl/adodb/cute_icons_for_site/adodb2.gifbin0 -> 1458 bytes
-rw-r--r--html/phpgacl/adodb/cute_icons_for_site/adodb2.pngbin0 -> 30806 bytes
-rw-r--r--html/phpgacl/adodb/datadict/datadict-access.inc.php95
-rw-r--r--html/phpgacl/adodb/datadict/datadict-db2.inc.php143
-rw-r--r--html/phpgacl/adodb/datadict/datadict-firebird.inc.php151
-rw-r--r--html/phpgacl/adodb/datadict/datadict-generic.inc.php125
-rw-r--r--html/phpgacl/adodb/datadict/datadict-ibase.inc.php67
-rw-r--r--html/phpgacl/adodb/datadict/datadict-informix.inc.php80
-rw-r--r--html/phpgacl/adodb/datadict/datadict-mssql.inc.php254
-rw-r--r--html/phpgacl/adodb/datadict/datadict-mysql.inc.php181
-rw-r--r--html/phpgacl/adodb/datadict/datadict-oci8.inc.php282
-rw-r--r--html/phpgacl/adodb/datadict/datadict-postgres.inc.php359
-rw-r--r--html/phpgacl/adodb/datadict/datadict-sapdb.inc.php121
-rw-r--r--html/phpgacl/adodb/datadict/datadict-sybase.inc.php228
-rw-r--r--html/phpgacl/adodb/docs/docs-adodb.htm3466
-rw-r--r--html/phpgacl/adodb/docs/docs-datadict.htm553
-rw-r--r--html/phpgacl/adodb/docs/docs-perf.htm388
-rw-r--r--html/phpgacl/adodb/docs/docs-session.htm239
-rw-r--r--html/phpgacl/adodb/docs/old-changelog.htm700
-rw-r--r--html/phpgacl/adodb/docs/readme.htm69
-rw-r--r--html/phpgacl/adodb/docs/tips_portable_sql.htm362
-rw-r--r--html/phpgacl/adodb/docs/tute.htm290
-rw-r--r--html/phpgacl/adodb/drivers/adodb-access.inc.php86
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ado.inc.php628
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ado5.inc.php636
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ado_access.inc.php54
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ado_mssql.inc.php98
-rw-r--r--html/phpgacl/adodb/drivers/adodb-borland_ibase.inc.php91
-rw-r--r--html/phpgacl/adodb/drivers/adodb-csv.inc.php203
-rw-r--r--html/phpgacl/adodb/drivers/adodb-db2.inc.php361
-rw-r--r--html/phpgacl/adodb/drivers/adodb-fbsql.inc.php266
-rw-r--r--html/phpgacl/adodb/drivers/adodb-firebird.inc.php75
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ibase.inc.php861
-rw-r--r--html/phpgacl/adodb/drivers/adodb-informix.inc.php35
-rw-r--r--html/phpgacl/adodb/drivers/adodb-informix72.inc.php475
-rw-r--r--html/phpgacl/adodb/drivers/adodb-ldap.inc.php406
-rw-r--r--html/phpgacl/adodb/drivers/adodb-mssql.inc.php1019
-rw-r--r--html/phpgacl/adodb/drivers/adodb-mssqlpo.inc.php62
-rw-r--r--html/phpgacl/adodb/drivers/adodb-mysql.inc.php765
-rw-r--r--html/phpgacl/adodb/drivers/adodb-mysqli.inc.php905
-rw-r--r--html/phpgacl/adodb/drivers/adodb-mysqlt.inc.php136
-rw-r--r--html/phpgacl/adodb/drivers/adodb-netezza.inc.php170
-rw-r--r--html/phpgacl/adodb/drivers/adodb-oci8.inc.php1477
-rw-r--r--html/phpgacl/adodb/drivers/adodb-oci805.inc.php59
-rw-r--r--html/phpgacl/adodb/drivers/adodb-oci8po.inc.php217
-rw-r--r--html/phpgacl/adodb/drivers/adodb-odbc.inc.php738
-rw-r--r--html/phpgacl/adodb/drivers/adodb-odbc_mssql.inc.php254
-rw-r--r--html/phpgacl/adodb/drivers/adodb-odbc_oracle.inc.php114
-rw-r--r--html/phpgacl/adodb/drivers/adodb-odbtp.inc.php728
-rw-r--r--html/phpgacl/adodb/drivers/adodb-odbtp_unicode.inc.php39
-rw-r--r--html/phpgacl/adodb/drivers/adodb-oracle.inc.php320
-rw-r--r--html/phpgacl/adodb/drivers/adodb-pdo.inc.php545
-rw-r--r--html/phpgacl/adodb/drivers/adodb-pdo_mysql.inc.php145
-rw-r--r--html/phpgacl/adodb/drivers/adodb-pdo_oci.inc.php92
-rw-r--r--html/phpgacl/adodb/drivers/adodb-pdo_pgsql.inc.php228
-rw-r--r--html/phpgacl/adodb/drivers/adodb-postgres.inc.php14
-rw-r--r--html/phpgacl/adodb/drivers/adodb-postgres64.inc.php1017
-rw-r--r--html/phpgacl/adodb/drivers/adodb-postgres7.inc.php230
-rw-r--r--html/phpgacl/adodb/drivers/adodb-postgres8.inc.php12
-rw-r--r--html/phpgacl/adodb/drivers/adodb-proxy.inc.php33
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sapdb.inc.php184
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sqlanywhere.inc.php169
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sqlite.inc.php373
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sqlitepo.inc.php62
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sybase.inc.php413
-rw-r--r--html/phpgacl/adodb/drivers/adodb-sybase_ase.inc.php115
-rw-r--r--html/phpgacl/adodb/drivers/adodb-vfp.inc.php107
-rw-r--r--html/phpgacl/adodb/lang/adodb-ar.inc.php34
-rw-r--r--html/phpgacl/adodb/lang/adodb-bg.inc.php38
-rw-r--r--html/phpgacl/adodb/lang/adodb-bgutf8.inc.php38
-rw-r--r--html/phpgacl/adodb/lang/adodb-ca.inc.php35
-rw-r--r--html/phpgacl/adodb/lang/adodb-cn.inc.php35
-rw-r--r--html/phpgacl/adodb/lang/adodb-cz.inc.php40
-rw-r--r--html/phpgacl/adodb/lang/adodb-da.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-de.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-en.inc.php34
-rw-r--r--html/phpgacl/adodb/lang/adodb-es.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-esperanto.inc.php35
-rw-r--r--html/phpgacl/adodb/lang/adodb-fr.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-hu.inc.php34
-rw-r--r--html/phpgacl/adodb/lang/adodb-it.inc.php34
-rw-r--r--html/phpgacl/adodb/lang/adodb-nl.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-pl.inc.php36
-rw-r--r--html/phpgacl/adodb/lang/adodb-pt-br.inc.php35
-rw-r--r--html/phpgacl/adodb/lang/adodb-ro.inc.php36
-rw-r--r--html/phpgacl/adodb/lang/adodb-ru1251.inc.php35
-rw-r--r--html/phpgacl/adodb/lang/adodb-sv.inc.php33
-rw-r--r--html/phpgacl/adodb/lang/adodb-uk1251.inc.php35
-rw-r--r--html/phpgacl/adodb/license.txt182
-rw-r--r--html/phpgacl/adodb/pear/readme.Auth.txt20
-rw-r--r--html/phpgacl/adodb/perf/perf-db2.inc.php102
-rw-r--r--html/phpgacl/adodb/perf/perf-informix.inc.php70
-rw-r--r--html/phpgacl/adodb/perf/perf-mssql.inc.php164
-rw-r--r--html/phpgacl/adodb/perf/perf-mysql.inc.php315
-rw-r--r--html/phpgacl/adodb/perf/perf-oci8.inc.php509
-rw-r--r--html/phpgacl/adodb/perf/perf-postgres.inc.php124
-rw-r--r--html/phpgacl/adodb/pivottable.inc.php185
-rw-r--r--html/phpgacl/adodb/readme.txt62
-rw-r--r--html/phpgacl/adodb/rsfilter.inc.php61
-rw-r--r--html/phpgacl/adodb/server.php98
-rw-r--r--html/phpgacl/adodb/session/adodb-compress-bzip2.php118
-rw-r--r--html/phpgacl/adodb/session/adodb-compress-gzip.php93
-rw-r--r--html/phpgacl/adodb/session/adodb-cryptsession.php24
-rw-r--r--html/phpgacl/adodb/session/adodb-encrypt-mcrypt.php109
-rw-r--r--html/phpgacl/adodb/session/adodb-encrypt-md5.php39
-rw-r--r--html/phpgacl/adodb/session/adodb-encrypt-secret.php48
-rw-r--r--html/phpgacl/adodb/session/adodb-sess.txt131
-rw-r--r--html/phpgacl/adodb/session/adodb-session-clob.php23
-rw-r--r--html/phpgacl/adodb/session/adodb-session.php909
-rw-r--r--html/phpgacl/adodb/session/adodb-sessions.mysql.sql16
-rw-r--r--html/phpgacl/adodb/session/adodb-sessions.oracle.clob.sql15
-rw-r--r--html/phpgacl/adodb/session/adodb-sessions.oracle.sql16
-rw-r--r--html/phpgacl/adodb/session/crypt.inc.php64
-rw-r--r--html/phpgacl/adodb/tests/benchmark.php84
-rw-r--r--html/phpgacl/adodb/tests/client.php194
-rw-r--r--html/phpgacl/adodb/tests/pdo.php82
-rw-r--r--html/phpgacl/adodb/tests/test-datadict.php248
-rw-r--r--html/phpgacl/adodb/tests/test-perf.php50
-rw-r--r--html/phpgacl/adodb/tests/test-pgblob.php88
-rw-r--r--html/phpgacl/adodb/tests/test-php5.php78
-rw-r--r--html/phpgacl/adodb/tests/test-xmlschema.php54
-rw-r--r--html/phpgacl/adodb/tests/test.php1704
-rw-r--r--html/phpgacl/adodb/tests/test2.php26
-rw-r--r--html/phpgacl/adodb/tests/test3.php44
-rw-r--r--html/phpgacl/adodb/tests/test4.php134
-rw-r--r--html/phpgacl/adodb/tests/test5.php47
-rw-r--r--html/phpgacl/adodb/tests/test_rs_array.php47
-rw-r--r--html/phpgacl/adodb/tests/testcache.php29
-rw-r--r--html/phpgacl/adodb/tests/testdatabases.inc.php412
-rw-r--r--html/phpgacl/adodb/tests/testgenid.php36
-rw-r--r--html/phpgacl/adodb/tests/testmssql.php76
-rw-r--r--html/phpgacl/adodb/tests/testoci8.php83
-rw-r--r--html/phpgacl/adodb/tests/testoci8cursor.php111
-rw-r--r--html/phpgacl/adodb/tests/testpaging.php86
-rw-r--r--html/phpgacl/adodb/tests/testpear.php34
-rw-r--r--html/phpgacl/adodb/tests/testsessions.php81
-rw-r--r--html/phpgacl/adodb/tests/time.php17
-rw-r--r--html/phpgacl/adodb/tests/tmssql.php65
-rw-r--r--html/phpgacl/adodb/tests/xmlschema.xml33
-rw-r--r--html/phpgacl/adodb/toexport.inc.php133
-rw-r--r--html/phpgacl/adodb/tohtml.inc.php195
-rw-r--r--html/phpgacl/adodb/xmlschema.dtd38
-rw-r--r--html/phpgacl/adodb/xsl/convert-0.1-0.2.xsl205
-rw-r--r--html/phpgacl/adodb/xsl/convert-0.2-0.1.xsl207
-rw-r--r--html/phpgacl/adodb/xsl/remove-0.2.xsl54
-rw-r--r--html/phpgacl/docs/examples/example.php164
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/Multi-levelGroups.php316
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/definingAccessControl.php472
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/fineGrainAccessControl.php138
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/footer.php13
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/header.php23
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/index.php53
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/millenniumFalcon.inc27
-rw-r--r--html/phpgacl/docs/examples/millennium_falcon/welcome.php34
-rw-r--r--html/phpgacl/docs/manual.html1308
-rw-r--r--html/phpgacl/docs/manual.pdfbin0 -> 1020282 bytes
-rw-r--r--html/phpgacl/docs/manual.sxwbin0 -> 348894 bytes
-rw-r--r--html/phpgacl/docs/manual.txt526
-rw-r--r--html/phpgacl/docs/manual_html_157037e7.pngbin0 -> 7123 bytes
-rw-r--r--html/phpgacl/docs/manual_html_4b803670.pngbin0 -> 26043 bytes
-rw-r--r--html/phpgacl/docs/manual_html_676f8c98.pngbin0 -> 15275 bytes
-rw-r--r--html/phpgacl/docs/manual_html_7dced6ce.pngbin0 -> 12036 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m481ab4b3.pngbin0 -> 8741 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m48c2db5c.pngbin0 -> 2639 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m4f4324cb.pngbin0 -> 3762 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m54d0ced8.pngbin0 -> 8976 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m608b392a.pngbin0 -> 6712 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m6a630ca2.pngbin0 -> 5165 bytes
-rw-r--r--html/phpgacl/docs/manual_html_m770a5a15.pngbin0 -> 2054 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/blank.html13
-rw-r--r--html/phpgacl/docs/phpdoc/classtrees_phpGACL.html26
-rw-r--r--html/phpgacl/docs/phpdoc/elementindex.html701
-rw-r--r--html/phpgacl/docs/phpdoc/elementindex_phpGACL.html698
-rw-r--r--html/phpgacl/docs/phpdoc/errors.html20
-rw-r--r--html/phpgacl/docs/phpdoc/index.html24
-rw-r--r--html/phpgacl/docs/phpdoc/li_phpGACL.html36
-rw-r--r--html/phpgacl/docs/phpdoc/media/banner.css33
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractClass.pngbin0 -> 620 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractClass_logo.pngbin0 -> 1232 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractMethod.pngbin0 -> 696 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass.pngbin0 -> 848 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass_logo.pngbin0 -> 1615 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/AbstractPrivateMethod.pngbin0 -> 874 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Class.pngbin0 -> 570 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Class_logo.pngbin0 -> 1600 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Constant.pngbin0 -> 752 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Constructor.pngbin0 -> 865 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Destructor.pngbin0 -> 956 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Function.pngbin0 -> 596 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Global.pngbin0 -> 712 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/I.pngbin0 -> 148 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Index.pngbin0 -> 584 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/L.pngbin0 -> 153 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Lminus.pngbin0 -> 219 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Lplus.pngbin0 -> 224 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Method.pngbin0 -> 661 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Page.pngbin0 -> 592 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Page_logo.pngbin0 -> 1369 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/PrivateClass.pngbin0 -> 790 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/PrivateClass_logo.pngbin0 -> 1836 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/PrivateMethod.pngbin0 -> 918 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/PrivateVariable.pngbin0 -> 772 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/T.pngbin0 -> 152 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Tminus.pngbin0 -> 207 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Tplus.pngbin0 -> 222 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/Variable.pngbin0 -> 688 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/blank.pngbin0 -> 144 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/class_folder.pngbin0 -> 633 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/empty.pngbin0 -> 90 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/file.pngbin0 -> 462 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/folder.pngbin0 -> 492 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/function_folder.pngbin0 -> 605 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/next_button.pngbin0 -> 657 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/next_button_disabled.pngbin0 -> 543 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/package.pngbin0 -> 668 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/package_folder.pngbin0 -> 564 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/previous_button.pngbin0 -> 644 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/previous_button_disabled.pngbin0 -> 541 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/private_class_logo.pngbin0 -> 1836 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/tutorial.pngbin0 -> 431 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/tutorial_folder.pngbin0 -> 572 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/images/up_button.pngbin0 -> 668 bytes
-rw-r--r--html/phpgacl/docs/phpdoc/media/stylesheet.css146
-rw-r--r--html/phpgacl/docs/phpdoc/packages.html29
-rw-r--r--html/phpgacl/docs/phpdoc/phpGACL/_gacl_api_class_php.html65
-rw-r--r--html/phpgacl/docs/phpdoc/phpGACL/_gacl_class_php.html93
-rw-r--r--html/phpgacl/docs/phpdoc/phpGACL/gacl.html974
-rw-r--r--html/phpgacl/docs/phpdoc/phpGACL/gacl_api.html2190
-rw-r--r--html/phpgacl/docs/phpgacl-db-schema.pngbin0 -> 96039 bytes
-rw-r--r--html/phpgacl/docs/phpgacl-db-schema.vsdbin0 -> 253440 bytes
-rw-r--r--html/phpgacl/docs/translations/russian/manual_rus.html848
-rw-r--r--html/phpgacl/docs/translations/russian/manual_rus.pdfbin0 -> 295683 bytes
-rw-r--r--html/phpgacl/docs/translations/russian/manual_rus.sxwbin0 -> 57886 bytes
-rw-r--r--html/phpgacl/docs/translations/russian/manual_rus.txt674
-rw-r--r--html/phpgacl/gacl.class.php629
-rw-r--r--html/phpgacl/gacl.ini.php42
-rw-r--r--html/phpgacl/gacl_api.class.php3899
-rw-r--r--html/phpgacl/other_languages/perl/perlGACL-check-1.0.tar.gzbin0 -> 6938 bytes
-rw-r--r--html/phpgacl/phpdoc.phpgacl.ini98
-rw-r--r--html/phpgacl/profiler.inc218
-rw-r--r--html/phpgacl/schema.xml513
-rw-r--r--html/phpgacl/setup.php206
-rw-r--r--html/phpgacl/soap/clients/perl_client.pl31
-rw-r--r--html/phpgacl/soap/clients/php_client.php24
-rw-r--r--html/phpgacl/soap/clients/python_client.py24
-rw-r--r--html/phpgacl/soap/nusoap.php4098
-rw-r--r--html/phpgacl/soap/server.php33
-rw-r--r--html/phpgacl/test_suite/acl_tests.php223
-rw-r--r--html/phpgacl/test_suite/phpunit/ChangeLog69
-rw-r--r--html/phpgacl/test_suite/phpunit/README24
-rw-r--r--html/phpgacl/test_suite/phpunit/phpunit.php633
-rw-r--r--html/phpgacl/test_suite/phpunit/phpunit_test.php268
-rw-r--r--html/phpgacl/test_suite/phpunit/runtests.php45
-rw-r--r--html/phpgacl/test_suite/phpunit/runtests2.php39
-rw-r--r--html/phpgacl/test_suite/phpunit/stylesheet.css64
-rw-r--r--html/phpgacl/test_suite/random_acl_check.php201
-rw-r--r--html/phpgacl/test_suite/run.php161
-rw-r--r--html/phpgacl/test_suite/stress_test.php419
-rw-r--r--html/phpgacl/test_suite/styles.css101
-rw-r--r--html/phpgacl/test_suite/unit_tests.php563
-rw-r--r--html/templates/admin.tpl27
-rw-r--r--html/templates/admin/add_client.tpl51
-rw-r--r--html/templates/admin/add_permission.tpl27
-rw-r--r--html/templates/admin/assign_permissions.tpl74
-rw-r--r--html/templates/admin/create_clientgroup.tpl15
-rw-r--r--html/templates/admin/create_user.tpl38
-rw-r--r--html/templates/admin/create_usergroup.tpl15
-rw-r--r--html/templates/admin/delete_client.tpl23
-rw-r--r--html/templates/admin/delete_clientgroup.tpl22
-rw-r--r--html/templates/admin/delete_permission.tpl26
-rw-r--r--html/templates/admin/delete_user.tpl21
-rw-r--r--html/templates/admin/delete_usergroup.tpl22
-rw-r--r--html/templates/admin/edit_client.tpl70
-rw-r--r--html/templates/admin/edit_clientgroup.tpl33
-rw-r--r--html/templates/admin/edit_permission.tpl41
-rw-r--r--html/templates/admin/edit_user.tpl35
-rw-r--r--html/templates/admin/edit_usergroup.tpl33
-rwxr-xr-xhtml/templates/header.tpl21
-rwxr-xr-xhtml/templates/index.tpl1
-rw-r--r--html/templates/leftbar.tpl43
-rw-r--r--html/templates_c/%%05^059^0591EA96%%delete_client.tpl.php58
-rw-r--r--html/templates_c/%%20^20E^20ED0D17%%delete_clientgroup.tpl.php32
-rw-r--r--html/templates_c/%%25^255^255963FB%%leftbar.tpl.php50
-rw-r--r--html/templates_c/%%2D^2D5^2D54479D%%add_permission.tpl.php33
-rw-r--r--html/templates_c/%%40^40A^40A26E7D%%assign_permissions.tpl.php115
-rw-r--r--html/templates_c/%%45^45E^45E480CD%%index.tpl.php7
-rw-r--r--html/templates_c/%%45^45E^45EE95AC%%edit_client.tpl.php115
-rw-r--r--html/templates_c/%%57^57F^57F47D92%%edit_clientgroup.tpl.php49
-rw-r--r--html/templates_c/%%62^620^6206D997%%admin.tpl.php33
-rw-r--r--html/templates_c/%%76^76E^76E347F5%%create_clientgroup.tpl.php24
-rw-r--r--html/templates_c/%%82^82E^82E719A3%%create_user.tpl.php47
-rw-r--r--html/templates_c/%%8B^8B9^8B93D9A4%%edit_usergroup.tpl.php115
-rw-r--r--html/templates_c/%%9E^9E0^9E0AB182%%delete_user.tpl.php54
-rw-r--r--html/templates_c/%%BF^BFC^BFC0C69B%%edit_role.tpl.php71
-rw-r--r--html/templates_c/%%C1^C17^C17E547B%%delete_role.tpl.php54
-rw-r--r--html/templates_c/%%CA^CA7^CA72B036%%delete_usergroup.tpl.php32
-rw-r--r--html/templates_c/%%CB^CB4^CB4A447D%%add_client.tpl.php60
-rw-r--r--html/templates_c/%%DD^DD9^DD93FC5A%%create_role.tpl.php21
-rw-r--r--html/templates_c/%%E0^E0B^E0B42362%%edit_user.tpl.php72
-rw-r--r--html/templates_c/%%E1^E1D^E1DC02AD%%delete_permission.tpl.php59
-rw-r--r--html/templates_c/%%F7^F7F^F7F34188%%header.tpl.php52
-rw-r--r--html/templates_c/%%F9^F94^F94199C6%%create_usergroup.tpl.php24
-rw-r--r--html/templates_c/%%FF^FF9^FF9C11AC%%edit_permission.tpl.php78
-rwxr-xr-xhtml/tux_large.pngbin0 -> 33191 bytes
-rw-r--r--moria/moria.sql25
-rw-r--r--moria/moria2.sql15
535 files changed, 89532 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 3edbf34..3cc4f6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
# Copyright 2006-2006 Gentoo Foundation; Distributed under the GPL v2
# $Id$
+ 26 Mar 2006; Preston Cody <codeman@gentoo.org> ChangeLog:
+ Adding current state of my webserver GIMLI directory
+ includes phpGACL code and smarty, both of which
+ are necessary to install. nothing works either
+ without the database
+
24 Mar 2006; Preston Cody <codeman@gentoo.org> ChangeLog:
Testing echangelog. Adding two db table creation commands.
diff --git a/html/2col_leftNav.css b/html/2col_leftNav.css
new file mode 100755
index 0000000..5ced7bd
--- /dev/null
+++ b/html/2col_leftNav.css
@@ -0,0 +1,307 @@
+/***********************************************/
+/* 2col_leftNav.css */
+/* Use with template 2col_leftNav.html */
+/***********************************************/
+
+/***********************************************/
+/* HTML tag styles */
+/***********************************************/
+
+body{
+ font-family: Arial,sans-serif;
+ color: #333333;
+ line-height: 1.166;
+ margin: 0px;
+ padding: 0px;
+}
+
+a:link, a:visited, a:hover {
+ color: #006699;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+/* overrides decoration from previous rule for hovered links */
+
+h1, h2, h3, h4, h5, h6 {
+ font-family: Arial,sans-serif;
+ margin: 0px;
+ padding: 0px;
+}
+
+h1{
+ font-family: Verdana,Arial,sans-serif;
+ font-size: 120%;
+ color: #334d55;
+}
+
+h2{
+ font-size: 114%;
+ color: #006699;
+}
+
+h3{
+ font-size: 100%;
+ color: #334d55;
+}
+
+h4{
+ font-size: 100%;
+ font-weight: normal;
+ color: #333333;
+}
+
+h5{
+ font-size: 100%;
+ color: #334d55;
+}
+
+ul{
+ list-style-type: square;
+}
+
+ul ul{
+ list-style-type: disc;
+}
+
+ul ul ul{
+ list-style-type: none;
+}
+
+label{
+ font: bold 100% Arial,sans-serif;
+ color: #334d55;
+}
+
+
+/***********************************************/
+/* Layout Divs */
+/***********************************************/
+
+#masthead{
+ margin: 0;
+ padding: 10px 0px;
+ border-bottom: 1px solid #cccccc;
+ width: 100%;
+}
+
+#navBar{
+ margin: 0 85% 0 0;
+ padding: 0px;
+ background-color: #eeeeee;
+ border-right: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+}
+
+#content{
+ float:right;
+ width: 75%;
+ margin: 0;
+ padding: 0 3% 0 0;
+}
+
+
+/***********************************************/
+/*Component Divs */
+/***********************************************/
+
+#siteName{
+ margin: 0px;
+ padding: 0px 0px 10px 10px;
+}
+
+
+/*************** #pageName styles **************/
+
+#pageName{
+ padding: 0px 0px 10px 10px;
+}
+
+
+/************* #globalNav styles **************/
+
+#globalNav{
+color: #cccccc;
+padding: 0px 0px 0px 10px;
+white-space: nowrap;
+}
+/* 'nowrap' prevents links from line-wrapping if there are too many to fit in one line
+ this will force a horizontal scrollbar if there isn't enough room for all links
+ remove rule or change value to 'normal' if you want the links to line-wrap */
+
+#globalNav img{
+ display: block;
+}
+
+#globalNav a {
+ font-size: 90%;
+ padding: 0px 4px 0px 0px;
+}
+
+
+/************* #breadCrumb styles *************/
+
+#breadCrumb{
+ font-size: 80%;
+ padding: 5px 0px 5px 10px;
+}
+
+
+/************** .feature styles ***************/
+
+.feature{
+ padding: 0px 0px 10px 10px;
+ font-size: 80%;
+}
+
+.feature h3{
+ padding: 30px 0px 5px 0px;
+ text-align: center;
+}
+
+.feature img{
+ float: left;
+ padding: 0px 10px 0px 0px;
+ margin: 0 5px 5px 0;
+}
+/* adjust margins to change separation between the feature image and text flowing around it */
+
+
+/************** .story styles *****************/
+
+.story{
+ clear: both;
+ padding: 10px 0px 0px 10px;
+ font-size: 80%;
+}
+
+.story p{
+ padding: 0px 0px 10px 0px;
+}
+
+
+/************* #siteInfo styles ***************/
+
+#siteInfo{
+ clear: both;
+ border: 1px solid #cccccc;
+ font-size: 75%;
+ color: #cccccc;
+ padding: 10px 10px 10px 10px;
+ margin-top: 0px;
+}
+/* negative top margin pulls siteinfo up so its top border overlaps (and thus lines up with)
+ the bottom border of the navBar in cases where they "touch" */
+
+#siteInfo img{
+ padding: 4px 4px 4px 0px;
+ vertical-align: middle;
+}
+
+
+/************* #search styles ***************/
+
+#search{
+ padding: 5px 0px 5px 10px;
+ border-bottom: 1px solid #cccccc;
+ font-size: 90%;
+}
+
+#search form{
+ margin: 0px;
+ padding: 0px;
+}
+
+#search label{
+ display: block;
+ margin: 0px;
+ padding: 0px;
+}
+
+
+/*********** #navBar link styles ***********/
+
+#navBar ul a:link, #navBar ul a:visited {display: block;}
+#navBar ul {list-style: none; margin: 0; padding: 0;}
+
+/* hack to fix IE/Win's broken rendering of block-level anchors in lists */
+#navBar li {border-bottom: 1px solid #EEE;}
+
+/* fix for browsers that don't need the hack */
+html>body #navBar li {border-bottom: none;}
+
+
+/*********** #sectionLinks styles ***********/
+
+#sectionLinks{
+ position: relative;
+ margin: 0px;
+ padding: 0px;
+ border-bottom: 1px solid #cccccc;
+ font-size: 90%;
+}
+
+#sectionLinks h3{
+ padding: 10px 0px 2px 10px;
+}
+
+#sectionLinks a:link{
+ padding: 2px 0px 2px 10px;
+ border-top: 1px solid #cccccc;
+ width: 100%;
+ voice-family: "\"}\"";
+ voice-family:inherit;
+ width: auto;
+}
+
+#sectionLinks a:visited{
+ border-top: 1px solid #cccccc;
+ padding: 2px 0px 2px 10px;
+}
+
+#sectionLinks a:hover{
+ border-top: 1px solid #cccccc;
+ background-color: #dddddd;
+ padding: 2px 0px 2px 10px;
+}
+
+
+/*********** .relatedLinks styles ***********/
+
+.relatedLinks{
+ margin: 0px;
+ padding: 0px 0px 10px 10px;
+ font-size: 90%;
+}
+
+.relatedLinks h3{
+ padding: 10px 0px 2px 0px;
+}
+
+
+/************** #advert styles **************/
+
+#advert{
+ padding: 10px 0px 0px 10px;
+ font-size: 80%;
+ border-top: 1px solid #cccccc;
+}
+
+#advert img{
+ display: block;
+}
+
+
+/************** #headlines styles **************/
+
+#headlines{
+ margin: 0px;
+ padding: 10px 0px 20px 10px;
+ font-size: 80%;
+}
+
+#headlines p{
+ padding: 5px 0px 5px 0px;
+}
diff --git a/html/ExportedData.php b/html/ExportedData.php
new file mode 100755
index 0000000..2bf4b3b
--- /dev/null
+++ b/html/ExportedData.php
@@ -0,0 +1,33 @@
+<?
+#This will be a core component and thus just show within gimli.
+require_once('Frodo.php');
+$machines = array();
+if ($_POST['group']) {
+ print $_POST['group'];
+ $machines = get_group_machines($_POST['group']);
+} else {
+ print "ALL";
+ $machines = get_all_machines();
+}
+if ($_POST['ExportToCSV']) {
+ print "This is a fake CSV. It has no header row.<br>";
+ foreach ($machines as $machine) {
+ for ($i=0;$i< count($machine);$i++) {
+ print "$machine[$i],";
+ }
+ print "<br>";
+ }
+}
+elseif ($_POST['ExportToXML']) {
+}
+elseif ($_POST['ExportToTXT']) {
+ print "This is a fake tab-delimited TXT. It has no header row.<br><pre>";
+ foreach ($machines as $machine) {
+ for ($i=0;$i< count($machine);$i++) {
+ print "$machine[$i]\t";
+ }
+ print "<br>";
+ }
+ print "</pre>";
+}
+?>
diff --git a/html/Exporter.php b/html/Exporter.php
new file mode 100755
index 0000000..3ecfd7e
--- /dev/null
+++ b/html/Exporter.php
@@ -0,0 +1,54 @@
+<h2>Server Information Exporter</h2>List of machines in group:
+<?
+#This will be a core component and thus just show within gimli.
+require_once('Frodo.php');
+$machines = array();
+if ($_POST['group']) {
+ print $_POST['group'];
+ $machines = get_group_machines($_POST['group']);
+} else {
+ print "ALL";
+ $machines = get_all_machines();
+}
+
+#Get a list of the groups to put in the select box.
+$profile_list = get_profile_list();
+?>
+
+<form name="form1" method="post" action="#">
+<select name="group" size="1">
+<option value=""></option>
+<?
+foreach ($profile_list as $profile)
+{
+ print "<option value=\"$profile[0]\">$profile[0]</option>\n";
+}
+?>
+</select>
+<input type="submit" name="ChangeView" value="Go, because i hate doing it with javascript.">
+</form>
+<form name="form2" method="post" action="ExportedData.php">
+<table><tr>
+ <th>HOSTNAME</th>
+ <th>STATUS</th>
+ <th>IP</th>
+ <th>MAC</th>
+ <th>METHOD</th>
+ <th>OTHER</th>
+ </tr>
+<?
+foreach ($machines as $machine)
+{
+ print "<tr><td>$machine[1]</td>\n";
+ print "<td>$machine[8]</td>\n";
+ print "<td>$machine[3]</td>\n";
+ print "<td>$machine[2]</td>\n";
+ print "<td>$machine[5]</td>\n";
+ print "<td>$machine[6]</td>\n";
+}
+?>
+</table>
+<hr>
+<input type="submit" name="ExportToXML" value="Export To XML">
+<input type="submit" name="ExportToCSV" value="Export To CSV">
+<input type="submit" name="ExportToTXT" value="Export To TXT">
diff --git a/html/Frodo.php b/html/Frodo.php
new file mode 100755
index 0000000..56a59be
--- /dev/null
+++ b/html/Frodo.php
@@ -0,0 +1,173 @@
+<?php
+//database access
+$db_host = 'localhost';
+$db_user = 'hobbit';
+$db_pass = 'hobbitpassword';
+$db_name = 'moria';
+$MYSQL_ERRNO = '';
+$MYSQL_ERROR = '';
+$DEBUG = 1;
+$link_id = mysql_connect($db_host, $db_user, $db_pass);
+if (!$link_id)
+{
+ $MYSQL_ERRNO = 0;
+ $MYSQL_ERROR = "Connection failed to the host $db_host.";
+}
+
+if (mysql_select_db($db_name, $link_id)) {
+ if ($DEBUG >= 2) {
+ echo "Connected.";
+ }
+}
+else {
+ die ("Connection failed.");
+}
+function call_query($query) {
+ if ($DEBUG) { print "DEBUG: $query <br>"; }
+ $result = mysql_query($query);
+ if (mysql_errno()) {
+ die("<br>" . mysql_errno().": " . mysql_error()."<br>"); }
+ return $result;
+}
+
+function get_gimli_modules()
+{
+ $query = "SELECT * FROM modules;";
+ $result = call_query($query);
+ $num_modules = mysql_num_rows($result);
+ for ($i =0; $i < $num_modules;$i++)
+ {
+ $module[$i] = mysql_fetch_row($result);
+ $module[$i];
+ #$module_list[$i] = $module[$i][1];
+ }
+ return $module;
+}
+
+function get_profile_list()
+{
+ $query = "SELECT profile_name FROM profiles";
+ $result = call_query($query);
+ $num_profiles = mysql_num_rows($result);
+ for ($i = 0; $i < $num_profiles;$i++)
+ {
+ $profile_list[$i] = mysql_fetch_row($result);
+ }
+ return $profile_list;
+}
+
+function get_group_clients($group)
+{
+ $query = "SELECT * FROM clients WHERE profile='$group'";
+ $result = call_query($query);
+ $num_clients = mysql_num_rows($result);
+ for ($i = 0; $i < $num_clients;$i++)
+ {
+ $clients[$i] = mysql_fetch_row($result);
+ }
+ return $clients;
+}
+
+function get_all_clients()
+{
+ $query = "SELECT * FROM clients";
+ $result = call_query($query);
+ $num_clients = mysql_num_rows($result);
+ for ($i = 0; $i < $num_clients;$i++)
+ {
+ $clients[$i] = mysql_fetch_array($result, MYSQL_ASSOC);
+ }
+ return $clients;
+}
+
+function get_gimli_client($client_id)
+{
+ $query = "SELECT * FROM clients WHERE client_id=$client_id";
+ $result = call_query($query);
+ return mysql_fetch_array($result, MYSQL_ASSOC);
+}
+
+function gimli_add_client($hostname, $mac, $ip, $profile, $distribution, $admin, $status)
+{
+ $query = "INSERT INTO clients (hostname,mac,ip,profile,distribution,administrator,status) values ('$hostname','$mac','$ip','$profile','$distribution','$admin','$status')";
+ print $query;
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_edit_client($client_id, $hostname, $mac, $ip, $profile, $distribution, $admin, $status)
+{
+ $query = "UPDATE clients SET hostname='$hostname', mac='$mac', ip='$ip', profile='$profile', distribution='$distribution', administrator='$administrator', status='$status' WHERE client_id=$client_id";
+ print $query;
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_del_client($client_id)
+{
+ $query = "DELETE FROM clients WHERE client_id=$client_id";
+ $result = call_query($query);
+ return $result;
+}
+
+function get_gimli_users()
+{
+ $query = "SELECT * FROM users";
+ $result = call_query($query);
+ $num_users = mysql_num_rows($result);
+ for ($i = 0; $i < $num_users;$i++)
+ {
+ $users[$i] = mysql_fetch_row($result);
+ }
+ return $users;
+}
+
+function gimli_add_user($username, $password, $real_name, $comment)
+{
+ $password = crypt($password,447470567);
+ $query = "INSERT INTO users (username,password,real_name,comment) VALUES ('$username','$password','$real_name','$comment')";
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_del_user($username)
+{
+ $query = "DELETE FROM users WHERE username='$username'";
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_add_permission($perm_name, $desc, $created_by)
+{
+ $query = "INSERT INTO permissions (perm_name, description, creator) VALUES ('$perm_name','$desc','$created_by')";
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_edit_permission($perm_name, $desc)
+{
+ $query = "UPDATE permissions SET description='$desc' WHERE perm_name='$perm_name'";
+ $result = call_query($query);
+ return $result;
+}
+
+function gimli_del_permission($perm_name)
+{
+ $query = "DELETE FROM permissions WHERE perm_name='$perm_name'";
+ $result = call_query($query);
+ return $result;
+}
+
+function get_gimli_permissions()
+{
+ $query = "SELECT * FROM permissions";
+ $result = call_query($query);
+ $num_users = mysql_num_rows($result);
+ for ($i = 0; $i < $num_users;$i++)
+ {
+ $users[$i] = mysql_fetch_row($result);
+ }
+ return $users;
+}
+
+?>
diff --git a/html/admin.php b/html/admin.php
new file mode 100644
index 0000000..1c174c9
--- /dev/null
+++ b/html/admin.php
@@ -0,0 +1,31 @@
+<?php
+
+include('Smarty.class.php');
+require_once('Frodo.php');
+if(!isset($_SESSION['userid'])) {
+ #print "<h1>NO MATCH</h1>";
+ header("Location: login.php");
+}
+else {
+ print "Welcome $_SESSION[userid]<br>";
+}
+$smarty = new Smarty;
+#phpinfo();
+$smarty->template_dir = './templates';
+$smarty->compile_dir = './templates_c';
+$smarty->cache_dir = './cache';
+$smarty->config_dir = './configs';
+
+$smarty->assign('topbar', array(
+ array('name'=> 'Login', 'link' => 'login.php'),
+ array('name'=> 'Clients', 'link' => 'clients.php'),
+ array('name'=> 'Jobs/Tasks', 'link' => 'jobs.php'),
+ array('name'=> 'Modules', 'link' => 'modules.php'),
+ array('name'=> 'Admin', 'link' => 'admin.php')));
+
+$smarty->display('admin.tpl');
+
+
+
+$smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/2col_leftNav.css b/html/admin/2col_leftNav.css
new file mode 120000
index 0000000..064a6ba
--- /dev/null
+++ b/html/admin/2col_leftNav.css
@@ -0,0 +1 @@
+../2col_leftNav.css \ No newline at end of file
diff --git a/html/admin/add_client.php b/html/admin/add_client.php
new file mode 100644
index 0000000..93ebca8
--- /dev/null
+++ b/html/admin/add_client.php
@@ -0,0 +1,67 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ #################################################### PHPGACL CODE
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+
+
+if($_POST['submit']) {
+ if (!$_POST['hostname']) { $status .= "ERROR: Hostname required! "; }
+ if (!$_POST['mac']) { $status .= "ERROR: Hostname required! "; }
+ if (!$_POST['ip']) { $status .= "ERROR: Hostname required! "; }
+ if ($_POST['hostname'] and $_POST['mac'] and $_POST['ip'])
+ {
+ #Add the client now.
+ $status .= gimli_add_client($_POST['hostname'], $_POST['mac'], $_POST['ip'], $_POST['profile'], $_POST['distribution'], $_POST['administrator'], $_POST['status']);
+ if (!$status) { $status = "User added to DB successfully.";}
+ $obj_id = $gacl_api->add_object("clients", $_POST['hostname'], $_POST['hostname'], 1, 0, 'AXO');
+ print "Object id: $obj_id <BR>";
+
+ if ($_POST['groups']) {
+ print "Adding client to groups ".$_POST['groups'];
+ foreach( $_POST['groups'] as $group) {
+ $worked = $gacl_api->add_group_object($group, "clients", $_POST['hostname'], 'AXO');
+ if ($worked) {
+ print "Group $group Addition successfull.<br>";
+ } else {
+ print "ERROR adding group $group <br>";
+ }
+ }
+ }
+ }
+}
+
+
+$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('axo'), TEXT);
+
+$ids = array();
+$groupnames = array();
+foreach($formatted_groups as $id => $name) {
+ print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+}
+
+
+ ####################################################
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ ###################################################
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->display('admin/add_client.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/add_permission.php b/html/admin/add_permission.php
new file mode 100644
index 0000000..fed71f8
--- /dev/null
+++ b/html/admin/add_permission.php
@@ -0,0 +1,32 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ #################################################### PHPGACL CODE
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+ if($_POST['permname'] and $_POST['permdesc']) {
+ #Add the user now.
+ $status .= gimli_add_permission($_POST['permname'], $_POST['permdesc'],$_SESSION['userid']);
+ if(!$status) {$status = "User added to DB successfully.";}
+ $obj_id = $gacl_api->add_object("perms", $_POST['permname'], $_POST['permname'], 1, 0, 'ACO');
+ print "Object id: $obj_id <BR>";
+ }
+ ####################################################
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ ###################################################
+
+ $smarty->display('admin/add_permission.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/admin_smarty.php b/html/admin/admin_smarty.php
new file mode 100644
index 0000000..6ffa7a1
--- /dev/null
+++ b/html/admin/admin_smarty.php
@@ -0,0 +1,42 @@
+<?php
+ #This is the code to set up the SMARTY templates for the Admin pages.
+ # it has ../ on things and sets the leftbar to show the admin list.
+ $smarty = new Smarty;
+ $smarty->template_dir = '../templates';
+ $smarty->compile_dir = '../templates_c';
+ $smarty->cache_dir = '../cache';
+ $smarty->config_dir = '../configs';
+ $smarty->assign('topbar', array(
+ array('name'=> 'Login', 'link' => '../login.php'),
+ array('name'=> 'Clients', 'link' => '../clients.php'),
+ array('name'=> 'Jobs/Tasks', 'link' => '../jobs.php'),
+ array('name'=> 'Modules', 'link' => '../modules.php'),
+ array('name'=> 'Admin', 'link' => '../admin.php')));
+ $smarty->assign('left_section_header',"Admin Functions");
+ $smarty->assign('leftnav', array(
+ array("create_user.php", "Create a User"),
+ array("edit_user.php","Edit a User"),
+ array("delete_user.php","Delete a User"),
+ array("",""),
+ array("create_usergroup.php","Create a UserGroup"),
+ array("edit_usergroup.php","Edit a UserGroup"),
+ array("delete_usergroup.php","Delete a UserGroup"),
+ array("",""),
+ array("add_permission.php","Add Permission"),
+ array("edit_permission.php","Edit Permission"),
+ array("delete_permission.php","Delete Permission"),
+ array("",""),
+ array("add_client.php","Add Client Manually"),
+ array("edit_client.php","Edit Clients"),
+ array("delete_client.php","Delete Client from GIMLI"),
+ array("",""),
+ array("create_clientgroup.php","Create a ClientGroup"),
+ array("edit_clientgroup.php","Edit a ClientGroup"),
+ array("delete_clientgroup.php","Delete a ClientGroup"),
+ ));
+
+
+ if($status) {
+ $smarty->assign('error', $status);
+ }
+?>
diff --git a/html/admin/assign_permissions.php b/html/admin/assign_permissions.php
new file mode 100644
index 0000000..56deada
--- /dev/null
+++ b/html/admin/assign_permissions.php
@@ -0,0 +1,40 @@
+<?php
+include('Smarty.class.php');
+include('../Frodo.php');
+#phpinfo();
+if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+}
+else {
+ print "Welcome $_SESSION[userid]<br>";
+}
+#################################################### PHPGACL CODE
+
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+
+####################################################
+#Load Smarty Template
+include('admin_smarty.php');
+
+###################################################
+#Get the usergroups.
+$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), HTML);
+$smarty->assign('usergroups',$formatted_groups);
+$all_users = $gacl_api->get_objects("users",1,'ARO');
+$userinfo = array();
+foreach ($all_users as $user) {
+ foreach ($user as $userdata) {
+ $id = $gacl_api->get_object_id("users",$userdata,'ARO');
+ $groups = $gacl_api->get_object_groups($id,'ARO');
+ array_push($userinfo, array($id,$userdata,$groups));
+ }
+}
+$smarty->assign('users', $userinfo);
+
+$smarty->display('admin/assign_permissions.tpl');
+
+
+$smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/create_clientgroup.php b/html/admin/create_clientgroup.php
new file mode 100644
index 0000000..5f0082f
--- /dev/null
+++ b/html/admin/create_clientgroup.php
@@ -0,0 +1,42 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if ($_POST['groupname'] and $_POST['parentgroup']) {
+ #Add the group as a subgroup. This is all done in the gacl_api.
+ $newgroup_id = $gacl_api->add_group($_POST['groupname'], $_POST['groupname'], $_POST['parentgroup'], 'AXO');
+ print "Group added successfully, new group id is: $newgroup_id<br>";
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('axo'), TEXT);
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups as $id => $name) {
+ print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->display('admin/create_clientgroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/create_user.php b/html/admin/create_user.php
new file mode 100644
index 0000000..675ef34
--- /dev/null
+++ b/html/admin/create_user.php
@@ -0,0 +1,68 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ #################################################### PHPGACL CODE
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+
+
+ if($_POST['username']) {
+ if ($_POST['passwd'] == $_POST['passwd2']) {
+ #Add the user now.
+ $status .= gimli_add_user($_POST['username'], $_POST['passwd'], $_POST['realname'], $_POST['comment']);
+ # $status = "User added to DB successfully.";
+ $obj_id = $gacl_api->add_object("users", $_POST['username'], $_POST['username'], 1, 0, 'ARO');
+ print "Object id: $obj_id <BR>";
+
+ if ($_POST['groups']) {
+ print "Adding user to groups ".$_POST['groups'];
+ foreach( $_POST['groups'] as $group) {
+ $worked = $gacl_api->add_group_object($group, "users", $_POST['username'], 'ARO');
+ if ($worked) {
+ print "Group $group Addition successfull.<br>";
+ } else {
+ print "ERROR adding group $group <br>";
+ }
+ }
+ }
+ }
+ else
+ {
+ $status = "ERROR: Passwords do not match.";
+ }
+
+ }
+
+
+$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), TEXT);
+
+$ids = array();
+$groupnames = array();
+foreach($formatted_groups as $id => $name) {
+ print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+}
+
+
+ ####################################################
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ ###################################################
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->display('admin/create_user.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/create_usergroup.php b/html/admin/create_usergroup.php
new file mode 100644
index 0000000..b66942b
--- /dev/null
+++ b/html/admin/create_usergroup.php
@@ -0,0 +1,42 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if ($_POST['groupname'] and $_POST['parentgroup']) {
+ #Add the group as a subgroup. This is all done in the gacl_api.
+ $newgroup_id = $gacl_api->add_group($_POST['groupname'], $_POST['groupname'], $_POST['parentgroup'], 'ARO');
+ print "Group added successfully, new group id is: $newgroup_id<br>";
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), TEXT);
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups as $id => $name) {
+ print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->display('admin/create_usergroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/delete_client.php b/html/admin/delete_client.php
new file mode 100644
index 0000000..9bd80eb
--- /dev/null
+++ b/html/admin/delete_client.php
@@ -0,0 +1,35 @@
+<?php
+
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ if($_POST['delsubmit'] and $_POST['delclient'] and $_POST['iamsure']) {
+ include('phpgacl_code.php');
+ $client_id = $_POST['delclient'];
+ $client_data = get_gimli_client($client_id);
+
+ $status = gimli_del_client($client_id);
+
+ $id = $gacl_api->get_object_id("clients", $client_data['hostname'], 'AXO');
+ $gacl_api->del_object($id, 'AXO', TRUE);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ $clients = get_all_clients();
+ $smarty->assign('clients', $clients);
+
+ $smarty->display('admin/delete_client.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/delete_clientgroup.php b/html/admin/delete_clientgroup.php
new file mode 100644
index 0000000..c1aa2ce
--- /dev/null
+++ b/html/admin/delete_clientgroup.php
@@ -0,0 +1,54 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if($_POST['delsubmit'] and $_POST['delgroup'] and $_POST['iamsure']) {
+ #Check if the group has children.
+ $result = $gacl_api->del_group($_POST['delgroup'],TRUE, 'AXO');
+ if ($result) {
+ $status = "Group deleted successfully.";
+ } else {
+ $status = "ERROR: Group could not be successfully deleted.";
+ }
+
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('axo'), HTML);
+ $formatted_groups2 = $gacl_api->format_groups($gacl_api->sort_groups('axo'), TEXT);
+
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups2 as $id => $name) {
+ #print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty templates.
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->assign('editgroup', $editgroup);
+ $smarty->assign('editgroupdata', $editgroupdata);
+
+ $smarty->assign('clientgroups', $formatted_groups);
+
+ $smarty->display('admin/delete_clientgroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/delete_permission.php b/html/admin/delete_permission.php
new file mode 100644
index 0000000..f9e7f55
--- /dev/null
+++ b/html/admin/delete_permission.php
@@ -0,0 +1,41 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ #################################################### PHPGACL CODE
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+
+ if($_POST['delperm'] and $_POST['delsubmit'] and $_POST['iamsure']) {
+ #Delete the user.
+ $status .= gimli_del_permission($_POST['delperm']);
+ if(!$status) {$status = "User deleted from DB successfully. ";}
+ #Get the obj ID for edit
+ $obj_id = $gacl_api->get_object_id("perms",$_POST['delperm'],'ACO');
+ $result = $gacl_api->del_object($obj_id, 'ACO', TRUE);
+ if($result) {
+ $status .= "Permission deleted from ACLs successfully. ";
+ } else {
+ $status .= "ERROR: Permission could not be delted from the ACLs! ";
+ }
+ }
+ ####################################################
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ ###################################################
+ $permissions = get_gimli_permissions();
+ $smarty->assign('permissions', $permissions);
+
+ $smarty->display('admin/delete_permission.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/delete_user.php b/html/admin/delete_user.php
new file mode 100644
index 0000000..17212a1
--- /dev/null
+++ b/html/admin/delete_user.php
@@ -0,0 +1,31 @@
+<?php
+
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ if($_POST['delsubmit'] and $_POST['deluser'] and $_POST['iamsure']) {
+ include('phpgacl_code.php');
+ $status = gimli_del_user($_POST['deluser']);
+ $id = $gacl_api->get_object_id("users", $_POST['deluser'], 'ARO');
+ $gacl_api->del_object($id, 'ARO', TRUE);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ $users = get_gimli_users();
+ $smarty->assign('users', $users);
+
+ $smarty->display('admin/delete_user.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/delete_usergroup.php b/html/admin/delete_usergroup.php
new file mode 100644
index 0000000..7b29229
--- /dev/null
+++ b/html/admin/delete_usergroup.php
@@ -0,0 +1,54 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if($_POST['delsubmit'] and $_POST['delgroup'] and $_POST['iamsure']) {
+ #Check if the group has children.
+ $result = $gacl_api->del_group($_POST['delgroup'],TRUE, 'ARO');
+ if ($result) {
+ $status = "Group deleted successfully.";
+ } else {
+ $status = "ERROR: Group could not be successfully deleted.";
+ }
+
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), HTML);
+ $formatted_groups2 = $gacl_api->format_groups($gacl_api->sort_groups('aro'), TEXT);
+
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups2 as $id => $name) {
+ #print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty templates.
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->assign('editgroup', $editgroup);
+ $smarty->assign('editgroupdata', $editgroupdata);
+
+ $smarty->assign('usergroups', $formatted_groups);
+
+ $smarty->display('admin/delete_usergroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/edit_client.php b/html/admin/edit_client.php
new file mode 100644
index 0000000..9e54d99
--- /dev/null
+++ b/html/admin/edit_client.php
@@ -0,0 +1,42 @@
+<?php
+
+include('Smarty.class.php');
+include('../Frodo.php');
+#phpinfo();
+if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+}
+else {
+ print "Welcome $_SESSION[userid]<br>";
+}
+
+if($_POST['savesubmit']) {
+ if (!$_POST['hostname']) { $status .= "ERROR: Hostname required! "; }
+ if (!$_POST['mac']) { $status .= "ERROR: Hostname required! "; }
+ if (!$_POST['ip']) { $status .= "ERROR: Hostname required! "; }
+ if ($_POST['hostname'] and $_POST['mac'] and $_POST['ip'])
+ {
+ $status .= gimli_edit_client($_POST['client_id'], $_POST['hostname'], $_POST['mac'], $_POST['ip'], $_POST['profile'], $_POST['distribution'], $_POST['administrator'], $_POST['status']);
+ if (!$status) { $status = "User added to DB successfully.";}
+ }
+}
+
+#Load Smarty Template
+include('admin_smarty.php');
+
+if($_POST['editsubmit'] and $_POST['editclient'])
+{
+ $client_id = $_POST['editclient'];
+ $client_data = get_gimli_client($client_id);
+ $smarty->assign('cdata', $client_data);
+
+}
+else{
+ $clients = get_all_clients();
+ $smarty->assign('clients', $clients);
+}
+$smarty->display('admin/edit_client.tpl');
+
+$smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/edit_clientgroup.php b/html/admin/edit_clientgroup.php
new file mode 100644
index 0000000..259bc32
--- /dev/null
+++ b/html/admin/edit_clientgroup.php
@@ -0,0 +1,53 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if ($_POST['editgroup']) {
+ $editgroup = $_POST['editgroup'];
+ $editgroupdata = $gacl_api->get_group_data($editgroup, 'AXO');
+ }
+
+ if ($_POST['groupname'] and $_POST['parentgroup']) {
+ $newgroup_id = $gacl_api->edit_group($_POST['groupid'], $_POST['groupname'], $_POST['groupname'], $_POST['parentgroup'], 'AXO');
+ print "Group edited successfully, group id is: $newgroup_id<br>";
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('axo'), HTML);
+ $formatted_groups2 = $gacl_api->format_groups($gacl_api->sort_groups('axo'), TEXT);
+
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups2 as $id => $name) {
+ #print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->assign('editgroup', $editgroup);
+ $smarty->assign('editgroupdata', $editgroupdata);
+
+ $smarty->assign('clientgroups', $formatted_groups);
+
+ $smarty->display('admin/edit_clientgroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/edit_permission.php b/html/admin/edit_permission.php
new file mode 100644
index 0000000..2ba24d4
--- /dev/null
+++ b/html/admin/edit_permission.php
@@ -0,0 +1,43 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ #################################################### PHPGACL CODE
+$status = "";
+include('phpgacl_code.php'); #load the GACL_API
+ if($_POST['permname'] and $_POST['permdesc']) {
+ #Add the user now.
+ $status .= gimli_edit_permission($_POST['permname'], $_POST['permdesc']);
+ if(!$status) {$status = "User edited to DB successfully.";}
+ #Get the obj ID for edit
+ $obj_id = $gacl_api->get_object_id("perms",$_POST['permname'],'ACO');
+ $result = $gacl_api->edit_object($obj_id, "perms", $_POST['permname'], $_POST['permname'], 1, 0, 'ACO');
+ print "Object id: $obj_id <BR>";
+ }
+ ####################################################
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ ###################################################
+ if($_POST['submit'] and $_POST['editperm'])
+ {
+ $permname = $_POST['editperm'];
+ $smarty->assign('permname', $_POST['editperm']);
+ $smarty->assign('permdesc', $_POST[$permname.'_desc']);
+ }
+ else{
+ $permissions = get_gimli_permissions();
+ $smarty->assign('permissions', $permissions);
+ }
+ $smarty->display('admin/edit_permission.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/edit_user.php b/html/admin/edit_user.php
new file mode 100644
index 0000000..ce7aef2
--- /dev/null
+++ b/html/admin/edit_user.php
@@ -0,0 +1,35 @@
+<?php
+
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+
+ if($_POST['savesubmit'] and $_POST['roledesc']) {
+ #$status = gimli_edit_user($_POST['rolename'], $_POST['roledesc']);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ if($_POST['editsubmit'] and $_POST['edituser'])
+ {
+ $edituser = $_POST['edituser'];
+ $smarty->assign('username', $_POST['edituser']);
+ $smarty->assign('userdesc', $_POST[$edituser.'_desc']);
+ }
+ else{
+ $users = get_gimli_users();
+ $smarty->assign('users', $users);
+ }
+ $smarty->display('admin/edit_user.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/edit_usergroup.php b/html/admin/edit_usergroup.php
new file mode 100644
index 0000000..5edc0e0
--- /dev/null
+++ b/html/admin/edit_usergroup.php
@@ -0,0 +1,53 @@
+<?php
+ include('Smarty.class.php');
+ include('../Frodo.php');
+ #phpinfo();
+ if(!isset($_SESSION['userid'])) {
+ header("Location: ../login.php");
+ exit;
+ }
+ else {
+ print "Welcome $_SESSION[userid]<br>";
+ }
+ $status = "";
+ include('phpgacl_code.php'); #load the GACL_API
+
+ ### Deal with submitted form here
+ if ($_POST['editgroup']) {
+ $editgroup = $_POST['editgroup'];
+ $editgroupdata = $gacl_api->get_group_data($editgroup, 'ARO');
+ }
+
+ if ($_POST['groupname'] and $_POST['parentgroup']) {
+ $newgroup_id = $gacl_api->edit_group($_POST['groupid'], $_POST['groupname'], $_POST['groupname'], $_POST['parentgroup'], 'ARO');
+ print "Group edited successfully, group id is: $newgroup_id<br>";
+ }
+
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), HTML);
+ $formatted_groups2 = $gacl_api->format_groups($gacl_api->sort_groups('aro'), TEXT);
+
+ $ids = array();
+ $groupnames = array();
+ foreach($formatted_groups2 as $id => $name) {
+ #print "ID: $id Name: $name <br>";
+ array_push($ids, $id);
+ array_push($groupnames, $name);
+ }
+
+ #Load Smarty Template
+ include('admin_smarty.php');
+
+ #For the <select> list of groups.
+ $smarty->assign('ids',$ids);
+ $smarty->assign('groupnames', $groupnames);
+
+ $smarty->assign('editgroup', $editgroup);
+ $smarty->assign('editgroupdata', $editgroupdata);
+
+ $smarty->assign('usergroups', $formatted_groups);
+
+ $smarty->display('admin/edit_usergroup.tpl');
+
+
+ $smarty->display('leftbar.tpl');
+?>
diff --git a/html/admin/phpgacl_code.php b/html/admin/phpgacl_code.php
new file mode 100644
index 0000000..d16165c
--- /dev/null
+++ b/html/admin/phpgacl_code.php
@@ -0,0 +1,28 @@
+<?php
+ #################################################### PHPGACL CODE
+ require_once(dirname(__FILE__).'/../phpgacl/gacl.class.php');
+ require_once(dirname(__FILE__).'/../phpgacl/gacl_api.class.php');
+ require_once(dirname(__FILE__).'/../phpgacl/admin/gacl_admin_api.class.php');
+
+// phpGACL Configuration file.
+if ( !isset($config_file) ) {
+# $config_file = '../gacl.ini.php';
+ $config_file = dirname(__FILE__).'/../phpgacl/gacl.ini.php';
+}
+
+//Values supplied in $gacl_options array overwrite those in the config file.
+if ( file_exists($config_file) ) {
+ $config = parse_ini_file($config_file);
+
+ if ( is_array($config) ) {
+ if ( isset($gacl_options) ) {
+ $gacl_options = array_merge($config, $gacl_options);
+ } else {
+ $gacl_options = $config;
+ }
+ }
+ unset($config);
+}
+$gacl_api = new gacl_admin_api($gacl_options);
+###############################################
+?>
diff --git a/html/admin/s.gif b/html/admin/s.gif
new file mode 100644
index 0000000..5035948
--- /dev/null
+++ b/html/admin/s.gif
Binary files differ
diff --git a/html/admin/tux_large.png b/html/admin/tux_large.png
new file mode 120000
index 0000000..f06f852
--- /dev/null
+++ b/html/admin/tux_large.png
@@ -0,0 +1 @@
+../tux_large.png \ No newline at end of file
diff --git a/html/gimli.php b/html/gimli.php
new file mode 100755
index 0000000..c3370e4
--- /dev/null
+++ b/html/gimli.php
@@ -0,0 +1,67 @@
+<?php require_once('Frodo.php');
+$module_list = array();
+#Database structure for gimli modules
+#Table: modules
+#Desc:
+# id = unique int; auto_increment
+# name = varchar(20)
+# long_name = varchar(90)
+# description = varchar(500)
+# main_content = varchar(90) # a filename to import.. we don't want php code in the database.
+# author = varchar(50)
+# creation_date =
+# distribution = varchar(30)
+# group? like categorizing them?
+# homepage = varchar(90) #misc modules should have a website
+
+?>
+<body>
+
+<div align="center">
+ <p>Generic Interface for the Management of Linux Installations</p>
+ <p>(G.I.M.L.I.)</p>
+ <table width="100%" border="1">
+ <tr>
+ <td scope="row"><p align="left">Modules:</p>
+ <p align="left">Load module list from DB</p>
+ <br><table border="2"><?php
+ $module_list = get_gimli_modules();
+ foreach ($module_list as $module) {
+ echo "<tr><td><a href=\"gimli.php?module=$module[1]\">$module[2]</a></td></tr>";
+ }
+ ?>
+ </table><p align="left">&nbsp; </p></td>
+ <td><?php
+ if ($_GET['module']) {
+ show_module_content($_GET['module']);
+ }
+ else {
+ show_main_page();
+ }
+ ?><hr>Once clicked, the description of the module will show up on this side. You can then launch the module by
+ <form name="form1" method="post" action="">
+ <input type="submit" name="Submit" value="Clicking the button">, unless it is a core module in which case it will just load up on the right side.
+ </form></td>
+ </tr>
+ </table>
+ <p align="left">&nbsp;</p>
+</div>
+<?
+function show_main_page()
+{
+ print "This is the main page because there are no modules currently loaded.";
+}
+function show_module_content($module)
+{
+ $module_list = get_gimli_modules();
+ foreach ($module_list as $single_module)
+ {
+ if ($single_module[1] == $module)
+ {
+ require_once($single_module[4]);
+ }
+ }
+}
+?>
+</body>
+</html>
diff --git a/html/glimd.txt b/html/glimd.txt
new file mode 100755
index 0000000..af6b68a
--- /dev/null
+++ b/html/glimd.txt
@@ -0,0 +1,3 @@
+here is some test text in a file for the main page content of GLIMD
+<a href="http://localhost:8000/" target="new">Load GLIMD</a>
+<br>
diff --git a/html/index.php b/html/index.php
new file mode 100755
index 0000000..2fbc4ff
--- /dev/null
+++ b/html/index.php
@@ -0,0 +1,67 @@
+<?php
+
+include('Smarty.class.php');
+require_once('Frodo.php');
+if(!isset($_SESSION['userid'])) {
+ #print "<h1>NO MATCH</h1>";
+ header("Location: login.php");
+}
+else {
+ print "Welcome $_SESSION[userid]<br>";
+}
+
+$smarty = new Smarty;
+#phpinfo();
+$smarty->template_dir = './templates';
+$smarty->compile_dir = './templates_c';
+$smarty->cache_dir = './cache';
+$smarty->config_dir = './configs';
+
+$smarty->assign('topbar', array(
+ array('name'=> 'Login', 'link' => 'login.php'),
+ array('name'=> 'Clients', 'link' => 'clients.php'),
+ array('name'=> 'Jobs/Tasks', 'link' => 'jobs.php'),
+ array('name'=> 'Modules', 'link' => 'modules.php'),
+ array('name'=> 'Admin', 'link' => 'admin.php')));
+
+#Database structure for gimli modules
+#Table: modules
+#Desc:
+# id = unique int; auto_increment
+# name = varchar(20)
+# long_name = varchar(90)
+# description = varchar(500)
+# main_content = varchar(90) # a filename to import.. we don't want php code in the database.
+# author = varchar(50)
+# creation_date =
+# distribution = varchar(30)
+# group? like categorizing them?
+# homepage = varchar(90) #misc modules should have a website
+$module_list = array();
+$module_list = get_gimli_modules();
+$smarty->assign('leftnav', $module_list);
+
+
+$smarty->display('index.tpl');
+
+if ($_GET['module']) {
+ show_module_content($_GET['module'], $module_list);
+}
+else {
+ print "Welcome to GIMLI. This is the index page. It has index-y stuff on it. ok?";
+}
+
+function show_module_content($module, $module_list)
+{
+# $module_list = get_gimli_modules();
+ foreach ($module_list as $single_module)
+ {
+ if ($single_module[1] == $module)
+ {
+ require_once($single_module[4]);
+ }
+ }
+}
+$smarty->display('leftbar.tpl');
+
+?>
diff --git a/html/index.tpl b/html/index.tpl
new file mode 100755
index 0000000..68921c9
--- /dev/null
+++ b/html/index.tpl
@@ -0,0 +1,5 @@
+<html>
+<body>
+{include file="header.tpl" title="Main Page"}
+</body>
+</html>
diff --git a/html/login.php b/html/login.php
new file mode 100644
index 0000000..87d3813
--- /dev/null
+++ b/html/login.php
@@ -0,0 +1,65 @@
+<?php
+
+include('Smarty.class.php');
+include('Frodo.php');
+#phpinfo();
+if ($_POST['username']) {
+ $users = array();
+ $users = get_gimli_users();
+ foreach ($users as $user) {
+ if ($_POST['username'] == $user[0]) {
+ if ($_POST['passwd'] and (crypt($_POST['passwd'],447470567) == $user[1])) {
+ session_start();
+ #session_register('userid', $user[0]);
+ $_SESSION['userid'] = $user[0];
+ session_write_close();
+ header("Location: index.php");
+ }
+ else {
+ session_unset();
+ print "<h1>Invalid password supplied!</h1>";
+ exit;
+ }
+ }
+ }
+ session_unset();
+ print "<h1>Invalid user supplied!</h1>";
+
+}
+
+
+$smarty = new Smarty;
+
+$smarty->template_dir = './templates';
+$smarty->compile_dir = './templates_c';
+$smarty->cache_dir = './cache';
+$smarty->config_dir = './configs';
+
+$smarty->assign('topbar', array(
+ array('name'=> 'Login', 'link' => 'login.php'),
+ array('name'=> 'Clients', 'link' => 'clients.php'),
+ array('name'=> 'Jobs/Tasks', 'link' => 'jobs.php'),
+ array('name'=> 'Modules', 'link' => 'modules.php'),
+ array('name'=> 'Admin', 'link' => 'admin.php')));
+
+
+$smarty->display('header.tpl');
+?>
+<b>Please Login to use GIMLI:</b>
+<form id="form1" name="form1" method="post" action="login.php">
+ <label>Username
+ <input name="username" type="text" id="username" />
+ </label>
+ <p>
+ <label>Password
+ <input name="passwd" type="password" id="passwd" />
+ </label>
+ </p>
+ <p>
+ <input name="submit" type="Submit" label="Submit">
+ </p>
+</form>
+
+<?php
+$smarty->display('leftbar.tpl');
+?>
diff --git a/html/phpgacl/AUTHORS b/html/phpgacl/AUTHORS
new file mode 100644
index 0000000..a4a1475
--- /dev/null
+++ b/html/phpgacl/AUTHORS
@@ -0,0 +1,5 @@
+Mike Benoit <ipso@snappymail.ca>
+ - Initial idea of completely configurable ACLs.
+ Though I haven't seen anything similar available, I'm sure its out there.
+ - Initial implementation
+ - Initial Documentation
diff --git a/html/phpgacl/CHANGELOG b/html/phpgacl/CHANGELOG
new file mode 100644
index 0000000..e93f9a5
--- /dev/null
+++ b/html/phpgacl/CHANGELOG
@@ -0,0 +1,451 @@
+Sat Dec 03 2005
+ mikeb - Release version 3.3.6
+Wed Oct 26 2005
+ mikeb - Added function get_section_data() thanks to Rodrigo Moraes <rodrigo.moraes@gmail.com>
+Mon Oct 17 2005
+ mikeb - Fixed a bunch of warnings/notices thanks to Charles M Hall <cmhall@hawaii.edu>
+Thu Oct 13 2005
+ mikeb - Fixed a few PHP NOTICEs
+Sun Oct 9 2005
+ mikeb - Fixed PHP5 warning/notice of reference in gacl_api.class to do with end() call.
+Thu Sep 22 2005
+ mikeb - added dirname() to the config_file variable in admin/gacl_admin.inc.php
+Wed Sep 21 2005
+ mikeb - Addslashes to JS creation code in assign_group.php.
+Thu Sep 08 2005
+ mikeb - Added support for MS-SQL in setup.php, thanks to François Tissandier <francois.tissandier@tebu-bio.com>
+Sat Sep 03 2005
+ mikeb - Fixed typo in manual
+ mikeb - Fixed comments in gacl.class.php
+ mikeb - released v3.3.5
+Mon Aug 22 2005
+ mikeb - Fixed bug with edit_acl() for cases where a non-existant acl_id is specified. Thanks to Caleb Simonyi-Gindele <caleb@vetstar.com>
+Thu Aug 04 2005
+ mikeb - Fixed bug with config ini file path in setup.php
+Thu Jul 28 2005
+ mikeb - Fixed bug with double/single quotes on line 3526. Jérémy Cohen Solal <jeremy@eiole.com>
+Sun Jul 24 2005
+ mikeb - Removed table prefix comment regarding not using "_". Apparently it works now
+ mikeb - Fixed comments in gacl.class.php regarding group IDs, it now correctly says group values.
+ mikeb - Hashed_Cache_Lite class now checks to see if Cache_Lite class already exists before including it.
+ mikeb - Added Russian manual translation thanks to <kuzma@russofile.ru>
+ mikeb - Added gacl.conf config file for both admin interface and gacl.class.php. Thanks to Richard Plevin <rich@plevin.com>
+ mikeb - Fixed a couple notices with E_ALL enabled in the API. John Mortlock <johnm@hlaustralia.com.au>
+ mikeb - Added a SQL quoting to insert. Eder <lukas.eder@iomedia.ch>
+ mikeb - Added support for custom ACL sections to add_acl(), for instance if someone deletes the 'system' section. Vincent Woo <vwooa@sfu.ca>
+ mikeb - Upgraded ADODB to v4.65
+ mikeb - Upgraded Smarty to v2.6.9
+ mikeb - Release v3.3.5b1
+Wed Dec 8 2004
+ mikeb - Release v3.3.4
+Sun Dec 5 2004
+ mikeb - Added clear_database() API function that truncates all phpGACL tables. Thanks to Ross Lawley <ross.lawley@mediatelgroup.co.uk>
+ mikeb - Modified millennium falcon example.
+ dcech - Updated get_group_objects function with much more efficient SQL.
+Tue Nov 30 2004
+ mikeb - modified query in get_group_objects() to speed it up. It could still be optimized further though.
+Mon Nov 29 2004
+ mikeb - Applied patch to admin/edit_group.php enabling the deletion of all groups. John Mortlock <johnm@hlaustralia.com.au>
+Sun Nov 28 2004
+ mikeb - Removed default table prefix from gacl.class.php.
+ mikeb - Corrected minor mistake in the manual with regards to incorrect argument ordering in acl_check()
+ mikeb - Modified API comments for search_acl() to include return value.
+ mikeb - Fixed admin link at the bottom of several pages in the Millennium Falcon examples.
+Sat Nov 27 2004
+ mikeb - Added Millennium Falcon example written by Ross Lawley <ross.lawley@mediatelgroup.co.uk>
+ mikeb - Added 3-dimensional ACL Test page from Meinhard <meinhard.jahn@karsten-jahnke.de>
+ mikeb - Upgraded ADODB to v4.54
+ mikeb - Upgraded Smarty to v2.6.6
+Sun Nov 7 2004
+ mikeb - Updated Cache Lite class to latest version, including improved Hashed_Cache_Lite class thanks to Dan.
+ mikeb - If caching is not enabled, improved the bypassing of the caching library/overhead thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+ mikeb - Updated manual thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+ mikeb - add_group API function now assigns the value to the insert ID if the value is not specified. thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+ mikeb - Moved admin interface specific functions/variables from gacl_api.class.php to admin/gacl_admin_api.class.php. thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+Mon Oct 4 2004
+ mikeb - Added phpDoc style comments thanks to Gordon Luk <gordon.luk@dfafunds.com>
+Sat Oct 2 2004
+ mikeb - Added get_ungrouped_objects() function, thanks to Gordon Luk <gordon.luk@dfafunds.com>
+Sun Sep 19 2004
+ mikeb - Added a "isset()" call in Hashed_Cache_Lite
+ mikeb - Applied patch from Gordon Luk <gordon.luk@dfafunds.com> to allow the search_acl() function to proceed without a where clause.
+Thu Sep 09 2004
+ mikeb - gacl.class.php line 532, missing quotes around $root_group. Thanks to Erwan le Gall <erwan.le-gall@education.gouv.fr>
+Sat Aug 28 2004
+ mikeb - Released v3.3.3
+Mon Aug 16 2004
+ mikeb - Quoted group value in acl_get_groups(). Thanks to Christer Lindh <clindh@homenet.se>
+Wed Aug 11 2004
+ mikeb - Add comment to admin/gacl_admin.inc.php to tell people not to use "_" for table prefixes.
+Thu Aug 05 2004
+ mikeb - Fixed acl_test.php ACL Check timings. Thanks to Gordon Luk <gordon.luk@dfafunds.com>
+Tue Jul 27 2004
+ dcech - Fixed missing table prefix in edit_object function.
+ Thanks to Martin Salo <salo@laborint.com>.
+ dcech - Updated to adodb-xmlschema CVS for prefixing.
+Mon Jul 26 2004
+ mikeb - Fixed bug in is_conflicting_acl() where it would detect an incorrect conflict when using certain AXO combinations. Thanks to a patch from Jeff McDonald <jeff@beefstudio.com>
+Sat Jul 17 2004
+ mikeb - Fixed group_admin SQL query to be standard complaint so it works on PostgreSQL.
+ mikeb - Made aro_groups/axo_groups value column unique.
+Sat Jul 10 2004
+ mikeb - Released v3.3.2
+ mikeb - upgraded to ADOdb v4.50
+ mikeb - upgraded to Smarty v2.6.3
+ mikeb - Fixed group_admin.php bug with hardcoded group_type column name.
+Sat Jun 19 2004
+ dcech - cleaned up setup script a little
+ dcech - upgraded to adodb-xmlschema CVS to get fixes for prefix-related problems.
+Fri Jun 18 2004
+ dcech - upgraded to ADOdb v4.23
+Thu Jun 17 2004
+ mikeb - Removed admin/mysql_db_demo_data.sql as it was the old 3.2.x format and useless now.
+ mikeb - Fixed issue with links and group names with spaces in them. Thanks to Gordon Luk <gordon.luk@dfafunds.com>
+ dcech - fixed object count in group admin for groups without objects
+Tue May 24 2004
+ mikeb - Fixed bug in API that stopped you from changing a group name to the same thing as the group value. Hakan Kuecuekyilmaz <hakan@lisas.de>
+Sat May 08 2004
+ mikeb - Released v3.3.1
+Fri May 07 2004
+ dcech - Fixed setup issues with new schema format, and moved to AXMLS prefixing.
+Wed May 05 2004
+ mikeb - Fixed bug in acl_get_groups() where $root_group = '' causes a SQL error. Thanks to Hakan Kuecuekyilmaz <hakan@lisas.de>
+ mikeb - Fixed Unit Tests to work with group_value's. Thanks to the help from Hakan Kuecuekyilmaz <hakan@lisas.de>
+Mon May 03 2004
+ mikeb - Updated comments for add_group() to explain the Root group limitation of our MPTT format.
+Sun May 02 2004
+ mikeb - Added Perl ACL_Check module written by Gordon Luk <gluk@dfafunds.com>
+ mikeb - Upgraded to ADODB v4.22
+ mikeb - Upgraded to Smarty v2.6.2
+ mikeb - Re-enabled JS selected = true when selecting objects to assign to groups.
+ mikeb - Released v3.3.0-final
+
+==> mikeb - Read the CHANGELOG line with "==>" infront of it. Mar 03 2004.
+
+Wed Apr 21 2004
+ mikeb - Fixed index name for value column in AXO group table. Falk <support@fajo.de>
+ mikeb - Updated schema diagrams. Falk <support@fajo.de>
+Tue Apr 06 2004
+ mikeb - applied code documentation patch thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+Mon Apr 05 2004
+ dcech - added index.php to admin directory, fixed bug in format_groups. Thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+ dcech - Fixed object_search javascript bug, cleaned up admin navigation html.
+Sat Apr 03 2004
+ dcech - Fixed JavaScript bug in IE, minor cleanup of admin_functions.js
+Fri Mar 19 2004
+ dcech - Fixed minor typo in gacl_api.class.php. Thanks to Andrew Eddie <eddieajau@iprimus.com.au>
+Wed Mar 03 2004
+ dcech - Updated admin interface and gacl class for value patch.
+ acl_* functions now all accept group values rather than IDs.
+ dcech - Minor fixes in gacl_api for group_value patch.
+
+==> mikeb - *BEWARE* add_group(), edit_group() both require a group_value now! This breaks backwards compatibility.
+
+Sat Feb 28 2004
+ mikeb - Upgraded ADODB to 4.20.
+ mikeb - Applied group value patch from Christer Lindh <clindh@homenet.se>.
+ Admin interface still needs updating. As well as the gacl.class.
+Tue Feb 24 2004
+ dcech - minor fix to display AXO controls when editing ACLs
+Sat Feb 14 2004
+ mikeb - Added DB schema diagram to docs/ directory. Thanks to Falk John <support@fajo.de>
+Fri Feb 13 2004
+ dcech - Changed all JOIN queries to INNER JOIN for MySQL 3.23.x compatibility
+Thu Feb 12 2004
+ dcech - removed final trailing semicolon from schema.xml
+Tue Feb 10 2004
+ mikeb - Fixed get_object() to support ACLs.
+Mon Feb 09 2004
+ mikeb - Fixed del_object_section() to properly delete ACLs if the section is deleted. Thanks to Falk John <support@fajo.de>
+ mikeb - Fixed del_object_section() when using ACL objects.
+ mikeb - Took ";" out of schema.xml, and changed version to b2.
+ mikeb - Added some missing transaction rollbacks to gacl_api. Thanks to Falk John <support@fajo.de>
+Sun Feb 08 2004
+ dcech - Added titles to admin interface
+ mikeb - Removed the last of "is_string()" DB errro checks, replaced with "is_object($rs)"
+ mikeb - Oracle SQL syntax fixes for gacl.class.php and gacl_api.class.php. Thanks to Falk John <support@fajo.de>
+ dcech - SQL syntax fixes for admin system
+Sat Feb 07 2004
+ dcech - New style for admin interface
+Wed Feb 04 2004
+ mikeb - Removed old, out dated examples from gacl_api.class.php
+Sun Feb 01 2004
+ dcech - cleanup of assign_group.php, template updates for assign_group and group_admin
+Sat Jan 31 2004
+ dcech - more interface cleanups
+Fri Jan 30 2004
+ dcech - complete overhaul of acl_admin.php
+ dcech - fix for LIMIT in sql, complete overhaul of object search
+Thu Jan 29 2004
+ dcech - major interface overhaul
+ dcech - acl_list interface improvements, minor css modification
+ mikeb - Upgraded to ADODB 4.11, removed trailing whitespace from adodb-pager.inc.php
+ dcech - major overhaul of acl_list filtering
+Wed Jan 28 2004
+ dcech - major update to acl_list
+ dcech - fix for stress_test to handle existing groups
+ dcech - fixed trailing whitespace in adodb-pager.inc.php
+Sun Jan 25 2004
+ mikeb - Changed acl_list layout.
+ mikeb - Changed setup.php to point to about.php and modified about.php to only display the report section on first run.
+ mikeb - Unleashed v3.3.0b1 upon the world! Wahahahah!
+Sat Jan 24 2004
+ mikeb - Minor updates to CREDITS file, README, and footer.tpl
+ mikeb - Upgraded ADODB to v4.10
+ mikeb - Upgraded Smarty to v2.6.1
+ dcech - del_object: fix for new GetCol behaviour in ADOdb 4.10
+Wed Jan 14 2004
+ mikeb - modified TODO list slightly.
+ mikeb - added Navigation bar submitted by: <eddieajau@iprimus.com.au> on Oct 13/2003.
+ mikeb - Moved the "select all" checkboxes...
+ mikeb - modified include syntax in acl_admin_js.tpl slightly.
+ mikeb - add_object(), edit_object(), edit_object_section(), add_object_section(), fixed issue with hidden being set to a non-int value.
+Thu Jan 08 2004
+ dcech - Added Select/Deselect All to Admin Interface
+Thu Jan 08 2004
+ dcech - applied _group_ patch
+Mon Nov 24 2003
+ mikeb - Fixed PostgreSQL LEFT JOIN issue with is_conflicting_acl(), Can't reference multiple tables, then a LEFT JOIN. ie:
+ select * from table1, table2 LEFT JOIN table3 LEFT JOIN table4.
+ Instead:
+ select * from table1 LEFT JOIN table2 LEFT JOIN table3 LEFT JOIN table4.
+ mikeb - Fixed PosgresSQL LEFT JOIN issue with acl_check()
+ mikeb - Fixed PostgreSQL transaction issue, where generating sequences causes the transaction to abort.
+ Simply move the transaction start _after_ the GenID() call.
+ dcech - cleaned up get_object_section_section_id - fixed bug if invalid object type specified, and bug if no value specified.
+Wed Nov 19 2003
+ mikeb - Added transactions to edit_object_section()
+ mikeb - Added more API test_suite functions.
+ mikeb - Fixed minor display issue with pager.tpl.
+ dcech - numerous fixes in gacl_api. edit_group, add_group_object, rebuild_tree & _rebuild_tree.
+ dcech - new functions in gacl_api. get_root_group_id & get_object_groups.
+Tue Nov 18 2003
+ mikeb - Added more tests to the test suite. Fixed up a couple SQL syntax errors in del_group().
+Fri Nov 14 2003
+ mikeb - Fixed minor bug in get_group_objects() to do with the SQL query, and table prefixes.
+ dcech - improved count_all function and documentation
+ dcech - updated Stress Test & added script to do random ACL checks
+ dcech - fixed bug where debug_db was called after RollBackTrans
+Wed Nov 12 2003
+ mikeb - More MPTT fixes from Dan
+ mikeb - is_conflicting_acl() patch from Dan also.
+Tue Nov 11 2003
+ mikeb - Applied MPTT (different group tree format) patch from Dan Cech <dcech@phpwerx.net>
+ mikeb - Minor cleanup of the above patch.
+ mikeb - FIxed a couple minor bugs with add_group_object() and del_object() relating to the MPTT patch.
+Wed Nov 05 2003
+ - Fixed issue where ARO and AXO groups use the same sequence. Not really a bug, but shouldn't
+ be the case. Thanks to Dan Cech <dcech@phpwerx.net>
+Wed Oct 29 2003
+ - Fixed bug in schema.xml where group_id was missing from a unique index.
+Tue Oct 21 2003
+ - Group select boxes represent the tree structure much better. Purely cosmetic change. Thanks to Dan Cech <dcech@phpwerx.net>
+Wed Oct 08 2003
+ - Released 3.2.2
+ - Fixed bug in acl_list.php where the filter wasn't being passed between pages. Thanks to Dan Cech <dcech@phpwerx.net>
+ - Greatly improved the speed of acl_list.php. Thanks to Dan Cech <dcech@phpwerx.net>
+Sun Oct 05 2003
+ - Fix for major bug in AXOs, if you don't specify AXO values in acl_check(), it could
+ still match ACLs that have AXO groups assigned to them. Discovered by Dan Cech <dcech@phpwerx.net>.
+Sun Oct 03 2003
+ - Released 3.2.1
+Mon Sep 29 2003
+ - Fixed possible bug with re-using database connection objects.
+ - Fixed bug in assign_group.tpl where it was hard coded to reference AROs.
+ - Fixed major bug with table prefixes and del_object() function, as well as sequences. Thanks to Ian Eure <ieure@debian.org> for reporting this.
+ - Fixed minor bug in generating javascript arrays with values containing quotes. Bug found by: Martino Piccinato <m.piccinato@nexus.it>
+Sat Sep 20 2003
+ - Released 3.2.0-final.
+ - Upgraded ADODB to 3.90.
+Sat Sep 06 2003
+ - Fixed minor bug when assigning objects to groups. Thanks Jos Vanlanduyt <jos.vanlanduyt@higis.eu.org> for pointing this out.
+Mon Aug 25 2003
+ - Added SOAP server and clients for PHP, Perl, and Python.
+ - Updated README regarding upgrading and PostgreSQL.
+ - Released phpGACL v3.2.0b2
+Thu Aug 21 2003
+ - Added Help / About page.
+ - Fixed up the ACL Sections, to use values instead of IDs for consistency sake
+ - Upgraded to Smarty 2.5.0
+ - Released phpGACL v3.2.0b
+Mon Aug 18 2003
+ - Merged table prefix patch from Ben Margolin (ben@prince.org), did some minor clean-ups/fixes.
+ - Upgraded to ADODB 3.72
+Wed Aug 13 2003
+ - Decreased column lengths to varchar(240) so MySQL can index multiple columns. Thanks to Ben Margolin (ben@prince.org)
+ - Fixed bug in add_object(), it was selecting from a non-existent table. Thanks to Ben Margolin (ben@prince.org)
+Tue July 08 2003
+ - Create a new setup.php from scratch using ADODB XML-Schema. This should greatly ease table creation on many different databases.
+ - Modified ADODB XML-Schema to support all types of indexes. Submitted patch to Richard Tango-Lowy <richtl@arscognita.com>
+
+Mon July 07 2003
+ - add_object() now returns TRUE if the object is already in the database.
+
+Fri July 04 2003
+ - Updated table schema for the acl table. Added the acl_section table, and the phpgacl table.
+ - Added ACL sections. The purpose of these is like all other sections, to simply classify objects.
+ For example, you may want to differentiate between automatically created ACLs (System ACLs) and
+ manually created ACLs (User ACLs). As some installations may have several thousand automatically created
+ ACLs, its nice to filter these out.
+ - add_group_object() now returns TRUE if the object is already assigned to the group.
+
+Tue July 01 2003
+ - Fixed security bug that could allow someone to see your database password.
+
+Mon June 16 2003
+ - Added acl_query_array() to aid in running an acl_check() over a large amount of AROs, returning section_value, values
+ of those that return true. Especially useful with get_group_objects();
+
+Thu June 12 2003
+ - Added "ACLs" link to the group page, so you easily show all ACLs a specific group is assigned too.
+ - Added "ACLs" link to the group assign page, so you easily show all ACLs a specific ARO/AXO is assigned too.
+ - modified return array format for get_group_objects() and added functionality to return objects in child groups as well.
+
+Wed June 11 2003
+ - Object searching now supports a newline delimited list of names/values.
+
+Sun June 8 2003
+ - Fixed more warnings.
+
+Wed May 28 2003
+ - More minor warning fixes.
+ - Moved the manual to the documentation directory.
+ - Case insensitive object searching when assigning to groups.
+
+Mon May 26 2003
+ - Fixed many more PHP warnings all over.
+ - Added example.php
+ - Upgraded Smarty to v2.5
+ - Upgraded ADODB to v3.5. Added line to set FETCH_MODE on a per connection basis.
+
+Wed May 21 2003
+ - Fixed add_acl() for AXOs, as it was previously completely broken.
+
+Mon May 19 2003
+ - Fixed ACL List filtering so it returns all ACL rows, not just the ones matching the LIKE query.
+
+Fri May 16 2003
+ - Fixed a few PHP warnings gacl.class.php
+ - Removed an else condition from an if statement that didn't do anything anyways.
+
+Sun Mar 09 2003
+ - Fixed small bug in API function get_object_id() where it referenced the $name variable,
+ but $name was never used. If the function was used properly, this shouldn't have affected anything.
+ Thanks to: Harald Fielker <fielker@informatik.fh-augsburg.de> for pointing this out.
+
+Sat Mar 01 2003
+ - Fixed up the layers with AXO show/hide functionality. Usable, but still needs improvement.
+
+Thu Feb 27 2003
+ - Attempted to add javascript show/hide to the AXO section of the acl_admin.
+
+Tue Feb 25 2003
+ - Fixed invalid DB reference in acl_get_groups(); Thanks to Gianluca Faieta <gfaieta@iname.com> for the patch.
+
+Thu Feb 20 2003
+ - Fixed bug in get_group_objects() that caused it to return the query record set, not the data itself. Thanks to Thomas <tstruebi@pentacon.ch> for submitting a patch.
+ - Fixed bug in del_group(), as it neglected to remove the object mapping. Thanks to Thomas <tstruebi@pentacon.ch> for pointing this out.
+
+Tue Feb 18 2003
+ - Added 'force_cache_expire' option, so the cache is automaticalled expired when ACL/Group modifications take place.
+ This should allow the cache_expire_time to be greatly increased (86400?) and still maintain instance updates.
+ - Removed un-needed table joins in search_acl() resulting in a large performance increase.
+
+Mon Feb 17 2003
+ - Added "limit" to ARO select query in group_assign.php
+
+Fri Feb 14 2003
+ - Tweeked consolidate_edit_acl() to better consolidate ACLs in the expected manor.
+ - Fixed cache ID in acl_get_group_path() so it doesn't contain non-alphanumeric characters.
+
+Wed Feb 12 2003
+ - Fixed bug caused by overzealous array_unique in add_acl()
+ - Switched acl_query() to return TRUE/FALSE for the 'allow' return value instead of 1/0
+ - API group functions didn't manipulate the path_to_root mapping when reparenting or deleting occured.
+
+Tue Feb 04 2003
+ - Fixed bug in edit_group(), added more error checking.
+ - Added object searching to the assign group pages.
+ - Moved all templates to $smarty_template_dir/phpgacl/ to better integrate with existing smarty installations.
+ - Fixed recursion in format_groups() so it doesn't use globals anymore.
+ - Greatly improved performance in sort_groups() (50% improvement) and format_groups() (20%) functions.
+
+Thu Jan 31 2003
+ - Added conflict detection to add_acl();
+
+Thu Jan 30 2003
+ - Created search_acl() to search for ACLs mapped to specific objects. This should also work for detecting conflicting ACLs.
+ - Created shift_acl() that basically does the opposite of append_acl(). Remove just the specific objects from the ACL mapping.
+
+Wed Jan 29 2003
+ - Created append_acl() function for simply appending ACO/ARO/ARO Groups/AXO/AXO Groups on to an already existing ACL.
+
+Mon Jan 28 2003
+ - Added ACL searching.
+ - Added ACL debug page.
+ - Added sanity checks to add_acl()/edit_acl() to make sure the objects mapped to ACLs actually exist.
+ - Transactionalized most API functions.
+
+Fri Jan 24 2003
+ - Fixed JS UnSelect button bug for AXO groups.
+ - Added Object searching to help the admin interface handle an unlimited number of objects.
+ - Added "max_select_box_items" config option to set the maximum number of items shown in select boxes.
+
+Tue Jan 14 2003
+ - Upgraded ADODB to v3.00
+ - Added user definable ACL return values, along with the acl_return_value() function.
+ - Added ACL notes which serve no other purpose other than to help the administrator keep track of ACL's
+ - Added paging for large record sets.
+
+Sun Dec 15 2002
+ - Moved to a completely OO structure.
+ - Config options can now be passed during object creation. $gacl = new gacl($options);
+
+Sun Dec 01 2002
+ - Fixed bug that broke allow and enabled from being changed when editing ACLs.
+
+Sat Nov 30 2002
+ - Merged ERASE feature in to API functions, del_object() and del_object_section() thanks to Martino.
+ - Changed the acl list page layout
+ - Changed the acl test page layout
+ - Added assigned object count to the group admin page.
+ - Fixed a JS bug that wouldn't allow you to "select" (>>) any objects at all, if one was already selected.
+
+Sun Nov 17 2002
+ - format_groups() function wasn't recursing as efficiently as it could be. Fixed.
+ - Re-wrote API aro/aco/group specific functions to be generic to help support AXO's.
+ - Re-wrote aro/aco/group specific admin scripts to be generic to help support AXO's.
+ - Added AXO support to acl_admin.php.
+ - Updated gacl.inc.php to support AXO's.
+
+Mon Nov 11 2002
+ - Changed the ordering of the main acl_query() SQL query. It wasn't properly preferring the deepest groups ACLs. - Thanks to Mauro
+ for spotting this one and helping me track it down.
+ - Fixed bug that prevented ACO/ARO's with the same 'value' in different sections from being assigned to an ACL. - Thanks to Martino
+ - Fixed bug that made it seem like assigning a single ARO to a group really added all AROs with the same value to that group. - Thanks to Martino
+ - Fixed bug causing virtual subtree'ing to only traverse 2 levels of the tree. - Thanks to Martino
+ - Used dirname(__FILE__) to remove the need for users to manually set the root path in config.inc.php.
+
+Wed Oct 23 2002
+ - Switched away from ID's in favor of VALUES for most functions, including acl_check(). Broke all backwards compatibility.
+ - Modified DB Schema to reflect above.
+ - When ARO/ACO values are changed, the API will modify said values in all tables.
+ - Added a variable for phpGACL's current path.
+
+Wed Oct 09 2002
+ - Added "hidden" flags to relavent API functions
+ - Added Oracle 8i schema to setup.php
+ - Changed group "level" table column name to "tree_level", as the old name "level" was a reserved word in some db's.
+ MySQL: ALTER TABLE `groups_path` CHANGE `level` `tree_level` INT(12) DEFAULT '0' NOT NULL
+ - Modified a few of the queries to be more portable, specifically for Oracle's sake.
+ - Added a FAQ entry regarding individualized item permissions.
+
+Wed Sep 25 2002
+ - Added multi-layer ACO checking to ACL_QUERY()
+ - Removed multi-layer ACO checking in favor of "dual" acl checking. ie:
+ If you want to set ACL's on a contact list. Create ACO's for each Contact in the list.
+ and create more generic ACO's for things like "View - Contacts", "Edit - Contacts".
+ Then simply create an ACL with ACO's "View - Contacts" AND "Contact ID: 15"
+ Then if ( acl_check("View - Contacts", "John Doe") AND acl_check("Contact ID: 15", "John Doe"))
+ Very simple, and should be just as fast, or faster then adding more bloat to the database.
+ - Added "hidden" flag to ACO, ACO Sections, ARO, and ARO sections.
diff --git a/html/phpgacl/COPYING.lib b/html/phpgacl/COPYING.lib
new file mode 100644
index 0000000..3b20440
--- /dev/null
+++ b/html/phpgacl/COPYING.lib
@@ -0,0 +1,458 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
diff --git a/html/phpgacl/CREDITS b/html/phpgacl/CREDITS
new file mode 100644
index 0000000..6ca885c
--- /dev/null
+++ b/html/phpgacl/CREDITS
@@ -0,0 +1,39 @@
+Mike Benoit <ipso@snappymail.ca>
+ Wrote initial "proof of concept" implementation, and maintains documentation & code base.
+
+Dan Cech <dcech@phpwerx.net>
+ Implemented the MPTT code, '_group_' feature, and ACL checks in the test suite.
+
+Gordon Luk <gluk@dfafunds.com>
+ Native ACL_Check module for Perl, and wrote comments for phpDocumentor.
+
+Ben Margolin <ben@prince.org>
+ Caught and fixed several bugs.
+
+R. Kunoth <R.Kunoth@web.de>
+ Caught and fixed several bugs.
+
+Karsten Dambekalns <k.dambekalns@fishfarm.de>
+ Sent in several patches to fix PHP warnings, and helped with the documentation.
+
+Martino Piccinato <martino@nexus.it>
+ Modified several API functions to help keep data in sync across tables.
+
+Paul Munn <pmunn@munn.com>
+ Sent in Postgres7 table schema, plus some very good suggestions. As well helped with the documentation.
+
+Fred Cohen <quadra@demosoft.org>
+ Sent in Oracle 8i table schema.
+
+Eric Batchelor
+ Always there to bounce ideas off of, he has consistently helped me out in many areas, including testing.
+
+Monte Ohrt <monte@ispi.net>
+Andrei Zmievski <andrei@php.net>
+ Together they made the best template engine available for PHP. Awesome job.
+
+John Lim <jlim@natsoft.com.my>
+ Author of ADODB, also the best database abstraction layer for PHP.
+
+Rasmus Lerdorf <rasmus@php.net>
+ For starting what eventually became the coolest programming language ever.
diff --git a/html/phpgacl/Cache_Lite/Hashed_Cache_Lite.php b/html/phpgacl/Cache_Lite/Hashed_Cache_Lite.php
new file mode 100644
index 0000000..894952f
--- /dev/null
+++ b/html/phpgacl/Cache_Lite/Hashed_Cache_Lite.php
@@ -0,0 +1,184 @@
+<?php
+/*
+ * phpGACL - Generic Access Control List - Hashed Directory Caching.
+ * Copyright (C) 2002 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ */
+
+if ( !class_exists('Cache_Lite') ) {
+ require_once(dirname(__FILE__) .'/Lite.php');
+}
+
+define('DIR_SEP',DIRECTORY_SEPARATOR);
+
+class Hashed_Cache_Lite extends Cache_Lite
+{
+ /**
+ * Make a file name (with path)
+ *
+ * @param string $id cache id
+ * @param string $group name of the group
+ * @access private
+ */
+ function _setFileName($id, $group)
+ {
+ // CRC32 with SUBSTR is still faster then MD5.
+ $encoded_id = substr(crc32($id),1);
+ // $encoded_id = md5($id);
+
+ // Generate just the directory, so it can be created.
+ // Groups will have their own top level directory, for quick/easy purging of an entire group.
+ $dir = $this->_cacheDir.$group.'/'.substr($encoded_id,0,3);
+ $this->_create_dir_structure($dir);
+
+ $this->_file = $dir.'/'.$encoded_id;
+ }
+
+ /**
+ * Create full directory structure, Ripped straight from the Smarty Template engine.
+ * Version: 2.3.0
+ * Copyright: 2001,2002 ispi of Lincoln, Inc.
+ *
+ * @param string $dir Full directory.
+ * @access private
+ */
+ function _create_dir_structure($dir)
+ {
+ if (!@file_exists($dir)) {
+ $dir_parts = preg_split('![\/]+!', $dir, -1, PREG_SPLIT_NO_EMPTY);
+ $new_dir = ($dir{0} == DIR_SEP) ? DIR_SEP : '';
+ foreach ($dir_parts as $dir_part) {
+ $new_dir .= $dir_part;
+ if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) {
+ Cache_Lite::raiseError('Cache_Lite : problem creating directory \"$dir\" !', -3);
+ return false;
+ }
+ $new_dir .= DIR_SEP;
+ }
+ }
+ }
+
+ function _remove_dir_structure($dir,$remove_dir = false)
+ {
+ if (in_array(substr($dir,-1),array(DIR_SEP,'/','\\'))) {
+ $dir = substr($dir,0,-1);
+ }
+
+ if (!($dh = opendir($dir))) {
+ $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
+ return false;
+ }
+
+ while ($file = readdir($dh)) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+ $file = $dir . DIR_SEP . $file;
+ if (is_dir($file)) {
+ $this->_remove_dir_structure($file,true);
+ continue;
+ }
+ if (is_file($file)) {
+ if (!@unlink($file)) {
+ closedir($dh);
+ $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
+ return false;
+ }
+ continue;
+ }
+ }
+
+ closedir($dh);
+
+ if ($remove_dir) {
+ clearstatcache();
+ if (!@rmdir($dir)) {
+ $this->raiseError('Cache_Lite : Unable to remove cache directory !', -4);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Clean the cache
+ *
+ * if no group is specified all cache files will be destroyed
+ * else only cache files of the specified group will be destroyed
+ *
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function clean($group = false)
+ {
+ if ($group) {
+ $motif = $this->_cacheDir.$group.'/';
+
+ if ($this->_memoryCaching) {
+ foreach ($this->_memoryCachingArray as $key => $value) {
+ if (strpos($key, $motif, 0)) {
+ unset($this->_memoryCachingArray[$key]);
+ }
+ }
+ $this->_memoryCachingCounter = count($this->_memoryCachingArray);
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+
+ return $this->_remove_dir_structure($motif);
+ }
+
+ if ($this->_memoryCaching) {
+ $this->_memoryCachingArray = array();
+ $this->_memoryCachingCounter = 0;
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+
+ if (!($dh = opendir($this->_cacheDir))) {
+ $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
+ return false;
+ }
+
+ while ($file = readdir($dh)) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+ $file = $this->_cacheDir . $file;
+ if (is_dir($file) && !$this->_remove_dir_structure($file,true)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
+
+// end of script
diff --git a/html/phpgacl/Cache_Lite/LICENSE b/html/phpgacl/Cache_Lite/LICENSE
new file mode 100644
index 0000000..27950e8
--- /dev/null
+++ b/html/phpgacl/Cache_Lite/LICENSE
@@ -0,0 +1,458 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
diff --git a/html/phpgacl/Cache_Lite/Lite.php b/html/phpgacl/Cache_Lite/Lite.php
new file mode 100644
index 0000000..3341fb1
--- /dev/null
+++ b/html/phpgacl/Cache_Lite/Lite.php
@@ -0,0 +1,615 @@
+<?php
+
+/**
+* Fast, light and safe Cache Class
+*
+* Cache_Lite is a fast, light and safe cache system. It's optimized
+* for file containers. It is fast and safe (because it uses file
+* locking and/or anti-corruption tests).
+*
+* There are some examples in the 'docs/examples' file
+* Technical choices are described in the 'docs/technical' file
+*
+* A tutorial is available in english at this url :
+* http://www.pearfr.org/index.php/en/article/cache_lite
+* (big thanks to Pierre-Alain Joye for the translation)
+*
+* The same tutorial is also available in french at this url :
+* http://www.pearfr.org/index.php/fr/article/cache_lite
+*
+* Memory Caching is from an original idea of
+* Mike BENOIT <ipso@snappymail.ca>
+*
+* @package Cache_Lite
+* @category Caching
+* @version $Id: Lite.php,v 1.1 2004/11/08 00:47:05 ipso Exp $
+* @author Fabien MARTY <fab@php.net>
+*/
+
+define('CACHE_LITE_ERROR_RETURN', 1);
+define('CACHE_LITE_ERROR_DIE', 8);
+
+class Cache_Lite
+{
+
+ // --- Private properties ---
+
+ /**
+ * Directory where to put the cache files
+ * (make sure to add a trailing slash)
+ *
+ * @var string $_cacheDir
+ */
+ var $_cacheDir = '/tmp/';
+
+ /**
+ * Enable / disable caching
+ *
+ * (can be very usefull for the debug of cached scripts)
+ *
+ * @var boolean $_caching
+ */
+ var $_caching = true;
+
+ /**
+ * Cache lifetime (in seconds)
+ *
+ * @var int $_lifeTime
+ */
+ var $_lifeTime = 3600;
+
+ /**
+ * Enable / disable fileLocking
+ *
+ * (can avoid cache corruption under bad circumstances)
+ *
+ * @var boolean $_fileLocking
+ */
+ var $_fileLocking = true;
+
+ /**
+ * Timestamp of the last valid cache
+ *
+ * @var int $_refreshTime
+ */
+ var $_refreshTime;
+
+ /**
+ * File name (with path)
+ *
+ * @var string $_file
+ */
+ var $_file;
+
+ /**
+ * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
+ *
+ * Enable write control will lightly slow the cache writing but not the cache reading
+ * Write control can detect some corrupt cache files but maybe it's not a perfect control
+ *
+ * @var boolean $_writeControl
+ */
+ var $_writeControl = true;
+
+ /**
+ * Enable / disable read control
+ *
+ * If enabled, a control key is embeded in cache file and this key is compared with the one
+ * calculated after the reading.
+ *
+ * @var boolean $_writeControl
+ */
+ var $_readControl = true;
+
+ /**
+ * Type of read control (only if read control is enabled)
+ *
+ * Available values are :
+ * 'md5' for a md5 hash control (best but slowest)
+ * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
+ * 'strlen' for a length only test (fastest)
+ *
+ * @var boolean $_readControlType
+ */
+ var $_readControlType = 'crc32';
+
+ /**
+ * Pear error mode (when raiseError is called)
+ *
+ * (see PEAR doc)
+ *
+ * @see setToDebug()
+ * @var int $_pearErrorMode
+ */
+ var $_pearErrorMode = CACHE_LITE_ERROR_RETURN;
+
+ /**
+ * Current cache id
+ *
+ * @var string $_id
+ */
+ var $_id;
+
+ /**
+ * Current cache group
+ *
+ * @var string $_group
+ */
+ var $_group;
+
+ /**
+ * Enable / Disable "Memory Caching"
+ *
+ * NB : There is no lifetime for memory caching !
+ *
+ * @var boolean $_memoryCaching
+ */
+ var $_memoryCaching = false;
+
+ /**
+ * Enable / Disable "Only Memory Caching"
+ * (be carefull, memory caching is "beta quality")
+ *
+ * @var boolean $_onlyMemoryCaching
+ */
+ var $_onlyMemoryCaching = false;
+
+ /**
+ * Memory caching array
+ *
+ * @var array $_memoryCachingArray
+ */
+ var $_memoryCachingArray = array();
+
+ /**
+ * Memory caching counter
+ *
+ * @var int $memoryCachingCounter
+ */
+ var $_memoryCachingCounter = 0;
+
+ /**
+ * Memory caching limit
+ *
+ * @var int $memoryCachingLimit
+ */
+ var $_memoryCachingLimit = 1000;
+
+ /**
+ * File Name protection
+ *
+ * if set to true, you can use any cache id or group name
+ * if set to false, it can be faster but cache ids and group names
+ * will be used directly in cache file names so be carefull with
+ * special characters...
+ *
+ * @var boolean $fileNameProtection
+ */
+ var $_fileNameProtection = true;
+
+ /**
+ * Enable / disable automatic serialization
+ *
+ * it can be used to save directly datas which aren't strings
+ * (but it's slower)
+ *
+ * @var boolean $_serialize
+ */
+ var $_automaticSerialization = false;
+
+ // --- Public methods ---
+
+ /**
+ * Constructor
+ *
+ * $options is an assoc. Available options are :
+ * $options = array(
+ * 'cacheDir' => directory where to put the cache files (string),
+ * 'caching' => enable / disable caching (boolean),
+ * 'lifeTime' => cache lifetime in seconds (int),
+ * 'fileLocking' => enable / disable fileLocking (boolean),
+ * 'writeControl' => enable / disable write control (boolean),
+ * 'readControl' => enable / disable read control (boolean),
+ * 'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
+ * 'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
+ * 'memoryCaching' => enable / disable memory caching (boolean),
+ * 'onlyMemoryCaching' => enable / disable only memory caching (boolean),
+ * 'memoryCachingLimit' => max nbr of records to store into memory caching (int),
+ * 'fileNameProtection' => enable / disable automatic file name protection (boolean),
+ * 'automaticSerialization' => enable / disable automatic serialization (boolean)
+ * );
+ *
+ * @param array $options options
+ * @access public
+ */
+ function Cache_Lite($options = array(NULL))
+ {
+ $availableOptions = array('automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
+ foreach($options as $key => $value) {
+ if(in_array($key, $availableOptions)) {
+ $property = '_'.$key;
+ $this->$property = $value;
+ }
+ }
+ $this->_refreshTime = time() - $this->_lifeTime;
+ }
+
+ /**
+ * Test if a cache is available and (if yes) return it
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
+ * @return string data of the cache (or false if no cache available)
+ * @access public
+ */
+ function get($id, $group = 'default', $doNotTestCacheValidity = false)
+ {
+ $this->_id = $id;
+ $this->_group = $group;
+ $data = false;
+ if ($this->_caching) {
+ $this->_setFileName($id, $group);
+ if ($this->_memoryCaching) {
+ if (isset($this->_memoryCachingArray[$this->_file])) {
+ if ($this->_automaticSerialization) {
+ return unserialize($this->_memoryCachingArray[$this->_file]);
+ } else {
+ return $this->_memoryCachingArray[$this->_file];
+ }
+ } else {
+ if ($this->_onlyMemoryCaching) {
+ return false;
+ }
+ }
+ }
+ if ($doNotTestCacheValidity) {
+ if (file_exists($this->_file)) {
+ $data = $this->_read();
+ }
+ } else {
+ if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) {
+ $data = $this->_read();
+ }
+ }
+ if (($data) and ($this->_memoryCaching)) {
+ $this->_memoryCacheAdd($this->_file, $data);
+ }
+ if (($this->_automaticSerialization) and (is_string($data))) {
+ $data = unserialize($data);
+ }
+ return $data;
+ }
+ return false;
+ }
+
+ /**
+ * Save some data in a cache file
+ *
+ * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function save($data, $id = NULL, $group = 'default')
+ {
+ if ($this->_caching) {
+ if ($this->_automaticSerialization) {
+ $data = serialize($data);
+ }
+ if (isset($id)) {
+ $this->_setFileName($id, $group);
+ }
+ if ($this->_memoryCaching) {
+ $this->_memoryCacheAdd($this->_file, $data);
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ if ($this->_writeControl) {
+ if (!$this->_writeAndControl($data)) {
+ @touch($this->_file, time() - 2*abs($this->_lifeTime));
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ return $this->_write($data);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Remove a cache file
+ *
+ * @param string $id cache id
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function remove($id, $group = 'default')
+ {
+ $this->_setFileName($id, $group);
+ if ($this->_memoryCaching) {
+ if (isset($this->_memoryCachingArray[$this->_file])) {
+ unset($this->_memoryCachingArray[$this->_file]);
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
+ }
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ if (!@unlink($this->_file)) {
+ $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Clean the cache
+ *
+ * if no group is specified all cache files will be destroyed
+ * else only cache files of the specified group will be destroyed
+ *
+ * @param string $group name of the cache group
+ * @return boolean true if no problem
+ * @access public
+ */
+ function clean($group = false)
+ {
+ if ($this->_fileNameProtection) {
+ $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
+ } else {
+ $motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
+ }
+ if ($this->_memoryCaching) {
+ while (list($key, $value) = each($this->_memoryCachingArray)) {
+ if (strpos($key, $motif, 0)) {
+ unset($this->_memoryCachingArray[$key]);
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
+ }
+ }
+ if ($this->_onlyMemoryCaching) {
+ return true;
+ }
+ }
+ if (!($dh = opendir($this->_cacheDir))) {
+ $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
+ return false;
+ }
+ while ($file = readdir($dh)) {
+ if (($file != '.') && ($file != '..')) {
+ $file = $this->_cacheDir . $file;
+ if (is_file($file)) {
+ if (strpos($file, $motif, 0)) {
+ if (!@unlink($file)) {
+ $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Set to debug mode
+ *
+ * When an error is found, the script will stop and the message will be displayed
+ * (in debug mode only).
+ *
+ * @access public
+ */
+ function setToDebug()
+ {
+ $this->_pearErrorMode = CACHE_LITE_ERROR_DIE;
+ }
+
+ /**
+ * Set a new life time
+ *
+ * @param int $newLifeTime new life time (in seconds)
+ * @access public
+ */
+ function setLifeTime($newLifeTime)
+ {
+ $this->_lifeTime = $newLifeTime;
+ $this->_refreshTime = time() - $newLifeTime;
+ }
+
+ /**
+ *
+ * @access public
+ */
+ function saveMemoryCachingState($id, $group = 'default')
+ {
+ if ($this->_caching) {
+ $array = array(
+ 'counter' => $this->_memoryCachingCounter,
+ 'array' => $this->_memoryCachingState
+ );
+ $data = serialize($array);
+ $this->save($data, $id, $group);
+ }
+ }
+
+ /**
+ *
+ * @access public
+ */
+ function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
+ {
+ if ($this->_caching) {
+ if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
+ $array = unserialize($data);
+ $this->_memoryCachingCounter = $array['counter'];
+ $this->_memoryCachingArray = $array['array'];
+ }
+ }
+ }
+
+ /**
+ * Return the cache last modification time
+ *
+ * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
+ *
+ * @return int last modification time
+ */
+ function lastModified() {
+ return filemtime($this->_file);
+ }
+
+ /**
+ * Trigger a PEAR error
+ *
+ * To improve performances, the PEAR.php file is included dynamically.
+ * The file is so included only when an error is triggered. So, in most
+ * cases, the file isn't included and perfs are much better.
+ *
+ * @param string $msg error message
+ * @param int $code error code
+ * @access public
+ */
+ function raiseError($msg, $code)
+ {
+ include_once('PEAR.php');
+ PEAR::raiseError($msg, $code, $this->_pearErrorMode);
+ }
+
+ // --- Private methods ---
+
+ /**
+ *
+ * @access private
+ */
+ function _memoryCacheAdd($id, $data)
+ {
+ $this->_memoryCachingArray[$this->_file] = $data;
+ if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
+ list($key, $value) = each($this->_memoryCachingArray);
+ unset($this->_memoryCachingArray[$key]);
+ } else {
+ $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
+ }
+ }
+
+ /**
+ * Make a file name (with path)
+ *
+ * @param string $id cache id
+ * @param string $group name of the group
+ * @access private
+ */
+ function _setFileName($id, $group)
+ {
+ if ($this->_fileNameProtection) {
+ $this->_file = ($this->_cacheDir.'cache_'.md5($group).'_'.md5($id));
+ } else {
+ $this->_file = $this->_cacheDir.'cache_'.$group.'_'.$id;
+ }
+ }
+
+ /**
+ * Read the cache file and return the content
+ *
+ * @return string content of the cache file
+ * @access private
+ */
+ function _read()
+ {
+ $fp = @fopen($this->_file, "rb");
+ if ($this->_fileLocking) @flock($fp, LOCK_SH);
+ if ($fp) {
+ clearstatcache(); // because the filesize can be cached by PHP itself...
+ $length = @filesize($this->_file);
+ $mqr = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+ if ($this->_readControl) {
+ $hashControl = @fread($fp, 32);
+ $length = $length - 32;
+ }
+ $data = @fread($fp, $length);
+ set_magic_quotes_runtime($mqr);
+ if ($this->_fileLocking) @flock($fp, LOCK_UN);
+ @fclose($fp);
+ if ($this->_readControl) {
+ $hashData = $this->_hash($data, $this->_readControlType);
+ if ($hashData != $hashControl) {
+ @touch($this->_file, time() - 2*abs($this->_lifeTime));
+ return false;
+ }
+ }
+ return $data;
+ }
+ $this->raiseError('Cache_Lite : Unable to read cache !', -2);
+ return false;
+ }
+
+ /**
+ * Write the given data in the cache file
+ *
+ * @param string $data data to put in cache
+ * @return boolean true if ok
+ * @access private
+ */
+ function _write($data)
+ {
+ $fp = @fopen($this->_file, "wb");
+ if ($fp) {
+ if ($this->_fileLocking) @flock($fp, LOCK_EX);
+ if ($this->_readControl) {
+ @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
+ }
+ $len = strlen($data);
+ @fwrite($fp, $data, $len);
+ if ($this->_fileLocking) @flock($fp, LOCK_UN);
+ @fclose($fp);
+ return true;
+ }
+ $this->raiseError('Cache_Lite : Unable to write cache !', -1);
+ return false;
+ }
+
+ /**
+ * Write the given data in the cache file and control it just after to avoir corrupted cache entries
+ *
+ * @param string $data data to put in cache
+ * @return boolean true if the test is ok
+ * @access private
+ */
+ function _writeAndControl($data)
+ {
+ $this->_write($data);
+ $dataRead = $this->_read($data);
+ return ($dataRead==$data);
+ }
+
+ /**
+ * Make a control key with the string containing datas
+ *
+ * @param string $data data
+ * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
+ * @return string control key
+ * @access private
+ */
+ function _hash($data, $controlType)
+ {
+ switch ($controlType) {
+ case 'md5':
+ return md5($data);
+ case 'crc32':
+ return sprintf('% 32d', crc32($data));
+ case 'strlen':
+ return sprintf('% 32d', strlen($data));
+ default:
+ $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
+ }
+ }
+
+}
+
+?>
diff --git a/html/phpgacl/FAQ b/html/phpgacl/FAQ
new file mode 100644
index 0000000..7a89be8
--- /dev/null
+++ b/html/phpgacl/FAQ
@@ -0,0 +1 @@
+Please see docs/MANUAL or http://phpgacl.sourceforge.net/
diff --git a/html/phpgacl/README b/html/phpgacl/README
new file mode 100644
index 0000000..34371dc
--- /dev/null
+++ b/html/phpgacl/README
@@ -0,0 +1,60 @@
+NAME:
+
+ phpGACL - PHP Generic Access Control List.
+
+AUTHORS:
+
+ Mike Benoit <ipso@snappymail.ca>
+
+MAILING LISTS:
+
+ See here: http://sourceforge.net/mail/?group_id=57103
+
+INSTALL:
+
+ Please refer to the docs/MANUAL or the "Manual" / API Guide link at http://phpgacl.sourceforge.net/
+
+ Consult the example.php file in this directory.
+
+UPGRADING:
+
+ MAKE A BACKUP FIRST!
+ MAKE A BACKUP FIRST!
+ MAKE A BACKUP FIRST!
+ Then run setup.php. It will most likely NOT work, as ADODB's XML Schema still needs some work.
+
+ Upgrading from ANY version to v3.3.x WILL NOT WORK YET! The schema format has changed way
+ to much.
+
+ Unless your running PostgreSQL, then upgrading from 3.1.x or older to 3.2.x or newer will require
+ a complete dump (including column names), dropping the database, running setup.php, then
+ importing the dump.
+
+SYNOPSIS:
+
+ require_once("gacl.class.php");
+
+ $gacl_options = array(
+ 'db_type' => 'mysql',
+ 'db_host' => 'localhost',
+ 'db_user' => 'root',
+ 'db_password' => '',
+ 'db_name' => 'gacl',
+ );
+
+ $gacl = new gacl($gacl_options);
+
+ if ( $gacl->acl_check( <ACO Section VALUE>, <Access Control Object VALUE> , <ARO Section VALUE>, <Access Request Object VALUE> ) ) {
+ echo "Access Granted!";
+ } else {
+ echo "Access Denied!";
+ }
+
+DESCRIPTION:
+
+ See here: http://phpgacl.sourceforge.net/
+
+COPYRIGHT:
+ Copyright (c) 2004 Mike Benoit, All rights reserved.
+ This software is released under the GNU Lesser General Public License.
+ Please read the disclaimer at the top of the gacl.inc.php file.
diff --git a/html/phpgacl/TODO b/html/phpgacl/TODO
new file mode 100644
index 0000000..91e039c
--- /dev/null
+++ b/html/phpgacl/TODO
@@ -0,0 +1,56 @@
+* Create a function that a SQL command with variables inserted can be passed to,
+phpGACL will then replace the variables with ACL specific SQL and return the entire query
+to be executed. IE:
+
+$sql = "select * from table #phggacl_join# where #phpgacl_allow# limit 100 offset 10";
+$retval = get_acl_sql( <ACO Section>, <ACO Value>, (ARO|AXO), <(ARX|AXO) Section>, $sql );
+
+phpGACL would insert the proper SQL to join ACL tables at #phpgacl_join# and proper SQL
+to limit the query to allowed entries only at #phpgacl_allow#. I think this is the best
+solution to the huge amount of rows for acl_check() problem.
+
+
+* Have the Admin interface "show code" as it does operations.
+
+* Create code that takes an ACL_ID as input arguments and returns example acl_check() code that will
+hit the given ACL, regardless if it is ALLOW or DENY. This should really help people get started
+with phpGACL.
+
+* Create enviroment tests in test suite to check if the database has data in it or not.
+* Create regression tests. - Need more of these.
+
+* Write function to find which groups an object is in.
+* Add ability to find all groups objects are assigned too in admin interface.
+
+* Value is a reserved word on SapDB/MaxDB. Quote it.
+
+* Make sure all input values in gacl.class.php are quoted.
+
+* Create upgrade.php script, to handle as much of the upgrade process as possible. Have it display the changelog as well?
+ Have setup.php handle this?
+
+* Array ACL Checks for select boxes. - Half done currently.
+
+* Add visual notification when a section has hit the $max_select_box_items.
+
+* Add filters/AXO's to ACL Test page.
+
+* Oracle compatibility. XML Schema should fix the majority of the Oracle issues.
+
+* FUTURE: Build framework for the plugin system.
+ Create a "plugin" directory.
+ Create a "plugin" section on the acl_admin page where plugin form fields can be displayed?
+ Plugins must be enabled in the config file, for both the admin interface and the calling interface?
+
+* FUTURE: Possibly support tree'd ACOs.
+
+* FUTURE: Allow phpGACL to set permissions on its own administration interface.
+Having said that, I think going 99.9% of the way would be inside said scope and
+would be something to seriously consider. We could add all the ACO's, ARO's, Groups, and
+mark them "system" so they can't be deleted, as well as all the acl_check()'s.
+Then in an include file or something we could place a hook to plugin with any
+existing login/authentication mechanism and disable all this by default. Once the
+user enables it and plugs in a simple ARO value, it would all come to life and allow
+them the ability to use phpGACL to set permissions on itself.
+
+* Write "mock" implementations to show off some of phpGACL's benefits.
diff --git a/html/phpgacl/admin/about.php b/html/phpgacl/admin/about.php
new file mode 100644
index 0000000..1d2d8f9
--- /dev/null
+++ b/html/phpgacl/admin/about.php
@@ -0,0 +1,95 @@
+<?php
+require_once("gacl_admin.inc.php");
+
+function get_system_info() {
+ global $gacl_api;
+
+ //Grab system info
+ $system_info .= 'PHP Version: '.phpversion()."\n";
+ $system_info .= 'Zend Version: '.zend_version()."\n";
+ $system_info .= 'Web Server: '.$_SERVER['SERVER_SOFTWARE']."\n\n";
+ $system_info .= 'phpGACL Settings: '."\n";
+ $system_info .= ' phpGACL Version: '.$gacl_api->get_version()."\n";
+ $system_info .= ' phpGACL Schema Version: '.$gacl_api->get_schema_version()."\n";
+
+ if($gacl_api->_caching == TRUE) {
+ $caching = 'True';
+ } else {
+ $caching = 'False';
+ }
+ $system_info .= ' Caching Enabled: '. $caching ."\n";
+
+ if($gacl_api->_force_cache_expire == TRUE) {
+ $force_cache_expire = 'True';
+ } else {
+ $force_cache_expire = 'False';
+ }
+ $system_info .= ' Force Cache Expire: '.$force_cache_expire."\n";
+
+ $system_info .= ' Database Prefix: \''.$gacl_api->_db_table_prefix."'\n";
+ $system_info .= ' Database Type: '.$gacl_api->_db_type."\n";
+
+ $database_server_info = $gacl_api->db->ServerInfo();
+ $system_info .= ' Database Version: '.$database_server_info['version']."\n";
+ $system_info .= ' Database Description: '.$database_server_info['description']."\n\n";
+
+ $system_info .= 'Server Name: '. $_SERVER["SERVER_NAME"] ."\n";
+ $system_info .= ' OS: '. PHP_OS ."\n";
+ $system_info .= ' IP Address: '. $_SERVER["REMOTE_ADDR"] ."\n";
+ $system_info .= ' Browser: '. $_SERVER["HTTP_USER_AGENT"] ."\n\n";
+
+ $system_info .= 'System Information: '. php_uname() ."\n";
+
+ return trim($system_info);
+}
+
+function submit_system_info($system_information, $system_info_md5) {
+
+ $md5sum = md5(trim($system_information));
+ if (trim($system_info_md5) == $md5sum) {
+ $tainted = 'FALSE';
+ } else {
+ $tainted = 'TRUE';
+ }
+
+ mail('phpgacl@snappymail.ca', 'phpGACL Report... ', "". $system_information ."\n\nTainted: $tainted");
+
+ return $tainted;
+}
+
+switch ($_POST['action']) {
+ case 'Submit':
+ $gacl_api->debug_text("Submit!!");
+
+ submit_system_info($_POST['system_information'], $_POST['system_info_md5']);
+
+ echo "<div align=center>Thanks for contributing to phpGACL. <br> Click <a href=\"acl_list.php\">here</a> to proceed to the Administration Interface.</div><br>\n";
+ exit;
+ break;
+ default:
+ $system_info = get_system_info();
+
+ //Read credits.
+ $smarty->assign("credits", htmlentities( implode('',file('../CREDITS')) ));
+
+ $smarty->assign("system_info", $system_info);
+ $smarty->assign("system_info_md5", md5($system_info) );
+ break;
+}
+
+$smarty->assign("first_run", $_GET['first_run'] );
+$smarty->assign("return_page", $_SERVER['PHP_SELF'] );
+
+$smarty->assign('current','about');
+if ($_GET['first_run']) {
+ $smarty->assign('page_title', 'Installation Report');
+ $smarty->assign('hidemenu', 1);
+} else {
+ $smarty->assign('page_title', 'About phpGACL');
+}
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/about.tpl');
+?>
diff --git a/html/phpgacl/admin/acl_admin.php b/html/phpgacl/admin/acl_admin.php
new file mode 100644
index 0000000..ff62f0a
--- /dev/null
+++ b/html/phpgacl/admin/acl_admin.php
@@ -0,0 +1,259 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+if (!isset($_POST['action']) ) {
+ $_POST['action'] = FALSE;
+}
+
+if (!isset($_GET['action']) ) {
+ $_GET['action'] = FALSE;
+}
+
+switch ($_POST['action']) {
+ case 'Delete':
+ break;
+ case 'Submit':
+ $gacl_api->debug_text('Submit!!');
+ //showarray($_POST['selected_aco']);
+ //showarray($_POST['selected_aro']);
+
+ //Parse the form values
+ foreach (array('aco','aro','axo') as $type) {
+ $type_array = 'selected_'. $type .'_array';
+ $$type_array = array();
+ if (is_array($_POST['selected_'. $type])) {
+ foreach ($_POST['selected_'. $type] as $value) {
+ $split_value = explode('^', $value);
+ ${$type_array}[$split_value[0]][] = $split_value[1];
+ }
+ }
+ //showarray($$type_array);
+ }
+
+ //Some sanity checks.
+ if (empty($selected_aco_array)) {
+ echo 'Must select at least one Access Control Object<br />' . "\n";
+ exit;
+ }
+
+ if (empty($selected_aro_array) AND empty($_POST['aro_groups'])) {
+ echo 'Must select at least one Access Request Object or Group<br />' . "\n";
+ exit;
+ }
+
+ $enabled = $_POST['enabled'];
+ if (empty($enabled)) {
+ $enabled = 0;
+ }
+
+ //function add_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $acl_id=FALSE ) {
+ if (!empty($_POST['acl_id'])) {
+ //Update existing ACL
+ $acl_id = $_POST['acl_id'];
+ if ($gacl_api->edit_acl($acl_id, $selected_aco_array, $selected_aro_array, $_POST['aro_groups'], $selected_axo_array, $_POST['axo_groups'], $_POST['allow'], $enabled, $_POST['return_value'], $_POST['note'], $_POST['acl_section']) == FALSE) {
+ echo 'ERROR editing ACL, possible conflict or error found...<br />' . "\n";
+ exit;
+ }
+ } else {
+ //Insert new ACL.
+ if ($gacl_api->add_acl($selected_aco_array, $selected_aro_array, $_POST['aro_groups'], $selected_axo_array, $_POST['axo_groups'], $_POST['allow'], $enabled, $_POST['return_value'], $_POST['note'], $_POST['acl_section']) == FALSE) {
+ echo 'ERROR adding ACL, possible conflict or error found...<br />' . "\n";
+ exit;
+ }
+ }
+
+ $gacl_api->return_page($_POST['return_page']);
+ break;
+ default:
+ //showarray($_GET);
+ if ($_GET['action'] == 'edit' AND !empty($_GET['acl_id'])) {
+ $gacl_api->debug_text('EDITING ACL');
+
+ //Grab ACL information
+ $query = '
+ SELECT id,section_value,allow,enabled,return_value,note
+ FROM '. $gacl_api->_db_table_prefix .'acl
+ WHERE id='. $db->qstr($_GET['acl_id']);
+ $acl_row = $db->GetRow($query);
+ list($acl_id, $acl_section_value, $allow, $enabled, $return_value, $note) = $acl_row;
+
+ //Grab selected objects
+ foreach (array('aco','aro','axo') as $type) {
+ $type_array = 'options_selected_'. $type;
+ $$type_array = array();
+
+ $query = '
+ SELECT a.section_value,a.value,c.name,b.name
+ FROM '. $gacl_api->_db_table_prefix . $type .'_map a
+ INNER JOIN '. $gacl_api->_db_table_prefix . $type .' b ON b.section_value=a.section_value AND b.value=a.value
+ INNER JOIN '. $gacl_api->_db_table_prefix . $type .'_sections c ON c.value=a.section_value
+ WHERE a.acl_id='. $db->qstr($acl_id);
+ $rs = $db->Execute($query);
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ list($section_value, $value, $section, $obj) = $row;
+ $gacl_api->debug_text("Section Value: $section_value Value: $value Section: $section ACO: $aco");
+ ${$type_array}[$section_value.'^'.$value] = $section.' > '.$obj;
+ }
+ }
+ //showarray($$type_array);
+ }
+
+ //Grab selected groups.
+ foreach (array('aro','axo') as $type) {
+ $type_array = 'selected_'. $type .'_groups';
+
+ $query = '
+ SELECT group_id
+ FROM '. $gacl_api->_db_table_prefix . $type .'_groups_map
+ WHERE acl_id='. $db->qstr($acl_id);
+ $$type_array = $db->GetCol($query);
+ //showarray($$type_array);
+ }
+
+ $show_axo = (!empty($selected_axo_groups) OR !empty($options_selected_axo));
+ } else {
+ $gacl_api->debug_text('NOT EDITING ACL');
+ $allow=1;
+ $enabled=1;
+ $acl_section_value='user';
+
+ $show_axo = isset($_COOKIE['show_axo']) && $_COOKIE['show_axo'] == '1';
+ }
+
+ //Grab sections for select boxes
+ foreach (array('acl','aco','aro','axo') as $type) {
+ $type_array = 'options_'. $type .'_sections';
+ $$type_array = array();
+
+ $query = '
+ SELECT value,name
+ FROM '. $gacl_api->_db_table_prefix . $type .'_sections
+ WHERE hidden=0
+ ORDER BY order_value,name';
+ $rs = $db->Execute($query);
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ ${$type_array}[$row[0]] = $row[1];
+ }
+ }
+
+ ${$type .'_section_id'} = reset($$type_array);
+ }
+
+ //Init the main js array
+ $js_array = 'var options = new Array();' . "\n";
+
+ //Grab objects for select boxes
+ foreach (array('aco','aro','axo') as $type) {
+ //Init the main object js array.
+ $js_array .= 'options[\''. $type .'\'] = new Array();' . "\n";
+
+ unset($tmp_section_value);
+
+ $query = '
+ SELECT section_value,value,name
+ FROM '. $gacl_api->_db_table_prefix . $type .'
+ WHERE hidden=0
+ ORDER BY section_value,order_value,name';
+ $rs = $db->SelectLimit($query,$gacl_api->_max_select_box_items);
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ $section_value = addslashes($row[0]);
+ $value = addslashes($row[1]);
+ $name = addslashes($row[2]);
+
+ //Prepare javascript code for dynamic select box.
+ //Init the javascript sub-array.
+ if (!isset($tmp_section_value) OR $section_value != $tmp_section_value) {
+ $i = 0;
+ $js_array .= 'options[\''. $type .'\'][\''. $section_value . '\'] = new Array();' . "\n";
+ $tmp_section_value = $section_value;
+ }
+
+ //Add each select option for the section
+ $js_array .= 'options[\''. $type .'\'][\''. $section_value .'\']['. $i .'] = new Array(\''. $value . '\', \''. $name . "');\n";
+ $i++;
+ }
+ }
+ }
+
+ //echo "Section ID: $section_id<br>\n";
+ //echo "Section Value: ". $acl_section_value ."<br>\n";
+
+ $smarty->assign('options_acl_sections', $options_acl_sections);
+ $smarty->assign('acl_section_value', $acl_section_value);
+
+ $smarty->assign('options_axo_sections', $options_axo_sections);
+ $smarty->assign('axo_section_value', $axo_section_value);
+
+ $smarty->assign('options_aro_sections', $options_aro_sections);
+ $smarty->assign('aro_section_value', $aro_section_value);
+
+ $smarty->assign('options_aco_sections', $options_aco_sections);
+ $smarty->assign('aco_section_value', $aco_section_value);
+
+ $smarty->assign('js_array', $js_array);
+
+ $smarty->assign('js_aco_array_name', 'aco');
+ $smarty->assign('js_aro_array_name', 'aro');
+ $smarty->assign('js_axo_array_name', 'axo');
+
+ //Grab formatted ARO Groups for select box
+ $smarty->assign('options_aro_groups', $gacl_api->format_groups($gacl_api->sort_groups('ARO')) );
+ $smarty->assign('selected_aro_groups', $selected_aro_groups);
+
+ //Grab formatted AXO Groups for select box
+ $smarty->assign('options_axo_groups', $gacl_api->format_groups($gacl_api->sort_groups('AXO')) );
+ $smarty->assign('selected_axo_groups', $selected_axo_groups);
+
+ $smarty->assign('allow', $allow);
+ $smarty->assign('enabled', $enabled);
+ $smarty->assign('return_value', $return_value);
+ $smarty->assign('note', $note);
+
+ if (isset($options_selected_aco)) {
+ $smarty->assign('options_selected_aco', $options_selected_aco);
+ }
+ $smarty->assign('selected_aco', @array_keys($options_selected_aco));
+
+ if (isset($options_selected_aro)) {
+ $smarty->assign('options_selected_aro', $options_selected_aro);
+ }
+ $smarty->assign('selected_aro', @array_keys($options_selected_aro));
+
+ if (isset($options_selected_axo)) {
+ $smarty->assign('options_selected_axo', $options_selected_axo);
+ }
+ $selected_axo = @array_keys($options_selected_axo);
+
+ $smarty->assign('selected_axo', $selected_axo);
+
+ //Show AXO layer if AXO's are selected.
+ $smarty->assign('show_axo', $show_axo);
+
+ if (isset($_GET['acl_id'])) {
+ $smarty->assign('acl_id', $_GET['acl_id'] );
+ }
+
+ break;
+}
+
+//$smarty->assign('return_page', urlencode($_SERVER[REQUEST_URI]) );
+if (isset($_GET['return_page'])) {
+ $smarty->assign('return_page', $_GET['return_page']);
+}
+if (isset($_GET['action'])) {
+ $smarty->assign('action', $_GET['action']);
+}
+
+$smarty->assign('current','acl_admin');
+$smarty->assign('page_title', 'ACL Admin');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version() );
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version() );
+$smarty->display('phpgacl/acl_admin.tpl');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/acl_debug.php b/html/phpgacl/admin/acl_debug.php
new file mode 100644
index 0000000..cb4f5ec
--- /dev/null
+++ b/html/phpgacl/admin/acl_debug.php
@@ -0,0 +1,95 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+switch ($_GET['action']) {
+ case 'Submit':
+ $gacl_api->debug_text('Submit!!');
+ //$result = $gacl_api->acl_query('system', 'email_pw', 'users', '1', NULL, NULL, NULL, NULL, TRUE);
+ $result = $gacl_api->acl_query( $_GET['aco_section_value'],
+ $_GET['aco_value'],
+ $_GET['aro_section_value'],
+ $_GET['aro_value'],
+ $_GET['axo_section_value'],
+ $_GET['axo_value'],
+ $_GET['root_aro_group_id'],
+ $_GET['root_axo_group_id'],
+ TRUE);
+
+ //Grab all relavent columns
+ $result['query'] = str_replace( 'a.id,a.allow,a.return_value',
+ ' a.id,
+ a.allow,
+ a.return_value,
+ a.note,
+ a.updated_date,
+ ac.section_value as aco_section_value,
+ ac.value as aco_value,
+ ar.section_value as aro_section_value,
+ ar.value as aro_value,
+ ax.section_value as axo_section_value,
+ ax.value as axo_value',
+ $result['query']);
+ $rs = $gacl_api->db->Execute($result['query']);
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ list(
+ $id,
+ $allow,
+ $return_value,
+ $note,
+ $updated_date,
+ $aco_section_value,
+ $aco_value,
+ $aro_section_value,
+ $aro_value,
+ $axo_section_value,
+ $axo_value
+ ) = $row;
+
+ $acls[] = array(
+ 'id' => $id,
+ 'allow' => $allow,
+ 'return_value' => $return_value,
+ 'note' => $note,
+ 'updated_date' => date('d-M-y H:m:i',$updated_date),
+
+ 'aco_section_value' => $aco_section_value,
+ 'aco_value' => $aco_value,
+
+ 'aro_section_value' => $aro_section_value,
+ 'aro_value' => $aro_value,
+
+ 'axo_section_value' => $axo_section_value,
+ 'axo_value' => $axo_value,
+ );
+ }
+ }
+
+ //echo "<br><br>$x ACL_CHECK()'s<br>\n";
+
+ $smarty->assign('acls', $acls);
+
+ $smarty->assign('aco_section_value', $_GET['aco_section_value']);
+ $smarty->assign('aco_value', $_GET['aco_value']);
+ $smarty->assign('aro_section_value', $_GET['aro_section_value']);
+ $smarty->assign('aro_value', $_GET['aro_value']);
+ $smarty->assign('axo_section_value', $_GET['axo_section_value']);
+ $smarty->assign('axo_value', $_GET['axo_value']);
+ $smarty->assign('root_aro_group_id', $_GET['root_aro_group_id']);
+ $smarty->assign('root_axo_group_id', $_GET['root_axo_group_id']);
+ break;
+ default:
+ break;
+}
+
+$smarty->assign('return_page', $_SERVER['PHP_SELF']);
+
+$smarty->assign('current','acl_debug');
+$smarty->assign('page_title', 'ACL Debug');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version());
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
+
+$smarty->display('phpgacl/acl_debug.tpl');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/acl_list.php b/html/phpgacl/admin/acl_list.php
new file mode 100644
index 0000000..6553d96
--- /dev/null
+++ b/html/phpgacl/admin/acl_list.php
@@ -0,0 +1,274 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+switch ($_GET['action']) {
+ case 'Delete':
+ $gacl_api->debug_text('Delete!');
+
+ if (is_array ($_GET['delete_acl']) AND !empty($_GET['delete_acl'])) {
+ foreach($_GET['delete_acl'] as $id) {
+ $gacl_api->del_acl($id);
+ }
+ }
+
+ //Return page.
+ $gacl_api->return_page($_GET['return_page']);
+ break;
+ case 'Submit':
+ $gacl_api->debug_text('Submit!!');
+ break;
+ default:
+ /*
+ * When the user requests to filter the list, run the filter and get just the matching IDs.
+ * Use these IDs to get the entire ACL information in the second query.
+ *
+ * If we just put the LIKE statements in the second query, it will match the correct ACLs
+ * but will only return the matching rows, so it won't show the entire ACL information.
+ *
+ */
+ if (isset($_GET['action']) AND $_GET['action'] == 'Filter') {
+ $gacl_api->debug_text('Filtering...');
+
+ $query = '
+ SELECT DISTINCT a.id
+ FROM '. $gacl_api->_db_table_prefix .'acl a
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aco_map ac ON ac.acl_id=a.id
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro_map ar ON ar.acl_id=a.id
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'axo_map ax ON ax.acl_id=a.id';
+
+ if ( isset($_GET['filter_aco_section']) AND $_GET['filter_aco_section'] != '-1') {
+ $filter_query[] = 'ac.section_value='. $db->qstr(strtolower($_GET['filter_aco_section']));
+ }
+ if ( isset($_GET['filter_aco']) AND $_GET['filter_aco'] != '') {
+ $query .= '
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aco c ON (c.section_value=ac.section_value AND c.value=ac.value)';
+
+ $name = $db->qstr(strtolower($_GET['filter_aco']));
+ $filter_query[] = '(lower(c.value) LIKE '. $name .' OR lower(c.name) LIKE '. $name .')';
+ }
+
+ if ( isset($_GET['filter_aro_section']) AND $_GET['filter_aro_section'] != '-1') {
+ $filter_query[] = 'ar.section_value='. $db->qstr(strtolower($_GET['filter_aro_section']));
+ }
+ if ( isset($_GET['filter_aro']) AND $_GET['filter_aro'] != '') {
+ $query .= '
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro r ON (r.section_value=ar.section_value AND r.value=ar.value)';
+
+ $name = $db->qstr(strtolower($_GET['filter_aro']));
+ $filter_query[] = '(lower(r.value) LIKE '. $name .' OR lower(r.name) LIKE '. $name .')';
+ }
+ if ( isset($_GET['filter_aro_group']) AND $_GET['filter_aro_group'] != '') {
+ $query .= '
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro_groups_map arg ON arg.acl_id=a.id
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro_groups rg ON rg.id=arg.group_id';
+
+ $filter_query[] = '(lower(rg.name) LIKE '. $db->qstr(strtolower($_GET['filter_aro_group'])) .')';
+ }
+
+ if ( isset($_GET['filter_axo_section']) AND $_GET['filter_axo_section'] != '-1') {
+ $filter_query[] = 'ax.section_value='. $db->qstr(strtolower($_GET['filter_axo_section']));
+ }
+ if ( isset($_GET['filter_axo']) AND $_GET['filter_axo'] != '') {
+ $query .= '
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'axo x ON (x.section_value=ax.section_value AND x.value=ax.value)';
+
+ $name = $db->qstr(strtolower($_GET['filter_axo']));
+ $filter_query[] = '(lower(x.value) LIKE '. $name .' OR lower(x.name) LIKE '. $name .')';
+ }
+ if ( isset($_GET['filter_axo_group']) AND $_GET['filter_axo_group'] != '') {
+ $query .= '
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'axo_groups_map axg ON axg.acl_id=a.id
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'axo_groups xg ON xg.id=axg.group_id';
+
+ $filter_query[] = '(lower(xg.name) LIKE '. $db->qstr(strtolower($_GET['filter_axo_group'])) .')';
+ }
+
+ if ( isset($_GET['filter_acl_section']) AND $_GET['filter_acl_section'] != '-1') {
+ $filter_query[] = 'a.section_value='. $db->qstr(strtolower($_GET['filter_acl_section']));
+ }
+ if ( isset($_GET['filter_return_value']) AND $_GET['filter_return_value'] != '') {
+ $filter_query[] = '(lower(a.return_value) LIKE '. $db->qstr(strtolower($_GET['filter_return_value'])) .')';
+ }
+ if ( isset($_GET['filter_allow']) AND $_GET['filter_allow'] != '-1') {
+ $filter_query[] = '(a.allow LIKE '. $db->qstr($_GET['filter_allow']) .')';
+ }
+ if ( isset($_GET['filter_enabled']) AND $_GET['filter_enabled'] != '-1') {
+ $filter_query[] = '(a.enabled LIKE '. $db->qstr($_GET['filter_enabled']) .')';
+ }
+
+ if (isset($filter_query) AND is_array($filter_query)) {
+ $query .= '
+ WHERE '. implode(' AND ', $filter_query);
+ }
+ } else {
+ $query = '
+ SELECT a.id FROM ' . $gacl_api->_db_table_prefix . 'acl a';
+ }
+
+ $query .= '
+ ORDER BY a.id ASC';
+
+ $acl_ids = array();
+
+ $rs = $db->PageExecute($query, $gacl_api->_items_per_page, $_GET['page']);
+ if ( is_object($rs) ) {
+ $smarty->assign('paging_data', $gacl_api->get_paging_data($rs));
+
+ while ( $row = $rs->FetchRow() ) {
+ $acl_ids[] = $row[0];
+ }
+
+ $rs->Close();
+ }
+
+ if ( !empty($acl_ids) ) {
+ $acl_ids_sql = implode(',', $acl_ids);
+ } else {
+ //This shouldn't match any ACLs, returning 0 rows.
+ $acl_ids_sql = -1;
+ }
+
+ $acls = array();
+
+ //If the user is searching, and there are no results, don't run the query at all
+ if ( !($_GET['action'] == 'Filter' AND $acl_ids_sql == -1) ) {
+
+ // grab acl details
+ $query = '
+ SELECT a.id,x.name,a.allow,a.enabled,a.return_value,a.note,a.updated_date
+ FROM '. $gacl_api->_db_table_prefix .'acl a
+ INNER JOIN '. $gacl_api->_db_table_prefix .'acl_sections x ON x.value=a.section_value
+ WHERE a.id IN ('. $acl_ids_sql . ')';
+ $rs = $db->Execute($query);
+
+ if ( is_object($rs) ) {
+ while ( $row = $rs->FetchRow() ) {
+ $acls[$row[0]] = array(
+ 'id' => $row[0],
+ // 'section_id' => $section_id,
+ 'section_name' => $row[1],
+ 'allow' => (bool)$row[2],
+ 'enabled' => (bool)$row[3],
+ 'return_value' => $row[4],
+ 'note' => $row[5],
+ 'updated_date' => $row[6],
+
+ 'aco' => array(),
+ 'aro' => array(),
+ 'aro_groups' => array(),
+ 'axo' => array(),
+ 'axo_groups' => array()
+ );
+ }
+ }
+
+ // grab ACO, ARO and AXOs
+ foreach ( array('aco', 'aro', 'axo') as $type ) {
+ $query = '
+ SELECT a.acl_id,o.name,s.name
+ FROM '. $gacl_api->_db_table_prefix . $type .'_map a
+ INNER JOIN '. $gacl_api->_db_table_prefix . $type .' o ON (o.section_value=a.section_value AND o.value=a.value)
+ INNER JOIN '. $gacl_api->_db_table_prefix . $type . '_sections s ON s.value=a.section_value
+ WHERE a.acl_id IN ('. $acl_ids_sql . ')';
+ $rs = $db->Execute($query);
+
+ if ( is_object($rs) ) {
+ while ( $row = $rs->FetchRow() ) {
+ list($acl_id, $name, $section_name) = $row;
+
+ if ( isset($acls[$acl_id]) ) {
+ $acls[$acl_id][$type][$section_name][] = $name;
+ }
+ }
+ }
+ }
+
+ // grab ARO and AXO groups
+ foreach ( array('aro', 'axo') as $type )
+ {
+ $query = '
+ SELECT a.acl_id,g.name
+ FROM '. $gacl_api->_db_table_prefix . $type .'_groups_map a
+ INNER JOIN '. $gacl_api->_db_table_prefix . $type .'_groups g ON g.id=a.group_id
+ WHERE a.acl_id IN ('. $acl_ids_sql . ')';
+ $rs = $db->Execute($query);
+
+ if ( is_object($rs) ) {
+ while ( $row = $rs->FetchRow () ) {
+ list($acl_id, $name) = $row;
+
+ if ( isset($acls[$acl_id]) ) {
+ $acls[$acl_id][$type .'_groups'][] = $name;
+ }
+ }
+ }
+ }
+ }
+
+ $smarty->assign('acls', $acls);
+
+ $smarty->assign('filter_aco', $_GET['filter_aco']);
+
+ $smarty->assign('filter_aro', $_GET['filter_aro']);
+ $smarty->assign('filter_aro_group', $_GET['filter_aro_group']);
+
+ $smarty->assign('filter_axo', $_GET['filter_axo']);
+ $smarty->assign('filter_axo_group', $_GET['filter_axo_group']);
+
+ $smarty->assign('filter_return_value', $_GET['filter_return_value']);
+
+ foreach(array('aco','aro','axo','acl') as $type) {
+ //
+ //Grab all sections for select box
+ //
+ $options = array (
+ -1 => 'Any'
+ );
+
+ $query = '
+ SELECT value,name
+ FROM '. $gacl_api->_db_table_prefix .$type .'_sections
+ WHERE hidden=0
+ ORDER BY order_value,name';
+ $rs = $db->Execute($query);
+
+ if ( is_object($rs) ) {
+ while ($row = $rs->FetchRow()) {
+ $options[$row[0]] = $row[1];
+ }
+ }
+
+ $smarty->assign('options_filter_'. $type . '_sections', $options);
+
+ if (!isset($_GET['filter_' . $type . '_section']) OR $_GET['filter_' . $type . '_section'] == '') {
+ $_GET['filter_' . $type . '_section'] = '-1';
+ }
+
+ $smarty->assign('filter_' . $type . '_section', $_GET['filter_' . $type .'_section']);
+ }
+
+ $smarty->assign('options_filter_allow', array('-1' => 'Any', 1 => 'Allow', 0 => 'Deny'));
+ $smarty->assign('options_filter_enabled', array('-1' => 'Any', 1 => 'Yes', 0 => 'No'));
+
+ if (!isset($_GET['filter_allow']) OR $_GET['filter_allow'] == '') {
+ $_GET['filter_allow'] = '-1';
+ }
+ if (!isset($_GET['filter_enabled']) OR $_GET['filter_enabled'] == '') {
+ $_GET['filter_enabled'] = '-1';
+ }
+
+ $smarty->assign('filter_allow', $_GET['filter_allow']);
+ $smarty->assign('filter_enabled', $_GET['filter_enabled']);
+}
+
+$smarty->assign('action', $_GET['action']);
+$smarty->assign('return_page', $_SERVER['PHP_SELF']);
+
+$smarty->assign('current','acl_list');
+$smarty->assign('page_title', 'ACL List');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version());
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
+
+$smarty->display('phpgacl/acl_list.tpl');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/acl_test.php b/html/phpgacl/admin/acl_test.php
new file mode 100644
index 0000000..f1c8b65
--- /dev/null
+++ b/html/phpgacl/admin/acl_test.php
@@ -0,0 +1,26 @@
+<?php
+/*
+meinhard_jahn@web.de, 20041102: link to acl_test2.php and acl_test3.php
+*/
+/*
+if (!empty($_GET['debug'])) {
+ $debug = $_GET['debug'];
+}
+*/
+@set_time_limit(600);
+
+require_once('../profiler.inc');
+$profiler = new Profiler(true,true);
+
+require_once("gacl_admin.inc.php");
+
+$smarty->assign("return_page", $_SERVER['PHP_SELF'] );
+
+$smarty->assign('current','acl_test');
+$smarty->assign('page_title', 'ACL Test');
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/acl_test.tpl');
+?>
diff --git a/html/phpgacl/admin/acl_test2.php b/html/phpgacl/admin/acl_test2.php
new file mode 100644
index 0000000..893bd9f
--- /dev/null
+++ b/html/phpgacl/admin/acl_test2.php
@@ -0,0 +1,110 @@
+<?php
+/*
+if (!empty($_GET['debug'])) {
+ $debug = $_GET['debug'];
+}
+*/
+@set_time_limit(600);
+
+require_once('../profiler.inc');
+$profiler = new Profiler(true,true);
+
+require_once("gacl_admin.inc.php");
+
+$query = '
+ SELECT a.value AS a_value, a.name AS a_name,
+ b.value AS b_value, b.name AS b_name,
+ c.value AS c_value, c.name AS c_name,
+ d.value AS d_value, d.name AS d_name
+ FROM '. $gacl_api->_db_table_prefix .'aco_sections a
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aco b ON a.value=b.section_value,
+ '. $gacl_api->_db_table_prefix .'aro_sections c
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro d ON c.value=d.section_value
+ ORDER BY a.value, b.value, c.value, d.value';
+
+//$rs = $db->Execute($query);
+$rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
+$rows = $rs->GetRows();
+
+/*
+echo("<pre>");
+print_r($rows);
+echo("</pre>");
+*/
+
+$total_rows = count($rows);
+
+while (list(,$row) = @each(&$rows)) {
+ list( $aco_section_value,
+ $aco_section_name,
+ $aco_value,
+ $aco_name,
+
+ $aro_section_value,
+ $aro_section_name,
+ $aro_value,
+ $aro_name
+ ) = $row;
+
+ $acl_check_begin_time = $profiler->getMicroTime();
+ $acl_result = $gacl->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value);
+ $acl_check_end_time = $profiler->getMicroTime();
+
+ $access = &$acl_result['allow'];
+ $return_value = &$acl_result['return_value'];
+
+ $acl_check_time = ($acl_check_end_time - $acl_check_begin_time) * 1000;
+ $total_acl_check_time += $acl_check_time;
+
+ if ($aco_section_name != $tmp_aco_section_name OR $aco_name != $tmp_aco_name) {
+ $display_aco_name = "$aco_section_name > $aco_name";
+ } else {
+ $display_aco_name = "<br>";
+ }
+
+ $acls[] = array(
+ 'aco_section_value' => $aco_section_value,
+ 'aco_section_name' => $aco_section_name,
+ 'aco_value' => $aco_value,
+ 'aco_name' => $aco_name,
+
+ 'aro_section_value' => $aro_section_value,
+ 'aro_section_name' => $aro_section_name,
+ 'aro_value' => $aro_value,
+ 'aro_name' => $aro_name,
+
+ 'access' => $access,
+ 'return_value' => $return_value,
+ 'acl_check_time' => number_format($acl_check_time, 2),
+
+ 'display_aco_name' => $display_aco_name,
+ );
+
+ $tmp_aco_section_name = $aco_section_name;
+ $tmp_aco_name = $aco_name;
+}
+
+//echo "<br><br>$x ACL_CHECK()'s<br>\n";
+
+$smarty->assign("acls", $acls);
+
+$smarty->assign("total_acl_checks", $total_rows);
+$smarty->assign("total_acl_check_time", $total_acl_check_time);
+
+if ($total_rows > 0) {
+ $avg_acl_check_time = $total_acl_check_time / $total_rows;
+}
+$smarty->assign("avg_acl_check_time", number_format( ($avg_acl_check_time + 0) ,2));
+
+$smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
+
+$smarty->assign("return_page", $_SERVER['PHP_SELF'] );
+
+$smarty->assign('current','acl_test');
+$smarty->assign('page_title', '2-dim. ACL Test');
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/acl_test2.tpl');
+?>
diff --git a/html/phpgacl/admin/acl_test3.php b/html/phpgacl/admin/acl_test3.php
new file mode 100644
index 0000000..86c2fde
--- /dev/null
+++ b/html/phpgacl/admin/acl_test3.php
@@ -0,0 +1,140 @@
+<?php
+/*
+meinhard_jahn@web.de, 20041102: axo implemented
+*/
+/*
+if (!empty($_GET['debug'])) {
+ $debug = $_GET['debug'];
+}
+*/
+@set_time_limit(600);
+
+require_once('../profiler.inc');
+$profiler = new Profiler(true,true);
+
+require_once("gacl_admin.inc.php");
+/*
+$query = '
+ SELECT a.value AS a_value, a.name AS a_name,
+ b.value AS b_value, b.name AS b_name,
+ c.value AS c_value, c.name AS c_name,
+ d.value AS d_value, d.name AS d_name
+ FROM '. $gacl_api->_db_table_prefix .'aco_sections a
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aco b ON a.value=b.section_value,
+ '. $gacl_api->_db_table_prefix .'aro_sections c
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro d ON c.value=d.section_value
+ ORDER BY a.value, b.value, c.value, d.value';
+*/
+
+$query = '
+ SELECT a.value AS a_value, a.name AS a_name,
+ b.value AS b_value, b.name AS b_name,
+ c.value AS c_value, c.name AS c_name,
+ d.value AS d_value, d.name AS d_name,
+ e.value AS e_value, e.name AS e_name,
+ f.value AS f_value, f.name AS f_name
+ FROM '. $gacl_api->_db_table_prefix .'aco_sections a
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aco b ON a.value=b.section_value,
+ '. $gacl_api->_db_table_prefix .'aro_sections c
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'aro d ON c.value=d.section_value,
+ '. $gacl_api->_db_table_prefix .'axo_sections e
+ LEFT JOIN '. $gacl_api->_db_table_prefix .'axo f ON e.value=f.section_value
+ ORDER BY a.value, b.value, c.value, d.value, e.value, f.value';
+
+
+//$rs = $db->Execute($query);
+$rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
+$rows = $rs->GetRows();
+
+/*
+echo("<pre>");
+print_r($rows);
+echo("</pre>");
+*/
+
+$total_rows = count($rows);
+
+while (list(,$row) = @each(&$rows)) {
+ list( $aco_section_value,
+ $aco_section_name,
+ $aco_value,
+ $aco_name,
+
+ $aro_section_value,
+ $aro_section_name,
+ $aro_value,
+ $aro_name,
+
+ $axo_section_value,
+ $axo_section_name,
+ $axo_value,
+ $axo_name
+ ) = $row;
+
+ $acl_check_begin_time = $profiler->getMicroTime();
+ $acl_result = $gacl->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value);
+ $acl_check_end_time = $profiler->getMicroTime();
+
+ $access = &$acl_result['allow'];
+ $return_value = &$acl_result['return_value'];
+
+ $acl_check_time = ($acl_check_end_time - $acl_check_begin_time) * 1000;
+ $total_acl_check_time += $acl_check_time;
+
+ if ($aco_section_name != $tmp_aco_section_name OR $aco_name != $tmp_aco_name) {
+ $display_aco_name = "$aco_section_name > $aco_name";
+ } else {
+ $display_aco_name = "<br>";
+ }
+
+ $acls[] = array(
+ 'aco_section_value' => $aco_section_value,
+ 'aco_section_name' => $aco_section_name,
+ 'aco_value' => $aco_value,
+ 'aco_name' => $aco_name,
+
+ 'aro_section_value' => $aro_section_value,
+ 'aro_section_name' => $aro_section_name,
+ 'aro_value' => $aro_value,
+ 'aro_name' => $aro_name,
+
+ 'axo_section_value' => $axo_section_value,
+ 'axo_section_name' => $axo_section_name,
+ 'axo_value' => $axo_value,
+ 'axo_name' => $axo_name,
+
+ 'access' => $access,
+ 'return_value' => $return_value,
+ 'acl_check_time' => number_format($acl_check_time, 2),
+
+ 'display_aco_name' => $display_aco_name,
+ );
+
+ $tmp_aco_section_name = $aco_section_name;
+ $tmp_aco_name = $aco_name;
+}
+
+//echo "<br><br>$x ACL_CHECK()'s<br>\n";
+
+$smarty->assign("acls", $acls);
+
+$smarty->assign("total_acl_checks", $total_rows);
+$smarty->assign("total_acl_check_time", $total_acl_check_time);
+
+if ($total_rows > 0) {
+ $avg_acl_check_time = $total_acl_check_time / $total_rows;
+}
+$smarty->assign("avg_acl_check_time", number_format( ($avg_acl_check_time + 0) ,2));
+
+$smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
+
+$smarty->assign("return_page", $_SERVER['PHP_SELF'] );
+
+$smarty->assign('current','acl_test');
+$smarty->assign('page_title', '3-dim. ACL Test');
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/acl_test3.tpl');
+?>
diff --git a/html/phpgacl/admin/admin.css b/html/phpgacl/admin/admin.css
new file mode 100644
index 0000000..acc3564
--- /dev/null
+++ b/html/phpgacl/admin/admin.css
@@ -0,0 +1,279 @@
+body {
+ background-color:#ffffff;
+ margin: 0px;
+ padding: 0px;
+}
+
+div {
+ position: relative;
+}
+
+div#top-tr {
+ margin: 0px;
+ padding: 0px;
+ background: #cccccc url("images/top-r.png") no-repeat top right;
+}
+
+div#top-tl {
+ margin: 0px;
+ padding: 0px;
+ background: url("images/top-l.png") no-repeat top left;
+}
+
+div#top-br {
+ margin: 0px;
+ padding: 0px;
+ background: url("images/div-r.png") no-repeat bottom right;
+}
+
+div#top-bl {
+ margin: 0px;
+ padding: 10px 180px 0px 10px;
+ background: url("images/div-l.png") no-repeat bottom left;
+}
+
+div#top-bl h1 {
+ position: absolute;
+ visibility: hidden;
+}
+
+div#top-bl h2 {
+ color: #eeeeee;
+ font-size: 150%;
+ margin: 6px 4px;
+ padding: 0px;
+}
+
+ul#menu {
+ margin: 0px;
+ padding: 0px;
+
+ display: table;
+ width: 100%;
+ list-style-type: none;
+}
+
+ul#menu li {
+ float: left;
+
+ margin: 0px 2px 0px 0px;
+ padding: 0px;
+ background: #999999 url("images/tab-off-r.png") no-repeat top right;
+ border-bottom: 1px solid #666666;
+}
+
+ul#menu li a {
+ display: block;
+ margin: 0px;
+ padding: 2px 5px 1px 5px;
+ background: url("images/tab-off-l.png") no-repeat top left;
+
+ color: #d8d8d8;
+ text-decoration: none;
+ text-align: center;
+ font-weight: normal;
+
+ width: .1em;
+ white-space: nowrap;
+ min-width: 50px;
+}
+
+ul#menu li>a {
+ width: auto;
+}
+
+ul#menu li a:hover {
+ color: #ffffff;
+}
+
+ul#menu li.current {
+ background-color: #ffffff;
+ background-image: url("images/tab-on-r.png");
+ border-bottom-width: 0px;
+}
+
+ul#menu li.current a {
+ background-image: url("images/tab-on-l.png");
+ padding-bottom: 2px;
+
+ color: #666666;
+ text-decoration: none;
+}
+
+ul#menu li.current a:hover {
+ color: #666666;
+}
+
+div#mid-r {
+ margin: 0px;
+ padding: 0px;
+ background: #ffffff url("images/mid-r.png") repeat-y top right;
+}
+
+div#mid-l {
+ margin: 0px;
+ padding: 4px 10px;
+ background: url("images/mid-l.png") repeat-y top left;
+}
+
+div#bot-tr {
+ margin: 0px;
+ padding: 0px;
+ background: url("images/div-r.png") no-repeat top right;
+}
+
+div#bot-tl {
+ margin: 0px;
+ padding: 2px 10px 10px 10px;
+ background: url("images/div-l.png") no-repeat top left;
+
+ font-size: 8pt;
+ text-align: center;
+}
+
+div#bot-tl a {
+ text-decoration: none;
+}
+
+div#bot-br {
+ margin: 0px;
+ padding: 0px;
+ background: #cccccc url("images/bot-r.png") no-repeat bottom right;
+}
+
+div#bot-bl {
+ margin: 0px;
+ padding: 0px;
+ background: url("images/bot-l.png") no-repeat bottom left;
+}
+
+body, td, th {
+ font-family: Verdana, Helvetica, Arial, sans-serif;
+ font-size: 9pt;
+}
+
+table, td, th {
+ border: 0px;
+}
+
+tr {
+ background-color: #cccccc;
+}
+
+th {
+ background-color: #d3dce3;
+ font-weight: bold;
+ text-align: center;
+}
+
+tr.controls {
+ background-color: #999999;
+}
+
+tr.odd {
+ background-color: #c0c0c0;
+}
+
+tr.even {
+ background-color: #d0d0d0;
+}
+
+tr.spacer {
+ background-color: transparent;
+ height: 10px;
+}
+
+td.green {
+ background-color: green;
+}
+
+td.red {
+ background-color: red;
+}
+
+input, select, textarea {
+ font-family: verdana, sans-serif;
+ font-size: 9pt;
+ border: 1px solid #333333;
+}
+
+input {
+ padding: 1px 2px;
+}
+
+input.checkbox, input.radio {
+ border: 0px;
+ margin: 1px 2px 0px;
+ padding: 0px;
+}
+
+input.button {
+ width: 100px;
+}
+
+input.paypal {
+ border-width: 0px;
+}
+
+.navigation {
+ font-family: verdana, sans-serif;
+ font-size: 8pt;
+ padding-bottom: 5px;
+}
+
+.navigation a {
+ color: #0000ff;
+}
+
+.navigation a:hover {
+ color: #aa0000;
+ background-color: #f0f0f0;
+}
+
+.footer {
+ font-size: 8pt;
+ text-align: center;
+}
+
+form {
+ margin: 0px;
+}
+
+tr.hide {
+ display: none;
+}
+
+tr.show {
+}
+
+td.tabon {
+ background: #438EC5;
+}
+
+td.taboff {
+ background: #ABC3D4;
+}
+
+select {
+ width: 99%;
+ margin-top: 5px;
+}
+
+textarea, input#return_value {
+ width: 99%;
+}
+
+input.un-select {
+ width: 99%;
+ margin-top: 5px;
+}
+
+input.select {
+ width: 99%;
+ margin-top: 5px;
+}
+
+input.deselect {
+ width: 99%;
+ margin-top: 8px;
+} \ No newline at end of file
diff --git a/html/phpgacl/admin/admin_functions.js b/html/phpgacl/admin/admin_functions.js
new file mode 100644
index 0000000..7ea3efe
--- /dev/null
+++ b/html/phpgacl/admin/admin_functions.js
@@ -0,0 +1,232 @@
+/*
+ * phpGACL - Generic Access Control List
+ * Copyright (C) 2002,2003 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ */
+
+var selectedTab = null;
+
+//Function to totally clear a select box.
+function depopulate(form_element) {
+ if (form_element.options.length > 0) {
+ form_element.innerHTML = '';
+ }
+}
+
+//Populates a select box based off the value of "parent" select box.
+function populate(parent_form_element, child_form_element, src_array) {
+ //alert('Parent: ' + parent_form_element);
+ //alert('Child: ' + child_form_element);
+
+ if (parent_form_element.selectedIndex >= 0) {
+ //Grab the current selected value from the parent
+ parent_id = parent_form_element.options[parent_form_element.selectedIndex].value;
+
+ //Clear the child form element
+ depopulate(child_form_element);
+
+ //Populate child form element
+ if (options[src_array][parent_id]) {
+ for (i=0; i < options[src_array][parent_id].length; i++) {
+ child_form_element.options[i] = new Option(options[src_array][parent_id][i][1], options[src_array][parent_id][i][0]);
+ }
+ }
+ }
+}
+
+//Select an item by "copying" it from one select box to another
+function select_item(parent_form_element, src_form_element, dst_form_element) {
+ //alert('Src: ' + src_form_element);
+ //alert('Dst: ' + dst_form_element);
+ found_dup=false;
+ //Copy it over to the dst element
+ for (i=0; i < src_form_element.options.length; i++) {
+ if (src_form_element.options[i].selected) {
+ //Check to see if duplicate entries exist.
+ for (n=0; n < dst_form_element.options.length; n++) {
+ if ( parent_form_element.options[parent_form_element.selectedIndex].value + '^' + src_form_element.options[i].value == dst_form_element.options[n].value) {
+ found_dup=true;
+ }
+ }
+
+ //Only add if its not a duplicate entry.
+ if (!found_dup) {
+ //Grab the current selected value from the parent
+ src_id = src_form_element.options[i].value;
+ src_text = src_form_element.options[i].text;
+
+ src_section_id = parent_form_element.options[parent_form_element.selectedIndex].value;
+ src_section_text = parent_form_element.options[parent_form_element.selectedIndex].text;
+
+ options_length = dst_form_element.options.length;
+ dst_form_element.options[options_length] = new Option(src_section_text + ' > ' + src_text, src_section_id + '^' + src_id);
+ dst_form_element.options[options_length].selected = true;
+ }
+ }
+
+ found_dup=false;
+ }
+}
+
+//Used for moving items to and from the selected combo box.
+function deselect_item(form_element) {
+ //alert('Src: ' + src_form_element);
+ //alert('Dst: ' + dst_form_element);
+
+ //Copy it over to the dst element
+ for (i=0; i < form_element.options.length; i++) {
+ if (form_element.options[i].selected) {
+ form_element.options[i] = null;
+ i=i - 1;
+ }
+ }
+}
+
+//Used to unselect all items in a combo box
+function unselect_all(form_element) {
+ for (i=0; i < form_element.options.length; i++) {
+ form_element.options[i].selected = false;
+ }
+}
+
+function select_all(select_box) {
+ for (i=0; i < select_box.options.length; i++) {
+ select_box.options[i].selected = true;
+ }
+}
+
+function edit_link(link, parent_id) {
+ alert('edit_aco.php?section_id=' + parent_id + '&return_page={$return_page}')
+}
+
+function toggleObject(objectID) {
+ if(document.getElementById) {
+ if(document.getElementById(objectID).className == 'hide') {
+ showObject(objectID);
+ } else {
+ hideObject(objectID);
+ }
+ }
+}
+
+function showObject(objectID) {
+ if(document.getElementById) {
+ document.getElementById(objectID).className = 'show';
+ }
+}
+
+function hideObject(objectID) {
+ if(document.getElementById) {
+ document.getElementById(objectID).className = 'hide';
+ }
+}
+
+function showTab(objectID) {
+ if(document.getElementById) {
+ if(selectedObject != objectID) {
+ document.getElementById(objectID).className = 'tabon';
+ selectedTab = objectID;
+ }
+ }
+}
+
+function hideTab() {
+ if(document.getElementById) {
+ if(selectedTab) {
+ document.getElementById(selectedTab).className = 'taboff';
+ }
+ }
+}
+
+function checkAll(checkbox) {
+ for (i=0; i<checkbox.form.elements.length; i++) {
+ if (checkbox.form.elements[i].type == checkbox.type) {
+ checkbox.form.elements[i].checked = checkbox.checked;
+ }
+ }
+ return true;
+}
+
+/**
+ * Sets a Cookie with the given name and value.
+ *
+ * name Name of the cookie
+ * value Value of the cookie
+ * [expires] Expiration date of the cookie (default: end of current session)
+ * [path] Path where the cookie is valid (default: path of calling document)
+ * [domain] Domain where the cookie is valid
+ * (default: domain of calling document)
+ * [secure] Boolean value indicating if the cookie transmission requires a
+ * secure transmission
+ */
+function setCookie(name, value, expires, path, domain, secure) {
+ document.cookie= name + "=" + escape(value) +
+ ((expires) ? "; expires=" + expires.toGMTString() : "") +
+ ((path) ? "; path=" + path : "") +
+ ((domain) ? "; domain=" + domain : "") +
+ ((secure) ? "; secure" : "");
+}
+
+/**
+ * Gets the value of the specified cookie.
+ *
+ * name Name of the desired cookie.
+ *
+ * Returns a string containing value of specified cookie,
+ * or null if cookie does not exist.
+ */
+function getCookie(name) {
+ var dc = document.cookie;
+ var prefix = name + "=";
+ var begin = dc.indexOf("; " + prefix);
+ if (begin == -1) {
+ begin = dc.indexOf(prefix);
+ if (begin != 0) return null;
+ } else {
+ begin += 2;
+ }
+ var end = document.cookie.indexOf(";", begin);
+ if (end == -1) {
+ end = dc.length;
+ }
+ return unescape(dc.substring(begin + prefix.length, end));
+}
+
+/**
+ * Deletes the specified cookie.
+ *
+ * name name of the cookie
+ * [path] path of the cookie (must be same as path used to create cookie)
+ * [domain] domain of the cookie (must be same as domain used to create cookie)
+ */
+function deleteCookie(name, path, domain) {
+ if (getCookie(name)) {
+ document.cookie = name + "=" +
+ ((path) ? "; path=" + path : "") +
+ ((domain) ? "; domain=" + domain : "") +
+ "; expires=Thu, 01-Jan-70 00:00:01 GMT";
+ }
+}
diff --git a/html/phpgacl/admin/assign_group.php b/html/phpgacl/admin/assign_group.php
new file mode 100644
index 0000000..8d02afc
--- /dev/null
+++ b/html/phpgacl/admin/assign_group.php
@@ -0,0 +1,188 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+//GET takes precedence.
+if ($_GET['group_type'] != '') {
+ $group_type = $_GET['group_type'];
+} else {
+ $group_type = $_POST['group_type'];
+}
+
+switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $gacl_api->_db_table_prefix . 'axo';
+ $group_table = $gacl_api->_db_table_prefix . 'axo_groups';
+ $group_sections_table = $gacl_api->_db_table_prefix . 'axo_sections';
+ $group_map_table = $gacl_api->_db_table_prefix . 'groups_axo_map';
+ $object_type = 'Access eXtension Object';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $gacl_api->_db_table_prefix . 'aro';
+ $group_table = $gacl_api->_db_table_prefix . 'aro_groups';
+ $group_sections_table = $gacl_api->_db_table_prefix . 'aro_sections';
+ $group_map_table = $gacl_api->_db_table_prefix . 'groups_aro_map';
+ $object_type = 'Access Request Object';
+ break;
+}
+
+switch ($_POST['action']) {
+ case 'Remove':
+ $gacl_api->debug_text('Delete!!');
+
+ //Parse the form values
+ //foreach ($_POST['delete_assigned_aro'] as $aro_value) {
+ while (list(,$object_value) = @each($_POST['delete_assigned_object'])) {
+ $split_object_value = explode('^', $object_value);
+ $selected_object_array[$split_object_value[0]][] = $split_object_value[1];
+ }
+
+ //Insert Object -> GROUP mappings
+ while (list($object_section_value,$object_array) = @each($selected_object_array)) {
+ $gacl_api->debug_text('Assign: Object ID: '. $object_section_value .' to Group: '. $_POST['group_id']);
+
+ foreach ($object_array as $object_value) {
+ $gacl_api->del_group_object($_POST['group_id'], $object_section_value, $object_value, $group_type);
+ }
+ }
+
+ //Return page.
+ $gacl_api->return_page($_SERVER['PHP_SELF'] .'?group_type='. $_POST['group_type'] .'&group_id='. $_POST['group_id']);
+
+ break;
+ case 'Submit':
+ $gacl_api->debug_text('Submit!!');
+
+ //showarray($_POST['selected_'.$_POST['group_type']]);
+ //Parse the form values
+ //foreach ($_POST['selected_aro'] as $aro_value) {
+ while (list(,$object_value) = @each($_POST['selected_'.$_POST['group_type']])) {
+ $split_object_value = explode('^', $object_value);
+ $selected_object_array[$split_object_value[0]][] = $split_object_value[1];
+ }
+
+ //Insert ARO -> GROUP mappings
+ while (list($object_section_value,$object_array) = @each($selected_object_array)) {
+ $gacl_api->debug_text('Assign: Object ID: '. $object_section_value .' to Group: '. $_POST['group_id']);
+
+ foreach ($object_array as $object_value) {
+ $gacl_api->add_group_object($_POST['group_id'], $object_section_value, $object_value, $group_type);
+ }
+ }
+
+ $gacl_api->return_page($_SERVER['PHP_SELF'] .'?group_type='. $_POST['group_type'] .'&group_id='. $_POST['group_id']);
+
+ break;
+ default:
+ //
+ //Grab all sections for select box
+ //
+ $query = 'SELECT value,name FROM '. $group_sections_table .' ORDER BY order_value,name';
+ $rs = $db->Execute($query);
+
+ $options_sections = array();
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ $options_sections[$row[0]] = $row[1];
+ }
+ }
+
+ //showarray($options_sections);
+ $smarty->assign('options_sections', $options_sections);
+ $smarty->assign('section_value', reset($options_sections));
+
+ //
+ //Grab all objects for select box
+ //
+ $query = 'SELECT section_value,value,name FROM '. $table .' ORDER BY section_value,order_value,name';
+ $rs = $db->SelectLimit($query, $gacl_api->_max_select_box_items);
+
+ $js_array_name = 'options[\''. $group_type .'\']';
+ //Init the main aro js array.
+ $js_array = 'var options = new Array();' . "\n";
+ $js_array .= $js_array_name .' = new Array();' . "\n";
+
+ unset($tmp_section_value);
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ //list($section_value, $value, $name) = $row;
+
+ $section_value = addslashes($row[0]);
+ $value = addslashes($row[1]);
+ $name = addslashes($row[2]);
+
+ //Prepare javascript code for dynamic select box.
+ //Init the javascript sub-array.
+ if (!isset($tmp_section_value) OR $section_value != $tmp_section_value) {
+ $i = 0;
+ $js_array .= $js_array_name .'[\''. $section_value .'\'] = new Array();' . "\n";
+ }
+
+ //Add each select option for the section
+ $js_array .= $js_array_name .'[\''. $section_value .'\']['. $i .'] = new Array(\''. $value .'\', \''. $name ."');\n";
+
+ $tmp_section_value = $section_value;
+ $i++;
+ }
+ }
+
+ $smarty->assign('js_array', $js_array);
+ $smarty->assign('js_array_name', $group_type);
+
+ //Grab list of assigned Objects
+ $query = '
+ SELECT b.section_value,b.value,b.name AS b_name,c.name AS c_name
+ FROM '. $group_map_table .' a
+ INNER JOIN '. $table .' b ON b.id=a.'. $group_type .'_id
+ INNER JOIN '. $group_sections_table .' c ON c.value=b.section_value
+ WHERE a.group_id='. $db->qstr($_GET['group_id']) .'
+ ORDER BY c.name, b.name';
+ //$rs = $db->Execute($query);
+ $rs = $db->PageExecute($query, $gacl_api->_items_per_page, $_GET['page']);
+
+ $object_rows = array();
+
+ if (is_object($rs)) {
+ while ($row = $rs->FetchRow()) {
+ list($section_value, $value, $name, $section) = $row;
+
+ $object_rows[] = array(
+ 'section_value' => $row[0],
+ 'value' => $row[1],
+ 'name' => $row[2],
+ 'section' => $row[3]
+ );
+ }
+
+ $smarty->assign('total_objects', $rs->_maxRecordCount);
+
+ $smarty->assign('paging_data', $gacl_api->get_paging_data($rs));
+ }
+ //showarray($aros);
+
+ $smarty->assign('rows', $object_rows);
+
+ //Get group name.
+ $group_data = $gacl_api->get_group_data($_GET['group_id'], $group_type);
+ $smarty->assign('group_name', $group_data[2]);
+
+ $smarty->assign('group_id', $_GET['group_id']);
+
+ break;
+}
+
+$smarty->assign('group_type', $group_type);
+$smarty->assign('object_type', $object_type);
+$smarty->assign('return_page', $_SERVER['REQUEST_URI'] );
+
+$smarty->assign('current','assign_group_'. $group_type);
+$smarty->assign('page_title', 'Assign Group - '. strtoupper($group_type));
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version() );
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/assign_group.tpl');
+?>
diff --git a/html/phpgacl/admin/edit_group.php b/html/phpgacl/admin/edit_group.php
new file mode 100644
index 0000000..23a86d9
--- /dev/null
+++ b/html/phpgacl/admin/edit_group.php
@@ -0,0 +1,118 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+// GET takes precedence.
+if ($_GET['group_type'] == '') {
+ $group_type = $_POST['group_type'];
+} else {
+ $group_type = $_GET['group_type'];
+}
+
+if ($_GET['return_page'] == '') {
+ $return_page = $_POST['return_page'];
+} else {
+ $return_page = $_GET['return_page'];
+}
+
+switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $group_table = $gacl_api->_db_table_prefix . 'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $group_table = $gacl_api->_db_table_prefix . 'aro_groups';
+ break;
+}
+
+
+switch ($_POST['action']) {
+ case 'Delete':
+ $gacl_api->debug_text('Delete');
+
+ if (count($_POST['delete_group']) > 0) {
+ //Always reparent children when deleting a group.
+ foreach ($_POST['delete_group'] as $group_id) {
+ $gacl_api->debug_text('Deleting group_id: '. $group_id);
+
+ $result = $gacl_api->del_group($group_id, TRUE, $group_type);
+ if ($result == FALSE) {
+ $retry[] = $group_id;
+ }
+ }
+
+ if (count($retry) > 0) {
+ foreach($retry as $group_id) {
+ $gacl_api->del_group($group_id, TRUE, $group_type);
+ }
+ }
+
+ }
+
+ //Return page.
+ $gacl_api->return_page($return_page);
+ break;
+ case 'Submit':
+ $gacl_api->debug_text('Submit');
+
+ if (empty($_POST['parent_id'])) {
+ $parent_id = 0;
+ } else {
+ $parent_id = $_POST['parent_id'];
+ }
+
+ //Make sure we're not reparenting to ourself.
+ if (!empty($_POST['group_id']) AND $parent_id == $_POST['group_id']) {
+ echo "Sorry, can't reparent to self!<br />\n";
+ exit;
+ }
+
+ //No parent, assume a "root" group, generate a new parent id.
+ if (empty($_POST['group_id'])) {
+ $gacl_api->debug_text('Insert');
+
+ $insert_id = $gacl_api->add_group($_POST['value'], $_POST['name'], $parent_id, $group_type);
+ } else {
+ $gacl_api->debug_text('Update');
+
+ $gacl_api->edit_group($_POST['group_id'], $_POST['value'], $_POST['name'], $parent_id, $group_type);
+ }
+
+ $gacl_api->return_page($return_page);
+ break;
+ default:
+ //Grab specific group data
+ if (!empty($_GET['group_id'])) {
+ $query = '
+ SELECT id,parent_id,value,name
+ FROM '. $group_table .'
+ WHERE id='. (int)$_GET['group_id'];
+
+ list($id, $parent_id, $value, $name) = $db->GetRow($query);
+ //showarray($row);
+ } else {
+ $parent_id = $_GET['parent_id'];
+ $value = '';
+ $name = '';
+ }
+
+ $smarty->assign('id', $id);
+ $smarty->assign('parent_id', $parent_id);
+ $smarty->assign('value', $value);
+ $smarty->assign('name', $name);
+
+ $smarty->assign('options_groups', $gacl_api->format_groups($gacl_api->sort_groups($group_type)));
+ break;
+}
+
+$smarty->assign('group_type', $group_type);
+$smarty->assign('return_page', $return_page);
+
+$smarty->assign('current','edit_'. $group_type .'_group');
+$smarty->assign('page_title', 'Edit '. strtoupper($group_type) .' Group');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version());
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
+
+$smarty->display('phpgacl/edit_group.tpl');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/edit_object_sections.php b/html/phpgacl/admin/edit_object_sections.php
new file mode 100644
index 0000000..6c12115
--- /dev/null
+++ b/html/phpgacl/admin/edit_object_sections.php
@@ -0,0 +1,122 @@
+<?php
+require_once("gacl_admin.inc.php");
+
+//GET takes precedence.
+if ( isset($_GET['object_type']) AND $_GET['object_type'] != '' ) {
+ $object_type = $_GET['object_type'];
+} else {
+ $object_type = $_POST['object_type'];
+}
+
+switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'axo_sections';
+ break;
+ case 'acl':
+ $object_type = 'acl';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'acl_sections';
+ break;
+ default:
+ echo "ERROR: Must select an object type<br>\n";
+ exit();
+ break;
+}
+
+switch ($_POST['action']) {
+ case 'Delete':
+
+ if (count($_POST['delete_sections']) > 0) {
+ foreach($_POST['delete_sections'] as $id) {
+ $gacl_api->del_object_section($id, $object_type, TRUE);
+ }
+ }
+
+ //Return page.
+ $gacl_api->return_page($_POST['return_page']);
+
+ break;
+ case 'Submit':
+ $gacl_api->debug_text("Submit!!");
+
+ //Update sections
+ while (list(,$row) = @each($_POST['sections'])) {
+ list($id, $value, $order, $name) = $row;
+ $gacl_api->edit_object_section($id, $name, $value, $order,0,$object_type );
+ }
+ unset($id);
+ unset($value);
+ unset($order);
+ unset($name);
+
+ //Insert new sections
+ while (list(,$row) = @each($_POST['new_sections'])) {
+ list($value, $order, $name) = $row;
+
+ if (!empty($value) AND !empty($order) AND !empty($name)) {
+
+ $object_section_id = $gacl_api->add_object_section($name, $value, $order, 0, $object_type);
+ $gacl_api->debug_text("Section ID: $object_section_id");
+ }
+ }
+ $gacl_api->debug_text("return_page: ". $_POST['return_page']);
+ $gacl_api->return_page($_POST['return_page']);
+
+ break;
+ default:
+ $query = "select id,value,order_value,name from $object_sections_table order by order_value";
+
+ $rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
+ $rows = $rs->GetRows();
+
+ $sections = array();
+
+ while (list(,$row) = @each($rows)) {
+ list($id, $value, $order_value, $name) = $row;
+
+ $sections[] = array(
+ 'id' => $id,
+ 'value' => $value,
+ 'order' => $order_value,
+ 'name' => $name
+ );
+ }
+
+ $new_sections = array();
+
+ for($i=0; $i < 5; $i++) {
+ $new_sections[] = array(
+ 'id' => $i,
+ 'value' => NULL,
+ 'order' => NULL,
+ 'name' => NULL
+ );
+ }
+
+ $smarty->assign('sections', $sections);
+ $smarty->assign('new_sections', $new_sections);
+
+ $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
+
+ break;
+}
+
+$smarty->assign('object_type', $object_type);
+$smarty->assign('return_page', $_SERVER['REQUEST_URI']);
+
+$smarty->assign('current','edit_'. $object_type .'_sections');
+$smarty->assign('page_title', 'Edit '. strtoupper($object_type) .' Sections');
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/edit_object_sections.tpl');
+?>
diff --git a/html/phpgacl/admin/edit_objects.php b/html/phpgacl/admin/edit_objects.php
new file mode 100644
index 0000000..90a2f62
--- /dev/null
+++ b/html/phpgacl/admin/edit_objects.php
@@ -0,0 +1,131 @@
+<?php
+require_once("gacl_admin.inc.php");
+
+//GET takes precedence.
+if ($_GET['object_type'] != '') {
+ $object_type = $_GET['object_type'];
+} else {
+ $object_type = $_POST['object_type'];
+}
+
+switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $object_table = $gacl_api->_db_table_prefix . 'aco';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $object_table = $gacl_api->_db_table_prefix . 'aro';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $object_table = $gacl_api->_db_table_prefix . 'axo';
+ $object_sections_table = $gacl_api->_db_table_prefix . 'axo_sections';
+ break;
+ default:
+ echo "ERROR: Must select an object type<br>\n";
+ exit();
+ break;
+}
+
+switch ($_POST['action']) {
+ case 'Delete':
+
+ if (count($_POST['delete_object']) > 0) {
+ foreach($_POST['delete_object'] as $id) {
+ $gacl_api->del_object($id, $object_type, TRUE);
+ }
+ }
+
+ //Return page.
+ $gacl_api->return_page($_POST['return_page']);
+
+ break;
+ case 'Submit':
+ $gacl_api->debug_text("Submit!!");
+
+ //Update objects
+ while (list(,$row) = @each($_POST['objects'])) {
+ list($id, $value, $order, $name) = $row;
+ $gacl_api->edit_object($id, $_POST['section_value'], $name, $value, $order, 0, $object_type);
+ }
+ unset($id);
+ unset($section_value);
+ unset($value);
+ unset($order);
+ unset($name);
+
+ //Insert new sections
+ while (list(,$row) = @each($_POST['new_objects'])) {
+ list($value, $order, $name) = $row;
+
+ if (!empty($value) AND !empty($name)) {
+ $object_id= $gacl_api->add_object($_POST['section_value'], $name, $value, $order, 0, $object_type);
+ }
+ }
+ $gacl_api->debug_text("return_page: ". $_POST['return_page']);
+ $gacl_api->return_page($_POST['return_page']);
+
+ break;
+ default:
+ //Grab section name
+ $query = "select name from $object_sections_table where value = '". $_GET['section_value'] ."'";
+ $section_name = $db->GetOne($query);
+
+ $query = "select
+ id,
+ section_value,
+ value,
+ order_value,
+ name
+ from $object_table
+ where section_value='". $_GET['section_value'] ."'
+ order by order_value";
+ $rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
+ $rows = $rs->GetRows();
+
+ while (list(,$row) = @each($rows)) {
+ list($id, $section_value, $value, $order_value, $name) = $row;
+
+ $objects[] = array(
+ 'id' => $id,
+ 'section_value' => $section_value,
+ 'value' => $value,
+ 'order' => $order_value,
+ 'name' => $name
+ );
+ }
+
+ for($i=0; $i < 5; $i++) {
+ $new_objects[] = array(
+ 'id' => $i,
+ 'section_value' => NULL,
+ 'value' => NULL,
+ 'order' => NULL,
+ 'name' => NULL
+ );
+ }
+
+ $smarty->assign('objects', $objects);
+ $smarty->assign('new_objects', $new_objects);
+
+ $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
+
+ break;
+}
+
+$smarty->assign('section_value', stripslashes($_GET['section_value']));
+$smarty->assign('section_name', $section_name);
+$smarty->assign('object_type', $object_type);
+$smarty->assign('return_page', $_SERVER['REQUEST_URI']);
+
+$smarty->assign('current','edit_'. $object_type .'s');
+$smarty->assign('page_title', 'Edit '. strtoupper($object_type) .' Objects');
+
+$smarty->assign("phpgacl_version", $gacl_api->get_version() );
+$smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
+
+$smarty->display('phpgacl/edit_objects.tpl');
+?>
diff --git a/html/phpgacl/admin/gacl_admin.inc.php b/html/phpgacl/admin/gacl_admin.inc.php
new file mode 100644
index 0000000..66e5900
--- /dev/null
+++ b/html/phpgacl/admin/gacl_admin.inc.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ * phpGACL - Generic Access Control List
+ * Copyright (C) 2002 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ */
+
+require_once(dirname(__FILE__).'/../gacl.class.php');
+require_once(dirname(__FILE__).'/../gacl_api.class.php');
+require_once(dirname(__FILE__).'/gacl_admin_api.class.php');
+
+// phpGACL Configuration file.
+if ( !isset($config_file) ) {
+# $config_file = '../gacl.ini.php';
+ $config_file = dirname(__FILE__).'/../gacl.ini.php';
+}
+
+//Values supplied in $gacl_options array overwrite those in the config file.
+if ( file_exists($config_file) ) {
+ $config = parse_ini_file($config_file);
+
+ if ( is_array($config) ) {
+ if ( isset($gacl_options) ) {
+ $gacl_options = array_merge($config, $gacl_options);
+ } else {
+ $gacl_options = $config;
+ }
+ }
+ unset($config);
+}
+
+$gacl_api = new gacl_admin_api($gacl_options);
+
+$gacl = &$gacl_api;
+
+$db = &$gacl->db;
+
+//Setup the Smarty Class.
+require_once($gacl_options['smarty_dir'].'/Smarty.class.php');
+
+$smarty = new Smarty;
+$smarty->compile_check = TRUE;
+$smarty->template_dir = $gacl_options['smarty_template_dir'];
+$smarty->compile_dir = $gacl_options['smarty_compile_dir'];
+
+/*
+ * Email address used in setup.php, please do not change.
+ */
+$author_email = 'ipso@snappymail.ca';
+
+/*
+ * Don't need to show notices, some of them are pretty lame and people get overly worried when they see them.
+ * Mean while I will try to fix most of these. ;) Please submit patches if you find any I may have missed.
+ */
+error_reporting (E_ALL ^ E_NOTICE);
+
+?>
diff --git a/html/phpgacl/admin/gacl_admin_api.class.php b/html/phpgacl/admin/gacl_admin_api.class.php
new file mode 100644
index 0000000..400dc08
--- /dev/null
+++ b/html/phpgacl/admin/gacl_admin_api.class.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * phpGACL - Generic Access Control List
+ * Copyright (C) 2002,2003 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ * @package phpGACL
+ *
+ */
+
+/*
+ *
+ * For examples, see example.php or the Administration interface,
+ * as it makes use of nearly every API Call.
+ *
+ */
+/**
+ * gacl_admin_api Custom Extended API Class
+ *
+ * Class gacl_api should be used for applications that must interface directly with
+ * phpGACL's data structures, objects, and rules.
+ *
+ * @package phpGACL
+ * @author Mike Benoit <ipso@snappymail.ca>
+ *
+ */
+
+class gacl_admin_api extends gacl_api {
+
+ /*
+ * Administration interface settings
+ */
+ /** @var int Number of items to display per page in the phpGACL interface. */
+ var $_items_per_page = 100;
+ /** @var int Maximum number of items to display in a select box. Override to manage large collections via ACL Admin */
+ var $_max_select_box_items = 100;
+ /** @var int Maximum number of items to return in an ACL Search. */
+ var $_max_search_return_items = 100;
+
+ /*
+ *
+ * Misc admin functions.
+ *
+ */
+
+ /**
+ * return_page()
+ *
+ * Sends the user back to a passed URL, unless debug is enabled, then we don't redirect.
+ * If no URL is passed, try the REFERER
+ * @param string URL to return to.
+ */
+ function return_page($url="") {
+ global $_SERVER, $debug;
+
+ if (empty($url) AND !empty($_SERVER[HTTP_REFERER])) {
+ $this->debug_text("return_page(): URL not set, using referer!");
+ $url = $_SERVER[HTTP_REFERER];
+ }
+
+ if (!$debug OR $debug==0) {
+ header("Location: $url\n\n");
+ } else {
+ $this->debug_text("return_page(): URL: $url -- Referer: $_SERVER[HTTP_REFERRER]");
+ }
+ }
+
+ /**
+ * get_paging_data()
+ *
+ * Creates a basic array for Smarty to deal with paging large recordsets.
+ *
+ * @param ADORecordSet ADODB recordset.
+ */
+ function get_paging_data($rs) {
+ return array(
+ 'prevpage' => $rs->absolutepage() - 1,
+ 'currentpage' => $rs->absolutepage(),
+ 'nextpage' => $rs->absolutepage() + 1,
+ 'atfirstpage' => $rs->atfirstpage(),
+ 'atlastpage' => $rs->atlastpage(),
+ 'lastpageno' => $rs->lastpageno()
+ );
+ }
+
+}
+?>
diff --git a/html/phpgacl/admin/group_admin.php b/html/phpgacl/admin/group_admin.php
new file mode 100644
index 0000000..2135879
--- /dev/null
+++ b/html/phpgacl/admin/group_admin.php
@@ -0,0 +1,80 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+//GET takes precedence.
+if ($_GET['group_type'] != '') {
+ $group_type = $_GET['group_type'];
+} else {
+ $group_type = $_POST['group_type'];
+}
+
+switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $group_table = $gacl_api->_db_table_prefix . 'axo_groups';
+ $group_map_table = $gacl_api->_db_table_prefix . 'groups_axo_map';
+ $smarty->assign('current','axo_group');
+ break;
+ default:
+ $group_type = 'aro';
+ $group_table = $gacl_api->_db_table_prefix . 'aro_groups';
+ $group_map_table = $gacl_api->_db_table_prefix . 'groups_aro_map';
+ $smarty->assign('current','aro_group');
+ break;
+}
+
+switch ($_POST['action']) {
+ case 'Delete':
+ //See edit_group.php
+ break;
+ default:
+ $formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups($group_type), HTML);
+
+ $query = '
+ SELECT a.id, a.name, a.value, count(b.'. $group_type .'_id)
+ FROM '. $group_table .' a
+ LEFT JOIN '. $group_map_table .' b ON b.group_id=a.id
+ GROUP BY a.id,a.name,a.value';
+ $rs = $db->Execute($query);
+
+ $group_data = array();
+
+ if(is_object($rs)) {
+ while($row = $rs->FetchRow()) {
+ $group_data[$row[0]] = array(
+ 'name' => $row[1],
+ 'value' => $row[2],
+ 'count' => $row[3]
+ );
+ }
+ }
+
+ $groups = array();
+
+ foreach($formatted_groups as $id => $name) {
+ $groups[] = array(
+ 'id' => $id,
+ // 'parent_id' => $parent_id,
+ // 'family_id' => $family_id,
+ 'name' => $name,
+ 'raw_name' => $group_data[$id]['name'],
+ 'value' => $group_data[$id]['value'],
+ 'object_count' => $group_data[$id]['count']
+ );
+ }
+
+ $smarty->assign('groups', $groups);
+ break;
+}
+
+$smarty->assign('group_type', $group_type);
+$smarty->assign('return_page', $_SERVER['REQUEST_URI']);
+
+$smarty->assign('current', $group_type .'_group');
+$smarty->assign('page_title', strtoupper($group_type) .' Group Admin');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version());
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
+
+$smarty->display('phpgacl/group_admin.tpl');
+?>
diff --git a/html/phpgacl/admin/images/bot-l.png b/html/phpgacl/admin/images/bot-l.png
new file mode 100644
index 0000000..76f8ddb
--- /dev/null
+++ b/html/phpgacl/admin/images/bot-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/bot-r.png b/html/phpgacl/admin/images/bot-r.png
new file mode 100644
index 0000000..c76f92e
--- /dev/null
+++ b/html/phpgacl/admin/images/bot-r.png
Binary files differ
diff --git a/html/phpgacl/admin/images/div-l.png b/html/phpgacl/admin/images/div-l.png
new file mode 100644
index 0000000..0a70f84
--- /dev/null
+++ b/html/phpgacl/admin/images/div-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/div-r.png b/html/phpgacl/admin/images/div-r.png
new file mode 100644
index 0000000..f0c8cd6
--- /dev/null
+++ b/html/phpgacl/admin/images/div-r.png
Binary files differ
diff --git a/html/phpgacl/admin/images/logo.png b/html/phpgacl/admin/images/logo.png
new file mode 100644
index 0000000..4e78430
--- /dev/null
+++ b/html/phpgacl/admin/images/logo.png
Binary files differ
diff --git a/html/phpgacl/admin/images/mid-l.png b/html/phpgacl/admin/images/mid-l.png
new file mode 100644
index 0000000..62f89d6
--- /dev/null
+++ b/html/phpgacl/admin/images/mid-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/mid-r.png b/html/phpgacl/admin/images/mid-r.png
new file mode 100644
index 0000000..d6ea7fc
--- /dev/null
+++ b/html/phpgacl/admin/images/mid-r.png
Binary files differ
diff --git a/html/phpgacl/admin/images/spacer.gif b/html/phpgacl/admin/images/spacer.gif
new file mode 100644
index 0000000..5bfd67a
--- /dev/null
+++ b/html/phpgacl/admin/images/spacer.gif
Binary files differ
diff --git a/html/phpgacl/admin/images/tab-off-l.png b/html/phpgacl/admin/images/tab-off-l.png
new file mode 100644
index 0000000..adf7ceb
--- /dev/null
+++ b/html/phpgacl/admin/images/tab-off-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/tab-off-r.png b/html/phpgacl/admin/images/tab-off-r.png
new file mode 100644
index 0000000..3e318b4
--- /dev/null
+++ b/html/phpgacl/admin/images/tab-off-r.png
Binary files differ
diff --git a/html/phpgacl/admin/images/tab-on-l.png b/html/phpgacl/admin/images/tab-on-l.png
new file mode 100644
index 0000000..3f25abd
--- /dev/null
+++ b/html/phpgacl/admin/images/tab-on-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/tab-on-r.png b/html/phpgacl/admin/images/tab-on-r.png
new file mode 100644
index 0000000..81c9bc1
--- /dev/null
+++ b/html/phpgacl/admin/images/tab-on-r.png
Binary files differ
diff --git a/html/phpgacl/admin/images/top-l.png b/html/phpgacl/admin/images/top-l.png
new file mode 100644
index 0000000..ae2a8db
--- /dev/null
+++ b/html/phpgacl/admin/images/top-l.png
Binary files differ
diff --git a/html/phpgacl/admin/images/top-r.png b/html/phpgacl/admin/images/top-r.png
new file mode 100644
index 0000000..9c58575
--- /dev/null
+++ b/html/phpgacl/admin/images/top-r.png
Binary files differ
diff --git a/html/phpgacl/admin/index.php b/html/phpgacl/admin/index.php
new file mode 100644
index 0000000..5818000
--- /dev/null
+++ b/html/phpgacl/admin/index.php
@@ -0,0 +1,3 @@
+<?php
+header('Location: acl_admin.php');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/junktest.php b/html/phpgacl/admin/junktest.php
new file mode 100644
index 0000000..6e0ad1b
--- /dev/null
+++ b/html/phpgacl/admin/junktest.php
@@ -0,0 +1,44 @@
+<?php
+#require_once('gacl_admin.inc.php');
+require_once(dirname(__FILE__).'/../gacl.class.php');
+require_once(dirname(__FILE__).'/../gacl_api.class.php');
+require_once(dirname(__FILE__).'/gacl_admin_api.class.php');
+
+// phpGACL Configuration file.
+if ( !isset($config_file) ) {
+# $config_file = '../gacl.ini.php';
+ $config_file = dirname(__FILE__).'/../gacl.ini.php';
+}
+
+//Values supplied in $gacl_options array overwrite those in the config file.
+if ( file_exists($config_file) ) {
+ $config = parse_ini_file($config_file);
+
+ if ( is_array($config) ) {
+ if ( isset($gacl_options) ) {
+ $gacl_options = array_merge($config, $gacl_options);
+ } else {
+ $gacl_options = $config;
+ }
+ }
+ unset($config);
+}
+$gacl_api = new gacl_admin_api($gacl_options);
+
+
+$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups('aro'), HTML);
+
+foreach($formatted_groups as $id => $name) {
+ print "ID: $id Name: $name RawName: ".$group_data[$id]['name']."<br>";
+ $groups[] = array(
+ 'id' => $id,
+ // 'parent_id' => $parent_id,
+ // 'family_id' => $family_id,
+ 'name' => $name,
+ 'raw_name' => $group_data[$id]['name'],
+ 'value' => $group_data[$id]['value'],
+ 'object_count' => $group_data[$id]['count']
+ );
+ }
+
+?>
diff --git a/html/phpgacl/admin/object_search.php b/html/phpgacl/admin/object_search.php
new file mode 100644
index 0000000..bec1d30
--- /dev/null
+++ b/html/phpgacl/admin/object_search.php
@@ -0,0 +1,102 @@
+<?php
+require_once('gacl_admin.inc.php');
+
+switch (strtolower($_GET['object_type'])) {
+ case 'axo':
+ $object_type = 'axo';
+ break;
+ default:
+ $object_type = 'aro';
+}
+
+switch ($_GET['action']) {
+ case 'Search':
+ $gacl_api->debug_text('Submit!!');
+
+ //Function to pass array_walk to trim all entries in an array.
+ function array_walk_trim(&$array_field) {
+ $array_field = $db->qstr(strtolower(trim($array_field)));
+ }
+
+ $value_search_str = trim($_GET['value_search_str']);
+ $name_search_str = trim($_GET['name_search_str']);
+
+ $exploded_value_search_str = explode("\n", $value_search_str);
+ $exploded_name_search_str = explode("\n", $name_search_str);
+
+ if (count($exploded_value_search_str) > 1 OR count($exploded_name_search_str) > 1) {
+ //Given a list, lets try to match all lines in it.
+ array_walk($exploded_value_search_str, 'array_walk_trim');
+ array_walk($exploded_name_search_str, 'array_walk_trim');
+ } else {
+ if ($value_search_str != '') {
+ $value_search_str .= '%';
+ }
+
+ if ($name_search_str != '') {
+ $name_search_str .= '%';
+ }
+ }
+
+ //Search
+ $query = '
+ SELECT section_value,value,name
+ FROM '. $gacl_api->_db_table_prefix . $object_type .'
+ WHERE section_value='. $db->qstr($_GET['section_value']) .'
+ AND (';
+
+ if (count($exploded_value_search_str) > 1) {
+ $query .= 'lower(value) IN ('. implode(',', $exploded_value_search_str) .')';
+ } else {
+ $query .= 'lower(value) LIKE ' . $db->qstr($value_search_str);
+ }
+
+ $query .= ' OR ';
+
+ if (count($exploded_name_search_str) > 1) {
+ $query .= 'lower(name) IN ('. implode(',', $exploded_name_search_str) .')';
+ } else {
+ $query .= 'lower(name) LIKE ' . $db->qstr($name_search_str);
+ }
+
+ $query .= ')
+ ORDER BY section_value,order_value,name';
+ $rs = $db->SelectLimit($query, $gacl_api->_max_search_return_items);
+
+ $options_objects = array();
+ $total_rows = 0;
+
+ if (is_object($rs)) {
+ $total_rows = $rs->RecordCount();
+
+ while ($row = $rs->FetchRow()) {
+ list($section_value, $value, $name) = $row;
+ $options_objects[$value] = $name;
+ }
+ }
+
+ $smarty->assign('options_objects', $options_objects);
+ $smarty->assign('total_rows', $total_rows);
+
+ $smarty->assign('value_search_str', $_GET['value_search_str']);
+ $smarty->assign('name_search_str', $_GET['name_search_str']);
+
+ //break;
+ default:
+ $smarty->assign('src_form', $_GET['src_form']);
+ $smarty->assign('section_value', $_GET['section_value']);
+ $smarty->assign('section_value_name', ucfirst($_GET['section_value']));
+ $smarty->assign('object_type', $object_type);
+ $smarty->assign('object_type_name', strtoupper($object_type));
+
+ break;
+}
+
+$smarty->assign('current', $object_type .'_search');
+$smarty->assign('page_title', strtoupper($object_type) .' Search');
+
+$smarty->assign('phpgacl_version', $gacl_api->get_version());
+$smarty->assign('phpgacl_schema_version', $gacl_api->get_schema_version());
+
+$smarty->display('phpgacl/object_search.tpl');
+?> \ No newline at end of file
diff --git a/html/phpgacl/admin/s.gif b/html/phpgacl/admin/s.gif
new file mode 100644
index 0000000..5035948
--- /dev/null
+++ b/html/phpgacl/admin/s.gif
Binary files differ
diff --git a/html/phpgacl/admin/smarty_x/README b/html/phpgacl/admin/smarty_x/README
new file mode 100644
index 0000000..7d3e56e
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/README
@@ -0,0 +1,80 @@
+NAME:
+
+ Smarty - the PHP compiling template engine
+
+VERSION: 2.6.0
+
+AUTHORS:
+
+ Monte Ohrt <monte at ohrt dot com>
+ Andrei Zmievski <andrei@php.net>
+
+MAILING LISTS:
+
+ We have a few mailing lists. "general" for you to share your ideas or ask
+ questions, "dev" for those interested in the development efforts of Smarty,
+ and "cvs" for those that would like to track the updates made in the cvs
+ repository.
+
+ send a blank e-mail message to:
+ smarty-general-subscribe@lists.php.net (subscribe to the general list)
+ smarty-general-unsubscribe@lists.php.net (unsubscribe from the general list)
+ smarty-general-digest-subscribe@lists.php.net (subscribe to digest)
+ smarty-general-digest-unsubscribe@lists.php.net (unsubscribe from digest)
+ smarty-dev-subscribe@lists.php.net (subscribe to the dev list)
+ smarty-dev-unsubscribe@lists.php.net (unsubscribe from the dev list)
+ smarty-cvs-subscribe@lists.php.net (subscribe to the cvs list)
+ smarty-cvs-unsubscribe@lists.php.net (unsubscribe from the cvs list)
+ You can also browse the mailing list archives at
+ http://marc.theaimsgroup.com/?l=smarty&r=1&w=2
+
+SYNOPSIS:
+
+ require("Smarty.class.php");
+
+ $smarty = new Smarty;
+
+ $smarty->assign("Title","My Homepage");
+ $smarty->assign("Names",array("John","Gary","Gregg","James"));
+
+ $smarty->display("index.tpl");
+
+
+DESCRIPTION:
+
+ What is Smarty?
+
+ Smarty is a template engine for PHP. Many other template engines for PHP
+ provide basic variable substitution and dynamic block functionality.
+ Smarty takes a step further to be a "smart" template engine, adding
+ features such as configuration files, template functions, and variable
+ modifiers, and making all of this functionality as easy as possible to
+ use for both programmers and template designers. Smarty also converts
+ the templates into PHP scripts, eliminating the need to parse the
+ templates on every invocation. This makes Smarty extremely scalable and
+ manageable for large application needs.
+
+ Some of Smarty's features:
+
+ * it is extremely fast
+ * no template parsing overhead, only compiles once.
+ * it is smart about recompiling only the template files that have
+ changed.
+ * the template language is remarkably extensible via the plugin
+ architecture.
+ * configurable template delimiter tag syntax, so you can use
+ {}, {{}}, <!--{}-->, or whatever you like.
+ * built-in caching of template output.
+ * arbitrary template sources (filesystem, databases, etc.)
+ * template if/elseif/else/endif constructs are passed to the PHP parser,
+ so the if syntax can be as simple or as complex as you like.
+ * unlimited nesting of sections, conditionals, etc. allowed
+ * it is possible to embed PHP code right in your template files,
+ although not recommended and doubtfully needed since the engine
+ is so customizable.
+ * and many more.
+
+COPYRIGHT:
+ Copyright (c) 2001-2005 New Digital Group, Inc. All rights reserved.
+ This software is released under the GNU Lesser General Public License.
+ Please read the disclaimer at the top of the Smarty.class.php file.
diff --git a/html/phpgacl/admin/smarty_x/libs/Config_File.class.php b/html/phpgacl/admin/smarty_x/libs/Config_File.class.php
new file mode 100644
index 0000000..7892820
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/Config_File.class.php
@@ -0,0 +1,389 @@
+<?php
+
+/**
+ * Config_File class.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @link http://smarty.php.net/
+ * @version 2.6.9
+ * @copyright Copyright: 2001-2005 New Digital Group, Inc.
+ * @author Andrei Zmievski <andrei@php.net>
+ * @access public
+ * @package Smarty
+ */
+
+/* $Id: Config_File.class.php,v 1.8 2005/07/24 19:57:45 ipso Exp $ */
+
+/**
+ * Config file reading class
+ * @package Smarty
+ */
+class Config_File {
+ /**#@+
+ * Options
+ * @var boolean
+ */
+ /**
+ * Controls whether variables with the same name overwrite each other.
+ */
+ var $overwrite = true;
+
+ /**
+ * Controls whether config values of on/true/yes and off/false/no get
+ * converted to boolean values automatically.
+ */
+ var $booleanize = true;
+
+ /**
+ * Controls whether hidden config sections/vars are read from the file.
+ */
+ var $read_hidden = true;
+
+ /**
+ * Controls whether or not to fix mac or dos formatted newlines.
+ * If set to true, \r or \r\n will be changed to \n.
+ */
+ var $fix_newlines = true;
+ /**#@-*/
+
+ /** @access private */
+ var $_config_path = "";
+ var $_config_data = array();
+ /**#@-*/
+
+ /**
+ * Constructs a new config file class.
+ *
+ * @param string $config_path (optional) path to the config files
+ */
+ function Config_File($config_path = NULL)
+ {
+ if (isset($config_path))
+ $this->set_path($config_path);
+ }
+
+
+ /**
+ * Set the path where configuration files can be found.
+ *
+ * @param string $config_path path to the config files
+ */
+ function set_path($config_path)
+ {
+ if (!empty($config_path)) {
+ if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
+ $this->_trigger_error_msg("Bad config file path '$config_path'");
+ return;
+ }
+ if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
+ $config_path .= DIRECTORY_SEPARATOR;
+ }
+
+ $this->_config_path = $config_path;
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the file, section, and variable name.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @param string $var_name (optional) variable to get info for
+ * @return string|array a value or array of values
+ */
+ function &get($file_name, $section_name = NULL, $var_name = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name]))
+ $this->load_file($file_name, false);
+ }
+
+ if (!empty($var_name)) {
+ if (empty($section_name)) {
+ return $this->_config_data[$file_name]["vars"][$var_name];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
+ return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
+ else
+ return array();
+ }
+ } else {
+ if (empty($section_name)) {
+ return (array)$this->_config_data[$file_name]["vars"];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
+ return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
+ else
+ return array();
+ }
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the key.
+ *
+ * @param $file_name string config key (filename/section/var)
+ * @return string|array same as get()
+ * @uses get() retrieves information from config file and returns it
+ */
+ function &get_key($config_key)
+ {
+ list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
+ $result = &$this->get($file_name, $section_name, $var_name);
+ return $result;
+ }
+
+ /**
+ * Get all loaded config file names.
+ *
+ * @return array an array of loaded config file names
+ */
+ function get_file_names()
+ {
+ return array_keys($this->_config_data);
+ }
+
+
+ /**
+ * Get all section names from a loaded file.
+ *
+ * @param string $file_name config file to get section names from
+ * @return array an array of section names from the specified file
+ */
+ function get_section_names($file_name)
+ {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ return array_keys($this->_config_data[$file_name]["sections"]);
+ }
+
+
+ /**
+ * Get all global or section variable names.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @return array an array of variables names from the specified file/section
+ */
+ function get_var_names($file_name, $section = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ if (empty($section))
+ return array_keys($this->_config_data[$file_name]["vars"]);
+ else
+ return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
+ }
+
+
+ /**
+ * Clear loaded config data for a certain file or all files.
+ *
+ * @param string $file_name file to clear config data for
+ */
+ function clear($file_name = NULL)
+ {
+ if ($file_name === NULL)
+ $this->_config_data = array();
+ else if (isset($this->_config_data[$file_name]))
+ $this->_config_data[$file_name] = array();
+ }
+
+
+ /**
+ * Load a configuration file manually.
+ *
+ * @param string $file_name file name to load
+ * @param boolean $prepend_path whether current config path should be
+ * prepended to the filename
+ */
+ function load_file($file_name, $prepend_path = true)
+ {
+ if ($prepend_path && $this->_config_path != "")
+ $config_file = $this->_config_path . $file_name;
+ else
+ $config_file = $file_name;
+
+ ini_set('track_errors', true);
+ $fp = @fopen($config_file, "r");
+ if (!is_resource($fp)) {
+ $this->_trigger_error_msg("Could not open config file '$config_file'");
+ return false;
+ }
+
+ $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
+ fclose($fp);
+
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * Store the contents of a file manually.
+ *
+ * @param string $config_file file name of the related contents
+ * @param string $contents the file-contents to parse
+ */
+ function set_file_contents($config_file, $contents)
+ {
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * parse the source of a configuration file manually.
+ *
+ * @param string $contents the file-contents to parse
+ */
+ function parse_contents($contents)
+ {
+ if($this->fix_newlines) {
+ // fix mac/dos formatted newlines
+ $contents = preg_replace('!\r\n?!', "\n", $contents);
+ }
+
+ $config_data = array();
+ $config_data['sections'] = array();
+ $config_data['vars'] = array();
+
+ /* reference to fill with data */
+ $vars =& $config_data['vars'];
+
+ /* parse file line by line */
+ preg_match_all('!^.*\r?\n?!m', $contents, $match);
+ $lines = $match[0];
+ for ($i=0, $count=count($lines); $i<$count; $i++) {
+ $line = $lines[$i];
+ if (empty($line)) continue;
+
+ if ( $line{0} == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
+ /* section found */
+ if ($match[1]{0} == '.') {
+ /* hidden section */
+ if ($this->read_hidden) {
+ $section_name = substr($match[1], 1);
+ } else {
+ /* break reference to $vars to ignore hidden section */
+ unset($vars);
+ $vars = array();
+ continue;
+ }
+ } else {
+ $section_name = $match[1];
+ }
+ if (!isset($config_data['sections'][$section_name]))
+ $config_data['sections'][$section_name] = array('vars' => array());
+ $vars =& $config_data['sections'][$section_name]['vars'];
+ continue;
+ }
+
+ if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
+ /* variable found */
+ $var_name = rtrim($match[1]);
+ if (strpos($match[2], '"""') === 0) {
+ /* handle multiline-value */
+ $lines[$i] = substr($match[2], 3);
+ $var_value = '';
+ while ($i<$count) {
+ if (($pos = strpos($lines[$i], '"""')) === false) {
+ $var_value .= $lines[$i++];
+ } else {
+ /* end of multiline-value */
+ $var_value .= substr($lines[$i], 0, $pos);
+ break;
+ }
+ }
+ $booleanize = false;
+
+ } else {
+ /* handle simple value */
+ $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
+ $booleanize = $this->booleanize;
+
+ }
+ $this->_set_config_var($vars, $var_name, $var_value, $booleanize);
+ }
+ /* else unparsable line / means it is a comment / means ignore it */
+ }
+ return $config_data;
+ }
+
+ /**#@+ @access private */
+ /**
+ * @param array &$container
+ * @param string $var_name
+ * @param mixed $var_value
+ * @param boolean $booleanize determines whether $var_value is converted to
+ * to true/false
+ */
+ function _set_config_var(&$container, $var_name, $var_value, $booleanize)
+ {
+ if ($var_name{0} == '.') {
+ if (!$this->read_hidden)
+ return;
+ else
+ $var_name = substr($var_name, 1);
+ }
+
+ if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
+ $this->_trigger_error_msg("Bad variable name '$var_name'");
+ return;
+ }
+
+ if ($booleanize) {
+ if (preg_match("/^(on|true|yes)$/i", $var_value))
+ $var_value = true;
+ else if (preg_match("/^(off|false|no)$/i", $var_value))
+ $var_value = false;
+ }
+
+ if (!isset($container[$var_name]) || $this->overwrite)
+ $container[$var_name] = $var_value;
+ else {
+ settype($container[$var_name], 'array');
+ $container[$var_name][] = $var_value;
+ }
+ }
+
+ /**
+ * @uses trigger_error() creates a PHP warning/error
+ * @param string $error_msg
+ * @param integer $error_type one of
+ */
+ function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Config_File error: $error_msg", $error_type);
+ }
+ /**#@-*/
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/Smarty.class.php b/html/phpgacl/admin/smarty_x/libs/Smarty.class.php
new file mode 100644
index 0000000..86236e5
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/Smarty.class.php
@@ -0,0 +1,1934 @@
+<?php
+
+/**
+ * Project: Smarty: the PHP compiling template engine
+ * File: Smarty.class.php
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * Smarty mailing list. Send a blank e-mail to
+ * smarty-general-subscribe@lists.php.net
+ *
+ * @link http://smarty.php.net/
+ * @copyright 2001-2005 New Digital Group, Inc.
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Andrei Zmievski <andrei@php.net>
+ * @package Smarty
+ * @version 2.6.9
+ */
+
+/* $Id: Smarty.class.php,v 1.9 2005/07/24 19:57:46 ipso Exp $ */
+
+/**
+ * DIR_SEP isn't used anymore, but third party apps might
+ */
+if(!defined('DIR_SEP')) {
+ define('DIR_SEP', DIRECTORY_SEPARATOR);
+}
+
+/**
+ * set SMARTY_DIR to absolute path to Smarty library files.
+ * if not defined, include_path will be used. Sets SMARTY_DIR only if user
+ * application has not already defined it.
+ */
+
+if (!defined('SMARTY_DIR')) {
+ define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+}
+
+if (!defined('SMARTY_CORE_DIR')) {
+ define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
+}
+
+define('SMARTY_PHP_PASSTHRU', 0);
+define('SMARTY_PHP_QUOTE', 1);
+define('SMARTY_PHP_REMOVE', 2);
+define('SMARTY_PHP_ALLOW', 3);
+
+/**
+ * @package Smarty
+ */
+class Smarty
+{
+ /**#@+
+ * Smarty Configuration Section
+ */
+
+ /**
+ * The name of the directory where templates are located.
+ *
+ * @var string
+ */
+ var $template_dir = 'templates';
+
+ /**
+ * The directory where compiled templates are located.
+ *
+ * @var string
+ */
+ var $compile_dir = 'templates_c';
+
+ /**
+ * The directory where config files are located.
+ *
+ * @var string
+ */
+ var $config_dir = 'configs';
+
+ /**
+ * An array of directories searched for plugins.
+ *
+ * @var array
+ */
+ var $plugins_dir = array('plugins');
+
+ /**
+ * If debugging is enabled, a debug console window will display
+ * when the page loads (make sure your browser allows unrequested
+ * popup windows)
+ *
+ * @var boolean
+ */
+ var $debugging = false;
+
+ /**
+ * When set, smarty does uses this value as error_reporting-level.
+ *
+ * @var boolean
+ */
+ var $error_reporting = null;
+
+ /**
+ * This is the path to the debug console template. If not set,
+ * the default one will be used.
+ *
+ * @var string
+ */
+ var $debug_tpl = '';
+
+ /**
+ * This determines if debugging is enable-able from the browser.
+ * <ul>
+ * <li>NONE => no debugging control allowed</li>
+ * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
+ * </ul>
+ * @link http://www.foo.dom/index.php?SMARTY_DEBUG
+ * @var string
+ */
+ var $debugging_ctrl = 'NONE';
+
+ /**
+ * This tells Smarty whether to check for recompiling or not. Recompiling
+ * does not need to happen unless a template or config file is changed.
+ * Typically you enable this during development, and disable for
+ * production.
+ *
+ * @var boolean
+ */
+ var $compile_check = true;
+
+ /**
+ * This forces templates to compile every time. Useful for development
+ * or debugging.
+ *
+ * @var boolean
+ */
+ var $force_compile = false;
+
+ /**
+ * This enables template caching.
+ * <ul>
+ * <li>0 = no caching</li>
+ * <li>1 = use class cache_lifetime value</li>
+ * <li>2 = use cache_lifetime in cache file</li>
+ * </ul>
+ * @var integer
+ */
+ var $caching = 0;
+
+ /**
+ * The name of the directory for cache files.
+ *
+ * @var string
+ */
+ var $cache_dir = 'cache';
+
+ /**
+ * This is the number of seconds cached content will persist.
+ * <ul>
+ * <li>0 = always regenerate cache</li>
+ * <li>-1 = never expires</li>
+ * </ul>
+ *
+ * @var integer
+ */
+ var $cache_lifetime = 3600;
+
+ /**
+ * Only used when $caching is enabled. If true, then If-Modified-Since headers
+ * are respected with cached content, and appropriate HTTP headers are sent.
+ * This way repeated hits to a cached page do not send the entire page to the
+ * client every time.
+ *
+ * @var boolean
+ */
+ var $cache_modified_check = false;
+
+ /**
+ * This determines how Smarty handles "<?php ... ?>" tags in templates.
+ * possible values:
+ * <ul>
+ * <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
+ * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
+ * <li>SMARTY_PHP_REMOVE -> remove php tags</li>
+ * <li>SMARTY_PHP_ALLOW -> execute php tags</li>
+ * </ul>
+ *
+ * @var integer
+ */
+ var $php_handling = SMARTY_PHP_PASSTHRU;
+
+ /**
+ * This enables template security. When enabled, many things are restricted
+ * in the templates that normally would go unchecked. This is useful when
+ * untrusted parties are editing templates and you want a reasonable level
+ * of security. (no direct execution of PHP in templates for example)
+ *
+ * @var boolean
+ */
+ var $security = false;
+
+ /**
+ * This is the list of template directories that are considered secure. This
+ * is used only if {@link $security} is enabled. One directory per array
+ * element. {@link $template_dir} is in this list implicitly.
+ *
+ * @var array
+ */
+ var $secure_dir = array();
+
+ /**
+ * These are the security settings for Smarty. They are used only when
+ * {@link $security} is enabled.
+ *
+ * @var array
+ */
+ var $security_settings = array(
+ 'PHP_HANDLING' => false,
+ 'IF_FUNCS' => array('array', 'list',
+ 'isset', 'empty',
+ 'count', 'sizeof',
+ 'in_array', 'is_array',
+ 'true', 'false', 'null'),
+ 'INCLUDE_ANY' => false,
+ 'PHP_TAGS' => false,
+ 'MODIFIER_FUNCS' => array('count'),
+ 'ALLOW_CONSTANTS' => false
+ );
+
+ /**
+ * This is an array of directories where trusted php scripts reside.
+ * {@link $security} is disabled during their inclusion/execution.
+ *
+ * @var array
+ */
+ var $trusted_dir = array();
+
+ /**
+ * The left delimiter used for the template tags.
+ *
+ * @var string
+ */
+ var $left_delimiter = '{';
+
+ /**
+ * The right delimiter used for the template tags.
+ *
+ * @var string
+ */
+ var $right_delimiter = '}';
+
+ /**
+ * The order in which request variables are registered, similar to
+ * variables_order in php.ini E = Environment, G = GET, P = POST,
+ * C = Cookies, S = Server
+ *
+ * @var string
+ */
+ var $request_vars_order = 'EGPCS';
+
+ /**
+ * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
+ * are uses as request-vars or $_*[]-vars. note: if
+ * request_use_auto_globals is true, then $request_vars_order has
+ * no effect, but the php-ini-value "gpc_order"
+ *
+ * @var boolean
+ */
+ var $request_use_auto_globals = true;
+
+ /**
+ * Set this if you want different sets of compiled files for the same
+ * templates. This is useful for things like different languages.
+ * Instead of creating separate sets of templates per language, you
+ * set different compile_ids like 'en' and 'de'.
+ *
+ * @var string
+ */
+ var $compile_id = null;
+
+ /**
+ * This tells Smarty whether or not to use sub dirs in the cache/ and
+ * templates_c/ directories. sub directories better organized, but
+ * may not work well with PHP safe mode enabled.
+ *
+ * @var boolean
+ *
+ */
+ var $use_sub_dirs = false;
+
+ /**
+ * This is a list of the modifiers to apply to all template variables.
+ * Put each modifier in a separate array element in the order you want
+ * them applied. example: <code>array('escape:"htmlall"');</code>
+ *
+ * @var array
+ */
+ var $default_modifiers = array();
+
+ /**
+ * This is the resource type to be used when not specified
+ * at the beginning of the resource path. examples:
+ * $smarty->display('file:index.tpl');
+ * $smarty->display('db:index.tpl');
+ * $smarty->display('index.tpl'); // will use default resource type
+ * {include file="file:index.tpl"}
+ * {include file="db:index.tpl"}
+ * {include file="index.tpl"} {* will use default resource type *}
+ *
+ * @var array
+ */
+ var $default_resource_type = 'file';
+
+ /**
+ * The function used for cache file handling. If not set, built-in caching is used.
+ *
+ * @var null|string function name
+ */
+ var $cache_handler_func = null;
+
+ /**
+ * This indicates which filters are automatically loaded into Smarty.
+ *
+ * @var array array of filter names
+ */
+ var $autoload_filters = array();
+
+ /**#@+
+ * @var boolean
+ */
+ /**
+ * This tells if config file vars of the same name overwrite each other or not.
+ * if disabled, same name variables are accumulated in an array.
+ */
+ var $config_overwrite = true;
+
+ /**
+ * This tells whether or not to automatically booleanize config file variables.
+ * If enabled, then the strings "on", "true", and "yes" are treated as boolean
+ * true, and "off", "false" and "no" are treated as boolean false.
+ */
+ var $config_booleanize = true;
+
+ /**
+ * This tells whether hidden sections [.foobar] are readable from the
+ * tempalates or not. Normally you would never allow this since that is
+ * the point behind hidden sections: the application can access them, but
+ * the templates cannot.
+ */
+ var $config_read_hidden = false;
+
+ /**
+ * This tells whether or not automatically fix newlines in config files.
+ * It basically converts \r (mac) or \r\n (dos) to \n
+ */
+ var $config_fix_newlines = true;
+ /**#@-*/
+
+ /**
+ * If a template cannot be found, this PHP function will be executed.
+ * Useful for creating templates on-the-fly or other special action.
+ *
+ * @var string function name
+ */
+ var $default_template_handler_func = '';
+
+ /**
+ * The file that contains the compiler class. This can a full
+ * pathname, or relative to the php_include path.
+ *
+ * @var string
+ */
+ var $compiler_file = 'Smarty_Compiler.class.php';
+
+ /**
+ * The class used for compiling templates.
+ *
+ * @var string
+ */
+ var $compiler_class = 'Smarty_Compiler';
+
+ /**
+ * The class used to load config vars.
+ *
+ * @var string
+ */
+ var $config_class = 'Config_File';
+
+/**#@+
+ * END Smarty Configuration Section
+ * There should be no need to touch anything below this line.
+ * @access private
+ */
+ /**
+ * where assigned template vars are kept
+ *
+ * @var array
+ */
+ var $_tpl_vars = array();
+
+ /**
+ * stores run-time $smarty.* vars
+ *
+ * @var null|array
+ */
+ var $_smarty_vars = null;
+
+ /**
+ * keeps track of sections
+ *
+ * @var array
+ */
+ var $_sections = array();
+
+ /**
+ * keeps track of foreach blocks
+ *
+ * @var array
+ */
+ var $_foreach = array();
+
+ /**
+ * keeps track of tag hierarchy
+ *
+ * @var array
+ */
+ var $_tag_stack = array();
+
+ /**
+ * configuration object
+ *
+ * @var Config_file
+ */
+ var $_conf_obj = null;
+
+ /**
+ * loaded configuration settings
+ *
+ * @var array
+ */
+ var $_config = array(array('vars' => array(), 'files' => array()));
+
+ /**
+ * md5 checksum of the string 'Smarty'
+ *
+ * @var string
+ */
+ var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
+
+ /**
+ * Smarty version number
+ *
+ * @var string
+ */
+ var $_version = '2.6.9';
+
+ /**
+ * current template inclusion depth
+ *
+ * @var integer
+ */
+ var $_inclusion_depth = 0;
+
+ /**
+ * for different compiled templates
+ *
+ * @var string
+ */
+ var $_compile_id = null;
+
+ /**
+ * text in URL to enable debug mode
+ *
+ * @var string
+ */
+ var $_smarty_debug_id = 'SMARTY_DEBUG';
+
+ /**
+ * debugging information for debug console
+ *
+ * @var array
+ */
+ var $_smarty_debug_info = array();
+
+ /**
+ * info that makes up a cache file
+ *
+ * @var array
+ */
+ var $_cache_info = array();
+
+ /**
+ * default file permissions
+ *
+ * @var integer
+ */
+ var $_file_perms = 0644;
+
+ /**
+ * default dir permissions
+ *
+ * @var integer
+ */
+ var $_dir_perms = 0771;
+
+ /**
+ * registered objects
+ *
+ * @var array
+ */
+ var $_reg_objects = array();
+
+ /**
+ * table keeping track of plugins
+ *
+ * @var array
+ */
+ var $_plugins = array(
+ 'modifier' => array(),
+ 'function' => array(),
+ 'block' => array(),
+ 'compiler' => array(),
+ 'prefilter' => array(),
+ 'postfilter' => array(),
+ 'outputfilter' => array(),
+ 'resource' => array(),
+ 'insert' => array());
+
+
+ /**
+ * cache serials
+ *
+ * @var array
+ */
+ var $_cache_serials = array();
+
+ /**
+ * name of optional cache include file
+ *
+ * @var string
+ */
+ var $_cache_include = null;
+
+ /**
+ * indicate if the current code is used in a compiled
+ * include
+ *
+ * @var string
+ */
+ var $_cache_including = false;
+
+ /**#@-*/
+ /**
+ * The class constructor.
+ */
+ function Smarty()
+ {
+ $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
+ : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
+ }
+
+ /**
+ * assigns values to template variables
+ *
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to assign
+ */
+ function assign($tpl_var, $value = null)
+ {
+ if (is_array($tpl_var)){
+ foreach ($tpl_var as $key => $val) {
+ if ($key != '') {
+ $this->_tpl_vars[$key] = $val;
+ }
+ }
+ } else {
+ if ($tpl_var != '')
+ $this->_tpl_vars[$tpl_var] = $value;
+ }
+ }
+
+ /**
+ * assigns values to template variables by reference
+ *
+ * @param string $tpl_var the template variable name
+ * @param mixed $value the referenced value to assign
+ */
+ function assign_by_ref($tpl_var, &$value)
+ {
+ if ($tpl_var != '')
+ $this->_tpl_vars[$tpl_var] = &$value;
+ }
+
+ /**
+ * appends values to template variables
+ *
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to append
+ */
+ function append($tpl_var, $value=null, $merge=false)
+ {
+ if (is_array($tpl_var)) {
+ // $tpl_var is an array, ignore $value
+ foreach ($tpl_var as $_key => $_val) {
+ if ($_key != '') {
+ if(!@is_array($this->_tpl_vars[$_key])) {
+ settype($this->_tpl_vars[$_key],'array');
+ }
+ if($merge && is_array($_val)) {
+ foreach($_val as $_mkey => $_mval) {
+ $this->_tpl_vars[$_key][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$_key][] = $_val;
+ }
+ }
+ }
+ } else {
+ if ($tpl_var != '' && isset($value)) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if($merge && is_array($value)) {
+ foreach($value as $_mkey => $_mval) {
+ $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = $value;
+ }
+ }
+ }
+ }
+
+ /**
+ * appends values to template variables by reference
+ *
+ * @param string $tpl_var the template variable name
+ * @param mixed $value the referenced value to append
+ */
+ function append_by_ref($tpl_var, &$value, $merge=false)
+ {
+ if ($tpl_var != '' && isset($value)) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
+ settype($this->_tpl_vars[$tpl_var],'array');
+ }
+ if ($merge && is_array($value)) {
+ foreach($value as $_key => $_val) {
+ $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
+ }
+ } else {
+ $this->_tpl_vars[$tpl_var][] = &$value;
+ }
+ }
+ }
+
+
+ /**
+ * clear the given assigned template variable.
+ *
+ * @param string $tpl_var the template variable to clear
+ */
+ function clear_assign($tpl_var)
+ {
+ if (is_array($tpl_var))
+ foreach ($tpl_var as $curr_var)
+ unset($this->_tpl_vars[$curr_var]);
+ else
+ unset($this->_tpl_vars[$tpl_var]);
+ }
+
+
+ /**
+ * Registers custom function to be used in templates
+ *
+ * @param string $function the name of the template function
+ * @param string $function_impl the name of the PHP function to register
+ */
+ function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
+ {
+ $this->_plugins['function'][$function] =
+ array($function_impl, null, null, false, $cacheable, $cache_attrs);
+
+ }
+
+ /**
+ * Unregisters custom function
+ *
+ * @param string $function name of template function
+ */
+ function unregister_function($function)
+ {
+ unset($this->_plugins['function'][$function]);
+ }
+
+ /**
+ * Registers object to be used in templates
+ *
+ * @param string $object name of template object
+ * @param object &$object_impl the referenced PHP object to register
+ * @param null|array $allowed list of allowed methods (empty = all)
+ * @param boolean $smarty_args smarty argument format, else traditional
+ * @param null|array $block_functs list of methods that are block format
+ */
+ function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
+ {
+ settype($allowed, 'array');
+ settype($smarty_args, 'boolean');
+ $this->_reg_objects[$object] =
+ array(&$object_impl, $allowed, $smarty_args, $block_methods);
+ }
+
+ /**
+ * Unregisters object
+ *
+ * @param string $object name of template object
+ */
+ function unregister_object($object)
+ {
+ unset($this->_reg_objects[$object]);
+ }
+
+
+ /**
+ * Registers block function to be used in templates
+ *
+ * @param string $block name of template block
+ * @param string $block_impl PHP function to register
+ */
+ function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
+ {
+ $this->_plugins['block'][$block] =
+ array($block_impl, null, null, false, $cacheable, $cache_attrs);
+ }
+
+ /**
+ * Unregisters block function
+ *
+ * @param string $block name of template function
+ */
+ function unregister_block($block)
+ {
+ unset($this->_plugins['block'][$block]);
+ }
+
+ /**
+ * Registers compiler function
+ *
+ * @param string $function name of template function
+ * @param string $function_impl name of PHP function to register
+ */
+ function register_compiler_function($function, $function_impl, $cacheable=true)
+ {
+ $this->_plugins['compiler'][$function] =
+ array($function_impl, null, null, false, $cacheable);
+ }
+
+ /**
+ * Unregisters compiler function
+ *
+ * @param string $function name of template function
+ */
+ function unregister_compiler_function($function)
+ {
+ unset($this->_plugins['compiler'][$function]);
+ }
+
+ /**
+ * Registers modifier to be used in templates
+ *
+ * @param string $modifier name of template modifier
+ * @param string $modifier_impl name of PHP function to register
+ */
+ function register_modifier($modifier, $modifier_impl)
+ {
+ $this->_plugins['modifier'][$modifier] =
+ array($modifier_impl, null, null, false);
+ }
+
+ /**
+ * Unregisters modifier
+ *
+ * @param string $modifier name of template modifier
+ */
+ function unregister_modifier($modifier)
+ {
+ unset($this->_plugins['modifier'][$modifier]);
+ }
+
+ /**
+ * Registers a resource to fetch a template
+ *
+ * @param string $type name of resource
+ * @param array $functions array of functions to handle resource
+ */
+ function register_resource($type, $functions)
+ {
+ if (count($functions)==4) {
+ $this->_plugins['resource'][$type] =
+ array($functions, false);
+
+ } elseif (count($functions)==5) {
+ $this->_plugins['resource'][$type] =
+ array(array(array(&$functions[0], $functions[1])
+ ,array(&$functions[0], $functions[2])
+ ,array(&$functions[0], $functions[3])
+ ,array(&$functions[0], $functions[4]))
+ ,false);
+
+ } else {
+ $this->trigger_error("malformed function-list for '$type' in register_resource");
+
+ }
+ }
+
+ /**
+ * Unregisters a resource
+ *
+ * @param string $type name of resource
+ */
+ function unregister_resource($type)
+ {
+ unset($this->_plugins['resource'][$type]);
+ }
+
+ /**
+ * Registers a prefilter function to apply
+ * to a template before compiling
+ *
+ * @param string $function name of PHP function to register
+ */
+ function register_prefilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['prefilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters a prefilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_prefilter($function)
+ {
+ unset($this->_plugins['prefilter'][$function]);
+ }
+
+ /**
+ * Registers a postfilter function to apply
+ * to a compiled template after compilation
+ *
+ * @param string $function name of PHP function to register
+ */
+ function register_postfilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['postfilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters a postfilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_postfilter($function)
+ {
+ unset($this->_plugins['postfilter'][$function]);
+ }
+
+ /**
+ * Registers an output filter function to apply
+ * to a template output
+ *
+ * @param string $function name of PHP function
+ */
+ function register_outputfilter($function)
+ {
+ $_name = (is_array($function)) ? $function[1] : $function;
+ $this->_plugins['outputfilter'][$_name]
+ = array($function, null, null, false);
+ }
+
+ /**
+ * Unregisters an outputfilter function
+ *
+ * @param string $function name of PHP function
+ */
+ function unregister_outputfilter($function)
+ {
+ unset($this->_plugins['outputfilter'][$function]);
+ }
+
+ /**
+ * load a filter of specified type and name
+ *
+ * @param string $type filter type
+ * @param string $name filter name
+ */
+ function load_filter($type, $name)
+ {
+ switch ($type) {
+ case 'output':
+ $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ break;
+
+ case 'pre':
+ case 'post':
+ if (!isset($this->_plugins[$type . 'filter'][$name]))
+ $this->_plugins[$type . 'filter'][$name] = false;
+ break;
+ }
+ }
+
+ /**
+ * clear cached content for the given template and cache id
+ *
+ * @param string $tpl_file name of template file
+ * @param string $cache_id name of cache_id
+ * @param string $compile_id name of compile_id
+ * @param string $exp_time expiration time
+ * @return boolean
+ */
+ function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
+ {
+
+ if (!isset($compile_id))
+ $compile_id = $this->compile_id;
+
+ if (!isset($tpl_file))
+ $compile_id = null;
+
+ $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
+
+ if (!empty($this->cache_handler_func)) {
+ return call_user_func_array($this->cache_handler_func,
+ array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
+ } else {
+ $_params = array('auto_base' => $this->cache_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $_auto_id,
+ 'exp_time' => $exp_time);
+ require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
+ }
+
+ }
+
+
+ /**
+ * clear the entire contents of cache (all templates)
+ *
+ * @param string $exp_time expire time
+ * @return boolean results of {@link smarty_core_rm_auto()}
+ */
+ function clear_all_cache($exp_time = null)
+ {
+ return $this->clear_cache(null, null, null, $exp_time);
+ }
+
+
+ /**
+ * test to see if valid cache exists for this template
+ *
+ * @param string $tpl_file name of template file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @return string|false results of {@link _read_cache_file()}
+ */
+ function is_cached($tpl_file, $cache_id = null, $compile_id = null)
+ {
+ if (!$this->caching)
+ return false;
+
+ if (!isset($compile_id))
+ $compile_id = $this->compile_id;
+
+ $_params = array(
+ 'tpl_file' => $tpl_file,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id
+ );
+ require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
+ return smarty_core_read_cache_file($_params, $this);
+ }
+
+
+ /**
+ * clear all the assigned template variables.
+ *
+ */
+ function clear_all_assign()
+ {
+ $this->_tpl_vars = array();
+ }
+
+ /**
+ * clears compiled version of specified template resource,
+ * or all compiled template files if one is not specified.
+ * This function is for advanced use only, not normally needed.
+ *
+ * @param string $tpl_file
+ * @param string $compile_id
+ * @param string $exp_time
+ * @return boolean results of {@link smarty_core_rm_auto()}
+ */
+ function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
+ {
+ if (!isset($compile_id)) {
+ $compile_id = $this->compile_id;
+ }
+ $_params = array('auto_base' => $this->compile_dir,
+ 'auto_source' => $tpl_file,
+ 'auto_id' => $compile_id,
+ 'exp_time' => $exp_time,
+ 'extensions' => array('.inc', '.php'));
+ require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
+ return smarty_core_rm_auto($_params, $this);
+ }
+
+ /**
+ * Checks whether requested template exists.
+ *
+ * @param string $tpl_file
+ * @return boolean
+ */
+ function template_exists($tpl_file)
+ {
+ $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
+ return $this->_fetch_resource_info($_params);
+ }
+
+ /**
+ * Returns an array containing template variables
+ *
+ * @param string $name
+ * @param string $type
+ * @return array
+ */
+ function &get_template_vars($name=null)
+ {
+ if(!isset($name)) {
+ return $this->_tpl_vars;
+ }
+ if(isset($this->_tpl_vars[$name])) {
+ return $this->_tpl_vars[$name];
+ }
+ }
+
+ /**
+ * Returns an array containing config variables
+ *
+ * @param string $name
+ * @param string $type
+ * @return array
+ */
+ function &get_config_vars($name=null)
+ {
+ if(!isset($name) && is_array($this->_config[0])) {
+ return $this->_config[0]['vars'];
+ } else if(isset($this->_config[0]['vars'][$name])) {
+ return $this->_config[0]['vars'][$name];
+ }
+ }
+
+ /**
+ * trigger Smarty error
+ *
+ * @param string $error_msg
+ * @param integer $error_type
+ */
+ function trigger_error($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Smarty error: $error_msg", $error_type);
+ }
+
+
+ /**
+ * executes & displays the template results
+ *
+ * @param string $resource_name
+ * @param string $cache_id
+ * @param string $compile_id
+ */
+ function display($resource_name, $cache_id = null, $compile_id = null)
+ {
+ $this->fetch($resource_name, $cache_id, $compile_id, true);
+ }
+
+ /**
+ * executes & returns or displays the template results
+ *
+ * @param string $resource_name
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param boolean $display
+ */
+ function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
+ {
+ static $_cache_info = array();
+
+ $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
+ ? $this->error_reporting : error_reporting() & ~E_NOTICE);
+
+ if (!$this->debugging && $this->debugging_ctrl == 'URL') {
+ $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
+ if (@strstr($_query_string, $this->_smarty_debug_id)) {
+ if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
+ // enable debugging for this browser session
+ @setcookie('SMARTY_DEBUG', true);
+ $this->debugging = true;
+ } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
+ // disable debugging for this browser session
+ @setcookie('SMARTY_DEBUG', false);
+ $this->debugging = false;
+ } else {
+ // enable debugging for this page
+ $this->debugging = true;
+ }
+ } else {
+ $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
+ }
+ }
+
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $_debug_start_time = smarty_core_get_microtime($_params, $this);
+ $this->_smarty_debug_info[] = array('type' => 'template',
+ 'filename' => $resource_name,
+ 'depth' => 0);
+ $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
+ }
+
+ if (!isset($compile_id)) {
+ $compile_id = $this->compile_id;
+ }
+
+ $this->_compile_id = $compile_id;
+ $this->_inclusion_depth = 0;
+
+ if ($this->caching) {
+ // save old cache_info, initialize cache_info
+ array_push($_cache_info, $this->_cache_info);
+ $this->_cache_info = array();
+ $_params = array(
+ 'tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => null
+ );
+ require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
+ if (smarty_core_read_cache_file($_params, $this)) {
+ $_smarty_results = $_params['results'];
+ if (!empty($this->_cache_info['insert_tags'])) {
+ $_params = array('plugins' => $this->_cache_info['insert_tags']);
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ $_params = array('results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
+ $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
+ }
+ if (!empty($this->_cache_info['cache_serials'])) {
+ $_params = array('results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
+ $_smarty_results = smarty_core_process_compiled_include($_params, $this);
+ }
+
+
+ if ($display) {
+ if ($this->debugging)
+ {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ $_smarty_results .= smarty_core_display_debug_console($_params, $this);
+ }
+ if ($this->cache_modified_check) {
+ $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
+ $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
+ $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
+ if (@count($this->_cache_info['insert_tags']) == 0
+ && !$this->_cache_serials
+ && $_gmt_mtime == $_last_modified_date) {
+ if (php_sapi_name()=='cgi')
+ header('Status: 304 Not Modified');
+ else
+ header('HTTP/1.1 304 Not Modified');
+
+ } else {
+ header('Last-Modified: '.$_gmt_mtime);
+ echo $_smarty_results;
+ }
+ } else {
+ echo $_smarty_results;
+ }
+ error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ return true;
+ } else {
+ error_reporting($_smarty_old_error_level);
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ return $_smarty_results;
+ }
+ } else {
+ $this->_cache_info['template'][$resource_name] = true;
+ if ($this->cache_modified_check && $display) {
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
+ }
+ }
+ }
+
+ // load filters that are marked as autoload
+ if (count($this->autoload_filters)) {
+ foreach ($this->autoload_filters as $_filter_type => $_filters) {
+ foreach ($_filters as $_filter) {
+ $this->load_filter($_filter_type, $_filter);
+ }
+ }
+ }
+
+ $_smarty_compile_path = $this->_get_compile_path($resource_name);
+
+ // if we just need to display the results, don't perform output
+ // buffering - for speed
+ $_cache_including = $this->_cache_including;
+ $this->_cache_including = false;
+ if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
+ if ($this->_is_compiled($resource_name, $_smarty_compile_path)
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+ } else {
+ ob_start();
+ if ($this->_is_compiled($resource_name, $_smarty_compile_path)
+ || $this->_compile_resource($resource_name, $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+ $_smarty_results = ob_get_contents();
+ ob_end_clean();
+
+ foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
+ $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
+ }
+ }
+
+ if ($this->caching) {
+ $_params = array('tpl_file' => $resource_name,
+ 'cache_id' => $cache_id,
+ 'compile_id' => $compile_id,
+ 'results' => $_smarty_results);
+ require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
+ smarty_core_write_cache_file($_params, $this);
+ require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
+ $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
+
+ if ($this->_cache_serials) {
+ // strip nocache-tags from output
+ $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
+ ,''
+ ,$_smarty_results);
+ }
+ // restore initial cache_info
+ $this->_cache_info = array_pop($_cache_info);
+ }
+ $this->_cache_including = $_cache_including;
+
+ if ($display) {
+ if (isset($_smarty_results)) { echo $_smarty_results; }
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ echo smarty_core_display_debug_console($_params, $this);
+ }
+ error_reporting($_smarty_old_error_level);
+ return;
+ } else {
+ error_reporting($_smarty_old_error_level);
+ if (isset($_smarty_results)) { return $_smarty_results; }
+ }
+ }
+
+ /**
+ * load configuration values
+ *
+ * @param string $file
+ * @param string $section
+ * @param string $scope
+ */
+ function config_load($file, $section = null, $scope = 'global')
+ {
+ require_once($this->_get_plugin_filepath('function', 'config_load'));
+ smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
+ }
+
+ /**
+ * return a reference to a registered object
+ *
+ * @param string $name
+ * @return object
+ */
+ function &get_registered_object($name) {
+ if (!isset($this->_reg_objects[$name]))
+ $this->_trigger_fatal_error("'$name' is not a registered object");
+
+ if (!is_object($this->_reg_objects[$name][0]))
+ $this->_trigger_fatal_error("registered '$name' is not an object");
+
+ return $this->_reg_objects[$name][0];
+ }
+
+ /**
+ * clear configuration values
+ *
+ * @param string $var
+ */
+ function clear_config($var = null)
+ {
+ if(!isset($var)) {
+ // clear all values
+ $this->_config = array(array('vars' => array(),
+ 'files' => array()));
+ } else {
+ unset($this->_config[0]['vars'][$var]);
+ }
+ }
+
+ /**
+ * get filepath of requested plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @return string|false
+ */
+ function _get_plugin_filepath($type, $name)
+ {
+ $_params = array('type' => $type, 'name' => $name);
+ require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
+ return smarty_core_assemble_plugin_filepath($_params, $this);
+ }
+
+ /**
+ * test if resource needs compiling
+ *
+ * @param string $resource_name
+ * @param string $compile_path
+ * @return boolean
+ */
+ function _is_compiled($resource_name, $compile_path)
+ {
+ if (!$this->force_compile && file_exists($compile_path)) {
+ if (!$this->compile_check) {
+ // no need to check compiled file
+ return true;
+ } else {
+ // get file source and timestamp
+ $_params = array('resource_name' => $resource_name, 'get_source'=>false);
+ if (!$this->_fetch_resource_info($_params)) {
+ return false;
+ }
+ if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
+ // template not expired, no recompile
+ return true;
+ } else {
+ // compile template
+ return false;
+ }
+ }
+ } else {
+ // compiled template does not exist, or forced compile
+ return false;
+ }
+ }
+
+ /**
+ * compile the template
+ *
+ * @param string $resource_name
+ * @param string $compile_path
+ * @return boolean
+ */
+ function _compile_resource($resource_name, $compile_path)
+ {
+
+ $_params = array('resource_name' => $resource_name);
+ if (!$this->_fetch_resource_info($_params)) {
+ return false;
+ }
+
+ $_source_content = $_params['source_content'];
+ $_cache_include = substr($compile_path, 0, -4).'.inc';
+
+ if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
+ // if a _cache_serial was set, we also have to write an include-file:
+ if ($this->_cache_include_info) {
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
+ smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)), $this);
+ }
+
+ $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
+ smarty_core_write_compiled_resource($_params, $this);
+
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
+ * compile the given source
+ *
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
+ * @return boolean
+ */
+ function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
+ {
+ if (file_exists(SMARTY_DIR . $this->compiler_file)) {
+ require_once(SMARTY_DIR . $this->compiler_file);
+ } else {
+ // use include_path
+ require_once($this->compiler_file);
+ }
+
+
+ $smarty_compiler = new $this->compiler_class;
+
+ $smarty_compiler->template_dir = $this->template_dir;
+ $smarty_compiler->compile_dir = $this->compile_dir;
+ $smarty_compiler->plugins_dir = $this->plugins_dir;
+ $smarty_compiler->config_dir = $this->config_dir;
+ $smarty_compiler->force_compile = $this->force_compile;
+ $smarty_compiler->caching = $this->caching;
+ $smarty_compiler->php_handling = $this->php_handling;
+ $smarty_compiler->left_delimiter = $this->left_delimiter;
+ $smarty_compiler->right_delimiter = $this->right_delimiter;
+ $smarty_compiler->_version = $this->_version;
+ $smarty_compiler->security = $this->security;
+ $smarty_compiler->secure_dir = $this->secure_dir;
+ $smarty_compiler->security_settings = $this->security_settings;
+ $smarty_compiler->trusted_dir = $this->trusted_dir;
+ $smarty_compiler->use_sub_dirs = $this->use_sub_dirs;
+ $smarty_compiler->_reg_objects = &$this->_reg_objects;
+ $smarty_compiler->_plugins = &$this->_plugins;
+ $smarty_compiler->_tpl_vars = &$this->_tpl_vars;
+ $smarty_compiler->default_modifiers = $this->default_modifiers;
+ $smarty_compiler->compile_id = $this->_compile_id;
+ $smarty_compiler->_config = $this->_config;
+ $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
+
+ if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
+ $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
+ }
+ $smarty_compiler->_cache_include = $cache_include_path;
+
+
+ $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
+
+ if ($smarty_compiler->_cache_serial) {
+ $this->_cache_include_info = array(
+ 'cache_serial'=>$smarty_compiler->_cache_serial
+ ,'plugins_code'=>$smarty_compiler->_plugins_code
+ ,'include_file_path' => $cache_include_path);
+
+ } else {
+ $this->_cache_include_info = null;
+
+ }
+
+ return $_results;
+ }
+
+ /**
+ * Get the compile path for this resource
+ *
+ * @param string $resource_name
+ * @return string results of {@link _get_auto_filename()}
+ */
+ function _get_compile_path($resource_name)
+ {
+ return $this->_get_auto_filename($this->compile_dir, $resource_name,
+ $this->_compile_id) . '.php';
+ }
+
+ /**
+ * fetch the template info. Gets timestamp, and source
+ * if get_source is true
+ *
+ * sets $source_content to the source of the template, and
+ * $resource_timestamp to its time stamp
+ * @param string $resource_name
+ * @param string $source_content
+ * @param integer $resource_timestamp
+ * @param boolean $get_source
+ * @param boolean $quiet
+ * @return boolean
+ */
+
+ function _fetch_resource_info(&$params)
+ {
+ if(!isset($params['get_source'])) { $params['get_source'] = true; }
+ if(!isset($params['quiet'])) { $params['quiet'] = false; }
+
+ $_return = false;
+ $_params = array('resource_name' => $params['resource_name']) ;
+ if (isset($params['resource_base_path']))
+ $_params['resource_base_path'] = $params['resource_base_path'];
+ else
+ $_params['resource_base_path'] = $this->template_dir;
+
+ if ($this->_parse_resource_name($_params)) {
+ $_resource_type = $_params['resource_type'];
+ $_resource_name = $_params['resource_name'];
+ switch ($_resource_type) {
+ case 'file':
+ if ($params['get_source']) {
+ $params['source_content'] = $this->_read_file($_resource_name);
+ }
+ $params['resource_timestamp'] = filemtime($_resource_name);
+ $_return = is_file($_resource_name);
+ break;
+
+ default:
+ // call resource functions to fetch the template source and timestamp
+ if ($params['get_source']) {
+ $_source_return = isset($this->_plugins['resource'][$_resource_type]) &&
+ call_user_func_array($this->_plugins['resource'][$_resource_type][0][0],
+ array($_resource_name, &$params['source_content'], &$this));
+ } else {
+ $_source_return = true;
+ }
+
+ $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) &&
+ call_user_func_array($this->_plugins['resource'][$_resource_type][0][1],
+ array($_resource_name, &$params['resource_timestamp'], &$this));
+
+ $_return = $_source_return && $_timestamp_return;
+ break;
+ }
+ }
+
+ if (!$_return) {
+ // see if we can get a template with the default template handler
+ if (!empty($this->default_template_handler_func)) {
+ if (!is_callable($this->default_template_handler_func)) {
+ $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
+ } else {
+ $_return = call_user_func_array(
+ $this->default_template_handler_func,
+ array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this));
+ }
+ }
+ }
+
+ if (!$_return) {
+ if (!$params['quiet']) {
+ $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
+ }
+ } else if ($_return && $this->security) {
+ require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
+ if (!smarty_core_is_secure($_params, $this)) {
+ if (!$params['quiet'])
+ $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
+ $params['source_content'] = null;
+ $params['resource_timestamp'] = null;
+ return false;
+ }
+ }
+ return $_return;
+ }
+
+
+ /**
+ * parse out the type and name from the resource
+ *
+ * @param string $resource_base_path
+ * @param string $resource_name
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+ function _parse_resource_name(&$params)
+ {
+
+ // split tpl_path by the first colon
+ $_resource_name_parts = explode(':', $params['resource_name'], 2);
+
+ if (count($_resource_name_parts) == 1) {
+ // no resource type given
+ $params['resource_type'] = $this->default_resource_type;
+ $params['resource_name'] = $_resource_name_parts[0];
+ } else {
+ if(strlen($_resource_name_parts[0]) == 1) {
+ // 1 char is not resource type, but part of filepath
+ $params['resource_type'] = $this->default_resource_type;
+ $params['resource_name'] = $params['resource_name'];
+ } else {
+ $params['resource_type'] = $_resource_name_parts[0];
+ $params['resource_name'] = $_resource_name_parts[1];
+ }
+ }
+
+ if ($params['resource_type'] == 'file') {
+ if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
+ // relative pathname to $params['resource_base_path']
+ // use the first directory where the file is found
+ foreach ((array)$params['resource_base_path'] as $_curr_path) {
+ $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
+ if (file_exists($_fullpath) && is_file($_fullpath)) {
+ $params['resource_name'] = $_fullpath;
+ return true;
+ }
+ // didn't find the file, try include_path
+ $_params = array('file_path' => $_fullpath);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $this)) {
+ $params['resource_name'] = $_params['new_file_path'];
+ return true;
+ }
+ }
+ return false;
+ } else {
+ /* absolute path */
+ return file_exists($params['resource_name']);
+ }
+ } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
+ $_params = array('type' => $params['resource_type']);
+ require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
+ smarty_core_load_resource_plugin($_params, $this);
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Handle modifiers
+ *
+ * @param string|null $modifier_name
+ * @param array|null $map_array
+ * @return string result of modifiers
+ */
+ function _run_mod_handler()
+ {
+ $_args = func_get_args();
+ list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
+ list($_func_name, $_tpl_file, $_tpl_line) =
+ $this->_plugins['modifier'][$_modifier_name];
+
+ $_var = $_args[0];
+ foreach ($_var as $_key => $_val) {
+ $_args[0] = $_val;
+ $_var[$_key] = call_user_func_array($_func_name, $_args);
+ }
+ return $_var;
+ }
+
+ /**
+ * Remove starting and ending quotes from the string
+ *
+ * @param string $string
+ * @return string
+ */
+ function _dequote($string)
+ {
+ if (($string{0} == "'" || $string{0} == '"') &&
+ $string{strlen($string)-1} == $string{0})
+ return substr($string, 1, -1);
+ else
+ return $string;
+ }
+
+
+ /**
+ * read in a file
+ *
+ * @param string $filename
+ * @return string
+ */
+ function _read_file($filename)
+ {
+ if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
+ $contents = ($size = filesize($filename)) ? fread($fd, $size) : '';
+ fclose($fd);
+ return $contents;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * get a concrete filename for automagically created content
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @return string
+ * @staticvar string|null
+ * @staticvar string|null
+ */
+ function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
+ {
+ $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
+ $_return = $auto_base . DIRECTORY_SEPARATOR;
+
+ if(isset($auto_id)) {
+ // make auto_id safe for directory names
+ $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
+ // split into separate directories
+ $_return .= $auto_id . $_compile_dir_sep;
+ }
+
+ if(isset($auto_source)) {
+ // make source name safe for filename
+ $_filename = urlencode(basename($auto_source));
+ $_crc32 = sprintf('%08X', crc32($auto_source));
+ // prepend %% to avoid name conflicts with
+ // with $params['auto_id'] names
+ $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep .
+ substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
+ $_return .= '%%' . $_crc32 . '%%' . $_filename;
+ }
+
+ return $_return;
+ }
+
+ /**
+ * unlink a file, possibly using expiration time
+ *
+ * @param string $resource
+ * @param integer $exp_time
+ */
+ function _unlink($resource, $exp_time = null)
+ {
+ if(isset($exp_time)) {
+ if(time() - @filemtime($resource) >= $exp_time) {
+ return @unlink($resource);
+ }
+ } else {
+ return @unlink($resource);
+ }
+ }
+
+ /**
+ * returns an auto_id for auto-file-functions
+ *
+ * @param string $cache_id
+ * @param string $compile_id
+ * @return string|null
+ */
+ function _get_auto_id($cache_id=null, $compile_id=null) {
+ if (isset($cache_id))
+ return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
+ elseif(isset($compile_id))
+ return $compile_id;
+ else
+ return null;
+ }
+
+ /**
+ * trigger Smarty plugin error
+ *
+ * @param string $error_msg
+ * @param string $tpl_file
+ * @param integer $tpl_line
+ * @param string $file
+ * @param integer $line
+ * @param integer $error_type
+ */
+ function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
+ $file = null, $line = null, $error_type = E_USER_ERROR)
+ {
+ if(isset($file) && isset($line)) {
+ $info = ' ('.basename($file).", line $line)";
+ } else {
+ $info = '';
+ }
+ if (isset($tpl_line) && isset($tpl_file)) {
+ $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
+ } else {
+ $this->trigger_error($error_msg . $info, $error_type);
+ }
+ }
+
+
+ /**
+ * callback function for preg_replace, to call a non-cacheable block
+ * @return string
+ */
+ function _process_compiled_include_callback($match) {
+ $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
+ ob_start();
+ $_func($this);
+ $_ret = ob_get_contents();
+ ob_end_clean();
+ return $_ret;
+ }
+
+
+ /**
+ * called for included templates
+ *
+ * @param string $_smarty_include_tpl_file
+ * @param string $_smarty_include_vars
+ */
+
+ // $_smarty_include_tpl_file, $_smarty_include_vars
+
+ function _smarty_include($params)
+ {
+ if ($this->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $debug_start_time = smarty_core_get_microtime($_params, $this);
+ $this->_smarty_debug_info[] = array('type' => 'template',
+ 'filename' => $params['smarty_include_tpl_file'],
+ 'depth' => ++$this->_inclusion_depth);
+ $included_tpls_idx = count($this->_smarty_debug_info) - 1;
+ }
+
+ $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
+
+ // config vars are treated as local, so push a copy of the
+ // current ones onto the front of the stack
+ array_unshift($this->_config, $this->_config[0]);
+
+ $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
+
+
+ if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path)
+ || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
+ {
+ include($_smarty_compile_path);
+ }
+
+ // pop the local vars off the front of the stack
+ array_shift($this->_config);
+
+ $this->_inclusion_depth--;
+
+ if ($this->debugging) {
+ // capture time for debugging info
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
+ }
+
+ if ($this->caching) {
+ $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
+ }
+ }
+
+
+ /**
+ * get or set an array of cached attributes for function that is
+ * not cacheable
+ * @return array
+ */
+ function &_smarty_cache_attrs($cache_serial, $count) {
+ $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count];
+
+ if ($this->_cache_including) {
+ /* return next set of cache_attrs */
+ $_return =& current($_cache_attrs);
+ next($_cache_attrs);
+ return $_return;
+
+ } else {
+ /* add a reference to a new set of cache_attrs */
+ $_cache_attrs[] = array();
+ return $_cache_attrs[count($_cache_attrs)-1];
+
+ }
+
+ }
+
+
+ /**
+ * wrapper for include() retaining $this
+ * @return mixed
+ */
+ function _include($filename, $once=false, $params=null)
+ {
+ if ($once) {
+ return include_once($filename);
+ } else {
+ return include($filename);
+ }
+ }
+
+
+ /**
+ * wrapper for eval() retaining $this
+ * @return mixed
+ */
+ function _eval($code, $params=null)
+ {
+ return eval($code);
+ }
+ /**#@-*/
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/Smarty_Compiler.class.php b/html/phpgacl/admin/smarty_x/libs/Smarty_Compiler.class.php
new file mode 100644
index 0000000..2d9dee4
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/Smarty_Compiler.class.php
@@ -0,0 +1,2304 @@
+<?php
+
+/**
+ * Project: Smarty: the PHP compiling template engine
+ * File: Smarty_Compiler.class.php
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * @link http://smarty.php.net/
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Andrei Zmievski <andrei@php.net>
+ * @version 2.6.9
+ * @copyright 2001-2005 New Digital Group, Inc.
+ * @package Smarty
+ */
+
+/* $Id: Smarty_Compiler.class.php,v 1.9 2005/07/24 19:57:54 ipso Exp $ */
+
+/**
+ * Template compiling class
+ * @package Smarty
+ */
+class Smarty_Compiler extends Smarty {
+
+ // internal vars
+ /**#@+
+ * @access private
+ */
+ var $_folded_blocks = array(); // keeps folded template blocks
+ var $_current_file = null; // the current template being compiled
+ var $_current_line_no = 1; // line number for error messages
+ var $_capture_stack = array(); // keeps track of nested capture buffers
+ var $_plugin_info = array(); // keeps track of plugins to load
+ var $_init_smarty_vars = false;
+ var $_permitted_tokens = array('true','false','yes','no','on','off','null');
+ var $_db_qstr_regexp = null; // regexps are setup in the constructor
+ var $_si_qstr_regexp = null;
+ var $_qstr_regexp = null;
+ var $_func_regexp = null;
+ var $_reg_obj_regexp = null;
+ var $_var_bracket_regexp = null;
+ var $_num_const_regexp = null;
+ var $_dvar_guts_regexp = null;
+ var $_dvar_regexp = null;
+ var $_cvar_regexp = null;
+ var $_svar_regexp = null;
+ var $_avar_regexp = null;
+ var $_mod_regexp = null;
+ var $_var_regexp = null;
+ var $_parenth_param_regexp = null;
+ var $_func_call_regexp = null;
+ var $_obj_ext_regexp = null;
+ var $_obj_start_regexp = null;
+ var $_obj_params_regexp = null;
+ var $_obj_call_regexp = null;
+ var $_cacheable_state = 0;
+ var $_cache_attrs_count = 0;
+ var $_nocache_count = 0;
+ var $_cache_serial = null;
+ var $_cache_include = null;
+
+ var $_strip_depth = 0;
+ var $_additional_newline = "\n";
+
+ /**#@-*/
+ /**
+ * The class constructor.
+ */
+ function Smarty_Compiler()
+ {
+ // matches double quoted strings:
+ // "foobar"
+ // "foo\"bar"
+ $this->_db_qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
+
+ // matches single quoted strings:
+ // 'foobar'
+ // 'foo\'bar'
+ $this->_si_qstr_regexp = '\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
+
+ // matches single or double quoted strings
+ $this->_qstr_regexp = '(?:' . $this->_db_qstr_regexp . '|' . $this->_si_qstr_regexp . ')';
+
+ // matches bracket portion of vars
+ // [0]
+ // [foo]
+ // [$bar]
+ $this->_var_bracket_regexp = '\[\$?[\w\.]+\]';
+
+ // matches numerical constants
+ // 30
+ // -12
+ // 13.22
+ $this->_num_const_regexp = '(?:\-?\d+(?:\.\d+)?)';
+
+ // matches $ vars (not objects):
+ // $foo
+ // $foo.bar
+ // $foo.bar.foobar
+ // $foo[0]
+ // $foo[$bar]
+ // $foo[5][blah]
+ // $foo[5].bar[$foobar][4]
+ $this->_dvar_math_regexp = '(?:[\+\*\/\%]|(?:-(?!>)))';
+ $this->_dvar_math_var_regexp = '[\$\w\.\+\-\*\/\%\d\>\[\]]';
+ $this->_dvar_guts_regexp = '\w+(?:' . $this->_var_bracket_regexp
+ . ')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp . ')*)*(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?';
+ $this->_dvar_regexp = '\$' . $this->_dvar_guts_regexp;
+
+ // matches config vars:
+ // #foo#
+ // #foobar123_foo#
+ $this->_cvar_regexp = '\#\w+\#';
+
+ // matches section vars:
+ // %foo.bar%
+ $this->_svar_regexp = '\%\w+\.\w+\%';
+
+ // matches all valid variables (no quotes, no modifiers)
+ $this->_avar_regexp = '(?:' . $this->_dvar_regexp . '|'
+ . $this->_cvar_regexp . '|' . $this->_svar_regexp . ')';
+
+ // matches valid variable syntax:
+ // $foo
+ // $foo
+ // #foo#
+ // #foo#
+ // "text"
+ // "text"
+ $this->_var_regexp = '(?:' . $this->_avar_regexp . '|' . $this->_qstr_regexp . ')';
+
+ // matches valid object call (one level of object nesting allowed in parameters):
+ // $foo->bar
+ // $foo->bar()
+ // $foo->bar("text")
+ // $foo->bar($foo, $bar, "text")
+ // $foo->bar($foo, "foo")
+ // $foo->bar->foo()
+ // $foo->bar->foo->bar()
+ // $foo->bar($foo->bar)
+ // $foo->bar($foo->bar())
+ // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar))
+ $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
+ $this->_obj_restricted_param_regexp = '(?:'
+ . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
+ . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
+ $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)';
+ $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
+ . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
+ $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
+ $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
+
+ // matches valid modifier syntax:
+ // |foo
+ // |@foo
+ // |foo:"bar"
+ // |foo:$bar
+ // |foo:"bar":$foobar
+ // |foo|bar
+ // |foo:$foo->bar
+ $this->_mod_regexp = '(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp . '|'
+ . $this->_obj_call_regexp . '|' . $this->_avar_regexp . '|' . $this->_qstr_regexp .'))*)';
+
+ // matches valid function name:
+ // foo123
+ // _foo_bar
+ $this->_func_regexp = '[a-zA-Z_]\w*';
+
+ // matches valid registered object:
+ // foo->bar
+ $this->_reg_obj_regexp = '[a-zA-Z_]\w*->[a-zA-Z_]\w*';
+
+ // matches valid parameter values:
+ // true
+ // $foo
+ // $foo|bar
+ // #foo#
+ // #foo#|bar
+ // "text"
+ // "text"|bar
+ // $foo->bar
+ $this->_param_regexp = '(?:\s*(?:' . $this->_obj_call_regexp . '|'
+ . $this->_var_regexp . '|' . $this->_num_const_regexp . '|\w+)(?>' . $this->_mod_regexp . '*)\s*)';
+
+ // matches valid parenthesised function parameters:
+ //
+ // "text"
+ // $foo, $bar, "text"
+ // $foo|bar, "foo"|bar, $foo->bar($foo)|bar
+ $this->_parenth_param_regexp = '(?:\((?:\w+|'
+ . $this->_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
+ . $this->_param_regexp . ')))*)?\))';
+
+ // matches valid function call:
+ // foo()
+ // foo_bar($foo)
+ // _foo_bar($foo,"bar")
+ // foo123($foo,$foo->bar(),"foo")
+ $this->_func_call_regexp = '(?:' . $this->_func_regexp . '\s*(?:'
+ . $this->_parenth_param_regexp . '))';
+ }
+
+ /**
+ * compile a resource
+ *
+ * sets $compiled_content to the compiled source
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
+ * @return true
+ */
+ function _compile_file($resource_name, $source_content, &$compiled_content)
+ {
+
+ if ($this->security) {
+ // do not allow php syntax to be executed unless specified
+ if ($this->php_handling == SMARTY_PHP_ALLOW &&
+ !$this->security_settings['PHP_HANDLING']) {
+ $this->php_handling = SMARTY_PHP_PASSTHRU;
+ }
+ }
+
+ $this->_load_filters();
+
+ $this->_current_file = $resource_name;
+ $this->_current_line_no = 1;
+ $ldq = preg_quote($this->left_delimiter, '~');
+ $rdq = preg_quote($this->right_delimiter, '~');
+
+ // run template source through prefilter functions
+ if (count($this->_plugins['prefilter']) > 0) {
+ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
+ if ($prefilter === false) continue;
+ if ($prefilter[3] || is_callable($prefilter[0])) {
+ $source_content = call_user_func_array($prefilter[0],
+ array($source_content, &$this));
+ $this->_plugins['prefilter'][$filter_name][3] = true;
+ } else {
+ $this->_trigger_fatal_error("[plugin] prefilter '$filter_name' is not implemented");
+ }
+ }
+ }
+
+ /* fetch all special blocks */
+ $search = "~{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}~s";
+
+ preg_match_all($search, $source_content, $match, PREG_SET_ORDER);
+ $this->_folded_blocks = $match;
+ reset($this->_folded_blocks);
+
+ /* replace special blocks by "{php}" */
+ $source_content = preg_replace($search.'e', "'"
+ . $this->_quote_replace($this->left_delimiter) . 'php'
+ . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
+ . $this->_quote_replace($this->right_delimiter)
+ . "'"
+ , $source_content);
+
+ /* Gather all template tags. */
+ preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
+ $template_tags = $_match[1];
+ /* Split content by template tags to obtain non-template content. */
+ $text_blocks = preg_split("~{$ldq}.*?{$rdq}~s", $source_content);
+
+ /* loop through text blocks */
+ for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
+ /* match anything resembling php tags */
+ if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
+ /* replace tags with placeholders to prevent recursive replacements */
+ $sp_match[1] = array_unique($sp_match[1]);
+ usort($sp_match[1], '_smarty_sort_length');
+ for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
+ $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
+ }
+ /* process each one */
+ for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
+ if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
+ /* echo php contents */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]);
+ } else if ($this->php_handling == SMARTY_PHP_QUOTE) {
+ /* quote php tags */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
+ } else if ($this->php_handling == SMARTY_PHP_REMOVE) {
+ /* remove php tags */
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
+ } else {
+ /* SMARTY_PHP_ALLOW, but echo non php starting tags */
+ $sp_match[1][$curr_sp] = preg_replace('~(<\?(?!php|=|$))~i', '<?php echo \'\\1\'?>'."\n", $sp_match[1][$curr_sp]);
+ $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
+ }
+ }
+ }
+ }
+
+ /* Compile the template tags into PHP code. */
+ $compiled_tags = array();
+ for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
+ $this->_current_line_no += substr_count($text_blocks[$i], "\n");
+ $compiled_tags[] = $this->_compile_tag($template_tags[$i]);
+ $this->_current_line_no += substr_count($template_tags[$i], "\n");
+ }
+ if (count($this->_tag_stack)>0) {
+ list($_open_tag, $_line_no) = end($this->_tag_stack);
+ $this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__);
+ return;
+ }
+
+ /* Reformat $text_blocks between 'strip' and '/strip' tags,
+ removing spaces, tabs and newlines. */
+ $strip = false;
+ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
+ if ($compiled_tags[$i] == '{strip}') {
+ $compiled_tags[$i] = '';
+ $strip = true;
+ /* remove leading whitespaces */
+ $text_blocks[$i + 1] = ltrim($text_blocks[$i + 1]);
+ }
+ if ($strip) {
+ /* strip all $text_blocks before the next '/strip' */
+ for ($j = $i + 1; $j < $for_max; $j++) {
+ /* remove leading and trailing whitespaces of each line */
+ $text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $text_blocks[$j]);
+ if ($compiled_tags[$j] == '{/strip}') {
+ /* remove trailing whitespaces from the last text_block */
+ $text_blocks[$j] = rtrim($text_blocks[$j]);
+ }
+ $text_blocks[$j] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>";
+ if ($compiled_tags[$j] == '{/strip}') {
+ $compiled_tags[$j] = "\n"; /* slurped by php, but necessary
+ if a newline is following the closing strip-tag */
+ $strip = false;
+ $i = $j;
+ break;
+ }
+ }
+ }
+ }
+ $compiled_content = '';
+
+ /* Interleave the compiled contents and text blocks to get the final result. */
+ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
+ if ($compiled_tags[$i] == '') {
+ // tag result empty, remove first newline from following text block
+ $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]);
+ }
+ $compiled_content .= $text_blocks[$i].$compiled_tags[$i];
+ }
+ $compiled_content .= $text_blocks[$i];
+
+ // remove \n from the end of the file, if any
+ if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) {
+ $compiled_content = substr($compiled_content, 0, -1);
+ }
+
+ if (!empty($this->_cache_serial)) {
+ $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content;
+ }
+
+ // remove unnecessary close/open tags
+ $compiled_content = preg_replace('~\?>\n?<\?php~', '', $compiled_content);
+
+ // run compiled template through postfilter functions
+ if (count($this->_plugins['postfilter']) > 0) {
+ foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
+ if ($postfilter === false) continue;
+ if ($postfilter[3] || is_callable($postfilter[0])) {
+ $compiled_content = call_user_func_array($postfilter[0],
+ array($compiled_content, &$this));
+ $this->_plugins['postfilter'][$filter_name][3] = true;
+ } else {
+ $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented");
+ }
+ }
+ }
+
+ // put header at the top of the compiled template
+ $template_header = "<?php /* Smarty version ".$this->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
+ $template_header .= " compiled from ".strtr(urlencode($resource_name), array('%2F'=>'/', '%3A'=>':'))." */ ?>\n";
+
+ /* Emit code to load needed plugins. */
+ $this->_plugins_code = '';
+ if (count($this->_plugin_info)) {
+ $_plugins_params = "array('plugins' => array(";
+ foreach ($this->_plugin_info as $plugin_type => $plugins) {
+ foreach ($plugins as $plugin_name => $plugin_info) {
+ $_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], ";
+ $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),';
+ }
+ }
+ $_plugins_params .= '))';
+ $plugins_code = "<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
+ $template_header .= $plugins_code;
+ $this->_plugin_info = array();
+ $this->_plugins_code = $plugins_code;
+ }
+
+ if ($this->_init_smarty_vars) {
+ $template_header .= "<?php require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
+ $this->_init_smarty_vars = false;
+ }
+
+ $compiled_content = $template_header . $compiled_content;
+ return true;
+ }
+
+ /**
+ * Compile a template tag
+ *
+ * @param string $template_tag
+ * @return string
+ */
+ function _compile_tag($template_tag)
+ {
+ /* Matched comment. */
+ if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
+ return '';
+
+ /* Split tag into two three parts: command, command modifiers and the arguments. */
+ if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
+ . '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
+ (?:\s+(.*))?$
+ ~xs', $template_tag, $match)) {
+ $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $tag_command = $match[1];
+ $tag_modifier = isset($match[2]) ? $match[2] : null;
+ $tag_args = isset($match[3]) ? $match[3] : null;
+
+ if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) {
+ /* tag name is a variable or object */
+ $_return = $this->_parse_var_props($tag_command . $tag_modifier);
+ return "<?php echo $_return; ?>" . $this->_additional_newline;
+ }
+
+ /* If the tag name is a registered object, we process it. */
+ if (preg_match('~^\/?' . $this->_reg_obj_regexp . '$~', $tag_command)) {
+ return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);
+ }
+
+ switch ($tag_command) {
+ case 'include':
+ return $this->_compile_include_tag($tag_args);
+
+ case 'include_php':
+ return $this->_compile_include_php_tag($tag_args);
+
+ case 'if':
+ $this->_push_tag('if');
+ return $this->_compile_if_tag($tag_args);
+
+ case 'else':
+ list($_open_tag) = end($this->_tag_stack);
+ if ($_open_tag != 'if' && $_open_tag != 'elseif')
+ $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
+ else
+ $this->_push_tag('else');
+ return '<?php else: ?>';
+
+ case 'elseif':
+ list($_open_tag) = end($this->_tag_stack);
+ if ($_open_tag != 'if' && $_open_tag != 'elseif')
+ $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
+ if ($_open_tag == 'if')
+ $this->_push_tag('elseif');
+ return $this->_compile_if_tag($tag_args, true);
+
+ case '/if':
+ $this->_pop_tag('if');
+ return '<?php endif; ?>';
+
+ case 'capture':
+ return $this->_compile_capture_tag(true, $tag_args);
+
+ case '/capture':
+ return $this->_compile_capture_tag(false);
+
+ case 'ldelim':
+ return $this->left_delimiter;
+
+ case 'rdelim':
+ return $this->right_delimiter;
+
+ case 'section':
+ $this->_push_tag('section');
+ return $this->_compile_section_start($tag_args);
+
+ case 'sectionelse':
+ $this->_push_tag('sectionelse');
+ return "<?php endfor; else: ?>";
+ break;
+
+ case '/section':
+ $_open_tag = $this->_pop_tag('section');
+ if ($_open_tag == 'sectionelse')
+ return "<?php endif; ?>";
+ else
+ return "<?php endfor; endif; ?>";
+
+ case 'foreach':
+ $this->_push_tag('foreach');
+ return $this->_compile_foreach_start($tag_args);
+ break;
+
+ case 'foreachelse':
+ $this->_push_tag('foreachelse');
+ return "<?php endforeach; else: ?>";
+
+ case '/foreach':
+ $_open_tag = $this->_pop_tag('foreach');
+ if ($_open_tag == 'foreachelse')
+ return "<?php endif; unset(\$_from); ?>";
+ else
+ return "<?php endforeach; endif; unset(\$_from); ?>";
+ break;
+
+ case 'strip':
+ case '/strip':
+ if ($tag_command{0}=='/') {
+ $this->_pop_tag('strip');
+ if (--$this->_strip_depth==0) { /* outermost closing {/strip} */
+ $this->_additional_newline = "\n";
+ return '{' . $tag_command . '}';
+ }
+ } else {
+ $this->_push_tag('strip');
+ if ($this->_strip_depth++==0) { /* outermost opening {strip} */
+ $this->_additional_newline = "";
+ return '{' . $tag_command . '}';
+ }
+ }
+ return '';
+
+ case 'php':
+ /* handle folded tags replaced by {php} */
+ list(, $block) = each($this->_folded_blocks);
+ $this->_current_line_no += substr_count($block[0], "\n");
+ /* the number of matched elements in the regexp in _compile_file()
+ determins the type of folded tag that was found */
+ switch (count($block)) {
+ case 2: /* comment */
+ return '';
+
+ case 3: /* literal */
+ return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline;
+
+ case 4: /* php */
+ if ($this->security && !$this->security_settings['PHP_TAGS']) {
+ $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
+ return;
+ }
+ return '<?php ' . $block[3] .' ?>';
+ }
+ break;
+
+ case 'insert':
+ return $this->_compile_insert_tag($tag_args);
+
+ default:
+ if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {
+ return $output;
+ } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ return $output;
+ } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ return $output;
+ } else {
+ $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ }
+ }
+
+
+ /**
+ * compile the custom compiler tag
+ *
+ * sets $output to the compiled custom compiler tag
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $output
+ * @return boolean
+ */
+ function _compile_compiler_tag($tag_command, $tag_args, &$output)
+ {
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the compiler function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['compiler'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['compiler'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "compiler function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('compiler', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_compiler_' . $tag_command;
+ if (!is_callable($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['compiler'][$tag_command] = array($plugin_func, null, null, null, true);
+ }
+ }
+
+ /*
+ * True return value means that we either found a plugin or a
+ * dynamically registered function. False means that we didn't and the
+ * compiler should now emit code to load custom function plugin for this
+ * tag.
+ */
+ if ($found) {
+ if ($have_function) {
+ $output = call_user_func_array($plugin_func, array($tag_args, &$this));
+ if($output != '') {
+ $output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command)
+ . $output
+ . $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
+ }
+ } else {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * compile block function tag
+ *
+ * sets $output to compiled block function tag
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @param string $output
+ * @return boolean
+ */
+ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
+ {
+ if ($tag_command{0} == '/') {
+ $start_tag = false;
+ $tag_command = substr($tag_command, 1);
+ } else
+ $start_tag = true;
+
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the block function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['block'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['block'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "block function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('block', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_block_' . $tag_command;
+ if (!function_exists($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['block'][$tag_command] = array($plugin_func, null, null, null, true);
+
+ }
+ }
+
+ if (!$found) {
+ return false;
+ } else if (!$have_function) {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ return true;
+ }
+
+ /*
+ * Even though we've located the plugin function, compilation
+ * happens only once, so the plugin will still need to be loaded
+ * at runtime for future requests.
+ */
+ $this->_add_plugin('block', $tag_command);
+
+ if ($start_tag)
+ $this->_push_tag($tag_command);
+ else
+ $this->_pop_tag($tag_command);
+
+ if ($start_tag) {
+ $output = '<?php ' . $this->_push_cacheable_state('block', $tag_command);
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs='');
+ $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); ';
+ $output .= $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);';
+ $output .= 'while ($_block_repeat) { ob_start(); ?>';
+ } else {
+ $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); ';
+ $_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat=false)';
+ if ($tag_modifier != '') {
+ $this->_parse_modifiers($_out_tag_text, $tag_modifier);
+ }
+ $output .= 'echo '.$_out_tag_text.'; } ';
+ $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>';
+ }
+
+ return true;
+ }
+
+
+ /**
+ * compile custom function tag
+ *
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @return string
+ */
+ function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output)
+ {
+ $found = false;
+ $have_function = true;
+
+ /*
+ * First we check if the custom function has already been registered
+ * or loaded from a plugin file.
+ */
+ if (isset($this->_plugins['function'][$tag_command])) {
+ $found = true;
+ $plugin_func = $this->_plugins['function'][$tag_command][0];
+ if (!is_callable($plugin_func)) {
+ $message = "custom function '$tag_command' is not implemented";
+ $have_function = false;
+ }
+ }
+ /*
+ * Otherwise we need to load plugin file and look for the function
+ * inside it.
+ */
+ else if ($plugin_file = $this->_get_plugin_filepath('function', $tag_command)) {
+ $found = true;
+
+ include_once $plugin_file;
+
+ $plugin_func = 'smarty_function_' . $tag_command;
+ if (!function_exists($plugin_func)) {
+ $message = "plugin function $plugin_func() not found in $plugin_file\n";
+ $have_function = false;
+ } else {
+ $this->_plugins['function'][$tag_command] = array($plugin_func, null, null, null, true);
+
+ }
+ }
+
+ if (!$found) {
+ return false;
+ } else if (!$have_function) {
+ $this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
+ return true;
+ }
+
+ /* declare plugin to be loaded on display of the template that
+ we compile right now */
+ $this->_add_plugin('function', $tag_command);
+
+ $_cacheable_state = $this->_push_cacheable_state('function', $tag_command);
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs='');
+
+ $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)";
+ if($tag_modifier != '') {
+ $this->_parse_modifiers($output, $tag_modifier);
+ }
+
+ if($output != '') {
+ $output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';'
+ . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
+ }
+
+ return true;
+ }
+
+ /**
+ * compile a registered object tag
+ *
+ * @param string $tag_command
+ * @param array $attrs
+ * @param string $tag_modifier
+ * @return string
+ */
+ function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)
+ {
+ if ($tag_command{0} == '/') {
+ $start_tag = false;
+ $tag_command = substr($tag_command, 1);
+ } else {
+ $start_tag = true;
+ }
+
+ list($object, $obj_comp) = explode('->', $tag_command);
+
+ $arg_list = array();
+ if(count($attrs)) {
+ $_assign_var = false;
+ foreach ($attrs as $arg_name => $arg_value) {
+ if($arg_name == 'assign') {
+ $_assign_var = $arg_value;
+ unset($attrs['assign']);
+ continue;
+ }
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
+ if($this->_reg_objects[$object][2]) {
+ // smarty object argument format
+ $args = "array(".implode(',', (array)$arg_list)."), \$this";
+ } else {
+ // traditional argument format
+ $args = implode(',', array_values($attrs));
+ if (empty($args)) {
+ $args = 'null';
+ }
+ }
+
+ $prefix = '';
+ $postfix = '';
+ $newline = '';
+ if(!is_object($this->_reg_objects[$object][0])) {
+ $this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
+ $this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
+ // method
+ if(in_array($obj_comp, $this->_reg_objects[$object][3])) {
+ // block method
+ if ($start_tag) {
+ $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); ";
+ $prefix .= "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat=true); ";
+ $prefix .= "while (\$_block_repeat) { ob_start();";
+ $return = null;
+ $postfix = '';
+ } else {
+ $prefix = "\$_obj_block_content = ob_get_contents(); ob_end_clean(); ";
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$_obj_block_content, \$this, \$_block_repeat=false)";
+ $postfix = "} array_pop(\$this->_tag_stack);";
+ }
+ } else {
+ // non-block method
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp($args)";
+ }
+ } else {
+ // property
+ $return = "\$this->_reg_objects['$object'][0]->$obj_comp";
+ }
+
+ if($return != null) {
+ if($tag_modifier != '') {
+ $this->_parse_modifiers($return, $tag_modifier);
+ }
+
+ if(!empty($_assign_var)) {
+ $output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);";
+ } else {
+ $output = 'echo ' . $return . ';';
+ $newline = $this->_additional_newline;
+ }
+ } else {
+ $output = '';
+ }
+
+ return '<?php ' . $prefix . $output . $postfix . "?>" . $newline;
+ }
+
+ /**
+ * Compile {insert ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_insert_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $name = $this->_dequote($attrs['name']);
+
+ if (empty($name)) {
+ $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (!empty($attrs['script'])) {
+ $delayed_loading = true;
+ } else {
+ $delayed_loading = false;
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+
+ $this->_add_plugin('insert', $name, $delayed_loading);
+
+ $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
+
+ return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline;
+ }
+
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_include_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ if (empty($attrs['file'])) {
+ $this->_syntax_error("missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if ($arg_name == 'file') {
+ $include_file = $arg_value;
+ continue;
+ } else if ($arg_name == 'assign') {
+ $assign_var = $arg_value;
+ continue;
+ }
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+
+ $output = '<?php ';
+
+ if (isset($assign_var)) {
+ $output .= "ob_start();\n";
+ }
+
+ $output .=
+ "\$_smarty_tpl_vars = \$this->_tpl_vars;\n";
+
+
+ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
+ $output .= "\$this->_smarty_include($_params);\n" .
+ "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
+ "unset(\$_smarty_tpl_vars);\n";
+
+ if (isset($assign_var)) {
+ $output .= "\$this->assign(" . $assign_var . ", ob_get_contents()); ob_end_clean();\n";
+ }
+
+ $output .= ' ?>';
+
+ return $output;
+
+ }
+
+ /**
+ * Compile {include ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_include_php_tag($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+
+ if (empty($attrs['file'])) {
+ $this->_syntax_error("missing 'file' attribute in include_php tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $assign_var = (empty($attrs['assign'])) ? '' : $this->_dequote($attrs['assign']);
+ $once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true';
+
+ $arg_list = array();
+ foreach($attrs as $arg_name => $arg_value) {
+ if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
+ if(is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+
+ $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', $arg_list)."))";
+
+ return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline;
+ }
+
+
+ /**
+ * Compile {section ...} tag
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_section_start($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ $output = '<?php ';
+ $section_name = $attrs['name'];
+ if (empty($section_name)) {
+ $this->_syntax_error("missing section name", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $output .= "unset(\$this->_sections[$section_name]);\n";
+ $section_props = "\$this->_sections[$section_name]";
+
+ foreach ($attrs as $attr_name => $attr_value) {
+ switch ($attr_name) {
+ case 'loop':
+ $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
+ break;
+
+ case 'show':
+ if (is_bool($attr_value))
+ $show_attr_value = $attr_value ? 'true' : 'false';
+ else
+ $show_attr_value = "(bool)$attr_value";
+ $output .= "{$section_props}['show'] = $show_attr_value;\n";
+ break;
+
+ case 'name':
+ $output .= "{$section_props}['$attr_name'] = $attr_value;\n";
+ break;
+
+ case 'max':
+ case 'start':
+ $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n";
+ break;
+
+ case 'step':
+ $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
+ break;
+
+ default:
+ $this->_syntax_error("unknown section attribute - '$attr_name'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+ }
+
+ if (!isset($attrs['show']))
+ $output .= "{$section_props}['show'] = true;\n";
+
+ if (!isset($attrs['loop']))
+ $output .= "{$section_props}['loop'] = 1;\n";
+
+ if (!isset($attrs['max']))
+ $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
+ else
+ $output .= "if ({$section_props}['max'] < 0)\n" .
+ " {$section_props}['max'] = {$section_props}['loop'];\n";
+
+ if (!isset($attrs['step']))
+ $output .= "{$section_props}['step'] = 1;\n";
+
+ if (!isset($attrs['start']))
+ $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
+ else {
+ $output .= "if ({$section_props}['start'] < 0)\n" .
+ " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
+ "else\n" .
+ " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
+ }
+
+ $output .= "if ({$section_props}['show']) {\n";
+ if (!isset($attrs['start']) && !isset($attrs['step']) && !isset($attrs['max'])) {
+ $output .= " {$section_props}['total'] = {$section_props}['loop'];\n";
+ } else {
+ $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
+ }
+ $output .= " if ({$section_props}['total'] == 0)\n" .
+ " {$section_props}['show'] = false;\n" .
+ "} else\n" .
+ " {$section_props}['total'] = 0;\n";
+
+ $output .= "if ({$section_props}['show']):\n";
+ $output .= "
+ for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
+ {$section_props}['iteration'] <= {$section_props}['total'];
+ {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
+ $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n";
+ $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
+ $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
+ $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
+ $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
+
+ $output .= "?>";
+
+ return $output;
+ }
+
+
+ /**
+ * Compile {foreach ...} tag.
+ *
+ * @param string $tag_args
+ * @return string
+ */
+ function _compile_foreach_start($tag_args)
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+ $arg_list = array();
+
+ if (empty($attrs['from'])) {
+ return $this->_syntax_error("foreach: missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $from = $attrs['from'];
+
+ if (empty($attrs['item'])) {
+ return $this->_syntax_error("foreach: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $item = $this->_dequote($attrs['item']);
+ if (!preg_match('~^\w+$~', $item)) {
+ return $this->_syntax_error("'foreach: item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (isset($attrs['key'])) {
+ $key = $this->_dequote($attrs['key']);
+ if (!preg_match('~^\w+$~', $key)) {
+ return $this->_syntax_error("foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ $key_part = "\$this->_tpl_vars['$key'] => ";
+ } else {
+ $key = null;
+ $key_part = '';
+ }
+
+ if (isset($attrs['name'])) {
+ $name = $attrs['name'];
+ } else {
+ $name = null;
+ }
+
+ $output = '<?php ';
+ $output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
+ if (isset($name)) {
+ $foreach_props = "\$this->_foreach[$name]";
+ $output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n";
+ $output .= "if ({$foreach_props}['total'] > 0):\n";
+ $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
+ $output .= " {$foreach_props}['iteration']++;\n";
+ } else {
+ $output .= "if (count(\$_from)):\n";
+ $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
+ }
+ $output .= '?>';
+
+ return $output;
+ }
+
+
+ /**
+ * Compile {capture} .. {/capture} tags
+ *
+ * @param boolean $start true if this is the {capture} tag
+ * @param string $tag_args
+ * @return string
+ */
+
+ function _compile_capture_tag($start, $tag_args = '')
+ {
+ $attrs = $this->_parse_attrs($tag_args);
+
+ if ($start) {
+ if (isset($attrs['name']))
+ $buffer = $attrs['name'];
+ else
+ $buffer = "'default'";
+
+ if (isset($attrs['assign']))
+ $assign = $attrs['assign'];
+ else
+ $assign = null;
+ $output = "<?php ob_start(); ?>";
+ $this->_capture_stack[] = array($buffer, $assign);
+ } else {
+ list($buffer, $assign) = array_pop($this->_capture_stack);
+ $output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
+ if (isset($assign)) {
+ $output .= " \$this->assign($assign, ob_get_contents());";
+ }
+ $output .= "ob_end_clean(); ?>";
+ }
+
+ return $output;
+ }
+
+ /**
+ * Compile {if ...} tag
+ *
+ * @param string $tag_args
+ * @param boolean $elseif if true, uses elseif instead of if
+ * @return string
+ */
+ function _compile_if_tag($tag_args, $elseif = false)
+ {
+
+ /* Tokenize args for 'if' tag. */
+ preg_match_all('~(?>
+ ' . $this->_obj_call_regexp . '(?:' . $this->_mod_regexp . '*)? | # valid object call
+ ' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)? | # var or quoted string
+ \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
+ \b\w+\b | # valid word token
+ \S+ # anything else
+ )~x', $tag_args, $match);
+
+ $tokens = $match[0];
+
+ // make sure we have balanced parenthesis
+ $token_count = array_count_values($tokens);
+ if(isset($token_count['(']) && $token_count['('] != $token_count[')']) {
+ $this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ $is_arg_stack = array();
+
+ for ($i = 0; $i < count($tokens); $i++) {
+
+ $token = &$tokens[$i];
+
+ switch (strtolower($token)) {
+ case '!':
+ case '%':
+ case '!==':
+ case '==':
+ case '===':
+ case '>':
+ case '<':
+ case '!=':
+ case '<>':
+ case '<<':
+ case '>>':
+ case '<=':
+ case '>=':
+ case '&&':
+ case '||':
+ case '|':
+ case '^':
+ case '&':
+ case '~':
+ case ')':
+ case ',':
+ case '+':
+ case '-':
+ case '*':
+ case '/':
+ case '@':
+ break;
+
+ case 'eq':
+ $token = '==';
+ break;
+
+ case 'ne':
+ case 'neq':
+ $token = '!=';
+ break;
+
+ case 'lt':
+ $token = '<';
+ break;
+
+ case 'le':
+ case 'lte':
+ $token = '<=';
+ break;
+
+ case 'gt':
+ $token = '>';
+ break;
+
+ case 'ge':
+ case 'gte':
+ $token = '>=';
+ break;
+
+ case 'and':
+ $token = '&&';
+ break;
+
+ case 'or':
+ $token = '||';
+ break;
+
+ case 'not':
+ $token = '!';
+ break;
+
+ case 'mod':
+ $token = '%';
+ break;
+
+ case '(':
+ array_push($is_arg_stack, $i);
+ break;
+
+ case 'is':
+ /* If last token was a ')', we operate on the parenthesized
+ expression. The start of the expression is on the stack.
+ Otherwise, we operate on the last encountered token. */
+ if ($tokens[$i-1] == ')')
+ $is_arg_start = array_pop($is_arg_stack);
+ else
+ $is_arg_start = $i-1;
+ /* Construct the argument for 'is' expression, so it knows
+ what to operate on. */
+ $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
+
+ /* Pass all tokens from next one until the end to the
+ 'is' expression parsing function. The function will
+ return modified tokens, where the first one is the result
+ of the 'is' expression and the rest are the tokens it
+ didn't touch. */
+ $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
+
+ /* Replace the old tokens with the new ones. */
+ array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);
+
+ /* Adjust argument start so that it won't change from the
+ current position for the next iteration. */
+ $i = $is_arg_start;
+ break;
+
+ default:
+ if(preg_match('~^' . $this->_func_regexp . '$~', $token) ) {
+ // function call
+ if($this->security &&
+ !in_array($token, $this->security_settings['IF_FUNCS'])) {
+ $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') {
+ // variable function call
+ $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) {
+ // object or variable
+ $token = $this->_parse_var_props($token);
+ } elseif(is_numeric($token)) {
+ // number, skip it
+ } else {
+ $this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ break;
+ }
+ }
+
+ if ($elseif)
+ return '<?php elseif ('.implode(' ', $tokens).'): ?>';
+ else
+ return '<?php if ('.implode(' ', $tokens).'): ?>';
+ }
+
+
+ function _compile_arg_list($type, $name, $attrs, &$cache_code) {
+ $arg_list = array();
+
+ if (isset($type) && isset($name)
+ && isset($this->_plugins[$type])
+ && isset($this->_plugins[$type][$name])
+ && empty($this->_plugins[$type][$name][4])
+ && is_array($this->_plugins[$type][$name][5])
+ ) {
+ /* we have a list of parameters that should be cached */
+ $_cache_attrs = $this->_plugins[$type][$name][5];
+ $_count = $this->_cache_attrs_count++;
+ $cache_code = "\$_cache_attrs =& \$this->_smarty_cache_attrs('$this->_cache_serial','$_count');";
+
+ } else {
+ /* no parameters are cached */
+ $_cache_attrs = null;
+ }
+
+ foreach ($attrs as $arg_name => $arg_value) {
+ if (is_bool($arg_value))
+ $arg_value = $arg_value ? 'true' : 'false';
+ if (is_null($arg_value))
+ $arg_value = 'null';
+ if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) {
+ $arg_list[] = "'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)";
+ } else {
+ $arg_list[] = "'$arg_name' => $arg_value";
+ }
+ }
+ return $arg_list;
+ }
+
+ /**
+ * Parse is expression
+ *
+ * @param string $is_arg
+ * @param array $tokens
+ * @return array
+ */
+ function _parse_is_expr($is_arg, $tokens)
+ {
+ $expr_end = 0;
+ $negate_expr = false;
+
+ if (($first_token = array_shift($tokens)) == 'not') {
+ $negate_expr = true;
+ $expr_type = array_shift($tokens);
+ } else
+ $expr_type = $first_token;
+
+ switch ($expr_type) {
+ case 'even':
+ if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "!(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
+ } else
+ $expr = "!(1 & $is_arg)";
+ break;
+
+ case 'odd':
+ if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "(1 & ($is_arg / " . $this->_parse_var_props($expr_arg) . "))";
+ } else
+ $expr = "(1 & $is_arg)";
+ break;
+
+ case 'div':
+ if (@$tokens[$expr_end] == 'by') {
+ $expr_end++;
+ $expr_arg = $tokens[$expr_end++];
+ $expr = "!($is_arg % " . $this->_parse_var_props($expr_arg) . ")";
+ } else {
+ $this->_syntax_error("expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ break;
+
+ default:
+ $this->_syntax_error("unknown 'is' expression - '$expr_type'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+
+ if ($negate_expr) {
+ $expr = "!($expr)";
+ }
+
+ array_splice($tokens, 0, $expr_end, $expr);
+
+ return $tokens;
+ }
+
+
+ /**
+ * Parse attribute string
+ *
+ * @param string $tag_args
+ * @return array
+ */
+ function _parse_attrs($tag_args)
+ {
+
+ /* Tokenize tag attributes. */
+ preg_match_all('~(?:' . $this->_obj_call_regexp . '|' . $this->_qstr_regexp . ' | (?>[^"\'=\s]+)
+ )+ |
+ [=]
+ ~x', $tag_args, $match);
+ $tokens = $match[0];
+
+ $attrs = array();
+ /* Parse state:
+ 0 - expecting attribute name
+ 1 - expecting '='
+ 2 - expecting attribute value (not '=') */
+ $state = 0;
+
+ foreach ($tokens as $token) {
+ switch ($state) {
+ case 0:
+ /* If the token is a valid identifier, we set attribute name
+ and go to state 1. */
+ if (preg_match('~^\w+$~', $token)) {
+ $attr_name = $token;
+ $state = 1;
+ } else
+ $this->_syntax_error("invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+
+ case 1:
+ /* If the token is '=', then we go to state 2. */
+ if ($token == '=') {
+ $state = 2;
+ } else
+ $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+
+ case 2:
+ /* If token is not '=', we set the attribute value and go to
+ state 0. */
+ if ($token != '=') {
+ /* We booleanize the token if it's a non-quoted possible
+ boolean value. */
+ if (preg_match('~^(on|yes|true)$~', $token)) {
+ $token = 'true';
+ } else if (preg_match('~^(off|no|false)$~', $token)) {
+ $token = 'false';
+ } else if ($token == 'null') {
+ $token = 'null';
+ } else if (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) {
+ /* treat integer literally */
+ } else if (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) {
+ /* treat as a string, double-quote it escaping quotes */
+ $token = '"'.addslashes($token).'"';
+ }
+
+ $attrs[$attr_name] = $token;
+ $state = 0;
+ } else
+ $this->_syntax_error("'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+ $last_token = $token;
+ }
+
+ if($state != 0) {
+ if($state == 1) {
+ $this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
+ } else {
+ $this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ }
+
+ $this->_parse_vars_props($attrs);
+
+ return $attrs;
+ }
+
+ /**
+ * compile multiple variables and section properties tokens into
+ * PHP code
+ *
+ * @param array $tokens
+ */
+ function _parse_vars_props(&$tokens)
+ {
+ foreach($tokens as $key => $val) {
+ $tokens[$key] = $this->_parse_var_props($val);
+ }
+ }
+
+ /**
+ * compile single variable and section properties token into
+ * PHP code
+ *
+ * @param string $val
+ * @param string $tag_attrs
+ * @return string
+ */
+ function _parse_var_props($val)
+ {
+ $val = trim($val);
+
+ if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) {
+ // $ variable or object
+ $return = $this->_parse_var($match[1]);
+ $modifiers = $match[2];
+ if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) {
+ $_default_mod_string = implode('|',(array)$this->default_modifiers);
+ $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
+ }
+ $this->_parse_modifiers($return, $modifiers);
+ return $return;
+ } elseif (preg_match('~^' . $this->_db_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // double quoted text
+ preg_match('~^(' . $this->_db_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ $return = $this->_expand_quoted_text($match[1]);
+ if($match[2] != '') {
+ $this->_parse_modifiers($return, $match[2]);
+ }
+ return $return;
+ }
+ elseif(preg_match('~^' . $this->_num_const_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // numerical constant
+ preg_match('~^(' . $this->_num_const_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ if($match[2] != '') {
+ $this->_parse_modifiers($match[1], $match[2]);
+ return $match[1];
+ }
+ }
+ elseif(preg_match('~^' . $this->_si_qstr_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // single quoted text
+ preg_match('~^(' . $this->_si_qstr_regexp . ')('. $this->_mod_regexp . '*)$~', $val, $match);
+ if($match[2] != '') {
+ $this->_parse_modifiers($match[1], $match[2]);
+ return $match[1];
+ }
+ }
+ elseif(preg_match('~^' . $this->_cvar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // config var
+ return $this->_parse_conf_var($val);
+ }
+ elseif(preg_match('~^' . $this->_svar_regexp . '(?:' . $this->_mod_regexp . '*)$~', $val)) {
+ // section var
+ return $this->_parse_section_prop($val);
+ }
+ elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
+ // literal string
+ return $this->_expand_quoted_text('"' . $val .'"');
+ }
+ return $val;
+ }
+
+ /**
+ * expand quoted text with embedded variables
+ *
+ * @param string $var_expr
+ * @return string
+ */
+ function _expand_quoted_text($var_expr)
+ {
+ // if contains unescaped $, expand it
+ if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) {
+ $_match = $_match[0];
+ rsort($_match);
+ reset($_match);
+ foreach($_match as $_var) {
+ $var_expr = str_replace ($_var, '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."', $var_expr);
+ }
+ $_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr);
+ } else {
+ $_return = $var_expr;
+ }
+ // replace double quoted literal string with single quotes
+ $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return);
+ return $_return;
+ }
+
+ /**
+ * parse variable expression into PHP code
+ *
+ * @param string $var_expr
+ * @param string $output
+ * @return string
+ */
+ function _parse_var($var_expr)
+ {
+ $_has_math = false;
+ $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ if(count($_math_vars) > 1) {
+ $_first_var = "";
+ $_complete_var = "";
+ $_output = "";
+ // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
+ foreach($_math_vars as $_k => $_math_var) {
+ $_math_var = $_math_vars[$_k];
+
+ if(!empty($_math_var) || is_numeric($_math_var)) {
+ // hit a math operator, so process the stuff which came before it
+ if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) {
+ $_has_math = true;
+ if(!empty($_complete_var) || is_numeric($_complete_var)) {
+ $_output .= $this->_parse_var($_complete_var);
+ }
+
+ // just output the math operator to php
+ $_output .= $_math_var;
+
+ if(empty($_first_var))
+ $_first_var = $_complete_var;
+
+ $_complete_var = "";
+ } else {
+ $_complete_var .= $_math_var;
+ }
+ }
+ }
+ if($_has_math) {
+ if(!empty($_complete_var) || is_numeric($_complete_var))
+ $_output .= $this->_parse_var($_complete_var);
+
+ // get the modifiers working (only the last var from math + modifier is left)
+ $var_expr = $_complete_var;
+ }
+ }
+
+ // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
+ if(is_numeric($var_expr{0}))
+ $_var_ref = $var_expr;
+ else
+ $_var_ref = substr($var_expr, 1);
+
+ if(!$_has_math) {
+
+ // get [foo] and .foo and ->foo and (...) pieces
+ preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match);
+
+ $_indexes = $match[0];
+ $_var_name = array_shift($_indexes);
+
+ /* Handle $smarty.* variable references as a special case. */
+ if ($_var_name == 'smarty') {
+ /*
+ * If the reference could be compiled, use the compiled output;
+ * otherwise, fall back on the $smarty variable generated at
+ * run-time.
+ */
+ if (($smarty_ref = $this->_compile_smarty_ref($_indexes)) !== null) {
+ $_output = $smarty_ref;
+ } else {
+ $_var_name = substr(array_shift($_indexes), 1);
+ $_output = "\$this->_smarty_vars['$_var_name']";
+ }
+ } elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) {
+ // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
+ if(count($_indexes) > 0)
+ {
+ $_var_name .= implode("", $_indexes);
+ $_indexes = array();
+ }
+ $_output = $_var_name;
+ } else {
+ $_output = "\$this->_tpl_vars['$_var_name']";
+ }
+
+ foreach ($_indexes as $_index) {
+ if ($_index{0} == '[') {
+ $_index = substr($_index, 1, -1);
+ if (is_numeric($_index)) {
+ $_output .= "[$_index]";
+ } elseif ($_index{0} == '$') {
+ if (strpos($_index, '.') !== false) {
+ $_output .= '[' . $this->_parse_var($_index) . ']';
+ } else {
+ $_output .= "[\$this->_tpl_vars['" . substr($_index, 1) . "']]";
+ }
+ } else {
+ $_var_parts = explode('.', $_index);
+ $_var_section = $_var_parts[0];
+ $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] : 'index';
+ $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]";
+ }
+ } else if ($_index{0} == '.') {
+ if ($_index{1} == '$')
+ $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
+ else
+ $_output .= "['" . substr($_index, 1) . "']";
+ } else if (substr($_index,0,2) == '->') {
+ if(substr($_index,2,2) == '__') {
+ $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } elseif($this->security && substr($_index, 2, 1) == '_') {
+ $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } elseif ($_index{2} == '$') {
+ if ($this->security) {
+ $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
+ } else {
+ $_output .= '->{(($_var=$this->_tpl_vars[\''.substr($_index,3).'\']) && substr($_var,0,2)!=\'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}';
+ }
+ } else {
+ $_output .= $_index;
+ }
+ } elseif ($_index{0} == '(') {
+ $_index = $this->_parse_parenth_args($_index);
+ $_output .= $_index;
+ } else {
+ $_output .= $_index;
+ }
+ }
+ }
+
+ return $_output;
+ }
+
+ /**
+ * parse arguments in function call parenthesis
+ *
+ * @param string $parenth_args
+ * @return string
+ */
+ function _parse_parenth_args($parenth_args)
+ {
+ preg_match_all('~' . $this->_param_regexp . '~',$parenth_args, $match);
+ $orig_vals = $match = $match[0];
+ $this->_parse_vars_props($match);
+ $replace = array();
+ for ($i = 0, $count = count($match); $i < $count; $i++) {
+ $replace[$orig_vals[$i]] = $match[$i];
+ }
+ return strtr($parenth_args, $replace);
+ }
+
+ /**
+ * parse configuration variable expression into PHP code
+ *
+ * @param string $conf_var_expr
+ */
+ function _parse_conf_var($conf_var_expr)
+ {
+ $parts = explode('|', $conf_var_expr, 2);
+ $var_ref = $parts[0];
+ $modifiers = isset($parts[1]) ? $parts[1] : '';
+
+ $var_name = substr($var_ref, 1, -1);
+
+ $output = "\$this->_config[0]['vars']['$var_name']";
+
+ $this->_parse_modifiers($output, $modifiers);
+
+ return $output;
+ }
+
+ /**
+ * parse section property expression into PHP code
+ *
+ * @param string $section_prop_expr
+ * @return string
+ */
+ function _parse_section_prop($section_prop_expr)
+ {
+ $parts = explode('|', $section_prop_expr, 2);
+ $var_ref = $parts[0];
+ $modifiers = isset($parts[1]) ? $parts[1] : '';
+
+ preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match);
+ $section_name = $match[1];
+ $prop_name = $match[2];
+
+ $output = "\$this->_sections['$section_name']['$prop_name']";
+
+ $this->_parse_modifiers($output, $modifiers);
+
+ return $output;
+ }
+
+
+ /**
+ * parse modifier chain into PHP code
+ *
+ * sets $output to parsed modified chain
+ * @param string $output
+ * @param string $modifier_string
+ */
+ function _parse_modifiers(&$output, $modifier_string)
+ {
+ preg_match_all('~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)~', '|' . $modifier_string, $_match);
+ list(, $_modifiers, $modifier_arg_strings) = $_match;
+
+ for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
+ $_modifier_name = $_modifiers[$_i];
+
+ if($_modifier_name == 'smarty') {
+ // skip smarty modifier
+ continue;
+ }
+
+ preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match);
+ $_modifier_args = $_match[1];
+
+ if ($_modifier_name{0} == '@') {
+ $_map_array = false;
+ $_modifier_name = substr($_modifier_name, 1);
+ } else {
+ $_map_array = true;
+ }
+
+ if (empty($this->_plugins['modifier'][$_modifier_name])
+ && !$this->_get_plugin_filepath('modifier', $_modifier_name)
+ && function_exists($_modifier_name)) {
+ if ($this->security && !in_array($_modifier_name, $this->security_settings['MODIFIER_FUNCS'])) {
+ $this->_trigger_fatal_error("[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
+ } else {
+ $this->_plugins['modifier'][$_modifier_name] = array($_modifier_name, null, null, false);
+ }
+ }
+ $this->_add_plugin('modifier', $_modifier_name);
+
+ $this->_parse_vars_props($_modifier_args);
+
+ if($_modifier_name == 'default') {
+ // supress notifications of default modifier vars and args
+ if($output{0} == '$') {
+ $output = '@' . $output;
+ }
+ if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') {
+ $_modifier_args[0] = '@' . $_modifier_args[0];
+ }
+ }
+ if (count($_modifier_args) > 0)
+ $_modifier_args = ', '.implode(', ', $_modifier_args);
+ else
+ $_modifier_args = '';
+
+ if ($_map_array) {
+ $output = "((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->_compile_plugin_call('modifier', $_modifier_name) . "(\$_tmp$_modifier_args))";
+
+ } else {
+
+ $output = $this->_compile_plugin_call('modifier', $_modifier_name)."($output$_modifier_args)";
+
+ }
+ }
+ }
+
+
+ /**
+ * add plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @param boolean? $delayed_loading
+ */
+ function _add_plugin($type, $name, $delayed_loading = null)
+ {
+ if (!isset($this->_plugin_info[$type])) {
+ $this->_plugin_info[$type] = array();
+ }
+ if (!isset($this->_plugin_info[$type][$name])) {
+ $this->_plugin_info[$type][$name] = array($this->_current_file,
+ $this->_current_line_no,
+ $delayed_loading);
+ }
+ }
+
+
+ /**
+ * Compiles references of type $smarty.foo
+ *
+ * @param string $indexes
+ * @return string
+ */
+ function _compile_smarty_ref(&$indexes)
+ {
+ /* Extract the reference name. */
+ $_ref = substr($indexes[0], 1);
+ foreach($indexes as $_index_no=>$_index) {
+ if ($_index{0} != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) {
+ $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
+ }
+ }
+
+ switch ($_ref) {
+ case 'now':
+ $compiled_ref = 'time()';
+ $_max_index = 1;
+ break;
+
+ case 'foreach':
+ array_shift($indexes);
+ $_var = $this->_parse_var_props(substr($indexes[0], 1));
+ $_propname = substr($indexes[1], 1);
+ $_max_index = 1;
+ switch ($_propname) {
+ case 'index':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration']-1)";
+ break;
+
+ case 'first':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration'] <= 1)";
+ break;
+
+ case 'last':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'])";
+ break;
+
+ case 'show':
+ array_shift($indexes);
+ $compiled_ref = "(\$this->_foreach[$_var]['total'] > 0)";
+ break;
+
+ default:
+ unset($_max_index);
+ $compiled_ref = "\$this->_foreach[$_var]";
+ }
+ break;
+
+ case 'section':
+ array_shift($indexes);
+ $_var = $this->_parse_var_props(substr($indexes[0], 1));
+ $compiled_ref = "\$this->_sections[$_var]";
+ break;
+
+ case 'get':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']";
+ break;
+
+ case 'post':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']";
+ break;
+
+ case 'cookies':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']";
+ break;
+
+ case 'env':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']";
+ break;
+
+ case 'server':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']";
+ break;
+
+ case 'session':
+ $compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']";
+ break;
+
+ /*
+ * These cases are handled either at run-time or elsewhere in the
+ * compiler.
+ */
+ case 'request':
+ if ($this->request_use_auto_globals) {
+ $compiled_ref = '$_REQUEST';
+ break;
+ } else {
+ $this->_init_smarty_vars = true;
+ }
+ return null;
+
+ case 'capture':
+ return null;
+
+ case 'template':
+ $compiled_ref = "'$this->_current_file'";
+ $_max_index = 1;
+ break;
+
+ case 'version':
+ $compiled_ref = "'$this->_version'";
+ $_max_index = 1;
+ break;
+
+ case 'const':
+ if ($this->security && !$this->security_settings['ALLOW_CONSTANTS']) {
+ $this->_syntax_error("(secure mode) constants not permitted",
+ E_USER_WARNING, __FILE__, __LINE__);
+ return;
+ }
+ array_shift($indexes);
+ if (preg_match('!^\.\w+$!', $indexes[0])) {
+ $compiled_ref = '@' . substr($indexes[0], 1);
+ } else {
+ $_val = $this->_parse_var_props(substr($indexes[0], 1));
+ $compiled_ref = '@constant(' . $_val . ')';
+ }
+ $_max_index = 1;
+ break;
+
+ case 'config':
+ $compiled_ref = "\$this->_config[0]['vars']";
+ $_max_index = 3;
+ break;
+
+ case 'ldelim':
+ $compiled_ref = "'$this->left_delimiter'";
+ break;
+
+ case 'rdelim':
+ $compiled_ref = "'$this->right_delimiter'";
+ break;
+
+ default:
+ $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__);
+ break;
+ }
+
+ if (isset($_max_index) && count($indexes) > $_max_index) {
+ $this->_syntax_error('$smarty' . implode('', $indexes) .' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ array_shift($indexes);
+ return $compiled_ref;
+ }
+
+ /**
+ * compiles call to plugin of type $type with name $name
+ * returns a string containing the function-name or method call
+ * without the paramter-list that would have follow to make the
+ * call valid php-syntax
+ *
+ * @param string $type
+ * @param string $name
+ * @return string
+ */
+ function _compile_plugin_call($type, $name) {
+ if (isset($this->_plugins[$type][$name])) {
+ /* plugin loaded */
+ if (is_array($this->_plugins[$type][$name][0])) {
+ return ((is_object($this->_plugins[$type][$name][0][0])) ?
+ "\$this->_plugins['$type']['$name'][0][0]->" /* method callback */
+ : (string)($this->_plugins[$type][$name][0][0]).'::' /* class callback */
+ ). $this->_plugins[$type][$name][0][1];
+
+ } else {
+ /* function callback */
+ return $this->_plugins[$type][$name][0];
+
+ }
+ } else {
+ /* plugin not loaded -> auto-loadable-plugin */
+ return 'smarty_'.$type.'_'.$name;
+
+ }
+ }
+
+ /**
+ * load pre- and post-filters
+ */
+ function _load_filters()
+ {
+ if (count($this->_plugins['prefilter']) > 0) {
+ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
+ if ($prefilter === false) {
+ unset($this->_plugins['prefilter'][$filter_name]);
+ $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ }
+ }
+ }
+ if (count($this->_plugins['postfilter']) > 0) {
+ foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
+ if ($postfilter === false) {
+ unset($this->_plugins['postfilter'][$filter_name]);
+ $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false)));
+ require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+ smarty_core_load_plugins($_params, $this);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Quote subpattern references
+ *
+ * @param string $string
+ * @return string
+ */
+ function _quote_replace($string)
+ {
+ return strtr($string, array('\\' => '\\\\', '$' => '\\$'));
+ }
+
+ /**
+ * display Smarty syntax error
+ *
+ * @param string $error_msg
+ * @param integer $error_type
+ * @param string $file
+ * @param integer $line
+ */
+ function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null)
+ {
+ $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type);
+ }
+
+
+ /**
+ * check if the compilation changes from cacheable to
+ * non-cacheable state with the beginning of the current
+ * plugin. return php-code to reflect the transition.
+ * @return string
+ */
+ function _push_cacheable_state($type, $name) {
+ $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
+ if ($_cacheable
+ || 0<$this->_cacheable_state++) return '';
+ if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
+ $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:'
+ . $this->_cache_serial . '#' . $this->_nocache_count
+ . '}\';}';
+ return $_ret;
+ }
+
+
+ /**
+ * check if the compilation changes from non-cacheable to
+ * cacheable state with the end of the current plugin return
+ * php-code to reflect the transition.
+ * @return string
+ */
+ function _pop_cacheable_state($type, $name) {
+ $_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
+ if ($_cacheable
+ || --$this->_cacheable_state>0) return '';
+ return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
+ . $this->_cache_serial . '#' . ($this->_nocache_count++)
+ . '}\';}';
+ }
+
+
+ /**
+ * push opening tag-name, file-name and line-number on the tag-stack
+ * @param string the opening tag's name
+ */
+ function _push_tag($open_tag)
+ {
+ array_push($this->_tag_stack, array($open_tag, $this->_current_line_no));
+ }
+
+ /**
+ * pop closing tag-name
+ * raise an error if this stack-top doesn't match with the closing tag
+ * @param string the closing tag's name
+ * @return string the opening tag's name
+ */
+ function _pop_tag($close_tag)
+ {
+ $message = '';
+ if (count($this->_tag_stack)>0) {
+ list($_open_tag, $_line_no) = array_pop($this->_tag_stack);
+ if ($close_tag == $_open_tag) {
+ return $_open_tag;
+ }
+ if ($close_tag == 'if' && ($_open_tag == 'else' || $_open_tag == 'elseif' )) {
+ return $this->_pop_tag($close_tag);
+ }
+ if ($close_tag == 'section' && $_open_tag == 'sectionelse') {
+ $this->_pop_tag($close_tag);
+ return $_open_tag;
+ }
+ if ($close_tag == 'foreach' && $_open_tag == 'foreachelse') {
+ $this->_pop_tag($close_tag);
+ return $_open_tag;
+ }
+ if ($_open_tag == 'else' || $_open_tag == 'elseif') {
+ $_open_tag = 'if';
+ } elseif ($_open_tag == 'sectionelse') {
+ $_open_tag = 'section';
+ } elseif ($_open_tag == 'foreachelse') {
+ $_open_tag = 'foreach';
+ }
+ $message = " expected {/$_open_tag} (opened line $_line_no).";
+ }
+ $this->_syntax_error("mismatched tag {/$close_tag}.$message",
+ E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+}
+
+/**
+ * compare to values by their string length
+ *
+ * @access private
+ * @param string $a
+ * @param string $b
+ * @return 0|-1|1
+ */
+function _smarty_sort_length($a, $b)
+{
+ if($a == $b)
+ return 0;
+
+ if(strlen($a) == strlen($b))
+ return ($a > $b) ? -1 : 1;
+
+ return (strlen($a) > strlen($b)) ? -1 : 1;
+}
+
+
+/* vim: set et: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.assemble_auto_filename.php b/html/phpgacl/admin/smarty_x/libs/core/core.assemble_auto_filename.php
new file mode 100644
index 0000000..c43dee9
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.assemble_auto_filename.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * get a concrete filename for automagically created content
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @return string
+ * @staticvar string|null
+ * @staticvar string|null
+ */
+function smarty_core_assemble_auto_filename($params, &$smarty)
+{
+
+ $_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
+
+ if(@is_dir($params['auto_base'])) {
+ $_return = $params['auto_base'] . DIRECTORY_SEPARATOR;
+ } else {
+ // auto_base not found, try include_path
+ $_params = array('file_path' => $params['auto_base']);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
+ smarty_core_get_include_path($_params, $smarty);
+ $_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null;
+ }
+
+ if(isset($params['auto_id'])) {
+ // make auto_id safe for directory names
+ $params['auto_id'] = str_replace('%7C','|',(urlencode($params['auto_id'])));
+ // split into separate directories
+ $params['auto_id'] = str_replace('|', $_compile_dir_sep, $params['auto_id']);
+ $_return .= $params['auto_id'] . $_compile_dir_sep;
+ }
+
+ if(isset($params['auto_source'])) {
+ // make source name safe for filename
+ $_filename = urlencode(basename($params['auto_source']));
+ $_crc32 = crc32($params['auto_source']) . $_compile_dir_sep;
+ // prepend %% to avoid name conflicts with
+ // with $params['auto_id'] names
+ $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
+ $_return .= $_crc32 . $_filename;
+ }
+
+ return $_return;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.assemble_plugin_filepath.php b/html/phpgacl/admin/smarty_x/libs/core/core.assemble_plugin_filepath.php
new file mode 100644
index 0000000..cb8f544
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.assemble_plugin_filepath.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * assemble filepath of requested plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @return string|false
+ */
+function smarty_core_assemble_plugin_filepath($params, &$smarty)
+{
+ static $_filepaths_cache = array();
+
+ $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
+ if (isset($_filepaths_cache[$_plugin_filename])) {
+ return $_filepaths_cache[$_plugin_filename];
+ }
+ $_return = false;
+
+ foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ // see if path is relative
+ if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
+ $_relative_paths[] = $_plugin_dir;
+ // relative path, see if it is in the SMARTY_DIR
+ if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
+ $_return = SMARTY_DIR . $_plugin_filepath;
+ break;
+ }
+ }
+ // try relative to cwd (or absolute)
+ if (@is_readable($_plugin_filepath)) {
+ $_return = $_plugin_filepath;
+ break;
+ }
+ }
+
+ if($_return === false) {
+ // still not found, try PHP include_path
+ if(isset($_relative_paths)) {
+ foreach ((array)$_relative_paths as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ $_params = array('file_path' => $_plugin_filepath);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_return = $_params['new_file_path'];
+ break;
+ }
+ }
+ }
+ }
+ $_filepaths_cache[$_plugin_filename] = $_return;
+ return $_return;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.assign_smarty_interface.php b/html/phpgacl/admin/smarty_x/libs/core/core.assign_smarty_interface.php
new file mode 100644
index 0000000..7e65a73
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.assign_smarty_interface.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty assign_smarty_interface core plugin
+ *
+ * Type: core<br>
+ * Name: assign_smarty_interface<br>
+ * Purpose: assign the $smarty interface variable
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_assign_smarty_interface($params, &$smarty)
+{
+ if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
+ return;
+ }
+
+ $_globals_map = array('g' => 'HTTP_GET_VARS',
+ 'p' => 'HTTP_POST_VARS',
+ 'c' => 'HTTP_COOKIE_VARS',
+ 's' => 'HTTP_SERVER_VARS',
+ 'e' => 'HTTP_ENV_VARS');
+
+ $_smarty_vars_request = array();
+
+ foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
+ if (isset($_globals_map[$_c])) {
+ $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
+ }
+ }
+ $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
+
+ $smarty->_smarty_vars['request'] = $_smarty_vars_request;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.create_dir_structure.php b/html/phpgacl/admin/smarty_x/libs/core/core.create_dir_structure.php
new file mode 100644
index 0000000..999cf59
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.create_dir_structure.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * create full directory structure
+ *
+ * @param string $dir
+ */
+
+// $dir
+
+function smarty_core_create_dir_structure($params, &$smarty)
+{
+ if (!file_exists($params['dir'])) {
+ $_open_basedir_ini = ini_get('open_basedir');
+
+ if (DIRECTORY_SEPARATOR=='/') {
+ /* unix-style paths */
+ $_dir = $params['dir'];
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/';
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(':', $_open_basedir_ini);
+ }
+
+ } else {
+ /* other-style paths */
+ $_dir = str_replace('\\','/', $params['dir']);
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
+ /* leading "//" for network volume, or "[letter]:/" for full path */
+ $_new_dir = $_root_dir[1];
+ /* remove drive-letter from _dir_parts */
+ if (isset($_root_dir[3])) array_shift($_dir_parts);
+
+ } else {
+ $_new_dir = str_replace('\\', '/', getcwd()).'/';
+
+ }
+
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
+ }
+
+ }
+
+ /* all paths use "/" only from here */
+ foreach ($_dir_parts as $_dir_part) {
+ $_new_dir .= $_dir_part;
+
+ if ($_use_open_basedir) {
+ // do not attempt to test or make directories outside of open_basedir
+ $_make_new_dir = false;
+ foreach ($_open_basedirs as $_open_basedir) {
+ if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
+ $_make_new_dir = true;
+ break;
+ }
+ }
+ } else {
+ $_make_new_dir = true;
+ }
+
+ if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
+ $smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
+ return false;
+ }
+ $_new_dir .= '/';
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.display_debug_console.php b/html/phpgacl/admin/smarty_x/libs/core/core.display_debug_console.php
new file mode 100644
index 0000000..a5d7291
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.display_debug_console.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty debug_console function plugin
+ *
+ * Type: core<br>
+ * Name: display_debug_console<br>
+ * Purpose: display the javascript debug console window
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_display_debug_console($params, &$smarty)
+{
+ // we must force compile the debug template in case the environment
+ // changed between separate applications.
+
+ if(empty($smarty->debug_tpl)) {
+ // set path to debug template from SMARTY_DIR
+ $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
+ if($smarty->security && is_file($smarty->debug_tpl)) {
+ $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
+ }
+ $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
+ }
+
+ $_ldelim_orig = $smarty->left_delimiter;
+ $_rdelim_orig = $smarty->right_delimiter;
+
+ $smarty->left_delimiter = '{';
+ $smarty->right_delimiter = '}';
+
+ $_compile_id_orig = $smarty->_compile_id;
+ $smarty->_compile_id = null;
+
+ $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
+ if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
+ {
+ ob_start();
+ $smarty->_include($_compile_path);
+ $_results = ob_get_contents();
+ ob_end_clean();
+ } else {
+ $_results = '';
+ }
+
+ $smarty->_compile_id = $_compile_id_orig;
+
+ $smarty->left_delimiter = $_ldelim_orig;
+ $smarty->right_delimiter = $_rdelim_orig;
+
+ return $_results;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.get_include_path.php b/html/phpgacl/admin/smarty_x/libs/core/core.get_include_path.php
new file mode 100644
index 0000000..4343241
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.get_include_path.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get path to file from include_path
+ *
+ * @param string $file_path
+ * @param string $new_file_path
+ * @return boolean
+ * @staticvar array|null
+ */
+
+// $file_path, &$new_file_path
+
+function smarty_core_get_include_path(&$params, &$smarty)
+{
+ static $_path_array = null;
+
+ if(!isset($_path_array)) {
+ $_ini_include_path = ini_get('include_path');
+
+ if(strstr($_ini_include_path,';')) {
+ // windows pathnames
+ $_path_array = explode(';',$_ini_include_path);
+ } else {
+ $_path_array = explode(':',$_ini_include_path);
+ }
+ }
+ foreach ($_path_array as $_include_path) {
+ if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
+ $params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
+ return true;
+ }
+ }
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.get_microtime.php b/html/phpgacl/admin/smarty_x/libs/core/core.get_microtime.php
new file mode 100644
index 0000000..f1a28e0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.get_microtime.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get seconds and microseconds
+ * @return double
+ */
+function smarty_core_get_microtime($params, &$smarty)
+{
+ $mtime = microtime();
+ $mtime = explode(" ", $mtime);
+ $mtime = (double)($mtime[1]) + (double)($mtime[0]);
+ return ($mtime);
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.get_php_resource.php b/html/phpgacl/admin/smarty_x/libs/core/core.get_php_resource.php
new file mode 100644
index 0000000..8121acf
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.get_php_resource.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Retrieves PHP script resource
+ *
+ * sets $php_resource to the returned resource
+ * @param string $resource
+ * @param string $resource_type
+ * @param $php_resource
+ * @return boolean
+ */
+
+function smarty_core_get_php_resource(&$params, &$smarty)
+{
+
+ $params['resource_base_path'] = $smarty->trusted_dir;
+ $smarty->_parse_resource_name($params, $smarty);
+
+ /*
+ * Find out if the resource exists.
+ */
+
+ if ($params['resource_type'] == 'file') {
+ $_readable = false;
+ if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
+ $_readable = true;
+ } else {
+ // test for file in include_path
+ $_params = array('file_path' => $params['resource_name']);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_include_path = $_params['new_file_path'];
+ $_readable = true;
+ }
+ }
+ } else if ($params['resource_type'] != 'file') {
+ $_template_source = null;
+ $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
+ && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
+ array($params['resource_name'], &$_template_source, &$smarty));
+ }
+
+ /*
+ * Set the error function, depending on which class calls us.
+ */
+ if (method_exists($smarty, '_syntax_error')) {
+ $_error_funcc = '_syntax_error';
+ } else {
+ $_error_funcc = 'trigger_error';
+ }
+
+ if ($_readable) {
+ if ($smarty->security) {
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php');
+ if (!smarty_core_is_trusted($params, $smarty)) {
+ $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
+ return false;
+ }
+ }
+ } else {
+ $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
+ return false;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $params['php_resource'] = $params['resource_name'];
+ } else {
+ $params['php_resource'] = $_template_source;
+ }
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.is_secure.php b/html/phpgacl/admin/smarty_x/libs/core/core.is_secure.php
new file mode 100644
index 0000000..342f3af
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.is_secure.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * determines if a resource is secure or not.
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+// $resource_type, $resource_name
+
+function smarty_core_is_secure($params, &$smarty)
+{
+ if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
+ return true;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $_rp = realpath($params['resource_name']);
+ if (isset($params['resource_base_path'])) {
+ foreach ((array)$params['resource_base_path'] as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ if (!empty($smarty->secure_dir)) {
+ foreach ((array)$smarty->secure_dir as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ // resource is not on local file system
+ return call_user_func_array(
+ $smarty->_plugins['resource'][$params['resource_type']][0][2],
+ array($params['resource_name'], &$smarty));
+ }
+
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.is_trusted.php b/html/phpgacl/admin/smarty_x/libs/core/core.is_trusted.php
new file mode 100644
index 0000000..c90e3ef
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.is_trusted.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**#@+
+ * @access private
+ */
+/**
+ * determines if a resource is trusted or not
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+ // $resource_type, $resource_name
+
+function smarty_core_is_trusted($params, &$smarty)
+{
+ $_smarty_trusted = false;
+ if ($params['resource_type'] == 'file') {
+ if (!empty($smarty->trusted_dir)) {
+ $_rp = realpath($params['resource_name']);
+ foreach ((array)$smarty->trusted_dir as $curr_dir) {
+ if (!empty($curr_dir) && is_readable ($curr_dir)) {
+ $_cd = realpath($curr_dir);
+ if (strncmp($_rp, $_cd, strlen($_cd)) == 0
+ && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ $_smarty_trusted = true;
+ break;
+ }
+ }
+ }
+ }
+
+ } else {
+ // resource is not on local file system
+ $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
+ array($params['resource_name'], $smarty));
+ }
+
+ return $_smarty_trusted;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.load_plugins.php b/html/phpgacl/admin/smarty_x/libs/core/core.load_plugins.php
new file mode 100644
index 0000000..6db1dc5
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.load_plugins.php
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Load requested plugins
+ *
+ * @param array $plugins
+ */
+
+// $plugins
+
+function smarty_core_load_plugins($params, &$smarty)
+{
+
+ foreach ($params['plugins'] as $_plugin_info) {
+ list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
+ $_plugin = &$smarty->_plugins[$_type][$_name];
+
+ /*
+ * We do not load plugin more than once for each instance of Smarty.
+ * The following code checks for that. The plugin can also be
+ * registered dynamically at runtime, in which case template file
+ * and line number will be unknown, so we fill them in.
+ *
+ * The final element of the info array is a flag that indicates
+ * whether the dynamically registered plugin function has been
+ * checked for existence yet or not.
+ */
+ if (isset($_plugin)) {
+ if (empty($_plugin[3])) {
+ if (!is_callable($_plugin[0])) {
+ $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ } else {
+ $_plugin[1] = $_tpl_file;
+ $_plugin[2] = $_tpl_line;
+ $_plugin[3] = true;
+ if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
+ }
+ }
+ continue;
+ } else if ($_type == 'insert') {
+ /*
+ * For backwards compatibility, we check for insert functions in
+ * the symbol table before trying to load them as a plugin.
+ */
+ $_plugin_func = 'insert_' . $_name;
+ if (function_exists($_plugin_func)) {
+ $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
+ continue;
+ }
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
+
+ if (! $_found = ($_plugin_file != false)) {
+ $_message = "could not load plugin file '$_type.$_name.php'\n";
+ }
+
+ /*
+ * If plugin file is found, it -must- provide the properly named
+ * plugin function. In case it doesn't, simply output the error and
+ * do not fall back on any other method.
+ */
+ if ($_found) {
+ include_once $_plugin_file;
+
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ continue;
+ }
+ }
+ /*
+ * In case of insert plugins, their code may be loaded later via
+ * 'script' attribute.
+ */
+ else if ($_type == 'insert' && $_delayed_loading) {
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ $_found = true;
+ }
+
+ /*
+ * Plugin specific processing and error checking.
+ */
+ if (!$_found) {
+ if ($_type == 'modifier') {
+ /*
+ * In case modifier falls back on using PHP functions
+ * directly, we only allow those specified in the security
+ * context.
+ */
+ if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
+ $_message = "(secure mode) modifier '$_name' is not allowed";
+ } else {
+ if (!function_exists($_name)) {
+ $_message = "modifier '$_name' is not implemented";
+ } else {
+ $_plugin_func = $_name;
+ $_found = true;
+ }
+ }
+ } else if ($_type == 'function') {
+ /*
+ * This is a catch-all situation.
+ */
+ $_message = "unknown tag - '$_name'";
+ }
+ }
+
+ if ($_found) {
+ $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
+ } else {
+ // output error
+ $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.load_resource_plugin.php b/html/phpgacl/admin/smarty_x/libs/core/core.load_resource_plugin.php
new file mode 100644
index 0000000..a7d37d1
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.load_resource_plugin.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * load a resource plugin
+ *
+ * @param string $type
+ */
+
+// $type
+
+function smarty_core_load_resource_plugin($params, &$smarty)
+{
+ /*
+ * Resource plugins are not quite like the other ones, so they are
+ * handled differently. The first element of plugin info is the array of
+ * functions provided by the plugin, the second one indicates whether
+ * all of them exist or not.
+ */
+
+ $_plugin = &$smarty->_plugins['resource'][$params['type']];
+ if (isset($_plugin)) {
+ if (!$_plugin[1] && count($_plugin[0])) {
+ $_plugin[1] = true;
+ foreach ($_plugin[0] as $_plugin_func) {
+ if (!is_callable($_plugin_func)) {
+ $_plugin[1] = false;
+ break;
+ }
+ }
+ }
+
+ if (!$_plugin[1]) {
+ $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
+ }
+
+ return;
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
+ $_found = ($_plugin_file != false);
+
+ if ($_found) { /*
+ * If the plugin file is found, it -must- provide the properly named
+ * plugin functions.
+ */
+ include_once($_plugin_file);
+
+ /*
+ * Locate functions that we require the plugin to provide.
+ */
+ $_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
+ $_resource_funcs = array();
+ foreach ($_resource_ops as $_op) {
+ $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
+ return;
+ } else {
+ $_resource_funcs[] = $_plugin_func;
+ }
+ }
+
+ $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.process_cached_inserts.php b/html/phpgacl/admin/smarty_x/libs/core/core.process_cached_inserts.php
new file mode 100644
index 0000000..0e368fd
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.process_cached_inserts.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace cached inserts with the actual results
+ *
+ * @param string $results
+ * @return string
+ */
+function smarty_core_process_cached_inserts($params, &$smarty)
+{
+ preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
+ $params['results'], $match);
+ list($cached_inserts, $insert_args) = $match;
+
+ for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ $args = unserialize($insert_args[$i]);
+ $name = $args['name'];
+
+ if (isset($args['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($args['script']));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+ $resource_type = $_params['resource_type'];
+ $php_resource = $_params['php_resource'];
+
+
+ if ($resource_type == 'file') {
+ $smarty->_include($php_resource, true);
+ } else {
+ $smarty->_eval($php_resource);
+ }
+ }
+
+ $function_name = $smarty->_plugins['insert'][$name][0];
+ if (empty($args['assign'])) {
+ $replace = $function_name($args, $smarty);
+ } else {
+ $smarty->assign($args['assign'], $function_name($args, $smarty));
+ $replace = '';
+ }
+
+ $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$name,
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
+ }
+ }
+
+ return $params['results'];
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.process_compiled_include.php b/html/phpgacl/admin/smarty_x/libs/core/core.process_compiled_include.php
new file mode 100644
index 0000000..3e1d4c1
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.process_compiled_include.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace nocache-tags by results of the corresponding non-cacheable
+ * functions and return it
+ *
+ * @param string $compiled_tpl
+ * @param string $cached_source
+ * @return string
+ */
+
+function smarty_core_process_compiled_include($params, &$smarty)
+{
+ $_cache_including = $smarty->_cache_including;
+ $smarty->_cache_including = true;
+
+ $_return = $params['results'];
+ foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
+ $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
+ array(&$smarty, '_process_compiled_include_callback'),
+ $_return);
+ }
+ $smarty->_cache_including = $_cache_including;
+ return $_return;
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.read_cache_file.php b/html/phpgacl/admin/smarty_x/libs/core/core.read_cache_file.php
new file mode 100644
index 0000000..2ab4281
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.read_cache_file.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * read a cache file, determine if it needs to be
+ * regenerated or not
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return boolean
+ */
+
+// $tpl_file, $cache_id, $compile_id, &$results
+
+function smarty_core_read_cache_file(&$params, &$smarty)
+{
+ static $content_cache = array();
+
+ if ($smarty->force_compile) {
+ // force compile enabled, always regenerate
+ return false;
+ }
+
+ if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
+ list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
+ return true;
+ }
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $params['results'] = $smarty->_read_file($_cache_file);
+ }
+
+ if (empty($params['results'])) {
+ // nothing to parse (error?), regenerate cache
+ return false;
+ }
+
+ $cache_split = explode("\n", $params['results'], 2);
+ $cache_header = $cache_split[0];
+
+ $_cache_info = unserialize($cache_header);
+
+ if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
+ // caching by expiration time
+ if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
+ // cache expired, regenerate
+ return false;
+ }
+ } else {
+ // caching by lifetime
+ if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
+ // cache expired, regenerate
+ return false;
+ }
+ }
+
+ if ($smarty->compile_check) {
+ $_params = array('get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['template']) as $_template_dep) {
+ $_params['resource_name'] = $_template_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // template file has changed, regenerate cache
+ return false;
+ }
+ }
+
+ if (isset($_cache_info['config'])) {
+ $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['config']) as $_config_dep) {
+ $_params['resource_name'] = $_config_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // config file has changed, regenerate cache
+ return false;
+ }
+ }
+ }
+ }
+
+ foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
+ if (empty($smarty->_cache_serials[$_include_file_path])) {
+ $smarty->_include($_include_file_path, true);
+ }
+
+ if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) {
+ /* regenerate */
+ return false;
+ }
+ }
+ $params['results'] = $cache_split[1];
+ $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
+
+ $smarty->_cache_info = $_cache_info;
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.rm_auto.php b/html/phpgacl/admin/smarty_x/libs/core/core.rm_auto.php
new file mode 100644
index 0000000..b7cdaf8
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.rm_auto.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete an automagically created file by name and id
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
+
+function smarty_core_rm_auto($params, &$smarty)
+{
+ if (!@is_dir($params['auto_base']))
+ return false;
+
+ if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
+ $_params = array(
+ 'dirname' => $params['auto_base'],
+ 'level' => 0,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
+
+ if(isset($params['auto_source'])) {
+ if (isset($params['extensions'])) {
+ $_res = false;
+ foreach ((array)$params['extensions'] as $_extension)
+ $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
+ } else {
+ $_res = $smarty->_unlink($_tname, $params['exp_time']);
+ }
+ } elseif ($smarty->use_sub_dirs) {
+ $_params = array(
+ 'dirname' => $_tname,
+ 'level' => 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ // remove matching file names
+ $_handle = opendir($params['auto_base']);
+ $_res = true;
+ while (false !== ($_filename = readdir($_handle))) {
+ if($_filename == '.' || $_filename == '..') {
+ continue;
+ } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
+ $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
+ }
+ }
+ }
+ }
+
+ return $_res;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.rmdir.php b/html/phpgacl/admin/smarty_x/libs/core/core.rmdir.php
new file mode 100644
index 0000000..38df822
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.rmdir.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete a dir recursively (level=0 -> keep root)
+ * WARNING: no tests, it will try to remove what you tell it!
+ *
+ * @param string $dirname
+ * @param integer $level
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $dirname, $level = 1, $exp_time = null
+
+function smarty_core_rmdir($params, &$smarty)
+{
+ if(!isset($params['level'])) { $params['level'] = 1; }
+ if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
+
+ if($_handle = @opendir($params['dirname'])) {
+
+ while (false !== ($_entry = readdir($_handle))) {
+ if ($_entry != '.' && $_entry != '..') {
+ if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
+ $_params = array(
+ 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
+ 'level' => $params['level'] + 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
+ smarty_core_rmdir($_params, $smarty);
+ }
+ else {
+ $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
+ }
+ }
+ }
+ closedir($_handle);
+ }
+
+ if ($params['level']) {
+ return @rmdir($params['dirname']);
+ }
+ return (bool)$_handle;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.run_insert_handler.php b/html/phpgacl/admin/smarty_x/libs/core/core.run_insert_handler.php
new file mode 100644
index 0000000..aa391ab
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.run_insert_handler.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Handle insert tags
+ *
+ * @param array $args
+ * @return string
+ */
+function smarty_core_run_insert_handler($params, &$smarty)
+{
+
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ if ($smarty->debugging) {
+ $_params = array();
+ $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ if ($smarty->caching) {
+ $_arg_string = serialize($params['args']);
+ $_name = $params['args']['name'];
+ if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
+ $smarty->_cache_info['insert_tags'][$_name] = array('insert',
+ $_name,
+ $smarty->_plugins['insert'][$_name][1],
+ $smarty->_plugins['insert'][$_name][2],
+ !empty($params['args']['script']) ? true : false);
+ }
+ return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
+ } else {
+ if (isset($params['args']['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+
+ if ($_params['resource_type'] == 'file') {
+ $smarty->_include($_params['php_resource'], true);
+ } else {
+ $smarty->_eval($_params['php_resource']);
+ }
+ unset($params['args']['script']);
+ }
+
+ $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
+ $_content = $_funcname($params['args'], $smarty);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$params['args']['name'],
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
+ }
+
+ if (!empty($params['args']["assign"])) {
+ $smarty->assign($params['args']["assign"], $_content);
+ } else {
+ return $_content;
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.smarty_include_php.php b/html/phpgacl/admin/smarty_x/libs/core/core.smarty_include_php.php
new file mode 100644
index 0000000..4b31648
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.smarty_include_php.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * called for included php files within templates
+ *
+ * @param string $smarty_file
+ * @param string $smarty_assign variable to assign the included template's
+ * output into
+ * @param boolean $smarty_once uses include_once if this is true
+ * @param array $smarty_include_vars associative array of vars from
+ * {include file="blah" var=$var}
+ */
+
+// $file, $assign, $once, $_smarty_include_vars
+
+function smarty_core_smarty_include_php($params, &$smarty)
+{
+ $_params = array('resource_name' => $params['smarty_file']);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
+ smarty_core_get_php_resource($_params, $smarty);
+ $_smarty_resource_type = $_params['resource_type'];
+ $_smarty_php_resource = $_params['php_resource'];
+
+ if (!empty($params['smarty_assign'])) {
+ ob_start();
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ $smarty->assign($params['smarty_assign'], ob_get_contents());
+ ob_end_clean();
+ } else {
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ }
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_file.php b/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_file.php
new file mode 100644
index 0000000..7429ad9
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_file.php
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Prepend the cache information to the cache file
+ * and write it
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return true|null
+ */
+
+ // $tpl_file, $cache_id, $compile_id, $results
+
+function smarty_core_write_cache_file($params, &$smarty)
+{
+
+ // put timestamp in cache header
+ $smarty->_cache_info['timestamp'] = time();
+ if ($smarty->cache_lifetime > -1){
+ // expiration set
+ $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
+ } else {
+ // cache will never expire
+ $smarty->_cache_info['expires'] = -1;
+ }
+
+ // collapse {nocache...}-tags
+ $params['results'] = preg_replace('!((\{nocache\:([0-9a-f]{32})#(\d+)\})'
+ .'.*'
+ .'{/nocache\:\\3#\\4\})!Us'
+ ,'\\2'
+ ,$params['results']);
+ $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
+
+ // prepend the cache header info into cache file
+ $params['results'] = serialize($smarty->_cache_info)."\n".$params['results'];
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+
+ if(!@is_writable($smarty->cache_dir)) {
+ // cache_dir not writable, see if it exists
+ if(!@is_dir($smarty->cache_dir)) {
+ $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_paths_file.php b/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_paths_file.php
new file mode 100644
index 0000000..eac5227
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.write_cache_paths_file.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write out the cached paths file
+ *
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+function smarty_core_write_cache_paths_file($params, &$smarty)
+{
+ if (!isset($smarty->_cache_paths_file)) {
+ return false;
+ }
+ $_compiled_content = function_exists('var_export') ? var_export($smarty->_cache_paths, true) : "unserialize('" . serialize($smarty->_cache_paths) . "')";
+ $_compiled_content = '<?php $this->_cache_paths = ' . $_compiled_content . '; ?>';
+ $_params = array('compile_path' => $smarty->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time());
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
+ return smarty_core_write_compiled_resource($_params, $smarty);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_include.php b/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_include.php
new file mode 100644
index 0000000..9c87cf0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_include.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Extract non-cacheable parts out of compiled template and write it
+ *
+ * @param string $compile_path
+ * @param string $template_compiled
+ * @param integer $template_timestamp
+ * @return boolean
+ */
+
+function smarty_core_write_compiled_include($params, &$smarty)
+{
+ $_tag_start = 'if \(\$this->caching\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
+ $_tag_end = 'if \(\$this->caching\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
+
+ preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
+ $params['compiled_content'], $_match_source, PREG_SET_ORDER);
+
+ // no nocache-parts found: done
+ if (count($_match_source)==0) return;
+
+ // convert the matched php-code to functions
+ $_include_compiled = "<?php /* funky header here */\n\n";
+
+ $_compile_path = $params['include_file_path'];
+
+ $smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
+ $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
+
+ $_include_compiled .= $params['plugins_code'];
+ $_include_compiled .= "<?php";
+
+ $this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
+ for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
+ $_match =& $_match_source[$_i];
+ $source = $_match[4];
+ if ($this_varname == '_smarty') {
+ /* rename $this to $_smarty in the sourcecode */
+ $tokens = token_get_all('<?php ' . $_match[4]);
+ array_shift($tokens); /* remove the opening <.?.php */
+ for ($i=0, $count = count($tokens); $i < $count; $i++) {
+ if (is_array($tokens[$i])) {
+ if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
+ $tokens[$i] = '$' . $this_varname;
+ } else {
+ $tokens[$i] = $tokens[$i][1];
+ }
+ }
+ }
+ $source = implode('', $tokens);
+ }
+
+ /* add function to compiled include */
+ $_include_compiled .= "
+function _smarty_tplfunc_$_match[2]_$_match[3](&\$$this_varname)
+{
+$source
+}
+
+";
+ }
+ $_include_compiled .= "\n\n?>\n";
+
+ $_params = array('filename' => $_compile_path,
+ 'contents' => $_include_compiled, 'create_dirs' => true);
+
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_resource.php b/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_resource.php
new file mode 100644
index 0000000..c701448
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.write_compiled_resource.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write the compiled resource
+ *
+ * @param string $compile_path
+ * @param string $compiled_content
+ * @param integer $resource_timestamp
+ * @return true
+ */
+function smarty_core_write_compiled_resource($params, &$smarty)
+{
+ if(!@is_writable($smarty->compile_dir)) {
+ // compile_dir not writable, see if it exists
+ if(!@is_dir($smarty->compile_dir)) {
+ $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_params = array('filename' => $params['compile_path'], 'timestamp'=>$params['resource_timestamp'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/core/core.write_file.php b/html/phpgacl/admin/smarty_x/libs/core/core.write_file.php
new file mode 100644
index 0000000..d6de731
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/core/core.write_file.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write out a file to disk
+ *
+ * @param string $filename
+ * @param string $contents
+ * @param boolean $create_dirs
+ * @return boolean
+ */
+function smarty_core_write_file($params, &$smarty)
+{
+ $_dirname = dirname($params['filename']);
+
+ if ($params['create_dirs']) {
+ $_params = array('dir' => $_dirname);
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.create_dir_structure.php');
+ smarty_core_create_dir_structure($_params, $smarty);
+ }
+
+ // write to tmp file, then rename it to avoid
+ // file locking race condition
+ $_tmp_file = tempnam($_dirname, 'write_');
+
+ if (!($fd = @fopen($_tmp_file, 'w'))) {
+ $smarty->trigger_error("problem writing temporary file '$_tmp_file'");
+ return false;
+ }
+
+ fwrite($fd, $params['contents']);
+
+ // Set the file's mtime
+ if (isset($params['timestamp'])) {
+ touch($_tmp_file, $params['timestamp']);
+ }
+ fclose($fd);
+
+ // Delete the file if it allready exists (this is needed on Win,
+ // because it cannot overwrite files with rename()
+ if (file_exists($params['filename'])) {
+ @unlink($params['filename']);
+ }
+ @rename($_tmp_file, $params['filename']);
+ @chmod($params['filename'], $smarty->_file_perms);
+
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/debug.tpl b/html/phpgacl/admin/smarty_x/libs/debug.tpl
new file mode 100644
index 0000000..7f1c9d4
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/debug.tpl
@@ -0,0 +1,64 @@
+{* Smarty *}
+
+{* debug.tpl, last updated version 2.0.1 *}
+
+{assign_debug_info}
+
+{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
+ <table border=0 width=100%>
+ <tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>
+ <tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>
+ {section name=templates loop=$_debug_tpls}
+ <tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>
+ {sectionelse}
+ <tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>
+ {/section}
+ <tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>
+ {section name=vars loop=$_debug_keys}
+ <tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>
+ {sectionelse}
+ <tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>
+ {/section}
+ <tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>
+ {section name=config_vars loop=$_debug_config_keys}
+ <tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var}</font></tt></td></tr>
+ {sectionelse}
+ <tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>
+ {/section}
+ </table>
+</BODY></HTML>
+{else}
+<SCRIPT language=javascript>
+ if( self.name == '' ) {ldelim}
+ var title = 'Console';
+ {rdelim}
+ else {ldelim}
+ var title = 'Console_' + self.name;
+ {rdelim}
+ _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
+ _smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"</TITLE></HEAD><BODY bgcolor=#ffffff>");
+ _smarty_console.document.write("<table border=0 width=100%>");
+ _smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>");
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>");
+ {section name=templates loop=$_debug_tpls}
+ _smarty_console.document.write("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename|escape:html|escape:javascript}</font>{if isset($_debug_tpls[templates].exec_time)} <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font>{/if}</tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>");
+ {section name=vars loop=$_debug_keys}
+ _smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outer template scope):</b></td></tr>");
+ {section name=config_vars loop=$_debug_config_keys}
+ _smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var|escape:javascript}</font></tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("</table>");
+ _smarty_console.document.write("</BODY></HTML>");
+ _smarty_console.document.close();
+</SCRIPT>
+{/if}
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.assemble_plugin_filepath.php b/html/phpgacl/admin/smarty_x/libs/internals/core.assemble_plugin_filepath.php
new file mode 100644
index 0000000..690d3dd
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.assemble_plugin_filepath.php
@@ -0,0 +1,67 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * assemble filepath of requested plugin
+ *
+ * @param string $type
+ * @param string $name
+ * @return string|false
+ */
+function smarty_core_assemble_plugin_filepath($params, &$smarty)
+{
+ static $_filepaths_cache = array();
+
+ $_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
+ if (isset($_filepaths_cache[$_plugin_filename])) {
+ return $_filepaths_cache[$_plugin_filename];
+ }
+ $_return = false;
+
+ foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ // see if path is relative
+ if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
+ $_relative_paths[] = $_plugin_dir;
+ // relative path, see if it is in the SMARTY_DIR
+ if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
+ $_return = SMARTY_DIR . $_plugin_filepath;
+ break;
+ }
+ }
+ // try relative to cwd (or absolute)
+ if (@is_readable($_plugin_filepath)) {
+ $_return = $_plugin_filepath;
+ break;
+ }
+ }
+
+ if($_return === false) {
+ // still not found, try PHP include_path
+ if(isset($_relative_paths)) {
+ foreach ((array)$_relative_paths as $_plugin_dir) {
+
+ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
+
+ $_params = array('file_path' => $_plugin_filepath);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_return = $_params['new_file_path'];
+ break;
+ }
+ }
+ }
+ }
+ $_filepaths_cache[$_plugin_filename] = $_return;
+ return $_return;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.assign_smarty_interface.php b/html/phpgacl/admin/smarty_x/libs/internals/core.assign_smarty_interface.php
new file mode 100644
index 0000000..7e65a73
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.assign_smarty_interface.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty assign_smarty_interface core plugin
+ *
+ * Type: core<br>
+ * Name: assign_smarty_interface<br>
+ * Purpose: assign the $smarty interface variable
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_assign_smarty_interface($params, &$smarty)
+{
+ if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
+ return;
+ }
+
+ $_globals_map = array('g' => 'HTTP_GET_VARS',
+ 'p' => 'HTTP_POST_VARS',
+ 'c' => 'HTTP_COOKIE_VARS',
+ 's' => 'HTTP_SERVER_VARS',
+ 'e' => 'HTTP_ENV_VARS');
+
+ $_smarty_vars_request = array();
+
+ foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
+ if (isset($_globals_map[$_c])) {
+ $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
+ }
+ }
+ $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
+
+ $smarty->_smarty_vars['request'] = $_smarty_vars_request;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.create_dir_structure.php b/html/phpgacl/admin/smarty_x/libs/internals/core.create_dir_structure.php
new file mode 100644
index 0000000..999cf59
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.create_dir_structure.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * create full directory structure
+ *
+ * @param string $dir
+ */
+
+// $dir
+
+function smarty_core_create_dir_structure($params, &$smarty)
+{
+ if (!file_exists($params['dir'])) {
+ $_open_basedir_ini = ini_get('open_basedir');
+
+ if (DIRECTORY_SEPARATOR=='/') {
+ /* unix-style paths */
+ $_dir = $params['dir'];
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/';
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(':', $_open_basedir_ini);
+ }
+
+ } else {
+ /* other-style paths */
+ $_dir = str_replace('\\','/', $params['dir']);
+ $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
+ if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
+ /* leading "//" for network volume, or "[letter]:/" for full path */
+ $_new_dir = $_root_dir[1];
+ /* remove drive-letter from _dir_parts */
+ if (isset($_root_dir[3])) array_shift($_dir_parts);
+
+ } else {
+ $_new_dir = str_replace('\\', '/', getcwd()).'/';
+
+ }
+
+ if($_use_open_basedir = !empty($_open_basedir_ini)) {
+ $_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
+ }
+
+ }
+
+ /* all paths use "/" only from here */
+ foreach ($_dir_parts as $_dir_part) {
+ $_new_dir .= $_dir_part;
+
+ if ($_use_open_basedir) {
+ // do not attempt to test or make directories outside of open_basedir
+ $_make_new_dir = false;
+ foreach ($_open_basedirs as $_open_basedir) {
+ if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
+ $_make_new_dir = true;
+ break;
+ }
+ }
+ } else {
+ $_make_new_dir = true;
+ }
+
+ if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
+ $smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
+ return false;
+ }
+ $_new_dir .= '/';
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.display_debug_console.php b/html/phpgacl/admin/smarty_x/libs/internals/core.display_debug_console.php
new file mode 100644
index 0000000..a5d7291
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.display_debug_console.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty debug_console function plugin
+ *
+ * Type: core<br>
+ * Name: display_debug_console<br>
+ * Purpose: display the javascript debug console window
+ * @param array Format: null
+ * @param Smarty
+ */
+function smarty_core_display_debug_console($params, &$smarty)
+{
+ // we must force compile the debug template in case the environment
+ // changed between separate applications.
+
+ if(empty($smarty->debug_tpl)) {
+ // set path to debug template from SMARTY_DIR
+ $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
+ if($smarty->security && is_file($smarty->debug_tpl)) {
+ $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
+ }
+ $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
+ }
+
+ $_ldelim_orig = $smarty->left_delimiter;
+ $_rdelim_orig = $smarty->right_delimiter;
+
+ $smarty->left_delimiter = '{';
+ $smarty->right_delimiter = '}';
+
+ $_compile_id_orig = $smarty->_compile_id;
+ $smarty->_compile_id = null;
+
+ $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
+ if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
+ {
+ ob_start();
+ $smarty->_include($_compile_path);
+ $_results = ob_get_contents();
+ ob_end_clean();
+ } else {
+ $_results = '';
+ }
+
+ $smarty->_compile_id = $_compile_id_orig;
+
+ $smarty->left_delimiter = $_ldelim_orig;
+ $smarty->right_delimiter = $_rdelim_orig;
+
+ return $_results;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.get_include_path.php b/html/phpgacl/admin/smarty_x/libs/internals/core.get_include_path.php
new file mode 100644
index 0000000..4343241
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.get_include_path.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get path to file from include_path
+ *
+ * @param string $file_path
+ * @param string $new_file_path
+ * @return boolean
+ * @staticvar array|null
+ */
+
+// $file_path, &$new_file_path
+
+function smarty_core_get_include_path(&$params, &$smarty)
+{
+ static $_path_array = null;
+
+ if(!isset($_path_array)) {
+ $_ini_include_path = ini_get('include_path');
+
+ if(strstr($_ini_include_path,';')) {
+ // windows pathnames
+ $_path_array = explode(';',$_ini_include_path);
+ } else {
+ $_path_array = explode(':',$_ini_include_path);
+ }
+ }
+ foreach ($_path_array as $_include_path) {
+ if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
+ $params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
+ return true;
+ }
+ }
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.get_microtime.php b/html/phpgacl/admin/smarty_x/libs/internals/core.get_microtime.php
new file mode 100644
index 0000000..f1a28e0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.get_microtime.php
@@ -0,0 +1,23 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Get seconds and microseconds
+ * @return double
+ */
+function smarty_core_get_microtime($params, &$smarty)
+{
+ $mtime = microtime();
+ $mtime = explode(" ", $mtime);
+ $mtime = (double)($mtime[1]) + (double)($mtime[0]);
+ return ($mtime);
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.get_php_resource.php b/html/phpgacl/admin/smarty_x/libs/internals/core.get_php_resource.php
new file mode 100644
index 0000000..786d4e7
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.get_php_resource.php
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Retrieves PHP script resource
+ *
+ * sets $php_resource to the returned resource
+ * @param string $resource
+ * @param string $resource_type
+ * @param $php_resource
+ * @return boolean
+ */
+
+function smarty_core_get_php_resource(&$params, &$smarty)
+{
+
+ $params['resource_base_path'] = $smarty->trusted_dir;
+ $smarty->_parse_resource_name($params, $smarty);
+
+ /*
+ * Find out if the resource exists.
+ */
+
+ if ($params['resource_type'] == 'file') {
+ $_readable = false;
+ if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
+ $_readable = true;
+ } else {
+ // test for file in include_path
+ $_params = array('file_path' => $params['resource_name']);
+ require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
+ if(smarty_core_get_include_path($_params, $smarty)) {
+ $_include_path = $_params['new_file_path'];
+ $_readable = true;
+ }
+ }
+ } else if ($params['resource_type'] != 'file') {
+ $_template_source = null;
+ $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
+ && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
+ array($params['resource_name'], &$_template_source, &$smarty));
+ }
+
+ /*
+ * Set the error function, depending on which class calls us.
+ */
+ if (method_exists($smarty, '_syntax_error')) {
+ $_error_funcc = '_syntax_error';
+ } else {
+ $_error_funcc = 'trigger_error';
+ }
+
+ if ($_readable) {
+ if ($smarty->security) {
+ require_once(SMARTY_CORE_DIR . 'core.is_trusted.php');
+ if (!smarty_core_is_trusted($params, $smarty)) {
+ $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
+ return false;
+ }
+ }
+ } else {
+ $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
+ return false;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $params['php_resource'] = $params['resource_name'];
+ } else {
+ $params['php_resource'] = $_template_source;
+ }
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.is_secure.php b/html/phpgacl/admin/smarty_x/libs/internals/core.is_secure.php
new file mode 100644
index 0000000..342f3af
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.is_secure.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * determines if a resource is secure or not.
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+// $resource_type, $resource_name
+
+function smarty_core_is_secure($params, &$smarty)
+{
+ if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
+ return true;
+ }
+
+ if ($params['resource_type'] == 'file') {
+ $_rp = realpath($params['resource_name']);
+ if (isset($params['resource_base_path'])) {
+ foreach ((array)$params['resource_base_path'] as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ if (!empty($smarty->secure_dir)) {
+ foreach ((array)$smarty->secure_dir as $curr_dir) {
+ if ( ($_cd = realpath($curr_dir)) !== false &&
+ strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
+ $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ return true;
+ }
+ }
+ }
+ } else {
+ // resource is not on local file system
+ return call_user_func_array(
+ $smarty->_plugins['resource'][$params['resource_type']][0][2],
+ array($params['resource_name'], &$smarty));
+ }
+
+ return false;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.is_trusted.php b/html/phpgacl/admin/smarty_x/libs/internals/core.is_trusted.php
new file mode 100644
index 0000000..f0bd2fb
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.is_trusted.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * determines if a resource is trusted or not
+ *
+ * @param string $resource_type
+ * @param string $resource_name
+ * @return boolean
+ */
+
+ // $resource_type, $resource_name
+
+function smarty_core_is_trusted($params, &$smarty)
+{
+ $_smarty_trusted = false;
+ if ($params['resource_type'] == 'file') {
+ if (!empty($smarty->trusted_dir)) {
+ $_rp = realpath($params['resource_name']);
+ foreach ((array)$smarty->trusted_dir as $curr_dir) {
+ if (!empty($curr_dir) && is_readable ($curr_dir)) {
+ $_cd = realpath($curr_dir);
+ if (strncmp($_rp, $_cd, strlen($_cd)) == 0
+ && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) {
+ $_smarty_trusted = true;
+ break;
+ }
+ }
+ }
+ }
+
+ } else {
+ // resource is not on local file system
+ $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
+ array($params['resource_name'], $smarty));
+ }
+
+ return $_smarty_trusted;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.load_plugins.php b/html/phpgacl/admin/smarty_x/libs/internals/core.load_plugins.php
new file mode 100644
index 0000000..6db1dc5
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.load_plugins.php
@@ -0,0 +1,125 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Load requested plugins
+ *
+ * @param array $plugins
+ */
+
+// $plugins
+
+function smarty_core_load_plugins($params, &$smarty)
+{
+
+ foreach ($params['plugins'] as $_plugin_info) {
+ list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
+ $_plugin = &$smarty->_plugins[$_type][$_name];
+
+ /*
+ * We do not load plugin more than once for each instance of Smarty.
+ * The following code checks for that. The plugin can also be
+ * registered dynamically at runtime, in which case template file
+ * and line number will be unknown, so we fill them in.
+ *
+ * The final element of the info array is a flag that indicates
+ * whether the dynamically registered plugin function has been
+ * checked for existence yet or not.
+ */
+ if (isset($_plugin)) {
+ if (empty($_plugin[3])) {
+ if (!is_callable($_plugin[0])) {
+ $smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ } else {
+ $_plugin[1] = $_tpl_file;
+ $_plugin[2] = $_tpl_line;
+ $_plugin[3] = true;
+ if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
+ }
+ }
+ continue;
+ } else if ($_type == 'insert') {
+ /*
+ * For backwards compatibility, we check for insert functions in
+ * the symbol table before trying to load them as a plugin.
+ */
+ $_plugin_func = 'insert_' . $_name;
+ if (function_exists($_plugin_func)) {
+ $_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
+ continue;
+ }
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
+
+ if (! $_found = ($_plugin_file != false)) {
+ $_message = "could not load plugin file '$_type.$_name.php'\n";
+ }
+
+ /*
+ * If plugin file is found, it -must- provide the properly named
+ * plugin function. In case it doesn't, simply output the error and
+ * do not fall back on any other method.
+ */
+ if ($_found) {
+ include_once $_plugin_file;
+
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ continue;
+ }
+ }
+ /*
+ * In case of insert plugins, their code may be loaded later via
+ * 'script' attribute.
+ */
+ else if ($_type == 'insert' && $_delayed_loading) {
+ $_plugin_func = 'smarty_' . $_type . '_' . $_name;
+ $_found = true;
+ }
+
+ /*
+ * Plugin specific processing and error checking.
+ */
+ if (!$_found) {
+ if ($_type == 'modifier') {
+ /*
+ * In case modifier falls back on using PHP functions
+ * directly, we only allow those specified in the security
+ * context.
+ */
+ if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
+ $_message = "(secure mode) modifier '$_name' is not allowed";
+ } else {
+ if (!function_exists($_name)) {
+ $_message = "modifier '$_name' is not implemented";
+ } else {
+ $_plugin_func = $_name;
+ $_found = true;
+ }
+ }
+ } else if ($_type == 'function') {
+ /*
+ * This is a catch-all situation.
+ */
+ $_message = "unknown tag - '$_name'";
+ }
+ }
+
+ if ($_found) {
+ $smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
+ } else {
+ // output error
+ $smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.load_resource_plugin.php b/html/phpgacl/admin/smarty_x/libs/internals/core.load_resource_plugin.php
new file mode 100644
index 0000000..a7d37d1
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.load_resource_plugin.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * load a resource plugin
+ *
+ * @param string $type
+ */
+
+// $type
+
+function smarty_core_load_resource_plugin($params, &$smarty)
+{
+ /*
+ * Resource plugins are not quite like the other ones, so they are
+ * handled differently. The first element of plugin info is the array of
+ * functions provided by the plugin, the second one indicates whether
+ * all of them exist or not.
+ */
+
+ $_plugin = &$smarty->_plugins['resource'][$params['type']];
+ if (isset($_plugin)) {
+ if (!$_plugin[1] && count($_plugin[0])) {
+ $_plugin[1] = true;
+ foreach ($_plugin[0] as $_plugin_func) {
+ if (!is_callable($_plugin_func)) {
+ $_plugin[1] = false;
+ break;
+ }
+ }
+ }
+
+ if (!$_plugin[1]) {
+ $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
+ }
+
+ return;
+ }
+
+ $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
+ $_found = ($_plugin_file != false);
+
+ if ($_found) { /*
+ * If the plugin file is found, it -must- provide the properly named
+ * plugin functions.
+ */
+ include_once($_plugin_file);
+
+ /*
+ * Locate functions that we require the plugin to provide.
+ */
+ $_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
+ $_resource_funcs = array();
+ foreach ($_resource_ops as $_op) {
+ $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
+ if (!function_exists($_plugin_func)) {
+ $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
+ return;
+ } else {
+ $_resource_funcs[] = $_plugin_func;
+ }
+ }
+
+ $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.process_cached_inserts.php b/html/phpgacl/admin/smarty_x/libs/internals/core.process_cached_inserts.php
new file mode 100644
index 0000000..29cb007
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.process_cached_inserts.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace cached inserts with the actual results
+ *
+ * @param string $results
+ * @return string
+ */
+function smarty_core_process_cached_inserts($params, &$smarty)
+{
+ preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
+ $params['results'], $match);
+ list($cached_inserts, $insert_args) = $match;
+
+ for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ $args = unserialize($insert_args[$i]);
+ $name = $args['name'];
+
+ if (isset($args['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($args['script']));
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+ $resource_type = $_params['resource_type'];
+ $php_resource = $_params['php_resource'];
+
+
+ if ($resource_type == 'file') {
+ $smarty->_include($php_resource, true);
+ } else {
+ $smarty->_eval($php_resource);
+ }
+ }
+
+ $function_name = $smarty->_plugins['insert'][$name][0];
+ if (empty($args['assign'])) {
+ $replace = $function_name($args, $smarty);
+ } else {
+ $smarty->assign($args['assign'], $function_name($args, $smarty));
+ $replace = '';
+ }
+
+ $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$name,
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
+ }
+ }
+
+ return $params['results'];
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.process_compiled_include.php b/html/phpgacl/admin/smarty_x/libs/internals/core.process_compiled_include.php
new file mode 100644
index 0000000..3e1d4c1
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.process_compiled_include.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Replace nocache-tags by results of the corresponding non-cacheable
+ * functions and return it
+ *
+ * @param string $compiled_tpl
+ * @param string $cached_source
+ * @return string
+ */
+
+function smarty_core_process_compiled_include($params, &$smarty)
+{
+ $_cache_including = $smarty->_cache_including;
+ $smarty->_cache_including = true;
+
+ $_return = $params['results'];
+ foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
+ $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
+ array(&$smarty, '_process_compiled_include_callback'),
+ $_return);
+ }
+ $smarty->_cache_including = $_cache_including;
+ return $_return;
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.read_cache_file.php b/html/phpgacl/admin/smarty_x/libs/internals/core.read_cache_file.php
new file mode 100644
index 0000000..ecb1470
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.read_cache_file.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * read a cache file, determine if it needs to be
+ * regenerated or not
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return boolean
+ */
+
+// $tpl_file, $cache_id, $compile_id, &$results
+
+function smarty_core_read_cache_file(&$params, &$smarty)
+{
+ static $content_cache = array();
+
+ if ($smarty->force_compile) {
+ // force compile enabled, always regenerate
+ return false;
+ }
+
+ if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
+ list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
+ return true;
+ }
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $params['results'] = $smarty->_read_file($_cache_file);
+ }
+
+ if (empty($params['results'])) {
+ // nothing to parse (error?), regenerate cache
+ return false;
+ }
+
+ $_contents = $params['results'];
+ $_info_start = strpos($_contents, "\n") + 1;
+ $_info_len = (int)substr($_contents, 0, $_info_start - 1);
+ $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
+ $params['results'] = substr($_contents, $_info_start + $_info_len);
+
+ if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
+ // caching by expiration time
+ if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
+ // cache expired, regenerate
+ return false;
+ }
+ } else {
+ // caching by lifetime
+ if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
+ // cache expired, regenerate
+ return false;
+ }
+ }
+
+ if ($smarty->compile_check) {
+ $_params = array('get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['template']) as $_template_dep) {
+ $_params['resource_name'] = $_template_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // template file has changed, regenerate cache
+ return false;
+ }
+ }
+
+ if (isset($_cache_info['config'])) {
+ $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
+ foreach (array_keys($_cache_info['config']) as $_config_dep) {
+ $_params['resource_name'] = $_config_dep;
+ if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
+ // config file has changed, regenerate cache
+ return false;
+ }
+ }
+ }
+ }
+
+ foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
+ if (empty($smarty->_cache_serials[$_include_file_path])) {
+ $smarty->_include($_include_file_path, true);
+ }
+
+ if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) {
+ /* regenerate */
+ return false;
+ }
+ }
+ $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
+
+ $smarty->_cache_info = $_cache_info;
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.rm_auto.php b/html/phpgacl/admin/smarty_x/libs/internals/core.rm_auto.php
new file mode 100644
index 0000000..b251f64
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.rm_auto.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete an automagically created file by name and id
+ *
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
+
+function smarty_core_rm_auto($params, &$smarty)
+{
+ if (!@is_dir($params['auto_base']))
+ return false;
+
+ if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
+ $_params = array(
+ 'dirname' => $params['auto_base'],
+ 'level' => 0,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
+
+ if(isset($params['auto_source'])) {
+ if (isset($params['extensions'])) {
+ $_res = false;
+ foreach ((array)$params['extensions'] as $_extension)
+ $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
+ } else {
+ $_res = $smarty->_unlink($_tname, $params['exp_time']);
+ }
+ } elseif ($smarty->use_sub_dirs) {
+ $_params = array(
+ 'dirname' => $_tname,
+ 'level' => 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ $_res = smarty_core_rmdir($_params, $smarty);
+ } else {
+ // remove matching file names
+ $_handle = opendir($params['auto_base']);
+ $_res = true;
+ while (false !== ($_filename = readdir($_handle))) {
+ if($_filename == '.' || $_filename == '..') {
+ continue;
+ } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
+ $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
+ }
+ }
+ }
+ }
+
+ return $_res;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.rmdir.php b/html/phpgacl/admin/smarty_x/libs/internals/core.rmdir.php
new file mode 100644
index 0000000..4fdbccc
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.rmdir.php
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * delete a dir recursively (level=0 -> keep root)
+ * WARNING: no tests, it will try to remove what you tell it!
+ *
+ * @param string $dirname
+ * @param integer $level
+ * @param integer $exp_time
+ * @return boolean
+ */
+
+// $dirname, $level = 1, $exp_time = null
+
+function smarty_core_rmdir($params, &$smarty)
+{
+ if(!isset($params['level'])) { $params['level'] = 1; }
+ if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
+
+ if($_handle = @opendir($params['dirname'])) {
+
+ while (false !== ($_entry = readdir($_handle))) {
+ if ($_entry != '.' && $_entry != '..') {
+ if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
+ $_params = array(
+ 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
+ 'level' => $params['level'] + 1,
+ 'exp_time' => $params['exp_time']
+ );
+ require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
+ smarty_core_rmdir($_params, $smarty);
+ }
+ else {
+ $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
+ }
+ }
+ }
+ closedir($_handle);
+ }
+
+ if ($params['level']) {
+ return @rmdir($params['dirname']);
+ }
+ return (bool)$_handle;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.run_insert_handler.php b/html/phpgacl/admin/smarty_x/libs/internals/core.run_insert_handler.php
new file mode 100644
index 0000000..71c3845
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.run_insert_handler.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Handle insert tags
+ *
+ * @param array $args
+ * @return string
+ */
+function smarty_core_run_insert_handler($params, &$smarty)
+{
+
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ if ($smarty->debugging) {
+ $_params = array();
+ $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ if ($smarty->caching) {
+ $_arg_string = serialize($params['args']);
+ $_name = $params['args']['name'];
+ if (!isset($smarty->_cache_info['insert_tags'][$_name])) {
+ $smarty->_cache_info['insert_tags'][$_name] = array('insert',
+ $_name,
+ $smarty->_plugins['insert'][$_name][1],
+ $smarty->_plugins['insert'][$_name][2],
+ !empty($params['args']['script']) ? true : false);
+ }
+ return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
+ } else {
+ if (isset($params['args']['script'])) {
+ $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ if(!smarty_core_get_php_resource($_params, $smarty)) {
+ return false;
+ }
+
+ if ($_params['resource_type'] == 'file') {
+ $smarty->_include($_params['php_resource'], true);
+ } else {
+ $smarty->_eval($_params['php_resource']);
+ }
+ unset($params['args']['script']);
+ }
+
+ $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
+ $_content = $_funcname($params['args'], $smarty);
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'insert',
+ 'filename' => 'insert_'.$params['args']['name'],
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
+ }
+
+ if (!empty($params['args']["assign"])) {
+ $smarty->assign($params['args']["assign"], $_content);
+ } else {
+ return $_content;
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.smarty_include_php.php b/html/phpgacl/admin/smarty_x/libs/internals/core.smarty_include_php.php
new file mode 100644
index 0000000..30c6e76
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.smarty_include_php.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * called for included php files within templates
+ *
+ * @param string $smarty_file
+ * @param string $smarty_assign variable to assign the included template's
+ * output into
+ * @param boolean $smarty_once uses include_once if this is true
+ * @param array $smarty_include_vars associative array of vars from
+ * {include file="blah" var=$var}
+ */
+
+// $file, $assign, $once, $_smarty_include_vars
+
+function smarty_core_smarty_include_php($params, &$smarty)
+{
+ $_params = array('resource_name' => $params['smarty_file']);
+ require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
+ smarty_core_get_php_resource($_params, $smarty);
+ $_smarty_resource_type = $_params['resource_type'];
+ $_smarty_php_resource = $_params['php_resource'];
+
+ if (!empty($params['smarty_assign'])) {
+ ob_start();
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ $smarty->assign($params['smarty_assign'], ob_get_contents());
+ ob_end_clean();
+ } else {
+ if ($_smarty_resource_type == 'file') {
+ $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
+ } else {
+ $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
+ }
+ }
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.write_cache_file.php b/html/phpgacl/admin/smarty_x/libs/internals/core.write_cache_file.php
new file mode 100644
index 0000000..72f785b
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.write_cache_file.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Prepend the cache information to the cache file
+ * and write it
+ *
+ * @param string $tpl_file
+ * @param string $cache_id
+ * @param string $compile_id
+ * @param string $results
+ * @return true|null
+ */
+
+ // $tpl_file, $cache_id, $compile_id, $results
+
+function smarty_core_write_cache_file($params, &$smarty)
+{
+
+ // put timestamp in cache header
+ $smarty->_cache_info['timestamp'] = time();
+ if ($smarty->cache_lifetime > -1){
+ // expiration set
+ $smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
+ } else {
+ // cache will never expire
+ $smarty->_cache_info['expires'] = -1;
+ }
+
+ // collapse nocache.../nocache-tags
+ if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) {
+ // remove everything between every pair of outermost noache.../nocache-tags
+ // and replace it by a single nocache-tag
+ // this new nocache-tag will be replaced by dynamic contents in
+ // smarty_core_process_compiled_includes() on a cache-read
+
+ $match_count = count($match[0]);
+ $results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE);
+
+ $level = 0;
+ $j = 0;
+ for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) {
+ if ($results[$i] == $match[0][$j]) {
+ // nocache tag
+ if ($match[1][$j]) { // closing tag
+ $level--;
+ unset($results[$i]);
+ } else { // opening tag
+ if ($level++ > 0) unset($results[$i]);
+ }
+ $j++;
+ } elseif ($level > 0) {
+ unset($results[$i]);
+ }
+ }
+ $params['results'] = implode('', $results);
+ }
+ $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
+
+ // prepend the cache header info into cache file
+ $_cache_info = serialize($smarty->_cache_info);
+ $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results'];
+
+ if (!empty($smarty->cache_handler_func)) {
+ // use cache_handler function
+ call_user_func_array($smarty->cache_handler_func,
+ array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
+ } else {
+ // use local cache file
+
+ if(!@is_writable($smarty->cache_dir)) {
+ // cache_dir not writable, see if it exists
+ if(!@is_dir($smarty->cache_dir)) {
+ $smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
+ $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
+ $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_include.php b/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_include.php
new file mode 100644
index 0000000..5e0b2e0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_include.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Extract non-cacheable parts out of compiled template and write it
+ *
+ * @param string $compile_path
+ * @param string $template_compiled
+ * @return boolean
+ */
+
+function smarty_core_write_compiled_include($params, &$smarty)
+{
+ $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}';
+ $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}';
+
+ preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
+ $params['compiled_content'], $_match_source, PREG_SET_ORDER);
+
+ // no nocache-parts found: done
+ if (count($_match_source)==0) return;
+
+ // convert the matched php-code to functions
+ $_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
+ $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n";
+
+ $_compile_path = $params['include_file_path'];
+
+ $smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
+ $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
+
+ $_include_compiled .= $params['plugins_code'];
+ $_include_compiled .= "<?php";
+
+ $this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
+ for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
+ $_match =& $_match_source[$_i];
+ $source = $_match[4];
+ if ($this_varname == '_smarty') {
+ /* rename $this to $_smarty in the sourcecode */
+ $tokens = token_get_all('<?php ' . $_match[4]);
+
+ /* remove trailing <?php */
+ $open_tag = '';
+ while ($tokens) {
+ $token = array_shift($tokens);
+ if (is_array($token)) {
+ $open_tag .= $token[1];
+ } else {
+ $open_tag .= $token;
+ }
+ if ($open_tag == '<?php ') break;
+ }
+
+ for ($i=0, $count = count($tokens); $i < $count; $i++) {
+ if (is_array($tokens[$i])) {
+ if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
+ $tokens[$i] = '$' . $this_varname;
+ } else {
+ $tokens[$i] = $tokens[$i][1];
+ }
+ }
+ }
+ $source = implode('', $tokens);
+ }
+
+ /* add function to compiled include */
+ $_include_compiled .= "
+function _smarty_tplfunc_$_match[2]_$_match[3](&\$$this_varname)
+{
+$source
+}
+
+";
+ }
+ $_include_compiled .= "\n\n?>\n";
+
+ $_params = array('filename' => $_compile_path,
+ 'contents' => $_include_compiled, 'create_dirs' => true);
+
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_resource.php b/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_resource.php
new file mode 100644
index 0000000..b902eff
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.write_compiled_resource.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write the compiled resource
+ *
+ * @param string $compile_path
+ * @param string $compiled_content
+ * @return true
+ */
+function smarty_core_write_compiled_resource($params, &$smarty)
+{
+ if(!@is_writable($smarty->compile_dir)) {
+ // compile_dir not writable, see if it exists
+ if(!@is_dir($smarty->compile_dir)) {
+ $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
+ return false;
+ }
+ $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
+ return false;
+ }
+
+ $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
+ require_once(SMARTY_CORE_DIR . 'core.write_file.php');
+ smarty_core_write_file($_params, $smarty);
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/internals/core.write_file.php b/html/phpgacl/admin/smarty_x/libs/internals/core.write_file.php
new file mode 100644
index 0000000..09e1698
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/internals/core.write_file.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * write out a file to disk
+ *
+ * @param string $filename
+ * @param string $contents
+ * @param boolean $create_dirs
+ * @return boolean
+ */
+function smarty_core_write_file($params, &$smarty)
+{
+ $_dirname = dirname($params['filename']);
+
+ if ($params['create_dirs']) {
+ $_params = array('dir' => $_dirname);
+ require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
+ smarty_core_create_dir_structure($_params, $smarty);
+ }
+
+ // write to tmp file, then rename it to avoid
+ // file locking race condition
+ $_tmp_file = tempnam($_dirname, 'wrt');
+
+ if (!($fd = @fopen($_tmp_file, 'wb'))) {
+ $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
+ if (!($fd = @fopen($_tmp_file, 'wb'))) {
+ $smarty->trigger_error("problem writing temporary file '$_tmp_file'");
+ return false;
+ }
+ }
+
+ fwrite($fd, $params['contents']);
+ fclose($fd);
+
+ // Delete the file if it allready exists (this is needed on Win,
+ // because it cannot overwrite files with rename()
+ if (file_exists($params['filename'])) {
+ @unlink($params['filename']);
+ }
+ @rename($_tmp_file, $params['filename']);
+ @chmod($params['filename'], $smarty->_file_perms);
+
+ return true;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/block.strip.php b/html/phpgacl/admin/smarty_x/libs/plugins/block.strip.php
new file mode 100644
index 0000000..bc092c8
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/block.strip.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {strip}{/strip} block plugin
+ *
+ * Type: block function<br>
+ * Name: strip<br>
+ * Purpose: strip unwanted white space from text<br>
+ * @link http://smarty.php.net/manual/en/language.function.strip.php {strip}
+ * (Smarty online manual)
+ * @param array unused, no parameters for this block
+ * @param string content of {strip}{/strip} tags
+ * @param Smarty clever method emulation
+ * @return string $content stripped of whitespace
+ */
+function smarty_block_strip($params, $content, &$smarty)
+{
+ /* Reformat data between 'strip' and '/strip' tags, removing spaces, tabs and newlines. */
+ $_strip_search = array(
+ "![\t ]+$|^[\t ]+!m", // remove leading/trailing space chars
+ '%[\r\n]+%m'); // remove CRs and newlines
+ $_strip_replace = array(
+ '',
+ '');
+ return preg_replace($_strip_search, $_strip_replace, $content);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/block.textformat.php b/html/phpgacl/admin/smarty_x/libs/plugins/block.textformat.php
new file mode 100644
index 0000000..aaebab2
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/block.textformat.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {textformat}{/textformat} block plugin
+ *
+ * Type: block function<br>
+ * Name: textformat<br>
+ * Purpose: format text a certain way with preset styles
+ * or custom wrap/indent settings<br>
+ * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
+ * (Smarty online manual)
+ * @param array
+ * <pre>
+ * Params: style: string (email)
+ * indent: integer (0)
+ * wrap: integer (80)
+ * wrap_char string ("\n")
+ * indent_char: string (" ")
+ * wrap_boundary: boolean (true)
+ * </pre>
+ * @param string contents of the block
+ * @param Smarty clever simulation of a method
+ * @return string string $content re-formatted
+ */
+function smarty_block_textformat($params, $content, &$smarty)
+{
+ if (is_null($content)) {
+ return;
+ }
+
+ $style = null;
+ $indent = 0;
+ $indent_first = 0;
+ $indent_char = ' ';
+ $wrap = 80;
+ $wrap_char = "\n";
+ $wrap_cut = false;
+ $assign = null;
+
+ foreach ($params as $_key => $_val) {
+ switch ($_key) {
+ case 'style':
+ case 'indent_char':
+ case 'wrap_char':
+ case 'assign':
+ $$_key = (string)$_val;
+ break;
+
+ case 'indent':
+ case 'indent_first':
+ case 'wrap':
+ $$_key = (int)$_val;
+ break;
+
+ case 'wrap_cut':
+ $$_key = (bool)$_val;
+ break;
+
+ default:
+ $smarty->trigger_error("textformat: unknown attribute '$_key'");
+ }
+ }
+
+ if ($style == 'email') {
+ $wrap = 72;
+ }
+
+ // split into paragraphs
+ $_paragraphs = preg_split('![\r\n][\r\n]!',$content);
+ $_output = '';
+
+ for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
+ if ($_paragraphs[$_x] == '') {
+ continue;
+ }
+ // convert mult. spaces & special chars to single space
+ $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
+ // indent first line
+ if($indent_first > 0) {
+ $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
+ }
+ // wordwrap sentences
+ $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
+ // indent lines
+ if($indent > 0) {
+ $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
+ }
+ }
+ $_output = implode($wrap_char . $wrap_char, $_paragraphs);
+
+ return $assign ? $smarty->assign($assign, $_output) : $_output;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/compiler.assign.php b/html/phpgacl/admin/smarty_x/libs/plugins/compiler.assign.php
new file mode 100644
index 0000000..2e02017
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/compiler.assign.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {assign} compiler function plugin
+ *
+ * Type: compiler function<br>
+ * Name: assign<br>
+ * Purpose: assign a value to a template variable
+ * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
+ * (Smarty online manual)
+ * @param string containing var-attribute and value-attribute
+ * @param Smarty_Compiler
+ */
+function smarty_compiler_assign($tag_attrs, &$compiler)
+{
+ $_params = $compiler->_parse_attrs($tag_attrs);
+
+ if (!isset($_params['var'])) {
+ $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING);
+ return;
+ }
+
+ if (!isset($_params['value'])) {
+ $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING);
+ return;
+ }
+
+ return "\$this->assign({$_params['var']}, {$_params['value']});";
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.assign.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.assign.php
new file mode 100644
index 0000000..3823791
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.assign.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/*
+ * Smarty {assign} function plugin
+ *
+ * Type: function<br>
+ * Name: assign<br>
+ * Purpose: assign a value to a template variable
+ * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
+ * (Smarty online manual)
+ * @param array Format: array('var' => variable name, 'value' => value to assign)
+ * @param Smarty
+ */
+function smarty_function_assign($params, &$smarty)
+{
+ extract($params);
+
+ if (empty($var)) {
+ $smarty->trigger_error("assign: missing 'var' parameter");
+ return;
+ }
+
+ if (!in_array('value', array_keys($params))) {
+ $smarty->trigger_error("assign: missing 'value' parameter");
+ return;
+ }
+
+ $smarty->assign($var, $value);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.assign_debug_info.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.assign_debug_info.php
new file mode 100644
index 0000000..8015624
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.assign_debug_info.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {assign_debug_info} function plugin
+ *
+ * Type: function<br>
+ * Name: assign_debug_info<br>
+ * Purpose: assign debug info to the template<br>
+ * @param array unused in this plugin, this plugin uses {@link Smarty::$_config},
+ * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info}
+ * @param Smarty
+ */
+function smarty_function_assign_debug_info($params, &$smarty)
+{
+ $assigned_vars = $smarty->_tpl_vars;
+ ksort($assigned_vars);
+ if (@is_array($smarty->_config[0])) {
+ $config_vars = $smarty->_config[0];
+ ksort($config_vars);
+ $smarty->assign("_debug_config_keys", array_keys($config_vars));
+ $smarty->assign("_debug_config_vals", array_values($config_vars));
+ }
+
+ $included_templates = $smarty->_smarty_debug_info;
+
+ $smarty->assign("_debug_keys", array_keys($assigned_vars));
+ $smarty->assign("_debug_vals", array_values($assigned_vars));
+
+ $smarty->assign("_debug_tpls", $included_templates);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.config_load.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.config_load.php
new file mode 100644
index 0000000..db7f8f6
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.config_load.php
@@ -0,0 +1,140 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {config_load} function plugin
+ *
+ * Type: function<br>
+ * Name: config_load<br>
+ * Purpose: load config file vars
+ * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}
+ * (Smarty online manual)
+ * @param array Format:
+ * <pre>
+ * array('file' => required config file name,
+ * 'section' => optional config file section to load
+ * 'scope' => local/parent/global
+ * 'global' => overrides scope, setting to parent if true)
+ * </pre>
+ * @param Smarty
+ */
+function smarty_function_config_load($params, &$smarty)
+{
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
+ }
+
+ $_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
+ $_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
+ $_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
+ $_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
+
+ if (!isset($_file) || strlen($_file) == 0) {
+ $smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
+ if (isset($_scope)) {
+ if ($_scope != 'local' &&
+ $_scope != 'parent' &&
+ $_scope != 'global') {
+ $smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
+ }
+ } else {
+ if ($_global) {
+ $_scope = 'parent';
+ } else {
+ $_scope = 'local';
+ }
+ }
+
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ 'get_source' => false);
+ $smarty->_parse_resource_name($_params);
+ $_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
+ if (isset($_section))
+ $_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
+ else
+ $_compile_file = $smarty->_get_compile_path($_file_path);
+
+ if($smarty->force_compile || !file_exists($_compile_file)) {
+ $_compile = true;
+ } elseif ($smarty->compile_check) {
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ 'get_source' => false);
+ $_compile = $smarty->_fetch_resource_info($_params) &&
+ $_params['resource_timestamp'] > filemtime($_compile_file);
+ } else {
+ $_compile = false;
+ }
+
+ if($_compile) {
+ // compile config file
+ if(!is_object($smarty->_conf_obj)) {
+ require_once SMARTY_DIR . $smarty->config_class . '.class.php';
+ $smarty->_conf_obj = new $smarty->config_class();
+ $smarty->_conf_obj->overwrite = $smarty->config_overwrite;
+ $smarty->_conf_obj->booleanize = $smarty->config_booleanize;
+ $smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
+ $smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
+ }
+
+ $_params = array('resource_name' => $_file,
+ 'resource_base_path' => $smarty->config_dir,
+ $_params['get_source'] = true);
+ if (!$smarty->_fetch_resource_info($_params)) {
+ return;
+ }
+ $smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
+ $_config_vars = array_merge($smarty->_conf_obj->get($_file),
+ $smarty->_conf_obj->get($_file, $_section));
+ if(function_exists('var_export')) {
+ $_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
+ } else {
+ $_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
+ }
+ $_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
+ require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
+ smarty_core_write_compiled_resource($_params, $smarty);
+ } else {
+ include($_compile_file);
+ }
+
+ if ($smarty->caching) {
+ $smarty->_cache_info['config'][$_file] = true;
+ }
+
+ $smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
+ $smarty->_config[0]['files'][$_file] = true;
+
+ if ($_scope == 'parent') {
+ $smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
+ $smarty->_config[1]['files'][$_file] = true;
+ } else if ($_scope == 'global') {
+ for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
+ $smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
+ $smarty->_config[$i]['files'][$_file] = true;
+ }
+ }
+
+ if ($smarty->debugging) {
+ $_params = array();
+ require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
+ $smarty->_smarty_debug_info[] = array('type' => 'config',
+ 'filename' => $_file.' ['.$_section.'] '.$_scope,
+ 'depth' => $smarty->_inclusion_depth,
+ 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
+ }
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.counter.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.counter.php
new file mode 100644
index 0000000..cfe5dd8
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.counter.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {counter} function plugin
+ *
+ * Type: function<br>
+ * Name: counter<br>
+ * Purpose: print out a counter value
+ * @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
+ * (Smarty online manual)
+ * @param array parameters
+ * @param Smarty
+ * @return string|null
+ */
+function smarty_function_counter($params, &$smarty)
+{
+ static $counters = array();
+
+ $name = (isset($params['name'])) ? $params['name'] : 'default';
+ if (!isset($counters[$name])) {
+ $counters[$name] = array(
+ 'start'=>1,
+ 'skip'=>1,
+ 'direction'=>'up',
+ 'count'=>1
+ );
+ }
+ $counter =& $counters[$name];
+
+ if (isset($params['start'])) {
+ $counter['start'] = $counter['count'] = (int)$params['start'];
+ }
+
+ if (!empty($params['assign'])) {
+ $counter['assign'] = $params['assign'];
+ }
+
+ if (isset($counter['assign'])) {
+ $smarty->assign($counter['assign'], $counter['count']);
+ }
+
+ if (isset($params['print'])) {
+ $print = (bool)$params['print'];
+ } else {
+ $print = empty($counter['assign']);
+ }
+
+ if ($print) {
+ $retval = $counter['count'];
+ } else {
+ $retval = null;
+ }
+
+ if (isset($params['skip'])) {
+ $counter['skip'] = $params['skip'];
+ }
+
+ if (isset($params['direction'])) {
+ $counter['direction'] = $params['direction'];
+ }
+
+ if ($counter['direction'] == "down")
+ $counter['count'] -= $counter['skip'];
+ else
+ $counter['count'] += $counter['skip'];
+
+ return $retval;
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.cycle.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.cycle.php
new file mode 100644
index 0000000..fe78bb8
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.cycle.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {cycle} function plugin
+ *
+ * Type: function<br>
+ * Name: cycle<br>
+ * Date: May 3, 2002<br>
+ * Purpose: cycle through given values<br>
+ * Input:
+ * - name = name of cycle (optional)
+ * - values = comma separated list of values to cycle,
+ * or an array of values to cycle
+ * (this can be left out for subsequent calls)
+ * - reset = boolean - resets given var to true
+ * - print = boolean - print var or not. default is true
+ * - advance = boolean - whether or not to advance the cycle
+ * - delimiter = the value delimiter, default is ","
+ * - assign = boolean, assigns to template var instead of
+ * printed.
+ *
+ * Examples:<br>
+ * <pre>
+ * {cycle values="#eeeeee,#d0d0d0d"}
+ * {cycle name=row values="one,two,three" reset=true}
+ * {cycle name=row}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credit to Mark Priatel <mpriatel@rogers.com>
+ * @author credit to Gerard <gerard@interfold.com>
+ * @author credit to Jason Sweat <jsweat_php@yahoo.com>
+ * @version 1.3
+ * @param array
+ * @param Smarty
+ * @return string|null
+ */
+function smarty_function_cycle($params, &$smarty)
+{
+ static $cycle_vars;
+
+ $name = (empty($params['name'])) ? 'default' : $params['name'];
+ $print = (isset($params['print'])) ? (bool)$params['print'] : true;
+ $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
+ $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
+
+ if (!in_array('values', array_keys($params))) {
+ if(!isset($cycle_vars[$name]['values'])) {
+ $smarty->trigger_error("cycle: missing 'values' parameter");
+ return;
+ }
+ } else {
+ if(isset($cycle_vars[$name]['values'])
+ && $cycle_vars[$name]['values'] != $params['values'] ) {
+ $cycle_vars[$name]['index'] = 0;
+ }
+ $cycle_vars[$name]['values'] = $params['values'];
+ }
+
+ $cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';
+
+ if(is_array($cycle_vars[$name]['values'])) {
+ $cycle_array = $cycle_vars[$name]['values'];
+ } else {
+ $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
+ }
+
+ if(!isset($cycle_vars[$name]['index']) || $reset ) {
+ $cycle_vars[$name]['index'] = 0;
+ }
+
+ if (isset($params['assign'])) {
+ $print = false;
+ $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
+ }
+
+ if($print) {
+ $retval = $cycle_array[$cycle_vars[$name]['index']];
+ } else {
+ $retval = null;
+ }
+
+ if($advance) {
+ if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
+ $cycle_vars[$name]['index'] = 0;
+ } else {
+ $cycle_vars[$name]['index']++;
+ }
+ }
+
+ return $retval;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.debug.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.debug.php
new file mode 100644
index 0000000..4345230
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.debug.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {debug} function plugin
+ *
+ * Type: function<br>
+ * Name: debug<br>
+ * Date: July 1, 2002<br>
+ * Purpose: popup debug window
+ * @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string output from {@link Smarty::_generate_debug_output()}
+ */
+function smarty_function_debug($params, &$smarty)
+{
+ if (isset($params['output'])) {
+ $smarty->assign('_smarty_debug_output', $params['output']);
+ }
+ require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
+ return smarty_core_display_debug_console(null, $smarty);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.eval.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.eval.php
new file mode 100644
index 0000000..3a4b8b2
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.eval.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {eval} function plugin
+ *
+ * Type: function<br>
+ * Name: eval<br>
+ * Purpose: evaluate a template variable as a template<br>
+ * @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ */
+function smarty_function_eval($params, &$smarty)
+{
+
+ if (!isset($params['var'])) {
+ $smarty->trigger_error("eval: missing 'var' parameter");
+ return;
+ }
+
+ if($params['var'] == '') {
+ return;
+ }
+
+ $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled);
+
+ ob_start();
+ $smarty->_eval('?>' . $_var_compiled);
+ $_contents = ob_get_contents();
+ ob_end_clean();
+
+ if (!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_contents);
+ } else {
+ return $_contents;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.fetch.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.fetch.php
new file mode 100644
index 0000000..f5a6987
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.fetch.php
@@ -0,0 +1,220 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {fetch} plugin
+ *
+ * Type: function<br>
+ * Name: fetch<br>
+ * Purpose: fetch file, web or ftp data and display results
+ * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string|null if the assign parameter is passed, Smarty assigns the
+ * result to a template variable
+ */
+function smarty_function_fetch($params, &$smarty)
+{
+ if (empty($params['file'])) {
+ $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");
+ return;
+ }
+
+ $content = '';
+ if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
+ $_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
+ require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
+ if(!smarty_core_is_secure($_params, $smarty)) {
+ $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
+ return;
+ }
+
+ // fetch the file
+ if($fp = @fopen($params['file'],'r')) {
+ while(!feof($fp)) {
+ $content .= fgets ($fp,4096);
+ }
+ fclose($fp);
+ } else {
+ $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'');
+ return;
+ }
+ } else {
+ // not a local file
+ if(preg_match('!^http://!i',$params['file'])) {
+ // http fetch
+ if($uri_parts = parse_url($params['file'])) {
+ // set defaults
+ $host = $server_name = $uri_parts['host'];
+ $timeout = 30;
+ $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
+ $agent = "Smarty Template Engine ".$smarty->_version;
+ $referer = "";
+ $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
+ $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
+ $_is_proxy = false;
+ if(empty($uri_parts['port'])) {
+ $port = 80;
+ } else {
+ $port = $uri_parts['port'];
+ }
+ if(!empty($uri_parts['user'])) {
+ $user = $uri_parts['user'];
+ }
+ if(!empty($uri_parts['pass'])) {
+ $pass = $uri_parts['pass'];
+ }
+ // loop through parameters, setup headers
+ foreach($params as $param_key => $param_value) {
+ switch($param_key) {
+ case "file":
+ case "assign":
+ case "assign_headers":
+ break;
+ case "user":
+ if(!empty($param_value)) {
+ $user = $param_value;
+ }
+ break;
+ case "pass":
+ if(!empty($param_value)) {
+ $pass = $param_value;
+ }
+ break;
+ case "accept":
+ if(!empty($param_value)) {
+ $accept = $param_value;
+ }
+ break;
+ case "header":
+ if(!empty($param_value)) {
+ if(!preg_match('![\w\d-]+: .+!',$param_value)) {
+ $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
+ return;
+ } else {
+ $extra_headers[] = $param_value;
+ }
+ }
+ break;
+ case "proxy_host":
+ if(!empty($param_value)) {
+ $proxy_host = $param_value;
+ }
+ break;
+ case "proxy_port":
+ if(!preg_match('!\D!', $param_value)) {
+ $proxy_port = (int) $param_value;
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ return;
+ }
+ break;
+ case "agent":
+ if(!empty($param_value)) {
+ $agent = $param_value;
+ }
+ break;
+ case "referer":
+ if(!empty($param_value)) {
+ $referer = $param_value;
+ }
+ break;
+ case "timeout":
+ if(!preg_match('!\D!', $param_value)) {
+ $timeout = (int) $param_value;
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ return;
+ }
+ break;
+ default:
+ $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");
+ return;
+ }
+ }
+ if(!empty($proxy_host) && !empty($proxy_port)) {
+ $_is_proxy = true;
+ $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
+ } else {
+ $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
+ }
+
+ if(!$fp) {
+ $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
+ return;
+ } else {
+ if($_is_proxy) {
+ fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
+ } else {
+ fputs($fp, "GET $uri HTTP/1.0\r\n");
+ }
+ if(!empty($host)) {
+ fputs($fp, "Host: $host\r\n");
+ }
+ if(!empty($accept)) {
+ fputs($fp, "Accept: $accept\r\n");
+ }
+ if(!empty($agent)) {
+ fputs($fp, "User-Agent: $agent\r\n");
+ }
+ if(!empty($referer)) {
+ fputs($fp, "Referer: $referer\r\n");
+ }
+ if(isset($extra_headers) && is_array($extra_headers)) {
+ foreach($extra_headers as $curr_header) {
+ fputs($fp, $curr_header."\r\n");
+ }
+ }
+ if(!empty($user) && !empty($pass)) {
+ fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
+ }
+
+ fputs($fp, "\r\n");
+ while(!feof($fp)) {
+ $content .= fgets($fp,4096);
+ }
+ fclose($fp);
+ $csplit = split("\r\n\r\n",$content,2);
+
+ $content = $csplit[1];
+
+ if(!empty($params['assign_headers'])) {
+ $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));
+ }
+ }
+ } else {
+ $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");
+ return;
+ }
+ } else {
+ // ftp fetch
+ if($fp = @fopen($params['file'],'r')) {
+ while(!feof($fp)) {
+ $content .= fgets ($fp,4096);
+ }
+ fclose($fp);
+ } else {
+ $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'');
+ return;
+ }
+ }
+
+ }
+
+
+ if (!empty($params['assign'])) {
+ $smarty->assign($params['assign'],$content);
+ } else {
+ return $content;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_checkboxes.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_checkboxes.php
new file mode 100644
index 0000000..ed8ad7f
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_checkboxes.php
@@ -0,0 +1,143 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_checkboxes} function plugin
+ *
+ * File: function.html_checkboxes.php<br>
+ * Type: function<br>
+ * Name: html_checkboxes<br>
+ * Date: 24.Feb.2003<br>
+ * Purpose: Prints out a list of checkbox input types<br>
+ * Input:<br>
+ * - name (optional) - string default "checkbox"
+ * - values (required) - array
+ * - options (optional) - associative array
+ * - checked (optional) - array default not set
+ * - separator (optional) - ie <br> or &nbsp;
+ * - output (optional) - the output next to each checkbox
+ * - assign (optional) - assign the output as an array to this variable
+ * Examples:
+ * <pre>
+ * {html_checkboxes values=$ids output=$names}
+ * {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
+ * {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
+ * (Smarty online manual)
+ * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_checkboxes($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = 'checkbox';
+ $values = null;
+ $options = null;
+ $selected = null;
+ $separator = '';
+ $labels = true;
+ $output = null;
+
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ case 'separator':
+ $$_key = $_val;
+ break;
+
+ case 'labels':
+ $$_key = (bool)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'checked':
+ case 'selected':
+ $selected = array_map('strval', array_values((array)$_val));
+ break;
+
+ case 'checkboxes':
+ $smarty->trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
+ $options = (array)$_val;
+ break;
+
+ case 'assign':
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ settype($selected, 'array');
+ $_html_result = array();
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+
+
+ } else {
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+ }
+
+ }
+
+ if(!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_html_result);
+ } else {
+ return implode("\n",$_html_result);
+ }
+
+}
+
+function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
+ $_output = '';
+ if ($labels) $_output .= '<label>';
+ $_output .= '<input type="checkbox" name="'
+ . smarty_function_escape_special_chars($name) . '[]" value="'
+ . smarty_function_escape_special_chars($value) . '"';
+
+ if (in_array((string)$value, $selected)) {
+ $_output .= ' checked="checked"';
+ }
+ $_output .= $extra . ' />' . $output;
+ if ($labels) $_output .= '</label>';
+ $_output .= $separator;
+
+ return $_output;
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_image.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_image.php
new file mode 100644
index 0000000..c62b0fe
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_image.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_image} function plugin
+ *
+ * Type: function<br>
+ * Name: html_image<br>
+ * Date: Feb 24, 2003<br>
+ * Purpose: format HTML tags for the image<br>
+ * Input:<br>
+ * - file = file (and path) of image (required)
+ * - height = image height (optional, default actual height)
+ * - width = image width (optional, default actual width)
+ * - basedir = base directory for absolute paths, default
+ * is environment variable DOCUMENT_ROOT
+ *
+ * Examples: {html_image file="images/masthead.gif"}
+ * Output: <img src="images/masthead.gif" width=400 height=23>
+ * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Duda <duda@big.hu> - wrote first image function
+ * in repository, helped with lots of functionality
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_image($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $alt = '';
+ $file = '';
+ $height = '';
+ $width = '';
+ $extra = '';
+ $prefix = '';
+ $suffix = '';
+ $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
+ $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'file':
+ case 'height':
+ case 'width':
+ case 'dpi':
+ case 'basedir':
+ $$_key = $_val;
+ break;
+
+ case 'alt':
+ if(!is_array($_val)) {
+ $$_key = smarty_function_escape_special_chars($_val);
+ } else {
+ $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+
+ case 'link':
+ case 'href':
+ $prefix = '<a href="' . $_val . '">';
+ $suffix = '</a>';
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (empty($file)) {
+ $smarty->trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
+ return;
+ }
+
+ if (substr($file,0,1) == '/') {
+ $_image_path = $basedir . $file;
+ } else {
+ $_image_path = $file;
+ }
+
+ if(!isset($params['width']) || !isset($params['height'])) {
+ if ($smarty->security &&
+ ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) &&
+ (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) &&
+ (!smarty_core_is_secure($_params, $smarty)) ) {
+ $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
+
+ } elseif (!$_image_data = @getimagesize($_image_path)) {
+ if(!file_exists($_image_path)) {
+ $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
+ return;
+ } else if(!is_readable($_image_path)) {
+ $smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
+ return;
+ } else {
+ $smarty->trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
+ return;
+ }
+ }
+
+ if(!isset($params['width'])) {
+ $width = $_image_data[0];
+ }
+ if(!isset($params['height'])) {
+ $height = $_image_data[1];
+ }
+
+ }
+
+ if(isset($params['dpi'])) {
+ if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
+ $dpi_default = 72;
+ } else {
+ $dpi_default = 96;
+ }
+ $_resize = $dpi_default/$params['dpi'];
+ $width = round($width * $_resize);
+ $height = round($height * $_resize);
+ }
+
+ return $prefix . '<img src="'.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_options.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_options.php
new file mode 100644
index 0000000..ae864f7
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_options.php
@@ -0,0 +1,121 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_options} function plugin
+ *
+ * Type: function<br>
+ * Name: html_options<br>
+ * Input:<br>
+ * - name (optional) - string default "select"
+ * - values (required if no options supplied) - array
+ * - options (required if no values supplied) - associative array
+ * - selected (optional) - string default not set
+ * - output (required if not options supplied) - array
+ * Purpose: Prints the list of <option> tags generated from
+ * the passed parameters
+ * @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_options($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = null;
+ $values = null;
+ $options = null;
+ $selected = array();
+ $output = null;
+
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ $$_key = (string)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'selected':
+ $$_key = array_map('strval', array_values((array)$_val));
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ $_html_result = '';
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+
+ } else {
+
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
+ }
+
+ }
+
+ if(!empty($name)) {
+ $_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
+ }
+
+ return $_html_result;
+
+}
+
+function smarty_function_html_options_optoutput($key, $value, $selected) {
+ if(!is_array($value)) {
+ $_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
+ smarty_function_escape_special_chars($key) . '"';
+ if (in_array((string)$key, $selected))
+ $_html_result .= ' selected="selected"';
+ $_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
+ } else {
+ $_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
+ }
+ return $_html_result;
+}
+
+function smarty_function_html_options_optgroup($key, $values, $selected) {
+ $optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
+ foreach ($values as $key => $value) {
+ $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
+ }
+ $optgroup_html .= "</optgroup>\n";
+ return $optgroup_html;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_radios.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_radios.php
new file mode 100644
index 0000000..dc7baee
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_radios.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_radios} function plugin
+ *
+ * File: function.html_radios.php<br>
+ * Type: function<br>
+ * Name: html_radios<br>
+ * Date: 24.Feb.2003<br>
+ * Purpose: Prints out a list of radio input types<br>
+ * Input:<br>
+ * - name (optional) - string default "radio"
+ * - values (required) - array
+ * - options (optional) - associative array
+ * - checked (optional) - array default not set
+ * - separator (optional) - ie <br> or &nbsp;
+ * - output (optional) - the output next to each radio button
+ * - assign (optional) - assign the output as an array to this variable
+ * Examples:
+ * <pre>
+ * {html_radios values=$ids output=$names}
+ * {html_radios values=$ids name='box' separator='<br>' output=$names}
+ * {html_radios values=$ids checked=$checked separator='<br>' output=$names}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
+ * (Smarty online manual)
+ * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_function_escape_special_chars()
+ */
+function smarty_function_html_radios($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
+
+ $name = 'radio';
+ $values = null;
+ $options = null;
+ $selected = null;
+ $separator = '';
+ $labels = true;
+ $output = null;
+ $extra = '';
+
+ foreach($params as $_key => $_val) {
+ switch($_key) {
+ case 'name':
+ case 'separator':
+ $$_key = (string)$_val;
+ break;
+
+ case 'checked':
+ case 'selected':
+ if(is_array($_val)) {
+ $smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
+ } else {
+ $selected = (string)$_val;
+ }
+ break;
+
+ case 'labels':
+ $$_key = (bool)$_val;
+ break;
+
+ case 'options':
+ $$_key = (array)$_val;
+ break;
+
+ case 'values':
+ case 'output':
+ $$_key = array_values((array)$_val);
+ break;
+
+ case 'radios':
+ $smarty->trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
+ $options = (array)$_val;
+ break;
+
+ case 'assign':
+ break;
+
+ default:
+ if(!is_array($_val)) {
+ $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
+ } else {
+ $smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
+ }
+ }
+
+ if (!isset($options) && !isset($values))
+ return ''; /* raise error here? */
+
+ $_html_result = array();
+
+ if (isset($options)) {
+
+ foreach ($options as $_key=>$_val)
+ $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+
+ } else {
+
+ foreach ($values as $_i=>$_key) {
+ $_val = isset($output[$_i]) ? $output[$_i] : '';
+ $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
+ }
+
+ }
+
+ if(!empty($params['assign'])) {
+ $smarty->assign($params['assign'], $_html_result);
+ } else {
+ return implode("\n",$_html_result);
+ }
+
+}
+
+function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
+ $_output = '';
+ if ($labels) {
+ $_id = smarty_function_escape_special_chars($name . '_' . $value);
+ $_output .= '<label for="' . $_id . '">';
+ }
+ $_output .= '<input type="radio" name="'
+ . smarty_function_escape_special_chars($name) . '" value="'
+ . smarty_function_escape_special_chars($value) . '"';
+
+ if ($labels) $_output .= ' id="' . $_id . '"';
+
+ if ($value==$selected) {
+ $_output .= ' checked="checked"';
+ }
+ $_output .= $extra . ' />' . $output;
+ if ($labels) $_output .= '</label>';
+ $_output .= $separator;
+
+ return $_output;
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_date.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_date.php
new file mode 100644
index 0000000..fc2d449
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_date.php
@@ -0,0 +1,316 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty {html_select_date} plugin
+ *
+ * Type: function<br>
+ * Name: html_select_date<br>
+ * Purpose: Prints the dropdowns for date selection.
+ *
+ * ChangeLog:<br>
+ * - 1.0 initial release
+ * - 1.1 added support for +/- N syntax for begin
+ * and end year values. (Monte)
+ * - 1.2 added support for yyyy-mm-dd syntax for
+ * time value. (Jan Rosier)
+ * - 1.3 added support for choosing format for
+ * month values (Gary Loescher)
+ * - 1.3.1 added support for choosing format for
+ * day values (Marcus Bointon)
+ * - 1.3.2 suppport negative timestamps, force year
+ * dropdown to include given date unless explicitly set (Monte)
+ * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
+ * (Smarty online manual)
+ * @version 1.3.2
+ * @author Andrei Zmievski
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_html_select_date($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $smarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Date_";
+ $start_year = strftime("%Y");
+ $end_year = $start_year;
+ $display_days = true;
+ $display_months = true;
+ $display_years = true;
+ $month_format = "%B";
+ /* Write months as numbers by default GL */
+ $month_value_format = "%m";
+ $day_format = "%02d";
+ /* Write day values using this format MB */
+ $day_value_format = "%d";
+ $year_as_text = false;
+ /* Display years in reverse order? Ie. 2000,1999,.... */
+ $reverse_years = false;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Day]",
+ "birthday[Month]" & "birthday[Year]". Can be combined with prefix */
+ $field_array = null;
+ /* <select size>'s of the different <select> tags.
+ If not set, uses default dropdown. */
+ $day_size = null;
+ $month_size = null;
+ $year_size = null;
+ /* Unparsed attributes common to *ALL* the <select>/<input> tags.
+ An example might be in the template: all_extra ='class ="foo"'. */
+ $all_extra = null;
+ /* Separate attributes for the tags. */
+ $day_extra = null;
+ $month_extra = null;
+ $year_extra = null;
+ /* Order in which to display the fields.
+ "D" -> day, "M" -> month, "Y" -> year. */
+ $field_order = 'MDY';
+ /* String printed between the different fields. */
+ $field_separator = "\n";
+ $time = time();
+ $all_empty = null;
+ $day_empty = null;
+ $month_empty = null;
+ $year_empty = null;
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'prefix':
+ case 'time':
+ case 'start_year':
+ case 'end_year':
+ case 'month_format':
+ case 'day_format':
+ case 'day_value_format':
+ case 'field_array':
+ case 'day_size':
+ case 'month_size':
+ case 'year_size':
+ case 'all_extra':
+ case 'day_extra':
+ case 'month_extra':
+ case 'year_extra':
+ case 'field_order':
+ case 'field_separator':
+ case 'month_value_format':
+ case 'month_empty':
+ case 'day_empty':
+ case 'year_empty':
+ $$_key = (string)$_value;
+ break;
+
+ case 'all_empty':
+ $$_key = (string)$_value;
+ $day_empty = $month_empty = $year_empty = $all_empty;
+ break;
+
+ case 'display_days':
+ case 'display_months':
+ case 'display_years':
+ case 'year_as_text':
+ case 'reverse_years':
+ $$_key = (bool)$_value;
+ break;
+
+ default:
+ $smarty->trigger_error("[html_select_date] unknown parameter $_key", E_USER_WARNING);
+
+ }
+ }
+
+ if(preg_match('!^-\d+$!',$time)) {
+ // negative timestamp, use date()
+ $time = date('Y-m-d',$time);
+ }
+ // If $time is not in format yyyy-mm-dd
+ if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) {
+ // use smarty_make_timestamp to get an unix timestamp and
+ // strftime to make yyyy-mm-dd
+ $time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
+ }
+ // Now split this in pieces, which later can be used to set the select
+ $time = explode("-", $time);
+
+ // make syntax "+N" or "-N" work with start_year and end_year
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
+ if ($match[1] == '+') {
+ $end_year = strftime('%Y') + $match[2];
+ } else {
+ $end_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
+ if ($match[1] == '+') {
+ $start_year = strftime('%Y') + $match[2];
+ } else {
+ $start_year = strftime('%Y') - $match[2];
+ }
+ }
+ if (strlen($time[0]) > 0) {
+ if ($start_year > $time[0] && !isset($params['start_year'])) {
+ // force start year to include given date if not explicitly set
+ $start_year = $time[0];
+ }
+ if($end_year < $time[0] && !isset($params['end_year'])) {
+ // force end year to include given date if not explicitly set
+ $end_year = $time[0];
+ }
+ }
+
+ $field_order = strtoupper($field_order);
+
+ $html_result = $month_result = $day_result = $year_result = "";
+
+ if ($display_months) {
+ $month_names = array();
+ $month_values = array();
+ if(isset($month_empty)) {
+ $month_names[''] = $month_empty;
+ $month_values[''] = '';
+ }
+ for ($i = 1; $i <= 12; $i++) {
+ $month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
+ $month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
+ }
+
+ $month_result .= '<select name=';
+ if (null !== $field_array){
+ $month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
+ } else {
+ $month_result .= '"' . $prefix . 'Month"';
+ }
+ if (null !== $month_size){
+ $month_result .= ' size="' . $month_size . '"';
+ }
+ if (null !== $month_extra){
+ $month_result .= ' ' . $month_extra;
+ }
+ if (null !== $all_extra){
+ $month_result .= ' ' . $all_extra;
+ }
+ $month_result .= '>'."\n";
+
+ $month_result .= smarty_function_html_options(array('output' => $month_names,
+ 'values' => $month_values,
+ 'selected' => $a=$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
+ 'print_result' => false),
+ $smarty);
+ $month_result .= '</select>';
+ }
+
+ if ($display_days) {
+ $days = array();
+ if (isset($day_empty)) {
+ $days[''] = $day_empty;
+ $day_values[''] = '';
+ }
+ for ($i = 1; $i <= 31; $i++) {
+ $days[] = sprintf($day_format, $i);
+ $day_values[] = sprintf($day_value_format, $i);
+ }
+
+ $day_result .= '<select name=';
+ if (null !== $field_array){
+ $day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
+ } else {
+ $day_result .= '"' . $prefix . 'Day"';
+ }
+ if (null !== $day_size){
+ $day_result .= ' size="' . $day_size . '"';
+ }
+ if (null !== $all_extra){
+ $day_result .= ' ' . $all_extra;
+ }
+ if (null !== $day_extra){
+ $day_result .= ' ' . $day_extra;
+ }
+ $day_result .= '>'."\n";
+ $day_result .= smarty_function_html_options(array('output' => $days,
+ 'values' => $day_values,
+ 'selected' => $time[2],
+ 'print_result' => false),
+ $smarty);
+ $day_result .= '</select>';
+ }
+
+ if ($display_years) {
+ if (null !== $field_array){
+ $year_name = $field_array . '[' . $prefix . 'Year]';
+ } else {
+ $year_name = $prefix . 'Year';
+ }
+ if ($year_as_text) {
+ $year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>';
+ } else {
+ $years = range((int)$start_year, (int)$end_year);
+ if ($reverse_years) {
+ rsort($years, SORT_NUMERIC);
+ } else {
+ sort($years, SORT_NUMERIC);
+ }
+ $yearvals = $years;
+ if(isset($year_empty)) {
+ array_unshift($years, $year_empty);
+ array_unshift($yearvals, '');
+ }
+ $year_result .= '<select name="' . $year_name . '"';
+ if (null !== $year_size){
+ $year_result .= ' size="' . $year_size . '"';
+ }
+ if (null !== $all_extra){
+ $year_result .= ' ' . $all_extra;
+ }
+ if (null !== $year_extra){
+ $year_result .= ' ' . $year_extra;
+ }
+ $year_result .= '>'."\n";
+ $year_result .= smarty_function_html_options(array('output' => $years,
+ 'values' => $yearvals,
+ 'selected' => $time[0],
+ 'print_result' => false),
+ $smarty);
+ $year_result .= '</select>';
+ }
+ }
+
+ // Loop thru the field_order field
+ for ($i = 0; $i <= 2; $i++){
+ $c = substr($field_order, $i, 1);
+ switch ($c){
+ case 'D':
+ $html_result .= $day_result;
+ break;
+
+ case 'M':
+ $html_result .= $month_result;
+ break;
+
+ case 'Y':
+ $html_result .= $year_result;
+ break;
+ }
+ // Add the field seperator
+ if($i != 2) {
+ $html_result .= $field_separator;
+ }
+ }
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_time.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_time.php
new file mode 100644
index 0000000..00cd1ae
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_select_time.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_select_time} function plugin
+ *
+ * Type: function<br>
+ * Name: html_select_time<br>
+ * Purpose: Prints the dropdowns for time selection
+ * @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses smarty_make_timestamp()
+ */
+function smarty_function_html_select_time($params, &$smarty)
+{
+ require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+ require_once $smarty->_get_plugin_filepath('function','html_options');
+ /* Default values. */
+ $prefix = "Time_";
+ $time = time();
+ $display_hours = true;
+ $display_minutes = true;
+ $display_seconds = true;
+ $display_meridian = true;
+ $use_24_hours = true;
+ $minute_interval = 1;
+ $second_interval = 1;
+ /* Should the select boxes be part of an array when returned from PHP?
+ e.g. setting it to "birthday", would create "birthday[Hour]",
+ "birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
+ Can be combined with prefix. */
+ $field_array = null;
+ $all_extra = null;
+ $hour_extra = null;
+ $minute_extra = null;
+ $second_extra = null;
+ $meridian_extra = null;
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'prefix':
+ case 'time':
+ case 'field_array':
+ case 'all_extra':
+ case 'hour_extra':
+ case 'minute_extra':
+ case 'second_extra':
+ case 'meridian_extra':
+ $$_key = (string)$_value;
+ break;
+
+ case 'display_hours':
+ case 'display_minutes':
+ case 'display_seconds':
+ case 'display_meridian':
+ case 'use_24_hours':
+ $$_key = (bool)$_value;
+ break;
+
+ case 'minute_interval':
+ case 'second_interval':
+ $$_key = (int)$_value;
+ break;
+
+ default:
+ $smarty->trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
+ }
+ }
+
+ $time = smarty_make_timestamp($time);
+
+ $html_result = '';
+
+ if ($display_hours) {
+ $hours = $use_24_hours ? range(0, 23) : range(1, 12);
+ $hour_fmt = $use_24_hours ? '%H' : '%I';
+ for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
+ $hours[$i] = sprintf('%02d', $hours[$i]);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Hour"';
+ }
+ if (null !== $hour_extra){
+ $html_result .= ' ' . $hour_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+ $html_result .= smarty_function_html_options(array('output' => $hours,
+ 'values' => $hours,
+ 'selected' => strftime($hour_fmt, $time),
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_minutes) {
+ $all_minutes = range(0, 59);
+ for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
+ $minutes[] = sprintf('%02d', $all_minutes[$i]);
+ $selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Minute"';
+ }
+ if (null !== $minute_extra){
+ $html_result .= ' ' . $minute_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $minutes,
+ 'values' => $minutes,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_seconds) {
+ $all_seconds = range(0, 59);
+ for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
+ $seconds[] = sprintf('%02d', $all_seconds[$i]);
+ $selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Second"';
+ }
+
+ if (null !== $second_extra){
+ $html_result .= ' ' . $second_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => $seconds,
+ 'values' => $seconds,
+ 'selected' => $selected,
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ if ($display_meridian && !$use_24_hours) {
+ $html_result .= '<select name=';
+ if (null !== $field_array) {
+ $html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
+ } else {
+ $html_result .= '"' . $prefix . 'Meridian"';
+ }
+
+ if (null !== $meridian_extra){
+ $html_result .= ' ' . $meridian_extra;
+ }
+ if (null !== $all_extra){
+ $html_result .= ' ' . $all_extra;
+ }
+ $html_result .= '>'."\n";
+
+ $html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
+ 'values' => array('am', 'pm'),
+ 'selected' => strtolower(strftime('%p', $time)),
+ 'print_result' => false),
+ $smarty);
+ $html_result .= "</select>\n";
+ }
+
+ return $html_result;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.html_table.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_table.php
new file mode 100644
index 0000000..62d7410
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.html_table.php
@@ -0,0 +1,137 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {html_table} function plugin
+ *
+ * Type: function<br>
+ * Name: html_table<br>
+ * Date: Feb 17, 2003<br>
+ * Purpose: make an html table from an array of data<br>
+ * Input:<br>
+ * - loop = array to loop through
+ * - cols = number of columns
+ * - rows = number of rows
+ * - table_attr = table attributes
+ * - tr_attr = table row attributes (arrays are cycled)
+ * - td_attr = table cell attributes (arrays are cycled)
+ * - trailpad = value to pad trailing cells with
+ * - vdir = vertical direction (default: "down", means top-to-bottom)
+ * - hdir = horizontal direction (default: "right", means left-to-right)
+ * - inner = inner loop (default "cols": print $loop line by line,
+ * $loop will be printed column by column otherwise)
+ *
+ *
+ * Examples:
+ * <pre>
+ * {table loop=$data}
+ * {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
+ * {table loop=$data cols=4 tr_attr=$colors}
+ * </pre>
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_html_table($params, &$smarty)
+{
+ $table_attr = 'border="1"';
+ $tr_attr = '';
+ $td_attr = '';
+ $cols = 3;
+ $rows = 3;
+ $trailpad = '&nbsp;';
+ $vdir = 'down';
+ $hdir = 'right';
+ $inner = 'cols';
+
+ if (!isset($params['loop'])) {
+ $smarty->trigger_error("html_table: missing 'loop' parameter");
+ return;
+ }
+
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'loop':
+ $$_key = (array)$_value;
+ break;
+
+ case 'cols':
+ case 'rows':
+ $$_key = (int)$_value;
+ break;
+
+ case 'table_attr':
+ case 'trailpad':
+ case 'hdir':
+ case 'vdir':
+ case 'inner':
+ $$_key = (string)$_value;
+ break;
+
+ case 'tr_attr':
+ case 'td_attr':
+ $$_key = $_value;
+ break;
+ }
+ }
+
+ $loop_count = count($loop);
+ if (empty($params['rows'])) {
+ /* no rows specified */
+ $rows = ceil($loop_count/$cols);
+ } elseif (empty($params['cols'])) {
+ if (!empty($params['rows'])) {
+ /* no cols specified, but rows */
+ $cols = ceil($loop_count/$rows);
+ }
+ }
+
+ $output = "<table $table_attr>\n";
+
+ for ($r=0; $r<$rows; $r++) {
+ $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
+ $rx = ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols;
+
+ for ($c=0; $c<$cols; $c++) {
+ $x = ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c;
+ if ($inner!='cols') {
+ /* shuffle x to loop over rows*/
+ $x = floor($x/$cols) + ($x%$cols)*$rows;
+ }
+
+ if ($x<$loop_count) {
+ $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n";
+ } else {
+ $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
+ }
+ }
+ $output .= "</tr>\n";
+ }
+ $output .= "</table>\n";
+
+ return $output;
+}
+
+function smarty_function_html_table_cycle($name, $var, $no) {
+ if(!is_array($var)) {
+ $ret = $var;
+ } else {
+ $ret = $var[$no % count($var)];
+ }
+
+ return ($ret) ? ' '.$ret : '';
+}
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.mailto.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.mailto.php
new file mode 100644
index 0000000..64c122c
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.mailto.php
@@ -0,0 +1,163 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {mailto} function plugin
+ *
+ * Type: function<br>
+ * Name: mailto<br>
+ * Date: May 21, 2002
+ * Purpose: automate mailto address link creation, and optionally
+ * encode them.<br>
+ * Input:<br>
+ * - address = e-mail address
+ * - text = (optional) text to display, default is address
+ * - encode = (optional) can be one of:
+ * * none : no encoding (default)
+ * * javascript : encode with javascript
+ * * javascript_charcode : encode with javascript charcode
+ * * hex : encode with hexidecimal (no javascript)
+ * - cc = (optional) address(es) to carbon copy
+ * - bcc = (optional) address(es) to blind carbon copy
+ * - subject = (optional) e-mail subject
+ * - newsgroups = (optional) newsgroup(s) to post to
+ * - followupto = (optional) address(es) to follow up to
+ * - extra = (optional) extra tags for the href link
+ *
+ * Examples:
+ * <pre>
+ * {mailto address="me@domain.com"}
+ * {mailto address="me@domain.com" encode="javascript"}
+ * {mailto address="me@domain.com" encode="hex"}
+ * {mailto address="me@domain.com" subject="Hello to you!"}
+ * {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
+ * {mailto address="me@domain.com" extra='class="mailto"'}
+ * </pre>
+ * @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
+ * (Smarty online manual)
+ * @version 1.2
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Jason Sweat (added cc, bcc and subject functionality)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_mailto($params, &$smarty)
+{
+ $extra = '';
+
+ if (empty($params['address'])) {
+ $smarty->trigger_error("mailto: missing 'address' parameter");
+ return;
+ } else {
+ $address = $params['address'];
+ }
+
+ $text = $address;
+
+ // netscape and mozilla do not decode %40 (@) in BCC field (bug?)
+ // so, don't encode it.
+ $mail_parms = array();
+ foreach ($params as $var=>$value) {
+ switch ($var) {
+ case 'cc':
+ case 'bcc':
+ case 'followupto':
+ if (!empty($value))
+ $mail_parms[] = $var.'='.str_replace('%40','@',rawurlencode($value));
+ break;
+
+ case 'subject':
+ case 'newsgroups':
+ $mail_parms[] = $var.'='.rawurlencode($value);
+ break;
+
+ case 'extra':
+ case 'text':
+ $$var = $value;
+
+ default:
+ }
+ }
+
+ $mail_parm_vals = '';
+ for ($i=0; $i<count($mail_parms); $i++) {
+ $mail_parm_vals .= (0==$i) ? '?' : '&';
+ $mail_parm_vals .= $mail_parms[$i];
+ }
+ $address .= $mail_parm_vals;
+
+ $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
+ if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
+ $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
+ return;
+ }
+
+ if ($encode == 'javascript' ) {
+ $string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
+
+ $js_encode = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $js_encode .= '%' . bin2hex($string[$x]);
+ }
+
+ return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
+
+ } elseif ($encode == 'javascript_charcode' ) {
+ $string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+ for($x = 0, $y = strlen($string); $x < $y; $x++ ) {
+ $ord[] = ord($string[$x]);
+ }
+
+ $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
+ $_ret .= "<!--\n";
+ $_ret .= "{document.write(String.fromCharCode(";
+ $_ret .= implode(',',$ord);
+ $_ret .= "))";
+ $_ret .= "}\n";
+ $_ret .= "//-->\n";
+ $_ret .= "</script>\n";
+
+ return $_ret;
+
+
+ } elseif ($encode == 'hex') {
+
+ preg_match('!^(.*)(\?.*)$!',$address,$match);
+ if(!empty($match[2])) {
+ $smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
+ return;
+ }
+ $address_encode = '';
+ for ($x=0; $x < strlen($address); $x++) {
+ if(preg_match('!\w!',$address[$x])) {
+ $address_encode .= '%' . bin2hex($address[$x]);
+ } else {
+ $address_encode .= $address[$x];
+ }
+ }
+ $text_encode = '';
+ for ($x=0; $x < strlen($text); $x++) {
+ $text_encode .= '&#x' . bin2hex($text[$x]).';';
+ }
+
+ $mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
+ return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
+
+ } else {
+ // no encoding
+ return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+ }
+
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.math.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.math.php
new file mode 100644
index 0000000..0439107
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.math.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {math} function plugin
+ *
+ * Type: function<br>
+ * Name: math<br>
+ * Purpose: handle math computations in template<br>
+ * @link http://smarty.php.net/manual/en/language.function.math.php {math}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_math($params, &$smarty)
+{
+ // be sure equation parameter is present
+ if (empty($params['equation'])) {
+ $smarty->trigger_error("math: missing equation parameter");
+ return;
+ }
+
+ $equation = $params['equation'];
+
+ // make sure parenthesis are balanced
+ if (substr_count($equation,"(") != substr_count($equation,")")) {
+ $smarty->trigger_error("math: unbalanced parenthesis");
+ return;
+ }
+
+ // match all vars in equation, make sure all are passed
+ preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]+)!",$equation, $match);
+ $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
+ 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
+
+ foreach($match[1] as $curr_var) {
+ if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
+ $smarty->trigger_error("math: function call $curr_var not allowed");
+ return;
+ }
+ }
+
+ foreach($params as $key => $val) {
+ if ($key != "equation" && $key != "format" && $key != "assign") {
+ // make sure value is not empty
+ if (strlen($val)==0) {
+ $smarty->trigger_error("math: parameter $key is empty");
+ return;
+ }
+ if (!is_numeric($val)) {
+ $smarty->trigger_error("math: parameter $key: is not numeric");
+ return;
+ }
+ $equation = preg_replace("/\b$key\b/",$val, $equation);
+ }
+ }
+
+ eval("\$smarty_math_result = ".$equation.";");
+
+ if (empty($params['format'])) {
+ if (empty($params['assign'])) {
+ return $smarty_math_result;
+ } else {
+ $smarty->assign($params['assign'],$smarty_math_result);
+ }
+ } else {
+ if (empty($params['assign'])){
+ printf($params['format'],$smarty_math_result);
+ } else {
+ $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
+ }
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.popup.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.popup.php
new file mode 100644
index 0000000..2ba54de
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.popup.php
@@ -0,0 +1,117 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {popup} function plugin
+ *
+ * Type: function<br>
+ * Name: popup<br>
+ * Purpose: make text pop up in windows via overlib
+ * @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_popup($params, &$smarty)
+{
+ $append = '';
+ foreach ($params as $_key=>$_value) {
+ switch ($_key) {
+ case 'text':
+ case 'trigger':
+ case 'function':
+ case 'inarray':
+ $$_key = (string)$_value;
+ if ($_key == 'function' || $_key == 'inarray')
+ $append .= ',' . strtoupper($_key) . ",'$_value'";
+ break;
+
+ case 'caption':
+ case 'closetext':
+ case 'status':
+ $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
+ break;
+
+ case 'fgcolor':
+ case 'bgcolor':
+ case 'textcolor':
+ case 'capcolor':
+ case 'closecolor':
+ case 'textfont':
+ case 'captionfont':
+ case 'closefont':
+ case 'fgbackground':
+ case 'bgbackground':
+ case 'caparray':
+ case 'capicon':
+ case 'background':
+ case 'frame':
+ $append .= ',' . strtoupper($_key) . ",'$_value'";
+ break;
+
+ case 'textsize':
+ case 'captionsize':
+ case 'closesize':
+ case 'width':
+ case 'height':
+ case 'border':
+ case 'offsetx':
+ case 'offsety':
+ case 'snapx':
+ case 'snapy':
+ case 'fixx':
+ case 'fixy':
+ case 'padx':
+ case 'pady':
+ case 'timeout':
+ case 'delay':
+ $append .= ',' . strtoupper($_key) . ",$_value";
+ break;
+
+ case 'sticky':
+ case 'left':
+ case 'right':
+ case 'center':
+ case 'above':
+ case 'below':
+ case 'noclose':
+ case 'autostatus':
+ case 'autostatuscap':
+ case 'fullhtml':
+ case 'hauto':
+ case 'vauto':
+ case 'mouseoff':
+ case 'followmouse':
+ if ($_value) $append .= ',' . strtoupper($_key);
+ break;
+
+ default:
+ $smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
+ }
+ }
+
+ if (empty($text) && !isset($inarray) && empty($function)) {
+ $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
+ return false;
+ }
+
+ if (empty($trigger)) { $trigger = "onmouseover"; }
+
+ $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
+ $retval .= $append . ');"';
+ if ($trigger == 'onmouseover')
+ $retval .= ' onmouseout="nd();"';
+
+
+ return $retval;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/function.popup_init.php b/html/phpgacl/admin/smarty_x/libs/plugins/function.popup_init.php
new file mode 100644
index 0000000..f62c33c
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/function.popup_init.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {popup_init} function plugin
+ *
+ * Type: function<br>
+ * Name: popup_init<br>
+ * Purpose: initialize overlib
+ * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init}
+ * (Smarty online manual)
+ * @param array
+ * @param Smarty
+ * @return string
+ */
+function smarty_function_popup_init($params, &$smarty)
+{
+ $zindex = 1000;
+
+ if (!empty($params['zindex'])) {
+ $zindex = $params['zindex'];
+ }
+
+ if (!empty($params['src'])) {
+ return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
+ . '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
+ } else {
+ $smarty->trigger_error("popup_init: missing src parameter");
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.capitalize.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.capitalize.php
new file mode 100644
index 0000000..2b9169c
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.capitalize.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty capitalize modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: capitalize<br>
+ * Purpose: capitalize words in the string
+ * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
+ * capitalize (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_capitalize($string, $uc_digits = false)
+{
+ smarty_modifier_capitalize_ucfirst(null, $uc_digits);
+ return preg_replace_callback('!\b\w+\b!', 'smarty_modifier_capitalize_ucfirst', $string);
+}
+
+function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
+{
+ static $_uc_digits = false;
+
+ if(isset($uc_digits)) {
+ $_uc_digits = $uc_digits;
+ return;
+ }
+
+ if(!preg_match('!\d!',$string[0]) || $_uc_digits)
+ return ucfirst($string[0]);
+ else
+ return $string[0];
+}
+
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.cat.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.cat.php
new file mode 100644
index 0000000..2e37940
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.cat.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty cat modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: cat<br>
+ * Date: Feb 24, 2003
+ * Purpose: catenate a value to a variable
+ * Input: string to catenate
+ * Example: {$var|cat:"foo"}
+ * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_cat($string, $cat)
+{
+ return $string . $cat;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_characters.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_characters.php
new file mode 100644
index 0000000..49ce655
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_characters.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_characters modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_characteres<br>
+ * Purpose: count the number of characters in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
+ * count_characters (Smarty online manual)
+ * @param string
+ * @param boolean include whitespace in the character count
+ * @return integer
+ */
+function smarty_modifier_count_characters($string, $include_spaces = false)
+{
+ if ($include_spaces)
+ return(strlen($string));
+
+ return preg_match_all("/[^\s]/",$string, $match);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_paragraphs.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_paragraphs.php
new file mode 100644
index 0000000..6a9833c
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_paragraphs.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_paragraphs modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_paragraphs<br>
+ * Purpose: count the number of paragraphs in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_paragraphs (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_paragraphs($string)
+{
+ // count \r or \n characters
+ return count(preg_split('/[\r\n]+/', $string));
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_sentences.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_sentences.php
new file mode 100644
index 0000000..0c210f0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_sentences.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_sentences modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_sentences
+ * Purpose: count the number of sentences in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
+ * count_sentences (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_sentences($string)
+{
+ // find periods with a word before but not after.
+ return preg_match_all('/[^\s]\.(?!\w)/', $string, $match);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_words.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_words.php
new file mode 100644
index 0000000..42c8a74
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.count_words.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty count_words modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: count_words<br>
+ * Purpose: count the number of words in a text
+ * @link http://smarty.php.net/manual/en/language.modifier.count.words.php
+ * count_words (Smarty online manual)
+ * @param string
+ * @return integer
+ */
+function smarty_modifier_count_words($string)
+{
+ // split text by ' ',\r,\n,\f,\t
+ $split_array = preg_split('/\s+/',$string);
+ // count matches that contain alphanumerics
+ $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
+
+ return count($word_count);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.date_format.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.date_format.php
new file mode 100644
index 0000000..2f36b3b
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.date_format.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Include the {@link shared.make_timestamp.php} plugin
+ */
+require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+/**
+ * Smarty date_format modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: date_format<br>
+ * Purpose: format datestamps via strftime<br>
+ * Input:<br>
+ * - string: input date string
+ * - format: strftime format for output
+ * - default_date: default date if $string is empty
+ * @link http://smarty.php.net/manual/en/language.modifier.date.format.php
+ * date_format (Smarty online manual)
+ * @param string
+ * @param string
+ * @param string
+ * @return string|void
+ * @uses smarty_make_timestamp()
+ */
+function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
+{
+ if (substr(PHP_OS,0,3) == 'WIN') {
+ $_win_from = array ('%e', '%T', '%D');
+ $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y');
+ $format = str_replace($_win_from, $_win_to, $format);
+ }
+ if($string != '') {
+ return strftime($format, smarty_make_timestamp($string));
+ } elseif (isset($default_date) && $default_date != '') {
+ return strftime($format, smarty_make_timestamp($default_date));
+ } else {
+ return;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.debug_print_var.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.debug_print_var.php
new file mode 100644
index 0000000..b9bb184
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.debug_print_var.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty debug_print_var modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: debug_print_var<br>
+ * Purpose: formats variable contents for display in the console
+ * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
+ * debug_print_var (Smarty online manual)
+ * @param array|object
+ * @param integer
+ * @param integer
+ * @return string
+ */
+function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
+{
+ $_replace = array("\n"=>'<i>&#92;n</i>', "\r"=>'<i>&#92;r</i>', "\t"=>'<i>&#92;t</i>');
+ if (is_array($var)) {
+ $results = "<b>Array (".count($var).")</b>";
+ foreach ($var as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>".strtr($curr_key, $_replace)."</b> =&gt; $return";
+ }
+ } else if (is_object($var)) {
+ $object_vars = get_object_vars($var);
+ $results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
+ foreach ($object_vars as $curr_key => $curr_val) {
+ $return = smarty_modifier_debug_print_var($curr_val, $depth+1, $length);
+ $results .= "<br>".str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
+ }
+ } else if (is_resource($var)) {
+ $results = '<i>'.(string)$var.'</i>';
+ } else if (empty($var) && $var != "0") {
+ $results = '<i>empty</i>';
+ } else {
+ if (strlen($var) > $length ) {
+ $results = substr($var, 0, $length-3).'...';
+ } else {
+ $results = $var;
+ }
+ $results = htmlspecialchars($results);
+ $results = strtr($results, $_replace);
+ }
+ return $results;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.default.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.default.php
new file mode 100644
index 0000000..8268e39
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.default.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty default modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: default<br>
+ * Purpose: designate default value for empty variables
+ * @link http://smarty.php.net/manual/en/language.modifier.default.php
+ * default (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_default($string, $default = '')
+{
+ if (!isset($string) || $string === '')
+ return $default;
+ else
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.escape.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.escape.php
new file mode 100644
index 0000000..a32a876
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.escape.php
@@ -0,0 +1,89 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty escape modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: escape<br>
+ * Purpose: Escape the string according to escapement type
+ * @link http://smarty.php.net/manual/en/language.modifier.escape.php
+ * escape (Smarty online manual)
+ * @param string
+ * @param html|htmlall|url|quotes|hex|hexentity|javascript
+ * @return string
+ */
+function smarty_modifier_escape($string, $esc_type = 'html')
+{
+ switch ($esc_type) {
+ case 'html':
+ return htmlspecialchars($string, ENT_QUOTES);
+
+ case 'htmlall':
+ return htmlentities($string, ENT_QUOTES);
+
+ case 'url':
+ return rawurlencode($string);
+
+ case 'quotes':
+ // escape unescaped single quotes
+ return preg_replace("%(?<!\\\\)'%", "\\'", $string);
+
+ case 'hex':
+ // escape every character into hex
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '%' . bin2hex($string[$x]);
+ }
+ return $return;
+
+ case 'hexentity':
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '&#x' . bin2hex($string[$x]) . ';';
+ }
+ return $return;
+
+ case 'decentity':
+ $return = '';
+ for ($x=0; $x < strlen($string); $x++) {
+ $return .= '&#' . ord($string[$x]) . ';';
+ }
+ return $return;
+
+ case 'javascript':
+ // escape quotes and backslashes, newlines, etc.
+ return strtr($string, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/'));
+
+ case 'mail':
+ // safe way to display e-mail address on a web page
+ return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string);
+
+ case 'nonstd':
+ // escape non-standard chars, such as ms document quotes
+ $_res = '';
+ for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
+ $_ord = ord($string{$_i});
+ // non-standard char, escape it
+ if($_ord >= 126){
+ $_res .= '&#' . $_ord . ';';
+ }
+ else {
+ $_res .= $string{$_i};
+ }
+ }
+ return $_res;
+
+ default:
+ return $string;
+ }
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.indent.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.indent.php
new file mode 100644
index 0000000..1642bac
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.indent.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty indent modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: indent<br>
+ * Purpose: indent lines of text
+ * @link http://smarty.php.net/manual/en/language.modifier.indent.php
+ * indent (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @return string
+ */
+function smarty_modifier_indent($string,$chars=4,$char=" ")
+{
+ return preg_replace('!^!m',str_repeat($char,$chars),$string);
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.lower.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.lower.php
new file mode 100644
index 0000000..0b4d151
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.lower.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty lower modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: lower<br>
+ * Purpose: convert string to lowercase
+ * @link http://smarty.php.net/manual/en/language.modifier.lower.php
+ * lower (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_lower($string)
+{
+ return strtolower($string);
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.nl2br.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.nl2br.php
new file mode 100644
index 0000000..d6fabff
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.nl2br.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty plugin
+ *
+ * Type: modifier<br>
+ * Name: nl2br<br>
+ * Date: Feb 26, 2003
+ * Purpose: convert \r\n, \r or \n to <<br>>
+ * Input:<br>
+ * - contents = contents to replace
+ * - preceed_test = if true, includes preceeding break tags
+ * in replacement
+ * Example: {$text|nl2br}
+ * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php
+ * nl2br (Smarty online manual)
+ * @version 1.0
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @param string
+ * @return string
+ */
+function smarty_modifier_nl2br($string)
+{
+ return nl2br($string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.regex_replace.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.regex_replace.php
new file mode 100644
index 0000000..7eee497
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.regex_replace.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty regex_replace modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: regex_replace<br>
+ * Purpose: regular epxression search/replace
+ * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
+ * regex_replace (Smarty online manual)
+ * @param string
+ * @param string|array
+ * @param string|array
+ * @return string
+ */
+function smarty_modifier_regex_replace($string, $search, $replace)
+{
+ if (preg_match('!\W(\w+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
+ /* remove eval-modifier from $search */
+ $search = substr($search, 0, -strlen($match[1])) . str_replace('e', '', $match[1]);
+ }
+ return preg_replace($search, $replace, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.replace.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.replace.php
new file mode 100644
index 0000000..2a43515
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.replace.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty replace modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: replace<br>
+ * Purpose: simple search/replace
+ * @link http://smarty.php.net/manual/en/language.modifier.replace.php
+ * replace (Smarty online manual)
+ * @param string
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_replace($string, $search, $replace)
+{
+ return str_replace($search, $replace, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.spacify.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.spacify.php
new file mode 100644
index 0000000..dad057f
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.spacify.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty spacify modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: spacify<br>
+ * Purpose: add spaces between characters in a string
+ * @link http://smarty.php.net/manual/en/language.modifier.spacify.php
+ * spacify (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_spacify($string, $spacify_char = ' ')
+{
+ return implode($spacify_char,
+ preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.string_format.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.string_format.php
new file mode 100644
index 0000000..efd6215
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.string_format.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty string_format modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: string_format<br>
+ * Purpose: format strings via sprintf
+ * @link http://smarty.php.net/manual/en/language.modifier.string.format.php
+ * string_format (Smarty online manual)
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_string_format($string, $format)
+{
+ return sprintf($format, $string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip.php
new file mode 100644
index 0000000..cc5c453
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty strip modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: strip<br>
+ * Purpose: Replace all repeated spaces, newlines, tabs
+ * with a single space or supplied replacement string.<br>
+ * Example: {$var|strip} {$var|strip:"&nbsp;"}
+ * Date: September 25th, 2002
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.php
+ * strip (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @version 1.0
+ * @param string
+ * @param string
+ * @return string
+ */
+function smarty_modifier_strip($text, $replace = ' ')
+{
+ return preg_replace('!\s+!', $replace, $text);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip_tags.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip_tags.php
new file mode 100644
index 0000000..45f1ec1
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.strip_tags.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty strip_tags modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: strip_tags<br>
+ * Purpose: strip html tags from text
+ * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php
+ * strip_tags (Smarty online manual)
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_strip_tags($string, $replace_with_space = true)
+{
+ if ($replace_with_space)
+ return preg_replace('!<[^>]*?>!', ' ', $string);
+ else
+ return strip_tags($string);
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.truncate.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.truncate.php
new file mode 100644
index 0000000..15a26ba
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.truncate.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty truncate modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: truncate<br>
+ * Purpose: Truncate a string to a certain length if necessary,
+ * optionally splitting in the middle of a word, and
+ * appending the $etc string.
+ * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
+ * truncate (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_truncate($string, $length = 80, $etc = '...',
+ $break_words = false)
+{
+ if ($length == 0)
+ return '';
+
+ if (strlen($string) > $length) {
+ $length -= strlen($etc);
+ if (!$break_words)
+ $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
+
+ return substr($string, 0, $length).$etc;
+ } else
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.upper.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.upper.php
new file mode 100644
index 0000000..69960ae
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.upper.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty upper modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: upper<br>
+ * Purpose: convert string to uppercase
+ * @link http://smarty.php.net/manual/en/language.modifier.upper.php
+ * upper (Smarty online manual)
+ * @param string
+ * @return string
+ */
+function smarty_modifier_upper($string)
+{
+ return strtoupper($string);
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/modifier.wordwrap.php b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.wordwrap.php
new file mode 100644
index 0000000..b9a9fe9
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/modifier.wordwrap.php
@@ -0,0 +1,28 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty wordwrap modifier plugin
+ *
+ * Type: modifier<br>
+ * Name: wordwrap<br>
+ * Purpose: wrap a string of text at a given length
+ * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php
+ * wordwrap (Smarty online manual)
+ * @param string
+ * @param integer
+ * @param string
+ * @param boolean
+ * @return string
+ */
+function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
+{
+ return wordwrap($string,$length,$break,$cut);
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/outputfilter.trimwhitespace.php b/html/phpgacl/admin/smarty_x/libs/plugins/outputfilter.trimwhitespace.php
new file mode 100644
index 0000000..01e35e0
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/outputfilter.trimwhitespace.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Smarty plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+/**
+ * Smarty trimwhitespace outputfilter plugin
+ *
+ * File: outputfilter.trimwhitespace.php<br>
+ * Type: outputfilter<br>
+ * Name: trimwhitespace<br>
+ * Date: Jan 25, 2003<br>
+ * Purpose: trim leading white space and blank lines from
+ * template source after it gets interpreted, cleaning
+ * up code and saving bandwidth. Does not affect
+ * <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
+ * Install: Drop into the plugin directory, call
+ * <code>$smarty->load_filter('output','trimwhitespace');</code>
+ * from application.
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
+ * @version 1.3
+ * @param string
+ * @param Smarty
+ */
+function smarty_outputfilter_trimwhitespace($source, &$smarty)
+{
+ // Pull out the script blocks
+ preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
+ $_script_blocks = $match[0];
+ $source = preg_replace("!<script[^>]+>.*?</script>!is",
+ '@@@SMARTY:TRIM:SCRIPT@@@', $source);
+
+ // Pull out the pre blocks
+ preg_match_all("!<pre>.*?</pre>!is", $source, $match);
+ $_pre_blocks = $match[0];
+ $source = preg_replace("!<pre>.*?</pre>!is",
+ '@@@SMARTY:TRIM:PRE@@@', $source);
+
+ // Pull out the textarea blocks
+ preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
+ $_textarea_blocks = $match[0];
+ $source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
+ '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
+
+ // remove all leading spaces, tabs and carriage returns NOT
+ // preceeded by a php close tag.
+ $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
+
+ // replace script blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
+
+ // replace pre blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
+
+ // replace textarea blocks
+ smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
+
+ return $source;
+}
+
+function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
+ $_len = strlen($search_str);
+ $_pos = 0;
+ for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
+ if (($_pos=strpos($subject, $search_str, $_pos))!==false)
+ $subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
+ else
+ break;
+
+}
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/shared.escape_special_chars.php b/html/phpgacl/admin/smarty_x/libs/plugins/shared.escape_special_chars.php
new file mode 100644
index 0000000..515763a
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/shared.escape_special_chars.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Smarty shared plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * escape_special_chars common function
+ *
+ * Function: smarty_function_escape_special_chars<br>
+ * Purpose: used by other smarty functions to escape
+ * special chars except for already escaped ones
+ * @param string
+ * @return string
+ */
+function smarty_function_escape_special_chars($string)
+{
+ if(!is_array($string)) {
+ $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
+ $string = htmlspecialchars($string);
+ $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
+ }
+ return $string;
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/smarty_x/libs/plugins/shared.make_timestamp.php b/html/phpgacl/admin/smarty_x/libs/plugins/shared.make_timestamp.php
new file mode 100644
index 0000000..acdd777
--- /dev/null
+++ b/html/phpgacl/admin/smarty_x/libs/plugins/shared.make_timestamp.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Smarty shared plugin
+ * @package Smarty
+ * @subpackage plugins
+ */
+
+
+/**
+ * Function: smarty_make_timestamp<br>
+ * Purpose: used by other smarty functions to make a timestamp
+ * from a string.
+ * @param string
+ * @return string
+ */
+function smarty_make_timestamp($string)
+{
+ if(empty($string)) {
+ $string = "now";
+ }
+ $time = strtotime($string);
+ if (is_numeric($time) && $time != -1)
+ return $time;
+
+ // is mysql timestamp format of YYYYMMDDHHMMSS?
+ if (preg_match('/^\d{14}$/', $string)) {
+ $time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
+ substr($string,4,2),substr($string,6,2),substr($string,0,4));
+
+ return $time;
+ }
+
+ // couldn't recognize it, try to return a time
+ $time = (int) $string;
+ if ($time > 0)
+ return $time;
+ else
+ return time();
+}
+
+/* vim: set expandtab: */
+
+?>
diff --git a/html/phpgacl/admin/templates/phpgacl/about.tpl b/html/phpgacl/admin/templates/phpgacl/about.tpl
new file mode 100644
index 0000000..9e32182
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/about.tpl
@@ -0,0 +1,86 @@
+{include file="phpgacl/header.tpl"}
+ </head>
+ <body>
+ {include file="phpgacl/navigation.tpl"}
+ <div style="text-align: center;">
+ <table cellpadding="2" cellspacing="2" border="2" align="center">
+ <tbody>
+ {if $first_run != 1}
+ <tr>
+ <th>
+ Help
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Please join the <a href="https://sourceforge.net/mail/?group_id=57103">Mailing Lists</a> if you have
+ any questions, comments, or support questions.
+ <p><b>TIP</b>: Searching the Mailing List archives may be a good idea prior to emailing the list, <br>
+ as well the below "Report" information may be helpful in any support questions.</p>
+ <p>PLEASE DO NOT EMAIL ME DIRECTLY REGARDING SUPPORT QUESTIONS<br />
+ You will receive answers faster on the mailing list, and any answers given may benefit others.</p>
+ But if you must email me (Mike Benoit) directly, click <a href="mailto:ipso@snappymail.ca">here</a>.
+ </td>
+ </tr>
+ <tr>
+ <th>
+ Donate
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Time working on phpGACL means less time that I can work to get paid.<br />
+ Therefore any donations I receive will help me to devote more time to developing phpGACL.
+ <p>However, I'd much rather donations in the form of code and/or documentation.</p>
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" align="center">
+ <input type="hidden" name="cmd" value="_xclick">
+ <input type="hidden" name="business" value="ipso@snappymail.ca">
+ <input type="hidden" name="item_name" value="php Generic Access Control List">
+ <input type="hidden" name="no_note" value="1">
+ <input type="hidden" name="currency_code" value="USD">
+ <input type="hidden" name="tax" value="0">
+ <input type="image" class="paypal" src="https://www.paypal.com/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
+ </form>
+ </td>
+ </tr>
+ {/if}
+ <tr>
+ <th>
+ {if $first_run != 1}
+ Report
+ {else}
+ <font color="#ff0000">* Report *</font>
+ {/if}
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Report some basic information back to the phpGACL project so we know where to spend our time.<br />
+ <b>All information will be kept private, will not be sold, and will only be used for informational purposes regarding phpGACL.</b>
+ <br /><br />
+ <form method="post" name="about" action="about.php" align="center">
+ <textarea name="system_information" rows="10" cols="60" wrap="VIRTUAL">{$system_info}</textarea>
+ <br />
+ <input type="hidden" name="system_info_md5" value="{$system_info_md5}" />
+ <input type="submit" name="action" value="Submit" />
+ </form>
+ </td>
+ </tr>
+ {if $first_run != 1}
+ <tr>
+ <th>
+ Credits
+ </th>
+ </tr>
+ <tr>
+ <td>
+<pre>
+{$credits}
+</pre>
+ </td>
+ </tr>
+ {/if}
+ </tbody>
+ </table>
+ </div>
+{include file="phpgacl/footer.tpl"}
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_admin.tpl b/html/phpgacl/admin/templates/phpgacl/acl_admin.tpl
new file mode 100644
index 0000000..e57e3d4
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_admin.tpl
@@ -0,0 +1,180 @@
+{include file="phpgacl/header.tpl"}
+<script LANGUAGE="JavaScript">
+{$js_array}
+</script>
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+<body onload="populate(document.acl_admin.aco_section,document.acl_admin.elements['aco[]'], '{$js_aco_array_name}');populate(document.acl_admin.aro_section,document.acl_admin.elements['aro[]'], '{$js_aro_array_name}')">
+{include file="phpgacl/navigation.tpl"}
+ <form method="post" name="acl_admin" action="acl_admin.php" onsubmit="select_all(document.acl_admin.elements['selected_aco[]']);select_all(document.acl_admin.elements['selected_aro[]']);select_all(document.acl_admin.elements['selected_aro[]']);return true;">
+ <div align="center">
+ <table cellpadding="2" cellspacing="2" border="2" align="center">
+ <tbody>
+ <tr>
+ <th width="24%">Sections</th>
+ <th width="24%">Access Control Objects</th>
+ <th width="4%">&nbsp;</th>
+ <th width="24%">Selected</th>
+ <th width="24%">Access</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type=aco&return_page={$return_page}">Edit</a> ]
+ <br />
+ <select name="aco_section" tabindex="0" size="10" onclick="populate(document.acl_admin.aco_section,document.acl_admin.elements['aco[]'], '{$js_aco_array_name}')">
+ {html_options options=$options_aco_sections selected=$aco_section_value}
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=aco&section_value=' + document.acl_admin.aco_section.options[document.acl_admin.aco_section.selectedIndex].value + '&return_page={$return_page}';">Edit</a> ]
+ <br />
+ <select name="aco[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.aco_section, document.acl_admin.elements['aco[]'], document.acl_admin.elements['selected_aco[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_aco[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_aco[]" tabindex="0" size="10" multiple>
+ {html_options options=$options_selected_aco selected=$selected_aco}
+ </select>
+ </td>
+ <td valign="middle">
+ <table class="invisible">
+ <tr align="left"><td><input type="radio" class="radio" name="allow" value="1" {if $allow==1}checked{/if} /></td><td>Allow</td></tr>
+ <tr align="left"><td><input type="radio" class="radio" name="allow" value="0" {if $allow==0}checked{/if} /></td><td>Deny</td></tr>
+ <tr class="spacer"><td colspan="2"></td></tr>
+ <tr align="left"><td><input type="checkbox" class="checkbox" name="enabled" value="1" {if $enabled==1}checked{/if} /></td><td>Enabled</td></tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <th>Sections</th>
+ <th>Access Request Objects</th>
+ <th>&nbsp;</th>
+ <th>Selected</th>
+ <th>Groups</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type=aro&return_page={$return_page}">Edit</a> ]
+ <br />
+ <select name="aro_section" tabindex="0" size="10" onclick="populate(document.acl_admin.aro_section,document.acl_admin.elements['aro[]'],'{$js_aro_array_name}')">
+ {html_options options=$options_aro_sections selected=$aro_section_value}
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=aro&section_value=' + document.acl_admin.aro_section.options[document.acl_admin.aro_section.selectedIndex].value + '&return_page={$return_page}';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=acl_admin&object_type=aro&section_value=' + document.acl_admin.aro_section.options[document.acl_admin.aro_section.selectedIndex].value + '&return_page={$return_page}','','status=yes,width=400,height=400');return false;">Search</a> ]
+ <br />
+ <select name="aro[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.aro_section, document.acl_admin.elements['aro[]'], document.acl_admin.elements['selected_aro[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_aro[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_aro[]" tabindex="0" size="10" multiple>
+ {html_options options=$options_selected_aro selected=$selected_aro}
+ </select>
+ </td>
+ <td>
+ [ <a href="group_admin.php?group_type=aro&return_page={$SCRIPT_NAME}?action={$action}&acl_id={$acl_id}">Edit</a> ]
+ <br />
+ <select name="aro_groups[]" tabindex="0" size="8" multiple>
+ {html_options options=$options_aro_groups selected=$selected_aro_groups}
+ </select>
+ <br /><input type="button" class="un-select" name="Un-Select" value="Un-Select" onClick="unselect_all(document.acl_admin.elements['aro_groups[]'])">
+ </td>
+ </tr>
+
+ <tr>
+ <th colspan="5">
+ [ <a href="javascript: showObject('axo_row1');showObject('axo_row2');setCookie('show_axo',1);">Show</a> / <a href="javascript: hideObject('axo_row1');hideObject('axo_row2');deleteCookie('show_axo');">Hide</a> ] Access eXtension Objects (Optional)
+ </th>
+ </tr>
+
+ <tr id="axo_row1" {if !$show_axo}class="hide"{/if}>
+ <th>Sections</th>
+ <th>Access eXtension Objects</th>
+ <th>&nbsp;</th>
+ <th>Selected</th>
+ <th>Groups</th>
+ </tr>
+ <tr valign="top" align="center" id="axo_row2" {if !$show_axo}class="hide"{/if}>
+ <td>
+ [ <a href="edit_object_sections.php?object_type=axo&return_page={$return_page}">Edit</a> ]
+ <br />
+ <select name="axo_section" tabindex="0" size="10" onclick="populate(document.acl_admin.axo_section,document.acl_admin.elements['axo[]'],'{$js_axo_array_name}')">
+ {html_options options=$options_axo_sections selected=$axo_section_value}
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=axo&section_value=' + document.acl_admin.axo_section.options[document.acl_admin.axo_section.selectedIndex].value + '&return_page={$return_page}';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=acl_admin&object_type=axo&section_value=' + document.acl_admin.axo_section.options[document.acl_admin.axo_section.selectedIndex].value + '&return_page={$return_page}','','status=yes,width=400,height=400');return false;">Search</a> ]
+ <br />
+ <select name="axo[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.axo_section, document.acl_admin.elements['axo[]'], document.acl_admin.elements['selected_axo[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_axo[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_axo[]" tabindex="0" size="10" multiple>
+ {html_options options=$options_selected_axo selected=$selected_axo}
+ </select>
+ </td>
+ <td>
+ [ <a href="group_admin.php?group_type=axo&return_page={$SCRIPT_NAME}?action={$action}&acl_id={$acl_id}">Edit</a> ]
+ <br />
+ <select name="axo_groups[]" tabindex="0" size="8" multiple>
+ {html_options options=$options_axo_groups selected=$selected_axo_groups}
+ </select>
+ <br /><input type="button" class="un-select" name="Un-Select" value="Un-Select" onClick="unselect_all(document.acl_admin.elements['axo_groups[]'])">
+ </td>
+ </tr>
+
+ <tr>
+ <th colspan="5">Miscellaneous Attributes</th>
+ </tr>
+ <tr valign="top" align="left">
+ <td align="center">
+ <b>ACL Section</b>
+ </td>
+ <td>
+ <b>Extended Return Value:</b>
+ </td>
+ <td colspan="4">
+ <input type="text" name="return_value" size="50" value="{$return_value}" id="return_value">
+ </td>
+ </tr>
+ <tr valign="top" align="left">
+ <td align="center">
+ [ <a href="edit_object_sections.php?object_type=acl&return_page={$return_page}">Edit</a> ]
+ <br />
+ <select name="acl_section" tabindex="0" size="3">
+ {html_options options=$options_acl_sections selected=$acl_section_value}
+ </select>
+ </td>
+ <td><b>Note:</b></td>
+ <td colspan="4"><textarea name="note" rows="4" cols="40">{$note}</textarea></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="5">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="acl_id" value="{$acl_id}">
+ <input type="hidden" name="return_page" value="{$return_page}">
+ </div>
+</form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_admin_js.tpl b/html/phpgacl/admin/templates/phpgacl/acl_admin_js.tpl
new file mode 100644
index 0000000..3c6e7a8
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_admin_js.tpl
@@ -0,0 +1,4 @@
+{literal}
+<script language="JavaScript" src="admin_functions.js">
+</script>
+{/literal} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_debug.tpl b/html/phpgacl/admin/templates/phpgacl/acl_debug.tpl
new file mode 100644
index 0000000..1423716
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_debug.tpl
@@ -0,0 +1,112 @@
+{include file="phpgacl/header.tpl"}
+ </head>
+<body>
+{include file="phpgacl/navigation.tpl"}
+<form method="get" name="acl_debug" action="acl_debug.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr>
+ <th rowspan="2">&nbsp;</th>
+ <th colspan="2">ACO</th>
+ <th colspan="2">ARO</th>
+ <th colspan="2">AXO</th>
+ <th rowspan="2">Root ARO<br />Group ID</th>
+ <th rowspan="2">Root AXO<br />Group ID</th>
+ <th rowspan="2">&nbsp;</th>
+ </tr>
+ <tr>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Section</th>
+ <th>Value</th>
+ </tr>
+ <tr valign="middle" align="center">
+ <td nowrap><b>acl_query(</b></td>
+ <td><input type="text" name="aco_section_value" size="15" value="{$aco_section_value}"></td>
+ <td><input type="text" name="aco_value" size="15" value="{$aco_value}"></td>
+ <td><input type="text" name="aro_section_value" size="15" value="{$aro_section_value}"></td>
+ <td><input type="text" name="aro_value" size="15" value="{$aro_value}"></td>
+ <td><input type="text" name="axo_section_value" size="15" value="{$axo_section_value}"></td>
+ <td><input type="text" name="axo_value" size="15" value="{$axo_value}"></td>
+ <td><input type="text" name="root_aro_group_id" size="15" value="{$root_aro_group_id}"></td>
+ <td><input type="text" name="root_axo_group_id" size="15" value="{$root_axo_group_id}"></td>
+ <td><b>)</b></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="10">
+ <input type="submit" class="button" name="action" value="Submit">
+ </td>
+ </tr>
+</table>
+{if count($acls) gt 0}
+<br />
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr>
+ <th rowspan="2" width="4%">ACL ID</th>
+ <th colspan="2">ACO</th>
+ <th colspan="2">ARO</th>
+ <th colspan="2">AXO</th>
+ <th colspan="2">ACL</th>
+ </tr>
+ <tr>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="8%">Access</th>
+ <th width="16%">Updated Date</th>
+ </tr>
+{foreach from=$acls item=acl}
+ <tr valign="top" align="left">
+ <td valign="middle" rowspan="2" align="center">
+ {$acl.id}
+ </td>
+ <td nowrap>
+ {$acl.aco_section_value}
+ </td>
+ <td nowrap>
+ {$acl.aco_value}
+ </td>
+
+ <td nowrap>
+ {$acl.aro_section_value}<br>
+ </td>
+ <td nowrap>
+ {$acl.aro_value}<br>
+ </td>
+
+ <td nowrap>
+ {$acl.axo_section_value}<br>
+ </td>
+ <td nowrap>
+ {$acl.axo_value}<br>
+ </td>
+
+ <td valign="middle" class="{if $acl.allow}green{else}red{/if}" align="center">
+ {if $acl.allow}
+ ALLOW
+ {else}
+ DENY
+ {/if}
+ </td>
+ <td valign="middle" align="center">
+ {$acl.updated_date}
+ </td>
+ </tr>
+ <tr valign="middle" align="left">
+ <td colspan="4">
+ <b>Return Value:</b> {$acl.return_value}<br>
+ </td>
+ <td colspan="4">
+ <b>Note:</b> {$acl.note}
+ </td>
+ </tr>
+{/foreach}
+</table>
+{/if}
+<input type="hidden" name="return_page" value="{$return_page}">
+</form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_list.tpl b/html/phpgacl/admin/templates/phpgacl/acl_list.tpl
new file mode 100644
index 0000000..8d20de9
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_list.tpl
@@ -0,0 +1,244 @@
+{include file="phpgacl/header.tpl"}
+{include file="phpgacl/acl_admin_js.tpl"}
+{literal}
+ <style type="text/css">
+ ul {
+ padding: 0px 0px 0px 0px;
+ margin: 0px 0px 0px 0px;
+ list-style-type: none;
+ }
+ ul li {
+ padding: 0px;
+ margin: 0px;
+ font-weight: bold;
+ }
+ ol {
+ padding: 0px 0px 0px 22px;
+ margin: 0px;
+ }
+ ol li {
+ padding: 0px;
+ margin: 0px;
+ font-weight: normal;
+ }
+ div.divider {
+ margin: 2px 0px;
+ padding: 0px;
+ border-bottom: 1px solid grey;
+ }
+ input.filter {
+ width: 99%;
+ }
+ select.filter {
+ width: 99%;
+ margin-top: 0px;
+ }
+ </style>
+{/literal}
+ </head>
+<body>
+{include file="phpgacl/navigation.tpl"}
+<form method="get" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr align="center">
+ <td colspan="6"><b>Filter</b></td>
+ </tr>
+ <tr>
+ <th width="12%">&nbsp;</th>
+ <th width="22%">ACO</th>
+ <th width="22%">ARO</th>
+ <th width="22%">AXO</th>
+ <th width="22%" colspan="2">ACL</th>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Section:</b> </td>
+ <td>
+ <select name="filter_aco_section" tabindex="0" class="filter">
+ {html_options options=$options_filter_aco_sections selected=$filter_aco_section}
+ </select>
+ </td>
+ <td>
+ <select name="filter_aro_section" tabindex="0" class="filter">
+ {html_options options=$options_filter_aro_sections selected=$filter_aro_section}
+ </select>
+ </td>
+ <td>
+ <select name="filter_axo_section" tabindex="0" class="filter">
+ {html_options options=$options_filter_axo_sections selected=$filter_axo_section}
+ </select>
+ </td>
+ <td colspan="2">
+ <select name="filter_acl_section" tabindex="0" class="filter">
+ {html_options options=$options_filter_acl_sections selected=$filter_acl_section}
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Object:</b> </td>
+ <td><input type="text" name="filter_aco" size="20" value="{$filter_aco}" class="filter"></td>
+ <td><input type="text" name="filter_aro" size="20" value="{$filter_aro}" class="filter"></td>
+ <td><input type="text" name="filter_axo" size="20" value="{$filter_axo}" class="filter"></td>
+ <td align="left" width="11%"><b>Allow:</b> </td>
+ <td align="left" width="11%">
+ <select name="filter_allow" tabindex="0" class="filter">
+ {html_options options=$options_filter_allow selected=$filter_allow}
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Group:</b> </td>
+ <td>&nbsp;</td>
+ <td><input type="text" name="filter_aro_group" size="20" value="{$filter_aro_group}" class="filter"></td>
+ <td><input type="text" name="filter_axo_group" size="20" value="{$filter_axo_group}" class="filter"></td>
+ <td align="left"><b>Enabled:</b> </td>
+ <td align="left">
+ <select name="filter_enabled" tabindex="0" class="filter">
+ {html_options options=$options_filter_enabled selected=$filter_enabled}
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="left">
+ <td><b>Return&nbsp;Value:</b> </td>
+ <td colspan="5"><input type="text" name="filter_return_value" size="50" value="{$filter_return_value}" class="filter"></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="6"><input type="submit" class="button" name="action" value="Filter"></td>
+ </tr>
+</table>
+<br />
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="8">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?action=$action&filter_aco_section=$filter_aco_section&filter_aco=$filter_aco&filter_aro_section=$filter_aro_section&filter_aro=$filter_aro&filter_axo_section=$filter_axo_section&filter_axo=$filter_axo&filter_aro_group=$filter_aro_group&filter_axo_group=$filter_axo_group&filter_return_value=$filter_return_value&filter_allow=$filter_allow&filter_enabled=$filter_enabled&"}
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th width="24%">ACO</th>
+ <th width="24%">ARO</th>
+ <th width="24%">AXO</th>
+ <th width="10%">Access</th>
+ <th width="10%">Enabled</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+
+{foreach from=$acls item=acl}
+ {cycle assign=class values="odd,even"}
+ <tr class="{$class}">
+ <td valign="middle" rowspan="3" align="center">{$acl.id}</td>
+ <td valign="top" align="left">
+ {if count($acl.aco) gt 0}
+ <ul>
+ {foreach from=$acl.aco key=section item=objects}
+ <li>{$section}<ol>
+ {foreach from=$objects item=obj}
+ <li>{$obj}</li>
+ {/foreach}
+ </ol></li>
+ {/foreach}
+ </ul>
+ {else}
+ &nbsp;
+ {/if}
+ </td>
+ <td valign="top" align="left">
+ {if count($acl.aro) gt 0}
+ <ul>
+ {foreach from=$acl.aro key=section item=objects}
+ <li>{$section}<ol>
+ {foreach from=$objects item=obj}
+ <li>{$obj}</li>
+ {/foreach}
+ </ol></li>
+ {/foreach}
+ </ul>
+ {if count($acl.aro_groups) gt 0}
+ <div class="divider"></div>
+ {/if}
+ {/if}
+ {if count($acl.aro_groups) gt 0}
+ <b>Groups</b><ol>
+ {foreach from=$acl.aro_groups item=group}
+ <li>{$group}</li>
+ {/foreach}
+ </ol>
+ {/if}
+ </td>
+ <td valign="top" align="left">
+ {if count($acl.axo) gt 0}
+ <ul>
+ {foreach from=$acl.axo key=section item=objects}
+ <li>{$section}<ol>
+ {foreach from=$objects item=obj}
+ <li>{$obj}</li>
+ {/foreach}
+ </ol></li>
+ {/foreach}
+ </ul>
+ {if count($acl.axo_groups) gt 0}
+ <div class="divider"></div>
+ {/if}
+ {/if}
+ {if count($acl.axo_groups) gt 0}
+ <b>Groups</b><ol>
+ {foreach from=$acl.axo_groups item=group}
+ <li>{$group}</li>
+ {/foreach}
+ </ol>
+ {/if}
+ </td>
+ <td valign="middle" class="{if $acl.allow}green{else}red{/if}" align="center">
+ {if $acl.allow}
+ ALLOW
+ {else}
+ DENY
+ {/if}
+ </td>
+ <td valign="middle" class="{if $acl.enabled}green{else}red{/if}" align="center">
+ {if $acl.enabled}
+ Yes
+ {else}
+ No
+ {/if}
+ </td>
+ <td valign="middle" rowspan="3" align="center">
+ [ <a href="acl_admin.php?action=edit&acl_id={$acl.id}&return_page={$return_page}">Edit</a> ]
+ </td>
+ <td valign="middle" rowspan="3" align="center">
+ <input type="checkbox" class="checkbox" name="delete_acl[]" value="{$acl.id}">
+ </td>
+ </tr>
+
+ <tr class="{$class}">
+ <td valign="top" colspan="3" align="left">
+ <b>Return Value:</b> {$acl.return_value}
+ </td>
+ <td valign="middle" colspan="2" align="center">
+ {$acl.section_name}
+ </td>
+ </tr>
+ <tr class="{$class}">
+ <td valign="top" colspan="3" align="left">
+ <b>Note:</b> {$acl.note}
+ </td>
+ <td valign="middle" colspan="2" align="center">
+ {$acl.updated_date|date_format:"%d-%b-%Y&nbsp;%H:%M:%S"}
+ </td>
+ </tr>
+{/foreach}
+ <tr class="pager">
+ <td colspan="8">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?action=$action&filter_aco_section=$filter_aco_section&filter_aco=$filter_aco&filter_aro_section=$filter_aro_section&filter_aro=$filter_aro&filter_axo_section=$filter_axo_section&filter_axo=$filter_axo&filter_aro_group=$filter_aro_group&filter_axo_group=$filter_axo_group&filter_return_value=$filter_return_value&filter_allow=$filter_allow&filter_enabled=$filter_enabled&"}
+ </td>
+ </tr>
+ <tr class="controls">
+ <td colspan="6">&nbsp;</td>
+ <td colspan="2" align="center">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="return_page" value="{$return_page}">
+</form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_test.tpl b/html/phpgacl/admin/templates/phpgacl/acl_test.tpl
new file mode 100644
index 0000000..69e6542
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_test.tpl
@@ -0,0 +1,24 @@
+{include file="phpgacl/header.tpl"}
+ </head>
+<body>
+{include file="phpgacl/navigation.tpl"}
+<br>
+<br>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="50%">
+ <th colspan="2">
+ Which dimension of ACLs do you want to test?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test2.php">2-dimensional ACLs</a> ]
+ </td>
+ <td>
+ [ <a href="acl_test3.php">3-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+<br>
+<br>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_test2.tpl b/html/phpgacl/admin/templates/phpgacl/acl_test2.tpl
new file mode 100644
index 0000000..b5119a1
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_test2.tpl
@@ -0,0 +1,98 @@
+{include file="phpgacl/header.tpl"}
+ </head>
+<body>
+{include file="phpgacl/navigation.tpl"}
+<form method="post" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="11">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?"}
+ </td>
+ </tr>
+ <tr>
+ <th>#</th>
+ <th>Section > ACO</th>
+ <th>Section > ARO</th>
+ <th>Return Value</th>
+ <th>ACL_CHECK() Code</th>
+ <th>Debug</th>
+ <th>Time (ms)</th>
+ <th>Access</th>
+ </tr>
+ {section name=x loop=$acls}
+ <tr>
+ <td valign="middle" align="center">
+ {$smarty.section.x.iteration}
+ </td>
+ <td valign="middle" align="center">
+ {$acls[x].display_aco_name}
+ </td>
+ <td valign="top" align="left">
+ {$acls[x].aro_section_name} > {$acls[x].aro_name}
+ </td>
+ <td valign="top" align="center">
+ {$acls[x].return_value}<br>
+ </td>
+ <td valign="top" align="left">
+ acl_check('{$acls[x].aco_section_value}', '{$acls[x].aco_value}', '{$acls[x].aro_section_value}', '{$acls[x].aro_value}')
+ </td>
+ <td valign="top" align="center" nowrap>
+ [ <a href="acl_debug.php?aco_section_value={$acls[x].aco_section_value}&aco_value={$acls[x].aco_value}&aro_section_value={$acls[x].aro_section_value}&aro_value={$acls[x].aro_value}&action=Submit">debug</a> ]
+ </td>
+ <td valign="top" align="center">
+ {$acls[x].acl_check_time}
+ </td>
+ <td valign="middle" class="{if $acls[x].access}green{else}red{/if}" align="center">
+ {if $acls[x].access}
+ ALLOW
+ {else}
+ DENY
+ {/if}
+ </td>
+ </tr>
+ {/section}
+ <tr classs="pager">
+ <td colspan="11">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?"}
+ </td>
+ </tr>
+</table>
+</form>
+
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <tr>
+ <th colspan="2">
+ Summary
+ </th>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Total ACL Check(s)</b>
+ </td>
+ <td>
+ {$total_acl_checks}
+ </td>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Average Time / Check</b>
+ </td>
+ <td>
+ {$avg_acl_check_time}ms
+ </td>
+ </tr>
+</table>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <th>
+ Do you want to test 3-dimensional ACLs?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test3.php">3-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/acl_test3.tpl b/html/phpgacl/admin/templates/phpgacl/acl_test3.tpl
new file mode 100644
index 0000000..a45c136
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/acl_test3.tpl
@@ -0,0 +1,106 @@
+{include file="phpgacl/header.tpl"}
+ </head>
+<body>
+{include file="phpgacl/navigation.tpl"}
+<form method="post" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="12">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?"}
+ </td>
+ </tr>
+ <tr>
+ <th>#</th>
+ <th>Section > ACO</th>
+ <th>Section > ARO</th>
+ <th>Section > AXO</th>
+ <th>Return Value</th>
+ <th>ACL_CHECK() Code</th>
+ <th>Debug</th>
+ <th>Time (ms)</th>
+ <th>Access</th>
+ </tr>
+ {section name=x loop=$acls}
+ <tr>
+ <td valign="middle" align="center">
+ {$smarty.section.x.iteration}
+ </td>
+ <td valign="middle" align="center">
+ {$acls[x].display_aco_name}
+ </td>
+ <td valign="top" align="left">
+ {$acls[x].aro_section_name} > {$acls[x].aro_name}
+ </td>
+ <td valign="top" align="left">
+ {$acls[x].axo_section_name} > {$acls[x].axo_name}
+ </td>
+ <td valign="top" align="center">
+ {$acls[x].return_value}<br>
+ </td>
+ <td valign="top" align="left">
+ <!---acl_check('{$acls[x].aco_section_value}', '{$acls[x].aco_value}', '{$acls[x].aro_section_value}', '{$acls[x].aro_value}')-->
+ <!---meinhard_jahn@web.de, 20041102: axo_section_value and axo_value implemented--->
+ acl_check('{$acls[x].aco_section_value}', '{$acls[x].aco_value}', '{$acls[x].aro_section_value}', '{$acls[x].aro_value}', '{$acls[x].axo_section_value}', '{$acls[x].axo_value}')
+ </td>
+ <td valign="top" align="center" nowrap>
+ <!---[ <a href="acl_debug.php?aco_section_value={$acls[x].aco_section_value}&aco_value={$acls[x].aco_value}&aro_section_value={$acls[x].aro_section_value}&aro_value={$acls[x].aro_value}&action=Submit">debug</a> ]-->
+ <!---meinhard_jahn@web.de, 20041102: axo_section_value and axo_value implemented--->
+ [ <a href="acl_debug.php?aco_section_value={$acls[x].aco_section_value}&aco_value={$acls[x].aco_value}&aro_section_value={$acls[x].aro_section_value}&aro_value={$acls[x].aro_value}&axo_section_value={$acls[x].axo_section_value}&axo_value={$acls[x].axo_value}&action=Submit">debug</a> ]
+ </td>
+ <td valign="top" align="center">
+ {$acls[x].acl_check_time}
+ </td>
+ <td valign="middle" class="{if $acls[x].access}green{else}red{/if}" align="center">
+ {if $acls[x].access}
+ ALLOW
+ {else}
+ DENY
+ {/if}
+ </td>
+ </tr>
+ {/section}
+ <tr classs="pager">
+ <td colspan="12">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?"}
+ </td>
+ </tr>
+</table>
+</form>
+
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <tr>
+ <th colspan="2">
+ Summary
+ </th>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Total ACL Check(s)</b>
+ </td>
+ <td>
+ {$total_acl_checks}
+ </td>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Average Time / Check</b>
+ </td>
+ <td>
+ {$avg_acl_check_time}ms
+ </td>
+ </tr>
+</table>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <th>
+ Do you want to test 2-dimensional ACLs?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test2.php">2-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/assign_group.tpl b/html/phpgacl/admin/templates/phpgacl/assign_group.tpl
new file mode 100644
index 0000000..4384a45
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/assign_group.tpl
@@ -0,0 +1,103 @@
+{include file="phpgacl/header.tpl"}
+<script LANGUAGE="JavaScript">
+{$js_array}
+</script>
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+ <body onload="populate(document.assign_group.{$group_type}_section,document.assign_group.elements['objects[]'], '{$js_array_name}')">
+ {include file="phpgacl/navigation.tpl"}
+ <form method="post" name="assign_group" action="assign_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="32%">Sections</th>
+ <th width="32%">{$object_type}s</th>
+ <th width="4%">&nbsp;</th>
+ <th width="32%">Selected</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type={$group_type}&return_page={$return_page}">Edit</a> ]
+ <br />
+ <select name="{$group_type}_section" tabindex="0" size="10" width="200" onclick="populate(document.assign_group.{$group_type}_section,document.assign_group.elements['objects[]'],'{$js_array_name}')">
+ {html_options options=$options_sections selected=$section_value}
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type={$group_type}&section_value=' + document.assign_group.{$group_type}_section.options[document.assign_group.{$group_type}_section.selectedIndex].value + '&return_page={$return_page}';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=assign_group&object_type={$group_type}&section_value=' + document.assign_group.{$group_type}_section.options[document.assign_group.{$group_type}_section.selectedIndex].value,'','status=yes,width=400,height=400','','status=yes,width=400,height=400');">Search</a> ]
+ <br />
+ <select name="objects[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.assign_group.{$group_type}_section, document.assign_group.elements['objects[]'], document.assign_group.elements['selected_{$group_type}[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.assign_group.elements['selected_{$group_type}[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_{$group_type}[]" tabindex="0" size="10" width="200" multiple>
+ {html_options options=$options_selected_objects selected=$selected_object}
+ </select>
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br />
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr align="center">
+ <td colspan="5"><b>{$total_objects}</b> {$group_type|upper}s in Group: <b>{$group_name}</b></td>
+ </tr>
+ <tr class="pager">
+ <td colspan="5">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?group_type=$group_type&group_id=$group_id&"}
+ </td>
+ </tr>
+ <tr>
+ <th>Section</th>
+ <th>{$object_type}</th>
+ <th>{$group_type|upper} Value</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+{foreach from=$rows item=row}
+ <tr valign="top" align="center">
+ <td>
+ {$row.section}
+ </td>
+ <td>
+ {$row.name}
+ </td>
+ <td>
+ {$row.value}
+ </td>
+ <td>
+ [ <a href="acl_list.php?action=Filter&filter_{$group_type}_section={$row.section_value}&filter_{$group_type}={$row.name}&return_page={$return_page}">ACLs</a> ]
+ </td>
+ <td>
+ <input type="checkbox" class="checkbox" name="delete_assigned_object[]" value="{$row.section_value}^{$row.value}">
+ </td>
+ </tr>
+{/foreach}
+ <tr class="pager">
+ <td colspan="5">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?"}
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="3">&nbsp;</td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Remove">
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="group_id" value="{$group_id}">
+<input type="hidden" name="group_type" value="{$group_type}">
+<input type="hidden" name="return_page" value="{$return_page}">
+</form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/debug.tpl b/html/phpgacl/admin/templates/phpgacl/debug.tpl
new file mode 100644
index 0000000..a273172
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/debug.tpl
@@ -0,0 +1,39 @@
+{* Smarty *}
+
+{* debug.tpl, last updated version 2.0.1 *}
+
+{assign_debug_info}
+
+<SCRIPT language=javascript>
+ if( self.name == '' ) {ldelim}
+ var title = 'Console';
+ {rdelim}
+ else {ldelim}
+ var title = 'Console_' + self.name;
+ {rdelim}
+ _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
+ _smarty_console.document.write("<HTML><TITLE>Smarty Debug Console_"+self.name+"</TITLE><BODY bgcolor=#ffffff>");
+ _smarty_console.document.write("<table border=0 width=100%>");
+ _smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>");
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>");
+ {section name=templates loop=$_debug_tpls}
+ _smarty_console.document.write("<tr bgcolor={if %templates.index% is even}#eeeeee{else}#fafafa{/if}><td colspan=2><tt>{section name=indent loop=$_debug_tpls[templates].depth}&nbsp;&nbsp;&nbsp;{/section}<font color={if $_debug_tpls[templates].type eq "template"}brown{elseif $_debug_tpls[templates].type eq "insert"}black{else}green{/if}>{$_debug_tpls[templates].filename}</font> <font size=-1><i>({$_debug_tpls[templates].exec_time|string_format:"%.5f"}){if %templates.index% eq 0} (total){/if}</i></font></tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no templates included</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned template variables:</b></td></tr>");
+ {section name=vars loop=$_debug_keys}
+ _smarty_console.document.write("<tr bgcolor={if %vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=blue>{ldelim}${$_debug_keys[vars]}{rdelim}</font></tt></td><td nowrap><tt><font color=green>{$_debug_vals[vars]|@debug_print_var}</font></tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no template variables assigned</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>assigned config file variables (outter template scope):</b></td></tr>");
+ {section name=config_vars loop=$_debug_config_keys}
+ _smarty_console.document.write("<tr bgcolor={if %config_vars.index% is even}#eeeeee{else}#fafafa{/if}><td valign=top><tt><font color=maroon>{ldelim}#{$_debug_config_keys[config_vars]}#{rdelim}</font></tt></td><td><tt><font color=green>{$_debug_config_vals[config_vars]|@debug_print_var}</font></tt></td></tr>");
+ {sectionelse}
+ _smarty_console.document.write("<tr bgcolor=#eeeeee><td colspan=2><tt><i>no config vars assigned</i></tt></td></tr>");
+ {/section}
+ _smarty_console.document.write("</table>");
+ _smarty_console.document.write("</BODY></HTML>");
+ _smarty_console.document.close();
+</SCRIPT>
diff --git a/html/phpgacl/admin/templates/phpgacl/edit_group.tpl b/html/phpgacl/admin/templates/phpgacl/edit_group.tpl
new file mode 100644
index 0000000..3498358
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/edit_group.tpl
@@ -0,0 +1,49 @@
+{include file="phpgacl/header.tpl"}
+ <style type="text/css">
+ {literal}
+ select {
+ margin-top: 0px;
+ }
+ input.group-name, input.group-value {
+ width: 99%;
+ }
+ {/literal}
+ </style>
+ </head>
+ <body>
+{include file="phpgacl/navigation.tpl"}
+ <form method="post" name="edit_group" action="edit_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="4%">ID</th>
+ <th width="32%">Parent</th>
+ <th width="32%">Name</th>
+ <th width="32%">Value</th>
+ </tr>
+ <tr valign="top">
+ <td align="center">{$id|default:"N/A"}</td>
+ <td>
+ <select name="parent_id" tabindex="0" multiple>
+ {html_options options=$options_groups selected=$parent_id}
+ </select>
+ </td>
+ <td>
+ <input type="text" class="group-name" size="50" name="name" value="{$name}">
+ </td>
+ <td>
+ <input type="text" class="group-value" size="50" name="value" value="{$value}">
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="group_id" value="{$id}">
+ <input type="hidden" name="group_type" value="{$group_type}">
+ <input type="hidden" name="return_page" value="{$return_page}">
+ </form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/edit_object_sections.tpl b/html/phpgacl/admin/templates/phpgacl/edit_object_sections.tpl
new file mode 100644
index 0000000..82fde3b
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/edit_object_sections.tpl
@@ -0,0 +1,77 @@
+{include file="phpgacl/header.tpl"}
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+ <body>
+ {include file="phpgacl/navigation.tpl"}
+ <form method="post" name="edit_object_sections" action="edit_object_sections.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr class="pager">
+ <td colspan="11">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?object_type=$object_type&"}
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+{section name=x loop=$sections}
+ <tr valign="top" align="center">
+ <td>
+ {$sections[x].id}
+ <input type="hidden" name="sections[{$sections[x].id}][]" value="{$sections[x].id}">
+ </td>
+ <td><input type="text" size="10" name="sections[{$sections[x].id}][]" value="{$sections[x].value}"></td>
+ <td><input type="text" size="10" name="sections[{$sections[x].id}][]" value="{$sections[x].order}"></td>
+ <td><input type="text" size="40" name="sections[{$sections[x].id}][]" value="{$sections[x].name}"></td>
+ <td>&nbsp;</td>
+ <td><input type="checkbox" class="checkbox" name="delete_sections[]" value="{$sections[x].id}"></td>
+ </tr>
+{/section}
+ <tr class="pager">
+ <td colspan="6">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?object_type=$object_type&"}
+ </td>
+ </tr>
+ <tr class="spacer">
+ <td colspan="6"></td>
+ </tr>
+ <tr align="center">
+ <td colspan="6"><b>Add {$object_type|upper} Sections</b></td>
+ </tr>
+ <tr>
+ <th>ID</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th>Functions</th>
+ <th>&nbsp;</td>
+ </tr>
+{section name=y loop=$new_sections}
+ <tr valign="top" align="center">
+ <td>N/A</td>
+ <td><input type="text" size="10" name="new_sections[{$new_sections[y].id}][]" value=""></td>
+ <td><input type="text" size="10" name="new_sections[{$new_sections[y].id}][]" value=""></td>
+ <td><input type="text" size="40" name="new_sections[{$new_sections[y].id}][]" value=""></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+{/section}
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="object_type" value="{$object_type}">
+ <input type="hidden" name="return_page" value="{$return_page}">
+ </form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/edit_objects.tpl b/html/phpgacl/admin/templates/phpgacl/edit_objects.tpl
new file mode 100644
index 0000000..0f695c1
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/edit_objects.tpl
@@ -0,0 +1,82 @@
+{include file="phpgacl/header.tpl"}
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+ <body>
+ {include file="phpgacl/navigation.tpl"}
+ <form method="post" name="edit_objects" action="edit_objects.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr class="pager">
+ <td colspan="7">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?section_value=$section_value&object_type=$object_type&"}
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+{section name=x loop=$objects}
+ <tr valign="top" align="center">
+ <td>
+ {$objects[x].id}
+ <input type="hidden" name="objects[{$objects[x].id}][]" value="{$objects[x].id}">
+ </td>
+ <td>{$section_name}</td>
+ <td><input type="text" size="10" name="objects[{$objects[x].id}][]" value="{$objects[x].value}"></td>
+ <td><input type="text" size="10" name="objects[{$objects[x].id}][]" value="{$objects[x].order}"></td>
+ <td><input type="text" size="40" name="objects[{$objects[x].id}][]" value="{$objects[x].name}"></td>
+ <td>&nbsp;</td>
+ <td><input type="checkbox" class="checkbox" name="delete_object[]" value="{$objects[x].id}"></td>
+ </tr>
+{/section}
+ <tr class="pager">
+ <td colspan="7">
+ {include file="phpgacl/pager.tpl" pager_data=$paging_data link="?section_value=$section_value&object_type=$object_type&"}
+ </td>
+ </tr>
+ <tr class="spacer">
+ <td colspan="7"></td>
+ </tr>
+ <tr align="center">
+ <td colspan="7"><b>Add {$object_type|upper}s</b></td>
+ </tr>
+ <tr>
+ <th>ID</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th>Functions</th>
+ <th>&nbsp;</th>
+ </tr>
+{section name=y loop=$new_objects}
+ <tr valign="top" align="center">
+ <td>N/A</td>
+ <td>{$section_name}</td>
+ <td><input type="text" size="10" name="new_objects[{$new_objects[y].id}][]" value=""></td>
+ <td><input type="text" size="10" name="new_objects[{$new_objects[y].id}][]" value=""></td>
+ <td><input type="text" size="40" name="new_objects[{$new_objects[y].id}][]" value=""></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+{/section}
+ <tr class="controls" align="center">
+ <td colspan="5">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset"><br>
+ </td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="section_value" value="{$section_value}">
+ <input type="hidden" name="object_type" value="{$object_type}">
+ <input type="hidden" name="return_page" value="{$return_page}">
+ </form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/footer.tpl b/html/phpgacl/admin/templates/phpgacl/footer.tpl
new file mode 100644
index 0000000..0068056
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/footer.tpl
@@ -0,0 +1,11 @@
+ </div></div>
+
+ <div id="bot-br"><div id="bot-bl"><div id="bot-tr"><div id="bot-tl">
+ <a href="http://phpgacl.sourceforge.net">phpGACL</a> v{$phpgacl_version} (Schema v{$phpgacl_schema_version}) - Generic Access Control Lists
+ <br />
+ Copyright &copy; 2005 <a href="about.php">Mike Benoit</a>
+ </div></div></div></div>
+
+ <!-- End Body -->
+ </body>
+</html>
diff --git a/html/phpgacl/admin/templates/phpgacl/group_admin.tpl b/html/phpgacl/admin/templates/phpgacl/group_admin.tpl
new file mode 100644
index 0000000..c941559
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/group_admin.tpl
@@ -0,0 +1,41 @@
+{include file="phpgacl/header.tpl"}
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+ <body>
+ {include file="phpgacl/navigation.tpl"}
+ <form method="post" name="edit_group" action="edit_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="2%">ID</th>
+ <th width="40%">Name</th>
+ <th width="20%">Value</th>
+ <th width="6%">Objects</th>
+ <th width="30%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+{foreach from=$groups item=group}
+ <tr valign="middle" align="center">
+ <td>{$group.id}</td>
+ <td align="left">{$group.name}</td>
+ <td align="left">{$group.value}</td>
+ <td>{$group.object_count}</td>
+ <td>
+ [&nbsp;<a href="assign_group.php?group_type={$group_type}&group_id={$group.id}&return_page={$return_page}">Assign&nbsp;{$group_type|upper}</a>&nbsp;]
+ [&nbsp;<a href="edit_group.php?group_type={$group_type}&parent_id={$group.id}&return_page={$return_page}">Add&nbsp;Child</a>&nbsp;]
+ [&nbsp;<a href="edit_group.php?group_type={$group_type}&group_id={$group.id}&return_page={$return_page}">Edit</a>&nbsp;]
+ [&nbsp;<a href="acl_list.php?action=Filter&filter_{$group_type}_group={$group.raw_name|urlencode}&return_page={$return_page}">ACLs</a>&nbsp;]
+ </td>
+ <td><input type="checkbox" class="checkbox" name="delete_group[]" value="{$group.id}"></td>
+ </tr>
+{/foreach}
+ <tr class="controls" align="center">
+ <td colspan="4">&nbsp;</td>
+ <td colspan="2" nowrap><input type="submit" class="button" name="action" value="Add" /> <input type="submit" class="button" name="action" value="Delete" /></td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="group_type" value="{$group_type}">
+ <input type="hidden" name="return_page" value="{$return_page}">
+ </form>
+{include file="phpgacl/footer.tpl"}
diff --git a/html/phpgacl/admin/templates/phpgacl/header.tpl b/html/phpgacl/admin/templates/phpgacl/header.tpl
new file mode 100644
index 0000000..5359f10
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/header.tpl
@@ -0,0 +1,7 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <title>phpGACL - {$page_title}</title>
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ <link rel="stylesheet" href="admin.css" type="text/css" title="phpGACL" /> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/navigation.tpl b/html/phpgacl/admin/templates/phpgacl/navigation.tpl
new file mode 100644
index 0000000..bda9a18
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/navigation.tpl
@@ -0,0 +1,19 @@
+ <div id="top-tr"><div id="top-tl"><div id="top-br"><div id="top-bl">
+ <h1><span>phpGACL</span></h1>
+ <h2>{$page_title}</h2>
+{if $hidemenu neq TRUE}
+ <ul id="menu">
+ <li{if $current eq 'aro_group'} class="current"{/if}><a href="group_admin.php?group_type=aro">ARO Group Admin</a></li>
+ <li{if $current eq 'axo_group'} class="current"{/if}><a href="group_admin.php?group_type=axo">AXO Group Admin</a></li>
+ <li{if $current eq 'acl_admin'} class="current"{/if}><a href="acl_admin.php?return_page=acl_admin.php">ACL Admin</a></li>
+ <li{if $current eq 'acl_list'} class="current"{/if}><a href="acl_list.php?return_page=acl_list.php">ACL List</a></li>
+ <li{if $current eq 'acl_test'} class="current"{/if}><a href="acl_test.php">ACL Test</a></li>
+ <li{if $current eq 'acl_debug'} class="current"{/if}><a href="acl_debug.php">ACL Debug</a></li>
+ <li{if $current eq 'about'} class="current"{/if}><a href="about.php">About</a></li>
+ <li><a href="../docs/manual.html" target="_blank">Manual</a></li>
+ <li><a href="../docs/phpdoc/" >API Guide</a></li>
+ </ul>
+{/if}
+ </div></div></div></div>
+
+ <div id="mid-r"><div id="mid-l">
diff --git a/html/phpgacl/admin/templates/phpgacl/object_search.tpl b/html/phpgacl/admin/templates/phpgacl/object_search.tpl
new file mode 100644
index 0000000..f339156
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/object_search.tpl
@@ -0,0 +1,62 @@
+{include file="phpgacl/header.tpl"}
+ <style type="text/css">
+ {literal}
+ input.search {
+ width: 99%;
+ }
+ select.search {
+ margin-top: 0px;
+ width: 99%;
+ }
+ {/literal}
+ </style>
+{include file="phpgacl/acl_admin_js.tpl"}
+ </head>
+ <body onload="document.object_search.name_search_str.focus();">
+{include file="phpgacl/navigation.tpl" hidemenu="1"}
+ <form method="get" name="object_search" action="object_search.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th colspan="2">{$object_type_name} > {$section_value_name}</th>
+ </tr>
+ <tr>
+ <td width="25%"><b>Name:</b></td>
+ <td width="75%"><input type="text" class="search" name="name_search_str" value="{$name_search_str}" /></td>
+ </tr>
+ <tr>
+ <td><b>Value:</b></td>
+ <td><input type="text" class="search" name="value_search_str" value="{$value_search_str}" /></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="2"><input type="submit" class="button" name="action" value="Search" /> <input type="button" class="button" name="action" value="Close" onClick="window.close();" /></td>
+ </tr>
+ </tbody>
+ </table>
+{if (strlen($total_rows) != 0)}
+ <br />
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th colspan="2">{$total_rows} Objects Found</th>
+ </tr>
+ {if ($total_rows > 0)}
+ <tr valign="middle" align="center">
+ <td width="90%">
+ <select name="objects" class="search" tabindex="0" size="10" multiple>
+ {html_options options=$options_objects}
+ </select>
+ </td>
+ <td width="10%">
+ <input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="opener.select_item(opener.document.forms['{$src_form}'].elements['{$object_type}_section'], this.form.elements['objects'], opener.document.forms['{$src_form}'].elements['selected_{$object_type}[]']);">
+ </td>
+ </tr>
+ {/if}
+ </tbody>
+ </table>
+{/if}
+ <input type="hidden" name="src_form" value="{$src_form}">
+ <input type="hidden" name="object_type" value="{$object_type}">
+ <input type="hidden" name="section_value" value="{$section_value}">
+ </form>
+{include file="phpgacl/footer.tpl"} \ No newline at end of file
diff --git a/html/phpgacl/admin/templates/phpgacl/pager.tpl b/html/phpgacl/admin/templates/phpgacl/pager.tpl
new file mode 100644
index 0000000..1185b1a
--- /dev/null
+++ b/html/phpgacl/admin/templates/phpgacl/pager.tpl
@@ -0,0 +1,18 @@
+<table width="100%" cellspacing="0" cellpadding="2" border="0">
+ <tr valign="middle">
+ <td align="left">
+{if $paging_data.atfirstpage}
+ |&lt; &lt;&lt;
+{else}
+ <a href="{$link}page=1">|&lt;</a> <a href="{$link}page={$paging_data.prevpage}">&lt;&lt;</a>
+{/if}
+ </td>
+ <td align="right">
+{if $paging_data.atlastpage}
+ &gt;&gt; &gt;|
+{else}
+ <a href="{$link}page={$paging_data.nextpage}">&gt;&gt;</a> <a href="{$link}page={$paging_data.lastpageno}">&gt;|</a>
+{/if}
+ </td>
+ </tr>
+</table> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%1C^1C3^1C38C10C%%navigation.tpl.php b/html/phpgacl/admin/templates_c/%%1C^1C3^1C38C10C%%navigation.tpl.php
new file mode 100644
index 0000000..2cf9baf
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%1C^1C3^1C38C10C%%navigation.tpl.php
@@ -0,0 +1,22 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:36:44
+ compiled from phpgacl/navigation.tpl */ ?>
+ <div id="top-tr"><div id="top-tl"><div id="top-br"><div id="top-bl">
+ <h1><span>phpGACL</span></h1>
+ <h2><?php echo $this->_tpl_vars['page_title']; ?>
+</h2>
+<?php if ($this->_tpl_vars['hidemenu'] != TRUE): ?>
+ <ul id="menu">
+ <li<?php if ($this->_tpl_vars['current'] == 'aro_group'): ?> class="current"<?php endif; ?>><a href="group_admin.php?group_type=aro">ARO Group Admin</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'axo_group'): ?> class="current"<?php endif; ?>><a href="group_admin.php?group_type=axo">AXO Group Admin</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'acl_admin'): ?> class="current"<?php endif; ?>><a href="acl_admin.php?return_page=acl_admin.php">ACL Admin</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'acl_list'): ?> class="current"<?php endif; ?>><a href="acl_list.php?return_page=acl_list.php">ACL List</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'acl_test'): ?> class="current"<?php endif; ?>><a href="acl_test.php">ACL Test</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'acl_debug'): ?> class="current"<?php endif; ?>><a href="acl_debug.php">ACL Debug</a></li>
+ <li<?php if ($this->_tpl_vars['current'] == 'about'): ?> class="current"<?php endif; ?>><a href="about.php">About</a></li>
+ <li><a href="../docs/manual.html" target="_blank">Manual</a></li>
+ <li><a href="../docs/phpdoc/" >API Guide</a></li>
+ </ul>
+<?php endif; ?>
+ </div></div></div></div>
+
+ <div id="mid-r"><div id="mid-l"> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%45^45C^45CE9A26%%edit_objects.tpl.php b/html/phpgacl/admin/templates_c/%%45^45C^45CE9A26%%edit_objects.tpl.php
new file mode 100644
index 0000000..c098a2a
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%45^45C^45CE9A26%%edit_objects.tpl.php
@@ -0,0 +1,175 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:32:53
+ compiled from phpgacl/edit_objects.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('modifier', 'upper', 'phpgacl/edit_objects.tpl', 46, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+ <body>
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="edit_objects" action="edit_objects.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr class="pager">
+ <td colspan="7">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?section_value=".($this->_tpl_vars['section_value'])."&object_type=".($this->_tpl_vars['object_type'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+<?php unset($this->_sections['x']);
+$this->_sections['x']['name'] = 'x';
+$this->_sections['x']['loop'] = is_array($_loop=$this->_tpl_vars['objects']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['x']['show'] = true;
+$this->_sections['x']['max'] = $this->_sections['x']['loop'];
+$this->_sections['x']['step'] = 1;
+$this->_sections['x']['start'] = $this->_sections['x']['step'] > 0 ? 0 : $this->_sections['x']['loop']-1;
+if ($this->_sections['x']['show']) {
+ $this->_sections['x']['total'] = $this->_sections['x']['loop'];
+ if ($this->_sections['x']['total'] == 0)
+ $this->_sections['x']['show'] = false;
+} else
+ $this->_sections['x']['total'] = 0;
+if ($this->_sections['x']['show']):
+
+ for ($this->_sections['x']['index'] = $this->_sections['x']['start'], $this->_sections['x']['iteration'] = 1;
+ $this->_sections['x']['iteration'] <= $this->_sections['x']['total'];
+ $this->_sections['x']['index'] += $this->_sections['x']['step'], $this->_sections['x']['iteration']++):
+$this->_sections['x']['rownum'] = $this->_sections['x']['iteration'];
+$this->_sections['x']['index_prev'] = $this->_sections['x']['index'] - $this->_sections['x']['step'];
+$this->_sections['x']['index_next'] = $this->_sections['x']['index'] + $this->_sections['x']['step'];
+$this->_sections['x']['first'] = ($this->_sections['x']['iteration'] == 1);
+$this->_sections['x']['last'] = ($this->_sections['x']['iteration'] == $this->_sections['x']['total']);
+?>
+ <tr valign="top" align="center">
+ <td>
+ <?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+
+ <input type="hidden" name="objects[<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+">
+ </td>
+ <td><?php echo $this->_tpl_vars['section_name']; ?>
+</td>
+ <td><input type="text" size="10" name="objects[<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['value']; ?>
+"></td>
+ <td><input type="text" size="10" name="objects[<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['order']; ?>
+"></td>
+ <td><input type="text" size="40" name="objects[<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['name']; ?>
+"></td>
+ <td>&nbsp;</td>
+ <td><input type="checkbox" class="checkbox" name="delete_object[]" value="<?php echo $this->_tpl_vars['objects'][$this->_sections['x']['index']]['id']; ?>
+"></td>
+ </tr>
+<?php endfor; endif; ?>
+ <tr class="pager">
+ <td colspan="7">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?section_value=".($this->_tpl_vars['section_value'])."&object_type=".($this->_tpl_vars['object_type'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr class="spacer">
+ <td colspan="7"></td>
+ </tr>
+ <tr align="center">
+ <td colspan="7"><b>Add <?php echo ((is_array($_tmp=$this->_tpl_vars['object_type'])) ? $this->_run_mod_handler('upper', true, $_tmp) : smarty_modifier_upper($_tmp)); ?>
+s</b></td>
+ </tr>
+ <tr>
+ <th>ID</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th>Functions</th>
+ <th>&nbsp;</th>
+ </tr>
+<?php unset($this->_sections['y']);
+$this->_sections['y']['name'] = 'y';
+$this->_sections['y']['loop'] = is_array($_loop=$this->_tpl_vars['new_objects']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['y']['show'] = true;
+$this->_sections['y']['max'] = $this->_sections['y']['loop'];
+$this->_sections['y']['step'] = 1;
+$this->_sections['y']['start'] = $this->_sections['y']['step'] > 0 ? 0 : $this->_sections['y']['loop']-1;
+if ($this->_sections['y']['show']) {
+ $this->_sections['y']['total'] = $this->_sections['y']['loop'];
+ if ($this->_sections['y']['total'] == 0)
+ $this->_sections['y']['show'] = false;
+} else
+ $this->_sections['y']['total'] = 0;
+if ($this->_sections['y']['show']):
+
+ for ($this->_sections['y']['index'] = $this->_sections['y']['start'], $this->_sections['y']['iteration'] = 1;
+ $this->_sections['y']['iteration'] <= $this->_sections['y']['total'];
+ $this->_sections['y']['index'] += $this->_sections['y']['step'], $this->_sections['y']['iteration']++):
+$this->_sections['y']['rownum'] = $this->_sections['y']['iteration'];
+$this->_sections['y']['index_prev'] = $this->_sections['y']['index'] - $this->_sections['y']['step'];
+$this->_sections['y']['index_next'] = $this->_sections['y']['index'] + $this->_sections['y']['step'];
+$this->_sections['y']['first'] = ($this->_sections['y']['iteration'] == 1);
+$this->_sections['y']['last'] = ($this->_sections['y']['iteration'] == $this->_sections['y']['total']);
+?>
+ <tr valign="top" align="center">
+ <td>N/A</td>
+ <td><?php echo $this->_tpl_vars['section_name']; ?>
+</td>
+ <td><input type="text" size="10" name="new_objects[<?php echo $this->_tpl_vars['new_objects'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td><input type="text" size="10" name="new_objects[<?php echo $this->_tpl_vars['new_objects'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td><input type="text" size="40" name="new_objects[<?php echo $this->_tpl_vars['new_objects'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+<?php endfor; endif; ?>
+ <tr class="controls" align="center">
+ <td colspan="5">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset"><br>
+ </td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="section_value" value="<?php echo $this->_tpl_vars['section_value']; ?>
+">
+ <input type="hidden" name="object_type" value="<?php echo $this->_tpl_vars['object_type']; ?>
+">
+ <input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+ </form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%4A^4AC^4AC2250D%%footer.tpl.php b/html/phpgacl/admin/templates_c/%%4A^4AC^4AC2250D%%footer.tpl.php
new file mode 100644
index 0000000..e5add3c
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%4A^4AC^4AC2250D%%footer.tpl.php
@@ -0,0 +1,15 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:36:44
+ compiled from phpgacl/footer.tpl */ ?>
+ </div></div>
+
+ <div id="bot-br"><div id="bot-bl"><div id="bot-tr"><div id="bot-tl">
+ <a href="http://phpgacl.sourceforge.net">phpGACL</a> v<?php echo $this->_tpl_vars['phpgacl_version']; ?>
+ (Schema v<?php echo $this->_tpl_vars['phpgacl_schema_version']; ?>
+) - Generic Access Control Lists
+ <br />
+ Copyright &copy; 2005 <a href="about.php">Mike Benoit</a>
+ </div></div></div></div>
+
+ <!-- End Body -->
+ </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%61^618^6182431B%%pager.tpl.php b/html/phpgacl/admin/templates_c/%%61^618^6182431B%%pager.tpl.php
new file mode 100644
index 0000000..36bd08d
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%61^618^6182431B%%pager.tpl.php
@@ -0,0 +1,27 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:37:27
+ compiled from phpgacl/pager.tpl */ ?>
+<table width="100%" cellspacing="0" cellpadding="2" border="0">
+ <tr valign="middle">
+ <td align="left">
+<?php if ($this->_tpl_vars['paging_data']['atfirstpage']): ?>
+ |&lt; &lt;&lt;
+<?php else: ?>
+ <a href="<?php echo $this->_tpl_vars['link']; ?>
+page=1">|&lt;</a> <a href="<?php echo $this->_tpl_vars['link']; ?>
+page=<?php echo $this->_tpl_vars['paging_data']['prevpage']; ?>
+">&lt;&lt;</a>
+<?php endif; ?>
+ </td>
+ <td align="right">
+<?php if ($this->_tpl_vars['paging_data']['atlastpage']): ?>
+ &gt;&gt; &gt;|
+<?php else: ?>
+ <a href="<?php echo $this->_tpl_vars['link']; ?>
+page=<?php echo $this->_tpl_vars['paging_data']['nextpage']; ?>
+">&gt;&gt;</a> <a href="<?php echo $this->_tpl_vars['link']; ?>
+page=<?php echo $this->_tpl_vars['paging_data']['lastpageno']; ?>
+">&gt;|</a>
+<?php endif; ?>
+ </td>
+ </tr>
+</table> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%85^85D^85DD3D56%%edit_group.tpl.php b/html/phpgacl/admin/templates_c/%%85^85D^85DD3D56%%edit_group.tpl.php
new file mode 100644
index 0000000..06feb54
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%85^85D^85DD3D56%%edit_group.tpl.php
@@ -0,0 +1,73 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:21:44
+ compiled from phpgacl/edit_group.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('modifier', 'default', 'phpgacl/edit_group.tpl', 25, false),array('function', 'html_options', 'phpgacl/edit_group.tpl', 28, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <style type="text/css">
+ <?php echo '
+ select {
+ margin-top: 0px;
+ }
+ input.group-name, input.group-value {
+ width: 99%;
+ }
+ '; ?>
+
+ </style>
+ </head>
+ <body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="edit_group" action="edit_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="4%">ID</th>
+ <th width="32%">Parent</th>
+ <th width="32%">Name</th>
+ <th width="32%">Value</th>
+ </tr>
+ <tr valign="top">
+ <td align="center"><?php echo ((is_array($_tmp=@$this->_tpl_vars['id'])) ? $this->_run_mod_handler('default', true, $_tmp, "N/A") : smarty_modifier_default($_tmp, "N/A")); ?>
+</td>
+ <td>
+ <select name="parent_id" tabindex="0" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_groups'],'selected' => $this->_tpl_vars['parent_id']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ <input type="text" class="group-name" size="50" name="name" value="<?php echo $this->_tpl_vars['name']; ?>
+">
+ </td>
+ <td>
+ <input type="text" class="group-value" size="50" name="value" value="<?php echo $this->_tpl_vars['value']; ?>
+">
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="group_id" value="<?php echo $this->_tpl_vars['id']; ?>
+">
+ <input type="hidden" name="group_type" value="<?php echo $this->_tpl_vars['group_type']; ?>
+">
+ <input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+ </form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%8B^8BF^8BF9EC71%%assign_group.tpl.php b/html/phpgacl/admin/templates_c/%%8B^8BF^8BF9EC71%%assign_group.tpl.php
new file mode 100644
index 0000000..93cad24
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%8B^8BF^8BF9EC71%%assign_group.tpl.php
@@ -0,0 +1,173 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:29:34
+ compiled from phpgacl/assign_group.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'phpgacl/assign_group.tpl', 23, false),array('modifier', 'upper', 'phpgacl/assign_group.tpl', 54, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<script LANGUAGE="JavaScript">
+<?php echo $this->_tpl_vars['js_array']; ?>
+
+</script>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+ <body onload="populate(document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section,document.assign_group.elements['objects[]'], '<?php echo $this->_tpl_vars['js_array_name']; ?>
+')">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="assign_group" action="assign_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="32%">Sections</th>
+ <th width="32%"><?php echo $this->_tpl_vars['object_type']; ?>
+s</th>
+ <th width="4%">&nbsp;</th>
+ <th width="32%">Selected</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ <br />
+ <select name="<?php echo $this->_tpl_vars['group_type']; ?>
+_section" tabindex="0" size="10" width="200" onclick="populate(document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section,document.assign_group.elements['objects[]'],'<?php echo $this->_tpl_vars['js_array_name']; ?>
+')">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_sections'],'selected' => $this->_tpl_vars['section_value']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&section_value=' + document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section.options[document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=assign_group&object_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&section_value=' + document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section.options[document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section.selectedIndex].value,'','status=yes,width=400,height=400','','status=yes,width=400,height=400');">Search</a> ]
+ <br />
+ <select name="objects[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.assign_group.<?php echo $this->_tpl_vars['group_type']; ?>
+_section, document.assign_group.elements['objects[]'], document.assign_group.elements['selected_<?php echo $this->_tpl_vars['group_type']; ?>
+[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.assign_group.elements['selected_<?php echo $this->_tpl_vars['group_type']; ?>
+[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_<?php echo $this->_tpl_vars['group_type']; ?>
+[]" tabindex="0" size="10" width="200" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_selected_objects'],'selected' => $this->_tpl_vars['selected_object']), $this);?>
+
+ </select>
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <br />
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr align="center">
+ <td colspan="5"><b><?php echo $this->_tpl_vars['total_objects']; ?>
+</b> <?php echo ((is_array($_tmp=$this->_tpl_vars['group_type'])) ? $this->_run_mod_handler('upper', true, $_tmp) : smarty_modifier_upper($_tmp)); ?>
+s in Group: <b><?php echo $this->_tpl_vars['group_name']; ?>
+</b></td>
+ </tr>
+ <tr class="pager">
+ <td colspan="5">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?group_type=".($this->_tpl_vars['group_type'])."&group_id=".($this->_tpl_vars['group_id'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th>Section</th>
+ <th><?php echo $this->_tpl_vars['object_type']; ?>
+</th>
+ <th><?php echo ((is_array($_tmp=$this->_tpl_vars['group_type'])) ? $this->_run_mod_handler('upper', true, $_tmp) : smarty_modifier_upper($_tmp)); ?>
+ Value</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+<?php $_from = $this->_tpl_vars['rows']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['row']):
+?>
+ <tr valign="top" align="center">
+ <td>
+ <?php echo $this->_tpl_vars['row']['section']; ?>
+
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['row']['name']; ?>
+
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['row']['value']; ?>
+
+ </td>
+ <td>
+ [ <a href="acl_list.php?action=Filter&filter_<?php echo $this->_tpl_vars['group_type']; ?>
+_section=<?php echo $this->_tpl_vars['row']['section_value']; ?>
+&filter_<?php echo $this->_tpl_vars['group_type']; ?>
+=<?php echo $this->_tpl_vars['row']['name']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">ACLs</a> ]
+ </td>
+ <td>
+ <input type="checkbox" class="checkbox" name="delete_assigned_object[]" value="<?php echo $this->_tpl_vars['row']['section_value']; ?>
+^<?php echo $this->_tpl_vars['row']['value']; ?>
+">
+ </td>
+ </tr>
+<?php endforeach; endif; unset($_from); ?>
+ <tr class="pager">
+ <td colspan="5">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="3">&nbsp;</td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Remove">
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="group_id" value="<?php echo $this->_tpl_vars['group_id']; ?>
+">
+<input type="hidden" name="group_type" value="<?php echo $this->_tpl_vars['group_type']; ?>
+">
+<input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+</form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%98^980^980C056E%%acl_test2.tpl.php b/html/phpgacl/admin/templates_c/%%98^980^980C056E%%acl_test2.tpl.php
new file mode 100644
index 0000000..263e926
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%98^980^980C056E%%acl_test2.tpl.php
@@ -0,0 +1,159 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:54:42
+ compiled from phpgacl/acl_test2.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+<body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<form method="post" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="11">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th>#</th>
+ <th>Section > ACO</th>
+ <th>Section > ARO</th>
+ <th>Return Value</th>
+ <th>ACL_CHECK() Code</th>
+ <th>Debug</th>
+ <th>Time (ms)</th>
+ <th>Access</th>
+ </tr>
+ <?php unset($this->_sections['x']);
+$this->_sections['x']['name'] = 'x';
+$this->_sections['x']['loop'] = is_array($_loop=$this->_tpl_vars['acls']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['x']['show'] = true;
+$this->_sections['x']['max'] = $this->_sections['x']['loop'];
+$this->_sections['x']['step'] = 1;
+$this->_sections['x']['start'] = $this->_sections['x']['step'] > 0 ? 0 : $this->_sections['x']['loop']-1;
+if ($this->_sections['x']['show']) {
+ $this->_sections['x']['total'] = $this->_sections['x']['loop'];
+ if ($this->_sections['x']['total'] == 0)
+ $this->_sections['x']['show'] = false;
+} else
+ $this->_sections['x']['total'] = 0;
+if ($this->_sections['x']['show']):
+
+ for ($this->_sections['x']['index'] = $this->_sections['x']['start'], $this->_sections['x']['iteration'] = 1;
+ $this->_sections['x']['iteration'] <= $this->_sections['x']['total'];
+ $this->_sections['x']['index'] += $this->_sections['x']['step'], $this->_sections['x']['iteration']++):
+$this->_sections['x']['rownum'] = $this->_sections['x']['iteration'];
+$this->_sections['x']['index_prev'] = $this->_sections['x']['index'] - $this->_sections['x']['step'];
+$this->_sections['x']['index_next'] = $this->_sections['x']['index'] + $this->_sections['x']['step'];
+$this->_sections['x']['first'] = ($this->_sections['x']['iteration'] == 1);
+$this->_sections['x']['last'] = ($this->_sections['x']['iteration'] == $this->_sections['x']['total']);
+?>
+ <tr>
+ <td valign="middle" align="center">
+ <?php echo $this->_sections['x']['iteration']; ?>
+
+ </td>
+ <td valign="middle" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['display_aco_name']; ?>
+
+ </td>
+ <td valign="top" align="left">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_name']; ?>
+ > <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_name']; ?>
+
+ </td>
+ <td valign="top" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['return_value']; ?>
+<br>
+ </td>
+ <td valign="top" align="left">
+ acl_check('<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+')
+ </td>
+ <td valign="top" align="center" nowrap>
+ [ <a href="acl_debug.php?aco_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+&aco_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+&aro_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+&aro_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+&action=Submit">debug</a> ]
+ </td>
+ <td valign="top" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['acl_check_time']; ?>
+
+ </td>
+ <td valign="middle" class="<?php if ($this->_tpl_vars['acls'][$this->_sections['x']['index']]['access']): ?>green<?php else: ?>red<?php endif; ?>" align="center">
+ <?php if ($this->_tpl_vars['acls'][$this->_sections['x']['index']]['access']): ?>
+ ALLOW
+ <?php else: ?>
+ DENY
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php endfor; endif; ?>
+ <tr classs="pager">
+ <td colspan="11">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+</table>
+</form>
+
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <tr>
+ <th colspan="2">
+ Summary
+ </th>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Total ACL Check(s)</b>
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['total_acl_checks']; ?>
+
+ </td>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Average Time / Check</b>
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['avg_acl_check_time']; ?>
+ms
+ </td>
+ </tr>
+</table>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <th>
+ Do you want to test 3-dimensional ACLs?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test3.php">3-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%A5^A56^A56C2CDE%%acl_test3.tpl.php b/html/phpgacl/admin/templates_c/%%A5^A56^A56C2CDE%%acl_test3.tpl.php
new file mode 100644
index 0000000..f43b91c
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%A5^A56^A56C2CDE%%acl_test3.tpl.php
@@ -0,0 +1,181 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:55:01
+ compiled from phpgacl/acl_test3.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+<body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<form method="post" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="12">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th>#</th>
+ <th>Section > ACO</th>
+ <th>Section > ARO</th>
+ <th>Section > AXO</th>
+ <th>Return Value</th>
+ <th>ACL_CHECK() Code</th>
+ <th>Debug</th>
+ <th>Time (ms)</th>
+ <th>Access</th>
+ </tr>
+ <?php unset($this->_sections['x']);
+$this->_sections['x']['name'] = 'x';
+$this->_sections['x']['loop'] = is_array($_loop=$this->_tpl_vars['acls']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['x']['show'] = true;
+$this->_sections['x']['max'] = $this->_sections['x']['loop'];
+$this->_sections['x']['step'] = 1;
+$this->_sections['x']['start'] = $this->_sections['x']['step'] > 0 ? 0 : $this->_sections['x']['loop']-1;
+if ($this->_sections['x']['show']) {
+ $this->_sections['x']['total'] = $this->_sections['x']['loop'];
+ if ($this->_sections['x']['total'] == 0)
+ $this->_sections['x']['show'] = false;
+} else
+ $this->_sections['x']['total'] = 0;
+if ($this->_sections['x']['show']):
+
+ for ($this->_sections['x']['index'] = $this->_sections['x']['start'], $this->_sections['x']['iteration'] = 1;
+ $this->_sections['x']['iteration'] <= $this->_sections['x']['total'];
+ $this->_sections['x']['index'] += $this->_sections['x']['step'], $this->_sections['x']['iteration']++):
+$this->_sections['x']['rownum'] = $this->_sections['x']['iteration'];
+$this->_sections['x']['index_prev'] = $this->_sections['x']['index'] - $this->_sections['x']['step'];
+$this->_sections['x']['index_next'] = $this->_sections['x']['index'] + $this->_sections['x']['step'];
+$this->_sections['x']['first'] = ($this->_sections['x']['iteration'] == 1);
+$this->_sections['x']['last'] = ($this->_sections['x']['iteration'] == $this->_sections['x']['total']);
+?>
+ <tr>
+ <td valign="middle" align="center">
+ <?php echo $this->_sections['x']['iteration']; ?>
+
+ </td>
+ <td valign="middle" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['display_aco_name']; ?>
+
+ </td>
+ <td valign="top" align="left">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_name']; ?>
+ > <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_name']; ?>
+
+ </td>
+ <td valign="top" align="left">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_section_name']; ?>
+ > <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_name']; ?>
+
+ </td>
+ <td valign="top" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['return_value']; ?>
+<br>
+ </td>
+ <td valign="top" align="left">
+ <!---acl_check('<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+')-->
+ <!---meinhard_jahn@web.de, 20041102: axo_section_value and axo_value implemented--->
+ acl_check('<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_section_value']; ?>
+', '<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_value']; ?>
+')
+ </td>
+ <td valign="top" align="center" nowrap>
+ <!---[ <a href="acl_debug.php?aco_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+&aco_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+&aro_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+&aro_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+&action=Submit">debug</a> ]-->
+ <!---meinhard_jahn@web.de, 20041102: axo_section_value and axo_value implemented--->
+ [ <a href="acl_debug.php?aco_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_section_value']; ?>
+&aco_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aco_value']; ?>
+&aro_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_section_value']; ?>
+&aro_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['aro_value']; ?>
+&axo_section_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_section_value']; ?>
+&axo_value=<?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['axo_value']; ?>
+&action=Submit">debug</a> ]
+ </td>
+ <td valign="top" align="center">
+ <?php echo $this->_tpl_vars['acls'][$this->_sections['x']['index']]['acl_check_time']; ?>
+
+ </td>
+ <td valign="middle" class="<?php if ($this->_tpl_vars['acls'][$this->_sections['x']['index']]['access']): ?>green<?php else: ?>red<?php endif; ?>" align="center">
+ <?php if ($this->_tpl_vars['acls'][$this->_sections['x']['index']]['access']): ?>
+ ALLOW
+ <?php else: ?>
+ DENY
+ <?php endif; ?>
+ </td>
+ </tr>
+ <?php endfor; endif; ?>
+ <tr classs="pager">
+ <td colspan="12">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+</table>
+</form>
+
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <tr>
+ <th colspan="2">
+ Summary
+ </th>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Total ACL Check(s)</b>
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['total_acl_checks']; ?>
+
+ </td>
+ </tr>
+ <tr align="center">
+ <td>
+ <b>Average Time / Check</b>
+ </td>
+ <td>
+ <?php echo $this->_tpl_vars['avg_acl_check_time']; ?>
+ms
+ </td>
+ </tr>
+</table>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="30%">
+ <th>
+ Do you want to test 2-dimensional ACLs?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test2.php">2-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%B2^B23^B23838E8%%acl_list.tpl.php b/html/phpgacl/admin/templates_c/%%B2^B23^B23838E8%%acl_list.tpl.php
new file mode 100644
index 0000000..5a84af9
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%B2^B23^B23838E8%%acl_list.tpl.php
@@ -0,0 +1,322 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:37:27
+ compiled from phpgacl/acl_list.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'phpgacl/acl_list.tpl', 57, false),array('function', 'cycle', 'phpgacl/acl_list.tpl', 127, false),array('modifier', 'date_format', 'phpgacl/acl_list.tpl', 226, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ echo '
+ <style type="text/css">
+ ul {
+ padding: 0px 0px 0px 0px;
+ margin: 0px 0px 0px 0px;
+ list-style-type: none;
+ }
+ ul li {
+ padding: 0px;
+ margin: 0px;
+ font-weight: bold;
+ }
+ ol {
+ padding: 0px 0px 0px 22px;
+ margin: 0px;
+ }
+ ol li {
+ padding: 0px;
+ margin: 0px;
+ font-weight: normal;
+ }
+ div.divider {
+ margin: 2px 0px;
+ padding: 0px;
+ border-bottom: 1px solid grey;
+ }
+ input.filter {
+ width: 99%;
+ }
+ select.filter {
+ width: 99%;
+ margin-top: 0px;
+ }
+ </style>
+'; ?>
+
+ </head>
+<body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<form method="get" name="acl_list" action="acl_list.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr align="center">
+ <td colspan="6"><b>Filter</b></td>
+ </tr>
+ <tr>
+ <th width="12%">&nbsp;</th>
+ <th width="22%">ACO</th>
+ <th width="22%">ARO</th>
+ <th width="22%">AXO</th>
+ <th width="22%" colspan="2">ACL</th>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Section:</b> </td>
+ <td>
+ <select name="filter_aco_section" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_aco_sections'],'selected' => $this->_tpl_vars['filter_aco_section']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ <select name="filter_aro_section" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_aro_sections'],'selected' => $this->_tpl_vars['filter_aro_section']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ <select name="filter_axo_section" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_axo_sections'],'selected' => $this->_tpl_vars['filter_axo_section']), $this);?>
+
+ </select>
+ </td>
+ <td colspan="2">
+ <select name="filter_acl_section" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_acl_sections'],'selected' => $this->_tpl_vars['filter_acl_section']), $this);?>
+
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Object:</b> </td>
+ <td><input type="text" name="filter_aco" size="20" value="<?php echo $this->_tpl_vars['filter_aco']; ?>
+" class="filter"></td>
+ <td><input type="text" name="filter_aro" size="20" value="<?php echo $this->_tpl_vars['filter_aro']; ?>
+" class="filter"></td>
+ <td><input type="text" name="filter_axo" size="20" value="<?php echo $this->_tpl_vars['filter_axo']; ?>
+" class="filter"></td>
+ <td align="left" width="11%"><b>Allow:</b> </td>
+ <td align="left" width="11%">
+ <select name="filter_allow" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_allow'],'selected' => $this->_tpl_vars['filter_allow']), $this);?>
+
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="center">
+ <td align="left"><b>Group:</b> </td>
+ <td>&nbsp;</td>
+ <td><input type="text" name="filter_aro_group" size="20" value="<?php echo $this->_tpl_vars['filter_aro_group']; ?>
+" class="filter"></td>
+ <td><input type="text" name="filter_axo_group" size="20" value="<?php echo $this->_tpl_vars['filter_axo_group']; ?>
+" class="filter"></td>
+ <td align="left"><b>Enabled:</b> </td>
+ <td align="left">
+ <select name="filter_enabled" tabindex="0" class="filter">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_filter_enabled'],'selected' => $this->_tpl_vars['filter_enabled']), $this);?>
+
+ </select>
+ </td>
+ </tr>
+ <tr valign="middle" align="left">
+ <td><b>Return&nbsp;Value:</b> </td>
+ <td colspan="5"><input type="text" name="filter_return_value" size="50" value="<?php echo $this->_tpl_vars['filter_return_value']; ?>
+" class="filter"></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="6"><input type="submit" class="button" name="action" value="Filter"></td>
+ </tr>
+</table>
+<br />
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr class="pager">
+ <td colspan="8">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?action=".($this->_tpl_vars['action'])."&filter_aco_section=".($this->_tpl_vars['filter_aco_section'])."&filter_aco=".($this->_tpl_vars['filter_aco'])."&filter_aro_section=".($this->_tpl_vars['filter_aro_section'])."&filter_aro=".($this->_tpl_vars['filter_aro'])."&filter_axo_section=".($this->_tpl_vars['filter_axo_section'])."&filter_axo=".($this->_tpl_vars['filter_axo'])."&filter_aro_group=".($this->_tpl_vars['filter_aro_group'])."&filter_axo_group=".($this->_tpl_vars['filter_axo_group'])."&filter_return_value=".($this->_tpl_vars['filter_return_value'])."&filter_allow=".($this->_tpl_vars['filter_allow'])."&filter_enabled=".($this->_tpl_vars['filter_enabled'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th width="24%">ACO</th>
+ <th width="24%">ARO</th>
+ <th width="24%">AXO</th>
+ <th width="10%">Access</th>
+ <th width="10%">Enabled</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+
+<?php $_from = $this->_tpl_vars['acls']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['acl']):
+?>
+ <?php echo smarty_function_cycle(array('assign' => 'class','values' => "odd,even"), $this);?>
+
+ <tr class="<?php echo $this->_tpl_vars['class']; ?>
+">
+ <td valign="middle" rowspan="3" align="center"><?php echo $this->_tpl_vars['acl']['id']; ?>
+</td>
+ <td valign="top" align="left">
+ <?php if (count ( $this->_tpl_vars['acl']['aco'] ) > 0): ?>
+ <ul>
+ <?php $_from = $this->_tpl_vars['acl']['aco']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['section'] => $this->_tpl_vars['objects']):
+?>
+ <li><?php echo $this->_tpl_vars['section']; ?>
+<ol>
+ <?php $_from = $this->_tpl_vars['objects']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['obj']):
+?>
+ <li><?php echo $this->_tpl_vars['obj']; ?>
+</li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ol></li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ul>
+ <?php else: ?>
+ &nbsp;
+ <?php endif; ?>
+ </td>
+ <td valign="top" align="left">
+ <?php if (count ( $this->_tpl_vars['acl']['aro'] ) > 0): ?>
+ <ul>
+ <?php $_from = $this->_tpl_vars['acl']['aro']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['section'] => $this->_tpl_vars['objects']):
+?>
+ <li><?php echo $this->_tpl_vars['section']; ?>
+<ol>
+ <?php $_from = $this->_tpl_vars['objects']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['obj']):
+?>
+ <li><?php echo $this->_tpl_vars['obj']; ?>
+</li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ol></li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ul>
+ <?php if (count ( $this->_tpl_vars['acl']['aro_groups'] ) > 0): ?>
+ <div class="divider"></div>
+ <?php endif; ?>
+ <?php endif; ?>
+ <?php if (count ( $this->_tpl_vars['acl']['aro_groups'] ) > 0): ?>
+ <b>Groups</b><ol>
+ <?php $_from = $this->_tpl_vars['acl']['aro_groups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['group']):
+?>
+ <li><?php echo $this->_tpl_vars['group']; ?>
+</li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ol>
+ <?php endif; ?>
+ </td>
+ <td valign="top" align="left">
+ <?php if (count ( $this->_tpl_vars['acl']['axo'] ) > 0): ?>
+ <ul>
+ <?php $_from = $this->_tpl_vars['acl']['axo']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['section'] => $this->_tpl_vars['objects']):
+?>
+ <li><?php echo $this->_tpl_vars['section']; ?>
+<ol>
+ <?php $_from = $this->_tpl_vars['objects']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['obj']):
+?>
+ <li><?php echo $this->_tpl_vars['obj']; ?>
+</li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ol></li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ul>
+ <?php if (count ( $this->_tpl_vars['acl']['axo_groups'] ) > 0): ?>
+ <div class="divider"></div>
+ <?php endif; ?>
+ <?php endif; ?>
+ <?php if (count ( $this->_tpl_vars['acl']['axo_groups'] ) > 0): ?>
+ <b>Groups</b><ol>
+ <?php $_from = $this->_tpl_vars['acl']['axo_groups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['group']):
+?>
+ <li><?php echo $this->_tpl_vars['group']; ?>
+</li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ol>
+ <?php endif; ?>
+ </td>
+ <td valign="middle" class="<?php if ($this->_tpl_vars['acl']['allow']): ?>green<?php else: ?>red<?php endif; ?>" align="center">
+ <?php if ($this->_tpl_vars['acl']['allow']): ?>
+ ALLOW
+ <?php else: ?>
+ DENY
+ <?php endif; ?>
+ </td>
+ <td valign="middle" class="<?php if ($this->_tpl_vars['acl']['enabled']): ?>green<?php else: ?>red<?php endif; ?>" align="center">
+ <?php if ($this->_tpl_vars['acl']['enabled']): ?>
+ Yes
+ <?php else: ?>
+ No
+ <?php endif; ?>
+ </td>
+ <td valign="middle" rowspan="3" align="center">
+ [ <a href="acl_admin.php?action=edit&acl_id=<?php echo $this->_tpl_vars['acl']['id']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ </td>
+ <td valign="middle" rowspan="3" align="center">
+ <input type="checkbox" class="checkbox" name="delete_acl[]" value="<?php echo $this->_tpl_vars['acl']['id']; ?>
+">
+ </td>
+ </tr>
+
+ <tr class="<?php echo $this->_tpl_vars['class']; ?>
+">
+ <td valign="top" colspan="3" align="left">
+ <b>Return Value:</b> <?php echo $this->_tpl_vars['acl']['return_value']; ?>
+
+ </td>
+ <td valign="middle" colspan="2" align="center">
+ <?php echo $this->_tpl_vars['acl']['section_name']; ?>
+
+ </td>
+ </tr>
+ <tr class="<?php echo $this->_tpl_vars['class']; ?>
+">
+ <td valign="top" colspan="3" align="left">
+ <b>Note:</b> <?php echo $this->_tpl_vars['acl']['note']; ?>
+
+ </td>
+ <td valign="middle" colspan="2" align="center">
+ <?php echo ((is_array($_tmp=$this->_tpl_vars['acl']['updated_date'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%d-%b-%Y&nbsp;%H:%M:%S") : smarty_modifier_date_format($_tmp, "%d-%b-%Y&nbsp;%H:%M:%S")); ?>
+
+ </td>
+ </tr>
+<?php endforeach; endif; unset($_from); ?>
+ <tr class="pager">
+ <td colspan="8">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?action=".($this->_tpl_vars['action'])."&filter_aco_section=".($this->_tpl_vars['filter_aco_section'])."&filter_aco=".($this->_tpl_vars['filter_aco'])."&filter_aro_section=".($this->_tpl_vars['filter_aro_section'])."&filter_aro=".($this->_tpl_vars['filter_aro'])."&filter_axo_section=".($this->_tpl_vars['filter_axo_section'])."&filter_axo=".($this->_tpl_vars['filter_axo'])."&filter_aro_group=".($this->_tpl_vars['filter_aro_group'])."&filter_axo_group=".($this->_tpl_vars['filter_axo_group'])."&filter_return_value=".($this->_tpl_vars['filter_return_value'])."&filter_allow=".($this->_tpl_vars['filter_allow'])."&filter_enabled=".($this->_tpl_vars['filter_enabled'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr class="controls">
+ <td colspan="6">&nbsp;</td>
+ <td colspan="2" align="center">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+</form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%B3^B37^B37111DC%%header.tpl.php b/html/phpgacl/admin/templates_c/%%B3^B37^B37111DC%%header.tpl.php
new file mode 100644
index 0000000..abae44a
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%B3^B37^B37111DC%%header.tpl.php
@@ -0,0 +1,10 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:36:44
+ compiled from phpgacl/header.tpl */ ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+ <head>
+ <title>phpGACL - <?php echo $this->_tpl_vars['page_title']; ?>
+</title>
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ <link rel="stylesheet" href="admin.css" type="text/css" title="phpGACL" /> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%C7^C72^C720F60D%%acl_admin_js.tpl.php b/html/phpgacl/admin/templates_c/%%C7^C72^C720F60D%%acl_admin_js.tpl.php
new file mode 100644
index 0000000..dbce8c3
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%C7^C72^C720F60D%%acl_admin_js.tpl.php
@@ -0,0 +1,6 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:37:27
+ compiled from phpgacl/acl_admin_js.tpl */ ?>
+<?php echo '
+<script language="JavaScript" src="admin_functions.js">
+</script>
+'; ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%C7^C7B^C7BBD6D2%%acl_admin.tpl.php b/html/phpgacl/admin/templates_c/%%C7^C7B^C7BBD6D2%%acl_admin.tpl.php
new file mode 100644
index 0000000..70ec34a
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%C7^C7B^C7BBD6D2%%acl_admin.tpl.php
@@ -0,0 +1,234 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:18:06
+ compiled from phpgacl/acl_admin.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'phpgacl/acl_admin.tpl', 25, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<script LANGUAGE="JavaScript">
+<?php echo $this->_tpl_vars['js_array']; ?>
+
+</script>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+<body onload="populate(document.acl_admin.aco_section,document.acl_admin.elements['aco[]'], '<?php echo $this->_tpl_vars['js_aco_array_name']; ?>
+');populate(document.acl_admin.aro_section,document.acl_admin.elements['aro[]'], '<?php echo $this->_tpl_vars['js_aro_array_name']; ?>
+')">
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="acl_admin" action="acl_admin.php" onsubmit="select_all(document.acl_admin.elements['selected_aco[]']);select_all(document.acl_admin.elements['selected_aro[]']);select_all(document.acl_admin.elements['selected_aro[]']);return true;">
+ <div align="center">
+ <table cellpadding="2" cellspacing="2" border="2" align="center">
+ <tbody>
+ <tr>
+ <th width="24%">Sections</th>
+ <th width="24%">Access Control Objects</th>
+ <th width="4%">&nbsp;</th>
+ <th width="24%">Selected</th>
+ <th width="24%">Access</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type=aco&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ <br />
+ <select name="aco_section" tabindex="0" size="10" onclick="populate(document.acl_admin.aco_section,document.acl_admin.elements['aco[]'], '<?php echo $this->_tpl_vars['js_aco_array_name']; ?>
+')">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_aco_sections'],'selected' => $this->_tpl_vars['aco_section_value']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=aco&section_value=' + document.acl_admin.aco_section.options[document.acl_admin.aco_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+';">Edit</a> ]
+ <br />
+ <select name="aco[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.aco_section, document.acl_admin.elements['aco[]'], document.acl_admin.elements['selected_aco[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_aco[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_aco[]" tabindex="0" size="10" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_selected_aco'],'selected' => $this->_tpl_vars['selected_aco']), $this);?>
+
+ </select>
+ </td>
+ <td valign="middle">
+ <table class="invisible">
+ <tr align="left"><td><input type="radio" class="radio" name="allow" value="1" <?php if ($this->_tpl_vars['allow'] == 1): ?>checked<?php endif; ?> /></td><td>Allow</td></tr>
+ <tr align="left"><td><input type="radio" class="radio" name="allow" value="0" <?php if ($this->_tpl_vars['allow'] == 0): ?>checked<?php endif; ?> /></td><td>Deny</td></tr>
+ <tr class="spacer"><td colspan="2"></td></tr>
+ <tr align="left"><td><input type="checkbox" class="checkbox" name="enabled" value="1" <?php if ($this->_tpl_vars['enabled'] == 1): ?>checked<?php endif; ?> /></td><td>Enabled</td></tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <th>Sections</th>
+ <th>Access Request Objects</th>
+ <th>&nbsp;</th>
+ <th>Selected</th>
+ <th>Groups</th>
+ </tr>
+ <tr valign="top" align="center">
+ <td>
+ [ <a href="edit_object_sections.php?object_type=aro&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ <br />
+ <select name="aro_section" tabindex="0" size="10" onclick="populate(document.acl_admin.aro_section,document.acl_admin.elements['aro[]'],'<?php echo $this->_tpl_vars['js_aro_array_name']; ?>
+')">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_aro_sections'],'selected' => $this->_tpl_vars['aro_section_value']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=aro&section_value=' + document.acl_admin.aro_section.options[document.acl_admin.aro_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=acl_admin&object_type=aro&section_value=' + document.acl_admin.aro_section.options[document.acl_admin.aro_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+','','status=yes,width=400,height=400');return false;">Search</a> ]
+ <br />
+ <select name="aro[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.aro_section, document.acl_admin.elements['aro[]'], document.acl_admin.elements['selected_aro[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_aro[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_aro[]" tabindex="0" size="10" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_selected_aro'],'selected' => $this->_tpl_vars['selected_aro']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="group_admin.php?group_type=aro&return_page=<?php echo $this->_tpl_vars['SCRIPT_NAME']; ?>
+?action=<?php echo $this->_tpl_vars['action']; ?>
+&acl_id=<?php echo $this->_tpl_vars['acl_id']; ?>
+">Edit</a> ]
+ <br />
+ <select name="aro_groups[]" tabindex="0" size="8" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_aro_groups'],'selected' => $this->_tpl_vars['selected_aro_groups']), $this);?>
+
+ </select>
+ <br /><input type="button" class="un-select" name="Un-Select" value="Un-Select" onClick="unselect_all(document.acl_admin.elements['aro_groups[]'])">
+ </td>
+ </tr>
+
+ <tr>
+ <th colspan="5">
+ [ <a href="javascript: showObject('axo_row1');showObject('axo_row2');setCookie('show_axo',1);">Show</a> / <a href="javascript: hideObject('axo_row1');hideObject('axo_row2');deleteCookie('show_axo');">Hide</a> ] Access eXtension Objects (Optional)
+ </th>
+ </tr>
+
+ <tr id="axo_row1" <?php if (! $this->_tpl_vars['show_axo']): ?>class="hide"<?php endif; ?>>
+ <th>Sections</th>
+ <th>Access eXtension Objects</th>
+ <th>&nbsp;</th>
+ <th>Selected</th>
+ <th>Groups</th>
+ </tr>
+ <tr valign="top" align="center" id="axo_row2" <?php if (! $this->_tpl_vars['show_axo']): ?>class="hide"<?php endif; ?>>
+ <td>
+ [ <a href="edit_object_sections.php?object_type=axo&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ <br />
+ <select name="axo_section" tabindex="0" size="10" onclick="populate(document.acl_admin.axo_section,document.acl_admin.elements['axo[]'],'<?php echo $this->_tpl_vars['js_axo_array_name']; ?>
+')">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_axo_sections'],'selected' => $this->_tpl_vars['axo_section_value']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="javascript: location.href = 'edit_objects.php?object_type=axo&section_value=' + document.acl_admin.axo_section.options[document.acl_admin.axo_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+';">Edit</a> ]
+ [ <a href="#" onClick="window.open('object_search.php?src_form=acl_admin&object_type=axo&section_value=' + document.acl_admin.axo_section.options[document.acl_admin.axo_section.selectedIndex].value + '&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+','','status=yes,width=400,height=400');return false;">Search</a> ]
+ <br />
+ <select name="axo[]" tabindex="0" size="10" width="200" multiple>
+ </select>
+ </td>
+ <td valign="middle">
+ <br /><input type="button" class="select" name="select" value="&nbsp;&gt;&gt;&nbsp;" onClick="select_item(document.acl_admin.axo_section, document.acl_admin.elements['axo[]'], document.acl_admin.elements['selected_axo[]'])">
+ <br /><input type="button" class="deselect" name="deselect" value="&nbsp;&lt;&lt;&nbsp;" onClick="deselect_item(document.acl_admin.elements['selected_axo[]'])">
+ </td>
+ <td>
+ <br />
+ <select name="selected_axo[]" tabindex="0" size="10" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_selected_axo'],'selected' => $this->_tpl_vars['selected_axo']), $this);?>
+
+ </select>
+ </td>
+ <td>
+ [ <a href="group_admin.php?group_type=axo&return_page=<?php echo $this->_tpl_vars['SCRIPT_NAME']; ?>
+?action=<?php echo $this->_tpl_vars['action']; ?>
+&acl_id=<?php echo $this->_tpl_vars['acl_id']; ?>
+">Edit</a> ]
+ <br />
+ <select name="axo_groups[]" tabindex="0" size="8" multiple>
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_axo_groups'],'selected' => $this->_tpl_vars['selected_axo_groups']), $this);?>
+
+ </select>
+ <br /><input type="button" class="un-select" name="Un-Select" value="Un-Select" onClick="unselect_all(document.acl_admin.elements['axo_groups[]'])">
+ </td>
+ </tr>
+
+ <tr>
+ <th colspan="5">Miscellaneous Attributes</th>
+ </tr>
+ <tr valign="top" align="left">
+ <td align="center">
+ <b>ACL Section</b>
+ </td>
+ <td>
+ <b>Extended Return Value:</b>
+ </td>
+ <td colspan="4">
+ <input type="text" name="return_value" size="50" value="<?php echo $this->_tpl_vars['return_value']; ?>
+" id="return_value">
+ </td>
+ </tr>
+ <tr valign="top" align="left">
+ <td align="center">
+ [ <a href="edit_object_sections.php?object_type=acl&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a> ]
+ <br />
+ <select name="acl_section" tabindex="0" size="3">
+ <?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['options_acl_sections'],'selected' => $this->_tpl_vars['acl_section_value']), $this);?>
+
+ </select>
+ </td>
+ <td><b>Note:</b></td>
+ <td colspan="4"><textarea name="note" rows="4" cols="40"><?php echo $this->_tpl_vars['note']; ?>
+</textarea></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="5">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="acl_id" value="<?php echo $this->_tpl_vars['acl_id']; ?>
+">
+ <input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+ </div>
+</form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%CE^CEC^CECA437B%%acl_debug.tpl.php b/html/phpgacl/admin/templates_c/%%CE^CEC^CECA437B%%acl_debug.tpl.php
new file mode 100644
index 0000000..3be2fd1
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%CE^CEC^CECA437B%%acl_debug.tpl.php
@@ -0,0 +1,147 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:55:55
+ compiled from phpgacl/acl_debug.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+<body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<form method="get" name="acl_debug" action="acl_debug.php">
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr>
+ <th rowspan="2">&nbsp;</th>
+ <th colspan="2">ACO</th>
+ <th colspan="2">ARO</th>
+ <th colspan="2">AXO</th>
+ <th rowspan="2">Root ARO<br />Group ID</th>
+ <th rowspan="2">Root AXO<br />Group ID</th>
+ <th rowspan="2">&nbsp;</th>
+ </tr>
+ <tr>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Section</th>
+ <th>Value</th>
+ <th>Section</th>
+ <th>Value</th>
+ </tr>
+ <tr valign="middle" align="center">
+ <td nowrap><b>acl_query(</b></td>
+ <td><input type="text" name="aco_section_value" size="15" value="<?php echo $this->_tpl_vars['aco_section_value']; ?>
+"></td>
+ <td><input type="text" name="aco_value" size="15" value="<?php echo $this->_tpl_vars['aco_value']; ?>
+"></td>
+ <td><input type="text" name="aro_section_value" size="15" value="<?php echo $this->_tpl_vars['aro_section_value']; ?>
+"></td>
+ <td><input type="text" name="aro_value" size="15" value="<?php echo $this->_tpl_vars['aro_value']; ?>
+"></td>
+ <td><input type="text" name="axo_section_value" size="15" value="<?php echo $this->_tpl_vars['axo_section_value']; ?>
+"></td>
+ <td><input type="text" name="axo_value" size="15" value="<?php echo $this->_tpl_vars['axo_value']; ?>
+"></td>
+ <td><input type="text" name="root_aro_group_id" size="15" value="<?php echo $this->_tpl_vars['root_aro_group_id']; ?>
+"></td>
+ <td><input type="text" name="root_axo_group_id" size="15" value="<?php echo $this->_tpl_vars['root_axo_group_id']; ?>
+"></td>
+ <td><b>)</b></td>
+ </tr>
+ <tr class="controls" align="center">
+ <td colspan="10">
+ <input type="submit" class="button" name="action" value="Submit">
+ </td>
+ </tr>
+</table>
+<?php if (count ( $this->_tpl_vars['acls'] ) > 0): ?>
+<br />
+<table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tr>
+ <th rowspan="2" width="4%">ACL ID</th>
+ <th colspan="2">ACO</th>
+ <th colspan="2">ARO</th>
+ <th colspan="2">AXO</th>
+ <th colspan="2">ACL</th>
+ </tr>
+ <tr>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="12%">Section</th>
+ <th width="12%">Value</th>
+ <th width="8%">Access</th>
+ <th width="16%">Updated Date</th>
+ </tr>
+<?php $_from = $this->_tpl_vars['acls']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['acl']):
+?>
+ <tr valign="top" align="left">
+ <td valign="middle" rowspan="2" align="center">
+ <?php echo $this->_tpl_vars['acl']['id']; ?>
+
+ </td>
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['aco_section_value']; ?>
+
+ </td>
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['aco_value']; ?>
+
+ </td>
+
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['aro_section_value']; ?>
+<br>
+ </td>
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['aro_value']; ?>
+<br>
+ </td>
+
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['axo_section_value']; ?>
+<br>
+ </td>
+ <td nowrap>
+ <?php echo $this->_tpl_vars['acl']['axo_value']; ?>
+<br>
+ </td>
+
+ <td valign="middle" class="<?php if ($this->_tpl_vars['acl']['allow']): ?>green<?php else: ?>red<?php endif; ?>" align="center">
+ <?php if ($this->_tpl_vars['acl']['allow']): ?>
+ ALLOW
+ <?php else: ?>
+ DENY
+ <?php endif; ?>
+ </td>
+ <td valign="middle" align="center">
+ <?php echo $this->_tpl_vars['acl']['updated_date']; ?>
+
+ </td>
+ </tr>
+ <tr valign="middle" align="left">
+ <td colspan="4">
+ <b>Return Value:</b> <?php echo $this->_tpl_vars['acl']['return_value']; ?>
+<br>
+ </td>
+ <td colspan="4">
+ <b>Note:</b> <?php echo $this->_tpl_vars['acl']['note']; ?>
+
+ </td>
+ </tr>
+<?php endforeach; endif; unset($_from); ?>
+</table>
+<?php endif; ?>
+<input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+</form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%D2^D28^D28FA630%%group_admin.tpl.php b/html/phpgacl/admin/templates_c/%%D2^D28^D28FA630%%group_admin.tpl.php
new file mode 100644
index 0000000..7e00cc1
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%D2^D28^D28FA630%%group_admin.tpl.php
@@ -0,0 +1,83 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:21:38
+ compiled from phpgacl/group_admin.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('modifier', 'upper', 'phpgacl/group_admin.tpl', 24, false),array('modifier', 'urlencode', 'phpgacl/group_admin.tpl', 27, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+ <body>
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="edit_group" action="edit_group.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr>
+ <th width="2%">ID</th>
+ <th width="40%">Name</th>
+ <th width="20%">Value</th>
+ <th width="6%">Objects</th>
+ <th width="30%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+<?php $_from = $this->_tpl_vars['groups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['group']):
+?>
+ <tr valign="middle" align="center">
+ <td><?php echo $this->_tpl_vars['group']['id']; ?>
+</td>
+ <td align="left"><?php echo $this->_tpl_vars['group']['name']; ?>
+</td>
+ <td align="left"><?php echo $this->_tpl_vars['group']['value']; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['group']['object_count']; ?>
+</td>
+ <td>
+ [&nbsp;<a href="assign_group.php?group_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&group_id=<?php echo $this->_tpl_vars['group']['id']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Assign&nbsp;<?php echo ((is_array($_tmp=$this->_tpl_vars['group_type'])) ? $this->_run_mod_handler('upper', true, $_tmp) : smarty_modifier_upper($_tmp)); ?>
+</a>&nbsp;]
+ [&nbsp;<a href="edit_group.php?group_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&parent_id=<?php echo $this->_tpl_vars['group']['id']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Add&nbsp;Child</a>&nbsp;]
+ [&nbsp;<a href="edit_group.php?group_type=<?php echo $this->_tpl_vars['group_type']; ?>
+&group_id=<?php echo $this->_tpl_vars['group']['id']; ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">Edit</a>&nbsp;]
+ [&nbsp;<a href="acl_list.php?action=Filter&filter_<?php echo $this->_tpl_vars['group_type']; ?>
+_group=<?php echo ((is_array($_tmp=$this->_tpl_vars['group']['raw_name'])) ? $this->_run_mod_handler('urlencode', true, $_tmp) : urlencode($_tmp)); ?>
+&return_page=<?php echo $this->_tpl_vars['return_page']; ?>
+">ACLs</a>&nbsp;]
+ </td>
+ <td><input type="checkbox" class="checkbox" name="delete_group[]" value="<?php echo $this->_tpl_vars['group']['id']; ?>
+"></td>
+ </tr>
+<?php endforeach; endif; unset($_from); ?>
+ <tr class="controls" align="center">
+ <td colspan="4">&nbsp;</td>
+ <td colspan="2" nowrap><input type="submit" class="button" name="action" value="Add" /> <input type="submit" class="button" name="action" value="Delete" /></td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="group_type" value="<?php echo $this->_tpl_vars['group_type']; ?>
+">
+ <input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+ </form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%D3^D36^D36362FF%%edit_object_sections.tpl.php b/html/phpgacl/admin/templates_c/%%D3^D36^D36362FF%%edit_object_sections.tpl.php
new file mode 100644
index 0000000..3293020
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%D3^D36^D36362FF%%edit_object_sections.tpl.php
@@ -0,0 +1,166 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:29:40
+ compiled from phpgacl/edit_object_sections.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('modifier', 'upper', 'phpgacl/edit_object_sections.tpl', 44, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/acl_admin_js.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+ <body>
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <form method="post" name="edit_object_sections" action="edit_object_sections.php">
+ <table cellpadding="2" cellspacing="2" border="2" width="100%">
+ <tbody>
+ <tr class="pager">
+ <td colspan="11">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?object_type=".($this->_tpl_vars['object_type'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <th width="2%">ID</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th width="4%">Functions</th>
+ <th width="2%"><input type="checkbox" class="checkbox" name="select_all" onClick="checkAll(this)"/></th>
+ </tr>
+<?php unset($this->_sections['x']);
+$this->_sections['x']['name'] = 'x';
+$this->_sections['x']['loop'] = is_array($_loop=$this->_tpl_vars['sections']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['x']['show'] = true;
+$this->_sections['x']['max'] = $this->_sections['x']['loop'];
+$this->_sections['x']['step'] = 1;
+$this->_sections['x']['start'] = $this->_sections['x']['step'] > 0 ? 0 : $this->_sections['x']['loop']-1;
+if ($this->_sections['x']['show']) {
+ $this->_sections['x']['total'] = $this->_sections['x']['loop'];
+ if ($this->_sections['x']['total'] == 0)
+ $this->_sections['x']['show'] = false;
+} else
+ $this->_sections['x']['total'] = 0;
+if ($this->_sections['x']['show']):
+
+ for ($this->_sections['x']['index'] = $this->_sections['x']['start'], $this->_sections['x']['iteration'] = 1;
+ $this->_sections['x']['iteration'] <= $this->_sections['x']['total'];
+ $this->_sections['x']['index'] += $this->_sections['x']['step'], $this->_sections['x']['iteration']++):
+$this->_sections['x']['rownum'] = $this->_sections['x']['iteration'];
+$this->_sections['x']['index_prev'] = $this->_sections['x']['index'] - $this->_sections['x']['step'];
+$this->_sections['x']['index_next'] = $this->_sections['x']['index'] + $this->_sections['x']['step'];
+$this->_sections['x']['first'] = ($this->_sections['x']['iteration'] == 1);
+$this->_sections['x']['last'] = ($this->_sections['x']['iteration'] == $this->_sections['x']['total']);
+?>
+ <tr valign="top" align="center">
+ <td>
+ <?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+
+ <input type="hidden" name="sections[<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+">
+ </td>
+ <td><input type="text" size="10" name="sections[<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['value']; ?>
+"></td>
+ <td><input type="text" size="10" name="sections[<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['order']; ?>
+"></td>
+ <td><input type="text" size="40" name="sections[<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+][]" value="<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['name']; ?>
+"></td>
+ <td>&nbsp;</td>
+ <td><input type="checkbox" class="checkbox" name="delete_sections[]" value="<?php echo $this->_tpl_vars['sections'][$this->_sections['x']['index']]['id']; ?>
+"></td>
+ </tr>
+<?php endfor; endif; ?>
+ <tr class="pager">
+ <td colspan="6">
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/pager.tpl", 'smarty_include_vars' => array('pager_data' => $this->_tpl_vars['paging_data'],'link' => "?object_type=".($this->_tpl_vars['object_type'])."&")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </td>
+ </tr>
+ <tr class="spacer">
+ <td colspan="6"></td>
+ </tr>
+ <tr align="center">
+ <td colspan="6"><b>Add <?php echo ((is_array($_tmp=$this->_tpl_vars['object_type'])) ? $this->_run_mod_handler('upper', true, $_tmp) : smarty_modifier_upper($_tmp)); ?>
+ Sections</b></td>
+ </tr>
+ <tr>
+ <th>ID</th>
+ <th>Value</th>
+ <th>Order</th>
+ <th>Name</th>
+ <th>Functions</th>
+ <th>&nbsp;</td>
+ </tr>
+<?php unset($this->_sections['y']);
+$this->_sections['y']['name'] = 'y';
+$this->_sections['y']['loop'] = is_array($_loop=$this->_tpl_vars['new_sections']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['y']['show'] = true;
+$this->_sections['y']['max'] = $this->_sections['y']['loop'];
+$this->_sections['y']['step'] = 1;
+$this->_sections['y']['start'] = $this->_sections['y']['step'] > 0 ? 0 : $this->_sections['y']['loop']-1;
+if ($this->_sections['y']['show']) {
+ $this->_sections['y']['total'] = $this->_sections['y']['loop'];
+ if ($this->_sections['y']['total'] == 0)
+ $this->_sections['y']['show'] = false;
+} else
+ $this->_sections['y']['total'] = 0;
+if ($this->_sections['y']['show']):
+
+ for ($this->_sections['y']['index'] = $this->_sections['y']['start'], $this->_sections['y']['iteration'] = 1;
+ $this->_sections['y']['iteration'] <= $this->_sections['y']['total'];
+ $this->_sections['y']['index'] += $this->_sections['y']['step'], $this->_sections['y']['iteration']++):
+$this->_sections['y']['rownum'] = $this->_sections['y']['iteration'];
+$this->_sections['y']['index_prev'] = $this->_sections['y']['index'] - $this->_sections['y']['step'];
+$this->_sections['y']['index_next'] = $this->_sections['y']['index'] + $this->_sections['y']['step'];
+$this->_sections['y']['first'] = ($this->_sections['y']['iteration'] == 1);
+$this->_sections['y']['last'] = ($this->_sections['y']['iteration'] == $this->_sections['y']['total']);
+?>
+ <tr valign="top" align="center">
+ <td>N/A</td>
+ <td><input type="text" size="10" name="new_sections[<?php echo $this->_tpl_vars['new_sections'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td><input type="text" size="10" name="new_sections[<?php echo $this->_tpl_vars['new_sections'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td><input type="text" size="40" name="new_sections[<?php echo $this->_tpl_vars['new_sections'][$this->_sections['y']['index']]['id']; ?>
+][]" value=""></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+<?php endfor; endif; ?>
+ <tr class="controls" align="center">
+ <td colspan="4">
+ <input type="submit" class="button" name="action" value="Submit"> <input type="reset" class="button" value="Reset">
+ </td>
+ <td colspan="2">
+ <input type="submit" class="button" name="action" value="Delete">
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <input type="hidden" name="object_type" value="<?php echo $this->_tpl_vars['object_type']; ?>
+">
+ <input type="hidden" name="return_page" value="<?php echo $this->_tpl_vars['return_page']; ?>
+">
+ </form>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%DA^DAC^DAC67802%%acl_test.tpl.php b/html/phpgacl/admin/templates_c/%%DA^DAC^DAC67802%%acl_test.tpl.php
new file mode 100644
index 0000000..3888ee1
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%DA^DAC^DAC67802%%acl_test.tpl.php
@@ -0,0 +1,38 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-21 11:54:41
+ compiled from phpgacl/acl_test.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+<body>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<br>
+<br>
+<br>
+<table align="center" cellpadding="2" cellspacing="2" border="2" width="50%">
+ <th colspan="2">
+ Which dimension of ACLs do you want to test?
+ </th>
+ <tr align="center">
+ <td>
+ [ <a href="acl_test2.php">2-dimensional ACLs</a> ]
+ </td>
+ <td>
+ [ <a href="acl_test3.php">3-dimensional ACLs</a> ]
+ </td>
+ </tr>
+</table>
+<br>
+<br>
+<br>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/templates_c/%%EB^EBC^EBCFAB96%%about.tpl.php b/html/phpgacl/admin/templates_c/%%EB^EBC^EBCFAB96%%about.tpl.php
new file mode 100644
index 0000000..6feb4a5
--- /dev/null
+++ b/html/phpgacl/admin/templates_c/%%EB^EBC^EBCFAB96%%about.tpl.php
@@ -0,0 +1,103 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-20 22:36:44
+ compiled from phpgacl/about.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/header.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ </head>
+ <body>
+ <?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/navigation.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+ <div style="text-align: center;">
+ <table cellpadding="2" cellspacing="2" border="2" align="center">
+ <tbody>
+ <?php if ($this->_tpl_vars['first_run'] != 1): ?>
+ <tr>
+ <th>
+ Help
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Please join the <a href="https://sourceforge.net/mail/?group_id=57103">Mailing Lists</a> if you have
+ any questions, comments, or support questions.
+ <p><b>TIP</b>: Searching the Mailing List archives may be a good idea prior to emailing the list, <br>
+ as well the below "Report" information may be helpful in any support questions.</p>
+ <p>PLEASE DO NOT EMAIL ME DIRECTLY REGARDING SUPPORT QUESTIONS<br />
+ You will receive answers faster on the mailing list, and any answers given may benefit others.</p>
+ But if you must email me (Mike Benoit) directly, click <a href="mailto:ipso@snappymail.ca">here</a>.
+ </td>
+ </tr>
+ <tr>
+ <th>
+ Donate
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Time working on phpGACL means less time that I can work to get paid.<br />
+ Therefore any donations I receive will help me to devote more time to developing phpGACL.
+ <p>However, I'd much rather donations in the form of code and/or documentation.</p>
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" align="center">
+ <input type="hidden" name="cmd" value="_xclick">
+ <input type="hidden" name="business" value="ipso@snappymail.ca">
+ <input type="hidden" name="item_name" value="php Generic Access Control List">
+ <input type="hidden" name="no_note" value="1">
+ <input type="hidden" name="currency_code" value="USD">
+ <input type="hidden" name="tax" value="0">
+ <input type="image" class="paypal" src="https://www.paypal.com/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
+ </form>
+ </td>
+ </tr>
+ <?php endif; ?>
+ <tr>
+ <th>
+ <?php if ($this->_tpl_vars['first_run'] != 1): ?>
+ Report
+ <?php else: ?>
+ <font color="#ff0000">* Report *</font>
+ <?php endif; ?>
+ </th>
+ </tr>
+ <tr>
+ <td>
+ Report some basic information back to the phpGACL project so we know where to spend our time.<br />
+ <b>All information will be kept private, will not be sold, and will only be used for informational purposes regarding phpGACL.</b>
+ <br /><br />
+ <form method="post" name="about" action="about.php" align="center">
+ <textarea name="system_information" rows="10" cols="60" wrap="VIRTUAL"><?php echo $this->_tpl_vars['system_info']; ?>
+</textarea>
+ <br />
+ <input type="hidden" name="system_info_md5" value="<?php echo $this->_tpl_vars['system_info_md5']; ?>
+" />
+ <input type="submit" name="action" value="Submit" />
+ </form>
+ </td>
+ </tr>
+ <?php if ($this->_tpl_vars['first_run'] != 1): ?>
+ <tr>
+ <th>
+ Credits
+ </th>
+ </tr>
+ <tr>
+ <td>
+<pre>
+<?php echo $this->_tpl_vars['credits']; ?>
+
+</pre>
+ </td>
+ </tr>
+ <?php endif; ?>
+ </tbody>
+ </table>
+ </div>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "phpgacl/footer.tpl", 'smarty_include_vars' => array()));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/phpgacl/admin/test.php b/html/phpgacl/admin/test.php
new file mode 100644
index 0000000..513019a
--- /dev/null
+++ b/html/phpgacl/admin/test.php
@@ -0,0 +1,422 @@
+<?php
+$debug=1;
+require_once("gacl_admin.inc.php");
+
+/*
+$test = $gacl->add_group_object(10, 'user','10');
+$gacl->showarray($test);
+
+$test = $gacl->add_group_object(10, 'user','10');
+$gacl->showarray($test);
+
+$test = $gacl->del_group_object(10, 'user','10');
+$gacl->showarray($test);
+
+$test = $gacl->del_group_object(10, 'user','10');
+$gacl->showarray($test);
+*/
+
+//$test = $gacl->acl_query('system','login','users','john_doe',NULL, NULL, NULL, NULL, TRUE);
+//showarray($test);
+
+/*
+$test = $gacl_api->get_group_objects(14,'ARO','RECURSE');
+showarray($test);
+
+$test = $gacl_api->get_group_objects(14,'ARO');
+showarray($test);
+*/
+/*
+$group_ids = array(14);
+$test = $gacl_api->acl_get_group_path($group_ids);
+showarray($test);
+$test = $gacl_api->get_group_objects(14,'ARO');
+showarray($test);
+*/
+
+//$gacl_api->clean_path_to_root(ARO);
+//$gacl_api->clean_path_to_root(AXO);
+
+/*
+$gacl_api->add_acl( array('system' => array('login', 'enabled', 'login')),
+ array('users' => array(1)),
+ array(10,12,10),
+ NULL,
+ NULL,
+ TRUE,
+ TRUE,
+ 666,
+ 'NOTE');
+*/
+/*
+
+$gacl_api->is_conflicting_acl(
+ array('system' => array('login')),
+ array('accounts' => array(1)),
+ array(99),
+ array('projects' => array(99)),
+ array(99));
+*/
+//$gacl_api->consolidated_edit_acl('system', 'add_pop','accounts',1, 99);
+
+//$gacl_api->search_acl('system','add_pop','accounts',1, 'Browsers','projects',5599,'Projects',99);
+
+/*
+$gacl_api->shift_acl( 18,
+ array('accounts' => array(1)),
+ array(14),
+ array('projects' => array(5599)),
+ array(23),
+ array('system' => array('add_pop'))
+ );
+*/
+/*
+$gacl_api->append_acl( 18,
+ array('accounts' => array(1,2,3,4)),
+ array(14),
+ array('projects' => array(5599)),
+ array(23),
+ array('system' => array('add_pop'))
+ );
+*/
+
+/*
+$gacl_api->add_acl( array('system' => array(99)),
+ array('accounts' => array(99)),
+ array(99),
+ array('projects' => array(99)),
+ array(99),
+ TRUE,
+ TRUE,
+ 666,
+ 'NOTE');
+*/
+
+//$rows = $rs->GetRows();
+//showarray($rows);
+
+
+/*
+$query = '
+ SELECT a.value AS a_value, a.name AS a_name,
+ b.value AS b_value, b.name AS b_name,
+ c.value AS c_value, c.name AS c_name,
+ d.value AS d_value, d.name AS d_name
+ FROM aco_sections a,
+ aco b,
+ aro_sections c,
+ aro d
+ WHERE a.value=b.section_value
+ AND c.value=d.section_value
+ ORDER BY a.value, b.value, c.value, d.value';
+//$rs = $db->Execute($query);
+//$rows = $rs->GetRows();
+$rs = $db->pageexecute($query, 100, 2);
+showarray($rows);
+$rows = $rs->GetRows();
+showarray($rows);
+*/
+
+//$test=$gacl-> acl_query('system', 'email_pw', 'users', '1');
+//showarray($test);
+
+//Test object deleting.
+//$gacl_api->del_object(10,'ARO', TRUE);
+//$gacl_api->del_object_section(10,'ACO',TRUE);
+
+/*
+//Test AXO's
+//function acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group_id=NULL, $root_axo_group_id=NULL) {
+$test1= acl_query('system','login','users', '1');
+showarray($test1);
+
+$test2=acl_query('system','login','users', '1','projects','1');
+showarray($test2);
+*/
+
+//Test subtree'ing
+/*
+$test=acl_get_groups('test_section2','user1',0);
+showarray($test);
+
+$test=acl_get_groups('test_section2','user1');
+showarray($test);
+*/
+
+/*
+//require_once('../Cache_Lite.php');
+require_once('./profiler.inc');
+$profiler = new Profiler(true,true);
+
+$options = array(
+ 'caching' => true,
+ 'cacheDir' => '/tmp/phpgacl_cache',
+ 'lifeTime' => 100
+);
+
+//$Cache_Lite = new Hashed_Cache_Lite($options);
+$Cache_Lite = new Cache_Lite($options);
+
+$data = '0123456789';
+$Cache_Lite->save($data,'123');
+
+$profiler->startTimer( "acl_query()");
+//Test memory caching.
+for ($i=0; $i < 2; $i++) {
+ //$Cache_Lite->save($data,'123'.$i);
+
+ $data = $Cache_Lite->get('123');
+ //echo "$data<br>\n";
+}
+$profiler->stopTimer( "acl_query()");
+
+$profiler->printTimers();
+*/
+/*
+//Test multi-layer ACOs
+$test = acl_query(array(21,19), 10);
+showarray($test);
+*/
+
+//Stress test.
+/*
+//Cleanup
+$aco_section_id = $gacl_api->get_aco_section_section_id("Stress Test");
+$del_aco_ids = $gacl_api->get_aco($aco_section_id);
+foreach ($del_aco_ids as $del_aco_id) {
+ $gacl_api->del_aco($del_aco_id);
+}
+$gacl_api->del_aco_section($aco_section_id);
+
+$aro_section_id = $gacl_api->get_aro_section_section_id("Stress Test");
+$del_aro_ids = $gacl_api->get_aro($aro_section_id);
+foreach ($del_aro_ids as $del_aro_id) {
+ $gacl_api->del_aro($del_aro_id);
+}
+$gacl_api->del_aro_section($aro_section_id);
+
+//Get all ACLs
+$query = "select id from acl";
+$rs = $db->GetCol($query);
+
+foreach($rs as $del_acl_id) {
+ $gacl_api->del_acl($del_acl_id);
+}
+*/
+
+/*
+$max_aco=10;
+$max_aro=50;
+
+$max_acl=100;
+$min_rand_aco=1;
+$max_rand_aco=9;
+$min_rand_aro=1;
+$max_rand_aro=9;
+
+//Seed random.
+srand ((float) microtime() * 10000000);
+
+//Grab ACO Section_id
+$aco_section_id = $gacl_api->get_aco_section_section_id("Stress Test");
+
+if (!$aco_section_id) {
+ //Add an ACO section.
+ $aco_section_id = $gacl_api->add_aco_section("Stress Test", 999,999);
+ $gacl_api->debug_text("Stress Test: ACO Section ID: $aco_section_id");
+}
+
+//Add 100 random ACO's
+if ($aco_section_id) {
+
+ for ($i=0; $i < $max_aco; $i++) {
+ $aco_id = $gacl_api->get_aco_id("Stress Test ACO #$i");
+
+ if (!$aco_id) {
+ //Add ACO.
+ $aco_id = $gacl_api->add_aco($aco_section_id, "Stress Test ACO #$i",$i, $i);
+ }
+ }
+}
+$aco_ids = $gacl_api->get_aco($aco_section_id);
+//showarray($aco_ids);
+
+//Grab ARO section id
+$aro_section_id = $gacl_api->get_aro_section_section_id("Stress Test");
+
+if (!$aro_section_id) {
+ //Add an ACO section.
+ $aro_section_id = $gacl_api->add_aro_section("Stress Test", 999,999);
+ $gacl_api->debug_text("Stress Test: ARO Section ID: $aro_section_id");
+}
+
+//Add 10,000 random ARO's
+if ($aro_section_id) {
+
+ for ($i=0; $i < $max_aro; $i++) {
+ $aro_id = $gacl_api->get_aro_id("Stress Test ARO #$i");
+
+ if (!$aro_id) {
+ //Add ARO.
+ $aro_id = $gacl_api->add_aro($aro_section_id, "Stress Test ARO #$i",$i, $i);
+ }
+ }
+}
+$aro_ids = $gacl_api->get_aro($aro_section_id);
+//showarray($aro_ids);
+
+//Create random ACL's using the above stress test ACO/AROs
+if (count($aco_ids) > 1 AND count($aro_ids) > 1) {
+ for ($i=0; $i < $max_acl; $i++) {
+ //Get random ACO IDS
+ $rand_aco_keys = array_rand($aco_ids, mt_rand($min_rand_aco, $max_rand_aco) );
+
+ unset($rand_aco_ids);
+ foreach ($rand_aco_keys as $rand_aco_key) {
+ $rand_aco_ids[] = $aco_ids[$rand_aco_key];
+ }
+
+ //Get random ARO IDS
+ $rand_aro_keys = array_rand($aro_ids, mt_rand($min_rand_aro, $max_rand_aro));
+
+ unset($rand_aro_ids);
+ foreach ($rand_aro_keys as $rand_aro_key) {
+ $rand_aro_ids[] = $aro_ids[$rand_aro_key];
+ }
+
+ //Random ALLOW
+ $allow = mt_rand(0,1);
+
+ $gacl_api->debug_text("Inserting ACL with ". count($rand_aco_ids) ." ACOs and ". count($rand_aro_ids) ." AROs - Allow: $allow");
+ $gacl_api->add_acl($rand_aco_ids, $rand_aro_ids, NULL, $allow, 1);
+ }
+}
+
+
+//Create much more Decoy data
+$max_aco=100;
+$max_aro=4000;
+
+$max_acl=1000;
+$min_rand_aco=1;
+$max_rand_aco=10;
+$min_rand_aro=1;
+$max_rand_aro=10;
+
+//Seed random.
+srand ((float) microtime() * 10000000);
+
+//Grab ACO Section_id
+$aco_section_id = $gacl_api->get_aco_section_section_id("Stress Test Decoy");
+
+if (!$aco_section_id) {
+ //Add an ACO section.
+ $aco_section_id = $gacl_api->add_aco_section("Stress Test Decoy", 1000,1000);
+ $gacl_api->debug_text("Stress Test: ACO Section ID: $aco_section_id");
+}
+
+//Add 100 random ACO's
+if ($aco_section_id) {
+
+ for ($i=0; $i < $max_aco; $i++) {
+ $aco_id = $gacl_api->get_aco_id("Stress Test Decoy ACO #$i");
+
+ if (!$aco_id) {
+ //Add ACO.
+ $aco_id = $gacl_api->add_aco($aco_section_id, "Stress Test ACO Decoy #$i",$i, $i);
+ }
+ }
+}
+$aco_ids = $gacl_api->get_aco($aco_section_id);
+//showarray($aco_ids);
+
+//Grab ARO section id
+$aro_section_id = $gacl_api->get_aro_section_section_id("Stress Test Decoy");
+
+if (!$aro_section_id) {
+ //Add an ACO section.
+ $aro_section_id = $gacl_api->add_aro_section("Stress Test Decoy", 1000,1000);
+ $gacl_api->debug_text("Stress Test: ARO Section ID: $aro_section_id");
+}
+
+//Add 10,000 random ARO's
+if ($aro_section_id) {
+
+ for ($i=0; $i < $max_aro; $i++) {
+ $aro_id = $gacl_api->get_aro_id("Stress Test Decoy ARO #$i");
+
+ if (!$aro_id) {
+ //Add ARO.
+ $aro_id = $gacl_api->add_aro($aro_section_id, "Stress Test Decoy ARO #$i",$i, $i);
+ }
+ }
+}
+$aro_ids = $gacl_api->get_aro($aro_section_id);
+//showarray($aro_ids);
+
+//Create random ACL's using the above stress test ACO/AROs
+if (count($aco_ids) > 1 AND count($aro_ids) > 1) {
+ for ($i=0; $i < $max_acl; $i++) {
+ //Get random ACO IDS
+ $rand_aco_keys = array_rand($aco_ids, mt_rand($min_rand_aco, $max_rand_aco) );
+
+ unset($rand_aco_ids);
+ foreach ($rand_aco_keys as $rand_aco_key) {
+ $rand_aco_ids[] = $aco_ids[$rand_aco_key];
+ }
+
+ //Get random ARO IDS
+ $rand_aro_keys = array_rand($aro_ids, mt_rand($min_rand_aro, $max_rand_aro));
+
+ unset($rand_aro_ids);
+ foreach ($rand_aro_keys as $rand_aro_key) {
+ $rand_aro_ids[] = $aro_ids[$rand_aro_key];
+ }
+
+ //Random ALLOW
+ $allow = mt_rand(0,1);
+
+ $gacl_api->debug_text("Inserting ACL with ". count($rand_aco_ids) ." ACOs and ". count($rand_aro_ids) ." AROs - Allow: $allow");
+ $gacl_api->add_acl($rand_aco_ids, $rand_aro_ids, NULL, $allow, 1);
+ }
+}
+*/
+
+
+
+
+
+
+
+/*
+//Test subtree'ing
+$aco_id=10;
+$aro_id=22;
+$root_group_id=30;
+
+$test=acl_query($aco_id,$aro_id,$root_group_id);
+showarray($test);
+
+$aco_id=10;
+$aro_id=22;
+$root_group_id=33;
+
+$test=acl_query($aco_id,$aro_id,$root_group_id);
+showarray($test);
+*/
+
+/*
+//Populate the ARO's
+$max_aros = 100;
+for ($i=0; $i < $max_aros; $i++) {
+
+ $aro_id = $gacl_api->add_aro(41,"$i First $i Last", $i, $i);
+
+ if ($aro_id) {
+ $gacl_api->debug_text("ARO ID: $aro_id");
+ } else {
+ $gacl_api->debug_text("Insert ARO ID FAILED!");
+ }
+}
+*/
+?>
diff --git a/html/phpgacl/adodb/adodb-csvlib.inc.php b/html/phpgacl/adodb/adodb-csvlib.inc.php
new file mode 100644
index 0000000..9ca9c1b
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-csvlib.inc.php
@@ -0,0 +1,312 @@
+<?php
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+global $ADODB_INCLUDED_CSV;
+$ADODB_INCLUDED_CSV = 1;
+
+/*
+
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for CSV serialization. This is used by the csv/proxy driver and is the
+ CacheExecute() serialization format.
+
+ ==== NOTE ====
+ Format documented at http://php.weblogs.com/ADODB_CSV
+ ==============
+*/
+
+ /**
+ * convert a recordset into special format
+ *
+ * @param rs the recordset
+ *
+ * @return the CSV formated data
+ */
+ function _rs2serialize(&$rs,$conn=false,$sql='')
+ {
+ $max = ($rs) ? $rs->FieldCount() : 0;
+
+ if ($sql) $sql = urlencode($sql);
+ // metadata setup
+
+ if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete
+ if (is_object($conn)) {
+ $sql .= ','.$conn->Affected_Rows();
+ $sql .= ','.$conn->Insert_ID();
+ } else
+ $sql .= ',,';
+
+ $text = "====-1,0,$sql\n";
+ return $text;
+ }
+ $tt = ($rs->timeCreated) ? $rs->timeCreated : time();
+
+ ## changed format from ====0 to ====1
+ $line = "====1,$tt,$sql\n";
+
+ if ($rs->databaseType == 'array') {
+ $rows =& $rs->_array;
+ } else {
+ $rows = array();
+ while (!$rs->EOF) {
+ $rows[] = $rs->fields;
+ $rs->MoveNext();
+ }
+ }
+
+ for($i=0; $i < $max; $i++) {
+ $o =& $rs->FetchField($i);
+ $flds[] = $o;
+ }
+
+ $savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
+ $class = $rs->connection->arrayClass;
+ $rs2 = new $class();
+ $rs2->sql = $rs->sql;
+ $rs2->oldProvider = $rs->dataProvider;
+ $rs2->InitArrayFields($rows,$flds);
+ $rs2->fetchMode = $savefetch;
+ return $line.serialize($rs2);
+ }
+
+
+/**
+* Open CSV file and convert it into Data.
+*
+* @param url file/ftp/http url
+* @param err returns the error message
+* @param timeout dispose if recordset has been alive for $timeout secs
+*
+* @return recordset, or false if error occured. If no
+* error occurred in sql INSERT/UPDATE/DELETE,
+* empty recordset is returned
+*/
+ function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
+ {
+ $false = false;
+ $err = false;
+ $fp = @fopen($url,'rb');
+ if (!$fp) {
+ $err = $url.' file/URL not found';
+ return $false;
+ }
+ @flock($fp, LOCK_SH);
+ $arr = array();
+ $ttl = 0;
+
+ if ($meta = fgetcsv($fp, 32000, ",")) {
+ // check if error message
+ if (strncmp($meta[0],'****',4) === 0) {
+ $err = trim(substr($meta[0],4,1024));
+ fclose($fp);
+ return $false;
+ }
+ // check for meta data
+ // $meta[0] is -1 means return an empty recordset
+ // $meta[1] contains a time
+
+ if (strncmp($meta[0], '====',4) === 0) {
+
+ if ($meta[0] == "====-1") {
+ if (sizeof($meta) < 5) {
+ $err = "Corrupt first line for format -1";
+ fclose($fp);
+ return $false;
+ }
+ fclose($fp);
+
+ if ($timeout > 0) {
+ $err = " Illegal Timeout $timeout ";
+ return $false;
+ }
+
+ $rs = new $rsclass($val=true);
+ $rs->fields = array();
+ $rs->timeCreated = $meta[1];
+ $rs->EOF = true;
+ $rs->_numOfFields = 0;
+ $rs->sql = urldecode($meta[2]);
+ $rs->affectedrows = (integer)$meta[3];
+ $rs->insertid = $meta[4];
+ return $rs;
+ }
+ # Under high volume loads, we want only 1 thread/process to _write_file
+ # so that we don't have 50 processes queueing to write the same data.
+ # We use probabilistic timeout, ahead of time.
+ #
+ # -4 sec before timeout, give processes 1/32 chance of timing out
+ # -2 sec before timeout, give processes 1/16 chance of timing out
+ # -1 sec after timeout give processes 1/4 chance of timing out
+ # +0 sec after timeout, give processes 100% chance of timing out
+ if (sizeof($meta) > 1) {
+ if($timeout >0){
+ $tdiff = (integer)( $meta[1]+$timeout - time());
+ if ($tdiff <= 2) {
+ switch($tdiff) {
+ case 4:
+ case 3:
+ if ((rand() & 31) == 0) {
+ fclose($fp);
+ $err = "Timeout 3";
+ return $false;
+ }
+ break;
+ case 2:
+ if ((rand() & 15) == 0) {
+ fclose($fp);
+ $err = "Timeout 2";
+ return $false;
+ }
+ break;
+ case 1:
+ if ((rand() & 3) == 0) {
+ fclose($fp);
+ $err = "Timeout 1";
+ return $false;
+ }
+ break;
+ default:
+ fclose($fp);
+ $err = "Timeout 0";
+ return $false;
+ } // switch
+
+ } // if check flush cache
+ }// (timeout>0)
+ $ttl = $meta[1];
+ }
+ //================================================
+ // new cache format - use serialize extensively...
+ if ($meta[0] === '====1') {
+ // slurp in the data
+ $MAXSIZE = 128000;
+
+ $text = fread($fp,$MAXSIZE);
+ if (strlen($text)) {
+ while ($txt = fread($fp,$MAXSIZE)) {
+ $text .= $txt;
+ }
+ }
+ fclose($fp);
+ $rs = unserialize($text);
+ if (is_object($rs)) $rs->timeCreated = $ttl;
+ else {
+ $err = "Unable to unserialize recordset";
+ //echo htmlspecialchars($text),' !--END--!<p>';
+ }
+ return $rs;
+ }
+
+ $meta = false;
+ $meta = fgetcsv($fp, 32000, ",");
+ if (!$meta) {
+ fclose($fp);
+ $err = "Unexpected EOF 1";
+ return $false;
+ }
+ }
+
+ // Get Column definitions
+ $flds = array();
+ foreach($meta as $o) {
+ $o2 = explode(':',$o);
+ if (sizeof($o2)!=3) {
+ $arr[] = $meta;
+ $flds = false;
+ break;
+ }
+ $fld = new ADOFieldObject();
+ $fld->name = urldecode($o2[0]);
+ $fld->type = $o2[1];
+ $fld->max_length = $o2[2];
+ $flds[] = $fld;
+ }
+ } else {
+ fclose($fp);
+ $err = "Recordset had unexpected EOF 2";
+ return $false;
+ }
+
+ // slurp in the data
+ $MAXSIZE = 128000;
+
+ $text = '';
+ while ($txt = fread($fp,$MAXSIZE)) {
+ $text .= $txt;
+ }
+
+ fclose($fp);
+ @$arr = unserialize($text);
+ //var_dump($arr);
+ if (!is_array($arr)) {
+ $err = "Recordset had unexpected EOF (in serialized recordset)";
+ if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!";
+ return $false;
+ }
+ $rs = new $rsclass();
+ $rs->timeCreated = $ttl;
+ $rs->InitArrayFields($arr,$flds);
+ return $rs;
+ }
+
+
+ /**
+ * Save a file $filename and its $contents (normally for caching) with file locking
+ */
+ function adodb_write_file($filename, $contents,$debug=false)
+ {
+ # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
+ # So to simulate locking, we assume that rename is an atomic operation.
+ # First we delete $filename, then we create a $tempfile write to it and
+ # rename to the desired $filename. If the rename works, then we successfully
+ # modified the file exclusively.
+ # What a stupid need - having to simulate locking.
+ # Risks:
+ # 1. $tempfile name is not unique -- very very low
+ # 2. unlink($filename) fails -- ok, rename will fail
+ # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
+ # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
+ if (strncmp(PHP_OS,'WIN',3) === 0) {
+ // skip the decimal place
+ $mtime = substr(str_replace(' ','_',microtime()),2);
+ // getmypid() actually returns 0 on Win98 - never mind!
+ $tmpname = $filename.uniqid($mtime).getmypid();
+ if (!($fd = @fopen($tmpname,'a'))) return false;
+ $ok = ftruncate($fd,0);
+ if (!fwrite($fd,$contents)) $ok = false;
+ fclose($fd);
+ chmod($tmpname,0644);
+ // the tricky moment
+ @unlink($filename);
+ if (!@rename($tmpname,$filename)) {
+ unlink($tmpname);
+ $ok = false;
+ }
+ if (!$ok) {
+ if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed'));
+ }
+ return $ok;
+ }
+ if (!($fd = @fopen($filename, 'a'))) return false;
+ if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) {
+ $ok = fwrite( $fd, $contents );
+ fclose($fd);
+ chmod($filename,0644);
+ }else {
+ fclose($fd);
+ if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
+ $ok = false;
+ }
+
+ return $ok;
+ }
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-datadict.inc.php b/html/phpgacl/adodb/adodb-datadict.inc.php
new file mode 100644
index 0000000..0c5efcd
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-datadict.inc.php
@@ -0,0 +1,778 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+ DOCUMENTATION:
+
+ See adodb/tests/test-datadict.php for docs and examples.
+*/
+
+/*
+ Test script for parser
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+function Lens_ParseTest()
+{
+$str = "`zcol ACOL` NUMBER(32,2) DEFAULT 'The \"cow\" (and Jim''s dog) jumps over the moon' PRIMARY, INTI INT AUTO DEFAULT 0, zcol2\"afs ds";
+print "<p>$str</p>";
+$a= Lens_ParseArgs($str);
+print "<pre>";
+print_r($a);
+print "</pre>";
+}
+
+
+if (!function_exists('ctype_alnum')) {
+ function ctype_alnum($text) {
+ return preg_match('/^[a-z0-9]*$/i', $text);
+ }
+}
+
+//Lens_ParseTest();
+
+/**
+ Parse arguments, treat "text" (text) and 'text' as quotation marks.
+ To escape, use "" or '' or ))
+
+ Will read in "abc def" sans quotes, as: abc def
+ Same with 'abc def'.
+ However if `abc def`, then will read in as `abc def`
+
+ @param endstmtchar Character that indicates end of statement
+ @param tokenchars Include the following characters in tokens apart from A-Z and 0-9
+ @returns 2 dimensional array containing parsed tokens.
+*/
+function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-')
+{
+ $pos = 0;
+ $intoken = false;
+ $stmtno = 0;
+ $endquote = false;
+ $tokens = array();
+ $tokens[$stmtno] = array();
+ $max = strlen($args);
+ $quoted = false;
+
+ while ($pos < $max) {
+ $ch = substr($args,$pos,1);
+ switch($ch) {
+ case ' ':
+ case "\t":
+ case "\n":
+ case "\r":
+ if (!$quoted) {
+ if ($intoken) {
+ $intoken = false;
+ $tokens[$stmtno][] = implode('',$tokarr);
+ }
+ break;
+ }
+
+ $tokarr[] = $ch;
+ break;
+
+ case '`':
+ if ($intoken) $tokarr[] = $ch;
+ case '(':
+ case ')':
+ case '"':
+ case "'":
+
+ if ($intoken) {
+ if (empty($endquote)) {
+ $tokens[$stmtno][] = implode('',$tokarr);
+ if ($ch == '(') $endquote = ')';
+ else $endquote = $ch;
+ $quoted = true;
+ $intoken = true;
+ $tokarr = array();
+ } else if ($endquote == $ch) {
+ $ch2 = substr($args,$pos+1,1);
+ if ($ch2 == $endquote) {
+ $pos += 1;
+ $tokarr[] = $ch2;
+ } else {
+ $quoted = false;
+ $intoken = false;
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $endquote = '';
+ }
+ } else
+ $tokarr[] = $ch;
+
+ }else {
+
+ if ($ch == '(') $endquote = ')';
+ else $endquote = $ch;
+ $quoted = true;
+ $intoken = true;
+ $tokarr = array();
+ if ($ch == '`') $tokarr[] = '`';
+ }
+ break;
+
+ default:
+
+ if (!$intoken) {
+ if ($ch == $endstmtchar) {
+ $stmtno += 1;
+ $tokens[$stmtno] = array();
+ break;
+ }
+
+ $intoken = true;
+ $quoted = false;
+ $endquote = false;
+ $tokarr = array();
+
+ }
+
+ if ($quoted) $tokarr[] = $ch;
+ else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch;
+ else {
+ if ($ch == $endstmtchar) {
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $stmtno += 1;
+ $tokens[$stmtno] = array();
+ $intoken = false;
+ $tokarr = array();
+ break;
+ }
+ $tokens[$stmtno][] = implode('',$tokarr);
+ $tokens[$stmtno][] = $ch;
+ $intoken = false;
+ }
+ }
+ $pos += 1;
+ }
+ if ($intoken) $tokens[$stmtno][] = implode('',$tokarr);
+
+ return $tokens;
+}
+
+
+class ADODB_DataDict {
+ var $connection;
+ var $debug = false;
+ var $dropTable = 'DROP TABLE %s';
+ var $renameTable = 'RENAME TABLE %s TO %s';
+ var $dropIndex = 'DROP INDEX %s';
+ var $addCol = ' ADD';
+ var $alterCol = ' ALTER COLUMN';
+ var $dropCol = ' DROP COLUMN';
+ var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default)
+ var $nameRegex = '\w';
+ var $nameRegexBrackets = 'a-zA-Z0-9_\(\)';
+ var $schema = false;
+ var $serverInfo = array();
+ var $autoIncrement = false;
+ var $dataProvider;
+ var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql
+ var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
+ /// in other words, we use a text area for editting.
+
+ function GetCommentSQL($table,$col)
+ {
+ return false;
+ }
+
+ function SetCommentSQL($table,$col,$cmt)
+ {
+ return false;
+ }
+
+ function MetaTables()
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaTables();
+ }
+
+ function MetaColumns($tab, $upper=true, $schema=false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema);
+ }
+
+ function MetaPrimaryKeys($tab,$owner=false,$intkey=false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey);
+ }
+
+ function MetaIndexes($table, $primary = false, $owner = false)
+ {
+ if (!$this->connection->IsConnected()) return array();
+ return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ return ADORecordSet::MetaType($t,$len,$fieldobj);
+ }
+
+ function NameQuote($name = NULL,$allowBrackets=false)
+ {
+ if (!is_string($name)) {
+ return FALSE;
+ }
+
+ $name = trim($name);
+
+ if ( !is_object($this->connection) ) {
+ return $name;
+ }
+
+ $quote = $this->connection->nameQuote;
+
+ // if name is of the form `name`, quote it
+ if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
+ return $quote . $matches[1] . $quote;
+ }
+
+ // if name contains special characters, quote it
+ $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex;
+
+ if ( !preg_match('/^[' . $regex . ']+$/', $name) ) {
+ return $quote . $name . $quote;
+ }
+
+ return $name;
+ }
+
+ function TableName($name)
+ {
+ if ( $this->schema ) {
+ return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name);
+ }
+ return $this->NameQuote($name);
+ }
+
+ // Executes the sql array returned by GetTableSQL and GetIndexSQL
+ function ExecuteSQLArray($sql, $continueOnError = true)
+ {
+ $rez = 2;
+ $conn = &$this->connection;
+ $saved = $conn->debug;
+ foreach($sql as $line) {
+
+ if ($this->debug) $conn->debug = true;
+ $ok = $conn->Execute($line);
+ $conn->debug = $saved;
+ if (!$ok) {
+ if ($this->debug) ADOConnection::outp($conn->ErrorMsg());
+ if (!$continueOnError) return 0;
+ $rez = 1;
+ }
+ }
+ return $rez;
+ }
+
+ /*
+ Returns the actual type given a character code.
+
+ C: varchar
+ X: CLOB (character large object) or largest varchar size if CLOB is not supported
+ C2: Multibyte varchar
+ X2: Multibyte CLOB
+
+ B: BLOB (binary large object)
+
+ D: Date
+ T: Date-time
+ L: Integer field suitable for storing booleans (0 or 1)
+ I: Integer
+ F: Floating point number
+ N: Numeric or decimal number
+ */
+
+ function ActualType($meta)
+ {
+ return $meta;
+ }
+
+ function CreateDatabase($dbname,$options=false)
+ {
+ $options = $this->_Options($options);
+ $sql = array();
+
+ $s = 'CREATE DATABASE ' . $this->NameQuote($dbname);
+ if (isset($options[$this->upperName]))
+ $s .= ' '.$options[$this->upperName];
+
+ $sql[] = $s;
+ return $sql;
+ }
+
+ /*
+ Generates the SQL to create index. Returns an array of sql strings.
+ */
+ function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false)
+ {
+ if (!is_array($flds)) {
+ $flds = explode(',',$flds);
+ }
+
+ foreach($flds as $key => $fld) {
+ # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32)
+ $flds[$key] = $this->NameQuote($fld,$allowBrackets=true);
+ }
+
+ return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions));
+ }
+
+ function DropIndexSQL ($idxname, $tabname = NULL)
+ {
+ return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname)));
+ }
+
+ function SetSchema($schema)
+ {
+ $this->schema = $schema;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+ foreach($lines as $v) {
+ $sql[] = $alter . $v;
+ }
+ return $sql;
+ }
+
+ /**
+ * Change the definition of one column
+ *
+ * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+ * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' ';
+ foreach($lines as $v) {
+ $sql[] = $alter . $v;
+ }
+ return $sql;
+ }
+
+ /**
+ * Rename one column
+ *
+ * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql)
+ * @param string $tabname table-name
+ * @param string $oldcolumn column-name to be renamed
+ * @param string $newcolumn new column-name
+ * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default=''
+ * @return array with SQL strings
+ */
+ function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if ($flds) {
+ list($lines,$pkey) = $this->_GenFields($flds);
+ list(,$first) = each($lines);
+ list(,$column_def) = split("[\t ]+",$first,2);
+ }
+ return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def));
+ }
+
+ /**
+ * Drop one column
+ *
+ * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default ''
+ * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ $sql = array();
+ $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' ';
+ foreach($flds as $v) {
+ $sql[] = $alter . $this->NameQuote($v);
+ }
+ return $sql;
+ }
+
+ function DropTableSQL($tabname)
+ {
+ return array (sprintf($this->dropTable, $this->TableName($tabname)));
+ }
+
+ function RenameTableSQL($tabname,$newname)
+ {
+ return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname)));
+ }
+
+ /*
+ Generate the SQL to create table. Returns an array of sql strings.
+ */
+ function CreateTableSQL($tabname, $flds, $tableoptions=false)
+ {
+ if (!$tableoptions) $tableoptions = array();
+
+ list($lines,$pkey) = $this->_GenFields($flds, true);
+
+ $taboptions = $this->_Options($tableoptions);
+ $tabname = $this->TableName ($tabname);
+ $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions);
+
+ $tsql = $this->_Triggers($tabname,$taboptions);
+ foreach($tsql as $s) $sql[] = $s;
+
+ return $sql;
+ }
+
+ function _GenFields($flds,$widespacing=false)
+ {
+ if (is_string($flds)) {
+ $padding = ' ';
+ $txt = $flds.$padding;
+ $flds = array();
+ $flds0 = Lens_ParseArgs($txt,',');
+ $hasparam = false;
+ foreach($flds0 as $f0) {
+ $f1 = array();
+ foreach($f0 as $token) {
+ switch (strtoupper($token)) {
+ case 'CONSTRAINT':
+ case 'DEFAULT':
+ $hasparam = $token;
+ break;
+ default:
+ if ($hasparam) $f1[$hasparam] = $token;
+ else $f1[] = $token;
+ $hasparam = false;
+ break;
+ }
+ }
+ $flds[] = $f1;
+
+ }
+ }
+ $this->autoIncrement = false;
+ $lines = array();
+ $pkey = array();
+ foreach($flds as $fld) {
+ $fld = _array_change_key_case($fld);
+
+ $fname = false;
+ $fdefault = false;
+ $fautoinc = false;
+ $ftype = false;
+ $fsize = false;
+ $fprec = false;
+ $fprimary = false;
+ $fnoquote = false;
+ $fdefts = false;
+ $fdefdate = false;
+ $fconstraint = false;
+ $fnotnull = false;
+ $funsigned = false;
+
+ //-----------------
+ // Parse attributes
+ foreach($fld as $attr => $v) {
+ if ($attr == 2 && is_numeric($v)) $attr = 'SIZE';
+ else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v);
+
+ switch($attr) {
+ case '0':
+ case 'NAME': $fname = $v; break;
+ case '1':
+ case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break;
+
+ case 'SIZE':
+ $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,',');
+ if ($dotat === false) $fsize = $v;
+ else {
+ $fsize = substr($v,0,$dotat);
+ $fprec = substr($v,$dotat+1);
+ }
+ break;
+ case 'UNSIGNED': $funsigned = true; break;
+ case 'AUTOINCREMENT':
+ case 'AUTO': $fautoinc = true; $fnotnull = true; break;
+ case 'KEY':
+ case 'PRIMARY': $fprimary = $v; $fnotnull = true; break;
+ case 'DEF':
+ case 'DEFAULT': $fdefault = $v; break;
+ case 'NOTNULL': $fnotnull = $v; break;
+ case 'NOQUOTE': $fnoquote = $v; break;
+ case 'DEFDATE': $fdefdate = $v; break;
+ case 'DEFTIMESTAMP': $fdefts = $v; break;
+ case 'CONSTRAINT': $fconstraint = $v; break;
+ } //switch
+ } // foreach $fld
+
+ //--------------------
+ // VALIDATE FIELD INFO
+ if (!strlen($fname)) {
+ if ($this->debug) ADOConnection::outp("Undefined NAME");
+ return false;
+ }
+
+ $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname));
+ $fname = $this->NameQuote($fname);
+
+ if (!strlen($ftype)) {
+ if ($this->debug) ADOConnection::outp("Undefined TYPE for field '$fname'");
+ return false;
+ } else {
+ $ftype = strtoupper($ftype);
+ }
+
+ $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec);
+
+ if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls
+
+ if ($fprimary) $pkey[] = $fname;
+
+ // some databases do not allow blobs to have defaults
+ if ($ty == 'X') $fdefault = false;
+
+ //--------------------
+ // CONSTRUCT FIELD SQL
+ if ($fdefts) {
+ if (substr($this->connection->databaseType,0,5) == 'mysql') {
+ $ftype = 'TIMESTAMP';
+ } else {
+ $fdefault = $this->connection->sysTimeStamp;
+ }
+ } else if ($fdefdate) {
+ if (substr($this->connection->databaseType,0,5) == 'mysql') {
+ $ftype = 'TIMESTAMP';
+ } else {
+ $fdefault = $this->connection->sysDate;
+ }
+ } else if ($fdefault !== false && !$fnoquote)
+ if ($ty == 'C' or $ty == 'X' or
+ ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault)))
+ if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ')
+ $fdefault = trim($fdefault);
+ else if (strtolower($fdefault) != 'null')
+ $fdefault = $this->connection->qstr($fdefault);
+ $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned);
+
+ if ($widespacing) $fname = str_pad($fname,24);
+ $lines[$fid] = $fname.' '.$ftype.$suffix;
+
+ if ($fautoinc) $this->autoIncrement = true;
+ } // foreach $flds
+
+ return array($lines,$pkey);
+ }
+ /*
+ GENERATE THE SIZE PART OF THE DATATYPE
+ $ftype is the actual type
+ $ty is the type defined originally in the DDL
+ */
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) {
+ $ftype .= "(".$fsize;
+ if (strlen($fprec)) $ftype .= ",".$fprec;
+ $ftype .= ')';
+ }
+ return $ftype;
+ }
+
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s .= '(' . $flds . ')';
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ function _DropAutoIncrement($tabname)
+ {
+ return false;
+ }
+
+ function _TableSQL($tabname,$lines,$pkey,$tableoptions)
+ {
+ $sql = array();
+
+ if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) {
+ $sql[] = sprintf($this->dropTable,$tabname);
+ if ($this->autoIncrement) {
+ $sInc = $this->_DropAutoIncrement($tabname);
+ if ($sInc) $sql[] = $sInc;
+ }
+ if ( isset ($tableoptions['DROP']) ) {
+ return $sql;
+ }
+ }
+ $s = "CREATE TABLE $tabname (\n";
+ $s .= implode(",\n", $lines);
+ if (sizeof($pkey)>0) {
+ $s .= ",\n PRIMARY KEY (";
+ $s .= implode(", ",$pkey).")";
+ }
+ if (isset($tableoptions['CONSTRAINTS']))
+ $s .= "\n".$tableoptions['CONSTRAINTS'];
+
+ if (isset($tableoptions[$this->upperName.'_CONSTRAINTS']))
+ $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS'];
+
+ $s .= "\n)";
+ if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName];
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ /*
+ GENERATE TRIGGERS IF NEEDED
+ used when table has auto-incrementing field that is emulated using triggers
+ */
+ function _Triggers($tabname,$taboptions)
+ {
+ return array();
+ }
+
+ /*
+ Sanitize options, so that array elements with no keys are promoted to keys
+ */
+ function _Options($opts)
+ {
+ if (!is_array($opts)) return array();
+ $newopts = array();
+ foreach($opts as $k => $v) {
+ if (is_numeric($k)) $newopts[strtoupper($v)] = $v;
+ else $newopts[strtoupper($k)] = $v;
+ }
+ return $newopts;
+ }
+
+ /*
+ "Florian Buzin [ easywe ]" <florian.buzin#easywe.de>
+
+ This function changes/adds new fields to your table. You don't
+ have to know if the col is new or not. It will check on its own.
+ */
+ function ChangeTableSQL($tablename, $flds, $tableoptions = false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false);
+
+ // check table exists
+ $save_handler = $this->connection->raiseErrorFn;
+ $this->connection->raiseErrorFn = '';
+ $cols = $this->MetaColumns($tablename);
+ $this->connection->raiseErrorFn = $save_handler;
+
+ if (isset($savem)) $this->connection->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ( empty($cols)) {
+ return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ }
+
+ if (is_array($flds)) {
+ // Cycle through the update fields, comparing
+ // existing fields to fields to update.
+ // if the Metatype and size is exactly the
+ // same, ignore - by Mark Newham
+ $holdflds = array();
+ foreach($flds as $k=>$v) {
+ if ( isset($cols[$k]) && is_object($cols[$k]) ) {
+ $c = $cols[$k];
+ $ml = $c->max_length;
+ $mt = &$this->MetaType($c->type,$ml);
+ if ($ml == -1) $ml = '';
+ if ($mt == 'X') $ml = $v['SIZE'];
+ if (($mt != $v['TYPE']) || $ml != $v['SIZE']) {
+ $holdflds[$k] = $v;
+ }
+ } else {
+ $holdflds[$k] = $v;
+ }
+ }
+ $flds = $holdflds;
+ }
+
+
+ // already exists, alter table instead
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $sql = array();
+
+ foreach ( $lines as $id => $v ) {
+ if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+
+ $flds = Lens_ParseArgs($v,',');
+
+ // We are trying to change the size of the field, if not allowed, simply ignore the request.
+ if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) continue;
+
+ $sql[] = $alter . $this->alterCol . ' ' . $v;
+ } else {
+ $sql[] = $alter . $this->addCol . ' ' . $v;
+ }
+ }
+
+ return $sql;
+ }
+} // class
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-error.inc.php b/html/phpgacl/adodb/adodb-error.inc.php
new file mode 100644
index 0000000..8d6e5ae
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-error.inc.php
@@ -0,0 +1,258 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * The following code is adapted from the PEAR DB error handling code.
+ * Portions (c)1997-2002 The PHP Group.
+ */
+
+
+if (!defined("DB_ERROR")) define("DB_ERROR",-1);
+
+if (!defined("DB_ERROR_SYNTAX")) {
+ define("DB_ERROR_SYNTAX", -2);
+ define("DB_ERROR_CONSTRAINT", -3);
+ define("DB_ERROR_NOT_FOUND", -4);
+ define("DB_ERROR_ALREADY_EXISTS", -5);
+ define("DB_ERROR_UNSUPPORTED", -6);
+ define("DB_ERROR_MISMATCH", -7);
+ define("DB_ERROR_INVALID", -8);
+ define("DB_ERROR_NOT_CAPABLE", -9);
+ define("DB_ERROR_TRUNCATED", -10);
+ define("DB_ERROR_INVALID_NUMBER", -11);
+ define("DB_ERROR_INVALID_DATE", -12);
+ define("DB_ERROR_DIVZERO", -13);
+ define("DB_ERROR_NODBSELECTED", -14);
+ define("DB_ERROR_CANNOT_CREATE", -15);
+ define("DB_ERROR_CANNOT_DELETE", -16);
+ define("DB_ERROR_CANNOT_DROP", -17);
+ define("DB_ERROR_NOSUCHTABLE", -18);
+ define("DB_ERROR_NOSUCHFIELD", -19);
+ define("DB_ERROR_NEED_MORE_DATA", -20);
+ define("DB_ERROR_NOT_LOCKED", -21);
+ define("DB_ERROR_VALUE_COUNT_ON_ROW", -22);
+ define("DB_ERROR_INVALID_DSN", -23);
+ define("DB_ERROR_CONNECT_FAILED", -24);
+ define("DB_ERROR_EXTENSION_NOT_FOUND",-25);
+ define("DB_ERROR_NOSUCHDB", -25);
+ define("DB_ERROR_ACCESS_VIOLATION", -26);
+}
+
+function adodb_errormsg($value)
+{
+global $ADODB_LANG,$ADODB_LANG_ARRAY;
+
+ if (empty($ADODB_LANG)) $ADODB_LANG = 'en';
+ if (isset($ADODB_LANG_ARRAY['LANG']) && $ADODB_LANG_ARRAY['LANG'] == $ADODB_LANG) ;
+ else {
+ include_once(ADODB_DIR."/lang/adodb-$ADODB_LANG.inc.php");
+ }
+ return isset($ADODB_LANG_ARRAY[$value]) ? $ADODB_LANG_ARRAY[$value] : $ADODB_LANG_ARRAY[DB_ERROR];
+}
+
+function adodb_error($provider,$dbType,$errno)
+{
+ //var_dump($errno);
+ if (is_numeric($errno) && $errno == 0) return 0;
+ switch($provider) {
+ case 'mysql': $map = adodb_error_mysql(); break;
+
+ case 'oracle':
+ case 'oci8': $map = adodb_error_oci8(); break;
+
+ case 'ibase': $map = adodb_error_ibase(); break;
+
+ case 'odbc': $map = adodb_error_odbc(); break;
+
+ case 'mssql':
+ case 'sybase': $map = adodb_error_mssql(); break;
+
+ case 'informix': $map = adodb_error_ifx(); break;
+
+ case 'postgres': return adodb_error_pg($errno); break;
+
+ case 'sqlite': return $map = adodb_error_sqlite(); break;
+ default:
+ return DB_ERROR;
+ }
+ //print_r($map);
+ //var_dump($errno);
+ if (isset($map[$errno])) return $map[$errno];
+ return DB_ERROR;
+}
+
+//**************************************************************************************
+
+function adodb_error_pg($errormsg)
+{
+ if (is_numeric($errormsg)) return (integer) $errormsg;
+ static $error_regexps = array(
+ '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => DB_ERROR_NOSUCHTABLE,
+ '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS,
+ '/divide by zero$/' => DB_ERROR_DIVZERO,
+ '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER,
+ '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD,
+ '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX,
+ '/referential integrity violation/' => DB_ERROR_CONSTRAINT,
+ '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/'
+ => DB_ERROR_ALREADY_EXISTS
+ );
+ reset($error_regexps);
+ while (list($regexp,$code) = each($error_regexps)) {
+ if (preg_match($regexp, $errormsg)) {
+ return $code;
+ }
+ }
+ // Fall back to DB_ERROR if there was no mapping.
+ return DB_ERROR;
+}
+
+function adodb_error_odbc()
+{
+static $MAP = array(
+ '01004' => DB_ERROR_TRUNCATED,
+ '07001' => DB_ERROR_MISMATCH,
+ '21S01' => DB_ERROR_MISMATCH,
+ '21S02' => DB_ERROR_MISMATCH,
+ '22003' => DB_ERROR_INVALID_NUMBER,
+ '22008' => DB_ERROR_INVALID_DATE,
+ '22012' => DB_ERROR_DIVZERO,
+ '23000' => DB_ERROR_CONSTRAINT,
+ '24000' => DB_ERROR_INVALID,
+ '34000' => DB_ERROR_INVALID,
+ '37000' => DB_ERROR_SYNTAX,
+ '42000' => DB_ERROR_SYNTAX,
+ 'IM001' => DB_ERROR_UNSUPPORTED,
+ 'S0000' => DB_ERROR_NOSUCHTABLE,
+ 'S0001' => DB_ERROR_NOT_FOUND,
+ 'S0002' => DB_ERROR_NOSUCHTABLE,
+ 'S0011' => DB_ERROR_ALREADY_EXISTS,
+ 'S0012' => DB_ERROR_NOT_FOUND,
+ 'S0021' => DB_ERROR_ALREADY_EXISTS,
+ 'S0022' => DB_ERROR_NOT_FOUND,
+ 'S1000' => DB_ERROR_NOSUCHTABLE,
+ 'S1009' => DB_ERROR_INVALID,
+ 'S1090' => DB_ERROR_INVALID,
+ 'S1C00' => DB_ERROR_NOT_CAPABLE
+ );
+ return $MAP;
+}
+
+function adodb_error_ibase()
+{
+static $MAP = array(
+ -104 => DB_ERROR_SYNTAX,
+ -150 => DB_ERROR_ACCESS_VIOLATION,
+ -151 => DB_ERROR_ACCESS_VIOLATION,
+ -155 => DB_ERROR_NOSUCHTABLE,
+ -157 => DB_ERROR_NOSUCHFIELD,
+ -158 => DB_ERROR_VALUE_COUNT_ON_ROW,
+ -170 => DB_ERROR_MISMATCH,
+ -171 => DB_ERROR_MISMATCH,
+ -172 => DB_ERROR_INVALID,
+ -204 => DB_ERROR_INVALID,
+ -205 => DB_ERROR_NOSUCHFIELD,
+ -206 => DB_ERROR_NOSUCHFIELD,
+ -208 => DB_ERROR_INVALID,
+ -219 => DB_ERROR_NOSUCHTABLE,
+ -297 => DB_ERROR_CONSTRAINT,
+ -530 => DB_ERROR_CONSTRAINT,
+ -803 => DB_ERROR_CONSTRAINT,
+ -551 => DB_ERROR_ACCESS_VIOLATION,
+ -552 => DB_ERROR_ACCESS_VIOLATION,
+ -922 => DB_ERROR_NOSUCHDB,
+ -923 => DB_ERROR_CONNECT_FAILED,
+ -924 => DB_ERROR_CONNECT_FAILED
+ );
+
+ return $MAP;
+}
+
+function adodb_error_ifx()
+{
+static $MAP = array(
+ '-201' => DB_ERROR_SYNTAX,
+ '-206' => DB_ERROR_NOSUCHTABLE,
+ '-217' => DB_ERROR_NOSUCHFIELD,
+ '-329' => DB_ERROR_NODBSELECTED,
+ '-1204' => DB_ERROR_INVALID_DATE,
+ '-1205' => DB_ERROR_INVALID_DATE,
+ '-1206' => DB_ERROR_INVALID_DATE,
+ '-1209' => DB_ERROR_INVALID_DATE,
+ '-1210' => DB_ERROR_INVALID_DATE,
+ '-1212' => DB_ERROR_INVALID_DATE
+ );
+
+ return $MAP;
+}
+
+function adodb_error_oci8()
+{
+static $MAP = array(
+ 1 => DB_ERROR_ALREADY_EXISTS,
+ 900 => DB_ERROR_SYNTAX,
+ 904 => DB_ERROR_NOSUCHFIELD,
+ 923 => DB_ERROR_SYNTAX,
+ 942 => DB_ERROR_NOSUCHTABLE,
+ 955 => DB_ERROR_ALREADY_EXISTS,
+ 1476 => DB_ERROR_DIVZERO,
+ 1722 => DB_ERROR_INVALID_NUMBER,
+ 2289 => DB_ERROR_NOSUCHTABLE,
+ 2291 => DB_ERROR_CONSTRAINT,
+ 2449 => DB_ERROR_CONSTRAINT
+ );
+
+ return $MAP;
+}
+
+function adodb_error_mssql()
+{
+static $MAP = array(
+ 208 => DB_ERROR_NOSUCHTABLE,
+ 2601 => DB_ERROR_ALREADY_EXISTS
+ );
+
+ return $MAP;
+}
+
+function adodb_error_sqlite()
+{
+static $MAP = array(
+ 1 => DB_ERROR_SYNTAX
+ );
+
+ return $MAP;
+}
+
+function adodb_error_mysql()
+{
+static $MAP = array(
+ 1004 => DB_ERROR_CANNOT_CREATE,
+ 1005 => DB_ERROR_CANNOT_CREATE,
+ 1006 => DB_ERROR_CANNOT_CREATE,
+ 1007 => DB_ERROR_ALREADY_EXISTS,
+ 1008 => DB_ERROR_CANNOT_DROP,
+ 1045 => DB_ERROR_ACCESS_VIOLATION,
+ 1046 => DB_ERROR_NODBSELECTED,
+ 1049 => DB_ERROR_NOSUCHDB,
+ 1050 => DB_ERROR_ALREADY_EXISTS,
+ 1051 => DB_ERROR_NOSUCHTABLE,
+ 1054 => DB_ERROR_NOSUCHFIELD,
+ 1062 => DB_ERROR_ALREADY_EXISTS,
+ 1064 => DB_ERROR_SYNTAX,
+ 1100 => DB_ERROR_NOT_LOCKED,
+ 1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
+ 1146 => DB_ERROR_NOSUCHTABLE,
+ 1048 => DB_ERROR_CONSTRAINT,
+ 2002 => DB_ERROR_CONNECT_FAILED,
+ 2005 => DB_ERROR_CONNECT_FAILED
+ );
+
+ return $MAP;
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-errorhandler.inc.php b/html/phpgacl/adodb/adodb-errorhandler.inc.php
new file mode 100644
index 0000000..a6f92d5
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-errorhandler.inc.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+*/
+
+
+// added Claudio Bustos clbustos#entelchile.net
+if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
+
+if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
+
+/**
+* Default Error Handler. This will be called with the following params
+*
+* @param $dbms the RDBMS you are connecting to
+* @param $fn the name of the calling function (in uppercase)
+* @param $errno the native error number from the database
+* @param $errmsg the native error msg from the database
+* @param $p1 $fn specific parameter - see below
+* @param $p2 $fn specific parameter - see below
+* @param $thisConn $current connection object - can be false if no connection object created
+*/
+function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
+{
+ if (error_reporting() == 0) return; // obey @ protocol
+ switch($fn) {
+ case 'EXECUTE':
+ $sql = $p1;
+ $inputparams = $p2;
+
+ $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
+ break;
+
+ case 'PCONNECT':
+ case 'CONNECT':
+ $host = $p1;
+ $database = $p2;
+
+ $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
+ break;
+ default:
+ $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
+ break;
+ }
+ /*
+ * Log connection error somewhere
+ * 0 message is sent to PHP's system logger, using the Operating System's system
+ * logging mechanism or a file, depending on what the error_log configuration
+ * directive is set to.
+ * 1 message is sent by email to the address in the destination parameter.
+ * This is the only message type where the fourth parameter, extra_headers is used.
+ * This message type uses the same internal function as mail() does.
+ * 2 message is sent through the PHP debugging connection.
+ * This option is only available if remote debugging has been enabled.
+ * In this case, the destination parameter specifies the host name or IP address
+ * and optionally, port number, of the socket receiving the debug information.
+ * 3 message is appended to the file destination
+ */
+ if (defined('ADODB_ERROR_LOG_TYPE')) {
+ $t = date('Y-m-d H:i:s');
+ if (defined('ADODB_ERROR_LOG_DEST'))
+ error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
+ else
+ error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
+ }
+
+
+ //print "<p>$s</p>";
+ trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
+}
+?>
diff --git a/html/phpgacl/adodb/adodb-errorpear.inc.php b/html/phpgacl/adodb/adodb-errorpear.inc.php
new file mode 100644
index 0000000..011e9a6
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-errorpear.inc.php
@@ -0,0 +1,88 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+*/
+include_once('PEAR.php');
+
+if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
+
+/*
+* Enabled the following if you want to terminate scripts when an error occurs
+*/
+//PEAR::setErrorHandling (PEAR_ERROR_DIE);
+
+/*
+* Name of the PEAR_Error derived class to call.
+*/
+if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
+
+/*
+* Store the last PEAR_Error object here
+*/
+global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
+
+ /**
+* Error Handler with PEAR support. This will be called with the following params
+*
+* @param $dbms the RDBMS you are connecting to
+* @param $fn the name of the calling function (in uppercase)
+* @param $errno the native error number from the database
+* @param $errmsg the native error msg from the database
+* @param $p1 $fn specific parameter - see below
+* @param $P2 $fn specific parameter - see below
+ */
+function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
+{
+global $ADODB_Last_PEAR_Error;
+
+ if (error_reporting() == 0) return; // obey @ protocol
+ switch($fn) {
+ case 'EXECUTE':
+ $sql = $p1;
+ $inputparams = $p2;
+
+ $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
+ break;
+
+ case 'PCONNECT':
+ case 'CONNECT':
+ $host = $p1;
+ $database = $p2;
+
+ $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
+ break;
+
+ default:
+ $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
+ break;
+ }
+
+ $class = ADODB_PEAR_ERROR_CLASS;
+ $ADODB_Last_PEAR_Error = new $class($s, $errno,
+ $GLOBALS['_PEAR_default_error_mode'],
+ $GLOBALS['_PEAR_default_error_options'],
+ $errmsg);
+
+ //print "<p>!$s</p>";
+}
+
+/**
+* Returns last PEAR_Error object. This error might be for an error that
+* occured several sql statements ago.
+*/
+function &ADODB_PEAR_Error()
+{
+global $ADODB_Last_PEAR_Error;
+
+ return $ADODB_Last_PEAR_Error;
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-exceptions.inc.php b/html/phpgacl/adodb/adodb-exceptions.inc.php
new file mode 100644
index 0000000..693b049
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-exceptions.inc.php
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Exception-handling code using PHP5 exceptions (try-catch-throw).
+ */
+
+
+if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
+define('ADODB_ERROR_HANDLER','adodb_throw');
+
+class ADODB_Exception extends Exception {
+var $dbms;
+var $fn;
+var $sql = '';
+var $params = '';
+var $host = '';
+var $database = '';
+
+ function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
+ {
+ switch($fn) {
+ case 'EXECUTE':
+ $this->sql = $p1;
+ $this->params = $p2;
+ $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
+ break;
+
+ case 'PCONNECT':
+ case 'CONNECT':
+ $user = $thisConnection->user;
+ $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
+ break;
+ default:
+ $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
+ break;
+ }
+
+ $this->dbms = $dbms;
+ $this->host = $thisConnection->host;
+ $this->database = $thisConnection->database;
+ $this->fn = $fn;
+ $this->msg = $errmsg;
+
+ if (!is_numeric($errno)) $errno = -1;
+ parent::__construct($s,$errno);
+ }
+}
+
+/**
+* Default Error Handler. This will be called with the following params
+*
+* @param $dbms the RDBMS you are connecting to
+* @param $fn the name of the calling function (in uppercase)
+* @param $errno the native error number from the database
+* @param $errmsg the native error msg from the database
+* @param $p1 $fn specific parameter - see below
+* @param $P2 $fn specific parameter - see below
+*/
+
+function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
+{
+global $ADODB_EXCEPTION;
+
+ if (error_reporting() == 0) return; // obey @ protocol
+ if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
+ else $errfn = 'ADODB_EXCEPTION';
+ throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-iterator.inc.php b/html/phpgacl/adodb/adodb-iterator.inc.php
new file mode 100644
index 0000000..a7126dd
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-iterator.inc.php
@@ -0,0 +1,84 @@
+<?php
+
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4.
+
+ Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
+ the ADODB_Iterator class.
+
+ $rs = $db->Execute("select * from adoxyz");
+ foreach($rs as $k => $v) {
+ echo $k; print_r($v); echo "<br>";
+ }
+
+
+ Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
+ */
+
+
+ class ADODB_Iterator implements Iterator {
+
+ private $rs;
+
+ function __construct($rs)
+ {
+ $this->rs = $rs;
+ }
+ function rewind()
+ {
+ $this->rs->MoveFirst();
+ }
+
+ function valid()
+ {
+ return !$this->rs->EOF;
+ }
+
+ function key()
+ {
+ return $this->rs->_currentRow;
+ }
+
+ function current()
+ {
+ return $this->rs->fields;
+ }
+
+ function next()
+ {
+ $this->rs->MoveNext();
+ }
+
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->rs, $func), $params);
+ }
+
+
+ function hasMore()
+ {
+ return !$this->rs->EOF;
+ }
+
+}
+
+
+class ADODB_BASE_RS implements IteratorAggregate {
+ function getIterator() {
+ return new ADODB_Iterator($this);
+ }
+
+ /* this is experimental - i don't really know what to return... */
+ function __toString()
+ {
+ include_once(ADODB_DIR.'/toexport.inc.php');
+ return _adodb_export($this,',',',',false,true);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-lib.inc.php b/html/phpgacl/adodb/adodb-lib.inc.php
new file mode 100644
index 0000000..b7fb8d2
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-lib.inc.php
@@ -0,0 +1,1002 @@
+<?php
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+global $ADODB_INCLUDED_LIB;
+$ADODB_INCLUDED_LIB = 1;
+
+/*
+ @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim\@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Less commonly used functions are placed here to reduce size of adodb.inc.php.
+*/
+
+
+// Force key to upper.
+// See also http://www.php.net/manual/en/function.array-change-key-case.php
+function _array_change_key_case($an_array)
+{
+ if (is_array($an_array)) {
+ $new_array = array();
+ foreach($an_array as $key=>$value)
+ $new_array[strtoupper($key)] = $value;
+
+ return $new_array;
+ }
+
+ return $an_array;
+}
+
+function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc)
+{
+ if (count($fieldArray) == 0) return 0;
+ $first = true;
+ $uSet = '';
+
+ if (!is_array($keyCol)) {
+ $keyCol = array($keyCol);
+ }
+ foreach($fieldArray as $k => $v) {
+ if ($autoQuote && !is_numeric($v) and strncmp($v,"'",1) !== 0 and strcasecmp($v,'null')!=0) {
+ $v = $zthis->qstr($v);
+ $fieldArray[$k] = $v;
+ }
+ if (in_array($k,$keyCol)) continue; // skip UPDATE if is key
+
+ if ($first) {
+ $first = false;
+ $uSet = "$k=$v";
+ } else
+ $uSet .= ",$k=$v";
+ }
+
+ $where = false;
+ foreach ($keyCol as $v) {
+ if ($where) $where .= " and $v=$fieldArray[$v]";
+ else $where = "$v=$fieldArray[$v]";
+ }
+
+ if ($uSet && $where) {
+ $update = "UPDATE $table SET $uSet WHERE $where";
+
+ $rs = $zthis->Execute($update);
+
+
+ if ($rs) {
+ if ($zthis->poorAffectedRows) {
+ /*
+ The Select count(*) wipes out any errors that the update would have returned.
+ http://phplens.com/lens/lensforum/msgs.php?id=5696
+ */
+ if ($zthis->ErrorNo()<>0) return 0;
+
+ # affected_rows == 0 if update field values identical to old values
+ # for mysql - which is silly.
+
+ $cnt = $zthis->GetOne("select count(*) from $table where $where");
+ if ($cnt > 0) return 1; // record already exists
+ } else {
+ if (($zthis->Affected_Rows()>0)) return 1;
+ }
+ } else
+ return 0;
+ }
+
+ // print "<p>Error=".$this->ErrorNo().'<p>';
+ $first = true;
+ foreach($fieldArray as $k => $v) {
+ if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col
+
+ if ($first) {
+ $first = false;
+ $iCols = "$k";
+ $iVals = "$v";
+ } else {
+ $iCols .= ",$k";
+ $iVals .= ",$v";
+ }
+ }
+ $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)";
+ $rs = $zthis->Execute($insert);
+ return ($rs) ? 2 : 0;
+}
+
+// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
+function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
+ $size=0, $selectAttr='',$compareFields0=true)
+{
+ $hasvalue = false;
+
+ if ($multiple or is_array($defstr)) {
+ if ($size==0) $size=5;
+ $attr = ' multiple size="'.$size.'"';
+ if (!strpos($name,'[]')) $name .= '[]';
+ } else if ($size) $attr = ' size="'.$size.'"';
+ else $attr ='';
+
+ $s = '<select name="'.$name.'"'.$attr.' '.$selectAttr.'>';
+ if ($blank1stItem)
+ if (is_string($blank1stItem)) {
+ $barr = explode(':',$blank1stItem);
+ if (sizeof($barr) == 1) $barr[] = '';
+ $s .= "\n<option value=\"".$barr[0]."\">".$barr[1]."</option>";
+ } else $s .= "\n<option></option>";
+
+ if ($zthis->FieldCount() > 1) $hasvalue=true;
+ else $compareFields0 = true;
+
+ $value = '';
+ $optgroup = null;
+ $firstgroup = true;
+ $fieldsize = $zthis->FieldCount();
+ while(!$zthis->EOF) {
+ $zval = rtrim(reset($zthis->fields));
+
+ if ($blank1stItem && $zval=="") {
+ $zthis->MoveNext();
+ continue;
+ }
+
+ if ($fieldsize > 1) {
+ if (isset($zthis->fields[1]))
+ $zval2 = rtrim($zthis->fields[1]);
+ else
+ $zval2 = rtrim(next($zthis->fields));
+ }
+ $selected = ($compareFields0) ? $zval : $zval2;
+
+ $group = '';
+ if ($fieldsize > 2) {
+ $group = rtrim($zthis->fields[2]);
+ }
+
+ if ($optgroup != $group) {
+ $optgroup = $group;
+ if ($firstgroup) {
+ $firstgroup = false;
+ $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
+ } else {
+ $s .="\n</optgroup>";
+ $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
+ }
+ }
+
+ if ($hasvalue)
+ $value = " value='".htmlspecialchars($zval2)."'";
+
+ if (is_array($defstr)) {
+
+ if (in_array($selected,$defstr))
+ $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
+ else
+ $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
+ }
+ else {
+ if (strcasecmp($selected,$defstr)==0)
+ $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
+ else
+ $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
+ }
+ $zthis->MoveNext();
+ } // while
+
+ // closing last optgroup
+ if($optgroup != null) {
+ $s .= "\n</optgroup>";
+ }
+ return $s ."\n</select>\n";
+}
+
+// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
+function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
+ $size=0, $selectAttr='',$compareFields0=true)
+{
+ $hasvalue = false;
+
+ if ($multiple or is_array($defstr)) {
+ if ($size==0) $size=5;
+ $attr = ' multiple size="'.$size.'"';
+ if (!strpos($name,'[]')) $name .= '[]';
+ } else if ($size) $attr = ' size="'.$size.'"';
+ else $attr ='';
+
+ $s = '<select name="'.$name.'"'.$attr.' '.$selectAttr.'>';
+ if ($blank1stItem)
+ if (is_string($blank1stItem)) {
+ $barr = explode(':',$blank1stItem);
+ if (sizeof($barr) == 1) $barr[] = '';
+ $s .= "\n<option value=\"".$barr[0]."\">".$barr[1]."</option>";
+ } else $s .= "\n<option></option>";
+
+ if ($zthis->FieldCount() > 1) $hasvalue=true;
+ else $compareFields0 = true;
+
+ $value = '';
+ $optgroup = null;
+ $firstgroup = true;
+ $fieldsize = sizeof($zthis->fields);
+ while(!$zthis->EOF) {
+ $zval = rtrim(reset($zthis->fields));
+
+ if ($blank1stItem && $zval=="") {
+ $zthis->MoveNext();
+ continue;
+ }
+
+ if ($fieldsize > 1) {
+ if (isset($zthis->fields[1]))
+ $zval2 = rtrim($zthis->fields[1]);
+ else
+ $zval2 = rtrim(next($zthis->fields));
+ }
+ $selected = ($compareFields0) ? $zval : $zval2;
+
+ $group = '';
+ if (isset($zthis->fields[2])) {
+ $group = rtrim($zthis->fields[2]);
+ }
+
+ if ($optgroup != $group) {
+ $optgroup = $group;
+ if ($firstgroup) {
+ $firstgroup = false;
+ $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
+ } else {
+ $s .="\n</optgroup>";
+ $s .="\n<optgroup label='". htmlspecialchars($group) ."'>";
+ }
+ }
+
+ if ($hasvalue)
+ $value = " value='".htmlspecialchars($zval2)."'";
+
+ if (is_array($defstr)) {
+
+ if (in_array($selected,$defstr))
+ $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
+ else
+ $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
+ }
+ else {
+ if (strcasecmp($selected,$defstr)==0)
+ $s .= "\n<option selected='selected'$value>".htmlspecialchars($zval).'</option>';
+ else
+ $s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
+ }
+ $zthis->MoveNext();
+ } // while
+
+ // closing last optgroup
+ if($optgroup != null) {
+ $s .= "\n</optgroup>";
+ }
+ return $s ."\n</select>\n";
+}
+
+
+/*
+ Count the number of records this sql statement will return by using
+ query rewriting techniques...
+
+ Does not work with UNIONs, except with postgresql and oracle.
+*/
+function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0)
+{
+ $qryRecs = 0;
+
+ if (preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) ||
+ preg_match('/\s+GROUP\s+BY\s+/is',$sql) ||
+ preg_match('/\s+UNION\s+/is',$sql)) {
+ // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias
+ // but this is only supported by oracle and postgresql...
+ if ($zthis->dataProvider == 'oci8') {
+
+ $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
+
+ // Allow Oracle hints to be used for query optimization, Chris Wrye
+ if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) {
+ $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")";
+ } else
+ $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")";
+
+ } else if (strncmp($zthis->databaseType,'postgres',8) == 0) {
+
+ $info = $zthis->ServerInfo();
+ if (substr($info['version'],0,3) >= 7.1) { // good till version 999
+ $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$sql);
+ $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_";
+ }
+ }
+ } else {
+ // now replace SELECT ... FROM with SELECT COUNT(*) FROM
+ $rewritesql = preg_replace(
+ '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql);
+
+ // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
+ // with mssql, access and postgresql. Also a good speedup optimization - skips sorting!
+ $rewritesql = preg_replace('/(\sORDER\s+BY\s[^)]*)/is','',$rewritesql);
+ }
+
+ if (isset($rewritesql) && $rewritesql != $sql) {
+ if ($secs2cache) {
+ // we only use half the time of secs2cache because the count can quickly
+ // become inaccurate if new records are added
+ $qryRecs = $zthis->CacheGetOne($secs2cache/2,$rewritesql,$inputarr);
+
+ } else {
+ $qryRecs = $zthis->GetOne($rewritesql,$inputarr);
+ }
+ if ($qryRecs !== false) return $qryRecs;
+ }
+ //--------------------------------------------
+ // query rewrite failed - so try slower way...
+
+
+ // strip off unneeded ORDER BY if no UNION
+ if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql;
+ else $rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$sql);
+
+ $rstest = &$zthis->Execute($rewritesql,$inputarr);
+ if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr);
+
+ if ($rstest) {
+ $qryRecs = $rstest->RecordCount();
+ if ($qryRecs == -1) {
+ global $ADODB_EXTENSION;
+ // some databases will return -1 on MoveLast() - change to MoveNext()
+ if ($ADODB_EXTENSION) {
+ while(!$rstest->EOF) {
+ adodb_movenext($rstest);
+ }
+ } else {
+ while(!$rstest->EOF) {
+ $rstest->MoveNext();
+ }
+ }
+ $qryRecs = $rstest->_currentRow;
+ }
+ $rstest->Close();
+ if ($qryRecs == -1) return 0;
+ }
+
+ return $qryRecs;
+}
+
+/*
+ Code originally from "Cornel G" <conyg@fx.ro>
+
+ This code might not work with SQL that has UNION in it
+
+ Also if you are using CachePageExecute(), there is a strong possibility that
+ data will get out of synch. use CachePageExecute() only with tables that
+ rarely change.
+*/
+function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page,
+ $inputarr=false, $secs2cache=0)
+{
+ $atfirstpage = false;
+ $atlastpage = false;
+ $lastpageno=1;
+
+ // If an invalid nrows is supplied,
+ // we assume a default value of 10 rows per page
+ if (!isset($nrows) || $nrows <= 0) $nrows = 10;
+
+ $qryRecs = false; //count records for no offset
+
+ $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache);
+ $lastpageno = (int) ceil($qryRecs / $nrows);
+ $zthis->_maxRecordCount = $qryRecs;
+
+
+
+ // ***** Here we check whether $page is the last page or
+ // whether we are trying to retrieve
+ // a page number greater than the last page number.
+ if ($page >= $lastpageno) {
+ $page = $lastpageno;
+ $atlastpage = true;
+ }
+
+ // If page number <= 1, then we are at the first page
+ if (empty($page) || $page <= 1) {
+ $page = 1;
+ $atfirstpage = true;
+ }
+
+ // We get the data we want
+ $offset = $nrows * ($page-1);
+ if ($secs2cache > 0)
+ $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr);
+ else
+ $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
+
+
+ // Before returning the RecordSet, we set the pagination properties we need
+ if ($rsreturn) {
+ $rsreturn->_maxRecordCount = $qryRecs;
+ $rsreturn->rowsPerPage = $nrows;
+ $rsreturn->AbsolutePage($page);
+ $rsreturn->AtFirstPage($atfirstpage);
+ $rsreturn->AtLastPage($atlastpage);
+ $rsreturn->LastPageNo($lastpageno);
+ }
+ return $rsreturn;
+}
+
+// Iván Oliva version
+function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0)
+{
+
+ $atfirstpage = false;
+ $atlastpage = false;
+
+ if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page
+ $page = 1;
+ $atfirstpage = true;
+ }
+ if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page
+
+ // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than
+ // the last page number.
+ $pagecounter = $page + 1;
+ $pagecounteroffset = ($pagecounter * $nrows) - $nrows;
+ if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
+ else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
+ if ($rstest) {
+ while ($rstest && $rstest->EOF && $pagecounter>0) {
+ $atlastpage = true;
+ $pagecounter--;
+ $pagecounteroffset = $nrows * ($pagecounter - 1);
+ $rstest->Close();
+ if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr);
+ else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache);
+ }
+ if ($rstest) $rstest->Close();
+ }
+ if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it
+ $page = $pagecounter;
+ if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first
+ //... page, that is, the recordset has only 1 page.
+ }
+
+ // We get the data we want
+ $offset = $nrows * ($page-1);
+ if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr);
+ else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache);
+
+ // Before returning the RecordSet, we set the pagination properties we need
+ if ($rsreturn) {
+ $rsreturn->rowsPerPage = $nrows;
+ $rsreturn->AbsolutePage($page);
+ $rsreturn->AtFirstPage($atfirstpage);
+ $rsreturn->AtLastPage($atlastpage);
+ }
+ return $rsreturn;
+}
+
+function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2)
+{
+ if (!$rs) {
+ printf(ADODB_BAD_RS,'GetUpdateSQL');
+ return false;
+ }
+
+ $fieldUpdatedCount = 0;
+ $arrFields = _array_change_key_case($arrFields);
+
+ $hasnumeric = isset($rs->fields[0]);
+ $setFields = '';
+
+ // Loop through all of the fields in the recordset
+ for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
+ // Get the field from the recordset
+ $field = $rs->FetchField($i);
+
+ // If the recordset field is one
+ // of the fields passed in then process.
+ $upperfname = strtoupper($field->name);
+ if (adodb_key_exists($upperfname,$arrFields,$force)) {
+
+ // If the existing field value in the recordset
+ // is different from the value passed in then
+ // go ahead and append the field name and new value to
+ // the update query.
+
+ if ($hasnumeric) $val = $rs->fields[$i];
+ else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname];
+ else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name];
+ else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)];
+ else $val = '';
+
+
+ if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) {
+ // Set the counter for the number of fields that will be updated.
+ $fieldUpdatedCount++;
+
+ // Based on the datatype of the field
+ // Format the value properly for the database
+ $type = $rs->MetaType($field->type);
+
+
+ if ($type == 'null') {
+ $type = 'C';
+ }
+
+ if (strpos($upperfname,' ') !== false)
+ $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
+ else
+ $fnameq = $upperfname;
+
+
+ // is_null requires php 4.0.4
+ //********************************************************//
+ if (is_null($arrFields[$upperfname])
+ || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
+ || $arrFields[$upperfname] === 'null'
+ )
+ {
+ switch ($force) {
+
+ //case 0:
+ // //Ignore empty values. This is allready handled in "adodb_key_exists" function.
+ //break;
+
+ case 1:
+ //Set null
+ $setFields .= $field->name . " = null, ";
+ break;
+
+ case 2:
+ //Set empty
+ $arrFields[$upperfname] = "";
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ break;
+ default:
+ case 3:
+ //Set the value that was given in array, so you can give both null and empty values
+ if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') {
+ $setFields .= $field->name . " = null, ";
+ } else {
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ }
+ break;
+ }
+ //********************************************************//
+ } else {
+ //we do this so each driver can customize the sql for
+ //DB specific column types.
+ //Oracle needs BLOB types to be handled with a returning clause
+ //postgres has special needs as well
+ $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,
+ $arrFields, $magicq);
+ }
+ }
+ }
+ }
+
+ // If there were any modified fields then build the rest of the update query.
+ if ($fieldUpdatedCount > 0 || $forceUpdate) {
+ // Get the table name from the existing query.
+ if (!empty($rs->tableName)) $tableName = $rs->tableName;
+ else preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName);
+
+ // Get the full where clause excluding the word "WHERE" from
+ // the existing query.
+ preg_match('/\sWHERE\s(.*)/is', $rs->sql, $whereClause);
+
+ $discard = false;
+ // not a good hack, improvements?
+ if ($whereClause) {
+ if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard));
+ else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard));
+ else preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard);
+ } else
+ $whereClause = array(false,false);
+
+ if ($discard)
+ $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1]));
+
+ $sql = 'UPDATE '.$tableName[1].' SET '.substr($setFields, 0, -2);
+ if (strlen($whereClause[1]) > 0)
+ $sql .= ' WHERE '.$whereClause[1];
+
+ return $sql;
+
+ } else {
+ return false;
+ }
+}
+
+function adodb_key_exists($key, &$arr,$force=2)
+{
+ if ($force<=0) {
+ // the following is the old behaviour where null or empty fields are ignored
+ return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0);
+ }
+
+ if (isset($arr[$key])) return true;
+ ## null check below
+ if (ADODB_PHPVER >= 0x4010) return array_key_exists($key,$arr);
+ return false;
+}
+
+/**
+ * There is a special case of this function for the oci8 driver.
+ * The proper way to handle an insert w/ a blob in oracle requires
+ * a returning clause with bind variables and a descriptor blob.
+ *
+ *
+ */
+function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2)
+{
+static $cacheRS = false;
+static $cacheSig = 0;
+static $cacheCols;
+
+ $tableName = '';
+ $values = '';
+ $fields = '';
+ $recordSet = null;
+ $arrFields = _array_change_key_case($arrFields);
+ $fieldInsertedCount = 0;
+
+ if (is_string($rs)) {
+ //ok we have a table name
+ //try and get the column info ourself.
+ $tableName = $rs;
+
+ //we need an object for the recordSet
+ //because we have to call MetaType.
+ //php can't do a $rsclass::MetaType()
+ $rsclass = $zthis->rsPrefix.$zthis->databaseType;
+ $recordSet = new $rsclass(-1,$zthis->fetchMode);
+ $recordSet->connection = &$zthis;
+
+ if (is_string($cacheRS) && $cacheRS == $rs) {
+ $columns =& $cacheCols;
+ } else {
+ $columns = $zthis->MetaColumns( $tableName );
+ $cacheRS = $tableName;
+ $cacheCols = $columns;
+ }
+ } else if (is_subclass_of($rs, 'adorecordset')) {
+ if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) {
+ $columns =& $cacheCols;
+ } else {
+ for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++)
+ $columns[] = $rs->FetchField($i);
+ $cacheRS = $cacheSig;
+ $cacheCols = $columns;
+ $rs->insertSig = $cacheSig++;
+ }
+ $recordSet =& $rs;
+
+ } else {
+ printf(ADODB_BAD_RS,'GetInsertSQL');
+ return false;
+ }
+
+ // Loop through all of the fields in the recordset
+ foreach( $columns as $field ) {
+ $upperfname = strtoupper($field->name);
+ if (adodb_key_exists($upperfname,$arrFields,$force)) {
+ $bad = false;
+ if (strpos($upperfname,' ') !== false)
+ $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
+ else
+ $fnameq = $upperfname;
+
+ $type = $recordSet->MetaType($field->type);
+
+ /********************************************************/
+ if (is_null($arrFields[$upperfname])
+ || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0)
+ || $arrFields[$upperfname] === 'null'
+ )
+ {
+ switch ($force) {
+
+ case 0: // we must always set null if missing
+ $bad = true;
+ break;
+
+ case 1:
+ $values .= "null, ";
+ break;
+
+ case 2:
+ //Set empty
+ $arrFields[$upperfname] = "";
+ $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,$arrFields, $magicq);
+ break;
+
+ default:
+ case 3:
+ //Set the value that was given in array, so you can give both null and empty values
+ if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === 'null') {
+ $values .= "null, ";
+ } else {
+ $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq);
+ }
+ break;
+ } // switch
+
+ /*********************************************************/
+ } else {
+ //we do this so each driver can customize the sql for
+ //DB specific column types.
+ //Oracle needs BLOB types to be handled with a returning clause
+ //postgres has special needs as well
+ $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,
+ $arrFields, $magicq);
+ }
+
+ if ($bad) continue;
+ // Set the counter for the number of fields that will be inserted.
+ $fieldInsertedCount++;
+
+
+ // Get the name of the fields to insert
+ $fields .= $fnameq . ", ";
+ }
+ }
+
+
+ // If there were any inserted fields then build the rest of the insert query.
+ if ($fieldInsertedCount <= 0) return false;
+
+ // Get the table name from the existing query.
+ if (!$tableName) {
+ if (!empty($rs->tableName)) $tableName = $rs->tableName;
+ else if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName))
+ $tableName = $tableName[1];
+ else
+ return false;
+ }
+
+ // Strip off the comma and space on the end of both the fields
+ // and their values.
+ $fields = substr($fields, 0, -2);
+ $values = substr($values, 0, -2);
+
+ // Append the fields and their values to the insert query.
+ return 'INSERT INTO '.$tableName.' ( '.$fields.' ) VALUES ( '.$values.' )';
+}
+
+
+/**
+ * This private method is used to help construct
+ * the update/sql which is generated by GetInsertSQL and GetUpdateSQL.
+ * It handles the string construction of 1 column -> sql string based on
+ * the column type. We want to do 'safe' handling of BLOBs
+ *
+ * @param string the type of sql we are trying to create
+ * 'I' or 'U'.
+ * @param string column data type from the db::MetaType() method
+ * @param string the column name
+ * @param array the column value
+ *
+ * @return string
+ *
+ */
+function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields, $magicq)
+{
+ $sql = '';
+
+ // Based on the datatype of the field
+ // Format the value properly for the database
+ switch($type) {
+ case 'B':
+ //in order to handle Blobs correctly, we need
+ //to do some magic for Oracle
+
+ //we need to create a new descriptor to handle
+ //this properly
+ if (!empty($zthis->hasReturningInto)) {
+ if ($action == 'I') {
+ $sql = 'empty_blob(), ';
+ } else {
+ $sql = $fnameq. '=empty_blob(), ';
+ }
+ //add the variable to the returning clause array
+ //so the user can build this later in
+ //case they want to add more to it
+ $zthis->_returningArray[$fname] = ':xx'.$fname.'xx';
+ } else if (empty($arrFields[$fname])){
+ if ($action == 'I') {
+ $sql = 'empty_blob(), ';
+ } else {
+ $sql = $fnameq. '=empty_blob(), ';
+ }
+ } else {
+ //this is to maintain compatibility
+ //with older adodb versions.
+ $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
+ }
+ break;
+
+ case "X":
+ //we need to do some more magic here for long variables
+ //to handle these correctly in oracle.
+
+ //create a safe bind var name
+ //to avoid conflicts w/ dupes.
+ if (!empty($zthis->hasReturningInto)) {
+ if ($action == 'I') {
+ $sql = ':xx'.$fname.'xx, ';
+ } else {
+ $sql = $fnameq.'=:xx'.$fname.'xx, ';
+ }
+ //add the variable to the returning clause array
+ //so the user can build this later in
+ //case they want to add more to it
+ $zthis->_returningArray[$fname] = ':xx'.$fname.'xx';
+ } else {
+ //this is to maintain compatibility
+ //with older adodb versions.
+ $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
+ }
+ break;
+
+ default:
+ $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false);
+ break;
+ }
+
+ return $sql;
+}
+
+function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq, $recurse=true)
+{
+
+ if ($recurse) {
+ switch($zthis->dataProvider) {
+ case 'postgres':
+ if ($type == 'L') $type = 'C';
+ break;
+ case 'oci8':
+ return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq);
+
+ }
+ }
+
+ switch($type) {
+ case "C":
+ case "X":
+ case 'B':
+ $val = $zthis->qstr($arrFields[$fname],$magicq);
+ break;
+
+ case "D":
+ $val = $zthis->DBDate($arrFields[$fname]);
+ break;
+
+ case "T":
+ $val = $zthis->DBTimeStamp($arrFields[$fname]);
+ break;
+
+ default:
+ $val = $arrFields[$fname];
+ if (empty($val)) $val = '0';
+ break;
+ }
+
+ if ($action == 'I') return $val . ", ";
+
+
+ return $fnameq . "=" . $val . ", ";
+
+}
+
+
+
+function _adodb_debug_execute(&$zthis, $sql, $inputarr)
+{
+ $ss = '';
+ if ($inputarr) {
+ foreach($inputarr as $kk=>$vv) {
+ if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...';
+ $ss .= "($kk=>'$vv') ";
+ }
+ $ss = "[ $ss ]";
+ }
+ $sqlTxt = is_array($sql) ? $sql[0] : $sql;
+ /*str_replace(', ','##1#__^LF',is_array($sql) ? $sql[0] : $sql);
+ $sqlTxt = str_replace(',',', ',$sqlTxt);
+ $sqlTxt = str_replace('##1#__^LF', ', ' ,$sqlTxt);
+ */
+ // check if running from browser or command-line
+ $inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
+
+ $dbt = $zthis->databaseType;
+ if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType;
+ if ($inBrowser) {
+ $ss = htmlspecialchars($ss);
+ if ($zthis->debug === -1)
+ ADOConnection::outp( "<br>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; <code>$ss</code>\n<br>\n",false);
+ else
+ ADOConnection::outp( "<hr>\n($dbt): ".htmlspecialchars($sqlTxt)." &nbsp; <code>$ss</code>\n<hr>\n",false);
+ } else {
+ ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false);
+ }
+
+ $qID = $zthis->_query($sql,$inputarr);
+
+ /*
+ Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql
+ because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion
+ */
+ if ($zthis->databaseType == 'mssql') {
+ // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6
+ if($emsg = $zthis->ErrorMsg()) {
+ if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg);
+ }
+ } else if (!$qID) {
+ ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg());
+ }
+
+ if ($zthis->debug === 99) _adodb_backtrace(true,9999,2);
+ return $qID;
+}
+
+
+function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0)
+{
+ if (PHPVERSION() < 4.3) return '';
+
+ $html = (isset($_SERVER['HTTP_USER_AGENT']));
+ $fmt = ($html) ? "</font><font color=#808080 size=-1> %% line %4d, file: <a href=\"file:/%s\">%s</a></font>" : "%% line %4d, file: %s";
+
+ $MAXSTRLEN = 128;
+
+ $s = ($html) ? '<pre align=left>' : '';
+
+ if (is_array($printOrArr)) $traceArr = $printOrArr;
+ else $traceArr = debug_backtrace();
+ array_shift($traceArr);
+ array_shift($traceArr);
+ $tabs = sizeof($traceArr)-2;
+
+ foreach ($traceArr as $arr) {
+ if ($skippy) {$skippy -= 1; continue;}
+ $levels -= 1;
+ if ($levels < 0) break;
+
+ $args = array();
+ for ($i=0; $i < $tabs; $i++) $s .= ($html) ? ' &nbsp; ' : "\t";
+ $tabs -= 1;
+ if ($html) $s .= '<font face="Courier New,Courier">';
+ if (isset($arr['class'])) $s .= $arr['class'].'.';
+ if (isset($arr['args']))
+ foreach($arr['args'] as $v) {
+ if (is_null($v)) $args[] = 'null';
+ else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
+ else if (is_object($v)) $args[] = 'Object:'.get_class($v);
+ else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
+ else {
+ $v = (string) @$v;
+ $str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
+ if (strlen($v) > $MAXSTRLEN) $str .= '...';
+ $args[] = $str;
+ }
+ }
+ $s .= $arr['function'].'('.implode(', ',$args).')';
+
+
+ $s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
+
+ $s .= "\n";
+ }
+ if ($html) $s .= '</pre>';
+ if ($printOrArr) print $s;
+
+ return $s;
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-pager.inc.php b/html/phpgacl/adodb/adodb-pager.inc.php
new file mode 100644
index 0000000..5deb18e
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-pager.inc.php
@@ -0,0 +1,289 @@
+<?php
+
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ This class provides recordset pagination with
+ First/Prev/Next/Last links.
+
+ Feel free to modify this class for your own use as
+ it is very basic. To learn how to use it, see the
+ example in adodb/tests/testpaging.php.
+
+ "Pablo Costa" <pablo@cbsp.com.br> implemented Render_PageLinks().
+
+ Please note, this class is entirely unsupported,
+ and no free support requests except for bug reports
+ will be entertained by the author.
+
+*/
+class ADODB_Pager {
+ var $id; // unique id for pager (defaults to 'adodb')
+ var $db; // ADODB connection object
+ var $sql; // sql used
+ var $rs; // recordset generated
+ var $curr_page; // current page number before Render() called, calculated in constructor
+ var $rows; // number of rows per page
+ var $linksPerPage=10; // number of links per page in navigation bar
+ var $showPageLinks;
+
+ var $gridAttributes = 'width=100% border=1 bgcolor=white';
+
+ // Localize text strings here
+ var $first = '<code>|&lt;</code>';
+ var $prev = '<code>&lt;&lt;</code>';
+ var $next = '<code>>></code>';
+ var $last = '<code>>|</code>';
+ var $moreLinks = '...';
+ var $startLinks = '...';
+ var $gridHeader = false;
+ var $htmlSpecialChars = true;
+ var $page = 'Page';
+ var $linkSelectedColor = 'red';
+ var $cache = 0; #secs to cache with CachePageExecute()
+
+ //----------------------------------------------
+ // constructor
+ //
+ // $db adodb connection object
+ // $sql sql statement
+ // $id optional id to identify which pager,
+ // if you have multiple on 1 page.
+ // $id should be only be [a-z0-9]*
+ //
+ function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
+ {
+ global $PHP_SELF;
+
+ $curr_page = $id.'_curr_page';
+ if (empty($PHP_SELF)) $PHP_SELF = $_SERVER['PHP_SELF'];
+
+ $this->sql = $sql;
+ $this->id = $id;
+ $this->db = $db;
+ $this->showPageLinks = $showPageLinks;
+
+ $next_page = $id.'_next_page';
+
+ if (isset($_GET[$next_page])) {
+ $_SESSION[$curr_page] = $_GET[$next_page];
+ }
+ if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page
+
+ $this->curr_page = $_SESSION[$curr_page];
+
+ }
+
+ //---------------------------
+ // Display link to first page
+ function Render_First($anchor=true)
+ {
+ global $PHP_SELF;
+ if ($anchor) {
+ ?>
+ <a href="<?php echo $PHP_SELF,'?',$this->id;?>_next_page=1"><?php echo $this->first;?></a> &nbsp;
+ <?php
+ } else {
+ print "$this->first &nbsp; ";
+ }
+ }
+
+ //--------------------------
+ // Display link to next page
+ function render_next($anchor=true)
+ {
+ global $PHP_SELF;
+
+ if ($anchor) {
+ ?>
+ <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() + 1 ?>"><?php echo $this->next;?></a> &nbsp;
+ <?php
+ } else {
+ print "$this->next &nbsp; ";
+ }
+ }
+
+ //------------------
+ // Link to last page
+ //
+ // for better performance with large recordsets, you can set
+ // $this->db->pageExecuteCountRows = false, which disables
+ // last page counting.
+ function render_last($anchor=true)
+ {
+ global $PHP_SELF;
+
+ if (!$this->db->pageExecuteCountRows) return;
+
+ if ($anchor) {
+ ?>
+ <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->LastPageNo() ?>"><?php echo $this->last;?></a> &nbsp;
+ <?php
+ } else {
+ print "$this->last &nbsp; ";
+ }
+ }
+
+ //---------------------------------------------------
+ // original code by "Pablo Costa" <pablo@cbsp.com.br>
+ function render_pagelinks()
+ {
+ global $PHP_SELF;
+ $pages = $this->rs->LastPageNo();
+ $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages;
+ for($i=1; $i <= $pages; $i+=$linksperpage)
+ {
+ if($this->rs->AbsolutePage() >= $i)
+ {
+ $start = $i;
+ }
+ }
+ $numbers = '';
+ $end = $start+$linksperpage-1;
+ $link = $this->id . "_next_page";
+ if($end > $pages) $end = $pages;
+
+
+ if ($this->startLinks && $start > 1) {
+ $pos = $start - 1;
+ $numbers .= "<a href=$PHP_SELF?$link=$pos>$this->startLinks</a> ";
+ }
+
+ for($i=$start; $i <= $end; $i++) {
+ if ($this->rs->AbsolutePage() == $i)
+ $numbers .= "<font color=$this->linkSelectedColor><b>$i</b></font> ";
+ else
+ $numbers .= "<a href=$PHP_SELF?$link=$i>$i</a> ";
+
+ }
+ if ($this->moreLinks && $end < $pages)
+ $numbers .= "<a href=$PHP_SELF?$link=$i>$this->moreLinks</a> ";
+ print $numbers . ' &nbsp; ';
+ }
+ // Link to previous page
+ function render_prev($anchor=true)
+ {
+ global $PHP_SELF;
+ if ($anchor) {
+ ?>
+ <a href="<?php echo $PHP_SELF,'?',$this->id,'_next_page=',$this->rs->AbsolutePage() - 1 ?>"><?php echo $this->prev;?></a> &nbsp;
+ <?php
+ } else {
+ print "$this->prev &nbsp; ";
+ }
+ }
+
+ //--------------------------------------------------------
+ // Simply rendering of grid. You should override this for
+ // better control over the format of the grid
+ //
+ // We use output buffering to keep code clean and readable.
+ function RenderGrid()
+ {
+ global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
+ include_once(ADODB_DIR.'/tohtml.inc.php');
+ ob_start();
+ $gSQLBlockRows = $this->rows;
+ rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars);
+ $s = ob_get_contents();
+ ob_end_clean();
+ return $s;
+ }
+
+ //-------------------------------------------------------
+ // Navigation bar
+ //
+ // we use output buffering to keep the code easy to read.
+ function RenderNav()
+ {
+ ob_start();
+ if (!$this->rs->AtFirstPage()) {
+ $this->Render_First();
+ $this->Render_Prev();
+ } else {
+ $this->Render_First(false);
+ $this->Render_Prev(false);
+ }
+ if ($this->showPageLinks){
+ $this->Render_PageLinks();
+ }
+ if (!$this->rs->AtLastPage()) {
+ $this->Render_Next();
+ $this->Render_Last();
+ } else {
+ $this->Render_Next(false);
+ $this->Render_Last(false);
+ }
+ $s = ob_get_contents();
+ ob_end_clean();
+ return $s;
+ }
+
+ //-------------------
+ // This is the footer
+ function RenderPageCount()
+ {
+ if (!$this->db->pageExecuteCountRows) return '';
+ $lastPage = $this->rs->LastPageNo();
+ if ($lastPage == -1) $lastPage = 1; // check for empty rs.
+ if ($this->curr_page > $lastPage) $this->curr_page = 1;
+ return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>";
+ }
+
+ //-----------------------------------
+ // Call this class to draw everything.
+ function Render($rows=10)
+ {
+ global $ADODB_COUNTRECS;
+
+ $this->rows = $rows;
+
+ if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL;
+
+ $savec = $ADODB_COUNTRECS;
+ if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true;
+ if ($this->cache)
+ $rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page);
+ else
+ $rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page);
+ $ADODB_COUNTRECS = $savec;
+
+ $this->rs = &$rs;
+ if (!$rs) {
+ print "<h3>Query failed: $this->sql</h3>";
+ return;
+ }
+
+ if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage()))
+ $header = $this->RenderNav();
+ else
+ $header = "&nbsp;";
+
+ $grid = $this->RenderGrid();
+ $footer = $this->RenderPageCount();
+ $rs->Close();
+ $this->rs = false;
+
+ $this->RenderLayout($header,$grid,$footer);
+ }
+
+ //------------------------------------------------------
+ // override this to control overall layout and formating
+ function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige')
+ {
+ echo "<table ".$attributes."><tr><td>",
+ $header,
+ "</td></tr><tr><td>",
+ $grid,
+ "</td></tr><tr><td>",
+ $footer,
+ "</td></tr></table>";
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-pear.inc.php b/html/phpgacl/adodb/adodb-pear.inc.php
new file mode 100644
index 0000000..2ed5213
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-pear.inc.php
@@ -0,0 +1,374 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * PEAR DB Emulation Layer for ADODB.
+ *
+ * The following code is modelled on PEAR DB code by Stig Bakken <ssb@fast.no> |
+ * and Tomas V.V.Cox <cox@idecnet.com>. Portions (c)1997-2002 The PHP Group.
+ */
+
+ /*
+ We support:
+
+ DB_Common
+ ---------
+ query - returns PEAR_Error on error
+ limitQuery - return PEAR_Error on error
+ prepare - does not return PEAR_Error on error
+ execute - does not return PEAR_Error on error
+ setFetchMode - supports ASSOC and ORDERED
+ errorNative
+ quote
+ nextID
+ disconnect
+
+ getOne
+ getAssoc
+ getRow
+ getCol
+ getAll
+
+ DB_Result
+ ---------
+ numRows - returns -1 if not supported
+ numCols
+ fetchInto - does not support passing of fetchmode
+ fetchRows - does not support passing of fetchmode
+ free
+ */
+
+define('ADODB_PEAR',dirname(__FILE__));
+include_once "PEAR.php";
+include_once ADODB_PEAR."/adodb-errorpear.inc.php";
+include_once ADODB_PEAR."/adodb.inc.php";
+
+if (!defined('DB_OK')) {
+define("DB_OK", 1);
+define("DB_ERROR",-1);
+
+// autoExecute constants
+define('DB_AUTOQUERY_INSERT', 1);
+define('DB_AUTOQUERY_UPDATE', 2);
+
+/**
+ * This is a special constant that tells DB the user hasn't specified
+ * any particular get mode, so the default should be used.
+ */
+
+define('DB_FETCHMODE_DEFAULT', 0);
+
+/**
+ * Column data indexed by numbers, ordered from 0 and up
+ */
+
+define('DB_FETCHMODE_ORDERED', 1);
+
+/**
+ * Column data indexed by column names
+ */
+
+define('DB_FETCHMODE_ASSOC', 2);
+
+/* for compatibility */
+
+define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED);
+define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC);
+
+/**
+ * these are constants for the tableInfo-function
+ * they are bitwised or'ed. so if there are more constants to be defined
+ * in the future, adjust DB_TABLEINFO_FULL accordingly
+ */
+
+define('DB_TABLEINFO_ORDER', 1);
+define('DB_TABLEINFO_ORDERTABLE', 2);
+define('DB_TABLEINFO_FULL', 3);
+}
+
+/**
+ * The main "DB" class is simply a container class with some static
+ * methods for creating DB objects as well as some utility functions
+ * common to all parts of DB.
+ *
+ */
+
+class DB
+{
+ /**
+ * Create a new DB object for the specified database type
+ *
+ * @param $type string database type, for example "mysql"
+ *
+ * @return object a newly created DB object, or a DB error code on
+ * error
+ */
+
+ function &factory($type)
+ {
+ include_once(ADODB_DIR."/drivers/adodb-$type.inc.php");
+ $obj = &NewADOConnection($type);
+ if (!is_object($obj)) $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
+ return $obj;
+ }
+
+ /**
+ * Create a new DB object and connect to the specified database
+ *
+ * @param $dsn mixed "data source name", see the DB::parseDSN
+ * method for a description of the dsn format. Can also be
+ * specified as an array of the format returned by DB::parseDSN.
+ *
+ * @param $options mixed if boolean (or scalar), tells whether
+ * this connection should be persistent (for backends that support
+ * this). This parameter can also be an array of options, see
+ * DB_common::setOption for more information on connection
+ * options.
+ *
+ * @return object a newly created DB connection object, or a DB
+ * error object on error
+ *
+ * @see DB::parseDSN
+ * @see DB::isError
+ */
+ function &connect($dsn, $options = false)
+ {
+ if (is_array($dsn)) {
+ $dsninfo = $dsn;
+ } else {
+ $dsninfo = DB::parseDSN($dsn);
+ }
+ switch ($dsninfo["phptype"]) {
+ case 'pgsql': $type = 'postgres7'; break;
+ case 'ifx': $type = 'informix9'; break;
+ default: $type = $dsninfo["phptype"]; break;
+ }
+
+ if (is_array($options) && isset($options["debug"]) &&
+ $options["debug"] >= 2) {
+ // expose php errors with sufficient debug level
+ @include_once("adodb-$type.inc.php");
+ } else {
+ @include_once("adodb-$type.inc.php");
+ }
+
+ @$obj =& NewADOConnection($type);
+ if (!is_object($obj)) {
+ $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
+ return $obj;
+ }
+ if (is_array($options)) {
+ foreach($options as $k => $v) {
+ switch(strtolower($k)) {
+ case 'persist':
+ case 'persistent': $persist = $v; break;
+ #ibase
+ case 'dialect': $obj->dialect = $v; break;
+ case 'charset': $obj->charset = $v; break;
+ case 'buffers': $obj->buffers = $v; break;
+ #ado
+ case 'charpage': $obj->charPage = $v; break;
+ #mysql
+ case 'clientflags': $obj->clientFlags = $v; break;
+ }
+ }
+ } else {
+ $persist = false;
+ }
+
+ if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
+ else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];
+
+ if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
+ else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
+
+ if (!$ok) $obj = ADODB_PEAR_Error();
+ return $obj;
+ }
+
+ /**
+ * Return the DB API version
+ *
+ * @return int the DB API version number
+ */
+ function apiVersion()
+ {
+ return 2;
+ }
+
+ /**
+ * Tell whether a result code from a DB method is an error
+ *
+ * @param $value int result code
+ *
+ * @return bool whether $value is an error
+ */
+ function isError($value)
+ {
+ if (!is_object($value)) return false;
+ $class = get_class($value);
+ return $class == 'pear_error' || is_subclass_of($value, 'pear_error') ||
+ $class == 'db_error' || is_subclass_of($value, 'db_error');
+ }
+
+
+ /**
+ * Tell whether a result code from a DB method is a warning.
+ * Warnings differ from errors in that they are generated by DB,
+ * and are not fatal.
+ *
+ * @param $value mixed result value
+ *
+ * @return bool whether $value is a warning
+ */
+ function isWarning($value)
+ {
+ return false;
+ /*
+ return is_object($value) &&
+ (get_class( $value ) == "db_warning" ||
+ is_subclass_of($value, "db_warning"));*/
+ }
+
+ /**
+ * Parse a data source name
+ *
+ * @param $dsn string Data Source Name to be parsed
+ *
+ * @return array an associative array with the following keys:
+ *
+ * phptype: Database backend used in PHP (mysql, odbc etc.)
+ * dbsyntax: Database used with regards to SQL syntax etc.
+ * protocol: Communication protocol to use (tcp, unix etc.)
+ * hostspec: Host specification (hostname[:port])
+ * database: Database to use on the DBMS server
+ * username: User name for login
+ * password: Password for login
+ *
+ * The format of the supplied DSN is in its fullest form:
+ *
+ * phptype(dbsyntax)://username:password@protocol+hostspec/database
+ *
+ * Most variations are allowed:
+ *
+ * phptype://username:password@protocol+hostspec:110//usr/db_file.db
+ * phptype://username:password@hostspec/database_name
+ * phptype://username:password@hostspec
+ * phptype://username@hostspec
+ * phptype://hostspec/database
+ * phptype://hostspec
+ * phptype(dbsyntax)
+ * phptype
+ *
+ * @author Tomas V.V.Cox <cox@idecnet.com>
+ */
+ function parseDSN($dsn)
+ {
+ if (is_array($dsn)) {
+ return $dsn;
+ }
+
+ $parsed = array(
+ 'phptype' => false,
+ 'dbsyntax' => false,
+ 'protocol' => false,
+ 'hostspec' => false,
+ 'database' => false,
+ 'username' => false,
+ 'password' => false
+ );
+
+ // Find phptype and dbsyntax
+ if (($pos = strpos($dsn, '://')) !== false) {
+ $str = substr($dsn, 0, $pos);
+ $dsn = substr($dsn, $pos + 3);
+ } else {
+ $str = $dsn;
+ $dsn = NULL;
+ }
+
+ // Get phptype and dbsyntax
+ // $str => phptype(dbsyntax)
+ if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
+ $parsed['phptype'] = $arr[1];
+ $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
+ } else {
+ $parsed['phptype'] = $str;
+ $parsed['dbsyntax'] = $str;
+ }
+
+ if (empty($dsn)) {
+ return $parsed;
+ }
+
+ // Get (if found): username and password
+ // $dsn => username:password@protocol+hostspec/database
+ if (($at = strpos($dsn,'@')) !== false) {
+ $str = substr($dsn, 0, $at);
+ $dsn = substr($dsn, $at + 1);
+ if (($pos = strpos($str, ':')) !== false) {
+ $parsed['username'] = urldecode(substr($str, 0, $pos));
+ $parsed['password'] = urldecode(substr($str, $pos + 1));
+ } else {
+ $parsed['username'] = urldecode($str);
+ }
+ }
+
+ // Find protocol and hostspec
+ // $dsn => protocol+hostspec/database
+ if (($pos=strpos($dsn, '/')) !== false) {
+ $str = substr($dsn, 0, $pos);
+ $dsn = substr($dsn, $pos + 1);
+ } else {
+ $str = $dsn;
+ $dsn = NULL;
+ }
+
+ // Get protocol + hostspec
+ // $str => protocol+hostspec
+ if (($pos=strpos($str, '+')) !== false) {
+ $parsed['protocol'] = substr($str, 0, $pos);
+ $parsed['hostspec'] = urldecode(substr($str, $pos + 1));
+ } else {
+ $parsed['hostspec'] = urldecode($str);
+ }
+
+ // Get dabase if any
+ // $dsn => database
+ if (!empty($dsn)) {
+ $parsed['database'] = $dsn;
+ }
+
+ return $parsed;
+ }
+
+ /**
+ * Load a PHP database extension if it is not loaded already.
+ *
+ * @access public
+ *
+ * @param $name the base name of the extension (without the .so or
+ * .dll suffix)
+ *
+ * @return bool true if the extension was already or successfully
+ * loaded, false if it could not be loaded
+ */
+ function assertExtension($name)
+ {
+ if (!extension_loaded($name)) {
+ $dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so';
+ @dl($name . $dlext);
+ }
+ if (!extension_loaded($name)) {
+ return false;
+ }
+ return true;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-perf.inc.php b/html/phpgacl/adodb/adodb-perf.inc.php
new file mode 100644
index 0000000..3a1fa4d
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-perf.inc.php
@@ -0,0 +1,1053 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning.
+
+ My apologies if you see code mixed with presentation. The presentation suits
+ my needs. If you want to separate code from presentation, be my guest. Patches
+ are welcome.
+
+*/
+
+if (!defined(ADODB_DIR)) include_once(dirname(__FILE__).'/adodb.inc.php');
+include_once(ADODB_DIR.'/tohtml.inc.php');
+
+define( 'ADODB_OPT_HIGH', 2);
+define( 'ADODB_OPT_LOW', 1);
+
+// returns in K the memory of current process, or 0 if not known
+function adodb_getmem()
+{
+ if (function_exists('memory_get_usage'))
+ return (integer) ((memory_get_usage()+512)/1024);
+
+ $pid = getmypid();
+
+ if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0) {
+ $output = array();
+
+ exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output);
+ return substr($output[5], strpos($output[5], ':') + 1);
+ }
+
+ /* Hopefully UNIX */
+ exec("ps --pid $pid --no-headers -o%mem,size", $output);
+ if (sizeof($output) == 0) return 0;
+
+ $memarr = explode(' ',$output[0]);
+ if (sizeof($memarr)>=2) return (integer) $memarr[1];
+
+ return 0;
+}
+
+// avoids localization problems where , is used instead of .
+function adodb_round($n,$prec)
+{
+ return number_format($n, $prec, '.', '');
+}
+
+/* return microtime value as a float */
+function adodb_microtime()
+{
+ $t = microtime();
+ $t = explode(' ',$t);
+ return (float)$t[1]+ (float)$t[0];
+}
+
+/* sql code timing */
+function& adodb_log_sql(&$conn,$sql,$inputarr)
+{
+
+ $perf_table = adodb_perf::table();
+ $conn->fnExecute = false;
+ $t0 = microtime();
+ $rs =& $conn->Execute($sql,$inputarr);
+ $t1 = microtime();
+
+ if (!empty($conn->_logsql)) {
+ $conn->_logsql = false; // disable logsql error simulation
+ $dbT = $conn->databaseType;
+
+ $a0 = split(' ',$t0);
+ $a0 = (float)$a0[1]+(float)$a0[0];
+
+ $a1 = split(' ',$t1);
+ $a1 = (float)$a1[1]+(float)$a1[0];
+
+ $time = $a1 - $a0;
+
+ if (!$rs) {
+ $errM = $conn->ErrorMsg();
+ $errN = $conn->ErrorNo();
+ $conn->lastInsID = 0;
+ $tracer = substr('ERROR: '.htmlspecialchars($errM),0,250);
+ } else {
+ $tracer = '';
+ $errM = '';
+ $errN = 0;
+ $dbg = $conn->debug;
+ $conn->debug = false;
+ if (!is_object($rs) || $rs->dataProvider == 'empty')
+ $conn->_affected = $conn->affected_rows(true);
+ $conn->lastInsID = @$conn->Insert_ID();
+ $conn->debug = $dbg;
+ }
+ if (isset($_SERVER['HTTP_HOST'])) {
+ $tracer .= '<br>'.$_SERVER['HTTP_HOST'];
+ if (isset($_SERVER['PHP_SELF'])) $tracer .= $_SERVER['PHP_SELF'];
+ } else
+ if (isset($_SERVER['PHP_SELF'])) $tracer .= '<br>'.$_SERVER['PHP_SELF'];
+ //$tracer .= (string) adodb_backtrace(false);
+
+ $tracer = (string) substr($tracer,0,500);
+
+ if (is_array($inputarr)) {
+ if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr);
+ else {
+ // Quote string parameters so we can see them in the
+ // performance stats. This helps spot disabled indexes.
+ $xar_params = $inputarr;
+ foreach ($xar_params as $xar_param_key => $xar_param) {
+ if (gettype($xar_param) == 'string')
+ $xar_params[$xar_param_key] = '"' . $xar_param . '"';
+ }
+ $params = implode(', ', $xar_params);
+ if (strlen($params) >= 3000) $params = substr($params, 0, 3000);
+ }
+ } else {
+ $params = '';
+ }
+
+ if (is_array($sql)) $sql = $sql[0];
+ $arr = array('b'=>strlen($sql).'.'.crc32($sql),
+ 'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6));
+ //var_dump($arr);
+ $saved = $conn->debug;
+ $conn->debug = 0;
+
+ $d = $conn->sysTimeStamp;
+ if (empty($d)) $d = date("'Y-m-d H:i:s'");
+ if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') {
+ $isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)";
+ } else if ($dbT == 'odbc_mssql' || $dbT == 'informix') {
+ $timer = $arr['f'];
+ if ($dbT == 'informix') $sql2 = substr($sql2,0,230);
+
+ $sql1 = $conn->qstr($arr['b']);
+ $sql2 = $conn->qstr($arr['c']);
+ $params = $conn->qstr($arr['d']);
+ $tracer = $conn->qstr($arr['e']);
+
+ $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)";
+ if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql);
+ $arr = false;
+ } else {
+ $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)";
+ }
+
+ $ok = $conn->Execute($isql,$arr);
+ $conn->debug = $saved;
+
+ if ($ok) {
+ $conn->_logsql = true;
+ } else {
+ $err2 = $conn->ErrorMsg();
+ $conn->_logsql = true; // enable logsql error simulation
+ $perf =& NewPerfMonitor($conn);
+ if ($perf) {
+ if ($perf->CreateLogTable()) $ok = $conn->Execute($isql,$arr);
+ } else {
+ $ok = $conn->Execute("create table $perf_table (
+ created varchar(50),
+ sql0 varchar(250),
+ sql1 varchar(4000),
+ params varchar(3000),
+ tracer varchar(500),
+ timer decimal(16,6))");
+ }
+ if (!$ok) {
+ ADOConnection::outp( "<p><b>LOGSQL Insert Failed</b>: $isql<br>$err2</p>");
+ $conn->_logsql = false;
+ }
+ }
+ $conn->_errorMsg = $errM;
+ $conn->_errorCode = $errN;
+ }
+ $conn->fnExecute = 'adodb_log_sql';
+ return $rs;
+}
+
+
+/*
+The settings data structure is an associative array that database parameter per element.
+
+Each database parameter element in the array is itself an array consisting of:
+
+0: category code, used to group related db parameters
+1: either
+ a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'",
+ b. array holding sql string and field to look for, e.g. array('show variables','table_cache'),
+ c. a string prefixed by =, then a PHP method of the class is invoked,
+ e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue',
+2: description of the database parameter
+*/
+
+class adodb_perf {
+ var $conn;
+ var $color = '#F0F0F0';
+ var $table = '<table border=1 bgcolor=white>';
+ var $titles = '<tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr>';
+ var $warnRatio = 90;
+ var $tablesSQL = false;
+ var $cliFormat = "%32s => %s \r\n";
+ var $sql1 = 'sql1'; // used for casting sql1 to text for mssql
+ var $explain = true;
+ var $helpurl = "<a href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL help</a>";
+ var $createTableSQL = false;
+ var $maxLength = 2000;
+
+ // Sets the tablename to be used
+ function table($newtable = false)
+ {
+ static $_table;
+
+ if (!empty($newtable)) $_table = $newtable;
+ if (empty($_table)) $_table = 'adodb_logsql';
+ return $_table;
+ }
+
+ // returns array with info to calculate CPU Load
+ function _CPULoad()
+ {
+/*
+
+cpu 524152 2662 2515228 336057010
+cpu0 264339 1408 1257951 168025827
+cpu1 259813 1254 1257277 168031181
+page 622307 25475680
+swap 24 1891
+intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320)
+ctxt 66155838
+btime 1062315585
+processes 69293
+
+*/
+ // Algorithm is taken from
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp
+ if (strncmp(PHP_OS,'WIN',3)==0) {
+ if (PHP_VERSION == '5.0.0') return false;
+ if (PHP_VERSION == '5.0.1') return false;
+ if (PHP_VERSION == '5.0.2') return false;
+ if (PHP_VERSION == '5.0.3') return false;
+ if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737
+
+ @$c = new COM("WinMgmts:{impersonationLevel=impersonate}!Win32_PerfRawData_PerfOS_Processor.Name='_Total'");
+ if (!$c) return false;
+
+ $info[0] = $c->PercentProcessorTime;
+ $info[1] = 0;
+ $info[2] = 0;
+ $info[3] = $c->TimeStamp_Sys100NS;
+ //print_r($info);
+ return $info;
+ }
+
+ // Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com)
+ $statfile = '/proc/stat';
+ if (!file_exists($statfile)) return false;
+
+ $fd = fopen($statfile,"r");
+ if (!$fd) return false;
+
+ $statinfo = explode("\n",fgets($fd, 1024));
+ fclose($fd);
+ foreach($statinfo as $line) {
+ $info = explode(" ",$line);
+ if($info[0]=="cpu") {
+ array_shift($info); // pop off "cpu"
+ if(!$info[0]) array_shift($info); // pop off blank space (if any)
+ return $info;
+ }
+ }
+
+ return false;
+
+ }
+
+ /* NOT IMPLEMENTED */
+ function MemInfo()
+ {
+ /*
+
+ total: used: free: shared: buffers: cached:
+Mem: 1055289344 917299200 137990144 0 165437440 599773184
+Swap: 2146775040 11055104 2135719936
+MemTotal: 1030556 kB
+MemFree: 134756 kB
+MemShared: 0 kB
+Buffers: 161560 kB
+Cached: 581384 kB
+SwapCached: 4332 kB
+Active: 494468 kB
+Inact_dirty: 322856 kB
+Inact_clean: 24256 kB
+Inact_target: 168316 kB
+HighTotal: 131064 kB
+HighFree: 1024 kB
+LowTotal: 899492 kB
+LowFree: 133732 kB
+SwapTotal: 2096460 kB
+SwapFree: 2085664 kB
+Committed_AS: 348732 kB
+ */
+ }
+
+
+ /*
+ Remember that this is client load, not db server load!
+ */
+ var $_lastLoad;
+ function CPULoad()
+ {
+ $info = $this->_CPULoad();
+ if (!$info) return false;
+
+ if (empty($this->_lastLoad)) {
+ sleep(1);
+ $this->_lastLoad = $info;
+ $info = $this->_CPULoad();
+ }
+
+ $last = $this->_lastLoad;
+ $this->_lastLoad = $info;
+
+ $d_user = $info[0] - $last[0];
+ $d_nice = $info[1] - $last[1];
+ $d_system = $info[2] - $last[2];
+ $d_idle = $info[3] - $last[3];
+
+ //printf("Delta - User: %f Nice: %f System: %f Idle: %f<br>",$d_user,$d_nice,$d_system,$d_idle);
+
+ if (strncmp(PHP_OS,'WIN',3)==0) {
+ if ($d_idle < 1) $d_idle = 1;
+ return 100*(1-$d_user/$d_idle);
+ }else {
+ $total=$d_user+$d_nice+$d_system+$d_idle;
+ if ($total<1) $total=1;
+ return 100*($d_user+$d_nice+$d_system)/$total;
+ }
+ }
+
+ function Tracer($sql)
+ {
+ $perf_table = adodb_perf::table();
+ $saveE = $this->conn->fnExecute;
+ $this->conn->fnExecute = false;
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $sqlq = $this->conn->qstr($sql);
+ $arr = $this->conn->GetArray(
+"select count(*),tracer
+ from $perf_table where sql1=$sqlq
+ group by tracer
+ order by 1 desc");
+ $s = '';
+ if ($arr) {
+ $s .= '<h3>Scripts Affected</h3>';
+ foreach($arr as $k) {
+ $s .= sprintf("%4d",$k[0]).' &nbsp; '.strip_tags($k[1]).'<br>';
+ }
+ }
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_CACHE_MODE = $save;
+ $this->conn->fnExecute = $saveE;
+ return $s;
+ }
+
+ /*
+ Explain Plan for $sql.
+ If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the
+ actual sql.
+ */
+ function Explain($sql,$partial=false)
+ {
+ return false;
+ }
+
+ function InvalidSQL($numsql = 10)
+ {
+
+ if (isset($_GET['sql'])) return;
+ $s = '<h3>Invalid SQL</h3>';
+ $saveE = $this->conn->fnExecute;
+ $this->conn->fnExecute = false;
+ $perf_table = adodb_perf::table();
+ $rs =& $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql);
+ $this->conn->fnExecute = $saveE;
+ if ($rs) {
+ $s .= rs2html($rs,false,false,false,false);
+ } else
+ return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
+
+ return $s;
+ }
+
+
+ /*
+ This script identifies the longest running SQL
+ */
+ function _SuspiciousSQL($numsql = 10)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $perf_table = adodb_perf::table();
+ $saveE = $this->conn->fnExecute;
+ $this->conn->fnExecute = false;
+
+ if (isset($_GET['exps']) && isset($_GET['sql'])) {
+ $partial = !empty($_GET['part']);
+ echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
+ }
+
+ if (isset($_GET['sql'])) return;
+ $sql1 = $this->sql1;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+ //$this->conn->debug=1;
+ $rs =& $this->conn->SelectLimit(
+ "select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
+ from $perf_table
+ where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT')
+ and (tracer is null or tracer not like 'ERROR:%')
+ group by sql1
+ order by 1 desc",$numsql);
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ $this->conn->fnExecute = $saveE;
+
+ if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
+ $s = "<h3>Suspicious SQL</h3>
+<font size=1>The following SQL have high average execution times</font><br>
+<table border=1 bgcolor=white><tr><td><b>Avg Time</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
+ $max = $this->maxLength;
+ while (!$rs->EOF) {
+ $sql = $rs->fields[1];
+ $raw = urlencode($sql);
+ if (strlen($raw)>$max-100) {
+ $sql2 = substr($sql,0,$max-500);
+ $raw = urlencode($sql2).'&part='.crc32($sql);
+ }
+ $prefix = "<a target=sql".rand()." href=\"?hidem=1&exps=1&sql=".$raw."&x#explain\">";
+ $suffix = "</a>";
+ if ($this->explain == false || strlen($prefix)>$max) {
+ $suffix = ' ... <i>String too long for GET parameter: '.strlen($prefix).'</i>';
+ $prefix = '';
+ }
+ $s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
+ "<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
+ $rs->MoveNext();
+ }
+ return $s."</table>";
+
+ }
+
+ function CheckMemory()
+ {
+ return '';
+ }
+
+
+ function SuspiciousSQL($numsql=10)
+ {
+ return adodb_perf::_SuspiciousSQL($numsql);
+ }
+
+ function ExpensiveSQL($numsql=10)
+ {
+ return adodb_perf::_ExpensiveSQL($numsql);
+ }
+
+
+ /*
+ This reports the percentage of load on the instance due to the most
+ expensive few SQL statements. Tuning these statements can often
+ make huge improvements in overall system performance.
+ */
+ function _ExpensiveSQL($numsql = 10)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $perf_table = adodb_perf::table();
+ $saveE = $this->conn->fnExecute;
+ $this->conn->fnExecute = false;
+
+ if (isset($_GET['expe']) && isset($_GET['sql'])) {
+ $partial = !empty($_GET['part']);
+ echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
+ }
+
+ if (isset($_GET['sql'])) return;
+
+ $sql1 = $this->sql1;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs =& $this->conn->SelectLimit(
+ "select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer
+ from $perf_table
+ where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT')
+ and (tracer is null or tracer not like 'ERROR:%')
+ group by sql1
+ having count(*)>1
+ order by 1 desc",$numsql);
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $this->conn->fnExecute = $saveE;
+ $ADODB_FETCH_MODE = $save;
+ if (!$rs) return "<p>$this->helpurl. ".$this->conn->ErrorMsg()."</p>";
+ $s = "<h3>Expensive SQL</h3>
+<font size=1>Tuning the following SQL could reduce the server load substantially</font><br>
+<table border=1 bgcolor=white><tr><td><b>Load</b><td><b>Count</b><td><b>SQL</b><td><b>Max</b><td><b>Min</b></tr>\n";
+ $max = $this->maxLength;
+ while (!$rs->EOF) {
+ $sql = $rs->fields[1];
+ $raw = urlencode($sql);
+ if (strlen($raw)>$max-100) {
+ $sql2 = substr($sql,0,$max-500);
+ $raw = urlencode($sql2).'&part='.crc32($sql);
+ }
+ $prefix = "<a target=sqle".rand()." href=\"?hidem=1&expe=1&sql=".$raw."&x#explain\">";
+ $suffix = "</a>";
+ if($this->explain == false || strlen($prefix>$max)) {
+ $prefix = '';
+ $suffix = '';
+ }
+ $s .= "<tr><td>".adodb_round($rs->fields[0],6)."<td align=right>".$rs->fields[2]."<td><font size=-1>".$prefix.htmlspecialchars($sql).$suffix."</font>".
+ "<td>".$rs->fields[3]."<td>".$rs->fields[4]."</tr>";
+ $rs->MoveNext();
+ }
+ return $s."</table>";
+ }
+
+ /*
+ Raw function to return parameter value from $settings.
+ */
+ function DBParameter($param)
+ {
+ if (empty($this->settings[$param])) return false;
+ $sql = $this->settings[$param][1];
+ return $this->_DBParameter($sql);
+ }
+
+ /*
+ Raw function returning array of poll paramters
+ */
+ function &PollParameters()
+ {
+ $arr[0] = (float)$this->DBParameter('data cache hit ratio');
+ $arr[1] = (float)$this->DBParameter('data reads');
+ $arr[2] = (float)$this->DBParameter('data writes');
+ $arr[3] = (integer) $this->DBParameter('current connections');
+ return $arr;
+ }
+
+ /*
+ Low-level Get Database Parameter
+ */
+ function _DBParameter($sql)
+ {
+ $savelog = $this->conn->LogSQL(false);
+ if (is_array($sql)) {
+ global $ADODB_FETCH_MODE;
+
+ $sql1 = $sql[0];
+ $key = $sql[1];
+ if (sizeof($sql)>2) $pos = $sql[2];
+ else $pos = 1;
+ if (sizeof($sql)>3) $coef = $sql[3];
+ else $coef = false;
+ $ret = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs = $this->conn->Execute($sql1);
+
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if ($rs) {
+ while (!$rs->EOF) {
+ $keyf = reset($rs->fields);
+ if (trim($keyf) == $key) {
+ $ret = $rs->fields[$pos];
+ if ($coef) $ret *= $coef;
+ break;
+ }
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ }
+ $this->conn->LogSQL($savelog);
+ return $ret;
+ } else {
+ if (strncmp($sql,'=',1) == 0) {
+ $fn = substr($sql,1);
+ return $this->$fn();
+ }
+ $sql = str_replace('$DATABASE',$this->conn->database,$sql);
+ $ret = $this->conn->GetOne($sql);
+ $this->conn->LogSQL($savelog);
+
+ return $ret;
+ }
+ }
+
+ /*
+ Warn if cache ratio falls below threshold. Displayed in "Description" column.
+ */
+ function WarnCacheRatio($val)
+ {
+ if ($val < $this->warnRatio)
+ return '<font color=red><b>Cache ratio should be at least '.$this->warnRatio.'%</b></font>';
+ else return '';
+ }
+
+ /***********************************************************************************************/
+ // HIGH LEVEL UI FUNCTIONS
+ /***********************************************************************************************/
+
+
+ function UI($pollsecs=5)
+ {
+
+ $perf_table = adodb_perf::table();
+ $conn = $this->conn;
+
+ $app = $conn->host;
+ if ($conn->host && $conn->database) $app .= ', db=';
+ $app .= $conn->database;
+
+ if ($app) $app .= ', ';
+ $savelog = $this->conn->LogSQL(false);
+ $info = $conn->ServerInfo();
+ if (isset($_GET['clearsql'])) {
+ $this->conn->Execute("delete from $perf_table");
+ }
+ $this->conn->LogSQL($savelog);
+
+ // magic quotes
+
+ if (isset($_GET['sql']) && get_magic_quotes_gpc()) {
+ $_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']);
+ }
+
+ if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10;
+ else $nsql = $_SESSION['ADODB_PERF_SQL'];
+
+ $app .= $info['description'];
+
+
+ if (isset($_GET['do'])) $do = $_GET['do'];
+ else if (isset($_POST['do'])) $do = $_POST['do'];
+ else if (isset($_GET['sql'])) $do = 'viewsql';
+ else $do = 'stats';
+
+ if (isset($_GET['nsql'])) {
+ if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql'];
+ }
+ echo "<title>ADOdb Performance Monitor on $app</title><body bgcolor=white>";
+ if ($do == 'viewsql') $form = "<td><form># SQL:<input type=hidden value=viewsql name=do> <input type=text size=4 name=nsql value=$nsql><input type=submit value=Go></td></form>";
+ else $form = "<td>&nbsp;</td>";
+
+ $allowsql = !defined('ADODB_PERF_NO_RUN_SQL');
+
+ if (empty($_GET['hidem']))
+ echo "<table border=1 width=100% bgcolor=lightyellow><tr><td colspan=2>
+ <b><a href=http://adodb.sourceforge.net/?perf=1>ADOdb</a> Performance Monitor</b> <font size=1>for $app</font></tr><tr><td>
+ <a href=?do=stats><b>Performance Stats</b></a> &nbsp; <a href=?do=viewsql><b>View SQL</b></a>
+ &nbsp; <a href=?do=tables><b>View Tables</b></a> &nbsp; <a href=?do=poll><b>Poll Stats</b></a>",
+ $allowsql ? ' &nbsp; <a href=?do=dosql><b>Run SQL</b></a>' : '',
+ "$form",
+ "</tr></table>";
+
+
+ switch ($do) {
+ default:
+ case 'stats':
+ echo $this->HealthCheck();
+ //$this->conn->debug=1;
+ echo $this->CheckMemory();
+ break;
+ case 'poll':
+ echo "<iframe width=720 height=80%
+ src=\"{$_SERVER['PHP_SELF']}?do=poll2&hidem=1\"></iframe>";
+ break;
+ case 'poll2':
+ echo "<pre>";
+ $this->Poll($pollsecs);
+ break;
+
+ case 'dosql':
+ if (!$allowsql) break;
+
+ $this->DoSQLForm();
+ break;
+ case 'viewsql':
+ if (empty($_GET['hidem']))
+ echo "&nbsp; <a href=\"?do=viewsql&clearsql=1\">Clear SQL Log</a><br>";
+ echo($this->SuspiciousSQL($nsql));
+ echo($this->ExpensiveSQL($nsql));
+ echo($this->InvalidSQL($nsql));
+ break;
+ case 'tables':
+ echo $this->Tables(); break;
+ }
+ global $ADODB_vers;
+ echo "<p><div align=center><font size=1>$ADODB_vers Sponsored by <a href=http://phplens.com/>phpLens</a></font></div>";
+ }
+
+ /*
+ Runs in infinite loop, returning real-time statistics
+ */
+ function Poll($secs=5)
+ {
+ $this->conn->fnExecute = false;
+ //$this->conn->debug=1;
+ if ($secs <= 1) $secs = 1;
+ echo "Accumulating statistics, every $secs seconds...\n";flush();
+ $arro =& $this->PollParameters();
+ $cnt = 0;
+ set_time_limit(0);
+ sleep($secs);
+ while (1) {
+
+ $arr =& $this->PollParameters();
+
+ $hits = sprintf('%2.2f',$arr[0]);
+ $reads = sprintf('%12.4f',($arr[1]-$arro[1])/$secs);
+ $writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs);
+ $sess = sprintf('%5d',$arr[3]);
+
+ $load = $this->CPULoad();
+ if ($load !== false) {
+ $oslabel = 'WS-CPU%';
+ $osval = sprintf(" %2.1f ",(float) $load);
+ }else {
+ $oslabel = '';
+ $osval = '';
+ }
+ if ($cnt % 10 == 0) echo " Time ".$oslabel." Hit% Sess Reads/s Writes/s\n";
+ $cnt += 1;
+ echo date('H:i:s').' '.$osval."$hits $sess $reads $writes\n";
+ flush();
+
+ if (connection_aborted()) return;
+
+ sleep($secs);
+ $arro = $arr;
+ }
+ }
+
+ /*
+ Returns basic health check in a command line interface
+ */
+ function HealthCheckCLI()
+ {
+ return $this->HealthCheck(true);
+ }
+
+
+ /*
+ Returns basic health check as HTML
+ */
+ function HealthCheck($cli=false)
+ {
+ $saveE = $this->conn->fnExecute;
+ $this->conn->fnExecute = false;
+ if ($cli) $html = '';
+ else $html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;
+
+ $oldc = false;
+ $bgc = '';
+ foreach($this->settings as $name => $arr) {
+ if ($arr === false) break;
+
+ if (!is_string($name)) {
+ if ($cli) $html .= " -- $arr -- \n";
+ else $html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
+ continue;
+ }
+
+ if (!is_array($arr)) break;
+ $category = $arr[0];
+ $how = $arr[1];
+ if (sizeof($arr)>2) $desc = $arr[2];
+ else $desc = ' &nbsp; ';
+
+
+ if ($category == 'HIDE') continue;
+
+ $val = $this->_DBParameter($how);
+
+ if ($desc && strncmp($desc,"=",1) === 0) {
+ $fn = substr($desc,1);
+ $desc = $this->$fn($val);
+ }
+
+ if ($val === false) {
+ $m = $this->conn->ErrorMsg();
+ $val = "Error: $m";
+ } else {
+ if (is_numeric($val) && $val >= 256*1024) {
+ if ($val % (1024*1024) == 0) {
+ $val /= (1024*1024);
+ $val .= 'M';
+ } else if ($val % 1024 == 0) {
+ $val /= 1024;
+ $val .= 'K';
+ }
+ //$val = htmlspecialchars($val);
+ }
+ }
+ if ($category != $oldc) {
+ $oldc = $category;
+ //$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color;
+ }
+ if (strlen($desc)==0) $desc = '&nbsp;';
+ if (strlen($val)==0) $val = '&nbsp;';
+ if ($cli) {
+ $html .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));
+
+ }else {
+ $html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
+ }
+ }
+
+ if (!$cli) $html .= "</table>\n";
+ $this->conn->fnExecute = $saveE;
+
+ return $html;
+ }
+
+ function Tables($orderby='1')
+ {
+ if (!$this->tablesSQL) return false;
+
+ $savelog = $this->conn->LogSQL(false);
+ $rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby);
+ $this->conn->LogSQL($savelog);
+ $html = rs2html($rs,false,false,false,false);
+ return $html;
+ }
+
+
+ function CreateLogTable()
+ {
+ if (!$this->createTableSQL) return false;
+
+ $savelog = $this->conn->LogSQL(false);
+ $ok = $this->conn->Execute($this->createTableSQL);
+ $this->conn->LogSQL($savelog);
+ return ($ok) ? true : false;
+ }
+
+ function DoSQLForm()
+ {
+
+
+ $PHP_SELF = $_SERVER['PHP_SELF'];
+ $sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : '';
+
+ if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows'];
+ else $rows = 3;
+
+ if (isset($_REQUEST['SMALLER'])) {
+ $rows /= 2;
+ if ($rows < 3) $rows = 3;
+ $_SESSION['phplens_sqlrows'] = $rows;
+ }
+ if (isset($_REQUEST['BIGGER'])) {
+ $rows *= 2;
+ $_SESSION['phplens_sqlrows'] = $rows;
+ }
+
+?>
+
+<form method="POST" action="<?php echo $PHP_SELF ?>">
+<table><tr>
+<td> Form size: <input type="submit" value=" &lt; " name="SMALLER"><input type="submit" value=" &gt; &gt; " name="BIGGER">
+</td>
+<td align=right>
+<input type="submit" value=" Run SQL Below " name="RUN"><input type=hidden name=do value=dosql>
+</td></tr>
+ <tr>
+ <td colspan=2><textarea rows=<?php print $rows; ?> name="sql" cols="80"><?php print htmlspecialchars($sql) ?></textarea>
+ </td>
+ </tr>
+ </table>
+</form>
+
+<?php
+ if (!isset($_REQUEST['sql'])) return;
+
+ $sql = $this->undomq(trim($sql));
+ if (substr($sql,strlen($sql)-1) === ';') {
+ $print = true;
+ $sqla = $this->SplitSQL($sql);
+ } else {
+ $print = false;
+ $sqla = array($sql);
+ }
+ foreach($sqla as $sqls) {
+
+ if (!$sqls) continue;
+
+ if ($print) {
+ print "<p>".htmlspecialchars($sqls)."</p>";
+ flush();
+ }
+ $savelog = $this->conn->LogSQL(false);
+ $rs = $this->conn->Execute($sqls);
+ $this->conn->LogSQL($savelog);
+ if ($rs && is_object($rs) && !$rs->EOF) {
+ rs2html($rs);
+ while ($rs->NextRecordSet()) {
+ print "<table width=98% bgcolor=#C0C0FF><tr><td>&nbsp;</td></tr></table>";
+ rs2html($rs);
+ }
+ } else {
+ $e1 = (integer) $this->conn->ErrorNo();
+ $e2 = $this->conn->ErrorMsg();
+ if (($e1) || ($e2)) {
+ if (empty($e1)) $e1 = '-1'; // postgresql fix
+ print ' &nbsp; '.$e1.': '.$e2;
+ } else {
+ print "<p>No Recordset returned<br></p>";
+ }
+ }
+ } // foreach
+ }
+
+ function SplitSQL($sql)
+ {
+ $arr = explode(';',$sql);
+ return $arr;
+ }
+
+ function undomq(&$m)
+ {
+ if (get_magic_quotes_gpc()) {
+ // undo the damage
+ $m = str_replace('\\\\','\\',$m);
+ $m = str_replace('\"','"',$m);
+ $m = str_replace('\\\'','\'',$m);
+ }
+ return $m;
+}
+
+
+ /************************************************************************/
+
+ /**
+ * Reorganise multiple table-indices/statistics/..
+ * OptimizeMode could be given by last Parameter
+ *
+ * @example
+ * <pre>
+ * optimizeTables( 'tableA');
+ * </pre>
+ * <pre>
+ * optimizeTables( 'tableA', 'tableB', 'tableC');
+ * </pre>
+ * <pre>
+ * optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
+ * </pre>
+ *
+ * @param string table name of the table to optimize
+ * @param int mode optimization-mode
+ * <code>ADODB_OPT_HIGH</code> for full optimization
+ * <code>ADODB_OPT_LOW</code> for CPU-less optimization
+ * Default is LOW <code>ADODB_OPT_LOW</code>
+ * @author Markus Staab
+ * @return Returns <code>true</code> on success and <code>false</code> on error
+ */
+ function OptimizeTables()
+ {
+ $args = func_get_args();
+ $numArgs = func_num_args();
+
+ if ( $numArgs == 0) return false;
+
+ $mode = ADODB_OPT_LOW;
+ $lastArg = $args[ $numArgs - 1];
+ if ( !is_string($lastArg)) {
+ $mode = $lastArg;
+ unset( $args[ $numArgs - 1]);
+ }
+
+ foreach( $args as $table) {
+ $this->optimizeTable( $table, $mode);
+ }
+ }
+
+ /**
+ * Reorganise the table-indices/statistics/.. depending on the given mode.
+ * Default Implementation throws an error.
+ *
+ * @param string table name of the table to optimize
+ * @param int mode optimization-mode
+ * <code>ADODB_OPT_HIGH</code> for full optimization
+ * <code>ADODB_OPT_LOW</code> for CPU-less optimization
+ * Default is LOW <code>ADODB_OPT_LOW</code>
+ * @author Markus Staab
+ * @return Returns <code>true</code> on success and <code>false</code> on error
+ */
+ function OptimizeTable( $table, $mode = ADODB_OPT_LOW)
+ {
+ ADOConnection::outp( sprintf( "<p>%s: '%s' not implemented for driver '%s'</p>", __CLASS__, __FUNCTION__, $this->conn->databaseType));
+ return false;
+ }
+
+ /**
+ * Reorganise current database.
+ * Default implementation loops over all <code>MetaTables()</code> and
+ * optimize each using <code>optmizeTable()</code>
+ *
+ * @author Markus Staab
+ * @return Returns <code>true</code> on success and <code>false</code> on error
+ */
+ function optimizeDatabase()
+ {
+ $conn = $this->conn;
+ if ( !$conn) return false;
+
+ $tables = $conn->MetaTables( 'TABLES');
+ if ( !$tables ) return false;
+
+ foreach( $tables as $table) {
+ if ( !$this->optimizeTable( $table)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ // end hack
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-php4.inc.php b/html/phpgacl/adodb/adodb-php4.inc.php
new file mode 100644
index 0000000..6059347
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-php4.inc.php
@@ -0,0 +1,16 @@
+<?php
+
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4.
+*/
+
+
+class ADODB_BASE_RS {
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-time.inc.php b/html/phpgacl/adodb/adodb-time.inc.php
new file mode 100644
index 0000000..a116fa0
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-time.inc.php
@@ -0,0 +1,1287 @@
+<?php
+/**
+ADOdb Date Library, part of the ADOdb abstraction library
+Download: http://php.weblogs.com/adodb_date_time_library
+
+PHP native date functions use integer timestamps for computations.
+Because of this, dates are restricted to the years 1901-2038 on Unix
+and 1970-2038 on Windows due to integer overflow for dates beyond
+those years. This library overcomes these limitations by replacing the
+native function's signed integers (normally 32-bits) with PHP floating
+point numbers (normally 64-bits).
+
+Dates from 100 A.D. to 3000 A.D. and later
+have been tested. The minimum is 100 A.D. as <100 will invoke the
+2 => 4 digit year conversion. The maximum is billions of years in the
+future, but this is a theoretical limit as the computation of that year
+would take too long with the current implementation of adodb_mktime().
+
+This library replaces native functions as follows:
+
+<pre>
+ getdate() with adodb_getdate()
+ date() with adodb_date()
+ gmdate() with adodb_gmdate()
+ mktime() with adodb_mktime()
+ gmmktime() with adodb_gmmktime()
+ strftime() with adodb_strftime()
+ strftime() with adodb_gmstrftime()
+</pre>
+
+The parameters are identical, except that adodb_date() accepts a subset
+of date()'s field formats. Mktime() will convert from local time to GMT,
+and date() will convert from GMT to local time, but daylight savings is
+not handled currently.
+
+This library is independant of the rest of ADOdb, and can be used
+as standalone code.
+
+PERFORMANCE
+
+For high speed, this library uses the native date functions where
+possible, and only switches to PHP code when the dates fall outside
+the 32-bit signed integer range.
+
+GREGORIAN CORRECTION
+
+Pope Gregory shortened October of A.D. 1582 by ten days. Thursday,
+October 4, 1582 (Julian) was followed immediately by Friday, October 15,
+1582 (Gregorian).
+
+Since 0.06, we handle this correctly, so:
+
+adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)
+ == 24 * 3600 (1 day)
+
+=============================================================================
+
+COPYRIGHT
+
+(c) 2003-2005 John Lim and released under BSD-style license except for code by
+jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year
+and originally found at http://www.php.net/manual/en/function.mktime.php
+
+=============================================================================
+
+BUG REPORTS
+
+These should be posted to the ADOdb forums at
+
+ http://phplens.com/lens/lensforum/topics.php?id=4
+
+=============================================================================
+
+FUNCTION DESCRIPTIONS
+
+
+** FUNCTION adodb_getdate($date=false)
+
+Returns an array containing date information, as getdate(), but supports
+dates greater than 1901 to 2038. The local date/time format is derived from a
+heuristic the first time adodb_getdate is called.
+
+
+** FUNCTION adodb_date($fmt, $timestamp = false)
+
+Convert a timestamp to a formatted local date. If $timestamp is not defined, the
+current timestamp is used. Unlike the function date(), it supports dates
+outside the 1901 to 2038 range.
+
+The format fields that adodb_date supports:
+
+<pre>
+ a - "am" or "pm"
+ A - "AM" or "PM"
+ d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
+ D - day of the week, textual, 3 letters; e.g. "Fri"
+ F - month, textual, long; e.g. "January"
+ g - hour, 12-hour format without leading zeros; i.e. "1" to "12"
+ G - hour, 24-hour format without leading zeros; i.e. "0" to "23"
+ h - hour, 12-hour format; i.e. "01" to "12"
+ H - hour, 24-hour format; i.e. "00" to "23"
+ i - minutes; i.e. "00" to "59"
+ j - day of the month without leading zeros; i.e. "1" to "31"
+ l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"
+ L - boolean for whether it is a leap year; i.e. "0" or "1"
+ m - month; i.e. "01" to "12"
+ M - month, textual, 3 letters; e.g. "Jan"
+ n - month without leading zeros; i.e. "1" to "12"
+ O - Difference to Greenwich time in hours; e.g. "+0200"
+ Q - Quarter, as in 1, 2, 3, 4
+ r - RFC 822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200"
+ s - seconds; i.e. "00" to "59"
+ S - English ordinal suffix for the day of the month, 2 characters;
+ i.e. "st", "nd", "rd" or "th"
+ t - number of days in the given month; i.e. "28" to "31"
+ T - Timezone setting of this machine; e.g. "EST" or "MDT"
+ U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
+ w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
+ Y - year, 4 digits; e.g. "1999"
+ y - year, 2 digits; e.g. "99"
+ z - day of the year; i.e. "0" to "365"
+ Z - timezone offset in seconds (i.e. "-43200" to "43200").
+ The offset for timezones west of UTC is always negative,
+ and for those east of UTC is always positive.
+</pre>
+
+Unsupported:
+<pre>
+ B - Swatch Internet time
+ I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
+ W - ISO-8601 week number of year, weeks starting on Monday
+
+</pre>
+
+
+** FUNCTION adodb_date2($fmt, $isoDateString = false)
+Same as adodb_date, but 2nd parameter accepts iso date, eg.
+
+ adodb_date2('d-M-Y H:i','2003-12-25 13:01:34');
+
+
+** FUNCTION adodb_gmdate($fmt, $timestamp = false)
+
+Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the
+current timestamp is used. Unlike the function date(), it supports dates
+outside the 1901 to 2038 range.
+
+
+** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year])
+
+Converts a local date to a unix timestamp. Unlike the function mktime(), it supports
+dates outside the 1901 to 2038 range. All parameters are optional.
+
+
+** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year])
+
+Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports
+dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters
+are currently compulsory.
+
+** FUNCTION adodb_gmstrftime($fmt, $timestamp = false)
+Convert a timestamp to a formatted GMT date.
+
+** FUNCTION adodb_strftime($fmt, $timestamp = false)
+
+Convert a timestamp to a formatted local date. Internally converts $fmt into
+adodb_date format, then echo result.
+
+For best results, you can define the local date format yourself. Define a global
+variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using
+adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax.
+
+ eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s');
+
+ Supported format codes:
+
+<pre>
+ %a - abbreviated weekday name according to the current locale
+ %A - full weekday name according to the current locale
+ %b - abbreviated month name according to the current locale
+ %B - full month name according to the current locale
+ %c - preferred date and time representation for the current locale
+ %d - day of the month as a decimal number (range 01 to 31)
+ %D - same as %m/%d/%y
+ %e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31')
+ %h - same as %b
+ %H - hour as a decimal number using a 24-hour clock (range 00 to 23)
+ %I - hour as a decimal number using a 12-hour clock (range 01 to 12)
+ %m - month as a decimal number (range 01 to 12)
+ %M - minute as a decimal number
+ %n - newline character
+ %p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale
+ %r - time in a.m. and p.m. notation
+ %R - time in 24 hour notation
+ %S - second as a decimal number
+ %t - tab character
+ %T - current time, equal to %H:%M:%S
+ %x - preferred date representation for the current locale without the time
+ %X - preferred time representation for the current locale without the date
+ %y - year as a decimal number without a century (range 00 to 99)
+ %Y - year as a decimal number including the century
+ %Z - time zone or name or abbreviation
+ %% - a literal `%' character
+</pre>
+
+ Unsupported codes:
+<pre>
+ %C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
+ %g - like %G, but without the century.
+ %G - The 4-digit year corresponding to the ISO week number (see %V).
+ This has the same format and value as %Y, except that if the ISO week number belongs
+ to the previous or next year, that year is used instead.
+ %j - day of the year as a decimal number (range 001 to 366)
+ %u - weekday as a decimal number [1,7], with 1 representing Monday
+ %U - week number of the current year as a decimal number, starting
+ with the first Sunday as the first day of the first week
+ %V - The ISO 8601:1988 week number of the current year as a decimal number,
+ range 01 to 53, where week 1 is the first week that has at least 4 days in the
+ current year, and with Monday as the first day of the week. (Use %G or %g for
+ the year component that corresponds to the week number for the specified timestamp.)
+ %w - day of the week as a decimal, Sunday being 0
+ %W - week number of the current year as a decimal number, starting with the
+ first Monday as the first day of the first week
+</pre>
+
+=============================================================================
+
+NOTES
+
+Useful url for generating test timestamps:
+ http://www.4webhelp.net/us/timestamp.php
+
+Possible future optimizations include
+
+a. Using an algorithm similar to Plauger's in "The Standard C Library"
+(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not
+work outside 32-bit signed range, so i decided not to implement it.
+
+b. Implement daylight savings, which looks awfully complicated, see
+ http://webexhibits.org/daylightsaving/
+
+
+CHANGELOG
+
+- 18 July 2005 0.18
+- In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat.
+- Added support for negative months in adodb_mktime().
+
+- 24 Feb 2005
+Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date().
+
+- 21 Dec 2004 0.17
+In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false.
+Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro.
+
+- 17 Nov 2004 0.16
+Removed intval typecast in adodb_mktime() for secs, allowing:
+ adodb_mktime(0,0,0 + 2236672153,1,1,1934);
+Suggested by Ryan.
+
+- 18 July 2004 0.15
+All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory.
+This brings it more in line with mktime (still not identical).
+
+- 23 June 2004 0.14
+
+Allow you to define your own daylights savings function, adodb_daylight_sv.
+If the function is defined (somewhere in an include), then you can correct for daylights savings.
+
+In this example, we apply daylights savings in June or July, adding one hour. This is extremely
+unrealistic as it does not take into account time-zone, geographic location, current year.
+
+function adodb_daylight_sv(&$arr, $is_gmt)
+{
+ if ($is_gmt) return;
+ $m = $arr['mon'];
+ if ($m == 6 || $m == 7) $arr['hours'] += 1;
+}
+
+This is only called by adodb_date() and not by adodb_mktime().
+
+The format of $arr is
+Array (
+ [seconds] => 0
+ [minutes] => 0
+ [hours] => 0
+ [mday] => 1 # day of month, eg 1st day of the month
+ [mon] => 2 # month (eg. Feb)
+ [year] => 2102
+ [yday] => 31 # days in current year
+ [leap] => # true if leap year
+ [ndays] => 28 # no of days in current month
+ )
+
+
+- 28 Apr 2004 0.13
+Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov.
+
+- 20 Mar 2004 0.12
+Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32.
+
+- 26 Oct 2003 0.11
+Because of daylight savings problems (some systems apply daylight savings to
+January!!!), changed adodb_get_gmt_diff() to ignore daylight savings.
+
+- 9 Aug 2003 0.10
+Fixed bug with dates after 2038.
+See http://phplens.com/lens/lensforum/msgs.php?id=6980
+
+- 1 July 2003 0.09
+Added support for Q (Quarter).
+Added adodb_date2(), which accepts ISO date in 2nd param
+
+- 3 March 2003 0.08
+Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS
+if you want PHP to handle negative timestamps between 1901 to 1969.
+
+- 27 Feb 2003 0.07
+All negative numbers handled by adodb now because of RH 7.3+ problems.
+See http://bugs.php.net/bug.php?id=20048&edit=2
+
+- 4 Feb 2003 0.06
+Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates
+are now correctly handled.
+
+- 29 Jan 2003 0.05
+
+Leap year checking differs under Julian calendar (pre 1582). Also
+leap year code optimized by checking for most common case first.
+
+We also handle month overflow correctly in mktime (eg month set to 13).
+
+Day overflow for less than one month's days is supported.
+
+- 28 Jan 2003 0.04
+
+Gregorian correction handled. In PHP5, we might throw an error if
+mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10.
+Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582.
+
+- 27 Jan 2003 0.03
+
+Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION.
+Fixed calculation of days since start of year for <1970.
+
+- 27 Jan 2003 0.02
+
+Changed _adodb_getdate() to inline leap year checking for better performance.
+Fixed problem with time-zones west of GMT +0000.
+
+- 24 Jan 2003 0.01
+
+First implementation.
+*/
+
+
+/* Initialization */
+
+/*
+ Version Number
+*/
+define('ADODB_DATE_VERSION',0.18);
+
+/*
+ This code was originally for windows. But apparently this problem happens
+ also with Linux, RH 7.3 and later!
+
+ glibc-2.2.5-34 and greater has been changed to return -1 for dates <
+ 1970. This used to work. The problem exists with RedHat 7.3 and 8.0
+ echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1
+
+ References:
+ http://bugs.php.net/bug.php?id=20048&edit=2
+ http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html
+*/
+
+if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1);
+
+function adodb_date_test_date($y1,$m,$d=13)
+{
+ $t = adodb_mktime(0,0,0,$m,$d,$y1);
+ $rez = adodb_date('Y-n-j H:i:s',$t);
+ if ("$y1-$m-$d 00:00:00" != $rez) {
+ print "<b>$y1 error, expected=$y1-$m-$d 00:00:00, adodb=$rez</b><br>";
+ return false;
+ }
+ return true;
+}
+
+function adodb_date_test_strftime($fmt)
+{
+ $s1 = strftime($fmt);
+ $s2 = adodb_strftime($fmt);
+
+ if ($s1 == $s2) return true;
+
+ echo "error for $fmt, strftime=$s1, $adodb=$s2<br>";
+ return false;
+}
+
+/**
+ Test Suite
+*/
+function adodb_date_test()
+{
+
+ error_reporting(E_ALL);
+ print "<h4>Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION.' PHP='.PHP_VERSION."</h4>";
+ @set_time_limit(0);
+ $fail = false;
+
+ // This flag disables calling of PHP native functions, so we can properly test the code
+ if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1);
+
+ adodb_date_test_strftime('%Y %m %x %X');
+ adodb_date_test_strftime("%A %d %B %Y");
+ adodb_date_test_strftime("%H %M S");
+
+ $t = adodb_mktime(0,0,0);
+ if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'<br>';
+
+ $t = adodb_mktime(0,0,0,6,1,2102);
+ if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
+
+ $t = adodb_mktime(0,0,0,2,1,2102);
+ if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'<br>';
+
+
+ print "<p>Testing gregorian <=> julian conversion<p>";
+ $t = adodb_mktime(0,0,0,10,11,1492);
+ //http://www.holidayorigins.com/html/columbus_day.html - Friday check
+ if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing<br>';
+
+ $t = adodb_mktime(0,0,0,2,29,1500);
+ if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years<br>';
+
+ $t = adodb_mktime(0,0,0,2,29,1700);
+ if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years<br>';
+
+ print adodb_mktime(0,0,0,10,4,1582).' ';
+ print adodb_mktime(0,0,0,10,15,1582);
+ $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582));
+ if ($diff != 3600*24) print " <b>Error in gregorian correction = ".($diff/3600/24)." days </b><br>";
+
+ print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : '<b>Error</b>')."<br>";
+ print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : '<b>Error</b>')."<br>";
+
+ print "<p>Testing overflow<p>";
+
+ $t = adodb_mktime(0,0,0,3,33,1965);
+ if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1 <br>';
+ $t = adodb_mktime(0,0,0,4,33,1971);
+ if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2 <br>';
+ $t = adodb_mktime(0,0,0,1,60,1965);
+ if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).' <br>';
+ $t = adodb_mktime(0,0,0,12,32,1965);
+ if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).' <br>';
+ $t = adodb_mktime(0,0,0,12,63,1965);
+ if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).' <br>';
+ $t = adodb_mktime(0,0,0,13,3,1965);
+ if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1 <br>';
+
+ print "Testing 2-digit => 4-digit year conversion<p>";
+ if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000<br>";
+ if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010<br>";
+ if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020<br>";
+ if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030<br>";
+ if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940<br>";
+ if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950<br>";
+ if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990<br>";
+
+ // Test string formating
+ print "<p>Testing date formating</p>";
+ $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C822 r s t U w y Y z Z 2003';
+ $s1 = date($fmt,0);
+ $s2 = adodb_date($fmt,0);
+ if ($s1 != $s2) {
+ print " date() 0 failed<br>$s1<br>$s2<br>";
+ }
+ flush();
+ for ($i=100; --$i > 0; ) {
+
+ $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000);
+ $s1 = date($fmt,$ts);
+ $s2 = adodb_date($fmt,$ts);
+ //print "$s1 <br>$s2 <p>";
+ $pos = strcmp($s1,$s2);
+
+ if (($s1) != ($s2)) {
+ for ($j=0,$k=strlen($s1); $j < $k; $j++) {
+ if ($s1[$j] != $s2[$j]) {
+ print substr($s1,$j).' ';
+ break;
+ }
+ }
+ print "<b>Error date(): $ts<br><pre>
+&nbsp; \"$s1\" (date len=".strlen($s1).")
+&nbsp; \"$s2\" (adodb_date len=".strlen($s2).")</b></pre><br>";
+ $fail = true;
+ }
+
+ $a1 = getdate($ts);
+ $a2 = adodb_getdate($ts);
+ $rez = array_diff($a1,$a2);
+ if (sizeof($rez)>0) {
+ print "<b>Error getdate() $ts</b><br>";
+ print_r($a1);
+ print "<br>";
+ print_r($a2);
+ print "<p>";
+ $fail = true;
+ }
+ }
+
+ // Test generation of dates outside 1901-2038
+ print "<p>Testing random dates between 100 and 4000</p>";
+ adodb_date_test_date(100,1);
+ for ($i=100; --$i >= 0;) {
+ $y1 = 100+rand(0,1970-100);
+ $m = rand(1,12);
+ adodb_date_test_date($y1,$m);
+
+ $y1 = 3000-rand(0,3000-1970);
+ adodb_date_test_date($y1,$m);
+ }
+ print '<p>';
+ $start = 1960+rand(0,10);
+ $yrs = 12;
+ $i = 365.25*86400*($start-1970);
+ $offset = 36000+rand(10000,60000);
+ $max = 365*$yrs*86400;
+ $lastyear = 0;
+
+ // we generate a timestamp, convert it to a date, and convert it back to a timestamp
+ // and check if the roundtrip broke the original timestamp value.
+ print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: ";
+ $cnt = 0;
+ for ($max += $i; $i < $max; $i += $offset) {
+ $ret = adodb_date('m,d,Y,H,i,s',$i);
+ $arr = explode(',',$ret);
+ if ($lastyear != $arr[2]) {
+ $lastyear = $arr[2];
+ print " $lastyear ";
+ flush();
+ }
+ $newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]);
+ if ($i != $newi) {
+ print "Error at $i, adodb_mktime returned $newi ($ret)";
+ $fail = true;
+ break;
+ }
+ $cnt += 1;
+ }
+ echo "Tested $cnt dates<br>";
+ if (!$fail) print "<p>Passed !</p>";
+ else print "<p><b>Failed</b> :-(</p>";
+}
+
+/**
+ Returns day of week, 0 = Sunday,... 6=Saturday.
+ Algorithm from PEAR::Date_Calc
+*/
+function adodb_dow($year, $month, $day)
+{
+/*
+Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and
+proclaimed that from that time onwards 3 days would be dropped from the calendar
+every 400 years.
+
+Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian).
+*/
+ if ($year <= 1582) {
+ if ($year < 1582 ||
+ ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3;
+ else
+ $greg_correction = 0;
+ } else
+ $greg_correction = 0;
+
+ if($month > 2)
+ $month -= 2;
+ else {
+ $month += 10;
+ $year--;
+ }
+
+ $day = floor((13 * $month - 1) / 5) +
+ $day + ($year % 100) +
+ floor(($year % 100) / 4) +
+ floor(($year / 100) / 4) - 2 *
+ floor($year / 100) + 77 + $greg_correction;
+
+ return $day - 7 * floor($day / 7);
+}
+
+
+/**
+ Checks for leap year, returns true if it is. No 2-digit year check. Also
+ handles julian calendar correctly.
+*/
+function _adodb_is_leap_year($year)
+{
+ if ($year % 4 != 0) return false;
+
+ if ($year % 400 == 0) {
+ return true;
+ // if gregorian calendar (>1582), century not-divisible by 400 is not leap
+ } else if ($year > 1582 && $year % 100 == 0 ) {
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ checks for leap year, returns true if it is. Has 2-digit year check
+*/
+function adodb_is_leap_year($year)
+{
+ return _adodb_is_leap_year(adodb_year_digit_check($year));
+}
+
+/**
+ Fix 2-digit years. Works for any century.
+ Assumes that if 2-digit is more than 30 years in future, then previous century.
+*/
+function adodb_year_digit_check($y)
+{
+ if ($y < 100) {
+
+ $yr = (integer) date("Y");
+ $century = (integer) ($yr /100);
+
+ if ($yr%100 > 50) {
+ $c1 = $century + 1;
+ $c0 = $century;
+ } else {
+ $c1 = $century;
+ $c0 = $century - 1;
+ }
+ $c1 *= 100;
+ // if 2-digit year is less than 30 years in future, set it to this century
+ // otherwise if more than 30 years in future, then we set 2-digit year to the prev century.
+ if (($y + $c1) < $yr+30) $y = $y + $c1;
+ else $y = $y + $c0*100;
+ }
+ return $y;
+}
+
+/**
+ get local time zone offset from GMT
+*/
+function adodb_get_gmt_diff()
+{
+static $TZ;
+ if (isset($TZ)) return $TZ;
+
+ $TZ = mktime(0,0,0,1,2,1970,0) - gmmktime(0,0,0,1,2,1970,0);
+ return $TZ;
+}
+
+/**
+ Returns an array with date info.
+*/
+function adodb_getdate($d=false,$fast=false)
+{
+ if ($d === false) return getdate();
+ if (!defined('ADODB_TEST_DATES')) {
+ if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
+ if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
+ return @getdate($d);
+ }
+ }
+ return _adodb_getdate($d);
+}
+
+/*
+// generate $YRS table for _adodb_getdate()
+function adodb_date_gentable($out=true)
+{
+
+ for ($i=1970; $i >= 1600; $i-=10) {
+ $s = adodb_gmmktime(0,0,0,1,1,$i);
+ echo "$i => $s,<br>";
+ }
+}
+adodb_date_gentable();
+
+for ($i=1970; $i > 1500; $i--) {
+
+echo "<hr>$i ";
+ adodb_date_test_date($i,1,1);
+}
+
+*/
+
+/**
+ Low-level function that returns the getdate() array. We have a special
+ $fast flag, which if set to true, will return fewer array values,
+ and is much faster as it does not calculate dow, etc.
+*/
+function _adodb_getdate($origd=false,$fast=false,$is_gmt=false)
+{
+static $YRS;
+
+ $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff());
+
+ $_day_power = 86400;
+ $_hour_power = 3600;
+ $_min_power = 60;
+
+ if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction
+
+ $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
+ $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
+
+ $d366 = $_day_power * 366;
+ $d365 = $_day_power * 365;
+
+ if ($d < 0) {
+
+ if (empty($YRS)) $YRS = array(
+ 1970 => 0,
+ 1960 => -315619200,
+ 1950 => -631152000,
+ 1940 => -946771200,
+ 1930 => -1262304000,
+ 1920 => -1577923200,
+ 1910 => -1893456000,
+ 1900 => -2208988800,
+ 1890 => -2524521600,
+ 1880 => -2840140800,
+ 1870 => -3155673600,
+ 1860 => -3471292800,
+ 1850 => -3786825600,
+ 1840 => -4102444800,
+ 1830 => -4417977600,
+ 1820 => -4733596800,
+ 1810 => -5049129600,
+ 1800 => -5364662400,
+ 1790 => -5680195200,
+ 1780 => -5995814400,
+ 1770 => -6311347200,
+ 1760 => -6626966400,
+ 1750 => -6942499200,
+ 1740 => -7258118400,
+ 1730 => -7573651200,
+ 1720 => -7889270400,
+ 1710 => -8204803200,
+ 1700 => -8520336000,
+ 1690 => -8835868800,
+ 1680 => -9151488000,
+ 1670 => -9467020800,
+ 1660 => -9782640000,
+ 1650 => -10098172800,
+ 1640 => -10413792000,
+ 1630 => -10729324800,
+ 1620 => -11044944000,
+ 1610 => -11360476800,
+ 1600 => -11676096000);
+
+ if ($is_gmt) $origd = $d;
+ // The valid range of a 32bit signed timestamp is typically from
+ // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT
+ //
+
+ # old algorithm iterates through all years. new algorithm does it in
+ # 10 year blocks
+
+ /*
+ # old algo
+ for ($a = 1970 ; --$a >= 0;) {
+ $lastd = $d;
+
+ if ($leaf = _adodb_is_leap_year($a)) $d += $d366;
+ else $d += $d365;
+
+ if ($d >= 0) {
+ $year = $a;
+ break;
+ }
+ }
+ */
+
+ $lastsecs = 0;
+ $lastyear = 1970;
+ foreach($YRS as $year => $secs) {
+ if ($d >= $secs) {
+ $a = $lastyear;
+ break;
+ }
+ $lastsecs = $secs;
+ $lastyear = $year;
+ }
+
+ $d -= $lastsecs;
+ if (!isset($a)) $a = $lastyear;
+
+ //echo ' yr=',$a,' ', $d,'.';
+
+ for (; --$a >= 0;) {
+ $lastd = $d;
+
+ if ($leaf = _adodb_is_leap_year($a)) $d += $d366;
+ else $d += $d365;
+
+ if ($d >= 0) {
+ $year = $a;
+ break;
+ }
+ }
+ /**/
+
+ $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd;
+
+ $d = $lastd;
+ $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
+ for ($a = 13 ; --$a > 0;) {
+ $lastd = $d;
+ $d += $mtab[$a] * $_day_power;
+ if ($d >= 0) {
+ $month = $a;
+ $ndays = $mtab[$a];
+ break;
+ }
+ }
+
+ $d = $lastd;
+ $day = $ndays + ceil(($d+1) / ($_day_power));
+
+ $d += ($ndays - $day+1)* $_day_power;
+ $hour = floor($d/$_hour_power);
+
+ } else {
+ for ($a = 1970 ;; $a++) {
+ $lastd = $d;
+
+ if ($leaf = _adodb_is_leap_year($a)) $d -= $d366;
+ else $d -= $d365;
+ if ($d < 0) {
+ $year = $a;
+ break;
+ }
+ }
+ $secsInYear = $lastd;
+ $d = $lastd;
+ $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal;
+ for ($a = 1 ; $a <= 12; $a++) {
+ $lastd = $d;
+ $d -= $mtab[$a] * $_day_power;
+ if ($d < 0) {
+ $month = $a;
+ $ndays = $mtab[$a];
+ break;
+ }
+ }
+ $d = $lastd;
+ $day = ceil(($d+1) / $_day_power);
+ $d = $d - ($day-1) * $_day_power;
+ $hour = floor($d /$_hour_power);
+ }
+
+ $d -= $hour * $_hour_power;
+ $min = floor($d/$_min_power);
+ $secs = $d - $min * $_min_power;
+ if ($fast) {
+ return array(
+ 'seconds' => $secs,
+ 'minutes' => $min,
+ 'hours' => $hour,
+ 'mday' => $day,
+ 'mon' => $month,
+ 'year' => $year,
+ 'yday' => floor($secsInYear/$_day_power),
+ 'leap' => $leaf,
+ 'ndays' => $ndays
+ );
+ }
+
+
+ $dow = adodb_dow($year,$month,$day);
+
+ return array(
+ 'seconds' => $secs,
+ 'minutes' => $min,
+ 'hours' => $hour,
+ 'mday' => $day,
+ 'wday' => $dow,
+ 'mon' => $month,
+ 'year' => $year,
+ 'yday' => floor($secsInYear/$_day_power),
+ 'weekday' => gmdate('l',$_day_power*(3+$dow)),
+ 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
+ 0 => $origd
+ );
+}
+
+function adodb_gmdate($fmt,$d=false)
+{
+ return adodb_date($fmt,$d,true);
+}
+
+// accepts unix timestamp and iso date format in $d
+function adodb_date2($fmt, $d=false, $is_gmt=false)
+{
+ if ($d !== false) {
+ if (!preg_match(
+ "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
+ ($d), $rr)) return adodb_date($fmt,false,$is_gmt);
+
+ if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt);
+
+ // h-m-s-MM-DD-YY
+ if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
+ else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
+ }
+
+ return adodb_date($fmt,$d,$is_gmt);
+}
+
+
+/**
+ Return formatted date based on timestamp $d
+*/
+function adodb_date($fmt,$d=false,$is_gmt=false)
+{
+static $daylight;
+
+ if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt);
+ if (!defined('ADODB_TEST_DATES')) {
+ if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
+ if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer
+ return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d);
+
+ }
+ }
+ $_day_power = 86400;
+
+ $arr = _adodb_getdate($d,true,$is_gmt);
+
+ if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv');
+ if ($daylight) adodb_daylight_sv($arr, $is_gmt);
+
+ $year = $arr['year'];
+ $month = $arr['mon'];
+ $day = $arr['mday'];
+ $hour = $arr['hours'];
+ $min = $arr['minutes'];
+ $secs = $arr['seconds'];
+
+ $max = strlen($fmt);
+ $dates = '';
+
+ /*
+ at this point, we have the following integer vars to manipulate:
+ $year, $month, $day, $hour, $min, $secs
+ */
+ for ($i=0; $i < $max; $i++) {
+ switch($fmt[$i]) {
+ case 'T': $dates .= date('T');break;
+ // YEAR
+ case 'L': $dates .= $arr['leap'] ? '1' : '0'; break;
+ case 'r': // Thu, 21 Dec 2000 16:01:07 +0200
+
+ // 4.3.11 uses '04 Jun 2004'
+ // 4.3.8 uses ' 4 Jun 2004'
+ $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', '
+ . ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' ';
+
+ if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour;
+
+ if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min;
+
+ if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs;
+
+ $gmt = adodb_get_gmt_diff();
+ $dates .= sprintf(' %s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
+
+ case 'Y': $dates .= $year; break;
+ case 'y': $dates .= substr($year,strlen($year)-2,2); break;
+ // MONTH
+ case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break;
+ case 'Q': $dates .= ($month+3)>>2; break;
+ case 'n': $dates .= $month; break;
+ case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break;
+ case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break;
+ // DAY
+ case 't': $dates .= $arr['ndays']; break;
+ case 'z': $dates .= $arr['yday']; break;
+ case 'w': $dates .= adodb_dow($year,$month,$day); break;
+ case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break;
+ case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break;
+ case 'j': $dates .= $day; break;
+ case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break;
+ case 'S':
+ $d10 = $day % 10;
+ if ($d10 == 1) $dates .= 'st';
+ else if ($d10 == 2 && $day != 12) $dates .= 'nd';
+ else if ($d10 == 3) $dates .= 'rd';
+ else $dates .= 'th';
+ break;
+
+ // HOUR
+ case 'Z':
+ $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff(); break;
+ case 'O':
+ $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff();
+ $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); break;
+
+ case 'H':
+ if ($hour < 10) $dates .= '0'.$hour;
+ else $dates .= $hour;
+ break;
+ case 'h':
+ if ($hour > 12) $hh = $hour - 12;
+ else {
+ if ($hour == 0) $hh = '12';
+ else $hh = $hour;
+ }
+
+ if ($hh < 10) $dates .= '0'.$hh;
+ else $dates .= $hh;
+ break;
+
+ case 'G':
+ $dates .= $hour;
+ break;
+
+ case 'g':
+ if ($hour > 12) $hh = $hour - 12;
+ else {
+ if ($hour == 0) $hh = '12';
+ else $hh = $hour;
+ }
+ $dates .= $hh;
+ break;
+ // MINUTES
+ case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break;
+ // SECONDS
+ case 'U': $dates .= $d; break;
+ case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break;
+ // AM/PM
+ // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM
+ case 'a':
+ if ($hour>=12) $dates .= 'pm';
+ else $dates .= 'am';
+ break;
+ case 'A':
+ if ($hour>=12) $dates .= 'PM';
+ else $dates .= 'AM';
+ break;
+ default:
+ $dates .= $fmt[$i]; break;
+ // ESCAPE
+ case "\\":
+ $i++;
+ if ($i < $max) $dates .= $fmt[$i];
+ break;
+ }
+ }
+ return $dates;
+}
+
+/**
+ Returns a timestamp given a GMT/UTC time.
+ Note that $is_dst is not implemented and is ignored.
+*/
+function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false)
+{
+ return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true);
+}
+
+/**
+ Return a timestamp given a local time. Originally by jackbbs.
+ Note that $is_dst is not implemented and is ignored.
+
+ Not a very fast algorithm - O(n) operation. Could be optimized to O(1).
+*/
+function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false)
+{
+ if (!defined('ADODB_TEST_DATES')) {
+
+ if ($mon === false) {
+ return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
+ }
+
+ // for windows, we don't check 1970 because with timezone differences,
+ // 1 Jan 1970 could generate negative timestamp, which is illegal
+ if (1971 < $year && $year < 2038
+ || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038)
+ ) {
+ return $is_gmt ?
+ @gmmktime($hr,$min,$sec,$mon,$day,$year):
+ @mktime($hr,$min,$sec,$mon,$day,$year);
+ }
+ }
+
+ $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff();
+
+ /*
+ # disabled because some people place large values in $sec.
+ # however we need it for $mon because we use an array...
+ $hr = intval($hr);
+ $min = intval($min);
+ $sec = intval($sec);
+ */
+ $mon = intval($mon);
+ $day = intval($day);
+ $year = intval($year);
+
+
+ $year = adodb_year_digit_check($year);
+
+ if ($mon > 12) {
+ $y = floor($mon / 12);
+ $year += $y;
+ $mon -= $y*12;
+ } else if ($mon < 1) {
+ $y = ceil((1-$mon) / 12);
+ $year -= $y;
+ $mon += $y*12;
+ }
+
+ $_day_power = 86400;
+ $_hour_power = 3600;
+ $_min_power = 60;
+
+ $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31);
+ $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31);
+
+ $_total_date = 0;
+ if ($year >= 1970) {
+ for ($a = 1970 ; $a <= $year; $a++) {
+ $leaf = _adodb_is_leap_year($a);
+ if ($leaf == true) {
+ $loop_table = $_month_table_leaf;
+ $_add_date = 366;
+ } else {
+ $loop_table = $_month_table_normal;
+ $_add_date = 365;
+ }
+ if ($a < $year) {
+ $_total_date += $_add_date;
+ } else {
+ for($b=1;$b<$mon;$b++) {
+ $_total_date += $loop_table[$b];
+ }
+ }
+ }
+ $_total_date +=$day-1;
+ $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
+
+ } else {
+ for ($a = 1969 ; $a >= $year; $a--) {
+ $leaf = _adodb_is_leap_year($a);
+ if ($leaf == true) {
+ $loop_table = $_month_table_leaf;
+ $_add_date = 366;
+ } else {
+ $loop_table = $_month_table_normal;
+ $_add_date = 365;
+ }
+ if ($a > $year) { $_total_date += $_add_date;
+ } else {
+ for($b=12;$b>$mon;$b--) {
+ $_total_date += $loop_table[$b];
+ }
+ }
+ }
+ $_total_date += $loop_table[$mon] - $day;
+
+ $_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
+ $_day_time = $_day_power - $_day_time;
+ $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different);
+ if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction
+ else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582.
+ }
+ //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret;
+ return $ret;
+}
+
+function adodb_gmstrftime($fmt, $ts=false)
+{
+ return adodb_strftime($fmt,$ts,true);
+}
+
+// hack - convert to adodb_date
+function adodb_strftime($fmt, $ts=false,$is_gmt=false)
+{
+global $ADODB_DATE_LOCALE;
+
+ if (!defined('ADODB_TEST_DATES')) {
+ if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
+ if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0) // if windows, must be +ve integer
+ return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts);
+
+ }
+ }
+
+ if (empty($ADODB_DATE_LOCALE)) {
+ $tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am
+ $sep = substr($tstr,2,1);
+ $hasAM = strrpos($tstr,'M') !== false;
+
+ $ADODB_DATE_LOCALE = array();
+ $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y';
+ $ADODB_DATE_LOCALE[] = ($hasAM) ? 'h:i:s a' : 'H:i:s';
+
+ }
+ $inpct = false;
+ $fmtdate = '';
+ for ($i=0,$max = strlen($fmt); $i < $max; $i++) {
+ $ch = $fmt[$i];
+ if ($ch == '%') {
+ if ($inpct) {
+ $fmtdate .= '%';
+ $inpct = false;
+ } else
+ $inpct = true;
+ } else if ($inpct) {
+
+ $inpct = false;
+ switch($ch) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case 'E':
+ case 'O':
+ /* ignore format modifiers */
+ $inpct = true;
+ break;
+
+ case 'a': $fmtdate .= 'D'; break;
+ case 'A': $fmtdate .= 'l'; break;
+ case 'h':
+ case 'b': $fmtdate .= 'M'; break;
+ case 'B': $fmtdate .= 'F'; break;
+ case 'c': $fmtdate .= $ADODB_DATE_LOCALE[0].$ADODB_DATE_LOCALE[1]; break;
+ case 'C': $fmtdate .= '\C?'; break; // century
+ case 'd': $fmtdate .= 'd'; break;
+ case 'D': $fmtdate .= 'm/d/y'; break;
+ case 'e': $fmtdate .= 'j'; break;
+ case 'g': $fmtdate .= '\g?'; break; //?
+ case 'G': $fmtdate .= '\G?'; break; //?
+ case 'H': $fmtdate .= 'H'; break;
+ case 'I': $fmtdate .= 'h'; break;
+ case 'j': $fmtdate .= '?z'; $parsej = true; break; // wrong as j=1-based, z=0-basd
+ case 'm': $fmtdate .= 'm'; break;
+ case 'M': $fmtdate .= 'i'; break;
+ case 'n': $fmtdate .= "\n"; break;
+ case 'p': $fmtdate .= 'a'; break;
+ case 'r': $fmtdate .= 'h:i:s a'; break;
+ case 'R': $fmtdate .= 'H:i:s'; break;
+ case 'S': $fmtdate .= 's'; break;
+ case 't': $fmtdate .= "\t"; break;
+ case 'T': $fmtdate .= 'H:i:s'; break;
+ case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
+ case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based
+ case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break;
+ case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break;
+ case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-basde
+ case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based
+ case 'y': $fmtdate .= 'y'; break;
+ case 'Y': $fmtdate .= 'Y'; break;
+ case 'Z': $fmtdate .= 'T'; break;
+ }
+ } else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' ))
+ $fmtdate .= "\\".$ch;
+ else
+ $fmtdate .= $ch;
+ }
+ //echo "fmt=",$fmtdate,"<br>";
+ if ($ts === false) $ts = time();
+ $ret = adodb_date($fmtdate, $ts, $is_gmt);
+ return $ret;
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb-xmlschema.inc.php b/html/phpgacl/adodb/adodb-xmlschema.inc.php
new file mode 100644
index 0000000..1e0e328
--- /dev/null
+++ b/html/phpgacl/adodb/adodb-xmlschema.inc.php
@@ -0,0 +1,2195 @@
+<?php
+// Copyright (c) 2004 ars Cognita Inc., all rights reserved
+/* ******************************************************************************
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+*******************************************************************************/
+/**
+ * xmlschema is a class that allows the user to quickly and easily
+ * build a database on any ADOdb-supported platform using a simple
+ * XML schema.
+ *
+ * Last Editor: $Author: ipso $
+ * @author Richard Tango-Lowy & Dan Cech
+ * @version $Revision: 1.23 $
+ *
+ * @package axmls
+ * @tutorial getting_started.pkg
+ */
+
+/**
+* Debug on or off
+*/
+if( !defined( 'XMLS_DEBUG' ) ) {
+ define( 'XMLS_DEBUG', FALSE );
+}
+
+/**
+* Default prefix key
+*/
+if( !defined( 'XMLS_PREFIX' ) ) {
+ define( 'XMLS_PREFIX', '%%P' );
+}
+
+/**
+* Maximum length allowed for object prefix
+*/
+if( !defined( 'XMLS_PREFIX_MAXLEN' ) ) {
+ define( 'XMLS_PREFIX_MAXLEN', 10 );
+}
+
+/**
+* Execute SQL inline as it is generated
+*/
+if( !defined( 'XMLS_EXECUTE_INLINE' ) ) {
+ define( 'XMLS_EXECUTE_INLINE', FALSE );
+}
+
+/**
+* Continue SQL Execution if an error occurs?
+*/
+if( !defined( 'XMLS_CONTINUE_ON_ERROR' ) ) {
+ define( 'XMLS_CONTINUE_ON_ERROR', FALSE );
+}
+
+/**
+* Current Schema Version
+*/
+if( !defined( 'XMLS_SCHEMA_VERSION' ) ) {
+ define( 'XMLS_SCHEMA_VERSION', '0.2' );
+}
+
+/**
+* Default Schema Version. Used for Schemas without an explicit version set.
+*/
+if( !defined( 'XMLS_DEFAULT_SCHEMA_VERSION' ) ) {
+ define( 'XMLS_DEFAULT_SCHEMA_VERSION', '0.1' );
+}
+
+/**
+* Default Schema Version. Used for Schemas without an explicit version set.
+*/
+if( !defined( 'XMLS_DEFAULT_UPGRADE_METHOD' ) ) {
+ define( 'XMLS_DEFAULT_UPGRADE_METHOD', 'ALTER' );
+}
+
+/**
+* Include the main ADODB library
+*/
+if( !defined( '_ADODB_LAYER' ) ) {
+ require( 'adodb.inc.php' );
+ require( 'adodb-datadict.inc.php' );
+}
+
+/**
+* Abstract DB Object. This class provides basic methods for database objects, such
+* as tables and indexes.
+*
+* @package axmls
+* @access private
+*/
+class dbObject {
+
+ /**
+ * var object Parent
+ */
+ var $parent;
+
+ /**
+ * var string current element
+ */
+ var $currentElement;
+
+ /**
+ * NOP
+ */
+ function dbObject( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+ }
+
+ /**
+ * XML Callback to process start elements
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+
+ }
+
+ function create() {
+ return array();
+ }
+
+ /**
+ * Destroys the object
+ */
+ function destroy() {
+ unset( $this );
+ }
+
+ /**
+ * Checks whether the specified RDBMS is supported by the current
+ * database object or its ranking ancestor.
+ *
+ * @param string $platform RDBMS platform name (from ADODB platform list).
+ * @return boolean TRUE if RDBMS is supported; otherwise returns FALSE.
+ */
+ function supportedPlatform( $platform = NULL ) {
+ return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE;
+ }
+
+ /**
+ * Returns the prefix set by the ranking ancestor of the database object.
+ *
+ * @param string $name Prefix string.
+ * @return string Prefix.
+ */
+ function prefix( $name = '' ) {
+ return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name;
+ }
+
+ /**
+ * Extracts a field ID from the specified field.
+ *
+ * @param string $field Field.
+ * @return string Field ID.
+ */
+ function FieldID( $field ) {
+ return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) );
+ }
+}
+
+/**
+* Creates a table object in ADOdb's datadict format
+*
+* This class stores information about a database table. As charactaristics
+* of the table are loaded from the external source, methods and properties
+* of this class are used to build up the table description in ADOdb's
+* datadict format.
+*
+* @package axmls
+* @access private
+*/
+class dbTable extends dbObject {
+
+ /**
+ * @var string Table name
+ */
+ var $name;
+
+ /**
+ * @var array Field specifier: Meta-information about each field
+ */
+ var $fields = array();
+
+ /**
+ * @var array List of table indexes.
+ */
+ var $indexes = array();
+
+ /**
+ * @var array Table options: Table-level options
+ */
+ var $opts = array();
+
+ /**
+ * @var string Field index: Keeps track of which field is currently being processed
+ */
+ var $current_field;
+
+ /**
+ * @var boolean Mark table for destruction
+ * @access private
+ */
+ var $drop_table;
+
+ /**
+ * @var boolean Mark field for destruction (not yet implemented)
+ * @access private
+ */
+ var $drop_field = array();
+
+ /**
+ * Iniitializes a new table object.
+ *
+ * @param string $prefix DB Object prefix
+ * @param array $attributes Array of table attributes.
+ */
+ function dbTable( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+ $this->name = $this->prefix($attributes['NAME']);
+ }
+
+ /**
+ * XML Callback to process start elements. Elements currently
+ * processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT.
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ $this->currentElement = strtoupper( $tag );
+
+ switch( $this->currentElement ) {
+ case 'INDEX':
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ xml_set_object( $parser, $this->addIndex( $attributes ) );
+ }
+ break;
+ case 'DATA':
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ xml_set_object( $parser, $this->addData( $attributes ) );
+ }
+ break;
+ case 'DROP':
+ $this->drop();
+ break;
+ case 'FIELD':
+ // Add a field
+ $fieldName = $attributes['NAME'];
+ $fieldType = $attributes['TYPE'];
+ $fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL;
+ $fieldOpts = isset( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL;
+
+ $this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts );
+ break;
+ case 'KEY':
+ case 'NOTNULL':
+ case 'AUTOINCREMENT':
+ // Add a field option
+ $this->addFieldOpt( $this->current_field, $this->currentElement );
+ break;
+ case 'DEFAULT':
+ // Add a field option to the table object
+
+ // Work around ADOdb datadict issue that misinterprets empty strings.
+ if( $attributes['VALUE'] == '' ) {
+ $attributes['VALUE'] = " '' ";
+ }
+
+ $this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] );
+ break;
+ case 'DEFDATE':
+ case 'DEFTIMESTAMP':
+ // Add a field option to the table object
+ $this->addFieldOpt( $this->current_field, $this->currentElement );
+ break;
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ switch( $this->currentElement ) {
+ // Table constraint
+ case 'CONSTRAINT':
+ if( isset( $this->current_field ) ) {
+ $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata );
+ } else {
+ $this->addTableOpt( $cdata );
+ }
+ break;
+ // Table option
+ case 'OPT':
+ $this->addTableOpt( $cdata );
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+ $this->currentElement = '';
+
+ switch( strtoupper( $tag ) ) {
+ case 'TABLE':
+ $this->parent->addSQL( $this->create( $this->parent ) );
+ xml_set_object( $parser, $this->parent );
+ $this->destroy();
+ break;
+ case 'FIELD':
+ unset($this->current_field);
+ break;
+
+ }
+ }
+
+ /**
+ * Adds an index to a table object
+ *
+ * @param array $attributes Index attributes
+ * @return object dbIndex object
+ */
+ function &addIndex( $attributes ) {
+ $name = strtoupper( $attributes['NAME'] );
+ $this->indexes[$name] =& new dbIndex( $this, $attributes );
+ return $this->indexes[$name];
+ }
+
+ /**
+ * Adds data to a table object
+ *
+ * @param array $attributes Data attributes
+ * @return object dbData object
+ */
+ function &addData( $attributes ) {
+ if( !isset( $this->data ) ) {
+ $this->data =& new dbData( $this, $attributes );
+ }
+ return $this->data;
+ }
+
+ /**
+ * Adds a field to a table object
+ *
+ * $name is the name of the table to which the field should be added.
+ * $type is an ADODB datadict field type. The following field types
+ * are supported as of ADODB 3.40:
+ * - C: varchar
+ * - X: CLOB (character large object) or largest varchar size
+ * if CLOB is not supported
+ * - C2: Multibyte varchar
+ * - X2: Multibyte CLOB
+ * - B: BLOB (binary large object)
+ * - D: Date (some databases do not support this, and we return a datetime type)
+ * - T: Datetime or Timestamp
+ * - L: Integer field suitable for storing booleans (0 or 1)
+ * - I: Integer (mapped to I4)
+ * - I1: 1-byte integer
+ * - I2: 2-byte integer
+ * - I4: 4-byte integer
+ * - I8: 8-byte integer
+ * - F: Floating point number
+ * - N: Numeric or decimal number
+ *
+ * @param string $name Name of the table to which the field will be added.
+ * @param string $type ADODB datadict field type.
+ * @param string $size Field size
+ * @param array $opts Field options array
+ * @return array Field specifier array
+ */
+ function addField( $name, $type, $size = NULL, $opts = NULL ) {
+ $field_id = $this->FieldID( $name );
+
+ // Set the field index so we know where we are
+ $this->current_field = $field_id;
+
+ // Set the field name (required)
+ $this->fields[$field_id]['NAME'] = $name;
+
+ // Set the field type (required)
+ $this->fields[$field_id]['TYPE'] = $type;
+
+ // Set the field size (optional)
+ if( isset( $size ) ) {
+ $this->fields[$field_id]['SIZE'] = $size;
+ }
+
+ // Set the field options
+ if( isset( $opts ) ) {
+ $this->fields[$field_id]['OPTS'][] = $opts;
+ }
+ }
+
+ /**
+ * Adds a field option to the current field specifier
+ *
+ * This method adds a field option allowed by the ADOdb datadict
+ * and appends it to the given field.
+ *
+ * @param string $field Field name
+ * @param string $opt ADOdb field option
+ * @param mixed $value Field option value
+ * @return array Field specifier array
+ */
+ function addFieldOpt( $field, $opt, $value = NULL ) {
+ if( !isset( $value ) ) {
+ $this->fields[$this->FieldID( $field )]['OPTS'][] = $opt;
+ // Add the option and value
+ } else {
+ $this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value );
+ }
+ }
+
+ /**
+ * Adds an option to the table
+ *
+ * This method takes a comma-separated list of table-level options
+ * and appends them to the table object.
+ *
+ * @param string $opt Table option
+ * @return array Options
+ */
+ function addTableOpt( $opt ) {
+ $this->opts[] = $opt;
+
+ return $this->opts;
+ }
+
+ /**
+ * Generates the SQL that will create the table in the database
+ *
+ * @param object $xmls adoSchema object
+ * @return array Array containing table creation SQL
+ */
+ function create( &$xmls ) {
+ $sql = array();
+
+ // drop any existing indexes
+ if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) {
+ foreach( $legacy_indexes as $index => $index_details ) {
+ $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name );
+ }
+ }
+
+ // remove fields to be dropped from table object
+ foreach( $this->drop_field as $field ) {
+ unset( $this->fields[$field] );
+ }
+
+ // if table exists
+ if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) {
+ // drop table
+ if( $this->drop_table ) {
+ $sql[] = $xmls->dict->DropTableSQL( $this->name );
+
+ return $sql;
+ }
+
+ // drop any existing fields not in schema
+ foreach( $legacy_fields as $field_id => $field ) {
+ if( !isset( $this->fields[$field_id] ) ) {
+ $sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' );
+ }
+ }
+ // if table doesn't exist
+ } else {
+ if( $this->drop_table ) {
+ return $sql;
+ }
+
+ $legacy_fields = array();
+ }
+
+ // Loop through the field specifier array, building the associative array for the field options
+ $fldarray = array();
+
+ foreach( $this->fields as $field_id => $finfo ) {
+ // Set an empty size if it isn't supplied
+ if( !isset( $finfo['SIZE'] ) ) {
+ $finfo['SIZE'] = '';
+ }
+
+ // Initialize the field array with the type and size
+ $fldarray[$field_id] = array(
+ 'NAME' => $finfo['NAME'],
+ 'TYPE' => $finfo['TYPE'],
+ 'SIZE' => $finfo['SIZE']
+ );
+
+ // Loop through the options array and add the field options.
+ if( isset( $finfo['OPTS'] ) ) {
+ foreach( $finfo['OPTS'] as $opt ) {
+ // Option has an argument.
+ if( is_array( $opt ) ) {
+ $key = key( $opt );
+ $value = $opt[key( $opt )];
+ @$fldarray[$field_id][$key] .= $value;
+ // Option doesn't have arguments
+ } else {
+ $fldarray[$field_id][$opt] = $opt;
+ }
+ }
+ }
+ }
+
+ if( empty( $legacy_fields ) ) {
+ // Create the new table
+ $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
+ logMsg( end( $sql ), 'Generated CreateTableSQL' );
+ } else {
+ // Upgrade an existing table
+ logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" );
+ switch( $xmls->upgrade ) {
+ // Use ChangeTableSQL
+ case 'ALTER':
+ logMsg( 'Generated ChangeTableSQL (ALTERing table)' );
+ $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts );
+ break;
+ case 'REPLACE':
+ logMsg( 'Doing upgrade REPLACE (testing)' );
+ $sql[] = $xmls->dict->DropTableSQL( $this->name );
+ $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts );
+ break;
+ // ignore table
+ default:
+ return array();
+ }
+ }
+
+ foreach( $this->indexes as $index ) {
+ $sql[] = $index->create( $xmls );
+ }
+
+ if( isset( $this->data ) ) {
+ $sql[] = $this->data->create( $xmls );
+ }
+
+ return $sql;
+ }
+
+ /**
+ * Marks a field or table for destruction
+ */
+ function drop() {
+ if( isset( $this->current_field ) ) {
+ // Drop the current field
+ logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" );
+ // $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field );
+ $this->drop_field[$this->current_field] = $this->current_field;
+ } else {
+ // Drop the current table
+ logMsg( "Dropping table '{$this->name}'" );
+ // $this->drop_table = $xmls->dict->DropTableSQL( $this->name );
+ $this->drop_table = TRUE;
+ }
+ }
+}
+
+/**
+* Creates an index object in ADOdb's datadict format
+*
+* This class stores information about a database index. As charactaristics
+* of the index are loaded from the external source, methods and properties
+* of this class are used to build up the index description in ADOdb's
+* datadict format.
+*
+* @package axmls
+* @access private
+*/
+class dbIndex extends dbObject {
+
+ /**
+ * @var string Index name
+ */
+ var $name;
+
+ /**
+ * @var array Index options: Index-level options
+ */
+ var $opts = array();
+
+ /**
+ * @var array Indexed fields: Table columns included in this index
+ */
+ var $columns = array();
+
+ /**
+ * @var boolean Mark index for destruction
+ * @access private
+ */
+ var $drop = FALSE;
+
+ /**
+ * Initializes the new dbIndex object.
+ *
+ * @param object $parent Parent object
+ * @param array $attributes Attributes
+ *
+ * @internal
+ */
+ function dbIndex( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+
+ $this->name = $this->prefix ($attributes['NAME']);
+ }
+
+ /**
+ * XML Callback to process start elements
+ *
+ * Processes XML opening tags.
+ * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH.
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ $this->currentElement = strtoupper( $tag );
+
+ switch( $this->currentElement ) {
+ case 'DROP':
+ $this->drop();
+ break;
+ case 'CLUSTERED':
+ case 'BITMAP':
+ case 'UNIQUE':
+ case 'FULLTEXT':
+ case 'HASH':
+ // Add index Option
+ $this->addIndexOpt( $this->currentElement );
+ break;
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * Processes XML cdata.
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ switch( $this->currentElement ) {
+ // Index field name
+ case 'COL':
+ $this->addField( $cdata );
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+ $this->currentElement = '';
+
+ switch( strtoupper( $tag ) ) {
+ case 'INDEX':
+ xml_set_object( $parser, $this->parent );
+ break;
+ }
+ }
+
+ /**
+ * Adds a field to the index
+ *
+ * @param string $name Field name
+ * @return string Field list
+ */
+ function addField( $name ) {
+ $this->columns[$this->FieldID( $name )] = $name;
+
+ // Return the field list
+ return $this->columns;
+ }
+
+ /**
+ * Adds options to the index
+ *
+ * @param string $opt Comma-separated list of index options.
+ * @return string Option list
+ */
+ function addIndexOpt( $opt ) {
+ $this->opts[] = $opt;
+
+ // Return the options list
+ return $this->opts;
+ }
+
+ /**
+ * Generates the SQL that will create the index in the database
+ *
+ * @param object $xmls adoSchema object
+ * @return array Array containing index creation SQL
+ */
+ function create( &$xmls ) {
+ if( $this->drop ) {
+ return NULL;
+ }
+
+ // eliminate any columns that aren't in the table
+ foreach( $this->columns as $id => $col ) {
+ if( !isset( $this->parent->fields[$id] ) ) {
+ unset( $this->columns[$id] );
+ }
+ }
+
+ return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts );
+ }
+
+ /**
+ * Marks an index for destruction
+ */
+ function drop() {
+ $this->drop = TRUE;
+ }
+}
+
+/**
+* Creates a data object in ADOdb's datadict format
+*
+* This class stores information about table data.
+*
+* @package axmls
+* @access private
+*/
+class dbData extends dbObject {
+
+ var $data = array();
+
+ var $row;
+
+ /**
+ * Initializes the new dbIndex object.
+ *
+ * @param object $parent Parent object
+ * @param array $attributes Attributes
+ *
+ * @internal
+ */
+ function dbData( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+ }
+
+ /**
+ * XML Callback to process start elements
+ *
+ * Processes XML opening tags.
+ * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH.
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ $this->currentElement = strtoupper( $tag );
+
+ switch( $this->currentElement ) {
+ case 'ROW':
+ $this->row = count( $this->data );
+ $this->data[$this->row] = array();
+ break;
+ case 'F':
+ $this->addField($attributes);
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * Processes XML cdata.
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ switch( $this->currentElement ) {
+ // Index field name
+ case 'F':
+ $this->addData( $cdata );
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+ $this->currentElement = '';
+
+ switch( strtoupper( $tag ) ) {
+ case 'DATA':
+ xml_set_object( $parser, $this->parent );
+ break;
+ }
+ }
+
+ /**
+ * Adds a field to the index
+ *
+ * @param string $name Field name
+ * @return string Field list
+ */
+ function addField( $attributes ) {
+ if( isset( $attributes['NAME'] ) ) {
+ $name = $attributes['NAME'];
+ } else {
+ $name = count($this->data[$this->row]);
+ }
+
+ // Set the field index so we know where we are
+ $this->current_field = $this->FieldID( $name );
+ }
+
+ /**
+ * Adds options to the index
+ *
+ * @param string $opt Comma-separated list of index options.
+ * @return string Option list
+ */
+ function addData( $cdata ) {
+ if( !isset( $this->data[$this->row] ) ) {
+ $this->data[$this->row] = array();
+ }
+
+ if( !isset( $this->data[$this->row][$this->current_field] ) ) {
+ $this->data[$this->row][$this->current_field] = '';
+ }
+
+ $this->data[$this->row][$this->current_field] .= $cdata;
+ }
+
+ /**
+ * Generates the SQL that will create the index in the database
+ *
+ * @param object $xmls adoSchema object
+ * @return array Array containing index creation SQL
+ */
+ function create( &$xmls ) {
+ $table = $xmls->dict->TableName($this->parent->name);
+ $table_field_count = count($this->parent->fields);
+ $sql = array();
+
+ // eliminate any columns that aren't in the table
+ foreach( $this->data as $row ) {
+ $table_fields = $this->parent->fields;
+ $fields = array();
+
+ foreach( $row as $field_id => $field_data ) {
+ if( !array_key_exists( $field_id, $table_fields ) ) {
+ if( is_numeric( $field_id ) ) {
+ $field_id = reset( array_keys( $table_fields ) );
+ } else {
+ continue;
+ }
+ }
+
+ $name = $table_fields[$field_id]['NAME'];
+
+ switch( $table_fields[$field_id]['TYPE'] ) {
+ case 'C':
+ case 'C2':
+ case 'X':
+ case 'X2':
+ $fields[$name] = $xmls->db->qstr( $field_data );
+ break;
+ case 'I':
+ case 'I1':
+ case 'I2':
+ case 'I4':
+ case 'I8':
+ $fields[$name] = intval($field_data);
+ break;
+ default:
+ $fields[$name] = $field_data;
+ }
+
+ unset($table_fields[$field_id]);
+ }
+
+ // check that at least 1 column is specified
+ if( empty( $fields ) ) {
+ continue;
+ }
+
+ // check that no required columns are missing
+ if( count( $fields ) < $table_field_count ) {
+ foreach( $table_fields as $field ) {
+ if (isset( $field['OPTS'] ))
+ if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) {
+ continue(2);
+ }
+ }
+ }
+
+ $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')';
+ }
+
+ return $sql;
+ }
+}
+
+/**
+* Creates the SQL to execute a list of provided SQL queries
+*
+* @package axmls
+* @access private
+*/
+class dbQuerySet extends dbObject {
+
+ /**
+ * @var array List of SQL queries
+ */
+ var $queries = array();
+
+ /**
+ * @var string String used to build of a query line by line
+ */
+ var $query;
+
+ /**
+ * @var string Query prefix key
+ */
+ var $prefixKey = '';
+
+ /**
+ * @var boolean Auto prefix enable (TRUE)
+ */
+ var $prefixMethod = 'AUTO';
+
+ /**
+ * Initializes the query set.
+ *
+ * @param object $parent Parent object
+ * @param array $attributes Attributes
+ */
+ function dbQuerySet( &$parent, $attributes = NULL ) {
+ $this->parent =& $parent;
+
+ // Overrides the manual prefix key
+ if( isset( $attributes['KEY'] ) ) {
+ $this->prefixKey = $attributes['KEY'];
+ }
+
+ $prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : '';
+
+ // Enables or disables automatic prefix prepending
+ switch( $prefixMethod ) {
+ case 'AUTO':
+ $this->prefixMethod = 'AUTO';
+ break;
+ case 'MANUAL':
+ $this->prefixMethod = 'MANUAL';
+ break;
+ case 'NONE':
+ $this->prefixMethod = 'NONE';
+ break;
+ }
+ }
+
+ /**
+ * XML Callback to process start elements. Elements currently
+ * processed are: QUERY.
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ $this->currentElement = strtoupper( $tag );
+
+ switch( $this->currentElement ) {
+ case 'QUERY':
+ // Create a new query in a SQL queryset.
+ // Ignore this query set if a platform is specified and it's different than the
+ // current connection platform.
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ $this->newQuery();
+ } else {
+ $this->discardQuery();
+ }
+ break;
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ switch( $this->currentElement ) {
+ // Line of queryset SQL data
+ case 'QUERY':
+ $this->buildQuery( $cdata );
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ */
+ function _tag_close( &$parser, $tag ) {
+ $this->currentElement = '';
+
+ switch( strtoupper( $tag ) ) {
+ case 'QUERY':
+ // Add the finished query to the open query set.
+ $this->addQuery();
+ break;
+ case 'SQL':
+ $this->parent->addSQL( $this->create( $this->parent ) );
+ xml_set_object( $parser, $this->parent );
+ $this->destroy();
+ break;
+ default:
+
+ }
+ }
+
+ /**
+ * Re-initializes the query.
+ *
+ * @return boolean TRUE
+ */
+ function newQuery() {
+ $this->query = '';
+
+ return TRUE;
+ }
+
+ /**
+ * Discards the existing query.
+ *
+ * @return boolean TRUE
+ */
+ function discardQuery() {
+ unset( $this->query );
+
+ return TRUE;
+ }
+
+ /**
+ * Appends a line to a query that is being built line by line
+ *
+ * @param string $data Line of SQL data or NULL to initialize a new query
+ * @return string SQL query string.
+ */
+ function buildQuery( $sql = NULL ) {
+ if( !isset( $this->query ) OR empty( $sql ) ) {
+ return FALSE;
+ }
+
+ $this->query .= $sql;
+
+ return $this->query;
+ }
+
+ /**
+ * Adds a completed query to the query list
+ *
+ * @return string SQL of added query
+ */
+ function addQuery() {
+ if( !isset( $this->query ) ) {
+ return FALSE;
+ }
+
+ $this->queries[] = $return = trim($this->query);
+
+ unset( $this->query );
+
+ return $return;
+ }
+
+ /**
+ * Creates and returns the current query set
+ *
+ * @param object $xmls adoSchema object
+ * @return array Query set
+ */
+ function create( &$xmls ) {
+ foreach( $this->queries as $id => $query ) {
+ switch( $this->prefixMethod ) {
+ case 'AUTO':
+ // Enable auto prefix replacement
+
+ // Process object prefix.
+ // Evaluate SQL statements to prepend prefix to objects
+ $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
+ $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
+ $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix );
+
+ // SELECT statements aren't working yet
+ #$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data );
+
+ case 'MANUAL':
+ // If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX.
+ // If prefixKey is not set, we use the default constant XMLS_PREFIX
+ if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) {
+ // Enable prefix override
+ $query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query );
+ } else {
+ // Use default replacement
+ $query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query );
+ }
+ }
+
+ $this->queries[$id] = trim( $query );
+ }
+
+ // Return the query set array
+ return $this->queries;
+ }
+
+ /**
+ * Rebuilds the query with the prefix attached to any objects
+ *
+ * @param string $regex Regex used to add prefix
+ * @param string $query SQL query string
+ * @param string $prefix Prefix to be appended to tables, indices, etc.
+ * @return string Prefixed SQL query string.
+ */
+ function prefixQuery( $regex, $query, $prefix = NULL ) {
+ if( !isset( $prefix ) ) {
+ return $query;
+ }
+
+ if( preg_match( $regex, $query, $match ) ) {
+ $preamble = $match[1];
+ $postamble = $match[5];
+ $objectList = explode( ',', $match[3] );
+ // $prefix = $prefix . '_';
+
+ $prefixedList = '';
+
+ foreach( $objectList as $object ) {
+ if( $prefixedList !== '' ) {
+ $prefixedList .= ', ';
+ }
+
+ $prefixedList .= $prefix . trim( $object );
+ }
+
+ $query = $preamble . ' ' . $prefixedList . ' ' . $postamble;
+ }
+
+ return $query;
+ }
+}
+
+/**
+* Loads and parses an XML file, creating an array of "ready-to-run" SQL statements
+*
+* This class is used to load and parse the XML file, to create an array of SQL statements
+* that can be used to build a database, and to build the database using the SQL array.
+*
+* @tutorial getting_started.pkg
+*
+* @author Richard Tango-Lowy & Dan Cech
+* @version $Revision: 1.23 $
+*
+* @package axmls
+*/
+class adoSchema {
+
+ /**
+ * @var array Array containing SQL queries to generate all objects
+ * @access private
+ */
+ var $sqlArray;
+
+ /**
+ * @var object ADOdb connection object
+ * @access private
+ */
+ var $db;
+
+ /**
+ * @var object ADOdb Data Dictionary
+ * @access private
+ */
+ var $dict;
+
+ /**
+ * @var string Current XML element
+ * @access private
+ */
+ var $currentElement = '';
+
+ /**
+ * @var string If set (to 'ALTER' or 'REPLACE'), upgrade an existing database
+ * @access private
+ */
+ var $upgrade = '';
+
+ /**
+ * @var string Optional object prefix
+ * @access private
+ */
+ var $objectPrefix = '';
+
+ /**
+ * @var long Original Magic Quotes Runtime value
+ * @access private
+ */
+ var $mgq;
+
+ /**
+ * @var long System debug
+ * @access private
+ */
+ var $debug;
+
+ /**
+ * @var string Regular expression to find schema version
+ * @access private
+ */
+ var $versionRegex = '/<schema.*?( version="([^"]*)")?.*?>/';
+
+ /**
+ * @var string Current schema version
+ * @access private
+ */
+ var $schemaVersion;
+
+ /**
+ * @var int Success of last Schema execution
+ */
+ var $success;
+
+ /**
+ * @var bool Execute SQL inline as it is generated
+ */
+ var $executeInline;
+
+ /**
+ * @var bool Continue SQL execution if errors occur
+ */
+ var $continueOnError;
+
+ /**
+ * Creates an adoSchema object
+ *
+ * Creating an adoSchema object is the first step in processing an XML schema.
+ * The only parameter is an ADOdb database connection object, which must already
+ * have been created.
+ *
+ * @param object $db ADOdb database connection object.
+ */
+ function adoSchema( &$db ) {
+ // Initialize the environment
+ $this->mgq = get_magic_quotes_runtime();
+ set_magic_quotes_runtime(0);
+
+ $this->db =& $db;
+ $this->debug = $this->db->debug;
+ $this->dict = NewDataDictionary( $this->db );
+ $this->sqlArray = array();
+ $this->schemaVersion = XMLS_SCHEMA_VERSION;
+ $this->executeInline( XMLS_EXECUTE_INLINE );
+ $this->continueOnError( XMLS_CONTINUE_ON_ERROR );
+ $this->setUpgradeMethod();
+ }
+
+ /**
+ * Sets the method to be used for upgrading an existing database
+ *
+ * Use this method to specify how existing database objects should be upgraded.
+ * The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to
+ * alter each database object directly, REPLACE attempts to rebuild each object
+ * from scratch, BEST attempts to determine the best upgrade method for each
+ * object, and NONE disables upgrading.
+ *
+ * This method is not yet used by AXMLS, but exists for backward compatibility.
+ * The ALTER method is automatically assumed when the adoSchema object is
+ * instantiated; other upgrade methods are not currently supported.
+ *
+ * @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE)
+ * @returns string Upgrade method used
+ */
+ function SetUpgradeMethod( $method = '' ) {
+ if( !is_string( $method ) ) {
+ return FALSE;
+ }
+
+ $method = strtoupper( $method );
+
+ // Handle the upgrade methods
+ switch( $method ) {
+ case 'ALTER':
+ $this->upgrade = $method;
+ break;
+ case 'REPLACE':
+ $this->upgrade = $method;
+ break;
+ case 'BEST':
+ $this->upgrade = 'ALTER';
+ break;
+ case 'NONE':
+ $this->upgrade = 'NONE';
+ break;
+ default:
+ // Use default if no legitimate method is passed.
+ $this->upgrade = XMLS_DEFAULT_UPGRADE_METHOD;
+ }
+
+ return $this->upgrade;
+ }
+
+ /**
+ * Enables/disables inline SQL execution.
+ *
+ * Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution),
+ * AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode
+ * is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema()
+ * to apply the schema to the database.
+ *
+ * @param bool $mode execute
+ * @return bool current execution mode
+ *
+ * @see ParseSchema(), ExecuteSchema()
+ */
+ function ExecuteInline( $mode = NULL ) {
+ if( is_bool( $mode ) ) {
+ $this->executeInline = $mode;
+ }
+
+ return $this->executeInline;
+ }
+
+ /**
+ * Enables/disables SQL continue on error.
+ *
+ * Call this method to enable or disable continuation of SQL execution if an error occurs.
+ * If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs.
+ * If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing
+ * of the schema will continue.
+ *
+ * @param bool $mode execute
+ * @return bool current continueOnError mode
+ *
+ * @see addSQL(), ExecuteSchema()
+ */
+ function ContinueOnError( $mode = NULL ) {
+ if( is_bool( $mode ) ) {
+ $this->continueOnError = $mode;
+ }
+
+ return $this->continueOnError;
+ }
+
+ /**
+ * Loads an XML schema from a file and converts it to SQL.
+ *
+ * Call this method to load the specified schema (see the DTD for the proper format) from
+ * the filesystem and generate the SQL necessary to create the database described.
+ * @see ParseSchemaString()
+ *
+ * @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute
+ */
+ function ParseSchema( $filename, $returnSchema = FALSE ) {
+ return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
+ }
+
+ /**
+ * Loads an XML schema from a file and converts it to SQL.
+ *
+ * Call this method to load the specified schema from a file (see the DTD for the proper format)
+ * and generate the SQL necessary to create the database described by the schema.
+ *
+ * @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute.
+ *
+ * @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString()
+ * @see ParseSchema(), ParseSchemaString()
+ */
+ function ParseSchemaFile( $filename, $returnSchema = FALSE ) {
+ // Open the file
+ if( !($fp = fopen( $filename, 'r' )) ) {
+ // die( 'Unable to open file' );
+ return FALSE;
+ }
+
+ // do version detection here
+ if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) {
+ return FALSE;
+ }
+
+ if ( $returnSchema )
+ {
+ return $xmlstring;
+ }
+
+ $this->success = 2;
+
+ $xmlParser = $this->create_parser();
+
+ // Process the file
+ while( $data = fread( $fp, 4096 ) ) {
+ if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) {
+ die( sprintf(
+ "XML error: %s at line %d",
+ xml_error_string( xml_get_error_code( $xmlParser) ),
+ xml_get_current_line_number( $xmlParser)
+ ) );
+ }
+ }
+
+ xml_parser_free( $xmlParser );
+
+ return $this->sqlArray;
+ }
+
+ /**
+ * Converts an XML schema string to SQL.
+ *
+ * Call this method to parse a string containing an XML schema (see the DTD for the proper format)
+ * and generate the SQL necessary to create the database described by the schema.
+ * @see ParseSchema()
+ *
+ * @param string $xmlstring XML schema string.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute.
+ */
+ function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) {
+ if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
+ return FALSE;
+ }
+
+ // do version detection here
+ if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) {
+ return FALSE;
+ }
+
+ if ( $returnSchema )
+ {
+ return $xmlstring;
+ }
+
+ $this->success = 2;
+
+ $xmlParser = $this->create_parser();
+
+ if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) {
+ die( sprintf(
+ "XML error: %s at line %d",
+ xml_error_string( xml_get_error_code( $xmlParser) ),
+ xml_get_current_line_number( $xmlParser)
+ ) );
+ }
+
+ xml_parser_free( $xmlParser );
+
+ return $this->sqlArray;
+ }
+
+ /**
+ * Loads an XML schema from a file and converts it to uninstallation SQL.
+ *
+ * Call this method to load the specified schema (see the DTD for the proper format) from
+ * the filesystem and generate the SQL necessary to remove the database described.
+ * @see RemoveSchemaString()
+ *
+ * @param string $file Name of XML schema file.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute
+ */
+ function RemoveSchema( $filename, $returnSchema = FALSE ) {
+ return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema );
+ }
+
+ /**
+ * Converts an XML schema string to uninstallation SQL.
+ *
+ * Call this method to parse a string containing an XML schema (see the DTD for the proper format)
+ * and generate the SQL necessary to uninstall the database described by the schema.
+ * @see RemoveSchema()
+ *
+ * @param string $schema XML schema string.
+ * @param bool $returnSchema Return schema rather than parsing.
+ * @return array Array of SQL queries, ready to execute.
+ */
+ function RemoveSchemaString( $schema, $returnSchema = FALSE ) {
+
+ // grab current version
+ if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
+ return FALSE;
+ }
+
+ return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema );
+ }
+
+ /**
+ * Applies the current XML schema to the database (post execution).
+ *
+ * Call this method to apply the current schema (generally created by calling
+ * ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes,
+ * and executing other SQL specified in the schema) after parsing.
+ * @see ParseSchema(), ParseSchemaString(), ExecuteInline()
+ *
+ * @param array $sqlArray Array of SQL statements that will be applied rather than
+ * the current schema.
+ * @param boolean $continueOnErr Continue to apply the schema even if an error occurs.
+ * @returns integer 0 if failure, 1 if errors, 2 if successful.
+ */
+ function ExecuteSchema( $sqlArray = NULL, $continueOnErr = NULL ) {
+ if( !is_bool( $continueOnErr ) ) {
+ $continueOnErr = $this->ContinueOnError();
+ }
+
+ if( !isset( $sqlArray ) ) {
+ $sqlArray = $this->sqlArray;
+ }
+
+ if( !is_array( $sqlArray ) ) {
+ $this->success = 0;
+ } else {
+ $this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr );
+ }
+
+ return $this->success;
+ }
+
+ /**
+ * Returns the current SQL array.
+ *
+ * Call this method to fetch the array of SQL queries resulting from
+ * ParseSchema() or ParseSchemaString().
+ *
+ * @param string $format Format: HTML, TEXT, or NONE (PHP array)
+ * @return array Array of SQL statements or FALSE if an error occurs
+ */
+ function PrintSQL( $format = 'NONE' ) {
+ return $this->getSQL( $format, $sqlArray );
+ }
+
+ /**
+ * Saves the current SQL array to the local filesystem as a list of SQL queries.
+ *
+ * Call this method to save the array of SQL queries (generally resulting from a
+ * parsed XML schema) to the filesystem.
+ *
+ * @param string $filename Path and name where the file should be saved.
+ * @return boolean TRUE if save is successful, else FALSE.
+ */
+ function SaveSQL( $filename = './schema.sql' ) {
+
+ if( !isset( $sqlArray ) ) {
+ $sqlArray = $this->sqlArray;
+ }
+ if( !isset( $sqlArray ) ) {
+ return FALSE;
+ }
+
+ $fp = fopen( $filename, "w" );
+
+ foreach( $sqlArray as $key => $query ) {
+ fwrite( $fp, $query . ";\n" );
+ }
+ fclose( $fp );
+ }
+
+ /**
+ * Create an xml parser
+ *
+ * @return object PHP XML parser object
+ *
+ * @access private
+ */
+ function &create_parser() {
+ // Create the parser
+ $xmlParser = xml_parser_create();
+ xml_set_object( $xmlParser, $this );
+
+ // Initialize the XML callback functions
+ xml_set_element_handler( $xmlParser, '_tag_open', '_tag_close' );
+ xml_set_character_data_handler( $xmlParser, '_tag_cdata' );
+
+ return $xmlParser;
+ }
+
+ /**
+ * XML Callback to process start elements
+ *
+ * @access private
+ */
+ function _tag_open( &$parser, $tag, $attributes ) {
+ switch( strtoupper( $tag ) ) {
+ case 'TABLE':
+ $this->obj = new dbTable( $this, $attributes );
+ xml_set_object( $parser, $this->obj );
+ break;
+ case 'SQL':
+ if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) {
+ $this->obj = new dbQuerySet( $this, $attributes );
+ xml_set_object( $parser, $this->obj );
+ }
+ break;
+ default:
+ // print_r( array( $tag, $attributes ) );
+ }
+
+ }
+
+ /**
+ * XML Callback to process CDATA elements
+ *
+ * @access private
+ */
+ function _tag_cdata( &$parser, $cdata ) {
+ }
+
+ /**
+ * XML Callback to process end elements
+ *
+ * @access private
+ * @internal
+ */
+ function _tag_close( &$parser, $tag ) {
+
+ }
+
+ /**
+ * Converts an XML schema string to the specified DTD version.
+ *
+ * Call this method to convert a string containing an XML schema to a different AXMLS
+ * DTD version. For instance, to convert a schema created for an pre-1.0 version for
+ * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version
+ * parameter is specified, the schema will be converted to the current DTD version.
+ * If the newFile parameter is provided, the converted schema will be written to the specified
+ * file.
+ * @see ConvertSchemaFile()
+ *
+ * @param string $schema String containing XML schema that will be converted.
+ * @param string $newVersion DTD version to convert to.
+ * @param string $newFile File name of (converted) output file.
+ * @return string Converted XML schema or FALSE if an error occurs.
+ */
+ function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) {
+
+ // grab current version
+ if( !( $version = $this->SchemaStringVersion( $schema ) ) ) {
+ return FALSE;
+ }
+
+ if( !isset ($newVersion) ) {
+ $newVersion = $this->schemaVersion;
+ }
+
+ if( $version == $newVersion ) {
+ $result = $schema;
+ } else {
+ $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion);
+ }
+
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
+ fwrite( $fp, $result );
+ fclose( $fp );
+ }
+
+ return $result;
+ }
+
+ /**
+ * Converts an XML schema file to the specified DTD version.
+ *
+ * Call this method to convert the specified XML schema file to a different AXMLS
+ * DTD version. For instance, to convert a schema created for an pre-1.0 version for
+ * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version
+ * parameter is specified, the schema will be converted to the current DTD version.
+ * If the newFile parameter is provided, the converted schema will be written to the specified
+ * file.
+ * @see ConvertSchemaString()
+ *
+ * @param string $filename Name of XML schema file that will be converted.
+ * @param string $newVersion DTD version to convert to.
+ * @param string $newFile File name of (converted) output file.
+ * @return string Converted XML schema or FALSE if an error occurs.
+ */
+ function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) {
+
+ // grab current version
+ if( !( $version = $this->SchemaFileVersion( $filename ) ) ) {
+ return FALSE;
+ }
+
+ if( !isset ($newVersion) ) {
+ $newVersion = $this->schemaVersion;
+ }
+
+ if( $version == $newVersion ) {
+ $result = file_get_contents( $filename );
+
+ // remove unicode BOM if present
+ if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) {
+ $result = substr( $result, 3 );
+ }
+ } else {
+ $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' );
+ }
+
+ if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) {
+ fwrite( $fp, $result );
+ fclose( $fp );
+ }
+
+ return $result;
+ }
+
+ function TransformSchema( $schema, $xsl, $schematype='string' )
+ {
+ // Fail if XSLT extension is not available
+ if( ! function_exists( 'xslt_create' ) ) {
+ return FALSE;
+ }
+
+ $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl';
+
+ // look for xsl
+ if( !is_readable( $xsl_file ) ) {
+ return FALSE;
+ }
+
+ switch( $schematype )
+ {
+ case 'file':
+ if( !is_readable( $schema ) ) {
+ return FALSE;
+ }
+
+ $schema = file_get_contents( $schema );
+ break;
+ case 'string':
+ default:
+ if( !is_string( $schema ) ) {
+ return FALSE;
+ }
+ }
+
+ $arguments = array (
+ '/_xml' => $schema,
+ '/_xsl' => file_get_contents( $xsl_file )
+ );
+
+ // create an XSLT processor
+ $xh = xslt_create ();
+
+ // set error handler
+ xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler'));
+
+ // process the schema
+ $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
+
+ xslt_free ($xh);
+
+ return $result;
+ }
+
+ /**
+ * Processes XSLT transformation errors
+ *
+ * @param object $parser XML parser object
+ * @param integer $errno Error number
+ * @param integer $level Error level
+ * @param array $fields Error information fields
+ *
+ * @access private
+ */
+ function xslt_error_handler( $parser, $errno, $level, $fields ) {
+ if( is_array( $fields ) ) {
+ $msg = array(
+ 'Message Type' => ucfirst( $fields['msgtype'] ),
+ 'Message Code' => $fields['code'],
+ 'Message' => $fields['msg'],
+ 'Error Number' => $errno,
+ 'Level' => $level
+ );
+
+ switch( $fields['URI'] ) {
+ case 'arg:/_xml':
+ $msg['Input'] = 'XML';
+ break;
+ case 'arg:/_xsl':
+ $msg['Input'] = 'XSL';
+ break;
+ default:
+ $msg['Input'] = $fields['URI'];
+ }
+
+ $msg['Line'] = $fields['line'];
+ } else {
+ $msg = array(
+ 'Message Type' => 'Error',
+ 'Error Number' => $errno,
+ 'Level' => $level,
+ 'Fields' => var_export( $fields, TRUE )
+ );
+ }
+
+ $error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n"
+ . '<table>' . "\n";
+
+ foreach( $msg as $label => $details ) {
+ $error_details .= '<tr><td><b>' . $label . ': </b></td><td>' . htmlentities( $details ) . '</td></tr>' . "\n";
+ }
+
+ $error_details .= '</table>';
+
+ trigger_error( $error_details, E_USER_ERROR );
+ }
+
+ /**
+ * Returns the AXMLS Schema Version of the requested XML schema file.
+ *
+ * Call this method to obtain the AXMLS DTD version of the requested XML schema file.
+ * @see SchemaStringVersion()
+ *
+ * @param string $filename AXMLS schema file
+ * @return string Schema version number or FALSE on error
+ */
+ function SchemaFileVersion( $filename ) {
+ // Open the file
+ if( !($fp = fopen( $filename, 'r' )) ) {
+ // die( 'Unable to open file' );
+ return FALSE;
+ }
+
+ // Process the file
+ while( $data = fread( $fp, 4096 ) ) {
+ if( preg_match( $this->versionRegex, $data, $matches ) ) {
+ return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
+ }
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Returns the AXMLS Schema Version of the provided XML schema string.
+ *
+ * Call this method to obtain the AXMLS DTD version of the provided XML schema string.
+ * @see SchemaFileVersion()
+ *
+ * @param string $xmlstring XML schema string
+ * @return string Schema version number or FALSE on error
+ */
+ function SchemaStringVersion( $xmlstring ) {
+ if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) {
+ return FALSE;
+ }
+
+ if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) {
+ return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Extracts an XML schema from an existing database.
+ *
+ * Call this method to create an XML schema string from an existing database.
+ * If the data parameter is set to TRUE, AXMLS will include the data from the database
+ * in the schema.
+ *
+ * @param boolean $data Include data in schema dump
+ * @return string Generated XML schema
+ */
+ function ExtractSchema( $data = FALSE ) {
+ $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM );
+
+ $schema = '<?xml version="1.0"?>' . "\n"
+ . '<schema version="' . $this->schemaVersion . '">' . "\n";
+
+ if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) {
+ foreach( $tables as $table ) {
+ $schema .= ' <table name="' . $table . '">' . "\n";
+
+ // grab details from database
+ $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE 1=1' );
+ $fields = $this->db->MetaColumns( $table );
+ $indexes = $this->db->MetaIndexes( $table );
+
+ if( is_array( $fields ) ) {
+ foreach( $fields as $details ) {
+ $extra = '';
+ $content = array();
+
+ if( $details->max_length > 0 ) {
+ $extra .= ' size="' . $details->max_length . '"';
+ }
+
+ if( $details->primary_key ) {
+ $content[] = '<KEY/>';
+ } elseif( $details->not_null ) {
+ $content[] = '<NOTNULL/>';
+ }
+
+ if( $details->has_default ) {
+ $content[] = '<DEFAULT value="' . $details->default_value . '"/>';
+ }
+
+ if( $details->auto_increment ) {
+ $content[] = '<AUTOINCREMENT/>';
+ }
+
+ // this stops the creation of 'R' columns,
+ // AUTOINCREMENT is used to create auto columns
+ $details->primary_key = 0;
+ $type = $rs->MetaType( $details );
+
+ $schema .= ' <field name="' . $details->name . '" type="' . $type . '"' . $extra . '>';
+
+ if( !empty( $content ) ) {
+ $schema .= "\n " . implode( "\n ", $content ) . "\n ";
+ }
+
+ $schema .= '</field>' . "\n";
+ }
+ }
+
+ if( is_array( $indexes ) ) {
+ foreach( $indexes as $index => $details ) {
+ $schema .= ' <index name="' . $index . '">' . "\n";
+
+ if( $details['unique'] ) {
+ $schema .= ' <UNIQUE/>' . "\n";
+ }
+
+ foreach( $details['columns'] as $column ) {
+ $schema .= ' <col>' . $column . '</col>' . "\n";
+ }
+
+ $schema .= ' </index>' . "\n";
+ }
+ }
+
+ if( $data ) {
+ $rs = $this->db->Execute( 'SELECT * FROM ' . $table );
+
+ if( is_object( $rs ) ) {
+ $schema .= ' <data>' . "\n";
+
+ while( $row = $rs->FetchRow() ) {
+ foreach( $row as $key => $val ) {
+ $row[$key] = htmlentities($val);
+ }
+
+ $schema .= ' <row><f>' . implode( '</f><f>', $row ) . '</f></row>' . "\n";
+ }
+
+ $schema .= ' </data>' . "\n";
+ }
+ }
+
+ $schema .= ' </table>' . "\n";
+ }
+ }
+
+ $this->db->SetFetchMode( $old_mode );
+
+ $schema .= '</schema>';
+ return $schema;
+ }
+
+ /**
+ * Sets a prefix for database objects
+ *
+ * Call this method to set a standard prefix that will be prepended to all database tables
+ * and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix.
+ *
+ * @param string $prefix Prefix that will be prepended.
+ * @param boolean $underscore If TRUE, automatically append an underscore character to the prefix.
+ * @return boolean TRUE if successful, else FALSE
+ */
+ function SetPrefix( $prefix = '', $underscore = TRUE ) {
+ switch( TRUE ) {
+ // clear prefix
+ case empty( $prefix ):
+ logMsg( 'Cleared prefix' );
+ $this->objectPrefix = '';
+ return TRUE;
+ // prefix too long
+ case strlen( $prefix ) > XMLS_PREFIX_MAXLEN:
+ // prefix contains invalid characters
+ case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ):
+ logMsg( 'Invalid prefix: ' . $prefix );
+ return FALSE;
+ }
+
+ if( $underscore AND substr( $prefix, -1 ) != '_' ) {
+ $prefix .= '_';
+ }
+
+ // prefix valid
+ logMsg( 'Set prefix: ' . $prefix );
+ $this->objectPrefix = $prefix;
+ return TRUE;
+ }
+
+ /**
+ * Returns an object name with the current prefix prepended.
+ *
+ * @param string $name Name
+ * @return string Prefixed name
+ *
+ * @access private
+ */
+ function prefix( $name = '' ) {
+ // if prefix is set
+ if( !empty( $this->objectPrefix ) ) {
+ // Prepend the object prefix to the table name
+ // prepend after quote if used
+ return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name );
+ }
+
+ // No prefix set. Use name provided.
+ return $name;
+ }
+
+ /**
+ * Checks if element references a specific platform
+ *
+ * @param string $platform Requested platform
+ * @returns boolean TRUE if platform check succeeds
+ *
+ * @access private
+ */
+ function supportedPlatform( $platform = NULL ) {
+ $regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/';
+
+ if( !isset( $platform ) OR preg_match( $regex, $platform ) ) {
+ logMsg( "Platform $platform is supported" );
+ return TRUE;
+ } else {
+ logMsg( "Platform $platform is NOT supported" );
+ return FALSE;
+ }
+ }
+
+ /**
+ * Clears the array of generated SQL.
+ *
+ * @access private
+ */
+ function clearSQL() {
+ $this->sqlArray = array();
+ }
+
+ /**
+ * Adds SQL into the SQL array.
+ *
+ * @param mixed $sql SQL to Add
+ * @return boolean TRUE if successful, else FALSE.
+ *
+ * @access private
+ */
+ function addSQL( $sql = NULL ) {
+ if( is_array( $sql ) ) {
+ foreach( $sql as $line ) {
+ $this->addSQL( $line );
+ }
+
+ return TRUE;
+ }
+
+ if( is_string( $sql ) ) {
+ $this->sqlArray[] = $sql;
+
+ // if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL.
+ if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) {
+ $saved = $this->db->debug;
+ $this->db->debug = $this->debug;
+ $ok = $this->db->Execute( $sql );
+ $this->db->debug = $saved;
+
+ if( !$ok ) {
+ if( $this->debug ) {
+ ADOConnection::outp( $this->db->ErrorMsg() );
+ }
+
+ $this->success = 1;
+ }
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ /**
+ * Gets the SQL array in the specified format.
+ *
+ * @param string $format Format
+ * @return mixed SQL
+ *
+ * @access private
+ */
+ function getSQL( $format = NULL, $sqlArray = NULL ) {
+ if( !is_array( $sqlArray ) ) {
+ $sqlArray = $this->sqlArray;
+ }
+
+ if( !is_array( $sqlArray ) ) {
+ return FALSE;
+ }
+
+ switch( strtolower( $format ) ) {
+ case 'string':
+ case 'text':
+ return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : '';
+ case'html':
+ return !empty( $sqlArray ) ? nl2br( htmlentities( implode( ";\n\n", $sqlArray ) . ';' ) ) : '';
+ }
+
+ return $this->sqlArray;
+ }
+
+ /**
+ * Destroys an adoSchema object.
+ *
+ * Call this method to clean up after an adoSchema object that is no longer in use.
+ * @deprecated adoSchema now cleans up automatically.
+ */
+ function Destroy() {
+ set_magic_quotes_runtime( $this->mgq );
+ unset( $this );
+ }
+}
+
+/**
+* Message logging function
+*
+* @access private
+*/
+function logMsg( $msg, $title = NULL, $force = FALSE ) {
+ if( XMLS_DEBUG or $force ) {
+ echo '<pre>';
+
+ if( isset( $title ) ) {
+ echo '<h3>' . htmlentities( $title ) . '</h3>';
+ }
+
+ if( is_object( $this ) ) {
+ echo '[' . get_class( $this ) . '] ';
+ }
+
+ print_r( $msg );
+
+ echo '</pre>';
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/adodb.inc.php b/html/phpgacl/adodb/adodb.inc.php
new file mode 100644
index 0000000..8151636
--- /dev/null
+++ b/html/phpgacl/adodb/adodb.inc.php
@@ -0,0 +1,3876 @@
+<?php
+/*
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://adodb.sourceforge.net
+ *
+ * This is the main include file for ADOdb.
+ * Database specific drivers are stored in the adodb/drivers/adodb-*.inc.php
+ *
+ * The ADOdb files are formatted so that doxygen can be used to generate documentation.
+ * Doxygen is a documentation generation tool and can be downloaded from http://doxygen.org/
+ */
+
+/**
+ \mainpage
+
+ @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+
+ Released under both BSD license and Lesser GPL library license. You can choose which license
+ you prefer.
+
+ PHP's database access functions are not standardised. This creates a need for a database
+ class library to hide the differences between the different database API's (encapsulate
+ the differences) so we can easily switch databases.
+
+ We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, DB2,
+ Informix, PostgreSQL, FrontBase, Interbase (Firebird and Borland variants), Foxpro, Access,
+ ADO, SAP DB, SQLite and ODBC. We have had successful reports of connecting to Progress and
+ other databases via ODBC.
+
+ Latest Download at http://php.weblogs.com/adodb<br>
+ Manual is at http://php.weblogs.com/adodb_manual
+
+ */
+
+ if (!defined('_ADODB_LAYER')) {
+ define('_ADODB_LAYER',1);
+
+ //==============================================================================================
+ // CONSTANT DEFINITIONS
+ //==============================================================================================
+
+
+ /**
+ * Set ADODB_DIR to the directory where this file resides...
+ * This constant was formerly called $ADODB_RootPath
+ */
+ if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
+
+ //==============================================================================================
+ // GLOBAL VARIABLES
+ //==============================================================================================
+
+ GLOBAL
+ $ADODB_vers, // database version
+ $ADODB_COUNTRECS, // count number of records returned - slows down query
+ $ADODB_CACHE_DIR, // directory to cache recordsets
+ $ADODB_EXTENSION, // ADODB extension installed
+ $ADODB_COMPAT_FETCH, // If $ADODB_COUNTRECS and this is true, $rs->fields is available on EOF
+ $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
+
+ //==============================================================================================
+ // GLOBAL SETUP
+ //==============================================================================================
+
+ $ADODB_EXTENSION = defined('ADODB_EXTENSION');
+
+ //********************************************************//
+ /*
+ Controls $ADODB_FORCE_TYPE mode. Default is ADODB_FORCE_VALUE (3).
+ Used in GetUpdateSql and GetInsertSql functions. Thx to Niko, nuko#mbnet.fi
+
+ 0 = ignore empty fields. All empty fields in array are ignored.
+ 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values.
+ 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values.
+ 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values.
+ */
+ define('ADODB_FORCE_IGNORE',0);
+ define('ADODB_FORCE_NULL',1);
+ define('ADODB_FORCE_EMPTY',2);
+ define('ADODB_FORCE_VALUE',3);
+ //********************************************************//
+
+
+ if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) {
+
+ define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
+
+ // allow [ ] @ ` " and . in table names
+ define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)');
+
+ // prefetching used by oracle
+ if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
+
+
+ /*
+ Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names.
+ This currently works only with mssql, odbc, oci8po and ibase derived drivers.
+
+ 0 = assoc lowercase field names. $rs->fields['orderid']
+ 1 = assoc uppercase field names. $rs->fields['ORDERID']
+ 2 = use native-case field names. $rs->fields['OrderID']
+ */
+
+ define('ADODB_FETCH_DEFAULT',0);
+ define('ADODB_FETCH_NUM',1);
+ define('ADODB_FETCH_ASSOC',2);
+ define('ADODB_FETCH_BOTH',3);
+
+ if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100);
+
+ // PHP's version scheme makes converting to numbers difficult - workaround
+ $_adodb_ver = (float) PHP_VERSION;
+ if ($_adodb_ver >= 5.0) {
+ define('ADODB_PHPVER',0x5000);
+ } else if ($_adodb_ver > 4.299999) { # 4.3
+ define('ADODB_PHPVER',0x4300);
+ } else if ($_adodb_ver > 4.199999) { # 4.2
+ define('ADODB_PHPVER',0x4200);
+ } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) {
+ define('ADODB_PHPVER',0x4050);
+ } else {
+ define('ADODB_PHPVER',0x4000);
+ }
+ }
+
+ //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
+
+
+ /**
+ Accepts $src and $dest arrays, replacing string $data
+ */
+ function ADODB_str_replace($src, $dest, $data)
+ {
+ if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data);
+
+ $s = reset($src);
+ $d = reset($dest);
+ while ($s !== false) {
+ $data = str_replace($s,$d,$data);
+ $s = next($src);
+ $d = next($dest);
+ }
+ return $data;
+ }
+
+ function ADODB_Setup()
+ {
+ GLOBAL
+ $ADODB_vers, // database version
+ $ADODB_COUNTRECS, // count number of records returned - slows down query
+ $ADODB_CACHE_DIR, // directory to cache recordsets
+ $ADODB_FETCH_MODE,
+ $ADODB_FORCE_TYPE;
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
+ $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
+
+
+ if (!isset($ADODB_CACHE_DIR)) {
+ $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp';
+ } else {
+ // do not accept url based paths, eg. http:/ or ftp:/
+ if (strpos($ADODB_CACHE_DIR,'://') !== false)
+ die("Illegal path http:// or ftp://");
+ }
+
+
+ // Initialize random number generator for randomizing cache flushes
+ srand(((double)microtime())*1000000);
+
+ /**
+ * ADODB version as a string.
+ */
+ $ADODB_vers = 'V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.';
+
+ /**
+ * Determines whether recordset->RecordCount() is used.
+ * Set to false for highest performance -- RecordCount() will always return -1 then
+ * for databases that provide "virtual" recordcounts...
+ */
+ if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true;
+ }
+
+
+ //==============================================================================================
+ // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB
+ //==============================================================================================
+
+ ADODB_Setup();
+
+ //==============================================================================================
+ // CLASS ADOFieldObject
+ //==============================================================================================
+ /**
+ * Helper class for FetchFields -- holds info on a column
+ */
+ class ADOFieldObject {
+ var $name = '';
+ var $max_length=0;
+ var $type="";
+/*
+ // additional fields by dannym... (danny_milo@yahoo.com)
+ var $not_null = false;
+ // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^
+ // so we can as well make not_null standard (leaving it at "false" does not harm anyways)
+
+ var $has_default = false; // this one I have done only in mysql and postgres for now ...
+ // others to come (dannym)
+ var $default_value; // default, if any, and supported. Check has_default first.
+*/
+ }
+
+
+
+ function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
+ {
+ //print "Errorno ($fn errno=$errno m=$errmsg) ";
+ $thisConnection->_transOK = false;
+ if ($thisConnection->_oldRaiseFn) {
+ $fn = $thisConnection->_oldRaiseFn;
+ $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection);
+ }
+ }
+
+ //==============================================================================================
+ // CLASS ADOConnection
+ //==============================================================================================
+
+ /**
+ * Connection object. For connecting to databases, and executing queries.
+ */
+ class ADOConnection {
+ //
+ // PUBLIC VARS
+ //
+ var $dataProvider = 'native';
+ var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql
+ var $database = ''; /// Name of database to be used.
+ var $host = ''; /// The hostname of the database server
+ var $user = ''; /// The username which is used to connect to the database server.
+ var $password = ''; /// Password for the username. For security, we no longer store it.
+ var $debug = false; /// if set to true will output sql statements
+ var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro
+ var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase
+ var $substr = 'substr'; /// substring operator
+ var $length = 'length'; /// string length ofperator
+ var $random = 'rand()'; /// random function
+ var $upperCase = 'upper'; /// uppercase function
+ var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt.
+ var $true = '1'; /// string that represents TRUE for a database
+ var $false = '0'; /// string that represents FALSE for a database
+ var $replaceQuote = "\\'"; /// string to use to replace quotes
+ var $nameQuote = '"'; /// string to use to quote identifiers and names
+ var $charSet=false; /// character set to use - only for interbase, postgres and oci8
+ var $metaDatabasesSQL = '';
+ var $metaTablesSQL = '';
+ var $uniqueOrderBy = false; /// All order by columns have to be unique
+ var $emptyDate = '&nbsp;';
+ var $emptyTimeStamp = '&nbsp;';
+ var $lastInsID = false;
+ //--
+ var $hasInsertID = false; /// supports autoincrement ID?
+ var $hasAffectedRows = false; /// supports affected rows for update/delete?
+ var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE
+ var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ var $readOnly = false; /// this is a readonly database - used by phpLens
+ var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards
+ var $hasGenID = false; /// can generate sequences using GenID();
+ var $hasTransactions = true; /// has transactions
+ //--
+ var $genID = 0; /// sequence id used by GenID();
+ var $raiseErrorFn = false; /// error function to call
+ var $isoDates = false; /// accepts dates in ISO format
+ var $cacheSecs = 3600; /// cache for 1 hour
+ var $sysDate = false; /// name of function that returns the current date
+ var $sysTimeStamp = false; /// name of function that returns the current timestamp
+ var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets
+
+ var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' '
+ var $numCacheHits = 0;
+ var $numCacheMisses = 0;
+ var $pageExecuteCountRows = true;
+ var $uniqueSort = false; /// indicates that all fields in order by must be unique
+ var $leftOuter = false; /// operator to use for left outer join in WHERE clause
+ var $rightOuter = false; /// operator to use for right outer join in WHERE clause
+ var $ansiOuter = false; /// whether ansi outer join syntax supported
+ var $autoRollback = false; // autoRollback on PConnect().
+ var $poorAffectedRows = false; // affectedRows not working or unreliable
+
+ var $fnExecute = false;
+ var $fnCacheExecute = false;
+ var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char
+ var $rsPrefix = "ADORecordSet_";
+
+ var $autoCommit = true; /// do not modify this yourself - actually private
+ var $transOff = 0; /// temporarily disable transactions
+ var $transCnt = 0; /// count of nested transactions
+
+ var $fetchMode=false;
+ //
+ // PRIVATE VARS
+ //
+ var $_oldRaiseFn = false;
+ var $_transOK = null;
+ var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made.
+ var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will
+ /// then returned by the errorMsg() function
+ var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8
+ var $_queryID = false; /// This variable keeps the last created result link identifier
+
+ var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */
+ var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters.
+ var $_evalAll = false;
+ var $_affected = false;
+ var $_logsql = false;
+
+
+
+ /**
+ * Constructor
+ */
+ function ADOConnection()
+ {
+ die('Virtual Class -- cannot instantiate');
+ }
+
+ function Version()
+ {
+ global $ADODB_vers;
+
+ return (float) substr($ADODB_vers,1);
+ }
+
+ /**
+ Get server version info...
+
+ @returns An array with 2 elements: $arr['string'] is the description string,
+ and $arr[version] is the version (also a string).
+ */
+ function ServerInfo()
+ {
+ return array('description' => '', 'version' => '');
+ }
+
+ function IsConnected()
+ {
+ return !empty($this->_connectionID);
+ }
+
+ function _findvers($str)
+ {
+ if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1];
+ else return '';
+ }
+
+ /**
+ * All error messages go through this bottleneck function.
+ * You can define your own handler by defining the function name in ADODB_OUTP.
+ */
+ function outp($msg,$newline=true)
+ {
+ global $ADODB_FLUSH,$ADODB_OUTP;
+
+ if (defined('ADODB_OUTP')) {
+ $fn = ADODB_OUTP;
+ $fn($msg,$newline);
+ return;
+ } else if (isset($ADODB_OUTP)) {
+ $fn = $ADODB_OUTP;
+ $fn($msg,$newline);
+ return;
+ }
+
+ if ($newline) $msg .= "<br>\n";
+
+ if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg;
+ else echo strip_tags($msg);
+
+
+ if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan
+
+ }
+
+ function Time()
+ {
+ $rs =& $this->_Execute("select $this->sysTimeStamp");
+ if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
+
+ return false;
+ }
+
+ /**
+ * Connect to database
+ *
+ * @param [argHostname] Host to connect to
+ * @param [argUsername] Userid to login
+ * @param [argPassword] Associated password
+ * @param [argDatabaseName] database
+ * @param [forceNew] force new connection
+ *
+ * @return true or false
+ */
+ function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false)
+ {
+ if ($argHostname != "") $this->host = $argHostname;
+ if ($argUsername != "") $this->user = $argUsername;
+ if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons
+ if ($argDatabaseName != "") $this->database = $argDatabaseName;
+
+ $this->_isPersistentConnection = false;
+ if ($forceNew) {
+ if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true;
+ } else {
+ if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true;
+ }
+ if (isset($rez)) {
+ $err = $this->ErrorMsg();
+ if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ $ret = false;
+ } else {
+ $err = "Missing extension for ".$this->dataProvider;
+ $ret = 0;
+ }
+ if ($fn = $this->raiseErrorFn)
+ $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
+
+
+ $this->_connectionID = false;
+ if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+ return $ret;
+ }
+
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName);
+ }
+
+
+ /**
+ * Always force a new connection to database - currently only works with oracle
+ *
+ * @param [argHostname] Host to connect to
+ * @param [argUsername] Userid to login
+ * @param [argPassword] Associated password
+ * @param [argDatabaseName] database
+ *
+ * @return true or false
+ */
+ function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
+ {
+ return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true);
+ }
+
+ /**
+ * Establish persistent connect to database
+ *
+ * @param [argHostname] Host to connect to
+ * @param [argUsername] Userid to login
+ * @param [argPassword] Associated password
+ * @param [argDatabaseName] database
+ *
+ * @return return true or false
+ */
+ function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "")
+ {
+ if (defined('ADODB_NEVER_PERSIST'))
+ return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
+
+ if ($argHostname != "") $this->host = $argHostname;
+ if ($argUsername != "") $this->user = $argUsername;
+ if ($argPassword != "") $this->password = $argPassword;
+ if ($argDatabaseName != "") $this->database = $argDatabaseName;
+
+ $this->_isPersistentConnection = true;
+ if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true;
+ if (isset($rez)) {
+ $err = $this->ErrorMsg();
+ if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'";
+ $ret = false;
+ } else {
+ $err = "Missing extension for ".$this->dataProvider;
+ $ret = 0;
+ }
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
+ }
+
+ $this->_connectionID = false;
+ if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+ return $ret;
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysDate;
+ return $col; // child class implement
+ }
+
+ /**
+ * Should prepare the sql statement and return the stmt resource.
+ * For databases that do not support this, we return the $sql. To ensure
+ * compatibility with databases that do not support prepare:
+ *
+ * $stmt = $db->Prepare("insert into table (id, name) values (?,?)");
+ * $db->Execute($stmt,array(1,'Jill')) or die('insert failed');
+ * $db->Execute($stmt,array(2,'Joe')) or die('insert failed');
+ *
+ * @param sql SQL to send to database
+ *
+ * @return return FALSE, or the prepared statement, or the original sql if
+ * if the database does not support prepare.
+ *
+ */
+ function Prepare($sql)
+ {
+ return $sql;
+ }
+
+ /**
+ * Some databases, eg. mssql require a different function for preparing
+ * stored procedures. So we cannot use Prepare().
+ *
+ * Should prepare the stored procedure and return the stmt resource.
+ * For databases that do not support this, we return the $sql. To ensure
+ * compatibility with databases that do not support prepare:
+ *
+ * @param sql SQL to send to database
+ *
+ * @return return FALSE, or the prepared statement, or the original sql if
+ * if the database does not support prepare.
+ *
+ */
+ function PrepareSP($sql,$param=true)
+ {
+ return $this->Prepare($sql,$param);
+ }
+
+ /**
+ * PEAR DB Compat
+ */
+ function Quote($s)
+ {
+ return $this->qstr($s,false);
+ }
+
+ /**
+ Requested by "Karsten Dambekalns" <k.dambekalns@fishfarm.de>
+ */
+ function QMagic($s)
+ {
+ return $this->qstr($s,get_magic_quotes_gpc());
+ }
+
+ function q(&$s)
+ {
+ $s = $this->qstr($s,false);
+ }
+
+ /**
+ * PEAR DB Compat - do not use internally.
+ */
+ function ErrorNative()
+ {
+ return $this->ErrorNo();
+ }
+
+
+ /**
+ * PEAR DB Compat - do not use internally.
+ */
+ function nextId($seq_name)
+ {
+ return $this->GenID($seq_name);
+ }
+
+ /**
+ * Lock a row, will escalate and lock the table if row locking not supported
+ * will normally free the lock at the end of the transaction
+ *
+ * @param $table name of table to lock
+ * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
+ */
+ function RowLock($table,$where)
+ {
+ return false;
+ }
+
+ function CommitLock($table)
+ {
+ return $this->CommitTrans();
+ }
+
+ function RollbackLock($table)
+ {
+ return $this->RollbackTrans();
+ }
+
+ /**
+ * PEAR DB Compat - do not use internally.
+ *
+ * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical
+ * for easy porting :-)
+ *
+ * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
+ * @returns The previous fetch mode
+ */
+ function SetFetchMode($mode)
+ {
+ $old = $this->fetchMode;
+ $this->fetchMode = $mode;
+
+ if ($old === false) {
+ global $ADODB_FETCH_MODE;
+ return $ADODB_FETCH_MODE;
+ }
+ return $old;
+ }
+
+
+ /**
+ * PEAR DB Compat - do not use internally.
+ */
+ function &Query($sql, $inputarr=false)
+ {
+ $rs = &$this->Execute($sql, $inputarr);
+ if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ return $rs;
+ }
+
+
+ /**
+ * PEAR DB Compat - do not use internally
+ */
+ function &LimitQuery($sql, $offset, $count, $params=false)
+ {
+ $rs = &$this->SelectLimit($sql, $count, $offset, $params);
+ if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ return $rs;
+ }
+
+
+ /**
+ * PEAR DB Compat - do not use internally
+ */
+ function Disconnect()
+ {
+ return $this->Close();
+ }
+
+ /*
+ Returns placeholder for parameter, eg.
+ $DB->Param('a')
+
+ will return ':a' for Oracle, and '?' for most other databases...
+
+ For databases that require positioned params, eg $1, $2, $3 for postgresql,
+ pass in Param(false) before setting the first parameter.
+ */
+ function Param($name,$type='C')
+ {
+ return '?';
+ }
+
+ /*
+ InParameter and OutParameter are self-documenting versions of Parameter().
+ */
+ function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
+ {
+ return $this->Parameter($stmt,$var,$name,false,$maxLen,$type);
+ }
+
+ /*
+ */
+ function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
+ {
+ return $this->Parameter($stmt,$var,$name,true,$maxLen,$type);
+
+ }
+
+ /*
+ Usage in oracle
+ $stmt = $db->Prepare('select * from table where id =:myid and group=:group');
+ $db->Parameter($stmt,$id,'myid');
+ $db->Parameter($stmt,$group,'group',64);
+ $db->Execute();
+
+ @param $stmt Statement returned by Prepare() or PrepareSP().
+ @param $var PHP variable to bind to
+ @param $name Name of stored procedure variable name to bind to.
+ @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8.
+ @param [$maxLen] Holds an maximum length of the variable.
+ @param [$type] The data type of $var. Legal values depend on driver.
+
+ */
+ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
+ {
+ return false;
+ }
+
+ /**
+ Improved method of initiating a transaction. Used together with CompleteTrans().
+ Advantages include:
+
+ a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans.
+ Only the outermost block is treated as a transaction.<br>
+ b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.<br>
+ c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block
+ are disabled, making it backward compatible.
+ */
+ function StartTrans($errfn = 'ADODB_TransMonitor')
+ {
+ if ($this->transOff > 0) {
+ $this->transOff += 1;
+ return;
+ }
+
+ $this->_oldRaiseFn = $this->raiseErrorFn;
+ $this->raiseErrorFn = $errfn;
+ $this->_transOK = true;
+
+ if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
+ $this->BeginTrans();
+ $this->transOff = 1;
+ }
+
+
+ /**
+ Used together with StartTrans() to end a transaction. Monitors connection
+ for sql errors, and will commit or rollback as appropriate.
+
+ @autoComplete if true, monitor sql errors and commit and rollback as appropriate,
+ and if set to false force rollback even if no SQL error detected.
+ @returns true on commit, false on rollback.
+ */
+ function CompleteTrans($autoComplete = true)
+ {
+ if ($this->transOff > 1) {
+ $this->transOff -= 1;
+ return true;
+ }
+ $this->raiseErrorFn = $this->_oldRaiseFn;
+
+ $this->transOff = 0;
+ if ($this->_transOK && $autoComplete) {
+ if (!$this->CommitTrans()) {
+ $this->_transOK = false;
+ if ($this->debug) ADOConnection::outp("Smart Commit failed");
+ } else
+ if ($this->debug) ADOConnection::outp("Smart Commit occurred");
+ } else {
+ $this->_transOK = false;
+ $this->RollbackTrans();
+ if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred");
+ }
+
+ return $this->_transOK;
+ }
+
+ /*
+ At the end of a StartTrans/CompleteTrans block, perform a rollback.
+ */
+ function FailTrans()
+ {
+ if ($this->debug)
+ if ($this->transOff == 0) {
+ ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans");
+ } else {
+ ADOConnection::outp("FailTrans was called");
+ adodb_backtrace();
+ }
+ $this->_transOK = false;
+ }
+
+ /**
+ Check if transaction has failed, only for Smart Transactions.
+ */
+ function HasFailedTrans()
+ {
+ if ($this->transOff > 0) return $this->_transOK == false;
+ return false;
+ }
+
+ /**
+ * Execute SQL
+ *
+ * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text)
+ * @param [inputarr] holds the input data to bind to. Null elements will be set to null.
+ * @return RecordSet or false
+ */
+ function &Execute($sql,$inputarr=false)
+ {
+ if ($this->fnExecute) {
+ $fn = $this->fnExecute;
+ $ret =& $fn($this,$sql,$inputarr);
+ if (isset($ret)) return $ret;
+ }
+ if ($inputarr) {
+ if (!is_array($inputarr)) $inputarr = array($inputarr);
+
+ $element0 = reset($inputarr);
+ # is_object check because oci8 descriptors can be passed in
+ $array_2d = is_array($element0) && !is_object(reset($element0));
+
+ if (!is_array($sql) && !$this->_bindInputArray) {
+ $sqlarr = explode('?',$sql);
+
+ if (!$array_2d) $inputarr = array($inputarr);
+ foreach($inputarr as $arr) {
+ $sql = ''; $i = 0;
+ foreach($arr as $v) {
+ $sql .= $sqlarr[$i];
+ // from Ron Baldwin <ron.baldwin#sourceprose.com>
+ // Only quote string types
+ $typ = gettype($v);
+ if ($typ == 'string')
+ $sql .= $this->qstr($v);
+ else if ($typ == 'double')
+ $sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
+ else if ($typ == 'boolean')
+ $sql .= $v ? $this->true : $this->false;
+ else if ($v === null)
+ $sql .= 'NULL';
+ else
+ $sql .= $v;
+ $i += 1;
+ }
+ if (isset($sqlarr[$i])) {
+ $sql .= $sqlarr[$i];
+ if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql));
+ } else if ($i != sizeof($sqlarr))
+ ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql));
+
+ $ret =& $this->_Execute($sql);
+ if (!$ret) return $ret;
+ }
+ } else {
+ if ($array_2d) {
+ if (is_string($sql))
+ $stmt = $this->Prepare($sql);
+ else
+ $stmt = $sql;
+
+ foreach($inputarr as $arr) {
+ $ret =& $this->_Execute($stmt,$arr);
+ if (!$ret) return $ret;
+ }
+ } else {
+ $ret =& $this->_Execute($sql,$inputarr);
+ }
+ }
+ } else {
+ $ret =& $this->_Execute($sql,false);
+ }
+
+ return $ret;
+ }
+
+
+ function &_Execute($sql,$inputarr=false)
+ {
+
+ if ($this->debug) {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr);
+ } else {
+ $this->_queryID = @$this->_query($sql,$inputarr);
+ }
+
+ /************************
+ // OK, query executed
+ *************************/
+
+ if ($this->_queryID === false) { // error handling if query fails
+ if ($this->debug == 99) adodb_backtrace(true,5);
+ $fn = $this->raiseErrorFn;
+ if ($fn) {
+ $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
+ }
+ $false = false;
+ return $false;
+ }
+
+ if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead
+ $rs =& new ADORecordSet_empty();
+ return $rs;
+ }
+
+ // return real recordset from select statement
+ $rsclass = $this->rsPrefix.$this->databaseType;
+ $rs = new $rsclass($this->_queryID,$this->fetchMode);
+ $rs->connection = &$this; // Pablo suggestion
+ $rs->Init();
+ if (is_array($sql)) $rs->sql = $sql[0];
+ else $rs->sql = $sql;
+ if ($rs->_numOfRows <= 0) {
+ global $ADODB_COUNTRECS;
+ if ($ADODB_COUNTRECS) {
+ if (!$rs->EOF) {
+ $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql));
+ $rs->_queryID = $this->_queryID;
+ } else
+ $rs->_numOfRows = 0;
+ }
+ }
+ return $rs;
+ }
+
+ function CreateSequence($seqname='adodbseq',$startID=1)
+ {
+ if (empty($this->_genSeqSQL)) return false;
+ return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
+ }
+
+ function DropSequence($seqname='adodbseq')
+ {
+ if (empty($this->_dropSeqSQL)) return false;
+ return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
+ }
+
+ /**
+ * Generates a sequence id and stores it in $this->genID;
+ * GenID is only available if $this->hasGenID = true;
+ *
+ * @param seqname name of sequence to use
+ * @param startID if sequence does not exist, start at this ID
+ * @return 0 if not supported, otherwise a sequence id
+ */
+ function GenID($seqname='adodbseq',$startID=1)
+ {
+ if (!$this->hasGenID) {
+ return 0; // formerly returns false pre 1.60
+ }
+
+ $getnext = sprintf($this->_genIDSQL,$seqname);
+
+ $holdtransOK = $this->_transOK;
+
+ $save_handler = $this->raiseErrorFn;
+ $this->raiseErrorFn = '';
+ @($rs = $this->Execute($getnext));
+ $this->raiseErrorFn = $save_handler;
+
+ if (!$rs) {
+ $this->_transOK = $holdtransOK; //if the status was ok before reset
+ $createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
+ $rs = $this->Execute($getnext);
+ }
+ if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
+ else $this->genID = 0; // false
+
+ if ($rs) $rs->Close();
+
+ return $this->genID;
+ }
+
+ /**
+ * @param $table string name of the table, not needed by all databases (eg. mysql), default ''
+ * @param $column string name of the column, not needed by all databases (eg. mysql), default ''
+ * @return the last inserted ID. Not all databases support this.
+ */
+ function Insert_ID($table='',$column='')
+ {
+ if ($this->_logsql && $this->lastInsID) return $this->lastInsID;
+ if ($this->hasInsertID) return $this->_insertid($table,$column);
+ if ($this->debug) {
+ ADOConnection::outp( '<p>Insert_ID error</p>');
+ adodb_backtrace();
+ }
+ return false;
+ }
+
+
+ /**
+ * Portable Insert ID. Pablo Roca <pabloroca#mvps.org>
+ *
+ * @return the last inserted ID. All databases support this. But aware possible
+ * problems in multiuser environments. Heavy test this before deploying.
+ */
+ function PO_Insert_ID($table="", $id="")
+ {
+ if ($this->hasInsertID){
+ return $this->Insert_ID($table,$id);
+ } else {
+ return $this->GetOne("SELECT MAX($id) FROM $table");
+ }
+ }
+
+ /**
+ * @return # rows affected by UPDATE/DELETE
+ */
+ function Affected_Rows()
+ {
+ if ($this->hasAffectedRows) {
+ if ($this->fnExecute === 'adodb_log_sql') {
+ if ($this->_logsql && $this->_affected !== false) return $this->_affected;
+ }
+ $val = $this->_affectedrows();
+ return ($val < 0) ? false : $val;
+ }
+
+ if ($this->debug) ADOConnection::outp( '<p>Affected_Rows error</p>',false);
+ return false;
+ }
+
+
+ /**
+ * @return the last error message
+ */
+ function ErrorMsg()
+ {
+ if ($this->_errorMsg) return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg;
+ else return '';
+ }
+
+
+ /**
+ * @return the last error number. Normally 0 means no error.
+ */
+ function ErrorNo()
+ {
+ return ($this->_errorMsg) ? -1 : 0;
+ }
+
+ function MetaError($err=false)
+ {
+ include_once(ADODB_DIR."/adodb-error.inc.php");
+ if ($err === false) $err = $this->ErrorNo();
+ return adodb_error($this->dataProvider,$this->databaseType,$err);
+ }
+
+ function MetaErrorMsg($errno)
+ {
+ include_once(ADODB_DIR."/adodb-error.inc.php");
+ return adodb_errormsg($errno);
+ }
+
+ /**
+ * @returns an array with the primary key columns in it.
+ */
+ function MetaPrimaryKeys($table, $owner=false)
+ {
+ // owner not used in base class - see oci8
+ $p = array();
+ $objs =& $this->MetaColumns($table);
+ if ($objs) {
+ foreach($objs as $v) {
+ if (!empty($v->primary_key))
+ $p[] = $v->name;
+ }
+ }
+ if (sizeof($p)) return $p;
+ if (function_exists('ADODB_VIEW_PRIMARYKEYS'))
+ return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner);
+ return false;
+ }
+
+ /**
+ * @returns assoc array where keys are tables, and values are foreign keys
+ */
+ function MetaForeignKeys($table, $owner=false, $upper=false)
+ {
+ return false;
+ }
+ /**
+ * Choose a database to connect to. Many databases do not support this.
+ *
+ * @param dbName is the name of the database to select
+ * @return true or false
+ */
+ function SelectDB($dbName)
+ {return false;}
+
+
+ /**
+ * Will select, getting rows from $offset (1-based), for $nrows.
+ * This simulates the MySQL "select * from table limit $offset,$nrows" , and
+ * the PostgreSQL "select * from table limit $nrows offset $offset". Note that
+ * MySQL and PostgreSQL parameter ordering is the opposite of the other.
+ * eg.
+ * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based)
+ * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based)
+ *
+ * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set)
+ * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set
+ *
+ * @param sql
+ * @param [offset] is the row to start calculations from (1-based)
+ * @param [nrows] is the number of rows to get
+ * @param [inputarr] array of bind variables
+ * @param [secs2cache] is a private parameter only used by jlim
+ * @return the recordset ($rs->databaseType == 'array')
+ */
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ if ($this->hasTop && $nrows > 0) {
+ // suggested by Reinhard Balling. Access requires top after distinct
+ // Informix requires first before distinct - F Riosa
+ $ismssql = (strpos($this->databaseType,'mssql') !== false);
+ if ($ismssql) $isaccess = false;
+ else $isaccess = (strpos($this->databaseType,'access') !== false);
+
+ if ($offset <= 0) {
+
+ // access includes ties in result
+ if ($isaccess) {
+ $sql = preg_replace(
+ '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
+
+ if ($secs2cache>0) {
+ $ret =& $this->CacheExecute($secs2cache, $sql,$inputarr);
+ } else {
+ $ret =& $this->Execute($sql,$inputarr);
+ }
+ return $ret; // PHP5 fix
+ } else if ($ismssql){
+ $sql = preg_replace(
+ '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
+ } else {
+ $sql = preg_replace(
+ '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nrows.' ',$sql);
+ }
+ } else {
+ $nn = $nrows + $offset;
+ if ($isaccess || $ismssql) {
+ $sql = preg_replace(
+ '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
+ } else {
+ $sql = preg_replace(
+ '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql);
+ }
+ }
+ }
+
+ // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows
+ // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS.
+ global $ADODB_COUNTRECS;
+
+ $savec = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+
+ if ($offset>0){
+ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
+ else $rs = &$this->Execute($sql,$inputarr);
+ } else {
+ if ($secs2cache>0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
+ else $rs = &$this->Execute($sql,$inputarr);
+ }
+ $ADODB_COUNTRECS = $savec;
+ if ($rs && !$rs->EOF) {
+ $rs =& $this->_rs2rs($rs,$nrows,$offset);
+ }
+ //print_r($rs);
+ return $rs;
+ }
+
+ /**
+ * Create serializable recordset. Breaks rs link to connection.
+ *
+ * @param rs the recordset to serialize
+ */
+ function &SerializableRS(&$rs)
+ {
+ $rs2 =& $this->_rs2rs($rs);
+ $ignore = false;
+ $rs2->connection =& $ignore;
+
+ return $rs2;
+ }
+
+ /**
+ * Convert database recordset to an array recordset
+ * input recordset's cursor should be at beginning, and
+ * old $rs will be closed.
+ *
+ * @param rs the recordset to copy
+ * @param [nrows] number of rows to retrieve (optional)
+ * @param [offset] offset by number of rows (optional)
+ * @return the new recordset
+ */
+ function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true)
+ {
+ if (! $rs) {
+ $false = false;
+ return $false;
+ }
+ $dbtype = $rs->databaseType;
+ if (!$dbtype) {
+ $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ?
+ return $rs;
+ }
+ if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) {
+ $rs->MoveFirst();
+ $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ?
+ return $rs;
+ }
+ $flds = array();
+ for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
+ $flds[] = $rs->FetchField($i);
+ }
+
+ $arr =& $rs->GetArrayLimit($nrows,$offset);
+ //print_r($arr);
+ if ($close) $rs->Close();
+
+ $arrayClass = $this->arrayClass;
+
+ $rs2 = new $arrayClass();
+ $rs2->connection = &$this;
+ $rs2->sql = $rs->sql;
+ $rs2->dataProvider = $this->dataProvider;
+ $rs2->InitArrayFields($arr,$flds);
+ $rs2->fetchMode = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
+ return $rs2;
+ }
+
+ /*
+ * Return all rows. Compat with PEAR DB
+ */
+ function &GetAll($sql, $inputarr=false)
+ {
+ $arr =& $this->GetArray($sql,$inputarr);
+ return $arr;
+ }
+
+ function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false)
+ {
+ $rs =& $this->Execute($sql, $inputarr);
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
+ $arr =& $rs->GetAssoc($force_array,$first2cols);
+ return $arr;
+ }
+
+ function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false)
+ {
+ if (!is_numeric($secs2cache)) {
+ $first2cols = $force_array;
+ $force_array = $inputarr;
+ }
+ $rs =& $this->CacheExecute($secs2cache, $sql, $inputarr);
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
+ $arr =& $rs->GetAssoc($force_array,$first2cols);
+ return $arr;
+ }
+
+ /**
+ * Return first element of first row of sql statement. Recordset is disposed
+ * for you.
+ *
+ * @param sql SQL statement
+ * @param [inputarr] input bind array
+ */
+ function GetOne($sql,$inputarr=false)
+ {
+ global $ADODB_COUNTRECS;
+ $crecs = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+
+ $ret = false;
+ $rs = &$this->Execute($sql,$inputarr);
+ if ($rs) {
+ if (!$rs->EOF) $ret = reset($rs->fields);
+ $rs->Close();
+ }
+ $ADODB_COUNTRECS = $crecs;
+ return $ret;
+ }
+
+ function CacheGetOne($secs2cache,$sql=false,$inputarr=false)
+ {
+ $ret = false;
+ $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr);
+ if ($rs) {
+ if (!$rs->EOF) $ret = reset($rs->fields);
+ $rs->Close();
+ }
+
+ return $ret;
+ }
+
+ function GetCol($sql, $inputarr = false, $trim = false)
+ {
+ $rv = false;
+ $rs = &$this->Execute($sql, $inputarr);
+ if ($rs) {
+ $rv = array();
+ if ($trim) {
+ while (!$rs->EOF) {
+ $rv[] = trim(reset($rs->fields));
+ $rs->MoveNext();
+ }
+ } else {
+ while (!$rs->EOF) {
+ $rv[] = reset($rs->fields);
+ $rs->MoveNext();
+ }
+ }
+ $rs->Close();
+ }
+ return $rv;
+ }
+
+ function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false)
+ {
+ $rv = false;
+ $rs = &$this->CacheExecute($secs, $sql, $inputarr);
+ if ($rs) {
+ if ($trim) {
+ while (!$rs->EOF) {
+ $rv[] = trim(reset($rs->fields));
+ $rs->MoveNext();
+ }
+ } else {
+ while (!$rs->EOF) {
+ $rv[] = reset($rs->fields);
+ $rs->MoveNext();
+ }
+ }
+ $rs->Close();
+ }
+ return $rv;
+ }
+
+ /*
+ Calculate the offset of a date for a particular database and generate
+ appropriate SQL. Useful for calculating future/past dates and storing
+ in a database.
+
+ If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour.
+ */
+ function OffsetDate($dayFraction,$date=false)
+ {
+ if (!$date) $date = $this->sysDate;
+ return '('.$date.'+'.$dayFraction.')';
+ }
+
+
+ /**
+ *
+ * @param sql SQL statement
+ * @param [inputarr] input bind array
+ */
+ function &GetArray($sql,$inputarr=false)
+ {
+ global $ADODB_COUNTRECS;
+
+ $savec = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+ $rs =& $this->Execute($sql,$inputarr);
+ $ADODB_COUNTRECS = $savec;
+ if (!$rs)
+ if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ else {
+ $false = false;
+ return $false;
+ }
+ $arr =& $rs->GetArray();
+ $rs->Close();
+ return $arr;
+ }
+
+ function &CacheGetAll($secs2cache,$sql=false,$inputarr=false)
+ {
+ return $this->CacheGetArray($secs2cache,$sql,$inputarr);
+ }
+
+ function &CacheGetArray($secs2cache,$sql=false,$inputarr=false)
+ {
+ global $ADODB_COUNTRECS;
+
+ $savec = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+ $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
+ $ADODB_COUNTRECS = $savec;
+
+ if (!$rs)
+ if (defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+ else {
+ $false = false;
+ return $false;
+ }
+ $arr =& $rs->GetArray();
+ $rs->Close();
+ return $arr;
+ }
+
+
+
+ /**
+ * Return one row of sql statement. Recordset is disposed for you.
+ *
+ * @param sql SQL statement
+ * @param [inputarr] input bind array
+ */
+ function &GetRow($sql,$inputarr=false)
+ {
+ global $ADODB_COUNTRECS;
+ $crecs = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+
+ $rs =& $this->Execute($sql,$inputarr);
+
+ $ADODB_COUNTRECS = $crecs;
+ if ($rs) {
+ if (!$rs->EOF) $arr = $rs->fields;
+ else $arr = array();
+ $rs->Close();
+ return $arr;
+ }
+
+ $false = false;
+ return $false;
+ }
+
+ function &CacheGetRow($secs2cache,$sql=false,$inputarr=false)
+ {
+ $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr);
+ if ($rs) {
+ $arr = false;
+ if (!$rs->EOF) $arr = $rs->fields;
+ $rs->Close();
+ return $arr;
+ }
+ $false = false;
+ return $false;
+ }
+
+ /**
+ * Insert or replace a single record. Note: this is not the same as MySQL's replace.
+ * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL.
+ * Also note that no table locking is done currently, so it is possible that the
+ * record be inserted twice by two programs...
+ *
+ * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname');
+ *
+ * $table table name
+ * $fieldArray associative array of data (you must quote strings yourself).
+ * $keyCol the primary key field name or if compound key, array of field names
+ * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers
+ * but does not work with dates nor SQL functions.
+ * has_autoinc the primary key is an auto-inc field, so skip in insert.
+ *
+ * Currently blob replace not supported
+ *
+ * returns 0 = fail, 1 = update, 2 = insert
+ */
+
+ function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false)
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+
+ return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc);
+ }
+
+
+ /**
+ * Will select, getting rows from $offset (1-based), for $nrows.
+ * This simulates the MySQL "select * from table limit $offset,$nrows" , and
+ * the PostgreSQL "select * from table limit $nrows offset $offset". Note that
+ * MySQL and PostgreSQL parameter ordering is the opposite of the other.
+ * eg.
+ * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based)
+ * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)
+ *
+ * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set
+ *
+ * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional
+ * @param sql
+ * @param [offset] is the row to start calculations from (1-based)
+ * @param [nrows] is the number of rows to get
+ * @param [inputarr] array of bind variables
+ * @return the recordset ($rs->databaseType == 'array')
+ */
+ function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false)
+ {
+ if (!is_numeric($secs2cache)) {
+ if ($sql === false) $sql = -1;
+ if ($offset == -1) $offset = false;
+ // sql, nrows, offset,inputarr
+ $rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs);
+ } else {
+ if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()");
+ $rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ }
+ return $rs;
+ }
+
+ /**
+ * Flush cached recordsets that match a particular $sql statement.
+ * If $sql == false, then we purge all files in the cache.
+ */
+ function CacheFlush($sql=false,$inputarr=false)
+ {
+ global $ADODB_CACHE_DIR;
+
+ if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) {
+ if (strncmp(PHP_OS,'WIN',3) === 0) {
+ $cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache';
+ } else {
+ //$cmd = 'find "'.$ADODB_CACHE_DIR.'" -type f -maxdepth 1 -print0 | xargs -0 rm -f';
+ $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/';
+ // old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`';
+ }
+ if ($this->debug) {
+ ADOConnection::outp( "CacheFlush: $cmd<br><pre>\n", system($cmd),"</pre>");
+ } else {
+ exec($cmd);
+ }
+ return;
+ }
+
+ global $ADODB_INCLUDED_CSV;
+ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+
+ $f = $this->_gencachename($sql.serialize($inputarr),false);
+ adodb_write_file($f,''); // is adodb_write_file needed?
+ if (!@unlink($f)) {
+ if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f");
+ }
+ }
+
+ /**
+ * Private function to generate filename for caching.
+ * Filename is generated based on:
+ *
+ * - sql statement
+ * - database type (oci8, ibase, ifx, etc)
+ * - database name
+ * - userid
+ * - setFetchMode (adodb 4.23)
+ *
+ * When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR).
+ * Assuming that we can have 50,000 files per directory with good performance,
+ * then we can scale to 12.8 million unique cached recordsets. Wow!
+ */
+ function _gencachename($sql,$createdir)
+ {
+ global $ADODB_CACHE_DIR;
+ static $notSafeMode;
+
+ if ($this->fetchMode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ } else {
+ $mode = $this->fetchMode;
+ }
+ $m = md5($sql.$this->databaseType.$this->database.$this->user.$mode);
+
+ if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode');
+ $dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR;
+
+ if ($createdir && $notSafeMode && !file_exists($dir)) {
+ $oldu = umask(0);
+ if (!mkdir($dir,0771))
+ if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql");
+ umask($oldu);
+ }
+ return $dir.'/adodb_'.$m.'.cache';
+ }
+
+
+ /**
+ * Execute SQL, caching recordsets.
+ *
+ * @param [secs2cache] seconds to cache data, set to 0 to force query.
+ * This is an optional parameter.
+ * @param sql SQL statement to execute
+ * @param [inputarr] holds the input data to bind to
+ * @return RecordSet or false
+ */
+ function &CacheExecute($secs2cache,$sql=false,$inputarr=false)
+ {
+
+
+ if (!is_numeric($secs2cache)) {
+ $inputarr = $sql;
+ $sql = $secs2cache;
+ $secs2cache = $this->cacheSecs;
+ }
+
+ if (is_array($sql)) {
+ $sqlparam = $sql;
+ $sql = $sql[0];
+ } else
+ $sqlparam = $sql;
+
+ global $ADODB_INCLUDED_CSV;
+ if (empty($ADODB_INCLUDED_CSV)) include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+
+ $md5file = $this->_gencachename($sql.serialize($inputarr),true);
+ $err = '';
+
+ if ($secs2cache > 0){
+ $rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass);
+ $this->numCacheHits += 1;
+ } else {
+ $err='Timeout 1';
+ $rs = false;
+ $this->numCacheMisses += 1;
+ }
+ if (!$rs) {
+ // no cached rs found
+ if ($this->debug) {
+ if (get_magic_quotes_runtime()) {
+ ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :(");
+ }
+ if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)");
+ }
+
+ $rs = &$this->Execute($sqlparam,$inputarr);
+
+ if ($rs) {
+ $eof = $rs->EOF;
+ $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
+ $txt = _rs2serialize($rs,false,$sql); // serialize
+
+ if (!adodb_write_file($md5file,$txt,$this->debug)) {
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this);
+ }
+ if ($this->debug) ADOConnection::outp( " Cache write error");
+ }
+ if ($rs->EOF && !$eof) {
+ $rs->MoveFirst();
+ //$rs = &csv2rs($md5file,$err);
+ $rs->connection = &$this; // Pablo suggestion
+ }
+
+ } else
+ @unlink($md5file);
+ } else {
+ $this->_errorMsg = '';
+ $this->_errorCode = 0;
+
+ if ($this->fnCacheExecute) {
+ $fn = $this->fnCacheExecute;
+ $fn($this, $secs2cache, $sql, $inputarr);
+ }
+ // ok, set cached object found
+ $rs->connection = &$this; // Pablo suggestion
+ if ($this->debug){
+
+ $inBrowser = isset($_SERVER['HTTP_USER_AGENT']);
+ $ttl = $rs->timeCreated + $secs2cache - time();
+ $s = is_array($sql) ? $sql[0] : $sql;
+ if ($inBrowser) $s = '<i>'.htmlspecialchars($s).'</i>';
+
+ ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]");
+ }
+ }
+ return $rs;
+ }
+
+
+ /*
+ Similar to PEAR DB's autoExecute(), except that
+ $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE
+ If $mode == 'UPDATE', then $where is compulsory as a safety measure.
+
+ $forceUpdate means that even if the data has not changed, perform update.
+ */
+ function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false)
+ {
+ $sql = 'SELECT * FROM '.$table;
+ if ($where!==FALSE) $sql .= ' WHERE '.$where;
+ else if ($mode == 'UPDATE') {
+ ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause');
+ return false;
+ }
+
+ $rs =& $this->SelectLimit($sql,1);
+ if (!$rs) return false; // table does not exist
+ $rs->tableName = $table;
+
+ switch((string) $mode) {
+ case 'UPDATE':
+ case '2':
+ $sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq);
+ break;
+ case 'INSERT':
+ case '1':
+ $sql = $this->GetInsertSQL($rs, $fields_values, $magicq);
+ break;
+ default:
+ ADOConnection::outp("AutoExecute: Unknown mode=$mode");
+ return false;
+ }
+ $ret = false;
+ if ($sql) $ret = $this->Execute($sql);
+ if ($ret) $ret = true;
+ return $ret;
+ }
+
+
+ /**
+ * Generates an Update Query based on an existing recordset.
+ * $arrFields is an associative array of fields with the value
+ * that should be assigned.
+ *
+ * Note: This function should only be used on a recordset
+ * that is run against a single table and sql should only
+ * be a simple select stmt with no groupby/orderby/limit
+ *
+ * "Jonathan Younger" <jyounger@unilab.com>
+ */
+ function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null)
+ {
+ global $ADODB_INCLUDED_LIB;
+
+ //********************************************************//
+ //This is here to maintain compatibility
+ //with older adodb versions. Sets force type to force nulls if $forcenulls is set.
+ if (!isset($force)) {
+ global $ADODB_FORCE_TYPE;
+ $force = $ADODB_FORCE_TYPE;
+ }
+ //********************************************************//
+
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force);
+ }
+
+
+
+
+ /**
+ * Generates an Insert Query based on an existing recordset.
+ * $arrFields is an associative array of fields with the value
+ * that should be assigned.
+ *
+ * Note: This function should only be used on a recordset
+ * that is run against a single table.
+ */
+ function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null)
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (!isset($force)) {
+ global $ADODB_FORCE_TYPE;
+ $force = $ADODB_FORCE_TYPE;
+
+ }
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force);
+ }
+
+
+ /**
+ * Update a blob column, given a where clause. There are more sophisticated
+ * blob handling functions that we could have implemented, but all require
+ * a very complex API. Instead we have chosen something that is extremely
+ * simple to understand and use.
+ *
+ * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course.
+ *
+ * Usage to update a $blobvalue which has a primary key blob_id=1 into a
+ * field blobtable.blobcolumn:
+ *
+ * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1');
+ *
+ * Insert example:
+ *
+ * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
+ }
+
+ /**
+ * Usage:
+ * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1');
+ *
+ * $blobtype supports 'BLOB' and 'CLOB'
+ *
+ * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ * $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');
+ */
+ function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
+ {
+ $fd = fopen($path,'rb');
+ if ($fd === false) return false;
+ $val = fread($fd,filesize($path));
+ fclose($fd);
+ return $this->UpdateBlob($table,$column,$val,$where,$blobtype);
+ }
+
+ function BlobDecode($blob)
+ {
+ return $blob;
+ }
+
+ function BlobEncode($blob)
+ {
+ return $blob;
+ }
+
+ function SetCharSet($charset)
+ {
+ return false;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";
+ }
+
+ function LogSQL($enable=true)
+ {
+ include_once(ADODB_DIR.'/adodb-perf.inc.php');
+
+ if ($enable) $this->fnExecute = 'adodb_log_sql';
+ else $this->fnExecute = false;
+
+ $old = $this->_logsql;
+ $this->_logsql = $enable;
+ if ($enable && !$old) $this->_affected = false;
+ return $old;
+ }
+
+ function GetCharSet()
+ {
+ return false;
+ }
+
+ /**
+ * Usage:
+ * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');
+ *
+ * $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
+ * $conn->UpdateClob('clobtable','clobcol',$clob,'id=1');
+ */
+ function UpdateClob($table,$column,$val,$where)
+ {
+ return $this->UpdateBlob($table,$column,$val,$where,'CLOB');
+ }
+
+ // not the fastest implementation - quick and dirty - jlim
+ // for best performance, use the actual $rs->MetaType().
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+
+ if (empty($this->_metars)) {
+ $rsclass = $this->rsPrefix.$this->databaseType;
+ $this->_metars =& new $rsclass(false,$this->fetchMode);
+ }
+
+ return $this->_metars->MetaType($t,$len,$fieldobj);
+ }
+
+
+ /**
+ * Change the SQL connection locale to a specified locale.
+ * This is used to get the date formats written depending on the client locale.
+ */
+ function SetDateLocale($locale = 'En')
+ {
+ $this->locale = $locale;
+ switch (strtoupper($locale))
+ {
+ case 'EN':
+ $this->fmtDate="'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d H:i:s'";
+ break;
+
+ case 'US':
+ $this->fmtDate = "'m-d-Y'";
+ $this->fmtTimeStamp = "'m-d-Y H:i:s'";
+ break;
+
+ case 'NL':
+ case 'FR':
+ case 'RO':
+ case 'IT':
+ $this->fmtDate="'d-m-Y'";
+ $this->fmtTimeStamp = "'d-m-Y H:i:s'";
+ break;
+
+ case 'GE':
+ $this->fmtDate="'d.m.Y'";
+ $this->fmtTimeStamp = "'d.m.Y H:i:s'";
+ break;
+
+ default:
+ $this->fmtDate="'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d H:i:s'";
+ break;
+ }
+ }
+
+
+ /**
+ * Close Connection
+ */
+ function Close()
+ {
+ $rez = $this->_close();
+ $this->_connectionID = false;
+ return $rez;
+ }
+
+ /**
+ * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().
+ *
+ * @return true if succeeded or false if database does not support transactions
+ */
+ function BeginTrans() {return false;}
+
+
+ /**
+ * If database does not support transactions, always return true as data always commited
+ *
+ * @param $ok set to false to rollback transaction, true to commit
+ *
+ * @return true/false.
+ */
+ function CommitTrans($ok=true)
+ { return true;}
+
+
+ /**
+ * If database does not support transactions, rollbacks always fail, so return false
+ *
+ * @return true/false.
+ */
+ function RollbackTrans()
+ { return false;}
+
+
+ /**
+ * return the databases that the driver can connect to.
+ * Some databases will return an empty array.
+ *
+ * @return an array of database names.
+ */
+ function MetaDatabases()
+ {
+ global $ADODB_FETCH_MODE;
+
+ if ($this->metaDatabasesSQL) {
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ $arr = $this->GetCol($this->metaDatabasesSQL);
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ return $arr;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param ttype can either be 'VIEW' or 'TABLE' or false.
+ * If false, both views and tables are returned.
+ * "VIEW" returns only views
+ * "TABLE" returns only tables
+ * @param showSchema returns the schema/user with the table name, eg. USER.TABLE
+ * @param mask is the input mask - only supported by oci8 and postgresql
+ *
+ * @return array of tables for current database.
+ */
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+
+ $false = false;
+ if ($mask) {
+ return $false;
+ }
+ if ($this->metaTablesSQL) {
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ $rs = $this->Execute($this->metaTablesSQL);
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rs === false) return $false;
+ $arr =& $rs->GetArray();
+ $arr2 = array();
+
+ if ($hast = ($ttype && isset($arr[0][1]))) {
+ $showt = strncmp($ttype,'T',1);
+ }
+
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if ($hast) {
+ if ($showt == 0) {
+ if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
+ } else {
+ if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
+ }
+ } else
+ $arr2[] = trim($arr[$i][0]);
+ }
+ $rs->Close();
+ return $arr2;
+ }
+ return $false;
+ }
+
+
+ function _findschema(&$table,&$schema)
+ {
+ if (!$schema && ($at = strpos($table,'.')) !== false) {
+ $schema = substr($table,0,$at);
+ $table = substr($table,$at+1);
+ }
+ }
+
+ /**
+ * List columns in a database as an array of ADOFieldObjects.
+ * See top of file for definition of object.
+ *
+ * @param table table name to query
+ * @param upper uppercase table name (required by some databases)
+ * @schema is optional database schema to use - not supported by all databases.
+ *
+ * @return array of ADOFieldObjects for current table.
+ */
+ function &MetaColumns($table,$upper=true)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+
+ if (!empty($this->metaColumnsSQL)) {
+
+ $schema = false;
+ $this->_findschema($table,$schema);
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if ($rs === false || $rs->EOF) return $false;
+
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ if (isset($rs->fields[3]) && $rs->fields[3]) {
+ if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
+ $fld->scale = $rs->fields[4];
+ if ($fld->scale>0) $fld->max_length += 1;
+ } else
+ $fld->max_length = $rs->fields[2];
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
+ }
+ return $false;
+ }
+
+ /**
+ * List indexes on a table as an array.
+ * @param table table name to query
+ * @param primary true to only show primary keys. Not actually used for most databases
+ *
+ * @return array of indexes on current table. Each element represents an index, and is itself an associative array.
+
+ Array (
+ [name_of_index] => Array
+ (
+ [unique] => true or false
+ [columns] => Array
+ (
+ [0] => firstname
+ [1] => lastname
+ )
+ )
+ */
+ function &MetaIndexes($table, $primary = false, $owner = false)
+ {
+ $false = false;
+ return $false;
+ }
+
+ /**
+ * List columns names in a table as an array.
+ * @param table table name to query
+ *
+ * @return array of column names for current table.
+ */
+ function &MetaColumnNames($table, $numIndexes=false)
+ {
+ $objarr =& $this->MetaColumns($table);
+ if (!is_array($objarr)) {
+ $false = false;
+ return $false;
+ }
+ $arr = array();
+ if ($numIndexes) {
+ $i = 0;
+ foreach($objarr as $v) $arr[$i++] = $v->name;
+ } else
+ foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;
+
+ return $arr;
+ }
+
+ /**
+ * Different SQL databases used different methods to combine strings together.
+ * This function provides a wrapper.
+ *
+ * param s variable number of string parameters
+ *
+ * Usage: $db->Concat($str1,$str2);
+ *
+ * @return concatenated string
+ */
+ function Concat()
+ {
+ $arr = func_get_args();
+ return implode($this->concat_operator, $arr);
+ }
+
+
+ /**
+ * Converts a date "d" to a string that the database can understand.
+ *
+ * @param d a date in Unix date time format.
+ *
+ * @return date string in database date format
+ */
+ function DBDate($d)
+ {
+ if (empty($d) && $d !== 0) return 'null';
+
+ if (is_string($d) && !is_numeric($d)) {
+ if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
+ if ($this->isoDates) return "'$d'";
+ $d = ADOConnection::UnixDate($d);
+ }
+
+ return adodb_date($this->fmtDate,$d);
+ }
+
+
+ /**
+ * Converts a timestamp "ts" to a string that the database can understand.
+ *
+ * @param ts a timestamp in Unix date time format.
+ *
+ * @return timestamp string in database timestamp format
+ */
+ function DBTimeStamp($ts)
+ {
+ if (empty($ts) && $ts !== 0) return 'null';
+
+ # strlen(14) allows YYYYMMDDHHMMSS format
+ if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14))
+ return adodb_date($this->fmtTimeStamp,$ts);
+
+ if ($ts === 'null') return $ts;
+ if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";
+
+ $ts = ADOConnection::UnixTimeStamp($ts);
+ return adodb_date($this->fmtTimeStamp,$ts);
+ }
+
+ /**
+ * Also in ADORecordSet.
+ * @param $v is a date string in YYYY-MM-DD format
+ *
+ * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
+ */
+ function UnixDate($v)
+ {
+ if (is_object($v)) {
+ // odbtp support
+ //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
+ return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
+ }
+
+ if (is_numeric($v) && strlen($v) !== 8) return $v;
+ if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
+ ($v), $rr)) return false;
+
+ if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
+ // h-m-s-MM-DD-YY
+ return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
+ }
+
+
+ /**
+ * Also in ADORecordSet.
+ * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
+ *
+ * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
+ */
+ function UnixTimeStamp($v)
+ {
+ if (is_object($v)) {
+ // odbtp support
+ //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 )
+ return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year);
+ }
+
+ if (!preg_match(
+ "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
+ ($v), $rr)) return false;
+
+ if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
+
+ // h-m-s-MM-DD-YY
+ if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
+ return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
+ }
+
+ /**
+ * Also in ADORecordSet.
+ *
+ * Format database date based on user defined format.
+ *
+ * @param v is the character date in YYYY-MM-DD format, returned by database
+ * @param fmt is the format to apply to it, using date()
+ *
+ * @return a date formated as user desires
+ */
+
+ function UserDate($v,$fmt='Y-m-d',$gmt=false)
+ {
+ $tt = $this->UnixDate($v);
+
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) return $v;
+ else if ($tt == 0) return $this->emptyDate;
+ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
+ }
+
+ return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
+
+ }
+
+ /**
+ *
+ * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
+ * @param fmt is the format to apply to it, using date()
+ *
+ * @return a timestamp formated as user desires
+ */
+ function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false)
+ {
+ if (!isset($v)) return $this->emptyTimeStamp;
+ # strlen(14) allows YYYYMMDDHHMMSS format
+ if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v);
+ $tt = $this->UnixTimeStamp($v);
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) return $v;
+ if ($tt == 0) return $this->emptyTimeStamp;
+ return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
+ }
+
+ function escape($s,$magic_quotes=false)
+ {
+ return $this->addq($s,$magic_quotes);
+ }
+
+ /**
+ * Quotes a string, without prefixing nor appending quotes.
+ */
+ function addq($s,$magic_quotes=false)
+ {
+ if (!$magic_quotes) {
+
+ if ($this->replaceQuote[0] == '\\'){
+ // only since php 4.0.5
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
+ }
+ return str_replace("'",$this->replaceQuote,$s);
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+
+ if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
+ return $s;
+ else {// change \' to '' for sybase/mssql
+ $s = str_replace('\\\\','\\',$s);
+ return str_replace("\\'",$this->replaceQuote,$s);
+ }
+ }
+
+ /**
+ * Correctly quotes a string so that all strings are escaped. We prefix and append
+ * to the string single-quotes.
+ * An example is $db->qstr("Don't bother",magic_quotes_runtime());
+ *
+ * @param s the string to quote
+ * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
+ * This undoes the stupidity of magic quotes for GPC.
+ *
+ * @return quoted string to be sent back to database
+ */
+ function qstr($s,$magic_quotes=false)
+ {
+ if (!$magic_quotes) {
+
+ if ($this->replaceQuote[0] == '\\'){
+ // only since php 4.0.5
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
+ }
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+
+ if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
+ return "'$s'";
+ else {// change \' to '' for sybase/mssql
+ $s = str_replace('\\\\','\\',$s);
+ return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
+ }
+ }
+
+
+ /**
+ * Will select the supplied $page number from a recordset, given that it is paginated in pages of
+ * $nrows rows per page. It also saves two boolean values saying if the given page is the first
+ * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
+ *
+ * See readme.htm#ex8 for an example of usage.
+ *
+ * @param sql
+ * @param nrows is the number of rows per page to get
+ * @param page is the page number to get (1-based)
+ * @param [inputarr] array of bind variables
+ * @param [secs2cache] is a private parameter only used by jlim
+ * @return the recordset ($rs->databaseType == 'array')
+ *
+ * NOTE: phpLens uses a different algorithm and does not use PageExecute().
+ *
+ */
+ function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
+ else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
+ return $rs;
+ }
+
+
+ /**
+ * Will select the supplied $page number from a recordset, given that it is paginated in pages of
+ * $nrows rows per page. It also saves two boolean values saying if the given page is the first
+ * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
+ *
+ * @param secs2cache seconds to cache data, set to 0 to force query
+ * @param sql
+ * @param nrows is the number of rows per page to get
+ * @param page is the page number to get (1-based)
+ * @param [inputarr] array of bind variables
+ * @return the recordset ($rs->databaseType == 'array')
+ */
+ function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
+ {
+ /*switch($this->dataProvider) {
+ case 'postgres':
+ case 'mysql':
+ break;
+ default: $secs2cache = 0; break;
+ }*/
+ $rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache);
+ return $rs;
+ }
+
+} // end class ADOConnection
+
+
+
+ //==============================================================================================
+ // CLASS ADOFetchObj
+ //==============================================================================================
+
+ /**
+ * Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
+ */
+ class ADOFetchObj {
+ };
+
+ //==============================================================================================
+ // CLASS ADORecordSet_empty
+ //==============================================================================================
+
+ /**
+ * Lightweight recordset when there are no records to be returned
+ */
+ class ADORecordSet_empty
+ {
+ var $dataProvider = 'empty';
+ var $databaseType = false;
+ var $EOF = true;
+ var $_numOfRows = 0;
+ var $fields = false;
+ var $connection = false;
+ function RowCount() {return 0;}
+ function RecordCount() {return 0;}
+ function PO_RecordCount(){return 0;}
+ function Close(){return true;}
+ function FetchRow() {return false;}
+ function FieldCount(){ return 0;}
+ function Init() {}
+ }
+
+ //==============================================================================================
+ // DATE AND TIME FUNCTIONS
+ //==============================================================================================
+ include_once(ADODB_DIR.'/adodb-time.inc.php');
+
+ //==============================================================================================
+ // CLASS ADORecordSet
+ //==============================================================================================
+
+ if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php');
+ else include_once(ADODB_DIR.'/adodb-iterator.inc.php');
+ /**
+ * RecordSet class that represents the dataset returned by the database.
+ * To keep memory overhead low, this class holds only the current row in memory.
+ * No prefetching of data is done, so the RecordCount() can return -1 ( which
+ * means recordcount not known).
+ */
+ class ADORecordSet extends ADODB_BASE_RS {
+ /*
+ * public variables
+ */
+ var $dataProvider = "native";
+ var $fields = false; /// holds the current row data
+ var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
+ /// in other words, we use a text area for editing.
+ var $canSeek = false; /// indicates that seek is supported
+ var $sql; /// sql text
+ var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object.
+
+ var $emptyTimeStamp = '&nbsp;'; /// what to display when $time==0
+ var $emptyDate = '&nbsp;'; /// what to display when $time==0
+ var $debug = false;
+ var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets
+
+ var $bind = false; /// used by Fields() to hold array - should be private?
+ var $fetchMode; /// default fetch mode
+ var $connection = false; /// the parent connection
+ /*
+ * private variables
+ */
+ var $_numOfRows = -1; /** number of rows, or -1 */
+ var $_numOfFields = -1; /** number of fields in recordset */
+ var $_queryID = -1; /** This variable keeps the result link identifier. */
+ var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */
+ var $_closed = false; /** has recordset been closed */
+ var $_inited = false; /** Init() should only be called once */
+ var $_obj; /** Used by FetchObj */
+ var $_names; /** Used by FetchObj */
+
+ var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */
+ var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */
+ var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */
+ var $_lastPageNo = -1;
+ var $_maxRecordCount = 0;
+ var $datetime = false;
+
+ /**
+ * Constructor
+ *
+ * @param queryID this is the queryID returned by ADOConnection->_query()
+ *
+ */
+ function ADORecordSet($queryID)
+ {
+ $this->_queryID = $queryID;
+ }
+
+
+
+ function Init()
+ {
+ if ($this->_inited) return;
+ $this->_inited = true;
+ if ($this->_queryID) @$this->_initrs();
+ else {
+ $this->_numOfRows = 0;
+ $this->_numOfFields = 0;
+ }
+ if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) {
+
+ $this->_currentRow = 0;
+ if ($this->EOF = ($this->_fetch() === false)) {
+ $this->_numOfRows = 0; // _numOfRows could be -1
+ }
+ } else {
+ $this->EOF = true;
+ }
+ }
+
+
+ /**
+ * Generate a SELECT tag string from a recordset, and return the string.
+ * If the recordset has 2 cols, we treat the 1st col as the containing
+ * the text to display to the user, and 2nd col as the return value. Default
+ * strings are compared with the FIRST column.
+ *
+ * @param name name of SELECT tag
+ * @param [defstr] the value to hilite. Use an array for multiple hilites for listbox.
+ * @param [blank1stItem] true to leave the 1st item in list empty
+ * @param [multiple] true for listbox, false for popup
+ * @param [size] #rows to show for listbox. not used by popup
+ * @param [selectAttr] additional attributes to defined for SELECT tag.
+ * useful for holding javascript onChange='...' handlers.
+ & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with
+ * column 0 (1st col) if this is true. This is not documented.
+ *
+ * @return HTML
+ *
+ * changes by glen.davies@cce.ac.nz to support multiple hilited items
+ */
+ function GetMenu($name,$defstr='',$blank1stItem=true,$multiple=false,
+ $size=0, $selectAttr='',$compareFields0=true)
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple,
+ $size, $selectAttr,$compareFields0);
+ }
+
+
+
+ /**
+ * Generate a SELECT tag string from a recordset, and return the string.
+ * If the recordset has 2 cols, we treat the 1st col as the containing
+ * the text to display to the user, and 2nd col as the return value. Default
+ * strings are compared with the SECOND column.
+ *
+ */
+ function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='')
+ {
+ return $this->GetMenu($name,$defstr,$blank1stItem,$multiple,
+ $size, $selectAttr,false);
+ }
+
+ /*
+ Grouped Menu
+ */
+ function GetMenu3($name,$defstr='',$blank1stItem=true,$multiple=false,
+ $size=0, $selectAttr='')
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple,
+ $size, $selectAttr,false);
+ }
+
+ /**
+ * return recordset as a 2-dimensional array.
+ *
+ * @param [nRows] is the number of rows to return. -1 means every row.
+ *
+ * @return an array indexed by the rows (0-based) from the recordset
+ */
+ function &GetArray($nRows = -1)
+ {
+ global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows);
+
+ $results = array();
+ $cnt = 0;
+ while (!$this->EOF && $nRows != $cnt) {
+ $results[] = $this->fields;
+ $this->MoveNext();
+ $cnt++;
+ }
+ return $results;
+ }
+
+ function &GetAll($nRows = -1)
+ {
+ $arr =& $this->GetArray($nRows);
+ return $arr;
+ }
+
+ /*
+ * Some databases allow multiple recordsets to be returned. This function
+ * will return true if there is a next recordset, or false if no more.
+ */
+ function NextRecordSet()
+ {
+ return false;
+ }
+
+ /**
+ * return recordset as a 2-dimensional array.
+ * Helper function for ADOConnection->SelectLimit()
+ *
+ * @param offset is the row to start calculations from (1-based)
+ * @param [nrows] is the number of rows to return
+ *
+ * @return an array indexed by the rows (0-based) from the recordset
+ */
+ function &GetArrayLimit($nrows,$offset=-1)
+ {
+ if ($offset <= 0) {
+ $arr =& $this->GetArray($nrows);
+ return $arr;
+ }
+
+ $this->Move($offset);
+
+ $results = array();
+ $cnt = 0;
+ while (!$this->EOF && $nrows != $cnt) {
+ $results[$cnt++] = $this->fields;
+ $this->MoveNext();
+ }
+
+ return $results;
+ }
+
+
+ /**
+ * Synonym for GetArray() for compatibility with ADO.
+ *
+ * @param [nRows] is the number of rows to return. -1 means every row.
+ *
+ * @return an array indexed by the rows (0-based) from the recordset
+ */
+ function &GetRows($nRows = -1)
+ {
+ $arr =& $this->GetArray($nRows);
+ return $arr;
+ }
+
+ /**
+ * return whole recordset as a 2-dimensional associative array if there are more than 2 columns.
+ * The first column is treated as the key and is not included in the array.
+ * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless
+ * $force_array == true.
+ *
+ * @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional
+ * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing,
+ * read the source.
+ *
+ * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and
+ * instead of returning array[col0] => array(remaining cols), return array[col0] => col1
+ *
+ * @return an associative array indexed by the first column of the array,
+ * or false if the data has less than 2 cols.
+ */
+ function &GetAssoc($force_array = false, $first2cols = false)
+ {
+ global $ADODB_EXTENSION;
+
+ $cols = $this->_numOfFields;
+ if ($cols < 2) {
+ $false = false;
+ return $false;
+ }
+ $numIndex = isset($this->fields[0]);
+ $results = array();
+
+ if (!$first2cols && ($cols > 2 || $force_array)) {
+ if ($ADODB_EXTENSION) {
+ if ($numIndex) {
+ while (!$this->EOF) {
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);
+ adodb_movenext($this);
+ }
+ } else {
+ while (!$this->EOF) {
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
+ adodb_movenext($this);
+ }
+ }
+ } else {
+ if ($numIndex) {
+ while (!$this->EOF) {
+ $results[trim($this->fields[0])] = array_slice($this->fields, 1);
+ $this->MoveNext();
+ }
+ } else {
+ while (!$this->EOF) {
+ $results[trim(reset($this->fields))] = array_slice($this->fields, 1);
+ $this->MoveNext();
+ }
+ }
+ }
+ } else {
+ if ($ADODB_EXTENSION) {
+ // return scalar values
+ if ($numIndex) {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $results[trim(($this->fields[0]))] = $this->fields[1];
+ adodb_movenext($this);
+ }
+ } else {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $v1 = trim(reset($this->fields));
+ $v2 = ''.next($this->fields);
+ $results[$v1] = $v2;
+ adodb_movenext($this);
+ }
+ }
+ } else {
+ if ($numIndex) {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $results[trim(($this->fields[0]))] = $this->fields[1];
+ $this->MoveNext();
+ }
+ } else {
+ while (!$this->EOF) {
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
+ $v1 = trim(reset($this->fields));
+ $v2 = ''.next($this->fields);
+ $results[$v1] = $v2;
+ $this->MoveNext();
+ }
+ }
+ }
+ }
+ return $results;
+ }
+
+
+ /**
+ *
+ * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
+ * @param fmt is the format to apply to it, using date()
+ *
+ * @return a timestamp formated as user desires
+ */
+ function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
+ {
+ if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v);
+ $tt = $this->UnixTimeStamp($v);
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) return $v;
+ if ($tt === 0) return $this->emptyTimeStamp;
+ return adodb_date($fmt,$tt);
+ }
+
+
+ /**
+ * @param v is the character date in YYYY-MM-DD format, returned by database
+ * @param fmt is the format to apply to it, using date()
+ *
+ * @return a date formated as user desires
+ */
+ function UserDate($v,$fmt='Y-m-d')
+ {
+ $tt = $this->UnixDate($v);
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
+ if (($tt === false || $tt == -1) && $v != false) return $v;
+ else if ($tt == 0) return $this->emptyDate;
+ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
+ }
+ return adodb_date($fmt,$tt);
+ }
+
+
+ /**
+ * @param $v is a date string in YYYY-MM-DD format
+ *
+ * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
+ */
+ function UnixDate($v)
+ {
+ return ADOConnection::UnixDate($v);
+ }
+
+
+ /**
+ * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
+ *
+ * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
+ */
+ function UnixTimeStamp($v)
+ {
+ return ADOConnection::UnixTimeStamp($v);
+ }
+
+
+ /**
+ * PEAR DB Compat - do not use internally
+ */
+ function Free()
+ {
+ return $this->Close();
+ }
+
+
+ /**
+ * PEAR DB compat, number of rows
+ */
+ function NumRows()
+ {
+ return $this->_numOfRows;
+ }
+
+
+ /**
+ * PEAR DB compat, number of cols
+ */
+ function NumCols()
+ {
+ return $this->_numOfFields;
+ }
+
+ /**
+ * Fetch a row, returning false if no more rows.
+ * This is PEAR DB compat mode.
+ *
+ * @return false or array containing the current record
+ */
+ function &FetchRow()
+ {
+ if ($this->EOF) {
+ $false = false;
+ return $false;
+ }
+ $arr = $this->fields;
+ $this->_currentRow++;
+ if (!$this->_fetch()) $this->EOF = true;
+ return $arr;
+ }
+
+
+ /**
+ * Fetch a row, returning PEAR_Error if no more rows.
+ * This is PEAR DB compat mode.
+ *
+ * @return DB_OK or error object
+ */
+ function FetchInto(&$arr)
+ {
+ if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
+ $arr = $this->fields;
+ $this->MoveNext();
+ return 1; // DB_OK
+ }
+
+
+ /**
+ * Move to the first row in the recordset. Many databases do NOT support this.
+ *
+ * @return true or false
+ */
+ function MoveFirst()
+ {
+ if ($this->_currentRow == 0) return true;
+ return $this->Move(0);
+ }
+
+
+ /**
+ * Move to the last row in the recordset.
+ *
+ * @return true or false
+ */
+ function MoveLast()
+ {
+ if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1);
+ if ($this->EOF) return false;
+ while (!$this->EOF) {
+ $f = $this->fields;
+ $this->MoveNext();
+ }
+ $this->fields = $f;
+ $this->EOF = false;
+ return true;
+ }
+
+
+ /**
+ * Move to next record in the recordset.
+ *
+ * @return true if there still rows available, or false if there are no more rows (EOF).
+ */
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+ if ($this->_fetch()) return true;
+ }
+ $this->EOF = true;
+ /* -- tested error handling when scrolling cursor -- seems useless.
+ $conn = $this->connection;
+ if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {
+ $fn = $conn->raiseErrorFn;
+ $fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);
+ }
+ */
+ return false;
+ }
+
+
+ /**
+ * Random access to a specific row in the recordset. Some databases do not support
+ * access to previous rows in the databases (no scrolling backwards).
+ *
+ * @param rowNumber is the row to move to (0-based)
+ *
+ * @return true if there still rows available, or false if there are no more rows (EOF).
+ */
+ function Move($rowNumber = 0)
+ {
+ $this->EOF = false;
+ if ($rowNumber == $this->_currentRow) return true;
+ if ($rowNumber >= $this->_numOfRows)
+ if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;
+
+ if ($this->canSeek) {
+
+ if ($this->_seek($rowNumber)) {
+ $this->_currentRow = $rowNumber;
+ if ($this->_fetch()) {
+ return true;
+ }
+ } else {
+ $this->EOF = true;
+ return false;
+ }
+ } else {
+ if ($rowNumber < $this->_currentRow) return false;
+ global $ADODB_EXTENSION;
+ if ($ADODB_EXTENSION) {
+ while (!$this->EOF && $this->_currentRow < $rowNumber) {
+ adodb_movenext($this);
+ }
+ } else {
+
+ while (! $this->EOF && $this->_currentRow < $rowNumber) {
+ $this->_currentRow++;
+
+ if (!$this->_fetch()) $this->EOF = true;
+ }
+ }
+ return !($this->EOF);
+ }
+
+ $this->fields = false;
+ $this->EOF = true;
+ return false;
+ }
+
+
+ /**
+ * Get the value of a field in the current row by column name.
+ * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM.
+ *
+ * @param colname is the field to access
+ *
+ * @return the value of $colname column
+ */
+ function Fields($colname)
+ {
+ return $this->fields[$colname];
+ }
+
+ function GetAssocKeys($upper=true)
+ {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ if ($upper === 2) $this->bind[$o->name] = $i;
+ else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i;
+ }
+ }
+
+ /**
+ * Use associative array to get fields array for databases that do not support
+ * associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it
+ *
+ * If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC
+ * before you execute your SQL statement, and access $rs->fields['col'] directly.
+ *
+ * $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField
+ */
+ function &GetRowAssoc($upper=1)
+ {
+ $record = array();
+ // if (!$this->fields) return $record;
+
+ if (!$this->bind) {
+ $this->GetAssocKeys($upper);
+ }
+
+ foreach($this->bind as $k => $v) {
+ $record[$k] = $this->fields[$v];
+ }
+
+ return $record;
+ }
+
+
+ /**
+ * Clean up recordset
+ *
+ * @return true or false
+ */
+ function Close()
+ {
+ // free connection object - this seems to globally free the object
+ // and not merely the reference, so don't do this...
+ // $this->connection = false;
+ if (!$this->_closed) {
+ $this->_closed = true;
+ return $this->_close();
+ } else
+ return true;
+ }
+
+ /**
+ * synonyms RecordCount and RowCount
+ *
+ * @return the number of rows or -1 if this is not supported
+ */
+ function RecordCount() {return $this->_numOfRows;}
+
+
+ /*
+ * If we are using PageExecute(), this will return the maximum possible rows
+ * that can be returned when paging a recordset.
+ */
+ function MaxRecordCount()
+ {
+ return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount();
+ }
+
+ /**
+ * synonyms RecordCount and RowCount
+ *
+ * @return the number of rows or -1 if this is not supported
+ */
+ function RowCount() {return $this->_numOfRows;}
+
+
+ /**
+ * Portable RecordCount. Pablo Roca <pabloroca@mvps.org>
+ *
+ * @return the number of records from a previous SELECT. All databases support this.
+ *
+ * But aware possible problems in multiuser environments. For better speed the table
+ * must be indexed by the condition. Heavy test this before deploying.
+ */
+ function PO_RecordCount($table="", $condition="") {
+
+ $lnumrows = $this->_numOfRows;
+ // the database doesn't support native recordcount, so we do a workaround
+ if ($lnumrows == -1 && $this->connection) {
+ IF ($table) {
+ if ($condition) $condition = " WHERE " . $condition;
+ $resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
+ if ($resultrows) $lnumrows = reset($resultrows->fields);
+ }
+ }
+ return $lnumrows;
+ }
+
+ /**
+ * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
+ */
+ function CurrentRow() {return $this->_currentRow;}
+
+ /**
+ * synonym for CurrentRow -- for ADO compat
+ *
+ * @return the current row in the recordset. If at EOF, will return the last row. 0-based.
+ */
+ function AbsolutePosition() {return $this->_currentRow;}
+
+ /**
+ * @return the number of columns in the recordset. Some databases will set this to 0
+ * if no records are returned, others will return the number of columns in the query.
+ */
+ function FieldCount() {return $this->_numOfFields;}
+
+
+ /**
+ * Get the ADOFieldObject of a specific column.
+ *
+ * @param fieldoffset is the column position to access(0-based).
+ *
+ * @return the ADOFieldObject for that column, or false.
+ */
+ function &FetchField($fieldoffset)
+ {
+ // must be defined by child class
+ }
+
+ /**
+ * Get the ADOFieldObjects of all columns in an array.
+ *
+ */
+ function& FieldTypesArray()
+ {
+ $arr = array();
+ for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
+ $arr[] = $this->FetchField($i);
+ return $arr;
+ }
+
+ /**
+ * Return the fields array of the current row as an object for convenience.
+ * The default case is lowercase field names.
+ *
+ * @return the object with the properties set to the fields of the current row
+ */
+ function &FetchObj()
+ {
+ $o =& $this->FetchObject(false);
+ return $o;
+ }
+
+ /**
+ * Return the fields array of the current row as an object for convenience.
+ * The default case is uppercase.
+ *
+ * @param $isupper to set the object property names to uppercase
+ *
+ * @return the object with the properties set to the fields of the current row
+ */
+ function &FetchObject($isupper=true)
+ {
+ if (empty($this->_obj)) {
+ $this->_obj = new ADOFetchObj();
+ $this->_names = array();
+ for ($i=0; $i <$this->_numOfFields; $i++) {
+ $f = $this->FetchField($i);
+ $this->_names[] = $f->name;
+ }
+ }
+ $i = 0;
+ if (PHP_VERSION >= 5) $o = clone($this->_obj);
+ else $o = $this->_obj;
+
+ for ($i=0; $i <$this->_numOfFields; $i++) {
+ $name = $this->_names[$i];
+ if ($isupper) $n = strtoupper($name);
+ else $n = $name;
+
+ $o->$n = $this->Fields($name);
+ }
+ return $o;
+ }
+
+ /**
+ * Return the fields array of the current row as an object for convenience.
+ * The default is lower-case field names.
+ *
+ * @return the object with the properties set to the fields of the current row,
+ * or false if EOF
+ *
+ * Fixed bug reported by tim@orotech.net
+ */
+ function &FetchNextObj()
+ {
+ $o =& $this->FetchNextObject(false);
+ return $o;
+ }
+
+
+ /**
+ * Return the fields array of the current row as an object for convenience.
+ * The default is upper case field names.
+ *
+ * @param $isupper to set the object property names to uppercase
+ *
+ * @return the object with the properties set to the fields of the current row,
+ * or false if EOF
+ *
+ * Fixed bug reported by tim@orotech.net
+ */
+ function &FetchNextObject($isupper=true)
+ {
+ $o = false;
+ if ($this->_numOfRows != 0 && !$this->EOF) {
+ $o = $this->FetchObject($isupper);
+ $this->_currentRow++;
+ if ($this->_fetch()) return $o;
+ }
+ $this->EOF = true;
+ return $o;
+ }
+
+ /**
+ * Get the metatype of the column. This is used for formatting. This is because
+ * many databases use different names for the same type, so we transform the original
+ * type to our standardised version which uses 1 character codes:
+ *
+ * @param t is the type passed in. Normally is ADOFieldObject->type.
+ * @param len is the maximum length of that field. This is because we treat character
+ * fields bigger than a certain size as a 'B' (blob).
+ * @param fieldobj is the field object returned by the database driver. Can hold
+ * additional info (eg. primary_key for mysql).
+ *
+ * @return the general type of the data:
+ * C for character < 250 chars
+ * X for teXt (>= 250 chars)
+ * B for Binary
+ * N for numeric or floating point
+ * D for date
+ * T for timestamp
+ * L for logical/Boolean
+ * I for integer
+ * R for autoincrement counter/integer
+ *
+ *
+ */
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ // changed in 2.32 to hashing instead of switch stmt for speed...
+ static $typeMap = array(
+ 'VARCHAR' => 'C',
+ 'VARCHAR2' => 'C',
+ 'CHAR' => 'C',
+ 'C' => 'C',
+ 'STRING' => 'C',
+ 'NCHAR' => 'C',
+ 'NVARCHAR' => 'C',
+ 'VARYING' => 'C',
+ 'BPCHAR' => 'C',
+ 'CHARACTER' => 'C',
+ 'INTERVAL' => 'C', # Postgres
+ ##
+ 'LONGCHAR' => 'X',
+ 'TEXT' => 'X',
+ 'NTEXT' => 'X',
+ 'M' => 'X',
+ 'X' => 'X',
+ 'CLOB' => 'X',
+ 'NCLOB' => 'X',
+ 'LVARCHAR' => 'X',
+ ##
+ 'BLOB' => 'B',
+ 'IMAGE' => 'B',
+ 'BINARY' => 'B',
+ 'VARBINARY' => 'B',
+ 'LONGBINARY' => 'B',
+ 'B' => 'B',
+ ##
+ 'YEAR' => 'D', // mysql
+ 'DATE' => 'D',
+ 'D' => 'D',
+ ##
+ 'TIME' => 'T',
+ 'TIMESTAMP' => 'T',
+ 'DATETIME' => 'T',
+ 'TIMESTAMPTZ' => 'T',
+ 'T' => 'T',
+ ##
+ 'BOOL' => 'L',
+ 'BOOLEAN' => 'L',
+ 'BIT' => 'L',
+ 'L' => 'L',
+ ##
+ 'COUNTER' => 'R',
+ 'R' => 'R',
+ 'SERIAL' => 'R', // ifx
+ 'INT IDENTITY' => 'R',
+ ##
+ 'INT' => 'I',
+ 'INT2' => 'I',
+ 'INT4' => 'I',
+ 'INT8' => 'I',
+ 'INTEGER' => 'I',
+ 'INTEGER UNSIGNED' => 'I',
+ 'SHORT' => 'I',
+ 'TINYINT' => 'I',
+ 'SMALLINT' => 'I',
+ 'I' => 'I',
+ ##
+ 'LONG' => 'N', // interbase is numeric, oci8 is blob
+ 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers
+ 'DECIMAL' => 'N',
+ 'DEC' => 'N',
+ 'REAL' => 'N',
+ 'DOUBLE' => 'N',
+ 'DOUBLE PRECISION' => 'N',
+ 'SMALLFLOAT' => 'N',
+ 'FLOAT' => 'N',
+ 'NUMBER' => 'N',
+ 'NUM' => 'N',
+ 'NUMERIC' => 'N',
+ 'MONEY' => 'N',
+
+ ## informix 9.2
+ 'SQLINT' => 'I',
+ 'SQLSERIAL' => 'I',
+ 'SQLSMINT' => 'I',
+ 'SQLSMFLOAT' => 'N',
+ 'SQLFLOAT' => 'N',
+ 'SQLMONEY' => 'N',
+ 'SQLDECIMAL' => 'N',
+ 'SQLDATE' => 'D',
+ 'SQLVCHAR' => 'C',
+ 'SQLCHAR' => 'C',
+ 'SQLDTIME' => 'T',
+ 'SQLINTERVAL' => 'N',
+ 'SQLBYTES' => 'B',
+ 'SQLTEXT' => 'X'
+ );
+
+ $tmap = false;
+ $t = strtoupper($t);
+ $tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N';
+ switch ($tmap) {
+ case 'C':
+
+ // is the char field is too long, return as text field...
+ if ($this->blobSize >= 0) {
+ if ($len > $this->blobSize) return 'X';
+ } else if ($len > 250) {
+ return 'X';
+ }
+ return 'C';
+
+ case 'I':
+ if (!empty($fieldobj->primary_key)) return 'R';
+ return 'I';
+
+ case false:
+ return 'N';
+
+ case 'B':
+ if (isset($fieldobj->binary))
+ return ($fieldobj->binary) ? 'B' : 'X';
+ return 'B';
+
+ case 'D':
+ if (!empty($this->datetime)) return 'T';
+ return 'D';
+
+ default:
+ if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
+ return $tmap;
+ }
+ }
+
+ function _close() {}
+
+ /**
+ * set/returns the current recordset page when paginating
+ */
+ function AbsolutePage($page=-1)
+ {
+ if ($page != -1) $this->_currentPage = $page;
+ return $this->_currentPage;
+ }
+
+ /**
+ * set/returns the status of the atFirstPage flag when paginating
+ */
+ function AtFirstPage($status=false)
+ {
+ if ($status != false) $this->_atFirstPage = $status;
+ return $this->_atFirstPage;
+ }
+
+ function LastPageNo($page = false)
+ {
+ if ($page != false) $this->_lastPageNo = $page;
+ return $this->_lastPageNo;
+ }
+
+ /**
+ * set/returns the status of the atLastPage flag when paginating
+ */
+ function AtLastPage($status=false)
+ {
+ if ($status != false) $this->_atLastPage = $status;
+ return $this->_atLastPage;
+ }
+
+} // end class ADORecordSet
+
+ //==============================================================================================
+ // CLASS ADORecordSet_array
+ //==============================================================================================
+
+ /**
+ * This class encapsulates the concept of a recordset created in memory
+ * as an array. This is useful for the creation of cached recordsets.
+ *
+ * Note that the constructor is different from the standard ADORecordSet
+ */
+
+ class ADORecordSet_array extends ADORecordSet
+ {
+ var $databaseType = 'array';
+
+ var $_array; // holds the 2-dimensional data array
+ var $_types; // the array of types of each column (C B I L M)
+ var $_colnames; // names of each column in array
+ var $_skiprow1; // skip 1st row because it holds column names
+ var $_fieldarr; // holds array of field objects
+ var $canSeek = true;
+ var $affectedrows = false;
+ var $insertid = false;
+ var $sql = '';
+ var $compat = false;
+ /**
+ * Constructor
+ *
+ */
+ function ADORecordSet_array($fakeid=1)
+ {
+ global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH;
+
+ // fetch() on EOF does not delete $this->fields
+ $this->compat = !empty($ADODB_COMPAT_FETCH);
+ $this->ADORecordSet($fakeid); // fake queryID
+ $this->fetchMode = $ADODB_FETCH_MODE;
+ }
+
+
+ /**
+ * Setup the array.
+ *
+ * @param array is a 2-dimensional array holding the data.
+ * The first row should hold the column names
+ * unless paramter $colnames is used.
+ * @param typearr holds an array of types. These are the same types
+ * used in MetaTypes (C,B,L,I,N).
+ * @param [colnames] array of column names. If set, then the first row of
+ * $array should not hold the column names.
+ */
+ function InitArray($array,$typearr,$colnames=false)
+ {
+ $this->_array = $array;
+ $this->_types = $typearr;
+ if ($colnames) {
+ $this->_skiprow1 = false;
+ $this->_colnames = $colnames;
+ } else {
+ $this->_skiprow1 = true;
+ $this->_colnames = $array[0];
+ }
+ $this->Init();
+ }
+ /**
+ * Setup the Array and datatype file objects
+ *
+ * @param array is a 2-dimensional array holding the data.
+ * The first row should hold the column names
+ * unless paramter $colnames is used.
+ * @param fieldarr holds an array of ADOFieldObject's.
+ */
+ function InitArrayFields(&$array,&$fieldarr)
+ {
+ $this->_array =& $array;
+ $this->_skiprow1= false;
+ if ($fieldarr) {
+ $this->_fieldobjects =& $fieldarr;
+ }
+ $this->Init();
+ }
+
+ function &GetArray($nRows=-1)
+ {
+ if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) {
+ return $this->_array;
+ } else {
+ $arr =& ADORecordSet::GetArray($nRows);
+ return $arr;
+ }
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = sizeof($this->_array);
+ if ($this->_skiprow1) $this->_numOfRows -= 1;
+
+ $this->_numOfFields =(isset($this->_fieldobjects)) ?
+ sizeof($this->_fieldobjects):sizeof($this->_types);
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ $mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode;
+
+ if ($mode & ADODB_FETCH_ASSOC) {
+ if (!isset($this->fields[$colname])) $colname = strtolower($colname);
+ return $this->fields[$colname];
+ }
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function &FetchField($fieldOffset = -1)
+ {
+ if (isset($this->_fieldobjects)) {
+ return $this->_fieldobjects[$fieldOffset];
+ }
+ $o = new ADOFieldObject();
+ $o->name = $this->_colnames[$fieldOffset];
+ $o->type = $this->_types[$fieldOffset];
+ $o->max_length = -1; // length not known
+
+ return $o;
+ }
+
+ function _seek($row)
+ {
+ if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) {
+ $this->_currentRow = $row;
+ if ($this->_skiprow1) $row += 1;
+ $this->fields = $this->_array[$row];
+ return true;
+ }
+ return false;
+ }
+
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+
+ $pos = $this->_currentRow;
+
+ if ($this->_numOfRows <= $pos) {
+ if (!$this->compat) $this->fields = false;
+ } else {
+ if ($this->_skiprow1) $pos += 1;
+ $this->fields = $this->_array[$pos];
+ return true;
+ }
+ $this->EOF = true;
+ }
+
+ return false;
+ }
+
+ function _fetch()
+ {
+ $pos = $this->_currentRow;
+
+ if ($this->_numOfRows <= $pos) {
+ if (!$this->compat) $this->fields = false;
+ return false;
+ }
+ if ($this->_skiprow1) $pos += 1;
+ $this->fields = $this->_array[$pos];
+ return true;
+ }
+
+ function _close()
+ {
+ return true;
+ }
+
+ } // ADORecordSet_array
+
+ //==============================================================================================
+ // HELPER FUNCTIONS
+ //==============================================================================================
+
+ /**
+ * Synonym for ADOLoadCode. Private function. Do not use.
+ *
+ * @deprecated
+ */
+ function ADOLoadDB($dbType)
+ {
+ return ADOLoadCode($dbType);
+ }
+
+ /**
+ * Load the code for a specific database driver. Private function. Do not use.
+ */
+ function ADOLoadCode($dbType)
+ {
+ global $ADODB_LASTDB;
+
+ if (!$dbType) return false;
+ $db = strtolower($dbType);
+ switch ($db) {
+ case 'ado':
+ if (PHP_VERSION >= 5) $db = 'ado5';
+ $class = 'ado';
+ break;
+ case 'ifx':
+ case 'maxsql': $class = $db = 'mysqlt'; break;
+ case 'postgres':
+ case 'postgres8':
+ case 'pgsql': $class = $db = 'postgres7'; break;
+ default:
+ $class = $db; break;
+ }
+
+ $file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
+ @include_once($file);
+ $ADODB_LASTDB = $class;
+ if (class_exists("ADODB_" . $class)) return $class;
+
+ //ADOConnection::outp(adodb_pr(get_declared_classes(),true));
+ if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
+ else ADOConnection::outp("Syntax error in file: $file");
+ return false;
+ }
+
+ /**
+ * synonym for ADONewConnection for people like me who cannot remember the correct name
+ */
+ function &NewADOConnection($db='')
+ {
+ $tmp =& ADONewConnection($db);
+ return $tmp;
+ }
+
+ /**
+ * Instantiate a new Connection class for a specific database driver.
+ *
+ * @param [db] is the database Connection object to create. If undefined,
+ * use the last database driver that was loaded by ADOLoadCode().
+ *
+ * @return the freshly created instance of the Connection class.
+ */
+ function &ADONewConnection($db='')
+ {
+ GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;
+
+ if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
+ $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;
+ $false = false;
+ if (strpos($db,'://')) {
+ $origdsn = $db;
+ $dsna = @parse_url($db);
+
+ if (!$dsna) {
+ // special handling of oracle, which might not have host
+ $db = str_replace('@/','@adodb-fakehost/',$db);
+ $dsna = parse_url($db);
+ if (!$dsna) return $false;
+ $dsna['host'] = '';
+ }
+ $db = @$dsna['scheme'];
+ if (!$db) return $false;
+ $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
+ $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
+ $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
+ $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial /
+
+ if (isset($dsna['query'])) {
+ $opt1 = explode('&',$dsna['query']);
+ foreach($opt1 as $k => $v) {
+ $arr = explode('=',$v);
+ $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
+ }
+ } else $opt = array();
+ }
+
+ /*
+ * phptype: Database backend used in PHP (mysql, odbc etc.)
+ * dbsyntax: Database used with regards to SQL syntax etc.
+ * protocol: Communication protocol to use (tcp, unix etc.)
+ * hostspec: Host specification (hostname[:port])
+ * database: Database to use on the DBMS server
+ * username: User name for login
+ * password: Password for login
+ */
+ if (!empty($ADODB_NEWCONNECTION)) {
+ $obj = $ADODB_NEWCONNECTION($db);
+
+ } else {
+
+ if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
+ if (empty($db)) $db = $ADODB_LASTDB;
+
+ if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);
+
+ if (!$db) {
+ if (isset($origdsn)) $db = $origdsn;
+ if ($errorfn) {
+ // raise an error
+ $ignore = false;
+ $errorfn('ADONewConnection', 'ADONewConnection', -998,
+ "could not load the database driver for '$db'",
+ $db,false,$ignore);
+ } else
+ ADOConnection::outp( "<p>ADONewConnection: Unable to load database driver '$db'</p>",false);
+
+ return $false;
+ }
+
+ $cls = 'ADODB_'.$db;
+ if (!class_exists($cls)) {
+ adodb_backtrace();
+ return $false;
+ }
+
+ $obj = new $cls();
+ }
+
+ # constructor should not fail
+ if ($obj) {
+ if ($errorfn) $obj->raiseErrorFn = $errorfn;
+ if (isset($dsna)) {
+ if (isset($dsna['port'])) $obj->port = $dsna['port'];
+ foreach($opt as $k => $v) {
+ switch(strtolower($k)) {
+ case 'persist':
+ case 'persistent': $persist = $v; break;
+ case 'debug': $obj->debug = (integer) $v; break;
+ #ibase
+ case 'role': $obj->role = $v; break;
+ case 'dialect': $obj->dialect = (integer) $v; break;
+ case 'charset': $obj->charset = $v; $obj->charSet=$v; break;
+ case 'buffers': $obj->buffers = $v; break;
+ case 'fetchmode': $obj->SetFetchMode($v); break;
+ #ado
+ case 'charpage': $obj->charPage = $v; break;
+ #mysql, mysqli
+ case 'clientflags': $obj->clientFlags = $v; break;
+ #mysql, mysqli, postgres
+ case 'port': $obj->port = $v; break;
+ #mysqli
+ case 'socket': $obj->socket = $v; break;
+ #oci8
+ case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break;
+ }
+ }
+ if (empty($persist))
+ $ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
+ else
+ $ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
+
+ if (!$ok) return $false;
+ }
+ }
+ return $obj;
+ }
+
+
+
+ // $perf == true means called by NewPerfMonitor(), otherwise for data dictionary
+ function _adodb_getdriver($provider,$drivername,$perf=false)
+ {
+ switch ($provider) {
+ case 'odbtp': if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6);
+ case 'odbc' : if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5);
+ case 'ado' : if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4);
+ case 'native': break;
+ default:
+ return $provider;
+ }
+
+ switch($drivername) {
+ case 'firebird15': $drivername = 'firebird'; break;
+ case 'oracle': $drivername = 'oci8'; break;
+ case 'access': if ($perf) $drivername = ''; break;
+ case 'db2' : break;
+ case 'sapdb' : break;
+ default:
+ $drivername = 'generic';
+ break;
+ }
+ return $drivername;
+ }
+
+ function &NewPerfMonitor(&$conn)
+ {
+ $false = false;
+ $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
+ if (!$drivername || $drivername == 'generic') return $false;
+ include_once(ADODB_DIR.'/adodb-perf.inc.php');
+ @include_once(ADODB_DIR."/perf/perf-$drivername.inc.php");
+ $class = "Perf_$drivername";
+ if (!class_exists($class)) return $false;
+ $perf = new $class($conn);
+
+ return $perf;
+ }
+
+ function &NewDataDictionary(&$conn,$drivername=false)
+ {
+ $false = false;
+ if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);
+
+ include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ include_once(ADODB_DIR.'/adodb-datadict.inc.php');
+ $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php";
+
+ if (!file_exists($path)) {
+ ADOConnection::outp("Database driver '$path' not available");
+ return $false;
+ }
+ include_once($path);
+ $class = "ADODB2_$drivername";
+ $dict = new $class();
+ $dict->dataProvider = $conn->dataProvider;
+ $dict->connection = &$conn;
+ $dict->upperName = strtoupper($drivername);
+ $dict->quote = $conn->nameQuote;
+ if (!empty($conn->_connectionID))
+ $dict->serverInfo = $conn->ServerInfo();
+
+ return $dict;
+ }
+
+
+
+ /*
+ Perform a print_r, with pre tags for better formatting.
+ */
+ function adodb_pr($var,$as_string=false)
+ {
+ if ($as_string) ob_start();
+
+ if (isset($_SERVER['HTTP_USER_AGENT'])) {
+ echo " <pre>\n";print_r($var);echo "</pre>\n";
+ } else
+ print_r($var);
+
+ if ($as_string) {
+ $s = ob_get_contents();
+ ob_end_clean();
+ return $s;
+ }
+ }
+
+ /*
+ Perform a stack-crawl and pretty print it.
+
+ @param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then).
+ @param levels Number of levels to display
+ */
+ function adodb_backtrace($printOrArr=true,$levels=9999)
+ {
+ global $ADODB_INCLUDED_LIB;
+ if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
+ return _adodb_backtrace($printOrArr,$levels);
+ }
+
+} // defined
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/contrib/toxmlrpc.inc.php b/html/phpgacl/adodb/contrib/toxmlrpc.inc.php
new file mode 100644
index 0000000..575bd9b
--- /dev/null
+++ b/html/phpgacl/adodb/contrib/toxmlrpc.inc.php
@@ -0,0 +1,157 @@
+<?php
+ /**
+ * Helper functions to convert between ADODB recordset objects and XMLRPC values.
+ * Uses John Lim's AdoDB and Edd Dumbill's phpxmlrpc libs
+ *
+ * @author Daniele Baroncelli
+ * @author Gaetano Giunta
+ * @copyright (c) 2003 Giunta/Baroncelli. All rights reserved.
+ *
+ * @todo some more error checking here and there
+ * @todo document the xmlrpc-struct used to encode recordset info
+ */
+
+ /**
+ * Include the main libraries
+ */
+ require_once('xmlrpc.inc');
+ require_once('adodb.inc.php');
+
+ /**
+ * Builds an xmlrpc struct value out of an AdoDB recordset
+ */
+ function rs2xmlrpcval(&$adodbrs) {
+
+ $numfields = $adodbrs->FieldCount();
+ $numrecords = $adodbrs->RecordCount();
+
+ // build structure holding recordset information
+ $fieldstruct = array();
+ for ($i = 0; $i < $numfields; $i++) {
+ $fld = $adodbrs->FetchField($i);
+ $fieldarray = array();
+ if (isset($fld->name))
+ $fieldarray["name"] = new xmlrpcval ($fld->name);
+ if (isset($fld->type))
+ $fieldarray["type"] = new xmlrpcval ($fld->type);
+ if (isset($fld->max_length))
+ $fieldarray["max_length"] = new xmlrpcval ($fld->max_length, "int");
+ if (isset($fld->not_null))
+ $fieldarray["not_null"] = new xmlrpcval ($fld->not_null, "boolean");
+ if (isset($fld->has_default))
+ $fieldarray["has_default"] = new xmlrpcval ($fld->has_default, "boolean");
+ if (isset($fld->default_value))
+ $fieldarray["default_value"] = new xmlrpcval ($fld->default_value);
+ $fieldstruct[$i] = new xmlrpcval ($fieldarray, "struct");
+ }
+ $fieldcount = new xmlrpcval ($numfields, "int");
+ $recordcount = new xmlrpcval ($numrecords, "int");
+ $sql = new xmlrpcval ($adodbrs->sql);
+ $fieldinfo = new xmlrpcval ($fieldstruct, "array");
+
+ $header = new xmlrpcval ( array(
+ "fieldcount" => $fieldcount,
+ "recordcount" => $recordcount,
+ "sql" => $sql,
+ "fieldinfo" => $fieldinfo
+ ), "struct");
+
+ // build structure containing recordset data
+ $rows = array();
+ while (!$adodbrs->EOF) {
+ $columns = array();
+ // This should work on all cases of fetch mode: assoc, num, both or default
+ if ($adodbrs->fetchMode == 'ADODB_FETCH_BOTH' || count($adodbrs->fields) == 2 * $adodbrs->FieldCount())
+ for ($i = 0; $i < $numfields; $i++)
+ if ($columns[$i] === null)
+ $columns[$i] = new xmlrpcval ('');
+ else
+ $columns[$i] = xmlrpc_encode ($adodbrs->fields[$i]);
+ else
+ foreach ($adodbrs->fields as $val)
+ if ($val === null)
+ $columns[$i] = new xmlrpcval ('');
+ else
+ $columns[] = xmlrpc_encode ($val);
+
+ $rows[] = new xmlrpcval ($columns, "array");
+
+ $adodbrs->MoveNext();
+ }
+ $body = new xmlrpcval ($rows, "array");
+
+ // put it all together and build final xmlrpc struct
+ $xmlrpcrs = new xmlrpcval ( array(
+ "header" => $header,
+ "body" => $body,
+ ), "struct");
+
+ return $xmlrpcrs;
+
+ }
+
+ /**
+ * Returns an xmlrpc struct value as string out of an AdoDB recordset
+ */
+ function rs2xmlrpcstring (&$adodbrs) {
+ $xmlrpc = rs2xmlrpcval ($adodbrs);
+ if ($xmlrpc)
+ return $xmlrpc->serialize();
+ else
+ return null;
+ }
+
+ /**
+ * Given a well-formed xmlrpc struct object returns an AdoDB object
+ *
+ * @todo add some error checking on the input value
+ */
+ function xmlrpcval2rs (&$xmlrpcval) {
+
+ $fields_array = array();
+ $data_array = array();
+
+ // rebuild column information
+ $header =& $xmlrpcval->structmem('header');
+
+ $numfields = $header->structmem('fieldcount');
+ $numfields = $numfields->scalarval();
+ $numrecords = $header->structmem('recordcount');
+ $numrecords = $numrecords->scalarval();
+ $sqlstring = $header->structmem('sql');
+ $sqlstring = $sqlstring->scalarval();
+
+ $fieldinfo =& $header->structmem('fieldinfo');
+ for ($i = 0; $i < $numfields; $i++) {
+ $temp =& $fieldinfo->arraymem($i);
+ $fld = new ADOFieldObject();
+ while (list($key,$value) = $temp->structeach()) {
+ if ($key == "name") $fld->name = $value->scalarval();
+ if ($key == "type") $fld->type = $value->scalarval();
+ if ($key == "max_length") $fld->max_length = $value->scalarval();
+ if ($key == "not_null") $fld->not_null = $value->scalarval();
+ if ($key == "has_default") $fld->has_default = $value->scalarval();
+ if ($key == "default_value") $fld->default_value = $value->scalarval();
+ } // while
+ $fields_array[] = $fld;
+ } // for
+
+ // fetch recordset information into php array
+ $body =& $xmlrpcval->structmem('body');
+ for ($i = 0; $i < $numrecords; $i++) {
+ $data_array[$i]= array();
+ $xmlrpcrs_row =& $body->arraymem($i);
+ for ($j = 0; $j < $numfields; $j++) {
+ $temp =& $xmlrpcrs_row->arraymem($j);
+ $data_array[$i][$j] = $temp->scalarval();
+ } // for j
+ } // for i
+
+ // finally build in-memory recordset object and return it
+ $rs = new ADORecordSet_array();
+ $rs->InitArrayFields($data_array,$fields_array);
+ return $rs;
+
+ }
+
+?>
diff --git a/html/phpgacl/adodb/cute_icons_for_site/adodb.gif b/html/phpgacl/adodb/cute_icons_for_site/adodb.gif
new file mode 100644
index 0000000..c5e8dfc
--- /dev/null
+++ b/html/phpgacl/adodb/cute_icons_for_site/adodb.gif
Binary files differ
diff --git a/html/phpgacl/adodb/cute_icons_for_site/adodb.png b/html/phpgacl/adodb/cute_icons_for_site/adodb.png
new file mode 100644
index 0000000..339dd76
--- /dev/null
+++ b/html/phpgacl/adodb/cute_icons_for_site/adodb.png
Binary files differ
diff --git a/html/phpgacl/adodb/cute_icons_for_site/adodb2.gif b/html/phpgacl/adodb/cute_icons_for_site/adodb2.gif
new file mode 100644
index 0000000..f12ae20
--- /dev/null
+++ b/html/phpgacl/adodb/cute_icons_for_site/adodb2.gif
Binary files differ
diff --git a/html/phpgacl/adodb/cute_icons_for_site/adodb2.png b/html/phpgacl/adodb/cute_icons_for_site/adodb2.png
new file mode 100644
index 0000000..ab18515
--- /dev/null
+++ b/html/phpgacl/adodb/cute_icons_for_site/adodb2.png
Binary files differ
diff --git a/html/phpgacl/adodb/datadict/datadict-access.inc.php b/html/phpgacl/adodb/datadict/datadict-access.inc.php
new file mode 100644
index 0000000..fdd2f14
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-access.inc.php
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_access extends ADODB_DataDict {
+
+ var $databaseType = 'access';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'TEXT';
+ case 'XL':
+ case 'X': return 'MEMO';
+
+ case 'C2': return 'TEXT'; // up to 32K
+ case 'X2': return 'MEMO';
+
+ case 'B': return 'BINARY';
+
+ case 'D': return 'DATETIME';
+ case 'T': return 'DATETIME';
+
+ case 'L': return 'BYTE';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'BYTE';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ if ($fautoinc) {
+ $ftype = 'COUNTER';
+ return '';
+ }
+ if (substr($ftype,0,7) == 'DECIMAL') $ftype = 'DECIMAL';
+ $suffix = '';
+ if (strlen($fdefault)) {
+ //$suffix .= " DEFAULT $fdefault";
+ if ($this->debug) ADOConnection::outp("Warning: Access does not supported DEFAULT values (field $fname)");
+ }
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function CreateDatabase($dbname,$options=false)
+ {
+ return array();
+ }
+
+
+ function SetSchema($schema)
+ {
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-db2.inc.php b/html/phpgacl/adodb/datadict/datadict-db2.inc.php
new file mode 100644
index 0000000..d8ef6ac
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-db2.inc.php
@@ -0,0 +1,143 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_db2 extends ADODB_DataDict {
+
+ var $databaseType = 'db2';
+ var $seqField = false;
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL': return 'CLOB';
+ case 'X': return 'VARCHAR(3600)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(3600)'; // up to 32000, but default page size too small
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ $suffix = '';
+ if ($fautoinc) return ' GENERATED ALWAYS AS IDENTITY'; # as identity start with
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+
+ function xChangeTableSQL($tablename, $flds, $tableoptions = false)
+ {
+
+ /**
+ Allow basic table changes to DB2 databases
+ DB2 will fatally reject changes to non character columns
+
+ */
+
+ $validTypes = array("CHAR","VARC");
+ $invalidTypes = array("BIGI","BLOB","CLOB","DATE", "DECI","DOUB", "INTE", "REAL","SMAL", "TIME");
+ // check table exists
+ $cols = &$this->MetaColumns($tablename);
+ if ( empty($cols)) {
+ return $this->CreateTableSQL($tablename, $flds, $tableoptions);
+ }
+
+ // already exists, alter table instead
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $this->TableName($tablename);
+ $sql = array();
+
+ foreach ( $lines as $id => $v ) {
+ if ( isset($cols[$id]) && is_object($cols[$id]) ) {
+ /**
+ If the first field of $v is the fieldname, and
+ the second is the field type/size, we assume its an
+ attempt to modify the column size, so check that it is allowed
+ $v can have an indeterminate number of blanks between the
+ fields, so account for that too
+ */
+ $vargs = explode(' ' , $v);
+ // assume that $vargs[0] is the field name.
+ $i=0;
+ // Find the next non-blank value;
+ for ($i=1;$i<sizeof($vargs);$i++)
+ if ($vargs[$i] != '')
+ break;
+
+ // if $vargs[$i] is one of the following, we are trying to change the
+ // size of the field, if not allowed, simply ignore the request.
+ if (in_array(substr($vargs[$i],0,4),$invalidTypes))
+ continue;
+ // insert the appropriate DB2 syntax
+ if (in_array(substr($vargs[$i],0,4),$validTypes)) {
+ array_splice($vargs,$i,0,array('SET','DATA','TYPE'));
+ }
+
+ // Now Look for the NOT NULL statement as this is not allowed in
+ // the ALTER table statement. If it is in there, remove it
+ if (in_array('NOT',$vargs) && in_array('NULL',$vargs)) {
+ for ($i=1;$i<sizeof($vargs);$i++)
+ if ($vargs[$i] == 'NOT')
+ break;
+ array_splice($vargs,$i,2,'');
+ }
+ $v = implode(' ',$vargs);
+ $sql[] = $alter . $this->alterCol . ' ' . $v;
+ } else {
+ $sql[] = $alter . $this->addCol . ' ' . $v;
+ }
+ }
+
+ return $sql;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-firebird.inc.php b/html/phpgacl/adodb/datadict/datadict-firebird.inc.php
new file mode 100644
index 0000000..cc20829
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-firebird.inc.php
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+class ADODB2_firebird extends ADODB_DataDict {
+
+ var $databaseType = 'firebird';
+ var $seqField = false;
+ var $seqPrefix = 'gen_';
+ var $blobSize = 40000;
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL': return 'VARCHAR(32000)';
+ case 'X': return 'VARCHAR(4000)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(4000)';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE PRECISION';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function NameQuote($name = NULL)
+ {
+ if (!is_string($name)) {
+ return FALSE;
+ }
+
+ $name = trim($name);
+
+ if ( !is_object($this->connection) ) {
+ return $name;
+ }
+
+ $quote = $this->connection->nameQuote;
+
+ // if name is of the form `name`, quote it
+ if ( preg_match('/^`(.+)`$/', $name, $matches) ) {
+ return $quote . $matches[1] . $quote;
+ }
+
+ // if name contains special characters, quote it
+ if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) {
+ return $quote . $name . $quote;
+ }
+
+ return $quote . $name . $quote;
+ }
+
+ function CreateDatabase($dbname, $options=false)
+ {
+ $options = $this->_Options($options);
+ $sql = array();
+
+ $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'";
+
+ return $sql;
+ }
+
+ function _DropAutoIncrement($t)
+ {
+ if (strpos($t,'.') !== false) {
+ $tarr = explode('.',$t);
+ return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"';
+ }
+ return 'DROP GENERATOR "GEN_'.$t;
+ }
+
+
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fautoinc) $this->seqField = $fname;
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+
+ return $suffix;
+ }
+
+/*
+CREATE or replace TRIGGER jaddress_insert
+before insert on jaddress
+for each row
+begin
+IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN
+ NEW."seqField" = GEN_ID("GEN_tabname", 1);
+end;
+*/
+ function _Triggers($tabname,$tableoptions)
+ {
+ if (!$this->seqField) return array();
+
+ $tab1 = preg_replace( '/"/', '', $tabname );
+ if ($this->schema) {
+ $t = strpos($tab1,'.');
+ if ($t !== false) $tab = substr($tab1,$t+1);
+ else $tab = $tab1;
+ $seqField = $this->seqField;
+ $seqname = $this->schema.'.'.$this->seqPrefix.$tab;
+ $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab;
+ } else {
+ $seqField = $this->seqField;
+ $seqname = $this->seqPrefix.$tab1;
+ $trigname = 'trig_'.$seqname;
+ }
+ if (isset($tableoptions['REPLACE']))
+ { $sql[] = "DROP GENERATOR \"$seqname\"";
+ $sql[] = "CREATE GENERATOR \"$seqname\"";
+ $sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
+ }
+ else
+ { $sql[] = "CREATE GENERATOR \"$seqname\"";
+ $sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END";
+ }
+
+ $this->seqField = false;
+ return $sql;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-generic.inc.php b/html/phpgacl/adodb/datadict/datadict-generic.inc.php
new file mode 100644
index 0000000..a8d9eb9
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-generic.inc.php
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_generic extends ADODB_DataDict {
+
+ var $databaseType = 'generic';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'VARCHAR(250)';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'VARCHAR(250)';
+
+ case 'B': return 'VARCHAR';
+
+ case 'D': return 'DATE';
+ case 'T': return 'DATE';
+
+ case 'L': return 'DECIMAL(1)';
+ case 'I': return 'DECIMAL(10)';
+ case 'I1': return 'DECIMAL(3)';
+ case 'I2': return 'DECIMAL(5)';
+ case 'I4': return 'DECIMAL(10)';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'DECIMAL(32,8)';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
+
+/*
+//db2
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'X': return 'VARCHAR';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+// ifx
+function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';// 255
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'DATETIME';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'FLOAT';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+*/
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-ibase.inc.php b/html/phpgacl/adodb/datadict/datadict-ibase.inc.php
new file mode 100644
index 0000000..92dc8f2
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-ibase.inc.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_ibase extends ADODB_DataDict {
+
+ var $databaseType = 'ibase';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'VARCHAR(4000)';
+
+ case 'C2': return 'VARCHAR'; // up to 32K
+ case 'X2': return 'VARCHAR(4000)';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'INTEGER';
+
+ case 'F': return 'DOUBLE PRECISION';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-informix.inc.php b/html/phpgacl/adodb/datadict/datadict-informix.inc.php
new file mode 100644
index 0000000..997e5bf
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-informix.inc.php
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_informix extends ADODB_DataDict {
+
+ var $databaseType = 'informix';
+ var $seqField = false;
+
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';// 255
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'DATETIME';
+
+ case 'L': return 'SMALLINT';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'DECIMAL(20)';
+
+ case 'F': return 'FLOAT';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported");
+ return array();
+ }
+
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL not supported");
+ return array();
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ if ($fautoinc) {
+ $ftype = 'SERIAL';
+ return '';
+ }
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-mssql.inc.php b/html/phpgacl/adodb/datadict/datadict-mssql.inc.php
new file mode 100644
index 0000000..eed6752
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-mssql.inc.php
@@ -0,0 +1,254 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_mssql extends ADODB_DataDict {
+ var $databaseType = 'mssql';
+ var $dropIndex = 'DROP INDEX %2$s.%1$s';
+ var $renameTable = "EXEC sp_rename '%s','%s'";
+ var $renameColumn = "EXEC sp_rename '%s.%s','%s'";
+
+ var $typeX = 'TEXT'; ## Alternatively, set it to VARCHAR(4000)
+ var $typeXL = 'TEXT';
+
+ //var $alterCol = ' ALTER COLUMN ';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'R':
+ case 'INT':
+ case 'INTEGER': return 'I';
+ case 'BIT':
+ case 'TINYINT': return 'I1';
+ case 'SMALLINT': return 'I2';
+ case 'BIGINT': return 'I8';
+
+ case 'REAL':
+ case 'FLOAT': return 'F';
+ default: return parent::MetaType($t,$len,$fieldobj);
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+
+ case 'C': return 'VARCHAR';
+ case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT';
+ case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NTEXT';
+
+ case 'B': return 'IMAGE';
+
+ case 'D': return 'DATETIME';
+ case 'T': return 'DATETIME';
+ case 'L': return 'BIT';
+
+ case 'R':
+ case 'I': return 'INT';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'REAL';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname $this->addCol";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ /*
+ function AlterColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ foreach($lines as $v) {
+ $sql[] = "ALTER TABLE $tabname $this->alterCol $v";
+ }
+
+ return $sql;
+ }
+ */
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds))
+ $flds = explode(',',$flds);
+ $f = array();
+ $s = 'ALTER TABLE ' . $tabname;
+ foreach($flds as $v) {
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' IDENTITY(1,1)';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ else if ($suffix == '') $suffix .= ' NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+CREATE TABLE
+ [ database_name.[ owner ] . | owner. ] table_name
+ ( { < column_definition >
+ | column_name AS computed_column_expression
+ | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
+
+ | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
+ )
+
+[ ON { filegroup | DEFAULT } ]
+[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
+
+< column_definition > ::= { column_name data_type }
+ [ COLLATE < collation_name > ]
+ [ [ DEFAULT constant_expression ]
+ | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
+ ]
+ [ ROWGUIDCOL]
+ [ < column_constraint > ] [ ...n ]
+
+< column_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ NULL | NOT NULL ]
+ | [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ [ WITH FILLFACTOR = fillfactor ]
+ [ON {filegroup | DEFAULT} ] ]
+ ]
+ | [ [ FOREIGN KEY ]
+ REFERENCES ref_table [ ( ref_column ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( logical_expression )
+ }
+
+< table_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ { ( column [ ASC | DESC ] [ ,...n ] ) }
+ [ WITH FILLFACTOR = fillfactor ]
+ [ ON { filegroup | DEFAULT } ]
+ ]
+ | FOREIGN KEY
+ [ ( column [ ,...n ] ) ]
+ REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( search_conditions )
+ }
+
+
+ */
+
+ /*
+ CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
+ ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
+ [ WITH < index_option > [ ,...n] ]
+ [ ON filegroup ]
+ < index_option > :: =
+ { PAD_INDEX |
+ FILLFACTOR = fillfactor |
+ IGNORE_DUP_KEY |
+ DROP_EXISTING |
+ STATISTICS_NORECOMPUTE |
+ SORT_IN_TEMPDB
+ }
+*/
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+ $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+
+ function _GetSize($ftype, $ty, $fsize, $fprec)
+ {
+ switch ($ftype) {
+ case 'INT':
+ case 'SMALLINT':
+ case 'TINYINT':
+ case 'BIGINT':
+ return $ftype;
+ }
+ if ($ty == 'T') return $ftype;
+ return parent::_GetSize($ftype, $ty, $fsize, $fprec);
+
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-mysql.inc.php b/html/phpgacl/adodb/datadict/datadict-mysql.inc.php
new file mode 100644
index 0000000..cdb83ef
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-mysql.inc.php
@@ -0,0 +1,181 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_mysql extends ADODB_DataDict {
+ var $databaseType = 'mysql';
+ var $alterCol = ' MODIFY COLUMN';
+ var $alterTableAddIndex = true;
+ var $dropTable = 'DROP TABLE IF EXISTS %s'; // requires mysql 3.22 or later
+
+ var $dropIndex = 'DROP INDEX %s ON %s';
+ var $renameColumn = 'ALTER TABLE %s CHANGE COLUMN %s %s %s'; // needs column-definition!
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment;
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'STRING':
+ case 'CHAR':
+ case 'VARCHAR':
+ case 'TINYBLOB':
+ case 'TINYTEXT':
+ case 'ENUM':
+ case 'SET':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ case 'LONGTEXT':
+ case 'MEDIUMTEXT':
+ return 'X';
+
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
+ case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+
+ case 'YEAR':
+ case 'DATE': return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP': return 'T';
+
+ case 'FLOAT':
+ case 'DOUBLE':
+ return 'F';
+
+ case 'INT':
+ case 'INTEGER': return $is_serial ? 'R' : 'I';
+ case 'TINYINT': return $is_serial ? 'R' : 'I1';
+ case 'SMALLINT': return $is_serial ? 'R' : 'I2';
+ case 'MEDIUMINT': return $is_serial ? 'R' : 'I4';
+ case 'BIGINT': return $is_serial ? 'R' : 'I8';
+ default: return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+ case 'C': return 'VARCHAR';
+ case 'XL':return 'LONGTEXT';
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'LONGTEXT';
+
+ case 'B': return 'LONGBLOB';
+
+ case 'D': return 'DATE';
+ case 'T': return 'DATETIME';
+ case 'L': return 'TINYINT';
+
+ case 'R':
+ case 'I4':
+ case 'I': return 'INTEGER';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'DOUBLE';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' AUTO_INCREMENT';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+ CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
+ [table_options] [select_statement]
+ create_definition:
+ col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
+ [PRIMARY KEY] [reference_definition]
+ or PRIMARY KEY (index_col_name,...)
+ or KEY [index_name] (index_col_name,...)
+ or INDEX [index_name] (index_col_name,...)
+ or UNIQUE [INDEX] [index_name] (index_col_name,...)
+ or FULLTEXT [INDEX] [index_name] (index_col_name,...)
+ or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
+ [reference_definition]
+ or CHECK (expr)
+ */
+
+ /*
+ CREATE [UNIQUE|FULLTEXT] INDEX index_name
+ ON tbl_name (col_name[(length)],... )
+ */
+
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ if ($this->alterTableAddIndex) $sql[] = "ALTER TABLE $tabname DROP INDEX $idxname";
+ else $sql[] = sprintf($this->dropIndex, $idxname, $tabname);
+
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ if (isset($idxoptions['FULLTEXT'])) {
+ $unique = ' FULLTEXT';
+ } elseif (isset($idxoptions['UNIQUE'])) {
+ $unique = ' UNIQUE';
+ } else {
+ $unique = '';
+ }
+
+ if ( is_array($flds) ) $flds = implode(', ',$flds);
+
+ if ($this->alterTableAddIndex) $s = "ALTER TABLE $tabname ADD $unique INDEX $idxname ";
+ else $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname;
+
+ $s .= ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-oci8.inc.php b/html/phpgacl/adodb/datadict/datadict-oci8.inc.php
new file mode 100644
index 0000000..391e532
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-oci8.inc.php
@@ -0,0 +1,282 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_oci8 extends ADODB_DataDict {
+
+ var $databaseType = 'oci8';
+ var $seqField = false;
+ var $seqPrefix = 'SEQ_';
+ var $dropTable = "DROP TABLE %s CASCADE CONSTRAINTS";
+ var $trigPrefix = 'TRIG_';
+ var $alterCol = ' MODIFY ';
+ var $typeX = 'VARCHAR(4000)';
+ var $typeXL = 'CLOB';
+
+ function MetaType($t,$len=-1)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'VARCHAR2':
+ case 'CHAR':
+ case 'VARBINARY':
+ case 'BINARY':
+ if (isset($this) && $len <= $this->blobSize) return 'C';
+ return 'X';
+
+ case 'NCHAR':
+ case 'NVARCHAR2':
+ case 'NVARCHAR':
+ if (isset($this) && $len <= $this->blobSize) return 'C2';
+ return 'X2';
+
+ case 'NCLOB':
+ case 'CLOB':
+ return 'XL';
+
+ case 'LONG RAW':
+ case 'LONG VARBINARY':
+ case 'BLOB':
+ return 'B';
+
+ case 'DATE':
+ return 'T';
+
+ case 'INT':
+ case 'SMALLINT':
+ case 'INTEGER':
+ return 'I';
+
+ default:
+ return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'X': return $this->typeX;
+ case 'XL': return $this->typeXL;
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NVARCHAR(2000)';
+
+ case 'B': return 'BLOB';
+
+ case 'D':
+ case 'T': return 'DATE';
+ case 'L': return 'DECIMAL(1)';
+ case 'I1': return 'DECIMAL(3)';
+ case 'I2': return 'DECIMAL(5)';
+ case 'I':
+ case 'I4': return 'DECIMAL(10)';
+
+ case 'I8': return 'DECIMAL(20)';
+ case 'F': return 'DECIMAL';
+ case 'N': return 'DECIMAL';
+ default:
+ return $meta;
+ }
+ }
+
+ function CreateDatabase($dbname, $options=false)
+ {
+ $options = $this->_Options($options);
+ $password = isset($options['PASSWORD']) ? $options['PASSWORD'] : 'tiger';
+ $tablespace = isset($options["TABLESPACE"]) ? " DEFAULT TABLESPACE ".$options["TABLESPACE"] : '';
+ $sql[] = "CREATE USER ".$dbname." IDENTIFIED BY ".$password.$tablespace;
+ $sql[] = "GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO $dbname";
+
+ return $sql;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname ADD (";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+
+ $s .= implode(', ',$f).')';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname MODIFY(";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f).')';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v);
+
+ $sql = array();
+ $s = "ALTER TABLE $tabname DROP(";
+ $s .= implode(', ',$flds).') CASCADE CONSTRAINTS';
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function _DropAutoIncrement($t)
+ {
+ if (strpos($t,'.') !== false) {
+ $tarr = explode('.',$t);
+ return "drop sequence ".$tarr[0].".seq_".$tarr[1];
+ }
+ return "drop sequence seq_".$t;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+
+ if ($fdefault == "''" && $fnotnull) {// this is null in oracle
+ $fnotnull = false;
+ if ($this->debug) ADOConnection::outp("NOT NULL and DEFAULT='' illegal in Oracle");
+ }
+
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+
+ if ($fautoinc) $this->seqField = $fname;
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+
+ return $suffix;
+ }
+
+/*
+CREATE or replace TRIGGER jaddress_insert
+before insert on jaddress
+for each row
+begin
+select seqaddress.nextval into :new.A_ID from dual;
+end;
+*/
+ function _Triggers($tabname,$tableoptions)
+ {
+ if (!$this->seqField) return array();
+
+ if ($this->schema) {
+ $t = strpos($tabname,'.');
+ if ($t !== false) $tab = substr($tabname,$t+1);
+ else $tab = $tabname;
+ $seqname = $this->schema.'.'.$this->seqPrefix.$tab;
+ $trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab;
+ } else {
+ $seqname = $this->seqPrefix.$tabname;
+ $trigname = $this->trigPrefix.$seqname;
+ }
+ if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname";
+ $seqCache = '';
+ if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];}
+ $seqIncr = '';
+ if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];}
+ $seqStart = '';
+ if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];}
+ $sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache";
+ $sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;";
+
+ $this->seqField = false;
+ return $sql;
+ }
+
+ /*
+ CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
+ [table_options] [select_statement]
+ create_definition:
+ col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
+ [PRIMARY KEY] [reference_definition]
+ or PRIMARY KEY (index_col_name,...)
+ or KEY [index_name] (index_col_name,...)
+ or INDEX [index_name] (index_col_name,...)
+ or UNIQUE [INDEX] [index_name] (index_col_name,...)
+ or FULLTEXT [INDEX] [index_name] (index_col_name,...)
+ or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
+ [reference_definition]
+ or CHECK (expr)
+ */
+
+
+
+ function _IndexSQL($idxname, $tabname, $flds,$idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ if (isset($idxoptions['BITMAP'])) {
+ $unique = ' BITMAP';
+ } elseif (isset($idxoptions['UNIQUE'])) {
+ $unique = ' UNIQUE';
+ } else {
+ $unique = '';
+ }
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if (isset($idxoptions['oci8']))
+ $s .= $idxoptions['oci8'];
+
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+
+ function GetCommentSQL($table,$col)
+ {
+ $table = $this->connection->qstr($table);
+ $col = $this->connection->qstr($col);
+ return "select comments from USER_COL_COMMENTS where TABLE_NAME=$table and COLUMN_NAME=$col";
+ }
+
+ function SetCommentSQL($table,$col,$cmt)
+ {
+ $cmt = $this->connection->qstr($cmt);
+ return "COMMENT ON COLUMN $table.$col IS $cmt";
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-postgres.inc.php b/html/phpgacl/adodb/datadict/datadict-postgres.inc.php
new file mode 100644
index 0000000..50a6e72
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-postgres.inc.php
@@ -0,0 +1,359 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_postgres extends ADODB_DataDict {
+
+ var $databaseType = 'postgres';
+ var $seqField = false;
+ var $seqPrefix = 'SEQ_';
+ var $addCol = ' ADD COLUMN';
+ var $quote = '"';
+ var $renameTable = 'ALTER TABLE %s RENAME TO %s'; // at least since 7.1
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique &&
+ $fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval(';
+
+ switch (strtoupper($t)) {
+ case 'INTERVAL':
+ case 'CHAR':
+ case 'CHARACTER':
+ case 'VARCHAR':
+ case 'NAME':
+ case 'BPCHAR':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ return 'X';
+
+ case 'IMAGE': // user defined type
+ case 'BLOB': // user defined type
+ case 'BIT': // This is a bit string, not a single bit, so don't return 'L'
+ case 'VARBIT':
+ case 'BYTEA':
+ return 'B';
+
+ case 'BOOL':
+ case 'BOOLEAN':
+ return 'L';
+
+ case 'DATE':
+ return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP':
+ case 'TIMESTAMPTZ':
+ return 'T';
+
+ case 'INTEGER': return !$is_serial ? 'I' : 'R';
+ case 'SMALLINT':
+ case 'INT2': return !$is_serial ? 'I2' : 'R';
+ case 'INT4': return !$is_serial ? 'I4' : 'R';
+ case 'BIGINT':
+ case 'INT8': return !$is_serial ? 'I8' : 'R';
+
+ case 'OID':
+ case 'SERIAL':
+ return 'R';
+
+ case 'FLOAT4':
+ case 'FLOAT8':
+ case 'DOUBLE PRECISION':
+ case 'REAL':
+ return 'F';
+
+ default:
+ return 'N';
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'VARCHAR';
+ case 'X2': return 'TEXT';
+
+ case 'B': return 'BYTEA';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'BOOLEAN';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'SMALLINT';
+ case 'I2': return 'INT2';
+ case 'I4': return 'INT4';
+ case 'I8': return 'INT8';
+
+ case 'F': return 'FLOAT8';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+ /**
+ * Adding a new Column
+ *
+ * reimplementation of the default function as postgres does NOT allow to set the default in the same statement
+ *
+ * @param string $tabname table-name
+ * @param string $flds column-names and types for the changed columns
+ * @return array with SQL strings
+ */
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' ';
+ foreach($lines as $v) {
+ if (($not_null = preg_match('/NOT NULL/i',$v))) {
+ $v = preg_replace('/NOT NULL/i','',$v);
+ }
+ if (preg_match('/^([^ ]+) .*(DEFAULT [^ ]+)/',$v,$matches)) {
+ list(,$colname,$default) = $matches;
+ $sql[] = $alter . str_replace($default,'',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET ' . $default;
+ } else {
+ $sql[] = $alter . $v;
+ }
+ if ($not_null) {
+ list($colname) = explode(' ',$v);
+ $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL';
+ }
+ }
+ return $sql;
+ }
+
+ /**
+ * Change the definition of one column
+ *
+ * Postgres can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ if (!$tableflds) {
+ if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL");
+ return array();
+ }
+ return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Drop one column
+ *
+ * Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table,
+ * to allow, recreating the table and copying the content over to the new table
+ * @param string $tabname table-name
+ * @param string $flds column-name and type for the changed column
+ * @param string $tableflds complete defintion of the new table, eg. for postgres, default ''
+ * @param array/ $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='')
+ {
+ $has_drop_column = 7.3 <= (float) @$this->serverInfo['version'];
+ if (!$has_drop_column && !$tableflds) {
+ if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3");
+ return array();
+ }
+ if ($has_drop_column) {
+ return ADODB_DataDict::DropColumnSQL($tabname, $flds);
+ }
+ return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions);
+ }
+
+ /**
+ * Save the content into a temp. table, drop and recreate the original table and copy the content back in
+ *
+ * We also take care to set the values of the sequenz and recreate the indexes.
+ * All this is done in a transaction, to not loose the content of the table, if something went wrong!
+ * @internal
+ * @param string $tabname table-name
+ * @param string $dropflds column-names to drop
+ * @param string $tableflds complete defintion of the new table, eg. for postgres
+ * @param array/string $tableoptions options for the new table see CreateTableSQL, default ''
+ * @return array with SQL strings
+ */
+ function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='')
+ {
+ if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
+ $copyflds = array();
+ foreach($this->MetaColumns($tabname) as $fld) {
+ if (!$dropflds || !in_array($fld->name,$dropflds)) {
+ // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
+ if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
+ in_array($fld->type,array('varchar','char','text','bytea'))) {
+ $copyflds[] = "to_number($fld->name,'S99D99')";
+ } else {
+ $copyflds[] = $fld->name;
+ }
+ // identify the sequence name and the fld its on
+ if ($fld->primary_key && $fld->has_default &&
+ preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) {
+ $seq_name = $matches[1];
+ $seq_fld = $fld->name;
+ }
+ }
+ }
+ $copyflds = implode(', ',$copyflds);
+
+ $tempname = $tabname.'_tmp';
+ $aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table
+ $aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname";
+ $aSql = array_merge($aSql,$this->DropTableSQL($tabname));
+ $aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions));
+ $aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname";
+ if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again
+ $seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence
+ $aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname";
+ }
+ $aSql[] = "DROP TABLE $tempname";
+ // recreate the indexes, if they not contain one of the droped columns
+ foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data)
+ {
+ if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) {
+ $aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'],
+ $idx_data['unique'] ? array('UNIQUE') : False));
+ }
+ }
+ $aSql[] = 'COMMIT';
+ return $aSql;
+ }
+
+ function DropTableSQL($tabname)
+ {
+ $sql = ADODB_DataDict::DropTableSQL($tabname);
+
+ $drop_seq = $this->_DropAutoIncrement($tabname);
+ if ($drop_seq) $sql[] = $drop_seq;
+
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ if ($fautoinc) {
+ $ftype = 'SERIAL';
+ return '';
+ }
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ // search for a sequece for the given table (asumes the seqence-name contains the table-name!)
+ // if yes return sql to drop it
+ // this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!!
+ function _DropAutoIncrement($tabname)
+ {
+ $tabname = $this->connection->quote('%'.$tabname.'%');
+
+ $seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'");
+
+ // check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly
+ if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) {
+ return False;
+ }
+ return "DROP SEQUENCE ".$seq;
+ }
+
+ /*
+ CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
+ { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ]
+ | table_constraint } [, ... ]
+ )
+ [ INHERITS ( parent_table [, ... ] ) ]
+ [ WITH OIDS | WITHOUT OIDS ]
+ where column_constraint is:
+ [ CONSTRAINT constraint_name ]
+ { NOT NULL | NULL | UNIQUE | PRIMARY KEY |
+ CHECK (expression) |
+ REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ]
+ [ ON DELETE action ] [ ON UPDATE action ] }
+ [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
+ and table_constraint is:
+ [ CONSTRAINT constraint_name ]
+ { UNIQUE ( column_name [, ... ] ) |
+ PRIMARY KEY ( column_name [, ... ] ) |
+ CHECK ( expression ) |
+ FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
+ [ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] }
+ [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
+ */
+
+
+ /*
+ CREATE [ UNIQUE ] INDEX index_name ON table
+[ USING acc_method ] ( column [ ops_name ] [, ...] )
+[ WHERE predicate ]
+CREATE [ UNIQUE ] INDEX index_name ON table
+[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] )
+[ WHERE predicate ]
+ */
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+
+ $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' ';
+
+ if (isset($idxoptions['HASH']))
+ $s .= 'USING HASH ';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s .= '(' . $flds . ')';
+ $sql[] = $s;
+
+ return $sql;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-sapdb.inc.php b/html/phpgacl/adodb/datadict/datadict-sapdb.inc.php
new file mode 100644
index 0000000..7f6b5ee
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-sapdb.inc.php
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ V4.50 6 July 2004 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+ Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_sapdb extends ADODB_DataDict {
+
+ var $databaseType = 'sapdb';
+ var $seqField = false;
+ var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
+
+ function ActualType($meta)
+ {
+ switch($meta) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'LONG';
+
+ case 'C2': return 'VARCHAR UNICODE';
+ case 'X2': return 'LONG UNICODE';
+
+ case 'B': return 'LONG';
+
+ case 'D': return 'DATE';
+ case 'T': return 'TIMESTAMP';
+
+ case 'L': return 'BOOLEAN';
+ case 'I': return 'INTEGER';
+ case 'I1': return 'FIXED(3)';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INTEGER';
+ case 'I8': return 'FIXED(20)';
+
+ case 'F': return 'FLOAT(38)';
+ case 'N': return 'FIXED';
+ default:
+ return $meta;
+ }
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ static $maxdb_type2adodb = array(
+ 'VARCHAR' => 'C',
+ 'CHARACTER' => 'C',
+ 'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
+ 'DATE' => 'D',
+ 'TIMESTAMP' => 'T',
+ 'BOOLEAN' => 'L',
+ 'INTEGER' => 'I4',
+ 'SMALLINT' => 'I2',
+ 'FLOAT' => 'F',
+ 'FIXED' => 'N',
+ );
+ $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
+
+ // convert integer-types simulated with fixed back to integer
+ if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
+ $type = $len == 20 ? 'I8' : 'I1';
+ }
+ if ($fieldobj->auto_increment) $type = 'R';
+
+ return $type;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
+ {
+ $suffix = '';
+ if ($funsigned) $suffix .= ' UNSIGNED';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
+ elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
+ }
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ foreach($flds as $k => $v) {
+ $flds[$k] = $this->NameQuote($v);
+ }
+ return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/datadict/datadict-sybase.inc.php b/html/phpgacl/adodb/datadict/datadict-sybase.inc.php
new file mode 100644
index 0000000..effb6e1
--- /dev/null
+++ b/html/phpgacl/adodb/datadict/datadict-sybase.inc.php
@@ -0,0 +1,228 @@
+<?php
+
+/**
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB2_sybase extends ADODB_DataDict {
+ var $databaseType = 'sybase';
+
+ var $dropIndex = 'DROP INDEX %2$s.%1$s';
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+
+ case 'INT':
+ case 'INTEGER': return 'I';
+ case 'BIT':
+ case 'TINYINT': return 'I1';
+ case 'SMALLINT': return 'I2';
+ case 'BIGINT': return 'I8';
+
+ case 'REAL':
+ case 'FLOAT': return 'F';
+ default: return parent::MetaType($t,$len,$fieldobj);
+ }
+ }
+
+ function ActualType($meta)
+ {
+ switch(strtoupper($meta)) {
+ case 'C': return 'VARCHAR';
+ case 'XL':
+ case 'X': return 'TEXT';
+
+ case 'C2': return 'NVARCHAR';
+ case 'X2': return 'NTEXT';
+
+ case 'B': return 'IMAGE';
+
+ case 'D': return 'DATETIME';
+ case 'T': return 'DATETIME';
+ case 'L': return 'BIT';
+
+ case 'I': return 'INT';
+ case 'I1': return 'TINYINT';
+ case 'I2': return 'SMALLINT';
+ case 'I4': return 'INT';
+ case 'I8': return 'BIGINT';
+
+ case 'F': return 'REAL';
+ case 'N': return 'NUMERIC';
+ default:
+ return $meta;
+ }
+ }
+
+
+ function AddColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $f = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ $s = "ALTER TABLE $tabname $this->addCol";
+ foreach($lines as $v) {
+ $f[] = "\n $v";
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ function AlterColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName ($tabname);
+ $sql = array();
+ list($lines,$pkey) = $this->_GenFields($flds);
+ foreach($lines as $v) {
+ $sql[] = "ALTER TABLE $tabname $this->alterCol $v";
+ }
+
+ return $sql;
+ }
+
+ function DropColumnSQL($tabname, $flds)
+ {
+ $tabname = $this->TableName($tabname);
+ if (!is_array($flds)) $flds = explode(',',$flds);
+ $f = array();
+ $s = "ALTER TABLE $tabname";
+ foreach($flds as $v) {
+ $f[] = "\n$this->dropCol ".$this->NameQuote($v);
+ }
+ $s .= implode(', ',$f);
+ $sql[] = $s;
+ return $sql;
+ }
+
+ // return string must begin with space
+ function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint)
+ {
+ $suffix = '';
+ if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
+ if ($fautoinc) $suffix .= ' DEFAULT AUTOINCREMENT';
+ if ($fnotnull) $suffix .= ' NOT NULL';
+ else if ($suffix == '') $suffix .= ' NULL';
+ if ($fconstraint) $suffix .= ' '.$fconstraint;
+ return $suffix;
+ }
+
+ /*
+CREATE TABLE
+ [ database_name.[ owner ] . | owner. ] table_name
+ ( { < column_definition >
+ | column_name AS computed_column_expression
+ | < table_constraint > ::= [ CONSTRAINT constraint_name ] }
+
+ | [ { PRIMARY KEY | UNIQUE } [ ,...n ]
+ )
+
+[ ON { filegroup | DEFAULT } ]
+[ TEXTIMAGE_ON { filegroup | DEFAULT } ]
+
+< column_definition > ::= { column_name data_type }
+ [ COLLATE < collation_name > ]
+ [ [ DEFAULT constant_expression ]
+ | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ]
+ ]
+ [ ROWGUIDCOL]
+ [ < column_constraint > ] [ ...n ]
+
+< column_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ NULL | NOT NULL ]
+ | [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ [ WITH FILLFACTOR = fillfactor ]
+ [ON {filegroup | DEFAULT} ] ]
+ ]
+ | [ [ FOREIGN KEY ]
+ REFERENCES ref_table [ ( ref_column ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( logical_expression )
+ }
+
+< table_constraint > ::= [ CONSTRAINT constraint_name ]
+ { [ { PRIMARY KEY | UNIQUE }
+ [ CLUSTERED | NONCLUSTERED ]
+ { ( column [ ASC | DESC ] [ ,...n ] ) }
+ [ WITH FILLFACTOR = fillfactor ]
+ [ ON { filegroup | DEFAULT } ]
+ ]
+ | FOREIGN KEY
+ [ ( column [ ,...n ] ) ]
+ REFERENCES ref_table [ ( ref_column [ ,...n ] ) ]
+ [ ON DELETE { CASCADE | NO ACTION } ]
+ [ ON UPDATE { CASCADE | NO ACTION } ]
+ [ NOT FOR REPLICATION ]
+ | CHECK [ NOT FOR REPLICATION ]
+ ( search_conditions )
+ }
+
+
+ */
+
+ /*
+ CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
+ ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
+ [ WITH < index_option > [ ,...n] ]
+ [ ON filegroup ]
+ < index_option > :: =
+ { PAD_INDEX |
+ FILLFACTOR = fillfactor |
+ IGNORE_DUP_KEY |
+ DROP_EXISTING |
+ STATISTICS_NORECOMPUTE |
+ SORT_IN_TEMPDB
+ }
+*/
+ function _IndexSQL($idxname, $tabname, $flds, $idxoptions)
+ {
+ $sql = array();
+
+ if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) {
+ $sql[] = sprintf ($this->dropIndex, $idxname, $tabname);
+ if ( isset($idxoptions['DROP']) )
+ return $sql;
+ }
+
+ if ( empty ($flds) ) {
+ return $sql;
+ }
+
+ $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : '';
+ $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : '';
+
+ if ( is_array($flds) )
+ $flds = implode(', ',$flds);
+ $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')';
+
+ if ( isset($idxoptions[$this->upperName]) )
+ $s .= $idxoptions[$this->upperName];
+
+ $sql[] = $s;
+
+ return $sql;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/docs/docs-adodb.htm b/html/phpgacl/adodb/docs/docs-adodb.htm
new file mode 100644
index 0000000..2ba06b3
--- /dev/null
+++ b/html/phpgacl/adodb/docs/docs-adodb.htm
@@ -0,0 +1,3466 @@
+<html>
+<head>
+<title>ADODB Manual</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<XSTYLE
+ body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
+ pre {font-size:9pt}
+ .toplink {font-size:8pt}
+ />
+</head>
+<body bgcolor="#FFFFFF">
+
+<h2>ADOdb Library for PHP</h2>
+<p>V4.23 16 June 2004 (c) 2000-2004 John Lim (jlim#natsoft.com)</p>
+<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This
+ means you can use it in compiled proprietary and commercial products.</font></p>
+
+
+ <table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
+ unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
+ <p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
+
+<p><a href="#intro"><b>Introduction</b></a><b><br>
+ <a href="#features">Unique Features</a><br>
+ <a href="#users">How People are using ADOdb</a><br>
+ <a href="#bugs">Feature Requests and Bug Reports</a><br>
+ </b><b><a href="#install">Installation</a><br>
+ <a href="#mininstall">Minimum Install</a><br>
+ <a href="#coding">Initializing Code and Connection Examples</a><br>
+ <font size="2"><a href=#adonewconnection>ADONewConnection</a></font>
+ <font size="2"><a href=#adonewconnection>NewADOConnection</a></font><br>
+ <a href="#speed">High Speed ADOdb - tuning tips</a></b><br>
+ <b><a href="#hack">Hacking and Modifying ADOdb Safely</a><br>
+ <a href="#php5">PHP5 Features</a></b><br>
+ <font size="2"><a href=#php5iterators>foreach iterators</a> <a href=#php5exceptions>exceptions</a></font><br>
+ <b> <a href="#drivers">Supported Databases</a></b><br>
+ <b> <a href="#quickstart">Tutorials</a></b><br>
+ <a href="#ex1">Example 1: Select</a><br>
+ <a href="#ex2">Example 2: Advanced Select</a><br>
+ <a href="#ex3">Example 3: Insert</a><br>
+ <a href="#ex4">Example 4: Debugging</a> &nbsp;<a href="#exrs2html">rs2html
+ example</a><br>
+ <a href="#ex5">Example 5: MySQL and Menus</a><br>
+ <a href="#ex6">Example 6: Connecting to Multiple Databases at once</a> <br>
+ <a href="#ex7">Example 7: Generating Update and Insert SQL</a> <br>
+ <a href="#ex8">Example 8: Implementing Scrolling with Next and Previous</a><br>
+ <a href="#ex9">Example 9: Exporting in CSV or Tab-Delimited Format</a> <br>
+ <a href="#ex10">Example 10: Custom filters</a><br>
+ <a href="#ex11">Example 11: Smart Transactions</a><br>
+ <br>
+ <b> <a href="#errorhandling">Using Custom Error Handlers and PEAR_Error</a><br>
+ <a href="#DSN">Data Source Names</a><br>
+ <a href="#caching">Caching</a><br>
+ <a href="#pivot">Pivot Tables</a></b>
+<p><a href="#ref"><b>REFERENCE</b></a>
+<p> <font size="2">Variables: <a href="#adodb_countrecs">$ADODB_COUNTRECS</a> <a href=#adodb_ansi_padding_off>$ADODB_ANSI_PADDING_OFF</a>
+ <a href="#adodb_cache_dir">$ADODB_CACHE_DIR</a> </font><font size="2"><a href=#adodb_fetch_mode>$ADODB_FETCH_MODE</a>
+ <a href=#adodb_lang>$ADODB_LANG</a><br>
+ Constants: </font><font size="2"><a href=#adodb_assoc_case>ADODB_ASSOC_CASE</a>
+ </font><br>
+ <a href="#ADOConnection"><b> ADOConnection</b></a><br>
+ <font size="2">Connections: <a href="#connect">Connect</a> <a href="#pconnect">PConnect</a>
+ <a href="#nconnect">NConnect</a> <br>
+ Executing SQL: <a href="#execute">Execute</a> <a href="#cacheexecute"><i>CacheExecute</i></a>
+ <a href="#SelectLimit">SelectLimit</a> <a href="#cacheSelectLimit"><i>CacheSelectLimit</i></a>
+ <a href="#param">Param</a> <a href="#prepare">Prepare</a> <a href=#preparesp>PrepareSP</a>
+ <a href="#inparameter">InParameter</a> <a href="#outparameter">OutParameter</a>
+ <br>
+ &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#getone">GetOne</a>
+ <a href="#cachegetone"><i>CacheGetOne</i></a> <a href="#getrow">GetRow</a> <a href="#cachegetrow"><i>CacheGetRow</i></a>
+ <a href="#getall">GetAll</a> <a href="#cachegetall"><i>CacheGetAll</i></a> <a href="#getcol">GetCol</a>
+ <a href="#cachegetcol"><i>CacheGetCol</i></a> <a href="#getassoc1">GetAssoc</a> <a href="#cachegetassoc"><i>CacheGetAssoc</i></a> <a href="#replace">Replace</a>
+ <br>
+ &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="#executecursor">ExecuteCursor</a>
+ (oci8 only)<br>
+ Generates SQL strings: <a href="#getupdatesql">GetUpdateSQL</a> <a href="#getinsertsql">GetInsertSQL</a>
+ <a href="#concat">Concat</a> <a href="#ifnull">IfNull</a> <a href="#length">length</a> <a href="#random">random</a> <a href="#substr">substr</a>
+ <a href="#qstr">qstr</a> <a href="#param">Param</a>
+ <a href="#prepare"></a><a href="#OffsetDate">OffsetDate</a> <a href="#SQLDate">SQLDate</a>
+ <a href="#dbdate">DBDate</a> <a href="#dbtimestamp"></a> <a href="#dbtimestamp">DBTimeStamp</a>
+ <br>
+ Blobs: <a href="#updateblob">UpdateBlob</a> <a href="#updateclob">UpdateClob</a>
+ <a href="#updateblobfile">UpdateBlobFile</a> <a href="#blobencode">BlobEncode</a>
+ <a href="#blobdecode">BlobDecode</a><br>
+ Paging/Scrolling: <a href="#pageexecute">PageExecute</a> <a href="#cachepageexecute">CachePageExecute</a><br>
+ Cleanup: <a href="#cacheflush">CacheFlush</a> <a href="#Close">Close</a><br>
+ Transactions: <a href="#starttrans">StartTrans</a> <a href="#completetrans">CompleteTrans</a>
+ <a href="#failtrans">FailTrans</a> <a href="#hasfailedtrans">HasFailedTrans</a>
+ <a href="#begintrans">BeginTrans</a> <a href="#committrans">CommitTrans</a>
+ <a href="#rollbacktrans">RollbackTrans</a> <br>
+ Fetching Data: </font> <font size="2"><a href="#setfetchmode">SetFetchMode</a><br>
+ Strings: <a href="#concat">concat</a> <a href="#length">length</a> <a href="#qstr">qstr</a> <a href="#quote">quote</a> <a href="#substr">substr</a><br>
+ Dates: <a href="#dbdate">DBDate</a> <a href="#dbtimestamp">DBTimeStamp</a> <a href="#unixdate">UnixDate</a>
+ <a href="#unixtimestamp">UnixTimeStamp</a> <a href="#OffsetDate">OffsetDate</a>
+ <a href="#SQLDate">SQLDate</a> <br>
+ Row Management: <a href="#affected_rows">Affected_Rows</a> <a href="#inserted_id">Insert_ID</a> <a href=#rowlock>RowLock</a>
+ <a href="#genid">GenID</a> <a href=#createseq>CreateSequence</a> <a href=#dropseq>DropSequence</a>
+ <br>
+ Error Handling: <a href="#errormsg">ErrorMsg</a> <a href="#errorno">ErrorNo</a>
+ <a href="#metaerror">MetaError</a> <a href="#metaerrormsg">MetaErrorMsg</a><br>
+ Data Dictionary (metadata): <a href="#metadatabases">MetaDatabases</a> <a href="#metatables">MetaTables</a>
+ <a href="#metacolumns">MetaColumns</a> <a href="#metacolumnames">MetaColumnNames</a>
+ <a href="#metaprimarykeys">MetaPrimaryKeys</a> <a href="#metaforeignkeys">MetaForeignKeys</a>
+ <a href="#serverinfo">ServerInfo</a> <br>
+ Statistics and Query-Rewriting: <a href="#logsql">LogSQL</a> <a href="#fnexecute">fnExecute
+ and fnCacheExecute</a><br>
+ </font><font size="2">Deprecated: <a href="#bind">Bind</a> <a href="#blankrecordset">BlankRecordSet</a>
+ <a href="#parameter">Parameter</a></font>
+ <a href="#adorecordSet"><b><br>
+ ADORecordSet</b></a><br>
+ <font size="2">
+ Returns one field: <a href="#fields">Fields</a><br>
+ Returns one row:<a href="#fetchrow">FetchRow</a> <a href="#fetchinto">FetchInto</a>
+ <a href="#fetchobject">FetchObject</a> <a href="#fetchnextobject">FetchNextObject</a>
+ <a href="#fetchobj">FetchObj</a> <a href="#fetchnextobj">FetchNextObj</a>
+ <a href="#getrowassoc">GetRowAssoc</a> <br>
+ Returns all rows:<a href="#getarray">GetArray</a> <a href="#getrows">GetRows</a>
+ <a href="#getassoc">GetAssoc</a><br>
+ Scrolling:<a href="#move">Move</a> <a href="#movenext">MoveNext</a> <a href="#movefirst">MoveFirst</a>
+ <a href="#movelast">MoveLast</a> <a href="#abspos">AbsolutePosition</a> <a href="#currentrow">CurrentRow</a>
+ <a href="#atfirstpage">AtFirstPage</a> <a href="#atlastpage">AtLastPage</a>
+ <a href="#absolutepage">AbsolutePage</a> </font> <font size="2"><br>
+ Menu generation:<a href="#getmenu">GetMenu</a> <a href="#getmenu2">GetMenu2</a><br>
+ Dates:<a href="#userdate">UserDate</a> <a href="#usertimestamp">UserTimeStamp</a>
+ <a href="#unixdate">UnixDate</a> <a href="#unixtimestamp">UnixTimeStamp<br>
+ </a>Recordset Info:<a href="#recordcount">RecordCount</a> <a href="#po_recordcount">PO_RecordSet</a>
+ <a href="#nextrecordset">NextRecordSet</a><br>
+ Field Info:<a href="#fieldcount">FieldCount</a> <a href="#fetchfield">FetchField</a>
+ <a href="#metatype">MetaType</a><br>
+ Cleanup: <a href="#rsclose">Close</a></font> <font size="2"></font>
+<p><font size="2"><a href="#rs2html"><b>rs2html</b></a>&nbsp; <a href="#exrs2html">example</a></font><br>
+ <a href="#adodiff">Differences between ADOdb and ADO</a><br>
+ <a href="#driverguide"><b>Database Driver Guide<br>
+ </b></a><b><a href="#changes">Change Log</a></b><br>
+</p>
+<h2>Introduction<a name="intro"></a></h2>
+<p>PHP's database access functions are not standardised. This creates a need for
+ a database class library to hide the differences between the different database
+ API's (encapsulate the differences) so we can easily switch databases. PHP 4.0.5 or later
+ is now required (because we use array-based str_replace).</p>
+<p>We currently support MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, Informix,
+ PostgreSQL, FrontBase, SQLite, Interbase (Firebird and Borland variants), Foxpro, Access, ADO, DB2, SAP DB and ODBC.
+ We have had successful reports of connecting to Progress and CacheLite via ODBC. We hope more people
+ will contribute drivers to support other databases.</p>
+<p>PHP4 supports session variables. You can store your session information using
+ ADOdb for true portability and scalability. See adodb-session.php for more information.</p>
+<p>Also read <a href="http://php.weblogs.com/portable_sql">http://php.weblogs.com/portable_sql</a>
+ (also available as tips_portable_sql.htm in the release) for tips on writing
+ portable SQL.</p>
+<h2>Unique Features of ADOdb<a name="features"></a></h2>
+<ul>
+ <li><b>Easy for Windows programmers</b> to adapt to because many of the conventions
+ are similar to Microsoft's ADO.</li>
+ <li>Unlike other PHP database classes which focus only on select statements,
+ <b>we provide support code to handle inserts and updates which can be adapted
+ to multiple databases quickly.</b> Methods are provided for date handling,
+ string concatenation and string quoting characters for differing databases.</li>
+ <li>A<b> metatype system </b>is built in so that we can figure out that types
+ such as CHAR, TEXT and STRING are equivalent in different databases.</li>
+ <li><b>Easy to port</b> because all the database dependant code are stored in
+ stub functions. You do not need to port the core logic of the classes.</li>
+ <li><b>Portable table and index creation</b> with the <a href=docs-datadict.htm>datadict</a> classes.
+ <li><b>Database performance monitoring and SQL tuning</b> with the <a href=docs-perf.htm>performance monitoring</a> classes.
+ <li><b>Database-backed sessions</b> with the <a href=docs-session.htm>session management</a> classes. Supports session expiry notification.
+</ul>
+<h2>How People are using ADOdb<a name="users"></a></h2>
+Here are some examples of how people are using ADOdb (for a much longer list,
+visit <a href="http://php.weblogs.com/adodb-cool-applications">http://php.weblogs.com/adodb-cool-applications</a>):
+<ul>
+<li><a href="http://phplens.com/">PhpLens</a> is a commercial data grid component that allows both cool Web designers and serious unshaved programmers to develop and maintain databases on the Web easily. Developed by the author of ADOdb.<p>
+
+<li><a href="http://www.interakt.ro/phakt/">PHAkt: PHP Extension for DreamWeaver Ultradev</a> allows you to script PHP in the popular Web page editor. Database handling provided by ADOdb.<p>
+
+<li><a href="http://www.andrew.cmu.edu/~rdanyliw/snort/snortacid.html">Analysis Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to search and process a database of security incidents generated by security-related software such as IDSes and firewalls (e.g. Snort, ipchains). By Roman Danyliw.<p>
+
+<li><a href="http://www.postnuke.com/">PostNuke</a> is a very popular free content management
+ system and weblog system. It offers full CSS support, HTML 4.01 transitional compliance throughout, an advanced blocks system, and is fully multi-lingual enabled. <p>
+
+<li><a href=http://www.auto-net.no/easypublish.php?page=index&lang_id=2>EasyPublish CMS</a> is another free content management system for managing information and integrated modules on your internet, intranet- and extranet-sites. From Norway.<p>
+
+<li><a href="http://nola.noguska.com/">NOLA</a> is a full featured accounting, inventory, and job tracking application. It is licensed under the GPL, and developed by Noguska.
+</ul><p>
+
+<h2>Feature Requests and Bug Reports<a name="bugs"></a></h2>
+<p>Feature requests and bug reports can be emailed to <a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>
+ or posted to the ADOdb Help forums at <a href="http://phplens.com/lens/lensforum/topics.php?id=4">http://phplens.com/lens/lensforum/topics.php?id=4</a>.</p>
+<h2>Installation Guide<a name="install"></a></h2>
+<p>Make sure you are running PHP 4.0.5 or later.
+ Unpack all the files into a directory accessible by your webserver.</p>
+<p>To test, try modifying some of the tutorial examples. Make sure you customize
+ the connection settings correctly. You can debug using <i>$db->debug = true</i> as shown below:</p>
+<pre>&lt;?php
+ include('adodb/adodb.inc.php');
+ $db = <a href="#adonewconnection">ADONewConnection</a>($dbdriver); # eg 'mysql' or 'postgres'
+ $db->debug = true;
+ $db-><a href="#connect">Connect</a>($server, $user, $password, $database);
+ $rs = $db-><a href="#execute">Execute</a>('select * from some_small_table');
+ print &quot;&lt;pre&gt;&quot;;
+ print_r($rs-><a href="#getrows">GetRows</a>());
+ print &quot;&lt;/pre&gt;&quot;;
+?&gt;</pre>
+
+ <h3>Minimum Install<a name=mininstall></a></h3>
+<p>For developers who want to release a minimal install of ADOdb, you will need:
+<ul>
+<li>adodb.inc.php
+<li>adodb-lib.inc.php
+<li>adodb-time.inc.php
+<li>drivers/adodb-$database.inc.php
+<li>license.txt (for legal reasons)
+<li>adodb-php4.inc.php
+<li>adodb-iterator.inc.php
+</ul>
+Optional:
+<ul>
+<li>adodb-error.inc.php and lang/adodb-$lang.inc.php (if you use MetaError())
+<li>adodb-csvlib.inc.php (if you use cached recordsets - CacheExecute(), etc)
+<li>adodb-exceptions.inc.php and adodb-errorhandler.inc.php (if you use adodb error handler or php5 exceptions).
+</ul>
+
+<h3>Code Initialization Examples<a name="coding"></a></h3>
+<p>When running ADOdb, at least two files are loaded. First is adodb/adodb.inc.php,
+ which contains all functions used by all database classes. The code specific
+ to a particular database is in the adodb/driver/adodb-????.inc.php file.</p>
+ <a name="adonewconnection"></a>
+<p>For example, to connect to a mysql database:</p>
+<pre>
+include('/path/to/set/here/adodb.inc.php');
+$conn = &amp;ADONewConnection('mysql');
+</pre>
+<p>Whenever you need to connect to a database, you create a Connection object
+ using the <b>ADONewConnection</b>($driver) function.
+ <b>NewADOConnection</b>($driver) is an alternative name for the same function.</p>
+
+<p>At this point, you are not connected to the database. You will first need to decide
+whether to use <i>persistent</i> or <i>non-persistent</i> connections. The advantage of <i>persistent</i>
+connections is that they are faster, as the database connection is never closed (even
+when you call Close()). <i>Non-persistent </i>connections take up much fewer resources though,
+reducing the risk of your database and your web-server becoming overloaded.
+<p>For persistent connections,
+use $conn-&gt;<a href="reference.functions.pconnect.html">PConnect()</a>,
+ or $conn-&gt;<a href="reference.functions.connect.html">Connect()</a> for non-persistent connections.
+Some database drivers also support <a href="reference.functions.nconnect.html">NConnect()</a>, which forces
+the creation of a new connection.
+<a name=connection_gotcha></a>
+<p><i>Connection Gotcha</i>: If you create two connections, but both use the same userid and password,
+PHP will share the same connection. This can cause problems if the connections are meant to
+different databases. The solution is to always use different userid's for different databases,
+ or use NConnect().
+
+<a name=connect_ex>
+<h3>Examples of Connecting to Databases</h3>
+<h4>MySQL and Most Other Database Drivers</h4>
+<p>MySQL connections are very straightforward, and the parameters are identical
+ to mysql_connect:</p>
+<pre>
+ $conn = &amp;ADONewConnection('mysql');
+ $conn-&gt;PConnect('localhost','userid','password','database');
+ </pre>
+<p> Most other database drivers use a similar convention: Connect($server, $user, $password, $database). Exceptions are listed below.
+<h4>PostgreSQL</h4>
+<p>PostgreSQL accepts connections using: </p>
+<p>a. the standard connection string:</p>
+<pre>
+ $conn = &amp;ADONewConnection('postgres7');
+ $conn-&gt;PConnect('host=localhost port=5432 dbname=mary');</pre>
+<p> b. the classical 4 parameters:</p>
+ <pre>
+ $conn-&gt;PConnect('localhost','userid','password','database');
+ </pre><a name=ldap></a>
+ <h4>LDAP</h4>
+ <p>Here is an example of querying a LDAP server. Thanks to Josh Eldridge for the driver and this example:
+<pre>
+ &lt;?php
+require('/path/to/adodb.inc.php');
+
+$host = 'ldap.baylor.edu';
+$ldapbase = 'ou=People,o=Baylor University,c=US';
+
+$ldap = NewADOConnection( 'ldap' );
+$ldap->Connect( $host, $user_name='', $password='', $ldapbase );
+
+echo "&lt;pre>";
+
+print_r( $ldap->ServerInfo() );
+$ldap->SetFetchMode(ADODB_FETCH_ASSOC);
+$userName = 'eldridge';
+$filter="(|(CN=$userName*)(sn=$userName*)(givenname=$userName*)(uid=$userName*))";
+
+$rs = $ldap->Execute( $filter );
+if ($rs)
+ while ($arr = $rs->FetchRow()) {
+ print_r($arr);
+ }
+
+$rs = $ldap->Execute( $filter );
+if ($rs)
+ while (!$rs->EOF) {
+ print_r($rs->fields);
+ $rs->MoveNext();
+ }
+
+print_r( $ldap->GetArray( $filter ) );
+
+print_r( $ldap->GetRow( $filter ) );
+
+$ldap->Close();
+echo "&lt;/pre>";
+?></pre>
+<h4>Interbase/Firebird</h4>
+You define the database in the $host parameter:
+<pre>
+ $conn = &ADONewConnection('ibase');
+ $conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');
+</pre>
+<h4>SQLite</h4>
+Sqlite will create the database file if it does not exist.
+<pre>
+ $conn = &ADONewConnection('sqlite');
+ $conn->PConnect('c:\path\to\sqlite.db'); # sqlite will create if does not exist
+</pre>
+<h4>Oracle (oci8)</h4>
+<p>With oci8, you can connect in multiple ways. Note that oci8 works fine with
+newer versions of the Oracle, eg. 9i and 10g.</p>
+<p>a. PHP and Oracle reside on the same machine, use default SID.</p>
+<pre> $conn-&gt;Connect(false, 'scott', 'tiger');</pre>
+<p>b. TNS Name defined in tnsnames.ora (or ONAMES or HOSTNAMES), eg. 'myTNS'</p>
+<pre> $conn-&gt;PConnect(false, 'scott', 'tiger', 'myTNS');</pre>
+<p>or</p>
+<pre> $conn-&gt;PConnect('myTNS', 'scott', 'tiger');</pre>
+<p>c. Host Address and SID</p>
+<pre> $conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'SID');</pre>
+<p>d. Host Address and Service Name</p>
+<pre> $conn-&gt;Connect('192.168.0.1', 'scott', 'tiger', 'servicename');</pre>
+<p>e. Oracle connection string:
+<pre> $cstr = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$host)(PORT=$port))
+ (CONNECT_DATA=(SID=$sid)))";
+ $conn-&gt;Connect($cstr, 'scott', 'tiger');
+</pre>
+<a name=dsnless></a>
+<h4>DSN-less ODBC (access and mssql examples)</h4>
+<p>ODBC DSN's can be created in the ODBC control panel, or you can use a DSN-less
+ connection.To use DSN-less connections with ODBC you need PHP 4.3 or later.
+</p>
+<p>For Microsoft Access:</p>
+<pre>
+ $db =& ADONewConnection('access');
+ $dsn = <strong>"Driver=&#123;Microsoft Access Driver (*.mdb)&#125;;Dbq=d:\\northwind.mdb;Uid=Admin;Pwd=;";</strong>
+ $db->Connect($dsn);
+</pre>
+For Microsoft SQL Server:
+<pre>
+ $db =& ADONewConnection('odbc_mssql');
+ $dsn = <strong>"Driver=&#123;SQL Server&#125;;Server=localhost;Database=northwind;"</strong>;
+ $db->Connect($dsn,'userid','password');
+</pre>
+or if you prefer to use the mssql extension (which is limited to mssql 6.5 functionality):
+<pre>
+ $db =& ADONewConnection('mssql');
+ $db->Execute("localhost', 'userid', 'password', 'northwind');
+</pre>
+<b>DSN-less Connections with ADO</b><br>
+If you are using versions of PHP earlier than PHP 4.3.0, DSN-less connections
+only work with Microsoft's ADO, which is Microsoft's COM based API. An example
+using the ADOdb library and Microsoft's ADO:
+<pre>
+&lt;?php
+ include('adodb.inc.php');
+ $db = &ADONewConnection("ado_mssql");
+ print "&lt;h1>Connecting DSN-less $db->databaseType...&lt;/h1>";
+
+ <b>$myDSN="PROVIDER=MSDASQL;DRIVER=&#123;SQL Server&#125;;"
+ . "SERVER=flipper;DATABASE=ai;UID=sa;PWD=;" ;</b>
+ $db->Connect($myDSN);
+
+ $rs = $db->Execute("select * from table");
+ $arr = $rs->GetArray();
+ print_r($arr);
+?>
+</pre><a name=speed></a>
+<h2>High Speed ADOdb - tuning tips</h2>
+<p>ADOdb is a big class library, yet it <a href=http://phplens.com/lens/adodb/>consistently beats</a> all other PHP class
+ libraries in performance. This is because it is designed in a layered fashion,
+ like an onion, with the fastest functions in the innermost layer. Stick to the
+ following functions for best performance:</p>
+<table width="40%" border="1" align="center">
+ <tr>
+ <td><div align="center"><b>Innermost Layer</b></div></td>
+ </tr>
+ <tr>
+ <td><p align="center">Connect, PConnect, NConnect<br>
+ Execute, CacheExecute<br>
+ SelectLimit, CacheSelectLimit<br>
+ MoveNext, Close <br>
+ qstr, Affected_Rows, Insert_ID</p></td>
+ </tr>
+</table>
+<p>The fastest way to access the fields is by accessing the array $recordset->fields
+ directly. Also set the global variables <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>
+ = ADODB_FETCH_NUM, and (for oci8, ibase/firebird and odbc) <a href="#adodb_countrecs">$ADODB_COUNTRECS</a> = false
+ before you connect to your database.</p>
+<p>Consider using bind parameters if your database supports it, as it improves
+ query plan reuse. Use ADOdb's performance tuning system to identify bottlenecks
+ quickly. At the time of writing (Dec 2003), this means oci8 and odbc drivers.</p>
+<p>Lastly make sure you have a PHP accelerator cache installed such as APC, Turck
+ MMCache, Zend Accelerator or ionCube.</p>
+ <p>Informix tips: Disable scrollable cursors with $db->cursorType = 0.
+<p><a name=hack></a> </p>
+<h2>Hacking ADOdb Safely</h2>
+<p>You might want to modify ADOdb for your own purposes. Luckily you can
+still maintain backward compatibility by sub-classing ADOdb and using the $ADODB_NEWCONNECTION
+variable. $ADODB_NEWCONNECTION allows you to override the behaviour of ADONewConnection().
+ADOConnection() checks for this variable and will call
+the function-name stored in this variable if it is defined.
+<p>In the following example, new functionality for the connection object
+is placed in the <i>hack_mysql</i> and <i>hack_postgres7</i> classes. The recordset class naming convention
+can be controlled using $rsPrefix. Here we set it to 'hack_rs_', which will make ADOdb use
+<i>hack_rs_mysql</i> and <i>hack_rs_postgres7</i> as the recordset classes.
+If you want to use the default ADOdb drivers return false.
+
+<pre>
+class hack_mysql extends adodb_mysql {
+var $rsPrefix = 'hack_rs_';
+ /* Your mods here */
+}
+
+class hack_rs_mysql extends ADORecordSet_mysql {
+ /* Your mods here */
+}
+
+class hack_postgres7 extends adodb_postgres7 {
+var $rsPrefix = 'hack_rs_';
+ /* Your mods here */
+}
+
+class hack_rs_postgres7 extends ADORecordSet_postgres7 {
+ /* Your mods here */
+}
+
+$ADODB_NEWCONNECTION = 'hack_factory';
+
+function& hack_factory($driver)
+{
+ if ($driver !== 'mysql' && $driver !== 'postgres7') return false;
+
+ $driver = 'hack_'.$driver;
+ $obj = new $driver();
+ return $obj;
+}
+
+include_once('adodb.inc.php');
+
+</pre>
+<p>Don't forget to call the constructor of the parent class.
+<a name="php5"></a>
+<h2>PHP5 Features</h2>
+ ADOdb 4.02 or later will transparently determine which version of PHP you are using.
+If PHP5 is detected, the following features become available:
+<ul>
+<a name="php5iterators"></a>
+<li><b>Foreach iterators</b>: This is a very natural way of going through a recordset:
+<pre>
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs = $db->Execute($sql);
+ foreach($rs as $k => $row) {
+ echo "r1=".$row[0]." r2=".$row[1]."&lt;br>";
+ }
+</pre>
+<p>
+<a name="php5exceptions"></a>
+<li><b>Exceptions</b>: Just include <i>adodb-exceptions.inc.php</i> and you can now
+catch exceptions on errors as they occur.
+<pre>
+ <b>include("../adodb-exceptions.inc.php");</b>
+ include("../adodb.inc.php");
+ try {
+ $db = NewADOConnection("oci8");
+ $db->Connect('','scott','bad-password');
+ } catch (exception $e) {
+ var_dump($e);
+ }
+</pre>
+<p>Note that reaching EOF is <b>not</b> considered an error nor an exception.
+</ul>
+<h3><a name="drivers"></a>Databases Supported</h3>
+The <i>name</i> below is the value you pass to NewADOConnection($name) to create a connection object for that database.
+<p>
+<table width="100%" border="1">
+ <tr valign="top">
+ <td><b>Name</b></td>
+ <td><b>Tested</b></td>
+ <td><b>Database</b></td>
+ <td><b><font size="2">RecordCount() usable</font></b></td>
+ <td><b>Prerequisites</b></td>
+ <td><b>Operating Systems</b></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">access</font></b></td>
+ <td><font size="2">B</font></td>
+ <td><font size="2">Microsoft Access/Jet. You need to create an ODBC DSN.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ODBC </font></td>
+ <td><font size="2">Windows only</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">ado</font></b></td>
+ <td><font size="2">B</font></td>
+ <td><p><font size="2">Generic ADO, not tuned for specific databases. Allows
+ DSN-less connections. For best performance, use an OLEDB provider. This
+ is the base class for all ado drivers.</font></p>
+ <p><font size="2">You can set $db-&gt;codePage before connecting.</font></p></td>
+ <td><font size="2">? depends on database</font></td>
+ <td><font size="2">ADO or OLEDB provider</font></td>
+ <td><font size="2">Windows only</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">ado_access</font></b></td>
+ <td><font size="2">B</font></td>
+ <td><font size="2">Microsoft Access/Jet using ADO. Allows DSN-less connections.
+ For best performance, use an OLEDB provider.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ADO or OLEDB provider</font></td>
+ <td><font size="2">Windows only</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">ado_mssql</font></b></td>
+ <td><font size="2">B</font></td>
+ <td><font size="2">Microsoft SQL Server using ADO. Allows DSN-less connections.
+ For best performance, use an OLEDB provider.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ADO or OLEDB provider</font></td>
+ <td><font size="2">Windows only</font></td>
+ </tr>
+ <tr valign="top">
+ <td height="54"><b><font size="2">db2</font></b></td>
+ <td height="54"><font size="2">A</font></td>
+ <td height="54"><font size="2">DB2. Should work reliably as based on ODBC
+ driver.</font></td>
+ <td height="54"><font size="2">Y/N</font></td>
+ <td height="54"><font size="2">DB2 CLI/ODBC interface</font></td>
+ <td height="54"> <p><font size="2">Unix and Windows. <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix
+ install hints</a>. I have had reports that the $host and $database params have to be reversed in Connect() when using the CLI interface.</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">vfp</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">Microsoft Visual FoxPro. You need to create an ODBC DSN.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ODBC</font></td>
+ <td><font size="2">Windows only</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">fbsql</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">FrontBase. </font></td>
+ <td><font size="2">Y</font></td>
+ <td><font size="2">?</font></td>
+ <td> <p><font size="2">Unix and Windows</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">ibase</font></b></td>
+ <td><font size="2">B</font></td>
+ <td><font size="2">Interbase 6 or earlier. Some users report you might need
+ to use this<br>
+ $db->PConnect('localhost:c:/ibase/employee.gdb', "sysdba", "masterkey")
+ to connect. Lacks Affected_Rows currently.<br>
+ <br>
+ You can set $db->dialect, $db-&gt;buffers and $db->charSet before connecting.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Interbase client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><i><font size="2">firebird</font></i></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Firebird version of interbase.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Interbase client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><i><font size="2">borland_ibase</font></i></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Borland version of Interbase 6.5 or later. Very sad that
+ the forks differ.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Interbase client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+
+ <tr valign="top">
+ <td><b><font size="2">informix</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Generic informix driver. Use this if you are using Informix 7.3 or later.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Informix client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">informix72</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2"> Informix databases before Informix 7.3 that do no support
+ SELECT FIRST.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Informix client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">ldap</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">LDAP driver. See this example for usage information.</font></td>
+ <td>&nbsp;</td>
+ <td><font size="2">LDAP extension</font></td>
+ <td><font size="2">?</font></td>
+ </tr>
+ <tr valign="top">
+ <td height="73"><b><font size="2">mssql</font></b></td>
+ <td height="73"><font size="2">A</font></td>
+ <td height="73"> <p><font size="2">Microsoft SQL Server 7 and later. Works
+ with Microsoft SQL Server 2000 also. Note that date formating is problematic
+ with this driver. For example, the PHP mssql extension does not return
+ the seconds for datetime!</font></p></td>
+ <td height="73"><font size="2">Y/N</font></td>
+ <td height="73"><font size="2">Mssql client</font></td>
+ <td height="73"> <p><font size="2">Unix and Windows. <br>
+ <a href="http://phpbuilder.com/columns/alberto20000919.php3">Unix install
+ howto</a> and <a href=http://linuxjournal.com/article.php?sid=6636&mode=thread&order=0>another
+ one</a>. </font></p></td>
+ </tr>
+ <tr valign="top">
+ <td height="73"><b><font size="2">mssqlpo</font></b></td>
+ <td height="73"><font size="2">A</font></td>
+ <td height="73"> <p><font size="2">Portable mssql driver. Identical to above
+ mssql driver, except that '||', the concatenation operator, is converted
+ to '+'. Useful for porting scripts from most other sql variants that use
+ ||.</font></p></td>
+ <td height="73"><font size="2">Y/N</font></td>
+ <td height="73"><font size="2">Mssql client</font></td>
+ <td height="73"> <p><font size="2">Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3"><br>
+ Unix install howto</a>.</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">mysql</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">MySQL without transaction support. You can also set $db-&gt;clientFlags
+ before connecting.</font></td>
+ <td><font size="2">Y</font></td>
+ <td><font size="2">MySQL client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><font size="2"><b>mysqlt</b> or <b>maxsql</b></font></td>
+ <td><font size="2">A</font></td>
+ <td> <p><font size="2">MySQL with transaction support. We recommend using
+ || as the concat operator for best portability. This can be done by running
+ MySQL using: <br>
+ <i>mysqld --ansi</i> or <i>mysqld --sql-mode=PIPES_AS_CONCAT</i></font></p></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">MySQL client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">oci8</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">Oracle 8/9. Has more functionality than <i>oracle</i> driver
+ (eg. Affected_Rows). You might have to putenv('ORACLE_HOME=...') before
+ Connect/PConnect. </font> <p><font size="2"> There are 2 ways of connecting
+ - with server IP and service name: <br>
+ <i>PConnect('serverip:1521','scott','tiger','service'</i>)<br>
+ or using an entry in TNSNAMES.ORA or ONAMES or HOSTNAMES: <br>
+ <i>PConnect(false, 'scott', 'tiger', $oraname)</i>. </font>
+ <p><font size="2">Since 2.31, we support Oracle REF cursor variables directly
+ (see <a href="#executecursor">ExecuteCursor</a>).</font> </td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Oracle client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">oci805</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Supports reduced Oracle functionality for Oracle 8.0.5.
+ SelectLimit is not as efficient as in the oci8 or oci8po drivers.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Oracle client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">oci8po</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">Oracle 8/9 portable driver. This is nearly identical with
+ the oci8 driver except (a) bind variables in Prepare() use the ? convention,
+ instead of :bindvar, (b) field names use the more common PHP convention
+ of lowercase names. </font> <p><font size="2">Use this driver if porting
+ from other databases is important. Otherwise the oci8 driver offers better
+ performance. </font> </td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Oracle client</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">odbc</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">Generic ODBC, not tuned for specific databases. To connect,
+ use <br>
+ PConnect('DSN','user','pwd'). This is the base class for all odbc derived
+ drivers.</font></td>
+ <td><font size="2">? depends on database</font></td>
+ <td><font size="2">ODBC</font></td>
+ <td><font size="2">Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3?page=4">Unix
+ hints.</a></font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">odbc_mssql</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Uses ODBC to connect to MSSQL</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ODBC</font></td>
+ <td><font size="2">Unix and Windows. </font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">odbc_oracle</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Uses ODBC to connect to Oracle</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">ODBC</font></td>
+ <td><font size="2">Unix and Windows. </font></td>
+ </tr>
+
+ <tr valign="top">
+ <td><b><font size="2">odbtp</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Generic odbtp driver. <a href=http://odbtp.sourceforge.net/>Odbtp</a> is a software for
+ accessing Windows ODBC data sources from other operating systems.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">odbtp</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">odbtp_unicode</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Odtbp with unicode support</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">odbtp</font></td>
+ <td><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td height="34"><b><font size="2">oracle</font></b></td>
+ <td height="34"><font size="2">C</font></td>
+ <td height="34"><font size="2">Implements old Oracle 7 client API. Use oci8
+ driver if possible for better performance.</font></td>
+ <td height="34"><font size="2">Y/N</font></td>
+ <td height="34"><font size="2">Oracle client</font></td>
+ <td height="34"><font size="2">Unix and Windows</font></td>
+ </tr>
+ <tr valign="top">
+ <td height="34"><b><font size="2">netezza</font></b></td>
+ <td height="34"><font size="2">C</font></td>
+ <td height="34"><font size="2">Netezza driver. Netezza is based on postgres code-base.</font></td>
+ <td height="34"><font size="2">Y</font></td>
+ <td height="34"><font size="2">?</font></td>
+ <td height="34"><font size="2">?</font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">postgres</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">Generic PostgreSQL driver. Currently identical to postgres7
+ driver. </font></td>
+ <td><font size="2">Y</font></td>
+ <td><font size="2">PostgreSQL client</font></td>
+ <td><font size="2">Unix and Windows. </font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">postgres64</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">For PostgreSQL 6.4 and earlier which does not support LIMIT
+ internally.</font></td>
+ <td><font size="2">Y</font></td>
+ <td><font size="2">PostgreSQL client</font></td>
+ <td><font size="2">Unix and Windows. </font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">postgres7</font></b></td>
+ <td><font size="2">A</font></td>
+ <td><font size="2">PostgreSQL which supports LIMIT and other version 7 functionality.</font></td>
+ <td><font size="2">Y</font></td>
+ <td><font size="2">PostgreSQL client</font></td>
+ <td><font size="2">Unix and Windows. </font></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">sapdb</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">SAP DB. Should work reliably as based on ODBC driver.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">SAP ODBC client</font></td>
+ <td> <p><font size="2">?</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">sqlanywhere</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Sybase SQL Anywhere. Should work reliably as based on ODBC
+ driver.</font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">SQL Anywhere ODBC client</font></td>
+ <td> <p><font size="2">?</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td height="54"><b><font size="2">sqlite</font></b></td>
+ <td height="54"><font size="2">B</font></td>
+ <td height="54"><font size="2">SQLite. Only tested on PHP5.</font></td>
+ <td height="54"><font size="2">Y</font></td>
+ <td height="54"><font size="2">-</font></td>
+ <td height="54"> <p><font size="2">Unix and Windows.</font></p></td>
+ </tr>
+ <tr valign="top">
+ <td><b><font size="2">sybase</font></b></td>
+ <td><font size="2">C</font></td>
+ <td><font size="2">Sybase. </font></td>
+ <td><font size="2">Y/N</font></td>
+ <td><font size="2">Sybase client</font></td>
+ <td> <p><font size="2">Unix and Windows.</font></p></td>
+ </tr>
+ <p>
+</table>
+
+<p>The &quot;Tested&quot; column indicates how extensively the code has been tested
+ and used. <br>
+ A = well tested and used by many people<br>
+ B = tested and usable, but some features might not be implemented<br>
+ C = user contributed or experimental driver. Might not fully support all of
+ the latest features of ADOdb. </p>
+<p>The column &quot;RecordCount() usable&quot; indicates whether RecordCount()
+ return the number of rows, or returns -1 when a SELECT statement is executed.
+ If this column displays Y/N then the RecordCount() is emulated when the global
+ variable $ADODB_COUNTRECS=true (this is the default). Note that for large recordsets,
+ it might be better to disable RecordCount() emulation because substantial amounts
+ of memory are required to cache the recordset for counting. Also there is a
+ speed penalty of 40-50% if emulation is required. This is emulated in most databases
+ except for PostgreSQL and MySQL. This variable is checked every time a query
+ is executed, so you can selectively choose which recordsets to count.</p>
+<p>
+<hr>
+<h1>Tutorials<a name="quickstart"></a></h1>
+<h3>Example 1: Select Statement<a name="ex1"></a></h3>
+<p>Task: Connect to the Access Northwind DSN, display the first 2 columns of each
+ row.</p>
+<p>In this example, we create a ADOConnection object, which represents the connection
+ to the database. The connection is initiated with <a href="#pconnect"><font face="Courier New, Courier, mono">PConnect</font></a>,
+ which is a persistent connection. Whenever we want to query the database, we
+ call the <font face="Courier New, Courier, mono">ADOConnection.<a href="#execute">Execute</a>()</font>
+ function. This returns an ADORecordSet object which is actually a cursor that
+ holds the current row in the array <font face="Courier New, Courier, mono">fields[]</font>.
+ We use <font face="Courier New, Courier, mono"><a href="#movenext">MoveNext</a>()</font>
+ to move from row to row.</p>
+<p>NB: A useful function that is not used in this example is <font face="Courier New, Courier, mono"><a href="#selectlimit">SelectLimit</a></font>,
+ which allows us to limit the number of rows shown.
+<pre>
+&lt;?
+<font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#660000">conn</font> = &amp;ADONewConnection('access'); # create a connection
+$<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind DSN
+$<font color="#660000">recordSet</font> = &amp;$<font color="#660000">conn</font>->Execute('select * from products');
+if (!$<font color="#660000">recordSet</font>)
+ print $<font color="#660000">conn</font>-&gt;ErrorMsg();
+else
+<b>while</b> (!$<font color="#660000">recordSet</font>-&gt;EOF) &#123;
+ <b>print</b> $<font color="#660000">recordSet</font>->fields[0].' '.$<font color="#660000">recordSet</font>->fields[1].'&lt;BR&gt;';
+ $<font color="#660000">recordSet</font>-&gt;MoveNext();
+&#125;</font><font face="Courier New, Courier, mono">
+
+$<font color="#660000">recordSet</font>->Close(); # optional
+$<font color="#660000">conn</font>->Close(); # optional
+</font>
+?>
+</pre>
+<p>The $<font face="Courier New, Courier, mono">recordSet</font> returned stores
+ the current row in the <font face="Courier New, Courier, mono">$recordSet-&gt;fields</font>
+ array, indexed by column number (starting from zero). We use the <font face="Courier New, Courier, mono"><a href="#movenext">MoveNext</a>()</font>
+ function to move to the next row. The <font face="Courier New, Courier, mono">EOF</font>
+ property is set to true when end-of-file is reached. If an error occurs in Execute(),
+ we return false instead of a recordset.</p>
+<p>The <code>$recordSet-&gt;fields[]</code> array is generated by the PHP database
+ extension. Some database extensions only index by number and do not index the
+ array by field name. To force indexing by name - that is associative arrays
+ - use the SetFetchMode function. Each recordset saves and uses whatever fetch
+ mode was set when the recordset was created in Execute() or SelectLimit().
+<pre>
+ $db->SetFetchMode(ADODB_FETCH_NUM);
+ $rs1 = $db->Execute('select * from table');
+ $db->SetFetchMode(ADODB_FETCH_ASSOC);
+ $rs2 = $db->Execute('select * from table');
+ print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i>
+ print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
+</pre>
+<p> </p>
+<p>To get the number of rows in the select statement, you can use <font face="Courier New, Courier, mono">$recordSet-&gt;<a href="#recordcount">RecordCount</a>()</font>.
+ Note that it can return -1 if the number of rows returned cannot be determined.</p>
+<h3>Example 2: Advanced Select with Field Objects<a name="ex2"></a></h3>
+<p>Select a table, display the first two columns. If the second column is a date
+ or timestamp, reformat the date to US format.</p>
+<pre>
+&lt;?
+<font face="Courier New, Courier, mono"><b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#660000">conn</font> = &amp;ADONewConnection('access'); # create a connection
+$<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn
+$<font color="#660000">recordSet</font> = &amp;$<font color="#660000">conn</font>->Execute('select CustomerID,OrderDate from Orders');
+if (!$<font color="#660000">recordSet</font>)
+ print $<font color="#660000">conn</font>-&gt;ErrorMsg();
+else
+<b>while</b> (!$<font color="#660000">recordSet</font>-&gt;EOF) &#123;
+ $<font color="#660000">fld</font> = <font color="#336600"><b>$</b><font color="#660000">recordSet</font><b>-&gt;FetchField</b></font><font color="#006600">(</font>1<font color="#006600">);</font>
+ $<font color="#660000">type</font> = <font color="#336600"><b>$</b><font color="#660000">recordSet</font><b>-&gt;MetaType</b></font>($fld-&gt;type);
+
+ <b>if</b> ( $<font color="#660000">type</font> == 'D' || $<font color="#660000">type</font> == 'T')
+ <b>print</b> $<font color="#660000">recordSet</font>-&gt;fields[0].' '.
+ <b><font color="#336600">$</font></b><font color="#660000">recordSet</font><b><font color="#336600">-&gt;UserDate</font></b>($<font color="#660000">recordSet</font>-&gt;fields[1],'<b>m/d/Y</b>').'&lt;BR&gt;';
+ <b>else </b>
+ <b>print</b> $<font color="#660000">recordSet</font>->fields[0].' '.$<font color="#660000">recordSet</font>->fields[1].'&lt;BR&gt;';
+
+ $<font color="#660000">recordSet</font>-&gt;MoveNext();
+&#125;</font><font face="Courier New, Courier, mono">
+$<font color="#660000">recordSet</font>->Close(); # optional
+$<font color="#660000">conn</font>->Close(); # optional
+</font>
+?>
+</pre>
+<p>In this example, we check the field type of the second column using <font face="Courier New, Courier, mono"><a href="#fetchfield">FetchField</a>().</font>
+ This returns an object with at least 3 fields.</p>
+<ul>
+ <li><b>name</b>: name of column</li>
+ <li> <b>type</b>: native field type of column</li>
+ <li> <b>max_length</b>: maximum length of field. Some databases such as MySQL
+ do not return the maximum length of the field correctly. In these cases max_length
+ will be set to -1.</li>
+</ul>
+<p>We then use <font face="Courier New, Courier, mono"><a href="#metatype">MetaType</a>()</font>
+ to translate the native type to a <i>generic</i> type. Currently the following
+ <i>generic</i> types are defined:</p>
+<ul>
+ <li><b>C</b>: character fields that should be shown in a &lt;input type=&quot;text&quot;&gt;
+ tag.</li>
+ <li><b>X</b>: TeXt, large text fields that should be shown in a &lt;textarea&gt;</li>
+ <li><b>B</b>: Blobs, or Binary Large Objects. Typically images.
+ <li><b>D</b>: Date field</li>
+ <li><b>T</b>: Timestamp field</li>
+ <li><b>L</b>: Logical field (boolean or bit-field)</li>
+ <li><b>I</b>:&nbsp; Integer field</li>
+ <li><b>N</b>: Numeric field. Includes autoincrement, numeric, floating point,
+ real and integer. </li>
+ <li><b>R</b>: Serial field. Includes serial, autoincrement integers. This works
+ for selected databases. </li>
+</ul>
+<p>If the metatype is of type date or timestamp, then we print it using the user
+ defined date format with <font face="Courier New, Courier, mono"><a href="#userdate">UserDate</a>(),</font>
+ which converts the PHP SQL date string format to a user defined one. Another
+ use for <font face="Courier New, Courier, mono"><a href="#metatype">MetaType</a>()</font>
+ is data validation before doing an SQL insert or update.</p>
+<h3>Example 3: Inserting<a name="ex3"></a></h3>
+<p>Insert a row to the Orders table containing dates and strings that need to
+ be quoted before they can be accepted by the database, eg: the single-quote
+ in the word <i>John's</i>.</p>
+<pre>
+&lt;?
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#660000">conn</font> = &amp;ADONewConnection('access'); # create a connection
+
+$<font color="#660000">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn
+$<font color="#660000">shipto</font> = <font color="#006600"><b>$conn-&gt;qstr</b></font>(&quot;<i>John's Old Shoppe</i>&quot;);
+
+$<font color="#660000">sql</font> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;
+$<font color="#660000">sql</font> .= &quot;values ('ANATR',2,&quot;.<b><font color="#006600">$conn-&gt;DBDate(</font>time()<font color="#006600">)</font></b><font color="#006600">.</font>&quot;,$<font color="#660000">shipto</font>)&quot;;
+
+<b>if</b> ($<font color="#660000">conn</font>->Execute($<font color="#660000">sql</font>) <font color="#336600"><b>=== false</b></font>) &#123;
+ <b>print</b> 'error inserting: '.<font color="#336600"><b>$conn-&gt;ErrorMsg()</b></font>.'&lt;BR&gt;';
+&#125;
+?>
+</pre>
+<p>In this example, we see the advanced date and quote handling facilities of
+ ADOdb. The unix timestamp (which is a long integer) is appropriately formated
+ for Access with <font face="Courier New, Courier, mono"><a href="#dbdate">DBDate</a>()</font>,
+ and the right escape character is used for quoting the <i>John's Old Shoppe</i>,
+ which is<b> </b><i>John'<b>'</b>s Old Shoppe</i> and not PHP's default <i>John<b>'</b>s
+ Old Shoppe</i> with <font face="Courier New, Courier, mono"><a href="#qstr">qstr</a>()</font>.
+</p>
+<p>Observe the error-handling of the Execute statement. False is returned by<font face="Courier New, Courier, mono">
+ <a href="#execute">Execute</a>() </font>if an error occured. The error message
+ for the last error that occurred is displayed in <font face="Courier New, Courier, mono"><a href="#errormsg">ErrorMsg</a>()</font>.
+ Note: <i>php_track_errors</i> might have to be enabled for error messages to
+ be saved.</p>
+<h3> Example 4: Debugging<a name="ex4"></a></h3>
+<pre>&lt;?
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#663300">conn</font> = &amp;ADONewConnection('access'); # create a connection
+$<font color="#663300">conn</font>->PConnect('northwind'); # connect to MS-Access, northwind dsn
+<font color="#000000">$<font color="#663300">shipto</font> = <b>$conn-&gt;qstr</b>(&quot;John's Old Shoppe&quot;);
+$<font color="#663300">sql</font> = &quot;insert into orders (customerID,EmployeeID,OrderDate,ShipName) &quot;;
+$<font color="#663300">sql</font> .= &quot;values ('ANATR',2,&quot;.$<font color="#663300">conn</font>-&gt;FormatDate(time()).&quot;,$shipto)&quot;;
+<b><font color="#336600">$<font color="#663300">conn</font>-&gt;debug = true;</font></b>
+<b>if</b> ($<font color="#663300">conn</font>->Execute($sql) <b>=== false</b>) <b>print</b> 'error inserting';</font>
+?&gt;
+</pre>
+<p>In the above example, we have turned on debugging by setting <b>debug = true</b>.
+ This will display the SQL statement before execution, and also show any error
+ messages. There is no need to call <font face="Courier New, Courier, mono"><a href="#errormsg">ErrorMsg</a>()</font>
+ in this case. For displaying the recordset, see the <font face="Courier New, Courier, mono"><a href="#exrs2html">rs2html</a>()
+ </font>example.</p>
+<p>Also see the section on <a href=#errorhandling>Custom Error Handlers</a>.</p>
+<h3>Example 5: MySQL and Menus<a name="ex5"></a></h3>
+<p>Connect to MySQL database <i>agora</i>, and generate a &lt;select&gt; menu
+ from an SQL statement where the &lt;option&gt; captions are in the 1st column,
+ and the value to send back to the server is in the 2nd column.</p>
+<pre>&lt;?
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#663300">conn</font> = &amp;ADONewConnection('mysql'); # create a connection
+$<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
+<font color="#000000">$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers';
+$<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute($sql);
+<b>print</b> <b><font color="#336600">$<font color="#663300">rs</font>-&gt;GetMenu('GetCust','Mary Rosli');
+?&gt;</font></b></font></pre>
+<p>Here we define a menu named GetCust, with the menu option 'Mary Rosli' selected.
+ See <a href="#getmenu"><font face="Courier New, Courier, mono">GetMenu</font></a><font face="Courier New, Courier, mono">()</font>.
+ We also have functions that return the recordset as an array: <font face="Courier New, Courier, mono"><a href="#getarray">GetArray</a>()</font>,
+ and as an associative array with the key being the first column: <a href="#getassoc1">GetAssoc</a>().</p>
+<h3>Example 6: Connecting to 2 Databases At Once<a name="ex6"></a></h3>
+<pre>&lt;?
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#663300">conn1</font> = &amp;ADONewConnection('mysql'); # create a mysql connection
+$<font color="#663300">conn2</font> = &amp;ADONewConnection('oracle'); # create a oracle connection
+
+$conn1-&gt;PConnect($server, $userid, $password, $database);
+$conn2-&gt;PConnect(false, $ora_userid, $ora_pwd, $oraname);
+
+$conn1-&gt;Execute('insert ...');
+$conn2-&gt;Execute('update ...');
+?&gt;</pre>
+<p>
+<h3>Example 7: Generating Update and Insert SQL<a name="ex7"></a></h3>
+ADOdb 1.31 and later supports two new recordset functions: GetUpdateSQL( ) and
+GetInsertSQL( ). This allow you to perform a "SELECT * FROM table query WHERE...",
+make a copy of the $rs->fields, modify the fields, and then generate the SQL to
+update or insert into the table automatically.
+<p> We show how the functions can be used when accessing a table with the following
+ fields: (ID, FirstName, LastName, Created).
+<p> Before these functions can be called, you need to initialize the recordset
+ by performing a select on the table. Idea and code by Jonathan Younger jyounger#unilab.com.
+ Since ADOdb 2.42, you can pass a table name instead of a recordset into
+GetInsertSQL (in $rs), and it will generate an insert statement for that table.
+<p>
+<pre>&lt;?
+#==============================================
+# SAMPLE GetUpdateSQL() and GetInsertSQL() code
+#==============================================
+include('adodb.inc.php');
+include('tohtml.inc.php');
+
+#==========================
+# This code tests an insert
+
+$sql = "SELECT * FROM ADOXYZ WHERE id = -1";
+# Select an empty record from the database
+
+$conn = &ADONewConnection("mysql"); # create a connection
+$conn->debug=1;
+$conn->PConnect("localhost", "admin", "", "test"); # connect to MySQL, testdb
+$rs = $conn->Execute($sql); # Execute the query and get the empty recordset
+
+$record = array(); # Initialize an array to hold the record data to insert
+
+# Set the values for the fields in the record
+# Note that field names are case-insensitive
+$record["firstname"] = "Bob";
+$record["lastNamE"] = "Smith";
+$record["creaTed"] = time();
+
+# Pass the empty recordset and the array containing the data to insert
+# into the GetInsertSQL function. The function will process the data and return
+# a fully formatted insert sql statement.
+$insertSQL = $conn->GetInsertSQL($rs, $record);
+
+$conn->Execute($insertSQL); # Insert the record into the database
+
+#==========================
+# This code tests an update
+
+$sql = "SELECT * FROM ADOXYZ WHERE id = 1";
+# Select a record to update
+
+$rs = $conn->Execute($sql); # Execute the query and get the existing record to update
+
+$record = array(); # Initialize an array to hold the record data to update
+
+# Set the values for the fields in the record
+# Note that field names are case-insensitive
+$record["firstname"] = "Caroline";
+$record["LasTnAme"] = "Smith"; # Update Caroline's lastname from Miranda to Smith
+
+# Pass the single record recordset and the array containing the data to update
+# into the GetUpdateSQL function. The function will process the data and return
+# a fully formatted update sql statement with the correct WHERE clause.
+# If the data has not changed, no recordset is returned
+$updateSQL = $conn->GetUpdateSQL($rs, $record);
+
+$conn->Execute($updateSQL); # Update the record in the database
+$conn->Close();
+?>
+</pre>
+GetInsertSQL/GetUpdateSQL ignore all empty fields (they are not added to the SQL generated).
+To explicitly force a field to be set to "null", set the constant define('ADODB_FORCE_NULLS',1) before
+you call the functions.
+<p>
+<h3>Example 8: Implementing Scrolling with Next and Previous<a name="ex8"></a></h3>
+<p> The following code creates a very simple recordset pager, where you can scroll
+ from page to page of a recordset.</p>
+<pre>
+include_once('../adodb.inc.php');
+include_once('../adodb-pager.inc.php');
+session_start();
+
+$db = NewADOConnection('mysql');
+
+$db->Connect('localhost','root','','xphplens');
+
+$sql = "select * from adoxyz ";
+
+$pager = new ADODB_Pager($db,$sql);
+$pager->Render($rows_per_page=5);</pre>
+<p>This will create a basic record pager that looks like this: <a name="scr"></a>
+<p>
+<table border=1 bgcolor=beige>
+ <tr>
+ <td> <a href="#scr"><code>|&lt;</code></a> &nbsp; <a href="#scr"><code>&lt;&lt;</code></a>
+ &nbsp; <a href="#scr"><code>>></code></a> &nbsp; <a href="#scr"><code>>|</code></a>
+ &nbsp; </td>
+ </tr>
+ <tr>
+ <td><TABLE COLS=4 width=100% border=1 bgcolor=white>
+ <TH>ID</TH>
+ <TH>First Name</TH>
+ <TH>Last Name</TH>
+ <TH>Date Created</TH>
+ <TR>
+ <TD align=right>36&nbsp;</TD>
+ <TD>Alan&nbsp;</TD>
+ <TD>Turing&nbsp;</TD>
+ <TD>Sat 06, Oct 2001&nbsp;</TD>
+ </TR>
+ <TR>
+ <TD align=right>37&nbsp;</TD>
+ <TD>Serena&nbsp;</TD>
+ <TD>Williams&nbsp;</TD>
+ <TD>Sat 06, Oct 2001&nbsp;</TD>
+ </TR>
+ <TR>
+ <TD align=right>38&nbsp;</TD>
+ <TD>Yat Sun&nbsp;</TD>
+ <TD>Sun&nbsp;</TD>
+ <TD>Sat 06, Oct 2001&nbsp;</TD>
+ </TR>
+ <TR>
+ <TD align=right>39&nbsp;</TD>
+ <TD>Wai Hun&nbsp;</TD>
+ <TD>See&nbsp;</TD>
+ <TD>Sat 06, Oct 2001&nbsp;</TD>
+ </TR>
+ <TR>
+ <TD align=right>40&nbsp;</TD>
+ <TD>Steven&nbsp;</TD>
+ <TD>Oey&nbsp;</TD>
+ <TD>Sat 06, Oct 2001&nbsp;</TD>
+ </TR>
+ </TABLE></td>
+ </tr>
+ <tr>
+ <td><font size=-1>Page 8/10</font></td>
+ </tr>
+</table>
+<p>The number of rows to display at one time is controled by the Render($rows)
+ method. If you do not pass any value to Render(), ADODB_Pager will default to
+ 10 records per page.
+<p>You can control the column titles by modifying your SQL (supported by most
+ databases):
+<pre>$sql = 'select id as &quot;ID&quot;, firstname as &quot;First Name&quot;,
+ lastname as &quot;Last Name&quot;, created as &quot;Date Created&quot; <br> from adoxyz';</pre>
+<p>The above code can be found in the <i>adodb/tests/testpaging.php</i> example
+ included with this release, and the class ADODB_Pager in <i>adodb/adodb-pager.inc.php</i>.
+ The ADODB_Pager code can be adapted by a programmer so that the text links can
+ be replaced by images, and the dull white background be replaced with more interesting
+ colors.
+<p>You can also allow display of html by setting $pager->htmlSpecialChars = false.
+<p>Some of the code used here was contributed by Iv&aacute;n Oliva and Cornel
+ G. </p>
+<h3><a name="ex9"></a>Example 9: Exporting in CSV or Tab-Delimited Format</h3>
+<p>We provide some helper functions to export in comma-separated-value (CSV) and
+ tab-delimited formats:</p>
+<pre><b>include_once('/path/to/adodb/toexport.inc.php');</b><br>include_once('/path/to/adodb/adodb.inc.php');<br>
+$db = &amp;NewADOConnection('mysql');<br>$db-&gt;Connect($server, $userid, $password, $database);<br><br>$rs = $db-&gt;Execute('select fname as &quot;First Name&quot;, surname as &quot;Surname&quot; from table');
+
+print &quot;&lt;pre&gt;&quot;;<br>print <b>rs2csv</b>($rs); # return a string, CSV format<p>print '&lt;hr&gt;';
+<br>$rs-&gt;MoveFirst(); # note, some databases do not support MoveFirst<br>print <b>rs2tab</b>($rs,<i>false</i>); # return a string, tab-delimited
+ # false == suppress field names in first line</p>print '&lt;hr&gt;';<br>$rs-&gt;MoveFirst();<br><b>rs2tabout</b>($rs); # send to stdout directly (there is also an rs2csvout function)
+print &quot;&lt;/pre&gt;&quot;;
+
+$rs-&gt;MoveFirst();<br><b></b>$fp = fopen($path, &quot;w&quot;);
+if ($fp) {<br> <b>rs2csvfile</b>($rs, $fp); # write to file (there is also an rs2tabfile function)
+ fclose($fp);<br>}
+</pre>
+<p> Carriage-returns or newlines are converted to spaces. Field names are returned
+ in the first line of text. Strings containing the delimiter character are quoted
+ with double-quotes. Double-quotes are double-quoted again. This conforms to
+ Excel import and export guide-lines.
+<p>All the above functions take as an optional last parameter, $addtitles which
+ defaults to <i>true</i>. When set to <i>false</i> field names in the first line
+ are suppressed. <br>
+<h3>Example 10: Recordset Filters<a name="ex10"></a></h3>
+<p>Sometimes we want to pre-process all rows in a recordset before we use it.
+ For example, we want to ucwords all text in recordset.
+<pre>
+include_once('adodb/rsfilter.inc.php');
+include_once('adodb/adodb.inc.php');
+
+// ucwords() every element in the recordset
+function do_ucwords(&$arr,$rs)
+&#123;
+ foreach($arr as $k => $v) &#123;
+ $arr[$k] = ucwords($v);
+ &#125;
+&#125;
+
+$db = NewADOConnection('mysql');
+$db->PConnect('server','user','pwd','db');
+
+$rs = $db->Execute('select ... from table');
+$rs = <b>RSFilter</b>($rs,'do_ucwords');
+</pre>
+<p>The <i>RSFilter</i> function takes 2 parameters, the recordset, and the name
+ of the <i>filter</i> function. It returns the processed recordset scrolled to
+ the first record. The <i>filter</i> function takes two parameters, the current
+ row as an array, and the recordset object. For future compatibility, you should
+ not use the original recordset object. </p>
+<h3>Example 11:<a name="ex11"></a> Smart Transactions</h3>
+The old way of doing transactions required you to use
+<pre>
+$conn-><b>BeginTrans</b>();
+$ok = $conn->Execute($sql);
+if ($ok) $ok = $conn->Execute($sql2);
+if (!$ok) $conn-><b>RollbackTrans</b>();
+else $conn-><b>CommitTrans</b>();
+</pre>
+This is very complicated for large projects because you have to track the error
+status. Smart Transactions is much simpler. You start a smart transaction by calling
+StartTrans():
+<pre>
+$conn-><b>StartTrans</b>();
+$conn->Execute($sql);
+$conn->Execute($Sql2);
+$conn-><b>CompleteTrans</b>();
+</pre>
+CompleteTrans() detects when an SQL error occurs, and will Rollback/Commit as
+appropriate. To specificly force a rollback even if no error occured, use FailTrans().
+Note that the rollback is done in CompleteTrans(), and not in FailTrans().
+<pre>
+$conn-><b>StartTrans</b>();
+$conn->Execute($sql);
+if (!CheckRecords()) $conn-><strong>FailTrans</strong>();
+$conn->Execute($Sql2);
+$conn-><b>CompleteTrans</b>();
+</pre>
+<p>You can also check if a transaction has failed, using HasFailedTrans(), which
+ returns true if FailTrans() was called, or there was an error in the SQL execution.
+ Make sure you call HasFailedTrans() before you call CompleteTrans(), as it is
+ only works between StartTrans/CompleteTrans.
+<p>Lastly, StartTrans/CompleteTrans is nestable, and only the outermost block
+ is executed. In contrast, BeginTrans/CommitTrans/RollbackTrans is NOT nestable.
+<pre>
+$conn-><strong>StartTrans</strong>();
+$conn->Execute($sql);
+ $conn-><strong>StartTrans</strong>(); <font color="#006600"># ignored</font>
+ if (!CheckRecords()) $conn->FailTrans();
+ $conn-><strong>CompleteTrans</strong>(); <font color="#006600"># ignored</font>
+$conn->Execute($Sql2);
+$conn-><strong>CompleteTrans</strong>();
+</pre>
+<p>Note: Savepoints are currently not supported.
+<h2><a name="errorhandling"></a>Using Custom Error Handlers and PEAR_Error</h2>
+Apart from the old $con->debug = true; way of debugging, ADOdb 1.50 onwards provides
+another way of handling errors using ADOdb's custom error handlers.
+<p> ADOdb provides two custom handlers which you can modify for your needs. The
+ first one is in the <b>adodb-errorhandler.inc.php</b> file. This makes use of
+ the standard PHP functions <a href=http://php.net/error_reporting>error_reporting</a>
+ to control what error messages types to display, and <a href=http://php.net/trigger_error>trigger_error</a>
+ which invokes the default PHP error handler.
+<p> Including the above file will cause <i>trigger_error($errorstring,E_USER_ERROR)</i>
+ to be called when<br>
+ (a) Connect() or PConnect() fails, or <br>
+ (b) a function that executes SQL statements such as Execute() or SelectLimit()
+ has an error.<br>
+ (c) GenID() appears to go into an infinite loop.
+<p> The $errorstring is generated by ADOdb and will contain useful debugging information
+ similar to the error.log data generated below. This file adodb-errorhandler.inc.php
+ should be included before you create any ADOConnection objects.
+<p> If you define error_reporting(0), no errors will be passed to the error handler.
+ If you set error_reporting(E_ALL), all errors will be passed to the error handler.
+ You still need to use <b>ini_set("display_errors", "0" or "1")</b> to control
+ the display of errors.
+<pre>
+&lt;?php
+<b>error_reporting(E_ALL); # pass any error messages triggered to error handler
+include('adodb-errorhandler.inc.php');</b>
+include('adodb.inc.php');
+include('tohtml.inc.php');
+$c = NewADOConnection('mysql');
+$c->PConnect('localhost','root','','northwind');
+$rs=$c->Execute('select * from productsz'); #invalid table productsz');
+if ($rs) rs2html($rs);
+?>
+</pre>
+<p> If you want to log the error message, you can do so by defining the following
+ optional constants ADODB_ERROR_LOG_TYPE and ADODB_ERROR_LOG_DEST. ADODB_ERROR_LOG_TYPE
+ is the error log message type (see <a href=http://php.net/error_log>error_log</a>
+ in the PHP manual). In this case we set it to 3, which means log to the file
+ defined by the constant ADODB_ERROR_LOG_DEST.
+<pre>
+&lt;?php
+<b>error_reporting(E_ALL); # report all errors
+ini_set("display_errors", "0"); # but do not echo the errors
+define('ADODB_ERROR_LOG_TYPE',3);
+define('ADODB_ERROR_LOG_DEST','C:/errors.log');
+include('adodb-errorhandler.inc.php');</b>
+include('adodb.inc.php');
+include('tohtml.inc.php');
+
+$c = NewADOConnection('mysql');
+$c->PConnect('localhost','root','','northwind');
+$rs=$c->Execute('select * from productsz'); ## invalid table productsz
+if ($rs) rs2html($rs);
+?>
+</pre>
+The following message will be logged in the error.log file:
+<pre>
+(2001-10-28 14:20:38) mysql error: [1146: Table 'northwind.productsz' doesn't exist] in
+ EXECUTE("select * from productsz")
+</pre>
+The second error handler is <b>adodb-errorpear.inc.php</b>. This will create a
+PEAR_Error derived object whenever an error occurs. The last PEAR_Error object
+created can be retrieved using ADODB_Pear_Error().
+<pre>
+&lt;?php
+<b>include('adodb-errorpear.inc.php');</b>
+include('adodb.inc.php');
+include('tohtml.inc.php');
+$c = NewADOConnection('mysql');
+$c->PConnect('localhost','root','','northwind');
+$rs=$c->Execute('select * from productsz'); #invalid table productsz');
+if ($rs) rs2html($rs);
+else &#123;
+ <b>$e = ADODB_Pear_Error();
+ echo '&lt;p>',$e->message,'&lt;/p>';</b>
+&#125;
+?>
+</pre>
+<p> You can use a PEAR_Error derived class by defining the constant ADODB_PEAR_ERROR_CLASS
+ before the adodb-errorpear.inc.php file is included. For easy debugging, you
+ can set the default error handler in the beginning of the PHP script to PEAR_ERROR_DIE,
+ which will cause an error message to be printed, then halt script execution:
+<pre>
+include('PEAR.php');
+PEAR::setErrorHandling('PEAR_ERROR_DIE');
+</pre>
+<p> Note that we do not explicitly return a PEAR_Error object to you when an error
+ occurs. We return false instead. You have to call ADODB_Pear_Error() to get
+ the last error or use the PEAR_ERROR_DIE technique.
+<h4>Error Messages</h4>
+<p>Error messages are outputted using the static method ADOConnnection::outp($msg,$newline=true).
+ By default, it sends the messages to the client. You can override this to perform
+ error-logging.
+<h2><a name="dsn"></a> Data Source Names</h2>
+<p>We now support connecting using PEAR style DSN's. A DSN is a connection string
+ of the form:</p>
+<p>$dsn = <i>&quot;$driver://$username:$password@$hostname/$databasename&quot;</i>;</p>
+<p>You pass the DSN to the static class function DB::Connect. An example:</p>
+<pre> include_once('../adodb/adodb-pear.inc.php');
+ $username = 'root';
+ $password = '';
+ $hostname = 'localhost';
+ $databasename = 'xphplens';
+ $driver = 'mysql';
+ $dsn = &quot;$driver://$username:$password@$hostname/$databasename&quot;;</pre>
+<pre> $db = DB::Connect($dsn);<br> $rs = $db-&gt;query('select firstname,lastname from adoxyz');
+ $cnt = 0;
+ while ($arr = $rs-&gt;fetchRow()) {
+ print_r($arr); print &quot;&lt;br&gt;&quot;;
+ }</pre>
+<p>This requires PEAR to be installed and in the default include path in php.ini.</p>
+ <h2><a name="pear"></a>PEAR Compatibility</h2>
+ We support DSN's (see above), and the following functions:
+ <pre>
+<b> DB_Common</b>
+ query - returns PEAR_Error on error
+ limitQuery - return PEAR_Error on error
+ prepare - does not return PEAR_Error on error
+ execute - does not return PEAR_Error on error
+ setFetchMode - supports ASSOC and ORDERED
+ errorNative
+ quote
+ nextID
+ disconnect
+
+ getOne
+ getAssoc
+ getRow
+ getCol
+
+<b> DB_Result</b>
+ numRows - returns -1 if not supported
+ numCols
+ fetchInto - does not support passing of fetchmode
+ fetchRows - does not support passing of fetchmode
+ free
+</pre>
+<h2><a name="caching"></a>Caching of Recordsets</h2>
+<p>ADOdb now supports caching of recordsets using the CacheExecute( ), CachePageExecute(
+ ) and CacheSelectLimit( ) functions. There are similar to the non-cache functions,
+ except that they take a new first parameter, $secs2cache.
+<p> An example:
+<pre>
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$ADODB_CACHE_DIR = '/usr/ADODB_cache';
+$<font color="#663300">conn</font> = &amp;ADONewConnection('mysql'); # create a connection
+$<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
+<font color="#000000">$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers';
+$<font color="#663300">rs</font> = $<font color="#663300">conn</font>->CacheExecute(15,$sql);</font></pre>
+<p><font color="#000000"> The first parameter is the number of seconds to cache
+ the query. Subsequent calls to that query will used the cached version stored
+ in $ADODB_CACHE_DIR. To force a query to execute and flush the cache, call CacheExecute()
+ with the first parameter set to zero. Alternatively, use the CacheFlush($sql)
+ call. </font></p>
+<p><font color="#000000">For the sake of security, we recommend you set <i>register_globals=off</i>
+ in php.ini if you are using $ADODB_CACHE_DIR.</font></p>
+<p>In ADOdb 1.80 onwards, the secs2cache parameter is optional in CacheSelectLimit()
+ and CacheExecute(). If you leave it out, it will use the $connection->cacheSecs
+ parameter, which defaults to 60 minutes.
+<pre>
+ $conn->Connect(...);
+ $conn->cacheSecs = 3600*24; # cache 24 hours
+ $rs = $conn->CacheExecute('select * from table');
+</pre>
+<p>Please note that magic_quotes_runtime should be turned off. <a href=http://phplens.com/lens/lensforum/msgs.php?LeNs#LensBM_forummsg>More
+ info</a>, and do not change $ADODB_FETCH_MODE (or SetFetchMode)
+ as the cached recordset will use the $ADODB_FETCH_MODE set when the query was executed. <font color="#000000">
+<h2><a name="pivot"></a>Pivot Tables</h2>
+</font> <p><font color="#000000">Since ADOdb 2.30, we support the generation of
+SQL to create pivot tables, also known as cross-tabulations. For further explanation
+read this DevShed <a href=http://www.devshed.com/Server_Side/MySQL/MySQLWiz/>Cross-Tabulation
+tutorial. We assume that your database supports the SQL case-when expression. </font></p>
+<font color="#000000">
+<p>In this example, we will use the Northwind database from Microsoft. In the
+ database, we have a products table, and we want to analyze this table by <i>suppliers
+ versus product categories</i>. We will place the suppliers on each row, and
+ pivot on categories. So from the table on the left, we generate the pivot-table
+ on the right:</p>
+</font>
+<table border="0" cellspacing="2" cellpadding="2" align="center">
+ <tr>
+ <td>
+ <table border="1" cellspacing="2" cellpadding="2" align="center" width="142">
+ <tr>
+ <td><i>Supplier</i></td>
+ <td><i>Category</i></td>
+ </tr>
+ <tr>
+ <td>supplier1</td>
+ <td>category1</td>
+ </tr>
+ <tr>
+ <td>supplier2</td>
+ <td>category1</td>
+ </tr>
+ <tr>
+ <td>supplier2</td>
+ <td>category2</td>
+ </tr>
+ </table>
+ </td>
+ <td> <font face="Courier New, Courier, mono">--&gt;</font></td>
+ <td>
+ <table border="1" cellspacing="2" cellpadding="2" align="center">
+ <tr>
+ <td>&nbsp;</td>
+ <td><i>category1</i></td>
+ <td><i>category2</i></td>
+ <td><i>total</i></td>
+ </tr>
+ <tr>
+ <td><i>supplier1</i></td>
+ <td align="right">1</td>
+ <td align="right">0</td>
+ <td align="right">1</td>
+ </tr>
+ <tr>
+ <td><i>supplier2</i></td>
+ <td align="right">1</td>
+ <td align="right">1</td>
+ <td align="right">2</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<font color="#000000">
+<p>The following code will generate the SQL for a cross-tabulation:
+<pre>
+# Query the main "product" table
+# Set the rows to CompanyName
+# and the columns to the values of Categories
+# and define the joins to link to lookup tables
+# "categories" and "suppliers"
+#
+ include &quot;adodb/pivottable.php&quot;;
+ $sql = PivotTableSQL(
+ $gDB, # adodb connection
+ 'products p ,categories c ,suppliers s', # tables
+ 'CompanyName', # rows (multiple fields allowed)
+ 'CategoryName', # column to pivot on
+ 'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where
+);
+</pre>
+</font>
+<p><font color="#000000"> This will generate the following SQL:</font></p>
+<p><code><font size="2">SELECT CompanyName, <br>
+ SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS &quot;Beverages&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS &quot;Condiments&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS &quot;Confections&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS &quot;Dairy
+ Products&quot;, <br>
+ SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS &quot;Grains/Cereals&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS &quot;Meat/Poultry&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS &quot;Produce&quot;,
+ <br>
+ SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS &quot;Seafood&quot;,
+ <br>
+ SUM(1) as Total <br>
+ FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID
+ and s.SupplierID= p.SupplierID <br>
+ GROUP BY CompanyName</font></code></p>
+<p> You can also pivot on <i>numerical columns</i> and <i>generate totals</i>
+ by using ranges. <font color="#000000">This code was revised in ADODB 2.41
+ and is not backward compatible.</font> The second example shows this:</p>
+<pre>
+ $sql = PivotTableSQL(
+ $gDB, # adodb connection
+ 'products p ,categories c ,suppliers s', # tables
+ 'CompanyName', #<font color="#000000"> rows (multiple fields allowed)</font>
+ array( # column ranges
+ ' 0 ' => 'UnitsInStock <= 0',
+ "1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5',
+ "6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10',
+ "11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15',
+ "16+" => '15 < UnitsInStock'
+ ),
+ ' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
+ 'UnitsInStock', # sum this field
+ 'Sum ' # sum label prefix
+);
+</pre>
+<p>Which generates: </p>
+<p> <code> <font size="2">SELECT CompanyName, <br>
+ SUM(CASE WHEN UnitsInStock &lt;= 0 THEN UnitsInStock ELSE 0 END) AS &quot;Sum
+ 0 &quot;, <br>
+ SUM(CASE WHEN 0 &lt; UnitsInStock and UnitsInStock &lt;= 5 THEN UnitsInStock
+ ELSE 0 END) AS &quot;Sum 1 to 5&quot;,<br>
+ SUM(CASE WHEN 5 &lt; UnitsInStock and UnitsInStock &lt;= 10 THEN UnitsInStock
+ ELSE 0 END) AS &quot;Sum 6 to 10&quot;,<br>
+ SUM(CASE WHEN 10 &lt; UnitsInStock and UnitsInStock &lt;= 15 THEN UnitsInStock
+ ELSE 0 END) AS &quot;Sum 11 to 15&quot;, <br>
+ SUM(CASE WHEN 15 &lt; UnitsInStock THEN UnitsInStock ELSE 0 END) AS &quot;Sum
+ 16+&quot;, <br>
+ SUM(UnitsInStock) AS "Sum UnitsInStock", <br>
+ SUM(1) as Total,<br>
+ FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID
+ and s.SupplierID= p.SupplierID <br>
+ GROUP BY CompanyName</font></code><font size="2"><br>
+ </font> </p>
+<font color="#000000"><hr>
+<h1>Class Reference<a name="ref"></a></h1>
+<p>Function parameters with [ ] around them are optional.</p>
+</font>
+<h2>Global Variables</h2>
+<h3><font color="#000000"><a name="adodb_countrecs"></a></font>$ADODB_COUNTRECS</h3>
+<p>If the database driver API does not support counting the number of records
+ returned in a SELECT statement, the function RecordCount() is emulated when
+ the global variable $ADODB_COUNTRECS is set to true, which is the default.
+ We emulate this by buffering the records, which can take up large amounts
+ of memory for big recordsets. Set this variable to false for the best performance.
+ This variable is checked every time a query is executed, so you can selectively
+ choose which recordsets to count.</p>
+<h3><font color="#000000"><a name="adodb_cache_dir"></a>$ADODB_CACHE_DIR</font></h3>
+<font color="#000000">
+<p>If you are using recordset caching, this is the directory to save your recordsets
+ in. Define this before you call any caching functions such as CacheExecute(
+ ). We recommend setting <i>register_globals=off</i> in php.ini if you use this
+ feature for security reasons.</p>
+<p>If you are using Unix and apache, you might need to set your cache directory
+ permissions to something similar to the following:</p>
+</font>
+<p>chown -R apache /path/to/adodb/cache<br>
+ chgrp -R apache /path/to/adodb/cache </p>
+<font color="#000000">
+<h3><a name="adodb_ansi_padding_off"></a>$ADODB_ANSI_PADDING_OFF</h3>
+<p>Determines whether to right trim CHAR fields (and also VARCHAR for ibase/firebird).
+Set to true to trim. Default is false. Currently works for oci8po, ibase and firebird
+drivers. Added in ADOdb 4.01.
+<h3><font color="#000000"><a name="adodb_lang"></a></font>$ADODB_LANG</h3>
+<p>Determines the language used in MetaErrorMsg(). The default is 'en', for English.
+To find out what languages are supported, see the files
+in adodb/lang/adodb-$lang.inc.php, where $lang is the supported langauge.
+<h3><a name="adodb_fetch_mode"></a>$ADODB_FETCH_MODE</h3>
+<p>This is a global variable that determines how arrays are retrieved by recordsets.
+ The recordset saves this value on creation (eg. in Execute( ) or SelectLimit(
+ )), and any subsequent changes to $ADODB_FETCH_MODE have no affect on existing
+ recordsets, only on recordsets created in the future.</p>
+<p>The following constants are defined:</p>
+</font>
+<p><font color="#000000">define('ADODB_FETCH_DEFAULT',0);<br>
+ define('ADODB_FETCH_NUM',1);<br>
+ define('ADODB_FETCH_ASSOC',2);<br>
+ define('ADODB_FETCH_BOTH',3); </font></p>
+<font color="#000000">
+<p> An example:
+<pre>
+ $ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_NUM;
+ $rs1 = $db->Execute('select * from table');
+ $ADODB_<b>FETCH_MODE</b> = ADODB_FETCH_ASSOC;
+ $rs2 = $db->Execute('select * from table');
+ print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i>
+ print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
+</pre>
+<p> As you can see in the above example, both recordsets store and use different
+ fetch modes based on the $ADODB_FETCH_MODE setting when the recordset was
+ created by Execute().</p>
+<p>If no fetch mode is predefined, the fetch mode defaults to ADODB_FETCH_DEFAULT.
+ The behaviour of this default mode varies from driver to driver, so do not
+ rely on ADODB_FETCH_DEFAULT. For portability, we recommend sticking to ADODB_FETCH_NUM
+ or ADODB_FETCH_ASSOC. Many drivers do not support ADODB_FETCH_BOTH.</p>
+<p><strong>SetFetchMode Function</strong></p>
+<p>Some programmers prefer to use a more object-oriented solution, where the fetch
+ mode is set by a object function, <a href="#setfetchmode">SetFetchMode</a>.
+ Once this function is called for a connection object, that connection object
+ will ignore the global variable $ADODB_FETCH_MODE and will use the internal
+ fetchMode property exclusively.</p>
+<pre>
+ $db->SetFetchMode(ADODB_FETCH_NUM);
+ $rs1 = $db->Execute('select * from table');
+ $db->SetFetchMode(ADODB_FETCH_ASSOC);
+ $rs2 = $db->Execute('select * from table');
+ print_r($rs1->fields); # shows <i>array([0]=>'v0',[1] =>'v1')</i>
+ print_r($rs2->fields); # shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i></pre>
+<p>To retrieve the previous fetch mode, you can use check the $db-&gt;fetchMode
+ property, or use the return value of SetFetchMode( ).
+<p><strong><a name="adodb_assoc_case"></a>ADODB_ASSOC_CASE</strong></p>
+<p>You can control the associative fetch case for certain drivers which behave
+ differently. For the sybase, oci8po, mssql, odbc and ibase drivers and all
+ drivers derived from them, ADODB_ASSOC_CASE will by default generate recordsets
+ where the field name keys are lower-cased. Use the constant ADODB_ASSOC_CASE
+ to change the case of the keys. There are 3 possible values:</p>
+<p>0 = assoc lowercase field names. $rs-&gt;fields['orderid']<br>
+ 1 = assoc uppercase field names. $rs-&gt;fields['ORDERID']<br>
+ 2 = use native-case field names. $rs-&gt;fields['OrderID'] -- this is the
+ default since ADOdb 2.90</p>
+<p>To use it, declare it before you incldue adodb.inc.php.</p>
+<p>define('ADODB_ASSOC_CASE', 2); # use native-case for ADODB_FETCH_ASSOC<br>
+ include('adodb.inc.php'); </p>
+<hr>
+<h2>ADOConnection<a name="adoconnection"></a></h2>
+<p>Object that performs the connection to the database, executes SQL statements
+ and has a set of utility functions for standardising the format of SQL statements
+ for issues such as concatenation and date formats.</p>
+<h3>ADOConnection Fields</h3>
+<p><b>databaseType</b>: Name of the database system we are connecting to. Eg.
+ <b>odbc</b> or <b>mssql</b> or <b>mysql</b>.</p>
+<p><b>dataProvider</b>: The underlying mechanism used to connect to the database.
+ Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
+<p><b>host: </b>Name of server or data source name (DSN) to connect to.</p>
+<p><b>database</b>: Name of the database or to connect to. If ado is used, it
+ will hold the ado data provider.</p>
+<p><b>user</b>: Login id to connect to database. Password is not saved for security
+ reasons.</p>
+<p><b>raiseErrorFn</b>: Allows you to define an error handling function. See adodb-errorhandler.inc.php
+ for an example.</p>
+<p><b>debug</b>: Set to <i>true</i> to make debug statements to appear.</p>
+<p><b>concat_operator</b>: Set to '+' or '||' normally. The operator used to concatenate
+ strings in SQL. Used by the <b><a href="#concat">Concat</a></b> function.</p>
+<p><b>fmtDate</b>: The format used by the <b><a href="#dbdate">DBDate</a></b>
+ function to send dates to the database. is '#Y-m-d#' for Microsoft Access,
+ and ''Y-m-d'' for MySQL.</p>
+<p><b>fmtTimeStamp: </b>The format used by the <b><a href="#dbtimestamp">DBTimeStamp</a></b>
+ function to send timestamps to the database. </p>
+<p><b>true</b>: The value used to represent true.Eg. '.T.'. for Foxpro, '1' for
+ Microsoft SQL.</p>
+<p><b>false: </b> The value used to represent false. Eg. '.F.'. for Foxpro, '0'
+ for Microsoft SQL.</p>
+<p><b>replaceQuote</b>: The string used to escape quotes. Eg. double single-quotes
+ for Microsoft SQL, and backslash-quote for MySQL. Used by <a href="#qstr">qstr</a>.</p>
+<p><b>autoCommit</b>: indicates whether automatic commit is enabled. Default is
+ true.</p>
+<p><b>charSet</b>: set the default charset to use. Currently only interbase supports
+ this.</p>
+<p><b>dialect</b>: set the default sql dialect to use. Currently only interbase
+ supports this.</p>
+<p><b>metaTablesSQL</b>: SQL statement to return a list of available tables. Eg.
+ <i>SHOW TABLES</i> in MySQL.</p>
+<p><b>genID</b>: The latest id generated by GenID() if supported by the database.</p>
+<p><b>cacheSecs</b>: The number of seconds to cache recordsets if CacheExecute()
+ or CacheSelectLimit() omit the $secs2cache parameter. Defaults to 60 minutes.</p>
+<p><b>sysDate</b>: String that holds the name of the database function to call
+ to get the current date. Useful for inserts and updates.</p>
+<p><b>sysTimeStamp</b>: String that holds the name of the database function to
+ call to get the current timestamp/datetime value.</p>
+<p><b>leftOuter</b>: String that holds operator for left outer join, if known.
+ Otherwise set to false.</p>
+<p><b>rightOuter</b>: String that holds operator for left outer join, if known.
+ Otherwise set to false.</p>
+<p><b>ansiOuter</b>: Boolean that if true indicates that ANSI style outer joins
+ are permitted. Eg. <i>select * from table1 left join table2 on p1=p2.</i></p>
+<p><b>connectSID</b>: Boolean that indicates whether to treat the $database parameter
+ in connects as the SID for the oci8 driver. Defaults to false. Useful for
+ Oracle 8.0.5 and earlier.</p>
+<p><b>autoRollback</b>: Persistent connections are auto-rollbacked in PConnect(
+ ) if this is set to true. Default is false.</p>
+<hr>
+<h3>ADOConnection Main Functions</h3>
+<p><b>ADOConnection( )</b></p>
+<p>Constructor function. Do not call this directly. Use ADONewConnection( ) instead.</p>
+<p><b>Connect<a name="connect"></a>($host,[$user],[$password],[$database])</b></p>
+<p>Non-persistent connect to data source or server $<b>host</b>, using userid
+ $<b>user </b>and password $<b>password</b>. If the server supports multiple
+ databases, connect to database $<b>database</b>. </p>
+<p>Returns true/false depending on connection success. Since 4.23, null is returned if the extension is not loaded.</p>
+<p>ADO Note: If you are using a Microsoft ADO and not OLEDB, you can set the $database
+ parameter to the OLEDB data provider you are using.</p>
+<p>PostgreSQL: An alternative way of connecting to the database is to pass the
+ standard PostgreSQL connection string in the first parameter $host, and the
+ other parameters will be ignored.</p>
+<p>For Oracle and Oci8, there are two ways to connect. First is to use the TNS
+ name defined in your local tnsnames.ora (or ONAMES or HOSTNAMES). Place the
+ name in the $database field, and set the $host field to false. Alternatively,
+ set $host to the server, and $database to the database SID, this bypassed
+ tnsnames.ora.
+<p>Examples:
+<pre> # $oraname in tnsnames.ora/ONAMES/HOSTNAMES
+ $conn->Connect(false, 'scott', 'tiger', $oraname);
+ $conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora</pre>
+<p>There are many examples of connecting to a database.
+See <a href=#connect_ex>Connection Examples</a>, <a href="http://php.weblogs.com/adodb">php.weblogs.com/ADOdb</a>,
+ and in the testdatabases.inc.php file included in the release.</p>
+
+<p><b>PConnect<a name="pconnect"></a>($host,[$user],[$password],[$database])</b></p>
+<p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b>
+ and password $<b>password</b>. If the server supports multiple databases,
+ connect to database $<b>database</b>.</p>
+<p>We now perform a rollback on persistent connection for selected databases since
+ 2.21, as advised in the PHP manual. See change log or source code for which
+ databases are affected.
+<p>Returns true/false depending on connection. Since 4.23, null is returned if the extension is not loaded.
+See Connect( ) above for more info.</p>
+<p>Since ADOdb 2.21, we also support autoRollback. If you set:</p>
+</font>
+<pre> $conn = &amp;NewADOConnection('mysql');
+ $conn-&gt;autoRollback = true; # default is false
+ $conn-&gt;PConnect(...); # rollback here</pre>
+<p> Then when doing a persistent connection with PConnect( ), ADOdb will
+ perform a rollback first. This is because it is documented that PHP is
+ not guaranteed to rollback existing failed transactions when
+ persistent connections are used. This is implemented in Oracle,
+ MySQL, PgSQL, MSSQL, ODBC currently.
+<p>Since ADOdb 3.11, you can force non-persistent
+connections even if PConnect is called by defining the constant
+ADODB_NEVER_PERSIST before you call PConnect.
+<p>
+Since 4.23, null is returned if the extension is not loaded.
+<p><b>NConnect<a name="nconnect"></a>($host,[$user],[$password],[$database])</b></p>
+<p>Always force a new connection. In contrast, PHP sometimes reuses connections
+ when you use Connect() or PConnect(). Currently works only on mysql (PHP 4.3.0
+ or later), postgresql and oci8-derived drivers. For other drivers, NConnect() works like
+ Connect().
+<font color="#000000">
+<p><b>Execute<a name="execute"></a>($sql,$inputarr=false)</b></p>
+<p>Execute SQL statement $<b>sql</b> and return derived class of ADORecordSet
+ if successful. Note that a record set is always returned on success, even
+ if we are executing an insert or update statement. You can also pass in $sql a statement prepared
+ in <a href=#prepare>Prepare()</a>.</p>
+<p>Returns derived class of ADORecordSet. Eg. if connecting via mysql, then ADORecordSet_mysql
+ would be returned. False is returned if there was an error in executing the
+ sql.</p>
+<p>The $inputarr parameter can be used for binding variables to parameters. Below
+ is an Oracle example:</p>
+<pre>
+ $conn->Execute("SELECT * FROM TABLE WHERE COND=:val", array('val'=> $val));
+ </pre>
+<p>Another example, using ODBC,which uses the ? convention:</p>
+<pre>
+ $conn->Execute("SELECT * FROM TABLE WHERE COND=?", array($val));
+</pre>
+<a name="binding"></a>
+<i>Binding variables</i><p>
+Variable binding speeds the compilation and caching of SQL statements, leading
+to higher performance. Currently Oracle, Interbase and ODBC supports variable binding.
+Interbase/ODBC style ? binding is emulated in databases that do not support binding.
+Note that you do not have to quote strings if you use binding.
+<p> Variable binding in the odbc, interbase and oci8po drivers.
+<pre>
+$rs = $db->Execute('select * from table where val=?', array('10'));
+</pre>
+Variable binding in the oci8 driver:
+<pre>
+$rs = $db->Execute('select name from table where val=:key',
+ array('key' => 10));
+</pre>
+<a name="bulkbind"></a>
+<i>Bulk binding</i>
+<p>Since ADOdb 3.80, we support bulk binding in Execute(), in which you pass in a 2-dimensional array to
+be bound to an INSERT/UPDATE or DELETE statement.
+<pre>
+$arr = array(
+ array('Ahmad',32),
+ array('Zulkifli', 24),
+ array('Rosnah', 21)
+ );
+$ok = $db->Execute('insert into table (name,age) values (?,?)',$arr);
+</pre>
+<p>This provides very high performance as the SQL statement is prepared first.
+The prepared statement is executed repeatedly for each array row until all rows are completed,
+or until the first error. Very useful for importing data.
+
+<p><b>CacheExecute<a name="cacheexecute"></a>([$secs2cache,]$sql,$inputarr=false)</b></p>
+<p>Similar to Execute, except that the recordset is cached for $secs2cache seconds
+ in the $ADODB_CACHE_DIR directory, and $inputarr only accepts 1-dimensional arrays.
+ If CacheExecute() is called again with the same $sql, $inputarr,
+ and also the same database, same userid, and the cached recordset
+ has not expired, the cached recordset is returned.
+<pre>
+ include('adodb.inc.php');
+ include('tohtml.inc.php');
+ $ADODB_<b>CACHE_DIR</b> = '/usr/local/ADOdbcache';
+ $conn = &ADONewConnection('mysql');
+ $conn->PConnect('localhost','userid','password','database');
+ $rs = $conn-><b>CacheExecute</b>(15, 'select * from table'); # cache 15 secs
+ rs2html($rs); /* recordset to html table */
+</pre>
+<p> Alternatively, since ADOdb 1.80, the $secs2cache parameter is optional:</p>
+<pre> $conn-&gt;Connect(...);
+ $conn-&gt;cacheSecs = 3600*24; // cache 24 hours
+ $rs = $conn-&gt;CacheExecute('select * from table');
+</pre>
+If $secs2cache is omitted, we use the value
+in $connection-&gt;cacheSecs (default is 3600 seconds, or 1 hour). Use CacheExecute()
+only with SELECT statements.
+<p>Performance note: I have done some benchmarks and found that they vary so greatly
+ that it's better to talk about when caching is of benefit. When your database
+ server is <i>much slower </i>than your Web server or the database is <i>very
+ overloaded </i>then ADOdb's caching is good because it reduces the load on
+ your database server. If your database server is lightly loaded or much faster
+ than your Web server, then caching could actually reduce performance. </p>
+<p><b>ExecuteCursor<a name="executecursor"></a>($sql,$cursorName='rs',$parameters=false)</b></p>
+<p>Execute an Oracle stored procedure, and returns an Oracle REF cursor variable as
+ a regular ADOdb recordset. Does not work with any other database except oci8.
+ Thanks to Robert Tuttle for the design.
+<pre>
+ $db = ADONewConnection("oci8");
+ $db->Connect("foo.com:1521", "uid", "pwd", "FOO");
+ $rs = $db->ExecuteCursor("begin :cursorvar := getdata(:param1); end;",
+ 'cursorvar',
+ array('param1'=>10));
+ # $rs is now just like any other ADOdb recordset object<br> rs2html($rs);</pre>
+<p>ExecuteCursor() is a helper function that does the following internally:
+<pre>
+ $stmt = $db->Prepare("BEGIN :RS := SP_FOO(); END;", true);
+ $db->Parameter($stmt, $cur, 'RS', false, -1, OCI_B_CURSOR);
+ $rs = $db->Execute($stmt);</pre>
+<p><b>SelectLimit<a name="selectlimit"></a>($sql,$numrows=-1,$offset=-1,$inputarr=false)</b></p>
+<p>Returns a recordset if successful. Returns false otherwise. Performs a select
+ statement, simulating PostgreSQL's SELECT statement, LIMIT $numrows OFFSET
+ $offset clause.</p>
+<p>In PostgreSQL, SELECT * FROM TABLE LIMIT 3 will return the first 3 records
+ only. The equivalent is <code>$connection->SelectLimit('SELECT * FROM TABLE',3)</code>.
+ This functionality is simulated for databases that do not possess this feature.</p>
+<p>And SELECT * FROM TABLE LIMIT 3 OFFSET 2 will return records 3, 4 and 5 (eg.
+ after record 2, return 3 rows). The equivalent in ADOdb is <code>$connection->SelectLimit('SELECT
+ * FROM TABLE',3,2)</code>.</p>
+<p>Note that this is the <i>opposite</i> of MySQL's LIMIT clause. You can also
+ set <code>$connection->SelectLimit('SELECT * FROM TABLE',-1,10)</code> to
+ get rows 11 to the last row.</p>
+<p>The last parameter $inputarr is for databases that support variable binding
+ such as Oracle oci8. This substantially reduces SQL compilation overhead.
+ Below is an Oracle example:</p>
+<pre>
+ $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=:val", 100,-1,array('val'=> $val));
+ </pre>
+<p>The oci8po driver (oracle portable driver) uses the more standard bind variable
+ of ?:
+<pre>
+ $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=?", 100,-1,array('val'=> $val));
+</pre>
+<p>
+<p>Ron Wilson reports that SelectLimit does not work with UNIONs.
+<p><b>CacheSelectLimit<a name="cacheselectlimit"></a>([$secs2cache,] $sql, $numrows=-1,$offset=-1,$inputarr=false)</b></p>
+<p>Similar to SelectLimit, except that the recordset returned is cached for $secs2cache
+ seconds in the $ADODB_CACHE_DIR directory. </p>
+<p>Since 1.80, $secs2cache has been optional, and you can define the caching time
+ in $connection-&gt;cacheSecs.</p>
+</font>
+<pre><font color="#000000"> $conn-&gt;Connect(...);
+ $conn-&gt;cacheSecs = 3600*24; // cache 24 hours
+ $rs = $conn-&gt;CacheSelectLimit('select * from table',10);</font></pre>
+<font color="#000000">
+<p><b>CacheFlush<a name="cacheflush"></a>($sql=false,$inputarr=false)</b></p>
+<p>Flush (delete) any cached recordsets for the SQL statement $sql in $ADODB_CACHE_DIR.
+<p>If no parameter is passed in, then all adodb_*.cache files are deleted.
+<p> If you want to flush all cached recordsets manually, execute the following
+ PHP code (works only under Unix): <br>
+ <code> &nbsp; system(&quot;rm -f `find &quot;.$ADODB_CACHE_DIR.&quot; -name
+ adodb_*.cache`&quot;);</code></p>
+<p>For general cleanup of all expired files, you should use <a href="http://www.superscripts.com/tutorial/crontab.html">crontab</a>
+ on Unix, or at.exe on Windows, and a shell script similar to the following:<font face="Courier New, Courier, mono"><br>
+ #------------------------------------------------------ <br>
+ # This particular example deletes files in the TMPPATH <br>
+ # directory with the string &quot;.cache&quot; in their name that <br>
+ # are more than 7 days old. <br>
+ #------------------------------------------------------ <br>
+ AGED=7 <br>
+ find ${TMPPATH} -mtime +$AGED | grep &quot;\.cache&quot; | xargs rm -f <br>
+ </font> </p>
+<p><b>MetaError<a name="metaerror"></a>($errno=false)</b></p>
+<p>Returns a virtualized error number, based on PEAR DB's error number system. You might
+need to include adodb-error.inc.php before you call this function. The parameter $errno
+is the native error number you want to convert. If you do not pass any parameter, MetaError
+will call ErrorNo() for you and convert it. If the error number cannot be virtualized, MetaError
+will return -1 (DB_ERROR).</p>
+
+<p><b>MetaErrorMsg<a name="metaerrormsg"></a>($errno)</b></p>
+<p>Pass the error number returned by MetaError() for the equivalent textual error message.</p>
+<p><b>ErrorMsg<a name="errormsg"></a>()</b></p>
+<p>Returns the last status or error message. The error message is reset after every
+call to Execute().
+<p>
+This can return a string even if
+ no error occurs. In general you do not need to call this function unless an
+ ADOdb function returns false on an error. </p>
+<p>Note: If <b>debug</b> is enabled, the SQL error message is always displayed
+ when the <b>Execute</b> function is called.</p>
+<p><b>ErrorNo<a name="errorno"></a>()</b></p>
+<p>Returns the last error number. The error number is reset after every call to Execute().
+If 0 is returned, no error occurred.
+<p>
+Note that old versions of PHP (pre 4.0.6) do
+ not support error number for ODBC. In general you do not need to call this
+ function unless an ADOdb function returns false on an error.</p>
+</font>
+<p><font color="#000000"><b>SetFetchMode<a name="setfetchmode"></a>($mode)</b></font></p>
+<p><font color="#000000">Sets the current fetch mode for the connection and stores
+ it in $db-&gt;fetchMode. Legal modes are ADODB_FETCH_ASSOC and ADODB_FETCH_NUM.
+ For more info, see <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>.</font></p>
+<p><font color="#000000">Returns the previous fetch mode, which could be false
+ if SetFetchMode( ) has not been called before.</font></p>
+<font color="#000000">
+<p><b>CreateSequence<a name="createseq"></a>($seqName = 'adodbseq',$startID=1)</b></p>
+<p>Create a sequence. The next time GenID( ) is called, the value returned will
+ be $startID. Added in 2.60.
+<p><b>DropSequenceD<a name="dropseq"></a>($seqName = 'adodbseq')</b></p>
+<p>Delete a sequence. Added in 2.60.
+<p><b>GenID<a name="genid"></a>($seqName = 'adodbseq',$startID=1)</b></p>
+<p>Generate a sequence number . Works for interbase,
+ mysql, postgresql, oci8, oci8po, mssql, ODBC based (access,vfp,db2,etc) drivers
+ currently. Uses $seqName as the name of the sequence. GenID() will automatically
+ create the sequence for you if it does not exist (provided the userid has
+ permission to do so). Otherwise you will have to create the sequence yourself.
+<p> If your database driver emulates sequences, the name of the table is the sequence
+ name. The table has one column, "id" which should be of type integer, or if
+ you need something larger - numeric(16).
+<p> For ODBC and databases that do not support sequences natively (eg mssql, mysql),
+ we create a table for each sequence. If the sequence has not been defined
+ earlier, it is created with the starting value set in $startID.</p>
+<p>Note that the mssql driver's GenID() before 1.90 used to generate 16 byte GUID's.</p>
+<p><b>UpdateBlob<a name="updateblob"></a>($table,$column,$val,$where)</b></p>
+Allows you to store a blob (in $val) into $table into $column in a row at $where.
+<p> Usage:
+<p>
+<pre>
+ # for oracle
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, empty_blob())');
+ $conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
+
+ # non oracle databases
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
+</pre>
+<p> Returns true if succesful, false otherwise. Supported by MySQL, PostgreSQL,
+ Oci8, Oci8po and Interbase drivers. Other drivers might work, depending on
+ the state of development.</p>
+<p>Note that when an Interbase blob is retrieved using SELECT, it still needs
+ to be decoded using $connection->DecodeBlob($blob); to derive the original
+ value in versions of PHP before 4.1.0.
+<p>For PostgreSQL, you can store your blob using blob oid's or as a bytea field.
+ You can use bytea fields but not blob oid's currently with UpdateBlob( ).
+ Conversely UpdateBlobFile( ) supports oid's, but not bytea data.<br>
+ <br>
+ If you do not pass in an oid, then UpdateBlob() assumes that you are storing
+ in bytea fields.
+<p><b>UpdateClob<a name="updateclob"></a>($table,$column,$val,$where)</b></p>
+Allows you to store a clob (in $val) into $table into $column in a row at $where.
+Similar to UpdateBlob (see above), but for Character Large OBjects.
+<p> Usage:
+<pre>
+ # for oracle
+ $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, empty_clob())');
+ $conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');
+
+ # non oracle databases
+ $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
+ $conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');
+</pre>
+<p><b>UpdateBlobFile<a name="updateblobfile"></a>($table,$column,$path,$where,$blobtype='BLOB')</b></p>
+<p>Similar to UpdateBlob, except that we pass in a file path to where the blob
+ resides.
+<p>For PostgreSQL, if you are using blob oid's, use this interface. This interface
+ does not support bytea fields.
+<p>Returns true if successful, false otherwise.
+<p><b>BlobEncode<a name="blobencode" id="blobencode"></a>($blob)</b>
+<p>Some databases require blob's to be encoded manually before upload. Note if
+ you use UpdateBlob( ) or UpdateBlobFile( ) the conversion is done automatically
+ for you and you do not have to call this function. For PostgreSQL, currently,
+ BlobEncode() can only be used for bytea fields.
+<p>Returns the encoded blob value.
+<p>Note that there is a connection property called <em>blobEncodeType</em> which
+ has 3 legal values:
+<p>false - no need to perform encoding or decoding.<br>
+ 'I' - blob encoding required, and returned encoded blob is a numeric value
+ (no need to quote).<br>
+ 'C' - blob encoding required, and returned encoded blob is a character value
+ (requires quoting).
+<p>This is purely for documentation purposes, so that programs that accept multiple
+ database drivers know what is the right thing to do when processing blobs.
+<p><strong>BlobDecode<a name="blobdecode"></a>($blob)</strong>
+</font><p><font color="#000000">Some databases require blob's to be decoded manually after doing a select statement.
+ If the database does not require decoding, then this function will return
+ the blob unchanged. Currently BlobDecode is only required for one database,
+ PostgreSQL, and only if you are using blob oid's (if you are using bytea fields,
+ we auto-decode for you).</font><font color="#000000">
+<pre>$rs = $db-&gt;Execute(&quot;select bloboid from postgres_table where id=$key&quot;);
+$blob = $db-&gt;BlobDecode( reset($rs-&gt;fields) );</pre>
+<p><b>Replace<a name="replace"></a>($table, $arrFields, $keyCols,$autoQuote=false)</b></p>
+<p>Try to update a record, and if the record is not found, an insert statement
+ is generated and executed. Returns 0 on failure, 1 if update statement worked,
+ 2 if no record was found and the insert was executed successfully. This differs
+ from MySQL's replace which deletes the record and inserts a new record. This
+ also means you cannot update the primary key. The only exception to this is
+ Interbase and its derivitives, which uses delete and insert because of some
+ Interbase API limitations.
+<p>The parameters are $table which is the table name, the $keyCols which is an
+ associative array where the keys are the field names, and keyCols is the name
+ of the primary key, or an array of field names if it is a compound key. If
+ $autoQuote is set to true, then Replace() will quote all values that are non-numeric;
+ auto-quoting will not quote nulls. Note that auto-quoting will not work if
+ you use SQL functions or operators.
+<p>Examples:
+<pre>
+# single field primary key
+$ret = $db->Replace('atable',
+ array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
+ 'id',$autoquote = true);
+# generates UPDATE atable SET firstname='Harun',lastname='Al-Rashid' WHERE id=1000
+# or INSERT INTO atable (id,firstname,lastname) VALUES (1000,'Harun','Al-Rashid')
+
+# compound key
+$ret = $db->Replace('atable2',
+ array('firstname'=>'Harun','lastname'=>'Al-Rashid', 'age' => 33, 'birthday' => 'null'),
+ array('lastname','firstname'),
+ $autoquote = true);
+
+# no auto-quoting
+$ret = $db->Replace('atable2',
+ array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'),
+ array('lastname','firstname'));
+</pre>
+<p><b>GetUpdateSQL<a name="getupdatesql"></a>(&$rs, $arrFields, $forceUpdate=false,$magicq=false)</b></p>
+<p>Generate SQL to update a table given a recordset $rs, and the modified fields
+ of the array $arrFields (which must be an associative array holding the column
+ names and the new values) are compared with the current recordset. If $forceUpdate
+ is true, then we also generate the SQL even if $arrFields is identical to
+ $rs-&gt;fields. Requires the recordset to be associative. $magicq is used
+ to indicate whether magic quotes are enabled (see qstr()). The field names in the array
+ are case-insensitive.</p>
+ <p>Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted to SQL nulls.
+<p><b>GetInsertSQL<a name="getinsertsql"></a>(&$rs, $arrFields,$magicq=false)</b></p>
+<p>Generate SQL to insert into a table given a recordset $rs. Requires the query
+ to be associative. $magicq is used to indicate whether magic quotes are enabled
+ (for qstr()). The field names in the array are case-insensitive.</p>
+
+<p>Since 3.61, define('ADODB_FORCE_NULLS',1) and all PHP nulls will be auto-converted
+ to SQL nulls.
+ Since ADOdb 2.42, you can pass a table name instead of a recordset into
+GetInsertSQL (in $rs), and it will generate an insert statement for that table.
+<p><b>PageExecute<a name="pageexecute"></a>($sql, $nrows, $page, $inputarr=false)</b>
+<p>Used for pagination of recordset. $page is 1-based. See <a href="#ex8">Example
+ 8</a>.</p>
+</font>
+<p><font color="#000000"><b>CachePageExecute<a name="cachepageexecute"></a>($secs2cache,
+ $sql, $nrows, $page, $inputarr=false)</b> </font></p>
+<p><font color="#000000">Used for pagination of recordset. $page is 1-based. See
+ <a href="#ex8">Example 8</a>. Caching version of PageExecute.</font></p>
+<font color="#000000">
+<p></p>
+<p><b>Close<a name="close"></a>( )</b></p>
+<p>Close the database connection. PHP4 proudly states that we no longer have to
+ clean up at the end of the connection because the reference counting mechanism
+ of PHP4 will automatically clean up for us.</p>
+ <p><b>StartTrans<a name="starttrans"></a>( )</b></p>
+ <p>Start a monitored transaction. As SQL statements are executed, ADOdb will monitor
+ for SQL errors, and if any are detected, when CompleteTrans() is called, we auto-rollback.
+ <p>
+ <p> To understand why StartTrans() is superior to BeginTrans(),
+ let us examine a few ways of using BeginTrans().
+ The following is the wrong way to use transactions:
+<pre>
+$DB->BeginTrans();
+$DB->Execute("update table1 set val=$val1 where id=$id");
+$DB->Execute("update table2 set val=$val2 where id=$id");
+$DB->CommitTrans();
+</pre>
+<p>because you perform no error checking. It is possible to update table1 and
+ for the update on table2 to fail. Here is a better way:
+<pre>
+$DB->BeginTrans();
+$ok = $DB->Execute("update table1 set val=$val1 where id=$id");
+if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");
+if ($ok) $DB->CommitTrans();
+else $DB->RollbackTrans();
+</pre>
+<p>Another way is (since ADOdb 2.0):
+<pre>
+$DB->BeginTrans();
+$ok = $DB->Execute("update table1 set val=$val1 where id=$id");
+if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");
+$DB->CommitTrans($ok);
+</pre>
+<p> Now it is a headache monitoring $ok all over the place. StartTrans() is an
+improvement because it monitors all SQL errors for you. This is particularly
+useful if you are calling black-box functions in which SQL queries might be executed.
+ Also all BeginTrans, CommitTrans and RollbackTrans calls inside a StartTrans block
+ will be disabled, so even if the black box function does a commit, it will be ignored.
+<pre>
+$DB->StartTrans();
+CallBlackBox();
+$DB->Execute("update table1 set val=$val1 where id=$id");
+$DB->Execute("update table2 set val=$val2 where id=$id");
+$DB->CompleteTrans($ok);
+</pre>
+<p>Note that a StartTrans blocks are nestable, the inner blocks are ignored.
+ <p><b>CompleteTrans<a name="completetrans"></a>($autoComplete=true)</b></p>
+ <p>Complete a transaction called with StartTrans(). This function monitors
+ for SQL errors, and will commit if no errors have occured, otherwise it will rollback.
+ Returns true on commit, false on rollback. If the parameter $autoComplete is true
+ monitor sql errors and commit and rollback as appropriate. Set $autoComplete to false
+ to force rollback even if no SQL error detected.
+ <p><b>FailTrans<a name="failtrans"></a>( )</b></p>
+ <p>Fail a transaction started with StartTrans(). The rollback will only occur when
+ CompleteTrans() is called.
+ <p><b>HasFailedTrans<a name="hasfailedtrans"></a>( )</b></p>
+ <p>Check whether smart transaction has failed,
+ eg. returns true if there was an error in SQL execution or FailTrans() was called.
+ If not within smart transaction, returns false.
+<p><b>BeginTrans<a name="begintrans"></a>( )</b></p>
+<p>Begin a transaction. Turns off autoCommit. Returns true if successful. Some
+ databases will always return false if transaction support is not available.
+ Any open transactions will be rolled back when the connection is closed. Among the
+ databases that support transactions are Oracle, PostgreSQL, Interbase, MSSQL, certain
+ versions of MySQL, DB2, Informix, Sybase, etc.</p>
+ <p>Note that <a href=#starttrans>StartTrans()</a> and CompleteTrans() is a superior method of
+ handling transactions, available since ADOdb 3.40. For a explanation, see the <a href=#starttrans>StartTrans()</a> documentation.
+
+<p>You can also use the ADOdb <a href=#errorhandling>error handler</a> to die
+ and rollback your transactions for you transparently. Some buggy database extensions
+ are known to commit all outstanding tranasactions, so you might want to explicitly
+ do a $DB->RollbackTrans() in your error handler for safety.
+ <h4>Detecting Transactions</h4>
+ <p>Since ADOdb 2.50, you are able to detect when you are inside a transaction. Check
+ that $connection->transCnt > 0. This variable is incremented whenever BeginTrans() is called,
+ and decremented whenever RollbackTrans() or CommitTrans() is called.
+<p><b>CommitTrans<a name="committrans"></a>($ok=true)</b></p>
+<p>End a transaction successfully. Returns true if successful. If the database
+ does not support transactions, will return true also as data is always committed.
+</p>
+<p>If you pass the parameter $ok=false, the data is rolled back. See example in
+ BeginTrans().</p>
+<p><b>RollbackTrans<a name="rollbacktrans"></a>( )</b></p>
+<p>End a transaction, rollback all changes. Returns true if successful. If the
+ database does not support transactions, will return false as data is never rollbacked.
+</p>
+</font><font color="#000000">
+<p><b>GetAssoc<a name=getassoc1></a>($sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
+<p>Returns an associative array for the given query $sql with optional bind parameters
+ in $inputarr. If the number of columns returned is greater to two, a 2-dimensional
+ array is returned, with the first column of the recordset becomes the keys
+ to the rest of the rows. If the columns is equal to two, a 1-dimensional array
+ is created, where the the keys directly map to the values (unless $force_array
+ is set to true, when an array is created for each value).
+<p> <font color="#000000">Examples:<a name=getassocex></a></font></p>
+</font>
+<p><font color="#000000">We have the following data in a recordset:</font></p>
+<p><font color="#000000">row1: Apple, Fruit, Edible<br>
+ row2: Cactus, Plant, Inedible<br>
+ row3: Rose, Flower, Edible</font></p>
+<p><font color="#000000">GetAssoc will generate the following 2-dimensional associative
+ array:</font></p>
+<p><font color="#000000">Apple =&gt; array[Fruit, Edible]<br>
+ Cactus =&gt; array[Plant, Inedible]<br>
+ Rose =&gt; array[Flower,Edible]</font></p>
+<p><font color="#000000">If the dataset is:</font></p>
+<p><font color="#000000"><font color="#000000"><font color="#000000">row1: Apple,
+ Fruit<br>
+ row2: Cactus, Plant<br>
+ row3: Rose, Flower</font> </font></font></p>
+<p><font color="#000000"><font color="#000000">GetAssoc will generate the following
+ 1-dimensional associative array (with $force_array==false):</font></font></p>
+<p><font color="#000000">Apple =&gt; Fruit</font><br>
+ Cactus=&gt;Plant<br>
+ Rose=&gt;Flower <font color="#000000"><font color="#000000"> </font></font><font color="#000000"><font color="#000000"></font></font></p>
+<p><font color="#000000">The function returns:</font></p>
+<p><font color="#000000">The associative array, or false if an error occurs.</font></p>
+<font color="#000000">
+<p><b>CacheGetAssoc<a name="cachegetassoc"></a>([$secs2cache,] $sql,$inputarr=false,$force_array=false,$first2cols=false)</b></p>
+</font><font color="#000000">
+<p>Caching version of <a href=#getassoc1>GetAssoc</a> function above.
+<p><b>GetOne<a name="getone"></a>($sql,$inputarr=false)</b></p>
+<p>Executes the SQL and returns the first field of the first row. The recordset
+ and remaining rows are discarded for you automatically. If an error occur, false
+ is returned.</p>
+<p><b>GetRow<a name="getrow"></a>($sql,$inputarr=false)</b></p>
+<p>Executes the SQL and returns the first row as an array. The recordset and remaining
+ rows are discarded for you automatically. If an error occurs, false is returned.</p>
+<p><b>GetAll<a name="getall"></a>($sql)</b></p>
+</font>
+<p><font color="#000000">Executes the SQL and returns the all the rows as a 2-dimensional
+ array. The recordset is discarded for you automatically. If an error occurs,
+ false is returned.</font></p>
+ <p><b>GetCol<a name="getcol"></a>($sql,$inputarr=false,$trim=false)</b></p>
+
+<p><font color="#000000">Executes the SQL and returns all elements of the first column as a
+1-dimensional array. The recordset is discarded for you automatically. If an error occurs,
+ false is returned.</font></p>
+<p><font color="#000000"><b>CacheGetOne<a name="cachegetone"></a>([$secs2cache,]
+ $sql,$inputarr=false), CacheGetRow<a name="cachegetrow"></a>([$secs2cache,] $sql,$inputarr=false), CacheGetAll<a name="cachegetall"></a>([$secs2cache,]
+ $sql,$inputarr=false), CacheGetCol<a name="cachegetcol"></a>([$secs2cache,]
+ $sql,$inputarr=false,$trim=false)</b></font></p>
+<font color="#000000">
+<p>Similar to above Get* functions, except that the recordset is serialized and
+ cached in the $ADODB_CACHE_DIR directory for $secs2cache seconds. Good for speeding
+ up queries on rarely changing data. Note that the $secs2cache parameter is optional.
+ If omitted, we use the value in $connection-&gt;cacheSecs (default is 3600 seconds,
+ or 1 hour).</p>
+<p><b>Prepare<a name="prepare"></a>($sql )</b></p>
+</font>
+<p><font color="#000000">Prepares (compiles) an SQL query for repeated execution. Bind parameters
+are denoted by ?, except for the oci8 driver, which uses the traditional Oracle :varname
+convention.
+ </font></p>
+<p><font color="#000000">Returns an array containing the original sql statement
+ in the first array element; the remaining elements of the array are driver dependent.
+ If there is an error, or we are emulating Prepare( ), we return the original
+ $sql string. This is because all error-handling has been centralized in Execute(
+ ).</font></p>
+<p><font color="#000000">Prepare( ) cannot be used with functions that use SQL
+ query rewriting techniques, e.g. PageExecute( ) and SelectLimit( ).</font></p>
+<p>Example:</p>
+<pre><font color="#000000">$stmt = $DB-&gt;Prepare('insert into table (col1,col2) values (?,?)');
+for ($i=0; $i &lt; $max; $i++)<br></font> $DB-&gt;<font color="#000000">Execute($stmt,array((string) rand(), $i));
+</font></pre>
+<font color="#000000">
+<p>Also see InParameter(), OutParameter() and PrepareSP() below. Only supported internally by interbase,
+ oci8 and selected ODBC-based drivers, otherwise it is emulated. There is no
+ performance advantage to using Prepare() with emulation.
+<p> Important: Due to limitations or bugs in PHP, if you are getting errors when
+ you using prepared queries, try setting $ADODB_COUNTRECS = false before preparing.
+ This behaviour has been observed with ODBC.
+<p><b>IfNull<a name="ifnull"></a>($field, $nullReplacementValue)</b></p>
+<p>Portable IFNULL function (NVL in Oracle). Returns a string that represents
+ the function that checks whether a $field is null for the given database, and
+ if null, change the value returned to $nullReplacementValue. Eg.</p>
+<pre>$sql = <font color="#993300">'SELECT '</font>.$db-&gt;IfNull('name', <font color="#993300">&quot;'- unknown -'&quot;</font>).<font color="#993300"> ' FROM table'</font>;</pre>
+
+<p><b>length<a name="length"></a></b></p>
+<p>This is not a function, but a property. Some databases have "length" and others "len"
+as the function to measure the length of a string. To use this property:
+<pre>
+ $sql = <font color="#993300">"SELECT "</font>.$db->length.<font color="#993300">"(field) from table"</font>;
+ $rs = $db->Execute($sql);
+</pre>
+
+<p><b>random<a name="random"></a></b></p>
+<p>This is not a function, but a property. This is a string that holds the sql to
+generate a random number between 0.0 and 1.0 inclusive.
+
+<p><b>substr<a name="substr"></a></b></p>
+<p>This is not a function, but a property. Some databases have "substr" and others "substring"
+as the function to retrieve a sub-string. To use this property:
+<pre>
+ $sql = <font color="#993300">"SELECT "</font>.$db->substr.<font color="#993300">"(field, $offset, $length) from table"</font>;
+ $rs = $db->Execute($sql);
+</pre>
+<p>For all databases, the 1st parameter of <i>substr</i> is the field, the 2nd is the
+offset (1-based) to the beginning of the sub-string, and the 3rd is the length of the sub-string.
+
+
+<p><b>Param<a name="param"></a>($name)</b></p>
+<p>Generates a bind placeholder portably. For most databases, the bind placeholder
+ is "?". However some databases use named bind parameters such as Oracle, eg
+ ":somevar". This allows us to portably define an SQL statement with bind parameters:
+<pre><font color="#000000">$sql = <font color="#993300">'insert into table (col1,col2) values ('</font>.$DB-&gt;Param('a').<font color="#993300">','</font>.$DB-&gt;Param('b').<font color="#993300">')'</font>;
+<font color="#006600"># generates 'insert into table (col1,col2) values (?,?)'
+# or 'insert into table (col1,col2) values (:a,:b)</font>'
+$stmt = $DB-&gt;Prepare($sql);
+$stmt = $DB-&gt;Execute($stmt,array('one','two'));
+</font></pre>
+<font color="#000000">
+<p></p>
+<p><b>PrepareSP</b><b><a name="preparesp"></a></b><b>($sql, $cursor=false )</b></p>
+<p>When calling stored procedures in mssql and oci8 (oracle), and you might want
+ to directly bind to parameters that return values, or for special LOB handling.
+ PrepareSP() allows you to do so.
+<p>Returns the same array or $sql string as Prepare( ) above. If you do not need
+ to bind to return values, you should use Prepare( ) instead.</p>
+<p>The 2nd parameter, $cursor is not used except with oci8. Setting it to true will
+force OCINewCursor to be called; this is to support output REF CURSORs.
+<p>For examples of usage of PrepareSP( ), see InParameter( ) below.
+<p>Note: in the mssql driver, preparing stored procedures requires a special function
+ call, mssql_init( ), which is called by this function. PrepareSP( ) is available
+ in all other drivers, and is emulated by calling Prepare( ). </p>
+<p><b> InParameter<a name="inparameter"></a>($stmt, $var, $name,
+ $maxLen = 4000, $type = false )</b></p>
+Binds a PHP variable as input to a stored procedure variable. The parameter <i>$stmt</i>
+ is the value returned by PrepareSP(), <i>$var</i> is the PHP variable you want to bind, $name
+ is the name of the stored procedure variable. Optional is <i>$maxLen</i>, the maximum length of the
+ data to bind, and $type which is database dependant.
+ Consult <a href=http://php.net/mssql_bind>mssql_bind</a> and <a href=http://php.net/ocibindbyname>ocibindbyname</a> docs
+ at php.net for more info on legal values for $type.
+ <p>
+InParameter() is a wrapper function that calls Parameter() with $isOutput=false.
+The advantage of this function is that it is self-documenting, because
+the $isOutput parameter is no longer needed. Only for mssql
+ and oci8 currently.
+ <p>Here is an example using oci8:
+ <pre><font color="green"># For oracle, Prepare and PrepareSP are identical</font>
+$stmt = $db-&gt;PrepareSP(
+ <font color="#993300">&quot;declare RETVAL integer;
+ begin
+ :RETVAL := </font><font color="#993300">SP_RUNSOMETHING</font><font color="#993300">(:myid,:group);
+ end;&quot;</font>);
+$db-&gt;InParameter($stmt,$id,'myid');
+$db-&gt;InParameter($stmt,$group,'group',64);
+$db-&gt;OutParameter($stmt,$ret,'RETVAL');<br>$db-&gt;Execute($stmt);
+</pre>
+<p> The same example using mssql:</p>
+</font>
+<pre><font color="#000000"><font color="green"># @RETVAL = SP_RUNSOMETHING @myid,@group</font>
+$stmt = $db-&gt;PrepareSP(<font color="#993333">'<font color="#993300">SP_RUNSOMETHING</font>'</font>); <br><font color="green"># note that the parameter name does not have @ in front!</font>
+$db-&gt;InParameter($stmt,$id,'myid');
+$db-&gt;InParameter($stmt,$group,'group',64);
+<font color="green"># return value in mssql - RETVAL is hard-coded name</font>
+$db-&gt;OutParameter($stmt,$ret,'RETVAL');
+$db-&gt;Execute($stmt); </font></pre>
+
+<p>Note that the only difference between the oci8 and mssql implementations is $sql.</p>
+ <p>
+ If $type parameter is set to false, in mssql, $type will be dynamicly determined
+based on the type of the PHP variable passed <font face="Courier New, Courier, mono">(string
+=&gt; SQLCHAR, boolean =&gt;SQLINT1, integer =&gt;SQLINT4 or float/double=&gt;SQLFLT8)</font>.
+<p>
+In oci8, $type can be set to OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File),
+OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and OCI_B_ROWID (ROWID). To
+pass in a null, use<font face="Courier New, Courier, mono"> $db-&gt;Parameter($stmt,
+$null=null, 'param')</font>.
+ <p><b> OutParameter<a name="outparameter"></a>($stmt, $var, $name,
+ $maxLen = 4000, $type = false )</b></p>
+ Binds a PHP variable as output from a stored procedure variable. The parameter <i>$stmt</i>
+ is the value returned by PrepareSP(), <i>$var</i> is the PHP variable you want to bind, <i>$name</i>
+ is the name of the stored procedure variable. Optional is <i>$maxLen</i>, the maximum length of the
+ data to bind, and <i>$type</i> which is database dependant.
+ <p>
+ OutParameter() is a wrapper function that calls Parameter() with $isOutput=true.
+ The advantage of this function is that it is self-documenting, because
+the $isOutput parameter is no longer needed. Only for mssql
+ and oci8 currently.
+<p>
+For an example, see <a href=#inparameter>InParameter</a>.
+
+<p><b> Parameter<a name="parameter"></a>($stmt, $var, $name, $isOutput=false,
+ $maxLen = 4000, $type = false )</b></p>
+<p>Note: This function is deprecated, because of the new InParameter() and OutParameter() functions.
+These are superior because they are self-documenting, unlike Parameter().
+<p>Adds a bind parameter suitable for return values or special data handling (eg.
+ LOBs) after a statement has been prepared using PrepareSP(). Only for mssql
+ and oci8 currently. The parameters are:<br>
+ <br>
+ $<i><b>stmt</b></i> Statement returned by Prepare() or PrepareSP().<br>
+ $<i><b>var</b></i> PHP variable to bind to. Make sure you pre-initialize it!<br>
+ $<i><b>name</b></i> Name of stored procedure variable name to bind to.<br>
+ [$<i><b>isOutput</b></i>] Indicates direction of parameter 0/false=IN 1=OUT
+ 2= IN/OUT. This is ignored in oci8 as this driver auto-detects the direction.<br>
+ [$<b>maxLen</b>] Maximum length of the parameter variable.<br>
+ [$<b>type</b>] Consult <a href="http://php.net/mssql_bind">mssql_bind</a> and
+ <a href="http://php.net/ocibindbyname">ocibindbyname</a> docs at php.net for
+ more info on legal values for type.</p>
+<p>Lastly, in oci8, bind parameters can be reused without calling PrepareSP( )
+ or Parameters again. This is not possible with mssql. An oci8 example:</p>
+<pre>$id = 0; $i = 0;
+$stmt = $db-&gt;PrepareSP( <font color="#993300">&quot;update table set val=:i where id=:id&quot;</font>);
+$db-&gt;Parameter($stmt,$id,'id');
+$db-&gt;Parameter($stmt,$i, 'i');
+for ($cnt=0; $cnt &lt; 1000; $cnt++) {
+ $id = $cnt; <br> $i = $cnt * $cnt; <font color="green"># works with oci8!</font>
+ $db-&gt;Execute($stmt); <br>}</pre>
+<p><b>Bind<a name="bind"></a>($stmt, $var, $size=4001, $type=false, $name=false)</b></p>
+</font>
+<p><font color="#000000">This is a low-level function supported only by the oci8
+ driver. <b>Avoid using</b> unless you only want to support Oracle. The Parameter(
+ ) function is the recommended way to go with bind variables.</font></p>
+<p><font color="#000000">Bind( ) allows you to use bind variables in your sql
+ statement. This binds a PHP variable to a name defined in an Oracle sql statement
+ that was previously prepared using Prepare(). Oracle named variables begin with
+ a colon, and ADOdb requires the named variables be called :0, :1, :2, :3, etc.
+ The first invocation of Bind() will match :0, the second invocation will match
+ :1, etc. Binding can provide 100% speedups for insert, select and update statements.
+ </font></p>
+<p>The other variables, $size sets the buffer size for data storage, $type is
+ the optional descriptor type OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File),
+ OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB) and OCI_B_ROWID (ROWID).
+ Lastly, instead of using the default :0, :1, etc names, you can define your
+ own bind-name using $name.
+<p><font color="#000000">The following example shows 3 bind variables being used:
+ p1, p2 and p3. These variables are bound to :0, :1 and :2.</font></p>
+<pre>$stmt = $DB-&gt;Prepare(&quot;insert into table (col0, col1, col2) values (:0, :1, :2)&quot;);
+$DB-&gt;Bind($stmt, $p1);
+$DB-&gt;Bind($stmt, $p2);
+$DB-&gt;Bind($stmt, $p3);
+for ($i = 0; $i &lt; $max; $i++) {
+ $p1 = ?; $p2 = ?; $p3 = ?;
+ $DB-&gt;Execute($stmt);
+}</pre>
+<p>You can also use named variables:</p>
+<pre>
+$stmt = $DB-&gt;Prepare(&quot;insert into table (col0, col1, col2) values (:name0, :name1, :name2)&quot;);
+$DB-&gt;Bind($stmt, $p1, &quot;name0&quot;);
+$DB-&gt;Bind($stmt, $p2, &quot;name1&quot;);
+$DB-&gt;Bind($stmt, $p3, &quot;name2&quot;);
+for ($i = 0; $i &lt; $max; $i++) {
+ $p1 = ?; $p2 = ?; $p3 = ?;
+ $DB-&gt;Execute($stmt);
+}</pre>
+<p><b>LogSQL($enable=true)<a name=logsql></a></b></p>
+Call this method to install a SQL logging and timing function (using fnExecute).
+Then all SQL statements are logged into an adodb_logsql table in a database. If
+the adodb_logsql table does not exist, ADOdb will create the table if you have
+the appropriate permissions. Returns the previous logging value (true for enabled,
+false for disabled). Here are samples of the DDL for selected databases:
+<p>
+<pre>
+ <b>mysql:</b>
+ CREATE TABLE adodb_logsql (
+ created datetime NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 text NOT NULL,
+ params text NOT NULL,
+ tracer text NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )
+
+ <b>postgres:</b>
+ CREATE TABLE adodb_logsql (
+ created timestamp NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 text NOT NULL,
+ params text NOT NULL,
+ tracer text NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )
+
+ <b>mssql:</b>
+ CREATE TABLE adodb_logsql (
+ created datetime NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(4000) NOT NULL,
+ params varchar(3000) NOT NULL,
+ tracer varchar(500) NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )
+
+ <b>oci8:</b>
+ CREATE TABLE adodb_logsql (
+ created date NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(4000) NOT NULL,
+ params varchar(4000),
+ tracer varchar(4000),
+ timer decimal(16,6) NOT NULL
+ )
+</pre>
+Usage:
+<pre>
+ $conn->LogSQL(); // turn on logging
+ :
+ $conn->Execute(...);
+ :
+ $conn->LogSQL(false); // turn off logging
+
+ # output summary of SQL logging results
+ $perf = NewPerfMonitor($conn);
+ echo $perf->SuspiciousSQL();
+ echo $perf->ExpensiveSQL();
+</pre>
+<p>One limitation of logging is that rollback also prevents SQL from being logged.
+<p>
+If you prefer to use another name for the table used to store the SQL, you can override it by calling
+adodb_perf::table($tablename), where $tablename is the new table name (you will still need to manually
+create the table yourself). An example:
+<pre>
+ include('adodb.inc.php');
+ include('adodb-perf.inc.php');
+ adodb_perf::table('my_logsql_table');
+</pre>
+Also see <a href=docs-perf.htm>Performance Monitor</a>.
+<p><font color="#000000"><b>fnExecute and fnCacheExecute properties<a name="fnexecute" id="fnexecute"></a></b></font></p>
+<p>These two properties allow you to define bottleneck functions for all sql statements
+ processed by ADOdb. This allows you to perform statistical analysis and query-rewriting
+ of your sql.
+<p><b>Examples of fnExecute</b></p>
+<p>Here is an example of using fnExecute, to count all cached queries and non-cached
+ queries, you can do this:</p>
+<pre><font color="#006600"># $db is the connection object</font>
+function CountExecs($db, $sql, $inputarray)
+{
+global $EXECS;
+
+if (!is_array(inputarray)) $EXECS++;
+<font color="#006600"># handle 2-dimensional input arrays</font>
+else if (is_array(reset($inputarray))) $EXECS += sizeof($inputarray);
+else $EXECS++;
+}
+
+<font color="#006600"># $db is the connection object</font>
+function CountCachedExecs($db, $secs2cache, $sql, $inputarray)
+{<br>global $CACHED; $CACHED++;
+}
+<br>$db = NewADOConnection('mysql');
+$db-&gt;Connect(...);
+$db-&gt;<strong>fnExecute</strong> = 'CountExecs';
+$db-&gt;<strong>fnCacheExecute</strong> = 'CountCachedExecs';
+ :
+ :<br><font color="#006600"># After many sql statements:</font>`
+printf(&quot;&lt;p&gt;Total queries=%d; total cached=%d&lt;/p&gt;&quot;,$EXECS+$CACHED, $CACHED);
+</pre>
+<p>The fnExecute function is called before the sql is parsed and executed, so
+ you can perform a query rewrite. If you are passing in a prepared statement,
+ then $sql is an array (see <a href="#prepare">Prepare</a>). The fnCacheExecute
+ function is only called if the recordset returned was cached.<font color="#000000">
+ The function parameters match the Execute and CacheExecute functions respectively,
+ except that $this (the connection object) is passed as the first parameter.</font></p>
+<p>Since ADOdb 3.91, the behaviour of fnExecute varies depending on whether the
+ defined function returns a value. If it does not return a value, then the $sql
+ is executed as before. This is useful for query rewriting or counting sql queries.
+<p> On the other hand, you might want to replace the Execute function with one
+ of your own design. If this is the case, then have your function return a value.
+ If a value is returned, that value is returned immediately, without any further
+ processing. This is used internally by ADOdb to implement LogSQL() functionality.
+<p> <font color="#000000">
+<hr>
+<h3>ADOConnection Utility Functions</h3>
+<p><b>BlankRecordSet<a name="blankrecordset"></a>([$queryid])</b></p>
+<p>No longer available - removed since 1.99.</p>
+<p><b>Concat<a name="concat"></a>($s1,$s2,....)</b></p>
+<p>Generates the sql string used to concatenate $s1, $s2, etc together. Uses the
+ string in the concat_operator field to generate the concatenation. Override
+ this function if a concatenation operator is not used, eg. MySQL.</p>
+<p>Returns the concatenated string.</p>
+<p><b>DBDate<a name="dbdate"></a>($date)</b></p>
+<p>Format the $<b>date</b> in the format the database accepts. This is used in
+ INSERT/UPDATE statements; for SELECT statements, use <a href="#sqldate">SQLDate</a>.
+ The $<b>date</b> parameter can be a Unix integer timestamp or an ISO format
+ Y-m-d. Uses the fmtDate field, which holds the format to use. If null or false
+ or '' is passed in, it will be converted to an SQL null.</p>
+<p>Returns the date as a quoted string.</p>
+<p><b>DBTimeStamp<a name="dbtimestamp"></a>($ts)</b></p>
+<p>Format the timestamp $<b>ts</b> in the format the database accepts; this can
+ be a Unix integer timestamp or an ISO format Y-m-d H:i:s. Uses the fmtTimeStamp
+ field, which holds the format to use. If null or false or '' is passed in, it
+ will be converted to an SQL null.</p>
+<p>Returns the timestamp as a quoted string.</p>
+<p><b>qstr<a name="qstr"></a>($s,[$magic_quotes_enabled</b>=false]<b>)</b></p>
+<p>Quotes a string to be sent to the database. The $<b>magic_quotes_enabled</b>
+ parameter may look funny, but the idea is if you are quoting a string extracted
+ from a POST/GET variable, then pass get_magic_quotes_gpc() as the second parameter.
+ This will ensure that the variable is not quoted twice, once by <i>qstr</i>
+ and once by the <i>magic_quotes_gpc</i>.</p>
+<p>Eg.<font face="Courier New, Courier, mono"> $s = $db-&gt;qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());</font></p>
+<p>Returns the quoted string.</p>
+<p><b>Quote<a name="quote"></a>($s)</b></p>
+<p>Quotes the string $s, escaping the database specific quote character as appropriate.
+ Formerly checked magic quotes setting, but this was disabled since 3.31 for
+ compatibility with PEAR DB.
+<p><b>Affected_Rows<a name="affected_rows"></a>( )</b></p>
+<p>Returns the number of rows affected by a update or delete statement. Returns
+ false if function not supported.</p>
+<p>Not supported by interbase/firebird currently. </p>
+<p><b>Insert_ID<a name="inserted_id"></a>( )</b></p>
+<p>Returns the last autonumbering ID inserted. Returns false if function not supported.
+</p>
+<p>Only supported by databases that support auto-increment or object id's, such
+ as PostgreSQL, MySQL and MS SQL Server currently. PostgreSQL returns the OID, which
+ can change on a database reload.</p>
+<p><b>RowLock<a name="rowlock"></a>($table,$where)</b></p>
+<p>Lock a table row for the duration of a transaction. For example to lock record $id in table1:
+<pre>
+ $DB->StartTrans();
+ $DB->RowLock("table1","rowid=$id");
+ $DB->Execute($sql1);
+ $DB->Execute($sql2);
+ $DB->CompleteTrans();
+</pre>
+<p>Supported in db2, interbase, informix, mssql, oci8, postgres, sybase.
+<p><b>MetaDatabases<a name="metadatabases"></a>()</b></p>
+<p>Returns a list of databases available on the server as an array. You have to
+ connect to the server first. Only available for ODBC, MySQL and ADO.</p>
+<p><b>MetaTables<a name="metatables"></a>($ttype = false, $showSchema = false,
+ $mask=false)</b></p>
+<p>Returns an array of tables and views for the current database as an array.
+ The array should exclude system catalog tables if possible. To only show tables,
+ use $db->MetaTables('TABLES'). To show only views, use $db->MetaTables('VIEWS').
+ The $showSchema parameter currently works only for DB2, and when set to true,
+ will add the schema name to the table, eg. "SCHEMA.TABLE". </p>
+<p>You can define a mask for matching. For example, setting $mask = 'TMP%' will
+ match all tables that begin with 'TMP'. Currently only mssql, oci8, odbc_mssql
+ and postgres* support $mask.
+<p><b>MetaColumns<a name="metacolumns"></a>($table,$toupper=true)</b></p>
+<p>Returns an array of ADOFieldObject's, one field object for every column of
+ $table. A field object is a class instance with (name, type, max_length) defined.
+ Currently Sybase does not recognise date types, and ADO cannot identify
+ the correct data type (so we default to varchar).
+ <p> The $toupper parameter determines whether we uppercase the table name
+ (required for some databases).
+ <p>For schema support, pass in the $table parameter, "$schema.$tablename". This is only
+ supported for selected databases.
+<p><b>MetaColumnNames<a name="metacolumnames"></a>($table,$numericIndex=false)</b></p>
+<p>Returns an array of column names for $table. Since ADOdb 4.22, this is an associative array, with the
+keys in uppercase. Set $numericIndex=true if you want the old behaviour of numeric indexes (since 4.23).
+<p>
+e.g. array('FIELD1' => 'Field1', 'FIELD2'=>'Field2')
+<p>
+<p><font color="#000000"><b>MetaPrimaryKeys<a name="metaprimarykeys"></a>($table,
+ $owner=false)</b></font></font>
+<p><font color="#000000">Returns an array containing column names that are the
+ primary keys of $table. Supported by mysql, odbc (including db2, odbc_mssql,
+ etc), mssql, postgres, interbase/firebird, oci8 currently. </font><font color="#000000">
+<p>Views (and some tables) have primary keys, but sometimes this information is not available from the
+database. You can define a function ADODB_View_PrimaryKeys($databaseType, $database, $view, $owner) that
+should return an array containing the fields that make up the primary key. If that function exists,
+it will be called when MetaPrimaryKeys() cannot find a primary key for a table or view.
+<pre>
+// In this example: dbtype = 'oci8', $db = 'mydb', $view = 'dataView', $owner = false
+function ADODB_View_PrimaryKeys($dbtype,$db,$view,$owner)
+{
+ switch(strtoupper($view)) {
+ case 'DATAVIEW': return array('DATAID');
+ default: return false;
+ }
+}
+
+$db = NewADOConnection('oci8');
+$db->Connect('localhost','root','','mydb');
+$db->MetaPrimaryKeys('dataView');
+</pre>
+<p><font color="#000000"><b>ServerInfo<a name="serverinfo" id="serverinfo"></a>($table)</b></font></font>
+<p><font color="#000000">Returns an array of containing two elements 'description'
+ and 'version'. The 'description' element contains the string description of
+ the database. The 'version' naturally holds the version number (which is also
+ a string).</font><font color="#000000">
+<p><b>MetaForeignKeys<a name="metaforeignkeys"></a>($table, $owner=false, $upper=false)</b>
+<p>Returns an associate array of foreign keys, or false if not supported. For
+ example, if table employee has a foreign key where employee.deptkey points to
+ dept_table.deptid, and employee.posn=posn_table.postionid and employee.poscategory=posn_table.category,
+ then $conn->MetaForeignKeys('employee') will return
+<pre>
+ array(
+ 'dept_table' => array('deptkey=deptid'),
+ 'posn_table' => array('posn=positionid','poscategory=category')
+ )
+</pre>
+<p>The optional schema or owner can be defined in $owner. If $upper is true, then
+ the table names (array keys) are upper-cased.
+<hr>
+<h2>ADORecordSet<a name="adorecordset"></a></h2>
+<p>When an SQL statement successfully is executed by <font face="Courier New, Courier, mono">ADOConnection-&gt;Execute($sql),</font>an
+ ADORecordSet object is returned. This object contains a virtual cursor so we
+ can move from row to row, functions to obtain information about the columns
+ and column types, and helper functions to deal with formating the results to
+ show to the user.</p>
+<h3>ADORecordSet Fields</h3>
+<p><b>fields: </b>Array containing the current row. This is not associative, but
+ is an indexed array from 0 to columns-1. See also the function <b><a href="#fields">Fields</a></b>,
+ which behaves like an associative array.</p>
+<p><b>dataProvider</b>: The underlying mechanism used to connect to the database.
+ Normally set to <b>native</b>, unless using <b>odbc</b> or <b>ado</b>.</p>
+<p><b>blobSize</b>: Maximum size of a char, string or varchar object before it
+ is treated as a Blob (Blob's should be shown with textarea's). See the <a href="#metatype">MetaType</a>
+ function.</p>
+<p><b>sql</b>: Holds the sql statement used to generate this record set.</p>
+<p><b>canSeek</b>: Set to true if Move( ) function works.</p>
+<p><b>EOF</b>: True if we have scrolled the cursor past the last record.</p>
+<h3>ADORecordSet Functions</h3>
+<p><b>ADORecordSet( )</b></p>
+<p>Constructer. Normally you never call this function yourself.</p>
+<p><b>GetAssoc<a name="getassoc"></a>([$force_array])</b></p>
+<p>Generates an associative array from the recordset. Note that is this function
+ is also <a href="#getassoc1">available</a> in the connection object. More details
+ can be found there.</p>
+</font></font><font color="#000000"><font color="#000000"> </font></font><font color="#000000"><font color="#000000">
+<p><b>GetArray<a name="getarray"></a>([$number_of_rows])</b></p>
+<p>Generate a 2-dimensional array of records from the current cursor position,
+ indexed from 0 to $number_of_rows - 1. If $number_of_rows is undefined, till
+ EOF.</p>
+<p><b>GetRows<a name="getrows"></a>([$number_of_rows])</b></p>
+Generate a 2-dimensional array of records from the current cursor position. Synonym
+for GetArray() for compatibility with Microsoft ADO.
+<p> <b>GetMenu<a name="getmenu"></a>($name, [$default_str=''], [$blank1stItem=true],
+ [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
+<p>Generate a HTML menu (&lt;select&gt;&lt;option&gt;&lt;option&gt;&lt;/select&gt;).
+ The first column of the recordset (fields[0]) will hold the string to display
+ in the option tags. If the recordset has more than 1 column, the second column
+ (fields[1]) is the value to send back to the web server.. The menu will be given
+ the name $<i>name</i>.
+<p> If $<i>default_str</i> is defined, then if $<i>default_str</i> == fields[0],
+ that field is selected. If $<i>blank1stItem</i> is true, the first option is
+ empty. You can also set the first option strings by setting $blank1stItem =
+ "$value:$text".</p>
+<p>$<i>Default_str</i> can be array for a multiple select listbox.</p>
+<p>To get a listbox, set the $<i>size</i> to a non-zero value (or pass $default_str
+ as an array). If $<i>multiple_select</i> is true then a listbox will be generated
+ with $<i>size</i> items (or if $size==0, then 5 items) visible, and we will
+ return an array to a server. Lastly use $<i>moreAttr </i> to add additional
+ attributes such as javascript or styles. </p>
+<p>Menu Example 1: <code>GetMenu('menu1','A',true)</code> will generate a menu:
+ <select name='menu1'>
+ <option>
+ <option value=1 selected>A
+ <option value=2>B
+ <option value=3>C
+ </select>
+ for the data (A,1), (B,2), (C,3). Also see <a href="#ex5">example 5</a>.</p>
+<p>Menu Example 2: For the same data, <code>GetMenu('menu1',array('A','B'),false)</code>
+ will generate a menu with both A and B selected: <br>
+ <select name='menu1' multiple size=3>
+ <option value=1 selected>A
+ <option value=2 selected>B
+ <option value=3>C
+ </select>
+<p> <b>GetMenu2<a name="getmenu2"></a>($name, [$default_str=''], [$blank1stItem=true],
+ [$multiple_select=false], [$size=0], [$moreAttr=''])</b></p>
+<p>This is nearly identical to GetMenu, except that the $<i>default_str</i> is
+ matched to fields[1] (the option values).</p>
+<p>Menu Example 3: Given the data in menu example 2, <code>GetMenu2('menu1',array('1','2'),false)</code>
+ will generate a menu with both A and B selected in menu example 2, but this
+ time the selection is based on the 2nd column, which holds the values to return
+ to the Web server.
+<p><b>UserDate<a name="userdate"></a>($str, [$fmt])</b></p>
+<p>Converts the date string $<i>str</i> to another format. The date format is Y-m-d,
+or Unix timestamp format. The default $<i>fmt</i> is Y-m-d.</p>
+<p><b>UserTimeStamp<a name="usertimestamp"></a>($str, [$fmt])</b></p>
+<p>Converts the timestamp string $<b>str</b> to another format. The timestamp
+ format is Y-m-d H:i:s, as in '2002-02-28 23:00:12', or Unix timestamp format.
+ UserTimeStamp calls UnixTimeStamp to parse $<i>str</i>, and $<i>fmt</i> defaults to Y-m-d H:i:s if not defined.
+</p>
+<p><b>UnixDate<a name="unixdate"></a>($str)</b></p>
+<p>Parses the date string $<b>str</b> and returns it in unix mktime format (eg.
+ a number indicating the seconds after January 1st, 1970). Expects the date to
+ be in Y-m-d H:i:s format, except for Sybase and Microsoft SQL Server, where
+ M d Y is also accepted (the 3 letter month strings are controlled by a global
+ array, which might need localisation).</p>
+<p>This function is available in both ADORecordSet and ADOConnection since 1.91.</p>
+<p><b>UnixTimeStamp<a name="unixtimestamp"></a>($str)</b></p>
+<p>Parses the timestamp string $<b>str</b> and returns it in unix mktime format
+ (eg. a number indicating the seconds after January 1st, 1970). Expects the date
+ to be in "Y-m-d, H:i:s" (1970-12-24, 00:00:00) or "Y-m-d H:i:s" (1970-12-24 00:00:00) or "YmdHis" (19701225000000) format, except for Sybase and Microsoft SQL Server, where
+ "M d Y h:i:sA" (Dec 25 1970 00:00:00AM) is also accepted (the 3 letter month strings are controlled by
+ a global array, which might need localisation).</p>
+</font>
+<p><font color="#000000">This function is available in both ADORecordSet and ADOConnection
+ since 1.91. </font></p>
+<p><font color="#000000"><b>OffsetDate<a name="offsetdate"></a>($dayFraction,
+ $basedate=false)</b></font></p>
+<p><font color="#000000"><font color="#000000">Returns a string </font>with the
+ native SQL functions to calculate future and past dates based on $basedate in
+ a portable fashion. If $basedate is not defined, then the current date (at 12
+ midnight) is used. Returns the SQL string that performs the calculation when
+ passed to Execute(). </font></p>
+<p><font color="#000000">For example, in Oracle, to find the date and time that
+ is 2.5 days from today, you can use:</font></p>
+<pre><font color="#000000"># get date one week from now
+$fld = $conn-&gt;OffsetDate(7); // returns &quot;(trunc(sysdate)+7&quot;)</font></pre>
+<pre><font color="#000000"># get date and time that is 60 hours from current date and time
+$fld = $conn-&gt;OffsetDate(2.5, $conn-&gt;sysTimeStamp); // returns &quot;(sysdate+2.5)&quot;</font>
+
+$conn-&gt;Execute(&quot;UPDATE TABLE SET dodate=$fld WHERE ID=$id&quot;);</pre>
+<p> This function is available for mysql, mssql, oracle, oci8 and postgresql drivers
+ since 2.13. It might work with other drivers<font color="#000000"> provided
+ they allow performing numeric day arithmetic on dates.</font></p>
+<font color="#000000">
+<p><font color="#000000"><b>SQLDate<a name="sqldate"></a>($dateFormat, $basedate=false)</b></font></p>
+Returns a string which contains the native SQL functions to format a date or date
+column $basedate. This is used in SELECT statements. For INSERT/UPDATE statements,
+use <a href="#dbdate">DBDate</a>. It uses a case-sensitive $dateFormat, which
+supports:
+<pre>
+ Y: 4-digit Year
+ Q: Quarter (1-4)
+ M: Month (Jan-Dec)
+ m: Month (01-12)
+ d: Day (01-31)
+ H: Hour (00-23)
+ h: Hour (1-12)
+ i: Minute (00-59)
+ s: Second (00-60)
+ A: AM/PM indicator</pre>
+<p>All other characters are treated as strings. You can also use \ to escape characters.
+ Available on selected databases, including mysql, postgresql, mssql, oci8 and
+ DB2.
+<p>This is useful in writing portable sql statements that GROUP BY on dates. For
+ example to display total cost of goods sold broken by quarter (dates are stored
+ in a field called postdate):
+<pre>
+ $sqlfn = $db->SQLDate('Y-\QQ','postdate'); # get sql that formats postdate to output 2002-Q1
+ $sql = "SELECT $sqlfn,SUM(cogs) FROM table GROUP BY $sqlfn ORDER BY 1 desc";
+ </pre>
+<p><b>MoveNext<a name="movenext"></a>( )</b></p>
+<p>Move the internal cursor to the next row. The <i>$this->fields</i> array is
+ automatically updated. Returns false if unable to do so (normally because EOF
+ has been reached), otherwise true.
+<p> If EOF is reached, then the $this->fields array is set to false (this was
+ only implemented consistently in ADOdb 3.30). For the pre-3.30 behaviour of
+ $this->fields (at EOF), set the global variable $ADODB_COMPAT_FETCH = true.</p>
+<p>Example:</p>
+<pre>$rs = $db-&gt;Execute($sql);
+if ($rs)
+ while (!$rs-&gt;EOF) {
+ ProcessArray($rs->fields);
+ $rs->MoveNext();
+ } </pre>
+<p><b>Move<a name="move"></a>($to)</b></p>
+<p>Moves the internal cursor to a specific row $<b>to</b>. Rows are zero-based
+ eg. 0 is the first row. The <b>fields</b> array is automatically updated. For
+ databases that do not support scrolling internally, ADOdb will simulate forward
+ scrolling. Some databases do not support backward scrolling. If the $<b>to</b>
+ position is after the EOF, $<b>to</b> will move to the end of the RecordSet
+ for most databases. Some obscure databases using odbc might not behave this
+ way.</p>
+<p>Note: This function uses <i>absolute positioning</i>, unlike Microsoft's ADO.</p>
+<p>Returns true or false. If false, the internal cursor is not moved in most implementations,
+ so AbsolutePosition( ) will return the last cursor position before the Move(
+ ). </p>
+<p><b>MoveFirst<a name="movefirst"></a>()</b></p>
+<p>Internally calls Move(0). Note that some databases do not support this function.</p>
+<p><b>MoveLast<a name="movelast"></a>()</b></p>
+<p>Internally calls Move(RecordCount()-1). Note that some databases do not support
+ this function.</p>
+<p><b>GetRowAssoc</b><a name="getrowassoc"></a>($toUpper=true)</p>
+<p>Returns an associative array containing the current row. The keys to the array
+ are the column names. The column names are upper-cased for easy access. To get
+ the next row, you will still need to call MoveNext(). </p>
+<p>For example:<br>
+ Array ( [ID] => 1 [FIRSTNAME] => Caroline [LASTNAME] => Miranda [CREATED] =>
+ 2001-07-05 ) </p>
+<p>Note: do not use GetRowAssoc() with $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC.
+ Because they have the same functionality, they will interfere with each other.</p>
+</font>
+<p><font color="#000000"><b>AbsolutePage<a name="absolutepage"></a>($page=-1)
+ </b></font></p>
+<p>Returns the current page. Requires PageExecute()/CachePageExecute() to be called.
+ See <a href=#ex8>Example 8</a>.</p>
+<font color="#000000">
+<p><b>AtFirstPage<a name="atfirstpage">($status='')</a></b></p>
+<p>Returns true if at first page (1-based). Requires PageExecute()/CachePageExecute()
+ to be called. See <a href=#ex8>Example 8</a>.</p>
+<p><b>AtLastPage<a name="atlastpage">($status='')</a></b></p>
+<p>Returns true if at last page (1-based). Requires PageExecute()/CachePageExecute()
+ to be called. See <a href=#ex8>Example 8</a>.</p>
+<p><b>Fields</b><a name="fields"></a>(<b>$colname</b>)</p>
+<p>Returns the value of the
+ associated column $<b>colname</b> for the current row. The column name is case-insensitive.</p>
+<p>This is a convenience function. For higher performance, use <a href="#adodb_fetch_mode">$ADODB_FETCH_MODE</a>. </p>
+<p><b>FetchRow</b><a name="fetchrow"></a>()</p>
+</font>
+<p><font color="#000000">Returns array containing current row, or false if EOF.
+ FetchRow( ) internally moves to the next record after returning the current
+ row. </font></p>
+<p><font color="#000000">Warning: Do not mix using FetchRow() with MoveNext().</font></p>
+<p><font color="#000000">Usage:</font></p>
+<pre><font color="#000000">$rs = $db-&gt;Execute($sql);
+if ($rs)
+ while ($arr = $rs-&gt;FetchRow()) &#123;
+ &nbsp;&nbsp;# process $arr
+</font><font color="#000000"> &#125;</font></pre>
+<p><font color="#000000"><b>FetchInto</b><a name="fetchinto"></a>(<b>&amp;$array</b>)</font></p>
+<p><font color="#000000"> Sets $array to the current row. Returns PEAR_Error object
+ if EOF, 1 if ok (DB_OK constant). If PEAR is undefined, false is returned when
+ EOF. </font><font color="#000000">FetchInto( ) internally moves to the next
+ record after returning the current row. </font></p>
+<p><font color="#000000"> FetchRow() is easier to use. See above.</font></p>
+<font color="#000000">
+<p><b>FetchField<a name="fetchfield"></a>($column_number)</b></p>
+<p>Returns an object containing the <b>name</b>, <b>type</b> and <b>max_length</b>
+ of the associated field. If the max_length cannot be determined reliably, it
+ will be set to -1. The column numbers are zero-based. See <a href="#ex2">example
+ 2.</a></p>
+<p><b>FieldCount<a name="fieldcount"></a>( )</b></p>
+<p>Returns the number of fields (columns) in the record set.</p>
+<p><b>RecordCount<a name="recordcount"></a>( )</b></p>
+<p>Returns the number of rows in the record set. If the number of records returned
+ cannot be determined from the database driver API, we will buffer all rows and
+ return a count of the rows after all the records have been retrieved. This buffering
+ can be disabled (for performance reasons) by setting the global variable $ADODB_COUNTRECS
+ = false. When disabled, RecordCount( ) will return -1 for certain databases.
+ See the supported databases list above for more details. </p>
+<p> RowCount is a synonym for RecordCount.</p>
+<p><b>PO_RecordCount<a name="po_recordcount"></a>($table, $where)</b></p>
+<p>Returns the number of rows in the record set. If the database does not support
+ this, it will perform a SELECT COUNT(*) on the table $table, with the given
+ $where condition to return an estimate of the recordset size.</p>
+<p>$numrows = $rs-&gt;PO_RecordCount(&quot;articles_table&quot;, &quot;group=$group&quot;);</p>
+<b> NextRecordSet<a name="nextrecordset" id="nextrecordset"></a>()</b>
+<p>For databases that allow multiple recordsets to be returned in one query, this
+ function allows you to switch to the next recordset. Currently only supported
+ by mssql driver.</p>
+<pre>
+$rs = $db-&gt;Execute('execute return_multiple_rs');
+$arr1 = $rs-&gt;GetArray();
+$rs-&gt;NextRecordSet();
+$arr2 = $rs-&gt;GetArray();</pre>
+<p><b>FetchObject<a name="fetchobject"></a>($toupper=true)</b></p>
+<p>Returns the current row as an object. If you set $toupper to true, then the
+ object fields are set to upper-case. Note: The newer FetchNextObject() is the
+ recommended way of accessing rows as objects. See below.</p>
+<p><b>FetchNextObject<a name="fetchnextobject"></a>($toupper=true)</b></p>
+<p>Gets the current row as an object and moves to the next row automatically.
+ Returns false if at end-of-file. If you set $toupper to true, then the object
+ fields are set to upper-case.</p>
+<pre>
+$rs = $db->Execute('select firstname,lastname from table');
+if ($rs) &#123;
+ while ($o = $rs->FetchNextObject()) &#123;
+ print "$o->FIRSTNAME, $o->LASTNAME&lt;BR>";
+ &#125;
+&#125;
+</pre>
+<p>There is some trade-off in speed in using FetchNextObject(). If performance
+ is important, you should access rows with the <code>fields[]</code> array. <b>FetchObj<a name="fetchobj" id="fetchobj"></a>()</b>
+<p>Returns the current record as an object. Fields are not upper-cased, unlike
+ FetchObject. </font>
+<p><font color="#000000"><b>FetchNextObj<a name="fetchnextobj" id="fetchnextobj"></a>()</b>
+ </font></p>
+<p><font color="#000000">Returns the current record as an object and moves to
+ the next record. If EOF, false is returned. Fields are not upper-cased, unlike
+ FetctNextObject. </font></p>
+<font color="#000000">
+<p><b>CurrentRow<a name="currentrow"></a>( )</b></p>
+<p>Returns the current row of the record set. 0 is the first row.</p>
+<p><b>AbsolutePosition<a name="abspos"></a>( )</b></p>
+<p>Synonym for <b>CurrentRow</b> for compatibility with ADO. Returns the current
+ row of the record set. 0 is the first row.</p>
+<p><b>MetaType<a name="metatype"></a>($nativeDBType[,$field_max_length],[$fieldobj])</b></p>
+<p>Determine what <i>generic</i> meta type a database field type is given its
+ native type $<b>nativeDBType</b> as a string and the length of the field $<b>field_max_length</b>.
+ Note that field_max_length can be -1 if it is not known. The field object returned
+ by FetchField() can be passed in $<b>fieldobj</b> or as the 1st parameter <b>$nativeDBType</b>.
+ This is useful for databases such as <i>mysql</i> which has additional properties
+ in the field object such as <i>primary_key</i>. </p>
+<p>Uses the field <b>blobSize</b> and compares it with $<b>field_max_length</b>
+ to determine whether the character field is actually a blob.</p>
+For example, $db-&gt;MetaType('char') will return 'C'.
+<p>Returns:</p>
+<ul>
+ <li><b>C</b>: Character fields that should be shown in a &lt;input type=&quot;text&quot;&gt;
+ tag. </li>
+ <li><b>X</b>: Clob (character large objects), or large text fields that should
+ be shown in a &lt;textarea&gt;</li>
+ <li><b>D</b>: Date field</li>
+ <li><b>T</b>: Timestamp field</li>
+ <li><b>L</b>: Logical field (boolean or bit-field)</li>
+ <li><b>N</b>: Numeric field. Includes decimal, numeric, floating point, and
+ real. </li>
+ <li><b>I</b>:&nbsp; Integer field. </li>
+ <li><b>R</b>: Counter or Autoincrement field. Must be numeric.</li>
+ <li><b>B</b>: Blob, or binary large objects.<font color="#000000"> </font></li>
+</ul>
+</font>
+<p><font color="#000000"> Since ADOdb 3.0, MetaType accepts $fieldobj as the first
+ parameter, instead of $nativeDBType. </font></p>
+<font color="#000000">
+<p><b>Close( )<a name="rsclose"></a></b></p>
+<p>Closes the recordset, cleaning all memory and resources associated with the recordset.
+<p>
+If memory management is not an issue, you do not need to call this function as recordsets
+are closed for you by PHP at the end of the script.
+SQL statements such as INSERT/UPDATE/DELETE do not really return a recordset, so you do not have to call Close()
+for such SQL statements.</p>
+<hr>
+<h3>function rs2html<a name="rs2html"></a>($adorecordset,[$tableheader_attributes],
+ [$col_titles])</h3>
+<p>This is a standalone function (rs2html = recordset to html) that is similar
+ to PHP's <i>odbc_result_all</i> function, it prints a ADORecordSet, $<b>adorecordset</b>
+ as a HTML table. $<b>tableheader_attributes</b> allow you to control the table
+ <i>cellpadding</i>, <i>cellspacing</i> and <i>border</i> attributes. Lastly
+ you can replace the database column names with your own column titles with the
+ array $<b>col_titles</b>. This is designed more as a quick debugging mechanism,
+ not a production table recordset viewer.</p>
+<p>You will need to include the file <i>tohtml.inc.php</i>.</p>
+<p>Example of rs2html:<b><font color="#336600"><a name="exrs2html"></a></font></b></p>
+<pre><b><font color="#336600">&lt;?
+include('tohtml.inc.php')</font></b>; # load code common to ADOdb
+<b>include</b>('adodb.inc.php'); # load code common to ADOdb
+$<font color="#663300">conn</font> = &amp;ADONewConnection('mysql'); # create a connection
+$<font color="#663300">conn</font>->PConnect('localhost','userid','','agora');# connect to MySQL, agora db
+$<font color="#663300">sql</font> = 'select CustomerName, CustomerID from customers';
+$<font color="#663300">rs</font> = $<font color="#663300">conn</font>->Execute($sql);
+<font color="#336600"><b>rs2html</b></font><b>($<font color="#663300">rs</font>,'<i>border=2 cellpadding=3</i>',array('<i>Customer Name','Customer ID</i>'));
+?&gt;</b></pre>
+<hr>
+<h3>Differences between this ADOdb library and Microsoft ADO<a name="adodiff"></a></h3>
+<ol>
+ <li>ADOdb only supports recordsets created by a connection object. Recordsets
+ cannot be created independently.</li>
+ <li>ADO properties are implemented as functions in ADOdb. This makes it easier
+ to implement any enhanced ADO functionality in the future.</li>
+ <li>ADOdb's <font face="Courier New, Courier, mono">ADORecordSet-&gt;Move()</font>
+ uses absolute positioning, not relative. Bookmarks are not supported.</li>
+ <li><font face="Courier New, Courier, mono">ADORecordSet-&gt;AbsolutePosition()
+ </font>cannot be used to move the record cursor.</li>
+ <li>ADO Parameter objects are not supported. Instead we have the ADOConnection::<a href="#parameter">Parameter</a>(
+ ) function, which provides a simpler interface for calling preparing parameters
+ and calling stored procedures.</li>
+ <li>Recordset properties for paging records are available, but implemented as
+ in <a href=#ex8>Example 8</a>.</li>
+</ol>
+<hr>
+<h1>Database Driver Guide<a name="driverguide"></a></h1>
+<p>This describes how to create a class to connect to a new database. To ensure
+ there is no duplication of work, kindly email me at jlim#natsoft.com.my if you
+ decide to create such a class.</p>
+<p>First decide on a name in lower case to call the database type. Let's say we
+ call it xbase. </p>
+<p>Then we need to create two classes ADODB_xbase and ADORecordSet_xbase in the
+ file adodb-xbase.inc.php.</p>
+<p>The simplest form of database driver is an adaptation of an existing ODBC driver.
+ Then we just need to create the class <i>ADODB_xbase extends ADODB_odbc</i>
+ to support the new <b>date</b> and <b>timestamp</b> formats, the <b>concatenation</b>
+ operator used, <b>true</b> and <b>false</b>. For the<i> ADORecordSet_xbase extends
+ ADORecordSet_odbc </i>we need to change the <b>MetaType</b> function. See<b>
+ adodb-vfp.inc.php</b> as an example.</p>
+<p>More complicated is a totally new database driver that connects to a new PHP
+ extension. Then you will need to implement several functions. Fortunately, you
+ do not have to modify most of the complex code. You only need to override a
+ few stub functions. See <b>adodb-mysql.inc.php</b> for example.</p>
+<p>The default date format of ADOdb internally is YYYY-MM-DD (Ansi-92). All dates
+ should be converted to that format when passing to an ADOdb date function. See
+ Oracle for an example how we use ALTER SESSION to change the default date format
+ in _pconnect _connect.</p>
+<p><b>ADOConnection Functions to Override</b></p>
+<p>Defining a constructor for your ADOConnection derived function is optional.
+ There is no need to call the base class constructor.</p>
+<p>_<b>connect</b>: Low level implementation of Connect. Returns true or false.
+ Should set the _<b>connectionID</b>.</p>
+<p>_<b>pconnect:</b> Low level implemention of PConnect. Returns true or false.
+ Should set the _<b>connectionID</b>.</p>
+<p>_<b>query</b>: Execute a query. Returns the queryID, or false.</p>
+<p>_<b>close: </b>Close the connection -- PHP should clean up all recordsets.
+</p>
+<p><b>ErrorMsg</b>: Stores the error message in the private variable _errorMsg.
+</p>
+<p><b>ADOConnection Fields to Set</b></p>
+<p>_<b>bindInputArray</b>: Set to true if binding of parameters for SQL inserts
+ and updates is allowed using ?, eg. as with ODBC.</p>
+<p><b>fmtDate</b></p>
+<p><b>fmtTimeStamp</b></p>
+<p><b>true</b></p>
+<p><b>false</b></p>
+<p><b>concat_operator</b></p>
+<p><b>replaceQuote</b></p>
+<p><b>hasLimit</b> support SELECT * FROM TABLE LIMIT 10 of MySQL.</p>
+<p><b>hasTop</b> support Microsoft style SELECT TOP 10 * FROM TABLE.</p>
+<p><b>ADORecordSet Functions to Override</b></p>
+<p>You will need to define a constructor for your ADORecordSet derived class that
+ calls the parent class constructor.</p>
+<p><b>FetchField: </b> as documented above in ADORecordSet</p>
+<p>_<b>initrs</b>: low level initialization of the recordset: setup the _<b>numOfRows</b>
+ and _<b>numOfFields</b> fields -- called by the constructor.</p>
+<p>_<b>seek</b>: seek to a particular row. Do not load the data into the fields
+ array. This is done by _fetch. Returns true or false. Note that some implementations
+ such as Interbase do not support seek. Set canSeek to false.</p>
+<p>_<b>fetch</b>: fetch a row using the database extension function and then move
+ to the next row. Sets the <b>fields</b> array. If the parameter $ignore_fields
+ is true then there is no need to populate the <b>fields</b> array, just move
+ to the next row. then Returns true or false.</p>
+<p>_<b>close</b>: close the recordset</p>
+<p><b>Fields</b>: If the array row returned by the PHP extension is not an associative
+ one, you will have to override this. See adodb-odbc.inc.php for an example.
+ For databases such as MySQL and MSSQL where an associative array is returned,
+ there is no need to override this function.</p>
+<p><b>ADOConnection Fields to Set</b></p>
+<p>canSeek: Set to true if the _seek function works.</p>
+<h2>ToDo:</h2>
+<p>See the <a href=http://php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p>
+<p>Also see the ADOdb <a href=http://php.weblogs.com/adodb_csv>proxy</a> article
+ for bridging Windows and Unix databases using http remote procedure calls. For
+ your education, visit <a href=http://palslib.com/>palslib.com</a> for database info,
+ and read this article on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing
+ PHP</a>. </p>
+</font>
+<h2>Change Log<a name="Changes"></a><a name="changes"></a><a name="changelog"></a></h2>
+<p><a name=4.23></a><b>4.23 ? June 2004</b>
+<p>
+New interbase/firebird fixes thx to Lester Caine.
+Driver fixes a problem with getting field names in the result array, and
+corrects a couple of data conversions. Also we default to dialect3 for firebird.
+Also ibase sysDate property was wrong. Changed to cast as timestamp.
+<p>
+The datadict driver is set up to give quoted tables and fields as this
+was the only way round reserver words being used as field names in
+TikiWiki. TikiPro is tidying that up, and I hope to be able to produce a
+build of THAT which uses what I consider proper UPPERCASE field and
+table names. The conversion of TikiWiki to ADOdb helped in that, but
+until the database is completely tidied up in TikiPro ...
+<p>Modified _gencachename() to include fetchmode in name hash.
+This means you should clear your cache directory after installing this release as the
+cache name algorithm has changed.
+<p>Now Cache* functions work in safe mode, because we do not create sub-directories in the $ADODB_CACHE_DIR in safe mode. In non-safe mode we still create sub-directories. Done by modifying _gencachename().
+<p>Added $gmt parameter (true/false) to UserDate and UserTimeStamp in connection class, to force conversion of input (in local time) to be converted to UTC/GMT.
+<p>Mssql datadict did not support INT types properly (no size param allowed).
+Added _GetSize() to datadict-mssql.inc.php.
+<p>For borland_ibase, BeginTrans(), changed:<br>
+<pre> $this->_transactionID = $this->_connectionID;</pre>
+to<br>
+<pre> $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);</pre>
+
+<p>Fixed typo in mysqi_field_seek(). Thx to Sh4dow (sh4dow#php.pl).
+<p>LogSQL did not work with Firebird/Interbase. Fixed.
+<p>Postgres: made errorno() handling more consistent. Thx to Michael Jahn, Michael.Jahn#mailbox.tu-dresden.de.
+<p>Added informix patch to better support metatables, metacolumns by "Cecilio Albero" c-albero#eos-i.com
+<p>Cyril Malevanov contributed patch to oci8 to support passing of LOB parameters:
+<pre>
+ $text = 'test test test';
+ $sql = "declare rs clob; begin :rs := lobinout(:sa0); end;";
+ $stmt = $conn -> PrepareSP($sql);
+ $conn -> InParameter($stmt,$text,'sa0', -1, OCI_B_CLOB);
+ $rs = '';
+ $conn -> OutParameter($stmt,$rs,'rs', -1, OCI_B_CLOB);
+ $conn -> Execute($stmt);
+ echo "return = ".$rs."&lt;br>";
+</pre>
+As he says, the LOBs limitations are:
+<pre>
+ - use OCINewDescriptor before binding
+ - if Param is IN, uses save() before each execute. This is done automatically for you.
+ - if Param is OUT, uses load() after each execute. This is done automatically for you.
+ - when we bind $var as LOB, we create new descriptor and return it as a
+ Bind Result, so if we want to use OUT parameters, we have to store
+ somewhere &$var to load() data from LOB to it.
+ - IN OUT params are not working now (should not be a big problem to fix it)
+ - now mass binding not working too (I've wrote about it before)
+</pre>
+<p>Simplified Connect() and PConnect() error handling.
+<p>When extension not loaded, Connect() and PConnect() will return null. On connect error, the fns will return false.
+<p>CacheGetArray() added to code.
+<p>Added Init() to adorecordset_empty().
+<p>Changed postgres64 driver, MetaColumns() to not strip off quotes in default value if :: detected (type-casting of default).
+<p>Added test: if (!defined('ADODB_DIR')) die(). Useful to prevent hackers from detecting file paths.
+<p>Changed metaTablesSQL to ignore Postgres 7.4 information schemas (sql_*).
+<p>New polish language file by Grzegorz Pacan
+<p>Added support for UNION in _adodb_getcount().
+<p>Added security check for ADODB_DIR to limit path disclosure issues. Requested by postnuke team.
+<p>Added better error message support to oracle driver. Thx to Gaetano Giunta.
+<p>Added showSchema support to mysql.
+<p>Bind in oci8 did not handle $name=false properly. Fixed.
+<p>If extension not loaded, Connect(), PConnect(), NConnect() will return null.
+<p><b>4.22 15 Apr 2004</b>
+<p>Moved docs to own adodb/docs folder.
+<p>Fixed session bug when quoting compressed/encrypted data in Replace().
+<p>Netezza Driver and LDAP drivers contributed by Josh Eldridge.
+<p>GetMenu now uses rtrim() on values instead of trim().
+<p>Changed MetaColumnNames to return an associative array, keys being the field names in uppercase.
+<p>Suggested fix to adodb-ado.inc.php affected_rows to support PHP5 variants. Thx to Alexios Fakos.
+<p>Contributed bulgarian language file by Valentin Sheiretsky valio#valio.eu.org.
+<p>Contributed romanian language file by stefan bogdan.
+<p>GetInsertSQL now checks for table name (string) in $rs, and will create a recordset for that
+table automatically. Contributed by Walt Boring. Also added OCI_B_BLOB in bind on Walt's request - hope
+it doesn't break anything :-)
+<p>Some minor postgres speedups in _initrs().
+<p> ChangeTableSQL checks now if MetaColumns returns empty. Thx Jason Judge.
+<p>Added ADOConnection::Time(), returns current database time in unix timestamp format, or false.
+<p><b>4.21 20 Mar 2004</b>
+<p>We no longer in SelectLimit for VFP driver add SELECT TOP X unless an ORDER BY exists.
+<p>Pim Koeman contributed dutch language file adodb-nl.inc.php.
+<p>Rick Hickerson added CLOB support to db2 datadict.
+<p>Added odbtp driver. Thx to "stefan bogdan" sbogdan#rsb.ro.
+<p>Changed PrepareSP() 2nd parameter, $cursor, to default to true (formerly false). Fixes oci8 backward
+compat problems with OUT params.
+<p>Fixed month calculation error in adodb-time.inc.php. 2102-June-01 appeared as 2102-May-32.
+<p>Updated PHP5 RC1 iterator support. API changed, hasMore() renamed to valid().
+<p>Changed internal format of serialized cache recordsets. As we store a version number, this should be
+backward compatible.
+<p>Error handling when driver file not found was flawed in ADOLoadCode(). Fixed.
+<p><b>4.20 27 Feb 2004</b>
+<p>Updated to AXMLS 1.01.
+<p>MetaForeignKeys for postgres7 modified by Edward Jaramilla, works on pg 7.4.
+<p>Now numbers accepts function calls or sequences for GetInsertSQL/GetUpdateSQL numeric fields.
+<p>Changed quotes of 'delete from $perf_table' to "". Thx Kehui (webmaster#kehui.net)
+<p>Added ServerInfo() for ifx, and putenv trim fix. Thx Fernando Ortiz.
+<p>Added addq(), which is analogous to addslashes().
+<p>Tested with php5b4. Fix some php5 compat problems with exceptions and sybase.
+<P>Carl-Christian Salvesen added patch to mssql _query to support binds greater than 4000 chars.
+<p>Mike suggested patch to PHP5 exception handler. $errno must be numeric.
+<p>Added double quotes (") to ADODB_TABLE_REGEX.
+<p>For oci8, Prepare(...,$cursor), $cursor's meaning was accidentally inverted in 4.11. This causes problems with ExecuteCursor() too, which calls Prepare() internally. Thx to William Lovaton.
+<p>Now dateHasTime property in connection object renamed to datetime for consistency. This could break bc.
+<p>Csongor Halmai reports that db2 SelectLimit with input array is not working. Fixed..
+<p><b>4.11 27 Jan 2004</b>
+<p>Csongor Halmai reports db2 binding not working. Reverted back to emulated binding.
+<p>Dan Cech modifies datadict code. Adds support for DropIndex. Minor cleanups.
+<p>Table misspelt in perf-oci8.inc.php. Changed v$conn_cache_advice to v$db_cache_advice. Reported by Steve W.
+<p>UserTimeStamp and DBTimeStamp did not handle YYYYMMDDHHMMSS format properly. Reported by Mike Muir. Fixed.
+<p>Changed oci8 Prepare(). Does not auto-allocate OCINewCursor automatically, unless 2nd param is set to true.
+This will break backward compat, if Prepare/Execute is used instead of ExecuteCursor. Reported by Chris Jones.
+<p>Added InParameter() and OutParameter(). Wrapper functions to Parameter(), but nicer because they
+are self-documenting.
+<p>Added 'R' handling in ActualType() to datadict-mysql.inc.php
+<p>Added ADOConnection::SerializableRS($rs). Returns a recordset that can be serialized in a session.
+<p>Added "Run SQL" to performance UI().
+<p>Misc spelling corrections in adodb-mysqli.inc.php, adodb-oci8.inc.php and datadict-oci8.inc.php, from Heinz Hombergs.
+<p>MetaIndexes() for ibase contributed by Heinz Hombergs.
+<p><b>4.10 12 Jan 2004</b>
+<p>Dan Cech contributed extensive changes to data dictionary to support name quoting (with `), and drop table/index.
+<p>Informix added cursorType property. Default remains IFX_SCROLL, but you can change to 0 (non-scrollable cursor) for performance.
+<p>Added ADODB_View_PrimaryKeys() for returning view primary keys to MetaPrimaryKeys().
+<p>Simplified chinese file, adodb-cn.inc.php from cysoft.
+<p>Added check for ctype_alnum in adodb-datadict.inc.php. Thx to Jason Judge.
+<p>Added connection parameter to ibase Prepare(). Fix by Daniel Hassan.
+<p>Added nameQuote for quoting identifiers and names to connection obj. Requested by Jason Judge. Also the
+data dictionary parser now detects `field name` and generates column names with spaces correctly.
+<p>BOOL type not recognised correctly as L. Fixed.
+<p>Fixed paths in ADODB_DIR for session files, and back-ported it to 4.05 (15 Dec 2003)
+<p>Added Schema to postgresql MetaTables. Thx to col#gear.hu
+<p>Empty postgresql recordsets that had blob fields did not set EOF properly. Fixed.
+<p>CacheSelectLimit internal parameters to SelectLimit were wrong. Thx to Nio.
+<p>Modified adodb_pr() and adodb_backtrace() to support command-line usage (eg. no html).
+<p>Fixed some fr and it lang errors. Thx to Gaetano G.
+<p>Added contrib directory, with adodb rs to xmlrpc convertor by Gaetano G.
+<p>Fixed array recordset bugs when _skiprow1 is true. Thx to Gaetano G.
+<p>Fixed pivot table code when count is false.
+<p>
+
+<p><b>4.05 13 Dec 2003 </b>
+<p>Added MetaIndexes - thx to Dan Cech.
+<p>Rewritten session code by Ross Smith. Moved code to adodb/session directory.
+<p>Added function exists check on connecting to most drivers, so we don't crash with the unknown function error.
+<p>Smart Transactions failed with GenID() when it no seq table has been created because the sql
+ statement fails. Fix by Mark Newnham.
+<p>Added $db->length, which holds name of function that returns strlen.
+<p>Fixed error handling for bad driver in ADONewConnection - passed too few params to error-handler.
+<p>Datadict did not handle types like 16.0 properly in _GetSize. Fixed.
+<p>Oci8 driver SelectLimit() bug &= instead of =& used. Thx to Swen Thümmler.
+<p>Jesse Mullan suggested not flushing outp when output buffering enabled. Due to Apache 2.0 bug. Added.
+<p>MetaTables/MetaColumns return ref bug with PHP5 fixed in adodb-datadict.inc.php.
+<p>New mysqli driver contributed by Arjen de Rijke. Based on adodb 3.40 driver.
+Then jlim added BeginTrans, CommitTrans, RollbackTrans, IfNull, SQLDate. Also fixed return ref bug.
+<p>$ADODB_FLUSH added, if true then force flush in debugging outp. Default is false. In earlier
+versions, outp defaulted to flush, which is not compat with apache 2.0.
+<p>Mysql driver's GenID() function did not work when when sql logging is on. Fixed.
+<p>$ADODB_SESSION_TBL not declared as global var. Not available if adodb-session.inc.php included in function. Fixed.
+<p>The input array not passed to Execute() in _adodb_getcount(). Fixed.
+<p><b>4.04 13 Nov 2003 </b>
+<p>Switched back to foreach - faster than list-each.
+<p>Fixed bug in ado driver - wiping out $this->fields with date fields.
+<p>Performance Monitor, View SQL, Explain Plan did not work if strlen($SQL)>max($_GET length). Fixed.
+<p>Performance monitor, oci8 driver added memory sort ratio.
+<p>Added random property, returns SQL to generate a floating point number between 0 and 1;
+<p><b>4.03 6 Nov 2003 </b>
+<p>The path to adodb-php4.inc.php and adodb-iterators.inc.php was not setup properly.
+<p>Patched SQLDate in interbase to support hours/mins/secs. Thx to ari kuorikoski.
+<p>Force autorollback for pgsql persistent connections -
+apparently pgsql did not autorollback properly before 4.3.4. See http://bugs.php.net/bug.php?id=25404
+<p><b>4.02 5 Nov 2003 </b>
+<p>Some errors in adodb_error_pg() fixed. Thx to Styve.
+<p>Spurious Insert_ID() error was generated by LogSQL(). Fixed.
+<p>Insert_ID was interfering with Affected_Rows() and Replace() when LogSQL() enabled. Fixed.
+<p>More foreach loops optimized with list/each.
+<p>Null dates not handled properly in ADO driver (it becomes 31 Dec 1969!).
+<p>Heinz Hombergs contributed patches for mysql MetaColumns - adding scale, made
+interbase MetaColumns work with firebird/interbase, and added lang/adodb-de.inc.php.
+<p>Added INFORMIXSERVER environment variable.
+<p>Added $ADODB_ANSI_PADDING_OFF for interbase/firebird.
+<p>PHP 5 beta 2 compat check. Foreach (Iterator) support. Exceptions support.
+<p><b>4.01 23 Oct 2003 </b>
+<p>Fixed bug in rs2html(), tohtml.inc.php, that generated blank table cells.
+<p>Fixed insert_id() incorrectly generated when logsql() enabled.
+<p>Modified PostgreSQL _fixblobs to use list/each instead of foreach.
+<p>Informix ErrorNo() implemented correctly.
+<p>Modified several places to use list/each, including GetRowAssoc().
+<p>Added UserTimeStamp() to connection class.
+<p>Added $ADODB_ANSI_PADDING_OFF for oci8po.
+<p><b>4.00 20 Oct 2003 </b>
+<p>Upgraded adodb-xmlschema to 1 Oct 2003 snapshot.
+<p>Fix to rs2html warning message. Thx to Filo.
+<p>Fix for odbc_mssql/mssql SQLDate(), hours was wrong.
+<p>Added MetaColumns and MetaPrimaryKeys for sybase. Thx to Chris Phillipson.
+<p>Added autoquoting to datadict for MySQL and PostgreSQL. Suggestion by Karsten Dambekalns
+<p><b>3.94 11 Oct 2003 </b>
+<p>Create trigger in datadict-oci8.inc.php did not work, because all cr/lf's must be removed.
+<p>ErrorMsg()/ErrorNo() did not work for many databases when logging enabled. Fixed.
+<p>Removed global variable $ADODB_LOGSQL as it does not work properly with multiple connections.
+<p>Added SQLDate support for sybase. Thx to Chris Phillipson
+<p>Postgresql checking of pgsql resultset resource was incorrect. Fix by Bharat Mediratta bharat#menalto.com.
+Same patch applied to _insertid and _affectedrows for adodb-postgres64.inc.php.
+<p>Added support for NConnect for postgresql.
+<p>Added Sybase data dict support. Thx to Chris Phillipson
+<p>Extensive improvements in $perf->UI(), eg. Explain now opens in new window, we show scripts
+which call sql, etc.
+<p>Perf Monitor UI works with magic quotes enabled.
+<p>rsPrefix was declared twice. Removed.
+<p>Oci8 stored procedure support, eg. "begin func(); end;" was incorrect in _query. Fixed.
+<p>Tiraboschi Massimiliano contributed italian language file.
+<p>Fernando Ortiz, fortiz#lacorona.com.mx, contributed informix performance monitor.
+<p>Added _varchar (varchar arrays) support for postgresql. Reported by PREVOT Stéphane.
+<p><b>3.92 22 Sept 2003</b>
+<p>Added GetAssoc and CacheGetAssoc to connection object.
+<p>Removed TextMax and CharMax functions from adodb.inc.php.
+<p>HasFailedTrans() returned false when trans failed. Fixed.
+<p>Moved perf driver classes into adodb/perf/*.php.
+<p>Misc improvements to performance monitoring, including UI().
+<p>RETVAL in mssql Parameter(), we do not append @ now.
+<p>Added Param($name) to connection class, returns '?' or ":$name", for defining
+ bind parameters portably.
+<p>LogSQL traps affected_rows() and saves its value properly now. Also fixed oci8
+ _stmt and _affectedrows() bugs.
+<p>Session code timestamp check for oci8 works now. Formerly default NLS_DATE_FORMAT
+ stripped off time portion. Thx to Tony Blair (tonanbarbarian#hotmail.com). Also
+ added new $conn->datetime field to oci8, controls whether MetaType() returns
+ 'D' ($this->datetime==false) or 'T' ($this->datetime == true) for DATE type.
+<p>Fixed bugs in adodb-cryptsession.inc.php and adodb-session-clob.inc.php.
+<p>Fixed misc bugs in adodb_key_exists, GetInsertSQL() and GetUpdateSQL().
+<p>Tuned include_once handling to reduce file-system checking overhead.
+<p><b>3.91 9 Sept 2003</b>
+<p>Only released to InterAkt
+<p>Added LogSQL() for sql logging and $ADODB_NEWCONNECTION to override factory
+ for driver instantiation.
+<p>Added IfNull($field,$ifNull) function, thx to johnwilk#juno.com
+<p>Added portable substr support.
+<p>Now rs2html() has new parameter, $echo. Set to false to return $html instead
+ of echoing it.
+<p><b>3.90 5 Sept 2003</b>
+<p>First beta of performance monitoring released.
+<p>MySQL supports MetaTable() masking.
+<p>Fixed key_exists() bug in adodb-lib.inc.php
+<p>Added sp_executesql Prepare() support to mssql.
+<p>Added bind support to db2.
+<p>Added swedish language file - Christian Tiberg" christian#commsoft.nu
+<p>Bug in drop index for mssql data dict fixed. Thx to Gert-Rainer Bitterlich.
+<p>Left join setting for oci8 was wrong. Thx to johnwilk#juno.com
+<p><b>3.80 27 Aug 2003</b>
+<p>Patch for PHP 4.3.3 cached recordset csv2rs() fread loop incompatibility.
+<p>Added matching mask for MetaTables. Only for oci8, mssql and postgres currently.
+<p>Rewrite of "oracle" driver connection code, merging with "oci8", by Gaetano.
+<p>Added better debugging for Smart Transactions.
+<p>Postgres DBTimeStamp() was wrongly using TO_DATE. Changed to TO_TIMESTAMP.
+<p>ADODB_FETCH_CASE check pushed to ADONewConnection to allow people to define
+ it after including adodb.inc.php.
+<p>Added portugese (brazilian) to languages. Thx to "Levi Fukumori".
+<p>Removed arg3 parameter from Execute/SelectLimit/Cache* functions.
+<p>Execute() now accepts 2-d array as $inputarray. Also changed docs of fnExecute()
+ to note change in sql query counting with 2-d arrays.
+<p>Added MONEY to MetaType in PostgreSQL.
+<p>Added more debugging output to CacheFlush().
+<p><b>3.72 9 Aug 2003</b>
+<p>Added qmagic($str), which is a qstr($str) that auto-checks for magic quotes
+ and does the right thing...
+<p>Fixed CacheFlush() bug - Thx to martin#gmx.de
+<p>Walt Boring contributed MetaForeignKeys for postgres7.
+<p>_fetch() called _BlobDecode() wrongly in interbase. Fixed.
+<p>adodb_time bug fixed with dates after 2038 fixed by Jason Pell. http://phplens.com/lens/lensforum/msgs.php?id=6980
+<p><b>3.71 4 Aug 2003</b>
+<p>The oci8 driver, MetaPrimaryKeys() did not check the owner correctly when $owner
+ == false.
+<p>Russian language file contributed by "Cyrill Malevanov" cyrill#malevanov.spb.ru.
+<p>Spanish language file contributed by "Horacio Degiorgi" horaciod#codigophp.com.
+<p>Error handling in oci8 bugfix - if there was an error in Execute(), then when
+ calling ErrorNo() and/or ErrorMsg(), the 1st call would return the error, but
+ the 2nd call would return no error.
+<p>Error handling in odbc bugfix. ODBC would always return the last error, even
+ if it happened 5 queries ago. Now we reset the errormsg to '' and errorno to
+ 0 everytime before CacheExecute() and Execute().
+<p><b>3.70 29 July 2003</b>
+<p>Added new SQLite driver. Tested on PHP 4.3 and PHP 5.
+<p>Added limited "sapdb" driver support - mainly date support.
+<p>The oci8 driver did not identify NUMBER with no defined precision correctly.
+<p>Added ADODB_FORCE_NULLS, if set, then PHP nulls are converted to SQL nulls
+ in GetInsertSQL/GetUpdateSQL.
+<p>DBDate() and DBTimeStamp() format for postgresql had problems. Fixed.
+<p>Added tableoptions to ChangeTableSQL(). Thx to Mike Benoit.
+<p>Added charset support to postgresql. Thx to Julian Tarkhanov.
+<p>Changed OS check for MS-Windows to prevent confusion with darWIN (MacOS)
+<p>Timestamp format for db2 was wrong. Changed to yyyy-mm-dd-hh.mm.ss.nnnnnn.
+<p>adodb-cryptsession.php includes wrong. Fixed.
+<p>Added MetaForeignKeys(). Supported by mssql, odbc_mssql and oci8.
+<p>Fixed some oci8 MetaColumns/MetaPrimaryKeys bugs. Thx to Walt Boring.
+<p>adodb_getcount() did not init qryRecs to 0. Missing "WHERE" clause checking
+ in GetUpdateSQL fixed. Thx to Sebastiaan van Stijn.
+<p>Added support for only 'VIEWS' and "TABLES" in MetaTables. From Walt Boring.
+<p>Upgraded to adodb-xmlschema.inc.php 0.0.2.
+<p>NConnect for mysql now returns value. Thx to Dennis Verspuij.
+<p>ADODB_FETCH_BOTH support added to interbase/firebird.
+<p>Czech language file contributed by Kamil Jakubovic jake#host.sk.
+<p>PostgreSQL BlobDecode did not use _connectionID properly. Thx to Juraj Chlebec.
+<p>Added some new initialization stuff for Informix. Thx to "Andrea Pinnisi" pinnisi#sysnet.it
+<p>ADODB_ASSOC_CASE constant wrong in sybase _fetch(). Fixed.
+<p><b>3.60 16 June 2003</b>
+<p>We now SET CONCAT_NULL_YIELDS_NULL OFF for odbc_mssql driver to be compat with
+ mssql driver.
+<p>The property $emptyDate missing from connection class. Also changed 1903 to
+ constant (TIMESTAMP_FIRST_YEAR=100). Thx to Sebastiaan van Stijn.
+<p>ADOdb speedup optimization - we now return all arrays by reference.
+<p>Now DBDate() and DBTimeStamp() now accepts the string 'null' as a parameter.
+ Suggested by vincent.
+<p>Added GetArray() to connection class.
+<p>Added not_null check in informix metacolumns().
+<p>Connection parameters for postgresql did not work correctly when port was defined.
+<p>DB2 is now a tested driver, making adodb 100% compatible. Extensive changes
+ to odbc driver for DB2, including implementing serverinfo() and SQLDate(), switching
+ to SQL_CUR_USE_ODBC as the cursor mode, and lastAffectedRows and SelectLimit()
+ fixes.
+<p>The odbc driver's FetchField() field names did not obey ADODB_ASSOC_CASE. Fixed.
+<p>Some bugs in adodb_backtrace() fixed.
+<p>Added "INT IDENTITY" type to adorecordset::MetaType() to support odbc_mssql
+ properly.
+<p>MetaColumns() for oci8, mssql, odbc revised to support scale. Also minor revisions
+ to odbc MetaColumns() for vfp and db2 compat.
+<p>Added unsigned support to mysql datadict class. Thx to iamsure.
+<p>Infinite loop in mssql MoveNext() fixed when ADODB_FETCH_ASSOC used. Thx to
+ Josh R, Night_Wulfe#hotmail.com.
+<p>ChangeTableSQL contributed by Florian Buzin.
+<p>The odbc_mssql driver now sets CONCAT_NULL_YIELDS_NULL OFF for compat with
+ mssql driver.
+<hr>
+<p><strong>0.10 Sept 9 2000</strong> First release
+<h3><strong>Old changelog history moved to <a href=old-changelog.htm>old-changelog.htm</a>.
+ </strong></h3>
+<p>&nbsp;</p>
+<p> </font>
+</body>
+</html>
diff --git a/html/phpgacl/adodb/docs/docs-datadict.htm b/html/phpgacl/adodb/docs/docs-datadict.htm
new file mode 100644
index 0000000..390dfb8
--- /dev/null
+++ b/html/phpgacl/adodb/docs/docs-datadict.htm
@@ -0,0 +1,553 @@
+<html>
+ <head>
+ <title>ADODB Data Dictionary Manual</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <style type="text/css">
+ body, td {
+ /*font-family: Arial, Helvetica, sans-serif;*/
+ font-size: 11pt;
+ }
+ pre {
+ font-size: 9pt;
+ }
+ .toplink {
+ font-size: 8pt;
+ }
+ </style>
+ </head>
+ <body bgcolor="#FFFFFF">
+
+<h2>ADOdb Data Dictionary Library for PHP</h2>
+<p>V4.23 16 June 2004 (c) 2000-2004 John Lim (<a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>).<br> AXMLS (c) 2004 ars Cognita, Inc</p>
+<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This means you can use it in compiled proprietary and commercial products.</font></p>
+ <table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
+ unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
+ <p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
+
+<p>This documentation describes a PHP class library to automate the creation of tables,
+ indexes and foreign key constraints portably for multiple databases. Richard Tango-Lowy and Dan Cech
+ have been kind enough to contribute <a href=#xmlschema>AXMLS</a>, an XML schema system for defining databases.</p>
+
+<p>Currently the following databases are supported:</p>
+<p>
+ <b>Well-tested:</b> PostgreSQL, MySQL, Oracle, MSSQL.<br />
+ <b>Beta-quality:</b> DB2, Informix, Sybase, Interbase, Firebird.<br />
+ <b>Alpha-quality:</b> MS Access (does not support DEFAULT values) and generic ODBC.
+</p>
+
+<h3>Example Usage</h3>
+<pre>
+ include_once('adodb.inc.php');
+ <font color="#006600"># First create a normal connection</font>
+ $db->NewADOConnection('mysql');
+ $db->Connect(...);
+
+ <font color="#006600"># Then create a data dictionary object, using this connection</font>
+ $dict = <strong>NewDataDictionary</strong>($db);
+
+ <font color="#006600"># We have a portable declarative data dictionary format in ADOdb, similar to SQL.
+ # Field types use 1 character codes, and fields are separated by commas.
+ # The following example creates three fields: "col1", "col2" and "col3":</font>
+ $flds = "
+ <font color="#663300"><strong> col1 C(32) NOTNULL DEFAULT 'abc',
+ col2 I DEFAULT 0,
+ col3 N(12.2)</strong></font>
+ ";
+
+ <font color="#006600"># We demonstrate creating tables and indexes</font>
+ $sqlarray = $dict-><strong>CreateTableSQL</strong>($tabname, $flds, $taboptarray);
+ $dict-><strong>ExecuteSQLArray</strong>($sqlarray);<br>
+ $idxflds = 'co11, col2';
+ $sqlarray = $dict-><strong>CreateIndexSQL</strong>($idxname, $tabname, $idxflds);
+ $dict-><strong>ExecuteSQLArray</strong>($sqlarray);
+</pre>
+
+<h3>Functions</h3>
+
+<h4>function CreateDatabase($dbname, $optionsarray=false)</h4>
+<p>Create a database with the name $dbname;</p>
+
+<h4>function CreateTableSQL($tabname, $fldarray, $taboptarray=false)</h4>
+<pre>
+ RETURNS: an array of strings, the sql to be executed, or false
+ $tabname: name of table
+ $fldarray: string (or array) containing field info
+ $taboptarray: array containing table options
+</pre>
+<p>The new format of $fldarray uses a free text format, where each field is comma-delimited.
+The first token for each field is the field name, followed by the type and optional
+field size. Then optional keywords in $otheroptions:</p>
+<pre> "$fieldname $type $colsize $otheroptions"</pre>
+<p>The older (and still supported) format of $fldarray is a 2-dimensional array, where each row in the 1st dimension represents one field. Each row has this format:</p>
+<pre> array($fieldname, $type, [,$colsize] [,$otheroptions]*)</pre>
+
+<p>The first 2 fields must be the field name and the field type. The field type can be a portable type codes or the actual type for that database.</p>
+<p>Legal portable type codes include:</p>
+<pre>
+ C: varchar
+ X: Largest varchar size
+ XL: For Oracle, returns CLOB, otherwise same as 'X' above
+
+ C2: Multibyte varchar
+ X2: Multibyte varchar (largest size)
+
+ B: BLOB (binary large object)
+
+ D: Date (some databases do not support this, and we return a datetime type)
+ T: Datetime or Timestamp
+ L: Integer field suitable for storing booleans (0 or 1)
+ I: Integer (mapped to I4)
+ I1: 1-byte integer
+ I2: 2-byte integer
+ I4: 4-byte integer
+ I8: 8-byte integer
+ F: Floating point number
+ N: Numeric or decimal number
+</pre>
+<p>The $colsize field represents the size of the field. If a decimal number is used, then it is assumed that the number following the dot is the precision, so 6.2 means a number of size 6 digits and 2 decimal places. It is recommended that the default for number types be represented as a string to avoid any rounding errors.</p>
+<p>The $otheroptions include the following keywords (case-insensitive):</p>
+<pre>
+ AUTO For autoincrement number. Emulated with triggers if not available.
+ Sets NOTNULL also.
+ AUTOINCREMENT Same as auto.
+ KEY Primary key field. Sets NOTNULL also. Compound keys are supported.
+ PRIMARY Same as KEY.
+ DEF Synonym for DEFAULT for lazy typists.
+ DEFAULT The default value. Character strings are auto-quoted unless
+ the string begins and ends with spaces, eg ' SYSDATE '.
+ NOTNULL If field is not null.
+ DEFDATE Set default value to call function to get today's date.
+ DEFTIMESTAMP Set default to call function to get today's datetime.
+ NOQUOTE Prevents autoquoting of default string values.
+ CONSTRAINTS Additional constraints defined at the end of the field
+ definition.
+</pre>
+<p>The Data Dictonary accepts two formats, the older array specification:</p>
+<pre>
+ $flds = array(
+ array('COLNAME', 'DECIMAL', '8.4', 'DEFAULT' => 0, 'NOTNULL'),
+ array('id', 'I' , 'AUTO'),
+ array('`MY DATE`', 'D' , 'DEFDATE'),
+ array('NAME', 'C' , '32', 'CONSTRAINTS' => 'FOREIGN KEY REFERENCES reftable')
+ );
+</pre>
+<p>Or the simpler declarative format:</p>
+<pre>
+ $flds = "<font color="#660000"><strong>
+ COLNAME DECIMAL(8.4) DEFAULT 0 NOTNULL,
+ id I AUTO,
+ `MY DATE` D DEFDATE,
+ NAME C(32) CONSTRAINTS 'FOREIGN KEY REFERENCES reftable'</strong></font>
+ ";
+</pre>
+<p>Note that if you have special characters in the field name (e.g. My Date), you should enclose it in back-quotes. Normally field names are not case-sensitive, but if you enclose it in back-quotes, some databases will treat the names as case-sensitive (eg. Oracle) , and others won't. So be careful.</p>
+
+<p>The $taboptarray is the 3rd parameter of the CreateTableSQL function. This contains table specific settings. Legal keywords include:</p>
+<ul>
+ <li><b>REPLACE</b><br />
+ Indicates that the previous table definition should be removed (dropped)together with ALL data. See first example below.
+ </li>
+ <li><b>DROP</b><br />
+ Drop table. Useful for removing unused tables.
+ </li>
+ <li><b>CONSTRAINTS</b><br />
+ Define this as the key, with the constraint as the value. See the postgresql example below.
+ Additional constraints defined for the whole table. You will probably need to prefix this with a comma.
+ </li>
+</ul>
+
+<p>Database specific table options can be defined also using the name of the database type as the array key. In the following example, <em>create the table as ISAM with MySQL, and store the table in the &quot;users&quot; tablespace if using Oracle</em>. And because we specified REPLACE, drop the table first.</p>
+<pre> $taboptarray = array('mysql' => 'TYPE=ISAM', 'oci8' => 'tablespace users', 'REPLACE');</pre>
+
+<p>You can also define foreignkey constraints. The following is syntax for postgresql:
+<pre> $taboptarray = array('constraints' => ', FOREIGN KEY (col1) REFERENCES reftable (refcol)');</pre>
+
+<h4>function DropTableSQL($tabname)</h4>
+<p>Returns the SQL to drop the specified table.</p>
+
+<h4>function ChangeTableSQL($tabname, $flds)</h4>
+<p>Checks to see if table exists, if table does not exist, behaves like CreateTableSQL.
+ If table exists, generates appropriate ALTER TABLE MODIFY COLUMN commands if
+ field already exists, or ALTER TABLE ADD $column if field does not exist.</p>
+<p>The class must be connected to the database for ChangeTableSQL to detect the
+ existence of the table. Idea and code contributed by Florian Buzin.</p>
+
+<h4>function CreateIndexSQL($idxname, $tabname, $flds, $idxoptarray=false)</h4>
+<pre>
+ RETURNS: an array of strings, the sql to be executed, or false
+ $idxname: name of index
+ $tabname: name of table
+ $flds: list of fields as a comma delimited string or an array of strings
+ $idxoptarray: array of index creation options
+</pre>
+<p>$idxoptarray is similar to $taboptarray in that index specific information can be embedded in the array. Other options include:</p>
+<pre>
+ CLUSTERED Create clustered index (only mssql)
+ BITMAP Create bitmap index (only oci8)
+ UNIQUE Make unique index
+ FULLTEXT Make fulltext index (only mysql)
+ HASH Create hash index (only postgres)
+ DROP Drop legacy index
+</pre>
+
+<h4>function DropIndexSQL ($idxname, $tabname = NULL)</h4>
+<p>Returns the SQL to drop the specified index.</p>
+
+<h4>function AddColumnSQL($tabname, $flds)</h4>
+<p>Add one or more columns. Not guaranteed to work under all situations.</p>
+
+<h4>function AlterColumnSQL($tabname, $flds)</h4>
+<p>Warning, not all databases support this feature.</p>
+
+<h4>function DropColumnSQL($tabname, $flds)</h4>
+<p>Drop 1 or more columns.</p>
+
+<h4>function SetSchema($schema)</h4>
+<p>Set the schema.</p>
+
+<h4>function &amp;MetaTables()</h4>
+<h4>function &amp;MetaColumns($tab, $upper=true, $schema=false)</h4>
+<h4>function &amp;MetaPrimaryKeys($tab,$owner=false,$intkey=false)</h4>
+<h4>function &amp;MetaIndexes($table, $primary = false, $owner = false)</h4>
+<p>These functions are wrappers for the corresponding functions in the connection object. However, the table names will be autoquoted by the TableName function (see below) before being passed to the connection object.</p>
+
+<h4>function NameQuote($name = NULL)</h4>
+<p>If the provided name is quoted with backquotes (`) or contains special characters, returns the name quoted with the appropriate quote character, otherwise the name is returned unchanged.</p>
+
+<h4>function TableName($name)</h4>
+<p>The same as NameQuote, but will prepend the current schema if specified</p>
+
+<h4>function MetaType($t,$len=-1,$fieldobj=false)</h4>
+<h4>function ActualType($meta)</h4>
+<p>Convert between database-independent 'Meta' and database-specific 'Actual' type codes.</p>
+
+<h4>function ExecuteSQLArray($sqlarray, $contOnError = true)</h4>
+<pre>
+ RETURNS: 0 if failed, 1 if executed all but with errors, 2 if executed successfully
+ $sqlarray: an array of strings with sql code (no semicolon at the end of string)
+ $contOnError: if true, then continue executing even if error occurs
+</pre>
+<p>Executes an array of SQL strings returned by CreateTableSQL or CreateIndexSQL.</p>
+
+<hr />
+
+<a name=xmlschema></a>
+<h2>ADOdb XML Schema (AXMLS)</h2>
+<p>This is a class contributed by Richard Tango-Lowy and Dan Cech that allows the user to quickly
+and easily build a database using the excellent ADODB database library and a simple XML formatted file.
+You can <a href=http://sourceforge.net/projects/adodb-xmlschema/>download the latest version of AXMLS here</a>.</p>
+
+<h3>Quick Start</h3>
+<p>First, create an XML database schema. Let's call it "schema.xml:"</p>
+<pre>
+ &lt;?xml version="1.0"?&gt;
+ &lt;schema version=&quot;0.2&quot;&gt;
+ &lt;table name="mytable"&gt;
+ &lt;field name="row1" type="I"&gt;
+ &lt;descr&gt;An integer row that's a primary key and autoincrements&lt;/descr&gt;
+ &lt;KEY/&gt;
+ &lt;AUTOINCREMENT/&gt;
+ &lt;/field&gt;
+ &lt;field name="row2" type="C" size="16"&gt;
+ &lt;descr&gt;A 16 character varchar row that can't be null&lt;/descr&gt;
+ &lt;NOTNULL/&gt;
+ &lt;/field&gt;
+ &lt;index name=&quot;myindex&quot;&gt;
+ &lt;col&gt;row1&lt;/col&gt;
+ &lt;col&gt;row2&lt;/col&gt;
+ &lt;/index&gt;
+ &lt;/table&gt;
+ &lt;sql&gt;
+ &lt;descr&gt;SQL to be executed only on specific platforms&lt;/descr&gt;
+ &lt;query platform="postgres|postgres7"&gt;
+ insert into mytable ( row1, row2 ) values ( 12, 'stuff' )
+ &lt;/query&gt;
+ &lt;query platform="mysql"&gt;
+ insert into mytable ( row1, row2 ) values ( 12, 'different stuff' )
+ &lt;/query&gt;
+ &lt;/sql&gt;
+ &lt;/schema&gt;
+</pre>
+
+<p>Create a new database using the appropriate tool for your platform.<br />
+Executing the following PHP code will create the a <i>mytable</i> and <i>myindex</i>
+in the database and insert one row into <i>mytable</i> if the platform is postgres or mysql.</p>
+
+<pre>
+ include_once('/path/to/adodb.inc.php');
+ include_once('/path/to/adodb-xmlschema.inc.php');
+
+ <font color="#006600">// To build the schema, start by creating a normal ADOdb connection:</font>
+ $db->NewADOConnection( 'mysql' );
+ $db->Connect( ... );
+
+ <font color="#006600">// Create the schema object and build the query array.</font>
+ $schema = new <b>adoSchema</b>( $db );
+
+ <font color="#006600">// Optionally, set a prefix for newly-created tables. In this example
+ // the prefix "myprefix_" will result in a table named "myprefix_tablename".</font>
+ $schema-><b>SetPrefix</b>( 'myprefix_' );
+
+ <font color="#006600">// Build the SQL array</font>
+ $schema-><b>ParseSchema</b>( 'schema.xml' );
+
+ <font color="#006600">// Execute the SQL on the database</font>
+ $result = $schema-><b>ExecuteSchema</b>();
+
+ <font color="#006600">// Finally, clean up after the XML parser
+ // (PHP won't do this for you!)</font>
+ $schema-><b>Destroy</b>();
+</pre>
+
+
+<h3>Using AXMLS in Your
+ Application</h3>
+
+ <p>
+There are two steps involved in using
+ AXMLS in your application: first,
+ you must create a schema, or XML representation of your
+ database, and second, you must create the PHP code that will
+ parse and execute the schema.</p>
+ <p>Let's begin with a schema that describes a typical, if simplistic
+ user management table for an application.</p>
+ <pre class="listing"><pre>
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;schema version=&quot;0.2&quot;&gt;
+
+ &lt;table name=&quot;users&quot;&gt;
+ &lt;desc&gt;A typical users table for our application.&lt;/desc&gt;
+ &lt;field name=&quot;userId&quot; type=&quot;I&quot;&gt;
+ &lt;descr&gt;A unique ID assigned to each user.&lt;/descr&gt;
+ &lt;KEY/&gt;
+ &lt;AUTOINCREMENT/&gt;
+ &lt;/field&gt;
+
+ &lt;field name=&quot;userName&quot; type=&quot;C&quot; size=&quot;16&quot;&gt;&lt;NOTNULL/&gt;&lt;/field&gt;
+
+ &lt;index name=&quot;userName&quot;&gt;
+ &lt;descr&gt;Put a unique index on the user name&lt;/descr&gt;
+ &lt;col&gt;userName&lt;/col&gt;
+ &lt;UNIQUE/&gt;
+ &lt;/index&gt;
+ &lt;/table&gt;
+
+ &lt;sql&gt;
+ &lt;descr&gt;Insert some data into the users table.&lt;/descr&gt;
+ &lt;query&gt;insert into users (userName) values ( 'admin' )&lt;/query&gt;
+ &lt;query&gt;insert into users (userName) values ( 'Joe' )&lt;/query&gt;
+ &lt;/sql&gt;
+&lt;/schema&gt;
+</pre></pre>
+ <p>Let's take a detailed look at this schema.</p>
+ <p>The opening &lt;?xml version=&quot;1.0&quot;?&gt; tag is
+ required by XML. The &lt;schema&gt; tag
+ tells the parser that the enclosed markup defines an XML
+ schema. The version=&quot;0.2&quot; attribute sets
+ <em>the version of the AXMLS DTD used by the XML
+ schema.</em> <p>All versions of AXMLS prior
+ to version 1.0 have a schema version of &quot;0.1&quot;. The current
+ schema version is &quot;0.2&quot;.</p></p>
+ <pre class="listing"><pre>
+&lt;?xml version=&quot;1.0&quot;?&gt;
+&lt;schema version=&quot;0.2&quot;&gt;
+ ...
+&lt;/schema&gt;
+</pre></pre>
+ <p>Next we define one or more tables. A table consists of a
+ fields (and other objects) enclosed by
+ &lt;table&gt; tags. The
+ name=&quot;&quot; attribute specifies the name of
+ the table that will be created in the database.</p>
+ <pre class="listing"><pre>
+&lt;table name=&quot;users&quot;&gt;
+
+ &lt;desc&gt;A typical users table for our application.&lt;/desc&gt;
+ &lt;field name=&quot;userId&quot; type=&quot;I&quot;&gt;
+ &lt;descr&gt;A unique ID assigned to each user.&lt;/descr&gt;
+ &lt;KEY/&gt;
+ &lt;AUTOINCREMENT/&gt;
+ &lt;/field&gt;
+
+ &lt;field name=&quot;userName&quot; type=&quot;C&quot; size=&quot;16&quot;&gt;&lt;NOTNULL/&gt;&lt;/field&gt;
+
+&lt;/table&gt;
+</pre></pre>
+ <p>This table is called &quot;users&quot; and has a description and
+ two fields. The description is optional, and is currently
+ only for your own information; it is not applied to the
+ database.</p>
+ <p>The first &lt;field&gt; tag will create
+ a field named &quot;userId&quot; of type &quot;I&quot;, or integer. (See the
+ ADOdb Data Dictionary
+ documentation for a list of valid types.) This
+ &lt;field&gt; tag encloses two special
+ field options: &lt;KEY/&gt;, which
+ specifies this field as a primary key, and
+ &lt;AUTOINCREMENT/&gt;, which specifies
+ that the database engine should automatically fill this
+ field with the next available value when a new row is
+ inserted.</p>
+ <p>The second &lt;field&gt; tag will create
+ a field named &quot;userName&quot; of type &quot;C&quot;, or character, and of
+ length 16 characters. The &lt;NOTNULL/&gt;
+ option specifies that this field does not allow
+ NULLs.</p>
+ <p>There are two ways to add indexes to a table. The
+ simplest is to mark a field with the
+ &lt;KEY/&gt; option as described above; a
+ primary key is a unique index. The second and more powerful
+ method uses the &lt;index&gt; tags.</p>
+ <pre class="listing"><pre>
+&lt;table name=&quot;users&quot;&gt;
+ ...
+
+ &lt;index name=&quot;userName&quot;&gt;
+ &lt;descr&gt;Put a unique index on the user name&lt;/descr&gt;
+ &lt;col&gt;userName&lt;/col&gt;
+ &lt;UNIQUE/&gt;
+ &lt;/index&gt;
+
+&lt;/table&gt;
+</pre></pre>
+ <p>The &lt;index&gt; tag specifies that an
+ index should be created on the enclosing table. The
+ name=&quot;&quot; attribute provides the name of the
+ index that will be created in the database. The
+ description, as above, is for your information only. The
+ &lt;col&gt; tags list each column that
+ will be included in the index. Finally, the
+ &lt;UNIQUE/&gt; tag specifies that this
+ will be created as a unique index.</p>
+ <p>Finally, AXMLS allows you to include arbitrary SQL that
+ will be applied to the database when the schema is
+ executed.</p>
+ <pre class="listing"><pre>
+&lt;sql&gt;
+ &lt;descr&gt;Insert some data into the users table.&lt;/descr&gt;
+ &lt;query&gt;insert into users (userName) values ( 'admin' )&lt;/query&gt;
+ &lt;query&gt;insert into users (userName) values ( 'Joe' )&lt;/query&gt;
+&lt;/sql&gt;
+</pre></pre>
+ <p>The &lt;sql&gt; tag encloses any number
+ of SQL queries that you define for your own use.</p>
+ <p>Now that we've defined an XML schema, you need to know how to
+ apply it to your database. Here's a simple PHP script that shows
+ how to load the schema.</p>
+ <p><pre class="listing"><pre>
+&lt;?PHP
+/* You must tell the script where to find the ADOdb and
+ * the AXMLS libraries.
+ */
+require( &quot;path_to_adodb/adodb.inc.php&quot;);
+require( &quot;path_to_adodb/adodb-xmlschema.inc.php&quot; );
+
+/* Configuration information. Define the schema filename,
+ * RDBMS platform (see the ADODB documentation for valid
+ * platform names), and database connection information here.
+ */
+$schemaFile = 'example.xml';
+$platform = 'mysql';
+$dbHost = 'localhost';
+$dbName = 'database';
+$dbUser = 'username';
+$dbPassword = 'password';
+
+/* Start by creating a normal ADODB connection.
+ */
+$db = ADONewConnection( $platform );
+$db-&gt;Connect( $dbHost, $dbUser, $dbPassword, $dbName );
+
+/* Use the database connection to create a new adoSchema object.
+ */
+$schema = new adoSchema( $db );
+
+/* Call ParseSchema() to build SQL from the XML schema file.
+ * Then call ExecuteSchema() to apply the resulting SQL to
+ * the database.
+ */
+$sql = $schema-&gt;ParseSchema( $schemaFile );
+$result = $schema-&gt;ExecuteSchema();
+?&gt;
+</pre></pre></p>
+ <p>Let's look at each part of the example in turn. After you
+ manually create the database, there are three steps required to
+ load (or upgrade) your schema.</p>
+ <p>First, create a normal ADOdb connection. The variables
+ and values here should be those required to connect to your
+ database.</p>
+ <pre class="listing"><pre>
+$db = ADONewConnection( 'mysql' );
+$db-&gt;Connect( 'host', 'user', 'password', 'database' );
+</pre></pre>
+ <p>Second, create the adoSchema object that load and
+ manipulate your schema. You must pass an ADOdb database
+ connection object in order to create the adoSchema
+ object.</p>
+ <pre class="listing"><pre>
+$schema = new adoSchema( $db );
+</pre></pre>
+ <p>Third, call ParseSchema() to parse the
+ schema and then ExecuteSchema() to apply
+ it to the database. You must pass
+ ParseSchema() the path and filename of
+ your schema file.</p>
+ <pre class="listing"><pre>
+$schema-&gt;ParseSchema( $schemaFile );
+$schema-&gt;ExecuteSchema();
+</pre></pre>
+ <p>Execute the above code and then log into your database. If you've
+ done all this right, you should see your tables, indexes, and
+ SQL.</p>
+ <p>You can find the source files for this tutorial in the
+ examples directory as
+ tutorial_shema.xml and
+ tutorial.php. See the class documentation for
+ a more detailed description of the adoSchema methods, including
+ methods and schema elements that are not described in this
+ tutorial.</p>
+
+<H3>XML Schema Format:</H3>
+<P>(See <a href="xmlschema.dtd">xmlschema.dtd</a> for the full specification)</P>
+<PRE>
+ &lt;?xml version="1.0"?&gt;
+ &lt;schema version=&quot;0.2&quot;&gt;
+ &lt;table name="tablename" platform="platform1|platform2|..."&gt;
+ &lt;descr&gt;Optional description&lt;/descr&gt;
+ &lt;field name="fieldname" type="datadict_type" size="size"&gt;
+ &lt;KEY/&gt;
+ &lt;NOTNULL/&gt;
+ &lt;AUTOINCREMENT/&gt;
+ &lt;DEFAULT value="value"/&gt;
+ &lt;/field&gt;
+ <i> ... more fields</i>
+ &lt;index name="indexname" platform="platform1|platform2|..."&gt;
+ &lt;descr&gt;Optional description&lt;/descr&gt;
+ &lt;col&gt;fieldname&lt;/col&gt;
+ <i> ... more columns</i>
+ &lt;/index&gt;
+ <i> ... more indexes</i>
+ &lt;/table&gt;
+ <i> ... more tables</i>
+
+ &lt;sql platform="platform1|platform2|..."&gt;
+ &lt;descr&gt;Optional description&lt;/descr&gt;
+ &lt;query platform="platform1|platform2|..."&gt;SQL query&lt;/query&gt;
+ <i> ... more queries</i>
+ &lt;/sql&gt;
+ <i> ... more SQL</i>
+ &lt;/schema&gt;
+</pre>
+
+<h3>Upgrading</h3>
+If your schema version is older, than XSLT is used to transform the schema to the newest version.
+This means that if you are using an older XML schema format, you need to have the XSLT extension installed.
+If you do not want to require your users to have the XSLT extension installed, make sure you
+modify your XML schema to conform to the latest version.
+<hr />
+
+<address>If you have any questions or comments, please email them to Richard at richtl#arscognita.com.
+</address>
+
+</body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/adodb/docs/docs-perf.htm b/html/phpgacl/adodb/docs/docs-perf.htm
new file mode 100644
index 0000000..5cc5ed9
--- /dev/null
+++ b/html/phpgacl/adodb/docs/docs-perf.htm
@@ -0,0 +1,388 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+<head>
+ <title>ADOdb Performance Monitoring Library</title>
+</head>
+
+<body>
+<h3>The ADOdb Performance Monitoring Library</h3>
+<p>V4.23 16 June 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)</p>
+<p><font size="1">This software is dual licensed using BSD-Style and LGPL. This
+ means you can use it in compiled proprietary and commercial products.</font></p>
+ <table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
+ unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td></tr></table>
+ <p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
+<h3>Introduction</h3>
+<p>This module, part of the ADOdb package, provides both CLI and HTML interfaces
+ for viewing key performance indicators of your database. This is very useful
+ because web apps such as the popular phpMyAdmin currently do not provide effective
+ database health monitoring tools. The module provides the following:
+<ul>
+ <li>A quick health check of your database server using <code>$perf->HealthCheck()</code>
+ or <code>$perf->HealthCheckCLI()</code>.
+ <li>User interface for performance monitoring, <code>$perf-&gt;UI()</code>.
+ This UI displays:
+ <ul>
+ <li>the health check, </li>
+ <li>all SQL logged and their query plans, </li>
+ <li>a list of all tables in the current database</li>
+ <li>an interface to continiously poll the server for key performance indicators
+ such as CPU, Hit Ratio, Disk I/O</li>
+ <li>a form where you can enter and run SQL interactively.</li>
+ </ul>
+ <li>Gives you an API to build database monitoring tools for a server farm, for
+ example calling <code>$perf->DBParameter('data cache hit ratio')</code> returns
+ this very important statistic in a database independant manner.
+</ul>
+<p>ADOdb also has the ability to log all SQL executed, using <a href=docs-adodb.htm#logsql>LogSQL</a>.
+ All SQL logged can be analyzed through the performance monitor <a href=#ui>UI</a>.
+ In the <i>View SQL</i> mode, we categorize the SQL into 3 types:
+<ul>
+ <li><b>Suspicious SQL</b>: queries with high average execution times, and are potential
+ candidates for rewriting</li>
+ <li><b>Expensive SQL</b>: queries with high total execution times (#executions * avg
+ execution time). Optimizing these queries will reduce your database server
+ load.</li>
+ <li><b>Invalid SQL</b>: queries that generate errors.</li>
+</ul>
+<p>Each query is hyperlinked to a description of the query plan, and every PHP
+ script that executed that query is also shown.</p>
+<p>Please note that the information presented is a very basic database health
+ check, and does not provide a complete overview of database performance. Although
+ some attempt has been made to make it work across multiple databases in the
+ same way, it is impossible to do so. For the health check, we do try to display
+ the following key database parameters for all drivers:</p>
+<ul>
+ <li><b>data cache size</b> - The amount of memory allocated to the cache.</li>
+ <li><b>data cache hit ratio</b> - A measure of how effective the cache is, as a percentage.
+ The higher, the better.</li>
+ <li><b>current connections</b> - The number of sessions currently connected to the
+ database. </li>
+</ul>
+<p>You will need to connect to the database as an administrator to view most of
+ the parameters. </p>
+<p>Code improvements as very welcome, particularly adding new database parameters
+ and automated tuning hints.</p><a name=usage></a>
+<h3>Usage</h3>
+<p>Currently, the following drivers: <em>mysql</em>, <em>postgres</em>, <em>oci8</em>,
+ <em>mssql</em>, <i>informix</i> and <em>db2</em> are supported. To create a
+ new performance monitor, call NewPerfMonitor( ) as demonstrated below: </p>
+<pre>
+&lt;?php
+include_once('adodb.inc.php');
+session_start(); <font color="#006600"># session variables required for monitoring</font>
+$conn = ADONewConnection($driver);
+$conn-&gt;Connect($server,$user,$pwd,$db);
+$perf =&amp; NewPerfMonitor($conn);
+$perf-&gt;UI($pollsecs=5);<font color="#006600"></font>
+?>
+</pre>
+<p>It is also possible to retrieve a single database parameter:</p>
+<pre>$size = $perf->DBParameter('data cache size');
+</pre>
+<p>
+Thx to Fernando Ortiz for the informix module.
+<h3>Methods</h3><a name=ui></a>
+<p><font face="Courier New, Courier, mono">function <b>UI($pollsecs=5)</b></font></p>
+<p>Creates a web-based user interface for performance monitoring. When you click on Poll,
+server statistics will be displayed every $pollsecs seconds. See <a href="#usage">Usage</a>
+ above.
+ <p>Since 4.11, we allow users to enter and run SQL interactively via the "Run SQL" link. To disable
+ this for security reasons, set this constant before calling $perf->UI().
+ <p>
+ <pre>define('ADODB_PERF_NO_RUN_SQL',1);</pre>
+
+ <p>Sample output follows below:</p>
+
+<table border=1 width=100% bgcolor=lightyellow><tr>
+ <td> <b><a href=http://php.weblogs.com/adodb?perf=1>ADOdb</a> Performance
+ Monitor</b> for localhost, db=test<br>
+ <font size=-1>PostgreSQL 7.3.2 on i686-pc-cygwin, compiled by GCC gcc (GCC)
+ 3.2 20020927 (prerelease)</font></tr>
+ <tr><td>
+ <a href=#>Performance Stats</a> &nbsp; <a href=#>View SQL</a>
+ &nbsp; <a href=#>View Tables</a> &nbsp; <a href=#>Poll Stats</a></tr></table><table border=1 bgcolor=white><tr><td colspan=3><h3>postgres7</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>statistics collector</td><td>TRUE</td><td>Value must be TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i> and <i>stats_block_level</i> must be set to true in postgresql.conf)</td></tr>
+<tr><td>data cache hit ratio</td><td>99.7967555299239</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>125</td><td>&nbsp; </td></tr>
+<tr><td>data writes</td><td>21.78125000000000000</td><td>Count of inserts/updates/deletes * coef</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>640</td><td>Number of cache buffers. <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a></td></tr>
+<tr><td>cache blocksize</td><td>8192</td><td>(estimate)</td></tr>
+<tr><td>data cache size</td><td>5M</td><td>&nbsp;</td></tr>
+<tr><td>operating system cache size</td><td>80M</td><td>(effective cache size)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Memory Usage</i> &nbsp;</td></tr><tr><td>sort buffer size</td><td>1M</td><td>Size of sort buffer (per query)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>0</td><td>&nbsp;</td></tr>
+<tr><td>max connections</td><td>32</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>rollback buffers</td><td>8</td><td>WAL buffers</td></tr>
+<tr><td>random page cost</td><td>4</td><td>Cost of doing a seek (default=4). See <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a></td></tr>
+</table>
+<p><font face="Courier New, Courier, mono">function <b>HealthCheck</b>()</font></p>
+<p>Returns database health check parameters as a HTML table. You will need to
+ echo or print the output of this function,</p>
+<p><font face="Courier New, Courier, mono">function <b>HealthCheckCLI</b>()</font></p>
+<p>Returns database health check parameters formatted for a command line interface.
+ You will need to echo or print the output of this function. Sample output for
+ mysql:</p>
+<pre>
+-- Ratios --
+ MyISAM cache hit ratio => 56.5635738832
+ InnoDB cache hit ratio => 0
+ sql cache hit ratio => 0
+ -- IO --
+ data reads => 2622
+ data writes => 2415.5
+ -- Data Cache --
+ MyISAM data cache size => 512K
+ BDB data cache size => 8388600
+ InnoDB data cache size => 8M
+ -- Memory Pools --
+ read buffer size => 131072
+ sort buffer size => 65528
+ table cache => 4
+ -- Connections --
+ current connections => 3
+ max connections => 100</pre>
+<p><font face="Courier New, Courier, mono">function <b>Poll</b>($pollSecs=5)
+ </font>
+<p> Run in infinite loop, displaying the following information every $pollSecs.
+ This will not work properly if output buffering is enabled.
+ In the example below, $pollSecs=3:
+<pre>
+Accumulating statistics...
+ Time WS-CPU% Hit% Sess Reads/s Writes/s
+11:08:30 0.7 56.56 1 0.0000 0.0000
+11:08:33 1.8 56.56 2 0.0000 0.0000
+11:08:36 11.1 56.55 3 2.5000 0.0000
+11:08:39 9.8 56.55 2 3.1121 0.0000
+11:08:42 2.8 56.55 1 0.0000 0.0000
+11:08:45 7.4 56.55 2 0.0000 1.5000
+</pre>
+<p><b>WS-CPU%</b> is the Web Server CPU load of the server that PHP is running
+ from (eg. the database client), and not the database. The <b>Hit%</b> is the
+ data cache hit ratio. <b>Sess</b> is the current number of sessions connected
+ to the database. If you are using persistent connections, this should not change
+ much. The <b>Reads/s</b> and <b>Writes/s</b> are synthetic values to give the
+ viewer a rough guide to I/O, and are not to be taken literally.
+<p><font face="Courier New, Courier, mono">function <b>SuspiciousSQL</b>($numsql=10)</font></p>
+<p>Returns SQL which have high average execution times as a HTML table. Each sql statement
+is hyperlinked to a new window which details the execution plan and the scripts that execute this SQL.
+<p> The number of statements returned is determined by $numsql. Data is taken from the adodb_logsql table, where the sql statements are logged when
+$connection->LogSQL(true) is enabled. The adodb_logsql table is populated using <a href=docs-adodb.htm#logsql>$conn->LogSQL</a>.
+<p>For Oracle, Ixora Suspicious SQL returns a list of SQL statements that are most cache intensive as a HTML table.
+ These are data intensive SQL statements that could benefit most from tuning.
+
+<p><font face="Courier New, Courier, mono">function <b>ExpensiveSQL</b>($numsql=10)</font></p>
+<p>Returns SQL whose total execution time (avg time * #executions) is high as a HTML table. Each sql statement
+is hyperlinked to a new window which details the execution plan and the scripts that execute this SQL.
+<p> The number of statements returned is determined by $numsql. Data is taken from the adodb_logsql table, where the sql statements are logged when
+$connection->LogSQL(true) is enabled. The adodb_logsql table is populated using <a href=docs-adodb.htm#logsql>$conn->LogSQL</a>.
+
+<p>For Oracle, Ixora Expensive SQL returns a list of SQL statements that are taking the most CPU load
+when run.
+<p><font face="Courier New, Courier, mono">function <b>InvalidSQL</b>($numsql=10)</font></p>
+<p>Returns a list of invalid SQL as an HTML table.
+<p>Data is taken from the adodb_logsql table, where the sql statements are logged when
+$connection->LogSQL(true) is enabled.
+<p><font face="Courier New, Courier, mono">function <b>Tables</b>($orderby=1)</font></p>
+<p>Returns information on all tables in a database, with the first two fields
+ containing the table name and table size, the remaining fields depend on the
+ database driver. If $orderby is set to 1, it will sort by name. If $orderby
+ is set to 2, then it will sort by table size. Some database drivers (mssql and
+ mysql) will ignore the $orderby clause. For postgresql, the information is up-to-date
+ since the last <i>vacuum</i>. Not supported currently for db2.</p>
+<h3>Raw Functions</h3>
+<p>Raw functions return values without any formatting.</p>
+<p><font face="Courier New, Courier, mono">function <b>DBParameter</b>($paramname)</font></p>
+<p>Returns the value of a database parameter, such as $this-&gt;DBParameter(&quot;data
+ cache size&quot;).</p>
+<p><font face="Courier New, Courier, mono">function <b>CPULoad</b>()</font></p>
+<p>Returns the CPU load of the database client (NOT THE SERVER) as a percentage.
+ Only works for Linux and Windows. For Windows, WMI must be available.</p>
+<h3>Format of $settings Property</h3>
+<p> To create new database parameters, you need to understand $settings. The $settings
+ data structure is an associative array. Each element of the array defines a
+ database parameter. The key is the name of the database parameter. If no key is defined,
+ then it is assumed to be a section break, and the value is the name of the section break.
+ If this is too confusing, looking at the source code will help a lot!</p>
+<p> Each database parameter is itself an array consisting of the following elements:</p>
+<ol start="0">
+ <li> Category code, used to group related db parameters. If the category code is 'HIDE', then
+the database parameter is not shown when HTML() is called. <br>
+ </li>
+ <li> either
+ <ol type="a">
+ <li>sql string to retrieve value, eg. "select value from v\$parameter where
+ name='db_block_size'", </li>
+ <li>array holding sql string and field to look for, e.g. array('show variables','table_cache');
+ optional 3rd parameter is the $rs-&gt;fields[$index] to use (otherwise
+ $index=1), and optional 4th parameter is a constant to multiply the result
+ with (typically 100 for percentage calculations),</li>
+ <li>a string prefixed by =, then a PHP method of the class is invoked, e.g.
+ to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue',
+ <br>
+ </li>
+ </ol>
+ </li>
+ <li> Description of database parameter. If description begins with an =, then
+ it is interpreted as a method call, just as in (1c) above, taking one parameter,
+ the current value. E.g. '=GetIndexDescription' will invoke $this->GetIndexDescription($val).
+ This is useful for generating tuning suggestions. For an example, see WarnCacheRatio().</li>
+</ol>
+<p>Example from MySQL, table_cache database parameter:</p>
+<pre>'table cache' =&gt; array('CACHE', # category code
+ array(&quot;show variables&quot;, 'table_cache'), # array (type 1b)
+ 'Number of tables to keep open'), # description</pre>
+<h3>Example Health Check Output</h3>
+<p><a href="#db2">db2</a> <a href=#informix>informix</a> <a href="#mysql">mysql</a> <a href="#mssql">mssql</a>
+ <a href="#oci8">oci8</a> <a href="#postgres">postgres</a></p>
+<p><a name=db2></a></p>
+<table border=1 bgcolor=white>
+ <tr>
+ <td colspan=3> <h3>db2</h3></td>
+ </tr>
+ <tr>
+ <td><b>Parameter</b></td>
+ <td><b>Value</b></td>
+ <td><b>Description</b></td>
+ </tr>
+ <tr bgcolor=#F0F0F0>
+ <td colspan=3><i>Ratios</i> &nbsp;</td>
+ </tr>
+ <tr bgcolor=#FFFFFF>
+ <td>data cache hit ratio</td>
+ <td>0 &nbsp; </td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr bgcolor=#F0F0F0>
+ <td colspan=3><i>Data Cache</i></td>
+ </tr>
+ <tr bgcolor=#FFFFFF>
+ <td>data cache buffers</td>
+ <td>250 &nbsp; </td>
+ <td>See <a href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning
+ reference</a>.</td>
+ </tr>
+ <tr bgcolor=#FFFFFF>
+ <td>cache blocksize</td>
+ <td>4096 &nbsp; </td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr bgcolor=#FFFFFF>
+ <td>data cache size</td>
+ <td>1000K &nbsp; </td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr bgcolor=#F0F0F0>
+ <td colspan=3><i>Connections</i></td>
+ </tr>
+ <tr bgcolor=#FFFFFF>
+ <td>current connections</td>
+ <td>2 &nbsp; </td>
+ <td>&nbsp;</td>
+ </tr>
+</table>
+<p>&nbsp;<p>
+<a name=informix></a>
+<table border=1 bgcolor=white><tr><td
+colspan=3><h3>informix</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Val
+ue</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td
+colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit
+ratio</td><td>95.89</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data
+reads</td><td>1883884</td><td>Page reads</td></tr>
+<tr><td>data writes</td><td>1716724</td><td>Page writes</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i>
+&nbsp;</td></tr><tr><td>current connections</td><td>263.0</td><td>Number of
+sessions</td></tr>
+</table>
+
+
+<p>&nbsp;</p>
+<p><a name=mysql id="mysql"></a></p><table border=1 bgcolor=white><tr><td colspan=3><h3>mysql</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>MyISAM cache hit ratio</td><td>56.5658301822</td><td><font color=red><b>Cache ratio should be at least 90%</b></font></td></tr>
+<tr><td>InnoDB cache hit ratio</td><td>0</td><td><font color=red><b>Cache ratio should be at least 90%</b></font></td></tr>
+<tr><td>sql cache hit ratio</td><td>0</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>2622</td><td>Number of selects (Key_reads is not accurate)</td></tr>
+<tr><td>data writes</td><td>2415.5</td><td>Number of inserts/updates/deletes * coef (Key_writes is not accurate)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>MyISAM data cache size</td><td>512K</td><td>&nbsp;</td></tr>
+<tr><td>BDB data cache size</td><td>8388600</td><td>&nbsp;</td></tr>
+<tr><td>InnoDB data cache size</td><td>8M</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>read buffer size</td><td>131072</td><td>(per session)</td></tr>
+<tr><td>sort buffer size</td><td>65528</td><td>Size of sort buffer (per session)</td></tr>
+<tr><td>table cache</td><td>4</td><td>Number of tables to keep open</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>3</td><td>&nbsp;</td></tr>
+<tr><td>max connections</td><td>100</td><td>&nbsp;</td></tr>
+</table>
+<p>&nbsp;</p>
+<p><a name=mssql id="mssql"></a></p>
+
+<table border=1 bgcolor=white><tr><td colspan=3><h3>mssql</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit ratio</td><td>99.9999694824</td><td>&nbsp;</td></tr>
+<tr><td>prepared sql hit ratio</td><td>99.7738579828</td><td>&nbsp;</td></tr>
+<tr><td>adhoc sql hit ratio</td><td>98.4540169133</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>2858</td><td>&nbsp; </td></tr>
+<tr><td>data writes</td><td>1438</td><td>&nbsp; </td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache size</td><td>4362</td><td>in K</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>14</td><td>&nbsp;</td></tr>
+<tr><td>max connections</td><td>32767</td><td>&nbsp;</td></tr>
+</table>
+
+<p>&nbsp;</p>
+<p><a name=oci8 id="oci8"></a></p>
+<table border=1 bgcolor=white><tr><td colspan=3><h3>oci8</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>data cache hit ratio</td><td>96.98</td><td>&nbsp;</td></tr>
+<tr><td>sql cache hit ratio</td><td>99.96</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>842938</td><td>&nbsp; </td></tr>
+<tr><td>data writes</td><td>16852</td><td>&nbsp; </td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>3072</td><td>Number of cache buffers</td></tr>
+<tr><td>data cache blocksize</td><td>8192</td><td>&nbsp;</td></tr>
+<tr><td>data cache size</td><td>48M</td><td>shared_pool_size</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>java pool size</td><td>0</td><td>java_pool_size</td></tr>
+<tr><td>sort buffer size</td><td>512K</td><td>sort_area_size (per query)</td></tr>
+<tr><td>user session buffer size</td><td>8M</td><td>large_pool_size</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>1</td><td>&nbsp;</td></tr>
+<tr><td>max connections</td><td>170</td><td>&nbsp;</td></tr>
+<tr><td>data cache utilization ratio</td><td>88.46</td><td>Percentage of data cache actually in use</td></tr>
+<tr><td>user cache utilization ratio</td><td>91.76</td><td>Percentage of user cache (large_pool) actually in use</td></tr>
+<tr><td>rollback segments</td><td>11</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Transactions</i> &nbsp;</td></tr><tr><td>peak transactions</td><td>24</td><td>Taken from high-water-mark</td></tr>
+<tr><td>max transactions</td><td>187</td><td>max transactions / rollback segments < 3.5 (or transactions_per_rollback_segment)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>cursor sharing</td><td>EXACT</td><td>Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR (9i+). See <a href=http://www.praetoriate.com/oracle_tips_cursor_sharing.htm>cursor_sharing</a>.</td></tr>
+<tr><td>index cache cost</td><td>0</td><td>% of indexed data blocks expected in the cache.
+ Recommended is 20-80. Default is 0. See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.</td></tr>
+<tr><td>random page cost</td><td>100</td><td>Recommended is 10-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. </td></tr>
+</table>
+<h3>Suspicious SQL</h3>
+
+<table border=1 bgcolor=white><tr><td><b>LOAD</b></td><td><b>EXECUTES</b></td><td><b>SQL_TEXT</b></td></tr>
+<tr><td align=right> .73%</td><td align=right>89</td><td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o, sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576) and o.obj#=t.obj# and o.owner# = u.user# select i.obj#, i.flags, u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and (not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td></tr>
+<tr><td align=right> .84%</td><td align=right>3</td><td>select /*+ RULE */ distinct tabs.table_name, tabs.owner , partitioned, iot_type , TEMPORARY, table_type, table_type_owner from DBA_ALL_TABLES tabs where tabs.owner = :own </td></tr>
+<tr><td align=right> 3.95%</td><td align=right>6</td><td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.buffer_pool = buf.name and buf.name = 'DEFAULT' </td></tr>
+<tr><td align=right> 4.50%</td><td align=right>6</td><td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td></tr>
+<tr><td align=right>57.34%</td><td align=right>9267</td><td>select t.schema, t.name, t.flags, q.name from system.aq$_queue_tables t, sys.aq$_queue_table_affinities aft, system.aq$_queues q where aft.table_objno = t.objno and aft.owner_instance = :1 and q.table_objno = t.objno and q.usage = 0 and bitand(t.flags, 4+16+32+64+128+256) = 0 for update of t.name, aft.table_objno skip locked </td></tr></table>
+
+<h3>Expensive SQL</h3>
+
+<table border=1 bgcolor=white><tr><td><b>LOAD</b></td><td><b>EXECUTES</b></td><td><b>SQL_TEXT</b></td></tr>
+<tr><td align=right> 5.24%</td><td align=right>1</td><td>select round(sum(bytes)/1048576) from dba_segments </td></tr>
+<tr><td align=right> 6.89%</td><td align=right>6</td><td>SELECT round(count(1)*avg(buf.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, v$buffer_pool buf WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.buffer_pool = buf.name and buf.name = 'DEFAULT' </td></tr>
+<tr><td align=right> 7.85%</td><td align=right>6</td><td>SELECT round(count(1)*avg(tsp.block_size)/1048576) FROM DBA_OBJECTS obj, V$BH bh, dba_segments seg, dba_tablespaces tsp WHERE obj.object_id = bh.objd AND obj.owner != 'SYS' and obj.owner = seg.owner and obj.object_name = seg.segment_name and obj.object_type = seg.segment_type and seg.tablespace_name = tsp.tablespace_name </td></tr>
+<tr><td align=right>33.69%</td><td align=right>89</td><td>select u.name, o.name, t.spare1, t.pctfree$ from sys.obj$ o, sys.user$ u, sys.tab$ t where (bitand(t.trigflag, 1048576) = 1048576) and o.obj#=t.obj# and o.owner# = u.user# </td></tr>
+<tr><td align=right>36.44%</td><td align=right>89</td><td>select i.obj#, i.flags, u.name, o.name from sys.obj$ o, sys.user$ u, sys.ind$ i where (bitand(i.flags, 256) = 256 or bitand(i.flags, 512) = 512) and (not((i.type# = 9) and bitand(i.flags,8) = 8)) and o.obj#=i.obj# and o.owner# = u.user# </td></tr></table>
+
+<p><a name=postgres id="postgres"></a></p>
+
+<table border=1 bgcolor=white><tr><td colspan=3><h3>postgres7</h3></td></tr><tr><td><b>Parameter</b></td><td><b>Value</b></td><td><b>Description</b></td></tr><tr bgcolor=#F0F0F0><td colspan=3><i>Ratios</i> &nbsp;</td></tr><tr><td>statistics collector</td><td>FALSE</td><td>Must be set to TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i> and <i>stats_block_level</i> must be set to true in postgresql.conf)</td></tr>
+<tr><td>data cache hit ratio</td><td>99.9666031916603</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>IO</i> &nbsp;</td></tr><tr><td>data reads</td><td>15</td><td>&nbsp; </td></tr>
+<tr><td>data writes</td><td>0.000000000000000000</td><td>Count of inserts/updates/deletes * coef</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Data Cache</i> &nbsp;</td></tr><tr><td>data cache buffers</td><td>1280</td><td>Number of cache buffers. <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a></td></tr>
+<tr><td>cache blocksize</td><td>8192</td><td>(estimate)</td></tr>
+<tr><td>data cache size</td><td>10M</td><td>&nbsp;</td></tr>
+<tr><td>operating system cache size</td><td>80000K</td><td>(effective cache size)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Memory Pools</i> &nbsp;</td></tr><tr><td>sort buffer size</td><td>1M</td><td>Size of sort buffer (per query)</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Connections</i> &nbsp;</td></tr><tr><td>current connections</td><td>13</td><td>&nbsp;</td></tr>
+<tr><td>max connections</td><td>32</td><td>&nbsp;</td></tr>
+<tr bgcolor=#F0F0F0><td colspan=3><i>Parameters</i> &nbsp;</td></tr><tr><td>rollback buffers</td><td>8</td><td>WAL buffers</td></tr>
+<tr><td>random page cost</td><td>4</td><td>Cost of doing a seek (default=4). See <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a></td></tr>
+</table>
+
+</body>
+</html>
diff --git a/html/phpgacl/adodb/docs/docs-session.htm b/html/phpgacl/adodb/docs/docs-session.htm
new file mode 100644
index 0000000..83f4603
--- /dev/null
+++ b/html/phpgacl/adodb/docs/docs-session.htm
@@ -0,0 +1,239 @@
+<html>
+<head>
+<title>ADODB Session Management Manual</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<XSTYLE
+ body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
+ pre {font-size:9pt}
+ .toplink {font-size:8pt}
+ />
+</head>
+<body bgcolor="#FFFFFF">
+<h3>ADODB Session Management Manual</h3>
+<p>
+V4.23 16 June 2004 (c) 2000-2004 John Lim (jlim#natsoft.com.my)
+<p> <font size=1>This software is dual licensed using BSD-Style and LGPL. This
+ means you can use it in compiled proprietary and commercial products. </font>
+ <table border=1><tr><td><font color=red>Kindly note that the ADOdb home page has moved to <a href=http://adodb.sourceforge.net/>http://adodb.sourceforge.net/</a> because of the persistent
+ unreliability of http://php.weblogs.com. <b>Please change your links</b>!</font></td><tr></table>
+ <p>Useful ADOdb links: <a href=http://adodb.sourceforge.net/#download>Download</a> &nbsp; <a href=http://adodb.sourceforge.net/#docs>Other Docs</a>
+
+<h3>Introduction</h3>
+<p>
+We store state information specific to a user or web client in session variables. These session variables
+ persist throughout a session, as the user moves from page to page.
+<p>
+To use session variables, call session_start() at the beginning of your web page,
+before your HTTP headers are sent. Then for every variable you want to keep alive
+for the duration of the session, call session_register($variable_name). By default,
+the session handler will keep track of the session by using a cookie. You can save objects
+ or arrays in session variables also.
+<p>The default method of storing sessions is to store it in a file. However if
+ you have special needs such as you:
+<ul>
+ <li>Have multiple web servers that need to share session info</li>
+ <li>Need to do special processing of each session</li>
+ <li>Require notification when a session expires</li>
+</ul>
+<p>Then the ADOdb session handler provides you with the above additional capabilities
+ by storing the session information as records in a database table that can be
+ shared across multiple servers.
+<p><b>Important Upgrade Notice:</b> Since ADOdb 4.05, the session files have been moved to its own folder, adodb/session. This is a rewrite
+of the session code by Ross Smith. The old session code is in adodb/session/old.
+<h4>ADOdb Session Handler Features</h4>
+<ul>
+<li>Ability to define a notification function that is called when a session expires. Typically
+used to detect session logout and release global resources.
+<li>Optimization of database writes. We crc32 the session data and only perform an update
+to the session data if there is a data change.
+<li>Support for large amounts of session data with CLOBs (see adodb-session-clob.php). Useful
+for Oracle.
+<li>Support for encrypted session data, see adodb-cryptsession.inc.php. Enabling encryption
+is simply a matter of including adodb-cryptsession.inc.php instead of adodb-session.inc.php.
+</ul>
+<h3>Setup</h3>
+<p>There are 3 session management files that you can use:
+<pre>
+adodb-session.php : The default
+adodb-session-clob.php : Use this if you are storing DATA in clobs
+adodb-cryptsession.php : Use this if you want to store encrypted session data in the database
+
+<strong>Examples</strong>
+ <font color=#004040>
+ include('adodb/adodb.inc.php');
+
+<b> $ADODB_SESSION_DRIVER='mysql';
+ $ADODB_SESSION_CONNECT='localhost';
+ $ADODB_SESSION_USER ='scott';
+ $ADODB_SESSION_PWD ='tiger';
+ $ADODB_SESSION_DB ='sessiondb';</b>
+
+ <b>include('adodb/session/adodb-session.php');</b>
+ session_start();
+
+ #
+ # Test session vars, the following should increment on refresh
+ #
+ $_SESSION['AVAR'] += 1;
+ print "&lt;p>\$_SESSION['AVAR']={$_SESSION['AVAR']}&lt;/p>";
+</font>
+To force non-persistent connections, call adodb_session_open first before session_start():
+ <font color=#004040>
+ include('adodb/adodb.inc.php');
+
+<b> $ADODB_SESSION_DRIVER='mysql';
+ $ADODB_SESSION_CONNECT='localhost';
+ $ADODB_SESSION_USER ='scott';
+ $ADODB_SESSION_PWD ='tiger';
+ $ADODB_SESSION_DB ='sessiondb';</b>
+
+ <b>include('adodb/session/adodb-session.php');
+ adodb_sess_open(false,false,false);</b>
+ session_start();
+ </font color=#004040>
+To use a encrypted sessions, simply replace the file:
+ <font color=#004040>
+ include('adodb/adodb.inc.php');
+
+<b> $ADODB_SESSION_DRIVER='mysql';
+ $ADODB_SESSION_CONNECT='localhost';
+ $ADODB_SESSION_USER ='scott';
+ $ADODB_SESSION_PWD ='tiger';
+ $ADODB_SESSION_DB ='sessiondb';
+
+ include('adodb/session/adodb-cryptsession.php');</b>
+ session_start();
+ </font>
+And the same technique for adodb-session-clob.php:
+ <font color=#004040>
+ include('adodb/adodb.inc.php');
+
+<b> $ADODB_SESSION_DRIVER='mysql';
+ $ADODB_SESSION_CONNECT='localhost';
+ $ADODB_SESSION_USER ='scott';
+ $ADODB_SESSION_PWD ='tiger';
+ $ADODB_SESSION_DB ='sessiondb';
+
+ include('adodb/session/adodb-session-clob.php');</b>
+ session_start();
+ </font>
+ <h4>Installation</h4>
+ 1. Create this table in your database (syntax might vary depending on your db):
+ <a name=sessiontab></a> <font color=#004040>
+ create table sessions (
+ SESSKEY char(32) not null,
+ EXPIRY int(11) unsigned not null,
+ EXPIREREF varchar(64),
+ DATA text not null,
+ primary key (sesskey)
+ );</font>
+
+ For the adodb-session-clob.php version, create this:
+ <font color=#004040>
+ create table sessions (
+ SESSKEY char(32) not null,
+ EXPIRY int(11) unsigned not null,
+ EXPIREREF varchar(64),
+ DATA CLOB,
+ primary key (sesskey)
+ );</font>
+
+ 2. Then define the following parameters. You can either modify
+ this file, or define them before this file is included:
+ <font color=#004040>
+ $ADODB_SESSION_DRIVER='database driver, eg. mysql or ibase';
+ $ADODB_SESSION_CONNECT='server to connect to';
+ $ADODB_SESSION_USER ='user';
+ $ADODB_SESSION_PWD ='password';
+ $ADODB_SESSION_DB ='database';
+ $ADODB_SESSION_TBL = 'sessions'; # setting this is optional
+ </font>
+ When the session is created, $<b>ADODB_SESS_CONN</b> holds the connection object.
+
+ 3. Recommended is PHP 4.0.6 or later. There are documented session bugs
+ in earlier versions of PHP.
+</pre>
+
+ <h3>Notifications</h3>
+<p>If you want to receive notification when a session expires, then
+ tag the session record with a <a href="#sessiontab">EXPIREREF</a> tag (see the
+ definition of the sessions table above). Before any session record is deleted,
+ ADOdb will call a notification function, passing in the EXPIREREF.
+<p>
+When a session is first created, we check a global variable $ADODB_SESSION_EXPIRE_NOTIFY.
+ This is an array with 2 elements, the first being the name of the session variable
+ you would like to store in the EXPIREREF field, and the 2nd is the
+ notification function's name.
+ <p>
+ Suppose we want to be notified when a user's session
+ has expired, based on the userid. The user id in the global session variable $USERID.
+ The function name is 'NotifyFn'. So we define:
+ <pre> <font color=#004040>
+ $ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
+ </font></pre>
+ And when the NotifyFn is called (when the session expires), we pass the $USERID
+ as the first parameter, eg. NotifyFn($userid, $sesskey). The session key (which is
+ the primary key of the record in the sessions table) is the 2nd parameter.
+ <p>
+ Here is an example of a Notification function that deletes some records in the database
+ and temporary files:
+ <pre><font color=#004040>
+ function NotifyFn($expireref, $sesskey)
+ {
+ global $ADODB_SESS_CONN; # the session connection object
+
+ $user = $ADODB_SESS_CONN->qstr($expireref);
+ $ADODB_SESS_CONN->Execute("delete from shopping_cart where user=$user");
+ system("rm /work/tmpfiles/$expireref/*");
+ }</font>
+ </pre>
+ <p>
+ NOTE 1: If you have register_globals disabled in php.ini, then you will have to
+ manually set the EXPIREREF. E.g.
+ <pre> <font color=#004040>
+ $GLOBALS['USERID'] =& $_SESSION['USERID'];
+ $ADODB_SESSION_EXPIRE_NOTIFY = array('USERID','NotifyFn');
+ </font></pre>
+ <p>
+ NOTE 2: If you want to change the EXPIREREF after the session record has been
+ created, you will need to modify any session variable to force a database
+ record update.
+
+<h4>Neat Notification Tricks</h4>
+
+<p><i>ExpireRef</i> normally holds the user id of the current session.
+<p>
+1. You can then write a session monitor, scanning expireref to see
+who is currently logged on.
+<p>
+2. If you delete the sessions record for a specific user, eg.
+<pre>
+delete from sessions where expireref = '$USER'
+</pre>
+then the user is logged out. Useful for ejecting someone from a
+site.
+<p>
+3. You can scan the sessions table to ensure no user
+can be logged in twice. Useful for security reasons.
+<p>
+
+<h3>Compression/Encryption Schemes</h3>
+Since ADOdb 4.05, thanks to Ross Smith, multiple encryption and compression schemes are supported.
+ Currently, supported:
+<pre>
+ MD5Crypt (crypt.inc.php)
+ MCrypt
+ Secure (Horde's emulation of MCrypt, if MCrypt module is not available.)
+ GZip
+ BZip2
+</pre>
+These are stackable. E.g.
+<pre>
+ADODB_Session::filter(new ADODB_Compress_Bzip2());
+ADODB_Session::filter(new ADODB_Encrypt_MD5());
+</pre>
+will compress and then encrypt the record in the database.
+<p>
+Also see the <a href=docs-adodb.htm>core ADOdb documentation</a>.
+</body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/adodb/docs/old-changelog.htm b/html/phpgacl/adodb/docs/old-changelog.htm
new file mode 100644
index 0000000..f43111c
--- /dev/null
+++ b/html/phpgacl/adodb/docs/old-changelog.htm
@@ -0,0 +1,700 @@
+<h3>Old Changelog</h3>
+<p><b>3.50 19 May 2003</b></p>
+<p>Fixed mssql compat with FreeTDS. FreeTDS does not implement mssql_fetch_assoc().
+<p>Merged back connection and recordset code into adodb.inc.php.
+<p>ADOdb sessions using oracle clobs contributed by achim.gosse#ddd.de. See adodb-session-clob.php.
+<p>Added /s modifier to preg_match everywhere, which ensures that regex does not
+ stop at /n. Thx Pao-Hsi Huang.
+<p>Fixed error in metacolumns() for mssql.
+<p>Added time format support for SQLDate.
+<p>Image => B added to metatype.
+<p>MetaType now checks empty($this->blobSize) instead of empty($this).
+<p>Datadict has beta support for informix, sybase (mapped to mssql), db2 and generic
+ (which is a fudge).
+<p>BlobEncode for postgresql uses pg_escape_bytea, if available. Needed for compat
+ with 7.3.
+<p>Added $ADODB_LANG, to support multiple languages in MetaErrorMsg().
+<p>Datadict can now parse table definition as declarative text.
+<p>For DataDict, oci8 autoincrement trigger missing semi-colon. Fixed.
+<p>For DataDict, when REPLACE flag enabled, drop sequence in datadict for autoincrement
+ field in postgres and oci8.s
+<p>Postgresql defaults to template1 database if no database defined in connect/pconnect.
+<p>We now clear _resultid in postgresql if query fails.
+<p><b>3.40 19 May 2003</b></p>
+<p>Added insert_id for odbc_mssql.
+<p>Modified postgresql UpdateBlobFile() because it did not work in safe mode.
+<p>Now connection object is passed to raiseErrorFn as last parameter. Needed by
+ StartTrans().
+<p>Added StartTrans() and CompleteTrans(). It is recommended that you do not modify
+ transOff, but use the above functions.
+<p>oci8po now obeys ADODB_ASSOC_CASE settings.
+<p>Added virtualized error codes, using PEAR DB equivalents. Requires you to manually
+ include adodb-error.inc.php yourself, with MetaError() and MetaErrorMsg($errno).
+<p>GetRowAssoc for mysql and pgsql were flawed. Fix by Ross Smith.
+<p>Added to datadict types I1, I2, I4 and I8. Changed datadict type 'T' to map
+ to timestamp instead of datetime for postgresql.
+<p>Error handling in ExecuteSQLArray(), adodb-datadict.inc.php did not work.
+<p>We now auto-quote postgresql connection parameters when building connection
+ string.
+<p>Added session expiry notification.
+<p>We now test with odbc mysql - made some changes to odbc recordset constructor.
+<p>MetaColumns now special cases access and other databases for odbc.
+<p><b>3.31 17 March 2003</b></p>
+<p>Added row checking for _fetch in postgres.
+<p>Added Interval type to MetaType for postgres.
+<p>Remapped postgres driver to call postgres7 driver internally.
+<p>Adorecordset_array::getarray() did not return array when nRows >= 0.
+<p>Postgresql: at times, no error message returned by pg_result_error() but error
+ message returned in pg_last_error(). Recoded again.
+<p>Interbase blob's now use chunking for updateblob.
+<p>Move() did not set EOF correctly. Reported by Jorma T.
+<p>We properly support mysql timestamp fields when we are creating mysql tables
+ using the data-dict interface.
+<p>Table regex includes backticks character now.
+<p><b>3.30 3 March 2003</b></p>
+<p>Added $ADODB_EXTENSION and $ADODB_COMPAT_FETCH constant.
+<p>Made blank1stItem configurable using syntax "value:text" in GetMenu/GetMenu2.
+ Thx to Gabriel Birke.
+<p>Previously ADOdb differed from the Microsoft standard because it did not define
+ what to set $this->fields when EOF was reached. Now at EOF, ADOdb sets $this->fields
+ to false for all databases, which is consist with Microsoft's implementation.
+ Postgresql and mysql have always worked this way (in 3.11 and earlier). If you
+ are experiencing compatibility problems (and you are not using postgresql nor
+ mysql) on upgrading to 3.30, try setting the global variables $ADODB_COUNTRECS
+ = true (which is the default) and $ADODB_FETCH_COMPAT = true (this is a new
+ global variable).
+<p>We now check both pg_result_error and pg_last_error as sometimes pg_result_error
+ does not display anything. Iman Mayes
+<p> We no longer check for magic quotes gpc in Quote().
+<p> Misc fixes for table creation in adodb-datadict.inc.php. Thx to iamsure.
+<p> Time calculations use adodb_time library for all negative timestamps due to
+ problems in Red Hat 7.3 or later. Formerly, only did this for Windows.
+<p> In mssqlpo, we now check if $sql in _query is a string before we change ||
+ to +. This is to support prepared stmts.
+<p> Move() and MoveLast() internals changed to support to support EOF and $this->fields
+ change.
+<p> Added ADODB_FETCH_BOTH support to mssql. Thx to Angel Fradejas afradejas#mediafusion.es
+<p> We now check if link resource exists before we run mysql_escape_string in
+ qstr().
+<p> Before we flock in csv code, we check that it is not a http url.
+<p><b>3.20 17 Feb 2003</b></p>
+<p>Added new Data Dictionary classes for creating tables and indexes. Warning
+ - this is very much alpha quality code. The API can still change. See adodb/tests/test-datadict.php
+ for more info.
+<p>We now ignore $ADODB_COUNTRECS for mysql, because PHP truncates incomplete
+ recordsets when mysql_unbuffered_query() is called a second time.
+<p>Now postgresql works correctly when $ADODB_COUNTRECS = false.
+<p>Changed _adodb_getcount to properly support SELECT DISTINCT.
+<p>Discovered that $ADODB_COUNTRECS=true has some problems with prepared queries
+ - suspect PHP bug.
+<p>Now GetOne and GetRow run in $ADODB_COUNTRECS=false mode for better performance.
+<p>Added support for mysql_real_escape_string() and pg_escape_string() in qstr().
+<p>Added an intermediate variable for mysql _fetch() and MoveNext() to store fields,
+ to prevent overwriting field array with boolean when mysql_fetch_array() returns
+ false.
+<p>Made arrays for getinsertsql and getupdatesql case-insensitive. Suggested by
+ Tim Uckun" tim#diligence.com
+<p><b>3.11 11 Feb 2003</b></p>
+<p>Added check for ADODB_NEVER_PERSIST constant in PConnect(). If defined, then
+ PConnect() will actually call non-persistent Connect().
+<p>Modified interbase to properly work with Prepare().
+<p>Added $this->ibase_timefmt to allow you to change the date and time format.
+<p>Added support for $input_array parameter in CacheFlush().
+<p>Added experimental support for dbx, which was then removed when i found that
+ it was slower than using native calls.
+<p>Added MetaPrimaryKeys for mssql and ibase/firebird.
+<p>Added new $trim parameter to GetCol and CacheGetCol
+<p>Uses updated adodb-time.inc.php 0.06.
+<p><b>3.10 27 Jan 2003</b>
+<p>Added adodb_date(), adodb_getdate(), adodb_mktime() and adodb-time.inc.php.
+<p>For interbase, added code to handle unlimited number of bind parameters. From
+ Daniel Hasan daniel#hasan.cl.
+<p>Added BlobDecode and UpdateBlob for informix. Thx to Fernando Ortiz.
+<p>Added constant ADODB_WINDOWS. If defined, means that running on Windows.
+<p>Added constant ADODB_PHPVER which stores php version as a hex num. Removed
+ $ADODB_PHPVER variable.
+<p>Felho Bacsi reported a minor white-space regular expression problem in GetInsertSQL.
+<p>Modified ADO to use variant to store _affectedRows
+<p>Changed ibase to use base class Replace(). Modified base class Replace() to
+ support ibase.
+<p>Changed odbc to auto-detect when 0 records returned is wrong due to bad odbc
+ drivers.
+<p>Changed mssql to use datetimeconvert ini setting only when 4.30 or later (does
+ not work in 4.23).
+<p>ExecuteCursor($stmt, $cursorname, $params) now accepts a new $params array
+ of additional bind parameters -- William Lovaton walovaton#yahoo.com.mx.
+<p>Added support for sybase_unbuffered_query if ADODB_COUNTRECS == false. Thx
+ to chuck may.
+<p>Fixed FetchNextObj() bug. Thx to Jorma Tuomainen.
+<p>We now use SCOPE_IDENTITY() instead of @@IDENTITY for mssql - thx to marchesini#eside.it
+<p>Changed postgresql movenext logic to prevent illegal row number from being
+ passed to pg_fetch_array().
+<p>Postgresql initrs bug found by "Bogdan RIPA" bripa#interakt.ro $f1 accidentally
+ named $f
+<p><b>3.00 6 Jan 2003</b>
+<p>Fixed adodb-pear.inc.php syntax error.
+<p>Improved _adodb_getcount() to use SELECT COUNT(*) FROM ($sql) for languages
+ that accept it.
+<p>Fixed _adodb_getcount() caching error.
+<p>Added sql to retrive table and column info for odbc_mssql.
+<p><strong>2.91 3 Jan 2003</strong>
+<p>Revised PHP version checking to use $ADODB_PHPVER with legal values 0x4000,
+ 0x4050, 0x4200, 0x4300.
+<p>Added support for bytea fields and oid blobs in postgres by allowing BlobDecode()
+ to detect and convert non-oid fields. Also added BlobEncode to postgres when
+ you want to encode oid blobs.
+<p>Added blobEncodeType property for connections to inform phpLens what encoding
+ method to use for blobs.
+<p>Added BlobDecode() and BlobEncode() to base ADOConnection class.
+<p>Added umask() to _gencachename() when creating directories.
+<p>Added charPage for ado drivers, so you can set the code page.
+<pre>
+$conn->charPage = CP_UTF8;
+$conn->Connect($dsn);
+</pre>
+<p>Modified _seek in mysql to check for num rows=0.
+<p>Added to metatypes new informix types for IDS 9.30. Thx Fernando Ortiz.
+<p>_maxrecordcount returned in CachePageExecute $rsreturn
+<p>Fixed sybase cacheselectlimit( ) problems
+<p>MetaColumns() max_length should use precision for types X and C for ms access.
+ Fixed.
+<p>Speedup of odbc non-SELECT sql statements.
+<p>Added support in MetaColumns for Wide Char types for ODBC. We halve max_length
+ if unicode/wide char.
+<p>Added 'B' to types handled by GetUpdateSQL/GetInsertSQL.
+<p>Fixed warning message in oci8 driver with $persist variable when using PConnect.
+<p><b>2.90 11 Dec 2002</b>
+<p>Mssql and mssqlpo and oci8po now support ADODB_ASSOC_CASE.
+<p>Now MetaType() can accept a field object as the first parameter.
+<p>New $arr = $db-&gt;ServerInfo( ) function. Returns $arr['description'] which
+ is the string description, and $arr['version'].
+<p>PostgreSQL and MSSQL speedups for insert/updates.
+<p> Implemented new SetFetchMode() that removes the need to use $ADODB_FETCH_MODE.
+ Each connection has independant fetchMode.
+<p>ADODB_ASSOC_CASE now defaults to 2, use native defaults. This is because we
+ would break backward compat for too many applications otherwise.
+<p>Patched encrypted sessions to use replace()
+<p>The qstr function supports quoting of nulls when escape character is \
+<p>Rewrote bits and pieces of session code to check for time synch and improve
+ reliability.
+<p>Added property ADOConnection::hasTransactions = true/false;
+<p>Added CreateSequence and DropSequence functions
+<p>Found misplaced MoveNext() in adodb-postgres.inc.php. Fixed.
+<p>Sybase SelectLimit not reliable because 'set rowcount' not cached - fixed.
+<p>Moved ADOConnection to adodb-connection.inc.php and ADORecordSet to adodb-recordset.inc.php.
+ This allows us to use doxygen to generate documentation. Doxygen doesn't like
+ the classes in the main adodb.inc.php file for some mysterious reason.
+<p><b>2.50, 14 Nov 2002</b>
+<p>Added transOff and transCnt properties for disabling (transOff = true) and
+ tracking transaction status (transCnt>0).
+<p>Added inputarray handling into _adodb_pageexecute_all_rows - "Ross Smith" RossSmith#bnw.com.
+<p>Fixed postgresql inconsistencies in date handling.
+<p>Added support for mssql_fetch_assoc.
+<p>Fixed $ADODB_FETCH_MODE bug in odbc MetaTables() and MetaPrimaryKeys().
+<p>Accidentally declared UnixDate() twice, making adodb incompatible with php
+ 4.3.0. Fixed.
+<p>Fixed pager problems with some databases that returned -1 for _currentRow on
+ MoveLast() by switching to MoveNext() in adodb-lib.inc.php.
+<p>Also fixed uninited $discard in adodb-lib.inc.php.
+<p><b>2.43, 25 Oct 2002</b></p>
+Added ADODB_ASSOC_CASE constant to better support ibase and odbc field names.
+<p>Added support for NConnect() for oracle OCINLogin.
+<p>Fixed NumCols() bug.
+<p>Changed session handler to use Replace() on write.
+<p>Fixed oci8 SelectLimit aggregate function bug again.
+<p>Rewrote pivoting code.
+<p><b>2.42, 4 Oct 2002</b></p>
+<p>Fixed ibase_fetch() problem with nulls. Also interbase now does automatic blob
+ decoding, and is backward compatible. Suggested by Heinz Hombergs heinz#hhombergs.de.
+<p>Fixed postgresql MoveNext() problems when called repeatedly after EOF. Also
+ suggested by Heinz Hombergs.
+<p>PageExecute() does not rewrite queries if SELECT DISTINCT is used. Requested
+ by hans#velum.net
+<p>Added additional fixes to oci8 SelectLimit handling with aggregate functions
+ - thx to Christian Bugge for reporting the problem.
+<p><b>2.41, 2 Oct 2002</b></p>
+<p>Fixed ADODB_COUNTRECS bug in odbc. Thx to Joshua Zoshi jzoshi#hotmail.com.
+<p>Increased buffers for adodb-csvlib.inc.php for extremely long sql from 8192
+ to 32000.
+<p>Revised pivottable.inc.php code. Added better support for aggregate fields.
+<p>Fixed mysql text/blob types problem in MetaTypes base class - thx to horacio
+ degiorgi.
+<p>Added SQLDate($fmt,$date) function, which allows an sql date format string
+ to be generated - useful for group by's.
+<p>Fixed bug in oci8 SelectLimit when offset>100.
+<p><b>2.40 4 Sept 2002</b></p>
+<p>Added new NLS_DATE_FORMAT property to oci8. Suggested by Laurent NAVARRO ln#altidev.com
+<p>Now use bind parameters in oci8 selectlimit for better performance.
+<p>Fixed interbase replaceQuote for dialect != 1. Thx to "BEGUIN Pierre-Henri
+ - INFOCOB" phb#infocob.com.
+<p>Added white-space check to QA.
+<p>Changed unixtimestamp to support fractional seconds (we always round down/floor
+ the seconds). Thanks to beezly#beezly.org.uk.
+<p>Now you can set the trigger_error type your own user-defined type in adodb-errorhandler.inc.php.
+ Suggested by Claudio Bustos clbustos#entelchile.net.
+<p>Added recordset filters with rsfilter.inc.php.
+<p>$conn->_rs2rs does not create a new recordset when it detects it is of type
+ array. Some trickery there as there seems to be a bug in Zend Engine
+<p>Added render_pagelinks to adodb-pager.inc.php. Code by "Pablo Costa" pablo#cbsp.com.br.
+<p>MetaType() speedup in adodb.inc.php by using hashing instead of switch. Best
+ performance if constant arrays are supported, as they are in PHP5.
+<p>adodb-session.php now updates only the expiry date if the crc32 check indicates
+ that the data has not been modified.
+<p><b>2.31 20 Aug 2002</b></p>
+<p>Made changes to pivottable.inc.php due to daniel lucuzaeu's suggestions (we sum the pivottable column if desired).
+<p>Fixed ErrorNo() in postgres so it does not depend on _errorMsg property.
+<p>Robert Tuttle added support for oracle cursors. See ExecuteCursor().
+<p>Fixed Replace() so it works with mysql when updating record where data has not changed. Reported by
+Cal Evans (cal#calevans.com).
+<p><b>2.30 1 Aug 2002</b></p>
+<p>Added pivottable.inc.php. Thanks to daniel.lucazeau#ajornet.com for the original
+ concept.
+<p>Added ADOConnection::outp($msg,$newline) to output error and debugging messages. Now
+you can override this using the ADODB_OUTP constant and use your own output handler.
+<p>Changed == to === for 'null' comparison. Reported by ericquil#yahoo.com
+<p>Fixed mssql SelectLimit( ) bug when distinct used.
+<p><b>2.30 1 Aug 2002</b></p>
+<p>New GetCol() and CacheGetCol() from ross#bnw.com that returns the first field as a 1 dim array.
+<p>We have an empty recordset, but RecordCount() could return -1. Fixed. Reported by "Jonathan Polansky" jonathan#polansky.com.
+<p>We now check for session variable changes using strlen($sessval).crc32($sessval).
+Formerly we only used crc32().
+<p>Informix SelectLimit() problem with $ADODB_COUNTRECS fixed.
+<p>Fixed informix SELECT FIRST x DISTINCT, and not SELECT DISTINCT FIRST x - reported by F Riosa
+<p>Now default adodb error handlers ignores error if @ used.
+<p>If you set $conn->autoRollback=true, we auto-rollback persistent connections for odbc, mysql, oci8, mssql.
+Default for autoRollback is false. No need to do so for postgres.
+As interbase requires a transaction id (what a flawed api), we don't do it for interbase.
+<p>Changed PageExecute() to use non-greedy preg_match when searching for "FROM" keyword.
+<p><b>2.20 9 July 2002</b></p>
+<p>Added CacheGetOne($secs2cache,$sql), CacheGetRow($secs2cache,$sql), CacheGetAll($secs2cache,$sql).
+<p>Added $conn->OffsetDate($dayFraction,$date=false) to generate sql that calcs
+ date offsets. Useful for scheduling appointments.
+<p>Added connection properties: leftOuter, rightOuter that hold left and right
+ outer join operators.
+<p>Added connection property: ansiOuter to indicate whether ansi outer joins supported.
+<p>New driver <i>mssqlpo</i>, the portable mssql driver, which converts string
+ concat operator from || to +.
+<p>Fixed ms access bug - SelectLimit() did not support ties - fixed.
+<p>Karsten Kraus (Karsten.Kraus#web.de), contributed error-handling code to ADONewConnection.
+ Unfortunately due to backward compat problems, had to rollback most of the changes.
+<p>Added new parameter to GetAssoc() to allow returning an array of key-value pairs,
+ignoring any additional columns in the recordset. Off by default.
+<p>Corrected mssql $conn->sysDate to return only date using convert().
+<p>CacheExecute() improved debugging output.
+<p>Changed rs2html() so newlines are converted to BR tags. Also optimized rs2html() based
+on feedback by "Jerry Workman" jerry#mtncad.com.
+<p>Added support for Replace() with Interbase, using DELETE and INSERT.
+<p>Some minor optimizations (mostly removing & references when passing arrays).
+<p>Changed GenID() to allows id's larger than the size of an integer.
+<p>Added force_session property to oci8 for better updateblob() support.
+<p>Fixed PageExecute() which did not work properly with sql containing GROUP BY.
+<p><b>2.12 12 June 2002</b></p>
+<p>Added toexport.inc.php to export recordsets in CSV and tab-delimited format.
+<p>CachePageExecute() does not work - fixed - thx John Huong.
+<p>Interbase aliases not set properly in FetchField() - fixed. Thx Stefan Goethals.
+<p>Added cache property to adodb pager class. The number of secs to cache recordsets.
+<p>SQL rewriting bug in pageexecute() due to skipping of newlines due to missing /s modifier. Fixed.
+<p>Max size of cached recordset due to a bug was 256000 bytes. Fixed.
+<p>Speedup of 1st invocation of CacheExecute() by tuning code.
+<p>We compare $rewritesql with $sql in pageexecute code in case of rewrite failure.
+<p><b>2.11 7 June 2002</b></p>
+<p>Fixed PageExecute() rewrite sql problem - COUNT(*) and ORDER BY don't go together with
+ mssql, access and postgres. Thx to Alexander Zhukov alex#unipack.ru
+<p>DB2 support for CHARACTER type added - thx John Huong huongch#bigfoot.com
+<p>For ado, $argProvider not properly checked. Fixed - kalimero#ngi.it
+<p>Added $conn->Replace() function for update with automatic insert if the record does not exist.
+ Supported by all databases except interbase.
+<p><b>2.10 4 June 2002</b></p>
+<p>Added uniqueSort property to indicate mssql ORDER BY cols must be unique.
+<p>Optimized session handler by crc32 the data. We only write if session data has changed.
+<p>adodb_sess_read in adodb-session.php now returns ''correctly - thanks to Jorma Tuomainen, webmaster#wizactive.com
+<p>Mssql driver did not throw EXECUTE errors correctly because ErrorMsg() and ErrorNo() called in wrong order.
+Pointed out by Alexios Fakos. Fixed.
+<p>Changed ado to use client cursors. This fixes BeginTran() problems with ado.
+<p>Added handling of timestamp type in ado.
+<p>Added to ado_mssql support for insert_id() and affected_rows().
+<p>Added support for mssql.datetimeconvert=0, available since php 4.2.0.
+<p>Made UnixDate() less strict, so that the time is ignored if present.
+<p>Changed quote() so that it checks for magic_quotes_gpc.
+<p>Changed maxblobsize for odbc to default to 64000.
+<p><b>2.00 13 May 2002</b></p>
+<p>Added drivers <i>informix72</i> for pre-7.3 versions, and <i>oci805</i> for
+ oracle 8.0.5, and postgres64 for postgresql 6.4 and earlier. The postgres and postgres7 drivers
+ are now identical.
+<p>Interbase now partially supports ADODB_FETCH_BOTH, by defaulting to ASSOC mode.
+<p>Proper support for blobs in mssql. Also revised blob support code
+is base class. Now UpdateBlobFile() calls UpdateBlob() for consistency.
+<p>Added support for changed odbc_fetch_into api in php 4.2.0
+with $conn-&gt;_has_stupid_odbc_fetch_api_change.
+<p>Fixed spelling of tablock locking hint in GenID( ) for mssql.
+<p>Added RowLock( ) to several databases, including oci8, informix, sybase, etc.
+ Fixed where error in mssql RowLock().
+<p>Added sysDate and sysTimeStamp properties to most database drivers. These are the sql
+functions/constants for that database that return the current date and current timestamp, and
+are useful for portable inserts and updates.
+<p>Support for RecordCount() caused date handling in sybase and mssql to break.
+Fixed, thanks to Toni Tunkkari, by creating derived classes for ADORecordSet_array for
+both databases. Generalized using arrayClass property. Also to support RecordCount(),
+changed metatype handling for ado drivers. Now the type returned in FetchField
+ is no longer a number, but the 1-char data type returned by MetaType.
+ At the same time, fixed a lot of date handling. Now mssql support dmy and mdy date formats.
+Also speedups in sybase and mssql with preg_match and ^ in date/timestamp handling.
+Added support in sybase and mssql for 24 hour clock in timestamps (no AM/PM).
+<p>Extensive revisions to informix driver - thanks to Samuel CARRIERE samuel_carriere#hotmail.com
+<p>Added $ok parameter to CommitTrans($ok) for easy rollbacks.
+<p>Fixed odbc MetaColumns and MetaTables to save and restore $ADODB_FETCH_MODE.
+<p>Some odbc drivers did not call the base connection class constructor. Fixed.
+<p>Fixed regex for GetUpdateSQL() and GetInsertSQL() to support more legal character combinations.
+
+<p><b>1.99 21 April 2002</b></p>
+<p>Added emulated RecordCount() to all database drivers if $ADODB_COUNTRECS = true
+ (which it is by default). Inspired by Cristiano Duarte (cunha17#uol.com.br).
+<p>Unified stored procedure support for mssql and oci8. Parameter() and PrepareSP()
+ functions implemented.
+<p>Added support for SELECT FIRST in informix, modified hasTop property to support
+ this.
+<p>Changed csv driver to handle updates/deletes/inserts properly (when Execute() returns true).
+Bind params also work now, and raiseErrorFn with csv driver. Added csv driver to QA process.
+<p>Better error checking in oci8 UpdateBlob() and UpdateBlobFile().
+<p>Added TIME type to MySQL - patch by Manfred h9125297#zechine.wu-wien.ac.at
+<p>Prepare/Execute implemented for Interbase/Firebird
+<p>Changed some regular expressions to be anchored by /^ $/ for speed.
+<p>Added UnixTimeStamp() and UnixDate() to ADOConnection(). Now these functions
+ are in both ADOConnection and ADORecordSet classes.
+<p>Empty recordsets were not cached - fixed.
+<p>Thanks to Gaetano Giunta (g.giunta#libero.it) for the oci8 code review. We
+ didn't agree on everything, but i hoped we agreed to disagree!
+<p><b>1.90 6 April 2002</b></p>
+<p>Now all database drivers support fetch modes ADODB_FETCH_NUM and ADODB_FETCH_ASSOC, though
+ still not fully tested. Eg. Frontbase, Sybase, Informix.
+<p>NextRecordSet() support for mssql. Contributed by "Sven Axelsson" sven.axelsson#bokochwebb.se
+<p>Added blob support for SQL Anywhere. Contributed by Wade Johnson wade#wadejohnson.de
+<p>Fixed some security loopholes in server.php. Server.php also supports fetch mode.
+<p>Generalized GenID() to support odbc and mssql drivers. Mssql no longer generates GUID's.
+<p>Experimental RowLock($table,$where) for mssql.
+<p>Properly implemented Prepare() in oci8 and ODBC.
+<p>Added Bind() support to oci8 to support Prepare().
+<p>Improved error handler. Catches CacheExecute() and GenID() errors now.
+<p>Now if you are running php from the command line, debugging messages do not output html formating.
+Not 100% complete, but getting there.
+<p><b>1.81 22 March 2002</b></p>
+<p>Restored default $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT for backward compatibility.
+<p>SelectLimit for oci8 improved - Our FIRST_ROWS optimization now does not overwrite existing hint.
+<p>New Sybase SQL Anywhere driver. Contributed by Wade Johnson wade#wadejohnson.de
+<p><b>1.80 15 March 2002</b></p>
+<p>Redesigned directory structure of ADOdb files. Added new driver directory where
+all database drivers reside.
+<p>Changed caching algorithm to create subdirectories. Now we scale better.
+<p>Informix driver now supports insert_id(). Contribution by "Andrea Pinnisi" pinnisi#sysnet.it
+<p>Added experimental ISO date and FetchField support for informix.
+<p>Fixed a quoting bug in Execute() with bind parameters, causing problems with blobs.
+<p>Mssql driver speedup by 10-15%.
+<p>Now in CacheExecute($secs2cache,$sql,...), $secs2cache is optional. If missing, it will
+take the value defined in $connection->cacheSecs (default is 3600 seconds). Note that
+CacheSelectLimit(), the secs2cache is still compulsory - sigh.
+<p>Sybase SQL Anywhere driver (using ODBC) contributed by Wade Johnson wade#wadejohnson.de
+<p><b>1.72 8 March 2002</b></p>
+<p>Added @ when returning Fields() to prevent spurious error - "Michael William Miller" mille562#pilot.msu.edu
+<p>MetaDatabases() for postgres contributed by Phil pamelant#nerim.net
+ <p>Mitchell T. Young (mitch#youngfamily.org) contributed informix driver.
+ <p>Fixed rs2html() problem. I cannot reproduce, so probably a problem with pre PHP 4.1.0 versions,
+ when supporting new ADODB_FETCH_MODEs.
+ <p>Mattia Rossi (mattia#technologist.com) contributed BlobDecode() and UpdateBlobFile() for postgresql
+ using the postgres specific pg_lo_import()/pg_lo_open() - i don't use them but hopefully others will
+ find this useful. See <a href="http://phplens.com/lens/lensforum/msgs.php?id=1262">this posting</a>
+ for an example of usage.
+ <p>Added UpdateBlobFile() for uploading files to a database.
+ <p>Made UpdateBlob() compatible with oci8po driver.
+ <p>Added noNullStrings support to oci8 driver. Oracle changes all ' ' strings to nulls,
+ so you need to set strings to ' ' to prevent the nullifying of strings. $conn->noNullStrings = true;
+ will do this for you automatically. This is useful when you define a char column as NOT NULL.
+ <p>Fixed UnixTimeStamp() bug - wasn't setting minutes and seconds properly. Patch from Agusti Fita i Borrell agusti#anglatecnic.com.
+ <p>Toni Tunkkari added patch for sybase dates. Problem with spaces in day part of date fixed.
+ <p><b>1.71 18 Jan 2002</b></p>
+ <p>Sequence start id support. Now $conn->Gen_ID('seqname', 50) to start sequence from 50.
+ <p>CSV driver fix for selectlimit, from Andreas - akaiser#vocote.de.
+<P>Gam3r spotted that a global variable was undefined in the session handler.
+<p>Mssql date regex had error. Fixed - reported by Minh Hoang vb_user#yahoo.com.
+<p>DBTimeStamp() and DBDate() now accept iso dates and unix timestamps. This means
+that the PostgreSQL handling of dates in GetInsertSQL() and GetUpdateSQL() can
+be removed. Also if these functions are passed '' or null or false, we return a SQL null.
+<p>GetInsertSQL() and GetUpdateSQL() now accept a new parameter, $magicq to
+indicate whether quotes should be inserted based on magic quote settings - suggested by
+dj#4ict.com.
+<p>Reformated docs slightly based on suggestions by Chris Small.
+ <p><b>1.65 28 Dec 2001</b></p>
+ <p>Fixed borland_ibase class naming bug.
+ <p>Now instead of using $rs->fields[0] internally, we use reset($rs->fields) so
+ that we are compatible with ADODB_FETCH_ASSOC mode. Reported by Nico S.
+ <p>Changed recordset constructor and _initrs() for oci8 so that it returns the field definitions even
+ if no rows in the recordset. Reported by Rick Hickerson (rhickers#mv.mv.com).
+ <p>Improved support for postgresql in GetInsertSQL and GetUpdateSQL by
+ "mike" mike#partner2partner.com and "Ryan Bailey" rebel#windriders.com
+ <p><b>1.64 20 Dec 2001</b></p>
+<p>Danny Milosavljevic &lt;danny.milo#gmx.net> added some patches for MySQL error handling
+and displaying default values.
+<p>Fixed some ADODB_FETCH_BOTH inconsistencies in odbc and interbase.
+<p>Added more tests to test suite to cover ADODB_FETCH_* and ADODB_ERROR_HANDLER.
+<p>Added firebird (ibase) driver
+<p>Added borland_ibase driver for interbase 6.5
+<p><b>1.63 13 Dec 2001</b></p>
+Absolute to the adodb-lib.inc.php file not set properly. Fixed.<p>
+
+<p><b>1.62 11 Dec 2001</b></p>
+<p>Major speedup of ADOdb for low-end web sites by reducing the php code loading and compiling
+cycle. We conditionally compile not so common functions.
+Moved csv code to adodb-csvlib.inc.php to reduce adodb.inc.php parsing. This file
+is loaded only when the csv/proxy driver is used, or CacheExecute() is run.
+Also moved PageExecute(), GetSelectSQL() and GetUpdateSQL() core code to adodb-lib.inc.php.
+This reduced the 70K main adodb.inc.php file to 55K, and since at least 20K of the file
+is comments, we have reduced 50K of code in adodb.inc.php to 35K. There
+ should be 35% reduction in memory and thus 35% speedup in compiling the php code for the
+main adodb.inc.php file.
+<p>Highly tuned SelectLimit() for oci8 for massive speed improvements on large files.
+Selecting 20 rows starting from the 20,000th row of a table is now 7 times faster.
+Thx to Tomas V V Cox.
+<p>Allow . and # in table definitions in GetInsertSQL and GetUpdateSQL.
+ See ADODB_TABLE_REGEX constant. Thx to Ari Kuorikoski.
+<p>Added ADODB_PREFETCH_ROWS constant, defaulting to 10. This determines the number
+of records to prefetch in a SELECT statement. Only used by oci8.</p>
+<p>Added high portability Oracle class called oci8po. This uses ? for bind variables, and
+lower cases column names.</p>
+<p>Now all database drivers support $ADODB_FETCH_MODE, including interbase, ado, and odbc:
+ADODB_FETCH_NUM and ADODB_FETCH_ASSOC. ADODB_FETCH_BOTH is not fully implemented for all
+database drivers.
+<p><b>1.61 Nov 2001</b></p>
+<p>Added PO_RecordCount() and PO_Insert_ID(). PO stands for portable. Pablo Roca
+ [pabloroca#mvps.org]</p>
+<p>GenID now returns 0 if not available. Safer is that you should check $conn->hasGenID
+ for availability.</p>
+<p>M'soft ADO we now correctly close recordset in _close() peterd#telephonetics.co.uk</p>
+<p>MSSQL now supports GenID(). It generates a 16-byte GUID from mssql newid()
+ function.</p>
+<p>Changed ereg_replace to preg_replace in SelectLimit. This is a fix for mssql.
+ Ereg doesn't support t or n! Reported by marino Carlos xaplo#postnuke-espanol.org</p>
+<p>Added $recordset->connection. This is the ADOConnection object for the recordset.
+Works with cached and normal recordsets. Surprisingly, this had no affect on performance!</p>
+<p><b>1.54 15 Nov 2001</b></p>
+Fixed some more bugs in PageExecute(). I am getting sick of bug in this and will have to
+reconsider my QA here. The main issue is that I don't use PageExecute() and
+to check whether it is working requires a visual inspection of the html generated currently.
+It is possible to write a test script but it would be quite complicated :(
+<p> More speedups of SelectLimit() for DB2, Oci8, access, vfp, mssql.
+<p>
+
+<p><b>1.53 7 Nov 2001</b></p>
+Added support for ADODB_FETCH_ASSOC for ado and odbc drivers.<p>
+Tuned GetRowAssoc(false) in postgresql and mysql.<p>
+Stephen Van Dyke contributed ADOdb icon, accepted with some minor mods.<p>
+Enabled Affected_Rows() for postgresql<p>
+Speedup for Concat() using implode() - Benjamin Curtis ben_curtis#yahoo.com<p>
+Fixed some more bugs in PageExecute() to prevent infinite loops<p>
+<p><b>1.52 5 Nov 2001</b></p>
+Spelling error in CacheExecute() caused it to fail. $ql should be $sql in line 625!<p>
+Added fixes for parsing [ and ] in GetUpdateSQL().
+<p><b>1.51 5 Nov 2001</b></p>
+<p>Oci8 SelectLimit() speedup by using OCIFetch().
+<p>Oci8 was mistakenly reporting errors when $db->debug = true.
+<p>If a connection failed with ODBC, it was not correctly reported - fixed.
+<p>_connectionID was inited to -1, changed to false.
+<p>Added $rs->FetchRow(), to simplify API, ala PEAR DB
+<p>Added PEAR DB compat mode, which is still faster than PEAR! See adodb-pear.inc.php.
+<p>Removed postgres pconnect debugging statement.
+<p><b>1.50 31 Oct 2001</b></p>
+<p>ADOdbConnection renamed to ADOConnection, and ADOdbFieldObject to ADOFieldObject.
+<p>PageExecute() now checks for empty $rs correctly, and the errors in the docs on this subject have been fixed.
+<p>odbc_error() does not return 6 digit error correctly at times. Implemented workaround.
+<p>Added ADORecordSet_empty class. This will speedup INSERTS/DELETES/UPDATES because the return
+object created is much smaller.
+<p>Added Prepare() to odbc, and oci8 (but doesn't work properly for oci8 still).
+<p>Made pgsql a synonym for postgre7, and changed SELECT LIMIT to use OFFSET for compat with
+postgres 7.2.
+<p>Revised adodb-cryptsession.php thanks to Ari.
+<p>Set resources to false on _close, to force freeing of resources.
+<p>Added adodb-errorhandler.inc.php, adodb-errorpear.inc.php and raiseErrorFn on Freek's urging.
+<p>GetRowAssoc($toUpper=true): $toUpper added as default.
+<p>Errors when connecting to a database were not captured formerly. Now we do it correctly.
+<p><b>1.40 19 September 2001</b></p>
+<p>PageExecute() to implement page scrolling added. Code and idea by Iv&aacute;n Oliva.</p>
+<p>Some minor postgresql fixes.</p>
+<p>Added sequence support using GenID() for postgresql, oci8, mysql, interbase.</p>
+<p>Added UpdateBlob support for interbase (untested).</p>
+<p>Added encrypted sessions (see adodb-cryptsession.php). By Ari Kuorikoski &lt;kuoriari#finebyte.com></p>
+<p><b>1.31 21 August 2001</b></p>
+<p>Many bug fixes thanks to "GaM3R (Cameron)" &lt;gamr#outworld.cx>. Some session changes due to Gam3r.
+<p>Fixed qstr() to quote also.
+<p>rs2html() now pretty printed.
+<p>Jonathan Younger jyounger#unilab.com contributed the great idea GetUpdateSQL() and GetInsertSQL() which
+generates SQL to update and insert into a table from a recordset. Modify the recordset fields
+array, then can this function to generate the SQL (the SQL is not executed).
+<p>"Nicola Fankhauser" &lt;nicola.fankhauser#couniq.com> found some bugs in date handling for mssql.</p>
+<p>Added minimal Oracle support for LOBs. Still under development.</p>
+Added $ADODB_FETCH_MODE so you can control whether recordsets return arrays which are
+numeric, associative or both. This is a global variable you set. Currently only MySQL, Oci8, Postgres
+drivers support this.
+<p>PostgreSQL properly closes recordsets now. Reported by several people.
+<p>
+Added UpdateBlob() for Oracle. A hack to make it easier to save blobs.
+<p>
+Oracle timestamps did not display properly. Fixed.
+<p><b>1.20 6 June 2001</b></p>
+<p>Now Oracle can connect using tnsnames.ora or server and service name</p>
+<p>Extensive Oci8 speed optimizations.
+Oci8 code revised to support variable binding, and /*+ FIRST_ROWS */ hint.</p>
+<p>Worked around some 4.0.6 bugs in odbc_fetch_into().</p>
+<p>Paolo S. Asioli paolo.asioli#libero.it suggested GetRowAssoc().</p>
+<p>Escape quotes for oracle wrongly set to '. Now '' is used.</p>
+<p>Variable binding now works in ODBC also.</p>
+<p>Jumped to version 1.20 because I don't like 13 :-)</p>
+<p><b>1.12 6 June 2001</b></p>
+<p>Changed $ADODB_DIR to ADODB_DIR constant to plug a security loophole.</p>
+<p>Changed _close() to close persistent connections also. Prevents connection leaks.</p>
+<p>Major revision of oracle and oci8 drivers.
+Added OCI_RETURN_NULLS and OCI_RETURN_LOBS to OCIFetchInto(). BLOB, CLOB and VARCHAR2 recognition
+in MetaType() improved. MetaColumns() returns columns in correct sort order.</p>
+<p>Interbase timestamp input format was wrong. Fixed.</p>
+<p><b>1.11 20 May 2001</b></p>
+<p>Improved file locking for Windows.</p>
+<p>Probabilistic flushing of cache to avoid avalanche updates when cache timeouts.</p>
+<p>Cached recordset timestamp not saved in some scenarios. Fixed.</p>
+<p><b>1.10 19 May 2001</b></p>
+<p>Added caching. CacheExecute() and CacheSelectLimit().
+<p>Added csv driver. See <a href="http://php.weblogs.com/adodb_csv">http://php.weblogs.com/ADODB_csv</a>.
+<p>Fixed SelectLimit(), SELECT TOP not working under certain circumstances.
+<p>Added better Frontbase support of MetaTypes() by Frank M. Kromann.
+<p><b>1.01 24 April 2001</b></p>
+<p>Fixed SelectLimit bug. not quoted properly.
+<p>SelectLimit: SELECT TOP -1 * FROM TABLE not support by Microsoft. Fixed.</p>
+<p>GetMenu improved by glen.davies#cce.ac.nz to support multiple hilited items<p>
+<p>FetchNextObject() did not work with only 1 record returned. Fixed bug reported by $tim#orotech.net</p>
+<p>Fixed mysql field max_length problem. Fix suggested by Jim Nicholson (jnich#att.com)</p>
+<p><b>1.00 16 April 2001</b></p>
+<p>Given some brilliant suggestions on how to simplify ADOdb by akul. You no longer need to
+setup $ADODB_DIR yourself, and ADOLoadCode() is automatically called by ADONewConnection(),
+simplifying the startup code.</p>
+<p>FetchNextObject() added. Suggested by Jakub Marecek. This makes FetchObject() obsolete, as
+this is more flexible and powerful.</p>
+<p>Misc fixes to SelectLimit() to support Access (top must follow distinct) and Fields()
+in the array recordset. From Reinhard Balling.</p>
+<p><b>0.96 27 Mar 2001</b></p>
+<p>ADOConnection Close() did not return a value correctly. Thanks to akul#otamedia.com.</p>
+<p>When the horrible magic_quotes is enabled, back-slash () is changed to double-backslash (\).
+This doesn't make sense for Microsoft/Sybase databases. We fix this in qstr().</p>
+<p>Fixed Sybase date problem in UnixDate() thanks to Toni Tunkkari. Also fixed MSSQL problem
+in UnixDate() - thanks to milhouse31#hotmail.com.</p>
+<p>MoveNext() moved to leaf classes for speed in MySQL/PostgreSQL. 10-15% speedup.</p>
+<p>Added null handling in bindInputArray in Execute() -- Ron Baldwin suggestion.</p>
+<p>Fixed some option tags. Thanks to john#jrmstudios.com.</p>
+<p><b>0.95 13 Mar 2001</b></p>
+<p>Added postgres7 database driver which supports LIMIT and other version 7 stuff in the future.</p>
+<p>Added SelectLimit to ADOConnection to simulate PostgreSQL's "select * from table limit 10 offset 3".
+Added helper function GetArrayLimit() to ADORecordSet.</p>
+<p>Fixed mysql metacolumns bug. Thanks to Freek Dijkstra (phpeverywhere#macfreek.com).</p>
+<p>Also many PostgreSQL changes by Freek. He almost rewrote the whole PostgreSQL driver!</p>
+<p>Added fix to input parameters in Execute for non-strings by Ron Baldwin.</p>
+<p>Added new metatype, X for TeXt. Formerly, metatype B for Blob also included
+text fields. Now 'B' is for binary/image data. 'X' for textual data.</p>
+<p>Fixed $this->GetArray() in GetRows().</p>
+<p>Oracle and OCI8: 1st parameter is always blank -- now warns if it is filled.</p>
+<p>Now <i>hasLimit</i> and <i>hasTop</i> added to indicate whether
+SELECT * FROM TABLE LIMIT 10 or SELECT TOP 10 * FROM TABLE are supported.</p>
+<p><b>0.94 04 Feb 2001</b></p>
+<p>Added ADORecordSet::GetRows() for compatibility with Microsoft ADO. Synonym for GetArray().</p>
+<p>Added new metatype 'R' to represent autoincrement numbers.</p>
+<p>Added ADORecordSet.FetchObject() to return a row as an object.</p>
+<p>Finally got a Linux box to test PostgreSql. Many fixes.</p>
+<p>Fixed copyright misspellings in 0.93.</p>
+<p>Fixed mssql MetaColumns type bug.</p>
+<p>Worked around odbc bug in PHP4 for sessions.</p>
+<p>Fixed many documentation bugs (affected_rows, metadatabases, qstr).</p>
+<p>Fixed MySQL timestamp format (removed comma).</p>
+<p>Interbase driver did not call ibase_pconnect(). Fixed.</p>
+<p><b>0.93 18 Jan 2002</b></p>
+<p>Fixed GetMenu bug.</p>
+<p>Simplified Interbase commit and rollback.</p>
+<p>Default behaviour on closing a connection is now to rollback all active transactions.</p>
+<p>Added field object handling for array recordset for future XML compatibility.</p>
+<p>Added arr2html() to convert array to html table.</p>
+<p><b>0.92 2 Jan 2002</b></p>
+<p>Interbase Commit and Rollback should be working again.</p>
+<p>Changed initialisation of ADORecordSet. This is internal and should not affect users. We
+are doing this to support cached recordsets in the future.</p>
+
+<p>Implemented ADORecordSet_array class. This allows you to simulate a database recordset
+with an array.</p>
+<p>Added UnixDate() and UnixTimeStamp() to ADORecordSet.</p>
+<p><b>0.91 21 Dec 2000</b></p>
+<p>Fixed ODBC so ErrorMsg() is working.</p>
+<p>Worked around ADO unrecognised null (0x1) value problem in COM.</p>
+<p>Added Sybase support for FetchField() type</p>
+<p>Removed debugging code and unneeded html from various files</p>
+<p>Changed to javadoc style comments to adodb.inc.php.</p>
+<p>Added maxsql as synonym for mysqlt</p>
+<p>Now ODBC downloads first 8K of blob by default
+<p><b>0.90 15 Nov 2000</b></p>
+<p>Lots of testing of Microsoft ADO. Should be more stable now.</p>
+<p>Added $ADODB_COUNTREC. Set to false for high speed selects.</p>
+<p>Added Sybase support. Contributed by Toni Tunkkari (toni.tunkkari#finebyte.com). Bug in Sybase
+ API: GetFields is unable to determine date types.</p>
+<p>Changed behaviour of RecordSet.GetMenu() to support size parameter (listbox) properly.</p>
+<p>Added emptyDate and emptyTimeStamp to RecordSet class that defines how to represent
+ empty dates.</p>
+<p>Added MetaColumns($table) that returns an array of ADOFieldObject's listing
+ the columns of a table.</p>
+<p>Added transaction support for PostgresSQL -- thanks to "Eric G. Werk" egw#netguide.dk.</p>
+<p>Added adodb-session.php for session support.</p>
+<p><b>0.80 30 Nov 2000</b></p>
+<p>Added support for charSet for interbase. Implemented MetaTables for most databases.
+ PostgreSQL more extensively tested.</p>
+<p><b>0.71 22 Nov 2000</b></p>
+<p>Switched from using require_once to include/include_once for backward compatability with PHP 4.02 and earlier.</p>
+<p><b>0.70 15 Nov 2000</b></p>
+<p>Calls by reference have been removed (call_time_pass_reference=Off) to ensure compatibility with future versions of PHP,
+except in Oracle 7 driver due to a bug in php_oracle.dll.</p>
+<p>PostgreSQL database driver contributed by Alberto Cerezal (acerezalp#dbnet.es).
+</p>
+<p>Oci8 driver for Oracle 8 contributed by George Fourlanos (fou#infomap.gr).</p>
+<p>Added <i>mysqlt</i> database driver to support MySQL 3.23 which has transaction
+ support. </p>
+<p>Oracle default date format (DD-MON-YY) did not match ADOdb default date format (which is YYYY-MM-DD). Use ALTER SESSION to force the default date.</p>
+<p>Error message checking is now included in test suite.</p>
+<p>MoveNext() did not check EOF properly -- fixed.</p>
+<p><b>0.60 Nov 8 2000</b></p>
+<p>Fixed some constructor bugs in ODBC and ADO. Added ErrorNo function to ADOConnection
+ class. </p>
+<p><b>0.51 Oct 18 2000</b></p>
+<p>Fixed some interbase bugs.</p>
+<p><b>0.50 Oct 16 2000</b></p>
+<p>Interbase commit/rollback changed to be compatible with PHP 4.03. </p>
+<p>CommitTrans( ) will now return true if transactions not supported. </p>
+<p>Conversely RollbackTrans( ) will return false if transactions not supported.
+</p>
+<p><b>0.46 Oct 12</b></p>
+Many Oracle compatibility issues fixed.
+<p><b>0.40 Sept 26</b></p>
+<p>Many bug fixes</p>
+<p>Now Code for BeginTrans, CommitTrans and RollbackTrans is working. So is the Affected_Rows
+and Insert_ID. Added above functions to test.php.</p>
+<p>ADO type handling was busted in 0.30. Fixed.</p>
+<p>Generalised Move( ) so it works will all databases, including ODBC.</p>
+<p><b>0.30 Sept 18</b></p>
+<p>Renamed ADOLoadDB to ADOLoadCode. This is clearer.</p>
+<p>Added BeginTrans, CommitTrans and RollbackTrans functions.</p>
+<p>Added Affected_Rows() and Insert_ID(), _affectedrows() and _insertID(), ListTables(),
+ ListDatabases(), ListColumns().</p>
+<p>Need to add New_ID() and hasInsertID and hasAffectedRows, autoCommit </p>
+<p><b>0.20 Sept 12</b></p>
+<p>Added support for Microsoft's ADO.</p>
+<p>Added new field to ADORecordSet -- canSeek</p>
+<p>Added new parameter to _fetch($ignore_fields = false). Setting to true will
+ not update fields array for faster performance.</p>
+<p>Added new field to ADORecordSet/ADOConnection -- dataProvider to indicate whether
+ a class is derived from odbc or ado.</p>
+<p>Changed class ODBCFieldObject to ADOFieldObject -- not documented currently.</p>
+<p>Added benchmark.php and testdatabases.inc.php to the test suite.</p>
+<p>Added to ADORecordSet FastForward( ) for future high speed scrolling. Not documented.</p>
+<p>Realised that ADO's Move( ) uses relative positioning. ADOdb uses absolute.
+</p>
+<p><b>0.10 Sept 9 2000</b></p>
+<p>First release</p>
+<p> \ No newline at end of file
diff --git a/html/phpgacl/adodb/docs/readme.htm b/html/phpgacl/adodb/docs/readme.htm
new file mode 100644
index 0000000..b19fde7
--- /dev/null
+++ b/html/phpgacl/adodb/docs/readme.htm
@@ -0,0 +1,69 @@
+<html>
+<head>
+<title>ADODB Manual</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<XSTYLE
+ body,td {font-family:Arial,Helvetica,sans-serif;font-size:11pt}
+ pre {font-size:9pt}
+ .toplink {font-size:8pt}
+ />
+</head>
+<body bgcolor="#FFFFFF">
+
+<h3>ADOdb Library for PHP</h3>
+<p>ADOdb is a suite of database libraries that allow you to connect to multiple
+ databases in a portable manner. Download from <a href=http://php.weblogs.com/adodb>http://php.weblogs.com/adodb</a>.
+<ul><li>The ADOdb documentation has moved to <a href=docs-adodb.htm>docs-adodb.htm</a>
+ This allows you to query, update and insert records using a portable API.
+<p><li>The ADOdb data dictionary docs are at <a href=docs-datadict.htm>docs-datadict.htm</a>.
+ This allows you to create database tables and indexes in a portable manner.
+<p><li>The ADOdb database performance monitoring docs are at <a href=docs-perf.htm>docs-perf.htm</a>.
+ This allows you to perform health checks, tune and monitor your database.
+<p><li>The ADOdb database-backed session docs are at <a href=docs-session.htm>docs-session.htm</a>.
+</ul>
+<p>
+<h3>Installation</h3>
+Make sure you are running PHP4.0.4 or later. Unpack all the files into a directory accessible by your webserver.
+<p>
+To test, try modifying some of the tutorial examples. Make sure you customize the connection settings correctly. You can debug using:
+<pre>
+&lt;?php
+include('adodb/adodb.inc.php');
+
+$db = <b>ADONewConnection</b>($driver); # eg. 'mysql' or 'oci8'
+$db->debug = true;
+$db-><b>Connect</b>($server, $user, $password, $database);
+$rs = $db-><b>Execute</b>('select * from some_small_table');
+print "&lt;pre>";
+print_r($rs-><b>GetRows</b>());
+print "&lt;/pre>";
+?>
+</pre>
+<h3>How are people using ADOdb</h3>
+Here are some examples of how people are using ADOdb (for a much longer list,
+visit <a href="http://php.weblogs.com/adodb-cool-applications">http://php.weblogs.com/adodb-cool-applications</a>):
+<ul>
+ <li> <strong>PhpLens</strong> is a commercial data grid component that allows
+ both cool Web designers and serious unshaved programmers to develop and
+ maintain databases on the Web easily. Developed by the author of ADOdb.
+ </li>
+ <li> <strong>PHAkt</strong>: PHP Extension for DreamWeaver Ultradev allows
+ you to script PHP in the popular Web page editor. Database handling provided
+ by ADOdb. </li>
+ <li> <strong>Analysis Console for Intrusion Databases (ACID)</strong>: PHP-based
+ analysis engine to search and process a database of security incidents
+ generated by security-related software such as IDSes and firewalls (e.g.
+ Snort, ipchains). By Roman Danyliw. </li>
+ <li> <strong>PostNuke</strong> is a very popular free content management system
+ and weblog system. It offers full CSS support, HTML 4.01 transitional
+ compliance throughout, an advanced blocks system, and is fully multi-lingual
+ enabled. </li>
+ <li><strong> EasyPublish CMS</strong> is another free content management system
+ for managing information and integrated modules on your internet, intranet-
+ and extranet-sites. From Norway. </li>
+ <li> <strong>NOLA</strong> is a full featured accounting, inventory, and job
+ tracking application. It is licensed under the GPL, and developed by Noguska.
+ </li>
+</ul>
+</body>
+</html>
diff --git a/html/phpgacl/adodb/docs/tips_portable_sql.htm b/html/phpgacl/adodb/docs/tips_portable_sql.htm
new file mode 100644
index 0000000..2d08bbb
--- /dev/null
+++ b/html/phpgacl/adodb/docs/tips_portable_sql.htm
@@ -0,0 +1,362 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <title>Tips on Writing Portable SQL for Multiple Databases for PHP</title>
+</head>
+
+<body bgcolor=white>
+<table width=100% border=0><tr><td><h2>Tips on Writing Portable SQL &nbsp;</h2></td><td>
+ <div align=right><img src="cute_icons_for_site/adodb.gif"></div></td></tr></table>
+ <p>Updated 18 Sep 2003. Added Portable Native SQL section.
+<p>
+
+ If you are writing an application that is used in multiple environments and
+ operating systems, you need to plan to support multiple databases. This article
+ is based on my experiences with multiple database systems, stretching from 4th
+ Dimension in my Mac days, to the databases I currently use, which are: Oracle,
+ FoxPro, Access, MS SQL Server and MySQL. Although most of the advice here applies
+ to using SQL with Perl, Python and other programming languages, I will focus on PHP and how
+ the <a href="http://adodb.sourceforge.net/">ADOdb</a> database abstraction library
+ offers some solutions.<p></p>
+<p>Most database vendors practice product lock-in. The best or fastest way to
+ do things is often implemented using proprietary extensions to SQL. This makes
+ it extremely hard to write portable SQL code that performs well under all conditions.
+ When the first ANSI committee got together in 1984 to standardize SQL, the database
+ vendors had such different implementations that they could only agree on the
+ core functionality of SQL. Many important application specific requirements
+ were not standardized, and after so many years since the ANSI effort began,
+ it looks as if much useful database functionality will never be standardized.
+ Even though ANSI-92 SQL has codified much more, we still have to implement portability
+ at the application level.</p>
+<h3><b>Selects</b></h3>
+<p>The SELECT statement has been standardized to a great degree. Nearly every
+ database supports the following:</p>
+<p>SELECT [cols] FROM [tables]<br>
+ &nbsp;&nbsp;[WHERE conditions]<br>
+ &nbsp; [GROUP BY cols]<br>
+ &nbsp; [HAVING conditions] <br>
+ &nbsp; [ORDER BY cols]</p>
+<p>But so many useful techniques can only be implemented by using proprietary
+ extensions. For example, when writing SQL to retrieve the first 10 rows for
+ paging, you could write...</p>
+<table width="80%" border="1" cellspacing="0" cellpadding="0" align="center">
+ <tr>
+ <td><b>Database</b></td>
+ <td><b>SQL Syntax</b></td>
+ </tr>
+ <tr>
+ <td>DB2</td>
+ <td>select * from table fetch first 10 rows only</td>
+ </tr>
+ <tr>
+ <td>Informix</td>
+ <td>select first 10 * from table</td>
+ </tr>
+ <tr>
+ <td>Microsoft SQL Server and Access</td>
+ <td>select top 10 * from table</td>
+ </tr>
+ <tr>
+ <td>MySQL and PostgreSQL</td>
+ <td>select * from table limit 10</td>
+ </tr>
+ <tr>
+ <td>Oracle 8i</td>
+ <td>select * from (select * from table) where rownum &lt;= 10</td>
+ </tr>
+</table>
+<p>This feature of getting a subset of data is so useful that in the PHP class
+ library ADOdb, we have a SelectLimit( ) function that allows you to hide the
+ implementation details within a function that will rewrite your SQL for you:</p>
+<pre>$connection-&gt;SelectLimit('select * from table', 10);
+</pre>
+<p><b>Selects: Fetch Modes</b></p>
+<p>PHP allows you to retrieve database records as arrays. You can choose to have
+ the arrays indexed by field name or number. However different low-level PHP
+ database drivers are inconsistent in their indexing efforts. ADOdb allows you
+ to determine your prefered mode. You set this by setting the variable $ADODB_FETCH_MODE
+ to either of the constants ADODB_FETCH_NUM (for numeric indexes) or ADODB_FETCH_ASSOC
+ (using field names as an associative index).</p>
+<p>The default behaviour of ADOdb varies depending on the database you are using.
+ For consistency, set the fetch mode to either ADODB_FETCH_NUM (for speed) or
+ ADODB_FETCH_ASSOC (for convenience) at the beginning of your code. </p>
+<p><b>Selects: Counting Records</b></p>
+<p>Another problem with SELECTs is that some databases do not return the number
+ of rows retrieved from a select statement. This is because the highest performance
+ databases will return records to you even before the last record has been found.
+</p>
+<p>In ADOdb, RecordCount( ) returns the number of rows returned, or will emulate
+ it by buffering the rows and returning the count after all rows have been returned.
+ This can be disabled for performance reasons when retrieving large recordsets
+ by setting the global variable $ADODB_COUNTRECS = false. This variable is checked
+ every time a query is executed, so you can selectively choose which recordsets
+ to count.</p>
+<p>If you prefer to set $ADODB_COUNTRECS = false, ADOdb still has the PO_RecordCount(
+ ) function. This will return the number of rows, or if it is not found, it will
+ return an estimate using SELECT COUNT(*):</p>
+<pre>$rs = $db-&gt;Execute(&quot;select * from table where state=$state&quot;);
+$numrows = $rs-&gt;PO_RecordCount('table', &quot;state=$state&quot;);</pre>
+<p><b>Selects: Locking</b> </p>
+<p>SELECT statements are commonly used to implement row-level locking of tables.
+ Other databases such as Oracle, Interbase, PostgreSQL and MySQL with InnoDB
+ do not require row-level locking because they use versioning to display data
+ consistent with a specific point in time.</p>
+<p>Currently, I recommend encapsulating the row-level locking in a separate function,
+ such as RowLock($table, $where):</p>
+<pre>$connection-&gt;BeginTrans( );
+$connection-&gt;RowLock($table, $where); </pre>
+<pre><font color=green># some operation</font></pre>
+<pre>if ($ok) $connection-&gt;CommitTrans( );
+else $connection-&gt;RollbackTrans( );
+</pre>
+<p><b>Selects: Outer Joins</b></p>
+<p>Not all databases support outer joins. Furthermore the syntax for outer joins
+ differs dramatically between database vendors. One portable (and possibly slower)
+ method of implementing outer joins is using UNION.</p>
+<p>For example, an ANSI-92 left outer join between two tables t1 and t2 could
+ look like:</p>
+<pre>SELECT t1.col1, t1.col2, t2.cola <br> FROM t1 <i>LEFT JOIN</i> t2 ON t1.col = t2.col</pre>
+<p>This can be emulated using:</p>
+<pre>SELECT t1.col1, t1.col2, t2.cola FROM t1, t2 <br> WHERE t1.col = t2.col
+ UNION ALL
+SELECT col1, col2, null FROM t1 <br> WHERE t1.col not in (select distinct col from t2)
+</pre>
+<p>Since ADOdb 2.13, we provide some hints in the connection object as to legal
+ join variations. This is still incomplete and sometimes depends on the database
+ version you are using, but is useful as a general guideline:</p>
+<p><font face="Courier New, Courier, mono">$conn-&gt;leftOuter</font>: holds the
+ operator used for left outer joins (eg. '*='), or false if not known or not
+ available.<br>
+ <font face="Courier New, Courier, mono">$conn-&gt;rightOuter</font>: holds the
+ operator used for right outer joins (eg '=*'), or false if not known or not
+ available.<br>
+ <font face="Courier New, Courier, mono">$conn-&gt;ansiOuter</font>: boolean
+ that if true means that ANSI-92 style outer joins are supported, or false if
+ not known.</p>
+<h3><b>Inserts</b> </h3>
+<p>When you create records, you need to generate unique id's for each record.
+ There are two common techniques: (1) auto-incrementing columns and (2) sequences.
+</p>
+<p>Auto-incrementing columns are supported by MySQL, Sybase and Microsoft Access
+ and SQL Server. However most other databases do not support this feature. So
+ for portability, you have little choice but to use sequences. Sequences are
+ special functions that return a unique incrementing number every time you call
+ it, suitable to be used as database keys. In ADOdb, we use the GenID( ) function.
+ It has takes a parameter, the sequence name. Different tables can have different
+ sequences. </p>
+<pre>$id = $connection-&gt;GenID('sequence_name');<br>$connection-&gt;Execute(&quot;insert into table (id, firstname, lastname) <br> values ($id, $firstname, $lastname)&quot;);</pre>
+<p>For databases that do not support sequences natively, ADOdb emulates sequences
+ by creating a table for every sequence.</p>
+<h3><b>Binding</b></h3>
+<p>Binding variables in an SQL statement is another tricky feature. Binding is
+ useful because it allows pre-compilation of SQL. When inserting multiple records
+ into a database in a loop, binding can offer a 50% (or greater) speedup. However
+ many databases such as Access and MySQL do not support binding natively and
+ there is some overhead in emulating binding. Furthermore, different databases
+ (specificly Oracle!) implement binding differently. My recommendation is to
+ use binding if your database queries are too slow, but make sure you are using
+ a database that supports it like Oracle. </p>
+<p>ADOdb supports portable Prepare/Execute with:</p>
+<pre>$stmt = $db-&gt;Prepare('select * from customers where custid=? and state=?');
+$rs = $db-&gt;Execute($stmt, array($id,'New York'));</pre>
+<p>Oracle uses named bind placeholders, not "?", so to support portable binding, we have Param() that generates
+the correct placeholder (available since ADOdb 3.92):
+<pre><font color="#000000">$sql = <font color="#993300">'insert into table (col1,col2) values ('</font>.$DB-&gt;Param('a').<font color="#993300">','</font>.$DB-&gt;Param('b').<font color="#993300">')'</font>;
+<font color="#006600"># generates 'insert into table (col1,col2) values (?,?)'
+# or 'insert into table (col1,col2) values (:a,:b)</font>'
+$stmt = $DB-&gt;Prepare($sql);
+$stmt = $DB-&gt;Execute($stmt,array('one','two'));
+</font></pre>
+<a name="native"></a>
+<h2>Portable Native SQL</h2>
+<p>ADOdb provides the following functions for portably generating SQL functions
+ as strings to be merged into your SQL statements (some are only available since
+ ADOdb 3.92): </p>
+<table width="75%" border="1" align=center>
+ <tr>
+ <td width=30%><b>Function</b></td>
+ <td><b>Description</b></td>
+ </tr>
+ <tr>
+ <td>DBDate($date)</td>
+ <td>Pass in a UNIX timestamp or ISO date and it will convert it to a date
+ string formatted for INSERT/UPDATE</td>
+ </tr>
+ <tr>
+ <td>DBTimeStamp($date)</td>
+ <td>Pass in a UNIX timestamp or ISO date and it will convert it to a timestamp
+ string formatted for INSERT/UPDATE</td>
+ </tr>
+ <tr>
+ <td>SQLDate($date, $fmt)</td>
+ <td>Portably generate a date formatted using $fmt mask, for use in SELECT
+ statements.</td>
+ </tr>
+ <tr>
+ <td>OffsetDate($date, $ndays)</td>
+ <td>Portably generate a $date offset by $ndays.</td>
+ </tr>
+ <tr>
+ <td>Concat($s1, $s2, ...)</td>
+ <td>Portably concatenate strings. Alternatively, for mssql use mssqlpo driver,
+ which allows || operator.</td>
+ </tr>
+ <tr>
+ <td>IfNull($fld, $replaceNull)</td>
+ <td>Returns a string that is the equivalent of MySQL IFNULL or Oracle NVL.</td>
+ </tr>
+ <tr>
+ <td>Param($name)</td>
+ <td>Generates bind placeholders, using ? or named conventions as appropriate.</td>
+ </tr>
+ <tr><td>$db->sysDate</td><td>Property that holds the SQL function that returns today's date</td>
+</tr>
+<tr><td>$db->sysTimeStamp</td><td>Property that holds the SQL function that returns the current
+timestamp (date+time).
+</td>
+</tr>
+<tr>
+<td>$db->concat_operator</td><td>Property that holds the concatenation operator
+</td>
+</tr>
+<tr><td>$db->length</td><td>Property that holds the name of the SQL strlen function.
+</td></tr>
+
+<tr><td>$db->upperCase</td><td>Property that holds the name of the SQL strtoupper function.
+</td></tr>
+<tr><td>$db->random</td><td>Property that holds the SQL to generate a random number between 0.00 and 1.00.
+</td>
+</tr>
+<tr><td>$db->substr</td><td>Property that holds the name of the SQL substring function.
+</td></tr>
+</table>
+<p>&nbsp; </p>
+<h2>DDL and Tuning</h2>
+There are database design tools such as ERWin or Dezign that allow you to generate data definition language commands such as ALTER TABLE or CREATE INDEX from Entity-Relationship diagrams.
+<p>
+However if you prefer to use a PHP-based table creation scheme, adodb provides you with this feature. Here is the code to generate the SQL to create a table with:
+<ol>
+ <li> Auto-increment primary key 'ID', </li>
+ <li>The person's 'NAME' VARCHAR(32) NOT NULL and defaults to '', </li>
+ <li>The date and time of record creation 'CREATED', </li>
+ <li> The person's 'AGE', defaulting to 0, type NUMERIC(16). </li>
+</ol>
+<p>
+Also create a compound index consisting of 'NAME' and 'AGE':
+<pre>
+$datadict = <strong>NewDataDictionary</strong>($connection);
+$flds = "
+<font color="#660000"> ID I AUTOINCREMENT PRIMARY,
+ NAME C(32) DEFAULT '' NOTNULL,
+ CREATED T DEFTIMESTAMP,
+ AGE N(16) DEFAULT 0</font>
+";
+$sql1 = $datadict-><strong>CreateTableSQL</strong>('tabname', $flds);
+$sql2 = $datadict-><strong>CreateIndexSQL</strong>('idx_name_age', 'tabname', 'NAME,AGE');
+</pre>
+
+<h3>Data Types</h3>
+<p>Stick to a few data types that are available in most databases. Char, varchar
+ and numeric/number are supported by most databases. Most other data types (including
+ integer, boolean and float) cannot be relied on being available. I recommend
+ using char(1) or number(1) to hold booleans. </p>
+<p>Different databases have different ways of representing dates and timestamps/datetime.
+ ADOdb attempts to display all dates in ISO (YYYY-MM-DD) format. ADOdb also provides
+ DBDate( ) and DBTimeStamp( ) to convert dates to formats that are acceptable
+ to that database. Both functions accept Unix integer timestamps and date strings
+ in ISO format.</p>
+<pre>$date1 = $connection-&gt;DBDate(time( ));<br>$date2 = $connection-&gt;DBTimeStamp('2002-02-23 13:03:33');</pre>
+<p>We also provide functions to convert database dates to Unix timestamps:</p>
+<pre>$unixts = $recordset-&gt;UnixDate('#2002-02-30#'); <font color="green"># MS Access date =&gt; unix timestamp</font></pre>
+<p>The maximum length of a char/varchar field is also database specific. You can
+ only assume that field lengths of up to 250 characters are supported. This is
+ normally impractical for web based forum or content management systems. You
+ will need to be familiar with how databases handle large objects (LOBs). ADOdb
+ implements two functions, UpdateBlob( ) and UpdateClob( ) that allow you to
+ update fields holding Binary Large Objects (eg. pictures) and Character Large
+ Objects (eg. HTML articles):</p>
+<pre><font color=green># for oracle </font>
+$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1,empty_blob())');
+$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
+
+<font color=green># non-oracle databases</font>
+$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
+</pre>
+<p>Null handling is another area where differences can occur. This is a mine-field,
+ because 3-value logic is tricky.
+<p>In general, I avoid using nulls except for dates and default all my numeric
+ and character fields to 0 or the empty string. This maintains consistency with
+ PHP, where empty strings and zero are treated as equivalent, and avoids SQL
+ ambiguities when you use the ANY and EXISTS operators. However if your database
+ has significant amounts of missing or unknown data, using nulls might be a good
+ idea.
+ <p>
+ ADOdb also supports a portable <a href=http://phplens.com/adodb/reference.functions.concat.html#ifnull>IfNull</a> function, so you can define what to display
+ if the field contains a null.
+<h3><b>Stored Procedures</b></h3>
+<p>Stored procedures are another problem area. Some databases allow recordsets
+ to be returned in a stored procedure (Microsoft SQL Server and Sybase), and
+ others only allow output parameters to be returned. Stored procedures sometimes
+ need to be wrapped in special syntax. For example, Oracle requires such code
+ to be wrapped in an anonymous block with BEGIN and END. Also internal sql operators
+ and functions such as +, ||, TRIM( ), SUBSTR( ) or INSTR( ) vary between vendors.
+</p>
+<p>An example of how to call a stored procedure with 2 parameters and 1 return
+ value follows:</p>
+<pre> switch ($db->databaseType) {
+ case '<font color="#993300">mssql</font>':
+ $sql = <font color="#000000"><font color="#993333">'<font color="#993300">SP_RUNSOMETHING</font>'</font></font>; break;
+ case '<font color="#993300">oci8</font>':
+ $sql =
+<font color="#993300"> </font><font color="#000000"><font color="#993300">&quot;declare RETVAL integer;begin :RETVAL := </font><font color="#000000"><font color="#993333"><font color="#993300">SP_RUNSOMETHING</font></font></font><font color="#993300">(:myid,:group);end;&quot;;
+</font> break;</font>
+ default:
+ die('<font color="#993300">Unsupported feature</font>');
+ }
+<font color="#000000"><font color="green"> # @RETVAL = SP_RUNSOMETHING @myid,@group</font>
+ $stmt = $db-&gt;PrepareSP($sql); <br> $db-&gt;Parameter($stmt,$id,'<font color="#993300">myid</font>');
+ $db-&gt;Parameter($stmt,$group,'<font color="#993300">group</font>');
+ <font color="green"># true indicates output parameter<br> </font>$db-&gt;Parameter($stmt,$ret,'<font color="#993300">RETVAL</font>',true);
+ $db-&gt;Execute($stmt); </font></pre>
+<p>As you can see, the ADOdb API is the same for both databases. But the stored
+ procedure SQL syntax is quite different between databases and is not portable,
+ so be forewarned! However sometimes you have little choice as some systems only
+ allow data to be accessed via stored procedures. This is when the ultimate portability
+ solution might be the only solution: <i>treating portable SQL as a localization
+ exercise...</i></p>
+<h3><b>SQL as a Localization Exercise</b></h3>
+<p> In general to provide real portability, you will have to treat SQL coding
+ as a localization exercise. In PHP, it has become common to define separate
+ language files for English, Russian, Korean, etc. Similarly, I would suggest
+ you have separate Sybase, Intebase, MySQL, etc files, and conditionally include
+ the SQL based on the database. For example, each MySQL SQL statement would be
+ stored in a separate variable, in a file called 'mysql-lang.inc.php'.</p>
+<pre>$sqlGetPassword = '<font color="#993300">select password from users where userid=%s</font>';
+$sqlSearchKeyword = &quot;<font color="#993300">SELECT * FROM articles WHERE match (title,body) against (%s</font>)&quot;;</pre>
+<p>In our main PHP file:</p>
+<pre><font color=green># define which database to load...</font>
+<b>$database = '<font color="#993300">mysql</font>';
+include_once(&quot;<font color="#993300">$database-lang.inc.php</font>&quot;);</b>
+
+$db = &amp;NewADOConnection($database);
+$db->PConnect(...) or die('<font color="#993300">Failed to connect to database</font>');
+
+<font color=green># search for a keyword $word</font>
+$rs = $db-&gt;Execute(sprintf($sqlSearchKeyWord,$db-&gt;qstr($word)));</pre>
+<p>Note that we quote the $word variable using the qstr( ) function. This is because
+ each database quotes strings using different conventions.</p>
+<p>
+<h3>Final Thoughts</h3>
+<p>The best way to ensure that you have portable SQL is to have your data tables designed using
+sound principles. Learn the theory of normalization and entity-relationship diagrams and model
+your data carefully. Understand how joins and indexes work and how they are used to tune performance.
+<p> Visit the following page for more references on database theory and vendors:
+ <a href="http://php.weblogs.com/sql_tutorial">http://php.weblogs.com/sql_tutorial</a>.
+ Also read this article on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>.
+<p>
+<font size=1>(c) 2002-2003 John Lim.</font>
+
+</body>
+</html>
diff --git a/html/phpgacl/adodb/docs/tute.htm b/html/phpgacl/adodb/docs/tute.htm
new file mode 100644
index 0000000..3f2261e
--- /dev/null
+++ b/html/phpgacl/adodb/docs/tute.htm
@@ -0,0 +1,290 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <title>Tutorial: Moving from MySQL to ADODB</title>
+</head>
+
+<body bgcolor=white>
+<h1>Tutorial: Moving from MySQL to ADODB</h1>
+
+<pre> You say eether and I say eyether,
+ You say neether and I say nyther;
+ Eether, eyether, neether, nyther -
+ Let's call the whole thing off !
+<br>
+ You like potato and I like po-tah-to,
+ You like tomato and I like to-mah-to;
+ Potato, po-tah-to, tomato, to-mah-to -
+ Let's call the whole thing off !
+</pre>
+<p>I love this song, especially the version with Louis Armstrong and Ella singing
+ duet. It is all about how hard it is for two people in love to be compatible
+ with each other. It's about compromise and finding a common ground, and that's
+ what this article is all about.
+<p>PHP is all about creating dynamic web-sites with the least fuss and the most
+ fun. To create these websites we need to use databases to retrieve login information,
+ to splash dynamic news onto the web page and store forum postings. So let's
+ say we were using the popular MySQL database for this. Your company has done
+ such a fantastic job that the Web site is more popular than your wildest dreams.
+ You find that MySQL cannot scale to handle the workload; time to switch databases.
+<p> Unfortunately in PHP every database is accessed slightly differently. To connect
+ to MySQL, you would use <i>mysql_connect()</i>; when you decide to upgrade to
+ Oracle or Microsoft SQL Server, you would use <i>ocilogon() </i>or <i>mssql_connect()</i>
+ respectively. What is worse is that the parameters you use for the different
+ connect functions are different also.. One database says po-tato, the other
+ database says pota-to. Oh-oh.
+<h3>Let's NOT call the whole thing off</h3>
+<p>A database wrapper library such as ADODB comes in handy when you need to ensure portability. It provides
+ you with a common API to communicate with any supported database so you don't have to call things off. <p>
+
+<p>ADODB stands for Active Data Objects DataBase (sorry computer guys are sometimes
+ not very original). ADODB currently supports MySQL, PostgreSQL, Oracle, Interbase,
+ Microsoft SQL Server, Access, FoxPro, Sybase, ODBC and ADO. You can download
+ ADODB from <a href=http://php.weblogs.com/adodb></a><a href="http://php.weblogs.com/adodb">http://php.weblogs.com/adodb</a>.
+<h3>MySQL Example</h3>
+<p>The most common database used with PHP is MySQL, so I guess you should be familiar
+ with the following code. It connects to a MySQL server at <i>localhost</i>,
+ database <i>mydb</i>, and executes an SQL select statement. The results are
+ printed, one line per row.
+<pre><font color="#666600">$db = <b>mysql_connect</b>(&quot;localhost&quot;, &quot;root&quot;, &quot;password&quot;);
+<b>mysql_select_db</b>(&quot;mydb&quot;,$db);</font>
+<font color="#660000">$result = <b>mysql_query</b>(&quot;SELECT * FROM employees&quot;,$db)</font><code><font color="#663300">;
+if ($result === false) die(&quot;failed&quot;);</font></code>
+<font color="#006666"><b>while</b> ($fields =<b> mysql_fetch_row</b>($result)) &#123;
+ <b>for</b> ($i=0, $max=sizeof($fields); $i &lt; $max; $i++) &#123;
+ <b>print</b> $fields[$i].' ';
+ &#125;
+ <b>print</b> &quot;&lt;br&gt;\n&quot;;
+&#125;</font>
+</pre>
+<p>The above code has been color-coded by section. The first section is the connection
+ phase. The second is the execution of the SQL, and the last section is displaying
+ the fields. The <i>while</i> loop scans the rows of the result, while the <i>for</i>
+ loop scans the fields in one row.</p>
+<p>Here is the equivalent code in ADODB</p>
+<pre><b><font color="#666600"> include(&quot;adodb.inc.php&quot;);</font></b><font color="#666600">
+ $db = <b>NewADOConnection</b>('mysql');
+ $db-&gt;<b>Connect</b>(&quot;localhost&quot;, &quot;root&quot;, &quot;password&quot;, &quot;mydb&quot;);</font>
+ <font color="#663300">$result = $db-&gt;<b>Execute</b>(&quot;SELECT * FROM employees&quot;);
+ </font><font color="#663300"></font><code><font color="#663300">if ($result === false) die(&quot;failed&quot;)</font></code><code><font color="#663300">;</font></code>
+ <font color="#006666"><b>while</b> (!$result-&gt;EOF) &#123;
+ <b>for</b> ($i=0, $max=$result-&gt;<b>FieldCount</b>(); $i &lt; $max; $i++)
+ <b>print</b> $result-&gt;fields[$i].' ';
+ $result-&gt;<b>MoveNext</b>();
+ <b>print</b> &quot;&lt;br&gt;\n&quot;;
+ &#125;</font> </pre>
+<p></p>
+<p>Now porting to Oracle is as simple as changing the second line to <code>NewADOConnection('oracle')</code>.
+ Let's walk through the code...</p>
+<h3>Connecting to the Database</h3>
+<p></p>
+<pre><b><font color="#666600">include(&quot;adodb.inc.php&quot;);</font></b><font color="#666600">
+$db = <b>NewADOConnection</b>('mysql');
+$db-&gt;<b>Connect</b>(&quot;localhost&quot;, &quot;root&quot;, &quot;password&quot;, &quot;mydb&quot;);</font></pre>
+<p>The connection code is a bit more sophisticated than MySQL's because our needs
+ are more sophisticated. In ADODB, we use an object-oriented approach to managing
+ the complexity of handling multiple databases. We have different classes to
+ handle different databases. If you aren't familiar with object-oriented programing,
+ don't worry -- the complexity is all hidden away in the<code> NewADOConnection()</code>
+ function.</p>
+<p>To conserve memory, we only load the PHP code specific to the database you
+ are connecting to. We do this by calling <code>NewADOConnection(databasedriver)</code>.
+ Legal database drivers include <i>mysql, mssql, oracle, oci8, postgres, sybase,
+ vfp, access, ibase </i>and many others.</p>
+<p>Then we create a new instance of the connection class by calling <code>NewADOConnection()</code>.
+ Finally we connect to the database using <code>$db-&gt;Connect(). </code></p>
+<h3>Executing the SQL</h3>
+<p><code><font color="#663300">$result = $db-&gt;<b>Execute</b>(&quot;SELECT *
+ FROM employees&quot;);<br>
+ if ($result === false) die(&quot;failed&quot;)</font></code><code><font color="#663300">;</font></code>
+ <br>
+</p>
+<p>Sending the SQL statement to the server is straight forward. Execute() will
+ return a recordset object on successful execution. You should check $result
+ as we do above.
+<p>An issue that confuses beginners is the fact that we have two types of objects
+ in ADODB, the connection object and the recordset object. When do we use each?
+<p>The connection object ($db) is responsible for connecting to the database,
+ formatting your SQL and querying the database server. The recordset object ($result)
+ is responsible for retrieving the results and formatting the reply as text or
+ as an array.
+<p>The only thing I need to add is that ADODB provides several helper functions
+ for making INSERT and UPDATE statements easier, which we will cover in the Advanced
+ section.
+<h3>Retrieving the Data<br>
+</h3>
+<pre><font color="#006666"><b>while</b> (!$result-&gt;EOF) &#123;
+ <b>for</b> ($i=0, $max=$result-&gt;<b>FieldCount</b>(); $i &lt; $max; $i++)
+ <b>print</b> $result-&gt;fields[$i].' ';
+ $result-&gt;<b>MoveNext</b>();
+ <b>print</b> &quot;&lt;br&gt;\n&quot;;
+&#125;</font></pre>
+<p>The paradigm for getting the data is that it's like reading a file. For every
+ line, we check first whether we have reached the end-of-file (EOF). While not
+ end-of-file, loop through each field in the row. Then move to the next line
+ (MoveNext) and repeat.
+<p>The <code>$result-&gt;fields[]</code> array is generated by the PHP database
+ extension. Some database extensions do not index the array by field name.
+ To force indexing by name - that is associative arrays -
+ use the $ADODB_FETCH_MODE global variable.
+<pre>
+ $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_NUM;
+ $rs1 = $db->Execute('select * from table');
+ $<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_ASSOC;
+ $rs2 = $db->Execute('select * from table');
+ print_r($rs1->fields); // shows <i>array([0]=>'v0',[1] =>'v1')</i>
+ print_r($rs2->fields); // shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
+</pre>
+<p>
+As you can see in the above example, both recordsets store and use different fetch modes
+based on the $ADODB_FETCH_MODE setting when the recordset was created by Execute().</p>
+<h2>ADOConnection<a name="ADOConnection"></a></h2>
+<p>Object that performs the connection to the database, executes SQL statements
+ and has a set of utility functions for standardising the format of SQL statements
+ for issues such as concatenation and date formats.</p>
+
+<h3>Other Useful Functions</h3>
+<p><code>$recordset-&gt;Move($pos)</code> scrolls to that particular row. ADODB supports forward
+ scrolling for all databases. Some databases will not support backwards scrolling.
+ This is normally not a problem as you can always cache records to simulate backwards
+ scrolling.
+<p><code>$recordset-&gt;RecordCount()</code> returns the number of records accessed by the
+ SQL statement. Some databases will return -1 because it is not supported.
+<p><code>$recordset-&gt;GetArray()</code> returns the result as an array.
+<p><code>rs2html($recordset)</code> is a function that is generates a HTML table based on the
+ $recordset passed to it. An example with the relevant lines in bold:
+<pre> include('adodb.inc.php');
+ <b>include('tohtml.inc.php');</b> /* includes the rs2html function */
+ $conn = &amp;ADONewConnection('mysql');
+ $conn-&gt;PConnect('localhost','userid','password','database');
+ $rs = $conn-&gt;Execute('select * from table');
+ <b> rs2html($rs)</b>; /* recordset to html table */ </pre>
+<p>There are many other helper functions that are listed in the documentation available at <a href="http://php.weblogs.com/adodb_manual"></a><a href="http://php.weblogs.com/adodb_manual">http://php.weblogs.com/adodb_manual</a>.
+<h2>Advanced Material</h2>
+<h3>Inserts and Updates </h3>
+<p>Let's say you want to insert the following data into a database.
+<p><b>ID</b> = 3<br>
+ <b>TheDate</b>=mktime(0,0,0,8,31,2001) /* 31st August 2001 */<br>
+ <b>Note</b>= sugar why don't we call it off
+<p>When you move to another database, your insert might no longer work.</p>
+<p>The first problem is that each database has a different default date format.
+ MySQL expects YYYY-MM-DD format, while other databases have different defaults.
+ ADODB has a function called DBDate() that addresses this issue by converting
+ converting the date to the correct format.</p>
+<p>The next problem is that the <b>don't</b> in the Note needs to be quoted. In
+ MySQL, we use <b>don\'t</b> but in some other databases (Sybase, Access, Microsoft
+ SQL Server) we use <b>don''t. </b>The qstr() function addresses this issue.</p>
+<p>So how do we use the functions? Like this:</p>
+<pre>$sql = &quot;INSERT INTO table (id, thedate,note) values (&quot;
+ . $<b>ID</b> . ','
+ . $db-&gt;DBDate($<b>TheDate</b>) .','
+ . $db-&gt;qstr($<b>Note</b>).&quot;)&quot;;
+$db-&gt;Execute($sql);</pre>
+<p>ADODB also supports <code>$connection-&gt;Affected_Rows()</code> (returns the
+ number of rows affected by last update or delete) and <code>$recordset-&gt;Insert_ID()</code>
+ (returns last autoincrement number generated by an insert statement). Be forewarned
+ that not all databases support the two functions.<br>
+</p>
+<h3>MetaTypes</h3>
+<p>You can find out more information about each of the fields (I use the words
+ fields and columns interchangebly) you are selecting by calling the recordset
+ method <code>FetchField($fieldoffset)</code>. This will return an object with
+ 3 properties: name, type and max_length.
+<pre>For example:</pre>
+<pre>$recordset = $conn-&gt;Execute(&quot;select adate from table&quot;);<br>$f0 = $recordset-&gt;FetchField(0);
+</pre>
+<p>Then <code>$f0-&gt;name</code> will hold <i>'adata'</i>, <code>$f0-&gt;type</code>
+ will be set to '<i>date'</i>. If the max_length is unknown, it will be set to
+ -1.
+<p>One problem with handling different databases is that each database often calls
+ the same type by a different name. For example a <i>timestamp</i> type is called
+ <i>datetime</i> in one database and <i>time</i> in another. So ADODB has a special
+ <code>MetaType($type, $max_length)</code> function that standardises the types
+ to the following:
+<p>C: character and varchar types<br>
+ X: text or long character (eg. more than 255 bytes wide).<br>
+ B: blob or binary image<br>
+ D: date<br>
+ T: timestamp<br>
+ L: logical (boolean)<br>
+ I: integer<br>
+ N: numeric (float, double, money)
+<p>In the above date example,
+<p><code>$recordset = $conn-&gt;Execute(&quot;select adate from table&quot;);<br>
+ $f0 = $recordset-&gt;FetchField(0);<br>
+ $type = $recordset-&gt;MetaType($f0-&gt;type, $f0-&gt;max_length);<br>
+ print $type; /* should print 'D'</code> */
+<p>
+<p><b>Select Limit and Top Support</b>
+<p>ADODB has a function called $connection->SelectLimit($sql,$nrows,$offset) that allows
+you to retrieve a subset of the recordset. This will take advantage of native
+SELECT TOP on Microsoft products and SELECT ... LIMIT with PostgreSQL and MySQL, and
+emulated if the database does not support it.
+<p><b>Caching Support</b>
+<p>ADODB allows you to cache recordsets in your file system, and only requery the database
+server after a certain timeout period with $connection->CacheExecute($secs2cache,$sql) and
+$connection->CacheSelectLimit($secs2cache,$sql,$nrows,$offset).
+<p><b>PHP4 Session Handler Support</b>
+<p>ADODB also supports PHP4 session handlers. You can store your session variables
+ in a database for true scalability using ADODB. For further information, visit
+ <a href="http://php.weblogs.com/adodb-sessions"></a><a href="http://php.weblogs.com/adodb-sessions">http://php.weblogs.com/adodb-sessions</a>
+<h3>Commercial Use Encouraged</h3>
+<p>If you plan to write commercial PHP applications that you want to resell, you should consider ADODB. It has been released using the lesser GPL, which means you can legally include it in commercial applications, while keeping your code proprietary. Commercial use of ADODB is strongly encouraged! We are using it internally for this reason.<p>
+
+<h2>Conclusion</h2>
+<p>As a thank you for finishing this article, here are the complete lyrics for
+ <i>let's call the whole thing off</i>.<br>
+ <br>
+<pre>
+ Refrain
+<br>
+ You say eether and I say eyether,
+ You say neether and I say nyther;
+ Eether, eyether, neether, nyther -
+ Let's call the whole thing off !
+<br>
+ You like potato and I like po-tah-to,
+ You like tomato and I like to-mah-to;
+ Potato, po-tah-to, tomato, to-mah-to -
+ Let's call the whole thing off !
+<br>
+But oh, if we call the whole thing off, then we must part.
+And oh, if we ever part, then that might break my heart.
+<br>
+ So, if you like pajamas and I like pa-jah-mas,
+ I'll wear pajamas and give up pa-jah-mas.
+ For we know we
+ Need each other, so we
+ Better call the calling off off.
+ Let's call the whole thing off !
+<br>
+ Second Refrain
+<br>
+ You say laughter and I say lawfter,
+ You say after and I say awfter;
+ Laughter, lawfter, after, awfter -
+ Let's call the whole thing off !
+<br>
+ You like vanilla and I like vanella,
+ You, sa's'parilla and I sa's'parella;
+ Vanilla, vanella, choc'late, strawb'ry -
+ Let's call the whole thing off !
+<br>
+But oh, if we call the whole thing off, then we must part.
+And oh, if we ever part, then that might break my heart.
+<br>
+ So, if you go for oysters and I go for ersters,
+ I'll order oysters and cancel the ersters.
+ For we know we
+ Need each other, so we
+ Better call the calling off off.
+ Let's call the whole thing off !
+ </pre>
+<p><font size=2>Song and lyrics by George and Ira Gershwin, introduced by Fred Astaire and Ginger Rogers
+in the film "Shall We Dance?" </font><p>
+<p>
+(c)2001-2002 John Lim.
+
+</body>
+</html>
diff --git a/html/phpgacl/adodb/drivers/adodb-access.inc.php b/html/phpgacl/adodb/drivers/adodb-access.inc.php
new file mode 100644
index 0000000..819ea59
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-access.inc.php
@@ -0,0 +1,86 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft Access data driver. Requires ODBC. Works only on MS Windows.
+*/
+if (!defined('_ADODB_ODBC_LAYER')) {
+ if (!defined('ADODB_DIR')) die();
+
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+ if (!defined('_ADODB_ACCESS')) {
+ define('_ADODB_ACCESS',1);
+
+class ADODB_access extends ADODB_odbc {
+ var $databaseType = 'access';
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
+ var $fmtDate = "#Y-m-d#";
+ var $fmtTimeStamp = "#Y-m-d h:i:sA#"; // note not comma
+ var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
+ var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
+ var $sysTimeStamp = 'NOW';
+ var $hasTransactions = false;
+
+ function ADODB_access()
+ {
+ global $ADODB_EXTENSION;
+
+ $ADODB_EXTENSION = false;
+ $this->ADODB_odbc();
+ }
+
+ function Time()
+ {
+ return time();
+ }
+
+ function BeginTrans() { return false;}
+
+ function IfNull( $field, $ifNull )
+ {
+ return " IIF(IsNull($field), $ifNull, $field) "; // if Access
+ }
+/*
+ function &MetaTables()
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $qid = odbc_tables($this->_connectionID);
+ $rs = new ADORecordSet_odbc($qid);
+ $ADODB_FETCH_MODE = $savem;
+ if (!$rs) return false;
+
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+
+ $arr = &$rs->GetArray();
+ //print_pre($arr);
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if ($arr[$i][2] && $arr[$i][3] != 'SYSTEM TABLE')
+ $arr2[] = $arr[$i][2];
+ }
+ return $arr2;
+ }*/
+}
+
+
+class ADORecordSet_access extends ADORecordSet_odbc {
+
+ var $databaseType = "access";
+
+ function ADORecordSet_access($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbc($id,$mode);
+ }
+}// class
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ado.inc.php b/html/phpgacl/adodb/drivers/adodb-ado.inc.php
new file mode 100644
index 0000000..277b9fd
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ado.inc.php
@@ -0,0 +1,628 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft ADO data driver. Requires ADO. Works only on MS Windows.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+define("_ADODB_ADO_LAYER", 1 );
+/*--------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------------*/
+
+
+class ADODB_ado extends ADOConnection {
+ var $databaseType = "ado";
+ var $_bindInputArray = false;
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $dataProvider = "ado";
+ var $hasAffectedRows = true;
+ var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary
+ var $_affectedRows = false;
+ var $_thisTransactions;
+ var $_cursor_type = 3; // 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic
+ var $_cursor_location = 3; // 2=adUseServer, 3 = adUseClient;
+ var $_lock_type = -1;
+ var $_execute_option = -1;
+ var $poorAffectedRows = true;
+ var $charPage;
+
+ function ADODB_ado()
+ {
+ $this->_affectedRows = new VARIANT;
+ }
+
+ function ServerInfo()
+ {
+ if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider;
+ return array('description' => $desc, 'version' => '');
+ }
+
+ function _affectedrows()
+ {
+ if (PHP_VERSION >= 5) return $this->_affectedRows;
+
+ return $this->_affectedRows->value;
+ }
+
+ // you can also pass a connection string like this:
+ //
+ // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB');
+ function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL')
+ {
+ $u = 'UID';
+ $p = 'PWD';
+
+ if (!empty($this->charPage))
+ $dbc = new COM('ADODB.Connection',null,$this->charPage);
+ else
+ $dbc = new COM('ADODB.Connection');
+
+ if (! $dbc) return false;
+
+ /* special support if provider is mssql or access */
+ if ($argProvider=='mssql') {
+ $u = 'User Id'; //User parameter name for OLEDB
+ $p = 'Password';
+ $argProvider = "SQLOLEDB"; // SQL Server Provider
+
+ // not yet
+ //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename";
+
+ //use trusted conection for SQL if username not specified
+ if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes";
+ } else if ($argProvider=='access')
+ $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider
+
+ if ($argProvider) $dbc->Provider = $argProvider;
+
+ if ($argUsername) $argHostname .= ";$u=$argUsername";
+ if ($argPassword)$argHostname .= ";$p=$argPassword";
+
+ if ($this->debug) ADOConnection::outp( "Host=".$argHostname."<BR>\n version=$dbc->version");
+ // @ added below for php 4.0.1 and earlier
+ @$dbc->Open((string) $argHostname);
+
+ $this->_connectionID = $dbc;
+
+ $dbc->CursorLocation = $this->_cursor_location;
+ return $dbc->State > 0;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL')
+ {
+ return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
+ }
+
+/*
+ adSchemaCatalogs = 1,
+ adSchemaCharacterSets = 2,
+ adSchemaCollations = 3,
+ adSchemaColumns = 4,
+ adSchemaCheckConstraints = 5,
+ adSchemaConstraintColumnUsage = 6,
+ adSchemaConstraintTableUsage = 7,
+ adSchemaKeyColumnUsage = 8,
+ adSchemaReferentialContraints = 9,
+ adSchemaTableConstraints = 10,
+ adSchemaColumnsDomainUsage = 11,
+ adSchemaIndexes = 12,
+ adSchemaColumnPrivileges = 13,
+ adSchemaTablePrivileges = 14,
+ adSchemaUsagePrivileges = 15,
+ adSchemaProcedures = 16,
+ adSchemaSchemata = 17,
+ adSchemaSQLLanguages = 18,
+ adSchemaStatistics = 19,
+ adSchemaTables = 20,
+ adSchemaTranslations = 21,
+ adSchemaProviderTypes = 22,
+ adSchemaViews = 23,
+ adSchemaViewColumnUsage = 24,
+ adSchemaViewTableUsage = 25,
+ adSchemaProcedureParameters = 26,
+ adSchemaForeignKeys = 27,
+ adSchemaPrimaryKeys = 28,
+ adSchemaProcedureColumns = 29,
+ adSchemaDBInfoKeywords = 30,
+ adSchemaDBInfoLiterals = 31,
+ adSchemaCubes = 32,
+ adSchemaDimensions = 33,
+ adSchemaHierarchies = 34,
+ adSchemaLevels = 35,
+ adSchemaMeasures = 36,
+ adSchemaProperties = 37,
+ adSchemaMembers = 38
+
+*/
+
+ function &MetaTables()
+ {
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(20);//tables
+ if ($adors){
+ $f = $adors->Fields(2);//table/view name
+ $t = $adors->Fields(3);//table type
+ while (!$adors->EOF){
+ $tt=substr($t->value,0,6);
+ if ($tt!='SYSTEM' && $tt !='ACCESS')
+ $arr[]=$f->value;
+ //print $f->value . ' ' . $t->value.'<br>';
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+ function &MetaColumns($table)
+ {
+ $table = strtoupper($table);
+ $arr = array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(4);//tables
+
+ if ($adors){
+ $t = $adors->Fields(2);//table/view name
+ while (!$adors->EOF){
+
+
+ if (strtoupper($t->Value) == $table) {
+
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+ }
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+ $false = false;
+ return empty($arr) ? $false : $arr;
+ }
+
+
+
+
+ /* returns queryID or false */
+ function &_query($sql,$inputarr=false)
+ {
+
+ $dbc = $this->_connectionID;
+ $false = false;
+
+ // return rs
+ if ($inputarr) {
+
+ if (!empty($this->charPage))
+ $oCmd = new COM('ADODB.Command',null,$this->charPage);
+ else
+ $oCmd = new COM('ADODB.Command');
+ $oCmd->ActiveConnection = $dbc;
+ $oCmd->CommandText = $sql;
+ $oCmd->CommandType = 1;
+
+ foreach($inputarr as $val) {
+ // name, type, direction 1 = input, len,
+ $this->adoParameterType = 130;
+ $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
+ //print $p->Type.' '.$p->value;
+ $oCmd->Parameters->Append($p);
+ }
+ $p = false;
+ $rs = $oCmd->Execute();
+ $e = $dbc->Errors;
+ if ($dbc->Errors->Count > 0) return $false;
+ return $rs;
+ }
+
+ $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option);
+
+ if ($dbc->Errors->Count > 0) return $false;
+ if (! $rs) return $false;
+
+ if ($rs->State == 0) {
+ $true = true;
+ return $true; // 0 = adStateClosed means no records returned
+ }
+ return $rs;
+ }
+
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+
+ if (isset($this->_thisTransactions))
+ if (!$this->_thisTransactions) return false;
+ else {
+ $o = $this->_connectionID->Properties("Transaction DDL");
+ $this->_thisTransactions = $o ? true : false;
+ if (!$o) return false;
+ }
+ @$this->_connectionID->BeginTrans();
+ $this->transCnt += 1;
+ return true;
+ }
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transOff) return true;
+
+ @$this->_connectionID->CommitTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+ function RollbackTrans() {
+ if ($this->transOff) return true;
+ @$this->_connectionID->RollbackTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+
+ /* Returns: the last error message from previous database operation */
+
+ function ErrorMsg()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return '';
+ $err = $errc->Item($errc->Count-1);
+ return $err->Description;
+ }
+
+ function ErrorNo()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return 0;
+ $err = $errc->Item($errc->Count-1);
+ return $err->NativeError;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->_connectionID) $this->_connectionID->Close();
+ $this->_connectionID = false;
+ return true;
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_ado extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "ado";
+ var $dataProvider = "ado";
+ var $_tarr = false; // caches the types
+ var $_flds; // and field objects
+ var $canSeek = true;
+ var $hideErrors = true;
+
+ function ADORecordSet_ado($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ return $this->ADORecordSet($id,$mode);
+ }
+
+
+ // returns the field object
+ function &FetchField($fieldOffset = -1) {
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $rs = $this->_queryID;
+ $f = $rs->Fields($fieldOffset);
+ $o->name = $f->Name;
+ $t = $f->Type;
+ $o->type = $this->MetaType($t);
+ $o->max_length = $f->DefinedSize;
+ $o->ado_type = $t;
+
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
+ return $o;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+
+ function _initrs()
+ {
+ $rs = $this->_queryID;
+ $this->_numOfRows = $rs->RecordCount;
+
+ $f = $rs->Fields;
+ $this->_numOfFields = $f->Count;
+ }
+
+
+ // should only be used to move forward as we normally use forward-only cursors
+ function _seek($row)
+ {
+ $rs = $this->_queryID;
+ // absoluteposition doesn't work -- my maths is wrong ?
+ // $rs->AbsolutePosition->$row-2;
+ // return true;
+ if ($this->_currentRow > $row) return false;
+ @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst
+ return true;
+ }
+
+/*
+ OLEDB types
+
+ enum DBTYPEENUM
+ { DBTYPE_EMPTY = 0,
+ DBTYPE_NULL = 1,
+ DBTYPE_I2 = 2,
+ DBTYPE_I4 = 3,
+ DBTYPE_R4 = 4,
+ DBTYPE_R8 = 5,
+ DBTYPE_CY = 6,
+ DBTYPE_DATE = 7,
+ DBTYPE_BSTR = 8,
+ DBTYPE_IDISPATCH = 9,
+ DBTYPE_ERROR = 10,
+ DBTYPE_BOOL = 11,
+ DBTYPE_VARIANT = 12,
+ DBTYPE_IUNKNOWN = 13,
+ DBTYPE_DECIMAL = 14,
+ DBTYPE_UI1 = 17,
+ DBTYPE_ARRAY = 0x2000,
+ DBTYPE_BYREF = 0x4000,
+ DBTYPE_I1 = 16,
+ DBTYPE_UI2 = 18,
+ DBTYPE_UI4 = 19,
+ DBTYPE_I8 = 20,
+ DBTYPE_UI8 = 21,
+ DBTYPE_GUID = 72,
+ DBTYPE_VECTOR = 0x1000,
+ DBTYPE_RESERVED = 0x8000,
+ DBTYPE_BYTES = 128,
+ DBTYPE_STR = 129,
+ DBTYPE_WSTR = 130,
+ DBTYPE_NUMERIC = 131,
+ DBTYPE_UDT = 132,
+ DBTYPE_DBDATE = 133,
+ DBTYPE_DBTIME = 134,
+ DBTYPE_DBTIMESTAMP = 135
+
+ ADO Types
+
+ adEmpty = 0,
+ adTinyInt = 16,
+ adSmallInt = 2,
+ adInteger = 3,
+ adBigInt = 20,
+ adUnsignedTinyInt = 17,
+ adUnsignedSmallInt = 18,
+ adUnsignedInt = 19,
+ adUnsignedBigInt = 21,
+ adSingle = 4,
+ adDouble = 5,
+ adCurrency = 6,
+ adDecimal = 14,
+ adNumeric = 131,
+ adBoolean = 11,
+ adError = 10,
+ adUserDefined = 132,
+ adVariant = 12,
+ adIDispatch = 9,
+ adIUnknown = 13,
+ adGUID = 72,
+ adDate = 7,
+ adDBDate = 133,
+ adDBTime = 134,
+ adDBTimeStamp = 135,
+ adBSTR = 8,
+ adChar = 129,
+ adVarChar = 200,
+ adLongVarChar = 201,
+ adWChar = 130,
+ adVarWChar = 202,
+ adLongVarWChar = 203,
+ adBinary = 128,
+ adVarBinary = 204,
+ adLongVarBinary = 205,
+ adChapter = 136,
+ adFileTime = 64,
+ adDBFileTime = 137,
+ adPropVariant = 138,
+ adVarNumeric = 139
+*/
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ if (!is_numeric($t)) return $t;
+
+ switch ($t) {
+ case 0:
+ case 12: // variant
+ case 8: // bstr
+ case 129: //char
+ case 130: //wc
+ case 200: // varc
+ case 202:// varWC
+ case 128: // bin
+ case 204: // varBin
+ case 72: // guid
+ if ($len <= $this->blobSize) return 'C';
+
+ case 201:
+ case 203:
+ return 'X';
+ case 128:
+ case 204:
+ case 205:
+ return 'B';
+ case 7:
+ case 133: return 'D';
+
+ case 134:
+ case 135: return 'T';
+
+ case 11: return 'L';
+
+ case 16:// adTinyInt = 16,
+ case 2://adSmallInt = 2,
+ case 3://adInteger = 3,
+ case 4://adBigInt = 20,
+ case 17://adUnsignedTinyInt = 17,
+ case 18://adUnsignedSmallInt = 18,
+ case 19://adUnsignedInt = 19,
+ case 20://adUnsignedBigInt = 21,
+ return 'I';
+ default: return 'N';
+ }
+ }
+
+ // time stamp not supported yet
+ function _fetch()
+ {
+ $rs = $this->_queryID;
+ if (!$rs or $rs->EOF) {
+ $this->fields = false;
+ return false;
+ }
+ $this->fields = array();
+
+ if (!$this->_tarr) {
+ $tarr = array();
+ $flds = array();
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ $f = $rs->Fields($i);
+ $flds[] = $f;
+ $tarr[] = $f->Type;
+ }
+ // bind types and flds only once
+ $this->_tarr = $tarr;
+ $this->_flds = $flds;
+ }
+ $t = reset($this->_tarr);
+ $f = reset($this->_flds);
+
+ if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ //echo "<p>",$t,' ';var_dump($f->value); echo '</p>';
+ switch($t) {
+ case 135: // timestamp
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+ $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 133:// A date value (yyyymmdd)
+ if ($val = $f->value) {
+ $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2);
+ } else
+ $this->fields[] = false;
+ break;
+ case 7: // adDate
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+
+ if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
+ else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 1: // null
+ $this->fields[] = false;
+ break;
+ case 6: // currency is not supported properly;
+ ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
+ $this->fields[] = (float) $f->value;
+ break;
+ default:
+ $this->fields[] = $f->value;
+ break;
+ }
+ //print " $f->value $t, ";
+ $f = next($this->_flds);
+ $t = next($this->_tarr);
+ } // for
+ if ($this->hideErrors) error_reporting($olde);
+ @$rs->MoveNext(); // @ needed for some versions of PHP!
+
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+ return true;
+ }
+
+ function NextRecordSet()
+ {
+ $rs = $this->_queryID;
+ $this->_queryID = $rs->NextRecordSet();
+ //$this->_queryID = $this->_QueryId->NextRecordSet();
+ if ($this->_queryID == null) return false;
+
+ $this->_currentRow = -1;
+ $this->_currentPage = -1;
+ $this->bind = false;
+ $this->fields = false;
+ $this->_flds = false;
+ $this->_tarr = false;
+
+ $this->_inited = false;
+ $this->Init();
+ return true;
+ }
+
+ function _close() {
+ $this->_flds = false;
+ @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
+ $this->_queryID = false;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ado5.inc.php b/html/phpgacl/adodb/drivers/adodb-ado5.inc.php
new file mode 100644
index 0000000..bf670bc
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ado5.inc.php
@@ -0,0 +1,636 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft ADO data driver. Requires ADO. Works only on MS Windows. PHP5 compat version.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+define("_ADODB_ADO_LAYER", 1 );
+/*--------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------------*/
+
+
+class ADODB_ado extends ADOConnection {
+ var $databaseType = "ado";
+ var $_bindInputArray = false;
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $dataProvider = "ado";
+ var $hasAffectedRows = true;
+ var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary
+ var $_affectedRows = false;
+ var $_thisTransactions;
+ var $_cursor_type = 3; // 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic
+ var $_cursor_location = 3; // 2=adUseServer, 3 = adUseClient;
+ var $_lock_type = -1;
+ var $_execute_option = -1;
+ var $poorAffectedRows = true;
+ var $charPage;
+
+ function ADODB_ado()
+ {
+ $this->_affectedRows = new VARIANT;
+ }
+
+ function ServerInfo()
+ {
+ if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider;
+ return array('description' => $desc, 'version' => '');
+ }
+
+ function _affectedrows()
+ {
+ if (PHP_VERSION >= 5) return $this->_affectedRows;
+
+ return $this->_affectedRows->value;
+ }
+
+ // you can also pass a connection string like this:
+ //
+ // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB');
+ function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL')
+ {
+ try {
+ $u = 'UID';
+ $p = 'PWD';
+
+ if (!empty($this->charPage))
+ $dbc = new COM('ADODB.Connection',null,$this->charPage);
+ else
+ $dbc = new COM('ADODB.Connection');
+
+ if (! $dbc) return false;
+
+ /* special support if provider is mssql or access */
+ if ($argProvider=='mssql') {
+ $u = 'User Id'; //User parameter name for OLEDB
+ $p = 'Password';
+ $argProvider = "SQLOLEDB"; // SQL Server Provider
+
+ // not yet
+ //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename";
+
+ //use trusted conection for SQL if username not specified
+ if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes";
+ } else if ($argProvider=='access')
+ $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider
+
+ if ($argProvider) $dbc->Provider = $argProvider;
+
+ if ($argUsername) $argHostname .= ";$u=$argUsername";
+ if ($argPassword)$argHostname .= ";$p=$argPassword";
+
+ if ($this->debug) ADOConnection::outp( "Host=".$argHostname."<BR>\n version=$dbc->version");
+ // @ added below for php 4.0.1 and earlier
+ @$dbc->Open((string) $argHostname);
+
+ $this->_connectionID = $dbc;
+
+ $dbc->CursorLocation = $this->_cursor_location;
+ return $dbc->State > 0;
+ } catch (exception $e) {
+ }
+
+ return false;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL')
+ {
+ return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
+ }
+
+/*
+ adSchemaCatalogs = 1,
+ adSchemaCharacterSets = 2,
+ adSchemaCollations = 3,
+ adSchemaColumns = 4,
+ adSchemaCheckConstraints = 5,
+ adSchemaConstraintColumnUsage = 6,
+ adSchemaConstraintTableUsage = 7,
+ adSchemaKeyColumnUsage = 8,
+ adSchemaReferentialContraints = 9,
+ adSchemaTableConstraints = 10,
+ adSchemaColumnsDomainUsage = 11,
+ adSchemaIndexes = 12,
+ adSchemaColumnPrivileges = 13,
+ adSchemaTablePrivileges = 14,
+ adSchemaUsagePrivileges = 15,
+ adSchemaProcedures = 16,
+ adSchemaSchemata = 17,
+ adSchemaSQLLanguages = 18,
+ adSchemaStatistics = 19,
+ adSchemaTables = 20,
+ adSchemaTranslations = 21,
+ adSchemaProviderTypes = 22,
+ adSchemaViews = 23,
+ adSchemaViewColumnUsage = 24,
+ adSchemaViewTableUsage = 25,
+ adSchemaProcedureParameters = 26,
+ adSchemaForeignKeys = 27,
+ adSchemaPrimaryKeys = 28,
+ adSchemaProcedureColumns = 29,
+ adSchemaDBInfoKeywords = 30,
+ adSchemaDBInfoLiterals = 31,
+ adSchemaCubes = 32,
+ adSchemaDimensions = 33,
+ adSchemaHierarchies = 34,
+ adSchemaLevels = 35,
+ adSchemaMeasures = 36,
+ adSchemaProperties = 37,
+ adSchemaMembers = 38
+
+*/
+
+ function &MetaTables()
+ {
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(20);//tables
+ if ($adors){
+ $f = $adors->Fields(2);//table/view name
+ $t = $adors->Fields(3);//table type
+ while (!$adors->EOF){
+ $tt=substr($t->value,0,6);
+ if ($tt!='SYSTEM' && $tt !='ACCESS')
+ $arr[]=$f->value;
+ //print $f->value . ' ' . $t->value.'<br>';
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+ function &MetaColumns($table)
+ {
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $adors=@$dbc->OpenSchema(4);//tables
+
+ if ($adors){
+ $t = $adors->Fields(2);//table/view name
+ while (!$adors->EOF){
+
+
+ if (strtoupper($t->Value) == $table) {
+
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+ }
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+
+ return $arr;
+ }
+
+
+
+
+ /* returns queryID or false */
+ function &_query($sql,$inputarr=false)
+ {
+ try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour...
+
+ $dbc = $this->_connectionID;
+
+ // return rs
+ if ($inputarr) {
+
+ if (!empty($this->charPage))
+ $oCmd = new COM('ADODB.Command',null,$this->charPage);
+ else
+ $oCmd = new COM('ADODB.Command');
+ $oCmd->ActiveConnection = $dbc;
+ $oCmd->CommandText = $sql;
+ $oCmd->CommandType = 1;
+
+ foreach($inputarr as $val) {
+ // name, type, direction 1 = input, len,
+ $this->adoParameterType = 130;
+ $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
+ //print $p->Type.' '.$p->value;
+ $oCmd->Parameters->Append($p);
+ }
+ $p = false;
+ $rs = $oCmd->Execute();
+ $e = $dbc->Errors;
+ if ($dbc->Errors->Count > 0) return false;
+ return $rs;
+ }
+
+ $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option);
+
+ if ($dbc->Errors->Count > 0) return false;
+ if (! $rs) return false;
+
+ if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned
+ return $rs;
+
+ } catch (exception $e) {
+
+ }
+ return false;
+ }
+
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+
+ if (isset($this->_thisTransactions))
+ if (!$this->_thisTransactions) return false;
+ else {
+ $o = $this->_connectionID->Properties("Transaction DDL");
+ $this->_thisTransactions = $o ? true : false;
+ if (!$o) return false;
+ }
+ @$this->_connectionID->BeginTrans();
+ $this->transCnt += 1;
+ return true;
+ }
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transOff) return true;
+
+ @$this->_connectionID->CommitTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+ function RollbackTrans() {
+ if ($this->transOff) return true;
+ @$this->_connectionID->RollbackTrans();
+ if ($this->transCnt) @$this->transCnt -= 1;
+ return true;
+ }
+
+ /* Returns: the last error message from previous database operation */
+
+ function ErrorMsg()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return '';
+ $err = $errc->Item($errc->Count-1);
+ return $err->Description;
+ }
+
+ function ErrorNo()
+ {
+ $errc = $this->_connectionID->Errors;
+ if ($errc->Count == 0) return 0;
+ $err = $errc->Item($errc->Count-1);
+ return $err->NativeError;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->_connectionID) $this->_connectionID->Close();
+ $this->_connectionID = false;
+ return true;
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_ado extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "ado";
+ var $dataProvider = "ado";
+ var $_tarr = false; // caches the types
+ var $_flds; // and field objects
+ var $canSeek = true;
+ var $hideErrors = true;
+
+ function ADORecordSet_ado($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ return $this->ADORecordSet($id,$mode);
+ }
+
+
+ // returns the field object
+ function &FetchField($fieldOffset = -1) {
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $rs = $this->_queryID;
+ $f = $rs->Fields($fieldOffset);
+ $o->name = $f->Name;
+ $t = $f->Type;
+ $o->type = $this->MetaType($t);
+ $o->max_length = $f->DefinedSize;
+ $o->ado_type = $t;
+
+
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
+ return $o;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+
+ function _initrs()
+ {
+ $rs = $this->_queryID;
+ $this->_numOfRows = $rs->RecordCount;
+
+ $f = $rs->Fields;
+ $this->_numOfFields = $f->Count;
+ }
+
+
+ // should only be used to move forward as we normally use forward-only cursors
+ function _seek($row)
+ {
+ $rs = $this->_queryID;
+ // absoluteposition doesn't work -- my maths is wrong ?
+ // $rs->AbsolutePosition->$row-2;
+ // return true;
+ if ($this->_currentRow > $row) return false;
+ @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst
+ return true;
+ }
+
+/*
+ OLEDB types
+
+ enum DBTYPEENUM
+ { DBTYPE_EMPTY = 0,
+ DBTYPE_NULL = 1,
+ DBTYPE_I2 = 2,
+ DBTYPE_I4 = 3,
+ DBTYPE_R4 = 4,
+ DBTYPE_R8 = 5,
+ DBTYPE_CY = 6,
+ DBTYPE_DATE = 7,
+ DBTYPE_BSTR = 8,
+ DBTYPE_IDISPATCH = 9,
+ DBTYPE_ERROR = 10,
+ DBTYPE_BOOL = 11,
+ DBTYPE_VARIANT = 12,
+ DBTYPE_IUNKNOWN = 13,
+ DBTYPE_DECIMAL = 14,
+ DBTYPE_UI1 = 17,
+ DBTYPE_ARRAY = 0x2000,
+ DBTYPE_BYREF = 0x4000,
+ DBTYPE_I1 = 16,
+ DBTYPE_UI2 = 18,
+ DBTYPE_UI4 = 19,
+ DBTYPE_I8 = 20,
+ DBTYPE_UI8 = 21,
+ DBTYPE_GUID = 72,
+ DBTYPE_VECTOR = 0x1000,
+ DBTYPE_RESERVED = 0x8000,
+ DBTYPE_BYTES = 128,
+ DBTYPE_STR = 129,
+ DBTYPE_WSTR = 130,
+ DBTYPE_NUMERIC = 131,
+ DBTYPE_UDT = 132,
+ DBTYPE_DBDATE = 133,
+ DBTYPE_DBTIME = 134,
+ DBTYPE_DBTIMESTAMP = 135
+
+ ADO Types
+
+ adEmpty = 0,
+ adTinyInt = 16,
+ adSmallInt = 2,
+ adInteger = 3,
+ adBigInt = 20,
+ adUnsignedTinyInt = 17,
+ adUnsignedSmallInt = 18,
+ adUnsignedInt = 19,
+ adUnsignedBigInt = 21,
+ adSingle = 4,
+ adDouble = 5,
+ adCurrency = 6,
+ adDecimal = 14,
+ adNumeric = 131,
+ adBoolean = 11,
+ adError = 10,
+ adUserDefined = 132,
+ adVariant = 12,
+ adIDispatch = 9,
+ adIUnknown = 13,
+ adGUID = 72,
+ adDate = 7,
+ adDBDate = 133,
+ adDBTime = 134,
+ adDBTimeStamp = 135,
+ adBSTR = 8,
+ adChar = 129,
+ adVarChar = 200,
+ adLongVarChar = 201,
+ adWChar = 130,
+ adVarWChar = 202,
+ adLongVarWChar = 203,
+ adBinary = 128,
+ adVarBinary = 204,
+ adLongVarBinary = 205,
+ adChapter = 136,
+ adFileTime = 64,
+ adDBFileTime = 137,
+ adPropVariant = 138,
+ adVarNumeric = 139
+*/
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ if (!is_numeric($t)) return $t;
+
+ switch ($t) {
+ case 0:
+ case 12: // variant
+ case 8: // bstr
+ case 129: //char
+ case 130: //wc
+ case 200: // varc
+ case 202:// varWC
+ case 128: // bin
+ case 204: // varBin
+ case 72: // guid
+ if ($len <= $this->blobSize) return 'C';
+
+ case 201:
+ case 203:
+ return 'X';
+ case 128:
+ case 204:
+ case 205:
+ return 'B';
+ case 7:
+ case 133: return 'D';
+
+ case 134:
+ case 135: return 'T';
+
+ case 11: return 'L';
+
+ case 16:// adTinyInt = 16,
+ case 2://adSmallInt = 2,
+ case 3://adInteger = 3,
+ case 4://adBigInt = 20,
+ case 17://adUnsignedTinyInt = 17,
+ case 18://adUnsignedSmallInt = 18,
+ case 19://adUnsignedInt = 19,
+ case 20://adUnsignedBigInt = 21,
+ return 'I';
+ default: return 'N';
+ }
+ }
+
+ // time stamp not supported yet
+ function _fetch()
+ {
+ $rs = $this->_queryID;
+ if (!$rs or $rs->EOF) {
+ $this->fields = false;
+ return false;
+ }
+ $this->fields = array();
+
+ if (!$this->_tarr) {
+ $tarr = array();
+ $flds = array();
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ $f = $rs->Fields($i);
+ $flds[] = $f;
+ $tarr[] = $f->Type;
+ }
+ // bind types and flds only once
+ $this->_tarr = $tarr;
+ $this->_flds = $flds;
+ }
+ $t = reset($this->_tarr);
+ $f = reset($this->_flds);
+
+ if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
+ for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
+ //echo "<p>",$t,' ';var_dump($f->value); echo '</p>';
+ switch($t) {
+ case 135: // timestamp
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+ $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 133:// A date value (yyyymmdd)
+ if ($val = $f->value) {
+ $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2);
+ } else
+ $this->fields[] = false;
+ break;
+ case 7: // adDate
+ if (!strlen((string)$f->value)) $this->fields[] = false;
+ else {
+ if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value);
+ else $val = $f->value;
+
+ if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val);
+ else $this->fields[] = adodb_date('Y-m-d H:i:s',$val);
+ }
+ break;
+ case 1: // null
+ $this->fields[] = false;
+ break;
+ case 6: // currency is not supported properly;
+ ADOConnection::outp( '<b>'.$f->Name.': currency type not supported by PHP</b>');
+ $this->fields[] = (float) $f->value;
+ break;
+ default:
+ $this->fields[] = $f->value;
+ break;
+ }
+ //print " $f->value $t, ";
+ $f = next($this->_flds);
+ $t = next($this->_tarr);
+ } // for
+ if ($this->hideErrors) error_reporting($olde);
+ @$rs->MoveNext(); // @ needed for some versions of PHP!
+
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+ return true;
+ }
+
+ function NextRecordSet()
+ {
+ $rs = $this->_queryID;
+ $this->_queryID = $rs->NextRecordSet();
+ //$this->_queryID = $this->_QueryId->NextRecordSet();
+ if ($this->_queryID == null) return false;
+
+ $this->_currentRow = -1;
+ $this->_currentPage = -1;
+ $this->bind = false;
+ $this->fields = false;
+ $this->_flds = false;
+ $this->_tarr = false;
+
+ $this->_inited = false;
+ $this->Init();
+ return true;
+ }
+
+ function _close() {
+ $this->_flds = false;
+ @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
+ $this->_queryID = false;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ado_access.inc.php b/html/phpgacl/adodb/drivers/adodb-ado_access.inc.php
new file mode 100644
index 0000000..611f3cc
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ado_access.inc.php
@@ -0,0 +1,54 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+Released under both BSD license and Lesser GPL library license.
+Whenever there is any discrepancy between the two licenses,
+the BSD license will take precedence. See License.txt.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft Access ADO data driver. Requires ADO and ODBC. Works only on MS Windows.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ADO_LAYER')) {
+ if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
+}
+
+class ADODB_ado_access extends ADODB_ado {
+ var $databaseType = 'ado_access';
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
+ var $fmtDate = "#Y-m-d#";
+ var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma
+ var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
+ var $sysTimeStamp = 'NOW';
+ var $hasTransactions = false;
+
+ function ADODB_ado_access()
+ {
+ $this->ADODB_ado();
+ }
+
+ function BeginTrans() { return false;}
+
+ function CommitTrans() { return false;}
+
+ function RollbackTrans() { return false;}
+
+}
+
+
+class ADORecordSet_ado_access extends ADORecordSet_ado {
+
+ var $databaseType = "ado_access";
+
+ function ADORecordSet_ado_access($id,$mode=false)
+ {
+ return $this->ADORecordSet_ado($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ado_mssql.inc.php b/html/phpgacl/adodb/drivers/adodb-ado_mssql.inc.php
new file mode 100644
index 0000000..96ed507
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ado_mssql.inc.php
@@ -0,0 +1,98 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft SQL Server ADO data driver. Requires ADO and MSSQL client.
+ Works only on MS Windows.
+
+ It is normally better to use the mssql driver directly because it is much faster.
+ This file is only a technology demonstration and for test purposes.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ADO_LAYER')) {
+ if (PHP_VERSION >= 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php");
+ else include(ADODB_DIR."/drivers/adodb-ado.inc.php");
+}
+
+
+class ADODB_ado_mssql extends ADODB_ado {
+ var $databaseType = 'ado_mssql';
+ var $hasTop = 'top';
+ var $hasInsertID = true;
+ var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
+ var $sysTimeStamp = 'GetDate()';
+ var $leftOuter = '*=';
+ var $rightOuter = '=*';
+ var $ansiOuter = true; // for mssql7 or later
+ var $substr = "substring";
+ var $length = 'len';
+
+ //var $_inTransaction = 1; // always open recordsets, so no transaction problems.
+
+ function ADODB_ado_mssql()
+ {
+ $this->ADODB_ado();
+ }
+
+ function _insertid()
+ {
+ return $this->GetOne('select @@identity');
+ }
+
+ function _affectedrows()
+ {
+ return $this->GetOne('select @@rowcount');
+ }
+
+ function MetaColumns($table)
+ {
+ $table = strtoupper($table);
+ $arr= array();
+ $dbc = $this->_connectionID;
+
+ $osoptions = array();
+ $osoptions[0] = null;
+ $osoptions[1] = null;
+ $osoptions[2] = $table;
+ $osoptions[3] = null;
+
+ $adors=@$dbc->OpenSchema(4, $osoptions);//tables
+
+ if ($adors){
+ while (!$adors->EOF){
+ $fld = new ADOFieldObject();
+ $c = $adors->Fields(3);
+ $fld->name = $c->Value;
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
+ $fld->max_length = -1;
+ $arr[strtoupper($fld->name)]=$fld;
+
+ $adors->MoveNext();
+ }
+ $adors->Close();
+ }
+ $false = false;
+ return empty($arr) ? $false : $arr;
+ }
+
+ } // end class
+
+ class ADORecordSet_ado_mssql extends ADORecordSet_ado {
+
+ var $databaseType = 'ado_mssql';
+
+ function ADORecordSet_ado_mssql($id,$mode=false)
+ {
+ return $this->ADORecordSet_ado($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-borland_ibase.inc.php b/html/phpgacl/adodb/drivers/adodb-borland_ibase.inc.php
new file mode 100644
index 0000000..d7b5924
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-borland_ibase.inc.php
@@ -0,0 +1,91 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Support Borland Interbase 6.5 and later
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
+
+class ADODB_borland_ibase extends ADODB_ibase {
+ var $databaseType = "borland_ibase";
+
+ function ADODB_borland_ibase()
+ {
+ $this->ADODB_ibase();
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->autoCommit = false;
+ $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);
+ return $this->_transactionID;
+ }
+
+ function ServerInfo()
+ {
+ $arr['dialect'] = $this->dialect;
+ switch($arr['dialect']) {
+ case '':
+ case '1': $s = 'Interbase 6.5, Dialect 1'; break;
+ case '2': $s = 'Interbase 6.5, Dialect 2'; break;
+ default:
+ case '3': $s = 'Interbase 6.5, Dialect 3'; break;
+ }
+ $arr['version'] = '6.5';
+ $arr['description'] = $s;
+ return $arr;
+ }
+
+ // Note that Interbase 6.5 uses ROWS instead - don't you love forking wars!
+ // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
+ // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
+ // Firebird uses
+ // SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ if ($nrows > 0) {
+ if ($offset <= 0) $str = " ROWS $nrows ";
+ else {
+ $a = $offset+1;
+ $b = $offset+$nrows;
+ $str = " ROWS $a TO $b";
+ }
+ } else {
+ // ok, skip
+ $a = $offset + 1;
+ $str = " ROWS $a TO 999999999"; // 999 million
+ }
+ $sql .= $str;
+
+ return ($secs2cache) ?
+ $this->CacheExecute($secs2cache,$sql,$inputarr)
+ :
+ $this->Execute($sql,$inputarr);
+ }
+
+};
+
+
+class ADORecordSet_borland_ibase extends ADORecordSet_ibase {
+
+ var $databaseType = "borland_ibase";
+
+ function ADORecordSet_borland_ibase($id,$mode=false)
+ {
+ $this->ADORecordSet_ibase($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-csv.inc.php b/html/phpgacl/adodb/drivers/adodb-csv.inc.php
new file mode 100644
index 0000000..d4c4600
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-csv.inc.php
@@ -0,0 +1,203 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ Currently unsupported: MetaDatabases, MetaTables and MetaColumns, and also inputarr in Execute.
+ Native types have been converted to MetaTypes.
+ Transactions not supported yet.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_CSV_LAYER")) {
+ define("_ADODB_CSV_LAYER", 1 );
+
+include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+
+class ADODB_csv extends ADOConnection {
+ var $databaseType = 'csv';
+ var $databaseProvider = 'csv';
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $_affectedrows=0;
+ var $_insertid=0;
+ var $_url;
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $hasTransactions = false;
+ var $_errorNo = false;
+
+ function ADODB_csv()
+ {
+ }
+
+ function _insertid()
+ {
+ return $this->_insertid;
+ }
+
+ function _affectedrows()
+ {
+ return $this->_affectedrows;
+ }
+
+ function &MetaDatabases()
+ {
+ return false;
+ }
+
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (strtolower(substr($argHostname,0,7)) !== 'http://') return false;
+ $this->_url = $argHostname;
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (strtolower(substr($argHostname,0,7)) !== 'http://') return false;
+ $this->_url = $argHostname;
+ return true;
+ }
+
+ function &MetaColumns($table)
+ {
+ return false;
+ }
+
+
+ // parameters use PostgreSQL convention, not MySQL
+ function &SelectLimit($sql,$nrows=-1,$offset=-1)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=".
+ (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE).
+ "&offset=$offset";
+ $err = false;
+ $rs = csv2rs($url,$err,false);
+
+ if ($this->debug) print "$url<br><i>$err</i><br>";
+
+ $at = strpos($err,'::::');
+ if ($at === false) {
+ $this->_errorMsg = $err;
+ $this->_errorNo = (integer)$err;
+ } else {
+ $this->_errorMsg = substr($err,$at+4,1024);
+ $this->_errorNo = -9999;
+ }
+ if ($this->_errorNo)
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,'');
+ }
+
+ if (is_object($rs)) {
+
+ $rs->databaseType='csv';
+ $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE;
+ $rs->connection = &$this;
+ }
+ return $rs;
+ }
+
+ // returns queryID or false
+ function &_Execute($sql,$inputarr=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ if (!$this->_bindInputArray && $inputarr) {
+ $sqlarr = explode('?',$sql);
+ $sql = '';
+ $i = 0;
+ foreach($inputarr as $v) {
+
+ $sql .= $sqlarr[$i];
+ if (gettype($v) == 'string')
+ $sql .= $this->qstr($v);
+ else if ($v === null)
+ $sql .= 'NULL';
+ else
+ $sql .= $v;
+ $i += 1;
+
+ }
+ $sql .= $sqlarr[$i];
+ if ($i+1 != sizeof($sqlarr))
+ print "Input Array does not match ?: ".htmlspecialchars($sql);
+ $inputarr = false;
+ }
+
+ $url = $this->_url.'?sql='.urlencode($sql)."&fetch=".
+ (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE);
+ $err = false;
+
+
+ $rs = csv2rs($url,$err,false);
+ if ($this->debug) print urldecode($url)."<br><i>$err</i><br>";
+ $at = strpos($err,'::::');
+ if ($at === false) {
+ $this->_errorMsg = $err;
+ $this->_errorNo = (integer)$err;
+ } else {
+ $this->_errorMsg = substr($err,$at+4,1024);
+ $this->_errorNo = -9999;
+ }
+
+ if ($this->_errorNo)
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr);
+ }
+ if (is_object($rs)) {
+ $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE;
+
+ $this->_affectedrows = $rs->affectedrows;
+ $this->_insertid = $rs->insertid;
+ $rs->databaseType='csv';
+ $rs->connection = &$this;
+ }
+ return $rs;
+ }
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+ return $this->_errorMsg;
+ }
+
+ /* Returns: the last error number from previous database operation */
+ function ErrorNo()
+ {
+ return $this->_errorNo;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ return true;
+ }
+} // class
+
+class ADORecordset_csv extends ADORecordset {
+ function ADORecordset_csv($id,$mode=false)
+ {
+ $this->ADORecordset($id,$mode);
+ }
+
+ function _close()
+ {
+ return true;
+ }
+}
+
+} // define
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-db2.inc.php b/html/phpgacl/adodb/drivers/adodb-db2.inc.php
new file mode 100644
index 0000000..173224e
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-db2.inc.php
@@ -0,0 +1,361 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ DB2 data driver. Requires ODBC.
+
+From phpdb list:
+
+Hi Andrew,
+
+thanks a lot for your help. Today we discovered what
+our real problem was:
+
+After "playing" a little bit with the php-scripts that try
+to connect to the IBM DB2, we set the optional parameter
+Cursortype when calling odbc_pconnect(....).
+
+And the exciting thing: When we set the cursor type
+to SQL_CUR_USE_ODBC Cursor Type, then
+the whole query speed up from 1 till 10 seconds
+to 0.2 till 0.3 seconds for 100 records. Amazing!!!
+
+Therfore, PHP is just almost fast as calling the DB2
+from Servlets using JDBC (don't take too much care
+about the speed at whole: the database was on a
+completely other location, so the whole connection
+was made over a slow network connection).
+
+I hope this helps when other encounter the same
+problem when trying to connect to DB2 from
+PHP.
+
+Kind regards,
+Christian Szardenings
+
+2 Oct 2001
+Mark Newnham has discovered that the SQL_CUR_USE_ODBC is not supported by
+IBM's DB2 ODBC driver, so this must be a 3rd party ODBC driver.
+
+From the IBM CLI Reference:
+
+SQL_ATTR_ODBC_CURSORS (DB2 CLI v5)
+This connection attribute is defined by ODBC, but is not supported by DB2
+CLI. Any attempt to set or get this attribute will result in an SQLSTATE of
+HYC00 (Driver not capable).
+
+A 32-bit option specifying how the Driver Manager uses the ODBC cursor
+library.
+
+So I guess this means the message [above] was related to using a 3rd party
+odbc driver.
+
+Setting SQL_CUR_USE_ODBC
+========================
+To set SQL_CUR_USE_ODBC for drivers that require it, do this:
+
+$db = NewADOConnection('db2');
+$db->curMode = SQL_CUR_USE_ODBC;
+$db->Connect($dsn, $userid, $pwd);
+
+
+
+USING CLI INTERFACE
+===================
+
+I have had reports that the $host and $database params have to be reversed in
+Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu:
+
+> The symptom is that if I change the database engine from postgres or any other to DB2 then the following
+> connection command becomes wrong despite being described this version to be correct in the docs.
+>
+> $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME )
+>
+> In case of DB2 I had to swap the first and last arguments in order to connect properly.
+
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+if (!defined('ADODB_DB2')){
+define('ADODB_DB2',1);
+
+class ADODB_DB2 extends ADODB_odbc {
+ var $databaseType = "db2";
+ var $concat_operator = '||';
+ var $sysDate = 'CURRENT_DATE';
+ var $sysTimeStamp = 'CURRENT TIMESTAMP';
+ // The complete string representation of a timestamp has the form
+ // yyyy-mm-dd-hh.mm.ss.nnnnnn.
+ var $fmtTimeStamp = "'Y-m-d-H.i.s'";
+ var $ansiOuter = true;
+ var $identitySQL = 'values IDENTITY_VAL_LOCAL()';
+ var $_bindInputArray = true;
+ var $hasInsertID = true;
+
+ function ADODB_DB2()
+ {
+ if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
+ $this->ADODB_odbc();
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " COALESCE($field, $ifNull) "; // if DB2 UDB
+ }
+
+ function ServerInfo()
+ {
+ //odbc_setoption($this->_connectionID,1,101 /*SQL_ATTR_ACCESS_MODE*/, 1 /*SQL_MODE_READ_ONLY*/);
+ $vers = $this->GetOne('select versionnumber from sysibm.sysversions');
+ //odbc_setoption($this->_connectionID,1,101, 0 /*SQL_MODE_READ_WRITE*/);
+ return array('description'=>'DB2 ODBC driver', 'version'=>$vers);
+ }
+
+ function _insertid()
+ {
+ return $this->GetOne($this->identitySQL);
+ }
+
+ function RowLock($tables,$where,$flds='1 as ignore')
+ {
+ if ($this->_autocommit) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables where $where for update");
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%")
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");
+
+ $rs = new ADORecordSet_odbc($qid);
+
+ $ADODB_FETCH_MODE = $savem;
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+
+ $arr =& $rs->GetArray();
+ //print_r($arr);
+
+ $rs->Close();
+ $arr2 = array();
+
+ if ($ttype) {
+ $isview = strncmp($ttype,'V',1) === 0;
+ }
+ for ($i=0; $i < sizeof($arr); $i++) {
+
+ if (!$arr[$i][2]) continue;
+ if (strncmp($arr[$i][1],'SYS',3) === 0) continue;
+
+ $type = $arr[$i][3];
+
+ if ($showSchema) $arr[$i][2] = $arr[$i][1].'.'.$arr[$i][2];
+
+ if ($ttype) {
+ if ($isview) {
+ if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2];
+ } else if (strncmp($type,'T',1) === 0) $arr2[] = $arr[$i][2];
+ } else if (strncmp($type,'S',1) !== 0) $arr2[] = $arr[$i][2];
+ }
+ return $arr2;
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $false = false;
+ // get index details
+ $table = strtoupper($table);
+ $SQL="SELECT NAME, UNIQUERULE, COLNAMES FROM SYSIBM.SYSINDEXES WHERE TBNAME='$table'";
+ if ($primary)
+ $SQL.= " AND UNIQUERULE='P'";
+ $rs = $this->Execute($SQL);
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+ $indexes = array ();
+ // parse index data into array
+ while ($row = $rs->FetchRow()) {
+ $indexes[$row[0]] = array(
+ 'unique' => ($row[1] == 'U' || $row[1] == 'P'),
+ 'columns' => array()
+ );
+ $cols = ltrim($row[2],'+');
+ $indexes[$row[0]]['columns'] = explode('+', $cols);
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ // use right() and replace() ?
+ if (!$col) $col = $this->sysDate;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '||';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "char(year($col))";
+ break;
+ case 'M':
+ $s .= "substr(monthname($col),1,3)";
+ break;
+ case 'm':
+ $s .= "right(digits(month($col)),2)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "right(digits(day($col)),2)";
+ break;
+ case 'H':
+ case 'h':
+ if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)";
+ else $s .= "''";
+ break;
+ case 'i':
+ case 'I':
+ if ($col != $this->sysDate)
+ $s .= "right(digits(minute($col)),2)";
+ else $s .= "''";
+ break;
+ case 'S':
+ case 's':
+ if ($col != $this->sysDate)
+ $s .= "right(digits(second($col)),2)";
+ else $s .= "''";
+ break;
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ }
+ }
+ return $s;
+ }
+
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false)
+ {
+ if ($offset <= 0) {
+ // could also use " OPTIMIZE FOR $nrows ROWS "
+ if ($nrows >= 0) $sql .= " FETCH FIRST $nrows ROWS ONLY ";
+ $rs =& $this->Execute($sql,$inputArr);
+ } else {
+ if ($offset > 0 && $nrows < 0);
+ else {
+ $nrows += $offset;
+ $sql .= " FETCH FIRST $nrows ROWS ONLY ";
+ }
+ $rs =& ADOConnection::SelectLimit($sql,-1,$offset,$inputArr);
+ }
+
+ return $rs;
+ }
+
+};
+
+
+class ADORecordSet_db2 extends ADORecordSet_odbc {
+
+ var $databaseType = "db2";
+
+ function ADORecordSet_db2($id,$mode=false)
+ {
+ $this->ADORecordSet_odbc($id,$mode);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'CHAR':
+ case 'CHARACTER':
+ case 'C':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'LONGCHAR':
+ case 'TEXT':
+ case 'CLOB':
+ case 'DBCLOB': // double-byte
+ case 'X':
+ return 'X';
+
+ case 'BLOB':
+ case 'GRAPHIC':
+ case 'VARGRAPHIC':
+ return 'B';
+
+ case 'DATE':
+ case 'D':
+ return 'D';
+
+ case 'TIME':
+ case 'TIMESTAMP':
+ case 'T':
+ return 'T';
+
+ //case 'BOOLEAN':
+ //case 'BIT':
+ // return 'L';
+
+ //case 'COUNTER':
+ // return 'R';
+
+ case 'INT':
+ case 'INTEGER':
+ case 'BIGINT':
+ case 'SMALLINT':
+ case 'I':
+ return 'I';
+
+ default: return 'N';
+ }
+ }
+}
+
+} //define
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-fbsql.inc.php b/html/phpgacl/adodb/drivers/adodb-fbsql.inc.php
new file mode 100644
index 0000000..a9335fb
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-fbsql.inc.php
@@ -0,0 +1,266 @@
+<?php
+/*
+ @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Contribution by Frank M. Kromann <frank@frontbase.com>.
+ Set tabs to 8.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_FBSQL_LAYER")) {
+ define("_ADODB_FBSQL_LAYER", 1 );
+
+class ADODB_fbsql extends ADOConnection {
+ var $databaseType = 'fbsql';
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $metaTablesSQL = "SHOW TABLES";
+ var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $hasLimit = false;
+
+ function ADODB_fbsql()
+ {
+ }
+
+ function _insertid()
+ {
+ return fbsql_insert_id($this->_connectionID);
+ }
+
+ function _affectedrows()
+ {
+ return fbsql_affected_rows($this->_connectionID);
+ }
+
+ function &MetaDatabases()
+ {
+ $qid = fbsql_list_dbs($this->_connectionID);
+ $arr = array();
+ $i = 0;
+ $max = fbsql_num_rows($qid);
+ while ($i < $max) {
+ $arr[] = fbsql_tablename($qid,$i);
+ $i += 1;
+ }
+ return $arr;
+ }
+
+ // returns concatenated string
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
+ $first = true;
+
+ $s = implode(',',$arr);
+ if (sizeof($arr) > 0) return "CONCAT($s)";
+ else return '';
+ }
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ $this->_connectionID = fbsql_connect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ $this->_connectionID = fbsql_pconnect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ function &MetaColumns($table)
+ {
+ if ($this->metaColumnsSQL) {
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+
+ if ($rs === false) return false;
+
+ $retarr = array();
+ while (!$rs->EOF){
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+
+ // split type into type(length):
+ if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = $query_array[2];
+ } else {
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($fld->type,'blob') !== false);
+
+ $retarr[strtoupper($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
+ }
+ return false;
+ }
+
+ // returns true or false
+ function SelectDB($dbName)
+ {
+ $this->databaseName = $dbName;
+ if ($this->_connectionID) {
+ return @fbsql_select_db($dbName,$this->_connectionID);
+ }
+ else return false;
+ }
+
+
+ // returns queryID or false
+ function _query($sql,$inputarr)
+ {
+ return fbsql_query("$sql;",$this->_connectionID);
+ }
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+ $this->_errorMsg = @fbsql_error($this->_connectionID);
+ return $this->_errorMsg;
+ }
+
+ /* Returns: the last error number from previous database operation */
+ function ErrorNo()
+ {
+ return @fbsql_errno($this->_connectionID);
+ }
+
+ // returns true or false
+ function _close()
+ {
+ return @fbsql_close($this->_connectionID);
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_fbsql extends ADORecordSet{
+
+ var $databaseType = "fbsql";
+ var $canSeek = true;
+
+ function ADORecordSet_fbsql($queryID,$mode=false)
+ {
+ if (!$mode) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode) {
+ case ADODB_FETCH_NUM: $this->fetchMode = FBSQL_NUM; break;
+ case ADODB_FETCH_ASSOC: $this->fetchMode = FBSQL_ASSOC; break;
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = FBSQL_BOTH; break;
+ }
+ return $this->ADORecordSet($queryID);
+ }
+
+ function _initrs()
+ {
+ GLOBAL $ADODB_COUNTRECS;
+ $this->_numOfRows = ($ADODB_COUNTRECS) ? @fbsql_num_rows($this->_queryID):-1;
+ $this->_numOfFields = @fbsql_num_fields($this->_queryID);
+ }
+
+
+
+ function &FetchField($fieldOffset = -1) {
+ if ($fieldOffset != -1) {
+ $o = @fbsql_fetch_field($this->_queryID, $fieldOffset);
+ //$o->max_length = -1; // fbsql returns the max length less spaces -- so it is unrealiable
+ $f = @fbsql_field_flags($this->_queryID,$fieldOffset);
+ $o->binary = (strpos($f,'binary')!== false);
+ }
+ else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
+ $o = @fbsql_fetch_field($this->_queryID);// fbsql returns the max length less spaces -- so it is unrealiable
+ //$o->max_length = -1;
+ }
+
+ return $o;
+ }
+
+ function _seek($row)
+ {
+ return @fbsql_data_seek($this->_queryID,$row);
+ }
+
+ function _fetch($ignore_fields=false)
+ {
+ $this->fields = @fbsql_fetch_array($this->_queryID,$this->fetchMode);
+ return ($this->fields == true);
+ }
+
+ function _close() {
+ return @fbsql_free_result($this->_queryID);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ $len = -1; // fbsql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'CHARACTER':
+ case 'CHARACTER VARYING':
+ case 'BLOB':
+ case 'CLOB':
+ case 'BIT':
+ case 'BIT VARYING':
+ if ($len <= $this->blobSize) return 'C';
+
+ // so we have to check whether binary...
+ case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+
+ case 'DATE': return 'D';
+
+ case 'TIME':
+ case 'TIME WITH TIME ZONE':
+ case 'TIMESTAMP':
+ case 'TIMESTAMP WITH TIME ZONE': return 'T';
+
+ case 'PRIMARY_KEY':
+ return 'R';
+ case 'INTEGER':
+ case 'SMALLINT':
+ case 'BOOLEAN':
+
+ if (!empty($fieldobj->primary_key)) return 'R';
+ else return 'I';
+
+ default: return 'N';
+ }
+ }
+
+} //class
+} // defined
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-firebird.inc.php b/html/phpgacl/adodb/drivers/adodb-firebird.inc.php
new file mode 100644
index 0000000..f349e2b
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-firebird.inc.php
@@ -0,0 +1,75 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
+
+class ADODB_firebird extends ADODB_ibase {
+ var $databaseType = "firebird";
+ var $dialect = 3;
+
+ var $sysTimeStamp = "cast('NOW' as timestamp)";
+
+ function ADODB_firebird()
+ {
+ $this->ADODB_ibase();
+ }
+
+ function ServerInfo()
+ {
+ $arr['dialect'] = $this->dialect;
+ switch($arr['dialect']) {
+ case '':
+ case '1': $s = 'Firebird Dialect 1'; break;
+ case '2': $s = 'Firebird Dialect 2'; break;
+ default:
+ case '3': $s = 'Firebird Dialect 3'; break;
+ }
+ $arr['version'] = ADOConnection::_findvers($s);
+ $arr['description'] = $s;
+ return $arr;
+ }
+
+ // Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars!
+ // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
+ // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0)
+ {
+ $str = 'SELECT ';
+ if ($nrows >= 0) $str .= "FIRST $nrows ";
+ $str .=($offset>=0) ? "SKIP $offset " : '';
+
+ $sql = preg_replace('/^[ \t]*select/i',$str,$sql);
+ if ($secs)
+ $rs =& $this->CacheExecute($secs,$sql,$inputarr);
+ else
+ $rs =& $this->Execute($sql,$inputarr);
+
+ return $rs;
+ }
+
+
+};
+
+
+class ADORecordSet_firebird extends ADORecordSet_ibase {
+
+ var $databaseType = "firebird";
+
+ function ADORecordSet_firebird($id,$mode=false)
+ {
+ $this->ADORecordSet_ibase($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ibase.inc.php b/html/phpgacl/adodb/drivers/adodb-ibase.inc.php
new file mode 100644
index 0000000..99d1bb0
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ibase.inc.php
@@ -0,0 +1,861 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Interbase data driver. Requires interbase client. Works on Windows and Unix.
+
+ 3 Jan 2002 -- suggestions by Hans-Peter Oeri <kampfcaspar75@oeri.ch>
+ changed transaction handling and added experimental blob stuff
+
+ Docs to interbase at the website
+ http://www.synectics.co.za/php3/tutorial/IB_PHP3_API.html
+
+ To use gen_id(), see
+ http://www.volny.cz/iprenosil/interbase/ip_ib_code.htm#_code_creategen
+
+ $rs = $conn->Execute('select gen_id(adodb,1) from rdb$database');
+ $id = $rs->fields[0];
+ $conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)");
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB_ibase extends ADOConnection {
+ var $databaseType = "ibase";
+ var $dataProvider = "ibase";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $ibase_datefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S';
+ var $fmtDate = "'Y-m-d'";
+ var $ibase_timestampfmt = "%Y-%m-%d %H:%M:%S";
+ var $ibase_timefmt = "%H:%M:%S";
+ var $fmtTimeStamp = "'Y-m-d, H:i:s'";
+ var $concat_operator='||';
+ var $_transactionID;
+ var $metaTablesSQL = "select rdb\$relation_name from rdb\$relations where rdb\$relation_name not like 'RDB\$%'";
+ //OPN STUFF start
+ var $metaColumnsSQL = "select a.rdb\$field_name, a.rdb\$null_flag, a.rdb\$default_source, b.rdb\$field_length, b.rdb\$field_scale, b.rdb\$field_sub_type, b.rdb\$field_precision, b.rdb\$field_type from rdb\$relation_fields a, rdb\$fields b where a.rdb\$field_source = b.rdb\$field_name and a.rdb\$relation_name = '%s' order by a.rdb\$field_position asc";
+ //OPN STUFF end
+ var $ibasetrans;
+ var $hasGenID = true;
+ var $_bindInputArray = true;
+ var $buffers = 0;
+ var $dialect = 1;
+ var $sysDate = "cast('TODAY' as timestamp)";
+ var $sysTimeStamp = "cast('NOW' as timestamp)";
+ var $ansiOuter = true;
+ var $hasAffectedRows = false;
+ var $poorAffectedRows = true;
+ var $blobEncodeType = 'C';
+ var $role = false;
+
+ function ADODB_ibase()
+ {
+ if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT;
+ }
+
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
+ {
+ if (!function_exists('ibase_pconnect')) return null;
+ if ($argDatabasename) $argHostname .= ':'.$argDatabasename;
+ $fn = ($persist) ? 'ibase_pconnect':'ibase_connect';
+ if ($this->role)
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
+ $this->charSet,$this->buffers,$this->dialect,$this->role);
+ else
+ $this->_connectionID = $fn($argHostname,$argUsername,$argPassword,
+ $this->charSet,$this->buffers,$this->dialect);
+
+ if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html
+ $this->replaceQuote = "''";
+ }
+ if ($this->_connectionID === false) {
+ $this->_handleerror();
+ return false;
+ }
+
+ // PHP5 change.
+ if (function_exists('ibase_timefmt')) {
+ ibase_timefmt($this->ibase_datefmt,IBASE_DATE );
+ if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP );
+ else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP );
+ ibase_timefmt($this->ibase_timefmt,IBASE_TIME );
+
+ } else {
+ ini_set("ibase.timestampformat", $this->ibase_timestampfmt);
+ ini_set("ibase.dateformat", $this->ibase_datefmt);
+ ini_set("ibase.timeformat", $this->ibase_timefmt);
+ }
+ return true;
+ }
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
+ }
+
+
+ function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false)
+ {
+ if ($internalKey) return array('RDB$DB_KEY');
+
+ $table = strtoupper($table);
+
+ $sql = 'SELECT S.RDB$FIELD_NAME AFIELDNAME
+ FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON I.RDB$INDEX_NAME=S.RDB$INDEX_NAME
+ WHERE I.RDB$RELATION_NAME=\''.$table.'\' and I.RDB$INDEX_NAME like \'RDB$PRIMARY%\'
+ ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION';
+
+ $a = $this->GetCol($sql,false,true);
+ if ($a && sizeof($a)>0) return $a;
+ return false;
+ }
+
+ function ServerInfo()
+ {
+ $arr['dialect'] = $this->dialect;
+ switch($arr['dialect']) {
+ case '':
+ case '1': $s = 'Interbase 5.5 or earlier'; break;
+ case '2': $s = 'Interbase 5.6'; break;
+ default:
+ case '3': $s = 'Interbase 6.0'; break;
+ }
+ $arr['version'] = ADOConnection::_findvers($s);
+ $arr['description'] = $s;
+ return $arr;
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->autoCommit = false;
+ $this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
+ return $this->_transactionID;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $ret = false;
+ $this->autoCommit = true;
+ if ($this->_transactionID) {
+ //print ' commit ';
+ $ret = ibase_commit($this->_transactionID);
+ }
+ $this->_transactionID = false;
+ return $ret;
+ }
+
+ // there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently.
+ // it appears that ibase extension cannot support multiple concurrent queryid's
+ function &_Execute($sql,$inputarr=false)
+ {
+ global $ADODB_COUNTRECS;
+
+ if ($this->_logsql) {
+ $savecrecs = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = true; // force countrecs
+ $ret =& ADOConnection::_Execute($sql,$inputarr);
+ $ADODB_COUNTRECS = $savecrecs;
+ } else {
+ $ret =& ADOConnection::_Execute($sql,$inputarr);
+ }
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $ret = false;
+ $this->autoCommit = true;
+ if ($this->_transactionID)
+ $ret = ibase_rollback($this->_transactionID);
+ $this->_transactionID = false;
+
+ return $ret;
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+ $false = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $table = strtoupper($table);
+ $sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'";
+ if (!$primary) {
+ $sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'";
+ } else {
+ $sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'";
+ }
+ // get index details
+ $rs = $this->Execute($sql);
+ if (!is_object($rs)) {
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+
+ $indexes = array ();
+ while ($row = $rs->FetchRow()) {
+ $index = $row[0];
+ if (!isset($indexes[$index])) {
+ if (is_null($row[3])) {$row[3] = 0;}
+ $indexes[$index] = array(
+ 'unique' => ($row[3] == 1),
+ 'columns' => array()
+ );
+ }
+ $sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$name."' ORDER BY RDB\$FIELD_POSITION ASC";
+ $rs1 = $this->Execute($sql);
+ while ($row1 = $rs1->FetchRow()) {
+ $indexes[$index]['columns'][$row1[2]] = $row1[1];
+ }
+ }
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ return $indexes;
+ }
+
+
+ // See http://community.borland.com/article/0,1410,25844,00.html
+ function RowLock($tables,$where,$col)
+ {
+ if ($this->autoCommit) $this->BeginTrans();
+ $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
+ return 1;
+ }
+
+
+ function CreateSequence($seqname,$startID=1)
+ {
+ $ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
+ if (!$ok) return false;
+ return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
+ }
+
+ function DropSequence($seqname)
+ {
+ $seqname = strtoupper($seqname);
+ $this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'");
+ }
+
+ function GenID($seqname='adodbseq',$startID=1)
+ {
+ $getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE");
+ $rs = @$this->Execute($getnext);
+ if (!$rs) {
+ $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" ));
+ $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';');
+ $rs = $this->Execute($getnext);
+ }
+ if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
+ else $this->genID = 0; // false
+
+ if ($rs) $rs->Close();
+
+ return $this->genID;
+ }
+
+ function SelectDB($dbName)
+ {
+ return false;
+ }
+
+ function _handleerror()
+ {
+ $this->_errorMsg = ibase_errmsg();
+ }
+
+ function ErrorNo()
+ {
+ if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1];
+ else return 0;
+ }
+
+ function ErrorMsg()
+ {
+ return $this->_errorMsg;
+ }
+
+ function Prepare($sql)
+ {
+ $stmt = ibase_prepare($this->_connectionID,$sql);
+ if (!$stmt) return false;
+ return array($sql,$stmt);
+ }
+
+ // returns query ID if successful, otherwise false
+ // there have been reports of problems with nested queries - the code is probably not re-entrant?
+ function _query($sql,$iarr=false)
+ {
+
+ if (!$this->autoCommit && $this->_transactionID) {
+ $conn = $this->_transactionID;
+ $docommit = false;
+ } else {
+ $conn = $this->_connectionID;
+ $docommit = true;
+ }
+ if (is_array($sql)) {
+ $fn = 'ibase_execute';
+ $sql = $sql[1];
+ if (is_array($iarr)) {
+ if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
+ if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack
+ $fnarr =& array_merge( array($sql) , $iarr);
+ $ret = call_user_func_array($fn,$fnarr);
+ } else {
+ switch(sizeof($iarr)) {
+ case 1: $ret = $fn($sql,$iarr[0]); break;
+ case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break;
+ case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break;
+ case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
+ case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
+ case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
+ case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
+ default: ADOConnection::outp( "Too many parameters to ibase query $sql");
+ case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
+ }
+ }
+ } else $ret = $fn($sql);
+ } else {
+ $fn = 'ibase_query';
+
+ if (is_array($iarr)) {
+ if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4
+ if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack
+ $fnarr =& array_merge( array($conn,$sql) , $iarr);
+ $ret = call_user_func_array($fn,$fnarr);
+ } else {
+ switch(sizeof($iarr)) {
+ case 1: $ret = $fn($conn,$sql,$iarr[0]); break;
+ case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break;
+ case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break;
+ case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break;
+ case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break;
+ case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break;
+ case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break;
+ default: ADOConnection::outp( "Too many parameters to ibase query $sql");
+ case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break;
+ }
+ }
+ } else $ret = $fn($conn,$sql);
+ }
+ if ($docommit && $ret === true) ibase_commit($this->_connectionID);
+
+ $this->_handleerror();
+ return $ret;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if (!$this->autoCommit) @ibase_rollback($this->_connectionID);
+ return @ibase_close($this->_connectionID);
+ }
+
+ //OPN STUFF start
+ function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3)
+ {
+ $fscale = abs($fscale);
+ $fld->max_length = $flen;
+ $fld->scale = null;
+ switch($ftype){
+ case 7:
+ case 8:
+ if ($dialect3) {
+ switch($fsubtype){
+ case 0:
+ $fld->type = ($ftype == 7 ? 'smallint' : 'integer');
+ break;
+ case 1:
+ $fld->type = 'numeric';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ case 2:
+ $fld->type = 'decimal';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ } // switch
+ } else {
+ if ($fscale !=0) {
+ $fld->type = 'decimal';
+ $fld->scale = $fscale;
+ $fld->max_length = ($ftype == 7 ? 4 : 9);
+ } else {
+ $fld->type = ($ftype == 7 ? 'smallint' : 'integer');
+ }
+ }
+ break;
+ case 16:
+ if ($dialect3) {
+ switch($fsubtype){
+ case 0:
+ $fld->type = 'decimal';
+ $fld->max_length = 18;
+ $fld->scale = 0;
+ break;
+ case 1:
+ $fld->type = 'numeric';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ case 2:
+ $fld->type = 'decimal';
+ $fld->max_length = $fprecision;
+ $fld->scale = $fscale;
+ break;
+ } // switch
+ }
+ break;
+ case 10:
+ $fld->type = 'float';
+ break;
+ case 14:
+ $fld->type = 'char';
+ break;
+ case 27:
+ if ($fscale !=0) {
+ $fld->type = 'decimal';
+ $fld->max_length = 15;
+ $fld->scale = 5;
+ } else {
+ $fld->type = 'double';
+ }
+ break;
+ case 35:
+ if ($dialect3) {
+ $fld->type = 'timestamp';
+ } else {
+ $fld->type = 'date';
+ }
+ break;
+ case 12:
+ $fld->type = 'date';
+ break;
+ case 13:
+ $fld->type = 'time';
+ break;
+ case 37:
+ $fld->type = 'varchar';
+ break;
+ case 40:
+ $fld->type = 'cstring';
+ break;
+ case 261:
+ $fld->type = 'blob';
+ $fld->max_length = -1;
+ break;
+ } // switch
+ }
+ //OPN STUFF end
+ // returns array of ADOFieldObjects for current table
+ function &MetaColumns($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+
+ $ADODB_FETCH_MODE = $save;
+ $false = false;
+ if ($rs === false) {
+ return $false;
+ }
+
+ $retarr = array();
+ //OPN STUFF start
+ $dialect3 = ($this->dialect==3 ? true : false);
+ //OPN STUFF end
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = trim($rs->fields[0]);
+ //OPN STUFF start
+ $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3);
+ if (isset($rs->fields[1]) && $rs->fields[1]) {
+ $fld->not_null = true;
+ }
+ if (isset($rs->fields[2])) {
+
+ $fld->has_default = true;
+ $d = substr($rs->fields[2],strlen('default '));
+ switch ($fld->type)
+ {
+ case 'smallint':
+ case 'integer': $fld->default_value = (int) $d; break;
+ case 'char':
+ case 'blob':
+ case 'text':
+ case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break;
+ case 'double':
+ case 'float': $fld->default_value = (float) $d; break;
+ default: $fld->default_value = $d; break;
+ }
+ // case 35:$tt = 'TIMESTAMP'; break;
+ }
+ if ((isset($rs->fields[5])) && ($fld->type == 'blob')) {
+ $fld->sub_type = $rs->fields[5];
+ } else {
+ $fld->sub_type = null;
+ }
+ //OPN STUFF end
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if ( empty($retarr)) return $false;
+ else return $retarr;
+ }
+
+ function BlobEncode( $blob )
+ {
+ $blobid = ibase_blob_create( $this->_connectionID);
+ ibase_blob_add( $blobid, $blob );
+ return ibase_blob_close( $blobid );
+ }
+
+ // since we auto-decode all blob's since 2.42,
+ // BlobDecode should not do any transforms
+ function BlobDecode($blob)
+ {
+ return $blob;
+ }
+
+
+
+
+ // old blobdecode function
+ // still used to auto-decode all blob's
+ function _BlobDecode( $blob )
+ {
+ $blobid = ibase_blob_open( $blob );
+ $realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet <kevinboillet@yahoo.fr>
+ while($string = ibase_blob_get($blobid, 8192)){
+ $realblob .= $string;
+ }
+ ibase_blob_close( $blobid );
+
+ return( $realblob );
+ }
+
+ function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
+ {
+ $fd = fopen($path,'rb');
+ if ($fd === false) return false;
+ $blob_id = ibase_blob_create($this->_connectionID);
+
+ /* fill with data */
+
+ while ($val = fread($fd,32768)){
+ ibase_blob_add($blob_id, $val);
+ }
+
+ /* close and get $blob_id_str for inserting into table */
+ $blob_id_str = ibase_blob_close($blob_id);
+
+ fclose($fd);
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+ }
+
+ /*
+ Insert a null into the blob field of the table first.
+ Then use UpdateBlob to store the blob.
+
+ Usage:
+
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ $blob_id = ibase_blob_create($this->_connectionID);
+
+ // ibase_blob_add($blob_id, $val);
+
+ // replacement that solves the problem by which only the first modulus 64K /
+ // of $val are stored at the blob field ////////////////////////////////////
+ // Thx Abel Berenstein aberenstein#afip.gov.ar
+ $len = strlen($val);
+ $chunk_size = 32768;
+ $tail_size = $len % $chunk_size;
+ $n_chunks = ($len - $tail_size) / $chunk_size;
+
+ for ($n = 0; $n < $n_chunks; $n++) {
+ $start = $n * $chunk_size;
+ $data = substr($val, $start, $chunk_size);
+ ibase_blob_add($blob_id, $data);
+ }
+
+ if ($tail_size) {
+ $start = $n_chunks * $chunk_size;
+ $data = substr($val, $start, $tail_size);
+ ibase_blob_add($blob_id, $data);
+ }
+ // end replacement /////////////////////////////////////////////////////////
+
+ $blob_id_str = ibase_blob_close($blob_id);
+
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+
+ }
+
+
+ function OldUpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ $blob_id = ibase_blob_create($this->_connectionID);
+ ibase_blob_add($blob_id, $val);
+ $blob_id_str = ibase_blob_close($blob_id);
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false;
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ // Only since Interbase 6.0 - uses EXTRACT
+ // problem - does not zero-fill the day and month yet
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysDate;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '||';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "extract(year from $col)";
+ break;
+ case 'M':
+ case 'm':
+ $s .= "extract(month from $col)";
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "cast(((extract(month from $col)+2) / 3) as integer)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "(extract(day from $col))";
+ break;
+ case 'H':
+ case 'h':
+ $s .= "(extract(hour from $col))";
+ break;
+ case 'I':
+ case 'i':
+ $s .= "(extract(minute from $col))";
+ break;
+ case 'S':
+ case 's':
+ $s .= "CAST((extract(second from $col)) AS INTEGER)";
+ break;
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ break;
+ }
+ }
+ return $s;
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_ibase extends ADORecordSet
+{
+
+ var $databaseType = "ibase";
+ var $bind=false;
+ var $_cacheType;
+
+ function ADORecordset_ibase($id,$mode=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode;
+ $this->ADORecordSet($id);
+ }
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+
+ function &FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $ibf = ibase_field_info($this->_queryID,$fieldOffset);
+ switch (ADODB_ASSOC_CASE) {
+ case 2: // the default
+ $fld->name = ($ibf['alias']);
+ if (empty($fld->name)) $fld->name = ($ibf['name']);
+ break;
+ case 0:
+ $fld->name = strtoupper($ibf['alias']);
+ if (empty($fld->name)) $fld->name = strtoupper($ibf['name']);
+ break;
+ case 1:
+ $fld->name = strtolower($ibf['alias']);
+ if (empty($fld->name)) $fld->name = strtolower($ibf['name']);
+ break;
+ }
+
+ $fld->type = $ibf['type'];
+ $fld->max_length = $ibf['length'];
+
+ /* This needs to be populated from the metadata */
+ $fld->not_null = false;
+ $fld->has_default = false;
+ $fld->default_value = 'null';
+ return $fld;
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = -1;
+ $this->_numOfFields = @ibase_num_fields($this->_queryID);
+
+ // cache types for blob decode check
+ for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
+ $f1 = $this->FetchField($i);
+ $this->_cacheType[] = $f1->type;
+ }
+ }
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ function _fetch()
+ {
+ $f = @ibase_fetch_row($this->_queryID);
+ if ($f === false) {
+ $this->fields = false;
+ return false;
+ }
+ // OPN stuff start - optimized
+ // fix missing nulls and decode blobs automatically
+
+ global $ADODB_ANSI_PADDING_OFF;
+ //$ADODB_ANSI_PADDING_OFF=1;
+ $rtrim = !empty($ADODB_ANSI_PADDING_OFF);
+
+ for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
+ if ($this->_cacheType[$i]=="BLOB") {
+ if (isset($f[$i])) {
+ $f[$i] = $this->connection->_BlobDecode($f[$i]);
+ } else {
+ $f[$i] = null;
+ }
+ } else {
+ if (!isset($f[$i])) {
+ $f[$i] = null;
+ } else if ($rtrim && is_string($f[$i])) {
+ $f[$i] = rtrim($f[$i]);
+ }
+ }
+ }
+ // OPN stuff end
+
+ $this->fields = $f;
+ if ($this->fetchMode == ADODB_FETCH_ASSOC) {
+ $this->fields = &$this->GetRowAssoc(ADODB_ASSOC_CASE);
+ } else if ($this->fetchMode == ADODB_FETCH_BOTH) {
+ $this->fields =& array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE));
+ }
+ return true;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+
+ }
+
+
+ function _close()
+ {
+ return @ibase_free_result($this->_queryID);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'CHAR':
+ return 'C';
+
+ case 'TEXT':
+ case 'VARCHAR':
+ case 'VARYING':
+ if ($len <= $this->blobSize) return 'C';
+ return 'X';
+ case 'BLOB':
+ return 'B';
+
+ case 'TIMESTAMP':
+ case 'DATE': return 'D';
+ case 'TIME': return 'T';
+ //case 'T': return 'T';
+
+ //case 'L': return 'L';
+ case 'INT':
+ case 'SHORT':
+ case 'INTEGER': return 'I';
+ default: return 'N';
+ }
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-informix.inc.php b/html/phpgacl/adodb/drivers/adodb-informix.inc.php
new file mode 100644
index 0000000..2322fda
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-informix.inc.php
@@ -0,0 +1,35 @@
+<?php
+/**
+* @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+* Released under both BSD license and Lesser GPL library license.
+* Whenever there is any discrepancy between the two licenses,
+* the BSD license will take precedence.
+*
+* Set tabs to 4 for best viewing.
+*
+* Latest version is available at http://php.weblogs.com
+*
+* Informix 9 driver that supports SELECT FIRST
+*
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR.'/drivers/adodb-informix72.inc.php');
+
+class ADODB_informix extends ADODB_informix72 {
+ var $databaseType = "informix";
+ var $hasTop = 'FIRST';
+ var $ansiOuter = true;
+}
+
+class ADORecordset_informix extends ADORecordset_informix72 {
+ var $databaseType = "informix";
+
+ function ADORecordset_informix($id,$mode=false)
+ {
+ $this->ADORecordset_informix72($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-informix72.inc.php b/html/phpgacl/adodb/drivers/adodb-informix72.inc.php
new file mode 100644
index 0000000..4388b1d
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-informix72.inc.php
@@ -0,0 +1,475 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim. All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Informix port by Mitchell T. Young (mitch@youngfamily.org)
+
+ Further mods by "Samuel CARRIERE" <samuel_carriere@hotmail.com>
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('IFX_SCROLL')) define('IFX_SCROLL',1);
+
+class ADODB_informix72 extends ADOConnection {
+ var $databaseType = "informix72";
+ var $dataProvider = "informix";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $substr = 'substr';
+ var $metaTablesSQL="select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables
+
+
+ var $metaColumnsSQL =
+ "select c.colname, c.coltype, c.collength, d.default,c.colno
+ from syscolumns c, systables t,outer sysdefaults d
+ where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno
+ and tabname='%s' order by c.colno";
+
+ var $metaPrimaryKeySQL =
+ "select part1,part2,part3,part4,part5,part6,part7,part8 from
+ systables t,sysconstraints s,sysindexes i where t.tabname='%s'
+ and s.tabid=t.tabid and s.constrtype='P'
+ and i.idxname=s.idxname";
+
+ var $concat_operator = '||';
+
+ var $lastQuery = false;
+ var $has_insertid = true;
+
+ var $_autocommit = true;
+ var $_bindInputArray = true; // set to true if ADOConnection.Execute() permits binding of array parameters.
+ var $sysDate = 'TODAY';
+ var $sysTimeStamp = 'CURRENT';
+ var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0
+
+ function ADODB_informix72()
+ {
+ // alternatively, use older method:
+ //putenv("DBDATE=Y4MD-");
+
+ // force ISO date format
+ putenv('GL_DATE=%Y-%m-%d');
+
+ if (function_exists('ifx_byteasvarchar')) {
+ ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content.
+ ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content.
+ ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file.
+ }
+ }
+
+ function ServerInfo()
+ {
+ if (isset($this->version)) return $this->version;
+
+ $arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1");
+ $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1");
+ $this->version = $arr;
+ return $arr;
+ }
+
+
+
+ function _insertid()
+ {
+ $sqlca =ifx_getsqlca($this->lastQuery);
+ return @$sqlca["sqlerrd1"];
+ }
+
+ function _affectedrows()
+ {
+ if ($this->lastQuery) {
+ return @ifx_affected_rows ($this->lastQuery);
+ }
+ return 0;
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->Execute('BEGIN');
+ $this->_autocommit = false;
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('COMMIT');
+ $this->_autocommit = true;
+ return true;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('ROLLBACK');
+ $this->_autocommit = true;
+ return true;
+ }
+
+ function RowLock($tables,$where,$flds='1 as ignore')
+ {
+ if ($this->_autocommit) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables where $where for update");
+ }
+
+ /* Returns: the last error message from previous database operation
+ Note: This function is NOT available for Microsoft SQL Server. */
+
+ function ErrorMsg()
+ {
+ if (!empty($this->_logsql)) return $this->_errorMsg;
+ $this->_errorMsg = ifx_errormsg();
+ return $this->_errorMsg;
+ }
+
+ function ErrorNo()
+ {
+ preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse);
+ if (is_array($parse) && isset($parse[1])) return (int)$parse[1];
+ return 0;
+ }
+
+
+ function &MetaColumns($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ if (!empty($this->metaColumnsSQL)) {
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if ($rs === false) return $false;
+ $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items
+
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+/* //!eos.
+ $rs->fields[1] is not the correct adodb type
+ $rs->fields[2] is not correct max_length, because can include not-null bit
+
+ $fld->type = $rs->fields[1];
+ $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag
+ $fld->max_length = $rs->fields[2];*/
+ $pr=ifx_props($rs->fields[1],$rs->fields[2]); //!eos
+ $fld->type = $pr[0] ;//!eos
+ $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields);
+ $fld->max_length = $pr[1]; //!eos
+ $fld->precision = $pr[2] ;//!eos
+ $fld->not_null = $pr[3]=="N"; //!eos
+
+ if (trim($rs->fields[3]) != "AAAAAA 0") {
+ $fld->has_default = 1;
+ $fld->default_value = $rs->fields[3];
+ } else {
+ $fld->has_default = 0;
+ }
+
+ $retarr[strtolower($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+ $rspKey->Close(); //!eos
+ return $retarr;
+ }
+
+ return $false;
+ }
+
+ function &xMetaColumns($table)
+ {
+ return ADOConnection::MetaColumns($table,false);
+ }
+
+ function MetaForeignKeys($table, $owner=false, $upper=false) //!Eos
+ {
+ $sql = "
+ select tr.tabname,updrule,delrule,
+ i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4,
+ i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8
+ from systables t,sysconstraints s,sysindexes i,
+ sysreferences r,systables tr,sysconstraints s2,sysindexes i2
+ where t.tabname='$table'
+ and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid
+ and i.idxname=s.idxname and tr.tabid=r.ptabid
+ and s2.constrid=r.primary and i2.idxname=s2.idxname";
+
+ $rs = $this->Execute($sql);
+ if (!$rs || $rs->EOF) return false;
+ $arr =& $rs->GetArray();
+ $a = array();
+ foreach($arr as $v) {
+ $coldest=$this->metaColumnNames($v["tabname"]);
+ $colorig=$this->metaColumnNames($table);
+ $colnames=array();
+ for($i=1;$i<=8 && $v["o$i"] ;$i++) {
+ $colnames[]=$coldest[$v["d$i"]-1]."=".$colorig[$v["o$i"]-1];
+ }
+ if($upper)
+ $a[strtoupper($v["tabname"])] = $colnames;
+ else
+ $a[$v["tabname"]] = $colnames;
+ }
+ return $a;
+ }
+
+ function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
+ {
+ $type = ($blobtype == 'TEXT') ? 1 : 0;
+ $blobid = ifx_create_blob($type,0,$val);
+ return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blobid));
+ }
+
+ function BlobDecode($blobid)
+ {
+ return function_exists('ifx_byteasvarchar') ? $blobid : @ifx_get_blob($blobid);
+ }
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('ifx_connect')) return null;
+
+ $dbs = $argDatabasename . "@" . $argHostname;
+ if ($argHostname) putenv("INFORMIXSERVER=$argHostname");
+ putenv("INFORMIXSERVER=".trim($argHostname));
+ $this->_connectionID = ifx_connect($dbs,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ #if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('ifx_connect')) return null;
+
+ $dbs = $argDatabasename . "@" . $argHostname;
+ putenv("INFORMIXSERVER=".trim($argHostname));
+ $this->_connectionID = ifx_pconnect($dbs,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ #if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+/*
+ // ifx_do does not accept bind parameters - weird ???
+ function Prepare($sql)
+ {
+ $stmt = ifx_prepare($sql);
+ if (!$stmt) return $sql;
+ else return array($sql,$stmt);
+ }
+*/
+ // returns query ID if successful, otherwise false
+ function _query($sql,$inputarr)
+ {
+ global $ADODB_COUNTRECS;
+
+ // String parameters have to be converted using ifx_create_char
+ if ($inputarr) {
+ foreach($inputarr as $v) {
+ if (gettype($v) == 'string') {
+ $tab[] = ifx_create_char($v);
+ }
+ else {
+ $tab[] = $v;
+ }
+ }
+ }
+
+ // In case of select statement, we use a scroll cursor in order
+ // to be able to call "move", or "movefirst" statements
+ if (!$ADODB_COUNTRECS && preg_match("/^\s*select/is", $sql)) {
+ if ($inputarr) {
+ $this->lastQuery = ifx_query($sql,$this->_connectionID, $this->cursorType, $tab);
+ }
+ else {
+ $this->lastQuery = ifx_query($sql,$this->_connectionID, $this->cursorType);
+ }
+ }
+ else {
+ if ($inputarr) {
+ $this->lastQuery = ifx_query($sql,$this->_connectionID, $tab);
+ }
+ else {
+ $this->lastQuery = ifx_query($sql,$this->_connectionID);
+ }
+ }
+
+ // Following line have been commented because autocommit mode is
+ // not supported by informix SE 7.2
+
+ //if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID);
+
+ return $this->lastQuery;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ $this->lastQuery = false;
+ return ifx_close($this->_connectionID);
+ }
+}
+
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_informix72 extends ADORecordSet {
+
+ var $databaseType = "informix72";
+ var $canSeek = true;
+ var $_fieldprops = false;
+
+ function ADORecordset_informix72($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ return $this->ADORecordSet($id);
+ }
+
+
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+ function &FetchField($fieldOffset = -1)
+ {
+ if (empty($this->_fieldprops)) {
+ $fp = ifx_fieldproperties($this->_queryID);
+ foreach($fp as $k => $v) {
+ $o = new ADOFieldObject;
+ $o->name = $k;
+ $arr = split(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE"
+ $o->type = $arr[0];
+ $o->max_length = $arr[1];
+ $this->_fieldprops[] = $o;
+ $o->not_null = $arr[4]=="N";
+ }
+ }
+ $ret = $this->_fieldprops[$fieldOffset];
+ return $ret;
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = -1; // ifx_affected_rows not reliable, only returns estimate -- ($ADODB_COUNTRECS)? ifx_affected_rows($this->_queryID):-1;
+ $this->_numOfFields = ifx_num_fields($this->_queryID);
+ }
+
+ function _seek($row)
+ {
+ return @ifx_fetch_row($this->_queryID, (int) $row);
+ }
+
+ function MoveLast()
+ {
+ $this->fields = @ifx_fetch_row($this->_queryID, "LAST");
+ if ($this->fields) $this->EOF = false;
+ $this->_currentRow = -1;
+
+ if ($this->fetchMode == ADODB_FETCH_NUM) {
+ foreach($this->fields as $v) {
+ $arr[] = $v;
+ }
+ $this->fields = $arr;
+ }
+
+ return true;
+ }
+
+ function MoveFirst()
+ {
+ $this->fields = @ifx_fetch_row($this->_queryID, "FIRST");
+ if ($this->fields) $this->EOF = false;
+ $this->_currentRow = 0;
+
+ if ($this->fetchMode == ADODB_FETCH_NUM) {
+ foreach($this->fields as $v) {
+ $arr[] = $v;
+ }
+ $this->fields = $arr;
+ }
+
+ return true;
+ }
+
+ function _fetch($ignore_fields=false)
+ {
+
+ $this->fields = @ifx_fetch_row($this->_queryID);
+
+ if (!is_array($this->fields)) return false;
+
+ if ($this->fetchMode == ADODB_FETCH_NUM) {
+ foreach($this->fields as $v) {
+ $arr[] = $v;
+ }
+ $this->fields = $arr;
+ }
+ return true;
+ }
+
+ /* close() only needs to be called if you are worried about using too much memory while your script
+ is running. All associated result memory for the specified result identifier will automatically be freed. */
+ function _close()
+ {
+ return ifx_free_result($this->_queryID);
+ }
+
+}
+/** !Eos
+* Auxiliar function to Parse coltype,collength. Used by Metacolumns
+* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties)
+*/
+function ifx_props($coltype,$collength){
+ $itype=fmod($coltype+1,256);
+ $nullable=floor(($coltype+1) /256) ?"N":"Y";
+ $mtype=substr(" CIIFFNNDN TBXCC ",$itype,1);
+ switch ($itype){
+ case 2:
+ $length=4;
+ case 6:
+ case 9:
+ case 14:
+ $length=floor($collength/256);
+ $precision=fmod($collength,256);
+ break;
+ default:
+ $precision=0;
+ $length=$collength;
+ }
+ return array($mtype,$length,$precision,$nullable);
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-ldap.inc.php b/html/phpgacl/adodb/drivers/adodb-ldap.inc.php
new file mode 100644
index 0000000..160886e
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-ldap.inc.php
@@ -0,0 +1,406 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+ Revision 1: (02/25/2005) Updated codebase to include the _inject_bind_options function. This allows
+ users to access the options in the ldap_set_option function appropriately. Most importantly
+ LDAP Version 3 is now supported. See the examples for more information. Also fixed some minor
+ bugs that surfaced when PHP error levels were set high.
+
+ Joshua Eldridge (joshuae74#hotmail.com)
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('LDAP_ASSOC')) {
+ define('LDAP_ASSOC',ADODB_FETCH_ASSOC);
+ define('LDAP_NUM',ADODB_FETCH_NUM);
+ define('LDAP_BOTH',ADODB_FETCH_BOTH);
+}
+
+class ADODB_ldap extends ADOConnection {
+ var $databaseType = 'ldap';
+ var $dataProvider = 'ldap';
+
+ # Connection information
+ var $username = false;
+ var $password = false;
+
+ # Used during searches
+ var $filter;
+ var $dn;
+ var $version;
+ var $port = 389;
+
+ # Options configuration information
+ var $LDAP_CONNECT_OPTIONS;
+
+ function ADODB_ldap()
+ {
+ }
+
+ // returns true or false
+
+ function _connect( $host, $username, $password, $ldapbase)
+ {
+ global $LDAP_CONNECT_OPTIONS;
+
+ if ( !function_exists( 'ldap_connect' ) ) return null;
+
+ $conn_info = array( $host,$this->port);
+
+ if ( strstr( $host, ':' ) ) {
+ $conn_info = split( ':', $host );
+ }
+
+ $this->_connectionID = ldap_connect( $conn_info[0], $conn_info[1] );
+ if (!$this->_connectionID) {
+ $e = 'Could not connect to ' . $conn_info[0];
+ $this->_errorMsg = $e;
+ if ($this->debug) ADOConnection::outp($e);
+ return false;
+ }
+ if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) {
+ $this->_inject_bind_options( $LDAP_CONNECT_OPTIONS );
+ }
+
+ if ($username) {
+ $bind = ldap_bind( $this->_connectionID, $username, $password );
+ } else {
+ $username = 'anonymous';
+ $bind = ldap_bind( $this->_connectionID );
+ }
+
+ if (!$bind) {
+ $e = 'Could not bind to ' . $conn_info[0] . " as ".$username;
+ $this->_errorMsg = $e;
+ if ($this->debug) ADOConnection::outp($e);
+ return false;
+ }
+ $this->_errorMsg = '';
+ $this->database = $ldapbase;
+ return $this->_connectionID;
+ }
+
+/*
+ Valid Domain Values for LDAP Options:
+
+ LDAP_OPT_DEREF (integer)
+ LDAP_OPT_SIZELIMIT (integer)
+ LDAP_OPT_TIMELIMIT (integer)
+ LDAP_OPT_PROTOCOL_VERSION (integer)
+ LDAP_OPT_ERROR_NUMBER (integer)
+ LDAP_OPT_REFERRALS (boolean)
+ LDAP_OPT_RESTART (boolean)
+ LDAP_OPT_HOST_NAME (string)
+ LDAP_OPT_ERROR_STRING (string)
+ LDAP_OPT_MATCHED_DN (string)
+ LDAP_OPT_SERVER_CONTROLS (array)
+ LDAP_OPT_CLIENT_CONTROLS (array)
+
+ Make sure to set this BEFORE calling Connect()
+
+ Example:
+
+ $LDAP_CONNECT_OPTIONS = Array(
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_DEREF,
+ "OPTION_VALUE"=>2
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_SIZELIMIT,
+ "OPTION_VALUE"=>100
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_TIMELIMIT,
+ "OPTION_VALUE"=>30
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_PROTOCOL_VERSION,
+ "OPTION_VALUE"=>3
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_ERROR_NUMBER,
+ "OPTION_VALUE"=>13
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_REFERRALS,
+ "OPTION_VALUE"=>FALSE
+ ),
+ Array (
+ "OPTION_NAME"=>LDAP_OPT_RESTART,
+ "OPTION_VALUE"=>FALSE
+ )
+ );
+*/
+
+ function _inject_bind_options( $options ) {
+ foreach( $options as $option ) {
+ ldap_set_option( $this->_connectionID, $option["OPTION_NAME"], $option["OPTION_VALUE"] )
+ or die( "Unable to set server option: " . $option["OPTION_NAME"] );
+ }
+ }
+
+ /* returns _queryID or false */
+ function _query($sql,$inputarr)
+ {
+ $rs = ldap_search( $this->_connectionID, $this->database, $sql );
+ $this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql;
+ return $rs;
+ }
+
+ /* closes the LDAP connection */
+ function _close()
+ {
+ @ldap_close( $this->_connectionID );
+ $this->_connectionID = false;
+ }
+
+ function SelectDB($db) {
+ $this->database = $db;
+ return true;
+ } // SelectDB
+
+ function ServerInfo()
+ {
+ if( !empty( $this->version ) ) return $this->version;
+ $version = array();
+ /*
+ Determines how aliases are handled during search.
+ LDAP_DEREF_NEVER (0x00)
+ LDAP_DEREF_SEARCHING (0x01)
+ LDAP_DEREF_FINDING (0x02)
+ LDAP_DEREF_ALWAYS (0x03)
+ The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but
+ not when locating the base object of the search. The LDAP_DEREF_FINDING value means
+ aliases are dereferenced when locating the base object but not during the search.
+ Default: LDAP_DEREF_NEVER
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ;
+ switch ( $version['LDAP_OPT_DEREF'] ) {
+ case 0:
+ $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_NEVER';
+ case 1:
+ $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_SEARCHING';
+ case 2:
+ $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_FINDING';
+ case 3:
+ $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS';
+ }
+
+ /*
+ A limit on the number of entries to return from a search.
+ LDAP_NO_LIMIT (0) means no limit.
+ Default: LDAP_NO_LIMIT
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_SIZELIMIT, $version['LDAP_OPT_SIZELIMIT'] );
+ if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) {
+ $version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT';
+ }
+
+ /*
+ A limit on the number of seconds to spend on a search.
+ LDAP_NO_LIMIT (0) means no limit.
+ Default: LDAP_NO_LIMIT
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_TIMELIMIT, $version['LDAP_OPT_TIMELIMIT'] );
+ if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) {
+ $version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT';
+ }
+
+ /*
+ Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not.
+ LDAP_OPT_ON
+ LDAP_OPT_OFF
+ Default: ON
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_REFERRALS, $version['LDAP_OPT_REFERRALS'] );
+ if ( $version['LDAP_OPT_REFERRALS'] == 0 ) {
+ $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF';
+ } else {
+ $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON';
+
+ }
+ /*
+ Determines whether LDAP I/O operations are automatically restarted if they abort prematurely.
+ LDAP_OPT_ON
+ LDAP_OPT_OFF
+ Default: OFF
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_RESTART, $version['LDAP_OPT_RESTART'] );
+ if ( $version['LDAP_OPT_RESTART'] == 0 ) {
+ $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF';
+ } else {
+ $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON';
+
+ }
+ /*
+ This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server.
+ LDAP_VERSION2 (2)
+ LDAP_VERSION3 (3)
+ Default: LDAP_VERSION2 (2)
+ */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_PROTOCOL_VERSION, $version['LDAP_OPT_PROTOCOL_VERSION'] );
+ if ( $version['LDAP_OPT_PROTOCOL_VERSION'] == 2 ) {
+ $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2';
+ } else {
+ $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3';
+
+ }
+ /* The host name (or list of hosts) for the primary LDAP server. */
+ ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] );
+ ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] );
+ ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['LDAP_OPT_ERROR_STRING'] );
+ ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] );
+
+ return $this->version = $version;
+
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_ldap extends ADORecordSet{
+
+ var $databaseType = "ldap";
+ var $canSeek = false;
+ var $_entryID; /* keeps track of the entry resource identifier */
+
+ function ADORecordSet_ldap($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM:
+ $this->fetchMode = LDAP_NUM;
+ break;
+ case ADODB_FETCH_ASSOC:
+ $this->fetchMode = LDAP_ASSOC;
+ break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = LDAP_BOTH;
+ break;
+ }
+
+ $this->ADORecordSet($queryID);
+ }
+
+ function _initrs()
+ {
+ /*
+ This could be teaked to respect the $COUNTRECS directive from ADODB
+ It's currently being used in the _fetch() function and the
+ GetAssoc() function
+ */
+ $this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID );
+
+ }
+
+ /*
+ Return whole recordset as a multi-dimensional associative array
+ */
+ function &GetAssoc($force_array = false, $first2cols = false)
+ {
+ $records = $this->_numOfRows;
+ $results = array();
+ for ( $i=0; $i < $records; $i++ ) {
+ foreach ( $this->fields as $k=>$v ) {
+ if ( is_array( $v ) ) {
+ if ( $v['count'] == 1 ) {
+ $results[$i][$k] = $v[0];
+ } else {
+ array_shift( $v );
+ $results[$i][$k] = $v;
+ }
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ function &GetRowAssoc()
+ {
+ $results = array();
+ foreach ( $this->fields as $k=>$v ) {
+ if ( is_array( $v ) ) {
+ if ( $v['count'] == 1 ) {
+ $results[$k] = $v[0];
+ } else {
+ array_shift( $v );
+ $results[$k] = $v;
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ function GetRowNums()
+ {
+ $results = array();
+ foreach ( $this->fields as $k=>$v ) {
+ static $i = 0;
+ if (is_array( $v )) {
+ if ( $v['count'] == 1 ) {
+ $results[$i] = $v[0];
+ } else {
+ array_shift( $v );
+ $results[$i] = $v;
+ }
+ $i++;
+ }
+ }
+ return $results;
+ }
+
+ function _fetch()
+ {
+ if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 )
+ return false;
+
+ if ( $this->_currentRow == 0 ) {
+ $this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID );
+ } else {
+ $this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID );
+ }
+
+ $this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID );
+ $this->_numOfFields = $this->fields['count'];
+ switch ( $this->fetchMode ) {
+
+ case LDAP_ASSOC:
+ $this->fields = $this->GetRowAssoc();
+ break;
+
+ case LDAP_NUM:
+ $this->fields = array_merge($this->GetRowNums(),$this->GetRowAssoc());
+ break;
+
+ case LDAP_BOTH:
+ default:
+ $this->fields = $this->GetRowNums();
+ break;
+ }
+ return ( is_array( $this->fields ) );
+ }
+
+ function _close() {
+ @ldap_free_result( $this->_queryID );
+ $this->_queryID = false;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-mssql.inc.php b/html/phpgacl/adodb/drivers/adodb-mssql.inc.php
new file mode 100644
index 0000000..1d1a97a
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-mssql.inc.php
@@ -0,0 +1,1019 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Native mssql driver. Requires mssql client. Works on Windows.
+ To configure for Unix, see
+ http://phpbuilder.com/columns/alberto20000919.php3
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+//----------------------------------------------------------------
+// MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
+// and this causes tons of problems because localized versions of
+// MSSQL will return the dates in dmy or mdy order; and also the
+// month strings depends on what language has been configured. The
+// following two variables allow you to control the localization
+// settings - Ugh.
+//
+// MORE LOCALIZATION INFO
+// ----------------------
+// To configure datetime, look for and modify sqlcommn.loc,
+// typically found in c:\mssql\install
+// Also read :
+// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
+// Alternatively use:
+// CONVERT(char(12),datecol,120)
+//----------------------------------------------------------------
+
+
+// has datetime converstion to YYYY-MM-DD format, and also mssql_fetch_assoc
+if (ADODB_PHPVER >= 0x4300) {
+// docs say 4.2.0, but testing shows only since 4.3.0 does it work!
+ ini_set('mssql.datetimeconvert',0);
+} else {
+global $ADODB_mssql_mths; // array, months must be upper-case
+
+
+ $ADODB_mssql_date_order = 'mdy';
+ $ADODB_mssql_mths = array(
+ 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
+ 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
+}
+
+//---------------------------------------------------------------------------
+// Call this to autoset $ADODB_mssql_date_order at the beginning of your code,
+// just after you connect to the database. Supports mdy and dmy only.
+// Not required for PHP 4.2.0 and above.
+function AutoDetect_MSSQL_Date_Order($conn)
+{
+global $ADODB_mssql_date_order;
+ $adate = $conn->GetOne('select getdate()');
+ if ($adate) {
+ $anum = (int) $adate;
+ if ($anum > 0) {
+ if ($anum > 31) {
+ //ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently");
+ } else
+ $ADODB_mssql_date_order = 'dmy';
+ } else
+ $ADODB_mssql_date_order = 'mdy';
+ }
+}
+
+class ADODB_mssql extends ADOConnection {
+ var $databaseType = "mssql";
+ var $dataProvider = "mssql";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d h:i:sA'";
+ var $hasInsertID = true;
+ var $substr = "substring";
+ var $length = 'len';
+ var $hasAffectedRows = true;
+ var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'";
+ var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))";
+ var $metaColumnsSQL = # xtype==61 is datetime
+"select c.name,t.name,c.length,
+ (case when c.xusertype=61 then 0 else c.xprec end),
+ (case when c.xusertype=61 then 0 else c.xscale end)
+ from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
+ var $hasGenID = true;
+ var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
+ var $sysTimeStamp = 'GetDate()';
+ var $_has_mssql_init;
+ var $maxParameterLen = 4000;
+ var $arrayClass = 'ADORecordSet_array_mssql';
+ var $uniqueSort = true;
+ var $leftOuter = '*=';
+ var $rightOuter = '=*';
+ var $ansiOuter = true; // for mssql7 or later
+ var $poorAffectedRows = true;
+ var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000
+ var $uniqueOrderBy = true;
+ var $_bindInputArray = true;
+
+ function ADODB_mssql()
+ {
+ $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
+ }
+
+ function ServerInfo()
+ {
+ global $ADODB_FETCH_MODE;
+
+ $stmt = $this->PrepareSP('sp_server_info');
+ $val = 2;
+ if ($this->fetchMode === false) {
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ } else
+ $savem = $this->SetFetchMode(ADODB_FETCH_NUM);
+
+
+ $this->Parameter($stmt,$val,'attribute_id');
+ $row = $this->GetRow($stmt);
+
+ //$row = $this->GetRow("execute sp_server_info 2");
+
+ if ($this->fetchMode === false) {
+ $ADODB_FETCH_MODE = $savem;
+ } else
+ $this->SetFetchMode($savem);
+
+ $arr['description'] = $row[2];
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " ISNULL($field, $ifNull) "; // if MS SQL Server
+ }
+
+ function _insertid()
+ {
+ // SCOPE_IDENTITY()
+ // Returns the last IDENTITY value inserted into an IDENTITY column in
+ // the same scope. A scope is a module -- a stored procedure, trigger,
+ // function, or batch. Thus, two statements are in the same scope if
+ // they are in the same stored procedure, function, or batch.
+ return $this->GetOne($this->identitySQL);
+ }
+
+ function _affectedrows()
+ {
+ return $this->GetOne('select @@rowcount');
+ }
+
+ var $_dropSeqSQL = "drop table %s";
+
+ function CreateSequence($seq='adodbseq',$start=1)
+ {
+ $start -= 1;
+ $this->Execute("create table $seq (id float(53))");
+ $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
+ if (!$ok) {
+ $this->Execute('ROLLBACK TRANSACTION adodbseq');
+ return false;
+ }
+ $this->Execute('COMMIT TRANSACTION adodbseq');
+ return true;
+ }
+
+ function GenID($seq='adodbseq',$start=1)
+ {
+ //$this->debug=1;
+ $this->Execute('BEGIN TRANSACTION adodbseq');
+ $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
+ if (!$ok) {
+ $this->Execute("create table $seq (id float(53))");
+ $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
+ if (!$ok) {
+ $this->Execute('ROLLBACK TRANSACTION adodbseq');
+ return false;
+ }
+ $this->Execute('COMMIT TRANSACTION adodbseq');
+ return $start;
+ }
+ $num = $this->GetOne("select id from $seq");
+ $this->Execute('COMMIT TRANSACTION adodbseq');
+ return $num;
+
+ // in old implementation, pre 1.90, we returned GUID...
+ //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
+ }
+
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ if ($nrows > 0 && $offset <= 0) {
+ $sql = preg_replace(
+ '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql);
+ $rs =& $this->Execute($sql,$inputarr);
+ } else
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+
+ return $rs;
+ }
+
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '+';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "datename(yyyy,$col)";
+ break;
+ case 'M':
+ $s .= "convert(char(3),$col,0)";
+ break;
+ case 'm':
+ $s .= "replace(str(month($col),2),' ','0')";
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "datename(quarter,$col)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "replace(str(day($col),2),' ','0')";
+ break;
+ case 'h':
+ $s .= "substring(convert(char(14),$col,0),13,2)";
+ break;
+
+ case 'H':
+ $s .= "replace(str(datepart(hh,$col),2),' ','0')";
+ break;
+
+ case 'i':
+ $s .= "replace(str(datepart(mi,$col),2),' ','0')";
+ break;
+ case 's':
+ $s .= "replace(str(datepart(ss,$col),2),' ','0')";
+ break;
+ case 'a':
+ case 'A':
+ $s .= "substring(convert(char(19),$col,0),18,2)";
+ break;
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ break;
+ }
+ }
+ return $s;
+ }
+
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->Execute('BEGIN TRAN');
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('COMMIT TRAN');
+ return true;
+ }
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('ROLLBACK TRAN');
+ return true;
+ }
+
+ /*
+ Usage:
+
+ $this->BeginTrans();
+ $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables
+
+ # some operation on both tables table1 and table2
+
+ $this->CommitTrans();
+
+ See http://www.swynk.com/friends/achigrik/SQL70Locks.asp
+ */
+ function RowLock($tables,$where,$flds='top 1 null as ignore')
+ {
+ if (!$this->transCnt) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where");
+ }
+
+
+ function &MetaIndexes($table,$primary=false)
+ {
+ $table = $this->qstr($table);
+
+ $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno,
+ CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK,
+ CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique
+ FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id
+ INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid
+ INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid
+ WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table
+ ORDER BY O.name, I.Name, K.keyno";
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return FALSE;
+ }
+
+ $indexes = array();
+ while ($row = $rs->FetchRow()) {
+ if (!$primary && $row[5]) continue;
+
+ $indexes[$row[0]]['unique'] = $row[6];
+ $indexes[$row[0]]['columns'][] = $row[1];
+ }
+ return $indexes;
+ }
+
+ function MetaForeignKeys($table, $owner=false, $upper=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $table = $this->qstr(strtoupper($table));
+
+ $sql =
+"select object_name(constid) as constraint_name,
+ col_name(fkeyid, fkey) as column_name,
+ object_name(rkeyid) as referenced_table_name,
+ col_name(rkeyid, rkey) as referenced_column_name
+from sysforeignkeys
+where upper(object_name(fkeyid)) = $table
+order by constraint_name, referenced_table_name, keyno";
+
+ $constraints =& $this->GetArray($sql);
+
+ $ADODB_FETCH_MODE = $save;
+
+ $arr = false;
+ foreach($constraints as $constr) {
+ //print_r($constr);
+ $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3];
+ }
+ if (!$arr) return false;
+
+ $arr2 = false;
+
+ foreach($arr as $k => $v) {
+ foreach($v as $a => $b) {
+ if ($upper) $a = strtoupper($a);
+ $arr2[$a] = $b;
+ }
+ }
+ return $arr2;
+ }
+
+ //From: Fernando Moreira <FMoreira@imediata.pt>
+ function MetaDatabases()
+ {
+ if(@mssql_select_db("master")) {
+ $qry=$this->metaDatabasesSQL;
+ if($rs=@mssql_query($qry)){
+ $tmpAr=$ar=array();
+ while($tmpAr=@mssql_fetch_row($rs))
+ $ar[]=$tmpAr[0];
+ @mssql_select_db($this->databaseName);
+ if(sizeof($ar))
+ return($ar);
+ else
+ return(false);
+ } else {
+ @mssql_select_db($this->databaseName);
+ return(false);
+ }
+ }
+ return(false);
+ }
+
+ // "Stein-Aksel Basma" <basma@accelero.no>
+ // tested with MSSQL 2000
+ function &MetaPrimaryKeys($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = '';
+ $this->_findschema($table,$schema);
+ if (!$schema) $schema = $this->database;
+ if ($schema) $schema = "and k.table_catalog like '$schema%'";
+
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
+ information_schema.table_constraints tc
+ where tc.constraint_name = k.constraint_name and tc.constraint_type =
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $a = $this->GetCol($sql);
+ $ADODB_FETCH_MODE = $savem;
+
+ if ($a && sizeof($a)>0) return $a;
+ $false = false;
+ return $false;
+ }
+
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ if ($mask) {
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr(($mask));
+ $this->metaTablesSQL .= " AND name like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ function SelectDB($dbName)
+ {
+ $this->databaseName = $dbName;
+ if ($this->_connectionID) {
+ return @mssql_select_db($dbName);
+ }
+ else return false;
+ }
+
+ function ErrorMsg()
+ {
+ if (empty($this->_errorMsg)){
+ $this->_errorMsg = mssql_get_last_message();
+ }
+ return $this->_errorMsg;
+ }
+
+ function ErrorNo()
+ {
+ if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode;
+ if (empty($this->_errorMsg)) {
+ $this->_errorMsg = mssql_get_last_message();
+ }
+ $id = @mssql_query("select @@ERROR",$this->_connectionID);
+ if (!$id) return false;
+ $arr = mssql_fetch_array($id);
+ @mssql_free_result($id);
+ if (is_array($arr)) return $arr[0];
+ else return -1;
+ }
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('mssql_pconnect')) return null;
+ $this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('mssql_pconnect')) return null;
+ $this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+
+ // persistent connections can forget to rollback on crash, so we do it here.
+ if ($this->autoRollback) {
+ $cnt = $this->GetOne('select @@TRANCOUNT');
+ while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN');
+ }
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ function Prepare($sql)
+ {
+ $sqlarr = explode('?',$sql);
+ if (sizeof($sqlarr) <= 1) return $sql;
+ $sql2 = $sqlarr[0];
+ for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
+ $sql2 .= '@P'.($i-1) . $sqlarr[$i];
+ }
+ return array($sql,$this->qstr($sql2),$max);
+ }
+
+ function PrepareSP($sql)
+ {
+ if (!$this->_has_mssql_init) {
+ ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
+ return $sql;
+ }
+ $stmt = mssql_init($sql,$this->_connectionID);
+ if (!$stmt) return $sql;
+ return array($sql,$stmt);
+ }
+
+ // returns concatenated string
+ // MSSQL requires integers to be cast as strings
+ // automatically cast every datatype to VARCHAR(255)
+ // @author David Rogers (introspectshun)
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
+
+ // Split single record on commas, if possible
+ if (sizeof($arr) == 1) {
+ foreach ($arr as $arg) {
+ $args = explode(',', $arg);
+ }
+ $arr = $args;
+ }
+
+ array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";'));
+ $s = implode('+',$arr);
+ if (sizeof($arr) > 0) return "$s";
+
+ return '';
+ }
+
+ /*
+ Usage:
+ $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group
+
+ # note that the parameter does not have @ in front!
+ $db->Parameter($stmt,$id,'myid');
+ $db->Parameter($stmt,$group,'group',false,64);
+ $db->Execute($stmt);
+
+ @param $stmt Statement returned by Prepare() or PrepareSP().
+ @param $var PHP variable to bind to. Can set to null (for isNull support).
+ @param $name Name of stored procedure variable name to bind to.
+ @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8.
+ @param [$maxLen] Holds an maximum length of the variable.
+ @param [$type] The data type of $var. Legal values depend on driver.
+
+ See mssql_bind documentation at php.net.
+ */
+ function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false)
+ {
+ if (!$this->_has_mssql_init) {
+ ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0");
+ return $sql;
+ }
+
+ $isNull = is_null($var); // php 4.0.4 and above...
+
+ if ($type === false)
+ switch(gettype($var)) {
+ default:
+ case 'string': $type = SQLCHAR; break;
+ case 'double': $type = SQLFLT8; break;
+ case 'integer': $type = SQLINT4; break;
+ case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0
+ }
+
+ if ($this->debug) {
+ $prefix = ($isOutput) ? 'Out' : 'In';
+ $ztype = (empty($type)) ? 'false' : $type;
+ ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
+ }
+ /*
+ See http://phplens.com/lens/lensforum/msgs.php?id=7231
+
+ RETVAL is HARD CODED into php_mssql extension:
+ The return value (a long integer value) is treated like a special OUTPUT parameter,
+ called "RETVAL" (without the @). See the example at mssql_execute to
+ see how it works. - type: one of this new supported PHP constants.
+ SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8
+ */
+ if ($name !== 'RETVAL') $name = '@'.$name;
+ return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen);
+ }
+
+ /*
+ Unfortunately, it appears that mssql cannot handle varbinary > 255 chars
+ So all your blobs must be of type "image".
+
+ Remember to set in php.ini the following...
+
+ ; Valid range 0 - 2147483647. Default = 4096.
+ mssql.textlimit = 0 ; zero to pass through
+
+ ; Valid range 0 - 2147483647. Default = 4096.
+ mssql.textsize = 0 ; zero to pass through
+ */
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+
+ if (strtoupper($blobtype) == 'CLOB') {
+ $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where";
+ return $this->Execute($sql) != false;
+ }
+ $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where";
+ return $this->Execute($sql) != false;
+ }
+
+ // returns query ID if successful, otherwise false
+ function _query($sql,$inputarr)
+ {
+ $this->_errorMsg = false;
+ if (is_array($inputarr)) {
+
+ # bind input params with sp_executesql:
+ # see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm
+ # works only with sql server 7 and newer
+ if (!is_array($sql)) $sql = $this->Prepare($sql);
+ $params = '';
+ $decl = '';
+ $i = 0;
+ foreach($inputarr as $v) {
+ if ($decl) {
+ $decl .= ', ';
+ $params .= ', ';
+ }
+ if (is_string($v)) {
+ $len = strlen($v);
+ if ($len == 0) $len = 1;
+
+ if ($len > 4000 ) {
+ // NVARCHAR is max 4000 chars. Let's use NTEXT
+ $decl .= "@P$i NTEXT";
+ } else {
+ $decl .= "@P$i NVARCHAR($len)";
+ }
+
+ $params .= "@P$i=N". (strncmp($v,"'",1)==0? $v : $this->qstr($v));
+ } else if (is_integer($v)) {
+ $decl .= "@P$i INT";
+ $params .= "@P$i=".$v;
+ } else if (is_float($v)) {
+ $decl .= "@P$i FLOAT";
+ $params .= "@P$i=".$v;
+ } else if (is_bool($v)) {
+ $decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately.
+ $params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field
+ } else {
+ $decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL.
+ $params .= "@P$i=NULL";
+ }
+ $i += 1;
+ }
+ $decl = $this->qstr($decl);
+ if ($this->debug) ADOConnection::outp("<font size=-1>sp_executesql N{$sql[1]},N$decl,$params</font>");
+ $rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params");
+
+ } else if (is_array($sql)) {
+ # PrepareSP()
+ $rez = mssql_execute($sql[1]);
+
+ } else {
+ $rez = mssql_query($sql,$this->_connectionID);
+ }
+ return $rez;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->transCnt) $this->RollbackTrans();
+ $rez = @mssql_close($this->_connectionID);
+ $this->_connectionID = false;
+ return $rez;
+ }
+
+ // mssql uses a default date like Dec 30 2000 12:00AM
+ function UnixDate($v)
+ {
+ return ADORecordSet_array_mssql::UnixDate($v);
+ }
+
+ function UnixTimeStamp($v)
+ {
+ return ADORecordSet_array_mssql::UnixTimeStamp($v);
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_mssql extends ADORecordSet {
+
+ var $databaseType = "mssql";
+ var $canSeek = true;
+ var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083
+ // _mths works only in non-localised system
+
+ function ADORecordset_mssql($id,$mode=false)
+ {
+ // freedts check...
+ $this->hasFetchAssoc = function_exists('mssql_fetch_assoc');
+
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ return $this->ADORecordSet($id,$mode);
+ }
+
+
+ function _initrs()
+ {
+ GLOBAL $ADODB_COUNTRECS;
+ $this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1;
+ $this->_numOfFields = @mssql_num_fields($this->_queryID);
+ }
+
+
+ //Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se>
+ // get next resultset - requires PHP 4.0.5 or later
+ function NextRecordSet()
+ {
+ if (!mssql_next_result($this->_queryID)) return false;
+ $this->_inited = false;
+ $this->bind = false;
+ $this->_currentRow = -1;
+ $this->Init();
+ return true;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+
+ function &FetchField($fieldOffset = -1)
+ {
+ if ($fieldOffset != -1) {
+ $f = @mssql_fetch_field($this->_queryID, $fieldOffset);
+ }
+ else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
+ $f = @mssql_fetch_field($this->_queryID);
+ }
+ $false = false;
+ if (empty($f)) return $false;
+ return $f;
+ }
+
+ function _seek($row)
+ {
+ return @mssql_data_seek($this->_queryID, $row);
+ }
+
+ // speedup
+ function MoveNext()
+ {
+ if ($this->EOF) return false;
+
+ $this->_currentRow++;
+
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ if ($this->fetchMode & ADODB_FETCH_NUM) {
+ //ADODB_FETCH_BOTH mode
+ $this->fields = @mssql_fetch_array($this->_queryID);
+ }
+ else {
+ if ($this->hasFetchAssoc) {// only for PHP 4.2.0 or later
+ $this->fields = @mssql_fetch_assoc($this->_queryID);
+ } else {
+ $flds = @mssql_fetch_array($this->_queryID);
+ if (is_array($flds)) {
+ $fassoc = array();
+ foreach($flds as $k => $v) {
+ if (is_numeric($k)) continue;
+ $fassoc[$k] = $v;
+ }
+ $this->fields = $fassoc;
+ } else
+ $this->fields = false;
+ }
+ }
+
+ if (is_array($this->fields)) {
+ if (ADODB_ASSOC_CASE == 0) {
+ foreach($this->fields as $k=>$v) {
+ $this->fields[strtolower($k)] = $v;
+ }
+ } else if (ADODB_ASSOC_CASE == 1) {
+ foreach($this->fields as $k=>$v) {
+ $this->fields[strtoupper($k)] = $v;
+ }
+ }
+ }
+ } else {
+ $this->fields = @mssql_fetch_row($this->_queryID);
+ }
+ if ($this->fields) return true;
+ $this->EOF = true;
+
+ return false;
+ }
+
+
+ // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
+ // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
+ function _fetch($ignore_fields=false)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ if ($this->fetchMode & ADODB_FETCH_NUM) {
+ //ADODB_FETCH_BOTH mode
+ $this->fields = @mssql_fetch_array($this->_queryID);
+ } else {
+ if ($this->hasFetchAssoc) // only for PHP 4.2.0 or later
+ $this->fields = @mssql_fetch_assoc($this->_queryID);
+ else {
+ $this->fields = @mssql_fetch_array($this->_queryID);
+ if (@is_array($$this->fields)) {
+ $fassoc = array();
+ foreach($$this->fields as $k => $v) {
+ if (is_integer($k)) continue;
+ $fassoc[$k] = $v;
+ }
+ $this->fields = $fassoc;
+ }
+ }
+ }
+
+ if (!$this->fields) {
+ } else if (ADODB_ASSOC_CASE == 0) {
+ foreach($this->fields as $k=>$v) {
+ $this->fields[strtolower($k)] = $v;
+ }
+ } else if (ADODB_ASSOC_CASE == 1) {
+ foreach($this->fields as $k=>$v) {
+ $this->fields[strtoupper($k)] = $v;
+ }
+ }
+ } else {
+ $this->fields = @mssql_fetch_row($this->_queryID);
+ }
+ return $this->fields;
+ }
+
+ /* close() only needs to be called if you are worried about using too much memory while your script
+ is running. All associated result memory for the specified result identifier will automatically be freed. */
+
+ function _close()
+ {
+ $rez = mssql_free_result($this->_queryID);
+ $this->_queryID = false;
+ return $rez;
+ }
+ // mssql uses a default date like Dec 30 2000 12:00AM
+ function UnixDate($v)
+ {
+ return ADORecordSet_array_mssql::UnixDate($v);
+ }
+
+ function UnixTimeStamp($v)
+ {
+ return ADORecordSet_array_mssql::UnixTimeStamp($v);
+ }
+
+}
+
+
+class ADORecordSet_array_mssql extends ADORecordSet_array {
+ function ADORecordSet_array_mssql($id=-1,$mode=false)
+ {
+ $this->ADORecordSet_array($id,$mode);
+ }
+
+ // mssql uses a default date like Dec 30 2000 12:00AM
+ function UnixDate($v)
+ {
+
+ if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
+
+ global $ADODB_mssql_mths,$ADODB_mssql_date_order;
+
+ //Dec 30 2000 12:00AM
+ if ($ADODB_mssql_date_order == 'dmy') {
+ if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
+ return parent::UnixDate($v);
+ }
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $theday = $rr[1];
+ $themth = substr(strtoupper($rr[2]),0,3);
+ } else {
+ if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
+ return parent::UnixDate($v);
+ }
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $theday = $rr[2];
+ $themth = substr(strtoupper($rr[1]),0,3);
+ }
+ $themth = $ADODB_mssql_mths[$themth];
+ if ($themth <= 0) return false;
+ // h-m-s-MM-DD-YY
+ return mktime(0,0,0,$themth,$theday,$rr[3]);
+ }
+
+ function UnixTimeStamp($v)
+ {
+
+ if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
+
+ global $ADODB_mssql_mths,$ADODB_mssql_date_order;
+
+ //Dec 30 2000 12:00AM
+ if ($ADODB_mssql_date_order == 'dmy') {
+ if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+ ,$v, $rr)) return parent::UnixTimeStamp($v);
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $theday = $rr[1];
+ $themth = substr(strtoupper($rr[2]),0,3);
+ } else {
+ if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+ ,$v, $rr)) return parent::UnixTimeStamp($v);
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $theday = $rr[2];
+ $themth = substr(strtoupper($rr[1]),0,3);
+ }
+
+ $themth = $ADODB_mssql_mths[$themth];
+ if ($themth <= 0) return false;
+
+ switch (strtoupper($rr[6])) {
+ case 'P':
+ if ($rr[4]<12) $rr[4] += 12;
+ break;
+ case 'A':
+ if ($rr[4]==12) $rr[4] = 0;
+ break;
+ default:
+ break;
+ }
+ // h-m-s-MM-DD-YY
+ return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
+ }
+}
+
+/*
+Code Example 1:
+
+select object_name(constid) as constraint_name,
+ object_name(fkeyid) as table_name,
+ col_name(fkeyid, fkey) as column_name,
+ object_name(rkeyid) as referenced_table_name,
+ col_name(rkeyid, rkey) as referenced_column_name
+from sysforeignkeys
+where object_name(fkeyid) = x
+order by constraint_name, table_name, referenced_table_name, keyno
+
+Code Example 2:
+select constraint_name,
+ column_name,
+ ordinal_position
+from information_schema.key_column_usage
+where constraint_catalog = db_name()
+and table_name = x
+order by constraint_name, ordinal_position
+
+http://www.databasejournal.com/scripts/article.php/1440551
+*/
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-mssqlpo.inc.php b/html/phpgacl/adodb/drivers/adodb-mssqlpo.inc.php
new file mode 100644
index 0000000..2db6934
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-mssqlpo.inc.php
@@ -0,0 +1,62 @@
+<?php
+/**
+* @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+* Released under both BSD license and Lesser GPL library license.
+* Whenever there is any discrepancy between the two licenses,
+* the BSD license will take precedence.
+*
+* Set tabs to 4 for best viewing.
+*
+* Latest version is available at http://php.weblogs.com
+*
+* Portable MSSQL Driver that supports || instead of +
+*
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+
+/*
+ The big difference between mssqlpo and it's parent mssql is that mssqlpo supports
+ the more standard || string concatenation operator.
+*/
+
+include_once(ADODB_DIR.'/drivers/adodb-mssql.inc.php');
+
+class ADODB_mssqlpo extends ADODB_mssql {
+ var $databaseType = "mssqlpo";
+ var $concat_operator = '||';
+
+ function ADODB_mssqlpo()
+ {
+ ADODB_mssql::ADODB_mssql();
+ }
+
+ function PrepareSP($sql)
+ {
+ if (!$this->_has_mssql_init) {
+ ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
+ return $sql;
+ }
+ if (is_string($sql)) $sql = str_replace('||','+',$sql);
+ $stmt = mssql_init($sql,$this->_connectionID);
+ if (!$stmt) return $sql;
+ return array($sql,$stmt);
+ }
+
+ function _query($sql,$inputarr)
+ {
+ if (is_string($sql)) $sql = str_replace('||','+',$sql);
+ return ADODB_mssql::_query($sql,$inputarr);
+ }
+}
+
+class ADORecordset_mssqlpo extends ADORecordset_mssql {
+ var $databaseType = "mssqlpo";
+ function ADORecordset_mssqlpo($id,$mode=false)
+ {
+ $this->ADORecordset_mssql($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-mysql.inc.php b/html/phpgacl/adodb/drivers/adodb-mysql.inc.php
new file mode 100644
index 0000000..2508fd2
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-mysql.inc.php
@@ -0,0 +1,765 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+ MySQL code that does not support transactions. Use mysqlt if you need transactions.
+ Requires mysql client. Works on Windows and Unix.
+
+ 28 Feb 2001: MetaColumns bug fix - suggested by Freek Dijkstra (phpeverywhere@macfreek.com)
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_MYSQL_LAYER")) {
+ define("_ADODB_MYSQL_LAYER", 1 );
+
+class ADODB_mysql extends ADOConnection {
+ var $databaseType = 'mysql';
+ var $dataProvider = 'mysql';
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $metaTablesSQL = "SHOW TABLES";
+ var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $hasLimit = true;
+ var $hasMoveFirst = true;
+ var $hasGenID = true;
+ var $isoDates = true; // accepts dates in ISO format
+ var $sysDate = 'CURDATE()';
+ var $sysTimeStamp = 'NOW()';
+ var $hasTransactions = false;
+ var $forceNewConnect = false;
+ var $poorAffectedRows = true;
+ var $clientFlags = 0;
+ var $substr = "substring";
+ var $nameQuote = '`'; /// string to use to quote identifiers and names
+
+ function ADODB_mysql()
+ {
+ if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
+ }
+
+ function ServerInfo()
+ {
+ $arr['description'] = ADOConnection::GetOne("select version()");
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " IFNULL($field, $ifNull) "; // if MySQL
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $save = $this->metaTablesSQL;
+ if ($showSchema && is_string($showSchema)) {
+ $this->metaTablesSQL .= " from $showSchema";
+ }
+
+ if ($mask) {
+ $mask = $this->qstr($mask);
+ $this->metaTablesSQL .= " like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ $this->metaTablesSQL = $save;
+ return $ret;
+ }
+
+
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ // get index details
+ $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
+
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return $false;
+ }
+
+ $indexes = array ();
+
+ // parse index data into array
+ while ($row = $rs->FetchRow()) {
+ if ($primary == FALSE AND $row[2] == 'PRIMARY') {
+ continue;
+ }
+
+ if (!isset($indexes[$row[2]])) {
+ $indexes[$row[2]] = array(
+ 'unique' => ($row[1] == 0),
+ 'columns' => array()
+ );
+ }
+
+ $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
+ }
+
+ // sort columns by order in the index
+ foreach ( array_keys ($indexes) as $index )
+ {
+ ksort ($indexes[$index]['columns']);
+ }
+
+ return $indexes;
+ }
+
+
+ // if magic quotes disabled, use mysql_real_escape_string()
+ function qstr($s,$magic_quotes=false)
+ {
+ if (!$magic_quotes) {
+
+ if (ADODB_PHPVER >= 0x4300) {
+ if (is_resource($this->_connectionID))
+ return "'".mysql_real_escape_string($s,$this->_connectionID)."'";
+ }
+ if ($this->replaceQuote[0] == '\\'){
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ }
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+ return "'$s'";
+ }
+
+ function _insertid()
+ {
+ return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
+ //return mysql_insert_id($this->_connectionID);
+ }
+
+ function GetOne($sql,$inputarr=false)
+ {
+ if (strncasecmp($sql,'sele',4) == 0) {
+ $rs =& $this->SelectLimit($sql,1,-1,$inputarr);
+ if ($rs) {
+ $rs->Close();
+ if ($rs->EOF) return false;
+ return reset($rs->fields);
+ }
+ } else {
+ return ADOConnection::GetOne($sql,$inputarr);
+ }
+ return false;
+ }
+
+ function BeginTrans()
+ {
+ if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
+ }
+
+ function _affectedrows()
+ {
+ return mysql_affected_rows($this->_connectionID);
+ }
+
+ // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
+ // Reference on Last_Insert_ID on the recommended way to simulate sequences
+ var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
+ var $_genSeqSQL = "create table %s (id int not null)";
+ var $_genSeq2SQL = "insert into %s values (%s)";
+ var $_dropSeqSQL = "drop table %s";
+
+ function CreateSequence($seqname='adodbseq',$startID=1)
+ {
+ if (empty($this->_genSeqSQL)) return false;
+ $u = strtoupper($seqname);
+
+ $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ if (!$ok) return false;
+ return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+ }
+
+
+ function GenID($seqname='adodbseq',$startID=1)
+ {
+ // post-nuke sets hasGenID to false
+ if (!$this->hasGenID) return false;
+
+ $savelog = $this->_logsql;
+ $this->_logsql = false;
+ $getnext = sprintf($this->_genIDSQL,$seqname);
+ $holdtransOK = $this->_transOK; // save the current status
+ $rs = @$this->Execute($getnext);
+ if (!$rs) {
+ if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
+ $u = strtoupper($seqname);
+ $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+ $rs = $this->Execute($getnext);
+ }
+ $this->genID = mysql_insert_id($this->_connectionID);
+
+ if ($rs) $rs->Close();
+
+ $this->_logsql = $savelog;
+ return $this->genID;
+ }
+
+ function &MetaDatabases()
+ {
+ $qid = mysql_list_dbs($this->_connectionID);
+ $arr = array();
+ $i = 0;
+ $max = mysql_num_rows($qid);
+ while ($i < $max) {
+ $db = mysql_tablename($qid,$i);
+ if ($db != 'mysql') $arr[] = $db;
+ $i += 1;
+ }
+ return $arr;
+ }
+
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = 'DATE_FORMAT('.$col.",'";
+ $concat = false;
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ $ch = $fmt[$i];
+ switch($ch) {
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ /** FALL THROUGH */
+ case '-':
+ case '/':
+ $s .= $ch;
+ break;
+
+ case 'Y':
+ case 'y':
+ $s .= '%Y';
+ break;
+ case 'M':
+ $s .= '%b';
+ break;
+
+ case 'm':
+ $s .= '%m';
+ break;
+ case 'D':
+ case 'd':
+ $s .= '%d';
+ break;
+
+ case 'Q':
+ case 'q':
+ $s .= "'),Quarter($col)";
+
+ if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
+ else $s .= ",('";
+ $concat = true;
+ break;
+
+ case 'H':
+ $s .= '%H';
+ break;
+
+ case 'h':
+ $s .= '%I';
+ break;
+
+ case 'i':
+ $s .= '%i';
+ break;
+
+ case 's':
+ $s .= '%s';
+ break;
+
+ case 'a':
+ case 'A':
+ $s .= '%p';
+ break;
+
+ case 'w':
+ $s .= '%w';
+ break;
+
+ case 'l':
+ $s .= '%W';
+ break;
+ }
+ }
+ $s.="')";
+ if ($concat) $s = "CONCAT($s)";
+ return $s;
+ }
+
+
+ // returns concatenated string
+ // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
+
+ // suggestion by andrew005@mnogo.ru
+ $s = implode(',',$arr);
+ if (strlen($s) > 0) return "CONCAT($s)";
+ else return '';
+ }
+
+ function OffsetDate($dayFraction,$date=false)
+ {
+ if (!$date) $date = $this->sysDate;
+ return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
+ }
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!empty($this->port)) $argHostname .= ":".$this->port;
+
+ if (ADODB_PHPVER >= 0x4300)
+ $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
+ $this->forceNewConnect,$this->clientFlags);
+ else if (ADODB_PHPVER >= 0x4200)
+ $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
+ $this->forceNewConnect);
+ else
+ $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
+
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!empty($this->port)) $argHostname .= ":".$this->port;
+
+ if (ADODB_PHPVER >= 0x4300)
+ $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
+ else
+ $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($this->autoRollback) $this->RollbackTrans();
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ $this->forceNewConnect = true;
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+ }
+
+ function &MetaColumns($table)
+ {
+ $this->_findschema($table,$schema);
+ if ($schema) {
+ $dbName = $this->database;
+ $this->SelectDB($schema);
+ }
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+
+ if ($schema) {
+ $this->SelectDB($dbName);
+ }
+
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!is_object($rs)) {
+ $false = false;
+ return $false;
+ }
+
+ $retarr = array();
+ while (!$rs->EOF){
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $type = $rs->fields[1];
+
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $arr = explode(",",$query_array[2]);
+ $fld->enums = $arr;
+ $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
+ $fld->max_length = ($zlen > 0) ? $zlen : 1;
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
+
+ if (!$fld->binary) {
+ $d = $rs->fields[4];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
+ } else {
+ $fld->has_default = false;
+ }
+ }
+
+ if ($save == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+ return $retarr;
+ }
+
+ // returns true or false
+ function SelectDB($dbName)
+ {
+ $this->database = $dbName;
+ if ($this->_connectionID) {
+ return @mysql_select_db($dbName,$this->_connectionID);
+ }
+ else return false;
+ }
+
+ // parameters use PostgreSQL convention, not MySQL
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
+ {
+ $offsetStr =($offset>=0) ? "$offset," : '';
+ // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
+ if ($nrows < 0) $nrows = '18446744073709551615';
+
+ if ($secs)
+ $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
+ else
+ $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
+ return $rs;
+ }
+
+ // returns queryID or false
+ function _query($sql,$inputarr)
+ {
+ //global $ADODB_COUNTRECS;
+ //if($ADODB_COUNTRECS)
+ return mysql_query($sql,$this->_connectionID);
+ //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
+ }
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+
+ if ($this->_logsql) return $this->_errorMsg;
+ if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error();
+ else $this->_errorMsg = @mysql_error($this->_connectionID);
+ return $this->_errorMsg;
+ }
+
+ /* Returns: the last error number from previous database operation */
+ function ErrorNo()
+ {
+ if ($this->_logsql) return $this->_errorCode;
+ if (empty($this->_connectionID)) return @mysql_errno();
+ else return @mysql_errno($this->_connectionID);
+ }
+
+ // returns true or false
+ function _close()
+ {
+ @mysql_close($this->_connectionID);
+ $this->_connectionID = false;
+ }
+
+
+ /*
+ * Maximum size of C field
+ */
+ function CharMax()
+ {
+ return 255;
+ }
+
+ /*
+ * Maximum size of X field
+ */
+ function TextMax()
+ {
+ return 4294967295;
+ }
+
+ // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
+ function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE )
+ {
+ if ( !empty($owner) ) {
+ $table = "$owner.$table";
+ }
+ $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
+ $create_sql = $a_create_table[1];
+
+ $matches = array();
+ $foreign_keys = array();
+ if ( preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches) ) {
+ $num_keys = count($matches[0]);
+ for ( $i = 0; $i < $num_keys; $i ++ ) {
+ $my_field = explode('`, `', $matches[1][$i]);
+ $ref_table = $matches[2][$i];
+ $ref_field = explode('`, `', $matches[3][$i]);
+
+ if ( $upper ) {
+ $ref_table = strtoupper($ref_table);
+ }
+
+ $foreign_keys[$ref_table] = array();
+ $num_fields = count($my_field);
+ for ( $j = 0; $j < $num_fields; $j ++ ) {
+ if ( $asociative ) {
+ $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
+ } else {
+ $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
+ }
+ }
+ }
+ }
+ return $foreign_keys;
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+
+class ADORecordSet_mysql extends ADORecordSet{
+
+ var $databaseType = "mysql";
+ var $canSeek = true;
+
+ function ADORecordSet_mysql($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function _initrs()
+ {
+ //GLOBAL $ADODB_COUNTRECS;
+ // $this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1;
+ $this->_numOfRows = @mysql_num_rows($this->_queryID);
+ $this->_numOfFields = @mysql_num_fields($this->_queryID);
+ }
+
+ function &FetchField($fieldOffset = -1)
+ {
+ if ($fieldOffset != -1) {
+ $o = @mysql_fetch_field($this->_queryID, $fieldOffset);
+ $f = @mysql_field_flags($this->_queryID,$fieldOffset);
+ $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com)
+ //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
+ $o->binary = (strpos($f,'binary')!== false);
+ }
+ else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
+ $o = @mysql_fetch_field($this->_queryID);
+ $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com)
+ //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
+ }
+
+ return $o;
+ }
+
+ function &GetRowAssoc($upper=true)
+ {
+ if ($this->fetchMode == MYSQL_ASSOC && !$upper) return $this->fields;
+ $row =& ADORecordSet::GetRowAssoc($upper);
+ return $row;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ // added @ by "Michael William Miller" <mille562@pilot.msu.edu>
+ if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function _seek($row)
+ {
+ if ($this->_numOfRows == 0) return false;
+ return @mysql_data_seek($this->_queryID,$row);
+ }
+
+ function MoveNext()
+ {
+ //return adodb_movenext($this);
+ //if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
+ if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
+ return false;
+ }
+
+ function _fetch()
+ {
+ $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
+ return is_array($this->fields);
+ }
+
+ function _close() {
+ @mysql_free_result($this->_queryID);
+ $this->_queryID = false;
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'STRING':
+ case 'CHAR':
+ case 'VARCHAR':
+ case 'TINYBLOB':
+ case 'TINYTEXT':
+ case 'ENUM':
+ case 'SET':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ case 'LONGTEXT':
+ case 'MEDIUMTEXT':
+ return 'X';
+
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
+ case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+
+ case 'YEAR':
+ case 'DATE': return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP': return 'T';
+
+ case 'INT':
+ case 'INTEGER':
+ case 'BIGINT':
+ case 'TINYINT':
+ case 'MEDIUMINT':
+ case 'SMALLINT':
+
+ if (!empty($fieldobj->primary_key)) return 'R';
+ else return 'I';
+
+ default: return 'N';
+ }
+ }
+
+}
+
+class ADORecordSet_ext_mysql extends ADORecordSet_mysql {
+ function ADORecordSet_ext_mysql($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function MoveNext()
+ {
+ return @adodb_movenext($this);
+ }
+}
+
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-mysqli.inc.php b/html/phpgacl/adodb/drivers/adodb-mysqli.inc.php
new file mode 100644
index 0000000..9ec316e
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-mysqli.inc.php
@@ -0,0 +1,905 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+ MySQL code that does not support transactions. Use mysqlt if you need transactions.
+ Requires mysql client. Works on Windows and Unix.
+
+21 October 2003: MySQLi extension implementation by Arjen de Rijke (a.de.rijke@xs4all.nl)
+Based on adodb 3.40
+*/
+
+// security - hide paths
+//if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_MYSQLI_LAYER")) {
+ define("_ADODB_MYSQLI_LAYER", 1 );
+
+ if (!defined('MYSQLI_READ_DEFAULT_GROUP')) define('MYSQLI_READ_DEFAULT_GROUP',1);
+
+ // disable adodb extension - currently incompatible.
+ global $ADODB_EXTENSION; $ADODB_EXTENSION = false;
+
+class ADODB_mysqli extends ADOConnection {
+ var $databaseType = 'mysqli';
+ var $dataProvider = 'native';
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $metaTablesSQL = "SHOW TABLES";
+ var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $hasLimit = true;
+ var $hasMoveFirst = true;
+ var $hasGenID = true;
+ var $isoDates = true; // accepts dates in ISO format
+ var $sysDate = 'CURDATE()';
+ var $sysTimeStamp = 'NOW()';
+ var $hasTransactions = true;
+ var $forceNewConnect = false;
+ var $poorAffectedRows = true;
+ var $clientFlags = 0;
+ var $substr = "substring";
+ var $port = false;
+ var $socket = false;
+ var $_bindInputArray = false;
+ var $nameQuote = '`'; /// string to use to quote identifiers and names
+ var $optionFlags = array(array(MYSQLI_READ_DEFAULT_GROUP,0));
+
+ function ADODB_mysqli()
+ {
+ // if(!extension_loaded("mysqli"))
+ ;//trigger_error("You must have the mysqli extension installed.", E_USER_ERROR);
+
+ }
+
+
+ // returns true or false
+ // To add: parameter int $port,
+ // parameter string $socket
+ function _connect($argHostname = NULL,
+ $argUsername = NULL,
+ $argPassword = NULL,
+ $argDatabasename = NULL, $persist=false)
+ {
+ if(!extension_loaded("mysqli")) {
+ return null;
+ }
+ $this->_connectionID = @mysqli_init();
+
+ if (is_null($this->_connectionID)) {
+ // mysqli_init only fails if insufficient memory
+ if ($this->debug)
+ ADOConnection::outp("mysqli_init() failed : " . $this->ErrorMsg());
+ return false;
+ }
+ /*
+ I suggest a simple fix which would enable adodb and mysqli driver to
+ read connection options from the standard mysql configuration file
+ /etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com>
+ */
+ foreach($this->optionFlags as $arr) {
+ mysqli_options($this->_connectionID,$arr[0],$arr[1]);
+ }
+
+ if (!empty($this->port)) $argHostname .= ":".$this->port;
+ $ok = mysqli_real_connect($this->_connectionID,
+ $argHostname,
+ $argUsername,
+ $argPassword,
+ $argDatabasename,
+ $this->port,
+ $this->socket,
+ $this->clientFlags);
+
+ if ($ok) {
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ } else {
+ if ($this->debug)
+ ADOConnection::outp("Could't connect : " . $this->ErrorMsg());
+ return false;
+ }
+ }
+
+ // returns true or false
+ // How to force a persistent connection
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
+
+ }
+
+ // When is this used? Close old connection first?
+ // In _connect(), check $this->forceNewConnect?
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ $this->forceNewConnect = true;
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " IFNULL($field, $ifNull) "; // if MySQL
+ }
+
+ function ServerInfo()
+ {
+ $arr['description'] = $this->GetOne("select version()");
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->Execute('SET AUTOCOMMIT=0');
+ $this->Execute('BEGIN');
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('COMMIT');
+ $this->Execute('SET AUTOCOMMIT=1');
+ return true;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('ROLLBACK');
+ $this->Execute('SET AUTOCOMMIT=1');
+ return true;
+ }
+
+ // if magic quotes disabled, use mysql_real_escape_string()
+ // From readme.htm:
+ // Quotes a string to be sent to the database. The $magic_quotes_enabled
+ // parameter may look funny, but the idea is if you are quoting a
+ // string extracted from a POST/GET variable, then
+ // pass get_magic_quotes_gpc() as the second parameter. This will
+ // ensure that the variable is not quoted twice, once by qstr and once
+ // by the magic_quotes_gpc.
+ //
+ //Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc());
+ function qstr($s, $magic_quotes = false)
+ {
+ if (!$magic_quotes) {
+ if (PHP_VERSION >= 5)
+ return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";
+
+ if ($this->replaceQuote[0] == '\\')
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ }
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+ return "'$s'";
+ }
+
+ function _insertid()
+ {
+ $result = @mysqli_insert_id($this->_connectionID);
+ if ($result == -1){
+ if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : " . $this->ErrorMsg());
+ }
+ return $result;
+ }
+
+ // Only works for INSERT, UPDATE and DELETE query's
+ function _affectedrows()
+ {
+ $result = @mysqli_affected_rows($this->_connectionID);
+ if ($result == -1) {
+ if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : " . $this->ErrorMsg());
+ }
+ return $result;
+ }
+
+ // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
+ // Reference on Last_Insert_ID on the recommended way to simulate sequences
+ var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
+ var $_genSeqSQL = "create table %s (id int not null)";
+ var $_genSeq2SQL = "insert into %s values (%s)";
+ var $_dropSeqSQL = "drop table %s";
+
+ function CreateSequence($seqname='adodbseq',$startID=1)
+ {
+ if (empty($this->_genSeqSQL)) return false;
+ $u = strtoupper($seqname);
+
+ $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ if (!$ok) return false;
+ return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+ }
+
+ function GenID($seqname='adodbseq',$startID=1)
+ {
+ // post-nuke sets hasGenID to false
+ if (!$this->hasGenID) return false;
+
+ $getnext = sprintf($this->_genIDSQL,$seqname);
+ $holdtransOK = $this->_transOK; // save the current status
+ $rs = @$this->Execute($getnext);
+ if (!$rs) {
+ if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
+ $u = strtoupper($seqname);
+ $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+ $rs = $this->Execute($getnext);
+ }
+ $this->genID = mysqli_insert_id($this->_connectionID);
+
+ if ($rs) $rs->Close();
+
+ return $this->genID;
+ }
+
+ function &MetaDatabases()
+ {
+ $query = "SHOW DATABASES";
+ $ret =& $this->Execute($query);
+ if ($ret && is_object($ret)){
+ $arr = array();
+ while (!$ret->EOF){
+ $db = $ret->Fields('Database');
+ if ($db != 'mysql') $arr[] = $db;
+ $ret->MoveNext();
+ }
+ return $arr;
+ }
+ return $ret;
+ }
+
+
+ function &MetaIndexes ($table, $primary = FALSE)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ // get index details
+ $rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
+
+ // restore fetchmode
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return $false;
+ }
+
+ $indexes = array ();
+
+ // parse index data into array
+ while ($row = $rs->FetchRow()) {
+ if ($primary == FALSE AND $row[2] == 'PRIMARY') {
+ continue;
+ }
+
+ if (!isset($indexes[$row[2]])) {
+ $indexes[$row[2]] = array(
+ 'unique' => ($row[1] == 0),
+ 'columns' => array()
+ );
+ }
+
+ $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
+ }
+
+ // sort columns by order in the index
+ foreach ( array_keys ($indexes) as $index )
+ {
+ ksort ($indexes[$index]['columns']);
+ }
+
+ return $indexes;
+ }
+
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = 'DATE_FORMAT('.$col.",'";
+ $concat = false;
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= '%Y';
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "'),Quarter($col)";
+
+ if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
+ else $s .= ",('";
+ $concat = true;
+ break;
+ case 'M':
+ $s .= '%b';
+ break;
+
+ case 'm':
+ $s .= '%m';
+ break;
+ case 'D':
+ case 'd':
+ $s .= '%d';
+ break;
+
+ case 'H':
+ $s .= '%H';
+ break;
+
+ case 'h':
+ $s .= '%I';
+ break;
+
+ case 'i':
+ $s .= '%i';
+ break;
+
+ case 's':
+ $s .= '%s';
+ break;
+
+ case 'a':
+ case 'A':
+ $s .= '%p';
+ break;
+
+ case 'w':
+ $s .= '%w';
+ break;
+
+ case 'l':
+ $s .= '%W';
+ break;
+
+ default:
+
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $ch;
+ break;
+ }
+ }
+ $s.="')";
+ if ($concat) $s = "CONCAT($s)";
+ return $s;
+ }
+
+ // returns concatenated string
+ // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
+ function Concat()
+ {
+ $s = "";
+ $arr = func_get_args();
+
+ // suggestion by andrew005@mnogo.ru
+ $s = implode(',',$arr);
+ if (strlen($s) > 0) return "CONCAT($s)";
+ else return '';
+ }
+
+ // dayFraction is a day in floating point
+ function OffsetDate($dayFraction,$date=false)
+ {
+ if (!$date)
+ $date = $this->sysDate;
+ return "from_unixtime(unix_timestamp($date)+($dayFraction)*24*3600)";
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $save = $this->metaTablesSQL;
+ if ($showSchema && is_string($showSchema)) {
+ $this->metaTablesSQL .= " from $showSchema";
+ }
+
+ if ($mask) {
+ $mask = $this->qstr($mask);
+ $this->metaTablesSQL .= " like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ $this->metaTablesSQL = $save;
+ return $ret;
+ }
+
+ // "Innox - Juan Carlos Gonzalez" <jgonzalez#innox.com.mx>
+ function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $asociative = FALSE )
+ {
+ if ( !empty($owner) ) {
+ $table = "$owner.$table";
+ }
+ $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
+ $create_sql = $a_create_table[1];
+
+ $matches = array();
+ $foreign_keys = array();
+ if ( preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches) ) {
+ $num_keys = count($matches[0]);
+ for ( $i = 0; $i < $num_keys; $i ++ ) {
+ $my_field = explode('`, `', $matches[1][$i]);
+ $ref_table = $matches[2][$i];
+ $ref_field = explode('`, `', $matches[3][$i]);
+
+ if ( $upper ) {
+ $ref_table = strtoupper($ref_table);
+ }
+
+ $foreign_keys[$ref_table] = array();
+ $num_fields = count($my_field);
+ for ( $j = 0; $j < $num_fields; $j ++ ) {
+ if ( $asociative ) {
+ $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
+ } else {
+ $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
+ }
+ }
+ }
+ }
+ return $foreign_keys;
+ }
+
+ function &MetaColumns($table)
+ {
+ $false = false;
+ if (!$this->metaColumnsSQL)
+ return $false;
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false)
+ $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!is_object($rs))
+ return $false;
+
+ $retarr = array();
+ while (!$rs->EOF) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $type = $rs->fields[1];
+
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = max(array_map("strlen",explode(",",$query_array[2]))) - 2; // PHP >= 4.0.6
+ $fld->max_length = ($fld->max_length == 0 ? 1 : $fld->max_length);
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
+
+ if (!$fld->binary) {
+ $d = $rs->fields[4];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
+ } else {
+ $fld->has_default = false;
+ }
+ }
+
+ if ($save == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+ return $retarr;
+ }
+
+ // returns true or false
+ function SelectDB($dbName)
+ {
+// $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
+ $this->databaseName = $dbName;
+ if ($this->_connectionID) {
+ $result = @mysqli_select_db($this->_connectionID, $dbName);
+ if (!$result) {
+ ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg());
+ }
+ return $result;
+ }
+ return false;
+ }
+
+ // parameters use PostgreSQL convention, not MySQL
+ function &SelectLimit($sql,
+ $nrows = -1,
+ $offset = -1,
+ $inputarr = false,
+ $arg3 = false,
+ $secs = 0)
+ {
+ $offsetStr = ($offset >= 0) ? "$offset," : '';
+ if ($nrows < 0) $nrows = '18446744073709551615';
+
+ if ($secs)
+ $rs =& $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
+ else
+ $rs =& $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr , $arg3);
+
+ return $rs;
+ }
+
+
+ function Prepare($sql)
+ {
+ return $sql;
+
+ $stmt = $this->_connectionID->prepare($sql);
+ if (!$stmt) {
+ echo $this->ErrorMsg();
+ return $sql;
+ }
+ return array($sql,$stmt);
+ }
+
+
+ // returns queryID or false
+ function _query($sql, $inputarr)
+ {
+ global $ADODB_COUNTRECS;
+
+ if (is_array($sql)) {
+ $stmt = $sql[1];
+ $a = '';
+ foreach($inputarr as $k => $v) {
+ if (is_string($v)) $a .= 's';
+ else if (is_integer($v)) $a .= 'i';
+ else $a .= 'd';
+ }
+
+ $fnarr =& array_merge( array($stmt,$a) , $inputarr);
+ $ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
+
+ $ret = mysqli_stmt_execute($stmt);
+ return $ret;
+ }
+ if (!$mysql_res = mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
+ if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
+ return false;
+ }
+
+ return $mysql_res;
+ }
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+ if (empty($this->_connectionID))
+ $this->_errorMsg = @mysqli_connect_error();
+ else
+ $this->_errorMsg = @mysqli_error($this->_connectionID);
+ return $this->_errorMsg;
+ }
+
+ /* Returns: the last error number from previous database operation */
+ function ErrorNo()
+ {
+ if (empty($this->_connectionID))
+ return @mysqli_connect_errno();
+ else
+ return @mysqli_errno($this->_connectionID);
+ }
+
+ // returns true or false
+ function _close()
+ {
+ @mysqli_close($this->_connectionID);
+ $this->_connectionID = false;
+ }
+
+ /*
+ * Maximum size of C field
+ */
+ function CharMax()
+ {
+ return 255;
+ }
+
+ /*
+ * Maximum size of X field
+ */
+ function TextMax()
+ {
+ return 4294967295;
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_mysqli extends ADORecordSet{
+
+ var $databaseType = "mysqli";
+ var $canSeek = true;
+
+ function ADORecordSet_mysqli($queryID, $mode = false)
+ {
+ if ($mode === false)
+ {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM:
+ $this->fetchMode = MYSQLI_NUM;
+ break;
+ case ADODB_FETCH_ASSOC:
+ $this->fetchMode = MYSQLI_ASSOC;
+ break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQLI_BOTH;
+ break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+
+ $this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1;
+ $this->_numOfFields = @mysqli_num_fields($this->_queryID);
+ }
+
+ function &FetchField($fieldOffset = -1)
+ {
+ $fieldnr = $fieldOffset;
+ if ($fieldOffset != -1) {
+ $fieldOffset = mysqli_field_seek($this->_queryID, $fieldnr);
+ }
+ $o = mysqli_fetch_field($this->_queryID);
+ return $o;
+ }
+
+ function &GetRowAssoc($upper = true)
+ {
+ if ($this->fetchMode == MYSQLI_ASSOC && !$upper)
+ return $this->fields;
+ $row =& ADORecordSet::GetRowAssoc($upper);
+ return $row;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode != MYSQLI_NUM)
+ return @$this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i = 0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function _seek($row)
+ {
+ if ($this->_numOfRows == 0)
+ return false;
+
+ if ($row < 0)
+ return false;
+
+ mysqli_data_seek($this->_queryID, $row);
+ $this->EOF = false;
+ return true;
+ }
+
+ // 10% speedup to move MoveNext to child class
+ // This is the only implementation that works now (23-10-2003).
+ // Other functions return no or the wrong results.
+ function MoveNext()
+ {
+ if ($this->EOF) return false;
+ $this->_currentRow++;
+ $this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
+
+ if (is_array($this->fields)) return true;
+ $this->EOF = true;
+ return false;
+ }
+
+ function _fetch()
+ {
+ $this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);
+ return is_array($this->fields);
+ }
+
+ function _close()
+ {
+ mysqli_free_result($this->_queryID);
+ $this->_queryID = false;
+ }
+
+/*
+
+0 = MYSQLI_TYPE_DECIMAL
+1 = MYSQLI_TYPE_CHAR
+1 = MYSQLI_TYPE_TINY
+2 = MYSQLI_TYPE_SHORT
+3 = MYSQLI_TYPE_LONG
+4 = MYSQLI_TYPE_FLOAT
+5 = MYSQLI_TYPE_DOUBLE
+6 = MYSQLI_TYPE_NULL
+7 = MYSQLI_TYPE_TIMESTAMP
+8 = MYSQLI_TYPE_LONGLONG
+9 = MYSQLI_TYPE_INT24
+10 = MYSQLI_TYPE_DATE
+11 = MYSQLI_TYPE_TIME
+12 = MYSQLI_TYPE_DATETIME
+13 = MYSQLI_TYPE_YEAR
+14 = MYSQLI_TYPE_NEWDATE
+247 = MYSQLI_TYPE_ENUM
+248 = MYSQLI_TYPE_SET
+249 = MYSQLI_TYPE_TINY_BLOB
+250 = MYSQLI_TYPE_MEDIUM_BLOB
+251 = MYSQLI_TYPE_LONG_BLOB
+252 = MYSQLI_TYPE_BLOB
+253 = MYSQLI_TYPE_VAR_STRING
+254 = MYSQLI_TYPE_STRING
+255 = MYSQLI_TYPE_GEOMETRY
+*/
+
+ function MetaType($t, $len = -1, $fieldobj = false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+
+ $len = -1; // mysql max_length is not accurate
+ switch (strtoupper($t)) {
+ case 'STRING':
+ case 'CHAR':
+ case 'VARCHAR':
+ case 'TINYBLOB':
+ case 'TINYTEXT':
+ case 'ENUM':
+ case 'SET':
+
+ case MYSQLI_TYPE_TINY_BLOB :
+ case MYSQLI_TYPE_CHAR :
+ case MYSQLI_TYPE_STRING :
+ case MYSQLI_TYPE_ENUM :
+ case MYSQLI_TYPE_SET :
+ case 253 :
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ case 'LONGTEXT':
+ case 'MEDIUMTEXT':
+ return 'X';
+
+
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
+ case 'IMAGE':
+ case 'LONGBLOB':
+ case 'BLOB':
+ case 'MEDIUMBLOB':
+
+ case MYSQLI_TYPE_BLOB :
+ case MYSQLI_TYPE_LONG_BLOB :
+ case MYSQLI_TYPE_MEDIUM_BLOB :
+
+ return !empty($fieldobj->binary) ? 'B' : 'X';
+ case 'YEAR':
+ case 'DATE':
+ case MYSQLI_TYPE_DATE :
+ case MYSQLI_TYPE_YEAR :
+
+ return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP':
+
+ case MYSQLI_TYPE_DATETIME :
+ case MYSQLI_TYPE_NEWDATE :
+ case MYSQLI_TYPE_TIME :
+ case MYSQLI_TYPE_TIMESTAMP :
+
+ return 'T';
+
+ case 'INT':
+ case 'INTEGER':
+ case 'BIGINT':
+ case 'TINYINT':
+ case 'MEDIUMINT':
+ case 'SMALLINT':
+
+ case MYSQLI_TYPE_INT24 :
+ case MYSQLI_TYPE_LONG :
+ case MYSQLI_TYPE_LONGLONG :
+ case MYSQLI_TYPE_SHORT :
+ case MYSQLI_TYPE_TINY :
+
+ if (!empty($fieldobj->primary_key)) return 'R';
+
+ return 'I';
+
+
+ // Added floating-point types
+ // Maybe not necessery.
+ case 'FLOAT':
+ case 'DOUBLE':
+ // case 'DOUBLE PRECISION':
+ case 'DECIMAL':
+ case 'DEC':
+ case 'FIXED':
+ default:
+ //if (!is_numeric($t)) echo "<p>--- Error in type matching $t -----</p>";
+ return 'N';
+ }
+ } // function
+
+
+} // rs class
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-mysqlt.inc.php b/html/phpgacl/adodb/drivers/adodb-mysqlt.inc.php
new file mode 100644
index 0000000..d7670d2
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-mysqlt.inc.php
@@ -0,0 +1,136 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+ MySQL code that supports transactions. For MySQL 3.23 or later.
+ Code from James Poon <jpoon88@yahoo.com>
+
+ Requires mysql client. Works on Windows and Unix.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php");
+
+
+class ADODB_mysqlt extends ADODB_mysql {
+ var $databaseType = 'mysqlt';
+ var $ansiOuter = true; // for Version 3.23.17 or later
+ var $hasTransactions = true;
+ var $autoRollback = true; // apparently mysql does not autorollback properly
+
+ function ADODB_mysqlt()
+ {
+ global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_';
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->Execute('SET AUTOCOMMIT=0');
+ $this->Execute('BEGIN');
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('COMMIT');
+ $this->Execute('SET AUTOCOMMIT=1');
+ return true;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->Execute('ROLLBACK');
+ $this->Execute('SET AUTOCOMMIT=1');
+ return true;
+ }
+
+ function RowLock($tables,$where,$flds='1 as ignore')
+ {
+ if ($this->transCnt==0) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables where $where for update");
+ }
+
+}
+
+class ADORecordSet_mysqlt extends ADORecordSet_mysql{
+ var $databaseType = "mysqlt";
+
+ function ADORecordSet_mysqlt($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = MYSQL_BOTH; break;
+ }
+
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function MoveNext()
+ {
+ if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
+ return false;
+ }
+}
+
+class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt {
+
+ function ADORecordSet_ext_mysqlt($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default:
+ $this->fetchMode = MYSQL_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function MoveNext()
+ {
+ return adodb_movenext($this);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-netezza.inc.php b/html/phpgacl/adodb/drivers/adodb-netezza.inc.php
new file mode 100644
index 0000000..f42ae55
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-netezza.inc.php
@@ -0,0 +1,170 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+
+ First cut at the Netezza Driver by Josh Eldridge joshuae74#hotmail.com
+ Based on the previous postgres drivers.
+ http://www.netezza.com/
+ Major Additions/Changes:
+ MetaDatabasesSQL, MetaTablesSQL, MetaColumnsSQL
+ Note: You have to have admin privileges to access the system tables
+ Removed non-working keys code (Netezza has no concept of keys)
+ Fixed the way data types and lengths are returned in MetaColumns()
+ as well as added the default lengths for certain types
+ Updated public variables for Netezza
+ Still need to remove blob functions, as Netezza doesn't suppport blob
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR.'/drivers/adodb-postgres64.inc.php');
+
+class ADODB_netezza extends ADODB_postgres64 {
+ var $databaseType = 'netezza';
+ var $dataProvider = 'netezza';
+ var $hasInsertID = false;
+ var $_resultid = false;
+ var $concat_operator='||';
+ var $random = 'random';
+ var $metaDatabasesSQL = "select objname from _v_object_data where objtype='database' order by 1";
+ var $metaTablesSQL = "select objname from _v_object_data where objtype='table' order by 1";
+ var $isoDates = true; // accepts dates in ISO format
+ var $sysDate = "CURRENT_DATE";
+ var $sysTimeStamp = "CURRENT_TIMESTAMP";
+ var $blobEncodeType = 'C';
+ var $metaColumnsSQL = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
+ var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum";
+ // netezza doesn't have keys. it does have distributions, so maybe this is
+ // something that can be pulled from the system tables
+ var $metaKeySQL = "";
+ var $hasAffectedRows = true;
+ var $hasLimit = true;
+ var $true = 't'; // string that represents TRUE for a database
+ var $false = 'f'; // string that represents FALSE for a database
+ var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
+ var $ansiOuter = true;
+ var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4
+ // http://bugs.php.net/bug.php?id=25404
+
+
+ function ADODB_netezza()
+ {
+
+ }
+
+ function &MetaColumns($table,$upper=true)
+ {
+
+ // Changed this function to support Netezza which has no concept of keys
+ // could posisbly work on other things from the system table later.
+
+ global $ADODB_FETCH_MODE;
+
+ $table = strtolower($table);
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rs === false) return false;
+
+ $retarr = array();
+ while (!$rs->EOF) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+
+ // since we're returning type and length as one string,
+ // split them out here.
+
+ if ($first = strstr($rs->fields[1], "(")) {
+ $fld->max_length = trim($first, "()");
+ } else {
+ $fld->max_length = -1;
+ }
+
+ if ($first = strpos($rs->fields[1], "(")) {
+ $fld->type = substr($rs->fields[1], 0, $first);
+ } else {
+ $fld->type = $rs->fields[1];
+ }
+
+ switch ($fld->type) {
+ case "byteint":
+ case "boolean":
+ $fld->max_length = 1;
+ break;
+ case "smallint":
+ $fld->max_length = 2;
+ break;
+ case "integer":
+ case "numeric":
+ case "date":
+ $fld->max_length = 4;
+ break;
+ case "bigint":
+ case "time":
+ case "timestamp":
+ $fld->max_length = 8;
+ break;
+ case "timetz":
+ case "time with time zone":
+ $fld->max_length = 12;
+ break;
+ }
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
+
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_netezza extends ADORecordSet_postgres64
+{
+ var $databaseType = "netezza";
+ var $canSeek = true;
+
+ function ADORecordSet_netezza($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
+
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = PGSQL_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ // _initrs modified to disable blob handling
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+ $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1;
+ $this->_numOfFields = @pg_numfields($this->_queryID);
+ }
+
+}
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-oci8.inc.php b/html/phpgacl/adodb/drivers/adodb-oci8.inc.php
new file mode 100644
index 0000000..94a80ae
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-oci8.inc.php
@@ -0,0 +1,1477 @@
+<?php
+/*
+
+ version V4.65 22 July 2005 (c) 2000-2005 John Lim. All rights reserved.
+
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Code contributed by George Fourlanos <fou@infomap.gr>
+
+ 13 Nov 2000 jlim - removed all ora_* references.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+NLS_Date_Format
+Allows you to use a date format other than the Oracle Lite default. When a literal
+character string appears where a date value is expected, the Oracle Lite database
+tests the string to see if it matches the formats of Oracle, SQL-92, or the value
+specified for this parameter in the POLITE.INI file. Setting this parameter also
+defines the default format used in the TO_CHAR or TO_DATE functions when no
+other format string is supplied.
+
+For Oracle the default is dd-mon-yy or dd-mon-yyyy, and for SQL-92 the default is
+yy-mm-dd or yyyy-mm-dd.
+
+Using 'RR' in the format forces two-digit years less than or equal to 49 to be
+interpreted as years in the 21st century (2000–2049), and years over 50 as years in
+the 20th century (1950–1999). Setting the RR format as the default for all two-digit
+year entries allows you to become year-2000 compliant. For example:
+NLS_DATE_FORMAT='RR-MM-DD'
+
+You can also modify the date format using the ALTER SESSION command.
+*/
+
+# define the LOB descriptor type for the given type
+# returns false if no LOB descriptor
+function oci_lob_desc($type) {
+ switch ($type) {
+ case OCI_B_BFILE: $result = OCI_D_FILE; break;
+ case OCI_B_CFILEE: $result = OCI_D_FILE; break;
+ case OCI_B_CLOB: $result = OCI_D_LOB; break;
+ case OCI_B_BLOB: $result = OCI_D_LOB; break;
+ case OCI_B_ROWID: $result = OCI_D_ROWID; break;
+ default: $result = false; break;
+ }
+ return $result;
+}
+
+class ADODB_oci8 extends ADOConnection {
+ var $databaseType = 'oci8';
+ var $dataProvider = 'oci8';
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $concat_operator='||';
+ var $sysDate = "TRUNC(SYSDATE)";
+ var $sysTimeStamp = 'SYSDATE';
+ var $metaDatabasesSQL = "SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN') ORDER BY 1";
+ var $_stmt;
+ var $_commit = OCI_COMMIT_ON_SUCCESS;
+ var $_initdate = true; // init date to YYYY-MM-DD
+ var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')";
+ var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net
+ var $_bindInputArray = true;
+ var $hasGenID = true;
+ var $_genIDSQL = "SELECT (%s.nextval) FROM DUAL";
+ var $_genSeqSQL = "CREATE SEQUENCE %s START WITH %s";
+ var $_dropSeqSQL = "DROP SEQUENCE %s";
+ var $hasAffectedRows = true;
+ var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
+ var $noNullStrings = false;
+ var $connectSID = false;
+ var $_bind = false;
+ var $_hasOCIFetchStatement = false;
+ var $_getarray = false; // currently not working
+ var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER
+ var $session_sharing_force_blob = false; // alter session on updateblob if set to true
+ var $firstrows = true; // enable first rows optimization on SelectLimit()
+ var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit.
+ var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
+ var $useDBDateFormatForTextInput=false;
+ var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true)
+ var $_refLOBs = array();
+
+ // var $ansiOuter = true; // if oracle9
+
+ function ADODB_oci8()
+ {
+ $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
+ if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_';
+ }
+
+ /* Function &MetaColumns($table) added by smondino@users.sourceforge.net*/
+ function &MetaColumns($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!$rs) {
+ return $false;
+ }
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+ $fld->scale = $rs->fields[3];
+ if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
+ $fld->type ='INT';
+ $fld->max_length = $rs->fields[4];
+ }
+ $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
+ $fld->binary = (strpos($fld->type,'BLOB') !== false);
+ $fld->default_value = $rs->fields[6];
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if (empty($retarr))
+ return $false;
+ else
+ return $retarr;
+ }
+
+ function Time()
+ {
+ $rs =& $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual");
+ if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields));
+
+ return false;
+ }
+
+/*
+
+ Multiple modes of connection are supported:
+
+ a. Local Database
+ $conn->Connect(false,'scott','tiger');
+
+ b. From tnsnames.ora
+ $conn->Connect(false,'scott','tiger',$tnsname);
+ $conn->Connect($tnsname,'scott','tiger');
+
+ c. Server + service name
+ $conn->Connect($serveraddress,'scott,'tiger',$service_name);
+
+ d. Server + SID
+ $conn->connectSID = true;
+ $conn->Connect($serveraddress,'scott,'tiger',$SID);
+
+
+Example TNSName:
+---------------
+NATSOFT.DOMAIN =
+ (DESCRIPTION =
+ (ADDRESS_LIST =
+ (ADDRESS = (PROTOCOL = TCP)(HOST = kermit)(PORT = 1523))
+ )
+ (CONNECT_DATA =
+ (SERVICE_NAME = natsoft.domain)
+ )
+ )
+
+ There are 3 connection modes, 0 = non-persistent, 1 = persistent, 2 = force new connection
+
+*/
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0)
+ {
+ if (!function_exists('OCIPLogon')) return null;
+
+
+ $this->_errorMsg = false;
+ $this->_errorCode = false;
+
+ if($argHostname) { // added by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
+ if (empty($argDatabasename)) $argDatabasename = $argHostname;
+ else {
+ if(strpos($argHostname,":")) {
+ $argHostinfo=explode(":",$argHostname);
+ $argHostname=$argHostinfo[0];
+ $argHostport=$argHostinfo[1];
+ } else {
+ $argHostport="1521";
+ }
+
+ if ($this->connectSID) {
+ $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
+ .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
+ } else
+ $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
+ .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
+ }
+ }
+
+ //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
+ if ($mode==1) {
+ $this->_connectionID = ($this->charSet) ?
+ OCIPLogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCIPLogon($argUsername,$argPassword, $argDatabasename, $this->charSet)
+ ;
+ if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID);
+ } else if ($mode==2) {
+ $this->_connectionID = ($this->charSet) ?
+ OCINLogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCINLogon($argUsername,$argPassword, $argDatabasename, $this->charSet);
+
+ } else {
+ $this->_connectionID = ($this->charSet) ?
+ OCILogon($argUsername,$argPassword, $argDatabasename)
+ :
+ OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet);
+ }
+ if (!$this->_connectionID) return false;
+ if ($this->_initdate) {
+ $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
+ }
+
+ // looks like:
+ // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production
+ // $vers = OCIServerVersion($this->_connectionID);
+ // if (strpos($vers,'8i') !== false) $this->ansiOuter = true;
+ return true;
+ }
+
+ function ServerInfo()
+ {
+ $arr['compat'] = $this->GetOne('select value from sys.database_compatible_level');
+ $arr['description'] = @OCIServerVersion($this->_connectionID);
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1);
+ }
+
+ // returns true or false
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2);
+ }
+
+ function _affectedrows()
+ {
+ if (is_resource($this->_stmt)) return @OCIRowCount($this->_stmt);
+ return 0;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " NVL($field, $ifNull) "; // if Oracle
+ }
+
+ // format and return date string in database date format
+ function DBDate($d)
+ {
+ if (empty($d) && $d !== 0) return 'null';
+
+ if (is_string($d)) $d = ADORecordSet::UnixDate($d);
+ return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->NLS_DATE_FORMAT."')";
+ }
+
+
+ // format and return date string in database timestamp format
+ function DBTimeStamp($ts)
+ {
+ if (empty($ts) && $ts !== 0) return 'null';
+ if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts);
+ return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')";
+ }
+
+ function RowLock($tables,$where,$flds='1 as ignore')
+ {
+ if ($this->autoCommit) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables where $where for update");
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ if ($mask) {
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr(strtoupper($mask));
+ $this->metaTablesSQL .= " AND table_name like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ // Mark Newnham
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ // get index details
+ $table = strtoupper($table);
+
+ // get Primary index
+ $primary_key = '';
+
+ $false = false;
+ $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table));
+ if ($row = $rs->FetchRow())
+ $primary_key = $row[1]; //constraint_name
+
+ if ($primary==TRUE && $primary_key=='') {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false; //There is no primary key
+ }
+
+ $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table));
+
+
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+
+ $indexes = array ();
+ // parse index data into array
+
+ while ($row = $rs->FetchRow()) {
+ if ($primary && $row[0] != $primary_key) continue;
+ if (!isset($indexes[$row[0]])) {
+ $indexes[$row[0]] = array(
+ 'unique' => ($row[1] == 'UNIQUE'),
+ 'columns' => array()
+ );
+ }
+ $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3];
+ }
+
+ // sort columns by order in the index
+ foreach ( array_keys ($indexes) as $index ) {
+ ksort ($indexes[$index]['columns']);
+ }
+
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->autoCommit = false;
+ $this->_commit = OCI_DEFAULT;
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+
+ if ($this->transCnt) $this->transCnt -= 1;
+ $ret = OCIcommit($this->_connectionID);
+ $this->_commit = OCI_COMMIT_ON_SUCCESS;
+ $this->autoCommit = true;
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $ret = OCIrollback($this->_connectionID);
+ $this->_commit = OCI_COMMIT_ON_SUCCESS;
+ $this->autoCommit = true;
+ return $ret;
+ }
+
+
+ function SelectDB($dbName)
+ {
+ return false;
+ }
+
+ function ErrorMsg()
+ {
+ if ($this->_errorMsg !== false) return $this->_errorMsg;
+
+ if (is_resource($this->_stmt)) $arr = @OCIerror($this->_stmt);
+ if (empty($arr)) {
+ $arr = @OCIerror($this->_connectionID);
+ if ($arr === false) $arr = @OCIError();
+ if ($arr === false) return '';
+ }
+ $this->_errorMsg = $arr['message'];
+ $this->_errorCode = $arr['code'];
+ return $this->_errorMsg;
+ }
+
+ function ErrorNo()
+ {
+ if ($this->_errorCode !== false) return $this->_errorCode;
+
+ if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt);
+ if (empty($arr)) {
+ $arr = @OCIError($this->_connectionID);
+ if ($arr == false) $arr = @OCIError();
+ if ($arr == false) return '';
+ }
+
+ $this->_errorMsg = $arr['message'];
+ $this->_errorCode = $arr['code'];
+
+ return $arr['code'];
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = 'TO_CHAR('.$col.",'";
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= 'YYYY';
+ break;
+ case 'Q':
+ case 'q':
+ $s .= 'Q';
+ break;
+
+ case 'M':
+ $s .= 'Mon';
+ break;
+
+ case 'm':
+ $s .= 'MM';
+ break;
+ case 'D':
+ case 'd':
+ $s .= 'DD';
+ break;
+
+ case 'H':
+ $s.= 'HH24';
+ break;
+
+ case 'h':
+ $s .= 'HH';
+ break;
+
+ case 'i':
+ $s .= 'MI';
+ break;
+
+ case 's':
+ $s .= 'SS';
+ break;
+
+ case 'a':
+ case 'A':
+ $s .= 'AM';
+ break;
+
+ case 'w':
+ $s .= 'D';
+ break;
+
+ case 'l':
+ $s .= 'DAY';
+ break;
+
+ default:
+ // handle escape characters...
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ if (strpos('-/.:;, ',$ch) !== false) $s .= $ch;
+ else $s .= '"'.$ch.'"';
+
+ }
+ }
+ return $s. "')";
+ }
+
+
+ /*
+ This algorithm makes use of
+
+ a. FIRST_ROWS hint
+ The FIRST_ROWS hint explicitly chooses the approach to optimize response time,
+ that is, minimum resource usage to return the first row. Results will be returned
+ as soon as they are identified.
+
+ b. Uses rownum tricks to obtain only the required rows from a given offset.
+ As this uses complicated sql statements, we only use this if the $offset >= 100.
+ This idea by Tomas V V Cox.
+
+ This implementation does not appear to work with oracle 8.0.5 or earlier. Comment
+ out this function then, and the slower SelectLimit() in the base class will be used.
+ */
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ // seems that oracle only supports 1 hint comment in 8i
+ if ($this->firstrows) {
+ if (strpos($sql,'/*+') !== false)
+ $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql);
+ else
+ $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql);
+ }
+
+ if ($offset < $this->selectOffsetAlg1) {
+ if ($nrows > 0) {
+ if ($offset > 0) $nrows += $offset;
+ //$inputarr['adodb_rownum'] = $nrows;
+ if ($this->databaseType == 'oci8po') {
+ $sql = "select * from (".$sql.") where rownum <= ?";
+ } else {
+ $sql = "select * from (".$sql.") where rownum <= :adodb_offset";
+ }
+ $inputarr['adodb_offset'] = $nrows;
+ $nrows = -1;
+ }
+ // note that $nrows = 0 still has to work ==> no rows returned
+
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ return $rs;
+
+ } else {
+ // Algorithm by Tomas V V Cox, from PEAR DB oci8.php
+
+ // Let Oracle return the name of the columns
+ $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL";
+
+ $false = false;
+ if (! $stmt_arr = $this->Prepare($q_fields)) {
+ return $false;
+ }
+ $stmt = $stmt_arr[1];
+
+ if (is_array($inputarr)) {
+ foreach($inputarr as $k => $v) {
+ if (is_array($v)) {
+ if (sizeof($v) == 2) // suggested by g.giunta@libero.
+ OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]);
+ else
+ OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]);
+ } else {
+ $len = -1;
+ if ($v === ' ') $len = 1;
+ if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again
+ $bindarr[$k] = $v;
+ } else { // dynamic sql, so rebind every time
+ OCIBindByName($stmt,":$k",$inputarr[$k],$len);
+ }
+ }
+ }
+ }
+
+ if (!OCIExecute($stmt, OCI_DEFAULT)) {
+ OCIFreeStatement($stmt);
+ return $false;
+ }
+
+ $ncols = OCINumCols($stmt);
+ for ( $i = 1; $i <= $ncols; $i++ ) {
+ $cols[] = '"'.OCIColumnName($stmt, $i).'"';
+ }
+ $result = false;
+
+ OCIFreeStatement($stmt);
+ $fields = implode(',', $cols);
+ $nrows += $offset;
+ $offset += 1; // in Oracle rownum starts at 1
+
+ if ($this->databaseType == 'oci8po') {
+ $sql = "SELECT $fields FROM".
+ "(SELECT rownum as adodb_rownum, $fields FROM".
+ " ($sql) WHERE rownum <= ?".
+ ") WHERE adodb_rownum >= ?";
+ } else {
+ $sql = "SELECT $fields FROM".
+ "(SELECT rownum as adodb_rownum, $fields FROM".
+ " ($sql) WHERE rownum <= :adodb_nrows".
+ ") WHERE adodb_rownum >= :adodb_offset";
+ }
+ $inputarr['adodb_nrows'] = $nrows;
+ $inputarr['adodb_offset'] = $offset;
+
+ if ($secs2cache>0) $rs =& $this->CacheExecute($secs2cache, $sql,$inputarr);
+ else $rs =& $this->Execute($sql,$inputarr);
+ return $rs;
+ }
+
+ }
+
+ /**
+ * Usage:
+ * Store BLOBs and CLOBs
+ *
+ * Example: to store $var in a blob
+ *
+ * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())');
+ * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB');
+ *
+ * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'.
+ *
+ * to get length of LOB:
+ * select DBMS_LOB.GETLENGTH(ablob) from TABLE
+ *
+ * If you are using CURSOR_SHARING = force, it appears this will case a segfault
+ * under oracle 8.1.7.0. Run:
+ * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
+ * before UpdateBlob() then...
+ */
+
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+
+ //if (strlen($val) < 4000) return $this->Execute("UPDATE $table SET $column=:blob WHERE $where",array('blob'=>$val)) != false;
+
+ switch(strtoupper($blobtype)) {
+ default: ADOConnection::outp("<b>UpdateBlob</b>: Unknown blobtype=$blobtype"); return false;
+ case 'BLOB': $type = OCI_B_BLOB; break;
+ case 'CLOB': $type = OCI_B_CLOB; break;
+ }
+
+ if ($this->databaseType == 'oci8po')
+ $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?";
+ else
+ $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob";
+
+ $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB);
+ $arr['blob'] = array($desc,-1,$type);
+ if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT');
+ $commit = $this->autoCommit;
+ if ($commit) $this->BeginTrans();
+ $rs = $this->Execute($sql,$arr);
+ if ($rez = !empty($rs)) $desc->save($val);
+ $desc->free();
+ if ($commit) $this->CommitTrans();
+ if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=FORCE');
+
+ if ($rez) $rs->Close();
+ return $rez;
+ }
+
+ /**
+ * Usage: store file pointed to by $var in a blob
+ */
+ function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ switch(strtoupper($blobtype)) {
+ default: ADOConnection::outp( "<b>UpdateBlob</b>: Unknown blobtype=$blobtype"); return false;
+ case 'BLOB': $type = OCI_B_BLOB; break;
+ case 'CLOB': $type = OCI_B_CLOB; break;
+ }
+
+ if ($this->databaseType == 'oci8po')
+ $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?";
+ else
+ $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob";
+
+ $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB);
+ $arr['blob'] = array($desc,-1,$type);
+
+ $this->BeginTrans();
+ $rs = ADODB_oci8::Execute($sql,$arr);
+ if ($rez = !empty($rs)) $desc->savefile($val);
+ $desc->free();
+ $this->CommitTrans();
+
+ if ($rez) $rs->Close();
+ return $rez;
+ }
+
+ /**
+ * Execute SQL
+ *
+ * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text)
+ * @param [inputarr] holds the input data to bind to. Null elements will be set to null.
+ * @return RecordSet or false
+ */
+ function &Execute($sql,$inputarr=false)
+ {
+ if ($this->fnExecute) {
+ $fn = $this->fnExecute;
+ $ret =& $fn($this,$sql,$inputarr);
+ if (isset($ret)) return $ret;
+ }
+ if ($inputarr) {
+ #if (!is_array($inputarr)) $inputarr = array($inputarr);
+
+ $element0 = reset($inputarr);
+
+ # is_object check because oci8 descriptors can be passed in
+ if (is_array($element0) && !is_object(reset($element0))) {
+ if (is_string($sql))
+ $stmt = $this->Prepare($sql);
+ else
+ $stmt = $sql;
+
+ foreach($inputarr as $arr) {
+ $ret =& $this->_Execute($stmt,$arr);
+ if (!$ret) return $ret;
+ }
+ } else {
+ $ret =& $this->_Execute($sql,$inputarr);
+ }
+
+ } else {
+ $ret =& $this->_Execute($sql,false);
+ }
+
+ return $ret;
+ }
+
+ /*
+ Example of usage:
+
+ $stmt = $this->Prepare('insert into emp (empno, ename) values (:empno, :ename)');
+ */
+ function Prepare($sql,$cursor=false)
+ {
+ static $BINDNUM = 0;
+
+ $stmt = OCIParse($this->_connectionID,$sql);
+
+ if (!$stmt) return false;
+
+ $BINDNUM += 1;
+
+ $sttype = @OCIStatementType($stmt);
+ if ($sttype == 'BEGIN' || $sttype == 'DECLARE') {
+ return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false);
+ }
+ return array($sql,$stmt,0,$BINDNUM);
+ }
+
+ /*
+ Call an oracle stored procedure and returns a cursor variable as a recordset.
+ Concept by Robert Tuttle robert@ud.com
+
+ Example:
+ Note: we return a cursor variable in :RS2
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS2); END;",'RS2');
+
+ $rs = $db->ExecuteCursor(
+ "BEGIN :RS2 = adodb.getdata(:VAR1); END;",
+ 'RS2',
+ array('VAR1' => 'Mr Bean'));
+
+ */
+ function &ExecuteCursor($sql,$cursorName='rs',$params=false)
+ {
+ if (is_array($sql)) $stmt = $sql;
+ else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor
+
+ if (is_array($stmt) && sizeof($stmt) >= 5) {
+ $hasref = true;
+ $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR);
+ if ($params) {
+ foreach($params as $k => $v) {
+ $this->Parameter($stmt,$params[$k], $k);
+ }
+ }
+ } else
+ $hasref = false;
+
+ $rs =& $this->Execute($stmt);
+ if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]);
+ else if ($hasref) $rs->_refcursor = $stmt[4];
+ return $rs;
+ }
+
+ /*
+ Bind a variable -- very, very fast for executing repeated statements in oracle.
+ Better than using
+ for ($i = 0; $i < $max; $i++) {
+ $p1 = ?; $p2 = ?; $p3 = ?;
+ $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)",
+ array($p1,$p2,$p3));
+ }
+
+ Usage:
+ $stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");
+ $DB->Bind($stmt, $p1);
+ $DB->Bind($stmt, $p2);
+ $DB->Bind($stmt, $p3);
+ for ($i = 0; $i < $max; $i++) {
+ $p1 = ?; $p2 = ?; $p3 = ?;
+ $DB->Execute($stmt);
+ }
+
+ Some timings:
+ ** Test table has 3 cols, and 1 index. Test to insert 1000 records
+ Time 0.6081s (1644.60 inserts/sec) with direct OCIParse/OCIExecute
+ Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute
+ Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute
+
+ Now if PHP only had batch/bulk updating like Java or PL/SQL...
+
+ Note that the order of parameters differs from OCIBindByName,
+ because we default the names to :0, :1, :2
+ */
+ function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false)
+ {
+
+ if (!is_array($stmt)) return false;
+
+ if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) {
+ return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type);
+ }
+
+ if ($name == false) {
+ if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type);
+ else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator
+ $stmt[2] += 1;
+ } else if (oci_lob_desc($type)) {
+ if ($this->debug) {
+ ADOConnection::outp("<b>Bind</b>: name = $name");
+ }
+ //we have to create a new Descriptor here
+ $numlob = count($this->_refLOBs);
+ $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type));
+ $this->_refLOBs[$numlob]['TYPE'] = $isOutput;
+
+ $tmp = &$this->_refLOBs[$numlob]['LOB'];
+ $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type);
+ if ($this->debug) {
+ ADOConnection::outp("<b>Bind</b>: descriptor has been allocated, var (".$name.") binded");
+ }
+
+ // if type is input then write data to lob now
+ if ($isOutput == false) {
+ $var = $this->BlobEncode($var);
+ $tmp->WriteTemporary($var);
+ $this->_refLOBs[$numlob]['VAR'] = &$var;
+ if ($this->debug) {
+ ADOConnection::outp("<b>Bind</b>: LOB has been written to temp");
+ }
+ } else {
+ $this->_refLOBs[$numlob]['VAR'] = &$var;
+ }
+ $rez = $tmp;
+ } else {
+ if ($this->debug)
+ ADOConnection::outp("<b>Bind</b>: name = $name");
+
+ if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type);
+ else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator
+ }
+
+ return $rez;
+ }
+
+ function Param($name,$type=false)
+ {
+ return ':'.$name;
+ }
+
+ /*
+ Usage:
+ $stmt = $db->Prepare('select * from table where id =:myid and group=:group');
+ $db->Parameter($stmt,$id,'myid');
+ $db->Parameter($stmt,$group,'group');
+ $db->Execute($stmt);
+
+ @param $stmt Statement returned by Prepare() or PrepareSP().
+ @param $var PHP variable to bind to
+ @param $name Name of stored procedure variable name to bind to.
+ @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8.
+ @param [$maxLen] Holds an maximum length of the variable.
+ @param [$type] The data type of $var. Legal values depend on driver.
+
+ See OCIBindByName documentation at php.net.
+ */
+ function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
+ {
+ if ($this->debug) {
+ $prefix = ($isOutput) ? 'Out' : 'In';
+ $ztype = (empty($type)) ? 'false' : $type;
+ ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);");
+ }
+ return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput);
+ }
+
+ /*
+ returns query ID if successful, otherwise false
+ this version supports:
+
+ 1. $db->execute('select * from table');
+
+ 2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
+ $db->execute($prepared_statement, array(1,2,3));
+
+ 3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3));
+
+ 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)');
+ $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3);
+ $db->execute($stmt);
+ */
+ function _query($sql,$inputarr)
+ {
+ if (is_array($sql)) { // is prepared sql
+ $stmt = $sql[1];
+
+ // we try to bind to permanent array, so that OCIBindByName is persistent
+ // and carried out once only - note that max array element size is 4000 chars
+ if (is_array($inputarr)) {
+ $bindpos = $sql[3];
+ if (isset($this->_bind[$bindpos])) {
+ // all tied up already
+ $bindarr = &$this->_bind[$bindpos];
+ } else {
+ // one statement to bind them all
+ $bindarr = array();
+ foreach($inputarr as $k => $v) {
+ $bindarr[$k] = $v;
+ OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000);
+ }
+ $this->_bind[$bindpos] = &$bindarr;
+ }
+ }
+ } else {
+ $stmt=OCIParse($this->_connectionID,$sql);
+ }
+
+ $this->_stmt = $stmt;
+ if (!$stmt) return false;
+
+ if (defined('ADODB_PREFETCH_ROWS')) @OCISetPrefetch($stmt,ADODB_PREFETCH_ROWS);
+
+ if (is_array($inputarr)) {
+ foreach($inputarr as $k => $v) {
+ if (is_array($v)) {
+ if (sizeof($v) == 2) // suggested by g.giunta@libero.
+ OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]);
+ else
+ OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]);
+
+ if ($this->debug==99) echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'<br>';
+ } else {
+ $len = -1;
+ if ($v === ' ') $len = 1;
+ if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again
+ $bindarr[$k] = $v;
+ } else { // dynamic sql, so rebind every time
+ OCIBindByName($stmt,":$k",$inputarr[$k],$len);
+ }
+ }
+ }
+ }
+
+ $this->_errorMsg = false;
+ $this->_errorCode = false;
+ if (OCIExecute($stmt,$this->_commit)) {
+//OCIInternalDebug(1);
+ if (count($this -> _refLOBs) > 0) {
+
+ foreach ($this -> _refLOBs as $key => $value) {
+ if ($this -> _refLOBs[$key]['TYPE'] == true) {
+ $tmp = $this -> _refLOBs[$key]['LOB'] -> load();
+ if ($this -> debug) {
+ ADOConnection::outp("<b>OUT LOB</b>: LOB has been loaded. <br>");
+ }
+ //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp;
+ $this -> _refLOBs[$key]['VAR'] = $tmp;
+ } else {
+ $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']);
+ $this -> _refLOBs[$key]['LOB']->free();
+ unset($this -> _refLOBs[$key]);
+ if ($this->debug) {
+ ADOConnection::outp("<b>IN LOB</b>: LOB has been saved. <br>");
+ }
+ }
+ }
+ }
+
+ switch (@OCIStatementType($stmt)) {
+ case "SELECT":
+ return $stmt;
+
+ case 'DECLARE':
+ case "BEGIN":
+ if (is_array($sql) && !empty($sql[4])) {
+ $cursor = $sql[4];
+ if (is_resource($cursor)) {
+ $ok = OCIExecute($cursor);
+ return $cursor;
+ }
+ return $stmt;
+ } else {
+ if (is_resource($stmt)) {
+ OCIFreeStatement($stmt);
+ return true;
+ }
+ return $stmt;
+ }
+ break;
+ default :
+ // ociclose -- no because it could be used in a LOB?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if (!$this->_connectionID) return;
+
+ if (!$this->autoCommit) OCIRollback($this->_connectionID);
+ if (count($this->_refLOBs) > 0) {
+ foreach ($this ->_refLOBs as $key => $value) {
+ $this->_refLOBs[$key]['LOB']->free();
+ unset($this->_refLOBs[$key]);
+ }
+ }
+ OCILogoff($this->_connectionID);
+
+ $this->_stmt = false;
+ $this->_connectionID = false;
+ }
+
+ function MetaPrimaryKeys($table, $owner=false,$internalKey=false)
+ {
+ if ($internalKey) return array('ROWID');
+
+ // tested with oracle 8.1.7
+ $table = strtoupper($table);
+ if ($owner) {
+ $owner_clause = "AND ((a.OWNER = b.OWNER) AND (a.OWNER = UPPER('$owner')))";
+ $ptab = 'ALL_';
+ } else {
+ $owner_clause = '';
+ $ptab = 'USER_';
+ }
+ $sql = "
+SELECT /*+ RULE */ distinct b.column_name
+ FROM {$ptab}CONSTRAINTS a
+ , {$ptab}CONS_COLUMNS b
+ WHERE ( UPPER(b.table_name) = ('$table'))
+ AND (UPPER(a.table_name) = ('$table') and a.constraint_type = 'P')
+ $owner_clause
+ AND (a.constraint_name = b.constraint_name)";
+
+ $rs = $this->Execute($sql);
+ if ($rs && !$rs->EOF) {
+ $arr =& $rs->GetArray();
+ $a = array();
+ foreach($arr as $v) {
+ $a[] = reset($v);
+ }
+ return $a;
+ }
+ else return false;
+ }
+
+ // http://gis.mit.edu/classes/11.521/sqlnotes/referential_integrity.html
+ function MetaForeignKeys($table, $owner=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $table = $this->qstr(strtoupper($table));
+ if (!$owner) {
+ $owner = $this->user;
+ $tabp = 'user_';
+ } else
+ $tabp = 'all_';
+
+ $owner = ' and owner='.$this->qstr(strtoupper($owner));
+
+ $sql =
+"select constraint_name,r_owner,r_constraint_name
+ from {$tabp}constraints
+ where constraint_type = 'R' and table_name = $table $owner";
+
+ $constraints =& $this->GetArray($sql);
+ $arr = false;
+ foreach($constraints as $constr) {
+ $cons = $this->qstr($constr[0]);
+ $rowner = $this->qstr($constr[1]);
+ $rcons = $this->qstr($constr[2]);
+ $cols = $this->GetArray("select column_name from {$tabp}cons_columns where constraint_name=$cons $owner order by position");
+ $tabcol = $this->GetArray("select table_name,column_name from {$tabp}cons_columns where owner=$rowner and constraint_name=$rcons order by position");
+
+ if ($cols && $tabcol)
+ for ($i=0, $max=sizeof($cols); $i < $max; $i++) {
+ $arr[$tabcol[$i][0]] = $cols[$i][0].'='.$tabcol[$i][1];
+ }
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ return $arr;
+ }
+
+
+ function CharMax()
+ {
+ return 4000;
+ }
+
+ function TextMax()
+ {
+ return 4000;
+ }
+
+ /**
+ * Quotes a string.
+ * An example is $db->qstr("Don't bother",magic_quotes_runtime());
+ *
+ * @param s the string to quote
+ * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
+ * This undoes the stupidity of magic quotes for GPC.
+ *
+ * @return quoted string to be sent back to database
+ */
+ function qstr($s,$magic_quotes=false)
+ {
+ $nofixquotes=false;
+
+ if ($this->noNullStrings && strlen($s)==0)$s = ' ';
+ if (!$magic_quotes) {
+ if ($this->replaceQuote[0] == '\\'){
+ $s = str_replace('\\','\\\\',$s);
+ }
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+
+ $s = str_replace('\\\\','\\',$s);
+ return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
+
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_oci8 extends ADORecordSet {
+
+ var $databaseType = 'oci8';
+ var $bind=false;
+ var $_fieldobjs;
+
+ //var $_arr = false;
+
+ function ADORecordset_oci8($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_NUM:
+ default:
+ $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ }
+
+ $this->adodbFetchMode = $mode;
+ $this->_queryID = $queryID;
+ }
+
+
+ function Init()
+ {
+ if ($this->_inited) return;
+
+ $this->_inited = true;
+ if ($this->_queryID) {
+
+ $this->_currentRow = 0;
+ @$this->_initrs();
+ $this->EOF = !$this->_fetch();
+
+ /*
+ // based on idea by Gaetano Giunta to detect unusual oracle errors
+ // see http://phplens.com/lens/lensforum/msgs.php?id=6771
+ $err = OCIError($this->_queryID);
+ if ($err && $this->connection->debug) ADOConnection::outp($err);
+ */
+
+ if (!is_array($this->fields)) {
+ $this->_numOfRows = 0;
+ $this->fields = array();
+ }
+ } else {
+ $this->fields = array();
+ $this->_numOfRows = 0;
+ $this->_numOfFields = 0;
+ $this->EOF = true;
+ }
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = -1;
+ $this->_numOfFields = OCInumcols($this->_queryID);
+ if ($this->_numOfFields>0) {
+ $this->_fieldobjs = array();
+ $max = $this->_numOfFields;
+ for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i);
+ }
+ }
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+
+ function &_FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $fieldOffset += 1;
+ $fld->name =OCIcolumnname($this->_queryID, $fieldOffset);
+ $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
+ $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
+ if ($fld->type == 'NUMBER') {
+ $p = OCIColumnPrecision($this->_queryID, $fieldOffset);
+ $sc = OCIColumnScale($this->_queryID, $fieldOffset);
+ if ($p != 0 && $sc == 0) $fld->type = 'INT';
+ //echo " $this->name ($p.$sc) ";
+ }
+ return $fld;
+ }
+
+ /* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */
+ function &FetchField($fieldOffset = -1)
+ {
+ return $this->_fieldobjs[$fieldOffset];
+ }
+
+
+ /*
+ // 10% speedup to move MoveNext to child class
+ function _MoveNext()
+ {
+ //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this);
+
+ if ($this->EOF) return false;
+
+ $this->_currentRow++;
+ if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode))
+ return true;
+ $this->EOF = true;
+
+ return false;
+ } */
+
+
+ function MoveNext()
+ {
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
+ return false;
+ }
+
+ /*
+ # does not work as first record is retrieved in _initrs(), so is not included in GetArray()
+ function &GetArray($nRows = -1)
+ {
+ global $ADODB_OCI8_GETARRAY;
+
+ if (true || !empty($ADODB_OCI8_GETARRAY)) {
+ # does not support $ADODB_ANSI_PADDING_OFF
+
+ //OCI_RETURN_NULLS and OCI_RETURN_LOBS is set by OCIfetchstatement
+ switch($this->adodbFetchMode) {
+ case ADODB_FETCH_NUM:
+
+ $ncols = @OCIfetchstatement($this->_queryID, $results, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM);
+ $results = array_merge(array($this->fields),$results);
+ return $results;
+
+ case ADODB_FETCH_ASSOC:
+ if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break;
+
+ $ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW);
+ $results =& array_merge(array($this->fields),$assoc);
+ return $results;
+
+ default:
+ break;
+ }
+ }
+
+ $results =& ADORecordSet::GetArray($nRows);
+ return $results;
+
+ } */
+
+ /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
+ function &GetArrayLimit($nrows,$offset=-1)
+ {
+ if ($offset <= 0) {
+ $arr =& $this->GetArray($nrows);
+ return $arr;
+ }
+ for ($i=1; $i < $offset; $i++)
+ if (!@OCIFetch($this->_queryID)) return array();
+
+ if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return array();
+ $results = array();
+ $cnt = 0;
+ while (!$this->EOF && $nrows != $cnt) {
+ $results[$cnt++] = $this->fields;
+ $this->MoveNext();
+ }
+
+ return $results;
+ }
+
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ function _fetch()
+ {
+ return @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
+ }
+
+ /* close() only needs to be called if you are worried about using too much memory while your script
+ is running. All associated result memory for the specified result identifier will automatically be freed. */
+
+ function _close()
+ {
+ if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false;
+ if (!empty($this->_refcursor)) {
+ OCIFreeCursor($this->_refcursor);
+ $this->_refcursor = false;
+ }
+ @OCIFreeStatement($this->_queryID);
+ $this->_queryID = false;
+
+ }
+
+ function MetaType($t,$len=-1)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'VARCHAR2':
+ case 'CHAR':
+ case 'VARBINARY':
+ case 'BINARY':
+ case 'NCHAR':
+ case 'NVARCHAR':
+ case 'NVARCHAR2':
+ if (isset($this) && $len <= $this->blobSize) return 'C';
+
+ case 'NCLOB':
+ case 'LONG':
+ case 'LONG VARCHAR':
+ case 'CLOB':
+ return 'X';
+
+ case 'LONG RAW':
+ case 'LONG VARBINARY':
+ case 'BLOB':
+ return 'B';
+
+ case 'DATE':
+ return ($this->connection->datetime) ? 'T' : 'D';
+
+
+ case 'TIMESTAMP': return 'T';
+
+ case 'INT':
+ case 'SMALLINT':
+ case 'INTEGER':
+ return 'I';
+
+ default: return 'N';
+ }
+ }
+}
+
+class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 {
+ function ADORecordSet_ext_oci8($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ case ADODB_FETCH_NUM:
+ default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->_queryID = $queryID;
+ }
+
+ function MoveNext()
+ {
+ return adodb_movenext($this);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-oci805.inc.php b/html/phpgacl/adodb/drivers/adodb-oci805.inc.php
new file mode 100644
index 0000000..f360d10
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-oci805.inc.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Oracle 8.0.5 driver
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
+
+class ADODB_oci805 extends ADODB_oci8 {
+ var $databaseType = "oci805";
+ var $connectSID = true;
+
+ function ADODB_oci805()
+ {
+ $this->ADODB_oci8();
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ // seems that oracle only supports 1 hint comment in 8i
+ if (strpos($sql,'/*+') !== false)
+ $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql);
+ else
+ $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql);
+
+ /*
+ The following is only available from 8.1.5 because order by in inline views not
+ available before then...
+ http://www.jlcomp.demon.co.uk/faq/top_sql.html
+ if ($nrows > 0) {
+ if ($offset > 0) $nrows += $offset;
+ $sql = "select * from ($sql) where rownum <= $nrows";
+ $nrows = -1;
+ }
+ */
+
+ return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ }
+}
+
+class ADORecordset_oci805 extends ADORecordset_oci8 {
+ var $databaseType = "oci805";
+ function ADORecordset_oci805($id,$mode=false)
+ {
+ $this->ADORecordset_oci8($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-oci8po.inc.php b/html/phpgacl/adodb/drivers/adodb-oci8po.inc.php
new file mode 100644
index 0000000..64e3fb0
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-oci8po.inc.php
@@ -0,0 +1,217 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim. All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Portable version of oci8 driver, to make it more similar to other database drivers.
+ The main differences are
+
+ 1. that the OCI_ASSOC names are in lowercase instead of uppercase.
+ 2. bind variables are mapped using ? instead of :<bindvar>
+
+ Should some emulation of RecordCount() be implemented?
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php');
+
+class ADODB_oci8po extends ADODB_oci8 {
+ var $databaseType = 'oci8po';
+ var $dataProvider = 'oci8';
+ var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net
+ var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')";
+
+ function ADODB_oci8po()
+ {
+ $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200;
+ # oci8po does not support adodb extension: adodb_movenext()
+ }
+
+ function Param($name)
+ {
+ return '?';
+ }
+
+ function Prepare($sql,$cursor=false)
+ {
+ $sqlarr = explode('?',$sql);
+ $sql = $sqlarr[0];
+ for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) {
+ $sql .= ':'.($i-1) . $sqlarr[$i];
+ }
+ return ADODB_oci8::Prepare($sql,$cursor);
+ }
+
+ // emulate handling of parameters ? ?, replacing with :bind0 :bind1
+ function _query($sql,$inputarr)
+ {
+ if (is_array($inputarr)) {
+ $i = 0;
+ if (is_array($sql)) {
+ foreach($inputarr as $v) {
+ $arr['bind'.$i++] = $v;
+ }
+ } else {
+ $sqlarr = explode('?',$sql);
+ $sql = $sqlarr[0];
+ foreach($inputarr as $k => $v) {
+ $sql .= ":$k" . $sqlarr[++$i];
+ }
+ }
+ }
+ return ADODB_oci8::_query($sql,$inputarr);
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_oci8po extends ADORecordset_oci8 {
+
+ var $databaseType = 'oci8po';
+
+ function ADORecordset_oci8po($queryID,$mode=false)
+ {
+ $this->ADORecordset_oci8($queryID,$mode);
+ }
+
+ function Fields($colname)
+ {
+ if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ // lowercase field names...
+ function &_FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $fieldOffset += 1;
+ $fld->name = strtolower(OCIcolumnname($this->_queryID, $fieldOffset));
+ $fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
+ $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
+ if ($fld->type == 'NUMBER') {
+ //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
+ $sc = OCIColumnScale($this->_queryID, $fieldOffset);
+ if ($sc == 0) $fld->type = 'INT';
+ }
+ return $fld;
+ }
+ /*
+ function MoveNext()
+ {
+ if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ $this->_currentRow += 1;
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->_currentRow += 1;
+ $this->EOF = true;
+ }
+ return false;
+ }*/
+
+ // 10% speedup to move MoveNext to child class
+ function MoveNext()
+ {
+ if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ global $ADODB_ANSI_PADDING_OFF;
+ $this->_currentRow++;
+
+ if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
+ if (!empty($ADODB_ANSI_PADDING_OFF)) {
+ foreach($this->fields as $k => $v) {
+ if (is_string($v)) $this->fields[$k] = rtrim($v);
+ }
+ }
+ return true;
+ }
+ if (!$this->EOF) {
+ $this->EOF = true;
+ $this->_currentRow++;
+ }
+ return false;
+ }
+
+ /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */
+ function &GetArrayLimit($nrows,$offset=-1)
+ {
+ if ($offset <= 0) {
+ $arr = $this->GetArray($nrows);
+ return $arr;
+ }
+ for ($i=1; $i < $offset; $i++)
+ if (!@OCIFetch($this->_queryID)) {
+ $arr = array();
+ return $arr;
+ }
+ if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) {
+ $arr = array();
+ return $arr;
+ }
+ if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
+ $results = array();
+ $cnt = 0;
+ while (!$this->EOF && $nrows != $cnt) {
+ $results[$cnt++] = $this->fields;
+ $this->MoveNext();
+ }
+
+ return $results;
+ }
+
+ // Create associative array
+ function _updatefields()
+ {
+ if (ADODB_ASSOC_CASE == 2) return; // native
+
+ $arr = array();
+ $lowercase = (ADODB_ASSOC_CASE == 0);
+
+ foreach($this->fields as $k => $v) {
+ if (is_integer($k)) $arr[$k] = $v;
+ else {
+ if ($lowercase)
+ $arr[strtolower($k)] = $v;
+ else
+ $arr[strtoupper($k)] = $v;
+ }
+ }
+ $this->fields = $arr;
+ }
+
+ function _fetch()
+ {
+ $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode);
+ if ($ret) {
+ global $ADODB_ANSI_PADDING_OFF;
+
+ if ($this->fetchMode & OCI_ASSOC) $this->_updatefields();
+ if (!empty($ADODB_ANSI_PADDING_OFF)) {
+ foreach($this->fields as $k => $v) {
+ if (is_string($v)) $this->fields[$k] = rtrim($v);
+ }
+ }
+ }
+ return $ret;
+ }
+
+}
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-odbc.inc.php b/html/phpgacl/adodb/drivers/adodb-odbc.inc.php
new file mode 100644
index 0000000..f2e75f9
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-odbc.inc.php
@@ -0,0 +1,738 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Requires ODBC. Works on Windows and Unix.
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+ define("_ADODB_ODBC_LAYER", 2 );
+
+/*--------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------------*/
+
+
+class ADODB_odbc extends ADOConnection {
+ var $databaseType = "odbc";
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $dataProvider = "odbc";
+ var $hasAffectedRows = true;
+ var $binmode = ODBC_BINMODE_RETURN;
+ var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive
+ // breaking backward-compat
+ //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
+ var $_bindInputArray = false;
+ var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
+ var $_genSeqSQL = "create table %s (id integer)";
+ var $_autocommit = true;
+ var $_haserrorfunctions = true;
+ var $_has_stupid_odbc_fetch_api_change = true;
+ var $_lastAffectedRows = 0;
+ var $uCaseTables = true; // for meta* functions, uppercase table names
+
+ function ADODB_odbc()
+ {
+ $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
+ $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
+ }
+
+ // returns true or false
+ function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ global $php_errormsg;
+
+ if (!function_exists('odbc_connect')) return null;
+
+ if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
+ ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
+ }
+ if (isset($php_errormsg)) $php_errormsg = '';
+ if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
+ else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
+
+ return $this->_connectionID != false;
+ }
+
+ // returns true or false
+ function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ global $php_errormsg;
+
+ if (!function_exists('odbc_connect')) return null;
+
+ if (isset($php_errormsg)) $php_errormsg = '';
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ if ($this->debug && $argDatabasename) {
+ ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
+ }
+ // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
+ if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
+ else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
+
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
+ if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
+
+ return $this->_connectionID != false;
+ }
+
+
+ function ServerInfo()
+ {
+
+ if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
+ $dsn = strtoupper($this->host);
+ $first = true;
+ $found = false;
+
+ if (!function_exists('odbc_data_source')) return false;
+
+ while(true) {
+
+ $rez = @odbc_data_source($this->_connectionID,
+ $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
+ $first = false;
+ if (!is_array($rez)) break;
+ if (strtoupper($rez['server']) == $dsn) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) return ADOConnection::ServerInfo();
+ if (!isset($rez['version'])) $rez['version'] = '';
+ return $rez;
+ } else {
+ return ADOConnection::ServerInfo();
+ }
+ }
+
+
+ function CreateSequence($seqname='adodbseq',$start=1)
+ {
+ if (empty($this->_genSeqSQL)) return false;
+ $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ if (!$ok) return false;
+ $start -= 1;
+ return $this->Execute("insert into $seqname values($start)");
+ }
+
+ var $_dropSeqSQL = 'drop table %s';
+ function DropSequence($seqname)
+ {
+ if (empty($this->_dropSeqSQL)) return false;
+ return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
+ }
+
+ /*
+ This algorithm is not very efficient, but works even if table locking
+ is not available.
+
+ Will return false if unable to generate an ID after $MAXLOOPS attempts.
+ */
+ function GenID($seq='adodbseq',$start=1)
+ {
+ // if you have to modify the parameter below, your database is overloaded,
+ // or you need to implement generation of id's yourself!
+ $MAXLOOPS = 100;
+ //$this->debug=1;
+ while (--$MAXLOOPS>=0) {
+ $num = $this->GetOne("select id from $seq");
+ if ($num === false) {
+ $this->Execute(sprintf($this->_genSeqSQL ,$seq));
+ $start -= 1;
+ $num = '0';
+ $ok = $this->Execute("insert into $seq values($start)");
+ if (!$ok) return false;
+ }
+ $this->Execute("update $seq set id=id+1 where id=$num");
+
+ if ($this->affected_rows() > 0) {
+ $num += 1;
+ $this->genID = $num;
+ return $num;
+ }
+ }
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
+ }
+ return false;
+ }
+
+
+ function ErrorMsg()
+ {
+ if ($this->_haserrorfunctions) {
+ if ($this->_errorMsg !== false) return $this->_errorMsg;
+ if (empty($this->_connectionID)) return @odbc_errormsg();
+ return @odbc_errormsg($this->_connectionID);
+ } else return ADOConnection::ErrorMsg();
+ }
+
+ function ErrorNo()
+ {
+
+ if ($this->_haserrorfunctions) {
+ if ($this->_errorCode !== false) {
+ // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
+ return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode;
+ }
+
+ if (empty($this->_connectionID)) $e = @odbc_error();
+ else $e = @odbc_error($this->_connectionID);
+
+ // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
+ // so we check and patch
+ if (strlen($e)<=2) return 0;
+ return $e;
+ } else return ADOConnection::ErrorNo();
+ }
+
+
+
+ function BeginTrans()
+ {
+ if (!$this->hasTransactions) return false;
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->_autocommit = false;
+ return odbc_autocommit($this->_connectionID,false);
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->_autocommit = true;
+ $ret = odbc_commit($this->_connectionID);
+ odbc_autocommit($this->_connectionID,true);
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->_autocommit = true;
+ $ret = odbc_rollback($this->_connectionID);
+ odbc_autocommit($this->_connectionID,true);
+ return $ret;
+ }
+
+ function MetaPrimaryKeys($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ if ($this->uCaseTables) $table = strtoupper($table);
+ $schema = '';
+ $this->_findschema($table,$schema);
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);
+
+ if (!$qid) {
+ $ADODB_FETCH_MODE = $savem;
+ return false;
+ }
+ $rs = new ADORecordSet_odbc($qid);
+ $ADODB_FETCH_MODE = $savem;
+
+ if (!$rs) return false;
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+
+ $arr =& $rs->GetArray();
+ $rs->Close();
+ //print_r($arr);
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if ($arr[$i][3]) $arr2[] = $arr[$i][3];
+ }
+ return $arr2;
+ }
+
+
+
+ function &MetaTables($ttype=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $qid = odbc_tables($this->_connectionID);
+
+ $rs = new ADORecordSet_odbc($qid);
+
+ $ADODB_FETCH_MODE = $savem;
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+
+ $arr =& $rs->GetArray();
+ //print_r($arr);
+
+ $rs->Close();
+ $arr2 = array();
+
+ if ($ttype) {
+ $isview = strncmp($ttype,'V',1) === 0;
+ }
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if (!$arr[$i][2]) continue;
+ $type = $arr[$i][3];
+ if ($ttype) {
+ if ($isview) {
+ if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2];
+ } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
+ } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
+ }
+ return $arr2;
+ }
+
+/*
+See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp
+/ SQL data type codes /
+#define SQL_UNKNOWN_TYPE 0
+#define SQL_CHAR 1
+#define SQL_NUMERIC 2
+#define SQL_DECIMAL 3
+#define SQL_INTEGER 4
+#define SQL_SMALLINT 5
+#define SQL_FLOAT 6
+#define SQL_REAL 7
+#define SQL_DOUBLE 8
+#if (ODBCVER >= 0x0300)
+#define SQL_DATETIME 9
+#endif
+#define SQL_VARCHAR 12
+
+
+/ One-parameter shortcuts for date/time data types /
+#if (ODBCVER >= 0x0300)
+#define SQL_TYPE_DATE 91
+#define SQL_TYPE_TIME 92
+#define SQL_TYPE_TIMESTAMP 93
+
+#define SQL_UNICODE (-95)
+#define SQL_UNICODE_VARCHAR (-96)
+#define SQL_UNICODE_LONGVARCHAR (-97)
+*/
+ function ODBCTypes($t)
+ {
+ switch ((integer)$t) {
+ case 1:
+ case 12:
+ case 0:
+ case -95:
+ case -96:
+ return 'C';
+ case -97:
+ case -1: //text
+ return 'X';
+ case -4: //image
+ return 'B';
+
+ case 9:
+ case 91:
+ return 'D';
+
+ case 10:
+ case 11:
+ case 92:
+ case 93:
+ return 'T';
+
+ case 4:
+ case 5:
+ case -6:
+ return 'I';
+
+ case -11: // uniqidentifier
+ return 'R';
+ case -7: //bit
+ return 'L';
+
+ default:
+ return 'N';
+ }
+ }
+
+ function &MetaColumns($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ if ($this->uCaseTables) $table = strtoupper($table);
+ $schema = '';
+ $this->_findschema($table,$schema);
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
+ $qid2 = odbc_tables($this->_connectionID);
+ $rs = new ADORecordSet_odbc($qid2);
+ $ADODB_FETCH_MODE = $savem;
+ if (!$rs) return false;
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+ $rs->_fetch();
+
+ while (!$rs->EOF) {
+ if ($table == strtoupper($rs->fields[2])) {
+ $q = $rs->fields[0];
+ $o = $rs->fields[1];
+ break;
+ }
+ $rs->MoveNext();
+ }
+ $rs->Close();
+
+ $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
+ } */
+
+ switch ($this->databaseType) {
+ case 'access':
+ case 'vfp':
+ $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
+ break;
+
+
+ case 'db2':
+ $colname = "%";
+ $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
+ break;
+
+ default:
+ $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
+ if (empty($qid)) $qid = odbc_columns($this->_connectionID);
+ break;
+ }
+ if (empty($qid)) return $false;
+
+ $rs =& new ADORecordSet_odbc($qid);
+ $ADODB_FETCH_MODE = $savem;
+
+ if (!$rs) return $false;
+ $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
+ $rs->_fetch();
+
+ $retarr = array();
+
+ /*
+ $rs->fields indices
+ 0 TABLE_QUALIFIER
+ 1 TABLE_SCHEM
+ 2 TABLE_NAME
+ 3 COLUMN_NAME
+ 4 DATA_TYPE
+ 5 TYPE_NAME
+ 6 PRECISION
+ 7 LENGTH
+ 8 SCALE
+ 9 RADIX
+ 10 NULLABLE
+ 11 REMARKS
+ */
+ while (!$rs->EOF) {
+ // adodb_pr($rs->fields);
+ if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[3];
+ $fld->type = $this->ODBCTypes($rs->fields[4]);
+
+ // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
+ // access uses precision to store length for char/varchar
+ if ($fld->type == 'C' or $fld->type == 'X') {
+ if ($this->databaseType == 'access')
+ $fld->max_length = $rs->fields[6];
+ else if ($rs->fields[4] <= -95) // UNICODE
+ $fld->max_length = $rs->fields[7]/2;
+ else
+ $fld->max_length = $rs->fields[7];
+ } else
+ $fld->max_length = $rs->fields[7];
+ $fld->not_null = !empty($rs->fields[10]);
+ $fld->scale = $rs->fields[8];
+ $retarr[strtoupper($fld->name)] = $fld;
+ } else if (sizeof($retarr)>0)
+ break;
+ $rs->MoveNext();
+ }
+ $rs->Close(); //-- crashes 4.03pl1 -- why?
+
+ if (empty($retarr)) $retarr = false;
+ return $retarr;
+ }
+
+ function Prepare($sql)
+ {
+ if (! $this->_bindInputArray) return $sql; // no binding
+ $stmt = odbc_prepare($this->_connectionID,$sql);
+ if (!$stmt) {
+ // we don't know whether odbc driver is parsing prepared stmts, so just return sql
+ return $sql;
+ }
+ return array($sql,$stmt,false);
+ }
+
+ /* returns queryID or false */
+ function _query($sql,$inputarr=false)
+ {
+ GLOBAL $php_errormsg;
+ if (isset($php_errormsg)) $php_errormsg = '';
+ $this->_error = '';
+
+ if ($inputarr) {
+ if (is_array($sql)) {
+ $stmtid = $sql[1];
+ } else {
+ $stmtid = odbc_prepare($this->_connectionID,$sql);
+
+ if ($stmtid == false) {
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ return false;
+ }
+ }
+
+ if (! odbc_execute($stmtid,$inputarr)) {
+ //@odbc_free_result($stmtid);
+ if ($this->_haserrorfunctions) {
+ $this->_errorMsg = odbc_errormsg();
+ $this->_errorCode = odbc_error();
+ }
+ return false;
+ }
+
+ } else if (is_array($sql)) {
+ $stmtid = $sql[1];
+ if (!odbc_execute($stmtid)) {
+ //@odbc_free_result($stmtid);
+ if ($this->_haserrorfunctions) {
+ $this->_errorMsg = odbc_errormsg();
+ $this->_errorCode = odbc_error();
+ }
+ return false;
+ }
+ } else
+ $stmtid = odbc_exec($this->_connectionID,$sql);
+
+ $this->_lastAffectedRows = 0;
+ if ($stmtid) {
+ if (@odbc_num_fields($stmtid) == 0) {
+ $this->_lastAffectedRows = odbc_num_rows($stmtid);
+ $stmtid = true;
+ } else {
+ $this->_lastAffectedRows = 0;
+ odbc_binmode($stmtid,$this->binmode);
+ odbc_longreadlen($stmtid,$this->maxblobsize);
+ }
+
+ if ($this->_haserrorfunctions) {
+ $this->_errorMsg = '';
+ $this->_errorCode = 0;
+ } else
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ } else {
+ if ($this->_haserrorfunctions) {
+ $this->_errorMsg = odbc_errormsg();
+ $this->_errorCode = odbc_error();
+ } else
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
+ }
+ return $stmtid;
+ }
+
+ /*
+ Insert a null into the blob field of the table first.
+ Then use UpdateBlob to store the blob.
+
+ Usage:
+
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+ return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ $ret = @odbc_close($this->_connectionID);
+ $this->_connectionID = false;
+ return $ret;
+ }
+
+ function _affectedrows()
+ {
+ return $this->_lastAffectedRows;
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_odbc extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "odbc";
+ var $dataProvider = "odbc";
+ var $useFetchArray;
+ var $_has_stupid_odbc_fetch_api_change;
+
+ function ADORecordSet_odbc($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+
+ $this->_queryID = $id;
+
+ // the following is required for mysql odbc driver in 4.3.1 -- why?
+ $this->EOF = false;
+ $this->_currentRow = -1;
+ //$this->ADORecordSet($id);
+ }
+
+
+ // returns the field object
+ function &FetchField($fieldOffset = -1)
+ {
+
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $o->name = @odbc_field_name($this->_queryID,$off);
+ $o->type = @odbc_field_type($this->_queryID,$off);
+ $o->max_length = @odbc_field_len($this->_queryID,$off);
+ if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
+ else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
+ return $o;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+ $this->_numOfRows = ($ADODB_COUNTRECS) ? @odbc_num_rows($this->_queryID) : -1;
+ $this->_numOfFields = @odbc_num_fields($this->_queryID);
+ // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
+ if ($this->_numOfRows == 0) $this->_numOfRows = -1;
+ //$this->useFetchArray = $this->connection->useFetchArray;
+ $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
+ }
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
+ function &GetArrayLimit($nrows,$offset=-1)
+ {
+ if ($offset <= 0) {
+ $rs =& $this->GetArray($nrows);
+ return $rs;
+ }
+ $savem = $this->fetchMode;
+ $this->fetchMode = ADODB_FETCH_NUM;
+ $this->Move($offset);
+ $this->fetchMode = $savem;
+
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+
+ $results = array();
+ $cnt = 0;
+ while (!$this->EOF && $nrows != $cnt) {
+ $results[$cnt++] = $this->fields;
+ $this->MoveNext();
+ }
+
+ return $results;
+ }
+
+
+ function MoveNext()
+ {
+ if ($this->_numOfRows != 0 && !$this->EOF) {
+ $this->_currentRow++;
+
+ if ($this->_has_stupid_odbc_fetch_api_change)
+ $rez = @odbc_fetch_into($this->_queryID,$this->fields);
+ else {
+ $row = 0;
+ $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
+ }
+ if ($rez) {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+ return true;
+ }
+ }
+ $this->fields = false;
+ $this->EOF = true;
+ return false;
+ }
+
+ function _fetch()
+ {
+
+ if ($this->_has_stupid_odbc_fetch_api_change)
+ $rez = @odbc_fetch_into($this->_queryID,$this->fields);
+ else {
+ $row = 0;
+ $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
+ }
+ if ($rez) {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) {
+ $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
+ }
+ return true;
+ }
+ $this->fields = false;
+ return false;
+ }
+
+ function _close()
+ {
+ return @odbc_free_result($this->_queryID);
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-odbc_mssql.inc.php b/html/phpgacl/adodb/drivers/adodb-odbc_mssql.inc.php
new file mode 100644
index 0000000..03700f7
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-odbc_mssql.inc.php
@@ -0,0 +1,254 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ MSSQL support via ODBC. Requires ODBC. Works on Windows and Unix.
+ For Unix configuration, see http://phpbuilder.com/columns/alberto20000919.php3
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+
+
+class ADODB_odbc_mssql extends ADODB_odbc {
+ var $databaseType = 'odbc_mssql';
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d h:i:sA'";
+ var $_bindInputArray = true;
+ var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE'))";
+ var $metaColumnsSQL = "select c.name,t.name,c.length from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
+ var $hasTop = 'top'; // support mssql/interbase SELECT TOP 10 * FROM TABLE
+ var $sysDate = 'GetDate()';
+ var $sysTimeStamp = 'GetDate()';
+ var $leftOuter = '*=';
+ var $rightOuter = '=*';
+ var $substr = 'substring';
+ var $length = 'len';
+ var $ansiOuter = true; // for mssql7 or later
+ var $identitySQL = 'select @@IDENTITY'; // 'select SCOPE_IDENTITY'; # for mssql 2000
+ var $hasInsertID = true;
+ var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL OFF'; # When SET CONCAT_NULL_YIELDS_NULL is ON,
+ # concatenating a null value with a string yields a NULL result
+
+ function ADODB_odbc_mssql()
+ {
+ $this->ADODB_odbc();
+ //$this->curmode = SQL_CUR_USE_ODBC;
+ }
+
+ // crashes php...
+ function ServerInfo()
+ {
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $row = $this->GetRow("execute sp_server_info 2");
+ $ADODB_FETCH_MODE = $save;
+ if (!is_array($row)) return false;
+ $arr['description'] = $row[2];
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " ISNULL($field, $ifNull) "; // if MS SQL Server
+ }
+
+ function _insertid()
+ {
+ // SCOPE_IDENTITY()
+ // Returns the last IDENTITY value inserted into an IDENTITY column in
+ // the same scope. A scope is a module -- a stored procedure, trigger,
+ // function, or batch. Thus, two statements are in the same scope if
+ // they are in the same stored procedure, function, or batch.
+ return $this->GetOne($this->identitySQL);
+ }
+
+
+ function MetaForeignKeys($table, $owner=false, $upper=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $table = $this->qstr(strtoupper($table));
+
+ $sql =
+"select object_name(constid) as constraint_name,
+ col_name(fkeyid, fkey) as column_name,
+ object_name(rkeyid) as referenced_table_name,
+ col_name(rkeyid, rkey) as referenced_column_name
+from sysforeignkeys
+where upper(object_name(fkeyid)) = $table
+order by constraint_name, referenced_table_name, keyno";
+
+ $constraints =& $this->GetArray($sql);
+
+ $ADODB_FETCH_MODE = $save;
+
+ $arr = false;
+ foreach($constraints as $constr) {
+ //print_r($constr);
+ $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3];
+ }
+ if (!$arr) return false;
+
+ $arr2 = false;
+
+ foreach($arr as $k => $v) {
+ foreach($v as $a => $b) {
+ if ($upper) $a = strtoupper($a);
+ $arr2[$a] = $b;
+ }
+ }
+ return $arr2;
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ if ($mask) {$this->debug=1;
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr($mask);
+ $this->metaTablesSQL .= " AND name like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ function &MetaColumns($table)
+ {
+ $arr = ADOConnection::MetaColumns($table);
+ return $arr;
+ }
+
+ function _query($sql,$inputarr)
+ {
+ if (is_string($sql)) $sql = str_replace('||','+',$sql);
+ return ADODB_odbc::_query($sql,$inputarr);
+ }
+
+ // "Stein-Aksel Basma" <basma@accelero.no>
+ // tested with MSSQL 2000
+ function &MetaPrimaryKeys($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = '';
+ $this->_findschema($table,$schema);
+ //if (!$schema) $schema = $this->database;
+ if ($schema) $schema = "and k.table_catalog like '$schema%'";
+
+ $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k,
+ information_schema.table_constraints tc
+ where tc.constraint_name = k.constraint_name and tc.constraint_type =
+ 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position ";
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $a = $this->GetCol($sql);
+ $ADODB_FETCH_MODE = $savem;
+
+ if ($a && sizeof($a)>0) return $a;
+ $false = false;
+ return $false;
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ if ($nrows > 0 && $offset <= 0) {
+ $sql = preg_replace(
+ '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql);
+ $rs =& $this->Execute($sql,$inputarr);
+ } else
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+
+ return $rs;
+ }
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '+';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "datename(yyyy,$col)";
+ break;
+ case 'M':
+ $s .= "convert(char(3),$col,0)";
+ break;
+ case 'm':
+ $s .= "replace(str(month($col),2),' ','0')";
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "datename(quarter,$col)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "replace(str(day($col),2),' ','0')";
+ break;
+ case 'h':
+ $s .= "substring(convert(char(14),$col,0),13,2)";
+ break;
+
+ case 'H':
+ $s .= "replace(str(datepart(hh,$col),2),' ','0')";
+ break;
+
+ case 'i':
+ $s .= "replace(str(datepart(mi,$col),2),' ','0')";
+ break;
+ case 's':
+ $s .= "replace(str(datepart(ss,$col),2),' ','0')";
+ break;
+ case 'a':
+ case 'A':
+ $s .= "substring(convert(char(19),$col,0),18,2)";
+ break;
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ break;
+ }
+ }
+ return $s;
+ }
+
+}
+
+class ADORecordSet_odbc_mssql extends ADORecordSet_odbc {
+
+ var $databaseType = 'odbc_mssql';
+
+ function ADORecordSet_odbc_mssql($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbc($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-odbc_oracle.inc.php b/html/phpgacl/adodb/drivers/adodb-odbc_oracle.inc.php
new file mode 100644
index 0000000..c0d7a06
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-odbc_oracle.inc.php
@@ -0,0 +1,114 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Oracle support via ODBC. Requires ODBC. Works on Windows.
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+
+
+class ADODB_odbc_oracle extends ADODB_odbc {
+ var $databaseType = 'odbc_oracle';
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $concat_operator='||';
+ var $fmtDate = "'Y-m-d 00:00:00'";
+ var $fmtTimeStamp = "'Y-m-d h:i:sA'";
+ var $metaTablesSQL = 'select table_name from cat';
+ var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
+ var $sysDate = "TRUNC(SYSDATE)";
+ var $sysTimeStamp = 'SYSDATE';
+
+ //var $_bindInputArray = false;
+
+ function ADODB_odbc_oracle()
+ {
+ $this->ADODB_odbc();
+ }
+
+ function &MetaTables()
+ {
+ $false = false;
+ $rs = $this->Execute($this->metaTablesSQL);
+ if ($rs === false) return $false;
+ $arr = $rs->GetArray();
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ $arr2[] = $arr[$i][0];
+ }
+ $rs->Close();
+ return $arr2;
+ }
+
+ function &MetaColumns($table)
+ {
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+ if ($rs === false) {
+ $false = false;
+ return $false;
+ }
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
+ }
+
+ // returns true or false
+ function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ global $php_errormsg;
+
+ $php_errormsg = '';
+ $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
+ $this->_errorMsg = $php_errormsg;
+
+ $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
+ return $this->_connectionID != false;
+ }
+ // returns true or false
+ function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ global $php_errormsg;
+ $php_errormsg = '';
+ $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC );
+ $this->_errorMsg = $php_errormsg;
+
+ $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
+ return $this->_connectionID != false;
+ }
+}
+
+class ADORecordSet_odbc_oracle extends ADORecordSet_odbc {
+
+ var $databaseType = 'odbc_oracle';
+
+ function ADORecordSet_odbc_oracle($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbc($id,$mode);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-odbtp.inc.php b/html/phpgacl/adodb/drivers/adodb-odbtp.inc.php
new file mode 100644
index 0000000..b916eaa
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-odbtp.inc.php
@@ -0,0 +1,728 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+ Latest version is available at http://adodb.sourceforge.net
+*/
+// Code contributed by "stefan bogdan" <sbogdan#rsb.ro>
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+define("_ADODB_ODBTP_LAYER", 2 );
+
+class ADODB_odbtp extends ADOConnection{
+ var $databaseType = "odbtp";
+ var $dataProvider = "odbtp";
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $odbc_driver = 0;
+ var $hasAffectedRows = true;
+ var $hasInsertID = false;
+ var $hasGenID = true;
+ var $hasMoveFirst = true;
+
+ var $_genSeqSQL = "create table %s (seq_name char(30) not null unique , seq_value integer not null)";
+ var $_dropSeqSQL = "delete from adodb_seq where seq_name = '%s'";
+ var $_bindInputArray = false;
+ var $_useUnicodeSQL = false;
+ var $_canPrepareSP = false;
+ var $_dontPoolDBC = true;
+
+ function ADODB_odbtp()
+ {
+ }
+
+ function ServerInfo()
+ {
+ return array('description' => @odbtp_get_attr( ODB_ATTR_DBMSNAME, $this->_connectionID),
+ 'version' => @odbtp_get_attr( ODB_ATTR_DBMSVER, $this->_connectionID));
+ }
+
+ function ErrorMsg()
+ {
+ if (empty($this->_connectionID)) return @odbtp_last_error();
+ return @odbtp_last_error($this->_connectionID);
+ }
+
+ function ErrorNo()
+ {
+ if (empty($this->_connectionID)) return @odbtp_last_error_state();
+ return @odbtp_last_error_state($this->_connectionID);
+ }
+
+ function _insertid()
+ {
+ // SCOPE_IDENTITY()
+ // Returns the last IDENTITY value inserted into an IDENTITY column in
+ // the same scope. A scope is a module -- a stored procedure, trigger,
+ // function, or batch. Thus, two statements are in the same scope if
+ // they are in the same stored procedure, function, or batch.
+ return $this->GetOne($this->identitySQL);
+ }
+
+ function _affectedrows()
+ {
+ if ($this->_queryID) {
+ return @odbtp_affected_rows ($this->_queryID);
+ } else
+ return 0;
+ }
+
+ function CreateSequence($seqname='adodbseq',$start=1)
+ {
+ //verify existence
+ $num = $this->GetOne("select seq_value from adodb_seq");
+ $seqtab='adodb_seq';
+ if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {
+ $path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID );
+ //if using vfp dbc file
+ if( !strcasecmp(strrchr($path, '.'), '.dbc') )
+ $path = substr($path,0,strrpos($path,'\/'));
+ $seqtab = $path . '/' . $seqtab;
+ }
+ if($num == false) {
+ if (empty($this->_genSeqSQL)) return false;
+ $ok = $this->Execute(sprintf($this->_genSeqSQL ,$seqtab));
+ }
+ $num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seqname'");
+ if ($num) {
+ return false;
+ }
+ $start -= 1;
+ return $this->Execute("insert into adodb_seq values('$seqname',$start)");
+ }
+
+ function DropSequence($seqname)
+ {
+ if (empty($this->_dropSeqSQL)) return false;
+ return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
+ }
+
+ function GenID($seq='adodbseq',$start=1)
+ {
+ $seqtab='adodb_seq';
+ if( $this->odbc_driver == ODB_DRIVER_FOXPRO) {
+ $path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID );
+ //if using vfp dbc file
+ if( !strcasecmp(strrchr($path, '.'), '.dbc') )
+ $path = substr($path,0,strrpos($path,'\/'));
+ $seqtab = $path . '/' . $seqtab;
+ }
+ $MAXLOOPS = 100;
+ while (--$MAXLOOPS>=0) {
+ $num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seq'");
+ if ($num === false) {
+ //verify if abodb_seq table exist
+ $ok = $this->GetOne("select seq_value from adodb_seq ");
+ if(!$ok) {
+ //creating the sequence table adodb_seq
+ $this->Execute(sprintf($this->_genSeqSQL ,$seqtab));
+ }
+ $start -= 1;
+ $num = '0';
+ $ok = $this->Execute("insert into adodb_seq values('$seq',$start)");
+ if (!$ok) return false;
+ }
+ $ok = $this->Execute("update adodb_seq set seq_value=seq_value+1 where seq_name='$seq'");
+ if($ok) {
+ $num += 1;
+ $this->genID = $num;
+ return $num;
+ }
+ }
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
+ }
+ return false;
+ }
+
+ //example for $UserOrDSN
+ //for visual fox : DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=c:\YourDbfFileDir;EXCLUSIVE=NO;
+ //for visual fox dbc: DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBC;SOURCEDB=c:\YourDbcFileDir\mydb.dbc;EXCLUSIVE=NO;
+ //for access : DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\path_to_access_db\base_test.mdb;UID=root;PWD=;
+ //for mssql : DRIVER={SQL Server};SERVER=myserver;UID=myuid;PWD=mypwd;DATABASE=OdbtpTest;
+ //if uid & pwd can be separate
+ function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
+ {
+ $this->_connectionID = @odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase);
+ if ($this->_connectionID === false) {
+ $this->_errorMsg = $this->ErrorMsg() ;
+ return false;
+ }
+ if ($this->_dontPoolDBC) {
+ if (function_exists('odbtp_dont_pool_dbc'))
+ @odbtp_dont_pool_dbc($this->_connectionID);
+ }
+ else {
+ $this->_dontPoolDBC = true;
+ }
+ $this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID);
+ $dbms = strtolower(@odbtp_get_attr(ODB_ATTR_DBMSNAME, $this->_connectionID));
+ $this->odbc_name = $dbms;
+
+ // Account for inconsistent DBMS names
+ if( $this->odbc_driver == ODB_DRIVER_ORACLE )
+ $dbms = 'oracle';
+ else if( $this->odbc_driver == ODB_DRIVER_SYBASE )
+ $dbms = 'sybase';
+
+ // Set DBMS specific attributes
+ switch( $dbms ) {
+ case 'microsoft sql server':
+ $this->databaseType = 'odbtp_mssql';
+ $this->fmtDate = "'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d h:i:sA'";
+ $this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)';
+ $this->sysTimeStamp = 'GetDate()';
+ $this->ansiOuter = true;
+ $this->leftOuter = '*=';
+ $this->rightOuter = '=*';
+ $this->hasTop = 'top';
+ $this->hasInsertID = true;
+ $this->hasTransactions = true;
+ $this->_bindInputArray = true;
+ $this->_canSelectDb = true;
+ $this->substr = "substring";
+ $this->length = 'len';
+ $this->identitySQL = 'select @@IDENTITY';
+ $this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'";
+ $this->_canPrepareSP = true;
+ break;
+ case 'access':
+ $this->databaseType = 'odbtp_access';
+ $this->fmtDate = "#Y-m-d#";
+ $this->fmtTimeStamp = "#Y-m-d h:i:sA#";
+ $this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
+ $this->sysTimeStamp = 'NOW';
+ $this->hasTop = 'top';
+ $this->hasTransactions = false;
+ $this->_canPrepareSP = true; // For MS Access only.
+ break;
+ case 'visual foxpro':
+ $this->databaseType = 'odbtp_vfp';
+ $this->fmtDate = "{^Y-m-d}";
+ $this->fmtTimeStamp = "{^Y-m-d, h:i:sA}";
+ $this->sysDate = 'date()';
+ $this->sysTimeStamp = 'datetime()';
+ $this->ansiOuter = true;
+ $this->hasTop = 'top';
+ $this->hasTransactions = false;
+ $this->replaceQuote = "'+chr(39)+'";
+ $this->true = '.T.';
+ $this->false = '.F.';
+ break;
+ case 'oracle':
+ $this->databaseType = 'odbtp_oci8';
+ $this->fmtDate = "'Y-m-d 00:00:00'";
+ $this->fmtTimeStamp = "'Y-m-d h:i:sA'";
+ $this->sysDate = 'TRUNC(SYSDATE)';
+ $this->sysTimeStamp = 'SYSDATE';
+ $this->hasTransactions = true;
+ $this->_bindInputArray = true;
+ $this->concat_operator = '||';
+ break;
+ case 'sybase':
+ $this->databaseType = 'odbtp_sybase';
+ $this->fmtDate = "'Y-m-d'";
+ $this->fmtTimeStamp = "'Y-m-d H:i:s'";
+ $this->sysDate = 'GetDate()';
+ $this->sysTimeStamp = 'GetDate()';
+ $this->leftOuter = '*=';
+ $this->rightOuter = '=*';
+ $this->hasInsertID = true;
+ $this->hasTransactions = true;
+ $this->identitySQL = 'select @@IDENTITY';
+ break;
+ default:
+ $this->databaseType = 'odbtp';
+ if( @odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID) )
+ $this->hasTransactions = true;
+ else
+ $this->hasTransactions = false;
+ }
+ @odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID );
+
+ if ($this->_useUnicodeSQL )
+ @odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID);
+
+ return true;
+ }
+
+ function _pconnect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='')
+ {
+ $this->_dontPoolDBC = false;
+ return $this->_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase);
+ }
+
+ function SelectDB($dbName)
+ {
+ if (!@odbtp_select_db($dbName, $this->_connectionID)) {
+ return false;
+ }
+ $this->databaseName = $dbName;
+ return true;
+ }
+
+ function &MetaTables($ttype='',$showSchema=false,$mask=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
+
+ $arr =& $this->GetArray("||SQLTables||||$ttype");
+
+ if (isset($savefm)) $this->SetFetchMode($savefm);
+ $ADODB_FETCH_MODE = $savem;
+
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if ($arr[$i][3] == 'SYSTEM TABLE' ) continue;
+ if ($arr[$i][2])
+ $arr2[] = $showSchema ? $arr[$i][1].'.'.$arr[$i][2] : $arr[$i][2];
+ }
+ return $arr2;
+ }
+
+ function &MetaColumns($table,$upper=true)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = false;
+ $this->_findschema($table,$schema);
+ if ($upper) $table = strtoupper($table);
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false);
+
+ $rs = $this->Execute( "||SQLColumns||$schema|$table" );
+
+ if (isset($savefm)) $this->SetFetchMode($savefm);
+ $ADODB_FETCH_MODE = $savem;
+
+ if (!$rs || $rs->EOF) {
+ $false = false;
+ return $false;
+ }
+ while (!$rs->EOF) {
+ //print_r($rs->fields);
+ if (strtoupper($rs->fields[2]) == $table) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[3];
+ $fld->type = $rs->fields[5];
+ $fld->max_length = $rs->fields[6];
+ $fld->not_null = !empty($rs->fields[9]);
+ $fld->scale = $rs->fields[7];
+ if (!is_null($rs->fields[12])) {
+ $fld->has_default = true;
+ $fld->default_value = $rs->fields[12];
+ }
+ $retarr[strtoupper($fld->name)] = $fld;
+ } else if (sizeof($retarr)>0)
+ break;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+
+ return $retarr;
+ }
+
+ function &MetaPrimaryKeys($table, $owner='')
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $arr =& $this->GetArray("||SQLPrimaryKeys||$owner|$table");
+ $ADODB_FETCH_MODE = $savem;
+
+ //print_r($arr);
+ $arr2 = array();
+ for ($i=0; $i < sizeof($arr); $i++) {
+ if ($arr[$i][3]) $arr2[] = $arr[$i][3];
+ }
+ return $arr2;
+ }
+
+ function &MetaForeignKeys($table, $owner='', $upper=false)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $savem = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $constraints =& $this->GetArray("||SQLForeignKeys|||||$owner|$table");
+ $ADODB_FETCH_MODE = $savem;
+
+ $arr = false;
+ foreach($constraints as $constr) {
+ //print_r($constr);
+ $arr[$constr[11]][$constr[2]][] = $constr[7].'='.$constr[3];
+ }
+ if (!$arr) {
+ $false = false;
+ return $false;
+ }
+
+ $arr2 = array();
+
+ foreach($arr as $k => $v) {
+ foreach($v as $a => $b) {
+ if ($upper) $a = strtoupper($a);
+ $arr2[$a] = $b;
+ }
+ }
+ return $arr2;
+ }
+
+ function BeginTrans()
+ {
+ if (!$this->hasTransactions) return false;
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->autoCommit = false;
+ if (defined('ODB_TXN_DEFAULT'))
+ $txn = ODB_TXN_DEFAULT;
+ else
+ $txn = ODB_TXN_READUNCOMMITTED;
+ $rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,$txn,$this->_connectionID);
+ if(!$rs) return false;
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->autoCommit = true;
+ if( ($ret = @odbtp_commit($this->_connectionID)) )
+ $ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->autoCommit = true;
+ if( ($ret = @odbtp_rollback($this->_connectionID)) )
+ $ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off
+ return $ret;
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ // TOP requires ORDER BY for Visual FoxPro
+ if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) {
+ if (!preg_match('/ORDER[ \t\r\n]+BY/is',$sql)) $sql .= ' ORDER BY 1';
+ }
+ $ret =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ return $ret;
+ }
+
+ function Prepare($sql)
+ {
+ if (! $this->_bindInputArray) return $sql; // no binding
+ $stmt = @odbtp_prepare($sql,$this->_connectionID);
+ if (!$stmt) {
+ // print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>";
+ return $sql;
+ }
+ return array($sql,$stmt,false);
+ }
+
+ function PrepareSP($sql)
+ {
+ if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures
+
+ $stmt = @odbtp_prepare_proc($sql,$this->_connectionID);
+ if (!$stmt) return false;
+ return array($sql,$stmt);
+ }
+
+ /*
+ Usage:
+ $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group
+
+ # note that the parameter does not have @ in front!
+ $db->Parameter($stmt,$id,'myid');
+ $db->Parameter($stmt,$group,'group',false,64);
+ $db->Parameter($stmt,$group,'photo',false,100000,ODB_BINARY);
+ $db->Execute($stmt);
+
+ @param $stmt Statement returned by Prepare() or PrepareSP().
+ @param $var PHP variable to bind to. Can set to null (for isNull support).
+ @param $name Name of stored procedure variable name to bind to.
+ @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in odbtp.
+ @param [$maxLen] Holds an maximum length of the variable.
+ @param [$type] The data type of $var. Legal values depend on driver.
+
+ See odbtp_attach_param documentation at http://odbtp.sourceforge.net.
+ */
+ function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=0, $type=0)
+ {
+ if ( $this->odbc_driver == ODB_DRIVER_JET ) {
+ $name = '['.$name.']';
+ if( !$type && $this->_useUnicodeSQL
+ && @odbtp_param_bindtype($stmt[1], $name) == ODB_CHAR )
+ {
+ $type = ODB_WCHAR;
+ }
+ }
+ else {
+ $name = '@'.$name;
+ }
+ return @odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen);
+ }
+
+ /*
+ Insert a null into the blob field of the table first.
+ Then use UpdateBlob to store the blob.
+
+ Usage:
+
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+
+ function UpdateBlob($table,$column,$val,$where,$blobtype='image')
+ {
+ $sql = "UPDATE $table SET $column = ? WHERE $where";
+ if( !($stmt = @odbtp_prepare($sql, $this->_connectionID)) )
+ return false;
+ if( !@odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) )
+ return false;
+ if( !@odbtp_set( $stmt, 1, $val ) )
+ return false;
+ return @odbtp_execute( $stmt ) != false;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ switch( $this->odbc_driver ) {
+ case ODB_DRIVER_MSSQL:
+ return " ISNULL($field, $ifNull) ";
+ case ODB_DRIVER_JET:
+ return " IIF(IsNull($field), $ifNull, $field) ";
+ }
+ return " CASE WHEN $field is null THEN $ifNull ELSE $field END ";
+ }
+
+ function _query($sql,$inputarr=false)
+ {
+ if ($inputarr) {
+ if (is_array($sql)) {
+ $stmtid = $sql[1];
+ } else {
+ $stmtid = @odbtp_prepare($sql,$this->_connectionID);
+ if ($stmtid == false) {
+ $this->_errorMsg = $php_errormsg;
+ return false;
+ }
+ }
+ $num_params = @odbtp_num_params( $stmtid );
+ for( $param = 1; $param <= $num_params; $param++ ) {
+ @odbtp_input( $stmtid, $param );
+ @odbtp_set( $stmtid, $param, $inputarr[$param-1] );
+ }
+ if (!@odbtp_execute($stmtid) ) {
+ return false;
+ }
+ } else if (is_array($sql)) {
+ $stmtid = $sql[1];
+ if (!@odbtp_execute($stmtid)) {
+ return false;
+ }
+ } else {
+ $stmtid = @odbtp_query($sql,$this->_connectionID);
+ }
+ $this->_lastAffectedRows = 0;
+ if ($stmtid) {
+ $this->_lastAffectedRows = @odbtp_affected_rows($stmtid);
+ }
+ return $stmtid;
+ }
+
+ function _close()
+ {
+ $ret = @odbtp_close($this->_connectionID);
+ $this->_connectionID = false;
+ return $ret;
+ }
+}
+
+class ADORecordSet_odbtp extends ADORecordSet {
+
+ var $databaseType = 'odbtp';
+ var $canSeek = true;
+
+ function ADORecordSet_odbtp($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function _initrs()
+ {
+ $this->_numOfFields = @odbtp_num_fields($this->_queryID);
+ if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID)))
+ $this->_numOfRows = -1;
+
+ if (!$this->connection->_useUnicodeSQL) return;
+
+ if ($this->connection->odbc_driver == ODB_DRIVER_JET) {
+ if (!@odbtp_get_attr(ODB_ATTR_MAPCHARTOWCHAR,
+ $this->connection->_connectionID))
+ {
+ for ($f = 0; $f < $this->_numOfFields; $f++) {
+ if (@odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR)
+ @odbtp_bind_field($this->_queryID, $f, ODB_WCHAR);
+ }
+ }
+ }
+ }
+
+ function &FetchField($fieldOffset = 0)
+ {
+ $off=$fieldOffset; // offsets begin at 0
+ $o= new ADOFieldObject();
+ $o->name = @odbtp_field_name($this->_queryID,$off);
+ $o->type = @odbtp_field_type($this->_queryID,$off);
+ $o->max_length = @odbtp_field_length($this->_queryID,$off);
+ if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
+ else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
+ return $o;
+ }
+
+ function _seek($row)
+ {
+ return @odbtp_data_seek($this->_queryID, $row);
+ }
+
+ function fields($colname)
+ {
+ if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $name = @odbtp_field_name( $this->_queryID, $i );
+ $this->bind[strtoupper($name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function _fetch_odbtp($type=0)
+ {
+ switch ($this->fetchMode) {
+ case ADODB_FETCH_NUM:
+ $this->fields = @odbtp_fetch_row($this->_queryID, $type);
+ break;
+ case ADODB_FETCH_ASSOC:
+ $this->fields = @odbtp_fetch_assoc($this->_queryID, $type);
+ break;
+ default:
+ $this->fields = @odbtp_fetch_array($this->_queryID, $type);
+ }
+ return is_array($this->fields);
+ }
+
+ function _fetch()
+ {
+ return $this->_fetch_odbtp();
+ }
+
+ function MoveFirst()
+ {
+ if (!$this->_fetch_odbtp(ODB_FETCH_FIRST)) return false;
+ $this->EOF = false;
+ $this->_currentRow = 0;
+ return true;
+ }
+
+ function MoveLast()
+ {
+ if (!$this->_fetch_odbtp(ODB_FETCH_LAST)) return false;
+ $this->EOF = false;
+ $this->_currentRow = $this->_numOfRows - 1;
+ return true;
+ }
+
+ function NextRecordSet()
+ {
+ if (!@odbtp_next_result($this->_queryID)) return false;
+ $this->_inited = false;
+ $this->bind = false;
+ $this->_currentRow = -1;
+ $this->Init();
+ return true;
+ }
+
+ function _close()
+ {
+ return @odbtp_free_query($this->_queryID);
+ }
+}
+
+class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_mssql';
+
+ function ADORecordSet_odbtp_mssql($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_access extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_access';
+
+ function ADORecordSet_odbtp_access($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_vfp';
+
+ function ADORecordSet_odbtp_vfp($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_oci8';
+
+ function ADORecordSet_odbtp_oci8($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+
+class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp {
+
+ var $databaseType = 'odbtp_sybase';
+
+ function ADORecordSet_odbtp_sybase($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbtp($id,$mode);
+ }
+}
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-odbtp_unicode.inc.php b/html/phpgacl/adodb/drivers/adodb-odbtp_unicode.inc.php
new file mode 100644
index 0000000..15dac7e
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-odbtp_unicode.inc.php
@@ -0,0 +1,39 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+// Code contributed by "Robert Twitty" <rtwitty#neutron.ushmm.org>
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+ Because the ODBTP server sends and reads UNICODE text data using UTF-8
+ encoding, the following HTML meta tag must be included within the HTML
+ head section of every HTML form and script page:
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+ Also, all SQL query strings must be submitted as UTF-8 encoded text.
+*/
+
+if (!defined('_ADODB_ODBTP_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbtp.inc.php");
+}
+
+class ADODB_odbtp_unicode extends ADODB_odbtp {
+ var $databaseType = 'odbtp';
+ var $_useUnicodeSQL = true;
+
+ function ADODB_odbtp_unicode()
+ {
+ $this->ADODB_odbtp();
+ }
+}
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-oracle.inc.php b/html/phpgacl/adodb/drivers/adodb-oracle.inc.php
new file mode 100644
index 0000000..f1b65d8
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-oracle.inc.php
@@ -0,0 +1,320 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Oracle data driver. Requires Oracle client. Works on Windows and Unix and Oracle 7.
+
+ If you are using Oracle 8 or later, use the oci8 driver which is much better and more reliable.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB_oracle extends ADOConnection {
+ var $databaseType = "oracle";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $concat_operator='||';
+ var $_curs;
+ var $_initdate = true; // init date to YYYY-MM-DD
+ var $metaTablesSQL = 'select table_name from cat';
+ var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
+ var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')";
+ var $sysTimeStamp = 'SYSDATE';
+ var $connectSID = true;
+
+ function ADODB_oracle()
+ {
+ }
+
+ // format and return date string in database date format
+ function DBDate($d)
+ {
+ if (is_string($d)) $d = ADORecordSet::UnixDate($d);
+ return 'TO_DATE('.adodb_date($this->fmtDate,$d).",'YYYY-MM-DD')";
+ }
+
+ // format and return date string in database timestamp format
+ function DBTimeStamp($ts)
+ {
+
+ if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts);
+ return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')";
+ }
+
+
+ function BeginTrans()
+ {
+ $this->autoCommit = false;
+ ora_commitoff($this->_connectionID);
+ return true;
+ }
+
+
+ function CommitTrans($ok=true)
+ {
+ if (!$ok) return $this->RollbackTrans();
+ $ret = ora_commit($this->_connectionID);
+ ora_commiton($this->_connectionID);
+ return $ret;
+ }
+
+
+ function RollbackTrans()
+ {
+ $ret = ora_rollback($this->_connectionID);
+ ora_commiton($this->_connectionID);
+ return $ret;
+ }
+
+
+ /* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */
+ function ErrorMsg()
+ {
+ if ($this->_errorMsg !== false) return $this->_errorMsg;
+
+ if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs);
+ if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID);
+ return $this->_errorMsg;
+ }
+
+
+ function ErrorNo()
+ {
+ if ($this->_errorCode !== false) return $this->_errorCode;
+
+ if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs);
+ if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID);
+ return $this->_errorCode;
+ }
+
+
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0)
+ {
+ if (!function_exists('ora_plogon')) return null;
+
+ // <G. Giunta 2003/03/03/> Reset error messages before connecting
+ $this->_errorMsg = false;
+ $this->_errorCode = false;
+
+ // G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set
+ // the oracle home to the host name of remote DB?
+// if ($argHostname) putenv("ORACLE_HOME=$argHostname");
+
+ if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
+ if (empty($argDatabasename)) $argDatabasename = $argHostname;
+ else {
+ if(strpos($argHostname,":")) {
+ $argHostinfo=explode(":",$argHostname);
+ $argHostname=$argHostinfo[0];
+ $argHostport=$argHostinfo[1];
+ } else {
+ $argHostport="1521";
+ }
+
+
+ if ($this->connectSID) {
+ $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
+ .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
+ } else
+ $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
+ .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
+ }
+
+ }
+
+ if ($argDatabasename) $argUsername .= "@$argDatabasename";
+
+ //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
+ if ($mode = 1)
+ $this->_connectionID = ora_plogon($argUsername,$argPassword);
+ else
+ $this->_connectionID = ora_logon($argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($this->autoCommit) ora_commiton($this->_connectionID);
+ if ($this->_initdate) {
+ $rs = $this->_query("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
+ if ($rs) ora_close($rs);
+ }
+
+ return true;
+ }
+
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, 1);
+ }
+
+
+ // returns query ID if successful, otherwise false
+ function _query($sql,$inputarr=false)
+ {
+ // <G. Giunta 2003/03/03/> Reset error messages before executing
+ $this->_errorMsg = false;
+ $this->_errorCode = false;
+
+ $curs = ora_open($this->_connectionID);
+
+ if ($curs === false) return false;
+ $this->_curs = $curs;
+ if (!ora_parse($curs,$sql)) return false;
+ if (ora_exec($curs)) return $curs;
+ // <G. Giunta 2004/03/03> before we close the cursor, we have to store the error message
+ // that we can obtain ONLY from the cursor (and not from the connection)
+ $this->_errorCode = @ora_errorcode($curs);
+ $this->_errorMsg = @ora_error($curs);
+ // </G. Giunta 2004/03/03>
+ @ora_close($curs);
+ return false;
+ }
+
+
+ // returns true or false
+ function _close()
+ {
+ return @ora_logoff($this->_connectionID);
+ }
+
+
+
+}
+
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_oracle extends ADORecordSet {
+
+ var $databaseType = "oracle";
+ var $bind = false;
+
+ function ADORecordset_oracle($queryID,$mode=false)
+ {
+
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->fetchMode = $mode;
+
+ $this->_queryID = $queryID;
+
+ $this->_inited = true;
+ $this->fields = array();
+ if ($queryID) {
+ $this->_currentRow = 0;
+ $this->EOF = !$this->_fetch();
+ @$this->_initrs();
+ } else {
+ $this->_numOfRows = 0;
+ $this->_numOfFields = 0;
+ $this->EOF = true;
+ }
+
+ return $this->_queryID;
+ }
+
+
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+
+ function &FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $fld->name = ora_columnname($this->_queryID, $fieldOffset);
+ $fld->type = ora_columntype($this->_queryID, $fieldOffset);
+ $fld->max_length = ora_columnsize($this->_queryID, $fieldOffset);
+ return $fld;
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = -1;
+ $this->_numOfFields = @ora_numcols($this->_queryID);
+ }
+
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ function _fetch($ignore_fields=false) {
+// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1
+ if ($this->fetchMode & ADODB_FETCH_ASSOC)
+ return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
+ else
+ return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS);
+ }
+
+ /* close() only needs to be called if you are worried about using too much memory while your script
+ is running. All associated result memory for the specified result identifier will automatically be freed. */
+
+ function _close()
+{
+ return @ora_close($this->_queryID);
+ }
+
+ function MetaType($t,$len=-1)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+
+ switch (strtoupper($t)) {
+ case 'VARCHAR':
+ case 'VARCHAR2':
+ case 'CHAR':
+ case 'VARBINARY':
+ case 'BINARY':
+ if ($len <= $this->blobSize) return 'C';
+ case 'LONG':
+ case 'LONG VARCHAR':
+ case 'CLOB':
+ return 'X';
+ case 'LONG RAW':
+ case 'LONG VARBINARY':
+ case 'BLOB':
+ return 'B';
+
+ case 'DATE': return 'D';
+
+ //case 'T': return 'T';
+
+ case 'BIT': return 'L';
+ case 'INT':
+ case 'SMALLINT':
+ case 'INTEGER': return 'I';
+ default: return 'N';
+ }
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-pdo.inc.php b/html/phpgacl/adodb/drivers/adodb-pdo.inc.php
new file mode 100644
index 0000000..1dcde6a
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-pdo.inc.php
@@ -0,0 +1,545 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Requires ODBC. Works on Windows and Unix.
+
+ Problems:
+ Where is float/decimal type in pdo_param_type
+ LOB handling for CLOB/BLOB differs significantly
+*/
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+
+/*
+enum pdo_param_type {
+PDO_PARAM_NULL, 0
+
+/* int as in long (the php native int type).
+ * If you mark a column as an int, PDO expects get_col to return
+ * a pointer to a long
+PDO_PARAM_INT, 1
+
+/* get_col ptr should point to start of the string buffer
+PDO_PARAM_STR, 2
+
+/* get_col: when len is 0 ptr should point to a php_stream *,
+ * otherwise it should behave like a string. Indicate a NULL field
+ * value by setting the ptr to NULL
+PDO_PARAM_LOB, 3
+
+/* get_col: will expect the ptr to point to a new PDOStatement object handle,
+ * but this isn't wired up yet
+PDO_PARAM_STMT, 4 /* hierarchical result set
+
+/* get_col ptr should point to a zend_bool
+PDO_PARAM_BOOL, 5
+
+
+/* magic flag to denote a parameter as being input/output
+PDO_PARAM_INPUT_OUTPUT = 0x80000000
+};
+*/
+
+function adodb_pdo_type($t)
+{
+ switch($t) {
+ case 2: return 'VARCHAR';
+ case 3: return 'BLOB';
+ default: return 'NUMERIC';
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+--------------------------------------------------------------------------------------*/
+
+////////////////////////////////////////////////
+
+
+
+class ADODB_pdo_base extends ADODB_pdo {
+
+ function _init($parentDriver)
+ {
+ $parentDriver->_bindInputArray = false;
+ #$parentDriver->_connectionID->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY,true);
+ }
+
+ function ServerInfo()
+ {
+ return ADOConnection::ServerInfo();
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ return $ret;
+ }
+
+ function MetaTables()
+ {
+ return false;
+ }
+
+ function MetaColumns()
+ {
+ return false;
+ }
+}
+
+
+class ADODB_pdo extends ADOConnection {
+ var $databaseType = "pdo";
+ var $dataProvider = "pdo";
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $hasAffectedRows = true;
+ var $_bindInputArray = true;
+ var $_genSeqSQL = "create table %s (id integer)";
+ var $_autocommit = true;
+ var $_haserrorfunctions = true;
+ var $_lastAffectedRows = 0;
+
+ var $_errormsg = false;
+ var $_errorno = false;
+
+ var $dsnType = '';
+ var $stmt = false;
+
+ function ADODB_pdo()
+ {
+ }
+
+ function _UpdatePDO()
+ {
+ $d = &$this->_driver;
+ $this->fmtDate = $d->fmtDate;
+ $this->fmtTimeStamp = $d->fmtTimeStamp;
+ $this->replaceQuote = $d->replaceQuote;
+ $this->sysDate = $d->sysDate;
+ $this->sysTimeStamp = $d->sysTimeStamp;
+ $this->random = $d->random;
+ $this->concat_operator = $d->concat_operator;
+
+ $d->_init($this);
+ }
+
+ function Time()
+ {
+ return false;
+ }
+
+ // returns true or false
+ function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false)
+ {
+ $at = strpos($argDSN,':');
+ $this->dsnType = substr($argDSN,0,$at);
+
+ try {
+ $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword);
+ } catch (Exception $e) {
+ $this->_connectionID = false;
+ $this->_errorno = -1;
+ //var_dump($e);
+ $this->_errormsg = 'Connection attempt failed: '.$e->getMessage();
+ return false;
+ }
+
+ if ($this->_connectionID) {
+ switch(ADODB_ASSOC_CASE){
+ case 0: $m = PDO_CASE_LOWER; break;
+ case 1: $m = PDO_CASE_UPPER; break;
+ default:
+ case 2: $m = PDO_CASE_NATURAL; break;
+ }
+
+ //$this->_connectionID->setAttribute(PDO_ATTR_ERRMODE,PDO_ERRMODE_SILENT );
+ $this->_connectionID->setAttribute(PDO_ATTR_CASE,$m);
+
+ $class = 'ADODB_pdo_'.$this->dsnType;
+ //$this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
+ switch($this->dsnType) {
+ case 'oci':
+ case 'mysql':
+ case 'pgsql':
+ include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php');
+ break;
+ }
+ if (class_exists($class))
+ $this->_driver = new $class();
+ else
+ $this->_driver = new ADODB_pdo_base();
+
+ $this->_driver->_connectionID = $this->_connectionID;
+ $this->_UpdatePDO();
+ return true;
+ }
+ $this->_driver = new ADODB_pdo_base();
+ return false;
+ }
+
+ // returns true or false
+ function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
+ {
+ return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true);
+ }
+
+ /*------------------------------------------------------------------------------*/
+
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ $save = $this->_driver->fetchMode;
+ $this->_driver->fetchMode = $this->fetchMode;
+ $ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ $this->_driver->fetchMode = $save;
+ return $ret;
+ }
+
+
+ function ServerInfo()
+ {
+ return $this->_driver->ServerInfo();
+ }
+
+ function MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ return $this->_driver->MetaTables($ttype,$showSchema,$mask);
+ }
+
+ function MetaColumns($table,$normalize=true)
+ {
+ return $this->_driver->MetaColumns($table,$normalize);
+ }
+
+ function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
+ {
+ $obj = $stmt[1];
+ if ($type) $obj->bindParam($name,$var,$type,$maxLen);
+ else $obj->bindParam($name, $var);
+ }
+
+
+ function ErrorMsg()
+ {
+ if ($this->_errormsg !== false) return $this->_errormsg;
+ if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo();
+ else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo();
+ else return 'No Connection Established';
+
+
+ if ($arr) {
+ if (sizeof($arr)<2) return '';
+ if ((integer)$arr[1]) return $arr[2];
+ else return '';
+ } else return '-1';
+ }
+
+
+ function ErrorNo()
+ {
+ if ($this->_errorno !== false) return $this->_errorno;
+ if (!empty($this->_stmt)) $err = $this->_stmt->errorCode();
+ else if (!empty($this->_connectionID)) {
+ $arr = $this->_connectionID->errorInfo();
+ if (isset($arr[0])) $err = $arr[0];
+ else $err = -1;
+ } else
+ return 0;
+
+ if ($err == '00000') return 0; // allows empty check
+ return $err;
+ }
+
+ function BeginTrans()
+ {
+ if (!$this->hasTransactions) return false;
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ $this->_autocommit = false;
+ $this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,false);
+ return $this->_connectionID->beginTransaction();
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if (!$this->hasTransactions) return false;
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->_autocommit = true;
+
+ $ret = $this->_connectionID->commit();
+ $this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
+ return $ret;
+ }
+
+ function RollbackTrans()
+ {
+ if (!$this->hasTransactions) return false;
+ if ($this->transOff) return true;
+ if ($this->transCnt) $this->transCnt -= 1;
+ $this->_autocommit = true;
+
+ $ret = $this->_connectionID->rollback();
+ $this->_connectionID->setAttribute(PDO_ATTR_AUTOCOMMIT,true);
+ return $ret;
+ }
+
+ function Prepare($sql)
+ {
+ $this->_stmt = $this->_connectionID->prepare($sql);
+ if ($this->_stmt) return array($sql,$this->_stmt);
+
+ return false;
+ }
+
+ function PrepareStmt($sql)
+ {
+ $stmt = $this->_connectionID->prepare($sql);
+ if (!$stmt) return false;
+ $obj = new ADOPDOStatement($stmt,$this);
+ return $obj;
+ }
+
+ /* returns queryID or false */
+ function _query($sql,$inputarr=false)
+ {
+ if (is_array($sql)) {
+ $stmt = $sql[1];
+ } else {
+ $stmt = $this->_connectionID->prepare($sql);
+ }
+
+ if ($stmt) {
+ if ($inputarr) $ok = $stmt->execute($inputarr);
+ else $ok = $stmt->execute();
+ }
+
+
+ $this->_errormsg = false;
+ $this->_errorno = false;
+
+ if ($ok) {
+ $this->_stmt = $stmt;
+ return $stmt;
+ }
+
+ if ($stmt) {
+
+ $arr = $stmt->errorinfo();
+ if ((integer)$arr[1]) {
+ $this->_errormsg = $arr[2];
+ $this->_errorno = $arr[1];
+ }
+
+ } else {
+ $this->_errormsg = false;
+ $this->_errorno = false;
+ }
+ return false;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ $this->_stmt = false;
+ return true;
+ }
+
+ function _affectedrows()
+ {
+ return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
+ }
+
+ function _insertid()
+ {
+ return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0;
+ }
+}
+
+class ADOPDOStatement {
+
+ var $databaseType = "pdo";
+ var $dataProvider = "pdo";
+ var $_stmt;
+ var $_connectionID;
+
+ function ADOPDOStatement($stmt,$connection)
+ {
+ $this->_stmt = $stmt;
+ $this->_connectionID = $connection;
+ }
+
+ function Execute($inputArr=false)
+ {
+ $savestmt = $this->_connectionID->_stmt;
+ $rs = $this->_connectionID->Execute(array(false,$this->_stmt),$inputArr);
+ $this->_connectionID->_stmt = $savestmt;
+ return $rs;
+ }
+
+ function InParameter(&$var,$name,$maxLen=4000,$type=false)
+ {
+
+ if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen);
+ else $this->_stmt->bindParam($name, $var);
+ }
+
+ function Affected_Rows()
+ {
+ return ($this->_stmt) ? $this->_stmt->rowCount() : 0;
+ }
+
+ function ErrorMsg()
+ {
+ if ($this->_stmt) $arr = $this->_stmt->errorInfo();
+ else $arr = $this->_connectionID->errorInfo();
+
+ if (is_array($arr)) {
+ if ((integer) $arr[0] && isset($arr[2])) return $arr[2];
+ else return '';
+ } else return '-1';
+ }
+
+ function NumCols()
+ {
+ return ($this->_stmt) ? $this->_stmt->columnCount() : 0;
+ }
+
+ function ErrorNo()
+ {
+ if ($this->_stmt) return $this->_stmt->errorCode();
+ else return $this->_connectionID->errorInfo();
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_pdo extends ADORecordSet {
+
+ var $bind = false;
+ var $databaseType = "pdo";
+ var $dataProvider = "pdo";
+
+ function ADORecordSet_pdo($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ $this->adodbFetchMode = $mode;
+ switch($mode) {
+ case ADODB_FETCH_NUM: $mode = PDO_FETCH_NUM; break;
+ case ADODB_FETCH_ASSOC: $mode = PDO_FETCH_ASSOC; break;
+
+ case ADODB_FETCH_BOTH:
+ default: $mode = PDO_FETCH_BOTH; break;
+ }
+ $this->fetchMode = $mode;
+
+ $this->_queryID = $id;
+ $this->ADORecordSet($id);
+ }
+
+
+ function Init()
+ {
+ if ($this->_inited) return;
+ $this->_inited = true;
+ if ($this->_queryID) @$this->_initrs();
+ else {
+ $this->_numOfRows = 0;
+ $this->_numOfFields = 0;
+ }
+ if ($this->_numOfRows != 0 && $this->_currentRow == -1) {
+ $this->_currentRow = 0;
+ if ($this->EOF = ($this->_fetch() === false)) {
+ $this->_numOfRows = 0; // _numOfRows could be -1
+ }
+ } else {
+ $this->EOF = true;
+ }
+ }
+
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+
+ $this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1;
+ if (!$this->_numOfRows) $this->_numOfRows = -1;
+ $this->_numOfFields = $this->_queryID->columnCount();
+ }
+
+ // returns the field object
+ function &FetchField($fieldOffset = -1)
+ {
+ $off=$fieldOffset+1; // offsets begin at 1
+
+ $o= new ADOFieldObject();
+ $arr = @$this->_queryID->getColumnMeta($fieldOffset);
+ if (!$arr) {
+ $o->name = 'bad getColumnMeta()';
+ $o->max_length = -1;
+ $o->type = 'VARCHAR';
+ $o->precision = 0;
+ # $false = false;
+ return $o;
+ }
+ //adodb_pr($arr);
+ $o->name = $arr['name'];
+ if (isset($arr['native_type'])) $o->type = $arr['native_type'];
+ else $o->type = adodb_pdo_type($arr['pdo_type']);
+ $o->max_length = $arr['len'];
+ $o->precision = $arr['precision'];
+
+ if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
+ else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
+ return $o;
+ }
+
+ function _seek($row)
+ {
+ return false;
+ }
+
+ function _fetch()
+ {
+ if (!$this->_queryID) return false;
+
+ $this->fields = $this->_queryID->fetch($this->fetchMode);
+ return !empty($this->fields);
+ }
+
+ function _close()
+ {
+ $this->_queryID = false;
+ }
+
+ function Fields($colname)
+ {
+ if ($this->adodbFetchMode != ADODB_FETCH_NUM) return @$this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-pdo_mysql.inc.php b/html/phpgacl/adodb/drivers/adodb-pdo_mysql.inc.php
new file mode 100644
index 0000000..b9df02d
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-pdo_mysql.inc.php
@@ -0,0 +1,145 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+*/
+
+class ADODB_pdo_mysql extends ADODB_pdo {
+ var $metaTablesSQL = "SHOW TABLES";
+ var $metaColumnsSQL = "SHOW COLUMNS FROM %s";
+ var $_bindInputArray = false;
+ var $sysDate = 'CURDATE()';
+ var $sysTimeStamp = 'NOW()';
+
+ function _init($parentDriver)
+ {
+
+ $parentDriver->hasTransactions = false;
+ $parentDriver->_bindInputArray = false;
+ $parentDriver->_connectionID->setAttribute(PDO_MYSQL_ATTR_USE_BUFFERED_QUERY,true);
+ }
+
+ function ServerInfo()
+ {
+ $arr['description'] = ADOConnection::GetOne("select version()");
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $save = $this->metaTablesSQL;
+ if ($showSchema && is_string($showSchema)) {
+ $this->metaTablesSQL .= " from $showSchema";
+ }
+
+ if ($mask) {
+ $mask = $this->qstr($mask);
+ $this->metaTablesSQL .= " like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ $this->metaTablesSQL = $save;
+ return $ret;
+ }
+
+ function &MetaColumns($table)
+ {
+ $this->_findschema($table,$schema);
+ if ($schema) {
+ $dbName = $this->database;
+ $this->SelectDB($schema);
+ }
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+
+ if ($schema) {
+ $this->SelectDB($dbName);
+ }
+
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!is_object($rs)) {
+ $false = false;
+ return $false;
+ }
+
+ $retarr = array();
+ while (!$rs->EOF){
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $type = $rs->fields[1];
+
+ // split type into type(length):
+ $fld->scale = null;
+ if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+ } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+ } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
+ $fld->type = $query_array[1];
+ $arr = explode(",",$query_array[2]);
+ $fld->enums = $arr;
+ $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
+ $fld->max_length = ($zlen > 0) ? $zlen : 1;
+ } else {
+ $fld->type = $type;
+ $fld->max_length = -1;
+ }
+ $fld->not_null = ($rs->fields[2] != 'YES');
+ $fld->primary_key = ($rs->fields[3] == 'PRI');
+ $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+ $fld->binary = (strpos($type,'blob') !== false);
+ $fld->unsigned = (strpos($type,'unsigned') !== false);
+
+ if (!$fld->binary) {
+ $d = $rs->fields[4];
+ if ($d != '' && $d != 'NULL') {
+ $fld->has_default = true;
+ $fld->default_value = $d;
+ } else {
+ $fld->has_default = false;
+ }
+ }
+
+ if ($save == ADODB_FETCH_NUM) {
+ $retarr[] = $fld;
+ } else {
+ $retarr[strtoupper($fld->name)] = $fld;
+ }
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+ return $retarr;
+ }
+
+
+ // parameters use PostgreSQL convention, not MySQL
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
+ {
+ $offsetStr =($offset>=0) ? "$offset," : '';
+ // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
+ if ($nrows < 0) $nrows = '18446744073709551615';
+
+ if ($secs)
+ $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr);
+ else
+ $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr);
+ return $rs;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-pdo_oci.inc.php b/html/phpgacl/adodb/drivers/adodb-pdo_oci.inc.php
new file mode 100644
index 0000000..5ad8bc3
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-pdo_oci.inc.php
@@ -0,0 +1,92 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+*/
+
+class ADODB_pdo_oci extends ADODB_pdo_base {
+
+ var $concat_operator='||';
+ var $sysDate = "TRUNC(SYSDATE)";
+ var $sysTimeStamp = 'SYSDATE';
+ var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS'
+ var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)";
+ var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW')";
+ var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno";
+
+ var $_initdate = true;
+
+ function _init($parentDriver)
+ {
+ $parentDriver->_bindInputArray = false;
+
+ if ($this->_initdate) {
+ $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
+ }
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ if ($mask) {
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr(strtoupper($mask));
+ $this->metaTablesSQL .= " AND table_name like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ function &MetaColumns($table)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $false = false;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table)));
+
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ if (!$rs) {
+ return $false;
+ }
+ $retarr = array();
+ while (!$rs->EOF) { //print_r($rs->fields);
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+ $fld->scale = $rs->fields[3];
+ if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) {
+ $fld->type ='INT';
+ $fld->max_length = $rs->fields[4];
+ }
+ $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0);
+ $fld->binary = (strpos($fld->type,'BLOB') !== false);
+ $fld->default_value = $rs->fields[6];
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[strtoupper($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if (empty($retarr))
+ return $false;
+ else
+ return $retarr;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-pdo_pgsql.inc.php b/html/phpgacl/adodb/drivers/adodb-pdo_pgsql.inc.php
new file mode 100644
index 0000000..91b92f9
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-pdo_pgsql.inc.php
@@ -0,0 +1,228 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+*/
+
+class ADODB_pdo_pgsql extends ADODB_pdo {
+var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
+ var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages',
+ 'sql_packages', 'sql_sizing', 'sql_sizing_profiles')
+ union
+ select viewname,'V' from pg_views where viewname not like 'pg\_%'";
+ //"select tablename from pg_tables where tablename not like 'pg_%' order by 1";
+ var $isoDates = true; // accepts dates in ISO format
+ var $sysDate = "CURRENT_DATE";
+ var $sysTimeStamp = "CURRENT_TIMESTAMP";
+ var $blobEncodeType = 'C';
+ var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum
+ FROM pg_class c, pg_attribute a,pg_type t
+ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%'
+AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+
+ // used when schema defined
+ var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
+FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n
+WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
+ and c.relnamespace=n.oid and n.nspname='%s'
+ and a.attname not like '....%%' AND a.attnum > 0
+ AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+
+ // get primary key etc -- from Freek Dijkstra
+ var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key
+ FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'";
+
+ var $hasAffectedRows = true;
+ var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ // below suggested by Freek Dijkstra
+ var $true = 't'; // string that represents TRUE for a database
+ var $false = 'f'; // string that represents FALSE for a database
+ var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
+ var $hasMoveFirst = true;
+ var $hasGenID = true;
+ var $_genIDSQL = "SELECT NEXTVAL('%s')";
+ var $_genSeqSQL = "CREATE SEQUENCE %s START %s";
+ var $_dropSeqSQL = "DROP SEQUENCE %s";
+ var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
+ var $random = 'random()'; /// random function
+ var $concat_operator='||';
+
+ function _init($parentDriver)
+ {
+
+ $parentDriver->hasTransactions = false;
+ }
+
+ function ServerInfo()
+ {
+ $arr['description'] = ADOConnection::GetOne("select version()");
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ return $arr;
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ $offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
+ $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : '';
+ if ($secs2cache)
+ $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
+ else
+ $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
+
+ return $rs;
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $info = $this->ServerInfo();
+ if ($info['version'] >= 7.3) {
+ $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and schemaname not in ( 'pg_catalog','information_schema')
+ union
+ select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') ";
+ }
+ if ($mask) {
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr(strtolower($mask));
+ if ($info['version']>=7.3)
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema')
+ union
+select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') ";
+ else
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask
+ union
+select viewname,'V' from pg_views where viewname like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ function &MetaColumns($table,$normalize=true)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = false;
+ $this->_findschema($table,$schema);
+
+ if ($normalize) $table = strtolower($table);
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
+ else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rs === false) {
+ $false = false;
+ return $false;
+ }
+ if (!empty($this->metaKeySQL)) {
+ // If we want the primary keys, we have to issue a separate query
+ // Of course, a modified version of the metaColumnsSQL query using a
+ // LEFT JOIN would have been much more elegant, but postgres does
+ // not support OUTER JOINS. So here is the clumsy way.
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+
+ $rskey = $this->Execute(sprintf($this->metaKeySQL,($table)));
+ // fetch all result in once for performance.
+ $keys =& $rskey->GetArray();
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ $rskey->Close();
+ unset($rskey);
+ }
+
+ $rsdefa = array();
+ if (!empty($this->metaDefaultsSQL)) {
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $sql = sprintf($this->metaDefaultsSQL, ($table));
+ $rsdef = $this->Execute($sql);
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rsdef) {
+ while (!$rsdef->EOF) {
+ $num = $rsdef->fields['num'];
+ $s = $rsdef->fields['def'];
+ if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
+ $s = substr($s, 1);
+ $s = substr($s, 0, strlen($s) - 1);
+ }
+
+ $rsdefa[$num] = $s;
+ $rsdef->MoveNext();
+ }
+ } else {
+ ADOConnection::outp( "==> SQL => " . $sql);
+ }
+ unset($rsdef);
+ }
+
+ $retarr = array();
+ while (!$rs->EOF) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+ if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4;
+ if ($fld->max_length <= 0) $fld->max_length = -1;
+ if ($fld->type == 'numeric') {
+ $fld->scale = $fld->max_length & 0xFFFF;
+ $fld->max_length >>= 16;
+ }
+ // dannym
+ // 5 hasdefault; 6 num-of-column
+ $fld->has_default = ($rs->fields[5] == 't');
+ if ($fld->has_default) {
+ $fld->default_value = $rsdefa[$rs->fields[6]];
+ }
+
+ //Freek
+ if ($rs->fields[4] == $this->true) {
+ $fld->not_null = true;
+ }
+
+ // Freek
+ if (is_array($keys)) {
+ foreach($keys as $key) {
+ if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true)
+ $fld->primary_key = true;
+ if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true)
+ $fld->unique = true; // What name is more compatible?
+ }
+ }
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if (empty($retarr)) {
+ $false = false;
+ return $false;
+ } else return $retarr;
+
+ }
+
+}
+
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-postgres.inc.php b/html/phpgacl/adodb/drivers/adodb-postgres.inc.php
new file mode 100644
index 0000000..5b36d55
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-postgres.inc.php
@@ -0,0 +1,14 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ NOTE: Since 3.31, this file is no longer used, and the "postgres" driver is
+ remapped to "postgres7". Maintaining multiple postgres drivers is no easy
+ job, so hopefully this will ensure greater consistency and fewer bugs.
+*/
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-postgres64.inc.php b/html/phpgacl/adodb/drivers/adodb-postgres64.inc.php
new file mode 100644
index 0000000..da6c5f2
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-postgres64.inc.php
@@ -0,0 +1,1017 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+
+ Original version derived from Alberto Cerezal (acerezalp@dbnet.es) - DBNet Informatica & Comunicaciones.
+ 08 Nov 2000 jlim - Minor corrections, removing mysql stuff
+ 09 Nov 2000 jlim - added insertid support suggested by "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
+ jlim - changed concat operator to || and data types to MetaType to match documented pgsql types
+ see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm
+ 22 Nov 2000 jlim - added changes to FetchField() and MetaTables() contributed by "raser" <raser@mail.zen.com.tw>
+ 27 Nov 2000 jlim - added changes to _connect/_pconnect from ideas by "Lennie" <leen@wirehub.nl>
+ 15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk.
+ 31 Jan 2002 jlim - finally installed postgresql. testing
+ 01 Mar 2001 jlim - Freek Dijkstra changes, also support for text type
+
+ See http://www.varlena.com/varlena/GeneralBits/47.php
+
+ -- What indexes are on my table?
+ select * from pg_indexes where tablename = 'tablename';
+
+ -- What triggers are on my table?
+ select c.relname as "Table", t.tgname as "Trigger Name",
+ t.tgconstrname as "Constraint Name", t.tgenabled as "Enabled",
+ t.tgisconstraint as "Is Constraint", cc.relname as "Referenced Table",
+ p.proname as "Function Name"
+ from pg_trigger t, pg_class c, pg_class cc, pg_proc p
+ where t.tgfoid = p.oid and t.tgrelid = c.oid
+ and t.tgconstrrelid = cc.oid
+ and c.relname = 'tablename';
+
+ -- What constraints are on my table?
+ select r.relname as "Table", c.conname as "Constraint Name",
+ contype as "Constraint Type", conkey as "Key Columns",
+ confkey as "Foreign Columns", consrc as "Source"
+ from pg_class r, pg_constraint c
+ where r.oid = c.conrelid
+ and relname = 'tablename';
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+function adodb_addslashes($s)
+{
+ $len = strlen($s);
+ if ($len == 0) return "''";
+ if (strncmp($s,"'",1) === 0 && substr(s,$len-1) == "'") return $s; // already quoted
+
+ return "'".addslashes($s)."'";
+}
+
+class ADODB_postgres64 extends ADOConnection{
+ var $databaseType = 'postgres64';
+ var $dataProvider = 'postgres';
+ var $hasInsertID = true;
+ var $_resultid = false;
+ var $concat_operator='||';
+ var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1";
+ var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages',
+ 'sql_packages', 'sql_sizing', 'sql_sizing_profiles')
+ union
+ select viewname,'V' from pg_views where viewname not like 'pg\_%'";
+ //"select tablename from pg_tables where tablename not like 'pg_%' order by 1";
+ var $isoDates = true; // accepts dates in ISO format
+ var $sysDate = "CURRENT_DATE";
+ var $sysTimeStamp = "CURRENT_TIMESTAMP";
+ var $blobEncodeType = 'C';
+ var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum
+ FROM pg_class c, pg_attribute a,pg_type t
+ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%'
+AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+
+ // used when schema defined
+ var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum
+FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n
+WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s'))
+ and c.relnamespace=n.oid and n.nspname='%s'
+ and a.attname not like '....%%' AND a.attnum > 0
+ AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
+
+ // get primary key etc -- from Freek Dijkstra
+ var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key
+ FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'";
+
+ var $hasAffectedRows = true;
+ var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ // below suggested by Freek Dijkstra
+ var $true = 'TRUE'; // string that represents TRUE for a database
+ var $false = 'FALSE'; // string that represents FALSE for a database
+ var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
+ var $hasMoveFirst = true;
+ var $hasGenID = true;
+ var $_genIDSQL = "SELECT NEXTVAL('%s')";
+ var $_genSeqSQL = "CREATE SEQUENCE %s START %s";
+ var $_dropSeqSQL = "DROP SEQUENCE %s";
+ var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
+ var $random = 'random()'; /// random function
+ var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
+ // http://bugs.php.net/bug.php?id=25404
+
+ var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database
+ var $disableBlobs = false; // set to true to disable blob checking, resulting in 2-5% improvement in performance.
+
+ // The last (fmtTimeStamp is not entirely correct:
+ // PostgreSQL also has support for time zones,
+ // and writes these time in this format: "2001-03-01 18:59:26+02".
+ // There is no code for the "+02" time zone information, so I just left that out.
+ // I'm not familiar enough with both ADODB as well as Postgres
+ // to know what the concequences are. The other values are correct (wheren't in 0.94)
+ // -- Freek Dijkstra
+
+ function ADODB_postgres64()
+ {
+ // changes the metaColumnsSQL, adds columns: attnum[6]
+ }
+
+ function ServerInfo()
+ {
+ if (isset($this->version)) return $this->version;
+
+ $arr['description'] = $this->GetOne("select version()");
+ $arr['version'] = ADOConnection::_findvers($arr['description']);
+ $this->version = $arr;
+ return $arr;
+ }
+
+ function IfNull( $field, $ifNull )
+ {
+ return " coalesce($field, $ifNull) ";
+ }
+
+ // get the last id - never tested
+ function pg_insert_id($tablename,$fieldname)
+ {
+ $result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq");
+ if ($result) {
+ $arr = @pg_fetch_row($result,0);
+ pg_freeresult($result);
+ if (isset($arr[0])) return $arr[0];
+ }
+ return false;
+ }
+
+/* Warning from http://www.php.net/manual/function.pg-getlastoid.php:
+Using a OID as a unique identifier is not generally wise.
+Unless you are very careful, you might end up with a tuple having
+a different OID if a database must be reloaded. */
+ function _insertid($table,$column)
+ {
+ if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
+ $oid = pg_getlastoid($this->_resultid);
+ // to really return the id, we need the table and column-name, else we can only return the oid != id
+ return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid);
+ }
+
+// I get this error with PHP before 4.0.6 - jlim
+// Warning: This compilation does not support pg_cmdtuples() in d:/inetpub/wwwroot/php/adodb/adodb-postgres.inc.php on line 44
+ function _affectedrows()
+ {
+ if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
+ return pg_cmdtuples($this->_resultid);
+ }
+
+
+ // returns true/false
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+ return @pg_Exec($this->_connectionID, "begin");
+ }
+
+ function RowLock($tables,$where,$flds='1 as ignore')
+ {
+ if (!$this->transCnt) $this->BeginTrans();
+ return $this->GetOne("select $flds from $tables where $where for update");
+ }
+
+ // returns true/false.
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+
+ $this->transCnt -= 1;
+ return @pg_Exec($this->_connectionID, "commit");
+ }
+
+ // returns true/false
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt -= 1;
+ return @pg_Exec($this->_connectionID, "rollback");
+ }
+
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $info = $this->ServerInfo();
+ if ($info['version'] >= 7.3) {
+ $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%'
+ and schemaname not in ( 'pg_catalog','information_schema')
+ union
+ select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') ";
+ }
+ if ($mask) {
+ $save = $this->metaTablesSQL;
+ $mask = $this->qstr(strtolower($mask));
+ if ($info['version']>=7.3)
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema')
+ union
+select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') ";
+ else
+ $this->metaTablesSQL = "
+select tablename,'T' from pg_tables where tablename like $mask
+ union
+select viewname,'V' from pg_views where viewname like $mask";
+ }
+ $ret =& ADOConnection::MetaTables($ttype,$showSchema);
+
+ if ($mask) {
+ $this->metaTablesSQL = $save;
+ }
+ return $ret;
+ }
+
+ /*
+ // if magic quotes disabled, use pg_escape_string()
+ function qstr($s,$magic_quotes=false)
+ {
+ if (!$magic_quotes) {
+ if (ADODB_PHPVER >= 0x4200) {
+ return "'".pg_escape_string($s)."'";
+ }
+ if ($this->replaceQuote[0] == '\\'){
+ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+ }
+ return "'".str_replace("'",$this->replaceQuote,$s)."'";
+ }
+
+ // undo magic quotes for "
+ $s = str_replace('\\"','"',$s);
+ return "'$s'";
+ }
+ */
+
+
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = 'TO_CHAR('.$col.",'";
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= 'YYYY';
+ break;
+ case 'Q':
+ case 'q':
+ $s .= 'Q';
+ break;
+
+ case 'M':
+ $s .= 'Mon';
+ break;
+
+ case 'm':
+ $s .= 'MM';
+ break;
+ case 'D':
+ case 'd':
+ $s .= 'DD';
+ break;
+
+ case 'H':
+ $s.= 'HH24';
+ break;
+
+ case 'h':
+ $s .= 'HH';
+ break;
+
+ case 'i':
+ $s .= 'MI';
+ break;
+
+ case 's':
+ $s .= 'SS';
+ break;
+
+ case 'a':
+ case 'A':
+ $s .= 'AM';
+ break;
+
+ case 'w':
+ $s .= 'D';
+ break;
+
+ case 'l':
+ $s .= 'DAY';
+ break;
+
+ default:
+ // handle escape characters...
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ if (strpos('-/.:;, ',$ch) !== false) $s .= $ch;
+ else $s .= '"'.$ch.'"';
+
+ }
+ }
+ return $s. "')";
+ }
+
+
+
+ /*
+ * Load a Large Object from a file
+ * - the procedure stores the object id in the table and imports the object using
+ * postgres proprietary blob handling routines
+ *
+ * contributed by Mattia Rossi mattia@technologist.com
+ * modified for safe mode by juraj chlebec
+ */
+ function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')
+ {
+ pg_exec ($this->_connectionID, "begin");
+
+ $fd = fopen($path,'r');
+ $contents = fread($fd,filesize($path));
+ fclose($fd);
+
+ $oid = pg_lo_create($this->_connectionID);
+ $handle = pg_lo_open($this->_connectionID, $oid, 'w');
+ pg_lo_write($handle, $contents);
+ pg_lo_close($handle);
+
+ // $oid = pg_lo_import ($path);
+ pg_exec($this->_connectionID, "commit");
+ $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype);
+ $rez = !empty($rs);
+ return $rez;
+ }
+
+ /*
+ Hueristic - not guaranteed to work.
+ */
+ function GuessOID($oid)
+ {
+ if (strlen($oid)>16) return false;
+ return is_numeric($oid);
+ }
+
+ /*
+ * If an OID is detected, then we use pg_lo_* to open the oid file and read the
+ * real blob from the db using the oid supplied as a parameter. If you are storing
+ * blobs using bytea, we autodetect and process it so this function is not needed.
+ *
+ * contributed by Mattia Rossi mattia@technologist.com
+ *
+ * see http://www.postgresql.org/idocs/index.php?largeobjects.html
+ *
+ * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also
+ * added maxsize parameter, which defaults to $db->maxblobsize if not defined.
+ */
+ function BlobDecode($blob,$maxsize=false,$hastrans=true)
+ {
+ if (!$this->GuessOID($blob)) return $blob;
+
+ if ($hastrans) @pg_exec($this->_connectionID,"begin");
+ $fd = @pg_lo_open($this->_connectionID,$blob,"r");
+ if ($fd === false) {
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
+ return $blob;
+ }
+ if (!$maxsize) $maxsize = $this->maxblobsize;
+ $realblob = @pg_loread($fd,$maxsize);
+ @pg_loclose($fd);
+ if ($hastrans) @pg_exec($this->_connectionID,"commit");
+ return $realblob;
+ }
+
+ /*
+ See http://www.postgresql.org/idocs/index.php?datatype-binary.html
+
+ NOTE: SQL string literals (input strings) must be preceded with two backslashes
+ due to the fact that they must pass through two parsers in the PostgreSQL
+ backend.
+ */
+ function BlobEncode($blob)
+ {
+ if (ADODB_PHPVER >= 0x4200) return pg_escape_bytea($blob);
+
+ /*92=backslash, 0=null, 39=single-quote*/
+ $badch = array(chr(92),chr(0),chr(39)); # \ null '
+ $fixch = array('\\\\134','\\\\000','\\\\047');
+ return adodb_str_replace($badch,$fixch,$blob);
+
+ // note that there is a pg_escape_bytea function only for php 4.2.0 or later
+ }
+
+ // assumes bytea for blob, and varchar for clob
+ function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
+ {
+
+ if ($blobtype == 'CLOB') {
+ return $this->Execute("UPDATE $table SET $column=" . $this->qstr($val) . " WHERE $where");
+ }
+ // do not use bind params which uses qstr(), as blobencode() already quotes data
+ return $this->Execute("UPDATE $table SET $column='".$this->BlobEncode($val)."'::bytea WHERE $where");
+ }
+
+ function OffsetDate($dayFraction,$date=false)
+ {
+ if (!$date) $date = $this->sysDate;
+ return "($date+interval'$dayFraction days')";
+ }
+
+
+ // for schema support, pass in the $table param "$schema.$tabname".
+ // converts field names to lowercase, $upper is ignored
+ function &MetaColumns($table,$normalize=true)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = false;
+ $false = false;
+ $this->_findschema($table,$schema);
+
+ if ($normalize) $table = strtolower($table);
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+
+ if ($schema) $rs =& $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema));
+ else $rs =& $this->Execute(sprintf($this->metaColumnsSQL,$table,$table));
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rs === false) {
+ return $false;
+ }
+ if (!empty($this->metaKeySQL)) {
+ // If we want the primary keys, we have to issue a separate query
+ // Of course, a modified version of the metaColumnsSQL query using a
+ // LEFT JOIN would have been much more elegant, but postgres does
+ // not support OUTER JOINS. So here is the clumsy way.
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+
+ $rskey = $this->Execute(sprintf($this->metaKeySQL,($table)));
+ // fetch all result in once for performance.
+ $keys =& $rskey->GetArray();
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ $rskey->Close();
+ unset($rskey);
+ }
+
+ $rsdefa = array();
+ if (!empty($this->metaDefaultsSQL)) {
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $sql = sprintf($this->metaDefaultsSQL, ($table));
+ $rsdef = $this->Execute($sql);
+ if (isset($savem)) $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if ($rsdef) {
+ while (!$rsdef->EOF) {
+ $num = $rsdef->fields['num'];
+ $s = $rsdef->fields['def'];
+ if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */
+ $s = substr($s, 1);
+ $s = substr($s, 0, strlen($s) - 1);
+ }
+
+ $rsdefa[$num] = $s;
+ $rsdef->MoveNext();
+ }
+ } else {
+ ADOConnection::outp( "==> SQL => " . $sql);
+ }
+ unset($rsdef);
+ }
+
+ $retarr = array();
+ while (!$rs->EOF) {
+ $fld = new ADOFieldObject();
+ $fld->name = $rs->fields[0];
+ $fld->type = $rs->fields[1];
+ $fld->max_length = $rs->fields[2];
+ if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4;
+ if ($fld->max_length <= 0) $fld->max_length = -1;
+ if ($fld->type == 'numeric') {
+ $fld->scale = $fld->max_length & 0xFFFF;
+ $fld->max_length >>= 16;
+ }
+ // dannym
+ // 5 hasdefault; 6 num-of-column
+ $fld->has_default = ($rs->fields[5] == 't');
+ if ($fld->has_default) {
+ $fld->default_value = $rsdefa[$rs->fields[6]];
+ }
+
+ //Freek
+ if ($rs->fields[4] == 't') {
+ $fld->not_null = true;
+ }
+
+ // Freek
+ if (is_array($keys)) {
+ foreach($keys as $key) {
+ if ($fld->name == $key['column_name'] AND $key['primary_key'] == 't')
+ $fld->primary_key = true;
+ if ($fld->name == $key['column_name'] AND $key['unique_key'] == 't')
+ $fld->unique = true; // What name is more compatible?
+ }
+ }
+
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
+ else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld;
+
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ if (empty($retarr))
+ return $false;
+ else
+ return $retarr;
+
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $schema = false;
+ $this->_findschema($table,$schema);
+
+ if ($schema) { // requires pgsql 7.3+ - pg_namespace used.
+ $sql = '
+SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns"
+FROM pg_catalog.pg_class c
+JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
+JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
+ ,pg_namespace n
+WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\' AND i.indisprimary=false';
+ } else {
+ $sql = '
+SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns"
+FROM pg_catalog.pg_class c
+JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid
+JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid
+WHERE c2.relname=\'%s\' or c2.relname=lower(\'%s\')';
+ }
+
+ if ($primary == FALSE) {
+ $sql .= ' AND i.indisprimary=false;';
+ }
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ $rs = $this->Execute(sprintf($sql,$table,$table,$schema));
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ $false = false;
+ return $false;
+ }
+
+ $col_names = $this->MetaColumnNames($table,true);
+ $indexes = array();
+ while ($row = $rs->FetchRow()) {
+ $columns = array();
+ foreach (explode(' ', $row[2]) as $col) {
+ $columns[] = $col_names[$col - 1];
+ }
+
+ $indexes[$row[0]] = array(
+ 'unique' => ($row[1] == 't'),
+ 'columns' => $columns
+ );
+ }
+ return $indexes;
+ }
+
+ // returns true or false
+ //
+ // examples:
+ // $db->Connect("host=host1 user=user1 password=secret port=4341");
+ // $db->Connect('host1','user1','secret');
+ function _connect($str,$user='',$pwd='',$db='',$ctype=0)
+ {
+
+ if (!function_exists('pg_pconnect')) return null;
+
+ $this->_errorMsg = false;
+
+ if ($user || $pwd || $db) {
+ $user = adodb_addslashes($user);
+ $pwd = adodb_addslashes($pwd);
+ if (strlen($db) == 0) $db = 'template1';
+ $db = adodb_addslashes($db);
+ if ($str) {
+ $host = split(":", $str);
+ if ($host[0]) $str = "host=".adodb_addslashes($host[0]);
+ else $str = 'host=localhost';
+ if (isset($host[1])) $str .= " port=$host[1]";
+ else if (!empty($this->port)) $str .= " port=".$this->port;
+ }
+ if ($user) $str .= " user=".$user;
+ if ($pwd) $str .= " password=".$pwd;
+ if ($db) $str .= " dbname=".$db;
+ }
+
+ //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432";
+
+ if ($ctype === 1) { // persistent
+ $this->_connectionID = pg_pconnect($str);
+ } else {
+ if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str
+ static $ncnt;
+
+ if (empty($ncnt)) $ncnt = 1;
+ else $ncnt += 1;
+
+ $str .= str_repeat(' ',$ncnt);
+ }
+ $this->_connectionID = pg_connect($str);
+ }
+ if ($this->_connectionID === false) return false;
+ $this->Execute("set datestyle='ISO'");
+ return true;
+ }
+
+ function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName)
+ {
+ return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName,-1);
+ }
+
+ // returns true or false
+ //
+ // examples:
+ // $db->PConnect("host=host1 user=user1 password=secret port=4341");
+ // $db->PConnect('host1','user1','secret');
+ function _pconnect($str,$user='',$pwd='',$db='')
+ {
+ return $this->_connect($str,$user,$pwd,$db,1);
+ }
+
+
+ // returns queryID or false
+ function _query($sql,$inputarr)
+ {
+
+ if ($inputarr) {
+ /*
+ It appears that PREPARE/EXECUTE is slower for many queries.
+
+ For query executed 1000 times:
+ "select id,firstname,lastname from adoxyz
+ where firstname not like ? and lastname not like ? and id = ?"
+
+ with plan = 1.51861286163 secs
+ no plan = 1.26903700829 secs
+
+
+
+ */
+ $plan = 'P'.md5($sql);
+
+ $execp = '';
+ foreach($inputarr as $v) {
+ if ($execp) $execp .= ',';
+ if (is_string($v)) {
+ if (strncmp($v,"'",1) !== 0) $execp .= $this->qstr($v);
+ } else {
+ $execp .= $v;
+ }
+ }
+
+ if ($execp) $exsql = "EXECUTE $plan ($execp)";
+ else $exsql = "EXECUTE $plan";
+
+ $rez = @pg_exec($this->_connectionID,$exsql);
+ if (!$rez) {
+ # Perhaps plan does not exist? Prepare/compile plan.
+ $params = '';
+ foreach($inputarr as $v) {
+ if ($params) $params .= ',';
+ if (is_string($v)) {
+ $params .= 'VARCHAR';
+ } else if (is_integer($v)) {
+ $params .= 'INTEGER';
+ } else {
+ $params .= "REAL";
+ }
+ }
+ $sqlarr = explode('?',$sql);
+ //print_r($sqlarr);
+ $sql = '';
+ $i = 1;
+ foreach($sqlarr as $v) {
+ $sql .= $v.' $'.$i;
+ $i++;
+ }
+ $s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2);
+ //adodb_pr($s);
+ pg_exec($this->_connectionID,$s);
+ echo $this->ErrorMsg();
+ }
+
+ $rez = pg_exec($this->_connectionID,$exsql);
+ } else {
+ $this->_errorMsg = false;
+ //adodb_backtrace();
+ $rez = pg_exec($this->_connectionID,$sql);
+ }
+ // check if no data returned, then no need to create real recordset
+ if ($rez && pg_numfields($rez) <= 0) {
+ if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') {
+ pg_freeresult($this->_resultid);
+ }
+ $this->_resultid = $rez;
+ return true;
+ }
+
+ return $rez;
+ }
+
+
+ /* Returns: the last error message from previous database operation */
+ function ErrorMsg()
+ {
+ if ($this->_errorMsg !== false) return $this->_errorMsg;
+ if (ADODB_PHPVER >= 0x4300) {
+ if (!empty($this->_resultid)) {
+ $this->_errorMsg = @pg_result_error($this->_resultid);
+ if ($this->_errorMsg) return $this->_errorMsg;
+ }
+
+ if (!empty($this->_connectionID)) {
+ $this->_errorMsg = @pg_last_error($this->_connectionID);
+ } else $this->_errorMsg = @pg_last_error();
+ } else {
+ if (empty($this->_connectionID)) $this->_errorMsg = @pg_errormessage();
+ else $this->_errorMsg = @pg_errormessage($this->_connectionID);
+ }
+ return $this->_errorMsg;
+ }
+
+ function ErrorNo()
+ {
+ $e = $this->ErrorMsg();
+ if (strlen($e)) {
+ return ADOConnection::MetaError($e);
+ }
+ return 0;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ if ($this->transCnt) $this->RollbackTrans();
+ if ($this->_resultid) {
+ @pg_freeresult($this->_resultid);
+ $this->_resultid = false;
+ }
+ @pg_close($this->_connectionID);
+ $this->_connectionID = false;
+ return true;
+ }
+
+
+ /*
+ * Maximum size of C field
+ */
+ function CharMax()
+ {
+ return 1000000000; // should be 1 Gb?
+ }
+
+ /*
+ * Maximum size of X field
+ */
+ function TextMax()
+ {
+ return 1000000000; // should be 1 Gb?
+ }
+
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_postgres64 extends ADORecordSet{
+ var $_blobArr;
+ var $databaseType = "postgres64";
+ var $canSeek = true;
+ function ADORecordSet_postgres64($queryID,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch ($mode)
+ {
+ case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break;
+ case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break;
+
+ case ADODB_FETCH_DEFAULT:
+ case ADODB_FETCH_BOTH:
+ default: $this->fetchMode = PGSQL_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+ $this->ADORecordSet($queryID);
+ }
+
+ function &GetRowAssoc($upper=true)
+ {
+ if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields;
+ $row =& ADORecordSet::GetRowAssoc($upper);
+ return $row;
+ }
+
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+ $qid = $this->_queryID;
+ $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1;
+ $this->_numOfFields = @pg_numfields($qid);
+
+ // cache types for blob decode check
+ // apparently pg_fieldtype actually performs an sql query on the database to get the type.
+ if (empty($this->connection->noBlobs))
+ for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) {
+ if (pg_fieldtype($qid,$i) == 'bytea') {
+ $this->_blobArr[$i] = pg_fieldname($qid,$i);
+ }
+ }
+ }
+
+ /* Use associative array to get fields array */
+ function Fields($colname)
+ {
+ if ($this->fetchMode != PGSQL_NUM) return @$this->fields[$colname];
+
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function &FetchField($off = 0)
+ {
+ // offsets begin at 0
+
+ $o= new ADOFieldObject();
+ $o->name = @pg_fieldname($this->_queryID,$off);
+ $o->type = @pg_fieldtype($this->_queryID,$off);
+ $o->max_length = @pg_fieldsize($this->_queryID,$off);
+ return $o;
+ }
+
+ function _seek($row)
+ {
+ return @pg_fetch_row($this->_queryID,$row);
+ }
+
+ function _decode($blob)
+ {
+ eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";');
+ return $realblob;
+ }
+
+ function _fixblobs()
+ {
+ if ($this->fetchMode == PGSQL_NUM || $this->fetchMode == PGSQL_BOTH) {
+ foreach($this->_blobArr as $k => $v) {
+ $this->fields[$k] = ADORecordSet_postgres64::_decode($this->fields[$k]);
+ }
+ }
+ if ($this->fetchMode == PGSQL_ASSOC || $this->fetchMode == PGSQL_BOTH) {
+ foreach($this->_blobArr as $k => $v) {
+ $this->fields[$v] = ADORecordSet_postgres64::_decode($this->fields[$v]);
+ }
+ }
+ }
+
+ // 10% speedup to move MoveNext to child class
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+ if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+ if (is_array($this->fields) && $this->fields) {
+ if (isset($this->_blobArr)) $this->_fixblobs();
+ return true;
+ }
+ }
+ $this->fields = false;
+ $this->EOF = true;
+ }
+ return false;
+ }
+
+ function _fetch()
+ {
+
+ if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0)
+ return false;
+
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+
+ return (is_array($this->fields));
+ }
+
+ function _close()
+ {
+ return @pg_freeresult($this->_queryID);
+ }
+
+ function MetaType($t,$len=-1,$fieldobj=false)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'MONEY': // stupid, postgres expects money to be a string
+ case 'INTERVAL':
+ case 'CHAR':
+ case 'CHARACTER':
+ case 'VARCHAR':
+ case 'NAME':
+ case 'BPCHAR':
+ case '_VARCHAR':
+ case 'INET':
+ if ($len <= $this->blobSize) return 'C';
+
+ case 'TEXT':
+ return 'X';
+
+ case 'IMAGE': // user defined type
+ case 'BLOB': // user defined type
+ case 'BIT': // This is a bit string, not a single bit, so don't return 'L'
+ case 'VARBIT':
+ case 'BYTEA':
+ return 'B';
+
+ case 'BOOL':
+ case 'BOOLEAN':
+ return 'L';
+
+ case 'DATE':
+ return 'D';
+
+ case 'TIME':
+ case 'DATETIME':
+ case 'TIMESTAMP':
+ case 'TIMESTAMPTZ':
+ return 'T';
+
+ case 'SMALLINT':
+ case 'BIGINT':
+ case 'INTEGER':
+ case 'INT8':
+ case 'INT4':
+ case 'INT2':
+ if (isset($fieldobj) &&
+ empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I';
+
+ case 'OID':
+ case 'SERIAL':
+ return 'R';
+
+ default:
+ return 'N';
+ }
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-postgres7.inc.php b/html/phpgacl/adodb/drivers/adodb-postgres7.inc.php
new file mode 100644
index 0000000..dc0c08e
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-postgres7.inc.php
@@ -0,0 +1,230 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim#natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ Postgres7 support.
+ 28 Feb 2001: Currently indicate that we support LIMIT
+ 01 Dec 2001: dannym added support for default values
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR."/drivers/adodb-postgres64.inc.php");
+
+class ADODB_postgres7 extends ADODB_postgres64 {
+ var $databaseType = 'postgres7';
+ var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ var $ansiOuter = true;
+ var $charSet = true; //set to true for Postgres 7 and above - PG client supports encodings
+
+ function ADODB_postgres7()
+ {
+ $this->ADODB_postgres64();
+ if (ADODB_ASSOC_CASE !== 2) {
+ $this->rsPrefix .= 'assoc_';
+ }
+ }
+
+
+ // the following should be compat with postgresql 7.2,
+ // which makes obsolete the LIMIT limit,offset syntax
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ $offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
+ $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : '';
+ if ($secs2cache)
+ $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
+ else
+ $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
+
+ return $rs;
+ }
+ /*
+ function Prepare($sql)
+ {
+ $info = $this->ServerInfo();
+ if ($info['version']>=7.3) {
+ return array($sql,false);
+ }
+ return $sql;
+ }
+ */
+
+ // from Edward Jaramilla, improved version - works on pg 7.4
+function MetaForeignKeys($table, $owner=false, $upper=false)
+{
+ $sql = 'SELECT t.tgargs as args
+ FROM
+ pg_trigger t,pg_class c,pg_proc p
+ WHERE
+ t.tgenabled AND
+ t.tgrelid = c.oid AND
+ t.tgfoid = p.oid AND
+ p.proname = \'RI_FKey_check_ins\' AND
+ c.relname = \''.strtolower($table).'\'
+ ORDER BY
+ t.tgrelid';
+
+ $rs = $this->Execute($sql);
+
+ if ($rs && !$rs->EOF) {
+ $arr =& $rs->GetArray();
+ $a = array();
+ foreach($arr as $v)
+ {
+ $data = explode(chr(0), $v['args']);
+ if ($upper) {
+ $a[strtoupper($data[2])][] = strtoupper($data[4].'='.$data[5]);
+ } else {
+ $a[$data[2]][] = $data[4].'='.$data[5];
+ }
+ }
+ return $a;
+ }
+ return false;
+}
+
+
+
+ // this is a set of functions for managing client encoding - very important if the encodings
+ // of your database and your output target (i.e. HTML) don't match
+ //for instance, you may have UNICODE database and server it on-site as WIN1251 etc.
+ // GetCharSet - get the name of the character set the client is using now
+ // the functions should work with Postgres 7.0 and above, the set of charsets supported
+ // depends on compile flags of postgres distribution - if no charsets were compiled into the server
+ // it will return 'SQL_ANSI' always
+ function GetCharSet()
+ {
+ //we will use ADO's builtin property charSet
+ $this->charSet = @pg_client_encoding($this->_connectionID);
+ if (!$this->charSet) {
+ return false;
+ } else {
+ return $this->charSet;
+ }
+ }
+
+ // SetCharSet - switch the client encoding
+ function SetCharSet($charset_name)
+ {
+ $this->GetCharSet();
+ if ($this->charSet !== $charset_name) {
+ $if = pg_set_client_encoding($this->_connectionID, $charset_name);
+ if ($if == "0" & $this->GetCharSet() == $charset_name) {
+ return true;
+ } else return false;
+ } else return true;
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_postgres7 extends ADORecordSet_postgres64{
+
+ var $databaseType = "postgres7";
+
+
+ function ADORecordSet_postgres7($queryID,$mode=false)
+ {
+ $this->ADORecordSet_postgres64($queryID,$mode);
+ }
+
+ // 10% speedup to move MoveNext to child class
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+ if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if (is_array($this->fields)) {
+ if ($this->fields && isset($this->_blobArr)) $this->_fixblobs();
+ return true;
+ }
+ }
+ $this->fields = false;
+ $this->EOF = true;
+ }
+ return false;
+ }
+
+}
+
+class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{
+
+ var $databaseType = "postgres7";
+
+
+ function ADORecordSet_assoc_postgres7($queryID,$mode=false)
+ {
+ $this->ADORecordSet_postgres64($queryID,$mode);
+ }
+
+ function _fetch()
+ {
+ if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0)
+ return false;
+
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if ($this->fields) {
+ if (isset($this->_blobArr)) $this->_fixblobs();
+ $this->_updatefields();
+ }
+
+ return (is_array($this->fields));
+ }
+
+ // Create associative array
+ function _updatefields()
+ {
+ if (ADODB_ASSOC_CASE == 2) return; // native
+
+ $arr = array();
+ $lowercase = (ADODB_ASSOC_CASE == 0);
+
+ foreach($this->fields as $k => $v) {
+ if (is_integer($k)) $arr[$k] = $v;
+ else {
+ if ($lowercase)
+ $arr[strtolower($k)] = $v;
+ else
+ $arr[strtoupper($k)] = $v;
+ }
+ }
+ $this->fields = $arr;
+ }
+
+ function MoveNext()
+ {
+ if (!$this->EOF) {
+ $this->_currentRow++;
+ if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) {
+ $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode);
+
+ if (is_array($this->fields)) {
+ if ($this->fields) {
+ if (isset($this->_blobArr)) $this->_fixblobs();
+
+ $this->_updatefields();
+ }
+ return true;
+ }
+ }
+
+
+ $this->fields = false;
+ $this->EOF = true;
+ }
+ return false;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-postgres8.inc.php b/html/phpgacl/adodb/drivers/adodb-postgres8.inc.php
new file mode 100644
index 0000000..9e3d060
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-postgres8.inc.php
@@ -0,0 +1,12 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ NOTE: The "postgres8" driver is remapped to "postgres7".
+*/
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-proxy.inc.php b/html/phpgacl/adodb/drivers/adodb-proxy.inc.php
new file mode 100644
index 0000000..e481ddd
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-proxy.inc.php
@@ -0,0 +1,33 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4.
+
+ Synonym for csv driver.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (! defined("_ADODB_PROXY_LAYER")) {
+ define("_ADODB_PROXY_LAYER", 1 );
+ include(ADODB_DIR."/drivers/adodb-csv.inc.php");
+
+ class ADODB_proxy extends ADODB_csv {
+ var $databaseType = 'proxy';
+ var $databaseProvider = 'csv';
+ }
+ class ADORecordset_proxy extends ADORecordset_csv {
+ var $databaseType = "proxy";
+
+ function ADORecordset_proxy($id,$mode=false)
+ {
+ $this->ADORecordset($id,$mode);
+ }
+ };
+} // define
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-sapdb.inc.php b/html/phpgacl/adodb/drivers/adodb-sapdb.inc.php
new file mode 100644
index 0000000..1955919
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sapdb.inc.php
@@ -0,0 +1,184 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ SAPDB data driver. Requires ODBC.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+if (!defined('ADODB_SAPDB')){
+define('ADODB_SAPDB',1);
+
+class ADODB_SAPDB extends ADODB_odbc {
+ var $databaseType = "sapdb";
+ var $concat_operator = '||';
+ var $sysDate = 'DATE';
+ var $sysTimeStamp = 'TIMESTAMP';
+ var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d H:i:s'"; /// used by DBTimeStamp as the default timestamp fmt.
+ var $hasInsertId = true;
+ var $_bindInputArray = true;
+
+ function ADODB_SAPDB()
+ {
+ //if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC;
+ $this->ADODB_odbc();
+ }
+
+ function ServerInfo()
+ {
+ $info = ADODB_odbc::ServerInfo();
+ if (!$info['version'] && preg_match('/([0-9.]+)/',$info['description'],$matches)) {
+ $info['version'] = $matches[1];
+ }
+ return $info;
+ }
+
+ function MetaPrimaryKeys($table)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos");
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ $sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ".
+ " WHERE TABLENAME=$table".
+ " ORDER BY INDEXNAME,COLUMNNO";
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+
+ $rs = $this->Execute($sql);
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ if (!is_object($rs)) {
+ return FALSE;
+ }
+
+ $indexes = array();
+ while ($row = $rs->FetchRow()) {
+ $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE';
+ $indexes[$row[0]]['columns'][] = $row[2];
+ }
+ if ($primary) {
+ $indexes['SYSPRIMARYKEYINDEX'] = array(
+ 'unique' => True, // by definition
+ 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"),
+ );
+ }
+ return $indexes;
+ }
+
+ function &MetaColumns ($table)
+ {
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $table = $this->Quote(strtoupper($table));
+
+ $retarr = array();
+ foreach($this->GetAll("SELECT COLUMNNAME,DATATYPE,LEN,DEC,NULLABLE,MODE,\"DEFAULT\",CASE WHEN \"DEFAULT\" IS NULL THEN 0 ELSE 1 END AS HAS_DEFAULT FROM COLUMNS WHERE tablename=$table ORDER BY pos") as $column)
+ {
+ $fld = new ADOFieldObject();
+ $fld->name = $column[0];
+ $fld->type = $column[1];
+ $fld->max_length = $fld->type == 'LONG' ? 2147483647 : $column[2];
+ $fld->scale = $column[3];
+ $fld->not_null = $column[4] == 'NO';
+ $fld->primary_key = $column[5] == 'KEY';
+ if ($fld->has_default = $column[7]) {
+ if ($fld->primary_key && $column[6] == 'DEFAULT SERIAL (1)') {
+ $fld->auto_increment = true;
+ $fld->has_default = false;
+ } else {
+ $fld->default_value = $column[6];
+ switch($fld->type) {
+ case 'VARCHAR':
+ case 'CHARACTER':
+ case 'LONG':
+ $fld->default_value = $column[6];
+ break;
+ default:
+ $fld->default_value = trim($column[6]);
+ break;
+ }
+ }
+ }
+ $retarr[$fld->name] = $fld;
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ }
+ $ADODB_FETCH_MODE = $save;
+
+ return $retarr;
+ }
+
+ function MetaColumnNames($table)
+ {
+ $table = $this->Quote(strtoupper($table));
+
+ return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos");
+ }
+
+ // unlike it seems, this depends on the db-session and works in a multiuser environment
+ function _insertid($table,$column)
+ {
+ return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL");
+ }
+
+ /*
+ SelectLimit implementation problems:
+
+ The following will return random 10 rows as order by performed after "WHERE rowno<10"
+ which is not ideal...
+
+ select * from table where rowno < 10 order by 1
+
+ This means that we have to use the adoconnection base class SelectLimit when
+ there is an "order by".
+
+ See http://listserv.sap.com/pipermail/sapdb.general/2002-January/010405.html
+ */
+
+};
+
+
+class ADORecordSet_sapdb extends ADORecordSet_odbc {
+
+ var $databaseType = "sapdb";
+
+ function ADORecordSet_sapdb($id,$mode=false)
+ {
+ $this->ADORecordSet_odbc($id,$mode);
+ }
+}
+
+} //define
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-sqlanywhere.inc.php b/html/phpgacl/adodb/drivers/adodb-sqlanywhere.inc.php
new file mode 100644
index 0000000..4cb5d4f
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sqlanywhere.inc.php
@@ -0,0 +1,169 @@
+<?php
+/*
+version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights
+reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ 21.02.2002 - Wade Johnson wade@wadejohnson.de
+ Extended ODBC class for Sybase SQLAnywhere.
+ 1) Added support to retrieve the last row insert ID on tables with
+ primary key column using autoincrement function.
+
+ 2) Added blob support. Usage:
+ a) create blob variable on db server:
+
+ $dbconn->create_blobvar($blobVarName);
+
+ b) load blob var from file. $filename must be complete path
+
+ $dbcon->load_blobvar_from_file($blobVarName, $filename);
+
+ c) Use the $blobVarName in SQL insert or update statement in the values
+ clause:
+
+ $recordSet = $dbconn->Execute('INSERT INTO tabname (idcol, blobcol) '
+ .
+ 'VALUES (\'test\', ' . $blobVarName . ')');
+
+ instead of loading blob from a file, you can also load from
+ an unformatted (raw) blob variable:
+ $dbcon->load_blobvar_from_var($blobVarName, $varName);
+
+ d) drop blob variable on db server to free up resources:
+ $dbconn->drop_blobvar($blobVarName);
+
+ Sybase_SQLAnywhere data driver. Requires ODBC.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+
+if (!defined('ADODB_SYBASE_SQLANYWHERE')){
+
+ define('ADODB_SYBASE_SQLANYWHERE',1);
+
+ class ADODB_sqlanywhere extends ADODB_odbc {
+ var $databaseType = "sqlanywhere";
+ var $hasInsertID = true;
+
+ function ADODB_sqlanywhere()
+ {
+ $this->ADODB_odbc();
+ }
+
+ function _insertid() {
+ return $this->GetOne('select @@identity');
+ }
+
+ function create_blobvar($blobVarName) {
+ $this->Execute("create variable $blobVarName long binary");
+ return;
+ }
+
+ function drop_blobvar($blobVarName) {
+ $this->Execute("drop variable $blobVarName");
+ return;
+ }
+
+ function load_blobvar_from_file($blobVarName, $filename) {
+ $chunk_size = 1000;
+
+ $fd = fopen ($filename, "rb");
+
+ $integer_chunks = (integer)filesize($filename) / $chunk_size;
+ $modulus = filesize($filename) % $chunk_size;
+ if ($modulus != 0){
+ $integer_chunks += 1;
+ }
+
+ for($loop=1;$loop<=$integer_chunks;$loop++){
+ $contents = fread ($fd, $chunk_size);
+ $contents = bin2hex($contents);
+
+ $hexstring = '';
+
+ for($loop2=0;$loop2<strlen($contents);$loop2+=2){
+ $hexstring .= '\x' . substr($contents,$loop2,2);
+ }
+
+ $hexstring = $this->qstr($hexstring);
+
+ $this->Execute("set $blobVarName = $blobVarName || " . $hexstring);
+ }
+
+ fclose ($fd);
+ return;
+ }
+
+ function load_blobvar_from_var($blobVarName, &$varName) {
+ $chunk_size = 1000;
+
+ $integer_chunks = (integer)strlen($varName) / $chunk_size;
+ $modulus = strlen($varName) % $chunk_size;
+ if ($modulus != 0){
+ $integer_chunks += 1;
+ }
+
+ for($loop=1;$loop<=$integer_chunks;$loop++){
+ $contents = substr ($varName, (($loop - 1) * $chunk_size), $chunk_size);
+ $contents = bin2hex($contents);
+
+ $hexstring = '';
+
+ for($loop2=0;$loop2<strlen($contents);$loop2+=2){
+ $hexstring .= '\x' . substr($contents,$loop2,2);
+ }
+
+ $hexstring = $this->qstr($hexstring);
+
+ $this->Execute("set $blobVarName = $blobVarName || " . $hexstring);
+ }
+
+ return;
+ }
+
+ /*
+ Insert a null into the blob field of the table first.
+ Then use UpdateBlob to store the blob.
+
+ Usage:
+
+ $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
+ $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
+ */
+ function UpdateBlob($table,$column,&$val,$where,$blobtype='BLOB')
+ {
+ $blobVarName = 'hold_blob';
+ $this->create_blobvar($blobVarName);
+ $this->load_blobvar_from_var($blobVarName, $val);
+ $this->Execute("UPDATE $table SET $column=$blobVarName WHERE $where");
+ $this->drop_blobvar($blobVarName);
+ return true;
+ }
+ }; //class
+
+ class ADORecordSet_sqlanywhere extends ADORecordSet_odbc {
+
+ var $databaseType = "sqlanywhere";
+
+ function ADORecordSet_sqlanywhere($id,$mode=false)
+ {
+ $this->ADORecordSet_odbc($id,$mode);
+ }
+
+
+ }; //class
+
+
+} //define
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-sqlite.inc.php b/html/phpgacl/adodb/drivers/adodb-sqlite.inc.php
new file mode 100644
index 0000000..ee77243
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sqlite.inc.php
@@ -0,0 +1,373 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ SQLite info: http://www.hwaci.com/sw/sqlite/
+
+ Install Instructions:
+ ====================
+ 1. Place this in adodb/drivers
+ 2. Rename the file, remove the .txt prefix.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB_sqlite extends ADOConnection {
+ var $databaseType = "sqlite";
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $concat_operator='||';
+ var $_errorNo = 0;
+ var $hasLimit = true;
+ var $hasInsertID = true; /// supports autoincrement ID?
+ var $hasAffectedRows = true; /// supports affected rows for update/delete?
+ var $metaTablesSQL = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";
+ var $sysDate = "adodb_date('Y-m-d')";
+ var $sysTimeStamp = "adodb_date('Y-m-d H:i:s')";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+
+ function ADODB_sqlite()
+ {
+ }
+
+/*
+ function __get($name)
+ {
+ switch($name) {
+ case 'sysDate': return "'".date($this->fmtDate)."'";
+ case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'";
+ }
+ }*/
+
+ function ServerInfo()
+ {
+ $arr['version'] = sqlite_libversion();
+ $arr['description'] = 'SQLite ';
+ $arr['encoding'] = sqlite_libencoding();
+ return $arr;
+ }
+
+ function BeginTrans()
+ {
+ if ($this->transOff) return true;
+ $ret = $this->Execute("BEGIN TRANSACTION");
+ $this->transCnt += 1;
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+ if (!$ok) return $this->RollbackTrans();
+ $ret = $this->Execute("COMMIT");
+ if ($this->transCnt>0)$this->transCnt -= 1;
+ return !empty($ret);
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ $ret = $this->Execute("ROLLBACK");
+ if ($this->transCnt>0)$this->transCnt -= 1;
+ return !empty($ret);
+ }
+
+ function _insertid()
+ {
+ return sqlite_last_insert_rowid($this->_connectionID);
+ }
+
+ function _affectedrows()
+ {
+ return sqlite_changes($this->_connectionID);
+ }
+
+ function ErrorMsg()
+ {
+ if ($this->_logsql) return $this->_errorMsg;
+ return ($this->_errorNo) ? sqlite_error_string($this->_errorNo) : '';
+ }
+
+ function ErrorNo()
+ {
+ return $this->_errorNo;
+ }
+
+ function SQLDate($fmt, $col=false)
+ {
+ $fmt = $this->qstr($fmt);
+ return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)";
+ }
+
+ function &MetaColumns($tab)
+ {
+ global $ADODB_FETCH_MODE;
+
+ $rs = $this->Execute("select * from $tab limit 1");
+ if (!$rs) {
+ $false = false;
+ return $false;
+ }
+ $arr = array();
+ for ($i=0,$max=$rs->_numOfFields; $i < $max; $i++) {
+ $fld =& $rs->FetchField($i);
+ if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] =& $fld;
+ else $arr[strtoupper($fld->name)] =& $fld;
+ }
+ $rs->Close();
+ return $arr;
+ }
+
+ function _createFunctions()
+ {
+ @sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1);
+ @sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2);
+ }
+
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('sqlite_open')) return null;
+ if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
+
+ $this->_connectionID = sqlite_open($argHostname);
+ if ($this->_connectionID === false) return false;
+ $this->_createFunctions();
+ return true;
+ }
+
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('sqlite_open')) return null;
+ if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename;
+
+ $this->_connectionID = sqlite_popen($argHostname);
+ if ($this->_connectionID === false) return false;
+ $this->_createFunctions();
+ return true;
+ }
+
+ // returns query ID if successful, otherwise false
+ function _query($sql,$inputarr=false)
+ {
+ $rez = sqlite_query($sql,$this->_connectionID);
+ if (!$rez) {
+ $this->_errorNo = sqlite_last_error($this->_connectionID);
+ }
+
+ return $rez;
+ }
+
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ $offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
+ $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : '');
+ if ($secs2cache)
+ $rs =& $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
+ else
+ $rs =& $this->Execute($sql."$limitStr$offsetStr",$inputarr);
+
+ return $rs;
+ }
+
+ /*
+ This algorithm is not very efficient, but works even if table locking
+ is not available.
+
+ Will return false if unable to generate an ID after $MAXLOOPS attempts.
+ */
+ var $_genSeqSQL = "create table %s (id integer)";
+
+ function GenID($seq='adodbseq',$start=1)
+ {
+ // if you have to modify the parameter below, your database is overloaded,
+ // or you need to implement generation of id's yourself!
+ $MAXLOOPS = 100;
+ //$this->debug=1;
+ while (--$MAXLOOPS>=0) {
+ @($num = $this->GetOne("select id from $seq"));
+ if ($num === false) {
+ $this->Execute(sprintf($this->_genSeqSQL ,$seq));
+ $start -= 1;
+ $num = '0';
+ $ok = $this->Execute("insert into $seq values($start)");
+ if (!$ok) return false;
+ }
+ $this->Execute("update $seq set id=id+1 where id=$num");
+
+ if ($this->affected_rows() > 0) {
+ $num += 1;
+ $this->genID = $num;
+ return $num;
+ }
+ }
+ if ($fn = $this->raiseErrorFn) {
+ $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
+ }
+ return false;
+ }
+
+ function CreateSequence($seqname='adodbseq',$start=1)
+ {
+ if (empty($this->_genSeqSQL)) return false;
+ $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+ if (!$ok) return false;
+ $start -= 1;
+ return $this->Execute("insert into $seqname values($start)");
+ }
+
+ var $_dropSeqSQL = 'drop table %s';
+ function DropSequence($seqname)
+ {
+ if (empty($this->_dropSeqSQL)) return false;
+ return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
+ }
+
+ // returns true or false
+ function _close()
+ {
+ return @sqlite_close($this->_connectionID);
+ }
+
+ function &MetaIndexes ($table, $primary = FALSE, $owner=false)
+ {
+ $false = false;
+ // save old fetch mode
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->fetchMode !== FALSE) {
+ $savem = $this->SetFetchMode(FALSE);
+ }
+ $SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table));
+ $rs = $this->Execute($SQL);
+ if (!is_object($rs)) {
+ if (isset($savem))
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ return $false;
+ }
+
+ $indexes = array ();
+ while ($row = $rs->FetchRow()) {
+ if ($primary && preg_match("/primary/i",$row[1]) == 0) continue;
+ if (!isset($indexes[$row[0]])) {
+
+ $indexes[$row[0]] = array(
+ 'unique' => preg_match("/unique/i",$row[1]),
+ 'columns' => array());
+ }
+ /**
+ * There must be a more elegant way of doing this,
+ * the index elements appear in the SQL statement
+ * in cols[1] between parentheses
+ * e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse)
+ */
+ $cols = explode("(",$row[1]);
+ $cols = explode(")",$cols[1]);
+ array_pop($cols);
+ $indexes[$row[0]]['columns'] = $cols;
+ }
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+ return $indexes;
+ }
+
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_sqlite extends ADORecordSet {
+
+ var $databaseType = "sqlite";
+ var $bind = false;
+
+ function ADORecordset_sqlite($queryID,$mode=false)
+ {
+
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ switch($mode) {
+ case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break;
+ case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break;
+ default: $this->fetchMode = SQLITE_BOTH; break;
+ }
+ $this->adodbFetchMode = $mode;
+
+ $this->_queryID = $queryID;
+
+ $this->_inited = true;
+ $this->fields = array();
+ if ($queryID) {
+ $this->_currentRow = 0;
+ $this->EOF = !$this->_fetch();
+ @$this->_initrs();
+ } else {
+ $this->_numOfRows = 0;
+ $this->_numOfFields = 0;
+ $this->EOF = true;
+ }
+
+ return $this->_queryID;
+ }
+
+
+ function &FetchField($fieldOffset = -1)
+ {
+ $fld = new ADOFieldObject;
+ $fld->name = sqlite_field_name($this->_queryID, $fieldOffset);
+ $fld->type = 'VARCHAR';
+ $fld->max_length = -1;
+ return $fld;
+ }
+
+ function _initrs()
+ {
+ $this->_numOfRows = @sqlite_num_rows($this->_queryID);
+ $this->_numOfFields = @sqlite_num_fields($this->_queryID);
+ }
+
+ function Fields($colname)
+ {
+ if ($this->fetchMode != SQLITE_NUM) return $this->fields[$colname];
+ if (!$this->bind) {
+ $this->bind = array();
+ for ($i=0; $i < $this->_numOfFields; $i++) {
+ $o = $this->FetchField($i);
+ $this->bind[strtoupper($o->name)] = $i;
+ }
+ }
+
+ return $this->fields[$this->bind[strtoupper($colname)]];
+ }
+
+ function _seek($row)
+ {
+ return sqlite_seek($this->_queryID, $row);
+ }
+
+ function _fetch($ignore_fields=false)
+ {
+ $this->fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode);
+ return !empty($this->fields);
+ }
+
+ function _close()
+ {
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-sqlitepo.inc.php b/html/phpgacl/adodb/drivers/adodb-sqlitepo.inc.php
new file mode 100644
index 0000000..0b49938
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sqlitepo.inc.php
@@ -0,0 +1,62 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Portable version of sqlite driver, to make it more similar to other database drivers.
+ The main differences are
+
+ 1. When selecting (joining) multiple tables, in assoc mode the table
+ names are included in the assoc keys in the "sqlite" driver.
+
+ In "sqlitepo" driver, the table names are stripped from the returned column names.
+ When this results in a conflict, the first field get preference.
+
+ Contributed by Herman Kuiper herman#ozuzo.net
+*/
+
+if (!defined('ADODB_DIR')) die();
+
+include_once(ADODB_DIR.'/drivers/adodb-sqlite.inc.php');
+
+class ADODB_sqlitepo extends ADODB_sqlite {
+ var $databaseType = 'sqlitepo';
+
+ function ADODB_sqlitepo()
+ {
+ $this->ADODB_sqlite();
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordset_sqlitepo extends ADORecordset_sqlite {
+
+ var $databaseType = 'sqlitepo';
+
+ function ADORecordset_sqlitepo($queryID,$mode=false)
+ {
+ $this->ADORecordset_sqlite($queryID,$mode);
+ }
+
+ // Modified to strip table names from returned fields
+ function _fetch($ignore_fields=false)
+ {
+ $this->fields = array();
+ $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode);
+ if(is_array($fields))
+ foreach($fields as $n => $v)
+ {
+ if(($p = strpos($n, ".")) !== false)
+ $n = substr($n, $p+1);
+ $this->fields[$n] = $v;
+ }
+
+ return !empty($this->fields);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-sybase.inc.php b/html/phpgacl/adodb/drivers/adodb-sybase.inc.php
new file mode 100644
index 0000000..cc719f4
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sybase.inc.php
@@ -0,0 +1,413 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim. All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Sybase driver contributed by Toni (toni.tunkkari@finebyte.com)
+
+ - MSSQL date patch applied.
+
+ Date patch by Toni 15 Feb 2002
+*/
+
+ // security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class ADODB_sybase extends ADOConnection {
+ var $databaseType = "sybase";
+ var $dataProvider = 'sybase';
+ var $replaceQuote = "''"; // string to use to replace quotes
+ var $fmtDate = "'Y-m-d'";
+ var $fmtTimeStamp = "'Y-m-d H:i:s'";
+ var $hasInsertID = true;
+ var $hasAffectedRows = true;
+ var $metaTablesSQL="select name from sysobjects where type='U' or type='V'";
+ // see http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8
+ var $metaColumnsSQL = "SELECT c.column_name, c.column_type, c.width FROM syscolumn c, systable t WHERE t.table_name='%s' AND c.table_id=t.table_id AND t.table_type='BASE'";
+ /*
+ "select c.name,t.name,c.length from
+ syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id
+ where o.name='%s'";
+ */
+ var $concat_operator = '+';
+ var $arrayClass = 'ADORecordSet_array_sybase';
+ var $sysDate = 'GetDate()';
+ var $leftOuter = '*=';
+ var $rightOuter = '=*';
+
+ function ADODB_sybase()
+ {
+ }
+
+ // might require begintrans -- committrans
+ function _insertid()
+ {
+ return $this->GetOne('select @@identity');
+ }
+ // might require begintrans -- committrans
+ function _affectedrows()
+ {
+ return $this->GetOne('select @@rowcount');
+ }
+
+
+ function BeginTrans()
+ {
+
+ if ($this->transOff) return true;
+ $this->transCnt += 1;
+
+ $this->Execute('BEGIN TRAN');
+ return true;
+ }
+
+ function CommitTrans($ok=true)
+ {
+ if ($this->transOff) return true;
+
+ if (!$ok) return $this->RollbackTrans();
+
+ $this->transCnt -= 1;
+ $this->Execute('COMMIT TRAN');
+ return true;
+ }
+
+ function RollbackTrans()
+ {
+ if ($this->transOff) return true;
+ $this->transCnt -= 1;
+ $this->Execute('ROLLBACK TRAN');
+ return true;
+ }
+
+ // http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4
+ function RowLock($tables,$where,$flds='top 1 null as ignore')
+ {
+ if (!$this->_hastrans) $this->BeginTrans();
+ $tables = str_replace(',',' HOLDLOCK,',$tables);
+ return $this->GetOne("select $flds from $tables HOLDLOCK where $where");
+
+ }
+
+ function SelectDB($dbName)
+ {
+ $this->databaseName = $dbName;
+ if ($this->_connectionID) {
+ return @sybase_select_db($dbName);
+ }
+ else return false;
+ }
+
+ /* Returns: the last error message from previous database operation
+ Note: This function is NOT available for Microsoft SQL Server. */
+
+
+ function ErrorMsg()
+ {
+ if ($this->_logsql) return $this->_errorMsg;
+ if (function_exists('sybase_get_last_message'))
+ $this->_errorMsg = sybase_get_last_message();
+ else
+ $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : 'SYBASE error messages not supported on this platform';
+ return $this->_errorMsg;
+ }
+
+ // returns true or false
+ function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('sybase_connect')) return null;
+
+ $this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+ // returns true or false
+ function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+ {
+ if (!function_exists('sybase_connect')) return null;
+
+ $this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword);
+ if ($this->_connectionID === false) return false;
+ if ($argDatabasename) return $this->SelectDB($argDatabasename);
+ return true;
+ }
+
+ // returns query ID if successful, otherwise false
+ function _query($sql,$inputarr)
+ {
+ global $ADODB_COUNTRECS;
+
+ if ($ADODB_COUNTRECS == false && ADODB_PHPVER >= 0x4300)
+ return sybase_unbuffered_query($sql,$this->_connectionID);
+ else
+ return sybase_query($sql,$this->_connectionID);
+ }
+
+ // See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12
+ function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
+ {
+ if ($secs2cache > 0) {// we do not cache rowcount, so we have to load entire recordset
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ return $rs;
+ }
+ $cnt = ($nrows >= 0) ? $nrows : 999999999;
+ if ($offset > 0 && $cnt) $cnt += $offset;
+
+ $this->Execute("set rowcount $cnt");
+ $rs =& ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0);
+ $this->Execute("set rowcount 0");
+
+ return $rs;
+ }
+
+ // returns true or false
+ function _close()
+ {
+ return @sybase_close($this->_connectionID);
+ }
+
+ function UnixDate($v)
+ {
+ return ADORecordSet_array_sybase::UnixDate($v);
+ }
+
+ function UnixTimeStamp($v)
+ {
+ return ADORecordSet_array_sybase::UnixTimeStamp($v);
+ }
+
+
+
+ # Added 2003-10-05 by Chris Phillipson
+ # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=16756?target=%25N%15_12018_START_RESTART_N%25
+ # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version
+ // Format date column in sql string given an input format that understands Y M D
+ function SQLDate($fmt, $col=false)
+ {
+ if (!$col) $col = $this->sysTimeStamp;
+ $s = '';
+
+ $len = strlen($fmt);
+ for ($i=0; $i < $len; $i++) {
+ if ($s) $s .= '+';
+ $ch = $fmt[$i];
+ switch($ch) {
+ case 'Y':
+ case 'y':
+ $s .= "datename(yy,$col)";
+ break;
+ case 'M':
+ $s .= "convert(char(3),$col,0)";
+ break;
+ case 'm':
+ $s .= "replace(str(month($col),2),' ','0')";
+ break;
+ case 'Q':
+ case 'q':
+ $s .= "datename(qq,$col)";
+ break;
+ case 'D':
+ case 'd':
+ $s .= "replace(str(datepart(dd,$col),2),' ','0')";
+ break;
+ case 'h':
+ $s .= "substring(convert(char(14),$col,0),13,2)";
+ break;
+
+ case 'H':
+ $s .= "replace(str(datepart(hh,$col),2),' ','0')";
+ break;
+
+ case 'i':
+ $s .= "replace(str(datepart(mi,$col),2),' ','0')";
+ break;
+ case 's':
+ $s .= "replace(str(datepart(ss,$col),2),' ','0')";
+ break;
+ case 'a':
+ case 'A':
+ $s .= "substring(convert(char(19),$col,0),18,2)";
+ break;
+
+ default:
+ if ($ch == '\\') {
+ $i++;
+ $ch = substr($fmt,$i,1);
+ }
+ $s .= $this->qstr($ch);
+ break;
+ }
+ }
+ return $s;
+ }
+
+ # Added 2003-10-07 by Chris Phillipson
+ # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8
+ # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version
+ function MetaPrimaryKeys($table)
+ {
+ $sql = "SELECT c.column_name " .
+ "FROM syscolumn c, systable t " .
+ "WHERE t.table_name='$table' AND c.table_id=t.table_id " .
+ "AND t.table_type='BASE' " .
+ "AND c.pkey = 'Y' " .
+ "ORDER BY c.column_id";
+
+ $a = $this->GetCol($sql);
+ if ($a && sizeof($a)>0) return $a;
+ return false;
+ }
+}
+
+/*--------------------------------------------------------------------------------------
+ Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+global $ADODB_sybase_mths;
+$ADODB_sybase_mths = array(
+ 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
+ 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
+
+class ADORecordset_sybase extends ADORecordSet {
+
+ var $databaseType = "sybase";
+ var $canSeek = true;
+ // _mths works only in non-localised system
+ var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
+
+ function ADORecordset_sybase($id,$mode=false)
+ {
+ if ($mode === false) {
+ global $ADODB_FETCH_MODE;
+ $mode = $ADODB_FETCH_MODE;
+ }
+ if (!$mode) $this->fetchMode = ADODB_FETCH_ASSOC;
+ else $this->fetchMode = $mode;
+ $this->ADORecordSet($id,$mode);
+ }
+
+ /* Returns: an object containing field information.
+ Get column information in the Recordset object. fetchField() can be used in order to obtain information about
+ fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by
+ fetchField() is retrieved. */
+ function &FetchField($fieldOffset = -1)
+ {
+ if ($fieldOffset != -1) {
+ $o = @sybase_fetch_field($this->_queryID, $fieldOffset);
+ }
+ else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
+ $o = @sybase_fetch_field($this->_queryID);
+ }
+ // older versions of PHP did not support type, only numeric
+ if ($o && !isset($o->type)) $o->type = ($o->numeric) ? 'float' : 'varchar';
+ return $o;
+ }
+
+ function _initrs()
+ {
+ global $ADODB_COUNTRECS;
+ $this->_numOfRows = ($ADODB_COUNTRECS)? @sybase_num_rows($this->_queryID):-1;
+ $this->_numOfFields = @sybase_num_fields($this->_queryID);
+ }
+
+ function _seek($row)
+ {
+ return @sybase_data_seek($this->_queryID, $row);
+ }
+
+ function _fetch($ignore_fields=false)
+ {
+ if ($this->fetchMode == ADODB_FETCH_NUM) {
+ $this->fields = @sybase_fetch_row($this->_queryID);
+ } else if ($this->fetchMode == ADODB_FETCH_ASSOC) {
+ $this->fields = @sybase_fetch_row($this->_queryID);
+ if (is_array($this->fields)) {
+ $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE);
+ return true;
+ }
+ return false;
+ } else {
+ $this->fields = @sybase_fetch_array($this->_queryID);
+ }
+ if ( is_array($this->fields)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /* close() only needs to be called if you are worried about using too much memory while your script
+ is running. All associated result memory for the specified result identifier will automatically be freed. */
+ function _close() {
+ return @sybase_free_result($this->_queryID);
+ }
+
+ // sybase/mssql uses a default date like Dec 30 2000 12:00AM
+ function UnixDate($v)
+ {
+ return ADORecordSet_array_sybase::UnixDate($v);
+ }
+
+ function UnixTimeStamp($v)
+ {
+ return ADORecordSet_array_sybase::UnixTimeStamp($v);
+ }
+}
+
+class ADORecordSet_array_sybase extends ADORecordSet_array {
+ function ADORecordSet_array_sybase($id=-1)
+ {
+ $this->ADORecordSet_array($id);
+ }
+
+ // sybase/mssql uses a default date like Dec 30 2000 12:00AM
+ function UnixDate($v)
+ {
+ global $ADODB_sybase_mths;
+
+ //Dec 30 2000 12:00AM
+ if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
+ ,$v, $rr)) return parent::UnixDate($v);
+
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $themth = substr(strtoupper($rr[1]),0,3);
+ $themth = $ADODB_sybase_mths[$themth];
+ if ($themth <= 0) return false;
+ // h-m-s-MM-DD-YY
+ return mktime(0,0,0,$themth,$rr[2],$rr[3]);
+ }
+
+ function UnixTimeStamp($v)
+ {
+ global $ADODB_sybase_mths;
+ //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
+ //Changed [0-9] to [0-9 ] in day conversion
+ if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
+ ,$v, $rr)) return parent::UnixTimeStamp($v);
+ if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+
+ $themth = substr(strtoupper($rr[1]),0,3);
+ $themth = $ADODB_sybase_mths[$themth];
+ if ($themth <= 0) return false;
+
+ switch (strtoupper($rr[6])) {
+ case 'P':
+ if ($rr[4]<12) $rr[4] += 12;
+ break;
+ case 'A':
+ if ($rr[4]==12) $rr[4] = 0;
+ break;
+ default:
+ break;
+ }
+ // h-m-s-MM-DD-YY
+ return mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]);
+ }
+}
+?>
diff --git a/html/phpgacl/adodb/drivers/adodb-sybase_ase.inc.php b/html/phpgacl/adodb/drivers/adodb-sybase_ase.inc.php
new file mode 100644
index 0000000..113f8f9
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-sybase_ase.inc.php
@@ -0,0 +1,115 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4.
+
+ Contributed by Interakt Online. Thx Cristian MARIN cristic#interaktonline.com
+*/
+class ADODB_sybase_ase extends ADODB_sybase {
+ var $databaseType = "sybase_ase";
+
+ var $metaTablesSQL="SELECT sysobjects.name FROM sysobjects, sysusers WHERE sysobjects.type='U' AND sysobjects.uid = sysusers.uid";
+ var $metaColumnsSQL = "SELECT syscolumns.name AS field_name, systypes.name AS type, systypes.length AS width FROM sysobjects, syscolumns, systypes WHERE sysobjects.name='%s' AND syscolumns.id = sysobjects.id AND systypes.type=syscolumns.type";
+ var $metaDatabasesSQL ="SELECT a.name FROM master.dbo.sysdatabases a, master.dbo.syslogins b WHERE a.suid = b.suid and a.name like '%' and a.name != 'tempdb' and a.status3 != 256 order by 1";
+
+ function ADODB_sybase_ase()
+ {
+ }
+
+ // split the Views, Tables and procedures.
+ function &MetaTables($ttype=false,$showSchema=false,$mask=false)
+ {
+ $false = false;
+ if ($this->metaTablesSQL) {
+ // complicated state saving by the need for backward compat
+
+ if ($ttype == 'VIEWS'){
+ $sql = str_replace('U', 'V', $this->metaTablesSQL);
+ }elseif (false === $ttype){
+ $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL);
+ }else{ // TABLES OR ANY OTHER
+ $sql = $this->metaTablesSQL;
+ }
+ $rs = $this->Execute($sql);
+
+ if ($rs === false || !method_exists($rs, 'GetArray')){
+ return $false;
+ }
+ $arr =& $rs->GetArray();
+
+ $arr2 = array();
+ foreach($arr as $key=>$value){
+ $arr2[] = trim($value['name']);
+ }
+ return $arr2;
+ }
+ return $false;
+ }
+
+ function MetaDatabases()
+ {
+ $arr = array();
+ if ($this->metaDatabasesSQL!='') {
+ $rs = $this->Execute($this->metaDatabasesSQL);
+ if ($rs && !$rs->EOF){
+ while (!$rs->EOF){
+ $arr[] = $rs->Fields('name');
+ $rs->MoveNext();
+ }
+ return $arr;
+ }
+ }
+ return false;
+ }
+
+ // fix a bug which prevent the metaColumns query to be executed for Sybase ASE
+ function &MetaColumns($table,$upper=false)
+ {
+ $false = false;
+ if (!empty($this->metaColumnsSQL)) {
+
+ $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+ if ($rs === false) return $false;
+
+ $retarr = array();
+ while (!$rs->EOF) {
+ $fld =& new ADOFieldObject();
+ $fld->name = $rs->Fields('field_name');
+ $fld->type = $rs->Fields('type');
+ $fld->max_length = $rs->Fields('width');
+ $retarr[strtoupper($fld->name)] = $fld;
+ $rs->MoveNext();
+ }
+ $rs->Close();
+ return $retarr;
+ }
+ return $false;
+ }
+
+ function getProcedureList($schema)
+ {
+ return false;
+ }
+
+ function ErrorMsg()
+ {
+ if (!function_exists('sybase_connect')){
+ return 'Your PHP doesn\'t contain the Sybase connection module!';
+ }
+ return parent::ErrorMsg();
+ }
+}
+
+class adorecordset_sybase_ase extends ADORecordset_sybase {
+var $databaseType = "sybase_ase";
+function ADORecordset_sybase_ase($id,$mode=false)
+ {
+ $this->ADORecordSet_sybase($id,$mode);
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/drivers/adodb-vfp.inc.php b/html/phpgacl/adodb/drivers/adodb-vfp.inc.php
new file mode 100644
index 0000000..ba7a4b6
--- /dev/null
+++ b/html/phpgacl/adodb/drivers/adodb-vfp.inc.php
@@ -0,0 +1,107 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+if (!defined('_ADODB_ODBC_LAYER')) {
+ include(ADODB_DIR."/drivers/adodb-odbc.inc.php");
+}
+if (!defined('ADODB_VFP')){
+define('ADODB_VFP',1);
+class ADODB_vfp extends ADODB_odbc {
+ var $databaseType = "vfp";
+ var $fmtDate = "{^Y-m-d}";
+ var $fmtTimeStamp = "{^Y-m-d, h:i:sA}";
+ var $replaceQuote = "'+chr(39)+'" ;
+ var $true = '.T.';
+ var $false = '.F.';
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
+ var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
+ var $sysTimeStamp = 'datetime()';
+ var $sysDate = 'date()';
+ var $ansiOuter = true;
+ var $hasTransactions = false;
+ var $curmode = false ; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
+
+ function ADODB_vfp()
+ {
+ $this->ADODB_odbc();
+ }
+
+ function Time()
+ {
+ return time();
+ }
+
+ function BeginTrans() { return false;}
+
+ // quote string to be sent back to database
+ function qstr($s,$nofixquotes=false)
+ {
+ if (!$nofixquotes) return "'".str_replace("\r\n","'+chr(13)+'",str_replace("'",$this->replaceQuote,$s))."'";
+ return "'".$s."'";
+ }
+
+
+ // TOP requires ORDER BY for VFP
+ function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0)
+ {
+ $this->hasTop = preg_match('/ORDER[ \t\r\n]+BY/is',$sql) ? 'top' : false;
+ $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache);
+ return $ret;
+ }
+
+
+
+};
+
+
+class ADORecordSet_vfp extends ADORecordSet_odbc {
+
+ var $databaseType = "vfp";
+
+
+ function ADORecordSet_vfp($id,$mode=false)
+ {
+ return $this->ADORecordSet_odbc($id,$mode);
+ }
+
+ function MetaType($t,$len=-1)
+ {
+ if (is_object($t)) {
+ $fieldobj = $t;
+ $t = $fieldobj->type;
+ $len = $fieldobj->max_length;
+ }
+ switch (strtoupper($t)) {
+ case 'C':
+ if ($len <= $this->blobSize) return 'C';
+ case 'M':
+ return 'X';
+
+ case 'D': return 'D';
+
+ case 'T': return 'T';
+
+ case 'L': return 'L';
+
+ case 'I': return 'I';
+
+ default: return 'N';
+ }
+ }
+}
+
+} //define
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-ar.inc.php b/html/phpgacl/adodb/lang/adodb-ar.inc.php
new file mode 100644
index 0000000..701d024
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-ar.inc.php
@@ -0,0 +1,34 @@
+<?php
+// by "El-Shamaa, Khaled" <k.el-shamaa#cgiar.org>
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'ar',
+ DB_ERROR => 'ÎØà ÛíÑ ãÍÏÏ',
+ DB_ERROR_ALREADY_EXISTS => 'ãæÌæÏ ãÓÈÞÇ',
+ DB_ERROR_CANNOT_CREATE => 'áÇ íãßä ÅäÔÇÁ',
+ DB_ERROR_CANNOT_DELETE => 'áÇ íãßä ÍÐÝ',
+ DB_ERROR_CANNOT_DROP => 'áÇ íãßä ÍÐÝ',
+ DB_ERROR_CONSTRAINT => 'ÚãáíÉ ÅÏÎÇá ããäæÚÉ',
+ DB_ERROR_DIVZERO => 'ÚãáíÉ ÇáÊÞÓíã Úáì ÕÝÑ',
+ DB_ERROR_INVALID => 'ÛíÑ ÕÍíÍ',
+ DB_ERROR_INVALID_DATE => 'ÕíÛÉ æÞÊ Ãæ ÊÇÑíÎ ÛíÑ ÕÍíÍÉ',
+ DB_ERROR_INVALID_NUMBER => 'ÕíÛÉ ÑÞã ÛíÑ ÕÍíÍÉ',
+ DB_ERROR_MISMATCH => 'ÛíÑ ãÊØÇÈÞ',
+ DB_ERROR_NODBSELECTED => 'áã íÊã ÅÎÊíÇÑ ÞÇÚÏÉ ÇáÈíÇäÇÊ ÈÚÏ',
+ DB_ERROR_NOSUCHFIELD => 'áíÓ åäÇáß ÍÞá ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_NOSUCHTABLE => 'áíÓ åäÇáß ÌÏæá ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_NOT_CAPABLE => 'ÞÇÚÏÉ ÇáÈíÇäÇÊ ÇáãÑÊÈØ ÈåÇ ÛíÑ ÞÇÏÑÉ',
+ DB_ERROR_NOT_FOUND => 'áã íÊã ÅíÌÇÏå',
+ DB_ERROR_NOT_LOCKED => 'ÛíÑ ãÞÝæá',
+ DB_ERROR_SYNTAX => 'ÎØÃ Ýí ÇáÕíÛÉ',
+ DB_ERROR_UNSUPPORTED => 'ÛíÑ ãÏÚæã',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'ÚÏÏ ÇáÞíã Ýí ÇáÓÌá',
+ DB_ERROR_INVALID_DSN => 'DNS ÛíÑ ÕÍíÍ',
+ DB_ERROR_CONNECT_FAILED => 'ÝÔá ÚãáíÉ ÇáÅÊÕÇá',
+ 0 => 'áíÓ åäÇáß ÃÎØÇÁ', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ÇáÈíÇäÇÊ ÇáãÒæÏÉ ÛíÑ ßÇÝíÉ',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'áã íÊã ÅíÌÇÏ ÇáÅÖÇÝÉ ÇáãÊÚáÞÉ',
+ DB_ERROR_NOSUCHDB => 'áíÓ åäÇáß ÞÇÚÏÉ ÈíÇäÇÊ ÈåÐÇ ÇáÇÓã',
+ DB_ERROR_ACCESS_VIOLATION => 'ÓãÇÍíÇÊ ÛíÑ ßÇÝíÉ'
+);
+?>
+
diff --git a/html/phpgacl/adodb/lang/adodb-bg.inc.php b/html/phpgacl/adodb/lang/adodb-bg.inc.php
new file mode 100644
index 0000000..4fb1dc0
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-bg.inc.php
@@ -0,0 +1,38 @@
+<?php
+/*
+ Bulgarian language, v1.0, 25.03.2004, encoding by Windows-1251 charset
+ contributed by Valentin Sheiretsky <valio#valio.eu.org>
+*/
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'bg',
+ DB_ERROR => 'íåèçâåñòíà ãðåøêà',
+ DB_ERROR_ALREADY_EXISTS => 'âå÷å ñúùåñòâóâà',
+ DB_ERROR_CANNOT_CREATE => 'íå ìîæå äà áúäå ñúçäàäåíà',
+ DB_ERROR_CANNOT_DELETE => 'íå ìîæå äà áúäå èçòðèòà',
+ DB_ERROR_CANNOT_DROP => 'íå ìîæå äà áúäå óíèùîæåíà',
+ DB_ERROR_CONSTRAINT => 'íàðóøåíî óñëîâèå',
+ DB_ERROR_DIVZERO => 'äåëåíèå íà íóëà',
+ DB_ERROR_INVALID => 'íåïðàâèëíî',
+ DB_ERROR_INVALID_DATE => 'íåêîðåêòíà äàòà èëè ÷àñ',
+ DB_ERROR_INVALID_NUMBER => 'íåâàëèäåí íîìåð',
+ DB_ERROR_MISMATCH => 'ïîãðåøíà óïîòðåáà',
+ DB_ERROR_NODBSELECTED => 'íå å èçáðàíà áàçà äàííè',
+ DB_ERROR_NOSUCHFIELD => 'íåñúùåñòâóâàùî ïîëå',
+ DB_ERROR_NOSUCHTABLE => 'íåñúùåñòâóâàùà òàáëèöà',
+ DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
+ DB_ERROR_NOT_FOUND => 'íå å íàìåðåíà',
+ DB_ERROR_NOT_LOCKED => 'íå å çàêëþ÷åíà',
+ DB_ERROR_SYNTAX => 'ãðåøåí ñèíòàêñèñ',
+ DB_ERROR_UNSUPPORTED => 'íå ñå ïîääúðæà',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'íåêîðåêòåí áðîé êîëîíè â ðåäà',
+ DB_ERROR_INVALID_DSN => 'íåâàëèäåí DSN',
+ DB_ERROR_CONNECT_FAILED => 'âðúçêàòà íå ìîæå äà áúäå îñúùåñòâåíà',
+ 0 => 'íÿìà ãðåøêè', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ïðåäîñòàâåíèòå äàííè ñà íåäîñòàòú÷íè',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'ðàçøèðåíèåòî íå å íàìåðåíî',
+ DB_ERROR_NOSUCHDB => 'íåñúùåñòâóâàùà áàçà äàííè',
+ DB_ERROR_ACCESS_VIOLATION => 'íÿìàòå äîñòàòú÷íî ïðàâà'
+);
+?>
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-bgutf8.inc.php b/html/phpgacl/adodb/lang/adodb-bgutf8.inc.php
new file mode 100644
index 0000000..6f3a417
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-bgutf8.inc.php
@@ -0,0 +1,38 @@
+<?php
+/*
+ Bulgarian language, v1.0, 25.03.2004, encoding by UTF-8 charset
+ contributed by Valentin Sheiretsky <valio#valio.eu.org>
+*/
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'bgutf8',
+ DB_ERROR => 'неизвеÑтна грешка',
+ DB_ERROR_ALREADY_EXISTS => 'вече ÑъщеÑтвува',
+ DB_ERROR_CANNOT_CREATE => 'не може да бъде Ñъздадена',
+ DB_ERROR_CANNOT_DELETE => 'не може да бъде изтрита',
+ DB_ERROR_CANNOT_DROP => 'не може да бъде унищожена',
+ DB_ERROR_CONSTRAINT => 'нарушено уÑловие',
+ DB_ERROR_DIVZERO => 'деление на нула',
+ DB_ERROR_INVALID => 'неправилно',
+ DB_ERROR_INVALID_DATE => 'некоректна дата или чаÑ',
+ DB_ERROR_INVALID_NUMBER => 'невалиден номер',
+ DB_ERROR_MISMATCH => 'погрешна употреба',
+ DB_ERROR_NODBSELECTED => 'не е избрана база данни',
+ DB_ERROR_NOSUCHFIELD => 'неÑъщеÑтвуващо поле',
+ DB_ERROR_NOSUCHTABLE => 'неÑъщеÑтвуваща таблица',
+ DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
+ DB_ERROR_NOT_FOUND => 'не е намерена',
+ DB_ERROR_NOT_LOCKED => 'не е заключена',
+ DB_ERROR_SYNTAX => 'грешен ÑинтакÑиÑ',
+ DB_ERROR_UNSUPPORTED => 'не Ñе поддържа',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'некоректен брой колони в реда',
+ DB_ERROR_INVALID_DSN => 'невалиден DSN',
+ DB_ERROR_CONNECT_FAILED => 'връзката не може да бъде оÑъщеÑтвена',
+ 0 => 'нÑма грешки', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'предоÑтавените данни Ñа недоÑтатъчни',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'разширението не е намерено',
+ DB_ERROR_NOSUCHDB => 'неÑъщеÑтвуваща база данни',
+ DB_ERROR_ACCESS_VIOLATION => 'нÑмате доÑтатъчно права'
+);
+?>
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-ca.inc.php b/html/phpgacl/adodb/lang/adodb-ca.inc.php
new file mode 100644
index 0000000..3e6a449
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-ca.inc.php
@@ -0,0 +1,35 @@
+<?php
+// Catalan language
+// contributed by "Josep Lladonosa" jlladono#pie.xtec.es
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'ca',
+ DB_ERROR => 'error desconegut',
+ DB_ERROR_ALREADY_EXISTS => 'ja existeix',
+ DB_ERROR_CANNOT_CREATE => 'no es pot crear',
+ DB_ERROR_CANNOT_DELETE => 'no es pot esborrar',
+ DB_ERROR_CANNOT_DROP => 'no es pot eliminar',
+ DB_ERROR_CONSTRAINT => 'violació de constraint',
+ DB_ERROR_DIVZERO => 'divisió per zero',
+ DB_ERROR_INVALID => 'no és vàlid',
+ DB_ERROR_INVALID_DATE => 'la data o l\'hora no són vàlides',
+ DB_ERROR_INVALID_NUMBER => 'el nombre no és vàlid',
+ DB_ERROR_MISMATCH => 'no hi ha coincidència',
+ DB_ERROR_NODBSELECTED => 'cap base de dades seleccionada',
+ DB_ERROR_NOSUCHFIELD => 'camp inexistent',
+ DB_ERROR_NOSUCHTABLE => 'taula inexistent',
+ DB_ERROR_NOT_CAPABLE => 'l\'execució secundària de DB no pot',
+ DB_ERROR_NOT_FOUND => 'no trobat',
+ DB_ERROR_NOT_LOCKED => 'no blocat',
+ DB_ERROR_SYNTAX => 'error de sintaxi',
+ DB_ERROR_UNSUPPORTED => 'no suportat',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'el nombre de columnes no coincideix amb el nombre de valors en la fila',
+ DB_ERROR_INVALID_DSN => 'el DSN no és vàlid',
+ DB_ERROR_CONNECT_FAILED => 'connexió fallida',
+ 0 => 'cap error', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'les dades subministrades són insuficients',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extensió no trobada',
+ DB_ERROR_NOSUCHDB => 'base de dades inexistent',
+ DB_ERROR_ACCESS_VIOLATION => 'permisos insuficients'
+);
+?>
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-cn.inc.php b/html/phpgacl/adodb/lang/adodb-cn.inc.php
new file mode 100644
index 0000000..eb8c7de
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-cn.inc.php
@@ -0,0 +1,35 @@
+<?php
+// Chinese language file contributed by "Cuiyan (cysoft)" cysoft#php.net.
+// Encode by GB2312
+// Simplified Chinese
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'cn',
+ DB_ERROR => 'δ֪´íÎó',
+ DB_ERROR_ALREADY_EXISTS => 'ÒѾ­´æÔÚ',
+ DB_ERROR_CANNOT_CREATE => '²»ÄÜ´´½¨',
+ DB_ERROR_CANNOT_DELETE => '²»ÄÜɾ³ý',
+ DB_ERROR_CANNOT_DROP => '²»ÄܶªÆú',
+ DB_ERROR_CONSTRAINT => 'Ô¼ÊøÏÞÖÆ',
+ DB_ERROR_DIVZERO => '±»0³ý',
+ DB_ERROR_INVALID => 'ÎÞЧ',
+ DB_ERROR_INVALID_DATE => 'ÎÞЧµÄÈÕÆÚ»òÕßʱ¼ä',
+ DB_ERROR_INVALID_NUMBER => 'ÎÞЧµÄÊý×Ö',
+ DB_ERROR_MISMATCH => '²»Æ¥Åä',
+ DB_ERROR_NODBSELECTED => 'ûÓÐÊý¾Ý¿â±»Ñ¡Ôñ',
+ DB_ERROR_NOSUCHFIELD => 'ûÓÐÏàÓ¦µÄ×Ö¶Î',
+ DB_ERROR_NOSUCHTABLE => 'ûÓÐÏàÓ¦µÄ±í',
+ DB_ERROR_NOT_CAPABLE => 'Êý¾Ý¿âºǫ́²»¼æÈÝ',
+ DB_ERROR_NOT_FOUND => 'ûÓз¢ÏÖ',
+ DB_ERROR_NOT_LOCKED => 'ûÓб»Ëø¶¨',
+ DB_ERROR_SYNTAX => 'Óï·¨´íÎó',
+ DB_ERROR_UNSUPPORTED => '²»Ö§³Ö',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'ÔÚÐÐÉÏÀÛ¼ÆÖµ',
+ DB_ERROR_INVALID_DSN => 'ÎÞЧµÄÊý¾ÝÔ´ (DSN)',
+ DB_ERROR_CONNECT_FAILED => 'Á¬½Óʧ°Ü',
+ 0 => 'ûÓдíÎó', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ÌṩµÄÊý¾Ý²»ÄÜ·ûºÏÒªÇó',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'À©Õ¹Ã»Óб»·¢ÏÖ',
+ DB_ERROR_NOSUCHDB => 'ûÓÐÏàÓ¦µÄÊý¾Ý¿â',
+ DB_ERROR_ACCESS_VIOLATION => 'ûÓкÏÊʵÄȨÏÞ'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-cz.inc.php b/html/phpgacl/adodb/lang/adodb-cz.inc.php
new file mode 100644
index 0000000..2424c24
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-cz.inc.php
@@ -0,0 +1,40 @@
+<?php
+
+# Czech language, encoding by ISO 8859-2 charset (Iso Latin-2)
+# For convert to MS Windows use shell command:
+# iconv -f ISO_8859-2 -t CP1250 < adodb-cz.inc.php
+# For convert to ASCII use shell command:
+# unaccent ISO_8859-2 < adodb-cz.inc.php
+# v1.0, 19.06.2003 Kamil Jakubovic <jake@host.sk>
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'cz',
+ DB_ERROR => 'neznámá chyba',
+ DB_ERROR_ALREADY_EXISTS => 'ji? existuje',
+ DB_ERROR_CANNOT_CREATE => 'nelze vytvo?it',
+ DB_ERROR_CANNOT_DELETE => 'nelze smazat',
+ DB_ERROR_CANNOT_DROP => 'nelze odstranit',
+ DB_ERROR_CONSTRAINT => 'poru?ení omezující podmínky',
+ DB_ERROR_DIVZERO => 'd?lení nulou',
+ DB_ERROR_INVALID => 'neplatné',
+ DB_ERROR_INVALID_DATE => 'neplatné datum nebo ?as',
+ DB_ERROR_INVALID_NUMBER => 'neplatné ?íslo',
+ DB_ERROR_MISMATCH => 'nesouhlasí',
+ DB_ERROR_NODBSELECTED => '?ádná databáze není vybrána',
+ DB_ERROR_NOSUCHFIELD => 'pole nenalezeno',
+ DB_ERROR_NOSUCHTABLE => 'tabulka nenalezena',
+ DB_ERROR_NOT_CAPABLE => 'nepodporováno',
+ DB_ERROR_NOT_FOUND => 'nenalezeno',
+ DB_ERROR_NOT_LOCKED => 'nezam?eno',
+ DB_ERROR_SYNTAX => 'syntaktická chyba',
+ DB_ERROR_UNSUPPORTED => 'nepodporováno',
+ DB_ERROR_VALUE_COUNT_ON_ROW => '',
+ DB_ERROR_INVALID_DSN => 'neplatné DSN',
+ DB_ERROR_CONNECT_FAILED => 'p?ipojení selhalo',
+ 0 => 'bez chyb', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'málo zdrojových dat',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'roz?í?ení nenalezeno',
+ DB_ERROR_NOSUCHDB => 'databáze neexistuje',
+ DB_ERROR_ACCESS_VIOLATION => 'nedostate?ná práva'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-da.inc.php b/html/phpgacl/adodb/lang/adodb-da.inc.php
new file mode 100644
index 0000000..b0394a8
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-da.inc.php
@@ -0,0 +1,33 @@
+<?php
+// Arne Eckmann bananstat#users.sourceforge.net
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'da',
+ DB_ERROR => 'ukendt fejl',
+ DB_ERROR_ALREADY_EXISTS => 'eksisterer allerede',
+ DB_ERROR_CANNOT_CREATE => 'kan ikke oprette',
+ DB_ERROR_CANNOT_DELETE => 'kan ikke slette',
+ DB_ERROR_CANNOT_DROP => 'kan ikke droppe',
+ DB_ERROR_CONSTRAINT => 'begr&aelig;nsning kr&aelig;nket',
+ DB_ERROR_DIVZERO => 'division med nul',
+ DB_ERROR_INVALID => 'ugyldig',
+ DB_ERROR_INVALID_DATE => 'ugyldig dato eller klokkeslet',
+ DB_ERROR_INVALID_NUMBER => 'ugyldigt tal',
+ DB_ERROR_MISMATCH => 'mismatch',
+ DB_ERROR_NODBSELECTED => 'ingen database valgt',
+ DB_ERROR_NOSUCHFIELD => 'felt findes ikke',
+ DB_ERROR_NOSUCHTABLE => 'tabel findes ikke',
+ DB_ERROR_NOT_CAPABLE => 'DB backend opgav',
+ DB_ERROR_NOT_FOUND => 'ikke fundet',
+ DB_ERROR_NOT_LOCKED => 'ikke l&aring;st',
+ DB_ERROR_SYNTAX => 'syntaksfejl',
+ DB_ERROR_UNSUPPORTED => 'ikke underst&oslash;ttet',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'resulterende antal felter svarer ikke til foresp&oslash;rgslens antal felter',
+ DB_ERROR_INVALID_DSN => 'ugyldig DSN',
+ DB_ERROR_CONNECT_FAILED => 'tilslutning mislykkedes',
+ 0 => 'ingen fejl', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'utilstr&aelig;kkelige data angivet',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'udvidelse ikke fundet',
+ DB_ERROR_NOSUCHDB => 'database ikke fundet',
+ DB_ERROR_ACCESS_VIOLATION => 'utilstr&aelig;kkelige rettigheder'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-de.inc.php b/html/phpgacl/adodb/lang/adodb-de.inc.php
new file mode 100644
index 0000000..244cb2f
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-de.inc.php
@@ -0,0 +1,33 @@
+<?php
+// contributed by "Heinz Hombergs" <opn@hhombergs.de>
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'de',
+ DB_ERROR => 'Unbekannter Fehler',
+ DB_ERROR_ALREADY_EXISTS => 'existiert bereits',
+ DB_ERROR_CANNOT_CREATE => 'kann nicht erstellen',
+ DB_ERROR_CANNOT_DELETE => 'kann nicht l&ouml;schen',
+ DB_ERROR_CANNOT_DROP => 'Tabelle oder Index konnte nicht gel&ouml;scht werden',
+ DB_ERROR_CONSTRAINT => 'Constraint Verletzung',
+ DB_ERROR_DIVZERO => 'Division durch Null',
+ DB_ERROR_INVALID => 'ung&uml;ltig',
+ DB_ERROR_INVALID_DATE => 'ung&uml;ltiges Datum oder Zeit',
+ DB_ERROR_INVALID_NUMBER => 'ung&uml;ltige Zahl',
+ DB_ERROR_MISMATCH => 'Unvertr&auml;glichkeit',
+ DB_ERROR_NODBSELECTED => 'keine Dantebank ausgew&auml;hlt',
+ DB_ERROR_NOSUCHFIELD => 'Feld nicht vorhanden',
+ DB_ERROR_NOSUCHTABLE => 'Tabelle nicht vorhanden',
+ DB_ERROR_NOT_CAPABLE => 'Funktion nicht installiert',
+ DB_ERROR_NOT_FOUND => 'nicht gefunden',
+ DB_ERROR_NOT_LOCKED => 'nicht gesperrt',
+ DB_ERROR_SYNTAX => 'Syntaxfehler',
+ DB_ERROR_UNSUPPORTED => 'nicht Unterst&uml;tzt',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'Anzahl der zur&uml;ckgelieferten Felder entspricht nicht der Anzahl der Felder in der Abfrage',
+ DB_ERROR_INVALID_DSN => 'ung&uml;ltiger DSN',
+ DB_ERROR_CONNECT_FAILED => 'Verbindung konnte nicht hergestellt werden',
+ 0 => 'kein Fehler', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'Nicht gen&uml;gend Daten geliefert',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'erweiterung nicht gefunden',
+ DB_ERROR_NOSUCHDB => 'keine Datenbank',
+ DB_ERROR_ACCESS_VIOLATION => 'ungen&uml;gende Rechte'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-en.inc.php b/html/phpgacl/adodb/lang/adodb-en.inc.php
new file mode 100644
index 0000000..d719d7a
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-en.inc.php
@@ -0,0 +1,34 @@
+<?php
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'en',
+ DB_ERROR => 'unknown error',
+ DB_ERROR_ALREADY_EXISTS => 'already exists',
+ DB_ERROR_CANNOT_CREATE => 'can not create',
+ DB_ERROR_CANNOT_DELETE => 'can not delete',
+ DB_ERROR_CANNOT_DROP => 'can not drop',
+ DB_ERROR_CONSTRAINT => 'constraint violation',
+ DB_ERROR_DIVZERO => 'division by zero',
+ DB_ERROR_INVALID => 'invalid',
+ DB_ERROR_INVALID_DATE => 'invalid date or time',
+ DB_ERROR_INVALID_NUMBER => 'invalid number',
+ DB_ERROR_MISMATCH => 'mismatch',
+ DB_ERROR_NODBSELECTED => 'no database selected',
+ DB_ERROR_NOSUCHFIELD => 'no such field',
+ DB_ERROR_NOSUCHTABLE => 'no such table',
+ DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
+ DB_ERROR_NOT_FOUND => 'not found',
+ DB_ERROR_NOT_LOCKED => 'not locked',
+ DB_ERROR_SYNTAX => 'syntax error',
+ DB_ERROR_UNSUPPORTED => 'not supported',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
+ DB_ERROR_INVALID_DSN => 'invalid DSN',
+ DB_ERROR_CONNECT_FAILED => 'connect failed',
+ 0 => 'no error', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extension not found',
+ DB_ERROR_NOSUCHDB => 'no such database',
+ DB_ERROR_ACCESS_VIOLATION => 'insufficient permissions'
+);
+?>
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-es.inc.php b/html/phpgacl/adodb/lang/adodb-es.inc.php
new file mode 100644
index 0000000..1e0afbb
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-es.inc.php
@@ -0,0 +1,33 @@
+<?php
+// contributed by "Horacio Degiorgi" <horaciod@codigophp.com>
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'es',
+ DB_ERROR => 'error desconocido',
+ DB_ERROR_ALREADY_EXISTS => 'ya existe',
+ DB_ERROR_CANNOT_CREATE => 'imposible crear',
+ DB_ERROR_CANNOT_DELETE => 'imposible borrar',
+ DB_ERROR_CANNOT_DROP => 'imposible hacer drop',
+ DB_ERROR_CONSTRAINT => 'violacion de constraint',
+ DB_ERROR_DIVZERO => 'division por cero',
+ DB_ERROR_INVALID => 'invalido',
+ DB_ERROR_INVALID_DATE => 'fecha u hora invalida',
+ DB_ERROR_INVALID_NUMBER => 'numero invalido',
+ DB_ERROR_MISMATCH => 'error',
+ DB_ERROR_NODBSELECTED => 'no hay base de datos seleccionada',
+ DB_ERROR_NOSUCHFIELD => 'campo invalido',
+ DB_ERROR_NOSUCHTABLE => 'tabla no existe',
+ DB_ERROR_NOT_CAPABLE => 'capacidad invalida para esta DB',
+ DB_ERROR_NOT_FOUND => 'no encontrado',
+ DB_ERROR_NOT_LOCKED => 'no bloqueado',
+ DB_ERROR_SYNTAX => 'error de sintaxis',
+ DB_ERROR_UNSUPPORTED => 'no soportado',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'la cantidad de columnas no corresponden a la cantidad de valores',
+ DB_ERROR_INVALID_DSN => 'DSN invalido',
+ DB_ERROR_CONNECT_FAILED => 'fallo la conexion',
+ 0 => 'sin error', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'insuficientes datos',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extension no encontrada',
+ DB_ERROR_NOSUCHDB => 'base de datos no encontrada',
+ DB_ERROR_ACCESS_VIOLATION => 'permisos insuficientes'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-esperanto.inc.php b/html/phpgacl/adodb/lang/adodb-esperanto.inc.php
new file mode 100644
index 0000000..60ae42f
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-esperanto.inc.php
@@ -0,0 +1,35 @@
+<?php
+// Vivu Esperanto cxiam!
+// Traduko fare de Antono Vasiljev (anders[#]brainactive.org)
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'eo',
+ DB_ERROR => 'nekonata eraro',
+ DB_ERROR_ALREADY_EXISTS => 'jam ekzistas',
+ DB_ERROR_CANNOT_CREATE => 'maleblas krei',
+ DB_ERROR_CANNOT_DELETE => 'maleblas elimini',
+ DB_ERROR_CANNOT_DROP => 'maleblas elimini (drop)',
+ DB_ERROR_CONSTRAINT => 'rompo de kondicxoj de provo',
+ DB_ERROR_DIVZERO => 'divido per 0 (nul)',
+ DB_ERROR_INVALID => 'malregule',
+ DB_ERROR_INVALID_DATE => 'malregula dato kaj tempo',
+ DB_ERROR_INVALID_NUMBER => 'malregula nombro',
+ DB_ERROR_MISMATCH => 'eraro',
+ DB_ERROR_NODBSELECTED => 'datumbazo ne elektita',
+ DB_ERROR_NOSUCHFIELD => 'ne ekzistas kampo',
+ DB_ERROR_NOSUCHTABLE => 'ne ekzistas tabelo',
+ DB_ERROR_NOT_CAPABLE => 'DBMS ne povas',
+ DB_ERROR_NOT_FOUND => 'ne trovita',
+ DB_ERROR_NOT_LOCKED => 'ne blokita',
+ DB_ERROR_SYNTAX => 'sintaksa eraro',
+ DB_ERROR_UNSUPPORTED => 'ne apogata',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'nombrilo de valoroj en linio',
+ DB_ERROR_INVALID_DSN => 'malregula DSN-o',
+ DB_ERROR_CONNECT_FAILED => 'konekto malsukcesa',
+ 0 => 'cxio bone', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ne suficxe da datumo',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'etendo ne trovita',
+ DB_ERROR_NOSUCHDB => 'datumbazo ne ekzistas',
+ DB_ERROR_ACCESS_VIOLATION => 'ne suficxe da rajto por atingo'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-fr.inc.php b/html/phpgacl/adodb/lang/adodb-fr.inc.php
new file mode 100644
index 0000000..066a2a5
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-fr.inc.php
@@ -0,0 +1,33 @@
+<?php
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'fr',
+ DB_ERROR => 'erreur inconnue',
+ DB_ERROR_ALREADY_EXISTS => 'existe d&eacute;j&agrave;',
+ DB_ERROR_CANNOT_CREATE => 'cr&eacute;tion impossible',
+ DB_ERROR_CANNOT_DELETE => 'effacement impossible',
+ DB_ERROR_CANNOT_DROP => 'suppression impossible',
+ DB_ERROR_CONSTRAINT => 'violation de contrainte',
+ DB_ERROR_DIVZERO => 'division par z&eacute;ro',
+ DB_ERROR_INVALID => 'invalide',
+ DB_ERROR_INVALID_DATE => 'date ou heure invalide',
+ DB_ERROR_INVALID_NUMBER => 'nombre invalide',
+ DB_ERROR_MISMATCH => 'erreur de concordance',
+ DB_ERROR_NODBSELECTED => 'pas de base de donn&eacute;ess&eacute;lectionn&eacute;e',
+ DB_ERROR_NOSUCHFIELD => 'nom de colonne invalide',
+ DB_ERROR_NOSUCHTABLE => 'table ou vue inexistante',
+ DB_ERROR_NOT_CAPABLE => 'fonction optionnelle non install&eacute;e',
+ DB_ERROR_NOT_FOUND => 'pas trouv&eacute;',
+ DB_ERROR_NOT_LOCKED => 'non verrouill&eacute;',
+ DB_ERROR_SYNTAX => 'erreur de syntaxe',
+ DB_ERROR_UNSUPPORTED => 'non support&eacute;',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'valeur ins&eacute;r&eacute;e trop grande pour colonne',
+ DB_ERROR_INVALID_DSN => 'DSN invalide',
+ DB_ERROR_CONNECT_FAILED => '&eacute;chec &agrave; la connexion',
+ 0 => "pas d'erreur", // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'donn&eacute;es fournies insuffisantes',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extension non trouv&eacute;e',
+ DB_ERROR_NOSUCHDB => 'base de donn&eacute;es inconnue',
+ DB_ERROR_ACCESS_VIOLATION => 'droits insuffisants'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-hu.inc.php b/html/phpgacl/adodb/lang/adodb-hu.inc.php
new file mode 100644
index 0000000..d5b91d9
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-hu.inc.php
@@ -0,0 +1,34 @@
+<?php
+# Hungarian language, encoding by ISO 8859-2 charset (Iso Latin-2)
+# Halászvári Gábor <g.halaszvari#portmax.hu>
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'hu',
+ DB_ERROR => 'ismeretlen hiba',
+ DB_ERROR_ALREADY_EXISTS => 'már létezik',
+ DB_ERROR_CANNOT_CREATE => 'nem sikerült létrehozni',
+ DB_ERROR_CANNOT_DELETE => 'nem sikerült törölni',
+ DB_ERROR_CANNOT_DROP => 'nem sikerült eldobni',
+ DB_ERROR_CONSTRAINT => 'szabályok megszegése',
+ DB_ERROR_DIVZERO => 'osztás nullával',
+ DB_ERROR_INVALID => 'érvénytelen',
+ DB_ERROR_INVALID_DATE => 'érvénytelen dátum vagy idõ',
+ DB_ERROR_INVALID_NUMBER => 'érvénytelen szám',
+ DB_ERROR_MISMATCH => 'nem megfelelõ',
+ DB_ERROR_NODBSELECTED => 'nincs kiválasztott adatbázis',
+ DB_ERROR_NOSUCHFIELD => 'nincs ilyen mezõ',
+ DB_ERROR_NOSUCHTABLE => 'nincs ilyen tábla',
+ DB_ERROR_NOT_CAPABLE => 'DB backend nem támogatja',
+ DB_ERROR_NOT_FOUND => 'nem található',
+ DB_ERROR_NOT_LOCKED => 'nincs lezárva',
+ DB_ERROR_SYNTAX => 'szintaktikai hiba',
+ DB_ERROR_UNSUPPORTED => 'nem támogatott',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'soron végzett érték számlálás',
+ DB_ERROR_INVALID_DSN => 'hibás DSN',
+ DB_ERROR_CONNECT_FAILED => 'sikertelen csatlakozás',
+ 0 => 'nincs hiba', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'túl kevés az adat',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'bõvítmény nem található',
+ DB_ERROR_NOSUCHDB => 'nincs ilyen adatbázis',
+ DB_ERROR_ACCESS_VIOLATION => 'nincs jogosultság'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-it.inc.php b/html/phpgacl/adodb/lang/adodb-it.inc.php
new file mode 100644
index 0000000..20c5b93
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-it.inc.php
@@ -0,0 +1,34 @@
+<?php
+// Italian language file contributed by Tiraboschi Massimiliano aka TiMax
+// www.maxdev.com timax@maxdev.com
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'it',
+ DB_ERROR => 'errore sconosciuto',
+ DB_ERROR_ALREADY_EXISTS => 'esiste gi&agrave;',
+ DB_ERROR_CANNOT_CREATE => 'non posso creare',
+ DB_ERROR_CANNOT_DELETE => 'non posso cancellare',
+ DB_ERROR_CANNOT_DROP => 'non posso eliminare',
+ DB_ERROR_CONSTRAINT => 'violazione constraint',
+ DB_ERROR_DIVZERO => 'divisione per zero',
+ DB_ERROR_INVALID => 'non valido',
+ DB_ERROR_INVALID_DATE => 'data od ora non valida',
+ DB_ERROR_INVALID_NUMBER => 'numero non valido',
+ DB_ERROR_MISMATCH => 'diversi',
+ DB_ERROR_NODBSELECTED => 'nessun database selezionato',
+ DB_ERROR_NOSUCHFIELD => 'nessun campo trovato',
+ DB_ERROR_NOSUCHTABLE => 'nessuna tabella trovata',
+ DB_ERROR_NOT_CAPABLE => 'DB backend non abilitato',
+ DB_ERROR_NOT_FOUND => 'non trovato',
+ DB_ERROR_NOT_LOCKED => 'non bloccato',
+ DB_ERROR_SYNTAX => 'errore di sintassi',
+ DB_ERROR_UNSUPPORTED => 'non supportato',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'valore inserito troppo grande per una colonna',
+ DB_ERROR_INVALID_DSN => 'DSN non valido',
+ DB_ERROR_CONNECT_FAILED => 'connessione fallita',
+ 0 => 'nessun errore', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'dati inseriti insufficienti',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'estensione non trovata',
+ DB_ERROR_NOSUCHDB => 'database non trovato',
+ DB_ERROR_ACCESS_VIOLATION => 'permessi insufficienti'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-nl.inc.php b/html/phpgacl/adodb/lang/adodb-nl.inc.php
new file mode 100644
index 0000000..bd9eb2f
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-nl.inc.php
@@ -0,0 +1,33 @@
+<?php
+// Translated by Pim Koeman (pim#wittenborg-university.com)
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'nl',
+ DB_ERROR => 'onbekende fout',
+ DB_ERROR_ALREADY_EXISTS => 'bestaat al',
+ DB_ERROR_CANNOT_CREATE => 'kan niet aanmaken',
+ DB_ERROR_CANNOT_DELETE => 'kan niet wissen',
+ DB_ERROR_CANNOT_DROP => 'kan niet verwijderen',
+ DB_ERROR_CONSTRAINT => 'constraint overtreding',
+ DB_ERROR_DIVZERO => 'poging tot delen door nul',
+ DB_ERROR_INVALID => 'ongeldig',
+ DB_ERROR_INVALID_DATE => 'ongeldige datum of tijd',
+ DB_ERROR_INVALID_NUMBER => 'ongeldig nummer',
+ DB_ERROR_MISMATCH => 'is incorrect',
+ DB_ERROR_NODBSELECTED => 'geen database geselecteerd',
+ DB_ERROR_NOSUCHFIELD => 'onbekend veld',
+ DB_ERROR_NOSUCHTABLE => 'onbekende tabel',
+ DB_ERROR_NOT_CAPABLE => 'database systeem is niet tot uitvoer in staat',
+ DB_ERROR_NOT_FOUND => 'niet gevonden',
+ DB_ERROR_NOT_LOCKED => 'niet vergrendeld',
+ DB_ERROR_SYNTAX => 'syntaxis fout',
+ DB_ERROR_UNSUPPORTED => 'niet ondersteund',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'waarde telling op rij',
+ DB_ERROR_INVALID_DSN => 'ongeldige DSN',
+ DB_ERROR_CONNECT_FAILED => 'connectie mislukt',
+ 0 => 'geen fout', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'onvoldoende data gegeven',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extensie niet gevonden',
+ DB_ERROR_NOSUCHDB => 'onbekende database',
+ DB_ERROR_ACCESS_VIOLATION => 'onvoldoende rechten'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-pl.inc.php b/html/phpgacl/adodb/lang/adodb-pl.inc.php
new file mode 100644
index 0000000..b874964
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-pl.inc.php
@@ -0,0 +1,36 @@
+<?php
+
+// Contributed by Grzegorz Pacan <gp#dione.cc>
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'pl',
+ DB_ERROR => 'niezidentyfikowany b³±d',
+ DB_ERROR_ALREADY_EXISTS => 'ju¿ istniej±',
+ DB_ERROR_CANNOT_CREATE => 'nie mo¿na stworzyæ',
+ DB_ERROR_CANNOT_DELETE => 'nie mo¿na usun±æ',
+ DB_ERROR_CANNOT_DROP => 'nie mo¿na porzuciæ',
+ DB_ERROR_CONSTRAINT => 'pogwa³cenie uprawnieñ',
+ DB_ERROR_DIVZERO => 'dzielenie przez zero',
+ DB_ERROR_INVALID => 'b³êdny',
+ DB_ERROR_INVALID_DATE => 'b³êdna godzina lub data',
+ DB_ERROR_INVALID_NUMBER => 'b³êdny numer',
+ DB_ERROR_MISMATCH => 'niedopasowanie',
+ DB_ERROR_NODBSELECTED => 'baza danych nie zosta³a wybrana',
+ DB_ERROR_NOSUCHFIELD => 'nie znaleziono pola',
+ DB_ERROR_NOSUCHTABLE => 'nie znaleziono tabeli',
+ DB_ERROR_NOT_CAPABLE => 'nie zdolny',
+ DB_ERROR_NOT_FOUND => 'nie znaleziono',
+ DB_ERROR_NOT_LOCKED => 'nie zakmniêty',
+ DB_ERROR_SYNTAX => 'b³±d sk³adni',
+ DB_ERROR_UNSUPPORTED => 'nie obs³uguje',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'warto¶æ liczona w szeregu',
+ DB_ERROR_INVALID_DSN => 'b³êdny DSN',
+ DB_ERROR_CONNECT_FAILED => 'po³±czenie nie zosta³o zrealizowane',
+ 0 => 'brak b³êdów', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'niedostateczna ilo¶æ informacji',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'nie znaleziono rozszerzenia',
+ DB_ERROR_NOSUCHDB => 'nie znaleziono bazy',
+ DB_ERROR_ACCESS_VIOLATION => 'niedostateczne uprawnienia'
+);
+?>
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-pt-br.inc.php b/html/phpgacl/adodb/lang/adodb-pt-br.inc.php
new file mode 100644
index 0000000..3424099
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-pt-br.inc.php
@@ -0,0 +1,35 @@
+<?php
+// contributed by "Levi Fukumori" levi _AT_ fukumori _DOT_ com _DOT_ br
+// portugese (brazilian)
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'pt-br',
+ DB_ERROR => 'erro desconhecido',
+ DB_ERROR_ALREADY_EXISTS => 'já existe',
+ DB_ERROR_CANNOT_CREATE => 'impossível criar',
+ DB_ERROR_CANNOT_DELETE => 'impossível excluír',
+ DB_ERROR_CANNOT_DROP => 'impossível remover',
+ DB_ERROR_CONSTRAINT => 'violação do confinamente',
+ DB_ERROR_DIVZERO => 'divisão por zero',
+ DB_ERROR_INVALID => 'inválido',
+ DB_ERROR_INVALID_DATE => 'data ou hora inválida',
+ DB_ERROR_INVALID_NUMBER => 'número inválido',
+ DB_ERROR_MISMATCH => 'erro',
+ DB_ERROR_NODBSELECTED => 'nenhum banco de dados selecionado',
+ DB_ERROR_NOSUCHFIELD => 'campo inválido',
+ DB_ERROR_NOSUCHTABLE => 'tabela inexistente',
+ DB_ERROR_NOT_CAPABLE => 'capacidade inválida para este BD',
+ DB_ERROR_NOT_FOUND => 'não encontrado',
+ DB_ERROR_NOT_LOCKED => 'não bloqueado',
+ DB_ERROR_SYNTAX => 'erro de sintaxe',
+ DB_ERROR_UNSUPPORTED =>
+'não suportado',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'a quantidade de colunas não corresponde ao de valores',
+ DB_ERROR_INVALID_DSN => 'DSN inválido',
+ DB_ERROR_CONNECT_FAILED => 'falha na conexão',
+ 0 => 'sem erro', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'dados insuficientes',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extensão não encontrada',
+ DB_ERROR_NOSUCHDB => 'banco de dados não encontrado',
+ DB_ERROR_ACCESS_VIOLATION => 'permissão insuficiente'
+);
+?>
diff --git a/html/phpgacl/adodb/lang/adodb-ro.inc.php b/html/phpgacl/adodb/lang/adodb-ro.inc.php
new file mode 100644
index 0000000..f390dba
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-ro.inc.php
@@ -0,0 +1,36 @@
+<?php
+
+/* Romanian - by "bogdan stefan" <sbogdan#rsb.ro> */
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'ro',
+ DB_ERROR => 'eroare necunoscuta',
+ DB_ERROR_ALREADY_EXISTS => 'deja exista',
+ DB_ERROR_CANNOT_CREATE => 'nu se poate creea',
+ DB_ERROR_CANNOT_DELETE => 'nu se poate sterge',
+ DB_ERROR_CANNOT_DROP => 'nu se poate executa drop',
+ DB_ERROR_CONSTRAINT => 'violare de constrain',
+ DB_ERROR_DIVZERO => 'se divide la zero',
+ DB_ERROR_INVALID => 'invalid',
+ DB_ERROR_INVALID_DATE => 'data sau timp invalide',
+ DB_ERROR_INVALID_NUMBER => 'numar invalid',
+ DB_ERROR_MISMATCH => 'nepotrivire-mismatch',
+ DB_ERROR_NODBSELECTED => 'nu exista baza de date selectata',
+ DB_ERROR_NOSUCHFIELD => 'camp inexistent',
+ DB_ERROR_NOSUCHTABLE => 'tabela inexistenta',
+ DB_ERROR_NOT_CAPABLE => 'functie optionala neinstalata',
+ DB_ERROR_NOT_FOUND => 'negasit',
+ DB_ERROR_NOT_LOCKED => 'neblocat',
+ DB_ERROR_SYNTAX => 'eroare de sintaxa',
+ DB_ERROR_UNSUPPORTED => 'nu e suportat',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'valoare prea mare pentru coloana',
+ DB_ERROR_INVALID_DSN => 'DSN invalid',
+ DB_ERROR_CONNECT_FAILED => 'conectare esuata',
+ 0 => 'fara eroare', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'data introduse insuficiente',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'extensie negasita',
+ DB_ERROR_NOSUCHDB => 'nu exista baza de date',
+ DB_ERROR_ACCESS_VIOLATION => 'permisiuni insuficiente'
+);
+?>
+
diff --git a/html/phpgacl/adodb/lang/adodb-ru1251.inc.php b/html/phpgacl/adodb/lang/adodb-ru1251.inc.php
new file mode 100644
index 0000000..3a20538
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-ru1251.inc.php
@@ -0,0 +1,35 @@
+<?php
+
+// Russian language file contributed by "Cyrill Malevanov" cyrill#malevanov.spb.ru.
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'ru1251',
+ DB_ERROR => 'íåèçâåñòíàÿ îøèáêà',
+ DB_ERROR_ALREADY_EXISTS => 'óæå ñóùåñòâóåò',
+ DB_ERROR_CANNOT_CREATE => 'íåâîçìîæíî ñîçäàòü',
+ DB_ERROR_CANNOT_DELETE => 'íåâîçìîæíî óäàëèòü',
+ DB_ERROR_CANNOT_DROP => 'íåâîçìîæíî óäàëèòü (drop)',
+ DB_ERROR_CONSTRAINT => 'íàðóøåíèå óñëîâèé ïðîâåðêè',
+ DB_ERROR_DIVZERO => 'äåëåíèå íà 0',
+ DB_ERROR_INVALID => 'íåïðàâèëüíî',
+ DB_ERROR_INVALID_DATE => 'íåêîððåêòíàÿ äàòà èëè âðåìÿ',
+ DB_ERROR_INVALID_NUMBER => 'íåêîððåêòíîå ÷èñëî',
+ DB_ERROR_MISMATCH => 'îøèáêà',
+ DB_ERROR_NODBSELECTED => 'ÁÄ íå âûáðàíà',
+ DB_ERROR_NOSUCHFIELD => 'íå ñóùåñòâóåò ïîëå',
+ DB_ERROR_NOSUCHTABLE => 'íå ñóùåñòâóåò òàáëèöà',
+ DB_ERROR_NOT_CAPABLE => 'ÑÓÁÄ íå â ñîñòîÿíèè',
+ DB_ERROR_NOT_FOUND => 'íå íàéäåíî',
+ DB_ERROR_NOT_LOCKED => 'íå çàáëîêèðîâàíî',
+ DB_ERROR_SYNTAX => 'ñèíòàêñè÷åñêàÿ îøèáêà',
+ DB_ERROR_UNSUPPORTED => 'íå ïîääåðæèâàåòñÿ',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'ñ÷åò÷èê çíà÷åíèé â ñòðîêå',
+ DB_ERROR_INVALID_DSN => 'íåïðàâèëüíàÿ DSN',
+ DB_ERROR_CONNECT_FAILED => 'ñîåäèíåíèå íåóñïåøíî',
+ 0 => 'íåò îøèáêè', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'ïðåäîñòàâëåíî íåäîñòàòî÷íî äàííûõ',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'ðàñøèðåíèå íå íàéäåíî',
+ DB_ERROR_NOSUCHDB => 'íå ñóùåñòâóåò ÁÄ',
+ DB_ERROR_ACCESS_VIOLATION => 'íåäîñòàòî÷íî ïðàâ äîñòóïà'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-sv.inc.php b/html/phpgacl/adodb/lang/adodb-sv.inc.php
new file mode 100644
index 0000000..a9fd698
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-sv.inc.php
@@ -0,0 +1,33 @@
+<?php
+// Christian Tiberg" christian@commsoft.nu
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'en',
+ DB_ERROR => 'Okänt fel',
+ DB_ERROR_ALREADY_EXISTS => 'finns redan',
+ DB_ERROR_CANNOT_CREATE => 'kan inte skapa',
+ DB_ERROR_CANNOT_DELETE => 'kan inte ta bort',
+ DB_ERROR_CANNOT_DROP => 'kan inte släppa',
+ DB_ERROR_CONSTRAINT => 'begränsning kränkt',
+ DB_ERROR_DIVZERO => 'division med noll',
+ DB_ERROR_INVALID => 'ogiltig',
+ DB_ERROR_INVALID_DATE => 'ogiltigt datum eller tid',
+ DB_ERROR_INVALID_NUMBER => 'ogiltigt tal',
+ DB_ERROR_MISMATCH => 'felaktig matchning',
+ DB_ERROR_NODBSELECTED => 'ingen databas vald',
+ DB_ERROR_NOSUCHFIELD => 'inget sådant fält',
+ DB_ERROR_NOSUCHTABLE => 'ingen sådan tabell',
+ DB_ERROR_NOT_CAPABLE => 'DB backend klarar det inte',
+ DB_ERROR_NOT_FOUND => 'finns inte',
+ DB_ERROR_NOT_LOCKED => 'inte låst',
+ DB_ERROR_SYNTAX => 'syntaxfel',
+ DB_ERROR_UNSUPPORTED => 'stöds ej',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'värde räknat på rad',
+ DB_ERROR_INVALID_DSN => 'ogiltig DSN',
+ DB_ERROR_CONNECT_FAILED => 'anslutning misslyckades',
+ 0 => 'inget fel', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'otillräckligt med data angivet',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'utökning hittades ej',
+ DB_ERROR_NOSUCHDB => 'ingen sådan databas',
+ DB_ERROR_ACCESS_VIOLATION => 'otillräckliga rättigheter'
+);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/lang/adodb-uk1251.inc.php b/html/phpgacl/adodb/lang/adodb-uk1251.inc.php
new file mode 100644
index 0000000..9fa32ed
--- /dev/null
+++ b/html/phpgacl/adodb/lang/adodb-uk1251.inc.php
@@ -0,0 +1,35 @@
+<?php
+
+// Ukrainian language file contributed by Alex Rootoff rootoff{AT}pisem.net.
+
+$ADODB_LANG_ARRAY = array (
+ 'LANG' => 'uk1251',
+ DB_ERROR => 'íåâ³äîìà ïîìèëêà',
+ DB_ERROR_ALREADY_EXISTS => 'âæå ³ñíóº',
+ DB_ERROR_CANNOT_CREATE => 'íåìîæëèâî ñòâîðèòè',
+ DB_ERROR_CANNOT_DELETE => 'íåìîæëèâî âèäàëèòè',
+ DB_ERROR_CANNOT_DROP => 'íåìîæëèâî çíèùèòè (drop)',
+ DB_ERROR_CONSTRAINT => 'ïîðóøåííÿ óìîâ ïåðåâ³ðêè',
+ DB_ERROR_DIVZERO => 'ä³ëåííÿ íà 0',
+ DB_ERROR_INVALID => 'íåïðàâèëüíî',
+ DB_ERROR_INVALID_DATE => 'íåïðàâèëüíà äàòà ÷è ÷àñ',
+ DB_ERROR_INVALID_NUMBER => 'íåïðàâèëüíå ÷èñëî',
+ DB_ERROR_MISMATCH => 'ïîìèëêà',
+ DB_ERROR_NODBSELECTED => 'íå âèáðàíî ÁÄ',
+ DB_ERROR_NOSUCHFIELD => 'íå ³ñíóº ïîëå',
+ DB_ERROR_NOSUCHTABLE => 'íå ³ñíóº òàáëèöÿ',
+ DB_ERROR_NOT_CAPABLE => 'ÑÓÁÄ íå â ñòàí³',
+ DB_ERROR_NOT_FOUND => 'íå çíàéäåíî',
+ DB_ERROR_NOT_LOCKED => 'íå çàáëîêîâàíî',
+ DB_ERROR_SYNTAX => 'ñèíòàêñè÷íà ïîìèëêà',
+ DB_ERROR_UNSUPPORTED => 'íå ï³äòðèìóºòüñÿ',
+ DB_ERROR_VALUE_COUNT_ON_ROW => 'ðàõ³âíèê çíà÷åíü â ñòð³÷ö³',
+ DB_ERROR_INVALID_DSN => 'íåïðàâèëüíà DSN',
+ DB_ERROR_CONNECT_FAILED => 'ç\'ºäíàííÿ íåóñï³øíå',
+ 0 => 'âñå ãàðàçä', // DB_OK
+ DB_ERROR_NEED_MORE_DATA => 'íàäàíî íåäîñòàòíüî äàíèõ',
+ DB_ERROR_EXTENSION_NOT_FOUND=> 'ðîçøèðåííÿ íå çíàéäåíî',
+ DB_ERROR_NOSUCHDB => 'íå ³ñíóº ÁÄ',
+ DB_ERROR_ACCESS_VIOLATION => 'íåäîñòàòíüî ïðàâ äîñòóïà'
+);
+?>
diff --git a/html/phpgacl/adodb/license.txt b/html/phpgacl/adodb/license.txt
new file mode 100644
index 0000000..2353871
--- /dev/null
+++ b/html/phpgacl/adodb/license.txt
@@ -0,0 +1,182 @@
+ADOdb is dual licensed using BSD and LGPL.
+
+In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license.
+
+For more info about ADOdb, visit http://adodb.sourceforge.net/
+
+BSD Style-License
+=================
+
+Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list
+of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this list
+of conditions and the following disclaimer in the documentation and/or other materials
+provided with the distribution.
+
+Neither the name of the John Lim nor the names of its contributors may be used to
+endorse or promote products derived from this software without specific prior written
+permission.
+
+DISCLAIMER:
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+JOHN LIM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+==========================================================
+GNU LESSER GENERAL PUBLIC LICENSE
+Version 2.1, February 1999
+
+Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+
+Preamble
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things.
+
+To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others.
+
+Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library.
+
+We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances.
+
+For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run.
+
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you".
+
+A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables.
+
+The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".)
+
+"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library.
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does.
+
+1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+
+a) The modified work must itself be a software library.
+b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
+c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
+d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
+(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices.
+
+Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the Library into a program that is not a library.
+
+4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code.
+
+5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
+
+However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables.
+
+When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself.
+
+6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
+
+
+a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.)
+b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with.
+c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
+d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place.
+e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy.
+For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute.
+
+7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things:
+
+
+a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above.
+b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
+8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it.
+
+10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License.
+
+11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation.
+
+14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+END OF TERMS AND CONDITIONS \ No newline at end of file
diff --git a/html/phpgacl/adodb/pear/readme.Auth.txt b/html/phpgacl/adodb/pear/readme.Auth.txt
new file mode 100644
index 0000000..b6b0c15
--- /dev/null
+++ b/html/phpgacl/adodb/pear/readme.Auth.txt
@@ -0,0 +1,20 @@
+From: Rich Tango-Lowy (richtl#arscognita.com)
+Date: Sat, May 29, 2004 11:20 am
+
+OK, I hacked out an ADOdb container for PEAR-Auth. The error handling's
+a bit of a mess, but all the methods work.
+
+Copy ADOdb.php to your pear/Auth/Container/ directory.
+
+Use the ADOdb container exactly as you would the DB
+container, but specify 'ADOdb' instead of 'DB':
+
+$dsn = "mysql://myuser:mypass@localhost/authdb";
+$a = new Auth("ADOdb", $dsn, "loginFunction");
+
+
+-------------------
+
+John Lim adds:
+
+See http://pear.php.net/manual/en/package.authentication.php
diff --git a/html/phpgacl/adodb/perf/perf-db2.inc.php b/html/phpgacl/adodb/perf/perf-db2.inc.php
new file mode 100644
index 0000000..3d0081a
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-db2.inc.php
@@ -0,0 +1,102 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+// Simple guide to configuring db2: so-so http://www.devx.com/gethelpon/10MinuteSolution/16575
+
+// SELECT * FROM TABLE(SNAPSHOT_APPL('SAMPLE', -1)) as t
+class perf_db2 extends adodb_perf{
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created TIMESTAMP NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(4000) NOT NULL,
+ params varchar(3000) NOT NULL,
+ tracer varchar(500) NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $settings = array(
+ 'Ratios',
+ 'data cache hit ratio' => array('RATIO',
+ "SELECT
+ case when sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)=0 then 0
+ else 100*(1-sum(POOL_DATA_P_READS+POOL_INDEX_P_READS)/sum(POOL_DATA_L_READS+POOL_INDEX_L_READS)) end
+ FROM TABLE(SNAPSHOT_APPL('',-2)) as t",
+ '=WarnCacheRatio'),
+
+ 'Data Cache',
+ 'data cache buffers' => array('DATAC',
+ 'select sum(npages) from SYSCAT.BUFFERPOOLS',
+ 'See <a href=http://www7b.boulder.ibm.com/dmdd/library/techarticle/anshum/0107anshum.html#bufferpoolsize>tuning reference</a>.' ),
+ 'cache blocksize' => array('DATAC',
+ 'select avg(pagesize) from SYSCAT.BUFFERPOOLS',
+ '' ),
+ 'data cache size' => array('DATAC',
+ 'select sum(npages*pagesize) from SYSCAT.BUFFERPOOLS',
+ '' ),
+ 'Connections',
+ 'current connections' => array('SESS',
+ "SELECT count(*) FROM TABLE(SNAPSHOT_APPL_INFO('',-2)) as t",
+ ''),
+
+ false
+ );
+
+
+ function perf_db2(&$conn)
+ {
+ $this->conn =& $conn;
+ }
+
+ function Explain($sql,$partial=false)
+ {
+ $save = $this->conn->LogSQL(false);
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
+ if ($arr) {
+ foreach($arr as $row) {
+ $sql = reset($row);
+ if (crc32($sql) == $partial) break;
+ }
+ }
+ }
+ $qno = rand();
+ $ok = $this->conn->Execute("EXPLAIN PLAN SET QUERYNO=$qno FOR $sql");
+ ob_start();
+ if (!$ok) echo "<p>Have EXPLAIN tables been created?</p>";
+ else {
+ $rs = $this->conn->Execute("select * from explain_statement where queryno=$qno");
+ if ($rs) rs2html($rs);
+ }
+ $s = ob_get_contents();
+ ob_end_clean();
+ $this->conn->LogSQL($save);
+
+ $s .= $this->Tracer($sql);
+ return $s;
+ }
+
+
+ function Tables()
+ {
+ $rs = $this->conn->Execute("select tabschema,tabname,card as rows,
+ npages pages_used,fpages pages_allocated, tbspace tablespace
+ from syscat.tables where tabschema not in ('SYSCAT','SYSIBM','SYSSTAT') order by 1,2");
+ return rs2html($rs,false,false,false,false);
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/perf/perf-informix.inc.php b/html/phpgacl/adodb/perf/perf-informix.inc.php
new file mode 100644
index 0000000..20f424d
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-informix.inc.php
@@ -0,0 +1,70 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+//
+// Thx to Fernando Ortiz, mailto:fortiz#lacorona.com.mx
+// With info taken from http://www.oninit.com/oninit/sysmaster/index.html
+//
+class perf_informix extends adodb_perf{
+
+ // Maximum size on varchar upto 9.30 255 chars
+ // better truncate varchar to 255 than char(4000) ?
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created datetime year to second NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(255) NOT NULL,
+ params varchar(255) NOT NULL,
+ tracer varchar(255) NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $tablesSQL = "select a.tabname tablename, ti_nptotal*2 size_in_k, ti_nextns extents, ti_nrows records from systables c, sysmaster:systabnames a, sysmaster:systabinfo b where c.tabname not matches 'sys*' and c.partnum = a.partnum and c.partnum = b.ti_partnum";
+
+ var $settings = array(
+ 'Ratios',
+ 'data cache hit ratio' => array('RATIOH',
+ "select round((1-(wt.value / (rd.value + wr.value)))*100,2)
+ from sysmaster:sysprofile wr, sysmaster:sysprofile rd, sysmaster:sysprofile wt
+ where rd.name = 'pagreads' and
+ wr.name = 'pagwrites' and
+ wt.name = 'buffwts'",
+ '=WarnCacheRatio'),
+ 'IO',
+ 'data reads' => array('IO',
+ "select value from sysmaster:sysprofile where name='pagreads'",
+ 'Page reads'),
+
+ 'data writes' => array('IO',
+ "select value from sysmaster:sysprofile where name='pagwrites'",
+ 'Page writes'),
+
+ 'Connections',
+ 'current connections' => array('SESS',
+ 'select count(*) from sysmaster:syssessions',
+ 'Number of sessions'),
+
+ false
+
+ );
+
+ function perf_informix(&$conn)
+ {
+ $this->conn =& $conn;
+ }
+
+}
+?>
diff --git a/html/phpgacl/adodb/perf/perf-mssql.inc.php b/html/phpgacl/adodb/perf/perf-mssql.inc.php
new file mode 100644
index 0000000..e20c8dd
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-mssql.inc.php
@@ -0,0 +1,164 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+ MSSQL has moved most performance info to Performance Monitor
+*/
+class perf_mssql extends adodb_perf{
+ var $sql1 = 'cast(sql1 as text)';
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created datetime NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(4000) NOT NULL,
+ params varchar(3000) NOT NULL,
+ tracer varchar(500) NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $settings = array(
+ 'Ratios',
+ 'data cache hit ratio' => array('RATIO',
+ "select round((a.cntr_value*100.0)/b.cntr_value,2) from master.dbo.sysperfinfo a, master.dbo.sysperfinfo b where a.counter_name = 'Buffer cache hit ratio' and b.counter_name='Buffer cache hit ratio base'",
+ '=WarnCacheRatio'),
+ 'prepared sql hit ratio' => array('RATIO',
+ array('dbcc cachestats','Prepared',1,100),
+ ''),
+ 'adhoc sql hit ratio' => array('RATIO',
+ array('dbcc cachestats','Adhoc',1,100),
+ ''),
+ 'IO',
+ 'data reads' => array('IO',
+ "select cntr_value from master.dbo.sysperfinfo where counter_name = 'Page reads/sec'"),
+ 'data writes' => array('IO',
+ "select cntr_value from master.dbo.sysperfinfo where counter_name = 'Page writes/sec'"),
+
+ 'Data Cache',
+ 'data cache size' => array('DATAC',
+ "select cntr_value*8192 from master.dbo.sysperfinfo where counter_name = 'Total Pages' and object_name='SQLServer:Buffer Manager'",
+ '' ),
+ 'data cache blocksize' => array('DATAC',
+ "select 8192",'page size'),
+ 'Connections',
+ 'current connections' => array('SESS',
+ '=sp_who',
+ ''),
+ 'max connections' => array('SESS',
+ "SELECT @@MAX_CONNECTIONS",
+ ''),
+
+ false
+ );
+
+
+ function perf_mssql(&$conn)
+ {
+ if ($conn->dataProvider == 'odbc') {
+ $this->sql1 = 'sql1';
+ //$this->explain = false;
+ }
+ $this->conn =& $conn;
+ }
+
+ function Explain($sql,$partial=false)
+ {
+
+ $save = $this->conn->LogSQL(false);
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
+ if ($arr) {
+ foreach($arr as $row) {
+ $sql = reset($row);
+ if (crc32($sql) == $partial) break;
+ }
+ }
+ }
+
+ $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+ $this->conn->Execute("SET SHOWPLAN_ALL ON;");
+ $sql = str_replace('?',"''",$sql);
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs =& $this->conn->Execute($sql);
+ //adodb_printr($rs);
+ $ADODB_FETCH_MODE = $save;
+ if ($rs) {
+ $rs->MoveNext();
+ $s .= '<table bgcolor=white border=0 cellpadding="1" callspacing=0><tr><td nowrap align=center> Rows<td nowrap align=center> IO<td nowrap align=center> CPU<td align=left> &nbsp; &nbsp; Plan</tr>';
+ while (!$rs->EOF) {
+ $s .= '<tr><td>'.round($rs->fields[8],1).'<td>'.round($rs->fields[9],3).'<td align=right>'.round($rs->fields[10],3).'<td nowrap><pre>'.htmlspecialchars($rs->fields[0])."</td></pre></tr>\n"; ## NOTE CORRUPT </td></pre> tag is intentional!!!!
+ $rs->MoveNext();
+ }
+ $s .= '</table>';
+
+ $rs->NextRecordSet();
+ }
+
+ $this->conn->Execute("SET SHOWPLAN_ALL OFF;");
+ $this->conn->LogSQL($save);
+ $s .= $this->Tracer($sql);
+ return $s;
+ }
+
+ function Tables()
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ //$this->conn->debug=1;
+ $s = '<table border=1 bgcolor=white><tr><td><b>tablename</b></td><td><b>size_in_k</b></td><td><b>index size</b></td><td><b>reserved size</b></td></tr>';
+ $rs1 = $this->conn->Execute("select distinct name from sysobjects where xtype='U'");
+ if ($rs1) {
+ while (!$rs1->EOF) {
+ $tab = $rs1->fields[0];
+ $tabq = $this->conn->qstr($tab);
+ $rs2 = $this->conn->Execute("sp_spaceused $tabq");
+ if ($rs2) {
+ $s .= '<tr><td>'.$tab.'</td><td align=right>'.$rs2->fields[3].'</td><td align=right>'.$rs2->fields[4].'</td><td align=right>'.$rs2->fields[2].'</td></tr>';
+ $rs2->Close();
+ }
+ $rs1->MoveNext();
+ }
+ $rs1->Close();
+ }
+ $ADODB_FETCH_MODE = $save;
+ return $s.'</table>';
+ }
+
+ function sp_who()
+ {
+ $arr = $this->conn->GetArray('sp_who');
+ return sizeof($arr);
+ }
+
+ function HealthCheck($cli=false)
+ {
+
+ $this->conn->Execute('dbcc traceon(3604)');
+ $html = adodb_perf::HealthCheck($cli);
+ $this->conn->Execute('dbcc traceoff(3604)');
+ return $html;
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/perf/perf-mysql.inc.php b/html/phpgacl/adodb/perf/perf-mysql.inc.php
new file mode 100644
index 0000000..5e0d078
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-mysql.inc.php
@@ -0,0 +1,315 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class perf_mysql extends adodb_perf{
+
+ var $tablesSQL = 'show table status';
+
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created datetime NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 text NOT NULL,
+ params text NOT NULL,
+ tracer text NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $settings = array(
+ 'Ratios',
+ 'MyISAM cache hit ratio' => array('RATIO',
+ '=GetKeyHitRatio',
+ '=WarnCacheRatio'),
+ 'InnoDB cache hit ratio' => array('RATIO',
+ '=GetInnoDBHitRatio',
+ '=WarnCacheRatio'),
+ 'data cache hit ratio' => array('HIDE', # only if called
+ '=FindDBHitRatio',
+ '=WarnCacheRatio'),
+ 'sql cache hit ratio' => array('RATIO',
+ '=GetQHitRatio',
+ ''),
+ 'IO',
+ 'data reads' => array('IO',
+ '=GetReads',
+ 'Number of selects (Key_reads is not accurate)'),
+ 'data writes' => array('IO',
+ '=GetWrites',
+ 'Number of inserts/updates/deletes * coef (Key_writes is not accurate)'),
+
+ 'Data Cache',
+ 'MyISAM data cache size' => array('DATAC',
+ array("show variables", 'key_buffer_size'),
+ '' ),
+ 'BDB data cache size' => array('DATAC',
+ array("show variables", 'bdb_cache_size'),
+ '' ),
+ 'InnoDB data cache size' => array('DATAC',
+ array("show variables", 'innodb_buffer_pool_size'),
+ '' ),
+ 'Memory Usage',
+ 'read buffer size' => array('CACHE',
+ array("show variables", 'read_buffer_size'),
+ '(per session)'),
+ 'sort buffer size' => array('CACHE',
+ array("show variables", 'sort_buffer_size'),
+ 'Size of sort buffer (per session)' ),
+ 'table cache' => array('CACHE',
+ array("show variables", 'table_cache'),
+ 'Number of tables to keep open'),
+ 'Connections',
+ 'current connections' => array('SESS',
+ array('show status','Threads_connected'),
+ ''),
+ 'max connections' => array( 'SESS',
+ array("show variables",'max_connections'),
+ ''),
+
+ false
+ );
+
+ function perf_mysql(&$conn)
+ {
+ $this->conn =& $conn;
+ }
+
+ function Explain($sql,$partial=false)
+ {
+
+ if (strtoupper(substr(trim($sql),0,6)) !== 'SELECT') return '<p>Unable to EXPLAIN non-select statement</p>';
+ $save = $this->conn->LogSQL(false);
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $arr = $this->conn->GetArray("select distinct sql1 from adodb_logsql where sql1 like $sqlq");
+ if ($arr) {
+ foreach($arr as $row) {
+ $sql = reset($row);
+ if (crc32($sql) == $partial) break;
+ }
+ }
+ }
+ $sql = str_replace('?',"''",$sql);
+
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $sql = $this->conn->GetOne("select sql1 from adodb_logsql where sql1 like $sqlq");
+ }
+
+ $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+ $rs = $this->conn->Execute('EXPLAIN '.$sql);
+ $s .= rs2html($rs,false,false,false,false);
+ $this->conn->LogSQL($save);
+ $s .= $this->Tracer($sql);
+ return $s;
+ }
+
+ function Tables()
+ {
+ if (!$this->tablesSQL) return false;
+
+ $rs = $this->conn->Execute($this->tablesSQL);
+ if (!$rs) return false;
+
+ $html = rs2html($rs,false,false,false,false);
+ return $html;
+ }
+
+ function GetReads()
+ {
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs = $this->conn->Execute('show status');
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if (!$rs) return 0;
+ $val = 0;
+ while (!$rs->EOF) {
+ switch($rs->fields[0]) {
+ case 'Com_select':
+ $val = $rs->fields[1];
+ $rs->Close();
+ return $val;
+ }
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+
+ return $val;
+ }
+
+ function GetWrites()
+ {
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs = $this->conn->Execute('show status');
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if (!$rs) return 0;
+ $val = 0.0;
+ while (!$rs->EOF) {
+ switch($rs->fields[0]) {
+ case 'Com_insert':
+ $val += $rs->fields[1]; break;
+ case 'Com_delete':
+ $val += $rs->fields[1]; break;
+ case 'Com_update':
+ $val += $rs->fields[1]/2;
+ $rs->Close();
+ return $val;
+ }
+ $rs->MoveNext();
+ }
+
+ $rs->Close();
+
+ return $val;
+ }
+
+ function FindDBHitRatio()
+ {
+ // first find out type of table
+ //$this->conn->debug=1;
+
+ global $ADODB_FETCH_MODE;
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs = $this->conn->Execute('show table status');
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if (!$rs) return '';
+ $type = strtoupper($rs->fields[1]);
+ $rs->Close();
+ switch($type){
+ case 'MYISAM':
+ case 'ISAM':
+ return $this->DBParameter('MyISAM cache hit ratio').' (MyISAM)';
+ case 'INNODB':
+ return $this->DBParameter('InnoDB cache hit ratio').' (InnoDB)';
+ default:
+ return $type.' not supported';
+ }
+
+ }
+
+ function GetQHitRatio()
+ {
+ //Total number of queries = Qcache_inserts + Qcache_hits + Qcache_not_cached
+ $hits = $this->_DBParameter(array("show status","Qcache_hits"));
+ $total = $this->_DBParameter(array("show status","Qcache_inserts"));
+ $total += $this->_DBParameter(array("show status","Qcache_not_cached"));
+
+ $total += $hits;
+ if ($total) return round(($hits*100)/$total,2);
+ return 0;
+ }
+
+ /*
+ Use session variable to store Hit percentage, because MySQL
+ does not remember last value of SHOW INNODB STATUS hit ratio
+
+ # 1st query to SHOW INNODB STATUS
+ 0.00 reads/s, 0.00 creates/s, 0.00 writes/s
+ Buffer pool hit rate 1000 / 1000
+
+ # 2nd query to SHOW INNODB STATUS
+ 0.00 reads/s, 0.00 creates/s, 0.00 writes/s
+ No buffer pool activity since the last printout
+ */
+ function GetInnoDBHitRatio()
+ {
+ global $ADODB_FETCH_MODE;
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $rs = $this->conn->Execute('show innodb status');
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+
+ if (!$rs || $rs->EOF) return 0;
+ $stat = $rs->fields[0];
+ $rs->Close();
+ $at = strpos($stat,'Buffer pool hit rate');
+ $stat = substr($stat,$at,200);
+ if (preg_match('!Buffer pool hit rate\s*([0-9]*) / ([0-9]*)!',$stat,$arr)) {
+ $val = 100*$arr[1]/$arr[2];
+ $_SESSION['INNODB_HIT_PCT'] = $val;
+ return round($val,2);
+ } else {
+ if (isset($_SESSION['INNODB_HIT_PCT'])) return $_SESSION['INNODB_HIT_PCT'];
+ return 0;
+ }
+ return 0;
+ }
+
+ function GetKeyHitRatio()
+ {
+ $hits = $this->_DBParameter(array("show status","Key_read_requests"));
+ $reqs = $this->_DBParameter(array("show status","Key_reads"));
+ if ($reqs == 0) return 0;
+
+ return round(($hits/($reqs+$hits))*100,2);
+ }
+
+ // start hack
+ var $optimizeTableLow = 'CHECK TABLE %s FAST QUICK';
+ var $optimizeTableHigh = 'OPTIMIZE TABLE %s';
+
+ /**
+ * @see adodb_perf#optimizeTable
+ */
+ function optimizeTable( $table, $mode = ADODB_OPT_LOW)
+ {
+ if ( !is_string( $table)) return false;
+
+ $conn = $this->conn;
+ if ( !$conn) return false;
+
+ $sql = '';
+ switch( $mode) {
+ case ADODB_OPT_LOW : $sql = $this->optimizeTableLow; break;
+ case ADODB_OPT_HIGH : $sql = $this->optimizeTableHigh; break;
+ default :
+ {
+ // May dont use __FUNCTION__ constant for BC (__FUNCTION__ Added in PHP 4.3.0)
+ ADOConnection::outp( sprintf( "<p>%s: '%s' using of undefined mode '%s'</p>", __CLASS__, __FUNCTION__, $mode));
+ return false;
+ }
+ }
+ $sql = sprintf( $sql, $table);
+
+ return $conn->Execute( $sql) !== false;
+ }
+ // end hack
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/perf/perf-oci8.inc.php b/html/phpgacl/adodb/perf/perf-oci8.inc.php
new file mode 100644
index 0000000..e6222e1
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-oci8.inc.php
@@ -0,0 +1,509 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+class perf_oci8 extends ADODB_perf{
+
+ var $tablesSQL = "select segment_name as \"tablename\", sum(bytes)/1024 as \"size_in_k\",tablespace_name as \"tablespace\",count(*) \"extents\" from sys.user_extents
+ group by segment_name,tablespace_name";
+
+ var $version;
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created date NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 varchar(4000) NOT NULL,
+ params varchar(4000),
+ tracer varchar(4000),
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $settings = array(
+ 'Ratios',
+ 'data cache hit ratio' => array('RATIOH',
+ "select round((1-(phy.value / (cur.value + con.value)))*100,2)
+ from v\$sysstat cur, v\$sysstat con, v\$sysstat phy
+ where cur.name = 'db block gets' and
+ con.name = 'consistent gets' and
+ phy.name = 'physical reads'",
+ '=WarnCacheRatio'),
+
+ 'sql cache hit ratio' => array( 'RATIOH',
+ 'select round(100*(sum(pins)-sum(reloads))/sum(pins),2) from v$librarycache',
+ 'increase <i>shared_pool_size</i> if too ratio low'),
+
+ 'datadict cache hit ratio' => array('RATIOH',
+ "select
+ round((1 - (sum(getmisses) / (sum(gets) +
+ sum(getmisses))))*100,2)
+ from v\$rowcache",
+ 'increase <i>shared_pool_size</i> if too ratio low'),
+
+ 'memory sort ratio' => array('RATIOH',
+ "SELECT ROUND((100 * b.VALUE) /DECODE ((a.VALUE + b.VALUE),
+ 0,1,(a.VALUE + b.VALUE)),2)
+FROM v\$sysstat a,
+ v\$sysstat b
+WHERE a.name = 'sorts (disk)'
+AND b.name = 'sorts (memory)'",
+ "% of memory sorts compared to disk sorts - should be over 95%"),
+
+ 'IO',
+ 'data reads' => array('IO',
+ "select value from v\$sysstat where name='physical reads'"),
+
+ 'data writes' => array('IO',
+ "select value from v\$sysstat where name='physical writes'"),
+
+ 'Data Cache',
+ 'data cache buffers' => array( 'DATAC',
+ "select a.value/b.value from v\$parameter a, v\$parameter b
+ where a.name = 'db_cache_size' and b.name= 'db_block_size'",
+ 'Number of cache buffers. Tune <i>db_cache_size</i> if the <i>data cache hit ratio</i> is too low.'),
+ 'data cache blocksize' => array('DATAC',
+ "select value from v\$parameter where name='db_block_size'",
+ '' ),
+ 'Memory Pools',
+ 'data cache size' => array('DATAC',
+ "select value from v\$parameter where name = 'db_cache_size'",
+ 'db_cache_size' ),
+ 'shared pool size' => array('DATAC',
+ "select value from v\$parameter where name = 'shared_pool_size'",
+ 'shared_pool_size, which holds shared sql, stored procedures, dict cache and similar shared structs' ),
+ 'java pool size' => array('DATAJ',
+ "select value from v\$parameter where name = 'java_pool_size'",
+ 'java_pool_size' ),
+ 'large pool buffer size' => array('CACHE',
+ "select value from v\$parameter where name='large_pool_size'",
+ 'this pool is for large mem allocations (not because it is larger than shared pool), for MTS sessions, parallel queries, io buffers (large_pool_size) ' ),
+
+ 'pga buffer size' => array('CACHE',
+ "select value from v\$parameter where name='pga_aggregate_target'",
+ 'program global area is private memory for sorting, and hash and bitmap merges - since oracle 9i (pga_aggregate_target)' ),
+
+
+ 'Connections',
+ 'current connections' => array('SESS',
+ 'select count(*) from sys.v_$session where username is not null',
+ ''),
+ 'max connections' => array( 'SESS',
+ "select value from v\$parameter where name='sessions'",
+ ''),
+
+ 'Memory Utilization',
+ 'data cache utilization ratio' => array('RATIOU',
+ "select round((1-bytes/sgasize)*100, 2)
+ from (select sum(bytes) sgasize from sys.v_\$sgastat) s, sys.v_\$sgastat f
+ where name = 'free memory' and pool = 'shared pool'",
+ 'Percentage of data cache actually in use - should be over 85%'),
+
+ 'shared pool utilization ratio' => array('RATIOU',
+ 'select round((sga.bytes/p.value)*100,2)
+ from v$sgastat sga, v$parameter p
+ where sga.name = \'free memory\' and sga.pool = \'shared pool\'
+ and p.name = \'shared_pool_size\'',
+ 'Percentage of shared pool actually used - too low is bad, too high is worse'),
+
+ 'large pool utilization ratio' => array('RATIOU',
+ "select round((1-bytes/sgasize)*100, 2)
+ from (select sum(bytes) sgasize from sys.v_\$sgastat) s, sys.v_\$sgastat f
+ where name = 'free memory' and pool = 'large pool'",
+ 'Percentage of large_pool actually in use - too low is bad, too high is worse'),
+ 'sort buffer size' => array('CACHE',
+ "select value from v\$parameter where name='sort_area_size'",
+ 'max in-mem sort_area_size (per query), uses memory in pga' ),
+
+ 'pga usage at peak' => array('RATIOU',
+ '=PGA','Mb utilization at peak transactions (requires Oracle 9i+)'),
+ 'Transactions',
+ 'rollback segments' => array('ROLLBACK',
+ "select count(*) from sys.v_\$rollstat",
+ ''),
+
+ 'peak transactions' => array('ROLLBACK',
+ "select max_utilization tx_hwm
+ from sys.v_\$resource_limit
+ where resource_name = 'transactions'",
+ 'Taken from high-water-mark'),
+ 'max transactions' => array('ROLLBACK',
+ "select value from v\$parameter where name = 'transactions'",
+ 'max transactions / rollback segments < 3.5 (or transactions_per_rollback_segment)'),
+ 'Parameters',
+ 'cursor sharing' => array('CURSOR',
+ "select value from v\$parameter where name = 'cursor_sharing'",
+ 'Cursor reuse strategy. Recommended is FORCE (8i+) or SIMILAR (9i+). See <a href=http://www.praetoriate.com/oracle_tips_cursor_sharing.htm>cursor_sharing</a>.'),
+ /*
+ 'cursor reuse' => array('CURSOR',
+ "select count(*) from (select sql_text_wo_constants, count(*)
+ from t1
+ group by sql_text_wo_constants
+having count(*) > 100)",'These are sql statements that should be using bind variables'),*/
+ 'index cache cost' => array('COST',
+ "select value from v\$parameter where name = 'optimizer_index_caching'",
+ '=WarnIndexCost'),
+ 'random page cost' => array('COST',
+ "select value from v\$parameter where name = 'optimizer_index_cost_adj'",
+ '=WarnPageCost'),
+
+ false
+
+ );
+
+
+ function perf_oci8(&$conn)
+ {
+ $savelog = $conn->LogSQL(false);
+ $this->version = $conn->ServerInfo();
+ $conn->LogSQL($savelog);
+ $this->conn =& $conn;
+ }
+
+ function WarnPageCost($val)
+ {
+ if ($val == 100) $s = '<font color=red><b>Too High</b>. </font>';
+ else $s = '';
+
+ return $s.'Recommended is 20-50 for TP, and 50 for data warehouses. Default is 100. See <a href=http://www.dba-oracle.com/oracle_tips_cost_adj.htm>optimizer_index_cost_adj</a>. ';
+ }
+
+ function WarnIndexCost($val)
+ {
+ if ($val == 0) $s = '<font color=red><b>Too Low</b>. </font>';
+ else $s = '';
+
+ return $s.'Percentage of indexed data blocks expected in the cache.
+ Recommended is 20 (fast disk array) to 50 (slower hard disks). Default is 0.
+ See <a href=http://www.dba-oracle.com/oracle_tips_cbo_part1.htm>optimizer_index_caching</a>.';
+ }
+
+ function PGA()
+ {
+ if ($this->version['version'] < 9) return 'Oracle 9i or later required';
+
+ $rs = $this->conn->Execute("select a.mb,a.targ as pga_size_pct,a.pct from
+ (select round(pga_target_for_estimate/1024.0/1024.0,0) Mb,
+ pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r
+ from v\$pga_target_advice) a left join
+ (select round(pga_target_for_estimate/1024.0/1024.0,0) Mb,
+ pga_target_factor targ,estd_pga_cache_hit_percentage pct,rownum as r
+ from v\$pga_target_advice) b on
+ a.r = b.r+1 where
+ b.pct < 100");
+ if (!$rs) return "Only in 9i or later";
+ $rs->Close();
+ if ($rs->EOF) return "PGA could be too big";
+
+ return reset($rs->fields);
+ }
+
+ function Explain($sql,$partial=false)
+ {
+ $savelog = $this->conn->LogSQL(false);
+ $rs =& $this->conn->SelectLimit("select ID FROM PLAN_TABLE");
+ if (!$rs) {
+ echo "<p><b>Missing PLAN_TABLE</b></p>
+<pre>
+CREATE TABLE PLAN_TABLE (
+ STATEMENT_ID VARCHAR2(30),
+ TIMESTAMP DATE,
+ REMARKS VARCHAR2(80),
+ OPERATION VARCHAR2(30),
+ OPTIONS VARCHAR2(30),
+ OBJECT_NODE VARCHAR2(128),
+ OBJECT_OWNER VARCHAR2(30),
+ OBJECT_NAME VARCHAR2(30),
+ OBJECT_INSTANCE NUMBER(38),
+ OBJECT_TYPE VARCHAR2(30),
+ OPTIMIZER VARCHAR2(255),
+ SEARCH_COLUMNS NUMBER,
+ ID NUMBER(38),
+ PARENT_ID NUMBER(38),
+ POSITION NUMBER(38),
+ COST NUMBER(38),
+ CARDINALITY NUMBER(38),
+ BYTES NUMBER(38),
+ OTHER_TAG VARCHAR2(255),
+ PARTITION_START VARCHAR2(255),
+ PARTITION_STOP VARCHAR2(255),
+ PARTITION_ID NUMBER(38),
+ OTHER LONG,
+ DISTRIBUTION VARCHAR2(30)
+);
+</pre>";
+ return false;
+ }
+
+ $rs->Close();
+ // $this->conn->debug=1;
+
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like $sqlq");
+ if ($arr) {
+ foreach($arr as $row) {
+ $sql = reset($row);
+ if (crc32($sql) == $partial) break;
+ }
+ }
+ }
+
+ $s = "<p><b>Explain</b>: ".htmlspecialchars($sql)."</p>";
+
+ $this->conn->BeginTrans();
+ $id = "ADODB ".microtime();
+
+ $rs =& $this->conn->Execute("EXPLAIN PLAN SET STATEMENT_ID='$id' FOR $sql");
+ $m = $this->conn->ErrorMsg();
+ if ($m) {
+ $this->conn->RollbackTrans();
+ $this->conn->LogSQL($savelog);
+ $s .= "<p>$m</p>";
+ return $s;
+ }
+ $rs =& $this->conn->Execute("
+ select
+ '<pre>'||lpad('--', (level-1)*2,'-') || trim(operation) || ' ' || trim(options)||'</pre>' as Operation,
+ object_name,COST,CARDINALITY,bytes
+ FROM plan_table
+START WITH id = 0 and STATEMENT_ID='$id'
+CONNECT BY prior id=parent_id and statement_id='$id'");
+
+ $s .= rs2html($rs,false,false,false,false);
+ $this->conn->RollbackTrans();
+ $this->conn->LogSQL($savelog);
+ $s .= $this->Tracer($sql,$partial);
+ return $s;
+ }
+
+
+ function CheckMemory()
+ {
+ if ($this->version['version'] < 9) return 'Oracle 9i or later required';
+
+ $rs =& $this->conn->Execute("
+select a.size_for_estimate as cache_mb_estimate,
+ case when a.size_factor=1 then
+ '&lt;&lt;= current'
+ when a.estd_physical_read_factor-b.estd_physical_read_factor > 0 and a.estd_physical_read_factor<1 then
+ '- BETTER - '
+ else ' ' end as currsize,
+ a.estd_physical_read_factor-b.estd_physical_read_factor as best_when_0
+ from (select size_for_estimate,size_factor,estd_physical_read_factor,rownum r from v\$db_cache_advice) a ,
+ (select size_for_estimate,size_factor,estd_physical_read_factor,rownum r from v\$db_cache_advice) b where a.r = b.r-1");
+ if (!$rs) return false;
+
+ /*
+ The v$db_cache_advice utility show the marginal changes in physical data block reads for different sizes of db_cache_size
+ */
+ $s = "<h3>Data Cache Estimate</h3>";
+ if ($rs->EOF) {
+ $s .= "<p>Cache that is 50% of current size is still too big</p>";
+ } else {
+ $s .= "Ideal size of Data Cache is when \"best_when_0\" changes from a positive number and becomes zero.";
+ $s .= rs2html($rs,false,false,false,false);
+ }
+ return $s;
+ }
+
+ /*
+ Generate html for suspicious/expensive sql
+ */
+ function tohtml(&$rs,$type)
+ {
+ $o1 = $rs->FetchField(0);
+ $o2 = $rs->FetchField(1);
+ $o3 = $rs->FetchField(2);
+ if ($rs->EOF) return '<p>None found</p>';
+ $check = '';
+ $sql = '';
+ $s = "\n\n<table border=1 bgcolor=white><tr><td><b>".$o1->name.'</b></td><td><b>'.$o2->name.'</b></td><td><b>'.$o3->name.'</b></td></tr>';
+ while (!$rs->EOF) {
+ if ($check != $rs->fields[0].'::'.$rs->fields[1]) {
+ if ($check) {
+ $carr = explode('::',$check);
+ $prefix = "<a href=\"?$type=1&sql=".rawurlencode($sql).'&x#explain">';
+ $suffix = '</a>';
+ if (strlen($prefix)>2000) {
+ $prefix = '';
+ $suffix = '';
+ }
+
+ $s .= "\n<tr><td align=right>".$carr[0].'</td><td align=right>'.$carr[1].'</td><td>'.$prefix.$sql.$suffix.'</td></tr>';
+ }
+ $sql = $rs->fields[2];
+ $check = $rs->fields[0].'::'.$rs->fields[1];
+ } else
+ $sql .= $rs->fields[2];
+ if (substr($sql,strlen($sql)-1) == "\0") $sql = substr($sql,0,strlen($sql)-1);
+ $rs->MoveNext();
+ }
+ $rs->Close();
+
+ $carr = explode('::',$check);
+ $prefix = "<a target=".rand()." href=\"?&hidem=1&$type=1&sql=".rawurlencode($sql).'&x#explain">';
+ $suffix = '</a>';
+ if (strlen($prefix)>2000) {
+ $prefix = '';
+ $suffix = '';
+ }
+ $s .= "\n<tr><td align=right>".$carr[0].'</td><td align=right>'.$carr[1].'</td><td>'.$prefix.$sql.$suffix.'</td></tr>';
+
+ return $s."</table>\n\n";
+ }
+
+ // code thanks to Ixora.
+ // http://www.ixora.com.au/scripts/query_opt.htm
+ // requires oracle 8.1.7 or later
+ function SuspiciousSQL($numsql=10)
+ {
+ $sql = "
+select
+ substr(to_char(s.pct, '99.00'), 2) || '%' load,
+ s.executions executes,
+ p.sql_text
+from
+ (
+ select
+ address,
+ buffer_gets,
+ executions,
+ pct,
+ rank() over (order by buffer_gets desc) ranking
+ from
+ (
+ select
+ address,
+ buffer_gets,
+ executions,
+ 100 * ratio_to_report(buffer_gets) over () pct
+ from
+ sys.v_\$sql
+ where
+ command_type != 47 and module != 'T.O.A.D.'
+ )
+ where
+ buffer_gets > 50 * executions
+ ) s,
+ sys.v_\$sqltext p
+where
+ s.ranking <= $numsql and
+ p.address = s.address
+order by
+ 1 desc, s.address, p.piece";
+
+ global $ADODB_CACHE_MODE;
+ if (isset($_GET['expsixora']) && isset($_GET['sql'])) {
+ $partial = empty($_GET['part']);
+ echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
+ }
+
+ if (isset($_GET['sql'])) return $this->_SuspiciousSQL($numsql);
+
+ $s = '';
+ $s .= $this->_SuspiciousSQL($numsql);
+ $s .= '<p>';
+
+ $save = $ADODB_CACHE_MODE;
+ $ADODB_CACHE_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $savelog = $this->conn->LogSQL(false);
+ $rs =& $this->conn->SelectLimit($sql);
+ $this->conn->LogSQL($savelog);
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_CACHE_MODE = $save;
+ if ($rs) {
+ $s .= "\n<h3>Ixora Suspicious SQL</h3>";
+ $s .= $this->tohtml($rs,'expsixora');
+ }
+
+ return $s;
+ }
+
+ // code thanks to Ixora.
+ // http://www.ixora.com.au/scripts/query_opt.htm
+ // requires oracle 8.1.7 or later
+ function ExpensiveSQL($numsql = 10)
+ {
+ $sql = "
+select
+ substr(to_char(s.pct, '99.00'), 2) || '%' load,
+ s.executions executes,
+ p.sql_text
+from
+ (
+ select
+ address,
+ disk_reads,
+ executions,
+ pct,
+ rank() over (order by disk_reads desc) ranking
+ from
+ (
+ select
+ address,
+ disk_reads,
+ executions,
+ 100 * ratio_to_report(disk_reads) over () pct
+ from
+ sys.v_\$sql
+ where
+ command_type != 47 and module != 'T.O.A.D.'
+ )
+ where
+ disk_reads > 50 * executions
+ ) s,
+ sys.v_\$sqltext p
+where
+ s.ranking <= $numsql and
+ p.address = s.address
+order by
+ 1 desc, s.address, p.piece
+";
+ global $ADODB_CACHE_MODE;
+ if (isset($_GET['expeixora']) && isset($_GET['sql'])) {
+ $partial = empty($_GET['part']);
+ echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n";
+ }
+ if (isset($_GET['sql'])) {
+ $var = $this->_ExpensiveSQL($numsql);
+ return $var;
+ }
+
+ $s = '';
+ $s .= $this->_ExpensiveSQL($numsql);
+ $s .= '<p>';
+ $save = $ADODB_CACHE_MODE;
+ $ADODB_CACHE_MODE = ADODB_FETCH_NUM;
+ if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false);
+
+ $savelog = $this->conn->LogSQL(false);
+ $rs =& $this->conn->Execute($sql);
+ $this->conn->LogSQL($savelog);
+
+ if (isset($savem)) $this->conn->SetFetchMode($savem);
+ $ADODB_CACHE_MODE = $save;
+
+ if ($rs) {
+ $s .= "\n<h3>Ixora Expensive SQL</h3>";
+ $s .= $this->tohtml($rs,'expeixora');
+ }
+
+ return $s;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/perf/perf-postgres.inc.php b/html/phpgacl/adodb/perf/perf-postgres.inc.php
new file mode 100644
index 0000000..a27c224
--- /dev/null
+++ b/html/phpgacl/adodb/perf/perf-postgres.inc.php
@@ -0,0 +1,124 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence. See License.txt.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+
+ Library for basic performance monitoring and tuning
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_DIR')) die();
+
+/*
+ Notice that PostgreSQL has no sql query cache
+*/
+class perf_postgres extends adodb_perf{
+
+ var $tablesSQL =
+ "select a.relname as tablename,(a.relpages+CASE WHEN b.relpages is null THEN 0 ELSE b.relpages END+CASE WHEN c.relpages is null THEN 0 ELSE c.relpages END)*8 as size_in_K,a.relfilenode as \"OID\" from pg_class a left join pg_class b
+ on b.relname = 'pg_toast_'||trim(a.relfilenode)
+ left join pg_class c on c.relname = 'pg_toast_'||trim(a.relfilenode)||'_index'
+ where a.relname in (select tablename from pg_tables where tablename not like 'pg_%')";
+
+ var $createTableSQL = "CREATE TABLE adodb_logsql (
+ created timestamp NOT NULL,
+ sql0 varchar(250) NOT NULL,
+ sql1 text NOT NULL,
+ params text NOT NULL,
+ tracer text NOT NULL,
+ timer decimal(16,6) NOT NULL
+ )";
+
+ var $settings = array(
+ 'Ratios',
+ 'statistics collector' => array('RATIO',
+ "select case when count(*)=3 then 'TRUE' else 'FALSE' end from pg_settings where (name='stats_block_level' or name='stats_row_level' or name='stats_start_collector') and setting='on' ",
+ 'Value must be TRUE to enable hit ratio statistics (<i>stats_start_collector</i>,<i>stats_row_level</i> and <i>stats_block_level</i> must be set to true in postgresql.conf)'),
+ 'data cache hit ratio' => array('RATIO',
+ "select case when blks_hit=0 then 0 else round( ((1-blks_read::float/blks_hit)*100)::numeric, 2) end from pg_stat_database where datname='\$DATABASE'",
+ '=WarnCacheRatio'),
+ 'IO',
+ 'data reads' => array('IO',
+ 'select sum(heap_blks_read+toast_blks_read) from pg_statio_user_tables',
+ ),
+ 'data writes' => array('IO',
+ 'select round((sum(n_tup_ins/4.0+n_tup_upd/8.0+n_tup_del/4.0)/16)::numeric,2) from pg_stat_user_tables',
+ 'Count of inserts/updates/deletes * coef'),
+
+ 'Data Cache',
+ 'data cache buffers' => array('DATAC',
+ "select setting from pg_settings where name='shared_buffers'",
+ 'Number of cache buffers. <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#basic>Tuning</a>'),
+ 'cache blocksize' => array('DATAC',
+ 'select 8192',
+ '(estimate)' ),
+ 'data cache size' => array( 'DATAC',
+ "select setting::integer*8192 from pg_settings where name='shared_buffers'",
+ '' ),
+ 'operating system cache size' => array( 'DATA',
+ "select setting::integer*8192 from pg_settings where name='effective_cache_size'",
+ '(effective cache size)' ),
+ 'Memory Usage',
+ # Postgres 7.5 changelog: Rename server parameters SortMem and VacuumMem to work_mem and maintenance_work_mem;
+ 'sort/work buffer size' => array('CACHE',
+ "select setting::integer*1024 from pg_settings where name='sort_mem' or name = 'work_mem' order by name",
+ 'Size of sort buffer (per query)' ),
+ 'Connections',
+ 'current connections' => array('SESS',
+ 'select count(*) from pg_stat_activity',
+ ''),
+ 'max connections' => array('SESS',
+ "select setting from pg_settings where name='max_connections'",
+ ''),
+ 'Parameters',
+ 'rollback buffers' => array('COST',
+ "select setting from pg_settings where name='wal_buffers'",
+ 'WAL buffers'),
+ 'random page cost' => array('COST',
+ "select setting from pg_settings where name='random_page_cost'",
+ 'Cost of doing a seek (default=4). See <a href=http://www.varlena.com/GeneralBits/Tidbits/perf.html#less>random_page_cost</a>'),
+ false
+ );
+
+ function perf_postgres(&$conn)
+ {
+ $this->conn =& $conn;
+ }
+
+ function Explain($sql,$partial=false)
+ {
+ $save = $this->conn->LogSQL(false);
+
+ if ($partial) {
+ $sqlq = $this->conn->qstr($sql.'%');
+ $arr = $this->conn->GetArray("select distinct distinct sql1 from adodb_logsql where sql1 like $sqlq");
+ if ($arr) {
+ foreach($arr as $row) {
+ $sql = reset($row);
+ if (crc32($sql) == $partial) break;
+ }
+ }
+ }
+ $sql = str_replace('?',"''",$sql);
+ $s = '<p><b>Explain</b>: '.htmlspecialchars($sql).'</p>';
+ $rs = $this->conn->Execute('EXPLAIN '.$sql);
+ $this->conn->LogSQL($save);
+ $s .= '<pre>';
+ if ($rs)
+ while (!$rs->EOF) {
+ $s .= reset($rs->fields)."\n";
+ $rs->MoveNext();
+ }
+ $s .= '</pre>';
+ $s .= $this->Tracer($sql,$partial);
+ return $s;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/pivottable.inc.php b/html/phpgacl/adodb/pivottable.inc.php
new file mode 100644
index 0000000..48788e6
--- /dev/null
+++ b/html/phpgacl/adodb/pivottable.inc.php
@@ -0,0 +1,185 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Requires PHP4.01pl2 or later because it uses include_once
+*/
+
+/*
+ * Concept from daniel.lucazeau@ajornet.com.
+ *
+ * @param db Adodb database connection
+ * @param tables List of tables to join
+ * @rowfields List of fields to display on each row
+ * @colfield Pivot field to slice and display in columns, if we want to calculate
+ * ranges, we pass in an array (see example2)
+ * @where Where clause. Optional.
+ * @aggfield This is the field to sum. Optional.
+ * Since 2.3.1, if you can use your own aggregate function
+ * instead of SUM, eg. $sumfield = 'AVG(fieldname)';
+ * @sumlabel Prefix to display in sum columns. Optional.
+ * @aggfn Aggregate function to use (could be AVG, SUM, COUNT)
+ * @showcount Show count of records
+ *
+ * @returns Sql generated
+ */
+
+ function PivotTableSQL($db,$tables,$rowfields,$colfield, $where=false,
+ $aggfield = false,$sumlabel='Sum ',$aggfn ='SUM', $showcount = true)
+ {
+ if ($aggfield) $hidecnt = true;
+ else $hidecnt = false;
+
+ $iif = strpos($db->databaseType,'access') !== false;
+ // note - vfp still doesn' work even with IIF enabled || $db->databaseType == 'vfp';
+
+ //$hidecnt = false;
+
+ if ($where) $where = "\nWHERE $where";
+ if (!is_array($colfield)) $colarr = $db->GetCol("select distinct $colfield from $tables $where order by 1");
+ if (!$aggfield) $hidecnt = false;
+
+ $sel = "$rowfields, ";
+ if (is_array($colfield)) {
+ foreach ($colfield as $k => $v) {
+ $k = trim($k);
+ if (!$hidecnt) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($v,1,0)) AS \"$k\", "
+ :
+ "\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", ";
+ }
+ if ($aggfield) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($v,$aggfield,0)) AS \"$sumlabel$k\", "
+ :
+ "\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", ";
+ }
+ }
+ } else {
+ foreach ($colarr as $v) {
+ if (!is_numeric($v)) $vq = $db->qstr($v);
+ else $vq = $v;
+ $v = trim($v);
+ if (strlen($v) == 0 ) $v = 'null';
+ if (!$hidecnt) {
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($colfield=$vq,1,0)) AS \"$v\", "
+ :
+ "\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", ";
+ }
+ if ($aggfield) {
+ if ($hidecnt) $label = $v;
+ else $label = "{$v}_$aggfield";
+ $sel .= $iif ?
+ "\n\t$aggfn(IIF($colfield=$vq,$aggfield,0)) AS \"$label\", "
+ :
+ "\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", ";
+ }
+ }
+ }
+ if ($aggfield && $aggfield != '1'){
+ $agg = "$aggfn($aggfield)";
+ $sel .= "\n\t$agg as \"$sumlabel$aggfield\", ";
+ }
+
+ if ($showcount)
+ $sel .= "\n\tSUM(1) as Total";
+ else
+ $sel = substr($sel,0,strlen($sel)-2);
+
+ $sql = "SELECT $sel \nFROM $tables $where \nGROUP BY $rowfields";
+ return $sql;
+ }
+
+/* EXAMPLES USING MS NORTHWIND DATABASE */
+if (0) {
+
+# example1
+#
+# Query the main "product" table
+# Set the rows to CompanyName and QuantityPerUnit
+# and the columns to the Categories
+# and define the joins to link to lookup tables
+# "categories" and "suppliers"
+#
+
+ $sql = PivotTableSQL(
+ $gDB, # adodb connection
+ 'products p ,categories c ,suppliers s', # tables
+ 'CompanyName,QuantityPerUnit', # row fields
+ 'CategoryName', # column fields
+ 'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where
+);
+ print "<pre>$sql";
+ $rs = $gDB->Execute($sql);
+ rs2html($rs);
+
+/*
+Generated SQL:
+
+SELECT CompanyName,QuantityPerUnit,
+ SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages",
+ SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments",
+ SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections",
+ SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy Products",
+ SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals",
+ SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry",
+ SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce",
+ SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood",
+ SUM(1) as Total
+FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
+GROUP BY CompanyName,QuantityPerUnit
+*/
+//=====================================================================
+
+# example2
+#
+# Query the main "product" table
+# Set the rows to CompanyName and QuantityPerUnit
+# and the columns to the UnitsInStock for diiferent ranges
+# and define the joins to link to lookup tables
+# "categories" and "suppliers"
+#
+ $sql = PivotTableSQL(
+ $gDB, # adodb connection
+ 'products p ,categories c ,suppliers s', # tables
+ 'CompanyName,QuantityPerUnit', # row fields
+ # column ranges
+array(
+' 0 ' => 'UnitsInStock <= 0',
+"1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5',
+"6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10',
+"11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15',
+"16+" =>'15 < UnitsInStock'
+),
+ ' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
+ 'UnitsInStock', # sum this field
+ 'Sum' # sum label prefix
+);
+ print "<pre>$sql";
+ $rs = $gDB->Execute($sql);
+ rs2html($rs);
+ /*
+ Generated SQL:
+
+SELECT CompanyName,QuantityPerUnit,
+ SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum 0 ",
+ SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ELSE 0 END) AS "Sum 1 to 5",
+ SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ELSE 0 END) AS "Sum 6 to 10",
+ SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ELSE 0 END) AS "Sum 11 to 15",
+ SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum 16+",
+ SUM(UnitsInStock) AS "Sum UnitsInStock",
+ SUM(1) as Total
+FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
+GROUP BY CompanyName,QuantityPerUnit
+ */
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/readme.txt b/html/phpgacl/adodb/readme.txt
new file mode 100644
index 0000000..97bdd9e
--- /dev/null
+++ b/html/phpgacl/adodb/readme.txt
@@ -0,0 +1,62 @@
+>> ADODB Library for PHP4
+
+(c) 2000-2004 John Lim (jlim@natsoft.com.my)
+
+Released under both BSD and GNU Lesser GPL library license.
+This means you can use it in proprietary products.
+
+
+>> Introduction
+
+PHP's database access functions are not standardised. This creates a
+need for a database class library to hide the differences between the
+different databases (encapsulate the differences) so we can easily
+switch databases.
+
+We currently support MySQL, Interbase, Sybase, PostgreSQL, Oracle,
+Microsoft SQL server, Foxpro ODBC, Access ODBC, Informix, DB2,
+Sybase SQL Anywhere, generic ODBC and Microsoft's ADO.
+
+We hope more people will contribute drivers to support other databases.
+
+
+>> Documentation and Examples
+
+Refer to the adodb/docs directory for full documentation and examples.
+There is also a tutorial tute.htm that contrasts ADODB code with
+mysql code.
+
+
+>>> Files
+Adodb.inc.php is the main file. You need to include only this file.
+
+Adodb-*.inc.php are the database specific driver code.
+
+Test.php contains a list of test commands to exercise the class library.
+
+Adodb-session.php is the PHP4 session handling code.
+
+Testdatabases.inc.php contains the list of databases to apply the tests on.
+
+Benchmark.php is a simple benchmark to test the throughput of a simple SELECT
+statement for databases described in testdatabases.inc.php. The benchmark
+tables are created in test.php.
+
+readme.htm is the main documentation.
+
+tute.htm is the tutorial.
+
+
+>> More Info
+
+For more information, including installation see readme.htm
+or visit
+ http://adodb.sourceforge.net/
+
+
+>> Feature Requests and Bug Reports
+
+Email to jlim@natsoft.com.my
+
+
+ \ No newline at end of file
diff --git a/html/phpgacl/adodb/rsfilter.inc.php b/html/phpgacl/adodb/rsfilter.inc.php
new file mode 100644
index 0000000..9d20a53
--- /dev/null
+++ b/html/phpgacl/adodb/rsfilter.inc.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Requires PHP4.01pl2 or later because it uses include_once
+*/
+
+/*
+ Filter all fields and all rows in a recordset and returns the
+ processed recordset. We scroll to the beginning of the new recordset
+ after processing.
+
+ We pass a recordset and function name to RSFilter($rs,'rowfunc');
+ and the function will be called multiple times, once
+ for each row in the recordset. The function will be passed
+ an array containing one row repeatedly.
+
+ Example:
+
+ // ucwords() every element in the recordset
+ function do_ucwords(&$arr,$rs)
+ {
+ foreach($arr as $k => $v) {
+ $arr[$k] = ucwords($v);
+ }
+ }
+ $rs = RSFilter($rs,'do_ucwords');
+ */
+function &RSFilter($rs,$fn)
+{
+ if ($rs->databaseType != 'array') {
+ if (!$rs->connection) return false;
+
+ $rs = &$rs->connection->_rs2rs($rs);
+ }
+ $rows = $rs->RecordCount();
+ for ($i=0; $i < $rows; $i++) {
+ if (is_array ($fn)) {
+ $obj = $fn[0];
+ $method = $fn[1];
+ $obj->$method ($rs->_array[$i],$rs);
+ } else {
+ $fn($rs->_array[$i],$rs);
+ }
+
+ }
+ if (!$rs->EOF) {
+ $rs->_currentRow = 0;
+ $rs->fields = $rs->_array[0];
+ }
+
+ return $rs;
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/server.php b/html/phpgacl/adodb/server.php
new file mode 100644
index 0000000..dbec033
--- /dev/null
+++ b/html/phpgacl/adodb/server.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ */
+
+/* Documentation on usage is at http://php.weblogs.com/adodb_csv
+ *
+ * Legal query string parameters:
+ *
+ * sql = holds sql string
+ * nrows = number of rows to return
+ * offset = skip offset rows of data
+ * fetch = $ADODB_FETCH_MODE
+ *
+ * example:
+ *
+ * http://localhost/php/server.php?select+*+from+table&nrows=10&offset=2
+ */
+
+
+/*
+ * Define the IP address you want to accept requests from
+ * as a security measure. If blank we accept anyone promisciously!
+ */
+$ACCEPTIP = '';
+
+/*
+ * Connection parameters
+ */
+$driver = 'mysql';
+$host = 'localhost'; // DSN for odbc
+$uid = 'root';
+$pwd = '';
+$database = 'test';
+
+/*============================ DO NOT MODIFY BELOW HERE =================================*/
+// $sep must match csv2rs() in adodb.inc.php
+$sep = ' :::: ';
+
+include('./adodb.inc.php');
+include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+
+function err($s)
+{
+ die('**** '.$s.' ');
+}
+
+// undo stupid magic quotes
+function undomq(&$m)
+{
+ if (get_magic_quotes_gpc()) {
+ // undo the damage
+ $m = str_replace('\\\\','\\',$m);
+ $m = str_replace('\"','"',$m);
+ $m = str_replace('\\\'','\'',$m);
+
+ }
+ return $m;
+}
+
+///////////////////////////////////////// DEFINITIONS
+
+
+$remote = $_SERVER["REMOTE_ADDR"];
+
+if (empty($_GET['sql'])) err('No SQL');
+
+if (!empty($ACCEPTIP))
+ if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
+ err("Unauthorised client: '$remote'");
+
+
+$conn = &ADONewConnection($driver);
+
+if (!$conn->Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
+$sql = undomq($_GET['sql']);
+
+if (isset($_GET['fetch']))
+ $ADODB_FETCH_MODE = $_GET['fetch'];
+
+if (isset($_GET['nrows'])) {
+ $nrows = $_GET['nrows'];
+ $offset = isset($_GET['offset']) ? $_GET['offset'] : -1;
+ $rs = $conn->SelectLimit($sql,$nrows,$offset);
+} else
+ $rs = $conn->Execute($sql);
+if ($rs){
+ //$rs->timeToLive = 1;
+ echo _rs2serialize($rs,$conn,$sql);
+ $rs->Close();
+} else
+ err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/session/adodb-compress-bzip2.php b/html/phpgacl/adodb/session/adodb-compress-bzip2.php
new file mode 100644
index 0000000..2f4b83c
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-compress-bzip2.php
@@ -0,0 +1,118 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+*/
+
+if (!function_exists('bzcompress')) {
+ trigger_error('bzip2 functions are not available', E_USER_ERROR);
+ return 0;
+}
+
+/*
+*/
+class ADODB_Compress_Bzip2 {
+ /**
+ */
+ var $_block_size = null;
+
+ /**
+ */
+ var $_work_level = null;
+
+ /**
+ */
+ var $_min_length = 1;
+
+ /**
+ */
+ function getBlockSize() {
+ return $this->_block_size;
+ }
+
+ /**
+ */
+ function setBlockSize($block_size) {
+ assert('$block_size >= 1');
+ assert('$block_size <= 9');
+ $this->_block_size = (int) $block_size;
+ }
+
+ /**
+ */
+ function getWorkLevel() {
+ return $this->_work_level;
+ }
+
+ /**
+ */
+ function setWorkLevel($work_level) {
+ assert('$work_level >= 0');
+ assert('$work_level <= 250');
+ $this->_work_level = (int) $work_level;
+ }
+
+ /**
+ */
+ function getMinLength() {
+ return $this->_min_length;
+ }
+
+ /**
+ */
+ function setMinLength($min_length) {
+ assert('$min_length >= 0');
+ $this->_min_length = (int) $min_length;
+ }
+
+ /**
+ */
+ function ADODB_Compress_Bzip2($block_size = null, $work_level = null, $min_length = null) {
+ if (!is_null($block_size)) {
+ $this->setBlockSize($block_size);
+ }
+
+ if (!is_null($work_level)) {
+ $this->setWorkLevel($work_level);
+ }
+
+ if (!is_null($min_length)) {
+ $this->setMinLength($min_length);
+ }
+ }
+
+ /**
+ */
+ function write($data, $key) {
+ if (strlen($data) < $this->_min_length) {
+ return $data;
+ }
+
+ if (!is_null($this->_block_size)) {
+ if (!is_null($this->_work_level)) {
+ return bzcompress($data, $this->_block_size, $this->_work_level);
+ } else {
+ return bzcompress($data, $this->_block_size);
+ }
+ }
+
+ return bzcompress($data);
+ }
+
+ /**
+ */
+ function read($data, $key) {
+ return $data ? bzdecompress($data) : $data;
+ }
+
+}
+
+return 1;
+
+?>
diff --git a/html/phpgacl/adodb/session/adodb-compress-gzip.php b/html/phpgacl/adodb/session/adodb-compress-gzip.php
new file mode 100644
index 0000000..ad84add
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-compress-gzip.php
@@ -0,0 +1,93 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+*/
+
+if (!function_exists('gzcompress')) {
+ trigger_error('gzip functions are not available', E_USER_ERROR);
+ return 0;
+}
+
+/*
+*/
+class ADODB_Compress_Gzip {
+ /**
+ */
+ var $_level = null;
+
+ /**
+ */
+ var $_min_length = 1;
+
+ /**
+ */
+ function getLevel() {
+ return $this->_level;
+ }
+
+ /**
+ */
+ function setLevel($level) {
+ assert('$level >= 0');
+ assert('$level <= 9');
+ $this->_level = (int) $level;
+ }
+
+ /**
+ */
+ function getMinLength() {
+ return $this->_min_length;
+ }
+
+ /**
+ */
+ function setMinLength($min_length) {
+ assert('$min_length >= 0');
+ $this->_min_length = (int) $min_length;
+ }
+
+ /**
+ */
+ function ADODB_Compress_Gzip($level = null, $min_length = null) {
+ if (!is_null($level)) {
+ $this->setLevel($level);
+ }
+
+ if (!is_null($min_length)) {
+ $this->setMinLength($min_length);
+ }
+ }
+
+ /**
+ */
+ function write($data, $key) {
+ if (strlen($data) < $this->_min_length) {
+ return $data;
+ }
+
+ if (!is_null($this->_level)) {
+ return gzcompress($data, $this->_level);
+ } else {
+ return gzcompress($data);
+ }
+ }
+
+ /**
+ */
+ function read($data, $key) {
+ return $data ? gzuncompress($data) : $data;
+ }
+
+}
+
+return 1;
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/session/adodb-cryptsession.php b/html/phpgacl/adodb/session/adodb-cryptsession.php
new file mode 100644
index 0000000..0138fde
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-cryptsession.php
@@ -0,0 +1,24 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+*/
+
+/*
+
+This file is provided for backwards compatibility purposes
+
+*/
+
+require_once dirname(__FILE__) . '/adodb-session.php';
+require_once ADODB_SESSION . '/adodb-encrypt-md5.php';
+
+ADODB_Session::filter(new ADODB_Encrypt_MD5());
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/session/adodb-encrypt-mcrypt.php b/html/phpgacl/adodb/session/adodb-encrypt-mcrypt.php
new file mode 100644
index 0000000..113618c
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-encrypt-mcrypt.php
@@ -0,0 +1,109 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+*/
+
+if (!function_exists('mcrypt_encrypt')) {
+ trigger_error('Mcrypt functions are not available', E_USER_ERROR);
+ return 0;
+}
+
+/**
+ */
+class ADODB_Encrypt_MCrypt {
+ /**
+ */
+ var $_cipher;
+
+ /**
+ */
+ var $_mode;
+
+ /**
+ */
+ var $_source;
+
+ /**
+ */
+ function getCipher() {
+ return $this->_cipher;
+ }
+
+ /**
+ */
+ function setCipher($cipher) {
+ $this->_cipher = $cipher;
+ }
+
+ /**
+ */
+ function getMode() {
+ return $this->_mode;
+ }
+
+ /**
+ */
+ function setMode($mode) {
+ $this->_mode = $mode;
+ }
+
+ /**
+ */
+ function getSource() {
+ return $this->_source;
+ }
+
+ /**
+ */
+ function setSource($source) {
+ $this->_source = $source;
+ }
+
+ /**
+ */
+ function ADODB_Encrypt_MCrypt($cipher = null, $mode = null, $source = null) {
+ if (!$cipher) {
+ $cipher = MCRYPT_RIJNDAEL_256;
+ }
+ if (!$mode) {
+ $mode = MCRYPT_MODE_ECB;
+ }
+ if (!$source) {
+ $source = MCRYPT_RAND;
+ }
+
+ $this->_cipher = $cipher;
+ $this->_mode = $mode;
+ $this->_source = $source;
+ }
+
+ /**
+ */
+ function write($data, $key) {
+ $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
+ $iv = mcrypt_create_iv($iv_size, $this->_source);
+ return mcrypt_encrypt($this->_cipher, $key, $data, $this->_mode, $iv);
+ }
+
+ /**
+ */
+ function read($data, $key) {
+ $iv_size = mcrypt_get_iv_size($this->_cipher, $this->_mode);
+ $iv = mcrypt_create_iv($iv_size, $this->_source);
+ $rv = mcrypt_decrypt($this->_cipher, $key, $data, $this->_mode, $iv);
+ return rtrim($rv, "\0");
+ }
+
+}
+
+return 1;
+
+?>
diff --git a/html/phpgacl/adodb/session/adodb-encrypt-md5.php b/html/phpgacl/adodb/session/adodb-encrypt-md5.php
new file mode 100644
index 0000000..4a5a215
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-encrypt-md5.php
@@ -0,0 +1,39 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+*/
+
+// security - hide paths
+if (!defined('ADODB_SESSION')) die();
+
+include_once ADODB_SESSION . '/crypt.inc.php';
+
+/**
+ */
+class ADODB_Encrypt_MD5 {
+ /**
+ */
+ function write($data, $key) {
+ $md5crypt =& new MD5Crypt();
+ return $md5crypt->encrypt($data, $key);
+ }
+
+ /**
+ */
+ function read($data, $key) {
+ $md5crypt =& new MD5Crypt();
+ return $md5crypt->decrypt($data, $key);
+ }
+
+}
+
+return 1;
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/session/adodb-encrypt-secret.php b/html/phpgacl/adodb/session/adodb-encrypt-secret.php
new file mode 100644
index 0000000..eeb5c96
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-encrypt-secret.php
@@ -0,0 +1,48 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+*/
+
+@define('HORDE_BASE', dirname(dirname(dirname(__FILE__))) . '/horde');
+
+if (!is_dir(HORDE_BASE)) {
+ trigger_error(sprintf('Directory not found: \'%s\'', HORDE_BASE), E_USER_ERROR);
+ return 0;
+}
+
+include_once HORDE_BASE . '/lib/Horde.php';
+include_once HORDE_BASE . '/lib/Secret.php';
+
+/**
+
+NOTE: On Windows 2000 SP4 with PHP 4.3.1, MCrypt 2.4.x, and Apache 1.3.28,
+the session didn't work properly.
+
+This may be resolved with 4.3.3.
+
+ */
+class ADODB_Encrypt_Secret {
+ /**
+ */
+ function write($data, $key) {
+ return Secret::write($key, $data);
+ }
+
+ /**
+ */
+ function read($data, $key) {
+ return Secret::read($key, $data);
+ }
+
+}
+
+return 1;
+
+?>
diff --git a/html/phpgacl/adodb/session/adodb-sess.txt b/html/phpgacl/adodb/session/adodb-sess.txt
new file mode 100644
index 0000000..d23dac4
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-sess.txt
@@ -0,0 +1,131 @@
+John,
+
+I have been an extremely satisfied ADODB user for several years now.
+
+To give you something back for all your hard work, I've spent the last 3
+days rewriting the adodb-session.php code.
+
+----------
+What's New
+----------
+
+Here's a list of the new code's benefits:
+
+* Combines the functionality of the three files:
+
+adodb-session.php
+adodb-session-clob.php
+adodb-cryptsession.php
+
+each with very similar functionality, into a single file adodb-session.php.
+This will ease maintenance and support issues.
+
+* Supports multiple encryption and compression schemes.
+ Currently, we support:
+
+ MD5Crypt (crypt.inc.php)
+ MCrypt
+ Secure (Horde's emulation of MCrypt, if MCrypt module is not available.)
+ GZip
+ BZip2
+
+These can be stacked, so if you want to compress and then encrypt your
+session data, it's easy.
+Also, the built-in MCrypt functions will be *much* faster, and more secure,
+than the MD5Crypt code.
+
+* adodb-session.php contains a single class ADODB_Session that encapsulates
+all functionality.
+ This eliminates the use of global vars and defines (though they are
+supported for backwards compatibility).
+
+* All user defined parameters are now static functions in the ADODB_Session
+class.
+
+New parameters include:
+
+* encryptionKey(): Define the encryption key used to encrypt the session.
+Originally, it was a hard coded string.
+
+* persist(): Define if the database will be opened in persistent mode.
+Originally, the user had to call adodb_sess_open().
+
+* dataFieldName(): Define the field name used to store the session data, as
+'DATA' appears to be a reserved word in the following cases:
+ ANSI SQL
+ IBM DB2
+ MS SQL Server
+ Postgres
+ SAP
+
+* filter(): Used to support multiple, simulataneous encryption/compression
+schemes.
+
+* Debug support is improved thru _rsdump() function, which is called after
+every database call.
+
+------------
+What's Fixed
+------------
+
+The new code includes several bug fixes and enhancements:
+
+* sesskey is compared in BINARY mode for MySQL, to avoid problems with
+session keys that differ only by case.
+ Of course, the user should define the sesskey field as BINARY, to
+correctly fix this problem, otherwise performance will suffer.
+
+* In ADODB_Session::gc(), if $expire_notify is true, the multiple DELETES in
+the original code have been optimized to a single DELETE.
+
+* In ADODB_Session::destroy(), since "SELECT expireref, sesskey FROM $table
+WHERE sesskey = $qkey" will only return a single value, we don't loop on the
+result, we simply process the row, if any.
+
+* We close $rs after every use.
+
+---------------
+What's the Same
+---------------
+
+I know backwards compatibility is *very* important to you. Therefore, the
+new code is 100% backwards compatible.
+
+If you like my code, but don't "trust" it's backwards compatible, maybe we
+offer it as beta code, in a new directory for a release or two?
+
+------------
+What's To Do
+------------
+
+I've vascillated over whether to use a single function to get/set
+parameters:
+
+$user = ADODB_Session::user(); // get
+ADODB_Session::user($user); // set
+
+or to use separate functions (which is the PEAR/Java way):
+
+$user = ADODB_Session::getUser();
+ADODB_Session::setUser($user);
+
+I've chosen the former as it's makes for a simpler API, and reduces the
+amount of code, but I'd be happy to change it to the latter.
+
+Also, do you think the class should be a singleton class, versus a static
+class?
+
+Let me know if you find this code useful, and will be including it in the
+next release of ADODB.
+
+If so, I will modify the current documentation to detail the new
+functionality. To that end, what file(s) contain the documentation? Please
+send them to me if they are not publically available.
+
+Also, if there is *anything* in the code that you like to see changed, let
+me know.
+
+Thanks,
+
+Ross
+
diff --git a/html/phpgacl/adodb/session/adodb-session-clob.php b/html/phpgacl/adodb/session/adodb-session-clob.php
new file mode 100644
index 0000000..6b09cfc
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-session-clob.php
@@ -0,0 +1,23 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+*/
+
+/*
+
+This file is provided for backwards compatibility purposes
+
+*/
+
+require_once dirname(__FILE__) . '/adodb-session.php';
+
+ADODB_Session::clob('CLOB');
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/session/adodb-session.php b/html/phpgacl/adodb/session/adodb-session.php
new file mode 100644
index 0000000..14a0063
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-session.php
@@ -0,0 +1,909 @@
+<?php
+
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Contributed by Ross Smith (adodb@netebb.com).
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+*/
+
+/*
+ You may want to rename the 'data' field to 'session_data' as
+ 'data' appears to be a reserved word for one or more of the following:
+ ANSI SQL
+ IBM DB2
+ MS SQL Server
+ Postgres
+ SAP
+
+ If you do, then execute:
+
+ ADODB_Session::dataFieldName('session_data');
+
+*/
+
+if (!defined('_ADODB_LAYER')) {
+ require_once realpath(dirname(__FILE__) . '/../adodb.inc.php');
+}
+
+if (defined('ADODB_SESSION')) return 1;
+
+define('ADODB_SESSION', dirname(__FILE__));
+
+
+/*
+ Unserialize session data manually. See http://phplens.com/lens/lensforum/msgs.php?id=9821
+
+ From Kerr Schere, to unserialize session data stored via ADOdb.
+ 1. Pull the session data from the db and loop through it.
+ 2. Inside the loop, you will need to urldecode the data column.
+ 3. After urldecode, run the serialized string through this function:
+
+*/
+function adodb_unserialize( $serialized_string )
+{
+ $variables = array( );
+ $a = preg_split( "/(\w+)\|/", $serialized_string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
+ for( $i = 0; $i < count( $a ); $i = $i+2 ) {
+ $variables[$a[$i]] = unserialize( $a[$i+1] );
+ }
+ return( $variables );
+}
+
+/*
+ Thanks Joe Li. See http://phplens.com/lens/lensforum/msgs.php?id=11487&x=1
+ Since adodb 4.61.
+*/
+function adodb_session_regenerate_id()
+{
+ $conn =& ADODB_Session::_conn();
+ if (!$conn) return false;
+
+ $old_id = session_id();
+ if (function_exists('session_regenerate_id')) {
+ session_regenerate_id();
+ } else {
+ session_id(md5(uniqid(rand(), true)));
+ $ck = session_get_cookie_params();
+ setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
+ //@session_start();
+ }
+ $new_id = session_id();
+ $ok =& $conn->Execute('UPDATE '. ADODB_Session::table(). ' SET sesskey='. $conn->qstr($new_id). ' WHERE sesskey='.$conn->qstr($old_id));
+
+ /* it is possible that the update statement fails due to a collision */
+ if (!$ok) {
+ session_id($old_id);
+ if (empty($ck)) $ck = session_get_cookie_params();
+ setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ Generate database table for session data
+ @see http://phplens.com/lens/lensforum/msgs.php?id=12280
+ @return 0 if failure, 1 if errors, 2 if successful.
+ @author Markus Staab http://www.public-4u.de
+*/
+function adodb_session_create_table($schemaFile=null,$conn = null)
+{
+ // set default values
+ if ($schemaFile===null) $schemaFile = ADODB_SESSION . '/session_schema.xml';
+ if ($conn===null) $conn =& ADODB_Session::_conn();
+
+ if (!$conn) return 0;
+
+ $schema = new adoSchema($conn);
+ $schema->ParseSchema($schemaFile);
+ return $schema->ExecuteSchema();
+}
+
+/*!
+ \static
+*/
+class ADODB_Session {
+ /////////////////////
+ // getter/setter methods
+ /////////////////////
+
+ /*
+
+ function Lock($lock=null)
+ {
+ static $_lock = false;
+
+ if (!is_null($lock)) $_lock = $lock;
+ return $lock;
+ }
+ */
+ /*!
+ */
+ function driver($driver = null) {
+ static $_driver = 'mysql';
+ static $set = false;
+
+ if (!is_null($driver)) {
+ $_driver = trim($driver);
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_DRIVER'])) {
+ return $GLOBALS['ADODB_SESSION_DRIVER'];
+ }
+ }
+
+ return $_driver;
+ }
+
+ /*!
+ */
+ function host($host = null) {
+ static $_host = 'localhost';
+ static $set = false;
+
+ if (!is_null($host)) {
+ $_host = trim($host);
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_CONNECT'])) {
+ return $GLOBALS['ADODB_SESSION_CONNECT'];
+ }
+ }
+
+ return $_host;
+ }
+
+ /*!
+ */
+ function user($user = null) {
+ static $_user = 'root';
+ static $set = false;
+
+ if (!is_null($user)) {
+ $_user = trim($user);
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_USER'])) {
+ return $GLOBALS['ADODB_SESSION_USER'];
+ }
+ }
+
+ return $_user;
+ }
+
+ /*!
+ */
+ function password($password = null) {
+ static $_password = '';
+ static $set = false;
+
+ if (!is_null($password)) {
+ $_password = $password;
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_PWD'])) {
+ return $GLOBALS['ADODB_SESSION_PWD'];
+ }
+ }
+
+ return $_password;
+ }
+
+ /*!
+ */
+ function database($database = null) {
+ static $_database = 'xphplens_2';
+ static $set = false;
+
+ if (!is_null($database)) {
+ $_database = trim($database);
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_DB'])) {
+ return $GLOBALS['ADODB_SESSION_DB'];
+ }
+ }
+
+ return $_database;
+ }
+
+ /*!
+ */
+ function persist($persist = null)
+ {
+ static $_persist = true;
+
+ if (!is_null($persist)) {
+ $_persist = trim($persist);
+ }
+
+ return $_persist;
+ }
+
+ /*!
+ */
+ function lifetime($lifetime = null) {
+ static $_lifetime;
+ static $set = false;
+
+ if (!is_null($lifetime)) {
+ $_lifetime = (int) $lifetime;
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESS_LIFE'])) {
+ return $GLOBALS['ADODB_SESS_LIFE'];
+ }
+ }
+ if (!$_lifetime) {
+ $_lifetime = ini_get('session.gc_maxlifetime');
+ if ($_lifetime <= 1) {
+ // bug in PHP 4.0.3 pl 1 -- how about other versions?
+ //print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $lifetime</h3>";
+ $_lifetime = 1440;
+ }
+ }
+
+ return $_lifetime;
+ }
+
+ /*!
+ */
+ function debug($debug = null) {
+ static $_debug = false;
+ static $set = false;
+
+ if (!is_null($debug)) {
+ $_debug = (bool) $debug;
+
+ $conn = ADODB_Session::_conn();
+ if ($conn) {
+ $conn->debug = $_debug;
+ }
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESS_DEBUG'])) {
+ return $GLOBALS['ADODB_SESS_DEBUG'];
+ }
+ }
+
+ return $_debug;
+ }
+
+ /*!
+ */
+ function expireNotify($expire_notify = null) {
+ static $_expire_notify;
+ static $set = false;
+
+ if (!is_null($expire_notify)) {
+ $_expire_notify = $expire_notify;
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'])) {
+ return $GLOBALS['ADODB_SESSION_EXPIRE_NOTIFY'];
+ }
+ }
+
+ return $_expire_notify;
+ }
+
+ /*!
+ */
+ function table($table = null) {
+ static $_table = 'sessions';
+ static $set = false;
+
+ if (!is_null($table)) {
+ $_table = trim($table);
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_TBL'])) {
+ return $GLOBALS['ADODB_SESSION_TBL'];
+ }
+ }
+
+ return $_table;
+ }
+
+ /*!
+ */
+ function optimize($optimize = null) {
+ static $_optimize = false;
+ static $set = false;
+
+ if (!is_null($optimize)) {
+ $_optimize = (bool) $optimize;
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (defined('ADODB_SESSION_OPTIMIZE')) {
+ return true;
+ }
+ }
+
+ return $_optimize;
+ }
+
+ /*!
+ */
+ function syncSeconds($sync_seconds = null) {
+ static $_sync_seconds = 60;
+ static $set = false;
+
+ if (!is_null($sync_seconds)) {
+ $_sync_seconds = (int) $sync_seconds;
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (defined('ADODB_SESSION_SYNCH_SECS')) {
+ return ADODB_SESSION_SYNCH_SECS;
+ }
+ }
+
+ return $_sync_seconds;
+ }
+
+ /*!
+ */
+ function clob($clob = null) {
+ static $_clob = false;
+ static $set = false;
+
+ if (!is_null($clob)) {
+ $_clob = strtolower(trim($clob));
+ $set = true;
+ } elseif (!$set) {
+ // backwards compatibility
+ if (isset($GLOBALS['ADODB_SESSION_USE_LOBS'])) {
+ return $GLOBALS['ADODB_SESSION_USE_LOBS'];
+ }
+ }
+
+ return $_clob;
+ }
+
+ /*!
+ */
+ function dataFieldName($data_field_name = null) {
+ static $_data_field_name = 'data';
+
+ if (!is_null($data_field_name)) {
+ $_data_field_name = trim($data_field_name);
+ }
+
+ return $_data_field_name;
+ }
+
+ /*!
+ */
+ function filter($filter = null) {
+ static $_filter = array();
+
+ if (!is_null($filter)) {
+ if (!is_array($filter)) {
+ $filter = array($filter);
+ }
+ $_filter = $filter;
+ }
+
+ return $_filter;
+ }
+
+ /*!
+ */
+ function encryptionKey($encryption_key = null) {
+ static $_encryption_key = 'CRYPTED ADODB SESSIONS ROCK!';
+
+ if (!is_null($encryption_key)) {
+ $_encryption_key = $encryption_key;
+ }
+
+ return $_encryption_key;
+ }
+
+ /////////////////////
+ // private methods
+ /////////////////////
+
+ /*!
+ */
+ function &_conn($conn=null) {
+ return $GLOBALS['ADODB_SESS_CONN'];
+ }
+
+ /*!
+ */
+ function _crc($crc = null) {
+ static $_crc = false;
+
+ if (!is_null($crc)) {
+ $_crc = $crc;
+ }
+
+ return $_crc;
+ }
+
+ /*!
+ */
+ function _init() {
+ session_module_name('user');
+ session_set_save_handler(
+ array('ADODB_Session', 'open'),
+ array('ADODB_Session', 'close'),
+ array('ADODB_Session', 'read'),
+ array('ADODB_Session', 'write'),
+ array('ADODB_Session', 'destroy'),
+ array('ADODB_Session', 'gc')
+ );
+ }
+
+
+ /*!
+ */
+ function _sessionKey() {
+ // use this function to create the encryption key for crypted sessions
+ // crypt the used key, ADODB_Session::encryptionKey() as key and session_id() as salt
+ return crypt(ADODB_Session::encryptionKey(), session_id());
+ }
+
+ /*!
+ */
+ function _dumprs($rs) {
+ $conn =& ADODB_Session::_conn();
+ $debug = ADODB_Session::debug();
+
+ if (!$conn) {
+ return;
+ }
+
+ if (!$debug) {
+ return;
+ }
+
+ if (!$rs) {
+ echo "<br />\$rs is null or false<br />\n";
+ return;
+ }
+
+ //echo "<br />\nAffected_Rows=",$conn->Affected_Rows(),"<br />\n";
+
+ if (!is_object($rs)) {
+ return;
+ }
+
+ require_once ADODB_SESSION.'/../tohtml.inc.php';
+ rs2html($rs);
+ }
+
+ /////////////////////
+ // public methods
+ /////////////////////
+
+ /*!
+ Create the connection to the database.
+
+ If $conn already exists, reuse that connection
+ */
+ function open($save_path, $session_name, $persist = null) {
+ $conn =& ADODB_Session::_conn();
+
+ if ($conn) {
+ return true;
+ }
+
+ $database = ADODB_Session::database();
+ $debug = ADODB_Session::debug();
+ $driver = ADODB_Session::driver();
+ $host = ADODB_Session::host();
+ $password = ADODB_Session::password();
+ $user = ADODB_Session::user();
+
+ if (!is_null($persist)) {
+ ADODB_Session::persist($persist);
+ } else {
+ $persist = ADODB_Session::persist();
+ }
+
+# these can all be defaulted to in php.ini
+# assert('$database');
+# assert('$driver');
+# assert('$host');
+
+ // cannot use =& below - do not know why...
+ $conn =& ADONewConnection($driver);
+
+ if ($debug) {
+ $conn->debug = true;
+// ADOConnection::outp( " driver=$driver user=$user pwd=$password db=$database ");
+ }
+
+ if ($persist) {
+ switch($persist) {
+ default:
+ case 'P': $ok = $conn->PConnect($host, $user, $password, $database); break;
+ case 'C': $ok = $conn->Connect($host, $user, $password, $database); break;
+ case 'N': $ok = $conn->NConnect($host, $user, $password, $database); break;
+ }
+ } else {
+ $ok = $conn->Connect($host, $user, $password, $database);
+ }
+
+ if ($ok) $GLOBALS['ADODB_SESS_CONN'] =& $conn;
+ else
+ ADOConnection::outp('<p>Session: connection failed</p>', false);
+
+
+ return $ok;
+ }
+
+ /*!
+ Close the connection
+ */
+ function close() {
+/*
+ $conn =& ADODB_Session::_conn();
+ if ($conn) $conn->Close();
+*/
+ return true;
+ }
+
+ /*
+ Slurp in the session variables and return the serialized string
+ */
+ function read($key) {
+ $conn =& ADODB_Session::_conn();
+ $data = ADODB_Session::dataFieldName();
+ $filter = ADODB_Session::filter();
+ $table = ADODB_Session::table();
+
+ if (!$conn) {
+ return '';
+ }
+
+ assert('$table');
+
+ $qkey = $conn->quote($key);
+ $binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
+
+ $sql = "SELECT $data FROM $table WHERE $binary sesskey = $qkey AND expiry >= " . time();
+ /* Lock code does not work as it needs to hold transaction within whole page, and we don't know if
+ developer has commited elsewhere... :(
+ */
+ #if (ADODB_Session::Lock())
+ # $rs =& $conn->RowLock($table, "$binary sesskey = $qkey AND expiry >= " . time(), $data);
+ #else
+
+ $rs =& $conn->Execute($sql);
+ //ADODB_Session::_dumprs($rs);
+ if ($rs) {
+ if ($rs->EOF) {
+ $v = '';
+ } else {
+ $v = reset($rs->fields);
+ $filter = array_reverse($filter);
+ foreach ($filter as $f) {
+ if (is_object($f)) {
+ $v = $f->read($v, ADODB_Session::_sessionKey());
+ }
+ }
+ $v = rawurldecode($v);
+ }
+
+ $rs->Close();
+
+ ADODB_Session::_crc(strlen($v) . crc32($v));
+ return $v;
+ }
+
+ return '';
+ }
+
+ /*!
+ Write the serialized data to a database.
+
+ If the data has not been modified since the last read(), we do not write.
+ */
+ function write($key, $val) {
+ $clob = ADODB_Session::clob();
+ $conn =& ADODB_Session::_conn();
+ $crc = ADODB_Session::_crc();
+ $data = ADODB_Session::dataFieldName();
+ $debug = ADODB_Session::debug();
+ $driver = ADODB_Session::driver();
+ $expire_notify = ADODB_Session::expireNotify();
+ $filter = ADODB_Session::filter();
+ $lifetime = ADODB_Session::lifetime();
+ $table = ADODB_Session::table();
+
+ if (!$conn) {
+ return false;
+ }
+ $qkey = $conn->qstr($key);
+
+ assert('$table');
+
+ $expiry = time() + $lifetime;
+
+ $binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
+
+ // crc32 optimization since adodb 2.1
+ // now we only update expiry date, thx to sebastian thom in adodb 2.32
+ if ($crc !== false && $crc == (strlen($val) . crc32($val))) {
+ if ($debug) {
+ echo '<p>Session: Only updating date - crc32 not changed</p>';
+ }
+ $sql = "UPDATE $table SET expiry = ".$conn->Param('0')." WHERE $binary sesskey = ".$conn->Param('1')." AND expiry >= ".$conn->Param('2');
+ $rs =& $conn->Execute($sql,array($expiry,$key,time()));
+ ADODB_Session::_dumprs($rs);
+ if ($rs) {
+ $rs->Close();
+ }
+ return true;
+ }
+ $val = rawurlencode($val);
+ foreach ($filter as $f) {
+ if (is_object($f)) {
+ $val = $f->write($val, ADODB_Session::_sessionKey());
+ }
+ }
+
+ $arr = array('sesskey' => $key, 'expiry' => $expiry, $data => $val, 'expireref' => '');
+ if ($expire_notify) {
+ $var = reset($expire_notify);
+ global $$var;
+ if (isset($$var)) {
+ $arr['expireref'] = $$var;
+ }
+ }
+
+ if (!$clob) { // no lobs, simply use replace()
+ $arr[$data] = $conn->qstr($val);
+ $rs = $conn->Replace($table, $arr, 'sesskey', $autoQuote = true);
+ ADODB_Session::_dumprs($rs);
+ } else {
+ // what value shall we insert/update for lob row?
+ switch ($driver) {
+ // empty_clob or empty_lob for oracle dbs
+ case 'oracle':
+ case 'oci8':
+ case 'oci8po':
+ case 'oci805':
+ $lob_value = sprintf('empty_%s()', strtolower($clob));
+ break;
+
+ // null for all other
+ default:
+ $lob_value = 'null';
+ break;
+ }
+
+ // do we insert or update? => as for sesskey
+ $rs =& $conn->Execute("SELECT COUNT(*) AS cnt FROM $table WHERE $binary sesskey = $qkey");
+ ADODB_Session::_dumprs($rs);
+ if ($rs && reset($rs->fields) > 0) {
+ $sql = "UPDATE $table SET expiry = $expiry, $data = $lob_value WHERE sesskey = $qkey";
+ } else {
+ $sql = "INSERT INTO $table (expiry, $data, sesskey) VALUES ($expiry, $lob_value, $qkey)";
+ }
+ if ($rs) {
+ $rs->Close();
+ }
+
+ $err = '';
+ $rs1 =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs1);
+ if (!$rs1) {
+ $err = $conn->ErrorMsg()."\n";
+ }
+ $rs2 =& $conn->UpdateBlob($table, $data, $val, " sesskey=$qkey", strtoupper($clob));
+ ADODB_Session::_dumprs($rs2);
+ if (!$rs2) {
+ $err .= $conn->ErrorMsg()."\n";
+ }
+ $rs = ($rs && $rs2) ? true : false;
+ if ($rs1) {
+ $rs1->Close();
+ }
+ if (is_object($rs2)) {
+ $rs2->Close();
+ }
+ }
+
+ if (!$rs) {
+ ADOConnection::outp('<p>Session Replace: ' . $conn->ErrorMsg() . '</p>', false);
+ return false;
+ } else {
+ // bug in access driver (could be odbc?) means that info is not committed
+ // properly unless select statement executed in Win2000
+ if ($conn->databaseType == 'access') {
+ $sql = "SELECT sesskey FROM $table WHERE $binary sesskey = $qkey";
+ $rs =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs);
+ if ($rs) {
+ $rs->Close();
+ }
+ }
+ }/*
+ if (ADODB_Session::Lock()) {
+ $conn->CommitTrans();
+ }*/
+ return $rs ? true : false;
+ }
+
+ /*!
+ */
+ function destroy($key) {
+ $conn =& ADODB_Session::_conn();
+ $table = ADODB_Session::table();
+ $expire_notify = ADODB_Session::expireNotify();
+
+ if (!$conn) {
+ return false;
+ }
+
+ assert('$table');
+
+ $qkey = $conn->quote($key);
+ $binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
+
+ if ($expire_notify) {
+ reset($expire_notify);
+ $fn = next($expire_notify);
+ $savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
+ $sql = "SELECT expireref, sesskey FROM $table WHERE $binary sesskey = $qkey";
+ $rs =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs);
+ $conn->SetFetchMode($savem);
+ if (!$rs) {
+ return false;
+ }
+ if (!$rs->EOF) {
+ $ref = $rs->fields[0];
+ $key = $rs->fields[1];
+ //assert('$ref');
+ //assert('$key');
+ $fn($ref, $key);
+ }
+ $rs->Close();
+ }
+
+ $sql = "DELETE FROM $table WHERE $binary sesskey = $qkey";
+ $rs =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs);
+ if ($rs) {
+ $rs->Close();
+ }
+
+ return $rs ? true : false;
+ }
+
+ /*!
+ */
+ function gc($maxlifetime) {
+ $conn =& ADODB_Session::_conn();
+ $debug = ADODB_Session::debug();
+ $expire_notify = ADODB_Session::expireNotify();
+ $optimize = ADODB_Session::optimize();
+ $sync_seconds = ADODB_Session::syncSeconds();
+ $table = ADODB_Session::table();
+
+ if (!$conn) {
+ return false;
+ }
+
+ assert('$table');
+
+ $time = time();
+
+ $binary = $conn->dataProvider === 'mysql' ? '/*! BINARY */' : '';
+
+ if ($expire_notify) {
+ reset($expire_notify);
+ $fn = next($expire_notify);
+ $savem = $conn->SetFetchMode(ADODB_FETCH_NUM);
+ $sql = "SELECT expireref, sesskey FROM $table WHERE expiry < $time";
+ $rs =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs);
+ $conn->SetFetchMode($savem);
+ if ($rs) {
+ $conn->BeginTrans();
+ $keys = array();
+ while (!$rs->EOF) {
+ $ref = $rs->fields[0];
+ $key = $rs->fields[1];
+ $fn($ref, $key);
+ $del = $conn->Execute("DELETE FROM $table WHERE sesskey='$key'");
+ $rs->MoveNext();
+ }
+ $rs->Close();
+
+ $conn->CommitTrans();
+ }
+ } else {
+ $sql = "DELETE FROM $table WHERE expiry < $time";
+ $rs =& $conn->Execute($sql);
+ ADODB_Session::_dumprs($rs);
+ if ($rs) {
+ $rs->Close();
+ }
+ if ($debug) {
+ ADOConnection::outp("<p><b>Garbage Collection</b>: $sql</p>");
+ }
+ }
+
+ // suggested by Cameron, "GaM3R" <gamr@outworld.cx>
+ if ($optimize) {
+ $driver = ADODB_Session::driver();
+
+ if (preg_match('/mysql/i', $driver)) {
+ $sql = "OPTIMIZE TABLE $table";
+ }
+ if (preg_match('/postgres/i', $driver)) {
+ $sql = "VACUUM $table";
+ }
+ if (!empty($sql)) {
+ $conn->Execute($sql);
+ }
+ }
+
+ if ($sync_seconds) {
+ $sql = 'SELECT ';
+ if ($conn->dataProvider === 'oci8') {
+ $sql .= "TO_CHAR({$conn->sysTimeStamp}, 'RRRR-MM-DD HH24:MI:SS')";
+ } else {
+ $sql .= $conn->sysTimeStamp;
+ }
+ $sql .= " FROM $table";
+
+ $rs =& $conn->SelectLimit($sql, 1);
+ if ($rs && !$rs->EOF) {
+ $dbts = reset($rs->fields);
+ $rs->Close();
+ $dbt = $conn->UnixTimeStamp($dbts);
+ $t = time();
+
+ if (abs($dbt - $t) >= $sync_seconds) {
+ $msg = __FILE__ .
+ ": Server time for webserver {$_SERVER['HTTP_HOST']} not in synch with database: " .
+ " database=$dbt ($dbts), webserver=$t (diff=". (abs($dbt - $t) / 60) . ' minutes)';
+ error_log($msg);
+ if ($debug) {
+ ADOConnection::outp("<p>$msg</p>");
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+}
+
+ADODB_Session::_init();
+
+
+// for backwards compatability only
+function adodb_sess_open($save_path, $session_name, $persist = true) {
+ return ADODB_Session::open($save_path, $session_name, $persist);
+}
+
+// for backwards compatability only
+function adodb_sess_gc($t)
+{
+ return ADODB_Session::gc($t);
+}
+
+?>
diff --git a/html/phpgacl/adodb/session/adodb-sessions.mysql.sql b/html/phpgacl/adodb/session/adodb-sessions.mysql.sql
new file mode 100644
index 0000000..f90de44
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-sessions.mysql.sql
@@ -0,0 +1,16 @@
+-- $CVSHeader$
+
+CREATE DATABASE /*! IF NOT EXISTS */ adodb_sessions;
+
+USE adodb_sessions;
+
+DROP TABLE /*! IF EXISTS */ sessions;
+
+CREATE TABLE /*! IF NOT EXISTS */ sessions (
+ sesskey CHAR(32) /*! BINARY */ NOT NULL DEFAULT '',
+ expiry INT(11) /*! UNSIGNED */ NOT NULL DEFAULT 0,
+ expireref VARCHAR(64) DEFAULT '',
+ data LONGTEXT DEFAULT '',
+ PRIMARY KEY (sesskey),
+ INDEX expiry (expiry)
+);
diff --git a/html/phpgacl/adodb/session/adodb-sessions.oracle.clob.sql b/html/phpgacl/adodb/session/adodb-sessions.oracle.clob.sql
new file mode 100644
index 0000000..c5c4f2d
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-sessions.oracle.clob.sql
@@ -0,0 +1,15 @@
+-- $CVSHeader$
+
+DROP TABLE adodb_sessions;
+
+CREATE TABLE sessions (
+ sesskey CHAR(32) DEFAULT '' NOT NULL,
+ expiry INT DEFAULT 0 NOT NULL,
+ expireref VARCHAR(64) DEFAULT '',
+ data CLOB DEFAULT '',
+ PRIMARY KEY (sesskey)
+);
+
+CREATE INDEX ix_expiry ON sessions (expiry);
+
+QUIT;
diff --git a/html/phpgacl/adodb/session/adodb-sessions.oracle.sql b/html/phpgacl/adodb/session/adodb-sessions.oracle.sql
new file mode 100644
index 0000000..8fd5a34
--- /dev/null
+++ b/html/phpgacl/adodb/session/adodb-sessions.oracle.sql
@@ -0,0 +1,16 @@
+-- $CVSHeader$
+
+DROP TABLE adodb_sessions;
+
+CREATE TABLE sessions (
+ sesskey CHAR(32) DEFAULT '' NOT NULL,
+ expiry INT DEFAULT 0 NOT NULL,
+ expireref VARCHAR(64) DEFAULT '',
+ data VARCHAR(4000) DEFAULT '',
+ PRIMARY KEY (sesskey),
+ INDEX expiry (expiry)
+);
+
+CREATE INDEX ix_expiry ON sessions (expiry);
+
+QUIT;
diff --git a/html/phpgacl/adodb/session/crypt.inc.php b/html/phpgacl/adodb/session/crypt.inc.php
new file mode 100644
index 0000000..7266ab6
--- /dev/null
+++ b/html/phpgacl/adodb/session/crypt.inc.php
@@ -0,0 +1,64 @@
+<?php
+// Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
+class MD5Crypt{
+ function keyED($txt,$encrypt_key)
+ {
+ $encrypt_key = md5($encrypt_key);
+ $ctr=0;
+ $tmp = "";
+ for ($i=0;$i<strlen($txt);$i++){
+ if ($ctr==strlen($encrypt_key)) $ctr=0;
+ $tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
+ $ctr++;
+ }
+ return $tmp;
+ }
+
+ function Encrypt($txt,$key)
+ {
+ srand((double)microtime()*1000000);
+ $encrypt_key = md5(rand(0,32000));
+ $ctr=0;
+ $tmp = "";
+ for ($i=0;$i<strlen($txt);$i++)
+ {
+ if ($ctr==strlen($encrypt_key)) $ctr=0;
+ $tmp.= substr($encrypt_key,$ctr,1) .
+ (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
+ $ctr++;
+ }
+ return base64_encode($this->keyED($tmp,$key));
+ }
+
+ function Decrypt($txt,$key)
+ {
+ $txt = $this->keyED(base64_decode($txt),$key);
+ $tmp = "";
+ for ($i=0;$i<strlen($txt);$i++){
+ $md5 = substr($txt,$i,1);
+ $i++;
+ $tmp.= (substr($txt,$i,1) ^ $md5);
+ }
+ return $tmp;
+ }
+
+ function RandPass()
+ {
+ $randomPassword = "";
+ srand((double)microtime()*1000000);
+ for($i=0;$i<8;$i++)
+ {
+ $randnumber = rand(48,120);
+
+ while (($randnumber >= 58 && $randnumber <= 64) || ($randnumber >= 91 && $randnumber <= 96))
+ {
+ $randnumber = rand(48,120);
+ }
+
+ $randomPassword .= chr($randnumber);
+ }
+ return $randomPassword;
+ }
+
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/benchmark.php b/html/phpgacl/adodb/tests/benchmark.php
new file mode 100644
index 0000000..6da6069
--- /dev/null
+++ b/html/phpgacl/adodb/tests/benchmark.php
@@ -0,0 +1,84 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+ <title>ADODB Benchmarks</title>
+</head>
+
+<body>
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Benchmark code to test the speed to the ADODB library with different databases.
+ This is a simplistic benchmark to be used as the basis for further testing.
+ It should not be used as proof of the superiority of one database over the other.
+*/
+
+$testmssql = true;
+//$testvfp = true;
+$testoracle = true;
+$testado = true;
+$testibase = true;
+$testaccess = true;
+$testmysql = true;
+$testsqlite = true;;
+
+set_time_limit(240); // increase timeout
+
+include("../tohtml.inc.php");
+include("../adodb.inc.php");
+
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
+{
+GLOBAL $ADODB_version,$ADODB_FETCH_MODE;
+
+ adodb_backtrace();
+
+ $max = 100;
+ $sql = 'select * from ADOXYZ';
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ //print "<h3>ADODB Version: $ADODB_version Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i></h3>";
+
+ // perform query once to cache results so we are only testing throughput
+ $rs = $db->Execute($sql);
+ if (!$rs){
+ print "Error in recordset<p>";
+ return;
+ }
+ $arr = $rs->GetArray();
+ //$db->debug = true;
+ global $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+ $start = microtime();
+ for ($i=0; $i < $max; $i++) {
+ $rs =& $db->Execute($sql);
+ $arr =& $rs->GetArray();
+ // print $arr[0][1];
+ }
+ $end = microtime();
+ $start = explode(' ',$start);
+ $end = explode(' ',$end);
+
+ //print_r($start);
+ //print_r($end);
+
+ // print_r($arr);
+ $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]);
+ printf ("<p>seconds = %8.2f for %d iterations each with %d records</p>",$total,$max, sizeof($arr));
+ flush();
+
+
+ //$db->Close();
+}
+include("testdatabases.inc.php");
+
+?>
+
+
+</body>
+</html>
diff --git a/html/phpgacl/adodb/tests/client.php b/html/phpgacl/adodb/tests/client.php
new file mode 100644
index 0000000..6c76389
--- /dev/null
+++ b/html/phpgacl/adodb/tests/client.php
@@ -0,0 +1,194 @@
+<html>
+<body bgcolor=white>
+<?php
+/**
+ * V4.50 6 July 2004 (c) 2001-2002 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ *
+ * set tabs to 8
+ */
+
+ // documentation on usage is at http://php.weblogs.com/adodb_csv
+
+include('../adodb.inc.php');
+include('../tohtml.inc.php');
+
+ function &send2server($url,$sql)
+ {
+ $url .= '?sql='.urlencode($sql);
+ print "<p>$url</p>";
+ $rs = csv2rs($url,$err);
+ if ($err) print $err;
+ return $rs;
+ }
+
+ function print_pre($s)
+ {
+ print "<pre>";print_r($s);print "</pre>";
+ }
+
+
+$serverURL = 'http://localhost/php/phplens/adodb/server.php';
+$testhttp = false;
+
+$sql1 = "insertz into products (productname) values ('testprod 1')";
+$sql2 = "insert into products (productname) values ('testprod 1')";
+$sql3 = "insert into products (productname) values ('testprod 2')";
+$sql4 = "delete from products where productid>80";
+$sql5 = 'select * from products';
+
+if ($testhttp) {
+ print "<a href=#c>Client Driver Tests</a><p>";
+ print "<h3>Test Error</h3>";
+ $rs = send2server($serverURL,$sql1);
+ print_pre($rs);
+ print "<hr>";
+
+ print "<h3>Test Insert</h3>";
+
+ $rs = send2server($serverURL,$sql2);
+ print_pre($rs);
+ print "<hr>";
+
+ print "<h3>Test Insert2</h3>";
+
+ $rs = send2server($serverURL,$sql3);
+ print_pre($rs);
+ print "<hr>";
+
+ print "<h3>Test Delete</h3>";
+
+ $rs = send2server($serverURL,$sql4);
+ print_pre($rs);
+ print "<hr>";
+
+
+ print "<h3>Test Select</h3>";
+ $rs = send2server($serverURL,$sql5);
+ if ($rs) rs2html($rs);
+
+ print "<hr>";
+}
+
+
+print "<a name=c><h1>CLIENT Driver Tests</h1>";
+$conn = ADONewConnection('csv');
+$conn->Connect($serverURL);
+$conn->debug = true;
+
+print "<h3>Bad SQL</h3>";
+
+$rs = $conn->Execute($sql1);
+
+print "<h3>Insert SQL 1</h3>";
+$rs = $conn->Execute($sql2);
+
+print "<h3>Insert SQL 2</h3>";
+$rs = $conn->Execute($sql3);
+
+print "<h3>Select SQL</h3>";
+$rs = $conn->Execute($sql5);
+if ($rs) rs2html($rs);
+
+print "<h3>Delete SQL</h3>";
+$rs = $conn->Execute($sql4);
+
+print "<h3>Select SQL</h3>";
+$rs = $conn->Execute($sql5);
+if ($rs) rs2html($rs);
+
+
+/* EXPECTED RESULTS FOR HTTP TEST:
+
+Test Insert
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => insert into products (productname) values ('testprod')
+ [affectedrows] => 1
+ [insertid] => 81
+)
+
+
+--------------------------------------------------------------------------------
+
+Test Insert2
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => insert into products (productname) values ('testprod')
+ [affectedrows] => 1
+ [insertid] => 82
+)
+
+
+--------------------------------------------------------------------------------
+
+Test Delete
+http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => delete from products where productid>80
+ [affectedrows] => 2
+ [insertid] => 0
+)
+
+[more stuff deleted]
+ .
+ .
+ .
+*/
+?>
diff --git a/html/phpgacl/adodb/tests/pdo.php b/html/phpgacl/adodb/tests/pdo.php
new file mode 100644
index 0000000..a40eb21
--- /dev/null
+++ b/html/phpgacl/adodb/tests/pdo.php
@@ -0,0 +1,82 @@
+<?php
+error_reporting(E_ALL);
+include('../adodb.inc.php');
+
+try {
+ echo "New Connection\n";
+ $DB = NewADOConnection('pdo');
+ echo "Connect\n";
+
+ $u = ''; $p = '';
+ /*
+ $connstr = 'odbc:nwind';
+
+ $connstr = 'oci:';
+ $u = 'scott';
+ $p = 'natsoft';
+
+
+ $connstr ="sqlite:d:\inetpub\adodb\sqlite.db";
+ */
+
+ $connstr = "mysql:dbname=northwind";
+ $u = 'root';
+
+ $connstr = "pgsql:dbname=test";
+ $u = 'tester';
+ $p = 'test';
+
+ $DB->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+
+
+ echo "$connstr: Execute\n";
+
+ //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = $DB->Execute("select * from ADOXYZ where id<3");
+ echo "*** e=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n";
+
+
+ //print_r(get_class_methods($DB->_stmt));
+
+ if (!$rs) die("NO RS");
+
+ echo "Meta\n";
+ for ($i=0; $i < $rs->NumCols(); $i++) {
+ var_dump($rs->FetchField($i));
+ echo "<br>";
+ }
+
+ echo "FETCH\n";
+ $cnt = 0;
+ while (!$rs->EOF) {
+ adodb_pr($rs->fields);
+ $rs->MoveNext();
+ if ($cnt++ > 1000) break;
+ }
+
+ echo "<br>--------------------------------------------------------<br>\n\n\n";
+
+ $stmt = $DB->PrepareStmt("select * from ADOXYZ");
+
+ $rs = $stmt->Execute();
+ $cols = $stmt->NumCols(); // execute required
+
+ echo "COLS = $cols";
+ for($i=1;$i<=$cols;$i++) {
+ $v = $stmt->_stmt->getColumnMeta($i);
+ var_dump($v);
+ }
+
+ echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n";
+ while ($arr = $rs->FetchRow()) {
+ adodb_pr($arr);
+ }
+ die("DONE\n");
+
+} catch (exception $e) {
+ echo "<pre>";
+ echo $e;
+ echo "</pre>";
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test-datadict.php b/html/phpgacl/adodb/tests/test-datadict.php
new file mode 100644
index 0000000..06710e4
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test-datadict.php
@@ -0,0 +1,248 @@
+<?php
+/*
+
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Set tabs to 4 for best viewing.
+
+*/
+
+error_reporting(E_ALL);
+include_once('../adodb.inc.php');
+
+foreach(array('sapdb','sybase','mysqlt','access','oci8','postgres','odbc_mssql','odbc','db2','firebird','informix') as $dbType) {
+ echo "<h3>$dbType</h3><p>";
+ $db = NewADOConnection($dbType);
+ $dict = NewDataDictionary($db);
+
+ if (!$dict) continue;
+ $dict->debug = 1;
+
+ $opts = array('REPLACE','mysql' => 'TYPE=INNODB', 'oci8' => 'TABLESPACE USERS');
+
+/* $flds = array(
+ array('id', 'I',
+ 'AUTO','KEY'),
+
+ array('name' => 'firstname', 'type' => 'varchar','size' => 30,
+ 'DEFAULT'=>'Joan'),
+
+ array('lastname','varchar',28,
+ 'DEFAULT'=>'Chen','key'),
+
+ array('averylonglongfieldname','X',1024,
+ 'NOTNULL','default' => 'test'),
+
+ array('price','N','7.2',
+ 'NOTNULL','default' => '0.00'),
+
+ array('MYDATE', 'D',
+ 'DEFDATE'),
+ array('TS','T',
+ 'DEFTIMESTAMP')
+ );*/
+
+ $flds = "
+ID I AUTO KEY,
+FIRSTNAME VARCHAR(30) DEFAULT 'Joan',
+LASTNAME VARCHAR(28) DEFAULT 'Chen' key,
+averylonglongfieldname X(1024) DEFAULT 'test',
+price N(7.2) DEFAULT '0.00',
+MYDATE D DEFDATE,
+BIGFELLOW X NOTNULL,
+TS T DEFTIMESTAMP";
+
+
+ $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'"));
+ $dict->SetSchema('KUTU');
+
+ $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts));
+ $sqla = array_merge($sqla,$sqli);
+
+ $sqli = $dict->CreateIndexSQL('idx','testtable','firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH'));
+ $sqla = array_merge($sqla,$sqli);
+ $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');//,array('BITMAP','FULLTEXT','CLUSTERED'));
+ $sqla = array_merge($sqla,$sqli);
+
+ $addflds = array(array('height', 'F'),array('weight','F'));
+ $sqli = $dict->AddColumnSQL('testtable',$addflds);
+ $sqla = array_merge($sqla,$sqli);
+ $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL'));
+ $sqli = $dict->AlterColumnSQL('testtable',$addflds);
+ $sqla = array_merge($sqla,$sqli);
+
+
+ printsqla($dbType,$sqla);
+
+ if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php'))
+ if ($dbType == 'mysqlt') {
+ $db->Connect('localhost', "root", "", "test");
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+ if ($dbType == 'postgres') {
+ if (@$db->Connect('localhost', "tester", "test", "test"));
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+
+ if ($dbType == 'odbc_mssql') {
+ $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
+ if (@$db->Connect($dsn, "sa", "natsoft", "test"));
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+
+
+
+ adodb_pr($dict->databaseType);
+ printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)')));
+ printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)'));
+
+}
+
+function printsqla($dbType,$sqla)
+{
+ print "<pre>";
+ //print_r($dict->MetaTables());
+ foreach($sqla as $s) {
+ $s = htmlspecialchars($s);
+ print "$s;\n";
+ if ($dbType == 'oci8') print "/\n";
+ }
+ print "</pre><hr>";
+}
+
+/***
+
+Generated SQL:
+
+mysql
+
+CREATE DATABASE KUTU;
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id INTEGER NOT NULL AUTO_INCREMENT,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) NOT NULL DEFAULT 'Chen',
+averylonglongfieldname LONGTEXT NOT NULL,
+price NUMERIC(7,2) NOT NULL DEFAULT 0.00,
+MYDATE DATE DEFAULT CURDATE(),
+ PRIMARY KEY (id, lastname)
+)TYPE=ISAM;
+CREATE FULLTEXT INDEX idx ON KUTU.testtable (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD height DOUBLE;
+ALTER TABLE KUTU.testtable ADD weight DOUBLE;
+ALTER TABLE KUTU.testtable MODIFY COLUMN height DOUBLE NOT NULL;
+ALTER TABLE KUTU.testtable MODIFY COLUMN weight DOUBLE NOT NULL;
+
+
+--------------------------------------------------------------------------------
+
+oci8
+
+CREATE USER KUTU IDENTIFIED BY tiger;
+/
+GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO KUTU;
+/
+DROP TABLE KUTU.testtable CASCADE CONSTRAINTS;
+/
+CREATE TABLE KUTU.testtable (
+id NUMBER(16) NOT NULL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname CLOB NOT NULL,
+price NUMBER(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATE DEFAULT TRUNC(SYSDATE),
+ PRIMARY KEY (id, lastname)
+)TABLESPACE USERS;
+/
+DROP SEQUENCE KUTU.SEQ_testtable;
+/
+CREATE SEQUENCE KUTU.SEQ_testtable;
+/
+CREATE OR REPLACE TRIGGER KUTU.TRIG_SEQ_testtable BEFORE insert ON KUTU.testtable
+ FOR EACH ROW
+ BEGIN
+ select KUTU.SEQ_testtable.nextval into :new.id from dual;
+ END;
+/
+CREATE BITMAP INDEX idx ON KUTU.testtable (firstname,lastname);
+/
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+/
+ALTER TABLE testtable ADD (
+ height NUMBER,
+ weight NUMBER);
+/
+ALTER TABLE testtable MODIFY(
+ height NUMBER NOT NULL,
+ weight NUMBER NOT NULL);
+/
+
+
+--------------------------------------------------------------------------------
+
+postgres
+AlterColumnSQL not supported for PostgreSQL
+
+
+CREATE DATABASE KUTU LOCATION='/u01/postdata';
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id SERIAL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname TEXT NOT NULL,
+price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATE DEFAULT CURRENT_DATE,
+ PRIMARY KEY (id, lastname)
+);
+CREATE INDEX idx ON KUTU.testtable USING HASH (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD height FLOAT8;
+ALTER TABLE KUTU.testtable ADD weight FLOAT8;
+
+
+--------------------------------------------------------------------------------
+
+odbc_mssql
+
+CREATE DATABASE KUTU;
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id INT IDENTITY(1,1) NOT NULL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname TEXT NOT NULL,
+price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATETIME DEFAULT GetDate(),
+ PRIMARY KEY (id, lastname)
+);
+CREATE CLUSTERED INDEX idx ON KUTU.testtable (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD
+ height REAL,
+ weight REAL;
+ALTER TABLE KUTU.testtable ALTER COLUMN height REAL NOT NULL;
+ALTER TABLE KUTU.testtable ALTER COLUMN weight REAL NOT NULL;
+
+
+--------------------------------------------------------------------------------
+*/
+
+
+echo "<h1>Test XML Schema</h1>";
+$ff = file('xmlschema.xml');
+echo "<pre>";
+foreach($ff as $xml) echo htmlspecialchars($xml);
+echo "</pre>";
+include_once('test-xmlschema.php');
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test-perf.php b/html/phpgacl/adodb/tests/test-perf.php
new file mode 100644
index 0000000..37406d2
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test-perf.php
@@ -0,0 +1,50 @@
+<?php
+
+include_once('../adodb-perf.inc.php');
+
+error_reporting(E_ALL);
+session_start();
+
+if (isset($_GET)) {
+ foreach($_GET as $k => $v) {
+ if (strncmp($k,'test',4) == 0) $_SESSION['_db'] = $k;
+ }
+}
+
+if (isset($_SESSION['_db'])) {
+ $_db = $_SESSION['_db'];
+ $_GET[$_db] = 1;
+ $$_db = 1;
+}
+
+echo "<h1>Performance Monitoring</h1>";
+include_once('testdatabases.inc.php');
+
+
+function testdb($db)
+{
+ if (!$db) return;
+ echo "<font size=1>";print_r($db->ServerInfo()); echo " user=".$db->user."</font>";
+
+ $perf = NewPerfMonitor($db);
+
+ # unit tests
+ if (0) {
+ //$DB->debug=1;
+ echo "Data Cache Size=".$perf->DBParameter('data cache size').'<p>';
+ echo $perf->HealthCheck();
+ echo($perf->SuspiciousSQL());
+ echo($perf->ExpensiveSQL());
+ echo($perf->InvalidSQL());
+ echo $perf->Tables();
+
+ echo "<pre>";
+ echo $perf->HealthCheckCLI();
+ $perf->Poll(3);
+ die();
+ }
+
+ if ($perf) $perf->UI(3);
+}
+
+?>
diff --git a/html/phpgacl/adodb/tests/test-pgblob.php b/html/phpgacl/adodb/tests/test-pgblob.php
new file mode 100644
index 0000000..029669f
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test-pgblob.php
@@ -0,0 +1,88 @@
+<?php
+
+function getmicrotime()
+{
+ $t = microtime();
+ $t = explode(' ',$t);
+ return (float)$t[1]+ (float)$t[0];
+}
+
+function doloop()
+{
+global $db,$MAX;
+
+ $sql = "select id,firstname,lastname from adoxyz where
+ firstname not like ? and lastname not like ? and id=?";
+ $offset = 0;
+ /*$sql = "select * from juris9.employee join juris9.emp_perf_plan on epp_empkey = emp_id
+ where emp_name not like ? and emp_name not like ? and emp_id=28000+?";
+ $offset = 28000;*/
+ for ($i=1; $i <= $MAX; $i++) {
+ $db->Param(false);
+ $x = (rand() % 10) + 1;
+ $db->debug= ($i==1);
+ $id = $db->GetOne($sql,
+ array('Z%','Z%',$x));
+ if($id != $offset+$x) {
+ print "<p>Error at $x";
+ break;
+ }
+ }
+}
+
+include_once('../adodb.inc.php');
+$db = NewADOConnection('postgres7');
+$db->PConnect('localhost','tester','test','test') || die("failed connection");
+
+$enc = "GIF89a%01%00%01%00%80%FF%00%C0%C0%C0%00%00%00%21%F9%04%01%00%00%00%00%2C%00%00%00%00%01%00%01%00%00%01%012%00%3Bt_clear.gif%0D";
+$val = rawurldecode($enc);
+
+$MAX = 1000;
+
+adodb_pr($db->ServerInfo());
+
+echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
+
+
+$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
+$t = getmicrotime();
+doloop();
+echo '<p>',$MAX,' times, with plan=',getmicrotime() - $t,'</p>';
+
+
+$db->_bindInputArray = false;
+$t = getmicrotime();
+doloop();
+echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
+
+
+
+echo "<h4>Testing UPDATEBLOB</h4>";
+$db->debug=1;
+
+### TEST BEGINS
+
+$db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
+$db->UpdateBlob('photos','photo',$val,'id=9999');
+$v = $db->GetOne('select photo from photos where id=9999');
+
+
+### CLEANUP
+
+$db->Execute("delete from photos where id=9999");
+
+### VALIDATION
+
+if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
+else echo "<b>*** OK: Passed</b>";
+
+echo "<pre>";
+echo "INSERTED: ", $enc;
+echo "<hr>";
+echo"RETURNED: ", rawurlencode($v);
+echo "<hr><p>";
+echo "INSERTED: ", $val;
+echo "<hr>";
+echo "RETURNED: ", $v;
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test-php5.php b/html/phpgacl/adodb/tests/test-php5.php
new file mode 100644
index 0000000..894f21e
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test-php5.php
@@ -0,0 +1,78 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+ */
+
+
+error_reporting(E_ALL);
+
+$path = dirname(__FILE__);
+
+include("$path/../adodb-exceptions.inc.php");
+include("$path/../adodb.inc.php");
+
+echo "<h3>PHP ".PHP_VERSION."</h3>\n";
+try {
+
+$dbt = 'mysql';
+
+try {
+switch($dbt) {
+case 'oci8po':
+ $db = NewADOConnection("oci8po");
+
+ $db->Connect('','scott','natsoft');
+ break;
+default:
+case 'mysql':
+ $db = NewADOConnection("mysql");
+ $db->Connect('localhost','roots','','northwind');
+ break;
+
+case 'mysqli':
+ $db = NewADOConnection("mysqli://root:@localhost/northwind");
+ //$db->Connect('localhost','root','','test');
+ break;
+}
+} catch (exception $e){
+ echo "Connect Failed";
+ adodb_pr($e);
+ die();
+}
+
+$db->debug=1;
+
+$cnt = $db->GetOne("select count(*) from adoxyz where ?<id and id<?",array(10,20));
+$stmt = $db->Prepare("select * from adoxyz where ?<id and id<?");
+if (!$stmt) echo $db->ErrorMsg(),"\n";
+$rs = $db->Execute($stmt,array(10,20));
+
+echo "<hr> Foreach Iterator Test (rand=".rand().")<hr>";
+$i = 0;
+foreach($rs as $v) {
+ $i += 1;
+ echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
+ if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
+ else echo "passed<br>";
+ flush();
+}
+
+
+if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
+else echo "Count $i is correct<br>";
+
+$rs = $db->Execute("select bad from badder");
+
+} catch (exception $e) {
+ adodb_pr($e);
+ echo "<h3>adodb_backtrace:</h3>\n";
+ $e = adodb_backtrace($e->gettrace());
+}
+
+$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
+echo "Result=\n",$rs;
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test-xmlschema.php b/html/phpgacl/adodb/tests/test-xmlschema.php
new file mode 100644
index 0000000..42870df
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test-xmlschema.php
@@ -0,0 +1,54 @@
+<?PHP
+
+// V4.50 6 July 2004
+
+error_reporting(E_ALL);
+include_once( "../adodb.inc.php" );
+include_once( "../adodb-xmlschema.inc.php" );
+
+// To build the schema, start by creating a normal ADOdb connection:
+$db = ADONewConnection( 'mysql' );
+$db->Connect( 'localhost', 'root', '', 'schematest' );
+
+// To create a schema object and build the query array.
+$schema = new adoSchema( $db );
+
+// To upgrade an existing schema object, use the following
+// To upgrade an existing database to the provided schema,
+// uncomment the following line:
+#$schema->upgradeSchema();
+
+print "<b>SQL to build xmlschema.xml</b>:\n<pre>";
+// Build the SQL array
+$sql = $schema->ParseSchema( "xmlschema.xml" );
+
+print_r( $sql );
+print "</pre>\n";
+
+// Execute the SQL on the database
+//$result = $schema->ExecuteSchema( $sql );
+
+// Finally, clean up after the XML parser
+// (PHP won't do this for you!)
+//$schema->Destroy();
+
+
+
+print "<b>SQL to build xmlschema-mssql.xml</b>:\n<pre>";
+
+$db2 = ADONewConnection('mssql');
+$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2");
+
+$db2->Execute("drop table simple_table");
+
+$schema = new adoSchema( $db2 );
+$sql = $schema->ParseSchema( "xmlschema-mssql.xml" );
+
+print_r( $sql );
+print "</pre>\n";
+
+$db2->debug=1;
+
+foreach ($sql as $s)
+$db2->Execute($s);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test.php b/html/phpgacl/adodb/tests/test.php
new file mode 100644
index 0000000..92eba25
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test.php
@@ -0,0 +1,1704 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+error_reporting(E_ALL);
+
+$ADODB_FLUSH = true;
+
+define('ADODB_ASSOC_CASE',0);
+
+
+function getmicrotime()
+{
+ $t = microtime();
+ $t = explode(' ',$t);
+ return (float)$t[1]+ (float)$t[0];
+}
+
+
+if (PHP_VERSION < 5) include_once('../adodb-pear.inc.php');
+//--------------------------------------------------------------------------------------
+//define('ADODB_ASSOC_CASE',1);
+//
+function Err($msg)
+{
+ print "<b>$msg</b><br>";
+ flush();
+}
+
+function CheckWS($conn)
+{
+global $ADODB_EXTENSION;
+
+ include_once('../session/adodb-session.php');
+ if (defined('CHECKWSFAIL')){ echo " TESTING $conn ";flush();}
+ $saved = $ADODB_EXTENSION;
+ $db = ADONewConnection($conn);
+ $ADODB_EXTENSION = $saved;
+ if (headers_sent()) {
+ print "<p><b>White space detected in adodb-$conn.inc.php or include file...</b></p>";
+ //die();
+ }
+}
+
+function do_strtolower(&$arr)
+{
+ foreach($arr as $k => $v) {
+ if (is_object($v)) $arr[$k] = adodb_pr($v,true);
+ else $arr[$k] = strtolower($v);
+ }
+}
+
+
+function CountExecs($db, $sql, $inputarray)
+{
+global $EXECS; $EXECS++;
+}
+
+function CountCachedExecs($db, $secs2cache, $sql, $inputarray)
+{
+global $CACHED; $CACHED++;
+}
+
+// the table creation code is specific to the database, so we allow the user
+// to define their own table creation stuff
+
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
+{
+GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE,$ADODB_COUNTRECS;
+
+?> <form method=GET>
+ </p>
+ <table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
+ </p>
+<?php
+ $create =false;
+ /*$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ $rs = $db->Execute('select lastname,firstname,lastname,id from adoxyz');
+ $arr = $rs->GetAssoc();
+ echo "<pre>";print_r($arr);
+ die();*/
+
+ GLOBAL $EXECS, $CACHED;
+
+ $EXECS = 0;
+ $CACHED = 0;
+ //$db->Execute("drop table adodb_logsql");
+ if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql");
+ $db->debug=1;
+
+ $db->fnExecute = 'CountExecs';
+ $db->fnCacheExecute = 'CountCachedExecs';
+
+ if (empty($_GET['nolog'])) {
+ echo "<h3>SQL Logging enabled</h3>";
+ $db->LogSQL();/*
+ $sql =
+"SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant,
+t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage,
+t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm
+FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4`
+ WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic)
+ AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0'))
+ ORDER BY t1.time DESC";
+ $db->SelectLimit($sql);
+ echo $db->ErrorMsg();*/
+ }
+ $ADODB_CACHE_DIR = dirname(TempNam('/tmp','testadodb'));
+ $db->debug = false;
+ //print $db->UnixTimeStamp('2003-7-22 23:00:00');
+
+ $phpv = phpversion();
+ if (defined('ADODB_EXTENSION')) $ext = ' &nbsp; Extension '.ADODB_EXTENSION.' installed';
+ else $ext = '';
+ print "<h3>ADODB Version: $ADODB_vers Host: <i>$db->host</i> &nbsp; Database: <i>$db->database</i> &nbsp; PHP: $phpv $ext</h3>";
+ flush();
+
+
+ $arr = $db->ServerInfo();
+ print_r($arr);
+ echo "<br>";
+ $e = error_reporting(E_ALL-E_WARNING);
+ flush();
+
+ $tt = $db->Time();
+ if ($tt == 0) echo '<br><b>$db->Time failed</b>';
+ else echo "<br>db->Time: ".date('d-m-Y H:i:s',$tt);
+ echo '<br>';
+
+ echo "Date=",$db->UserDate('2002-04-07'),'<br>';
+ print "<i>date1</i> (1969-02-20) = ".$db->DBDate('1969-2-20');
+ print "<br><i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20');
+ print "<br><i>date1.1</i> 1999 = ".$db->DBDate("'1999'");
+ print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>";
+ print "<i>ts1</i> (1999-02-20 13:40:50) = ".$db->DBTimeStamp('1999-2-20 1:40:50 pm');
+ print "<br><i>ts1.1</i> (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40');
+ print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20');
+ print "<br><i>ts3</i> (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);
+ print "<br> Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
+ $dd = $db->UnixDate('1999-02-20');
+ print "<br>unixdate</i> 1999-02-20 = ".date('Y-m-d',$dd)."<p>";
+ print "<br><i>ts4</i> =".($db->UnixTimeStamp("19700101000101")+8*3600);
+ print "<br><i>ts5</i> =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
+ print "<br><i>ts6</i> =".$db->UserTimeStamp("20040110092123");
+ print "<br><i>ts7</i> =".$db->DBTimeStamp("20040110092123");
+ flush();
+ // mssql too slow in failing bad connection
+ if (false && $db->databaseType != 'mssql') {
+ print "<p>Testing bad connection. Ignore following error msgs:<br>";
+ $db2 = ADONewConnection();
+ $rez = $db2->Connect("bad connection");
+ $err = $db2->ErrorMsg();
+ print "<i>Error='$err'</i></p>";
+ if ($rez) print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
+ }
+ error_reporting($e);
+ flush();
+
+ //$ADODB_COUNTRECS=false;
+ $rs=$db->Execute('select * from adoxyz order by id');
+ if($rs === false) $create = true;
+ else $rs->Close();
+
+ //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
+
+ if ($create) {
+ if (false && $db->databaseType == 'ibase') {
+ print "<b>Please create the following table for testing:</b></p>$createtab</p>";
+ return;
+ } else {
+ $db->debug = 99;
+ $e = error_reporting(E_ALL-E_WARNING);
+ $db->Execute($createtab);
+ error_reporting($e);
+ }
+ }
+
+ echo "<p>Testing Metatypes</p>";
+ $t = $db->MetaType('varchar');
+ if ($t != 'C') Err("Bad Metatype for varchar");
+
+ $rs = &$db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete
+ if ($rs) {
+ if(! $rs->EOF) print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
+ $rs->Close();
+ } else print "err=".$db->ErrorMsg();
+
+ print "<p>Test select on empty table, FetchField when EOF, and GetInsertSQL</p>";
+ $rs = &$db->Execute("select id,firstname from ADOXYZ where id=9999");
+ if ($rs && !$rs->EOF) print "<b>Error: </b>RecordSet returned by Execute(select...') on empty table should show EOF</p>";
+ if ($rs->EOF && (($ox = $rs->FetchField(0)) && !empty($ox->name))) {
+ $record['id'] = 99;
+ $record['firstname'] = 'John';
+ $sql = $db->GetInsertSQL($rs, $record);
+ if (strtoupper($sql) != strtoupper("INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )")) Err("GetInsertSQL does not work on empty table: $sql");
+ } else {
+ Err("FetchField does not work on empty recordset, meaning GetInsertSQL will fail...");
+ }
+ if ($rs) $rs->Close();
+ flush();
+ //$db->debug=true;
+ print "<p>Testing Commit: ";
+ $time = $db->DBDate(time());
+ if (!$db->BeginTrans()) {
+ print '<b>Transactions not supported</b></p>';
+ if ($db->hasTransactions) Err("hasTransactions should be false");
+ } else { /* COMMIT */
+ if (!$db->hasTransactions) Err("hasTransactions should be true");
+ if ($db->transCnt != 1) Err("Invalid transCnt = $db->transCnt (should be 1)");
+ $rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)");
+ if ($rs && $db->CommitTrans()) {
+ $rs->Close();
+ $rs = &$db->Execute("select * from ADOXYZ where id=99");
+ if ($rs === false || $rs->EOF) {
+ print '<b>Data not saved</b></p>';
+ $rs = &$db->Execute("select * from ADOXYZ where id=99");
+ print_r($rs);
+ die();
+ } else print 'OK</p>';
+ if ($rs) $rs->Close();
+ } else {
+ if (!$rs) {
+ print "<b>Insert failed</b></p>";
+ $db->RollbackTrans();
+ } else print "<b>Commit failed</b></p>";
+ }
+ if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)");
+
+ /* ROLLBACK */
+ if (!$db->BeginTrans()) print "<p><b>Error in BeginTrans</b>()</p>";
+ print "<p>Testing Rollback: ";
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)");
+ if ($db->RollbackTrans()) {
+ $rs = $db->Execute("select * from ADOXYZ where id=100");
+ if ($rs && !$rs->EOF) print '<b>Fail: Data should rollback</b></p>';
+ else print 'OK</p>';
+ if ($rs) $rs->Close();
+ } else
+ print "<b>Commit failed</b></p>";
+
+ $rs = &$db->Execute('delete from ADOXYZ where id>50');
+ if ($rs) $rs->Close();
+
+ if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)");
+ }
+
+ if (1) {
+ print "<p>Testing MetaDatabases()</p>";
+ print_r( $db->MetaDatabases());
+
+ print "<p>Testing MetaTables() and MetaColumns()</p>";
+ $a = $db->MetaTables();
+ if ($a===false) print "<b>MetaTables not supported</b></p>";
+ else {
+ print "Array of tables and views: ";
+ foreach($a as $v) print " ($v) ";
+ print '</p>';
+ }
+
+ $a = $db->MetaTables('VIEW');
+ if ($a===false) print "<b>MetaTables not supported (views)</b></p>";
+ else {
+ print "Array of views: ";
+ foreach($a as $v) print " ($v) ";
+ print '</p>';
+ }
+
+ $a = $db->MetaTables(false,false,'aDo%');
+ if ($a===false) print "<b>MetaTables not supported (mask)</b></p>";
+ else {
+ print "Array of ado%: ";
+ foreach($a as $v) print " ($v) ";
+ print '</p>';
+ }
+
+ $a = $db->MetaTables('TABLE');
+ if ($a===false) print "<b>MetaTables not supported</b></p>";
+ else {
+ print "Array of tables: ";
+ foreach($a as $v) print " ($v) ";
+ print '</p>';
+ }
+
+ $db->debug=0;
+ $rez = $db->MetaColumns("NOSUCHTABLEHERE");
+ if ($rez !== false) {
+ Err("MetaColumns error handling failed");
+ var_dump($rez);
+ }
+ $db->debug=1;
+ $a = $db->MetaColumns('ADOXYZ');
+ if ($a===false) print "<b>MetaColumns not supported</b></p>";
+ else {
+ print "<p>Columns of ADOXYZ: <font size=1><br>";
+ foreach($a as $v) {print_r($v); echo "<br>";}
+ echo "</font>";
+ }
+
+ print "<p>Testing MetaIndexes</p>";
+
+ $a = $db->MetaIndexes(('ADOXYZ'),true);
+ if ($a===false) print "<b>MetaIndexes not supported</b></p>";
+ else {
+ print "<p>Indexes of ADOXYZ: <font size=1><br>";
+ adodb_pr($a);
+ echo "</font>";
+ }
+ print "<p>Testing MetaPrimaryKeys</p>";
+ $a = $db->MetaPrimaryKeys('ADOXYZ');
+ var_dump($a);
+ }
+ $rs = &$db->Execute('delete from ADOXYZ');
+ if ($rs) $rs->Close();
+
+ $db->debug = false;
+
+
+ switch ($db->databaseType) {
+ case 'vfp':
+
+ if (0) {
+ // memo test
+ $rs = $db->Execute("select data from memo");
+ rs2html($rs);
+ }
+ break;
+
+ case 'postgres7':
+ case 'postgres64':
+ case 'postgres':
+ case 'ibase':
+ print "<p>Encode=".$db->BlobEncode("abc\0d\"'
+ef")."</p>";//'
+
+ print "<p>Testing Foreign Keys</p>";
+ $arr = $db->MetaForeignKeys('adoxyz',false,true);
+ print_r($arr);
+ if (!$arr) Err("Bad MetaForeignKeys");
+ break;
+
+ case 'odbc_mssql':
+ case 'mssqlpo':
+ print "<p>Testing Foreign Keys</p>";
+ $arr = $db->MetaForeignKeys('Orders',false,true);
+ print_r($arr);
+ if (!$arr) Err("Bad MetaForeignKeys");
+ if ($db->databaseType == 'odbc_mssql') break;
+
+ case 'mssql':
+
+
+/*
+ASSUME Northwind available...
+
+CREATE PROCEDURE SalesByCategory
+ @CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998'
+AS
+IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998'
+BEGIN
+ SELECT @OrdYear = '1998'
+END
+
+SELECT ProductName,
+ TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0)
+FROM [Order Details] OD, Orders O, Products P, Categories C
+WHERE OD.OrderID = O.OrderID
+ AND OD.ProductID = P.ProductID
+ AND P.CategoryID = C.CategoryID
+ AND C.CategoryName = @CategoryName
+ AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear
+GROUP BY ProductName
+ORDER BY ProductName
+GO
+
+
+CREATE PROCEDURE ADODBTestSP
+@a nvarchar(25)
+AS
+SELECT GETDATE() AS T, @a AS A
+GO
+*/
+ print "<h4>Testing Stored Procedures for mssql</h4>";
+ $saved = $db->debug;
+ $db->debug=true;
+
+ $cmd = $db->PrepareSP('ADODBTestSP');
+ $ss = "You should see me in the output.";
+ $db->InParameter($cmd,$ss,'a');
+ $rs = $db->Execute($cmd);
+ echo $rs->fields['T']." --- ".$rs->fields['A']."---<br>";
+
+ $cat = 'Dairy Products';
+ $yr = '1998';
+
+ $stmt = $db->PrepareSP('SalesByCategory');
+ $db->InParameter($stmt,$cat,'CategoryName');
+ $db->InParameter($stmt,$yr,'OrdYear');
+ $rs = $db->Execute($stmt);
+ rs2html($rs);
+
+ $cat = 'Grains/Cereals';
+ $yr = 1998;
+
+ $stmt = $db->PrepareSP('SalesByCategory');
+ $db->InParameter($stmt,$cat,'CategoryName');
+ $db->InParameter($stmt,$yr,'OrdYear');
+ $rs = $db->Execute($stmt);
+ rs2html($rs);
+
+ /*
+ Test out params - works in PHP 4.2.3 and 4.3.3 and 4.3.8 but not 4.3.0:
+
+ CREATE PROCEDURE at_date_interval
+ @days INTEGER,
+ @start VARCHAR(20) OUT,
+ @end VARCHAR(20) OUT
+ AS
+ BEGIN
+ set @start = CONVERT(VARCHAR(20), getdate(), 101)
+ set @end =CONVERT(VARCHAR(20), dateadd(day, @days, getdate()), 101 )
+ END
+ GO
+ */
+ $db->debug=1;
+ $stmt = $db->PrepareSP('at_date_interval');
+ $days = 10;
+ $begin_date = '';
+ $end_date = '';
+ $db->InParameter($stmt,$days,'days', 4, SQLINT4);
+ $db->OutParameter($stmt,$begin_date,'start', 20, SQLVARCHAR );
+ $db->OutParameter($stmt,$end_date,'end', 20, SQLVARCHAR );
+ $db->Execute($stmt);
+ if (empty($begin_date) or empty($end_date) or $begin_date == $end_date) {
+ Err("MSSQL SP Test for OUT Failed");
+ print "begin=$begin_date end=$end_date<p>";
+ } else print "(Today +10days) = (begin=$begin_date end=$end_date)<p>";
+
+ $db->debug = $saved;
+ break;
+ case 'oci8':
+ case 'oci8po':
+
+ if (0) {
+ $t = getmicrotime();
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $arr = $db->GetArray('select * from abalone_tree');
+ $arr = $db->GetArray('select * from abalone_tree');
+ $arr = $db->GetArray('select * from abalone_tree');
+ echo "<p>t = ",getmicrotime() - $t,"</p>";
+ die();
+ }
+
+ # cleanup
+ $db->Execute("delete from photos where id=99 or id=1");
+ $db->Execute("insert into photos (id) values(1)");
+ $db->Execute("update photos set photo=null,descclob=null where id=1");
+
+ $saved = $db->debug;
+ $db->debug=true;
+
+
+
+ /*
+ CREATE TABLE PHOTOS
+ (
+ ID NUMBER(16),
+ PHOTO BLOB,
+ DESCRIPTION VARCHAR2(4000 BYTE),
+ DESCCLOB CLOB
+ );
+
+ INSERT INTO PHOTOS (ID) VALUES(1);
+ */
+ $s = '';
+ for ($i = 0; $i <= 500; $i++) {
+ $s .= '1234567890';
+ }
+
+ $sql = "INSERT INTO photos ( ID, photo) ".
+ "VALUES ( :id, empty_blob() )".
+ " RETURNING photo INTO :xx";
+
+
+ $blob_data = $s;
+ $id = 99;
+
+ $stmt = $db->PrepareSP($sql);
+ $db->InParameter($stmt, $id, 'id');
+ $blob = $db->InParameter($stmt, $s, 'xx',-1, OCI_B_BLOB);
+ $db->StartTrans();
+ $result = $db->Execute($stmt);
+ $db->CompleteTrans();
+
+ $s2= $db->GetOne("select photo from photos where id=99");
+ echo "<br>---$s2";
+ if ($s !== $s2) Err("insert blob does not match");
+
+ print "<h4>Testing Blob: size=".strlen($s)."</h4>";
+ $ok = $db->Updateblob('photos','photo',$s,'id=1');
+ if (!$ok) Err("Blob failed 1");
+ else {
+ $s2= $db->GetOne("select photo from photos where id=1");
+ if ($s !== $s2) Err("updateblob does not match");
+ }
+
+ print "<h4>Testing Clob: size=".strlen($s)."</h4>";
+ $ok = $db->UpdateClob('photos','descclob',$s,'id=1');
+ if (!$ok) Err("Clob failed 1");
+ else {
+ $s2= $db->GetOne("select descclob from photos where id=1");
+ if ($s !== $s2) Err("updateclob does not match");
+ }
+
+
+ $s = '';
+ $s2 = '';
+ print "<h4>Testing Foreign Keys</h4>";
+ $arr = $db->MetaForeignKeys('emp','scott');
+ print_r($arr);
+ if (!$arr) Err("Bad MetaForeignKeys");
+/*
+-- TEST PACKAGE
+-- "Set scan off" turns off substitution variables.
+Set scan off;
+
+CREATE OR REPLACE PACKAGE Adodb AS
+TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE;
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR);
+PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ;
+PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR);
+PROCEDURE data_in(input IN VARCHAR);
+PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER);
+END Adodb;
+/
+
+
+CREATE OR REPLACE PACKAGE BODY Adodb AS
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS
+ BEGIN
+ OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
+ END open_tab;
+
+ PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS
+ BEGIN
+ OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames;
+ tablenames := 'TEST';
+ END open_tab2;
+
+PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS
+ BEGIN
+ output := 'Cinta Hati '||input;
+ END;
+
+PROCEDURE data_in(input IN VARCHAR) IS
+ ignore varchar(1000);
+ BEGIN
+ ignore := input;
+ END;
+
+PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS
+BEGIN
+p2 := p1;
+END;
+END Adodb;
+/
+
+*/
+
+ print "<h4>Testing Cursor Variables</h4>";
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz');
+
+ if ($rs && !$rs->EOF) {
+ $v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'");
+ if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK<p>";
+ else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v");
+ } else {
+ print "<b>Error in using Cursor Variables 1</b><p>";
+ }
+ $rs->Close();
+
+ print "<h4>Testing Stored Procedures for oci8</h4>";
+
+ $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;");
+ $a1 = 'Malaysia';
+ //$a2 = ''; # a2 doesn't even need to be defined!
+ $db->InParameter($stmt,$a1,'a1');
+ $db->OutParameter($stmt,$a2,'a2');
+ $rs = $db->Execute($stmt);
+ if ($rs) {
+ if ($a2 !== 'Cinta Hati Malaysia') print "<b>Stored Procedure Error: a2 = $a2</b><p>";
+ else echo "OK: a2=$a2<p>";
+ } else {
+ print "<b>Error in using Stored Procedure IN/Out Variables</b><p>";
+ }
+
+ $tname = 'A%';
+
+ $stmt = $db->PrepareSP('select * from tab where tname like :tablename');
+ $db->Parameter($stmt,$tname,'tablename');
+ $rs = $db->Execute($stmt);
+ rs2html($rs);
+
+ $stmt = $db->PrepareSP("begin adodb.data_in(:a1); end;");
+ $db->InParameter($stmt,$a1,'a1');
+ $db->Execute($stmt);
+
+ $db->debug = $saved;
+ break;
+
+ default:
+ break;
+ }
+ $arr = array(
+ array(1,'Caroline','Miranda'),
+ array(2,'John','Lim'),
+ array(3,'Wai Hun','See')
+ );
+ //$db->debug=1;
+ print "<p>Testing Bulk Insert of 3 rows</p>";
+
+ $sql = "insert into ADOXYZ (id,firstname,lastname) values (".$db->Param('0').",".$db->Param('1').",".$db->Param('2').")";
+ $db->StartTrans();
+ $db->Execute($sql,$arr);
+ $db->CompleteTrans();
+ $rs = $db->Execute('select * from ADOXYZ order by id');
+ if (!$rs || $rs->RecordCount() != 3) Err("Bad bulk insert");
+
+ rs2html($rs);
+
+ $db->Execute('delete from ADOXYZ');
+
+ print "<p>Inserting 50 rows</p>";
+
+ for ($i = 0; $i < 5; $i++) {
+
+ $time = $db->DBDate(time());
+ if (empty($_GET['hide'])) $db->debug = true;
+ switch($db->databaseType){
+ case 'mssqlpo':
+ case 'mssql':
+ $sqlt = "CREATE TABLE mytable (
+ row1 INT IDENTITY(1,1) NOT NULL,
+ row2 varchar(16),
+ PRIMARY KEY (row1))";
+ //$db->debug=1;
+ if (!$db->Execute("delete from mytable"))
+ $db->Execute($sqlt);
+
+ $ok = $db->Execute("insert into mytable (row2) values ('test')");
+ $ins_id=$db->Insert_ID();
+ echo "Insert ID=";var_dump($ins_id);
+ if ($ins_id == 0) Err("Bad Insert_ID()");
+ $ins_id2 = $db->GetOne("select row1 from mytable");
+ if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2");
+
+ $arr = array(0=>'Caroline',1=>'Miranda');
+ $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)";
+ break;
+ case 'mysqli':
+ case 'mysqlt':
+ case 'mysql':
+ $sqlt = "CREATE TABLE `mytable` (
+ `row1` int(11) NOT NULL auto_increment,
+ `row2` varchar(16) NOT NULL default '',
+ PRIMARY KEY (`row1`),
+ KEY `myindex` (`row1`,`row2`)
+) ";
+ if (!$db->Execute("delete from mytable"))
+ $db->Execute($sqlt);
+
+ $ok = $db->Execute("insert into mytable (row2) values ('test')");
+ $ins_id=$db->Insert_ID();
+ echo "Insert ID=";var_dump($ins_id);
+ if ($ins_id == 0) Err("Bad Insert_ID()");
+ $ins_id2 = $db->GetOne("select row1 from mytable");
+ if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2");
+
+ default:
+ $arr = array(0=>'Caroline',1=>'Miranda');
+ $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)";
+ break;
+
+ case 'oci8':
+ case 'oci805':
+ $arr = array('first'=>'Caroline','last'=>'Miranda');
+ $amt = rand() % 100;
+ $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,:first,:last,$time)";
+ break;
+ }
+ if ($i & 1) {
+ $sql = $db->Prepare($sql);
+ }
+ $rs = $db->Execute($sql,$arr);
+
+ if ($rs === false) Err( 'Error inserting with parameters');
+ else $rs->Close();
+ $db->debug = false;
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+1,'John','Lim',$time)");
+ /*$ins_id=$db->Insert_ID();
+ echo "Insert ID=";var_dump($ins_id);*/
+ if ($db->databaseType == 'mysql') if ($ins_id == 0) Err('Bad Insert_ID');
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+2,'Mary','Lamb',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+3,'George','Washington',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+4,'Mr. Alan','Tam',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+5,'Alan',".$db->quote("Turing'ton").",$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created)values ($i*10+6,'Serena','Williams',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+7,'Yat Sun','Sun',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+8,'Wai Hun','See',$time )");
+ $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+9,'Steven','Oey',$time )");
+ } // for
+ if (1) {
+ $db->debug=1;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $cnt = $db->GetOne("select count(*) from ADOXYZ");
+ $rs = $db->Execute('update ADOXYZ set id=id+1');
+ if (!is_object($rs)) {
+ print_r($rs);
+ err("Update should return object");
+ }
+ if (!$rs) err("Update generated error");
+
+ $nrows = $db->Affected_Rows();
+ if ($nrows === false) print "<p><b>Affected_Rows() not supported</b></p>";
+ else if ($nrows != $cnt) print "<p><b>Affected_Rows() Error: $nrows returned (should be 50) </b></p>";
+ else print "<p>Affected_Rows() passed</p>";
+ }
+
+ /*if ($db->dataProvider == 'oci8') */ $array = array('zid'=>1,'zdate'=>date('Y-m-d',time()));
+ /*else $array=array(1,date('Y-m-d',time()));*/
+
+ $id = $db->GetOne("select id from ADOXYZ
+ where id=".$db->Param('zid')." and created>=".$db->Param('ZDATE')."",
+ $array);
+ if ($id != 1) Err("Bad bind; id=$id");
+ else echo "<br>Bind date/integer passed";
+
+ $db->debug = false;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ //////////////////////////////////////////////////////////////////////////////////////////
+
+ $rs = $db->Execute("select * from ADOXYZ where firstname = 'not known'");
+ if (!$rs || !$rs->EOF) print "<p><b>Error on empty recordset</b></p>";
+ else if ($rs->RecordCount() != 0) {
+ print "<p><b>Error on RecordCount. Should be 0. Was ".$rs->RecordCount()."</b></p>";
+ print_r($rs->fields);
+ }
+ if ($db->databaseType !== 'odbc') {
+ $rs = &$db->Execute("select id,firstname,lastname,created,".$db->random." from ADOXYZ order by id");
+ if ($rs) {
+ if ($rs->RecordCount() != 50) {
+ print "<p><b>RecordCount returns ".$rs->RecordCount().", should be 50</b></p>";
+ adodb_pr($rs->GetArray());
+ $poc = $rs->PO_RecordCount('ADOXYZ');
+ if ($poc == 50) print "<p> &nbsp; &nbsp; PO_RecordCount passed</p>";
+ else print "<p><b>PO_RecordCount returns wrong value: $poc</b></p>";
+ } else print "<p>RecordCount() passed</p>";
+ if (isset($rs->fields['firstname'])) print '<p>The fields columns can be indexed by column name.</p>';
+ else {
+ Err( '<p>The fields columns <i>cannot</i> be indexed by column name.</p>');
+ print_r($rs->fields);
+ }
+ if (empty($_GET['hide'])) rs2html($rs);
+ }
+ else print "<p><b>Error in Execute of SELECT with random</b></p>";
+ }
+ $val = $db->GetOne("select count(*) from ADOXYZ");
+ if ($val == 50) print "<p>GetOne returns ok</p>";
+ else print "<p><b>Fail: GetOne returns $val</b></p>";
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $val = $db->GetRow("select count(*) from ADOXYZ");
+ if ($val[0] == 50 and sizeof($val) == 1) print "<p>GetRow returns ok</p>";
+ else {
+ print_r($val);
+ print "<p><b>Fail: GetRow returns {$val[0]}</b></p>";
+ }
+
+ print "<p>FetchObject/FetchNextObject Test</p>";
+ $rs = $db->Execute('select * from ADOXYZ');
+ if ($rs) {
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
+
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally
+ if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {
+ print_r($o);
+ print "<p><b>Firstname is not string</b></p>";
+ break;
+ }
+ }
+ } else {
+ print "<p><b>Failed rs</b></p>";
+ die("<p>ADOXYZ table cannot be read - die()");
+ }
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ print "<p>FetchObject/FetchNextObject Test 2</p>";
+ #$db->debug=99;
+ $rs = $db->Execute('select * from ADOXYZ');
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
+ print_r($rs->fields);
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally
+ if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {
+ print_r($o);
+ print "<p><b>Firstname is not string</b></p>";
+ break;
+ }
+ }
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ $savefetch = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+
+ print "<p>CacheSelectLimit Test</p>";
+ $db->debug=1;
+ $rs = $db->CacheSelectLimit(' select id, firstname from ADOXYZ order by id',2);
+
+ if ($rs && !$rs->EOF) {
+ if (isset($rs->fields[0])) {
+ Err("ASSOC has numeric fields");
+ print_r($rs->fields);
+ }
+ if ($rs->fields['id'] != 1) {Err("Error"); print_r($rs->fields);};
+ if (trim($rs->fields['firstname']) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);};
+
+ $rs->MoveNext();
+ if ($rs->fields['id'] != 2) {Err("Error 3"); print_r($rs->fields);};
+ $rs->MoveNext();
+ if (!$rs->EOF) {
+ Err("Error EOF");
+ print_r($rs);
+ }
+ }
+
+ print "<p>FETCH_MODE = ASSOC: Should get 1, Caroline</p>";
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',2);
+ if ($rs && !$rs->EOF) {
+ if (ADODB_ASSOC_CASE == 2) {
+ $id = 'ID';
+ $fname = 'FIRSTNAME';
+ }else {
+ $id = 'id';
+ $fname = 'firstname';
+ }
+ if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);};
+ if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);};
+ $rs->MoveNext();
+ if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);};
+ $rs->MoveNext();
+ if (!$rs->EOF) Err("Error EOF");
+ else if (is_array($rs->fields) || $rs->fields) {
+ Err("Error: ## fields should be set to false on EOF");
+ print_r($rs->fields);
+ }
+ }
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ print "<p>FETCH_MODE = NUM: Should get 1, Caroline</p>";
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);
+ if ($rs && !$rs->EOF) {
+ if (isset($rs->fields['id'])) Err("FETCH_NUM has ASSOC fields");
+ if ($rs->fields[0] != 1) {Err("Error 1"); print_r($rs->fields);};
+ if (trim($rs->fields[1]) != 'Caroline') {Err("Error 2");print_r($rs->fields);};
+ $rs->MoveNext();
+ if (!$rs->EOF) Err("Error EOF");
+
+ }
+ $ADODB_FETCH_MODE = $savefetch;
+
+ $db->debug = false;
+ print "<p>GetRowAssoc Upper: Should get 1, Caroline</p>";
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);
+ if ($rs && !$rs->EOF) {
+ $arr = &$rs->GetRowAssoc();
+ if ($arr['ID'] != 1) {Err("Error 1");print_r($arr);};
+ if (trim($arr['FIRSTNAME']) != 'Caroline') {Err("Error 2"); print_r($arr);};
+ $rs->MoveNext();
+ if (!$rs->EOF) Err("Error EOF");
+
+ }
+ print "<p>GetRowAssoc Lower: Should get 1, Caroline</p>";
+ $rs = &$db->SelectLimit('select id,firstname from ADOXYZ order by id',1);
+ if ($rs && !$rs->EOF) {
+ $arr = &$rs->GetRowAssoc(false);
+ if ($arr['id'] != 1) {Err("Error 1"); print_r($arr);};
+ if (trim($arr['firstname']) != 'Caroline') {Err("Error 2"); print_r($arr);};
+
+ }
+
+ print "<p>GetCol Test</p>";
+ $col = $db->GetCol('select distinct firstname from adoxyz order by 1');
+ if (!is_array($col)) Err("Col size is wrong");
+ if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong");
+
+ $db->debug = true;
+
+
+ echo "<p>Date Update Test</p>";
+ $zdate = date('Y-m-d',time()+3600*24);
+ $zdate = $db->DBDate($zdate);
+ $db->Execute("update ADOXYZ set created=$zdate where id=1");
+ $row = $db->GetRow("select created,firstname from ADOXYZ where id=1");
+ print_r($row); echo "<br>";
+
+
+
+ print "<p>SelectLimit Distinct Test 1: Should see Caroline, John and Mary</p>";
+ $rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
+
+
+ if ($rs && !$rs->EOF) {
+ if (trim($rs->fields[1]) != 'Caroline') Err("Error 1 (exp Caroline), ".$rs->fields[1]);
+ $rs->MoveNext();
+
+ if (trim($rs->fields[1]) != 'John') Err("Error 2 (exp John), ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (trim($rs->fields[1]) != 'Mary') Err("Error 3 (exp Mary),".$rs->fields[1]);
+ $rs->MoveNext();
+ if (! $rs->EOF) Err("Error EOF");
+ //rs2html($rs);
+ } else Err("Failed SelectLimit Test 1");
+
+ print "<p>SelectLimit Test 2: Should see Mary, George and Mr. Alan</p>";
+ $rs = &$db->SelectLimit('select * from ADOXYZ order by id',3,2);
+ if ($rs && !$rs->EOF) {
+ if (trim($rs->fields[1]) != 'Mary') Err("Error 1 - No Mary, instead: ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (trim($rs->fields[1]) != 'George')Err("Error 2 - No George, instead: ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (trim($rs->fields[1]) != 'Mr. Alan') Err("Error 3 - No Mr. Alan, instead: ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (! $rs->EOF) Err("Error EOF");
+ // rs2html($rs);
+ }
+ else Err("Failed SelectLimit Test 2 ". ($rs ? 'EOF':'no RS'));
+
+ print "<p>SelectLimit Test 3: Should see Wai Hun and Steven</p>";
+ $db->debug=1;
+ global $A; $A=1;
+ $rs = &$db->SelectLimit('select * from ADOXYZ order by id',-1,48);
+ $A=0;
+ if ($rs && !$rs->EOF) {
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
+ if (trim($rs->fields[1]) != 'Wai Hun') Err("Error 1 ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (trim($rs->fields[1]) != 'Steven') Err("Error 2 ".$rs->fields[1]);
+ $rs->MoveNext();
+ if (! $rs->EOF) {
+ Err("Error EOF");
+ }
+ //rs2html($rs);
+ }
+ else Err("Failed SelectLimit Test 3");
+ $db->debug = false;
+
+
+ $rs = &$db->Execute("select * from ADOXYZ order by id");
+ print "<p>Testing Move()</p>";
+ if (!$rs)Err( "Failed Move SELECT");
+ else {
+ if (!$rs->Move(2)) {
+ if (!$rs->canSeek) print "<p>$db->databaseType: <b>Move(), MoveFirst() nor MoveLast() not supported.</b></p>";
+ else print '<p><b>RecordSet->canSeek property should be set to false</b></p>';
+ } else {
+ $rs->MoveFirst();
+ if (trim($rs->Fields("firstname")) != 'Caroline') {
+ print "<p><b>$db->databaseType: MoveFirst failed -- probably cannot scroll backwards</b></p>";
+ }
+ else print "MoveFirst() OK<BR>";
+
+ // Move(3) tests error handling -- MoveFirst should not move cursor
+ $rs->Move(3);
+ if (trim($rs->Fields("firstname")) != 'George') {
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(3) failed</b></p>";
+ } else print "Move(3) OK<BR>";
+
+ $rs->Move(7);
+ if (trim($rs->Fields("firstname")) != 'Yat Sun') {
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(7) failed</b></p>";
+ print_r($rs);
+ } else print "Move(7) OK<BR>";
+ if ($rs->EOF) Err("Move(7) is EOF already");
+ $rs->MoveLast();
+ if (trim($rs->Fields("firstname")) != 'Steven'){
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: MoveLast() failed</b></p>";
+ print_r($rs);
+ }else print "MoveLast() OK<BR>";
+ $rs->MoveNext();
+ if (!$rs->EOF) err("Bad MoveNext");
+ if ($rs->canSeek) {
+ $rs->Move(3);
+ if (trim($rs->Fields("firstname")) != 'George') {
+ print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(3) after MoveLast failed</b></p>";
+
+ } else print "Move(3) after MoveLast() OK<BR>";
+ }
+
+ print "<p>Empty Move Test";
+ $rs = $db->Execute("select * from ADOXYZ where id > 0 and id < 0");
+ $rs->MoveFirst();
+ if (!$rs->EOF || $rs->fields) Err("Error in empty move first");
+ }
+ }
+
+ $rs = $db->Execute('select * from ADOXYZ where id = 2');
+ if ($rs->EOF || !is_array($rs->fields)) Err("Error in select");
+ $rs->MoveNext();
+ if (!$rs->EOF) Err("Error in EOF (xx) ");
+ // $db->debug=true;
+ print "<p>Testing ADODB_FETCH_ASSOC and concat: concat firstname and lastname</p>";
+
+ $save = $ADODB_FETCH_MODE;
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ if ($db->dataProvider == 'postgres') {
+ $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
+ $rs = &$db->Execute($sql);
+ } else {
+ $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ";
+ $rs = &$db->Execute($sql);
+ }
+ if ($rs) {
+ if (empty($_GET['hide'])) rs2html($rs);
+ } else {
+ Err( "Failed Concat:".$sql);
+ }
+ $ADODB_FETCH_MODE = $save;
+ print "<hr>Testing GetArray() ";
+ //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+
+ $rs = &$db->Execute("select * from ADOXYZ order by id");
+ if ($rs) {
+ $arr = &$rs->GetArray(10);
+ if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]."<b> &nbsp; ERROR</b><br>";
+ else print " OK<BR>";
+ }
+
+ $arr = $db->GetArray("select x from ADOXYZ");
+ $e = $db->ErrorMsg(); $e2 = $db->ErrorNo();
+ echo "Testing error handling, should see illegal column 'x' error=<i>$e ($e2) </i><br>";
+ if (!$e || !$e2) Err("Error handling did not work");
+ print "Testing FetchNextObject for 1 object ";
+ $rs = &$db->Execute("select distinct lastname,firstname from ADOXYZ where firstname='Caroline'");
+ $fcnt = 0;
+ if ($rs)
+ while ($o = $rs->FetchNextObject()) {
+ $fcnt += 1;
+ }
+ if ($fcnt == 1) print " OK<BR>";
+ else print "<b>FAILED</b><BR>";
+
+ $stmt = $db->Prepare("select * from ADOXYZ where id < 3");
+ $rs = $db->Execute($stmt);
+ if (!$rs) Err("Prepare failed");
+ else {
+ $arr = $rs->GetArray();
+ if (!$arr) Err("Prepare failed 2");
+ if (sizeof($arr) != 2) Err("Prepare failed 3");
+ }
+ print "Testing GetAssoc() ";
+ $savecrecs = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+ //$arr = $db->GetArray("select lastname,firstname from ADOXYZ");
+ //print_r($arr);
+ print "<hr>";
+ $rs =& $db->Execute("select distinct lastname,firstname,created from ADOXYZ");
+
+ if ($rs) {
+ $arr = $rs->GetAssoc();
+ //print_r($arr);
+ if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']." &nbsp; <b>ERROR</b><br>";
+ else print " OK 1";
+ }
+
+ $arr = &$db->GetAssoc("select distinct lastname,firstname from ADOXYZ");
+ if ($arr) {
+ //print_r($arr);
+ if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']." &nbsp; <b>ERROR</b><br>";
+ else print " OK 2<BR>";
+ }
+ // Comment this out to test countrecs = false
+ $ADODB_COUNTRECS = $savecrecs;
+ $db->debug=1;
+ $query = $db->Prepare("select count(*) from ADOXYZ");
+ $rs = $db->CacheExecute(10,$query);
+ if (reset($rs->fields) != 50) echo Err("$cnt wrong for Prepare/CacheGetOne");
+
+ for ($loop=0; $loop < 1; $loop++) {
+ print "Testing GetMenu() and CacheExecute<BR>";
+ $db->debug = true;
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
+
+
+
+
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').'<BR>';
+ else print " Fail<BR>";
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
+
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).'<BR>';
+ else print " Fail<BR>";
+
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
+ if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).'<BR>';
+ else print " Fail<BR>";
+ print '</p><hr>';
+
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
+ if ($rs) {
+ print ' Multiple, Alan and George selected: '. $rs->GetMenu('menu',array('Alan','George'),false,true);
+ if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
+ } else print " Fail<BR>";
+ print '</p><hr>';
+
+ print "Testing GetMenu3()<br>";
+ $rs = $db->Execute("select ".$db->Concat('firstname',"'-'",'id').",id, lastname from ADOXYZ order by lastname,id");
+ print "Grouped Menu: ".$rs->GetMenu3('name');
+ print "<hr>";
+
+ print "Testing GetMenu2() <BR>";
+ $rs = &$db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ");
+ if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).'<BR>';
+ else print " Fail<BR>";
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).'<BR>';
+ else print " Fail<BR>";
+ }
+ echo "<h3>CacheEXecute</h3>";
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ print_r($rs->fields); echo $rs->fetchMode;echo "<br>";
+ echo $rs->Fields('firstname');
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = &$db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ");
+ print_r($rs->fields);echo "<br>";
+ echo $rs->Fields('firstname');
+ $db->debug = false;
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ // phplens
+
+ $sql = 'select * from ADOXYZ where 0=1';
+ echo "<p>**Testing '$sql' (phplens compat 1)</p>";
+ $rs = &$db->Execute($sql);
+ if (!$rs) err( "<b>No recordset returned for '$sql'</b>");
+ if (!$rs->FieldCount()) err( "<b>No fields returned for $sql</b>");
+ if (!$rs->FetchField(1)) err( "<b>FetchField failed for $sql</b>");
+
+ $sql = 'select * from ADOXYZ order by 1';
+ echo "<p>**Testing '$sql' (phplens compat 2)</p>";
+ $rs = &$db->Execute($sql);
+ if (!$rs) err( "<b>No recordset returned for '$sql'<br>".$db->ErrorMsg()."</b>");
+
+
+ $sql = 'select * from ADOXYZ order by 1,1';
+ echo "<p>**Testing '$sql' (phplens compat 3)</p>";
+ $rs = &$db->Execute($sql);
+ if (!$rs) err( "<b>No recordset returned for '$sql'<br>".$db->ErrorMsg()."</b>");
+
+
+ // Move
+ $rs1 = &$db->Execute("select id from ADOXYZ where id <= 2 order by 1");
+ $rs2 = &$db->Execute("select id from ADOXYZ where id = 3 or id = 4 order by 1");
+
+ if ($rs1) $rs1->MoveLast();
+ if ($rs2) $rs2->MoveLast();
+
+ if (empty($rs1) || empty($rs2) || $rs1->fields[0] != 2 || $rs2->fields[0] != 4) {
+ $a = $rs1->fields[0];
+ $b = $rs2->fields[0];
+ print "<p><b>Error in multiple recordset test rs1=$a rs2=$b (should be rs1=2 rs2=4)</b></p>";
+ } else
+ print "<p>Testing multiple recordsets OK</p>";
+
+
+ echo "<p> GenID test: ";
+ for ($i=1; $i <= 10; $i++)
+ echo "($i: ",$val = $db->GenID($db->databaseType.'abcseq6' ,5), ") ";
+ if ($val == 0) Err("GenID not supported");
+
+ if ($val) {
+ $db->DropSequence('abc_seq2');
+ $db->CreateSequence('abc_seq2');
+ $val = $db->GenID('abc_seq2');
+ $db->DropSequence('abc_seq2');
+ $db->CreateSequence('abc_seq2');
+ $val = $db->GenID('abc_seq2');
+ if ($val != 1) Err("Drop and Create Sequence not supported ($val)");
+ }
+ echo "<p>";
+
+ if (substr($db->dataProvider,0,3) != 'notused') { // used to crash ado
+ $sql = "select firstnames from adoxyz";
+ print "<p>Testing execution of illegal statement: <i>$sql</i></p>";
+ if ($db->Execute($sql) === false) {
+ print "<p>This returns the following ErrorMsg(): <i>".$db->ErrorMsg()."</i> and ErrorNo(): ".$db->ErrorNo().'</p>';
+ } else
+ print "<p><b>Error in error handling -- Execute() should return false</b></p>";
+ } else
+ print "<p><b>ADO skipped error handling of bad select statement</b></p>";
+
+ print "<p>ASSOC TEST 2<br>";
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = $db->query('select * from adoxyz order by id');
+ if ($ee = $db->ErrorMsg()) {
+ Err("Error message=$ee");
+ }
+ if ($ee = $db->ErrorNo()) {
+ Err("Error No = $ee");
+ }
+ print_r($rs->fields);
+ for($i=0;$i<$rs->FieldCount();$i++)
+ {
+ $fld=$rs->FetchField($i);
+ print "<br> Field name is ".$fld->name;
+ print " ".$rs->Fields($fld->name);
+ }
+
+
+ print "<p>BOTH TEST 2<br>";
+ if ($db->dataProvider == 'ado') {
+ print "<b>ADODB_FETCH_BOTH not supported</b> for dataProvider=".$db->dataProvider."<br>";
+ } else {
+ $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
+ $rs = $db->query('select * from adoxyz order by id');
+ for($i=0;$i<$rs->FieldCount();$i++)
+ {
+ $fld=$rs->FetchField($i);
+ print "<br> Field name is ".$fld->name;
+ print " ".$rs->Fields($fld->name);
+ }
+ }
+
+ print "<p>NUM TEST 2<br>";
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs = $db->query('select * from adoxyz order by id');
+ for($i=0;$i<$rs->FieldCount();$i++)
+ {
+ $fld=$rs->FetchField($i);
+ print "<br> Field name is ".$fld->name;
+ print " ".$rs->Fields($fld->name);
+ }
+
+ print "<p>ASSOC Test of SelectLimit<br>";
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = $db->selectlimit('select * from adoxyz order by id',3,4);
+ $cnt = 0;
+ while ($rs && !$rs->EOF) {
+ $cnt += 1;
+ if (!isset($rs->fields['firstname'])) {
+ print "<br><b>ASSOC returned numeric field</b></p>";
+ break;
+ }
+ $rs->MoveNext();
+ }
+ if ($cnt != 3) print "<br><b>Count should be 3, instead it was $cnt</b></p>";
+
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ if ($db->sysDate) {
+ $saved = $db->debug;
+ $db->debug = 1;
+ $rs = $db->Execute("select {$db->sysDate} from adoxyz where id=1");
+ if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) {
+ print "<p><b>Invalid date {$rs->fields[0]}</b></p>";
+ } else
+ print "<p>Passed \$sysDate test ({$rs->fields[0]})</p>";
+
+ print_r($rs->FetchField(0));
+ print time();
+ $db->debug=$saved;
+ } else {
+ print "<p><b>\$db->sysDate not defined</b></p>";
+ }
+
+ print "<p>Test CSV</p>";
+ include_once('../toexport.inc.php');
+ //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = $db->SelectLimit('select id,firstname,lastname,created,\'He, he\' he,\'"\' q from adoxyz',10);
+
+ print "<pre>";
+ print rs2csv($rs);
+ print "</pre>";
+
+ $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from adoxyz',10);
+
+ if (PHP_VERSION < 5) {
+ print "<pre>";
+ rs2tabout($rs);
+ print "</pre>";
+ }
+ //print " CacheFlush ";
+ //$db->CacheFlush();
+ $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A');
+ $sql = "SELECT $date from ADOXYZ";
+ print "<p>Test SQLDate: ".htmlspecialchars($sql)."</p>";
+ $rs = $db->SelectLimit($sql,1);
+ $d = date('d-m-M-Y-').'Q'.(ceil(date('m')/3.0)).date(' h:i:s A');
+ if (!$rs) Err("SQLDate query returned no recordset");
+ else if ($d != $rs->fields[0]) Err("SQLDate 1 failed expected: <br>act:$d <br>sql:".$rs->fields[0]);
+
+ $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A',$db->DBDate("1974-02-25"));
+ $sql = "SELECT $date from ADOXYZ";
+ print "<p>Test SQLDate: ".htmlspecialchars($sql)."</p>";
+ $rs = $db->SelectLimit($sql,1);
+ $ts = ADOConnection::UnixDate('1974-02-25');
+ $d = date('d-m-M-Y-',$ts).'Q'.(ceil(date('m',$ts)/3.0)).date(' h:i:s A',$ts);
+ if (!$rs) {
+ Err("SQLDate query returned no recordset");
+ echo $db->ErrorMsg(),'<br>';
+ } else if ($d != $rs->fields[0]) Err("SQLDate 2 failed expected: <br>act:$d <br>sql:".$rs->fields[0]);
+
+
+ print "<p>Test Filter</p>";
+ $db->debug = 1;
+
+ $rs = $db->SelectLimit('select * from ADOXYZ where id < 3 order by id');
+
+ $rs = RSFilter($rs,'do_strtolower');
+ if (trim($rs->fields[1]) != 'caroline' && trim($rs->fields[2]) != 'miranda') {
+ err('**** RSFilter failed');
+ print_r($rs->fields);
+ }
+
+ rs2html($rs);
+
+ $db->debug=1;
+
+
+ print "<p>Test Replace</p>";
+
+ $ret = $db->Replace('adoxyz',
+ array('id'=>1,'firstname'=>'Caroline','lastname'=>'Miranda'),
+ array('id'),
+ $autoq = true);
+ if (!$ret) echo "<p>Error in replacing existing record</p>";
+ else {
+ $saved = $db->debug;
+ $db->debug = 0;
+ $savec = $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = true;
+ $rs = $db->Execute('select * FROM ADOXYZ where id=1');
+ $db->debug = $saved;
+ if ($rs->RecordCount() != 1) {
+ $cnt = $rs->RecordCount();
+ rs2html($rs);
+ print "<b>Error - Replace failed, count=$cnt</b><p>";
+ }
+ $ADODB_COUNTRECS = $savec;
+ }
+ $ret = $db->Replace('adoxyz',
+ array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
+ array('id','firstname'),
+ $autoq = true);
+ if ($ret != 2) print "<b>Replace failed: </b>";
+ print "test A return value=$ret (2 expected) <p>";
+
+ $ret = $db->Replace('adoxyz',
+ array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'),
+ 'id',
+ $autoq = true);
+ if ($ret != 1)
+ if ($db->dataProvider == 'ibase' && $ret == 2);
+ else print "<b>Replace failed: </b>";
+ print "test B return value=$ret (1 or if ibase then 2 expected) <p>";
+
+ print "<h3>rs2rs Test</h3>";
+
+ $rs = $db->Execute('select * from adoxyz where id>= 1 order by id');
+ $rs = $db->_rs2rs($rs);
+ $rs->valueX = 'X';
+ $rs->MoveNext();
+ $rs = $db->_rs2rs($rs);
+ if (!isset($rs->valueX)) err("rs2rs does not preserve array recordsets");
+ if (reset($rs->fields) != 1) err("rs2rs does not move to first row: id=".reset($rs->fields));
+
+ /////////////////////////////////////////////////////////////
+ include_once('../pivottable.inc.php');
+ print "<h3>Pivot Test</h3>";
+ $db->debug=true;
+ $sql = PivotTableSQL(
+ $db, # adodb connection
+ 'adoxyz', # tables
+ 'firstname', # row fields
+ 'lastname', # column fields
+ false, # join
+ 'ID', # sum
+ 'Sum ', # label for sum
+ 'sum', # aggregate function
+ true
+ );
+ $rs = $db->Execute($sql);
+ if ($rs) rs2html($rs);
+ else Err("Pivot sql error");
+
+ $pear = true; //true;
+ $db->debug=false;
+
+ if ($pear) {
+ // PEAR TESTS BELOW
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ include_once "PEAR.php";
+ $rs = $db->query('select * from adoxyz where id>0 and id<10 order by id');
+
+ $i = 0;
+ if ($rs && !$rs->EOF) {
+ while ($arr = $rs->fetchRow()) {
+ $i++;
+ //print "$i ";
+ if ($arr[0] != $i) {
+ print_r($arr);
+ print "<p><b>PEAR DB emulation error 1.</b></p>";
+ $pear = false;
+ break;
+ }
+ }
+ $rs->Close();
+ }
+
+
+ if ($i != $db->GetOne('select count(*) from adoxyz where id>0 and id<10')) {
+ print "<p><b>PEAR DB emulation error 1.1 EOF ($i)</b></p>";
+ $pear = false;
+ }
+
+ $rs = $db->limitQuery('select * from adoxyz where id>0 order by id',$i=3,$top=3);
+ $i2 = $i;
+ if ($rs && !$rs->EOF) {
+
+ while (!is_object($rs->fetchInto($arr))) {
+ $i2++;
+
+ // print_r($arr);
+ // print "$i ";print_r($arr);
+ if ($arr[0] != $i2) {
+ print "<p><b>PEAR DB emulation error 2.</b></p>";
+ $pear = false;
+ break;
+ }
+ }
+ $rs->Close();
+ }
+ if ($i2 != $i+$top) {
+ print "<p><b>PEAR DB emulation error 2.1 EOF (correct=$i+$top, actual=$i2)</b></p>";
+ $pear = false;
+ }
+ }
+ if ($pear) print "<p>PEAR DB emulation passed.</p>";
+ flush();
+
+
+ $rs = $db->SelectLimit("select ".$db->sysDate." from adoxyz",1);
+ $date = $rs->fields[0];
+ if (!$date) Err("Bad sysDate");
+ else {
+ $ds = $db->UserDate($date,"d m Y");
+ if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds.' expected='.date("d m Y"));
+ else echo "Passed UserDate: $ds<p>";
+ }
+ $db->debug=1;
+ if ($db->dataProvider == 'oci8')
+ $rs = $db->SelectLimit("select to_char(".$db->sysTimeStamp.",'YYYY-MM-DD HH24:MI:SS') from adoxyz",1);
+ else
+ $rs = $db->SelectLimit("select ".$db->sysTimeStamp." from adoxyz",1);
+ $date = $rs->fields[0];
+ if (!$date) Err("Bad sysTimeStamp");
+ else {
+ $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y");
+ if ($ds != date("H \\h\\r\\s-d m Y")) Err("Bad UserTimeStamp: ".$ds.", correct is ".date("H \\h\\r\\s-d m Y"));
+ else echo "Passed UserTimeStamp: $ds<p>";
+
+ $date = 100;
+ $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y");
+ $ds2 = date("H \\h\\r\\s-d m Y",$date);
+ if ($ds != $ds2) Err("Bad UserTimeStamp 2: $ds: $ds2");
+ else echo "Passed UserTimeStamp 2: $ds<p>";
+ }
+ flush();
+
+ if ($db->hasTransactions) {
+ //$db->debug=1;
+ echo "<p>Testing StartTrans CompleteTrans</p>";
+ $db->raiseErrorFn = false;
+ $db->StartTrans();
+ $rs = $db->Execute('select * from notable');
+ $db->StartTrans();
+ $db->BeginTrans();
+ $db->Execute("update ADOXYZ set firstname='Carolx' where id=1");
+ $db->CommitTrans();
+ $db->CompleteTrans();
+ $rez = $db->CompleteTrans();
+ if ($rez !== false) {
+ if (is_null($rez)) Err("Error: _transOK not modified");
+ else Err("Error: CompleteTrans (1) should have failed");
+ } else {
+ $name = $db->GetOne("Select firstname from ADOXYZ where id=1");
+ if ($name == "Carolx") Err("Error: CompleteTrans (2) should have failed");
+ else echo "<p> -- Passed StartTrans test1 - rolling back</p>";
+ }
+
+ $db->StartTrans();
+ $db->BeginTrans();
+ $db->Execute("update ADOXYZ set firstname='Carolx' where id=1");
+ $db->RollbackTrans();
+ $rez = $db->CompleteTrans();
+ if ($rez !== true) Err("Error: CompleteTrans (1) should have succeeded");
+ else {
+ $name = $db->GetOne("Select firstname from ADOXYZ where id=1");
+ if (trim($name) != "Carolx") Err("Error: CompleteTrans (2) should have succeeded, returned name=$name");
+ else echo "<p> -- Passed StartTrans test2 - commiting</p>";
+ }
+ }
+ flush();
+ $saved = $db->debug;
+ $db->debug=1;
+ $cnt = _adodb_getcount($db, 'select * from ADOXYZ where firstname in (select firstname from ADOXYZ)');
+ echo "<b>Count=</b> $cnt";
+ $db->debug=$saved;
+
+ global $TESTERRS;
+ $debugerr = true;
+
+ global $ADODB_LANG;$ADODB_LANG = 'fr';
+ $db->debug = false;
+ $TESTERRS = 0;
+ $db->raiseErrorFn = 'adodb_test_err';
+ global $ERRNO; // from adodb_test_err
+ $db->Execute('select * from nowhere');
+ $metae = $db->MetaError($ERRNO);
+ if ($metae !== DB_ERROR_NOSUCHTABLE) print "<p><b>MetaError=".$metae." wrong</b>, should be ".DB_ERROR_NOSUCHTABLE."</p>";
+ else print "<p>MetaError ok (".DB_ERROR_NOSUCHTABLE."): ".$db->MetaErrorMsg($metae)."</p>";
+ if ($TESTERRS != 1) print "<b>raiseErrorFn select nowhere failed</b><br>";
+ $rs = $db->Execute('select * from adoxyz');
+ if ($debugerr) print " Move";
+ $rs->Move(100);
+ $rs->_queryID = false;
+ if ($debugerr) print " MoveNext";
+ $rs->MoveNext();
+ if ($debugerr) print " $rs=false";
+ $rs = false;
+
+ flush();
+
+ print "<p>SetFetchMode() tests</p>";
+ $db->SetFetchMode(ADODB_FETCH_ASSOC);
+ $rs = $db->SelectLimit('select firstname from adoxyz',1);
+ if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC");
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+ $rs = $db->SelectLimit('select firstname from adoxyz',1);
+ //var_dump($rs->fields);
+ if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC");
+
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $db->SetFetchMode(ADODB_FETCH_NUM);
+ $rs = $db->SelectLimit('select firstname from adoxyz',1);
+ if (!isset($rs->fields[0])) Err("BAD FETCH NUM");
+
+ flush();
+
+ print "<p>Test MetaTables again with SetFetchMode()</p>";
+ $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $db->SetFetchMode(ADODB_FETCH_ASSOC);
+ print_r($db->MetaTables());
+ print "<p>";
+
+ ////////////////////////////////////////////////////////////////////
+
+ print "<p>Testing Bad Connection</p>";
+ flush();
+
+ if (true || PHP_VERSION < 5) {
+ if ($db->dataProvider == 'odbtp') $db->databaseType = 'odbtp';
+ $conn = NewADOConnection($db->databaseType);
+ $conn->raiseErrorFn = 'adodb_test_err';
+ if (1) $conn->PConnect('abc','baduser','badpassword');
+ if ($TESTERRS == 2) print "raiseErrorFn tests passed<br>";
+ else print "<b>raiseErrorFn tests failed ($TESTERRS)</b><br>";
+
+ flush();
+ }
+ ////////////////////////////////////////////////////////////////////
+
+ global $nocountrecs;
+
+ if (isset($nocountrecs) && $ADODB_COUNTRECS) err("Error: \$ADODB_COUNTRECS is set");
+ if (empty($nocountrecs) && $ADODB_COUNTRECS==false) err("Error: \$ADODB_COUNTRECS is not set");
+
+ flush();
+?>
+ </p>
+ <table width=100% ><tr><td bgcolor=beige>&nbsp;</td></tr></table>
+ </p></form>
+<?php
+
+ if ($rs1) $rs1->Close();
+ if ($rs2) $rs2->Close();
+ if ($rs) $rs->Close();
+ $db->Close();
+
+ if ($db->transCnt != 0) Err("Error in transCnt=$db->transCnt (should be 0)");
+
+
+ printf("<p>Total queries=%d; total cached=%d</p>",$EXECS+$CACHED, $CACHED);
+ flush();
+}
+
+function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
+{
+global $TESTERRS,$ERRNO;
+
+ $ERRNO = $errno;
+ $TESTERRS += 1;
+ print "<i>** $dbms ($fn): errno=$errno &nbsp; errmsg=$errmsg ($p1,$p2)</i><br>";
+}
+
+//--------------------------------------------------------------------------------------
+
+
+@set_time_limit(240); // increase timeout
+
+include("../tohtml.inc.php");
+include("../adodb.inc.php");
+include("../rsfilter.inc.php");
+
+/* White Space Check */
+
+if (isset($_SERVER['argv'][1])) {
+ //print_r($_SERVER['argv']);
+ $_GET[$_SERVER['argv'][1]] = 1;
+}
+
+if (@$_SERVER['COMPUTERNAME'] == 'TIGRESS') {
+ CheckWS('mysqlt');
+ CheckWS('postgres');
+ CheckWS('oci8po');
+
+ CheckWS('firebird');
+ CheckWS('sybase');
+ if (!ini_get('safe_mode')) CheckWS('informix');
+
+ CheckWS('ado_mssql');
+ CheckWS('ado_access');
+ CheckWS('mssql');
+
+ CheckWS('vfp');
+ CheckWS('sqlanywhere');
+ CheckWS('db2');
+ CheckWS('access');
+ CheckWS('odbc_mssql');
+ CheckWS('firebird15');
+ //
+ CheckWS('oracle');
+ CheckWS('proxy');
+ CheckWS('fbsql');
+ print "White Space Check complete<p>";
+}
+if (sizeof($_GET) == 0) $testmysql = true;
+
+
+foreach($_GET as $k=>$v) {
+ //global $$k;
+ $$k = $v;
+}
+if (strpos(PHP_VERSION,'5') === 0) {
+ //$testaccess=1;
+ //$testmssql = 1;
+ //$testsqlite=1;
+}
+?>
+<html>
+<title>ADODB Testing</title>
+<body bgcolor=white>
+<H1>ADODB Test</H1>
+
+This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO).
+There is also support for Sybase, PostgreSQL.</p>
+For the latest version of ADODB, visit <a href=http://adodb.sourceforge.net/>adodb.sourceforge.net</a>.</p>
+
+Test <a href=test4.php>GetInsertSQL/GetUpdateSQL</a> &nbsp;
+ <a href=testsessions.php>Sessions</a> &nbsp;
+ <a href=testpaging.php>Paging</a> &nbsp;
+ <a href=test-perf.php>Perf Monitor</a><p>
+<?php
+include('./testdatabases.inc.php');
+
+echo "<br>vers=",ADOConnection::Version();
+
+
+include_once('../adodb-time.inc.php');
+if (isset($_GET['time'])) adodb_date_test();
+
+?>
+<p><i>ADODB Database Library (c) 2000-2005 John Lim. All rights reserved. Released under BSD and LGPL, PHP <?php echo PHP_VERSION ?>.</i></p>
+</body>
+</html>
diff --git a/html/phpgacl/adodb/tests/test2.php b/html/phpgacl/adodb/tests/test2.php
new file mode 100644
index 0000000..3b1dafe
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test2.php
@@ -0,0 +1,26 @@
+<?php
+
+// BASIC ADO test
+
+ include_once('../adodb.inc.php');
+
+ $db = &ADONewConnection("ado_access");
+ $db->debug=1;
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
+ $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'
+ . 'DATA SOURCE=' . $access . ';';
+
+ echo "<p>PHP ",PHP_VERSION,"</p>";
+
+ $db->Connect($myDSN) || die('fail');
+
+ print_r($db->ServerInfo());
+
+ try {
+ $rs = $db->Execute("select $db->sysTimeStamp,* from adoxyz where id>02xx");
+ print_r($rs->fields);
+ } catch(exception $e) {
+ print_r($e);
+ echo "<p> Date m/d/Y =",$db->UserDate($rs->fields[4],'m/d/Y');
+ }
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test3.php b/html/phpgacl/adodb/tests/test3.php
new file mode 100644
index 0000000..cf1fff6
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test3.php
@@ -0,0 +1,44 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 8.
+ */
+
+
+error_reporting(E_ALL);
+
+$path = dirname(__FILE__);
+
+include("$path/../adodb-exceptions.inc.php");
+include("$path/../adodb.inc.php");
+
+try {
+$db = NewADOConnection("oci8");
+$db->Connect('','scott','natsoft');
+$db->debug=1;
+
+$cnt = $db->GetOne("select count(*) from adoxyz");
+$rs = $db->Execute("select * from adoxyz order by id");
+
+$i = 0;
+foreach($rs as $k => $v) {
+ $i += 1;
+ echo $k; adodb_pr($v);
+ flush();
+}
+
+if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
+
+
+
+$rs = $db->Execute("select bad from badder");
+
+} catch (exception $e) {
+ adodb_pr($e);
+ $e = adodb_backtrace($e->trace);
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test4.php b/html/phpgacl/adodb/tests/test4.php
new file mode 100644
index 0000000..3798254
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test4.php
@@ -0,0 +1,134 @@
+<?php
+
+/**
+ * @version V4.50 6 July 2004 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Test GetUpdateSQL and GetInsertSQL.
+ */
+
+error_reporting(E_ALL);
+function testsql()
+{
+
+
+include('../adodb.inc.php');
+include('../tohtml.inc.php');
+
+global $ADODB_FORCE_TYPE;
+
+
+//==========================
+// This code tests an insert
+
+$sql = "
+SELECT *
+FROM ADOXYZ WHERE id = -1";
+// Select an empty record from the database
+
+
+#$conn = &ADONewConnection("mssql"); // create a connection
+#$conn->PConnect("", "sa", "natsoft", "northwind"); // connect to MySQL, testdb
+
+$conn = &ADONewConnection("mysql"); // create a connection
+$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb
+
+//$conn =& ADONewConnection('oci8');
+//$conn->Connect('','scott','natsoft');
+//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+
+$conn->debug=1;
+$conn->Execute("delete from adoxyz where lastname like 'Smi%'");
+
+$rs = $conn->Execute($sql); // Execute the query and get the empty recordset
+$record = array(); // Initialize an array to hold the record data to insert
+
+if (strpos($conn->databaseType,'mssql')!==false) $record['id'] = 751;
+$record["firstname"] = 'Jann';
+$record["lastname"] = "Smitts";
+$record["created"] = time();
+
+$insertSQL = $conn->GetInsertSQL($rs, $record);
+$conn->Execute($insertSQL); // Insert the record into the database
+
+if (strpos($conn->databaseType,'mssql')!==false) $record['id'] = 752;
+// Set the values for the fields in the record
+$record["firstname"] = 'null';
+$record["lastname"] = "Smith\$@//";
+$record["created"] = time();
+
+if (isset($_GET['f'])) $ADODB_FORCE_TYPE = $_GET['f'];
+
+//$record["id"] = -1;
+
+// Pass the empty recordset and the array containing the data to insert
+// into the GetInsertSQL function. The function will process the data and return
+// a fully formatted insert sql statement.
+$insertSQL = $conn->GetInsertSQL($rs, $record);
+$conn->Execute($insertSQL); // Insert the record into the database
+
+
+
+$insertSQL2 = $conn->GetInsertSQL($table='ADOXYZ', $record);
+if ($insertSQL != $insertSQL2) echo "<p><b>Walt's new stuff failed</b>: $insertSQL2</p>";
+//==========================
+// This code tests an update
+
+$sql = "
+SELECT *
+FROM ADOXYZ WHERE lastname=".$conn->Param('var'). " ORDER BY 1";
+// Select a record to update
+
+$varr = array('var'=>$record['lastname'].'');
+$rs = $conn->Execute($sql,$varr); // Execute the query and get the existing record to update
+if (!$rs || $rs->EOF) print "<p><b>No record found!</b></p>";
+
+$record = array(); // Initialize an array to hold the record data to update
+
+
+// Set the values for the fields in the record
+$record["firstName"] = "Caroline".rand();
+//$record["lasTname"] = ""; // Update Caroline's lastname from Miranda to Smith
+$record["creAted"] = '2002-12-'.(rand()%30+1);
+$record['num'] = '';
+// Pass the single record recordset and the array containing the data to update
+// into the GetUpdateSQL function. The function will process the data and return
+// a fully formatted update sql statement.
+// If the data has not changed, no recordset is returned
+
+$updateSQL = $conn->GetUpdateSQL($rs, $record);
+$conn->Execute($updateSQL,$varr); // Update the record in the database
+if ($conn->Affected_Rows() != 1)print "<p><b>Error1 </b>: Rows Affected=".$conn->Affected_Rows().", should be 1</p>";
+
+$record["firstName"] = "Caroline".rand();
+$record["lasTname"] = "Smithy Jones"; // Update Caroline's lastname from Miranda to Smith
+$record["creAted"] = '2002-12-'.(rand()%30+1);
+$record['num'] = 331;
+$updateSQL = $conn->GetUpdateSQL($rs, $record);
+$conn->Execute($updateSQL,$varr); // Update the record in the database
+if ($conn->Affected_Rows() != 1)print "<p><b>Error 2</b>: Rows Affected=".$conn->Affected_Rows().", should be 1</p>";
+
+$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'");
+//adodb_pr($rs);
+rs2html($rs);
+
+$record["firstName"] = "Carol-new-".rand();
+$record["lasTname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith
+$record["creAted"] = '2002-12-'.(rand()%30+1);
+$record['num'] = 331;
+
+$conn->AutoExecute('ADOXYZ',$record,'UPDATE', "lastname like 'Sm%'");
+$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'");
+//adodb_pr($rs);
+rs2html($rs);
+}
+
+
+testsql();
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/test5.php b/html/phpgacl/adodb/tests/test5.php
new file mode 100644
index 0000000..1a1b3c1
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test5.php
@@ -0,0 +1,47 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+
+// Select an empty record from the database
+
+include('../adodb.inc.php');
+include('../tohtml.inc.php');
+
+include('../adodb-errorpear.inc.php');
+
+if (0) {
+ $conn = &ADONewConnection('mysql');
+ $conn->debug=1;
+ $conn->PConnect("localhost","root","","xphplens");
+ print $conn->databaseType.':'.$conn->GenID().'<br>';
+}
+
+if (0) {
+ $conn = &ADONewConnection("oci8"); // create a connection
+ $conn->debug=1;
+ $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); // connect to MySQL, testdb
+ print $conn->databaseType.':'.$conn->GenID();
+}
+
+if (0) {
+ $conn = &ADONewConnection("ibase"); // create a connection
+ $conn->debug=1;
+ $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); // connect to MySQL, testdb
+ print $conn->databaseType.':'.$conn->GenID().'<br>';
+}
+
+if (0) {
+ $conn = &ADONewConnection('postgres');
+ $conn->debug=1;
+ @$conn->PConnect("susetikus","tester","test","test");
+ print $conn->databaseType.':'.$conn->GenID().'<br>';
+}
+?>
diff --git a/html/phpgacl/adodb/tests/test_rs_array.php b/html/phpgacl/adodb/tests/test_rs_array.php
new file mode 100644
index 0000000..99f1fa3
--- /dev/null
+++ b/html/phpgacl/adodb/tests/test_rs_array.php
@@ -0,0 +1,47 @@
+<?php
+
+include_once('../adodb.inc.php');
+$rs = new ADORecordSet_array();
+
+$array = array(
+array ('Name', 'Age'),
+array ('John', '12'),
+array ('Jill', '8'),
+array ('Bill', '49')
+);
+
+$typearr = array('C','I');
+
+
+$rs->InitArray($array,$typearr);
+
+while (!$rs->EOF) {
+ print_r($rs->fields);echo "<br>";
+ $rs->MoveNext();
+}
+
+echo "<hr> 1 Seek<br>";
+$rs->Move(1);
+while (!$rs->EOF) {
+ print_r($rs->fields);echo "<br>";
+ $rs->MoveNext();
+}
+
+echo "<hr> 2 Seek<br>";
+$rs->Move(2);
+while (!$rs->EOF) {
+ print_r($rs->fields);echo "<br>";
+ $rs->MoveNext();
+}
+
+echo "<hr> 3 Seek<br>";
+$rs->Move(3);
+while (!$rs->EOF) {
+ print_r($rs->fields);echo "<br>";
+ $rs->MoveNext();
+}
+
+
+
+die();
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testcache.php b/html/phpgacl/adodb/tests/testcache.php
new file mode 100644
index 0000000..db1eb5b
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testcache.php
@@ -0,0 +1,29 @@
+<html>
+<body>
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+$ADODB_CACHE_DIR = dirname(tempnam('/tmp',''));
+include("../adodb.inc.php");
+
+if (isset($access)) {
+ $db=ADONewConnection('access');
+ $db->PConnect('nwind');
+} else {
+ $db = ADONewConnection('mysql');
+ $db->PConnect('mangrove','root','','xphplens');
+}
+if (isset($cache)) $rs = $db->CacheExecute(120,'select * from products');
+else $rs = $db->Execute('select * from products');
+
+$arr = $rs->GetArray();
+print sizeof($arr);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testdatabases.inc.php b/html/phpgacl/adodb/tests/testdatabases.inc.php
new file mode 100644
index 0000000..b3dbc25
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testdatabases.inc.php
@@ -0,0 +1,412 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+*/
+
+ /* this file is used by the ADODB test program: test.php */
+ ?>
+
+<table><tr valign=top><td>
+<form method=get>
+<input type=checkbox name="testaccess" value=1 <?php echo !empty($testaccess) ? 'checked' : '' ?>> <b>Access</b><br>
+<input type=checkbox name="testibase" value=1 <?php echo !empty($testibase) ? 'checked' : '' ?>> <b>Interbase</b><br>
+<input type=checkbox name="testmssql" value=1 <?php echo !empty($testmssql) ? 'checked' : '' ?>> <b>MSSQL</b><br>
+ <input type=checkbox name="testmysql" value=1 <?php echo !empty($testmysql) ? 'checked' : '' ?>> <b>MySQL</b><br>
+<input type=checkbox name="testmysqlodbc" value=1 <?php echo !empty($testmysqlodbc) ? 'checked' : '' ?>> <b>MySQL ODBC</b><br>
+<input type=checkbox name="testmysqli" value=1 <?php echo !empty($testmysqli) ? 'checked' : '' ?>> <b>MySQLi</b>
+<br>
+<td><input type=checkbox name="testsqlite" value=1 <?php echo !empty($testsqlite) ? 'checked' : '' ?>> <b>SQLite</b><br>
+<input type=checkbox name="testproxy" value=1 <?php echo !empty($testproxy) ? 'checked' : '' ?>> <b>MySQL Proxy</b><br>
+<input type=checkbox name="testoracle" value=1 <?php echo !empty($testoracle) ? 'checked' : '' ?>> <b>Oracle (oci8)</b> <br>
+<input type=checkbox name="testpostgres" value=1 <?php echo !empty($testpostgres) ? 'checked' : '' ?>> <b>PostgreSQL</b><br>
+<input type=checkbox name="testpgodbc" value=1 <?php echo !empty($testpgodbc) ? 'checked' : '' ?>> <b>PostgreSQL ODBC</b><br>
+<td>
+<input type=checkbox name="testpdopgsql" value=1 <?php echo !empty($testpdopgsql) ? 'checked' : '' ?>> <b>PgSQL PDO</b><br>
+<input type=checkbox name="testpdomysql" value=1 <?php echo !empty($testpdomysql) ? 'checked' : '' ?>> <b>MySQL PDO</b><br>
+<input type=checkbox name="testpdosqlite" value=1 <?php echo !empty($testpdosqlite) ? 'checked' : '' ?>> <b>SQLite PDO</b><br>
+<input type=checkbox name="testpdoaccess" value=1 <?php echo !empty($testpdoaccess) ? 'checked' : '' ?>> <b>Access PDO</b><br>
+
+<input type=checkbox name="testpdoora" value=1 <?php echo !empty($testpdoora) ? 'checked' : '' ?>> <b>OCI PDO</b><br>
+
+<td><input type=checkbox name="testdb2" value=1 <?php echo !empty($testdb2) ? 'checked' : '' ?>> DB2<br>
+<input type=checkbox name="testvfp" value=1 <?php echo !empty($testvfp) ? 'checked' : '' ?>> VFP+ODBTP<br>
+<input type=checkbox name="testado" value=1 <?php echo !empty($testado) ? 'checked' : '' ?>> ADO (for mssql and access)<br>
+<input type=checkbox name="nocountrecs" value=1 <?php echo !empty($nocountrecs) ? 'checked' : '' ?>> $ADODB_COUNTRECS=false<br>
+<input type=checkbox name="nolog" value=1 <?php echo !empty($nolog) ? 'checked' : '' ?>> No SQL Logging<br>
+<input type=checkbox name="time" value=1 <?php echo !empty($_GET['time']) ? 'checked' : '' ?>> ADOdb time test
+</table>
+<input type=submit>
+</form>
+
+<?php
+
+if ($ADODB_FETCH_MODE != ADODB_FETCH_DEFAULT) print "<h3>FETCH MODE IS NOT ADODB_FETCH_DEFAULT</h3>";
+
+if (isset($nocountrecs)) $ADODB_COUNTRECS = false;
+
+// cannot test databases below, but we include them anyway to check
+// if they parse ok...
+
+if (!strpos(PHP_VERSION,'5') === 0) {
+ ADOLoadCode("sybase");
+ //ADOLoadCode("postgres");
+ //ADOLoadCode("postgres7");
+ ADOLoadCode("firebird");
+ ADOLoadCode("borland_ibase");
+ ADOLoadCode("informix");
+ ADOLoadCode("sqlanywhere");
+// ADOLoadCode('mysqli');
+}
+
+
+flush();
+if (!empty($testpostgres)) {
+ //ADOLoadCode("postgres");
+
+ $db = &ADONewConnection('postgres');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if ($db->Connect("localhost","tester","test","test")) {
+ testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date)");
+ }else
+ print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
+}
+
+if (!empty($testpgodbc)) {
+
+ $db = &ADONewConnection('odbc');
+ $db->hasTransactions = false;
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ if ($db->PConnect('Postgresql')) {
+ $db->hasTransactions = true;
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
+ } else print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.<BR>".$db->ErrorMsg();
+}
+
+if (!empty($testibase)) {
+ //$_GET['nolog'] = true;
+ $db = &ADONewConnection('firebird');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", ""))
+ testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)");
+ else print "ERROR: Interbase test requires a database called employee.gdb".'<BR>'.$db->ErrorMsg();
+
+}
+
+
+if (!empty($testsqlite)) {
+ $path =urlencode('d:\inetpub\adodb\sqlite.db');
+ $dsn = "sqlite://$path/";
+ $db = ADONewConnection($dsn);
+ echo $dsn;
+
+// $db = &ADONewConnection('sqlite');
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ if (1)
+ //if ($db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", ""))
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
+ else print "ERROR: SQLite";
+
+}
+
+if (!empty($testpdopgsql)) {
+ $connstr = "pgsql:dbname=test";
+ $u = 'tester';$p='test';
+ $db = &ADONewConnection('pdo');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $db->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+}
+
+if (!empty($testpdomysql)) {
+ $connstr = "mysql:dbname=northwind";
+ $u = 'root';$p='';
+ $db = &ADONewConnection('pdo');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $db->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+}
+
+if (!empty($testpdosqlite)) {
+ $connstr = "sqlite:d:/inetpub/adodb/sqlite-pdo.db3";
+ $u = '';$p='';
+ $db = &ADONewConnection('pdo');
+ $db->hasTransactions = false;
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $db->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+}
+
+if (!empty($testpdoaccess)) {
+ $connstr = 'odbc:nwind';
+ $u = '';$p='';
+ $db = &ADONewConnection('pdo');
+ $db->hasTransactions = false;
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $db->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+}
+
+if (!empty($testpdoora)) {
+ $connstr = 'oci:';
+ $u = 'scott';$p='natsoft';
+ $db = &ADONewConnection('pdo');
+ #$db->hasTransactions = false;
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $db->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+}
+
+// REQUIRES ODBC DSN CALLED nwind
+if (!empty($testaccess)) {
+ $db = &ADONewConnection('access');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
+ $dsn = "nwind";
+ $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;";
+
+ //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';';
+ if ($db->PConnect($dsn, "", "", ""))
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
+ else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver";
+
+}
+
+if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS
+
+ $db = &ADONewConnection("ado_access");
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ $access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
+ $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'
+ . 'DATA SOURCE=' . $access . ';';
+ //. 'USER ID=;PASSWORD=;';
+ $_GET['nolog'] = 1;
+ if ($db->PConnect($myDSN, "", "", "")) {
+ print "ADO version=".$db->_connectionID->version."<br>";
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
+ } else print "ERROR: Access test requires a Access database $access".'<BR>'.$db->ErrorMsg();
+
+}
+
+if (!empty($testvfp)) { // ODBC
+ $db = &ADONewConnection('vfp');
+ print "<h1>Connecting $db->databaseType...</h1>";flush();
+
+ if ( $db->PConnect("vfp-adoxyz")) {
+ testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)");
+ } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver";
+
+ echo "<hr>";
+ $db = &ADONewConnection('odbtp');
+
+ if ( $db->PConnect('localhost','DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=d:\inetpub\adodb;EXCLUSIVE=NO;')) {
+ print "<h1>Connecting $db->databaseType...</h1>";flush();
+ testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)");
+ } else print "ERROR: Visual FoxPro odbtp requires a Windows ODBC DSN=vfp-adoxyz, VFP driver";
+
+}
+
+
+// REQUIRES MySQL server at localhost with database 'test'
+if (!empty($testmysql)) { // MYSQL
+
+
+ if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost';
+ else $server = "mangrove";
+ $user = 'root'; $password = ''; $database = 'northwind';
+ $db = &ADONewConnection("mysqlt://$user:$password@$server/$database?persist");
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ if (true || $db->PConnect($server, "root", "", "northwind")) {
+ //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop');
+ //$db->debug=1;$db->Execute('drop table ADOXYZ');
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) Type=InnoDB");
+ } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
+}
+
+// REQUIRES MySQL server at localhost with database 'test'
+if (!empty($testmysqli)) { // MYSQL
+
+ $db = &ADONewConnection('mysqli');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost';
+ else $server = "mangrove";
+ if ($db->PConnect($server, "root", "", "northwind")) {
+ //$db->debug=1;$db->Execute('drop table ADOXYZ');
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)");
+ } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
+}
+
+
+// REQUIRES MySQL server at localhost with database 'test'
+if (!empty($testmysqlodbc)) { // MYSQL
+
+ $db = &ADONewConnection('odbc');
+ $db->hasTransactions = false;
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost';
+ else $server = "mangrove";
+ if ($db->PConnect('mysql', "root", ""))
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
+ else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
+}
+
+if (!empty($testproxy)){
+ $db = &ADONewConnection('proxy');
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost';
+
+ if ($db->PConnect('http://localhost/php/phplens/adodb/server.php'))
+ testdb($db,
+ "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
+ else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
+
+}
+
+ADOLoadCode('oci805');
+ADOLoadCode("oci8po");
+if (!empty($testoracle)) {
+ $dsn = "oci8po://juris10:natsoft@sherkhan?persist";
+ $db = ADONewConnection($dsn);
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if (true || $db->Connect('', "scott", "natsoft",''))
+ testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
+ else print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'<BR>'.$db->ErrorMsg();
+
+}
+ADOLoadCode("oracle"); // no longer supported
+if (false && !empty($testoracle)) {
+
+ $db = ADONewConnection();
+ print "<h1>Connecting $db->databaseType...</h1>";
+ if ($db->PConnect("", "scott", "tiger", "natsoft.domain"))
+ testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
+ else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg();
+
+}
+
+ADOLoadCode("db2"); // no longer supported
+if (!empty($testdb2)) {
+ $db = ADONewConnection();
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ $dsn = "db2_sample";
+ $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft";
+ if ($db->Connect($dsn)) {
+ // testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
+ } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'<BR>'.$db->ErrorMsg();
+
+echo "<hr>";
+flush();
+ $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft";
+
+ $db = ADONewConnection('odbtp');
+ if ($db->Connect('127.0.0.1',$dsn)) {
+
+ $db->debug=1;
+ $arr = $db->GetArray( "||SQLProcedures" ); adodb_pr($arr);
+ $arr = $db->GetArray( "||SQLProcedureColumns|||GET_ROUTINE_SAR" );adodb_pr($arr);
+
+ testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
+ } else echo ("ERROR Connection");
+ echo $db->ErrorMsg();
+}
+
+
+$server = 'sherkhan';
+
+ADOLoadCode('odbc_mssql');
+if (!empty($testmssql)) { // MS SQL Server via ODBC
+ $db = ADONewConnection();
+
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;";
+
+ if ($db->PConnect($dsn, "adodb", "natsoft", "")) {
+ testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
+ }
+ else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
+
+}
+
+ADOLoadCode("ado_mssql");
+if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
+
+ $db = &ADONewConnection("ado_mssql");
+ //$db->debug=1;
+ print "<h1>Connecting DSN-less $db->databaseType...</h1>";
+
+ $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
+ . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No";
+
+
+ if ($db->PConnect($myDSN, "", "", ""))
+ testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
+ else print "ERROR: MSSQL test 2 requires MS SQL 7";
+
+}
+
+
+ADOLoadCode("mssqlpo");
+if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC
+ $db = ADONewConnection("mssqlpo");
+ //$db->debug=1;
+ print "<h1>Connecting $db->databaseType...</h1>";
+
+ $ok = $db->Connect('','adodb','natsoft','northwind');
+
+ if ($ok or $db->PConnect("mangrove", "sa", "natsoft", "ai")) {
+ AutoDetect_MSSQL_Date_Order($db);
+ // $db->Execute('drop table adoxyz');
+ testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
+ } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='192.168.0.1', userid='adodb', password='natsoft', database='ai'".'<BR>'.$db->ErrorMsg();
+
+}
+
+if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider
+
+ $db = &ADONewConnection("ado_mssql");
+ print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
+ //$db->debug=1;
+ $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes";
+ if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) {
+ testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
+ } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
+
+}
+
+
+if (extension_loaded('odbtp') && !empty($testmssql)) { // MS SQL Server via ODBC
+ $db = ADONewConnection('odbtp');
+
+ $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;uid=adodb;pwd=natsoft";
+
+ if ($db->PConnect('localhost',$dsn, "", "")) {
+ print "<h1>Connecting $db->databaseType...</h1>";
+ testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)");
+ }
+ else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup";
+
+}
+
+
+print "<h3>Tests Completed</h3>";
+
+?>
diff --git a/html/phpgacl/adodb/tests/testgenid.php b/html/phpgacl/adodb/tests/testgenid.php
new file mode 100644
index 0000000..14b48ce
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testgenid.php
@@ -0,0 +1,36 @@
+<?php
+/*
+ V4.50 6 July 2004
+
+ Run multiple copies of this php script at the same time
+ to test unique generation of id's in multiuser mode
+*/
+include_once('../adodb.inc.php');
+$testaccess = true;
+include_once('testdatabases.inc.php');
+
+function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
+{
+ $table = 'adodbseq';
+
+ $db->Execute("drop table $table");
+ //$db->debug=true;
+
+ $ctr = 5000;
+ $lastnum = 0;
+
+ while (--$ctr >= 0) {
+ $num = $db->GenID($table);
+ if ($num === false) {
+ print "GenID returned false";
+ break;
+ }
+ if ($lastnum + 1 == $num) print " $num ";
+ else {
+ print " <font color=red>$num</font> ";
+ flush();
+ }
+ $lastnum = $num;
+ }
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testmssql.php b/html/phpgacl/adodb/tests/testmssql.php
new file mode 100644
index 0000000..1b7493c
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testmssql.php
@@ -0,0 +1,76 @@
+<?php
+
+/**
+ * @version V4.50 6 July 2004 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Test GetUpdateSQL and GetInsertSQL.
+ */
+
+error_reporting(E_ALL);
+
+
+include('../adodb.inc.php');
+include('../tohtml.inc.php');
+
+//==========================
+// This code tests an insert
+
+
+
+$conn = &ADONewConnection("mssql"); // create a connection
+$conn->Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail');
+
+$conn->debug =1;
+$query = 'select * from products';
+$conn->SetFetchMode(ADODB_FETCH_ASSOC);
+$rs = $conn->Execute($query);
+echo "<pre>";
+while( !$rs->EOF ) {
+ $output[] = $rs->fields;
+ var_dump($rs->fields);
+ $rs->MoveNext();
+ print "<p>";
+}
+die();
+
+
+$p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)');
+echo "<pre>";
+print_r($p);
+
+$conn->debug=1;
+$conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time())));
+
+$p = $conn->Prepare('select * from products where productname like ?');
+$arr = $conn->getarray($p,array('V%'));
+print_r($arr);
+die();
+
+//$conn = &ADONewConnection("mssql");
+//$conn->Connect('mangrove','sa','natsoft','ai');
+
+//$conn->Connect('mangrove','sa','natsoft','ai');
+$conn->debug=1;
+$conn->Execute('delete from blobtest');
+
+$conn->Execute('insert into blobtest (id) values(1)');
+$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
+$rs = $conn->Execute('select b1 from blobtest where id=1');
+
+$output = "c:\\temp\\test_out-".date('H-i-s').".gif";
+print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
+$fd = fopen($output, "wb");
+fwrite($fd, $rs->fields[0]);
+fclose($fd);
+
+print " <a href=file://$output>View Image</a>";
+//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
+//rs2html($rs);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testoci8.php b/html/phpgacl/adodb/tests/testoci8.php
new file mode 100644
index 0000000..3bac3d1
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testoci8.php
@@ -0,0 +1,83 @@
+<html>
+<body>
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+error_reporting(63);
+include("../adodb.inc.php");
+include("../tohtml.inc.php");
+
+if (0) {
+ $db = ADONewConnection('oci8po');
+
+ $db->PConnect('','scott','natsoft');
+ if (!empty($testblob)) {
+ $varHoldingBlob = 'ABC DEF GEF John TEST';
+ $num = time()%10240;
+ // create table atable (id integer, ablob blob);
+ $db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())');
+ $db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB');
+
+ $rs = &$db->Execute('select * from atable');
+
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+ }
+ $stmt = $db->Prepare('select * from adoxyz where id=?');
+ for ($i = 1; $i <= 10; $i++) {
+ $rs = &$db->Execute(
+ $stmt,
+ array($i));
+
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+ }
+}
+if (1) {
+ $db = ADONewConnection('oci8');
+ $db->PConnect('','scott','natsoft');
+ $db->debug = true;
+ $db->Execute("delete from emp where ename='John'");
+ print $db->Affected_Rows().'<BR>';
+ $stmt = &$db->Prepare('insert into emp (empno, ename) values (:empno, :ename)');
+ $rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John'));
+ // prepare not quite ready for prime time
+ //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
+ if (!$rs) die("Empty RS");
+
+ $db->setfetchmode(ADODB_FETCH_NUM);
+
+ $vv = 'A%';
+ $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true);
+ $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR);
+ $db->OutParameter($stmt, $vv, 'tt');
+ $rs = $db->Execute($stmt);
+ while (!$rs->EOF) {
+ adodb_pr($rs->fields);
+ $rs->MoveNext();
+ }
+ echo " val = $vv";
+
+}
+
+if (0) {
+ $db = ADONewConnection('odbc_oracle');
+ if (!$db->PConnect('local_oracle','scott','tiger')) die('fail connect');
+ $db->debug = true;
+ $rs = &$db->Execute(
+ 'select * from adoxyz where firstname=? and trim(lastname)=?',
+ array('first'=>'Caroline','last'=>'Miranda'));
+ if (!$rs) die("Empty RS");
+ if ($rs->EOF) die("EOF RS");
+ rs2html($rs);
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testoci8cursor.php b/html/phpgacl/adodb/tests/testoci8cursor.php
new file mode 100644
index 0000000..f9b3b4e
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testoci8cursor.php
@@ -0,0 +1,111 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+/*
+ Test for Oracle Variable Cursors, which are treated as ADOdb recordsets.
+
+ We have 2 examples. The first shows us using the Parameter statement.
+ The second shows us using the new ExecuteCursor($sql, $cursorName)
+ function.
+
+------------------------------------------------------------------
+-- TEST PACKAGE YOU NEED TO INSTALL ON ORACLE - run from sql*plus
+------------------------------------------------------------------
+
+
+-- TEST PACKAGE
+CREATE OR REPLACE PACKAGE adodb AS
+TYPE TabType IS REF CURSOR RETURN tab%ROWTYPE;
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar);
+PROCEDURE data_out(input IN varchar, output OUT varchar);
+
+procedure myproc (p1 in number, p2 out number);
+END adodb;
+/
+
+CREATE OR REPLACE PACKAGE BODY adodb AS
+PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames in varchar) IS
+ BEGIN
+ OPEN tabcursor FOR SELECT * FROM tab where tname like tablenames;
+ END open_tab;
+
+PROCEDURE data_out(input IN varchar, output OUT varchar) IS
+ BEGIN
+ output := 'Cinta Hati '||input;
+ END;
+
+procedure myproc (p1 in number, p2 out number) as
+begin
+p2 := p1;
+end;
+END adodb;
+/
+
+------------------------------------------------------------------
+-- END PACKAGE
+------------------------------------------------------------------
+
+*/
+
+include('../adodb.inc.php');
+include('../tohtml.inc.php');
+
+ error_reporting(E_ALL);
+ $db = ADONewConnection('oci8');
+ $db->PConnect('','scott','natsoft');
+ $db->debug = 99;
+
+
+/*
+*/
+
+ define('MYNUM',5);
+
+
+ $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;");
+
+ if ($rs && !$rs->EOF) {
+ print "Test 1 RowCount: ".$rs->RecordCount()."<p>";
+ } else {
+ print "<b>Error in using Cursor Variables 1</b><p>";
+ }
+
+ print "<h4>Testing Stored Procedures for oci8</h4>";
+
+ $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;');
+ $db->OutParameter($stid, $myov, 'myov');
+ $db->Execute($stid);
+ if ($myov != MYNUM) print "<p><b>Error with myproc</b></p>";
+
+
+ $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true);
+ $a1 = 'Malaysia';
+ //$a2 = ''; # a2 doesn't even need to be defined!
+ $db->InParameter($stmt,$a1,'a1');
+ $db->OutParameter($stmt,$a2,'a2');
+ $rs = $db->Execute($stmt);
+ if ($rs) {
+ if ($a2 !== 'Cinta Hati Malaysia') print "<b>Stored Procedure Error: a2 = $a2</b><p>";
+ else echo "OK: a2=$a2<p>";
+ } else {
+ print "<b>Error in using Stored Procedure IN/Out Variables</b><p>";
+ }
+
+
+ $tname = 'A%';
+
+ $stmt = $db->PrepareSP('select * from tab where tname like :tablename');
+ $db->Parameter($stmt,$tname,'tablename');
+ $rs = $db->Execute($stmt);
+ rs2html($rs);
+
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testpaging.php b/html/phpgacl/adodb/tests/testpaging.php
new file mode 100644
index 0000000..adbe113
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testpaging.php
@@ -0,0 +1,86 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+error_reporting(E_ALL);
+
+
+include_once('../adodb.inc.php');
+include_once('../adodb-pager.inc.php');
+
+$driver = 'oci8';
+$sql = 'select ID, firstname as "First Name", lastname as "Last Name" from adoxyz order by id';
+//$sql = 'select count(*),firstname from adoxyz group by firstname order by 2 ';
+//$sql = 'select distinct firstname, lastname from adoxyz order by firstname';
+
+if ($driver == 'postgres') {
+ $db = NewADOConnection('postgres');
+ $db->PConnect('localhost','tester','test','test');
+}
+
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->PConnect("nwind", "", "", "");
+}
+
+if ($driver == 'ibase') {
+ $db = NewADOConnection('ibase');
+ $db->PConnect("localhost:e:\\firebird\\examples\\employee.gdb", "sysdba", "masterkey", "");
+ $sql = 'select distinct firstname, lastname from adoxyz order by firstname';
+
+}
+if ($driver == 'mssql') {
+ $db = NewADOConnection('mssql');
+ $db->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind');
+}
+if ($driver == 'oci8') {
+ $db = NewADOConnection('oci8');
+ $db->Connect('','scott','natsoft');
+
+$sql = "select * from (select ID, firstname as \"First Name\", lastname as \"Last Name\" from adoxyz
+ order by (1))";
+}
+
+if ($driver == 'access') {
+ $db = NewADOConnection('access');
+ $db->Connect('nwind');
+}
+
+if (empty($driver) or $driver == 'mysql') {
+ $db = NewADOConnection('mysql');
+ $db->Connect('localhost','root','','test');
+}
+
+//$db->pageExecuteCountRows = false;
+
+$db->debug = true;
+
+if (0) {
+$rs = &$db->Execute($sql);
+include_once('../toexport.inc.php');
+print "<pre>";
+print rs2csv($rs); # return a string
+
+print '<hr>';
+$rs->MoveFirst(); # note, some databases do not support MoveFirst
+print rs2tab($rs); # return a string
+
+print '<hr>';
+$rs->MoveFirst();
+rs2tabout($rs); # send to stdout directly
+print "</pre>";
+}
+
+$pager = new ADODB_Pager($db,$sql);
+$pager->showPageLinks = true;
+$pager->linksPerPage = 10;
+$pager->cache = 60;
+$pager->Render($rows=7);
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testpear.php b/html/phpgacl/adodb/tests/testpear.php
new file mode 100644
index 0000000..2ad1db3
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testpear.php
@@ -0,0 +1,34 @@
+<?php
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+error_reporting(E_ALL);
+
+include_once('../adodb-pear.inc.php');
+$username = 'root';
+$password = '';
+$hostname = 'localhost';
+$databasename = 'xphplens';
+$driver = 'mysql';
+
+$dsn = "$driver://$username:$password@$hostname/$databasename";
+
+$db = DB::Connect($dsn);
+$db->setFetchMode(ADODB_FETCH_ASSOC);
+$rs = $db->Query('select firstname,lastname from adoxyz');
+$cnt = 0;
+while ($arr = $rs->FetchRow()) {
+ print_r($arr);
+ print "<br>";
+ $cnt += 1;
+}
+
+if ($cnt != 50) print "<b>Error in \$cnt = $cnt</b>";
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/testsessions.php b/html/phpgacl/adodb/tests/testsessions.php
new file mode 100644
index 0000000..7889215
--- /dev/null
+++ b/html/phpgacl/adodb/tests/testsessions.php
@@ -0,0 +1,81 @@
+<?php
+
+/*
+V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+ Set tabs to 4 for best viewing.
+
+ Latest version is available at http://adodb.sourceforge.net
+*/
+
+function NotifyExpire($ref,$key)
+{
+ print "<p><b>Notify Expiring=$ref, sessionkey=$key</b></p>";
+}
+
+//-------------------------------------------------------------------
+
+error_reporting(E_ALL);
+
+#### CONNECTION
+if (0) {
+ $ADODB_SESSION_DRIVER='oci8';
+ $ADODB_SESSION_CONNECT='';
+ $ADODB_SESSION_USER ='scott';
+ $ADODB_SESSION_PWD ='natsoft';
+ $ADODB_SESSION_DB ='';
+} else {
+ $ADODB_SESSION_DRIVER='mysql';
+ $ADODB_SESSION_CONNECT='localhost';
+ $ADODB_SESSION_USER ='root';
+ $ADODB_SESSION_PWD ='';
+ $ADODB_SESSION_DB ='xphplens_2';
+}
+
+### TURN DEBUGGING ON
+ $ADODB_SESS_DEBUG = 99;
+
+
+#### SETUP NOTIFICATION
+ $USER = 'JLIM'.rand();
+ $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire');
+
+
+#### INIT
+ ob_start();
+ include('../session/adodb-cryptsession.php');
+ session_start();
+
+ adodb_session_regenerate_id();
+
+### SETUP SESSION VARIABLES
+ $_SESSION['MONKEY'] = array('1','abc',44.41);
+ if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1;
+
+
+### START DISPLAY
+ print "<h3>PHP ".PHP_VERSION."</h3>";
+ print "<p><b>\$_SESSION['AVAR']={$_SESSION['AVAR']}</b></p>";
+
+ print "<hr> <b>Cookies</b>: ";
+ print_r($_COOKIE);
+
+### RANDOMLY PERFORM Garbage Collection
+### In real-production environment, this is done for you
+### by php's session extension, which calls adodb_sess_gc()
+### automatically for you. See php.ini's
+### session.cookie_lifetime and session.gc_probability
+
+ if (rand() % 5 == 0) {
+
+ print "<hr><p><b>Garbage Collection</b></p>";
+ adodb_sess_gc(10);
+
+ if (rand() % 2 == 0) {
+ print "<p>Random session destroy</p>";
+ session_destroy();
+ }
+ }
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/time.php b/html/phpgacl/adodb/tests/time.php
new file mode 100644
index 0000000..e4474b1
--- /dev/null
+++ b/html/phpgacl/adodb/tests/time.php
@@ -0,0 +1,17 @@
+<?php
+
+include_once('../adodb-time.inc.php');
+//adodb_date_test();
+?>
+<?php
+//require("adodb-time.inc.php");
+
+$datestring = "1963-12-04"; // string normally from mySQL
+$stringArray = explode("-", $datestring);
+$date = adodb_mktime(0,0,0,$stringArray[1],$stringArray[2],$stringArray[0]);
+
+$convertedDate = date("d-M-Y", $date); // converted string to UK style date
+
+echo( "Birthday: $convertedDate" ); //why is string returned as one day (3 not 4) less for this example??
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/tmssql.php b/html/phpgacl/adodb/tests/tmssql.php
new file mode 100644
index 0000000..a3b743c
--- /dev/null
+++ b/html/phpgacl/adodb/tests/tmssql.php
@@ -0,0 +1,65 @@
+<?php
+error_reporting(E_ALL);
+ini_set('mssql.datetimeconvert',0);
+
+function tmssql()
+{
+ print "<h3>mssql</h3>";
+ $db = mssql_connect('JAGUAR\vsdotnet','adodb','natsoft') or die('No Connection');
+ mssql_select_db('northwind',$db);
+
+ $rs = mssql_query('select getdate() as date',$db);
+ $o = mssql_fetch_row($rs);
+ print_r($o);
+ mssql_free_result($rs);
+
+ print "<p>Delete</p>"; flush();
+ $rs2 = mssql_query('delete from adoxyz',$db);
+ $p = mssql_num_rows($rs2);
+ mssql_free_result($rs2);
+
+}
+
+function tpear()
+{
+include_once('DB.php');
+
+ print "<h3>PEAR</h3>";
+ $username = 'adodb';
+ $password = 'natsoft';
+ $hostname = 'JAGUAR\vsdotnet';
+ $databasename = 'northwind';
+
+ $dsn = "mssql://$username:$password@$hostname/$databasename";
+ $conn = &DB::connect($dsn);
+ print "date=".$conn->GetOne('select getdate()')."<br>";
+ @$conn->query('create table tester (id integer)');
+ print "<p>Delete</p>"; flush();
+ $rs = $conn->query('delete from tester');
+ print "date=".$conn->GetOne('select getdate()')."<br>";
+}
+
+function tadodb()
+{
+include_once('../adodb.inc.php');
+
+ print "<h3>ADOdb</h3>";
+ $conn = NewADOConnection('mssql');
+ $conn->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind');
+// $conn->debug=1;
+ print "date=".$conn->GetOne('select getdate()')."<br>";
+ $conn->Execute('create table tester (id integer)');
+ print "<p>Delete</p>"; flush();
+ $rs = $conn->Execute('delete from tester');
+ print "date=".$conn->GetOne('select getdate()')."<br>";
+}
+?>
+<a href=tmssql.php?do=tmssql>mssql</a>
+<a href=tmssql.php?do=tpear>pear</a>
+<a href=tmssql.php?do=tadodb>adodb</a>
+<?php
+if (!empty($_GET['do'])) {
+ $do = $_GET['do'];
+ $do();
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tests/xmlschema.xml b/html/phpgacl/adodb/tests/xmlschema.xml
new file mode 100644
index 0000000..2a871d2
--- /dev/null
+++ b/html/phpgacl/adodb/tests/xmlschema.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<schema version="0.2">
+ <table name="mytable">
+ <field name="row1" type="I">
+ <descr>An integer row that's a primary key and autoincrements</descr>
+ <KEY/>
+ <AUTOINCREMENT/>
+ </field>
+ <field name="row2" type="C" size="16">
+ <descr>A 16 character varchar row that can't be null</descr>
+ <NOTNULL/>
+ </field>
+ <index name="myindex">
+ <col>row1</col>
+ <col>row2</col>
+ </index>
+ </table>
+ <sql>
+ <descr>SQL to be executed only on specific platforms</descr>
+ <query platform="postgres|postgres7">
+ insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' )
+ </query>
+ <query platform="mysql">
+ insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' )
+ </query>
+ <query platform="mssql">
+ insert into mytable ( row1, row2 ) values ( 12, 'Microsoft stuff' )
+ </query>
+ </sql>
+ <table name="obsoletetable">
+ <DROP/>
+ </table>
+</schema> \ No newline at end of file
diff --git a/html/phpgacl/adodb/toexport.inc.php b/html/phpgacl/adodb/toexport.inc.php
new file mode 100644
index 0000000..e0d6127
--- /dev/null
+++ b/html/phpgacl/adodb/toexport.inc.php
@@ -0,0 +1,133 @@
+<?php
+
+/**
+ * @version V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Code to export recordsets in several formats:
+ *
+ * AS VARIABLE
+ * $s = rs2csv($rs); # comma-separated values
+ * $s = rs2tab($rs); # tab delimited
+ *
+ * TO A FILE
+ * $f = fopen($path,'w');
+ * rs2csvfile($rs,$f);
+ * fclose($f);
+ *
+ * TO STDOUT
+ * rs2csvout($rs);
+ */
+
+// returns a recordset as a csv string
+function rs2csv(&$rs,$addtitles=true)
+{
+ return _adodb_export($rs,',',',',false,$addtitles);
+}
+
+// writes recordset to csv file
+function rs2csvfile(&$rs,$fp,$addtitles=true)
+{
+ _adodb_export($rs,',',',',$fp,$addtitles);
+}
+
+// write recordset as csv string to stdout
+function rs2csvout(&$rs,$addtitles=true)
+{
+ $fp = fopen('php://stdout','wb');
+ _adodb_export($rs,',',',',true,$addtitles);
+ fclose($fp);
+}
+
+function rs2tab(&$rs,$addtitles=true)
+{
+ return _adodb_export($rs,"\t",',',false,$addtitles);
+}
+
+// to file pointer
+function rs2tabfile(&$rs,$fp,$addtitles=true)
+{
+ _adodb_export($rs,"\t",',',$fp,$addtitles);
+}
+
+// to stdout
+function rs2tabout(&$rs,$addtitles=true)
+{
+ $fp = fopen('php://stdout','wb');
+ _adodb_export($rs,"\t",' ',true,$addtitles);
+ if ($fp) fclose($fp);
+}
+
+function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote = '"',$escquote = '"',$replaceNewLine = ' ')
+{
+ if (!$rs) return '';
+ //----------
+ // CONSTANTS
+ $NEWLINE = "\r\n";
+ $BUFLINES = 100;
+ $escquotequote = $escquote.$quote;
+ $s = '';
+
+ if ($addtitles) {
+ $fieldTypes = $rs->FieldTypesArray();
+ reset($fieldTypes);
+ while(list(,$o) = each($fieldTypes)) {
+
+ $v = $o->name;
+ if ($escquote) $v = str_replace($quote,$escquotequote,$v);
+ $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+ $elements[] = $v;
+
+ }
+ $s .= implode($sep, $elements).$NEWLINE;
+ }
+ $hasNumIndex = isset($rs->fields[0]);
+
+ $line = 0;
+ $max = $rs->FieldCount();
+
+ while (!$rs->EOF) {
+ $elements = array();
+ $i = 0;
+
+ if ($hasNumIndex) {
+ for ($j=0; $j < $max; $j++) {
+ $v = $rs->fields[$j];
+ if (!is_object($v)) $v = trim($v);
+ else $v = 'Object';
+ if ($escquote) $v = str_replace($quote,$escquotequote,$v);
+ $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+
+ if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
+ else $elements[] = $v;
+ }
+ } else { // ASSOCIATIVE ARRAY
+ foreach($rs->fields as $v) {
+ if ($escquote) $v = str_replace($quote,$escquotequote,trim($v));
+ $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+
+ if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
+ else $elements[] = $v;
+ }
+ }
+ $s .= implode($sep, $elements).$NEWLINE;
+ $rs->MoveNext();
+ $line += 1;
+ if ($fp && ($line % $BUFLINES) == 0) {
+ if ($fp === true) echo $s;
+ else fwrite($fp,$s);
+ $s = '';
+ }
+ }
+
+ if ($fp) {
+ if ($fp === true) echo $s;
+ else fwrite($fp,$s);
+ $s = '';
+ }
+
+ return $s;
+}
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/tohtml.inc.php b/html/phpgacl/adodb/tohtml.inc.php
new file mode 100644
index 0000000..4e68f579
--- /dev/null
+++ b/html/phpgacl/adodb/tohtml.inc.php
@@ -0,0 +1,195 @@
+<?php
+/*
+ V4.65 22 July 2005 (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
+ Released under both BSD license and Lesser GPL library license.
+ Whenever there is any discrepancy between the two licenses,
+ the BSD license will take precedence.
+
+ Some pretty-printing by Chris Oxenreider <oxenreid@state.net>
+*/
+
+// specific code for tohtml
+GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
+
+$ADODB_ROUND=4; // rounding
+$gSQLMaxRows = 1000; // max no of rows to download
+$gSQLBlockRows=20; // max no of rows per table block
+
+// RecordSet to HTML Table
+//------------------------------------------------------------
+// Convert a recordset to a html table. Multiple tables are generated
+// if the number of rows is > $gSQLBlockRows. This is because
+// web browsers normally require the whole table to be downloaded
+// before it can be rendered, so we break the output into several
+// smaller faster rendering tables.
+//
+// $rs: the recordset
+// $ztabhtml: the table tag attributes (optional)
+// $zheaderarray: contains the replacement strings for the headers (optional)
+//
+// USAGE:
+// include('adodb.inc.php');
+// $db = ADONewConnection('mysql');
+// $db->Connect('mysql','userid','password','database');
+// $rs = $db->Execute('select col1,col2,col3 from table');
+// rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3'));
+// $rs->Close();
+//
+// RETURNS: number of rows displayed
+
+
+function rs2html(&$rs,$ztabhtml=false,$zheaderarray=false,$htmlspecialchars=true,$echo = true)
+{
+$s ='';$rows=0;$docnt = false;
+GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
+
+ if (!$rs) {
+ printf(ADODB_BAD_RS,'rs2html');
+ return false;
+ }
+
+ if (! $ztabhtml) $ztabhtml = "BORDER='1' WIDTH='98%'";
+ //else $docnt = true;
+ $typearr = array();
+ $ncols = $rs->FieldCount();
+ $hdr = "<TABLE COLS=$ncols $ztabhtml><tr>\n\n";
+ for ($i=0; $i < $ncols; $i++) {
+ $field = $rs->FetchField($i);
+ if ($field) {
+ if ($zheaderarray) $fname = $zheaderarray[$i];
+ else $fname = htmlspecialchars($field->name);
+ $typearr[$i] = $rs->MetaType($field->type,$field->max_length);
+ //print " $field->name $field->type $typearr[$i] ";
+ } else {
+ $fname = 'Field '.($i+1);
+ $typearr[$i] = 'C';
+ }
+ if (strlen($fname)==0) $fname = '&nbsp;';
+ $hdr .= "<TH>$fname</TH>";
+ }
+ $hdr .= "\n</tr>";
+ if ($echo) print $hdr."\n\n";
+ else $html = $hdr;
+
+ // smart algorithm - handles ADODB_FETCH_MODE's correctly by probing...
+ $numoffset = isset($rs->fields[0]) ||isset($rs->fields[1]) || isset($rs->fields[2]);
+ while (!$rs->EOF) {
+
+ $s .= "<TR valign=top>\n";
+
+ for ($i=0; $i < $ncols; $i++) {
+ if ($i===0) $v=($numoffset) ? $rs->fields[0] : reset($rs->fields);
+ else $v = ($numoffset) ? $rs->fields[$i] : next($rs->fields);
+
+ $type = $typearr[$i];
+ switch($type) {
+ case 'D':
+ if (empty($v)) $s .= "<TD> &nbsp; </TD>\n";
+ else if (!strpos($v,':')) {
+ $s .= " <TD>".$rs->UserDate($v,"D d, M Y") ."&nbsp;</TD>\n";
+ }
+ break;
+ case 'T':
+ if (empty($v)) $s .= "<TD> &nbsp; </TD>\n";
+ else $s .= " <TD>".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ."&nbsp;</TD>\n";
+ break;
+
+ case 'N':
+ if (abs($v) - round($v,0) < 0.00000001)
+ $v = round($v);
+ else
+ $v = round($v,$ADODB_ROUND);
+ case 'I':
+ $s .= " <TD align=right>".stripslashes((trim($v))) ."&nbsp;</TD>\n";
+
+ break;
+ /*
+ case 'B':
+ if (substr($v,8,2)=="BM" ) $v = substr($v,8);
+ $mtime = substr(str_replace(' ','_',microtime()),2);
+ $tmpname = "tmp/".uniqid($mtime).getmypid();
+ $fd = @fopen($tmpname,'a');
+ @ftruncate($fd,0);
+ @fwrite($fd,$v);
+ @fclose($fd);
+ if (!function_exists ("mime_content_type")) {
+ function mime_content_type ($file) {
+ return exec("file -bi ".escapeshellarg($file));
+ }
+ }
+ $t = mime_content_type($tmpname);
+ $s .= (substr($t,0,5)=="image") ? " <td><img src='$tmpname' alt='$t'></td>\\n" : " <td><a
+ href='$tmpname'>$t</a></td>\\n";
+ break;
+ */
+
+ default:
+ if ($htmlspecialchars) $v = htmlspecialchars(trim($v));
+ $v = trim($v);
+ if (strlen($v) == 0) $v = '&nbsp;';
+ $s .= " <TD>". str_replace("\n",'<br>',stripslashes($v)) ."</TD>\n";
+
+ }
+ } // for
+ $s .= "</TR>\n\n";
+
+ $rows += 1;
+ if ($rows >= $gSQLMaxRows) {
+ $rows = "<p>Truncated at $gSQLMaxRows</p>";
+ break;
+ } // switch
+
+ $rs->MoveNext();
+
+ // additional EOF check to prevent a widow header
+ if (!$rs->EOF && $rows % $gSQLBlockRows == 0) {
+
+ //if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP
+ if ($echo) print $s . "</TABLE>\n\n";
+ else $html .= $s ."</TABLE>\n\n";
+ $s = $hdr;
+ }
+ } // while
+
+ if ($echo) print $s."</TABLE>\n\n";
+ else $html .= $s."</TABLE>\n\n";
+
+ if ($docnt) if ($echo) print "<H2>".$rows." Rows</H2>";
+
+ return ($echo) ? $rows : $html;
+ }
+
+// pass in 2 dimensional array
+function arr2html(&$arr,$ztabhtml='',$zheaderarray='')
+{
+ if (!$ztabhtml) $ztabhtml = 'BORDER=1';
+
+ $s = "<TABLE $ztabhtml>";//';print_r($arr);
+
+ if ($zheaderarray) {
+ $s .= '<TR>';
+ for ($i=0; $i<sizeof($zheaderarray); $i++) {
+ $s .= " <TH>{$zheaderarray[$i]}</TH>\n";
+ }
+ $s .= "\n</TR>";
+ }
+
+ for ($i=0; $i<sizeof($arr); $i++) {
+ $s .= '<TR>';
+ $a = &$arr[$i];
+ if (is_array($a))
+ for ($j=0; $j<sizeof($a); $j++) {
+ $val = $a[$j];
+ if (empty($val)) $val = '&nbsp;';
+ $s .= " <TD>$val</TD>\n";
+ }
+ else if ($a) {
+ $s .= ' <TD>'.$a."</TD>\n";
+ } else $s .= " <TD>&nbsp;</TD>\n";
+ $s .= "\n</TR>\n";
+ }
+ $s .= '</TABLE>';
+ print $s;
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/adodb/xmlschema.dtd b/html/phpgacl/adodb/xmlschema.dtd
new file mode 100644
index 0000000..5aa2350
--- /dev/null
+++ b/html/phpgacl/adodb/xmlschema.dtd
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!DOCTYPE adodb_schema [
+<!ELEMENT schema (table*, sql*)>
+<!ATTLIST schema version CDATA #REQUIRED>
+<!ELEMENT table ((field+|DROP), constraint*, descr?, index*, data*)>
+<!ELEMENT field ((NOTNULL|KEY|PRIMARY)?, (AUTO|AUTOINCREMENT)?, (DEFAULT|DEFDATE|DEFTIMESTAMP)?, NOQUOTE, constraint, descr?)>
+<!ELEMENT data (row+)>
+<!ELEMENT row (f+)>
+<!ELEMENT f (#CDATA)>
+<!ELEMENT descr (#CDATA)>
+<!ELEMENT NOTNULL EMPTY>
+<!ELEMENT KEY EMPTY>
+<!ELEMENT PRIMARY EMPTY>
+<!ELEMENT AUTO EMPTY>
+<!ELEMENT AUTOINCREMENT EMPTY>
+<!ELEMENT DEFAULT EMPTY>
+<!ELEMENT DEFDATE EMPTY>
+<!ELEMENT DEFTIMESTAMP EMPTY>
+<!ELEMENT NOQUOTE EMPTY>
+<!ELEMENT DROP EMPTY>
+<!ELEMENT constraint (#CDATA)>
+<!ATTLIST table name CDATA #REQUIRED platform CDATA #IMPLIED version CDATA #IMPLIED>
+<!ATTLIST field name CDATA #REQUIRED type (C|C2|X|X2|B|D|T|L|I|F|N) #REQUIRED size CDATA #IMPLIED>
+<!ATTLIST data platform CDATA #IMPLIED>
+<!ATTLIST f name CDATA #IMPLIED>
+<!ATTLIST DEFAULT value CDATA #REQUIRED>
+<!ELEMENT index ((col+|DROP), CLUSTERED?, BITMAP?, UNIQUE?, FULLTEXT?, HASH?, descr?)>
+<!ELEMENT col (#CDATA)>
+<!ELEMENT CLUSTERED EMPTY>
+<!ELEMENT BITMAP EMPTY>
+<!ELEMENT UNIQUE EMPTY>
+<!ELEMENT FULLTEXT EMPTY>
+<!ELEMENT HASH EMPTY>
+<!ATTLIST index name CDATA #REQUIRED platform CDATA #IMPLIED>
+<!ELEMENT sql (query+, descr?)>
+<!ELEMENT query (#CDATA)>
+<!ATTLIST sql name CDATA #IMPLIED platform CDATA #IMPLIED, key CDATA, prefixmethod (AUTO|MANUAL|NONE) >
+] >
diff --git a/html/phpgacl/adodb/xsl/convert-0.1-0.2.xsl b/html/phpgacl/adodb/xsl/convert-0.1-0.2.xsl
new file mode 100644
index 0000000..8cd534f
--- /dev/null
+++ b/html/phpgacl/adodb/xsl/convert-0.1-0.2.xsl
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
+
+ <!-- Schema -->
+ <xsl:template match="/">
+ <xsl:comment>
+ADODB XMLSchema
+http://adodb-xmlschema.sourceforge.net
+</xsl:comment>
+
+ <xsl:element name="schema">
+ <xsl:attribute name="version">0.2</xsl:attribute>
+
+ <xsl:apply-templates select="schema/table|schema/sql"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Table -->
+ <xsl:template match="table">
+ <xsl:variable name="table_name" select="@name"/>
+
+ <xsl:element name="table">
+ <xsl:attribute name="name"><xsl:value-of select="$table_name"/></xsl:attribute>
+
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@version) > 0">
+ <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="descr[1]"/>
+
+ <xsl:choose>
+ <xsl:when test="count(DROP) > 0">
+ <xsl:element name="DROP"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="field"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:apply-templates select="constraint"/>
+
+ <xsl:apply-templates select="../index[@table=$table_name]"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Field -->
+ <xsl:template match="field">
+ <xsl:element name="field">
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
+ <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
+
+ <xsl:if test="string-length(@size) > 0">
+ <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="count(PRIMARY) > 0">
+ <xsl:element name="PRIMARY"/>
+ </xsl:when>
+ <xsl:when test="count(KEY) > 0">
+ <xsl:element name="KEY"/>
+ </xsl:when>
+ <xsl:when test="count(NOTNULL) > 0">
+ <xsl:element name="NOTNULL"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="count(AUTO) > 0">
+ <xsl:element name="AUTO"/>
+ </xsl:when>
+ <xsl:when test="count(AUTOINCREMENT) > 0">
+ <xsl:element name="AUTOINCREMENT"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="count(DEFAULT) > 0">
+ <xsl:element name="DEFAULT">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFAULT[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="count(DEFDATE) > 0">
+ <xsl:element name="DEFDATE">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFDATE[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="count(DEFTIMESTAMP) > 0">
+ <xsl:element name="DEFDTIMESTAMP">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:if test="count(NOQUOTE) > 0">
+ <xsl:element name="NOQUOTE"/>
+ </xsl:if>
+
+ <xsl:apply-templates select="constraint"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Constraint -->
+ <xsl:template match="constraint">
+ <xsl:element name="constraint">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Index -->
+ <xsl:template match="index">
+ <xsl:element name="index">
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
+
+ <xsl:apply-templates select="descr[1]"/>
+
+ <xsl:if test="count(CLUSTERED) > 0">
+ <xsl:element name="CLUSTERED"/>
+ </xsl:if>
+
+ <xsl:if test="count(BITMAP) > 0">
+ <xsl:element name="BITMAP"/>
+ </xsl:if>
+
+ <xsl:if test="count(UNIQUE) > 0">
+ <xsl:element name="UNIQUE"/>
+ </xsl:if>
+
+ <xsl:if test="count(FULLTEXT) > 0">
+ <xsl:element name="FULLTEXT"/>
+ </xsl:if>
+
+ <xsl:if test="count(HASH) > 0">
+ <xsl:element name="HASH"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="count(DROP) > 0">
+ <xsl:element name="DROP"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="col"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Index Column -->
+ <xsl:template match="col">
+ <xsl:element name="col">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- SQL QuerySet -->
+ <xsl:template match="sql">
+ <xsl:element name="sql">
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@key) > 0">
+ <xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@prefixmethod) > 0">
+ <xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="descr[1]"/>
+ <xsl:apply-templates select="query"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Query -->
+ <xsl:template match="query">
+ <xsl:element name="query">
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Description -->
+ <xsl:template match="descr">
+ <xsl:element name="descr">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+</xsl:stylesheet> \ No newline at end of file
diff --git a/html/phpgacl/adodb/xsl/convert-0.2-0.1.xsl b/html/phpgacl/adodb/xsl/convert-0.2-0.1.xsl
new file mode 100644
index 0000000..61841b4
--- /dev/null
+++ b/html/phpgacl/adodb/xsl/convert-0.2-0.1.xsl
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
+
+ <!-- Schema -->
+ <xsl:template match="/">
+ <xsl:comment>
+ADODB XMLSchema
+http://adodb-xmlschema.sourceforge.net
+</xsl:comment>
+
+ <xsl:element name="schema">
+ <xsl:attribute name="version">0.1</xsl:attribute>
+
+ <xsl:apply-templates select="schema/table|schema/sql"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Table -->
+ <xsl:template match="table">
+ <xsl:variable name="table_name" select="@name"/>
+
+ <xsl:element name="table">
+ <xsl:attribute name="name"><xsl:value-of select="$table_name"/></xsl:attribute>
+
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@version) > 0">
+ <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="descr[1]"/>
+
+ <xsl:choose>
+ <xsl:when test="count(DROP) > 0">
+ <xsl:element name="DROP"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="field"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:apply-templates select="constraint"/>
+
+ </xsl:element>
+
+ <xsl:apply-templates select="index"/>
+ </xsl:template>
+
+ <!-- Field -->
+ <xsl:template match="field">
+ <xsl:element name="field">
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
+ <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
+
+ <xsl:if test="string-length(@size) > 0">
+ <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="count(PRIMARY) > 0">
+ <xsl:element name="PRIMARY"/>
+ </xsl:when>
+ <xsl:when test="count(KEY) > 0">
+ <xsl:element name="KEY"/>
+ </xsl:when>
+ <xsl:when test="count(NOTNULL) > 0">
+ <xsl:element name="NOTNULL"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="count(AUTO) > 0">
+ <xsl:element name="AUTO"/>
+ </xsl:when>
+ <xsl:when test="count(AUTOINCREMENT) > 0">
+ <xsl:element name="AUTOINCREMENT"/>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:choose>
+ <xsl:when test="count(DEFAULT) > 0">
+ <xsl:element name="DEFAULT">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFAULT[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="count(DEFDATE) > 0">
+ <xsl:element name="DEFDATE">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFDATE[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ <xsl:when test="count(DEFTIMESTAMP) > 0">
+ <xsl:element name="DEFDTIMESTAMP">
+ <xsl:attribute name="value">
+ <xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+ </xsl:choose>
+
+ <xsl:if test="count(NOQUOTE) > 0">
+ <xsl:element name="NOQUOTE"/>
+ </xsl:if>
+
+ <xsl:apply-templates select="constraint"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Constraint -->
+ <xsl:template match="constraint">
+ <xsl:element name="constraint">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Index -->
+ <xsl:template match="index">
+ <xsl:element name="index">
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
+ <xsl:attribute name="table"><xsl:value-of select="../@name"/></xsl:attribute>
+
+ <xsl:apply-templates select="descr[1]"/>
+
+ <xsl:if test="count(CLUSTERED) > 0">
+ <xsl:element name="CLUSTERED"/>
+ </xsl:if>
+
+ <xsl:if test="count(BITMAP) > 0">
+ <xsl:element name="BITMAP"/>
+ </xsl:if>
+
+ <xsl:if test="count(UNIQUE) > 0">
+ <xsl:element name="UNIQUE"/>
+ </xsl:if>
+
+ <xsl:if test="count(FULLTEXT) > 0">
+ <xsl:element name="FULLTEXT"/>
+ </xsl:if>
+
+ <xsl:if test="count(HASH) > 0">
+ <xsl:element name="HASH"/>
+ </xsl:if>
+
+ <xsl:choose>
+ <xsl:when test="count(DROP) > 0">
+ <xsl:element name="DROP"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="col"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Index Column -->
+ <xsl:template match="col">
+ <xsl:element name="col">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- SQL QuerySet -->
+ <xsl:template match="sql">
+ <xsl:element name="sql">
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@key) > 0">
+ <xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@prefixmethod) > 0">
+ <xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="descr[1]"/>
+ <xsl:apply-templates select="query"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Query -->
+ <xsl:template match="query">
+ <xsl:element name="query">
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Description -->
+ <xsl:template match="descr">
+ <xsl:element name="descr">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+</xsl:stylesheet> \ No newline at end of file
diff --git a/html/phpgacl/adodb/xsl/remove-0.2.xsl b/html/phpgacl/adodb/xsl/remove-0.2.xsl
new file mode 100644
index 0000000..079f161
--- /dev/null
+++ b/html/phpgacl/adodb/xsl/remove-0.2.xsl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
+
+ <!-- Schema -->
+ <xsl:template match="/">
+ <xsl:comment>
+ADODB XMLSchema
+http://adodb-xmlschema.sourceforge.net
+</xsl:comment>
+
+ <xsl:comment>
+Uninstallation Schema
+</xsl:comment>
+
+ <xsl:element name="schema">
+ <xsl:attribute name="version">0.2</xsl:attribute>
+
+ <xsl:apply-templates select="schema/table">
+ <xsl:sort select="position()" data-type="number" order="descending"/>
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Table -->
+ <xsl:template match="table">
+ <xsl:if test="count(DROP) = 0">
+ <xsl:element name="table">
+ <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
+
+ <xsl:if test="string-length(@platform) > 0">
+ <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="string-length(@version) > 0">
+ <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="descr[1]"/>
+
+ <xsl:element name="DROP"/>
+ </xsl:element>
+ </xsl:if>
+ </xsl:template>
+
+ <!-- Description -->
+ <xsl:template match="descr">
+ <xsl:element name="descr">
+ <xsl:value-of select="normalize-space(text())"/>
+ </xsl:element>
+ </xsl:template>
+</xsl:stylesheet> \ No newline at end of file
diff --git a/html/phpgacl/docs/examples/example.php b/html/phpgacl/docs/examples/example.php
new file mode 100644
index 0000000..90c251b
--- /dev/null
+++ b/html/phpgacl/docs/examples/example.php
@@ -0,0 +1,164 @@
+<?php
+require_once(dirname(__FILE__).'/gacl.class.php');
+require_once(dirname(__FILE__).'/gacl_api.class.php');
+require_once(dirname(__FILE__).'/admin/gacl_admin.inc.php');
+
+/*
+ * Create an array containing your preferred settings, including how to connect to your database.
+ */
+$gacl_options = array(
+ 'debug' => $gacl_options['debug'],
+ 'items_per_page' => 100,
+ 'max_select_box_items' => 100,
+ 'max_search_return_items' => 200,
+ 'db_type' => $gacl_options['db_type'],
+ 'db_host' => $gacl_options['db_host'],
+ 'db_user' => $gacl_options['db_user'],
+ 'db_password' => $gacl_options['db_password'],
+ 'db_name' => $gacl_options['db_name'],
+ 'db_table_prefix' => $gacl_options['db_table_prefix'],
+ 'caching' => FALSE,
+ 'force_cache_expire' => TRUE,
+ 'cache_dir' => '/tmp/phpgacl_cache',
+ 'cache_expire_time' => 600
+ );
+
+/*
+ * Let's get ready to RUMBLE!!!
+ */
+$gacl_api = new gacl_api($gacl_options);
+
+
+/*
+ * Keep in mind, all of this can be done through the Administration Interface via your browser.
+ */
+
+
+/*
+ * Create an Access Control Object (ACO) section.
+ * Sections serve no other purpose than to categorize ACOs.
+ *
+ * add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+
+$result = $gacl_api->add_object_section('System', 'system', 10, 0, 'ACO'); //Must specifiy Object Type.
+
+if ($result !== FALSE) {
+ echo "Created ACO section sucessfully. <br>\n";
+} else {
+ echo "Error creating ACO section.<br>\n";
+}
+unset($result);
+
+/*
+ * Now that we have our ACO Section created, lets put a Access Control Object (ACO) in it.
+ * You can think of ACO's as "Actions".
+ *
+ * add_object($section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+$result = $gacl_api->add_object('system', 'Enable - Login', 'login', 10, 0, 'ACO'); //Must specifiy Object Type.
+
+if ($result !== FALSE) {
+ echo "Created ACO sucessfully. <br>\n";
+} else {
+ echo "Error creating ACO.<br>\n";
+}
+unset($result);
+
+/*
+ * So we've created our ACO that will enable login access. Now we have create Access Request Objects (ARO)
+ * that will eventually "request" access to login. This is an almost identical process.
+ *
+ * add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ * add_object($section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+$result = $gacl_api->add_object_section('Users', 'users', 10, 0, 'ARO'); //Must specifiy Object Type, notice it is ARO now.
+if ($result !== FALSE) {
+ echo "Created ARO section sucessfully. <br>\n";
+} else {
+ echo "Error creating ARO section.<br>\n";
+}
+unset($result);
+
+//Notice the Object Type. In most cases you'll want to make the ARO value for users a unique User ID,
+//or user name of some sort.
+$result = $gacl_api->add_object('users', 'John Doe', 'john_doe', 10, 0, 'ARO');
+
+if ($result !== FALSE) {
+ echo "Created 'John Doe' ARO sucessfully. <br>\n";
+} else {
+ echo "Error creating 'John Doe' ARO.<br>\n";
+}
+unset($result);
+
+//Lets create two users, just for fun.
+$result = $gacl_api->add_object('users', 'Jane Doe', 'jane_doe', 11, 0, 'ARO');
+
+if ($result !== FALSE) {
+ echo "Created 'Jane Doe' ARO sucessfully. <br>\n";
+} else {
+ echo "Error creating 'Jane Doe' ARO.<br>\n";
+}
+unset($result);
+
+
+/*
+ * There, we now have the building blocks to start creating our ACL matrix from.
+ * Lets give John Doe access to login.
+ *
+ * add_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $acl_id=FALSE )
+ */
+
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('system' => array('login') );
+$aro_array = array('users' => array('john_doe', 'jane_doe') );
+
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing John and Jane Doe access to login!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, $aro_array, NULL, NULL, NULL, $allow, $enabled, $return_value, $note);
+
+if ($result !== FALSE) {
+ echo "Created our first ACL sucessfully. Click <a href=admin/acl_test.php>here</a> to see it in action!<br>\n";
+} else {
+ echo "Error creating ACL.<br>\n";
+}
+unset($result);
+
+echo "<br>\n<br>\n";
+echo "-- Lets test our work --<br>\n";
+
+/*
+ * Awesome, we've setup our ACL system just the way we want it. Now for the easy part,
+ * the code to check ACLs.
+ *
+ * Keep in the mind the API class does not need to be included in scripts that just
+ * check ACLs. This is for performance reasons of course.
+ *
+ * I'm including gacl.class.php again here just to give you the full picture of what you
+ * need in each script to check ACLs.
+ */
+require_once(dirname(__FILE__).'/gacl.class.php');
+$gacl = new gacl($gacl_options); //Use the same options as above.
+
+if ( $gacl->acl_check('system','login','users','john_doe') ) {
+ echo "John Doe has been granted access to login!<br>\n";
+} else {
+ echo "John Doe has been denied access to login!<br>\n";
+}
+
+if ( $gacl->acl_check('system','login','users','jane_doe') ) {
+ echo "Jane Doe has been granted access to login!<br>\n";
+} else {
+ echo "Jane Doe has been denied access to login!<br>\n";
+}
+
+
+echo "<br>\n<br>\nDone! Now how easy was that? <br>\n";
+echo "Remember to check out the <a href=admin/acl_list.php>Administration Interface</a> which can do all of the above in a few simple clicks.<br>\n<br>\n";
+
+echo "<b>If you run this script more then once, you may get some errors, as duplicate object entries can not be created.</b><br>\n";
+?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/Multi-levelGroups.php b/html/phpgacl/docs/examples/millennium_falcon/Multi-levelGroups.php
new file mode 100644
index 0000000..202ce81
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/Multi-levelGroups.php
@@ -0,0 +1,316 @@
+<?php
+/*
+ * PHPGACL Millennium Falcon ACL Multi-levelGroups.php
+ *
+ * Multi-level Groups. (manual p.9)
+ *
+ * The ACL tree for this example should start as:
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO [DENY: Engines]
+ * '-Passengers Group [ALLOW: Lounge]
+ * |-Obi-wan ARO
+ * |-Luke ARO [ALLOW: Guns]
+ * |-R2D2 ARO [ALLOW: Engines]
+ * '-C3PO ARO
+ *
+ * The ACL tree at the end of this example will be:
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO [DENY: Engines]
+ * '-Passengers Group [ALLOW: Lounge]
+ * |- Jedi [ALLOW: Cockpit]
+ | |-Obi-wan ARO
+ * | '-Luke ARO [ALLOW: Guns]
+ * |-R2D2 ARO [ALLOW: Engines]
+ * '-C3PO ARO
+ *
+ */
+
+// Get the phpGACL option settings
+require_once('millenniumFalcon.inc');
+
+/*
+ * Initialise the database - by clearing and running the previous examples.
+ */
+
+// Let's get ready to RUMBLE!!!
+$gacl_api = new gacl_api($gacl_options);
+
+/*
+ * Keep in mind, all of this can be done through the Administration Interface via your browser.
+ */
+
+/*
+ * To keep things clear for this stage the process is as follows:
+ *
+ * 1) Add a Jedi ARO Section.
+ * 2) Add the ARO Group for Jedi, with the parent group being Passengers
+ * 3) Edit Obi-wan and Lukes Object to assign the Section to Jedi.
+ * 4) Assign ACL to Jedi ARO Group.
+ * 5) Test!
+ */
+
+/*
+ * Add an ARO Section for Jedi - so we can assign Passengers to this section.
+ */
+$result = $gacl_api->add_object_section('Jedi', 'jedi', 12, 0, 'ARO'); //Must specifiy Object Type, notice it is ARO now.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created Jedi ARO section sucessfully. <br>\n";
+ } else {
+ echo "Error creating Jedi ARO section.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Add Jedi Group to Passengers
+ *
+ * First get the Passengers Groupid.
+ */
+$result = $gacl_api->get_group_id('passengers');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Got the groupid for Passengers!<br>\n";
+ } else {
+ echo "Error failed getting the groupid for passengers.<br>\n";
+ }
+}
+$passengersGroupID = $result;
+unset($result);
+
+/*
+ * We add the Jedi Group and use the Passengers groupid for the parent.
+ */
+$result = $gacl_api->add_group('jedi','Jedi', $passengersGroupID, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "The Jedi ARO Group has been added to the Passengers Successfully. <br>\n";
+ } else {
+ echo "Error creating the Jedi ARO Group.<br>\n";
+ }
+}
+// Get the Jedi Group Id that has been returned from: add_group.
+$jediGroupID = $result;
+unset($result);
+
+/*
+ * The tree now looks like:
+ *
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO [DENY: Engines]
+ * '-Passengers Group [ALLOW: Lounge]
+ * | '- Jedi
+ * |-Obi-wan ARO
+ * |-Luke ARO [ALLOW: Guns]
+ * |-R2D2 ARO [ALLOW: Engines]
+ * '-C3PO ARO
+ *
+ * So we need to reassign Obi-wan and Luke from the Passengers Group, to the
+ * Jedi group.
+ *
+ * So we do this by editing Obi-wans and Lukes object which links them to the Passengers Section.
+ * edit_object($object_id, $section_value, $name, $value=0, $order=0, $hidden=0, $object_type)
+ */
+
+/*
+ * First we need the object_id's!
+ * get_object_id($section_value, $value, $object_type)
+ */
+$result = $gacl_api->get_object_id('passengers','obi-wan','aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Got 'Passengers > Obi-wan' objectid!<br>\n";
+ } else {
+ echo "Error getting 'Passengers > Obi-wan' objectid.<br>\n";
+ }
+}
+$obiWanObjectId = $result;
+unset($result);
+
+$result = $gacl_api->get_object_id('passengers','luke','aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Got 'Passengers > Luke' objectid!<br>\n";
+ } else {
+ echo "Error getting 'Passengers > Luke' objectid.<br>\n";
+ }
+}
+$lukeObjectId = $result;
+unset($result);
+
+/*
+ * Excellent, we are nearly there!
+ * Next we need to remove Obi-wans and Lukes assigned AROs to the Passengers Group
+ * and add the AROs to the Jedi ARO Group.
+ *
+ * get_group_id($value, $name, $group_type)
+ * del_group_object($group_id, $object_section_value, $object_value, $group_type)
+ * add_group_object($group_id, $object_section_value, $object_value, $group_type)
+ */
+
+/*
+ * First lets get the Passengers ARO GroupID
+ */
+$result = $gacl_api->get_group_id('passengers', 'Passengers', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Got 'Passengers' ARO GroupID!<br>\n";
+ } else {
+ echo "Error getting 'Passengers' ARO GroupID!.<br>\n";
+ }
+}
+$passengersGroupId = $result;
+unset($result);
+$gacl_api->_DEBUG = true;
+/*
+ * Now lets delete Obi-Wans and Lukes ARO GROUP ARO connections.
+ */
+$result = $gacl_api->del_group_object($passengersGroupId, 'passengers', 'obi-wan', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Deleted 'Passengers > Obi-Wan' ARO Group > ARO Connection!<br>\n";
+ } else {
+ echo "Error deleting 'Passengers > Obi-Wan' ARO Group > ARO Connection!<br>\n";
+ }
+}
+unset($result);
+
+$result = $gacl_api->del_group_object($passengersGroupId, 'passengers', 'luke', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Deleted 'Passengers > Luke' ARO Group > ARO Connection!<br>\n";
+ } else {
+ echo "Error deleting 'Passengers > Luke' ARO Group > ARO Connection!<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * OK - we now have the id's to edit - lets change the Section_Value to 'jedi'
+ * before we add the new AROs to the ARO Group.
+ */
+$result = $gacl_api->edit_object($obiWanObjectId, 'jedi', 'Obi-wan', 'obi-wan', 10, 0, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Edited 'Passengers > Obi-wan' Successfully - now its: 'Jedi > Obi-wan'!<br>\n";
+ } else {
+ echo "Error editing 'Passengers > Obi-wan' Object.<br>\n";
+ }
+}
+unset($result);
+$result = $gacl_api->edit_object($lukeObjectId, 'jedi', 'Luke', 'luke', 11, 0, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Edited 'Passengers > Luke' Successfully - now its: 'Jedi > Luke'!<br>\n";
+ } else {
+ echo "Error editing 'Passengers > Luke' Object.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Ok lets get the Jedi ARO GroupID
+ */
+$result = $gacl_api->get_group_id('jedi', 'Jedi', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Got 'Jedi' ARO GroupID!<br>\n";
+ } else {
+ echo "Error getting 'Jedi' ARO GroupID!.<br>\n";
+ }
+}
+$jediGroupId = $result;
+unset($result);
+/*
+ * Now lets add Obi-Wans and Lukes ARO GROUP ARO connections to Jedi.
+ */
+$result = $gacl_api->add_group_object($jediGroupId, 'jedi', 'obi-wan', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Jedi > Obi-Wan' ARO Group > ARO Connection!<br>\n";
+ } else {
+ echo "Error creating 'Jedi > Obi-Wan' ARO Group > ARO Connection!<br>\n";
+ }
+}
+unset($result);
+
+$result = $gacl_api->add_group_object($jediGroupId, 'jedi', 'luke', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Jedi > Luke' ARO Group > ARO Connection!<br>\n";
+ } else {
+ echo "Error creating 'Jedi > Luke' ARO Group > ARO Connection!<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Allow the Jedi ARO Group Access to the Cockpit:
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('cockpit') );
+$aro_array_GroupID =array($gacl_api->get_group_id('jedi') );
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing the Jedi to have Access to the cockpit!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, NULL, $aro_array_GroupID, NULL, NULL, $allow, $enabled, $return_value, $note, 'user');
+if ($outputDebug == TRUE){
+if ($result !== FALSE) {
+ echo "Created our Jedi Cockpit Access ACL sucessfully!<br>\n";
+} else {
+ echo "Error creating ACL.<br>\n";
+}
+}
+unset($result);
+
+if ($outputDebug == TRUE){
+echo "<br>\n";
+echo "=================================================================================================<br>\n";
+echo "-- Lets test the Jedi ACL for Obi-wan! --<br>\n";
+echo "=================================================================================================<br>\n";
+}
+// Lets check if Obi-wan has access to the Lounge
+if ( $gacl_api->acl_check('access', 'lounge', 'jedi', 'obi-wan') ) {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan still has access to the lounge!<br>\n";
+ }
+} else {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan no longer has access to the lounge! (Not good!)<br>\n";
+ }
+}
+// Lets check if Obi-wan has access to the Cockpit
+if ( $gacl_api->acl_check('access', 'cockpit', 'jedi', 'obi-wan') ) {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan has access to the Cockpit! (the Jedi ACL Worked!)<br>\n";
+ }
+} else {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan can't access to the Cockpit! (Something went wrong!)<br>\n";
+ }
+}
+// Lets check if Obi-wan has access to the Engines - should fail!
+if ( $gacl_api->acl_check('access', 'engines', 'jedi', 'obi-wan') ) {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan has access to the Engines! (How'd he get in there?)<br>\n";
+ }
+} else {
+ if ($outputDebug == TRUE){
+ echo "Obi-Wan can't access to the Engines! (Good hes not allowed there!)<br>\n";
+ }
+}
+
+if ($outputDebug == TRUE){
+echo "<br>\n<br>\nDone! Not difficult really! <br>\n";
+echo "Remember to check out the <a href='../../../admin/acl_list.php'>Administration Interface</a> which can do all of the above in a few simple clicks.<br>\n<br>\n";
+}
+?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/definingAccessControl.php b/html/phpgacl/docs/examples/millennium_falcon/definingAccessControl.php
new file mode 100644
index 0000000..c5a6ced
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/definingAccessControl.php
@@ -0,0 +1,472 @@
+<?php
+/*
+ * PHPGACL Millennium Falcon ACL definingAccessControl.php
+ *
+ * Defining access Control with phpGACL. (manual p.7-8)
+ *
+ * The ACL tree for this example is:
+ * Millennium Falcon Passengers Group
+ * |-Crew Group
+ * | |-Han ARO
+ * | '-Chewie ARO
+ * '-Passengers Group
+ * |-Obi-wan ARO
+ * |-Luke ARO
+ * |-R2D2 ARO
+ * '-C3PO ARO
+ */
+
+/*
+ * Initialise the database - by clearing the database.
+ */
+
+// Let's get ready to RUMBLE!!!
+$gacl_api = new gacl_api($gacl_options);
+
+/*
+ * Keep in mind, all of this can be done through the Administration Interface via your browser.
+ */
+
+/*
+ * Create an Access Control Object (ACO) section.
+ * Sections serve no other purpose than to categorize ACOs.
+ *
+ * add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+
+$result = $gacl_api->add_object_section('Access', 'access', 10, 0, 'ACO'); //Must specifiy Object Type.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created ACO section sucessfully. <br>\n";
+ } else {
+ echo "Error creating ACO section.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Now that we have our ACO Section created, lets put a Access Control Object (ACO) in it.
+ * You can think of ACO's as "Actions".
+ * In this case the Action is the rooms the passengers have Access to.
+ * The ACOs required for the Millennium Falcon are Access to:
+ * - Lounge
+ * - Engines
+ * - Guns
+ * - Cockpit
+ *
+ * add_object($section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+$result = $gacl_api->add_object('access', 'Lounge', 'lounge', 10, 0, 'ACO'); //Must specifiy Object Type.
+if ($outputDebug == TRUE)
+{
+ if ($result !== FALSE) {
+ echo "Created Lounge ACO sucessfully. <br>\n";
+ } else {
+ echo "Error creating Lounge ACO.<br>\n";
+ }
+}
+unset($result);
+
+// Add the Engines ACO
+$result = $gacl_api->add_object('access', 'Engines', 'engines', 10, 0, 'ACO'); //Must specifiy Object Type.
+if ($outputDebug == TRUE)
+{
+ if ($result !== FALSE) {
+ echo "Created Engines ACO sucessfully. <br>\n";
+ } else {
+ echo "Error creating Engines ACO.<br>\n";
+ }
+}
+unset($result);
+
+// Add the Guns ACO
+$result = $gacl_api->add_object('access', 'Guns', 'guns', 10, 0, 'ACO'); //Must specifiy Object Type.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created Guns ACO sucessfully. <br>\n";
+ } else {
+ echo "Error creating Guns ACO.<br>\n";
+ }
+}
+unset($result);
+
+// Add the Cockpit ACO
+$result = $gacl_api->add_object('access', 'Cockpit', 'cockpit', 10, 0, 'ACO'); //Must specifiy Object Type.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created Cockpit ACO sucessfully. <br>\n";
+ } else {
+ echo "Error creating Cockpit ACO.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * So we've created our ACOs that will be used to control who has access to where.
+ * Now we create Access Request Objects (ARO) Sections to assign to the passengers.
+ * The Sections are in this example are:
+ * - Crew
+ * - Passengers
+ *
+ * This is an almost identical process as for the ACOs.
+ *
+ * add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+$result = $gacl_api->add_object_section('Crew', 'crew', 10, 0, 'ARO'); //Must specifiy Object Type, notice it is ARO now.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created Crew ARO section sucessfully. <br>\n";
+ } else {
+ echo "Error creating Crew ARO section.<br>\n";
+ }
+}
+unset($result);
+
+// Add Passengers Section
+$result = $gacl_api->add_object_section('Passengers', 'passengers', 11, 0, 'ARO'); //Must specifiy Object Type, notice it is ARO now.
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created Passengers ARO section sucessfully. <br>\n";
+ } else {
+ echo "Error creating Passengers ARO section.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Now we have our sections, now we create Access Request Objects (ARO).
+ * The passengers of the Millenium Falcon:
+ *
+ * -Han
+ * -Chewie
+ * -Obi-wan
+ * -Luke
+ * -R2D2
+ * -C3PO
+ *
+ * So, we will create AROs for the Two Sections.
+ * add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL)
+ */
+
+// Add Han to the Crew
+$result = $gacl_api->add_object('crew', 'Han', 'han', 10, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Han' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'Han' ARO.<br>\n";
+ }
+}
+unset($result);
+
+// Add Chewie to the Crew
+$result = $gacl_api->add_object('crew', 'Chewie', 'chewie', 11, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Chewie' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'Chewie' ARO.<br>\n";
+ }
+}
+unset($result);
+
+// Add Obi-wan to the Passengers
+$result = $gacl_api->add_object('passengers', 'Obi-wan', 'obi-wan', 10, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Obi-wan' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'Obi-wan' ARO.<br>\n";
+ }
+}
+unset($result);
+
+// Add Luke to the Passengers
+$result = $gacl_api->add_object('passengers', 'Luke', 'luke', 11, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'Luke' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'Luke' ARO.<br>\n";
+ }
+}
+unset($result);
+
+// Add R2D2 to the Passengers
+$result = $gacl_api->add_object('passengers', 'R2D2', 'r2d2', 12, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'R2D2' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'R2D2' ARO.<br>\n";
+ }
+}
+unset($result);
+
+// Add C3PO to the Passengers
+$result = $gacl_api->add_object('passengers', 'C3PO', 'c3po', 13, 0, 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created 'C3PO' ARO sucessfully. <br>\n";
+ } else {
+ echo "Error creating 'C3PO' ARO.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * The Millennium Falcon has now got all its passengers.
+ * Now we need to add the groups:
+ *
+ * Millennium Falcon Passengers Group
+ * |-Crew Group
+ * '-Passengers Group
+ *
+ * add_group($value, $name, $parent_id, $group_type);
+ */
+
+
+/*
+ * So working from the Top lets add the Millennium Falcon Passengers Group
+ */
+$result = $gacl_api->add_group('millennium_falcon_passengers','Millennium Falcon Passengers', 0, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created our Millennium Falcon Passengers ARO Group Successfully. <br>\n";
+ } else {
+ echo "Error Millennium Falcon Passengers ARO Group.<br>\n";
+ }
+}
+$millenniumFalconPassengersGroupID = $result;
+unset($result);
+
+/*
+ * Next its the Crew Group
+ */
+$result = $gacl_api->add_group('crew','Crew', $millenniumFalconPassengersGroupID, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created our Crew ARO Group Successfully. <br>\n";
+ } else {
+ echo "Error Crew ARO Group.<br>\n";
+ }
+}
+$crewGroupID = $result;
+unset($result);
+
+/*
+ * Next its the Passengers Group
+ */
+$result = $gacl_api->add_group('passengers','Passengers', $millenniumFalconPassengersGroupID, 'aro');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created our Passengers ARO Group Successfully. <br>\n";
+ } else {
+ echo "Error Passengers ARO Group.<br>\n";
+ }
+}
+$passengersGroupID = $result;
+unset($result);
+
+/*
+ * The Millennium Falcon has now got all its passengers & groups.
+ * But we need to assign the passengers to the groups, like so:
+ *
+ * Millennium Falcon Passengers Group
+ * |-Crew Group
+ * | |-Han ARO
+ * | '-Chewie ARO
+ * '-Passengers Group
+ * |-Obi-wan ARO
+ * |-Luke ARO
+ * |-R2D2 ARO
+ * '-C3PO ARO
+ *
+ * add_group_object($group_id, $object_section_value, $object_value, $group_type='ARO')
+ */
+
+/*
+ * Assign Han to the Crew Group.
+ */
+$result = $gacl_api->add_group_object($crewGroupID, 'crew', 'han', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'Han' to the Crew ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'Han' to the Crew ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Assign Chewie to the Crew Group.
+ */
+$result = $gacl_api->add_group_object($crewGroupID, 'crew', 'chewie', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'Chewie' to the Crew ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'Chewie' to the Crew ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Assign Obi-wan to the Passengers Group.
+ */
+$result = $gacl_api->add_group_object($passengersGroupID, 'passengers', 'obi-wan', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'Obi-wan' to the Passengers ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'Obi-wan' to the Passengers ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Assign Luke to the Passengers Group.
+ */
+$result = $gacl_api->add_group_object($passengersGroupID, 'passengers', 'luke', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'Luke' to the Passengers ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'Luke' to the Passengers ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Assign R2D2 to the Passengers Group.
+ */
+$result = $gacl_api->add_group_object($passengersGroupID, 'passengers', 'r2d2', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'R2D2' to the Passengers ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'R2D2' to the Passengers ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Assign C3PO to the Passengers Group.
+ */
+$result = $gacl_api->add_group_object($passengersGroupID, 'passengers', 'c3po', 'ARO');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Assigned 'C3PO' to the Passengers ARO Group. <br>\n";
+ } else {
+ echo "Error assigning 'C3PO' to the Passengers ARO Group.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * The Millennium Falcon has now got all its passengers & groups.
+ * The passengers are assigned to their groups, but as yet no one has permission to
+ * to go anywhere - we need to create ACLs, shown in the tree by the ALLOW notation.
+ *
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO
+ * '-Passengers Group [ALLOW: Lounge]
+ * |-Obi-wan ARO
+ * |-Luke ARO
+ * |-R2D2 ARO
+ * '-C3PO ARO
+ *
+ * add_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $section_value=NULL )
+ */
+
+/*
+ * First The Crew:
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('cockpit','engines','guns','lounge') );
+$aro_array_GroupID =array($gacl_api->get_group_id('crew') );
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing the Crew to have Access to: cockpit, engines, guns and lounge!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, NULL, $aro_array_GroupID, NULL, NULL, $allow, $enabled, $return_value, $note, 'user');
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created our first ACL sucessfully!<br>\n";
+ } else {
+ echo "Error creating ACL.<br>\n";
+ }
+}
+unset($result);
+
+/*
+ * Now The Passengers:
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('lounge') );
+$aro_array_GroupID = array($gacl_api->get_group_id('Passengers'));
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing the Passengers to have Access to the lounge!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, NULL, $aro_array_GroupID, NULL, NULL, $allow, $enabled, $return_value, $note);
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Created our second ACL sucessfully! Click <a href='../../../admin/acl_test.php'>here</a> to see it in action!<br>\n";
+ } else {
+ echo "Error creating ACL.<br>\n";
+ }
+}
+unset($result);
+if ($outputDebug == TRUE){
+ echo "<br>\n";
+ echo "=================================================================================================<br>\n";
+ echo "-- Good stuff thats it all done as of the top of Page 8! - so lets test a couple of scenarios --<br>\n";
+ echo "=================================================================================================<br>\n";
+}
+/*
+ * Awesome, we've setup our ACL system just the way we want it. Now for the easy part,
+ * the code to check ACLs.
+ *
+ * Keep in the mind the API class does not need to be included in scripts that just
+ * check ACLs. This is for performance reasons of course.
+ *
+ * I'm including gacl.class.php again here just to give you the full picture of what you
+ * need in each script to check ACLs.
+ */
+require_once(dirname(__FILE__).'/../../../gacl.class.php');
+$gacl = new gacl($gacl_options); //Use the same options as above.
+
+// Lets check Han has access to the cockpit
+ if ( $gacl->acl_check('access', 'cockpit', 'crew', 'han') ) {
+ if ($outputDebug == TRUE){
+ echo "Han has been granted access to the cockpit!<br>\n";
+ }
+ } else {
+ if ($outputDebug == TRUE){
+ echo "Han has been denied access to the cockpit!<br>\n";
+ }
+ }
+
+// Lets check Luke has access to the cockpit *should fail!
+ if ( $gacl->acl_check('access', 'cockpit', 'crew', 'Luke') ) {
+ if ($outputDebug == TRUE){
+ echo "Luke has been granted access to the cockpit!<br>\n";
+ }
+ } else {
+ if ($outputDebug == TRUE){
+ echo "Luke has been denied access to the cockpit! (good he's not allowed there!)<br>\n";
+ }
+ }
+
+if ($outputDebug == TRUE){
+ echo "<br>\n<br>\nDone! Easy - lots of setting up done in this example - but next we'll extend this setup <br>\n";
+ echo "Remember to check out the <a href='../../../admin/acl_list.php'>Administration Interface</a> which can do all of the above in a few simple clicks.<br>\n<br>\n";
+}
+?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/fineGrainAccessControl.php b/html/phpgacl/docs/examples/millennium_falcon/fineGrainAccessControl.php
new file mode 100644
index 0000000..120572a
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/fineGrainAccessControl.php
@@ -0,0 +1,138 @@
+<?php
+/*
+ * PHPGACL Millennium Falcon ACL fineGrainAccessControl.php
+ *
+ * Fine-grain access Control. (manual p.8-9)
+ *
+ * The ACL tree for this example should start as:
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO
+ * '-Passengers Group [ALLOW: Lounge]
+ * |-Obi-wan ARO
+ * |-Luke ARO
+ * |-R2D2 ARO
+ * '-C3PO ARO
+ *
+ * The ACL tree at the end of this example will be:
+ * Millennium Falcon Passengers Group
+ * |-Crew Group [ALLOW: ALL]
+ * | |-Han ARO
+ * | '-Chewie ARO [DENY: Engines]
+ * '-Passengers Group [ALLOW: Lounge]
+ * |-Obi-wan ARO
+ * |-Luke ARO [ALLOW: Guns]
+ * |-R2D2 ARO [ALLOW: Engines]
+ * '-C3PO ARO
+ */
+
+/*
+ * Initialise the database - by clearing and running the previous examples.
+ */
+
+// Let's get ready to RUMBLE!!!
+$gacl_api = new gacl_api($gacl_options);
+
+/*
+ * Keep in mind, all of this can be done through the Administration Interface via your browser.
+ */
+
+/*
+ * Deny Chewie Access to the Engines!
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('engines') );
+$aro_array = array('crew' => array('chewie') );
+$allow = FALSE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Denying Chewie access to the engines!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, $aro_array, NULL, NULL, NULL, $allow, $enabled, $return_value, $note);
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Chewie has been denied access to the Engines!<br>\n";
+ } else {
+ echo "Error creating ACL.<br>\n";
+ }
+ echo "<br>\n";
+ echo "=================================================================================================<br>\n";
+ echo "-- Lets test the new ACL for Chewie! --<br>\n";
+ echo "=================================================================================================<br>\n";
+}
+// Lets check if Chewie has access to the engines
+if ( $gacl_api->acl_check('access', 'engines', 'crew', 'chewie') ) {
+ if ($outputDebug == TRUE){
+ echo "Chewie still has access to the engines!<br>\n";
+ }
+} else {
+ if ($outputDebug == TRUE){
+ echo "Chewie has been denied access to the engines! (Han saves the hyperdrive from further distress!)<br>\n";
+ }
+}
+// Lets check if Chewie still has access to the cockpit
+if ( $gacl_api->acl_check('access', 'cockpit', 'crew', 'chewie') ) {
+ if ($outputDebug == TRUE){
+ echo "And Chewie still has access to the cockpit! (Hans plan worked!)<br>\n";
+ }
+} else {
+ if ($outputDebug == TRUE){
+ echo "Chewie has been denied access to the cockpit! (Not good - somethings not right!)<br>\n";
+ }
+}
+
+if ($outputDebug == TRUE){
+ echo "<br>\n";
+ echo "=================================================================================================<br>\n";
+ echo "-- Under Attack - Allow Luke Access to the Guns and R2D2 to the Engines! --<br>\n";
+ echo "=================================================================================================<br>\n";
+}
+/*
+ * Allow Luke Access to the Guns!
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('guns') );
+$aro_array = array('passengers' => array('luke') );
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing Luke access to the guns!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, $aro_array, NULL, NULL, NULL, $allow, $enabled, $return_value, $note);
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "Luke has been granted access to the Guns!<br>\n";
+ } else {
+ echo "Error creating ACL - Luke can't get to the Guns.<br>\n";
+ }
+}
+
+/*
+ * Allow R2D2 Access to the Engines!
+ */
+//Associative array, with Object Section Value => array( Object Value ) pairs.
+$aco_array = array('access' => array('engines') );
+$aro_array = array('passengers' => array('r2d2') );
+$allow = TRUE;
+$enabled = TRUE;
+$return_value = NULL;
+$note = "Allowing R2D2 access to the engines!";
+
+//The NULL values are for the more advanced options such as groups, and AXOs. Refer to the manual for more info.
+$result = $gacl_api->add_acl($aco_array, $aro_array, NULL, NULL, NULL, $allow, $enabled, $return_value, $note);
+if ($outputDebug == TRUE){
+ if ($result !== FALSE) {
+ echo "R2D2 has been granted access to the Engines!<br>\n";
+ } else {
+ echo "Error creating ACL - R2D2 can't get to the Engines! (we're doomed says C3PO!).<br>\n";
+ }
+}
+
+if ($outputDebug == TRUE){
+ echo "<br>\n<br>\nDone! Now how easy was that? <br>\n";
+ echo "Remember to check out the <a href='../../../admin/acl_list.php'>Administration Interface</a> which can do all of the above in a few simple clicks.<br>\n<br>\n";
+}
+?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/footer.php b/html/phpgacl/docs/examples/millennium_falcon/footer.php
new file mode 100644
index 0000000..0d83d71
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/footer.php
@@ -0,0 +1,13 @@
+<div id="bot-br">
+ <div id="bot-bl">
+ <div id="bot-tr">
+ <div id="bot-tl">
+ <a href="http://phpgacl.sourceforge.net">phpGACL</a> v3.3.3 (Schema v2.1) - Generic Access Control Lists
+ <br />
+ Copyright &copy; 2004 <a href="about.php">Mike Benoit</a>
+ </div>
+ </div>
+ </div>
+</div>
+ </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/examples/millennium_falcon/header.php b/html/phpgacl/docs/examples/millennium_falcon/header.php
new file mode 100644
index 0000000..f8fbdd0
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/header.php
@@ -0,0 +1,23 @@
+<html>
+<head>
+ <title>phpGACL Millennium Falcon API</title>
+ <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+ <link rel="stylesheet" href="../../../admin/admin.css" type="text/css" title="phpGACL Millennium Demo" />
+</head>
+<body>
+<div id="top-tr">
+ <div id="top-tl">
+ <div id="top-br">
+ <div id="top-bl">
+ <h1><span>phpGACL</span></h1>
+ <h2>phpGACL Millennium Falcon API demo.</h2>
+ <ul id="menu">
+ <li <?php if($URL == 'index'){ echo("class='current'");}?>><a href='index.php?do=index'>Index</a></li>
+ <li <?php if($URL == 'example1'){ echo("class='current'");}?>><a href='index.php?do=example1'>Defining Access Control</a></li>
+ <li <?php if($URL == 'example2'){ echo("class='current'");}?>><a href='index.php?do=example2'>Fine-grain Access Control</a></li>
+ <li <?php if($URL == 'example3'){ echo("class='current'");}?>><a href='index.php?do=example3'>Multi-level Groups</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/index.php b/html/phpgacl/docs/examples/millennium_falcon/index.php
new file mode 100644
index 0000000..d7f635e
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/index.php
@@ -0,0 +1,53 @@
+<?php
+if (isset($_GET['do'])){
+ $URL = $_GET['do'];
+} else {
+ $URL = 'index';
+}
+
+include_once('header.php');
+?>
+<div id="mid-r">
+ <div id="mid-l">
+ <div>
+ <p>
+ <b>Millenium Falcon API Example by Ross Lawley.</b>
+ </p>
+<?php
+include_once('millenniumFalcon.inc');
+ switch ($URL) {
+ case 'index':
+ include('welcome.php');
+ break;
+ case 'example1':
+ $outputDebug = true;
+ $gacl_api = new gacl_api($gacl_options);
+ $gacl_api->clear_database();
+ include('definingAccessControl.php');
+ break;
+ case 'example2':
+ $outputDebug = false;
+ $gacl_api = new gacl_api($gacl_options);
+ $gacl_api->clear_database();
+ include('definingAccessControl.php');
+ $outputDebug = true;
+ include('fineGrainAccessControl.php');
+ break;
+ case 'example3':
+ $outputDebug = false;
+ $gacl_api = new gacl_api($gacl_options);
+ $gacl_api->clear_database();
+ include('definingAccessControl.php');
+ include('fineGrainAccessControl.php');
+ $outputDebug = true;
+ include('Multi-levelGroups.php');
+ break;
+ default:
+ include('welcome.php');
+ break;
+}
+?>
+ </div>
+ </div>
+</div>
+<?php include_once('footer.php'); ?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/millenniumFalcon.inc b/html/phpgacl/docs/examples/millennium_falcon/millenniumFalcon.inc
new file mode 100644
index 0000000..99d730e
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/millenniumFalcon.inc
@@ -0,0 +1,27 @@
+<?php
+require_once(dirname(__FILE__).'/../../../gacl.class.php');
+require_once(dirname(__FILE__).'/../../../gacl_api.class.php');
+require_once(dirname(__FILE__).'/../../../admin/gacl_admin.inc.php');
+
+/*
+ * Create an array containing your preferred settings, including how to connect to your database.
+ */
+ //'db_name' => $gacl_options['db_name'],
+$gacl_options = array(
+ 'debug' => $gacl_options['debug'],
+ 'items_per_page' => 100,
+ 'max_select_box_items' => 100,
+ 'max_search_return_items' => 200,
+ 'db_type' => $gacl_options['db_type'],
+ 'db_host' => $gacl_options['db_host'],
+ 'db_user' => $gacl_options['db_user'],
+ 'db_password' => $gacl_options['db_password'],
+ 'db_name' => $gacl_options['db_name'],
+ 'db_table_prefix' => $gacl_options['db_table_prefix'],
+ 'caching' => FALSE,
+ 'force_cache_expire' => TRUE,
+ 'cache_dir' => '/tmp/phpgacl_cache',
+ 'cache_expire_time' => 600
+ );
+
+?>
diff --git a/html/phpgacl/docs/examples/millennium_falcon/welcome.php b/html/phpgacl/docs/examples/millennium_falcon/welcome.php
new file mode 100644
index 0000000..37223a5
--- /dev/null
+++ b/html/phpgacl/docs/examples/millennium_falcon/welcome.php
@@ -0,0 +1,34 @@
+ <p>
+ <b>Pre-Requirements:</b>
+ <ul>
+ <li><b>You should setup a phpGACL database and edit your gacl.class.php to point to the database.</b></li>
+ <?php
+ require_once('millenniumFalcon.inc');
+ echo "<li><b>CURRENT DATABASE: ".$gacl_options['db_name']."</b></li>";
+ echo "<li><font color='red' size='+1'><b>WARNING: THE ".$gacl_options['db_name']." DATABASEWILL BE RESET IF YOU RUN ANY EXAMPLE!</b></font></li>";
+ ?>
+ </ul>
+</p>
+<p>
+ These 3 examples work hand in hand with the phpGACL documentation Millenium Falcon example, which can be found here: <a href='../docs/manual.pdf' target='_new'>phpGACL documentation</a><br />
+ Run the examples and have a look at the code, but don't forget to check out phpGACLs excellent <a href='../../../admin/index.php' target='_new'>admin suite</a>.
+</p>
+<p>
+ <ul>
+ <li><a href='index.php?do=example1'>Defining Access Control</a> Manual pages: 7-8</li>
+ <li><a href='index.php?do=example2'>Fine-grain Access Control</a> Manual pages: 8-9</li>
+ <li><a href='index.php?do=example3'>Multi-level Groups</a> Manual pages: 9</li>
+ </ul>
+ </p>
+ <p>
+ By now you should have a good idea about the phpGACL API and how to:
+ <ul>
+ <li> Creating ACO sections and ACOs.</li>
+ <li> Creating ARO sections and AROs.</li>
+ <li> Creating ARO Groups and assigning AROs.</li>
+ <li> Editing Groups.</li>
+ <li> Deleting Groups / Objects.</li>
+ </ul>
+ The rest of the API functions are in the manual!
+ </p>
+ <br /><br /><br /><br />
diff --git a/html/phpgacl/docs/manual.html b/html/phpgacl/docs/manual.html
new file mode 100644
index 0000000..01a229d
--- /dev/null
+++ b/html/phpgacl/docs/manual.html
@@ -0,0 +1,1308 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-1">
+ <TITLE>phpGACL</TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.9.100 (Linux)">
+ <META NAME="AUTHOR" CONTENT="jrussell">
+ <META NAME="CREATED" CONTENT="20030206;8320000">
+ <META NAME="CHANGEDBY" CONTENT="Mike">
+ <META NAME="CHANGED" CONTENT="20050903;14522300">
+ <META NAME="SDFOOTNOTE" CONTENT=";;;;P">
+ <META NAME="SDENDNOTE" CONTENT="ARABIC">
+ <STYLE>
+ <!--
+ @page { size: 8.27in 11.69in; margin: 1.18in }
+ P { margin-top: 0.08in; margin-bottom: 0.08in; color: #000000; line-height: 0.17in; widows: 2; orphans: 2 }
+ P.western { font-family: "Helv", "Arial", sans-serif; font-size: 10pt; so-language: en-US }
+ P.cjk { font-family: "Times New Roman", serif; font-size: 10pt; so-language: ja-JP }
+ H1 { margin-bottom: 0.04in; border-top: none; border-bottom: 1px solid #4700b8; border-left: 5.00pt solid #4700b8; border-right: none; padding-top: 0in; padding-bottom: 0.02in; padding-left: 0.02in; padding-right: 0in; color: #000000; widows: 2; orphans: 2; page-break-before: always }
+ H1.western { font-family: "Arial", sans-serif; font-size: 16pt; so-language: en-GB }
+ H1.cjk { font-family: "MS Mincho", "MS ??", monospace; font-size: 16pt; so-language: ja-JP }
+ H1.ctl { font-family: "Arial Unicode MS"; font-size: 12pt; font-weight: medium }
+ H2 { margin-bottom: 0.04in; color: #000000; widows: 2; orphans: 2 }
+ H2.western { font-family: "Georgia", serif; font-size: 13pt; so-language: en-GB; font-style: normal }
+ H2.cjk { font-family: "MS Mincho", "MS ??", monospace; font-size: 14pt; so-language: ja-JP; font-style: italic }
+ H2.ctl { font-family: "Arial Unicode MS"; font-size: 12pt; font-weight: medium }
+ H3 { margin-top: 0.08in; margin-bottom: 0.08in; color: #000000; line-height: 0.17in; widows: 2; orphans: 2 }
+ H3.western { font-family: "Helv", "Arial", sans-serif; font-size: 10pt; so-language: en-GB }
+ H3.cjk { font-family: "Times New Roman", serif; font-size: 10pt; so-language: ja-JP }
+ H3.ctl { font-family: "Arial Unicode MS"; font-size: 12pt; font-weight: medium }
+ H4 { margin-top: 0.08in; margin-bottom: 0.08in; color: #000000; line-height: 0.17in; widows: 2; orphans: 2 }
+ H4.western { font-family: "Helv", "Arial", sans-serif; font-size: 10pt; so-language: en-GB; font-style: italic; font-weight: medium }
+ H4.cjk { font-family: "Times New Roman", serif; font-size: 10pt; so-language: ja-JP; font-style: italic; font-weight: medium }
+ H4.ctl { font-family: "Arial Unicode MS"; font-size: 12pt; font-weight: medium }
+ A:link { color: #0000ff }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="en-US" TEXT="#000000" LINK="#0000ff" DIR="LTR">
+<P LANG="en-GB" ALIGN=CENTER STYLE="margin-top: 0.17in; line-height: 100%; page-break-after: avoid">
+<IMG SRC="manual_html_m54d0ced8.png" NAME="Graphic6" ALIGN=RIGHT WIDTH=165 HEIGHT=45 BORDER=0><BR CLEAR=RIGHT><BR><BR>
+</P>
+<P LANG="en-GB" ALIGN=CENTER STYLE="margin-top: 0.17in; line-height: 100%; page-break-after: avoid">
+<FONT FACE="Luxi Sans, sans-serif"><FONT SIZE=5><B>Generic Access
+Control Lists with PHP</B></FONT></FONT></P>
+<P CLASS="western">Mike Benoit &lt;<FONT COLOR="#0000ff"><U><A HREF="mailto:ipso@snappymail.ca">ipso@snappymail.ca</A></U></FONT>&gt;<BR>James
+Russell &lt;<A HREF="mailto:james-phpgacl@ps2-pro.com">james-phpgacl@ps2-pro.com</A>&gt;<BR>Karsten
+Dambekalns &lt;<A HREF="mailto:k.dambekalns@fishfarm.de">k.dambekalns@fishfarm.de</A>&gt;</P>
+<P CLASS="western">Copyright &copy; 2002,2003,2004 Mike
+Benoit<BR>Copyright &copy; 2003, James Russell<BR>Copyright &copy;
+2003, Karsten Dambekalns</P>
+<P CLASS="western">Document Version: 58</P>
+<P CLASS="western">Last Updated:<B> <SDFIELD TYPE=DATETIME SDNUM="1033;1033;MMMM D, YYYY">September 3, 2005</SDFIELD>
+- <SDFIELD TYPE=DATETIME SDVAL="37761.788287037" SDNUM="1033;1033;HH:MM AM/PM">06:55 PM</SDFIELD></B></P>
+<H1 LANG="en-GB" CLASS="western">Table of Contents</H1>
+<DIV ID="Table of Contents1" DIR="LTR" STYLE="background: transparent">
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Table of Contents 2</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">About 4</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">What is it? 4</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Where can I get it? 4</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">What do I need to run it? 4</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Who is responsible for it? 4</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Introduction 5</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Understanding Access Control 5</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Who/Where 5</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Who/Where 6</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Defining access control with
+ phpGACL 6</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Fine-grain access control 7</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Multi-level Groups 8</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">How does phpGACL determine
+ permissions? 9</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Adding groups 10</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Adding people 11</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Resolving conflicts 11</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Naming Access Objects 12</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Adding Sections 14</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Multiple Purposes 15</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Access eXtension Objects 16</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Installation 18</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Basic setup 18</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Advanced setup 20</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Reusing an already existing ADOdb
+ installation 20</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Reusing an already existing Smarty
+ installation 20</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">How do I move the phpGACL files out
+ of my website tree while leaving a link in the tree for
+ administration? 20</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Using phpGACL in your application 21</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Basic usage 21</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Advanced usage 21</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Using the ACL admin utility 22</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">ACL's 22</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Creating 22</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Sections 23</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Extended Return Value 24</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.33in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Notes 24</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">Glossary 25</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">ACO 25</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">ARO 25</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">AXO 25</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">References 26</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">phpGACL API 26</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">phpGACL Examples and Tutorials 26</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Access Control Resources 26</FONT></P>
+ <P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+ <FONT FACE="Arial, sans-serif">FAQ 27</FONT></P>
+ <P LANG="en-GB" STYLE="margin-left: 0.17in; text-indent: 0in; margin-top: 0in; margin-bottom: 0.08in; line-height: 100%">
+ <FONT FACE="Arial, sans-serif">Can phpGACL handle large sets of
+ data? 27</FONT></P>
+</DIV>
+<P LANG="en-GB" STYLE="margin-top: 0in; margin-bottom: 0.08in; line-height: 100%; page-break-before: auto">
+<BR><BR>
+</P>
+<H1 LANG="en-GB" CLASS="western">About</H1>
+<H2 LANG="en-GB" CLASS="western">What is it?</H2>
+<P CLASS="western">phpGACL is an set of functions that allows you to
+apply access control to arbitrary objects (web pages, databases, etc)
+by other arbitrary objects (users, remote hosts, etc).</P>
+<P CLASS="western">It offers fine-grained access control with simple
+management, and is very fast.</P>
+<P CLASS="western">It is written in PHP (hence <B>php</B>GACL), a
+popular scripting language that is commonly used to dynamically
+create web pages. The GACL part of phpGACL stands for Generic Access
+Control List.</P>
+<H2 LANG="en-GB" CLASS="western">Where can I get it?</H2>
+<P CLASS="western">phpGACL is hosted by sourceforge.net at
+<A HREF="http://phpGACL.sourceforge.net/">http://phpGACL.sourceforge.net/</A></P>
+<H2 LANG="en-GB" CLASS="western">What do I need to run it?</H2>
+<P CLASS="western">phpGACL requires a relational database to store
+the access control information. It accesses this database via an
+abstract wrapper called <A HREF="http://php.weblogs.com/adodb">ADOdb</A>.
+This is compatible with databases such as PostgreSQL, MySQL and
+Oracle.</P>
+<P CLASS="western">phpGACL is written in the <A HREF="http://www.php.net/">PHP</A>
+scripting language. It requires PHP 4.2 and above.</P>
+<P CLASS="western">Access Control List administration is performed by
+a web interface, and therefore it is necessary to have a web server
+with PHP support, such as <A HREF="http://httpd.apache.org/">Apache</A>.</P>
+<H2 LANG="en-GB" CLASS="western">Who is responsible for it?</H2>
+<P CLASS="western">Mike Benoit &lt;<A HREF="mailto:ipso@snappymail.ca">ipso@snappymail.ca</A>&gt;
+is the author and project manager.</P>
+<P CLASS="western">James Russell &lt;j<A HREF="mailto:ames-phpgacl@ps2-pro.com">ames-phpgacl@ps2-pro.com</A>&gt;
+and Karsten Dambekalns &lt;<A HREF="mailto:k.dambekalns@fishfarm.de">k.dambekalns@fishfarm.de</A>&gt;
+did the documentation.</P>
+<H1 LANG="en-GB" CLASS="western">Introduction</H1>
+<H2 LANG="en-GB" CLASS="western">Understanding Access Control</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+best way to explain access control is to use examples with real
+things rather than trying to relate to concepts.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han
+is captain of the Millennium Falcon and Chewie is his second officer.
+They've taken on board some passengers: Luke, Obi-wan, R2D2 and C3PO.
+Han needs to define access restrictions for various rooms of the
+ship: The Cockpit, Lounge, Engines and the external Guns.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han
+says: &quot;Me and Chewie should have access to everywhere, but after
+a particularly messy hyperdrive repair, I forbid Chewie from going
+near the Engine Room ever again. Passengers are confined to the
+Passenger's Lounge.&quot;</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Let's
+assume from now on that access is Boolean. That is, the result of
+looking up a person's access to a room is either ALLOW or DENY. There
+is no middle ground.</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">If
+we mapped this statement into an </SPAN><B>access matrix</B><SPAN LANG="en-US">
+showing who has access to where, it would look something like this (O
+means ALLOW, X means DENY):</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<DL>
+ <DD>
+ <TABLE WIDTH=337 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=7 CELLSPACING=0>
+ <COL WIDTH=81>
+ <COL WIDTH=52>
+ <COL WIDTH=44>
+ <COL WIDTH=35>
+ <COL WIDTH=54>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <H3 LANG="en-GB" CLASS="western" ALIGN=RIGHT>Who/Where</H3>
+ </TD>
+ <TD WIDTH=52>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Cockpit</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Lounge</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Guns</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Engines</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Chewie</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Obi-wan</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Luke</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>R2-D2</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>C3PO</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ </TABLE>
+</DL>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">The
+columns list the rooms that Han wants to restrict access to, and the
+rows list the people that might request access to those rooms. More
+generally, the &quot;rooms&quot; are &quot;things to control access
+on&quot;. We call these </SPAN><B>Access Control Objects</B><SPAN LANG="en-US">
+(ACOs). The &quot;people&quot; are &quot;things </SPAN><I>requesting</I><SPAN LANG="en-US">
+access&quot;. We call these </SPAN><B>Access Request Objects</B><SPAN LANG="en-US">
+(AROs). The </SPAN><I>people</I><SPAN LANG="en-US"> request access to
+the </SPAN><I>rooms</I><SPAN LANG="en-US">, or in our terminology,
+</SPAN><I>AROs</I><SPAN LANG="en-US"> request access to the </SPAN><I>ACOs</I><SPAN LANG="en-US">.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">There
+is a third type of Object, the </SPAN><B>Access eXtention Object</B><SPAN LANG="en-US">
+(AXO) that we'll discuss later. These objects share many attributes
+and are collectively referred to as Access Objects.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Managing
+access using an access matrix like the one above has advantages and
+disadvantages.</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><I>Advantages:</I></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>It's
+ very fine-grained. It's possible to control access for an individual
+ person if necessary.</FONT></FONT></P>
+ <LI><P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN LANG="en-US"><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000">It's
+ easy to see <U>who</U> has access to <U>what</U>. The answer is
+ stored in the intersection of the person and the room.</FONT></FONT></FONT></SPAN></FONT></FONT></P>
+</UL>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><I>Disadvantages:</I></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>It's
+ difficult to manage on a large scale. 6 passengers and 4 places is
+ fairly simple, but what if there were thousands of passengers and
+ hundreds of places, and you need to restrict access to large groups
+ of them at once, but still retain enough fine-grained control to
+ manage access for an individual? That would mean a lot of fiddly and
+ lengthy adjustment to the matrix, and it's a difficult task to
+ verify that the final matrix is correct.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>It's
+ hard to summarize or visualize. The above example is fairly simple
+ to summarize in a few sentences (as Han did above), but what if the
+ matrix looked like this?</FONT></FONT></P>
+</UL>
+<DL>
+ <DD>
+ <TABLE WIDTH=337 BORDER=1 BORDERCOLOR="#000000" CELLPADDING=7 CELLSPACING=0>
+ <COL WIDTH=81>
+ <COL WIDTH=52>
+ <COL WIDTH=44>
+ <COL WIDTH=35>
+ <COL WIDTH=54>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <H3 LANG="en-GB" CLASS="western" ALIGN=RIGHT>Who/Where</H3>
+ </TD>
+ <TD WIDTH=52>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Cockpit</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Lounge</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Guns</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54>
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Engines</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Chewie</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Obi-wan</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Luke</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>R2-D2</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ </TR>
+ <TR VALIGN=TOP>
+ <TD WIDTH=81>
+ <P CLASS="western" ALIGN=RIGHT><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>C3PO</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=52 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=44 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=35 BGCOLOR="#ff0000">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>X</FONT></FONT></P>
+ </TD>
+ <TD WIDTH=54 BGCOLOR="#00ff00">
+ <P CLASS="western" ALIGN=CENTER><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>O</FONT></FONT></P>
+ </TD>
+ </TR>
+ </TABLE>
+</DL>
+<UL>
+ <P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>This
+ matrix is not so obvious to summarize, and it's not clear to the
+ reader why those access decisions might have been made in the first
+ place.</FONT></FONT></P>
+</UL>
+<H2 LANG="en-GB" CLASS="western">Defining access control with phpGACL</H2>
+<P CLASS="western">It seems that for large or complex situations,
+this 'access matrix' approach is clearly unsuitable. We need a better
+system that maintains the advantages (fine-grain control and a clear
+idea of <U>who</U> has access to <U>what</U>) but removes the
+disadvantages (difficult to summarize, and difficult to manage large
+groups of people at once). One solution is phpGACL.</P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN LANG="en-US"><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000">phpGACL
+doesn't describe access from the 'bottom-up' like the Access Matrix
+above. Instead, it describes it 'top-down', like the textual
+description of Han's access policy. This is a very flexible system
+that allows you to manage access in large groups, it neatly
+summarizes the access policy, and it's easy to see <U>who </U>has
+access to <U>what</U>.</FONT></FONT></FONT></SPAN></FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">An
+</SPAN><B>ARO tree</B><SPAN LANG="en-US"> defines a hierarchy of
+</SPAN><B>Groups</B><SPAN LANG="en-US"> and AROs (things that request
+access). This is very similar to a tree view of folders and files.
+The 'folders' are the Groups and the 'files' are AROs.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Let's
+make an ACL tree for the people on Han's ship. First we define some
+categories for the people. It's clear that Han and Chewie run the
+ship, and the rest of them are just passengers:</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Courier New, monospace"><FONT SIZE=2>Millennium
+Falcon Passengers Group<BR>&#9500;&#9472;Crew Group<BR>&#9474;
+&#9500;&#9472;Han ARO<BR>&#9474;
+&#9492;&#9472;Chewie ARO<BR>&#9492;&#9472;Passengers Group<BR>
+ &#9500;&#9472;Obi-wan ARO<BR> &#9500;&#9472;Luke ARO<BR>
+&#9500;&#9472;R2D2 ARO<BR> &#9492;&#9472;C3PO ARO</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>This
+tree by itself doesn't specify any access policy; it just shows how
+we're grouping the people who might request access (AROs).</FONT></FONT></P>
+<P CLASS="western">We apply access restrictions by assigning
+instructions about a particular room (ACO) to Groups or AROs in the
+tree. Han says: &quot;By default, no-one should be allowed access to
+any room on the Millennium Falcon. But the Crew should have access to
+every room. The Passengers should only have access to the Lounge.&quot;</P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000"><SPAN LANG="en-US">Millennium
+Falcon Passengers<BR>&#9500;&#9472;Crew </SPAN><B>[ALLOW: ALL]</B><SPAN LANG="en-US"><BR>&#9474;
+&#9500;&#9472;Han<BR>&#9474; &#9492;&#9472;Chewie<BR>&#9492;&#9472;Passengers </SPAN><B>[ALLOW:
+Lounge]</B><SPAN LANG="en-US"><BR> &#9500;&#9472;Obi-wan<BR>
+&#9500;&#9472;Luke<BR> &#9500;&#9472;R2D2<BR> &#9492;&#9472;C3PO</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>To
+interpret this ARO tree, we start from the top and work our way down.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Firstly,
+the default policy is always to deny access. Permissions have been
+overridden for the &quot;Crew&quot;, so they have access to
+everywhere (&quot;ALL&quot; is a synonym for all rooms: &quot;Cockpit,
+Lounge, Guns, Engines&quot;). The &quot;Passengers&quot; have access
+only to the Lounge.</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><SPAN LANG="en-US"><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000">This
+way of describing the access policy is much clearer than the access
+matrix. You can easily see who has access to what, and it's easier to
+determine <U>why</U> they've got access (it seems obvious that Han
+and Chewie would have access to everything, since they're grouped
+under &quot;Crew&quot;).</FONT></FONT></FONT></SPAN></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>To
+summarize:</FONT></FONT></P>
+<UL>
+ <LI><P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>Access
+ Control Objects </B><SPAN LANG="en-US">(ACOs) are the things we want
+ to control access to (e.g. web pages, databases, rooms, etc).</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+ <LI><P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>Access
+ Request Objects</B><SPAN LANG="en-US"> (AROs) are the things that
+ request access (e.g. people, remote computers, etc)</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+ <LI><P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>ARO
+ trees</B><SPAN LANG="en-US"> define a hierarchy of </SPAN><B>Groups</B><SPAN LANG="en-US">
+ and AROs. Groups can contain other Groups and AROs.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+ default 'catch-all' policy for the ARO tree is always &quot;DENY
+ ALL&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>To
+ assign access policy, work your way down the tree, explicitly
+ assigning permissions to Groups and AROs for each ACO as the need
+ arises.</FONT></FONT></P>
+</UL>
+<H2 LANG="en-GB" CLASS="western">Fine-grain access control</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Oops!
+What about Chewie? By grouping him in &quot;Crew&quot;, Han has
+indirectly given him access to the Engines! He doesn't want that
+after what Chewie recently did to the hyperdrive, so he adds a rule
+to disallow this:</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000"><SPAN LANG="en-US">Millennium
+Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW: ALL]<BR>&#9474;
+&#9500;&#9472;Han<BR>&#9474; &#9492;&#9472;Chewie </SPAN><B>[DENY:
+Engines]</B><SPAN LANG="en-US"><BR>&#9492;&#9472;Passengers [ALLOW:
+Lounge]<BR> &#9500;&#9472;Obi-wan<BR> &#9500;&#9472;Luke<BR>
+&#9500;&#9472;R2D2<BR> &#9492;&#9472;C3PO</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>This
+is an example of the way you can control access policy in a
+fine-grained manner. It is not necessary to move Chewie to another
+Group; we simply over-ride the access policy at a lower level.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Another
+example of fine-grain control happens when the Empire attacks; Han
+needs to let Luke man the guns, and let R2D2 repair the hyperdrive in
+the Engine room. He can do this by over-riding the general
+permissions granted by their status as a &quot;Passenger&quot;:</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000"><SPAN LANG="en-US">Millennium
+Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW: ALL]<BR>&#9474;
+&#9500;&#9472;Han<BR>&#9474; &#9492;&#9472;Chewie [DENY:
+Engines]<BR>&#9492;&#9472;Passengers [ALLOW: Lounge]<BR> &#9500;&#9472;Obi-wan<BR>
+ &#9500;&#9472;Luke </SPAN><B>[ALLOW: Guns]</B><SPAN LANG="en-US"><BR>
+ &#9500;&#9472;R2D2 </SPAN><B>[ALLOW: Engines]</B><SPAN LANG="en-US"><BR>
+ &#9492;&#9472;C3PO</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<H2 CLASS="western">Multi-level Groups</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Groups
+can be extended to any level in the ARO tree. For example, you could
+add a Group &quot;Jedi&quot; to &quot;Passengers&quot;. Most
+passengers would be categorized under &quot;Passengers&quot;, but
+Luke and Obi-wan would be under &quot;Jedi&quot; and therefore might
+be extended extra privileges (like access to the Cockpit):</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Courier New, monospace"><FONT COLOR="#000000"><SPAN LANG="en-US">Millennium
+Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW: ALL]<BR>&#9474;
+&#9500;&#9472;Han<BR>&#9474; &#9492;&#9472;Chewie [DENY:
+Engines]<BR>&#9492;&#9472;Passengers [ALLOW: Lounge]<BR>
+&#9500;&#9472;</SPAN><B>Jedi [ALLOW: Cockpit]</B><SPAN LANG="en-US"><BR>
+ &#9474; &#9500;&#9472;</SPAN><B>Obi-wan</B><SPAN LANG="en-US"><BR>
+&#9474; &#9492;&#9472;</SPAN><B>Luke</B><SPAN LANG="en-US"> [ALLOW:
+Guns] <BR> &#9500;&#9472;R2D2 [ALLOW: Engines]<BR> &#9492;&#9472;C3PO</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<H2 CLASS="western">How does phpGACL determine permissions?</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>When
+the ship's computer (running phpGACL of course) checks access, the
+only question it can ask itself is &quot;Does person X have access to
+room Y?&quot; In phpGACL terms, this is rephrased as &quot;Does ARO
+'X' have access to ACO 'Y'?&quot;</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>phpGACL
+determines whether a specific person has access to a specific room by
+working from the top of the ARO tree towards the specified person,
+noting explicit access controls for that place along the way. When it
+reaches that person, it uses the last explicit access control it
+encountered as the result to return. In this way, you can define
+access controls for groups of people, but over-ride them further down
+the tree if you need to.</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>Example
+1</B><SPAN LANG="en-US">: We ask: &quot;Does Luke have access to the
+Lounge?&quot;.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Set
+ the default result, &quot;DENY&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Work
+ out a path to Luke:</FONT></FONT></P>
+</UL>
+<H4 LANG="en-GB" CLASS="western"> Millennium Falcon Passengers &rarr;
+Passengers &rarr; Jedi &rarr; Luke</H4>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Start
+ at the top of the tree and move towards Luke: The &quot;Millennium
+ Falcon Passengers&quot; node doesn't say anything about any room, so
+ do nothing here.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Move
+ on to &quot;Passengers&quot;, which explicitly says that
+ &quot;Passengers&quot; have Lounge access, so change the internal
+ result to &quot;ALLOW&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Move
+ to the &quot;Jedi&quot; node, which doesn't mention the Lounge at
+ all.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Finally
+ move to Luke's node, and again there's nothing there about the
+ Lounge.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>There's
+ nowhere left to go, so the result returned is the current value of
+ the internal result: &quot;ALLOW&quot;</FONT></FONT></P>
+</UL>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>Example
+2</B><SPAN LANG="en-US">: We ask: &quot;Does Chewie have access to
+the Engines?&quot;</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Set
+ the default result, &quot;DENY&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Work
+ out a path to Chewie:</FONT></FONT></P>
+</UL>
+<H4 LANG="en-GB" CLASS="western"> Millennium Falcon Passengers &rarr;
+Crew &rarr; Chewie</H4>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Start
+ at the top of the tree and move towards Chewie. The &quot;Millennium
+ Falcon Passengers&quot; node doesn't say anything about anywhere, so
+ do nothing here.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Move
+ on to &quot;Crew&quot;, which explicitly says that &quot;Crew&quot;
+ have Engine access, so change the internal result to &quot;ALLOW&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Move
+ to Chewie's node, and there's an explicit rule saying that he
+ doesn't have access to the Engines, so change the internal result to
+ &quot;DENY&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>There's
+ nowhere left to go, so the result returned is the current value of
+ the internal result: &quot;DENY&quot;</FONT></FONT></P>
+</UL>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>As
+you can see from the examples, if a Group doesn't explicitly specify
+a permission for a room, then that Group inherits the access
+restrictions of its parent for that room. If the root node
+(&quot;Millennium Falcon Passengers&quot;) doesn't specify a
+permission, it inherits it from the default setting (&quot;DENY ALL&quot;
+in the above examples).</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>This
+implies a couple of interesting points about the ARO tree:</FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+ ARO tree always shows the full list of the AROs. It would not make
+ sense to ask &quot;Does Jabba have access to the Cockpit?&quot;
+ because Jabba has not been defined in this system. However, phpGACL
+ does not check to see if AROs or ACOs exist before performing the
+ check, so if this question was actually asked then the result would
+ be the default &quot;DENY&quot;.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+ ARO tree may not display some defined ACOs, and relies on the
+ default setting to define access policy. For example, say Han
+ defined a &quot;Bathroom&quot; ACO. Any question like &quot;Does
+ Luke have access to the Bathroom?&quot; would have the answer
+ &quot;DENY&quot;, because the default is &quot;DENY&quot; and
+ nowhere in the ARO tree does it ever explicitly mention the
+ Bathroom. Keep in mind when examining the ARO tree that some ACOs
+ may not be visible.</FONT></FONT></P>
+</UL>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><B>Note:</B><SPAN LANG="en-US">
+When asking phpGACL questions about access to an ACO, it is not
+possible to use Groups as AROs (even though it might 'seem' right).
+For example, it is impossible to answer the question &quot;Do
+Passengers have access to Guns?&quot; The complete answer is not a
+Boolean &quot;ALLOW&quot; or &quot;DENY&quot;, but the more complex
+&quot;Luke and Obi-wan can but R2D2 and C3PO cannot.&quot; phpGACL is
+not designed to return that kind of answer.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<H2 CLASS="western">Adding groups</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han
+feels this ACL is starting to look a little complicated. There are so
+many exceptions! Perhaps he should make another group, &quot;Engineers&quot;,
+containing the people who are allowed access to the Engines and Guns.
+That group should contain Han and R2D2 since they're both capable of
+repairing the engines and guns. This means Han can remove some of
+those messy exceptions-to-the-rules, and that has the benefit of
+making the description clearer:</FONT></FONT></P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Default: DENY
+ALL<BR>Millennium Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW:
+ALL]<BR>&#9474; &#9500;&#9472;Han<BR>&#9474; &#9492;&#9472;Chewie [DENY:
+Engines]<BR>&#9500;&#9472;Passengers [ALLOW: Lounge]<BR>&#9474;
+&#9500;&#9472;Jedi [ALLOW: Cockpit]<BR>&#9474; &#9474; &#9500;&#9472;Obi-wan<BR>&#9474;
+&#9474; &#9492;&#9472;Luke [ALLOW: Guns] <BR>&#9474; &#9500;&#9472;R2D2<BR>&#9474;
+&#9492;&#9472;C3PO<BR>&#9492;&#9472;<B>Engineers [ALLOW: Engines,
+Guns]</B><BR> &#9500;&#9472;<B>Han</B><BR> &#9492;&#9472;<B>R2D2</B></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>We
+can read this as &quot;By default, no-one has access to anywhere.
+Crew have access to everywhere (except Chewie, who has no access to
+the Engines). Passengers only have access to the Lounge, except Jedi
+who also have access to the Cockpit. Luke has access to the Guns too.
+Engineers are allowed access to the Engines and Guns.&quot;</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">Most
+importantly, we can see that Han and R2D2 are now in </SPAN><I>two</I><SPAN LANG="en-US">
+places in the ACL. It is not necessary for them to be uniquely
+categorized at all. This defines the policy more clearly to the
+reader: &quot;Ahh, Han and R2D2 have access to the Engines and Guns
+because they're </SPAN><I>engineers</I><SPAN LANG="en-US">.&quot;</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<H2 CLASS="western">Adding people</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han
+goes to Cloud City to pick up Lando and get some repairs. Lando's the
+Millennium Falcon's previous owner, so Han reckons he qualifies as
+Crew. Lando also offers the services of his top engineer, Hontook,
+for help with repairing the ship while they're in dock.</FONT></FONT></P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Default: DENY
+ALL<BR>Millennium Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW:
+ALL]<BR>&#9474; &#9500;&#9472;Han<BR>&#9474; &#9500;&#9472;Chewie [DENY:
+Engines]<BR>&#9474; &#9492;&#9472;<B>Lando</B><BR>&#9500;&#9472;Passengers [ALLOW:
+Lounge]<BR>&#9474; &#9500;&#9472;Jedi [ALLOW: Cockpit]<BR>&#9474; &#9474;
+&#9500;&#9472;Obi-wan<BR>&#9474; &#9474; &#9492;&#9472;Luke [ALLOW:
+Guns] <BR>&#9474; &#9500;&#9472;R2D2<BR>&#9474;
+&#9492;&#9472;C3PO<BR>&#9492;&#9472;Engineers [ALLOW: Engines,
+Guns]<BR> &#9500;&#9472;Han<BR> &#9500;&#9472;R2D2<BR> &#9492;&#9472;<B>Hontook</B></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>This
+shows how easy it is to grant new people access. If we used the
+original matrix scheme, we'd have to set permissions for each room
+for both Lando and Hontook. Instead, we simply add them to their
+appropriate groups and their access is implicitly and easily defined.</FONT></FONT></P>
+<H2 CLASS="western">Resolving conflicts</H2>
+<P CLASS="western">What happens if we add Chewie to the list of
+Engineers?</P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Default: DENY
+ALL<BR>Millennium Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW:
+ALL]<BR>&#9474; &#9500;&#9472;Han<BR>&#9474; &#9500;&#9472;Chewie [DENY:
+Engines]<BR>&#9474; &#9492;&#9472;Lando<BR>&#9500;&#9472;Passengers [ALLOW:
+Lounge]<BR>&#9474; &#9500;&#9472;Jedi [ALLOW: Cockpit]<BR>&#9474; &#9474;
+&#9500;&#9472;Obi-wan<BR>&#9474; &#9474; &#9492;&#9472;Luke [ALLOW:
+Guns] <BR>&#9474; &#9500;&#9472;R2D2<BR>&#9474;
+&#9492;&#9472;C3PO<BR>&#9492;&#9472;Engineers [ALLOW: Engines,
+Guns]<BR> &#9500;&#9472;Han<BR> &#9500;&#9472;R2D2<BR> &#9500;&#9472;Hontook<BR>
+ &#9492;&#9472;<B>Chewie</B></FONT></P>
+<P CLASS="western">This makes Chewie's access to the Engines
+ambiguous, because now there are two paths from the root of the tree
+to Chewie. If the ship's computer follows one path (along the &quot;Crew&quot;
+branch), the result is &quot;DENY access to Engines.&quot; If it
+follows the other path (along the &quot;Engineers&quot; branch) then
+the result is &quot;ALLOW access to Engines&quot;. So, is he allowed
+or denied?</P>
+<P CLASS="western">phpGACL will warn you if you add or edit an
+multiply-grouped ARO in such a way that the ARO's access to an
+arbitrary ACO would be ambiguous. But it is <U>up to you</U> to
+resolve the conflict.</P>
+<P CLASS="western">If we now asked phpGACL the question &quot;Does
+Chewie have access to Engines?&quot; the result returned is the
+result given by the <U>last ACL entry to be modified</U> (this is
+phpGACL's policy). In this case the result is ALLOW, because the
+&quot;ALLOW: Engines, Guns&quot; directive assigned to the Engineers
+Group is more recent than the &quot;DENY: Engines&quot; directive
+assigned to Chewie's Group.</P>
+<P CLASS="western">When ambiguous access entries exist in the ACL,
+the ACL is said to be <B>inconsistent</B>. Inconsistent ACLs can be
+very dangerous, and you may unwittingly provide access to
+inappropriate people if you allow your ACL to remain in this state.
+When phpGACL warns you that the ACL is inconsistent, it is best to
+resolve the conflicts as soon as possible to regain consistency.</P>
+<P CLASS="western">To resolve the conflict in this case, we could
+either:</P>
+<UL>
+ <LI><P CLASS="western">Remove the &quot;DENY: Engines&quot;
+ directive from Chewie's entry under the Crew Group.</P>
+ <LI><P CLASS="western">Add a &quot;DENY: Engines&quot; directive to
+ Chewie's entry under the Engineers Group.</P>
+ <LI><P CLASS="western">Remove Chewie from the Engineers Group, since
+ Han doesn't think him a worthy Engineer anyway.</P>
+</UL>
+<P CLASS="western">Han chooses option 3, and removes Chewie from the
+Engineers list.</P>
+<H2 CLASS="western">Naming Access Objects</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>phpGACL
+uniquely identifies each Access Object (AROs, AXOs and ACOs) with a
+two-keyword combination and it's Access Object type.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+tuple &quot;(Access Object type, Section, Value)&quot; uniquely
+identifies any Access Object.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>The
+first element of the tuple is the type of Access Object (ARO, AXO or
+ACO).</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">The
+second element of the tuple, called the </SPAN><B>Section</B><SPAN LANG="en-US">,
+is a user-defined string which names the general category of the
+Access Object. Multiple Access Objects can share the same Section
+name. The Section name should be short but descriptive. It's used in
+the user interface in selection boxes, so try not to make it too
+long.</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Sections
+are stored in a flat namespace; they are not nestable like Groups.
+Sections have nothing to do with Groups or the ARO/AXO trees - they
+are purely a mechanism for helping to maintain large numbers of
+Access Objects.</FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">The
+third element of the tuple is a user-defined name for the Access
+Object, and is called the </SPAN><B>Value</B><SPAN LANG="en-US">. <U>A
+Value cannot contain spaces</U> (however, a Section can).</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><U>Both
+Section and Values are case sensitive.</U></FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="margin-left: 0.38in; margin-top: 0in; margin-bottom: 0in; line-height: 0.17in">
+<FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT COLOR="#000000"><FONT FACE="Helv, Arial, sans-serif"><B>Aside:</B><SPAN LANG="en-US">
+It is commonly asked why strings are used to identify Access Objects,
+rather than integers which ostensibly seem faster. The answer is for
+legibility. It is much easier to understand:<BR> </SPAN></FONT><SPAN LANG="en-US"><FONT FACE="Courier, Courier New, monospace">acl_check('system',
+'login', 'users', 'john_doe');<BR></FONT><FONT FACE="Helv, Arial, sans-serif">than:</FONT><FONT FACE="Courier, Courier New, monospace"><BR> acl_check(10,
+21004, 15, 20304);</FONT></SPAN></FONT></FONT></FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Times New Roman, serif"><FONT SIZE=3><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000"><SPAN LANG="en-US">Since
+it is often obvious from the context which type of Access Object we
+are referring to, the interface for phpGACL (and this documentation)
+drops the Access Object type and uses the format &quot;</SPAN><B>Section
+&gt; Value</B><SPAN LANG="en-US">&quot; when displaying the name of
+an Access Object. However, the API requires an Access Object's
+&quot;Section&quot; and &quot;Value&quot; to be specified in separate
+function arguments (the Access Object type is usually implicit in the
+argument description).</SPAN></FONT></FONT></FONT></FONT></FONT></P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><B>Example
+ACO &quot;Section &gt; Values&quot;:</B></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;Floors
+ &gt; 1st&quot;</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;Floors
+ &gt; 2nd&quot;</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;Rooms
+ &gt; Engines&quot;</FONT></FONT></P>
+</UL>
+<P CLASS="western"><B>Example ARO &quot;Section &gt; Values&quot;:</B></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;People
+ &gt; John_Smith&rdquo;</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in">&ldquo;<FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>People
+ &gt; Cathy_Jones&rdquo;</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in">&ldquo;<FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Hosts
+ &gt; sandbox.something.com&rdquo;</FONT></FONT></P>
+</UL>
+<P CLASS="western"><B>Example API usage:</B></P>
+<UL>
+ <LI><P CLASS="western" STYLE="font-weight: medium; line-height: 0.17in">
+ <FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>acl_check (
+ aco_section, aco_value, aro_section, aro_value);</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="font-weight: medium; line-height: 0.17in">
+ <FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>acl_check (
+ 'Floors', '2nd', 'People', 'John_Smith' );</FONT></FONT></P>
+</UL>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><B>Valid
+Naming Restrictions Examples:</B></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;ACO
+ -Frob &gt; Flerg&quot;, &quot;ARO - Frob &gt; Flerg&quot; (The
+ Section and Value are the same in both, but this is fine as
+ namespaces are separate across Access Object types)</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;ACO
+ -Frob &gt; Flerg&quot;, &quot;ACO - Frob &gt; Queegle&quot; (The
+ Access Object type and Section are the same, but this is fine as the
+ Values are different)</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;AXO
+ - Frob Hrung &gt; Flerg&quot; (Sections can contain spaces)</FONT></FONT></P>
+</UL>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><B>Invalid
+Naming Restrictions Examples:</B></FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;ACO
+ - Frob &gt; Flerg&quot;, &quot;ACO - Frob &gt; Flerg&quot; (&quot;Access
+ Object type - Section &gt; Value&quot; must be unique)</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>&quot;ACO
+ - Frob &gt; Flerg Habit&quot; (Values cannot contain spaces)</FONT></FONT></P>
+</UL>
+<H2 LANG="en-GB" CLASS="western">Adding Sections</H2>
+<P LANG="en-GB" STYLE="line-height: 100%">Before you can add a new
+Access Object, its Section must be defined. To add a new section, use
+the add_object_section() function.</P>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 100%"><FONT FACE="Arial, sans-serif"><FONT SIZE=2>add_object_section
+(</FONT></FONT></P>
+<P LANG="en-GB" STYLE="margin-left: 2.5in; text-indent: -2in; line-height: 100%">
+<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace">string
+NAME,</FONT> A short description of what this Section is for. (e.g.
+&quot;Levels in building&quot;).</FONT></P>
+<P LANG="en-GB" STYLE="margin-left: 2.5in; text-indent: -2in; line-height: 100%">
+<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace">string
+VALUE,</FONT> The name of the Section (e.g. &quot;Floor&quot;).</FONT></P>
+<P LANG="en-GB" STYLE="margin-left: 2.5in; text-indent: -2in; line-height: 100%">
+<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace">int
+ORDER,</FONT> An arbitrary value which affects the order this Section
+appears in the UI.</FONT></P>
+<P LANG="en-GB" STYLE="margin-left: 2.5in; text-indent: -2in; line-height: 100%">
+<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace">bool
+HIDDEN, </FONT>Whether this should appear in the UI or not (TRUE
+means that is will be hidden).</FONT></P>
+<P LANG="en-GB" STYLE="margin-left: 2.5in; text-indent: -2in; line-height: 100%">
+<FONT FACE="Arial, sans-serif"><FONT FACE="Courier New, monospace">string
+GROUP_TYPE) </FONT>The Access Object type (&quot;aco&quot;, &quot;aro&quot;
+or &quot;axo&quot;)</FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Han
+creates 3 Sections for the AROs. &quot;Humans&quot;, &quot;Aliens&quot;
+and &quot;Androids&quot;. Let's list the AROs with their full names</FONT></FONT></P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Millennium
+Falcon Passengers<BR>&#9500;&#9472;Crew [ALLOW: ALL]<BR>&#9474;
+&#9500;&#9472;<B>&quot;Humans &gt; Han&quot;</B><BR>&#9474; &#9500;&#9472;<B>&quot;Aliens
+&gt; Chewie&quot;</B> [DENY: Engines]<BR>&#9474; &#9492;&#9472;<B>&quot;Humans
+&gt; Lando&quot;</B><BR>&#9500;&#9472;Passengers [ALLOW: Lounge]<BR>&#9474;
+&#9500;&#9472;Jedi [ALLOW: Cockpit]<BR>&#9474; &#9474; &#9500;&#9472;<B>&quot;Humans
+&gt; Obi-wan&quot;</B><BR>&#9474; &#9474; &#9492;&#9472;<B>&quot;Humans
+&gt; Luke&quot;</B> [ALLOW: Guns] <BR>&#9474; &#9500;&#9472;<B>&quot;Androids
+&gt; R2D2&quot;</B><BR>&#9474; &#9492;&#9472;<B>&quot;Androids &gt;
+C3PO&quot;</B><BR>&#9492;&#9472;Engineers [ALLOW: Engines, Guns]<BR>
+ &#9500;&#9472;<B>&quot;Humans &gt; Han&quot;</B><BR> &#9500;&#9472;<B>&quot;Androids
+&gt; R2D2&quot;</B><BR> &#9492;&#9472;<B>&quot;Aliens &gt; Hontook&quot;</B></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>Sections
+are just a way of categorizing Access Objects, to make the user
+interface more usable, and the code for acl_check() more readable.
+They do not affect the way phpGACL determines access to an object.
+They cannot be nested (so it would not be able to create a &quot;Males&quot;
+sub-Section under &quot;Humans&quot; for example; you'd have to
+create a Section called &quot;Humans-Male&quot; or similar)</FONT></FONT></P>
+<H2 CLASS="western">Multiple Purposes</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>You
+may need to use phpGACL for multiple independent purposes. For
+example, you may need to restrict user access to web pages, and also
+remote host access to your server. The two tasks are not related.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>phpGACL
+can handle this in three different ways.</FONT></FONT></P>
+<UL>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>It
+ can use an alternative database to store the access tables.</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>It
+ can use the same database but with differently named access tables.
+ (this feature is not implemented yet).</FONT></FONT></P>
+ <LI><P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>You
+ can store the Access Objects for both purposes in the same tables,
+ and carefully manage your list so that they don't conflict.</FONT></FONT></P>
+</UL>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>To
+implement Option 1 (and Option 2 when it becomes available), use the
+$gacl_options array when creating a new phpGACL class. This allows
+you to specify the database and table name prefixes to use:</FONT></FONT></P>
+<P CLASS="western" STYLE="margin-top: 0in; margin-bottom: 0in; line-height: 0.17in">
+<FONT FACE="Courier, Courier New, monospace"><FONT SIZE=2>$gacl_options
+= array(<BR> 'db_table_prefix' =&gt; 'gacl_',<BR> 'db_type' =&gt;
+'mysql',<BR> 'db_host' =&gt; 'host1',<BR> 'db_user' =&gt;
+'user',<BR> 'db_password' =&gt; 'passwd',<BR> 'db_name' =&gt;
+'gacl');</FONT></FONT></P>
+<P CLASS="western" STYLE="margin-top: 0in; margin-bottom: 0in; line-height: 0.17in">
+<BR>
+</P>
+<P CLASS="western" STYLE="margin-top: 0in; margin-bottom: 0in; line-height: 0.17in">
+<FONT FACE="Courier, Courier New, monospace"><FONT SIZE=2>$gacl_host1
+= new gacl($gacl_options);</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>To
+implement Option 3, you must be careful, since phpGACL doesn't know
+the relationship between your different tasks, and it will be
+possible to make meaningless Access Policy Directives.</FONT></FONT></P>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2>For
+example, say Han wanted to restrict access to other ships contacting
+his ship's computer, in addition to restricting access to the
+different rooms. To do this, he might add &quot;Luke's X-Wing
+Fighter&quot; as a remote ship ARO (in addition to other ships and an
+ACO for the ship's computer). Because all AROs are in the same ARO
+tree, it would be possible to create an APD like &quot;Ships &gt;
+Luke's X-Wing Fighter&quot; [ALLOW: &quot;Rooms &gt; Lounge&quot;],
+which would be totally meaningless! To help reduce mistakes like
+this, good Section naming can make it clearer what Access Objects are
+for which tasks. It should be obvious to any administrator that it's
+meaningless to assign a Ship permission to use a Room.</FONT></FONT></P>
+<H2 LANG="en-GB" CLASS="western">Access eXtension Objects</H2>
+<P CLASS="western"><B>Access eXtension Objects</B> (AXOs) can add a
+3rd dimension to the permissions that can be configured in phpGACL.
+We've seen how phpGACL allows you to combine an ARO and an ACO (2
+dimensions) to create an Access Policy Directive. This is great for
+simple permission requests like:</P>
+<P CLASS="western"> Luke (ARO) requests access to &quot;Guns&quot;
+(ACO)</P>
+<P CLASS="western">If that's all you need, that's fine - AXOs are
+totally optional.</P>
+<P CLASS="western">But because all ACOs are considered equal, it
+makes it difficult to manage if there are many ACOs. If this is the
+case, we can change the way we look at Access Objects to manage it
+more easily.</P>
+<P CLASS="western">AXOs are identical to AROs in many respects. There
+is an AXO tree (separate from the ARO tree), with it's own Groups and
+AXOs. When dealing with AXOs, consider an AXO to take the old role of
+the ACO (i.e. &quot;things to control access on&quot;), and change
+the view of ACOs from &quot;things to control access on&quot; to
+&quot;actions that are requested&quot;.</P>
+<P CLASS="western"><B>ARO and ACO-only View:</B></P>
+<UL>
+ <LI><P CLASS="western">AROs: Things requesting access</P>
+ <LI><P CLASS="western">ACOs: Things to control access on</P>
+</UL>
+<P CLASS="western"><B>ARO, ACO and AXO View:</B></P>
+<UL>
+ <LI><P CLASS="western">AROs: Things requesting access</P>
+ <LI><P CLASS="western">ACOs: Actions that are requested</P>
+ <LI><P CLASS="western">AXOs: Things to control access on</P>
+</UL>
+<P CLASS="western"><B>Example:</B></P>
+<P CLASS="western">A website manager is trying to manage access to
+projects on the website. The ARO tree consists of all the users:</P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Website<BR>&#9500;&#9472;Administrators<BR>&#9474;
+&#9500;&#9472;Alice<BR>&#9474; &#9492;&#9472;Carol<BR>&#9492;&#9472;Users<BR>
+ &#9500;&#9472;Bob<BR> &#9492;&#9472;Alan</FONT></P>
+<P CLASS="western">The projects are organized by Operating System
+into categories in the AXO tree:</P>
+<P CLASS="western"><FONT FACE="Courier New, monospace">Projects<BR>&#9500;&#9472;Linux<BR>&#9474;
+&#9500;&#9472;SpamFilter2<BR>&#9474; &#9492;&#9472;AutoLinusWorshipper<BR>&#9492;&#9472;Windows<BR>
+ &#9500;&#9472;PaperclipKiller<BR> &#9492;&#9472;PopupStopper</FONT></P>
+<P CLASS="western">The actions that can be taken with each project
+are &quot;View&quot; and &quot;Edit&quot;. These are the ACOs.</P>
+<P CLASS="western">Now we want Bob to have &quot;View&quot; access to
+all the Linux projects, so it's possible to add an ACL that links
+Bob's ARO to the View ACO and the Linux AXO, and thus we can ask the
+question:</P>
+<P CLASS="western"> Bob (ARO) requests access to &quot;View&quot;
+(ACO) the project(s) called &quot;Linux&quot; (AXO)</P>
+<P CLASS="western">Keep in mind AXO's are optional, if you don't
+specify an AXO when calling acl_check() and a matching ACL exists
+with no AXO, it will be allowed. However if <U>only</U> ACLs exist
+with AXO's, and you call acl_check() without an AXO, it will fail.</P>
+<P CLASS="western">So basically as soon as you specify an AXO when
+calling acl_check(), acl_check() will only search ACLs containing
+AXO's. If no AXO is specified, only ACLs without AXOs are searched.
+This in theory (I haven't benchmarked) gives us a slight performance
+increase as well.</P>
+<H1 LANG="en-GB" CLASS="western">Installation</H1>
+<H2 LANG="en-GB" CLASS="western">Basic setup</H2>
+<OL>
+ <LI><P CLASS="western">Untar the distribution .tar.gz file into the
+ root or a subdirectory of your web site. You might want to rename it
+ to something more suitable.<BR><BR><BR>
+ </P>
+ <P CLASS="western"><IMG SRC="manual_html_m48c2db5c.png" NAME="Graphic1" ALIGN=LEFT WIDTH=474 HEIGHT=146 BORDER=0><BR CLEAR=LEFT></P>
+ <LI><P CLASS="western">Edit phpgacl/gacl.class.php using your
+ favourite editor and set the db_type, db_host, db_user, db_password,
+ and db_name you will be using.<BR><BR><BR>
+ </P>
+</OL>
+<IMG SRC="manual_html_m6a630ca2.png" NAME="Graphic2" ALIGN=LEFT WIDTH=519 HEIGHT=320 BORDER=0><BR CLEAR=LEFT>
+<P CLASS="western" STYLE="margin-left: 0.5in"> <BR>Now edit
+phpgacl/admin/gacl_admin.inc.php to hold the same information. This
+file is used by the setup script as well as the ACL admin backend.</P>
+<P CLASS="western" STYLE="margin-left: 0.5in">The reason for two
+files holding that (same) information, is that the core ACL library
+gacl.class.php is much smaller than the full-fledged API class, and
+there is no need to include all the code when you just want to call
+acl_check().</P>
+<OL START=3>
+ <LI><P CLASS="western">Create the database you specified in db_name
+ on the server.<BR><BR><BR>
+ </P>
+ <P CLASS="western"><IMG SRC="manual_html_m770a5a15.png" NAME="Graphic3" ALIGN=LEFT WIDTH=397 HEIGHT=123 BORDER=0><BR CLEAR=LEFT></P>
+ <P CLASS="western"></P>
+ <LI><P CLASS="western">Surf to
+ http://yoursite.net/phpgacl/setup.php. The required tables will be
+ installed based on your choice of database. Don't be afraid of the
+ truckload of output, if all goes well you will see only success
+ messages.<BR><BR><BR>
+ </P>
+</OL>
+<P CLASS="western"><IMG SRC="manual_html_7dced6ce.png" NAME="Graphic4" ALIGN=LEFT WIDTH=519 HEIGHT=504 BORDER=0><BR CLEAR=LEFT><BR><BR>
+</P>
+<OL START=5>
+ <LI><P CLASS="western">Now follow the last advice shown on that
+ screen and create the phpgacl/admin/smarty/templates_c directory. It
+ must be writable by the user the webserver runs as. If you don't do
+ this, you will not be able to use the CAL admin!</P>
+ <LI><P CLASS="western">Click the link at the bottom of the
+ successful setup page or surf
+ to:<BR>http://yoursite.net/phpgacl/admin/acl_admin.php</P>
+</OL>
+<H2 LANG="en-GB" CLASS="western">Advanced setup</H2>
+<H3 LANG="en-GB" CLASS="western">Reusing an already existing ADOdb
+installation</H3>
+<P CLASS="western">If you already have ADOdb installed you can get
+phpGACL to use this copy of ADOdb.</P>
+<OL>
+ <LI><P CLASS="western">Edit phpgacl/gacl.class.php so that ADODB_DIR
+ reflects the location of the ADOdb library in your path.</P>
+ <LI><P CLASS="western">Rename the phpgacl/adodb folder to something
+ else like adodb_x and reload the phpgacl/admin/acl_admin.php page to
+ ensure it still works.</P>
+ <LI><P CLASS="western">Erase the adodb directory installed with
+ phpGACL.</P>
+</OL>
+<H3 LANG="en-GB" CLASS="western">Reusing an already existing Smarty
+installation</H3>
+<P CLASS="western">If you already have ADOdb installed you can get
+phpGACL to use this copy of ADOdb.</P>
+<OL>
+ <LI><P CLASS="western">Edit phpgacl/admin/gacl_admin.inc.php so that
+ the variables $smarty_dir and $smarty_compile_dir reflect the
+ location of the Smarty library in your path and the template_c
+ directory you already use.</P>
+ <P CLASS="western">Move the templates directory that came with
+ phpGACL to another directory (e.g. one level up). Adjust the
+ $smarty_template_dir so it points to the new location. If you like
+ you can move those templates to your existing templates folder, of
+ course.</P>
+ <LI><P CLASS="western">Rename the phpgacl/smarty folder to something
+ else like smarty_x and reload the phpgacl/admin/acl_admin.php page
+ to ensure it still works.</P>
+ <LI><P CLASS="western">Erase the smarty directory installed with
+ phpGACL.</P>
+</OL>
+<H3 LANG="en-GB" CLASS="western">How do I move the phpGACL files out
+of my website tree while leaving a link in the tree for
+administration?</H3>
+<OL>
+ <LI><P CLASS="western">Go to your website root.</P>
+ <LI><P CLASS="western">Move the phpGACL directory to your includes
+ directory and create a symlink to the admin directory where you want
+ the admin tool to go. For example:</P>
+ <P CLASS="western">mv phpgacl/ /www/includes_directory<BR>ln -s
+ /www/includes_directory/phpgacl/admin/ gacl</P>
+ <LI><P CLASS="western">Now surfing to
+ http://yoursite.net/gacl/acl_admin.php will take you to the admin
+ page. If it doesn't work, make sure your Webserver allows symbolic
+ links in the website tree.</P>
+</OL>
+<H1 LANG="en-GB" CLASS="western">Using phpGACL in your application</H1>
+<H2 LANG="en-GB" CLASS="western">Basic usage</H2>
+<P CLASS="western">This example shows a basic example of using
+phpGACL in your code. It uses the ADOdb abstraction layer as well,
+and shows a simple way to validate a login attempt against a
+database.</P>
+<P CLASS="western"><FONT FACE="Courier New"><FONT COLOR="#ff0000">//
+include basic ACL api</FONT><BR><FONT COLOR="#00cccc">include</FONT>('<FONT COLOR="#008000">phpgacl/gacl.class.php</FONT>');<BR>$<FONT COLOR="#ff6633">gacl</FONT>
+= <FONT COLOR="#00cccc">new</FONT> gacl();</FONT></P>
+<P CLASS="western"><FONT FACE="Courier New">$<FONT COLOR="#ff6633">username</FONT>
+= $<FONT COLOR="#ff6633">db</FONT>-&gt;<FONT COLOR="#00cccc">quote</FONT>($<FONT COLOR="#ff6633">_POST</FONT>['<FONT COLOR="#008000">username</FONT>']);<BR>$<FONT COLOR="#ff6633">password</FONT>
+= $<FONT COLOR="#ff6633">db</FONT>-&gt;<FONT COLOR="#00cccc">quote</FONT>(md5($<FONT COLOR="#ff6633">_POST</FONT>['<FONT COLOR="#008000">password</FONT>']));<BR>$<FONT COLOR="#ff6633">sql</FONT>
+= '<FONT COLOR="#008000">SELECT name FROM users WHERE name=</FONT>';<BR>$<FONT COLOR="#ff6633">sql</FONT>
+.= $<FONT COLOR="#ff6633">username</FONT>.' <FONT COLOR="#008000">AND
+password=</FONT>'.$<FONT COLOR="#ff6633">password</FONT>;<BR>$<FONT COLOR="#ff6633">row</FONT>
+= $<FONT COLOR="#ff6633">db</FONT>-&gt;<FONT COLOR="#00cccc">GetRow</FONT>($<FONT COLOR="#ff6633">sql</FONT>);</FONT></P>
+<P CLASS="western"><FONT FACE="Courier New"><FONT COLOR="#00cccc">if</FONT>($<FONT COLOR="#ff6633">gacl</FONT>-&gt;<FONT COLOR="#00cccc">acl_check</FONT>('<FONT COLOR="#008000">system</FONT>','<FONT COLOR="#008000">login</FONT>','<FONT COLOR="#008000">user</FONT>',$<FONT COLOR="#ff6633">row</FONT>['<FONT COLOR="#008000">name</FONT>'])){<BR>
+ $<FONT COLOR="#ff6633">_SESSION</FONT>['<FONT COLOR="#008000">username</FONT>']
+= $<FONT COLOR="#ff6633">row</FONT>['<FONT COLOR="#008000">name</FONT>'];<BR>
+ <FONT COLOR="#00cccc">return</FONT> <FONT COLOR="#6b4794">true</FONT>;<BR>}<BR><FONT COLOR="#00cccc">else</FONT><BR>
+ <FONT COLOR="#00cccc">return</FONT> <FONT COLOR="#6b4794">false</FONT>;</FONT></P>
+<P CLASS="western">As you can see there is only one call to
+acl_check() in this code. What does it do? Well, it</P>
+<UL>
+ <LI><P CLASS="western">checks the ARO object $row['name'] from the
+ ARO section 'user'</P>
+ <LI><P CLASS="western">against the ACO object 'login' from the ACO
+ section 'system'.</P>
+</UL>
+<H2 LANG="en-GB" CLASS="western">Advanced usage</H2>
+<P CLASS="western"><BR><BR>
+</P>
+<H1 LANG="en-GB" CLASS="western">Using the ACL admin utility</H1>
+<P CLASS="western">If you want to get a grip on the included ACL
+admin utitlity, it will help you a lot if you run the example.php
+file. It contains some ACO, ARO and AXO objects, as well as some ACL
+defined using those objects. After running it, you should see some
+sample data in the admin interface.<BR><BR><BR>
+</P>
+<P CLASS="western"><IMG SRC="manual_html_4b803670.png" NAME="Graphic5" ALIGN=LEFT WIDTH=531 HEIGHT=488 BORDER=0><BR CLEAR=LEFT><BR><BR>
+</P>
+<P CLASS="western">Play around with it, and if you get stuck, come
+back and read on...</P>
+<P CLASS="western">(yet to be written)</P>
+<H2 LANG="en-GB" CLASS="western">ACL's</H2>
+<H3 LANG="en-GB" CLASS="western">Creating</H3>
+<P CLASS="western">You must have a minimum of an ACO and an ARO
+defined to create an ACL.</P>
+<P CLASS="western">Select an ACO Section then select from the
+available items show in the Access Control Objects list. Click the [
+&gt; &gt; ] button to add the Section-ACO to the Selected list. You
+may add any number of Section-ACO pairs to this list.</P>
+<P CLASS="western"><IMG SRC="manual_html_m608b392a.png" NAME="Graphic9" ALIGN=LEFT WIDTH=531 HEIGHT=177 BORDER=0><BR CLEAR=LEFT><BR><BR>
+</P>
+<P CLASS="western">Next select an ARO Section. At this point you may
+select from either the Access Request Objects list or from the ARO
+Groups list.</P>
+<P CLASS="western"><IMG SRC="manual_html_157037e7.png" NAME="Graphic10" ALIGN=LEFT WIDTH=531 HEIGHT=157 BORDER=0><BR CLEAR=LEFT><BR><BR>
+</P>
+<P CLASS="western">Select on of the ACL Sections (usually &ldquo;user&rdquo;
+for this case), provide a brief description in the Note area and then
+click Submit. Click on the &ldquo;ACL Admin&rdquo; tab and you will
+see your new ACL in the list.</P>
+<H3 LANG="en-GB" CLASS="western">Sections</H3>
+<P CLASS="western"><IMG SRC="manual_html_676f8c98.png" NAME="Graphic7" ALIGN=LEFT WIDTH=518 HEIGHT=149 BORDER=0><BR CLEAR=LEFT>A
+default install provides you with two ACL sections &ndash; 'system'
+and 'user'. You would typically put user created ACL's (for example,
+those you enter via the admin interface) in the 'user' section and
+put ACL's generated by code in the 'system' section. However, you
+can use the ACL sections to provide any other logical grouping that
+suits your purposes.</P>
+<H3 LANG="en-GB" CLASS="western">Extended Return Value</H3>
+<P CLASS="western">Typically a call to the acl_check method will
+return a boolean value. However, you may specify a different value
+or evan a string to be returned.
+</P>
+<P CLASS="western">For example, you may negotiate for a user to login
+at a cost of $0.20 per time by default and another for $0.18 per time
+under a different scheme. You could create a separate ACL for the
+default login and for the special use but varying the 'return value'.
+ If the call to acl_check is successful, you will know the cost of
+the login via the return value.</P>
+<H3 LANG="en-GB" CLASS="western">Notes</H3>
+<P CLASS="western">It's a good idea to add a note when creating an
+ACL to help remember it's purpose, for example &ldquo;Basic
+permissions for a user in the Administrator group&rdquo;.</P>
+<P CLASS="western"><IMG SRC="manual_html_m4f4324cb.png" NAME="Graphic8" ALIGN=LEFT WIDTH=526 HEIGHT=120 BORDER=0><BR CLEAR=LEFT><BR><BR>
+</P>
+<H1 LANG="en-GB" CLASS="western"><A NAME="Glossary"></A>Glossary</H1>
+<H2 LANG="en-GB" CLASS="western">ACO</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><DFN>Access
+Control Object &ndash; An action that are requested to be performed.</DFN></FONT></FONT></P>
+<H2 LANG="en-GB" CLASS="western">ARO</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><DFN><SPAN LANG="en-US"><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000">Access
+Request Object &ndash; An entity (for example, a user) that is
+requesting an action to be performed.</FONT></FONT></FONT></SPAN></DFN></FONT></FONT></P>
+<H2 LANG="en-GB" CLASS="western">AXO</H2>
+<P CLASS="western" STYLE="line-height: 0.17in"><FONT FACE="Helv, Arial, sans-serif"><FONT SIZE=2><DFN><SPAN LANG="en-US"><FONT SIZE=2><FONT FACE="Helv, Arial, sans-serif"><FONT COLOR="#000000">Access
+eXtension Object &ndash; An object to perform an action on for an
+entity.</FONT></FONT></FONT></SPAN></DFN></FONT></FONT></P>
+<H1 LANG="en-GB" CLASS="western">References</H1>
+<H2 LANG="en-GB" CLASS="western">phpGACL API</H2>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 100%"><FONT FACE="Helv, Arial"><FONT SIZE=2>The
+API documentation is included in the tarball under the /docs/phpdoc/
+directory.</FONT></FONT></P>
+<H2 LANG="en-GB" CLASS="western">phpGACL Examples and Tutorials</H2>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 100%"><FONT FACE="Helv, Arial"><FONT SIZE=2>See
+example.php included in the tarball.</FONT></FONT></P>
+<H2 LANG="en-GB" CLASS="western">Access Control Resources</H2>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 100%"><FONT FACE="Helv, Arial"><FONT SIZE=2>.
+. .</FONT></FONT></P>
+<P CLASS="western"><BR><BR>
+</P>
+<H1 LANG="en-GB" CLASS="western">FAQ</H1>
+<H2 LANG="en-GB" CLASS="western">Can phpGACL handle large sets of
+data?</H2>
+<P LANG="en-GB" CLASS="western" STYLE="line-height: 100%"><FONT FACE="Helv, Arial"><FONT SIZE=2>Not
+a problem at all. We've tested up to 100,000 AXO's and 100,000 ARO's
+on moderate hardware even. The performance issues come down to how
+well you can cache the ACL's, and how fast your database server is.</FONT></FONT></P>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/html/phpgacl/docs/manual.pdf b/html/phpgacl/docs/manual.pdf
new file mode 100644
index 0000000..8410c30
--- /dev/null
+++ b/html/phpgacl/docs/manual.pdf
Binary files differ
diff --git a/html/phpgacl/docs/manual.sxw b/html/phpgacl/docs/manual.sxw
new file mode 100644
index 0000000..d04fa69
--- /dev/null
+++ b/html/phpgacl/docs/manual.sxw
Binary files differ
diff --git a/html/phpgacl/docs/manual.txt b/html/phpgacl/docs/manual.txt
new file mode 100644
index 0000000..18aa209
--- /dev/null
+++ b/html/phpgacl/docs/manual.txt
@@ -0,0 +1,526 @@
+
+Generic Access Control Lists with PHP
+Mike Benoit <ipso@snappymail.ca>
+James Russell <james-phpgacl@ps2-pro.com>
+Karsten Dambekalns <k.dambekalns@fishfarm.de>
+Copyright © 2002,2003,2004 Mike Benoit
+Copyright © 2003, James Russell
+Copyright © 2003, Karsten Dambekalns
+Document Version: 58
+Last Updated: September 3, 2005 - 06:55 PM
+Table of Contents
+Table of Contents 2
+About 4
+What is it? 4
+Where can I get it? 4
+What do I need to run it? 4
+Who is responsible for it? 4
+Introduction 5
+Understanding Access Control 5
+Who/Where 5
+Who/Where 6
+Defining access control with phpGACL 6
+Fine-grain access control 7
+Multi-level Groups 8
+How does phpGACL determine permissions? 9
+Adding groups 10
+Adding people 11
+Resolving conflicts 11
+Naming Access Objects 12
+Adding Sections 14
+Multiple Purposes 15
+Access eXtension Objects 16
+Installation 18
+Basic setup 18
+Advanced setup 20
+Reusing an already existing ADOdb installation 20
+Reusing an already existing Smarty installation 20
+How do I move the phpGACL files out of my website tree while leaving a link in the tree for administration? 20
+Using phpGACL in your application 21
+Basic usage 21
+Advanced usage 21
+Using the ACL admin utility 22
+ACL's 22
+Creating 22
+Sections 23
+Extended Return Value 24
+Notes 24
+Glossary 25
+ACO 25
+ARO 25
+AXO 25
+References 26
+phpGACL API 26
+phpGACL Examples and Tutorials 26
+Access Control Resources 26
+FAQ 27
+Can phpGACL handle large sets of data? 27
+
+About
+What is it?
+phpGACL is an set of functions that allows you to apply access control to arbitrary objects (web pages, databases, etc) by other arbitrary objects (users, remote hosts, etc).
+It offers fine-grained access control with simple management, and is very fast.
+It is written in PHP (hence phpGACL), a popular scripting language that is commonly used to dynamically create web pages. The GACL part of phpGACL stands for Generic Access Control List.
+Where can I get it?
+phpGACL is hosted by sourceforge.net at http://phpGACL.sourceforge.net/
+What do I need to run it?
+phpGACL requires a relational database to store the access control information. It accesses this database via an abstract wrapper called ADOdb. This is compatible with databases such as PostgreSQL, MySQL and Oracle.
+phpGACL is written in the PHP scripting language. It requires PHP 4.2 and above.
+Access Control List administration is performed by a web interface, and therefore it is necessary to have a web server with PHP support, such as Apache.
+Who is responsible for it?
+Mike Benoit <ipso@snappymail.ca> is the author and project manager.
+James Russell <james-phpgacl@ps2-pro.com> and Karsten Dambekalns <k.dambekalns@fishfarm.de> did the documentation.
+Introduction
+Understanding Access Control
+The best way to explain access control is to use examples with real things rather than trying to relate to concepts.
+Han is captain of the Millennium Falcon and Chewie is his second officer. They've taken on board some passengers: Luke, Obi-wan, R2D2 and C3PO. Han needs to define access restrictions for various rooms of the ship: The Cockpit, Lounge, Engines and the external Guns.
+Han says: "Me and Chewie should have access to everywhere, but after a particularly messy hyperdrive repair, I forbid Chewie from going near the Engine Room ever again. Passengers are confined to the Passenger's Lounge."
+Let's assume from now on that access is Boolean. That is, the result of looking up a person's access to a room is either ALLOW or DENY. There is no middle ground.
+If we mapped this statement into an access matrix showing who has access to where, it would look something like this (O means ALLOW, X means DENY):
+Who/Where
+Cockpit
+Lounge
+Guns
+Engines
+Han
+O
+O
+O
+O
+Chewie
+O
+O
+O
+X
+Obi-wan
+X
+O
+X
+X
+Luke
+X
+O
+X
+X
+R2-D2
+X
+O
+X
+X
+C3PO
+X
+O
+X
+X
+The columns list the rooms that Han wants to restrict access to, and the rows list the people that might request access to those rooms. More generally, the "rooms" are "things to control access on". We call these Access Control Objects (ACOs). The "people" are "things requesting access". We call these Access Request Objects (AROs). The people request access to the rooms, or in our terminology, AROs request access to the ACOs.
+There is a third type of Object, the Access eXtention Object (AXO) that we'll discuss later. These objects share many attributes and are collectively referred to as Access Objects.
+Managing access using an access matrix like the one above has advantages and disadvantages.
+Advantages:
+It's very fine-grained. It's possible to control access for an individual person if necessary.
+It's easy to see who has access to what. The answer is stored in the intersection of the person and the room.
+Disadvantages:
+It's difficult to manage on a large scale. 6 passengers and 4 places is fairly simple, but what if there were thousands of passengers and hundreds of places, and you need to restrict access to large groups of them at once, but still retain enough fine-grained control to manage access for an individual? That would mean a lot of fiddly and lengthy adjustment to the matrix, and it's a difficult task to verify that the final matrix is correct.
+It's hard to summarize or visualize. The above example is fairly simple to summarize in a few sentences (as Han did above), but what if the matrix looked like this?
+Who/Where
+Cockpit
+Lounge
+Guns
+Engines
+Han
+O
+O
+O
+O
+Chewie
+O
+X
+O
+X
+Obi-wan
+X
+O
+X
+X
+Luke
+O
+O
+O
+X
+R2-D2
+X
+O
+X
+O
+C3PO
+O
+O
+X
+O
+This matrix is not so obvious to summarize, and it's not clear to the reader why those access decisions might have been made in the first place.
+Defining access control with phpGACL
+It seems that for large or complex situations, this 'access matrix' approach is clearly unsuitable. We need a better system that maintains the advantages (fine-grain control and a clear idea of who has access to what) but removes the disadvantages (difficult to summarize, and difficult to manage large groups of people at once). One solution is phpGACL.
+phpGACL doesn't describe access from the 'bottom-up' like the Access Matrix above. Instead, it describes it 'top-down', like the textual description of Han's access policy. This is a very flexible system that allows you to manage access in large groups, it neatly summarizes the access policy, and it's easy to see who has access to what.
+An ARO tree defines a hierarchy of Groups and AROs (things that request access). This is very similar to a tree view of folders and files. The 'folders' are the Groups and the 'files' are AROs.
+Let's make an ACL tree for the people on Han's ship. First we define some categories for the people. It's clear that Han and Chewie run the ship, and the rest of them are just passengers:
+Millennium Falcon Passengers Group
+??Crew Group
+? ??Han ARO
+? ??Chewie ARO
+??Passengers Group
+ ??Obi-wan ARO
+ ??Luke ARO
+ ??R2D2 ARO
+ ??C3PO ARO
+This tree by itself doesn't specify any access policy; it just shows how we're grouping the people who might request access (AROs).
+We apply access restrictions by assigning instructions about a particular room (ACO) to Groups or AROs in the tree. Han says: "By default, no-one should be allowed access to any room on the Millennium Falcon. But the Crew should have access to every room. The Passengers should only have access to the Lounge."
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie
+??Passengers [ALLOW: Lounge]
+ ??Obi-wan
+ ??Luke
+ ??R2D2
+ ??C3PO
+To interpret this ARO tree, we start from the top and work our way down.
+Firstly, the default policy is always to deny access. Permissions have been overridden for the "Crew", so they have access to everywhere ("ALL" is a synonym for all rooms: "Cockpit, Lounge, Guns, Engines"). The "Passengers" have access only to the Lounge.
+This way of describing the access policy is much clearer than the access matrix. You can easily see who has access to what, and it's easier to determine why they've got access (it seems obvious that Han and Chewie would have access to everything, since they're grouped under "Crew").
+To summarize:
+Access Control Objects (ACOs) are the things we want to control access to (e.g. web pages, databases, rooms, etc).
+Access Request Objects (AROs) are the things that request access (e.g. people, remote computers, etc)
+ARO trees define a hierarchy of Groups and AROs. Groups can contain other Groups and AROs.
+The default 'catch-all' policy for the ARO tree is always "DENY ALL".
+To assign access policy, work your way down the tree, explicitly assigning permissions to Groups and AROs for each ACO as the need arises.
+Fine-grain access control
+Oops! What about Chewie? By grouping him in "Crew", Han has indirectly given him access to the Engines! He doesn't want that after what Chewie recently did to the hyperdrive, so he adds a rule to disallow this:
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+??Passengers [ALLOW: Lounge]
+ ??Obi-wan
+ ??Luke
+ ??R2D2
+ ??C3PO
+This is an example of the way you can control access policy in a fine-grained manner. It is not necessary to move Chewie to another Group; we simply over-ride the access policy at a lower level.
+Another example of fine-grain control happens when the Empire attacks; Han needs to let Luke man the guns, and let R2D2 repair the hyperdrive in the Engine room. He can do this by over-riding the general permissions granted by their status as a "Passenger":
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+??Passengers [ALLOW: Lounge]
+ ??Obi-wan
+ ??Luke [ALLOW: Guns]
+ ??R2D2 [ALLOW: Engines]
+ ??C3PO
+Multi-level Groups
+Groups can be extended to any level in the ARO tree. For example, you could add a Group "Jedi" to "Passengers". Most passengers would be categorized under "Passengers", but Luke and Obi-wan would be under "Jedi" and therefore might be extended extra privileges (like access to the Cockpit):
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+??Passengers [ALLOW: Lounge]
+ ??Jedi [ALLOW: Cockpit]
+ ? ??Obi-wan
+ ? ??Luke [ALLOW: Guns]
+ ??R2D2 [ALLOW: Engines]
+ ??C3PO
+How does phpGACL determine permissions?
+When the ship's computer (running phpGACL of course) checks access, the only question it can ask itself is "Does person X have access to room Y?" In phpGACL terms, this is rephrased as "Does ARO 'X' have access to ACO 'Y'?"
+phpGACL determines whether a specific person has access to a specific room by working from the top of the ARO tree towards the specified person, noting explicit access controls for that place along the way. When it reaches that person, it uses the last explicit access control it encountered as the result to return. In this way, you can define access controls for groups of people, but over-ride them further down the tree if you need to.
+Example 1: We ask: "Does Luke have access to the Lounge?".
+Set the default result, "DENY".
+Work out a path to Luke:
+ Millennium Falcon Passengers ? Passengers ? Jedi ? Luke
+Start at the top of the tree and move towards Luke: The "Millennium Falcon Passengers" node doesn't say anything about any room, so do nothing here.
+Move on to "Passengers", which explicitly says that "Passengers" have Lounge access, so change the internal result to "ALLOW".
+Move to the "Jedi" node, which doesn't mention the Lounge at all.
+Finally move to Luke's node, and again there's nothing there about the Lounge.
+There's nowhere left to go, so the result returned is the current value of the internal result: "ALLOW"
+Example 2: We ask: "Does Chewie have access to the Engines?"
+Set the default result, "DENY".
+Work out a path to Chewie:
+ Millennium Falcon Passengers ? Crew ? Chewie
+Start at the top of the tree and move towards Chewie. The "Millennium Falcon Passengers" node doesn't say anything about anywhere, so do nothing here.
+Move on to "Crew", which explicitly says that "Crew" have Engine access, so change the internal result to "ALLOW".
+Move to Chewie's node, and there's an explicit rule saying that he doesn't have access to the Engines, so change the internal result to "DENY".
+There's nowhere left to go, so the result returned is the current value of the internal result: "DENY"
+As you can see from the examples, if a Group doesn't explicitly specify a permission for a room, then that Group inherits the access restrictions of its parent for that room. If the root node ("Millennium Falcon Passengers") doesn't specify a permission, it inherits it from the default setting ("DENY ALL" in the above examples).
+This implies a couple of interesting points about the ARO tree:
+The ARO tree always shows the full list of the AROs. It would not make sense to ask "Does Jabba have access to the Cockpit?" because Jabba has not been defined in this system. However, phpGACL does not check to see if AROs or ACOs exist before performing the check, so if this question was actually asked then the result would be the default "DENY".
+The ARO tree may not display some defined ACOs, and relies on the default setting to define access policy. For example, say Han defined a "Bathroom" ACO. Any question like "Does Luke have access to the Bathroom?" would have the answer "DENY", because the default is "DENY" and nowhere in the ARO tree does it ever explicitly mention the Bathroom. Keep in mind when examining the ARO tree that some ACOs may not be visible.
+Note: When asking phpGACL questions about access to an ACO, it is not possible to use Groups as AROs (even though it might 'seem' right). For example, it is impossible to answer the question "Do Passengers have access to Guns?" The complete answer is not a Boolean "ALLOW" or "DENY", but the more complex "Luke and Obi-wan can but R2D2 and C3PO cannot." phpGACL is not designed to return that kind of answer.
+Adding groups
+Han feels this ACL is starting to look a little complicated. There are so many exceptions! Perhaps he should make another group, "Engineers", containing the people who are allowed access to the Engines and Guns. That group should contain Han and R2D2 since they're both capable of repairing the engines and guns. This means Han can remove some of those messy exceptions-to-the-rules, and that has the benefit of making the description clearer:
+Default: DENY ALL
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+??Passengers [ALLOW: Lounge]
+? ??Jedi [ALLOW: Cockpit]
+? ? ??Obi-wan
+? ? ??Luke [ALLOW: Guns]
+? ??R2D2
+? ??C3PO
+??Engineers [ALLOW: Engines, Guns]
+ ??Han
+ ??R2D2
+We can read this as "By default, no-one has access to anywhere. Crew have access to everywhere (except Chewie, who has no access to the Engines). Passengers only have access to the Lounge, except Jedi who also have access to the Cockpit. Luke has access to the Guns too. Engineers are allowed access to the Engines and Guns."
+Most importantly, we can see that Han and R2D2 are now in two places in the ACL. It is not necessary for them to be uniquely categorized at all. This defines the policy more clearly to the reader: "Ahh, Han and R2D2 have access to the Engines and Guns because they're engineers."
+Adding people
+Han goes to Cloud City to pick up Lando and get some repairs. Lando's the Millennium Falcon's previous owner, so Han reckons he qualifies as Crew. Lando also offers the services of his top engineer, Hontook, for help with repairing the ship while they're in dock.
+Default: DENY ALL
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+? ??Lando
+??Passengers [ALLOW: Lounge]
+? ??Jedi [ALLOW: Cockpit]
+? ? ??Obi-wan
+? ? ??Luke [ALLOW: Guns]
+? ??R2D2
+? ??C3PO
+??Engineers [ALLOW: Engines, Guns]
+ ??Han
+ ??R2D2
+ ??Hontook
+This shows how easy it is to grant new people access. If we used the original matrix scheme, we'd have to set permissions for each room for both Lando and Hontook. Instead, we simply add them to their appropriate groups and their access is implicitly and easily defined.
+Resolving conflicts
+What happens if we add Chewie to the list of Engineers?
+Default: DENY ALL
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??Han
+? ??Chewie [DENY: Engines]
+? ??Lando
+??Passengers [ALLOW: Lounge]
+? ??Jedi [ALLOW: Cockpit]
+? ? ??Obi-wan
+? ? ??Luke [ALLOW: Guns]
+? ??R2D2
+? ??C3PO
+??Engineers [ALLOW: Engines, Guns]
+ ??Han
+ ??R2D2
+ ??Hontook
+ ??Chewie
+This makes Chewie's access to the Engines ambiguous, because now there are two paths from the root of the tree to Chewie. If the ship's computer follows one path (along the "Crew" branch), the result is "DENY access to Engines." If it follows the other path (along the "Engineers" branch) then the result is "ALLOW access to Engines". So, is he allowed or denied?
+phpGACL will warn you if you add or edit an multiply-grouped ARO in such a way that the ARO's access to an arbitrary ACO would be ambiguous. But it is up to you to resolve the conflict.
+If we now asked phpGACL the question "Does Chewie have access to Engines?" the result returned is the result given by the last ACL entry to be modified (this is phpGACL's policy). In this case the result is ALLOW, because the "ALLOW: Engines, Guns" directive assigned to the Engineers Group is more recent than the "DENY: Engines" directive assigned to Chewie's Group.
+When ambiguous access entries exist in the ACL, the ACL is said to be inconsistent. Inconsistent ACLs can be very dangerous, and you may unwittingly provide access to inappropriate people if you allow your ACL to remain in this state. When phpGACL warns you that the ACL is inconsistent, it is best to resolve the conflicts as soon as possible to regain consistency.
+To resolve the conflict in this case, we could either:
+Remove the "DENY: Engines" directive from Chewie's entry under the Crew Group.
+Add a "DENY: Engines" directive to Chewie's entry under the Engineers Group.
+Remove Chewie from the Engineers Group, since Han doesn't think him a worthy Engineer anyway.
+Han chooses option 3, and removes Chewie from the Engineers list.
+Naming Access Objects
+phpGACL uniquely identifies each Access Object (AROs, AXOs and ACOs) with a two-keyword combination and it's Access Object type.
+The tuple "(Access Object type, Section, Value)" uniquely identifies any Access Object.
+The first element of the tuple is the type of Access Object (ARO, AXO or ACO).
+The second element of the tuple, called the Section, is a user-defined string which names the general category of the Access Object. Multiple Access Objects can share the same Section name. The Section name should be short but descriptive. It's used in the user interface in selection boxes, so try not to make it too long.
+Sections are stored in a flat namespace; they are not nestable like Groups. Sections have nothing to do with Groups or the ARO/AXO trees - they are purely a mechanism for helping to maintain large numbers of Access Objects.
+The third element of the tuple is a user-defined name for the Access Object, and is called the Value. A Value cannot contain spaces (however, a Section can).
+Both Section and Values are case sensitive.
+Aside: It is commonly asked why strings are used to identify Access Objects, rather than integers which ostensibly seem faster. The answer is for legibility. It is much easier to understand:
+ acl_check('system', 'login', 'users', 'john_doe');
+than:
+ acl_check(10, 21004, 15, 20304);
+Since it is often obvious from the context which type of Access Object we are referring to, the interface for phpGACL (and this documentation) drops the Access Object type and uses the format "Section > Value" when displaying the name of an Access Object. However, the API requires an Access Object's "Section" and "Value" to be specified in separate function arguments (the Access Object type is usually implicit in the argument description).
+Example ACO "Section > Values":
+"Floors > 1st"
+"Floors > 2nd"
+"Rooms > Engines"
+Example ARO "Section > Values":
+"People > John_Smith"
+"People > Cathy_Jones"
+"Hosts > sandbox.something.com"
+Example API usage:
+acl_check ( aco_section, aco_value, aro_section, aro_value);
+acl_check ( 'Floors', '2nd', 'People', 'John_Smith' );
+Valid Naming Restrictions Examples:
+"ACO -Frob > Flerg", "ARO - Frob > Flerg" (The Section and Value are the same in both, but this is fine as namespaces are separate across Access Object types)
+"ACO -Frob > Flerg", "ACO - Frob > Queegle" (The Access Object type and Section are the same, but this is fine as the Values are different)
+"AXO - Frob Hrung > Flerg" (Sections can contain spaces)
+Invalid Naming Restrictions Examples:
+"ACO - Frob > Flerg", "ACO - Frob > Flerg" ("Access Object type - Section > Value" must be unique)
+"ACO - Frob > Flerg Habit" (Values cannot contain spaces)
+Adding Sections
+Before you can add a new Access Object, its Section must be defined. To add a new section, use the add_object_section() function.
+add_object_section (
+string NAME, A short description of what this Section is for. (e.g. "Levels in building").
+string VALUE, The name of the Section (e.g. "Floor").
+int ORDER, An arbitrary value which affects the order this Section appears in the UI.
+bool HIDDEN, Whether this should appear in the UI or not (TRUE means that is will be hidden).
+string GROUP_TYPE) The Access Object type ("aco", "aro" or "axo")
+Han creates 3 Sections for the AROs. "Humans", "Aliens" and "Androids". Let's list the AROs with their full names
+Millennium Falcon Passengers
+??Crew [ALLOW: ALL]
+? ??"Humans > Han"
+? ??"Aliens > Chewie" [DENY: Engines]
+? ??"Humans > Lando"
+??Passengers [ALLOW: Lounge]
+? ??Jedi [ALLOW: Cockpit]
+? ? ??"Humans > Obi-wan"
+? ? ??"Humans > Luke" [ALLOW: Guns]
+? ??"Androids > R2D2"
+? ??"Androids > C3PO"
+??Engineers [ALLOW: Engines, Guns]
+ ??"Humans > Han"
+ ??"Androids > R2D2"
+ ??"Aliens > Hontook"
+Sections are just a way of categorizing Access Objects, to make the user interface more usable, and the code for acl_check() more readable. They do not affect the way phpGACL determines access to an object. They cannot be nested (so it would not be able to create a "Males" sub-Section under "Humans" for example; you'd have to create a Section called "Humans-Male" or similar)
+Multiple Purposes
+You may need to use phpGACL for multiple independent purposes. For example, you may need to restrict user access to web pages, and also remote host access to your server. The two tasks are not related.
+phpGACL can handle this in three different ways.
+It can use an alternative database to store the access tables.
+It can use the same database but with differently named access tables. (this feature is not implemented yet).
+You can store the Access Objects for both purposes in the same tables, and carefully manage your list so that they don't conflict.
+To implement Option 1 (and Option 2 when it becomes available), use the $gacl_options array when creating a new phpGACL class. This allows you to specify the database and table name prefixes to use:
+$gacl_options = array(
+ 'db_table_prefix' => 'gacl_',
+ 'db_type' => 'mysql',
+ 'db_host' => 'host1',
+ 'db_user' => 'user',
+ 'db_password' => 'passwd',
+ 'db_name' => 'gacl');
+
+$gacl_host1 = new gacl($gacl_options);
+To implement Option 3, you must be careful, since phpGACL doesn't know the relationship between your different tasks, and it will be possible to make meaningless Access Policy Directives.
+For example, say Han wanted to restrict access to other ships contacting his ship's computer, in addition to restricting access to the different rooms. To do this, he might add "Luke's X-Wing Fighter" as a remote ship ARO (in addition to other ships and an ACO for the ship's computer). Because all AROs are in the same ARO tree, it would be possible to create an APD like "Ships > Luke's X-Wing Fighter" [ALLOW: "Rooms > Lounge"], which would be totally meaningless! To help reduce mistakes like this, good Section naming can make it clearer what Access Objects are for which tasks. It should be obvious to any administrator that it's meaningless to assign a Ship permission to use a Room.
+Access eXtension Objects
+Access eXtension Objects (AXOs) can add a 3rd dimension to the permissions that can be configured in phpGACL. We've seen how phpGACL allows you to combine an ARO and an ACO (2 dimensions) to create an Access Policy Directive. This is great for simple permission requests like:
+ Luke (ARO) requests access to "Guns" (ACO)
+If that's all you need, that's fine - AXOs are totally optional.
+But because all ACOs are considered equal, it makes it difficult to manage if there are many ACOs. If this is the case, we can change the way we look at Access Objects to manage it more easily.
+AXOs are identical to AROs in many respects. There is an AXO tree (separate from the ARO tree), with it's own Groups and AXOs. When dealing with AXOs, consider an AXO to take the old role of the ACO (i.e. "things to control access on"), and change the view of ACOs from "things to control access on" to "actions that are requested".
+ARO and ACO-only View:
+AROs: Things requesting access
+ACOs: Things to control access on
+ARO, ACO and AXO View:
+AROs: Things requesting access
+ACOs: Actions that are requested
+AXOs: Things to control access on
+Example:
+A website manager is trying to manage access to projects on the website. The ARO tree consists of all the users:
+Website
+??Administrators
+? ??Alice
+? ??Carol
+??Users
+ ??Bob
+ ??Alan
+The projects are organized by Operating System into categories in the AXO tree:
+Projects
+??Linux
+? ??SpamFilter2
+? ??AutoLinusWorshipper
+??Windows
+ ??PaperclipKiller
+ ??PopupStopper
+The actions that can be taken with each project are "View" and "Edit". These are the ACOs.
+Now we want Bob to have "View" access to all the Linux projects, so it's possible to add an ACL that links Bob's ARO to the View ACO and the Linux AXO, and thus we can ask the question:
+ Bob (ARO) requests access to "View" (ACO) the project(s) called "Linux" (AXO)
+Keep in mind AXO's are optional, if you don't specify an AXO when calling acl_check() and a matching ACL exists with no AXO, it will be allowed. However if only ACLs exist with AXO's, and you call acl_check() without an AXO, it will fail.
+So basically as soon as you specify an AXO when calling acl_check(), acl_check() will only search ACLs containing AXO's. If no AXO is specified, only ACLs without AXOs are searched. This in theory (I haven't benchmarked) gives us a slight performance increase as well.
+Installation
+Basic setup
+1.Untar the distribution .tar.gz file into the root or a subdirectory of your web site. You might want to rename it to something more suitable.
+
+
+2.Edit phpgacl/gacl.class.php using your favourite editor and set the db_type, db_host, db_user, db_password, and db_name you will be using.
+
+
+Now edit phpgacl/admin/gacl_admin.inc.php to hold the same information. This file is used by the setup script as well as the ACL admin backend.
+The reason for two files holding that (same) information, is that the core ACL library gacl.class.php is much smaller than the full-fledged API class, and there is no need to include all the code when you just want to call acl_check().
+3.Create the database you specified in db_name on the server.
+
+
+
+4.Surf to http://yoursite.net/phpgacl/setup.php. The required tables will be installed based on your choice of database. Don't be afraid of the truckload of output, if all goes well you will see only success messages.
+
+
+5.Now follow the last advice shown on that screen and create the phpgacl/admin/smarty/templates_c directory. It must be writable by the user the webserver runs as. If you don't do this, you will not be able to use the CAL admin!
+6.Click the link at the bottom of the successful setup page or surf to:
+http://yoursite.net/phpgacl/admin/acl_admin.php
+Advanced setup
+Reusing an already existing ADOdb installation
+If you already have ADOdb installed you can get phpGACL to use this copy of ADOdb.
+1.Edit phpgacl/gacl.class.php so that ADODB_DIR reflects the location of the ADOdb library in your path.
+2.Rename the phpgacl/adodb folder to something else like adodb_x and reload the phpgacl/admin/acl_admin.php page to ensure it still works.
+3.Erase the adodb directory installed with phpGACL.
+Reusing an already existing Smarty installation
+If you already have ADOdb installed you can get phpGACL to use this copy of ADOdb.
+1.Edit phpgacl/admin/gacl_admin.inc.php so that the variables $smarty_dir and $smarty_compile_dir reflect the location of the Smarty library in your path and the template_c directory you already use.
+Move the templates directory that came with phpGACL to another directory (e.g. one level up). Adjust the $smarty_template_dir so it points to the new location. If you like you can move those templates to your existing templates folder, of course.
+2.Rename the phpgacl/smarty folder to something else like smarty_x and reload the phpgacl/admin/acl_admin.php page to ensure it still works.
+3.Erase the smarty directory installed with phpGACL.
+How do I move the phpGACL files out of my website tree while leaving a link in the tree for administration?
+1.Go to your website root.
+2.Move the phpGACL directory to your includes directory and create a symlink to the admin directory where you want the admin tool to go. For example:
+mv phpgacl/ /www/includes_directory
+ln -s /www/includes_directory/phpgacl/admin/ gacl
+3.Now surfing to http://yoursite.net/gacl/acl_admin.php will take you to the admin page. If it doesn't work, make sure your Webserver allows symbolic links in the website tree.
+Using phpGACL in your application
+Basic usage
+This example shows a basic example of using phpGACL in your code. It uses the ADOdb abstraction layer as well, and shows a simple way to validate a login attempt against a database.
+// include basic ACL api
+include('phpgacl/gacl.class.php');
+$gacl = new gacl();
+$username = $db->quote($_POST['username']);
+$password = $db->quote(md5($_POST['password']));
+$sql = 'SELECT name FROM users WHERE name=';
+$sql .= $username.' AND password='.$password;
+$row = $db->GetRow($sql);
+if($gacl->acl_check('system','login','user',$row['name'])){
+ $_SESSION['username'] = $row['name'];
+ return true;
+}
+else
+ return false;
+As you can see there is only one call to acl_check() in this code. What does it do? Well, it
+checks the ARO object $row['name'] from the ARO section 'user'
+against the ACO object 'login' from the ACO section 'system'.
+Advanced usage
+
+Using the ACL admin utility
+If you want to get a grip on the included ACL admin utitlity, it will help you a lot if you run the example.php file. It contains some ACO, ARO and AXO objects, as well as some ACL defined using those objects. After running it, you should see some sample data in the admin interface.
+
+
+Play around with it, and if you get stuck, come back and read on...
+(yet to be written)
+ACL's
+Creating
+You must have a minimum of an ACO and an ARO defined to create an ACL.
+Select an ACO Section then select from the available items show in the Access Control Objects list. Click the [ > > ] button to add the Section-ACO to the Selected list. You may add any number of Section-ACO pairs to this list.
+
+Next select an ARO Section. At this point you may select from either the Access Request Objects list or from the ARO Groups list.
+
+Select on of the ACL Sections (usually "user" for this case), provide a brief description in the Note area and then click Submit. Click on the "ACL Admin" tab and you will see your new ACL in the list.
+Sections
+A default install provides you with two ACL sections - 'system' and 'user'. You would typically put user created ACL's (for example, those you enter via the admin interface) in the 'user' section and put ACL's generated by code in the 'system' section. However, you can use the ACL sections to provide any other logical grouping that suits your purposes.
+Extended Return Value
+Typically a call to the acl_check method will return a boolean value. However, you may specify a different value or evan a string to be returned.
+For example, you may negotiate for a user to login at a cost of $0.20 per time by default and another for $0.18 per time under a different scheme. You could create a separate ACL for the default login and for the special use but varying the 'return value'. If the call to acl_check is successful, you will know the cost of the login via the return value.
+Notes
+It's a good idea to add a note when creating an ACL to help remember it's purpose, for example "Basic permissions for a user in the Administrator group".
+
+Glossary
+ACO
+Access Control Object - An action that are requested to be performed.
+ARO
+Access Request Object - An entity (for example, a user) that is requesting an action to be performed.
+AXO
+Access eXtension Object - An object to perform an action on for an entity.
+References
+phpGACL API
+The API documentation is included in the tarball under the /docs/phpdoc/ directory.
+phpGACL Examples and Tutorials
+See example.php included in the tarball.
+Access Control Resources
+. . .
+
+FAQ
+Can phpGACL handle large sets of data?
+Not a problem at all. We've tested up to 100,000 AXO's and 100,000 ARO's on moderate hardware even. The performance issues come down to how well you can cache the ACL's, and how fast your database server is. \ No newline at end of file
diff --git a/html/phpgacl/docs/manual_html_157037e7.png b/html/phpgacl/docs/manual_html_157037e7.png
new file mode 100644
index 0000000..c09367c
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_157037e7.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_4b803670.png b/html/phpgacl/docs/manual_html_4b803670.png
new file mode 100644
index 0000000..64f75b8
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_4b803670.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_676f8c98.png b/html/phpgacl/docs/manual_html_676f8c98.png
new file mode 100644
index 0000000..9c040e4
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_676f8c98.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_7dced6ce.png b/html/phpgacl/docs/manual_html_7dced6ce.png
new file mode 100644
index 0000000..0600fa7
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_7dced6ce.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m481ab4b3.png b/html/phpgacl/docs/manual_html_m481ab4b3.png
new file mode 100644
index 0000000..3943cc4
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m481ab4b3.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m48c2db5c.png b/html/phpgacl/docs/manual_html_m48c2db5c.png
new file mode 100644
index 0000000..ee8b44e
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m48c2db5c.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m4f4324cb.png b/html/phpgacl/docs/manual_html_m4f4324cb.png
new file mode 100644
index 0000000..8c0eca6
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m4f4324cb.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m54d0ced8.png b/html/phpgacl/docs/manual_html_m54d0ced8.png
new file mode 100644
index 0000000..4e78430
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m54d0ced8.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m608b392a.png b/html/phpgacl/docs/manual_html_m608b392a.png
new file mode 100644
index 0000000..d8a9c01
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m608b392a.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m6a630ca2.png b/html/phpgacl/docs/manual_html_m6a630ca2.png
new file mode 100644
index 0000000..9609485
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m6a630ca2.png
Binary files differ
diff --git a/html/phpgacl/docs/manual_html_m770a5a15.png b/html/phpgacl/docs/manual_html_m770a5a15.png
new file mode 100644
index 0000000..9aaadad
--- /dev/null
+++ b/html/phpgacl/docs/manual_html_m770a5a15.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/blank.html b/html/phpgacl/docs/phpdoc/blank.html
new file mode 100644
index 0000000..e92c6cc
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/blank.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+ <title>phpGACL 3.3.6 Developer's Manual</title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+</head>
+<body>
+<div align="center"><h1>phpGACL 3.3.6 Developer's Manual</h1></div>
+<b>Welcome to phpGACL!</b><br />
+<br />
+This documentation was generated by <a href="http://www.phpdoc.org">phpDocumentor v1.3.0RC3</a><br />
+</body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/classtrees_phpGACL.html b/html/phpgacl/docs/phpdoc/classtrees_phpGACL.html
new file mode 100644
index 0000000..5cd04a0
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/classtrees_phpGACL.html
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title></title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+
+<!-- Start of Class Data -->
+<H2>
+
+</H2>
+<h2>Root class gacl</h2>
+<ul>
+<li><a href="phpGACL/gacl.html">gacl</a><ul>
+<li><a href="phpGACL/gacl_api.html">gacl_api</a></li></ul></li>
+</ul>
+
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:28 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/elementindex.html b/html/phpgacl/docs/phpdoc/elementindex.html
new file mode 100644
index 0000000..930dce0
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/elementindex.html
@@ -0,0 +1,701 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title></title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <a name="top"></a>
+<h2>Full index</h2>
+<h3>Package indexes</h3>
+<ul>
+ <li><a href="elementindex_phpGACL.html">phpGACL</a></li>
+</ul>
+<br />
+<div class="index-letter-menu">
+ <a class="index-letter" href="elementindex.html#a">a</a>
+ <a class="index-letter" href="elementindex.html#c">c</a>
+ <a class="index-letter" href="elementindex.html#d">d</a>
+ <a class="index-letter" href="elementindex.html#e">e</a>
+ <a class="index-letter" href="elementindex.html#f">f</a>
+ <a class="index-letter" href="elementindex.html#g">g</a>
+ <a class="index-letter" href="elementindex.html#i">i</a>
+ <a class="index-letter" href="elementindex.html#p">p</a>
+ <a class="index-letter" href="elementindex.html#r">r</a>
+ <a class="index-letter" href="elementindex.html#s">s</a>
+ <a class="index-letter" href="elementindex.html#_">_</a>
+</div>
+
+ <a name="a"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">a</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_check</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_check">gacl::acl_check()</a> in gacl.class.php</div>
+ <div class="index-item-description">Wraps the actual acl_query() function.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_check_array</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_check_array">gacl::acl_check_array()</a> in gacl.class.php</div>
+ <div class="index-item-description">Handles ACL lookups over arrays of AROs</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_get_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_get_groups">gacl::acl_get_groups()</a> in gacl.class.php</div>
+ <div class="index-item-description">Grabs all groups mapped to an ARO. You can also specify a root_group for subtree'ing.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_query</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_query">gacl::acl_query()</a> in gacl.class.php</div>
+ <div class="index-item-description">The Main function that does the actual ACL lookup.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_return_value</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_return_value">gacl::acl_return_value()</a> in gacl.class.php</div>
+ <div class="index-item-description">Wraps the actual acl_query() function.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_acl">gacl_api::add_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_group">gacl_api::add_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_group_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_group_object">gacl_api::add_group_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_group_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_object">gacl_api::add_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_object_section">gacl_api::add_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_object_section()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Constant.png" alt="Constant" title="Constant" /></title>
+ <span class="const-title">ADODB_DIR</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_class_php.html#defineADODB_DIR">ADODB_DIR</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">append_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodappend_acl">gacl_api::append_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">append_acl()</div>
+ </dd>
+ </dl>
+ <a name="c"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">c</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$config_file</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$config_file">gacl::$config_file</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">clear_database</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodclear_database">gacl_api::clear_database()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">clear_database()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">consolidated_edit_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodconsolidated_edit_acl">gacl_api::consolidated_edit_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">consolidated_edit_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">count_all</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodcount_all">gacl_api::count_all()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">count_all()</div>
+ </dd>
+ </dl>
+ <a name="d"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">d</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">debug_db</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methoddebug_db">gacl::debug_db()</a> in gacl.class.php</div>
+ <div class="index-item-description">Prints database debug text if debug is enabled.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">debug_text</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methoddebug_text">gacl::debug_text()</a> in gacl.class.php</div>
+ <div class="index-item-description">Prints debug text if debug is enabled.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_acl">gacl_api::del_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_group">gacl_api::del_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_group_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_group_object">gacl_api::del_group_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_group_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_object">gacl_api::del_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_object_section">gacl_api::del_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_object_section()</div>
+ </dd>
+ </dl>
+ <a name="e"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">e</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_acl">gacl_api::edit_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_group">gacl_api::edit_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_object">gacl_api::edit_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_object_section">gacl_api::edit_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_object_section()</div>
+ </dd>
+ </dl>
+ <a name="f"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">f</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">format_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodformat_groups">gacl_api::format_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">format_groups()</div>
+ </dd>
+ </dl>
+ <a name="g"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">g</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Class.png" alt="Class" title="Class" /></title>
+ gacl
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html">gacl</a> in gacl.class.php</div>
+ <div class="index-item-description">phpGACL main class</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Constructor.png" alt="Method" title="Method" /></title>
+ <span class="method-title">gacl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodgacl">gacl::gacl()</a> in gacl.class.php</div>
+ <div class="index-item-description">Constructor</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Class.png" alt="Class" title="Class" /></title>
+ gacl_api
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html">gacl_api</a> in gacl_api.class.php</div>
+ <div class="index-item-description">gacl_api Extended API Class</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Page.png" alt="Page" title="Page" /></title>
+ <span class="include-title">gacl_api.class.php</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_api_class_php.html">gacl_api.class.php</a> in gacl_api.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Page.png" alt="Page" title="Page" /></title>
+ <span class="include-title">gacl.class.php</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_class_php.html">gacl.class.php</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_acl">gacl_api::get_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_cache</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodget_cache">gacl::get_cache()</a> in gacl.class.php</div>
+ <div class="index-item-description">Uses PEAR's Cache_Lite package to grab cached arrays, objects, variables etc...</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_children</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_children">gacl_api::get_group_children()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_children()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_data">gacl_api::get_group_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_id">gacl_api::get_group_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_objects">gacl_api::get_group_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_objects()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_parent_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_parent_id">gacl_api::get_group_parent_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_parent_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object">gacl_api::get_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_objects">gacl_api::get_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_objects ()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_data">gacl_api::get_object_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_groups">gacl_api::get_object_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_groups()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_id">gacl_api::get_object_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_section_section_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_section_section_id">gacl_api::get_object_section_section_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_section_section_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_section_value</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_section_value">gacl_api::get_object_section_value()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_section_value()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_root_group_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_root_group_id">gacl_api::get_root_group_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_root_group_id ()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_schema_version</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_schema_version">gacl_api::get_schema_version()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_schema_version()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_section_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_section_data">gacl_api::get_section_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_section_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_ungrouped_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_ungrouped_objects">gacl_api::get_ungrouped_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_ungrouped_objects()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_version</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_version">gacl_api::get_version()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_version()</div>
+ </dd>
+ </dl>
+ <a name="i"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">i</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">is_conflicting_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodis_conflicting_acl">gacl_api::is_conflicting_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">is_conflicting_acl()</div>
+ </dd>
+ </dl>
+ <a name="p"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">p</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">put_cache</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodput_cache">gacl::put_cache()</a> in gacl.class.php</div>
+ <div class="index-item-description">Uses PEAR's Cache_Lite package to write cached arrays, objects, variables etc...</div>
+ </dd>
+ </dl>
+ <a name="r"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">r</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">rebuild_tree</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodrebuild_tree">gacl_api::rebuild_tree()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">rebuild_tree ()</div>
+ </dd>
+ </dl>
+ <a name="s"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">s</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">search_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodsearch_acl">gacl_api::search_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">search_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">shift_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodshift_acl">gacl_api::shift_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">shift_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">showarray</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodshowarray">gacl_api::showarray()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">showarray()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">sort_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodsort_groups">gacl_api::sort_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">sort_groups()</div>
+ </dd>
+ </dl>
+ <a name="_"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">_</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_cache_dir</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_cache_dir">gacl::$_cache_dir</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_cache_expire_time</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_cache_expire_time">gacl::$_cache_expire_time</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_caching</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_caching">gacl::$_caching</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db">gacl::$_db</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_host</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_host">gacl::$_db_host</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_name</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_name">gacl::$_db_name</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_password</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_password">gacl::$_db_password</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_table_prefix</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_table_prefix">gacl::$_db_table_prefix</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_type</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_type">gacl::$_db_type</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_user</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_user">gacl::$_db_user</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_debug</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_debug">gacl::$_debug</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_force_cache_expire</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_force_cache_expire">gacl::$_force_cache_expire</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_group_switch</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_group_switch">gacl::$_group_switch</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">_rebuild_tree</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#method_rebuild_tree">gacl_api::_rebuild_tree()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">_rebuild_tree ()</div>
+ </dd>
+ </dl>
+
+<div class="index-letter-menu">
+ <a class="index-letter" href="elementindex.html#a">a</a>
+ <a class="index-letter" href="elementindex.html#c">c</a>
+ <a class="index-letter" href="elementindex.html#d">d</a>
+ <a class="index-letter" href="elementindex.html#e">e</a>
+ <a class="index-letter" href="elementindex.html#f">f</a>
+ <a class="index-letter" href="elementindex.html#g">g</a>
+ <a class="index-letter" href="elementindex.html#i">i</a>
+ <a class="index-letter" href="elementindex.html#p">p</a>
+ <a class="index-letter" href="elementindex.html#r">r</a>
+ <a class="index-letter" href="elementindex.html#s">s</a>
+ <a class="index-letter" href="elementindex.html#_">_</a>
+</div> </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/elementindex_phpGACL.html b/html/phpgacl/docs/phpdoc/elementindex_phpGACL.html
new file mode 100644
index 0000000..832d870
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/elementindex_phpGACL.html
@@ -0,0 +1,698 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title></title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <a name="top"></a>
+<h2>[phpGACL] element index</h2>
+<a href="elementindex.html">All elements</a>
+<br />
+<div class="index-letter-menu">
+ <a class="index-letter" href="elementindex_phpGACL.html#a">a</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#c">c</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#d">d</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#e">e</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#f">f</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#g">g</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#i">i</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#p">p</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#r">r</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#s">s</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#_">_</a>
+</div>
+
+ <a name="_"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">_</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_cache_dir</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_cache_dir">gacl::$_cache_dir</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_cache_expire_time</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_cache_expire_time">gacl::$_cache_expire_time</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_caching</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_caching">gacl::$_caching</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db">gacl::$_db</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_host</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_host">gacl::$_db_host</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_name</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_name">gacl::$_db_name</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_password</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_password">gacl::$_db_password</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_table_prefix</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_table_prefix">gacl::$_db_table_prefix</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_type</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_type">gacl::$_db_type</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_db_user</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_db_user">gacl::$_db_user</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_debug</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_debug">gacl::$_debug</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_force_cache_expire</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_force_cache_expire">gacl::$_force_cache_expire</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$_group_switch</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$_group_switch">gacl::$_group_switch</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">_rebuild_tree</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#method_rebuild_tree">gacl_api::_rebuild_tree()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">_rebuild_tree ()</div>
+ </dd>
+ </dl>
+ <a name="a"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">a</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_check</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_check">gacl::acl_check()</a> in gacl.class.php</div>
+ <div class="index-item-description">Wraps the actual acl_query() function.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_check_array</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_check_array">gacl::acl_check_array()</a> in gacl.class.php</div>
+ <div class="index-item-description">Handles ACL lookups over arrays of AROs</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_get_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_get_groups">gacl::acl_get_groups()</a> in gacl.class.php</div>
+ <div class="index-item-description">Grabs all groups mapped to an ARO. You can also specify a root_group for subtree'ing.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_query</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_query">gacl::acl_query()</a> in gacl.class.php</div>
+ <div class="index-item-description">The Main function that does the actual ACL lookup.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">acl_return_value</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodacl_return_value">gacl::acl_return_value()</a> in gacl.class.php</div>
+ <div class="index-item-description">Wraps the actual acl_query() function.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_acl">gacl_api::add_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_group">gacl_api::add_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_group_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_group_object">gacl_api::add_group_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_group_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_object">gacl_api::add_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">add_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodadd_object_section">gacl_api::add_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">add_object_section()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Constant.png" alt="Constant" title="Constant" /></title>
+ <span class="const-title">ADODB_DIR</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_class_php.html#defineADODB_DIR">ADODB_DIR</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">append_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodappend_acl">gacl_api::append_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">append_acl()</div>
+ </dd>
+ </dl>
+ <a name="c"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">c</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Variable.png" alt="Variable" title="Variable" /></title>
+ <span class="var-title">$config_file</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#var$config_file">gacl::$config_file</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">clear_database</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodclear_database">gacl_api::clear_database()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">clear_database()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">consolidated_edit_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodconsolidated_edit_acl">gacl_api::consolidated_edit_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">consolidated_edit_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">count_all</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodcount_all">gacl_api::count_all()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">count_all()</div>
+ </dd>
+ </dl>
+ <a name="d"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">d</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">debug_db</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methoddebug_db">gacl::debug_db()</a> in gacl.class.php</div>
+ <div class="index-item-description">Prints database debug text if debug is enabled.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">debug_text</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methoddebug_text">gacl::debug_text()</a> in gacl.class.php</div>
+ <div class="index-item-description">Prints debug text if debug is enabled.</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_acl">gacl_api::del_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_group">gacl_api::del_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_group_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_group_object">gacl_api::del_group_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_group_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_object">gacl_api::del_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">del_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methoddel_object_section">gacl_api::del_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">del_object_section()</div>
+ </dd>
+ </dl>
+ <a name="e"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">e</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_acl">gacl_api::edit_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_group</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_group">gacl_api::edit_group()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_group()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_object">gacl_api::edit_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">edit_object_section</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodedit_object_section">gacl_api::edit_object_section()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">edit_object_section()</div>
+ </dd>
+ </dl>
+ <a name="f"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">f</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">format_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodformat_groups">gacl_api::format_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">format_groups()</div>
+ </dd>
+ </dl>
+ <a name="g"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">g</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Class.png" alt="Class" title="Class" /></title>
+ gacl
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html">gacl</a> in gacl.class.php</div>
+ <div class="index-item-description">phpGACL main class</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Constructor.png" alt="Method" title="Method" /></title>
+ <span class="method-title">gacl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodgacl">gacl::gacl()</a> in gacl.class.php</div>
+ <div class="index-item-description">Constructor</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Class.png" alt="Class" title="Class" /></title>
+ gacl_api
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html">gacl_api</a> in gacl_api.class.php</div>
+ <div class="index-item-description">gacl_api Extended API Class</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Page.png" alt="Page" title="Page" /></title>
+ <span class="include-title">gacl_api.class.php</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_api_class_php.html">gacl_api.class.php</a> in gacl_api.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Page.png" alt="Page" title="Page" /></title>
+ <span class="include-title">gacl.class.php</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/_gacl_class_php.html">gacl.class.php</a> in gacl.class.php</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_acl">gacl_api::get_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_cache</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodget_cache">gacl::get_cache()</a> in gacl.class.php</div>
+ <div class="index-item-description">Uses PEAR's Cache_Lite package to grab cached arrays, objects, variables etc...</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_children</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_children">gacl_api::get_group_children()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_children()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_data">gacl_api::get_group_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_id">gacl_api::get_group_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_objects">gacl_api::get_group_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_objects()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_group_parent_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_group_parent_id">gacl_api::get_group_parent_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_group_parent_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object">gacl_api::get_object()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_objects">gacl_api::get_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_objects ()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_data">gacl_api::get_object_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_groups">gacl_api::get_object_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_groups()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_id">gacl_api::get_object_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_section_section_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_section_section_id">gacl_api::get_object_section_section_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_section_section_id()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_object_section_value</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_object_section_value">gacl_api::get_object_section_value()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_object_section_value()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_root_group_id</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_root_group_id">gacl_api::get_root_group_id()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_root_group_id ()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_schema_version</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_schema_version">gacl_api::get_schema_version()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_schema_version()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_section_data</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_section_data">gacl_api::get_section_data()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_section_data()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_ungrouped_objects</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_ungrouped_objects">gacl_api::get_ungrouped_objects()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_ungrouped_objects()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">get_version</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodget_version">gacl_api::get_version()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">get_version()</div>
+ </dd>
+ </dl>
+ <a name="i"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">i</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">is_conflicting_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodis_conflicting_acl">gacl_api::is_conflicting_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">is_conflicting_acl()</div>
+ </dd>
+ </dl>
+ <a name="p"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">p</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">put_cache</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl.html#methodput_cache">gacl::put_cache()</a> in gacl.class.php</div>
+ <div class="index-item-description">Uses PEAR's Cache_Lite package to write cached arrays, objects, variables etc...</div>
+ </dd>
+ </dl>
+ <a name="r"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">r</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">rebuild_tree</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodrebuild_tree">gacl_api::rebuild_tree()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">rebuild_tree ()</div>
+ </dd>
+ </dl>
+ <a name="s"></a>
+ <div class="index-letter-section">
+ <div style="float: left" class="index-letter-title">s</div>
+ <div style="float: right"><a href="#top">top</a></div>
+ <div style="clear: both"></div>
+ </div>
+ <dl>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">search_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodsearch_acl">gacl_api::search_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">search_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">shift_acl</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodshift_acl">gacl_api::shift_acl()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">shift_acl()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">showarray</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodshowarray">gacl_api::showarray()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">showarray()</div>
+ </dd>
+ <dt class="field">
+ <img src="media/images/Method.png" alt="Method" title="Method" /></title>
+ <span class="method-title">sort_groups</span>
+ </dt>
+ <dd class="index-item-body">
+ <div class="index-item-details"><a href="phpGACL/gacl_api.html#methodsort_groups">gacl_api::sort_groups()</a> in gacl_api.class.php</div>
+ <div class="index-item-description">sort_groups()</div>
+ </dd>
+ </dl>
+
+<div class="index-letter-menu">
+ <a class="index-letter" href="elementindex_phpGACL.html#a">a</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#c">c</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#d">d</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#e">e</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#f">f</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#g">g</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#i">i</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#p">p</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#r">r</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#s">s</a>
+ <a class="index-letter" href="elementindex_phpGACL.html#_">_</a>
+</div> </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/errors.html b/html/phpgacl/docs/phpdoc/errors.html
new file mode 100644
index 0000000..0e4c027
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/errors.html
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title>phpDocumentor Parser Errors and Warnings</title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <a href="#Post-parsing">Post-parsing</a><br>
+<a name="gacl.class.php"></a>
+<h1>gacl.class.php</h1>
+<h2>Warnings:</h2><br>
+<b>Warning on line 37</b> - Page-level DocBlock precedes "define ADODB_DIR", use another DocBlock to document the source element<br>
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:30 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/index.html b/html/phpgacl/docs/phpdoc/index.html
new file mode 100644
index 0000000..0303b03
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/index.html
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//FR"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <!-- Generated by phpDocumentor on Sat, 03 Dec 2005 12:47:28 -0800 -->
+ <title>phpGACL 3.3.6 Developer's Manual</title>
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+</head>
+
+<FRAMESET rows='120,*'>
+ <FRAME src='packages.html' name='left_top' frameborder="1" bordercolor="#999999">
+ <FRAMESET cols='25%,*'>
+ <FRAME src='li_phpGACL.html' name='left_bottom' frameborder="1" bordercolor="#999999">
+ <FRAME src='blank.html' name='right' frameborder="1" bordercolor="#999999">
+ </FRAMESET>
+ <NOFRAMES>
+ <H2>Frame Alert</H2>
+ <P>This document is designed to be viewed using the frames feature.
+ If you see this message, you are using a non-frame-capable web client.</P>
+ </NOFRAMES>
+</FRAMESET>
+</HTML> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/li_phpGACL.html b/html/phpgacl/docs/phpdoc/li_phpGACL.html
new file mode 100644
index 0000000..5042023
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/li_phpGACL.html
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title></title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="package-title">phpGACL</div>
+<div class="package-details">
+
+ <dl class="tree">
+
+ <dt class="folder-title">Description</dt>
+ <dd>
+ <a href='classtrees_phpGACL.html' target='right'>Class trees</a><br />
+ <a href='elementindex_phpGACL.html' target='right'>Index of elements</a><br />
+ </dd>
+
+
+
+ <dt class="folder-title"><img class="tree-icon" src="media/images/class_folder.png" alt=" ">Classes</dt>
+ <dd><img class="tree-icon" src="media/images/Class.png" alt="Class"><a href='phpGACL/gacl.html' target='right'>gacl</a></dd>
+ <dd><img class="tree-icon" src="media/images/Class.png" alt="Class"><a href='phpGACL/gacl_api.html' target='right'>gacl_api</a></dd>
+ <dt class="folder-title"><img class="tree-icon" src="media/images/folder.png" alt=" ">Files</dt>
+ <dd><img class="tree-icon" src="media/images/Page.png" alt="File"><a href='phpGACL/_gacl_class_php.html' target='right'>gacl.class.php</a></dd>
+ <dd><img class="tree-icon" src="media/images/Page.png" alt="File"><a href='phpGACL/_gacl_api_class_php.html' target='right'>gacl_api.class.php</a></dd>
+
+
+ </dl>
+</div>
+<p class="notes"><a href="http://www.phpdoc.org" target="_blank">phpDocumentor v <span class="field">1.3.0RC3</span></a></p>
+</BODY>
+</HTML> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/media/banner.css b/html/phpgacl/docs/phpdoc/media/banner.css
new file mode 100644
index 0000000..032b037
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/banner.css
@@ -0,0 +1,33 @@
+body
+{
+ background-color: #EEEEEE;
+ margin: 0px;
+ padding: 0px;
+}
+
+/* Banner (top bar) classes */
+
+.banner { }
+
+.banner-menu
+{
+ text-align: right;
+ clear: both;
+ padding: .5em;
+ border-top: 2px solid #AAAAAA;
+}
+
+.banner-title
+{
+ text-align: right;
+ font-size: 20pt;
+ font-weight: bold;
+ margin: .2em;
+}
+
+.package-selector
+{
+ background-color: #DDDDDD;
+ border: 1px solid #AAAAAA;
+ color: #000090;
+}
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractClass.png b/html/phpgacl/docs/phpdoc/media/images/AbstractClass.png
new file mode 100644
index 0000000..afa9d1d
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractClass.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractClass_logo.png b/html/phpgacl/docs/phpdoc/media/images/AbstractClass_logo.png
new file mode 100644
index 0000000..8f65c39
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractClass_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractMethod.png b/html/phpgacl/docs/phpdoc/media/images/AbstractMethod.png
new file mode 100644
index 0000000..605ccbe
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractMethod.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass.png b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass.png
new file mode 100644
index 0000000..53d76c6
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass_logo.png b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass_logo.png
new file mode 100644
index 0000000..4e68f570
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateClass_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateMethod.png b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateMethod.png
new file mode 100644
index 0000000..41cc9f0
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/AbstractPrivateMethod.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Class.png b/html/phpgacl/docs/phpdoc/media/images/Class.png
new file mode 100644
index 0000000..cf548d2
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Class.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Class_logo.png b/html/phpgacl/docs/phpdoc/media/images/Class_logo.png
new file mode 100644
index 0000000..6f223c4
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Class_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Constant.png b/html/phpgacl/docs/phpdoc/media/images/Constant.png
new file mode 100644
index 0000000..a9c6f28
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Constant.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Constructor.png b/html/phpgacl/docs/phpdoc/media/images/Constructor.png
new file mode 100644
index 0000000..3f16222
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Constructor.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Destructor.png b/html/phpgacl/docs/phpdoc/media/images/Destructor.png
new file mode 100644
index 0000000..f28528f
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Destructor.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Function.png b/html/phpgacl/docs/phpdoc/media/images/Function.png
new file mode 100644
index 0000000..902fe25
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Function.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Global.png b/html/phpgacl/docs/phpdoc/media/images/Global.png
new file mode 100644
index 0000000..7281bd2
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Global.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/I.png b/html/phpgacl/docs/phpdoc/media/images/I.png
new file mode 100644
index 0000000..e8512fb
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/I.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Index.png b/html/phpgacl/docs/phpdoc/media/images/Index.png
new file mode 100644
index 0000000..6558ec3
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Index.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/L.png b/html/phpgacl/docs/phpdoc/media/images/L.png
new file mode 100644
index 0000000..eb334ed
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/L.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Lminus.png b/html/phpgacl/docs/phpdoc/media/images/Lminus.png
new file mode 100644
index 0000000..f7c43c0
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Lminus.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Lplus.png b/html/phpgacl/docs/phpdoc/media/images/Lplus.png
new file mode 100644
index 0000000..848ec2f
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Lplus.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Method.png b/html/phpgacl/docs/phpdoc/media/images/Method.png
new file mode 100644
index 0000000..9b21578
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Method.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Page.png b/html/phpgacl/docs/phpdoc/media/images/Page.png
new file mode 100644
index 0000000..ffe7986
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Page.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Page_logo.png b/html/phpgacl/docs/phpdoc/media/images/Page_logo.png
new file mode 100644
index 0000000..44ce0b3
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Page_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/PrivateClass.png b/html/phpgacl/docs/phpdoc/media/images/PrivateClass.png
new file mode 100644
index 0000000..470e6d5
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/PrivateClass.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/PrivateClass_logo.png b/html/phpgacl/docs/phpdoc/media/images/PrivateClass_logo.png
new file mode 100644
index 0000000..590e006
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/PrivateClass_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/PrivateMethod.png b/html/phpgacl/docs/phpdoc/media/images/PrivateMethod.png
new file mode 100644
index 0000000..d01f2b3
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/PrivateMethod.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/PrivateVariable.png b/html/phpgacl/docs/phpdoc/media/images/PrivateVariable.png
new file mode 100644
index 0000000..d76b21d
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/PrivateVariable.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/T.png b/html/phpgacl/docs/phpdoc/media/images/T.png
new file mode 100644
index 0000000..3017325
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/T.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Tminus.png b/html/phpgacl/docs/phpdoc/media/images/Tminus.png
new file mode 100644
index 0000000..2260e42
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Tminus.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Tplus.png b/html/phpgacl/docs/phpdoc/media/images/Tplus.png
new file mode 100644
index 0000000..2c8d8f4
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Tplus.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/Variable.png b/html/phpgacl/docs/phpdoc/media/images/Variable.png
new file mode 100644
index 0000000..8e82019
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/Variable.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/blank.png b/html/phpgacl/docs/phpdoc/media/images/blank.png
new file mode 100644
index 0000000..cee9cd3
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/blank.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/class_folder.png b/html/phpgacl/docs/phpdoc/media/images/class_folder.png
new file mode 100644
index 0000000..84e9587
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/class_folder.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/empty.png b/html/phpgacl/docs/phpdoc/media/images/empty.png
new file mode 100644
index 0000000..d568386
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/empty.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/file.png b/html/phpgacl/docs/phpdoc/media/images/file.png
new file mode 100644
index 0000000..0bb2427
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/file.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/folder.png b/html/phpgacl/docs/phpdoc/media/images/folder.png
new file mode 100644
index 0000000..a2d79f8
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/folder.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/function_folder.png b/html/phpgacl/docs/phpdoc/media/images/function_folder.png
new file mode 100644
index 0000000..8b3d6e3
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/function_folder.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/next_button.png b/html/phpgacl/docs/phpdoc/media/images/next_button.png
new file mode 100644
index 0000000..cdbc615
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/next_button.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/next_button_disabled.png b/html/phpgacl/docs/phpdoc/media/images/next_button_disabled.png
new file mode 100644
index 0000000..4a11780
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/next_button_disabled.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/package.png b/html/phpgacl/docs/phpdoc/media/images/package.png
new file mode 100644
index 0000000..b04cf56
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/package.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/package_folder.png b/html/phpgacl/docs/phpdoc/media/images/package_folder.png
new file mode 100644
index 0000000..6162baf
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/package_folder.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/previous_button.png b/html/phpgacl/docs/phpdoc/media/images/previous_button.png
new file mode 100644
index 0000000..327fdbc
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/previous_button.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/previous_button_disabled.png b/html/phpgacl/docs/phpdoc/media/images/previous_button_disabled.png
new file mode 100644
index 0000000..c02ff64
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/previous_button_disabled.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/private_class_logo.png b/html/phpgacl/docs/phpdoc/media/images/private_class_logo.png
new file mode 100644
index 0000000..590e006
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/private_class_logo.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/tutorial.png b/html/phpgacl/docs/phpdoc/media/images/tutorial.png
new file mode 100644
index 0000000..bc19737
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/tutorial.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/tutorial_folder.png b/html/phpgacl/docs/phpdoc/media/images/tutorial_folder.png
new file mode 100644
index 0000000..2a468b2
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/tutorial_folder.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/images/up_button.png b/html/phpgacl/docs/phpdoc/media/images/up_button.png
new file mode 100644
index 0000000..ff36c59
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/images/up_button.png
Binary files differ
diff --git a/html/phpgacl/docs/phpdoc/media/stylesheet.css b/html/phpgacl/docs/phpdoc/media/stylesheet.css
new file mode 100644
index 0000000..77ce696
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/media/stylesheet.css
@@ -0,0 +1,146 @@
+a { color: #000090; text-decoration: none; }
+a:hover, a:active, a:focus { color: highlighttext; background-color: highlight; text-decoration: none; }
+
+body { background: #FFFFFF; }
+body, table { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; }
+
+a img { border: 0px; }
+
+/* Page layout/boxes */
+
+.info-box { }
+.info-box-title { margin: 1em 0em 0em 0em; font-weight: normal; font-size: 14pt; color: #999999; border-bottom: 2px solid #999999; }
+.info-box-body { border: 1px solid #999999; padding: .5em; }
+.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; }
+
+.oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em}
+.evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em}
+
+.page-body { max-width: 800px; margin: auto; }
+.tree { white-space: nowrap; font: icon }
+.tree dd { margin-left: 19px }
+.tree dl { margin: 0px }
+.tree-icon { vertical-align: middle; border: 0px; margin-right: 3px }
+
+/* Index formatting classes */
+
+.index-item-body { margin-top: .5em; margin-bottom: .5em}
+.index-item-description { margin-top: .25em }
+.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt }
+.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em}
+.index-letter-title { font-size: 12pt; font-weight: bold }
+.index-letter-menu { text-align: center; margin: 1em }
+.index-letter { font-size: 12pt }
+
+/* Docbook classes */
+
+.description {}
+.short-description { font-weight: bold; color: #666666; }
+.tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; }
+.parameters { padding-left: 0em; margin-left: 3em; color: #014fbe; list-style-type: square; }
+.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; }
+.package { font-weight: bold; }
+.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black }
+.package-details { font-size: 85%; }
+.sub-package { font-weight: bold; }
+.tutorial { border-width: thin; border-color: #0066ff; }
+.tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; }
+.folder-title { font-style: italic; font-family: Verdana, Arial, Helvetica, sans-serif }
+
+/* Generic formatting */
+
+.field { font-weight: bold; }
+.detail { font-size: 8pt; }
+.notes { font-style: italic; font-size: 8pt; }
+.separator { background-color: #999999; height: 2px; }
+.warning { color: #FF6600; }
+.disabled { font-style: italic; color: #999999; }
+
+/* Code elements */
+
+.line-number { }
+
+.class-table { width: 100%; }
+.class-table-header { border-bottom: 1px dotted #666666; text-align: left}
+.class-name { color: #0000AA; font-weight: bold; }
+
+.method-summary { color: #009000; padding-left: 1em; font-size: 8pt; }
+.method-header { }
+.method-definition { margin-bottom: .2em }
+.method-title { color: #009000; font-weight: bold; }
+.method-name { font-weight: bold; }
+.method-signature { font-size: 85%; color: #666666; margin: .5em 0em }
+.method-result { font-style: italic; }
+
+.var-summary { padding-left: 1em; font-size: 8pt; }
+.var-header { }
+.var-title { color: #014fbe; margin-bottom: .3em }
+.var-type { font-style: italic; }
+.var-name { font-weight: bold; }
+.var-default {}
+.var-description { font-weight: normal; color: #000000; }
+
+.include-title { color: #014fbe;}
+.include-type { font-style: italic; }
+.include-name { font-weight: bold; }
+
+.const-title { color: #FF6600; }
+.const-name { font-weight: bold; }
+
+/* Syntax highlighting */
+
+.src-code { }
+*[class="src-code"] { line-height : 0.5em }
+
+.src-code a:link { padding: 1px; text-decoration: underline; color: #0000DD; }
+.src-code a:visited { text-decoration: underline; color: #0000DD; }
+.src-code a:active { background-color: #FFFF66; color: #008000; }
+.src-code a:hover { background-color: #FFFF66; text-decoration: overline underline; color: #008000; }
+
+.src-comm { color: #666666; }
+.src-id { color: #FF6600; font-style: italic; }
+.src-inc { color: #0000AA; font-weight: bold; }
+.src-key { color: #0000AA; font-weight: bold; }
+.src-num { color: #CC0000; }
+.src-str { color: #CC0000; }
+.src-sym { }
+.src-var { }
+
+.src-php { font-weight: bold; }
+
+.src-doc { color: #666666; }
+.src-doc-close-template { color: #666666 }
+.src-doc-coretag { color: #008000; }
+.src-doc-inlinetag {}
+.src-doc-internal {}
+.src-doc-tag { color: #0080CC; }
+.src-doc-template { color: #666666 }
+.src-doc-type { font-style: italic; color: #444444 }
+.src-doc-var { color: #444444 }
+
+.tute-tag { color: #009999 }
+.tute-attribute-name { color: #0000FF }
+.tute-attribute-value { color: #0099FF }
+.tute-entity { font-weight: bold; }
+.tute-comment { font-style: italic }
+.tute-inline-tag { color: #636311; font-weight: bold }
+
+/* tutorial */
+
+.authors { }
+.author { font-style: italic; font-weight: bold }
+.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal }
+.example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; }
+*[class="example"] { line-height : 0.5em; }
+.listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap; }
+*[class="listing"] { line-height : 0.5em; }
+.release-info { font-size: 85%; font-style: italic; margin: 1em 0em }
+.ref-title-box { }
+.ref-title { }
+.ref-purpose { font-style: italic; color: #666666 }
+.ref-synopsis { }
+.title { font-weight: bold; border-bottom: 1px solid #999999; color: #999999; }
+.cmd-synopsis { margin: 1em 0em }
+.cmd-title { font-weight: bold }
+.toc { margin-left: 2em; padding-left: 0em }
+
diff --git a/html/phpgacl/docs/phpdoc/packages.html b/html/phpgacl/docs/phpdoc/packages.html
new file mode 100644
index 0000000..ad9f33f
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/packages.html
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title></title>
+ <link rel="stylesheet" href="media/stylesheet.css" />
+ <link rel="stylesheet" href="media/banner.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="banner">
+ <div class="banner-title">phpGACL</div>
+ <div class="banner-menu">
+ <form>
+ <table cellpadding="0" cellspacing="0" style="width: 100%">
+ <tr>
+ <td>
+ </td>
+ <td style="width: 2em">&nbsp;</td>
+ <td style="text-align: right">
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </div>
+ </body>
+ </html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/phpGACL/_gacl_api_class_php.html b/html/phpgacl/docs/phpdoc/phpGACL/_gacl_api_class_php.html
new file mode 100644
index 0000000..1f4f66c
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/phpGACL/_gacl_api_class_php.html
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title>Docs for page gacl_api.class.php</title>
+ <link rel="stylesheet" href="../media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="page-body">
+<h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/gacl_api.class.php</h2>
+
+<a name="sec-description"></a>
+<div class="info-box">
+ <div class="info-box-title">Description</div>
+ <div class="nav-bar">
+ <span class="disabled">Description</span> |
+ <a href="#sec-classes">Classes</a>
+ </div>
+ <div class="info-box-body">
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">phpGACL - Generic Access Control List Copyright (C) 2002,2003 Mike Benoit</p>
+<p class="description"><p>This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.</p><p>This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</p><p>You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p><p>For questions, help, comments, discussion, etc., please join the phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103</p><p>You may contact the author of phpGACL by e-mail at: ipso@snappymail.ca</p><p>The latest version of phpGACL can be obtained from: http://phpgacl.sourceforge.net/</p></p>
+
+ </div>
+</div>
+
+ <a name="sec-classes"></a>
+ <div class="info-box">
+ <div class="info-box-title">Classes</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <span class="disabled">Classes</span>
+ </div>
+ <div class="info-box-body">
+ <table cellpadding="2" cellspacing="0" class="class-table">
+ <tr>
+ <th class="class-table-header">Class</th>
+ <th class="class-table-header">Description</th>
+ </tr>
+ <tr>
+ <td style="padding-right: 2em; vertical-align: top; white-space: nowrap">
+ <img src="../media/images/Class.png"
+ alt=" class"
+ title=" class"/>
+ <a href="../phpGACL/gacl_api.html">gacl_api</a>
+ </td>
+ <td>
+ gacl_api Extended API Class
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+
+
+
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:29 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </div></body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/phpGACL/_gacl_class_php.html b/html/phpgacl/docs/phpdoc/phpGACL/_gacl_class_php.html
new file mode 100644
index 0000000..d179d39
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/phpGACL/_gacl_class_php.html
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title>Docs for page gacl.class.php</title>
+ <link rel="stylesheet" href="../media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="page-body">
+<h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/gacl.class.php</h2>
+
+<a name="sec-description"></a>
+<div class="info-box">
+ <div class="info-box-title">Description</div>
+ <div class="nav-bar">
+ <span class="disabled">Description</span> |
+ <a href="#sec-classes">Classes</a>
+ | <a href="#sec-constants">Constants</a>
+ </div>
+ <div class="info-box-body">
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">phpGACL - Generic Access Control List Copyright (C) 2002,2003 Mike Benoit</p>
+<p class="description"><p>This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.</p><p>This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</p><p>You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p><p>For questions, help, comments, discussion, etc., please join the phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103</p><p>You may contact the author of phpGACL by e-mail at: ipso@snappymail.ca</p><p>The latest version of phpGACL can be obtained from: http://phpgacl.sourceforge.net/</p></p>
+
+ </div>
+</div>
+
+ <a name="sec-classes"></a>
+ <div class="info-box">
+ <div class="info-box-title">Classes</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <span class="disabled">Classes</span>
+ | <a href="#sec-constants">Constants</a>
+ </div>
+ <div class="info-box-body">
+ <table cellpadding="2" cellspacing="0" class="class-table">
+ <tr>
+ <th class="class-table-header">Class</th>
+ <th class="class-table-header">Description</th>
+ </tr>
+ <tr>
+ <td style="padding-right: 2em; vertical-align: top; white-space: nowrap">
+ <img src="../media/images/Class.png"
+ alt=" class"
+ title=" class"/>
+ <a href="../phpGACL/gacl.html">gacl</a>
+ </td>
+ <td>
+ phpGACL main class
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+ <a name="sec-constants"></a>
+ <div class="info-box">
+ <div class="info-box-title">Constants</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-classes">Classes</a>
+ | <span class="disabled">Constants</span>
+ </div>
+ <div class="info-box-body">
+ <a name="defineADODB_DIR"><!-- --></a>
+<div class="evenrow">
+
+ <div>
+ <img src="../media/images/Constant.png" />
+ <span class="const-title">
+ <span class="const-name">ADODB_DIR</span> = dirname(__FILE__).'/adodb'
+ (line <span class="line-number">38</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+
+
+</div>
+ </div>
+ </div>
+
+
+
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:28 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </div></body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/phpGACL/gacl.html b/html/phpgacl/docs/phpdoc/phpGACL/gacl.html
new file mode 100644
index 0000000..03c66d1
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/phpGACL/gacl.html
@@ -0,0 +1,974 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title>Docs For Class gacl</title>
+ <link rel="stylesheet" href="../media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="page-body">
+<h2 class="class-name"><img src="../media/images/Class_logo.png"
+ alt=" Class"
+ title=" Class"
+ style="vertical-align: middle"> gacl</h2>
+
+<a name="sec-description"></a>
+<div class="info-box">
+ <div class="info-box-title">Description</div>
+ <div class="nav-bar">
+ <span class="disabled">Description</span> |
+ <a href="#sec-descendents">Descendents</a>
+ | <a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
+ | <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">phpGACL main class</p>
+<p class="description"><p>Class gacl should be used in applications where only querying the phpGACL database is required.</p></p>
+ <ul class="tags">
+ <li><span class="field">author:</span> Mike Benoit &lt;<a href="mailto:ipso@snappymail.ca">ipso@snappymail.ca</a>&gt;</li>
+ </ul>
+ <p class="notes">
+ Located in <a class="field" href="_gacl_class_php.html">/gacl.class.php</a> (line <span class="field">50</span>)
+ </p>
+
+
+ <pre></pre>
+
+ </div>
+</div>
+
+ <a name="sec-descendents"></a>
+ <div class="info-box">
+ <div class="info-box-title">Direct descendents</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <span class="disabled">Descendents</span>
+ | <a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
+ | <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <table cellpadding="2" cellspacing="0" class="class-table">
+ <tr>
+ <th class="class-table-header">Class</th>
+ <th class="class-table-header">Description</th>
+ </tr>
+ <tr>
+ <td style="padding-right: 2em; white-space: nowrap">
+ <img src="../media/images/Class.png"
+ alt=" class"
+ title=" class"
+ style="vertical-align: center"/>
+ <a href="../phpGACL/gacl_api.html">gacl_api</a>
+ </td>
+ <td>
+ gacl_api Extended API Class
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
+
+ <a name="sec-var-summary"></a>
+ <div class="info-box">
+ <div class="info-box-title">Variable Summary</span></div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-descendents">Descendants</a> |
+ <span class="disabled">Vars</span> (<a href="#sec-vars">details</a>)
+ |
+ <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <div class="var-summary">
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">mixed</span>
+ <a href="#$config_file" title="details" class="var-name">$config_file</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_cache_dir" title="details" class="var-name">$_cache_dir</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">int</span>
+ <a href="#$_cache_expire_time" title="details" class="var-name">$_cache_expire_time</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">boolean</span>
+ <a href="#$_caching" title="details" class="var-name">$_caching</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">object An</span>
+ <a href="#$_db" title="details" class="var-name">$_db</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_host" title="details" class="var-name">$_db_host</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_name" title="details" class="var-name">$_db_name</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_password" title="details" class="var-name">$_db_password</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_table_prefix" title="details" class="var-name">$_db_table_prefix</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_type" title="details" class="var-name">$_db_type</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_db_user" title="details" class="var-name">$_db_user</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">boolean</span>
+ <a href="#$_debug" title="details" class="var-name">$_debug</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">boolean</span>
+ <a href="#$_force_cache_expire" title="details" class="var-name">$_force_cache_expire</a>
+ </div>
+ <div class="var-title">
+ <img src="../media/images/Variable.png" alt=" " />
+ <span class="var-type">string</span>
+ <a href="#$_group_switch" title="details" class="var-name">$_group_switch</a>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <a name="sec-method-summary"></a>
+ <div class="info-box">
+ <div class="info-box-title">Method Summary</span></div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-descendents">Descendants</a> |
+ <a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
+
+ |
+ <span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
+ </div>
+ <div class="info-box-body">
+ <div class="method-summary">
+
+ <div class="method-definition">
+ <img src="../media/images/Constructor.png" alt=" "/>
+ <span class="method-result">gacl</span>
+ <a href="#gacl" title="details" class="method-name">gacl</a>
+ ([<span class="var-type">array</span>&nbsp;<span class="var-name">$options</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">boolean</span>
+ <a href="#acl_check" title="details" class="method-name">acl_check</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">mixed</span>
+ <a href="#acl_check_array" title="details" class="method-name">acl_check_array</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">void</span>
+ <a href="#acl_get_groups" title="details" class="method-name">acl_get_groups</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#acl_query" title="details" class="method-name">acl_query</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">boolean</span>&nbsp;<span class="var-name">$debug</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">string</span>
+ <a href="#acl_return_value" title="details" class="method-name">acl_return_value</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">string</span>
+ <a href="#debug_db" title="details" class="method-name">debug_db</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$function_name</span> = <span class="var-default">''</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">boolean</span>
+ <a href="#debug_text" title="details" class="method-name">debug_text</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$text</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">mixed</span>
+ <a href="#get_cache" title="details" class="method-name">get_cache</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$cache_id</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">void</span>
+ <a href="#put_cache" title="details" class="method-name">put_cache</a>
+ (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$data</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$cache_id</span>)
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <a name="sec-vars"></a>
+ <div class="info-box">
+ <div class="info-box-title">Variables</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-descendents">Descendents</a> |
+ <a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)
+
+
+ |
+ <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <a name="var$config_file" id="$config_file"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">mixed</span>
+ <span class="var-name">$config_file</span>
+ = <span class="var-default"> './gacl.ini.php'</span> (line <span class="line-number">54</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+
+
+
+
+
+</div>
+<a name="var$_cache_dir" id="$_cache_dir"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_cache_dir</span>
+ = <span class="var-default"> '/tmp/phpgacl_cache'</span> (line <span class="line-number">98</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The directory for cache file to eb written (ensure write permission are set)</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_cache_expire_time" id="$_cache_expire_time"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">int</span>
+ <span class="var-name">$_cache_expire_time</span>
+ = <span class="var-default">600</span> (line <span class="line-number">101</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The time for the cache to expire in seconds - 600 == Ten Minutes</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_caching" id="$_caching"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">boolean</span>
+ <span class="var-name">$_caching</span>
+ = <span class="var-default"> FALSE</span> (line <span class="line-number">92</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> Caches queries if true</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db" id="$_db"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">object An</span>
+ <span class="var-name">$_db</span>
+ = <span class="var-default"> ''</span> (line <span class="line-number">84</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> ADODB database connector object</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_host" id="$_db_host"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_host</span>
+ = <span class="var-default"> 'localhost'</span> (line <span class="line-number">72</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The database server</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_name" id="$_db_name"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_name</span>
+ = <span class="var-default"> 'gacl'</span> (line <span class="line-number">81</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The database name</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_password" id="$_db_password"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_password</span>
+ = <span class="var-default"> ''</span> (line <span class="line-number">78</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The database user password</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_table_prefix" id="$_db_table_prefix"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_table_prefix</span>
+ = <span class="var-default"> ''</span> (line <span class="line-number">66</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> Prefix for all the phpgacl tables in the database</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_type" id="$_db_type"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_type</span>
+ = <span class="var-default"> 'mysql'</span> (line <span class="line-number">69</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The database type, based on available ADODB connectors - mysql, postgres7, sybase, oci8po See here for more: http://php.weblogs.com/adodb_manual#driverguide</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_db_user" id="$_db_user"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_db_user</span>
+ = <span class="var-default"> 'root'</span> (line <span class="line-number">75</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> The database user name</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_debug" id="$_debug"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">boolean</span>
+ <span class="var-name">$_debug</span>
+ = <span class="var-default"> FALSE</span> (line <span class="line-number">60</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> Enables Debug output if true</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_force_cache_expire" id="$_force_cache_expire"><!-- --></A>
+<div class="evenrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">boolean</span>
+ <span class="var-name">$_force_cache_expire</span>
+ = <span class="var-default"> TRUE</span> (line <span class="line-number">95</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> Force cache to expire</li>
+ </ul>
+
+
+
+
+
+</div>
+<a name="var$_group_switch" id="$_group_switch"><!-- --></A>
+<div class="oddrow">
+
+ <div class="var-header">
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-type">string</span>
+ <span class="var-name">$_group_switch</span>
+ = <span class="var-default"> '_group_'</span> (line <span class="line-number">104</span>)
+ </span>
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+ <ul class="tags">
+ <li><span class="field">var:</span> A switch to put acl_check into '_group_' mode</li>
+ </ul>
+
+
+
+
+
+</div>
+
+ </div>
+ </div>
+
+ <a name="sec-methods"></a>
+ <div class="info-box">
+ <div class="info-box-title">Methods</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-descendents">Descendents</a> |
+ <a href="#sec-var-summary">Vars</a> (<a href="#sec-vars">details</a>)
+ <a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
+
+ </div>
+ <div class="info-box-body">
+ <A NAME='method_detail'></A>
+<a name="methodgacl" id="gacl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Constructor.png" />
+ <span class="method-title">Constructor gacl</span> (line <span class="line-number">110</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Constructor</p>
+
+ <div class="method-signature">
+ <span class="method-result">gacl</span>
+ <span class="method-name">
+ gacl
+ </span>
+ ([<span class="var-type">array</span>&nbsp;<span class="var-name">$options</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$options</span><span class="var-description">: An arry of options to oeverride the class defaults</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodacl_check" id="acl_check"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">acl_check</span> (line <span class="line-number">223</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Wraps the actual acl_query() function.</p>
+<p class="description"><p>It is simply here to return TRUE/FALSE accordingly.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> TRUE if the check succeeds, false if not.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">boolean</span>
+ <span class="method-name">
+ acl_check
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: The ACO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: The ACO value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_section_value</span><span class="var-description">: The ARO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_value</span><span class="var-description">: The ARO section</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_section_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">integer</span>
+ <span class="var-name">$root_aro_group</span><span class="var-description">: The group id of the ARO ??Mike?? (optional)</span> </li>
+ <li>
+ <span class="var-type">integer</span>
+ <span class="var-name">$root_axo_group</span><span class="var-description">: The group id of the AXO ??Mike?? (optional)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodacl_check_array" id="acl_check_array"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">acl_check_array</span> (line <span class="line-number">256</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Handles ACL lookups over arrays of AROs</p>
+ <ul class="tags">
+ <li><span class="field">return:</span> The same data format as inputted.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">mixed</span>
+ <span class="method-name">
+ acl_check_array
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: The ACO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: The ACO value</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: An named array of arrays, each element in the format aro_section_value=&gt;array(aro_value1,aro_value1,...)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodacl_get_groups" id="acl_get_groups"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">acl_get_groups</span> (line <span class="line-number">486</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Grabs all groups mapped to an ARO. You can also specify a root_group for subtree'ing.</p>
+
+ <div class="method-signature">
+ <span class="method-result">void</span>
+ <span class="method-name">
+ acl_get_groups
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: The section value or the ARO or ACO</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: The value of the ARO or ACO</span> </li>
+ <li>
+ <span class="var-type">integer</span>
+ <span class="var-name">$root_group</span><span class="var-description">: The group id of the group to start at (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: The type of group, either ARO or AXO (optional)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodacl_query" id="acl_query"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">acl_query</span> (line <span class="line-number">299</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">The Main function that does the actual ACL lookup.</p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns as much information as possible about the ACL so other functions can trim it down and omit unwanted data.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ acl_query
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">boolean</span>&nbsp;<span class="var-name">$debug</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: The ACO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: The ACO value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_section_value</span><span class="var-description">: The ARO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_value</span><span class="var-description">: The ARO section</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_section_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$root_aro_group</span><span class="var-description">: The value of the ARO group (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$root_axo_group</span><span class="var-description">: The value of the AXO group (optional)</span> </li>
+ <li>
+ <span class="var-type">boolean</span>
+ <span class="var-name">$debug</span><span class="var-description">: Debug the operation if true (optional)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodacl_return_value" id="acl_return_value"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">acl_return_value</span> (line <span class="line-number">243</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Wraps the actual acl_query() function.</p>
+<p class="description"><p>Quick access to the return value of an ACL.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> The return value of the ACL</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">string</span>
+ <span class="method-name">
+ acl_return_value
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_aro_group</span> = <span class="var-default">NULL</span>], [<span class="var-type">integer</span>&nbsp;<span class="var-name">$root_axo_group</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: The ACO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: The ACO value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_section_value</span><span class="var-description">: The ARO section value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_value</span><span class="var-description">: The ARO section</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_section_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_value</span><span class="var-description">: The AXO section value (optional)</span> </li>
+ <li>
+ <span class="var-type">integer</span>
+ <span class="var-name">$root_aro_group</span><span class="var-description">: The group id of the ARO (optional)</span> </li>
+ <li>
+ <span class="var-type">integer</span>
+ <span class="var-name">$root_axo_group</span><span class="var-description">: The group id of the AXO (optional)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddebug_db" id="debug_db"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">debug_db</span> (line <span class="line-number">201</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Prints database debug text if debug is enabled.</p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns an error message</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">string</span>
+ <span class="method-name">
+ debug_db
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$function_name</span> = <span class="var-default">''</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$function_name</span><span class="var-description">: The name of the function calling this method</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddebug_text" id="debug_text"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">debug_text</span> (line <span class="line-number">187</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Prints debug text if debug is enabled.</p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Always returns true</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">boolean</span>
+ <span class="method-name">
+ debug_text
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$text</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$text</span><span class="var-description">: THe text to output</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_cache" id="get_cache"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_cache</span> (line <span class="line-number">572</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Uses PEAR's Cache_Lite package to grab cached arrays, objects, variables etc...</p>
+<p class="description"><p>using unserialize() so it can handle more then just text string.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> The cached object, otherwise FALSE if the object identifier was not found</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">mixed</span>
+ <span class="method-name">
+ get_cache
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$cache_id</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$cache_id</span><span class="var-description">: The id of the cached object</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodput_cache" id="put_cache"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">put_cache</span> (line <span class="line-number">591</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">Uses PEAR's Cache_Lite package to write cached arrays, objects, variables etc...</p>
+<p class="description"><p>using serialize() so it can handle more then just text string.</p></p>
+
+ <div class="method-signature">
+ <span class="method-result">void</span>
+ <span class="method-name">
+ put_cache
+ </span>
+ (<span class="var-type">mixed</span>&nbsp;<span class="var-name">$data</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$cache_id</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">mixed</span>
+ <span class="var-name">$data</span><span class="var-description">: A variable to cache</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$cache_id</span><span class="var-description">: The id of the cached variable</span> </li>
+ </ul>
+
+
+ </div>
+
+ </div>
+ </div>
+
+
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:28 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </div></body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpdoc/phpGACL/gacl_api.html b/html/phpgacl/docs/phpdoc/phpGACL/gacl_api.html
new file mode 100644
index 0000000..025c63a
--- /dev/null
+++ b/html/phpgacl/docs/phpdoc/phpGACL/gacl_api.html
@@ -0,0 +1,2190 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <!-- template designed by Marco Von Ballmoos -->
+ <title>Docs For Class gacl_api</title>
+ <link rel="stylesheet" href="../media/stylesheet.css" />
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
+ </head>
+ <body>
+ <div class="page-body">
+<h2 class="class-name"><img src="../media/images/Class_logo.png"
+ alt=" Class"
+ title=" Class"
+ style="vertical-align: middle"> gacl_api</h2>
+
+<a name="sec-description"></a>
+<div class="info-box">
+ <div class="info-box-title">Description</div>
+ <div class="nav-bar">
+ <span class="disabled">Description</span> |
+ <a href="#sec-vars">Vars</a>
+ | <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">gacl_api Extended API Class</p>
+<p class="description"><p>Class gacl_api should be used for applications that must interface directly with phpGACL's data structures, objects, and rules.</p></p>
+ <ul class="tags">
+ <li><span class="field">author:</span> Mike Benoit &lt;<a href="mailto:ipso@snappymail.ca">ipso@snappymail.ca</a>&gt;</li>
+ </ul>
+ <p class="notes">
+ Located in <a class="field" href="_gacl_api_class_php.html">/gacl_api.class.php</a> (line <span class="field">50</span>)
+ </p>
+
+
+ <pre><a href="../phpGACL/gacl.html">gacl</a>
+ |
+ --gacl_api</pre>
+
+ </div>
+</div>
+
+
+
+
+ <a name="sec-method-summary"></a>
+ <div class="info-box">
+ <div class="info-box-title">Method Summary</span></div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-vars">Vars</a>
+
+ |
+ <span class="disabled">Methods</span> (<a href="#sec-methods">details</a>)
+ </div>
+ <div class="info-box-body">
+ <div class="method-summary">
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#add_acl" title="details" class="method-name">add_acl</a>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$allow</span> = <span class="var-default">1</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$enabled</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$note</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#add_group" title="details" class="method-name">add_group</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$parent_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#add_group_object" title="details" class="method-name">add_group_object</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#add_object" title="details" class="method-name">add_object</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#add_object_section" title="details" class="method-name">add_object_section</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#append_acl" title="details" class="method-name">append_acl</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#clear_database" title="details" class="method-name">clear_database</a>
+ ()
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#consolidated_edit_acl" title="details" class="method-name">consolidated_edit_acl</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#count_all" title="details" class="method-name">count_all</a>
+ ([<span class="var-type">array</span>&nbsp;<span class="var-name">$arg</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#del_acl" title="details" class="method-name">del_acl</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#del_group" title="details" class="method-name">del_group</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">bool</span>&nbsp;<span class="var-name">$reparent_children</span> = <span class="var-default">TRUE</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#del_group_object" title="details" class="method-name">del_group_object</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#del_object" title="details" class="method-name">del_object</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$erase</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#del_object_section" title="details" class="method-name">del_object_section</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_section_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$erase</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#edit_acl" title="details" class="method-name">edit_acl</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$allow</span> = <span class="var-default">1</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$enabled</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$note</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#edit_group" title="details" class="method-name">edit_group</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$parent_id</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#edit_object" title="details" class="method-name">edit_object</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#edit_object_section" title="details" class="method-name">edit_object_section</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_section_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#format_groups" title="details" class="method-name">format_groups</a>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$sorted_groups</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$type</span> = <span class="var-default">'TEXT'</span>], <span class="var-type">int</span>&nbsp;<span class="var-name">$root_id</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$level</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$formatted_groups</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#get_acl" title="details" class="method-name">get_acl</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_group_children" title="details" class="method-name">get_group_children</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">int</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$recurse</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_group_data" title="details" class="method-name">get_group_data</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#get_group_id" title="details" class="method-name">get_group_id</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_group_objects" title="details" class="method-name">get_group_objects</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$option</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#get_group_parent_id" title="details" class="method-name">get_group_parent_id</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">ADORecordSet</span>
+ <a href="#get_object" title="details" class="method-name">get_object</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">null</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_objects" title="details" class="method-name">get_objects</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_object_data" title="details" class="method-name">get_object_data</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_object_groups" title="details" class="method-name">get_object_groups</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$option</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#get_object_id" title="details" class="method-name">get_object_id</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#get_object_section_section_id" title="details" class="method-name">get_object_section_section_id</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">string</span>
+ <a href="#get_object_section_value" title="details" class="method-name">get_object_section_value</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#get_root_group_id" title="details" class="method-name">get_root_group_id</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">string</span>
+ <a href="#get_schema_version" title="details" class="method-name">get_schema_version</a>
+ ()
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_section_data" title="details" class="method-name">get_section_data</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#get_ungrouped_objects" title="details" class="method-name">get_ungrouped_objects</a>
+ ([<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">string</span>
+ <a href="#get_version" title="details" class="method-name">get_version</a>
+ ()
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#is_conflicting_acl" title="details" class="method-name">is_conflicting_acl</a>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$ignore_acl_ids</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#rebuild_tree" title="details" class="method-name">rebuild_tree</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$left</span> = <span class="var-default">1</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#search_acl" title="details" class="method-name">search_acl</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_group_name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_group_name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">bool</span>
+ <a href="#shift_acl" title="details" class="method-name">shift_acl</a>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">void</span>
+ <a href="#showarray" title="details" class="method-name">showarray</a>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$array</span>)
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">array</span>
+ <a href="#sort_groups" title="details" class="method-name">sort_groups</a>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <div class="method-definition">
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-result">int</span>
+ <a href="#_rebuild_tree" title="details" class="method-name">_rebuild_tree</a>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$table</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">int</span>&nbsp;<span class="var-name">$left</span> = <span class="var-default">1</span>])
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <a name="sec-vars"></a>
+ <div class="info-box">
+ <div class="info-box-title">Variables</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-var-summary">Vars</a> (<span class="disabled">details</span>)
+
+
+ |
+ <a href="#sec-method-summary">Methods</a> (<a href="#sec-methods">details</a>)
+
+ </div>
+ <div class="info-box-body">
+ <h4>Inherited Variables</h4>
+ <A NAME='inherited_vars'><!-- --></A>
+ <p>Inherited from <span class="classname"><a href="../phpGACL/gacl.html">gacl</a></span></p>
+ <blockquote>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$config_file">gacl::$config_file</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_cache_dir">gacl::$_cache_dir</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_cache_expire_time">gacl::$_cache_expire_time</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_caching">gacl::$_caching</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db">gacl::$_db</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_host">gacl::$_db_host</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_name">gacl::$_db_name</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_password">gacl::$_db_password</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_table_prefix">gacl::$_db_table_prefix</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_type">gacl::$_db_type</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_db_user">gacl::$_db_user</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_debug">gacl::$_debug</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_force_cache_expire">gacl::$_force_cache_expire</a></span><br>
+ </span>
+ <img src="../media/images/Variable.png" />
+ <span class="var-title">
+ <span class="var-name"><a href="../phpGACL/gacl.html#var$_group_switch">gacl::$_group_switch</a></span><br>
+ </span>
+ </blockquote>
+
+ </div>
+ </div>
+
+ <a name="sec-methods"></a>
+ <div class="info-box">
+ <div class="info-box-title">Methods</div>
+ <div class="nav-bar">
+ <a href="#sec-description">Description</a> |
+ <a href="#sec-vars">Vars</a>
+ <a href="#sec-method-summary">Methods</a> (<span class="disabled">details</span>)
+
+ </div>
+ <div class="info-box-body">
+ <A NAME='method_detail'></A>
+<a name="methodadd_acl" id="add_acl"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">add_acl</span> (line <span class="line-number">921</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">add_acl()</p>
+<p class="description"><p>Add's an ACL. ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Return ACL ID of new ACL if successful, FALSE otherewise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ add_acl
+ </span>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$allow</span> = <span class="var-default">1</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$enabled</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$note</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aco_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$allow</span><span class="var-description">: Allow flag</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$enabled</span><span class="var-description">: Enabled flag</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$return_value</span><span class="var-description">: Return Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$note</span><span class="var-description">: Note</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: ACL Section Value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID # Specific Request</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodadd_group" id="add_group"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">add_group</span> (line <span class="line-number">1684</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">add_group()</p>
+<p class="description"><p>Inserts a group, defaults to be on the &quot;root&quot; branch.</p><p>Since v3.3.x you can only create one group with Parent_ID=0 So, its a good idea to create a &quot;Virtual Root&quot; group with Parent_ID=0 Then assign other groups to that.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> New Group ID # if successful, FALSE if otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ add_group
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$parent_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Group Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Group Name</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$parent_id</span><span class="var-description">: Parent Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodadd_group_object" id="add_group_object"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">add_group_object</span> (line <span class="line-number">1878</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">add_group_object()</p>
+<p class="description"><p>Assigns an Object to a group</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ add_group_object
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_section_value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodadd_object" id="add_object"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">add_object</span> (line <span class="line-number">2951</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">add_object()</p>
+<p class="description"><p>Inserts a new object</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns the ID # of the new object if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ add_object
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Object Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$order</span><span class="var-description">: Display Order</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$hidden</span><span class="var-description">: Hidden Flag, either 1 to hide, or 0 to show.</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodadd_object_section" id="add_object_section"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">add_object_section</span> (line <span class="line-number">3429</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">add_object_section()</p>
+<p class="description"><p>Inserts an object Section</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Object Section ID of new section</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ add_object_section
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Object Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$order</span><span class="var-description">: Display Order</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$hidden</span><span class="var-description">: Hidden flag, hides section if 1, shows section if 0</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodappend_acl" id="append_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">append_acl</span> (line <span class="line-number">413</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">append_acl()</p>
+<p class="description"><p>Appends objects on to a specific ACL.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ append_acl
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID #</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aco_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodclear_database" id="clear_database"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">clear_database</span> (line <span class="line-number">3782</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">clear_database()</p>
+<p class="description"><p>Deletes all data from the phpGACL tables. USE WITH CAUTION.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ clear_database
+ </span>
+ ()
+ </div>
+
+
+
+ </div>
+<a name="methodconsolidated_edit_acl" id="consolidated_edit_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">consolidated_edit_acl</span> (line <span class="line-number">156</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">consolidated_edit_acl()</p>
+<p class="description"><p>Add's an ACL but checks to see if it can consolidate it with another one first.</p><p>This ONLY works with ACO's and ARO's. Groups, and AXO are excluded. As well this function is designed for handling ACLs with return values, and consolidating on the return_value, in hopes of keeping the ACL count to a minimum.</p><p>A return value of false must _always_ be handled outside this function. As this function will remove AROs from ACLs and return false, in most cases you will need to a create a completely new ACL on a false return.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Special boolean return value. See note.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ consolidated_edit_acl
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: ACO Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: ACO Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_section_value</span><span class="var-description">: ARO Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_value</span><span class="var-description">: ARO Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$return_value</span><span class="var-description">: Return Value of ACL</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodcount_all" id="count_all"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">count_all</span> (line <span class="line-number">84</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">count_all()</p>
+<p class="description"><p>Recursively counts elements in an array and sub-arrays.</p><p>This is different from count($arg, COUNT_RECURSIVE) in PHP &gt;= 4.2.0, which includes sub-arrays in the count.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> The returned count is a count of all scalar elements found.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ count_all
+ </span>
+ ([<span class="var-type">array</span>&nbsp;<span class="var-name">$arg</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$arg</span><span class="var-description">: Array to count</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddel_acl" id="del_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">del_acl</span> (line <span class="line-number">1189</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">del_acl()</p>
+<p class="description"><p>Deletes a given ACL</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ del_acl
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID # to delete</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddel_group" id="del_group"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">del_group</span> (line <span class="line-number">2248</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">del_group()</p>
+<p class="description"><p>deletes a given group</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ del_group
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">bool</span>&nbsp;<span class="var-name">$reparent_children</span> = <span class="var-default">TRUE</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">bool</span>
+ <span class="var-name">$reparent_children</span><span class="var-description">: If TRUE, child groups of this group will be reparented to the current group's parent.</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddel_group_object" id="del_group_object"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">del_group_object</span> (line <span class="line-number">1965</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">del_group_object()</p>
+<p class="description"><p>Removes an Object from a group.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ del_group_object
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$object_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_section_value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddel_object" id="del_object"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">del_object</span> (line <span class="line-number">3144</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">del_object()</p>
+<p class="description"><p>Deletes a given Object and, if instructed to do so, erase all referencing objects</p><p>ERASE feature by: Martino Piccinato</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ del_object
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$erase</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_id</span><span class="var-description">: Object ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', or 'AXO'</span> </li>
+ <li>
+ <span class="var-type">bool</span>
+ <span class="var-name">$erase</span><span class="var-description">: Erases all referencing objects if TRUE, leaves them alone otherwise.</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methoddel_object_section" id="del_object_section"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">del_object_section</span> (line <span class="line-number">3635</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">del_object_section()</p>
+<p class="description"><p>Deletes a given Object Section and, if explicitly asked, all the section objects</p><p>ERASE feature by: Martino Piccinato</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ del_object_section
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_section_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>], [<span class="var-type">bool</span>&nbsp;<span class="var-name">$erase</span> = <span class="var-default">FALSE</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_section_id</span><span class="var-description">: Object Section ID # to delete</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'</span> </li>
+ <li>
+ <span class="var-type">bool</span>
+ <span class="var-name">$erase</span><span class="var-description">: Erases all section objects assigned to the section</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodedit_acl" id="edit_acl"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">edit_acl</span> (line <span class="line-number">1145</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">edit_acl()</p>
+<p class="description"><p>Edit's an ACL, ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Return TRUE if successful, FALSE otherewise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ edit_acl
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$allow</span> = <span class="var-default">1</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$enabled</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$note</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID # to edit</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aco_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$allow</span><span class="var-description">: Allow flag</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$enabled</span><span class="var-description">: Enabled flag</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$return_value</span><span class="var-description">: Return Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$note</span><span class="var-description">: Note</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: ACL Section Value</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodedit_group" id="edit_group"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">edit_group</span> (line <span class="line-number">2024</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">edit_group()</p>
+<p class="description"><p>Edits a group</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ edit_group
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$parent_id</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Group Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Group Name</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$parent_id</span><span class="var-description">: Parent ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodedit_object" id="edit_object"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">edit_object</span> (line <span class="line-number">3051</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">edit_object()</p>
+<p class="description"><p>Edits a given Object</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ edit_object
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_id</span><span class="var-description">: Object ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Object Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$order</span><span class="var-description">: Display Order</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$hidden</span><span class="var-description">: Hidden Flag, either 1 to hide, or 0 to show</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodedit_object_section" id="edit_object_section"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">edit_object_section</span> (line <span class="line-number">3498</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">edit_object_section()</p>
+<p class="description"><p>Edits a given Object Section</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ edit_object_section
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_section_id</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$name</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$order</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$hidden</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_section_id</span><span class="var-description">: Object Section ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Object Section Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$order</span><span class="var-description">: Display Order</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$hidden</span><span class="var-description">: Hidden Flag, hide object section if 1, show if 0</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodformat_groups" id="format_groups"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">format_groups</span> (line <span class="line-number">1300</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">format_groups()</p>
+<p class="description"><p>Takes the array returned by sort_groups() and formats for human consumption. Recursively calls itself to produce the desired output.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Array of formatted text, ordered by group id, formatted according to $type</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ format_groups
+ </span>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$sorted_groups</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$type</span> = <span class="var-default">'TEXT'</span>], <span class="var-type">int</span>&nbsp;<span class="var-name">$root_id</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$level</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$formatted_groups</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$sorted_groups</span><span class="var-description">: Output from gacl_api-&gt;sorted_groups($group_type)</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$type</span><span class="var-description">: Output type desired, either 'TEXT', 'HTML', or 'ARRAY'</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$root_id</span><span class="var-description">: Root of tree to produce</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$level</span><span class="var-description">: Current level of depth</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$formatted_groups</span><span class="var-description">: Pass the current formatted groups object for appending via recursion.</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_acl" id="get_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_acl</span> (line <span class="line-number">690</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_acl()</p>
+<p class="description"><p>Grabs ACL data.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> <p>FALSE if not found, or Associative Array with the following items:</p><p><ul><li>'aco' =&gt; Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</li><li>'aro' =&gt; Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</li><li>'axo' =&gt; Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</li><li>'aro_groups' =&gt; Array of Group IDs</li><li>'axo_groups' =&gt; Array of Group IDs</li><li>'acl_id' =&gt; int ACL ID #</li><li>'allow' =&gt; int Allow flag</li><li>'enabled' =&gt; int Enabled flag</li><li>'return_value' =&gt; string Return Value</li><li>'note' =&gt; string Note</li></ul></p></li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ get_acl
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID #</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_group_children" id="get_group_children"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_group_children</span> (line <span class="line-number">1457</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_group_children()</p>
+<p class="description"><p>Gets a groups child IDs</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Array of Child ID's of the referenced group</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_group_children
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">int</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$recurse</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$recurse</span><span class="var-description">: Either 'RECURSE' or 'NO_RECURSE', to recurse while fetching group children.</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_group_data" id="get_group_data"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_group_data</span> (line <span class="line-number">1507</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_group_data()</p>
+<p class="description"><p>Gets the group data given the GROUP_ID.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns numerically indexed array with the following columns: <ul><li>array[0] = (int) Group ID #</li><li>array[1] = (int) Parent Group ID #</li><li>array[2] = (string) Group Value</li><li>array[3] = (string) Group Name</li><li>array[4] = (int) lft MPTT Value</li><li>array[5] = (int) rgt MPTT Value</li></ul></li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_group_data
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_group_id" id="get_group_id"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_group_id</span> (line <span class="line-number">1394</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_group_id()</p>
+<p class="description"><p>Gets the group_id given the name or value.</p><p>Will only return one group id, so if there are duplicate names, it will return false.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns Group ID if found and Group ID is unique in database, otherwise, returns FALSE</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ get_group_id
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Group Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Group Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_group_objects" id="get_group_objects"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_group_objects</span> (line <span class="line-number">1812</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_group_objects()</p>
+<p class="description"><p>Gets all objects assigned to a group.</p><p>If $option == 'RECURSE' it will get all objects in child groups as well. defaults to omit child groups.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_group_objects
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$option</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$option</span><span class="var-description">: Option, either 'RECURSE' or 'NO_RECURSE'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_group_parent_id" id="get_group_parent_id"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_group_parent_id</span> (line <span class="line-number">1549</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_group_parent_id()</p>
+<p class="description"><p>Grabs the parent_id of a given group</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Parent ID of the Group</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ get_group_parent_id
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object" id="get_object"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object</span> (line <span class="line-number">2496</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object()</p>
+<p class="description"><p>Grabs all Objects's in the database, or specific to a section_value</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns recordset directly, with object ID only selected:</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">ADORecordSet</span>
+ <span class="method-name">
+ get_object
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">null</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Filter to this section value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$return_hidden</span><span class="var-description">: Returns hidden objects if 1, leaves them out otherwise.</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_objects" id="get_objects"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_objects</span> (line <span class="line-number">2623</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_objects ()</p>
+<p class="description"><p>Grabs all Objects in the database, or specific to a section_value</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns objects in format suitable for add_acl and is_conflicting_acl <ul><li>i.e. Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</li></ul></li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_objects
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Filter for section value</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$return_hidden</span><span class="var-description">: Returns hidden objects if 1, does not if 0</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object_data" id="get_object_data"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object_data</span> (line <span class="line-number">2687</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object_data()</p>
+<p class="description"><p>Gets all data pertaining to a specific Object.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns 2-Dimensional array of rows with columns = ( section_value, value, order_value, name, hidden )</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_object_data
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_id</span><span class="var-description">: Object ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object_groups" id="get_object_groups"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object_groups</span> (line <span class="line-number">2890</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object_groups()</p>
+<p class="description"><p>Gets all groups an object is a member of.</p><p>If $option == 'RECURSE' it will get all ancestor groups. defaults to only get direct parents.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Array of Group ID #'s, or FALSE if Failed</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_object_groups
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$option</span> = <span class="var-default">'NO_RECURSE'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_id</span><span class="var-description">: Object ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ARO' or 'AXO'</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$option</span><span class="var-description">: Option, either 'RECURSE', or 'NO_RECURSE'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object_id" id="get_object_id"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object_id</span> (line <span class="line-number">2747</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object_id()</p>
+<p class="description"><p>Gets the object_id given the section_value AND value of the object.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Object ID #</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ get_object_id
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, <span class="var-type">string</span>&nbsp;<span class="var-name">$value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Object Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object_section_section_id" id="get_object_section_section_id"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object_section_section_id</span> (line <span class="line-number">3349</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object_section_section_id()</p>
+<p class="description"><p>Gets the object_section_id given the name AND/OR value of the section.</p><p>Will only return one section id, so if there are duplicate names it will return false.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Object Section ID if the object section is found AND is unique, or FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ get_object_section_section_id
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$name</span><span class="var-description">: Object Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$value</span><span class="var-description">: Object Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_object_section_value" id="get_object_section_value"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_object_section_value</span> (line <span class="line-number">2818</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_object_section_value()</p>
+<p class="description"><p>Gets the object_section_value given object id</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Object Section Value</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">string</span>
+ <span class="method-name">
+ get_object_section_value
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$object_id</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$object_id</span><span class="var-description">: Object ID #</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_root_group_id" id="get_root_group_id"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_root_group_id</span> (line <span class="line-number">1603</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_root_group_id ()</p>
+<p class="description"><p>Grabs the id of the root group for the specified tree</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Root Group ID #</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ get_root_group_id
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_schema_version" id="get_schema_version"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_schema_version</span> (line <span class="line-number">122</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_schema_version()</p>
+<p class="description"><p>Grabs phpGACL schema version from the database.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Schema Version</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">string</span>
+ <span class="method-name">
+ get_schema_version
+ </span>
+ ()
+ </div>
+
+
+
+ </div>
+<a name="methodget_section_data" id="get_section_data"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_section_data</span> (line <span class="line-number">3731</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_section_data()</p>
+<p class="description"><p>Gets the section data given the Section Value</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns numerically indexed array with the following columns: <ul><li>array[0] = (int) Section ID #</li><li>array[1] = (string) Section Value</li><li>array[2] = (int) Section Order</li><li>array[3] = (string) Section Name</li><li>array[4] = (int) Section Hidden?</li></ul></li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_section_data
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$section_value</span>, [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$section_value</span><span class="var-description">: Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ACO', 'ARO', or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_ungrouped_objects" id="get_ungrouped_objects"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_ungrouped_objects</span> (line <span class="line-number">2563</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_ungrouped_objects()</p>
+<p class="description"><p>Grabs ID's of all Objects (ARO's and AXO's only) in the database not assigned to a Group.</p><p>This function is useful for applications that synchronize user databases with an outside source. If syncrhonization doesn't automatically place users in an appropriate group, this function can quickly identify them so that they can be assigned to the correct group.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns an array of object ID's</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ get_ungrouped_objects
+ </span>
+ ([<span class="var-type">int</span>&nbsp;<span class="var-name">$return_hidden</span> = <span class="var-default">1</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$object_type</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$return_hidden</span><span class="var-description">: Returns hidden objects if 1, does not if 0.</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$object_type</span><span class="var-description">: Object Type, either 'ARO' or 'AXO' (groupable types)</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodget_version" id="get_version"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">get_version</span> (line <span class="line-number">108</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">get_version()</p>
+<p class="description"><p>Grabs phpGACL version from the database.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Version of phpGACL</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">string</span>
+ <span class="method-name">
+ get_version
+ </span>
+ ()
+ </div>
+
+
+
+ </div>
+<a name="methodis_conflicting_acl" id="is_conflicting_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">is_conflicting_acl</span> (line <span class="line-number">789</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">is_conflicting_acl()</p>
+<p class="description"><p>Checks for conflicts when adding a specific ACL.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns true if conflict is found.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ is_conflicting_acl
+ </span>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span>, <span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$ignore_acl_ids</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aco_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$ignore_acl_ids</span><span class="var-description">: Array of ACL IDs to ignore from the result set.</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodrebuild_tree" id="rebuild_tree"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">rebuild_tree</span> (line <span class="line-number">2148</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">rebuild_tree ()</p>
+<p class="description"><p>rebuilds the group tree for the given type</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns TRUE if successful, FALSE otherwise</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ rebuild_tree
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span> = <span class="var-default">NULL</span>], [<span class="var-type">int</span>&nbsp;<span class="var-name">$left</span> = <span class="var-default">1</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$left</span><span class="var-description">: Left value of Group</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodsearch_acl" id="search_acl"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">search_acl</span> (line <span class="line-number">323</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">search_acl()</p>
+<p class="description"><p>Searches for ACL's with specified objects mapped to them.</p><p>NULL values are included in the search, if you want to ignore for instance aro_groups use FALSE instead of NULL.</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> containing ACL IDs if search is successful</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ search_acl
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aco_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$aro_group_name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_section_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_value</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$axo_group_name</span> = <span class="var-default">NULL</span>], [<span class="var-type">string</span>&nbsp;<span class="var-name">$return_value</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_section_value</span><span class="var-description">: ACO Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aco_value</span><span class="var-description">: ACO Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_section_value</span><span class="var-description">: ARO Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_value</span><span class="var-description">: ARO Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$aro_group_name</span><span class="var-description">: ARO Group Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_section_value</span><span class="var-description">: AXO Section Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_value</span><span class="var-description">: AXO Value</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$axo_group_name</span><span class="var-description">: AXO Group Name</span> </li>
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$return_value</span><span class="var-description">: Return Value</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodshift_acl" id="shift_acl"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">shift_acl</span> (line <span class="line-number">533</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">shift_acl()</p>
+<p class="description"><p>Opposite of append_acl(). Removes objects from a specific ACL. (named after PHP's array_shift())</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> TRUE if successful, FALSE otherwise.</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">bool</span>
+ <span class="method-name">
+ shift_acl
+ </span>
+ (<span class="var-type">int</span>&nbsp;<span class="var-name">$acl_id</span>, [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aro_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_array</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$axo_group_ids</span> = <span class="var-default">NULL</span>], [<span class="var-type">array</span>&nbsp;<span class="var-name">$aco_array</span> = <span class="var-default">NULL</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$acl_id</span><span class="var-description">: ACL ID #</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aro_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$axo_group_ids</span><span class="var-description">: Array of Group IDs</span> </li>
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$aco_array</span><span class="var-description">: Associative array, item={Section Value}, key={Array of Object Values} i.e. [&quot;&lt;Section Value&gt;&quot; =&gt; [&quot;&lt;Value 1&gt;&quot;, &quot;&lt;Value 2&gt;&quot;, &quot;&lt;Value 3&gt;&quot;], ...]</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodshowarray" id="showarray"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">showarray</span> (line <span class="line-number">66</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">showarray()</p>
+<p class="description"><p>Dump all contents of an array in HTML (kinda)</p></p>
+
+ <div class="method-signature">
+ <span class="method-result">void</span>
+ <span class="method-name">
+ showarray
+ </span>
+ (<span class="var-type">array</span>&nbsp;<span class="var-name">$array</span>)
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">array</span>
+ <span class="var-name">$array</span> </li>
+ </ul>
+
+
+ </div>
+<a name="methodsort_groups" id="sort_groups"><!-- --></a>
+<div class="oddrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">sort_groups</span> (line <span class="line-number">1250</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">sort_groups()</p>
+<p class="description"><p>Grabs all the groups from the database doing preliminary grouping by parent</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns 2-Dimensional array: $array[&lt;parent_id&gt;][&lt;group_id&gt;] = &lt;group_name&gt;</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">array</span>
+ <span class="method-name">
+ sort_groups
+ </span>
+ ([<span class="var-type">string</span>&nbsp;<span class="var-name">$group_type</span> = <span class="var-default">'ARO'</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$group_type</span><span class="var-description">: Group Type, either 'ARO' or 'AXO'</span> </li>
+ </ul>
+
+
+ </div>
+<a name="method_rebuild_tree" id="_rebuild_tree"><!-- --></a>
+<div class="evenrow">
+
+ <div class="method-header">
+ <img src="../media/images/Method.png" />
+ <span class="method-title">_rebuild_tree</span> (line <span class="line-number">2196</span>)
+ </div>
+
+ <!-- ========== Info from phpDoc block ========= -->
+<p class="short-description">_rebuild_tree ()</p>
+<p class="description"><p>Utility recursive function called by rebuild_tree()</p></p>
+ <ul class="tags">
+ <li><span class="field">return:</span> Returns right value of this node + 1</li>
+ </ul>
+
+ <div class="method-signature">
+ <span class="method-result">int</span>
+ <span class="method-name">
+ _rebuild_tree
+ </span>
+ (<span class="var-type">string</span>&nbsp;<span class="var-name">$table</span>, <span class="var-type">int</span>&nbsp;<span class="var-name">$group_id</span>, [<span class="var-type">int</span>&nbsp;<span class="var-name">$left</span> = <span class="var-default">1</span>])
+ </div>
+
+ <ul class="parameters">
+ <li>
+ <span class="var-type">string</span>
+ <span class="var-name">$table</span><span class="var-description">: Table name of group type</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$group_id</span><span class="var-description">: Group ID #</span> </li>
+ <li>
+ <span class="var-type">int</span>
+ <span class="var-name">$left</span><span class="var-description">: Left value of Group</span> </li>
+ </ul>
+
+
+ </div>
+ <h4>Inherited Methods</h4>
+ <a name='inherited_methods'><!-- --></a>
+ <!-- =========== Summary =========== -->
+ <p>Inherited From <span class="classname"><a href="../phpGACL/gacl.html">gacl</a></span></p>
+ <blockquote>
+ <img src="../media/images/Constructor.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodgacl">gacl::gacl()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodacl_check">gacl::acl_check()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodacl_check_array">gacl::acl_check_array()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodacl_get_groups">gacl::acl_get_groups()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodacl_query">gacl::acl_query()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodacl_return_value">gacl::acl_return_value()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methoddebug_db">gacl::debug_db()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methoddebug_text">gacl::debug_text()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodget_cache">gacl::get_cache()</a></span><br>
+ <img src="../media/images/Method.png" alt=" "/>
+ <span class="method-name"><a href="../phpGACL/gacl.html#methodput_cache">gacl::put_cache()</a></span><br>
+ </blockquote>
+
+ </div>
+ </div>
+
+
+ <p class="notes" id="credit">
+ Documentation generated on Sat, 03 Dec 2005 12:47:29 -0800 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.3.0RC3</a>
+ </p>
+ </div></body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/phpgacl-db-schema.png b/html/phpgacl/docs/phpgacl-db-schema.png
new file mode 100644
index 0000000..9dcc142
--- /dev/null
+++ b/html/phpgacl/docs/phpgacl-db-schema.png
Binary files differ
diff --git a/html/phpgacl/docs/phpgacl-db-schema.vsd b/html/phpgacl/docs/phpgacl-db-schema.vsd
new file mode 100644
index 0000000..4320b47
--- /dev/null
+++ b/html/phpgacl/docs/phpgacl-db-schema.vsd
Binary files differ
diff --git a/html/phpgacl/docs/translations/russian/manual_rus.html b/html/phpgacl/docs/translations/russian/manual_rus.html
new file mode 100644
index 0000000..76a7371
--- /dev/null
+++ b/html/phpgacl/docs/translations/russian/manual_rus.html
@@ -0,0 +1,848 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>phpGACL - руÑÑÐºÐ°Ñ Ð´Ð¾ÐºÑƒÐ¼ÐµÐ½Ñ‚Ð°Ñ†Ð¸Ñ</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta name="author" content="Feskov Kuzma, http://russofile.ru/kuzma/">
+<style>
+BODY{color:Black;background-color:White;font-family:sans-serif;font-size:14px;}
+TABLE.BORDER{border-color:#FFFFCC;border-style:Solid;border-width:3px;}
+TD{font-family:sans-serif;font-size:14px;}
+TD.CONTENT{padding:.5cm .5cm .5cm;}
+A{color: #002080;text-decoration:none;}
+A:hover{color:#D49000;}
+P{text-indent:1cm;margin:0cm;}
+PRE{font-size:14px;}
+HR{color:#FFFFCC;}
+H1{color:#FFD068;}
+H2{color:#FFD068;}
+H3{color:#FFD068;}
+.P1{letter-spacing:2pt}
+</style>
+</head>
+<body>
+<h1>phpGACL - руÑÑÐºÐ°Ñ Ð´Ð¾ÐºÑƒÐ¼ÐµÐ½Ñ‚Ð°Ñ†Ð¸Ñ</h1>
+Generic Access Control List
+<br><br>
+Mike Benoit (<a href="mailto:ipso@snappymail.ca">ipso@snappymail.ca</a>)<br>
+James Russell (<a href="mailto:james-phpgacl@ps2-pro.com">james-phpgacl@ps2-pro.com</a>)<br>
+Karsten Dambekalns (<a href="mailto:k.dambekalns@fishfarm.de">k.dambekalns@fishfarm.de</a>)<br>
+РуÑÑкий перевод ФеÑьков Кузьма (<a href="mailto:kuzma@russofile.ru">kuzma@russofile.ru</a>) (<a href="http://php.russofile.ru" target="_blank">http://php.russofile.ru</a>)<br>
+Copyright © 2002,2003, Mike Benoit<br>
+Copyright © 2003, James Russell<br>
+Copyright © 2003, Karsten Dambekalns<br>
+Document Version: 672<br>
+Last Updated: 5/20/03 - 18:55:08<br>
+
+<h1>phpGACL</h1>
+<h2>Что Ñто?</h2>
+<p>PhpGACL – Ñто набор функций, который позволÑет определить права доÑтупа к произвольным объектам (например, Ñтраницам, базам данных и так далее) другим объектам (например, пользователÑми, удаленными хоÑтами и так далее).
+<p>Это предполагает подробный контроль доÑтупа Ñ Ð¿Ñ€Ð¾Ñтым управлением и выÑокой ÑкороÑтью.
+<p>Скрипт напиÑан на PHP (отÑюда его название – phpGACL) – Ñто популÑрный Ñкриптовый Ñзык, который обычно иÑпользуетÑÑ Ð´Ð»Ñ Ð´Ð¸Ð½Ð°Ð¼Ð¸Ñ‡ÐµÑкого ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ñтраниц Ñети. GACL чаÑÑ‚ÑŒ phpGACL – Родовой ÑпиÑок ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð´Ð¾Ñтупа.
+<h2>Где взÑÑ‚ÑŒ?</h2>
+<p>PhpGACL хоÑтитÑÑ Ð½Ð° sourceforge.net здеÑÑŒ <a href="http://phpGACL.sourceforge.net/" target="_blank">http://phpGACL.sourceforge.net/</a>
+<h2>Что нужно Ð´Ð»Ñ Ð·Ð°Ð¿ÑƒÑка?</h2>
+<P>PhpGACL требует релÑционную базу данных Ð´Ð»Ñ Ñ…Ñ€Ð°Ð½ÐµÐ½Ð¸Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ð¸ о правах. ДоÑтуп к базе данных оÑущеÑтвлÑетÑÑ Ñ‡ÐµÑ€ÐµÐ· абÑтрактный клаÑÑ Ð´Ð¾Ñтупа к базам данных ADOdb (<a href="http://php.weblogs.com/adodb" target="_blank">http://php.weblogs.com/adodb</a>). Данный клаÑÑ Ð¿Ð¾Ð·Ð²Ð¾Ð»Ñет работать Ñ Ñ‚Ð°ÐºÐ¸Ð¼Ð¸ базами данных как: PostgreSQL, MySQL, Oracle.
+<p>ПоÑкольку phpGACL напиÑан на Ñзыке PHP, то он требует уÑтановки PHP верÑии не ниже 4.2. ACL (ÐдминиÑтрирование ÑпиÑка ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð´Ð¾Ñтупа) дополнена веб-интерфейÑом, потому необходимо наличие веб-Ñервера Ñ Ð¿Ð¾Ð´Ð´ÐµÑ€Ð¶ÐºÐ¾Ð¹ PHP, например, Apache (<a href="http://httpd.apache.org/" target="_blank">http://httpd.apache.org/</a>).
+<h2>Ðвторы</h2>
+<p>Mike Benoit (<a href="mailto:ipso@snappymail.ca">ipso@snappymail.ca</a>) – автор и менеджер проекта.
+<p>James Russel (<a href="mailto:james-phpgacl@ps2-pro.com">james-phpgacl@ps2-pro.com</a>) и
+<p>Karsten Dambekalns (<a href="mailto:k.dambekalns@fishfarm.de">k.dambekalns@fishfarm.de</a>) – авторы документации.
+<p>Feskov Kuzma (<a href="mailto:kuzma@russofile.ru">kuzma@russofile.ru</a>) – руÑÑкий перевод
+<p>ПоÑледнÑÑ Ð²ÐµÑ€ÑÐ¸Ñ Ð¿ÐµÑ€ÐµÐ²Ð¾Ð´Ð° вÑегда здеÑÑŒ: <a href="http://php.russofile.ru" target="_blank">http://php.russofile.ru</a>
+<h1>Введение</h1>
+<h2>Понимание ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð´ÐµÐ¹ÑтвиÑ</h2>
+<p>Хан – капитан “Сокола Ñ‚Ñ‹ÑÑчелетици Чуви – его второй офицер. Они взÑли на борт неÑколько паÑÑажиров: Люка, Оби-Вана, R2-D2 и C3PO. Хан должен определить Ð¾Ð³Ñ€Ð°Ð½Ð¸Ñ‡ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа Ð´Ð»Ñ Ñ€Ð°Ð·Ð»Ð¸Ñ‡Ð½Ñ‹Ñ… меÑÑ‚ (комнат) кораблÑ, например: кабина, машинный зал, двигатели и внешнее оружие.
+<p>Хан Ñказал: “Я и Чуви могут иметь доÑтуп вÑюду, но, поÑле оÑобенно грÑзного ремонта гипердвигателÑ, Ñ Ð·Ð°Ð¿Ñ€ÐµÑ‰Ð°ÑŽ Чуви когда-либо подходить к машинному залу. ПаÑÑажиры ограничены паÑÑажирÑким заломâ€.
+<p>С Ñтого момента, давайте будем Ñчитать, что доÑтуп ÑвлÑетÑÑ Boolean (Булевым), то еÑÑ‚ÑŒ, результат запроÑа на доÑтуп перÑонажа к какому-либо помещению ÑвлÑетÑÑ â€œÐ Ð°Ð·Ñ€ÐµÑˆÐ¸Ñ‚ÑŒâ€ Ð¸Ð»Ð¸ “Ðе разрешитьâ€, и нет никакого Ñреднего результата.
+<p>ЕÑли мы нанеÑем Ñто утверждение на матрицу доÑтупа, показывающую, кто имеет доÑтуп куда-либо, то Ñто бы выглÑдело примерно так (O – доÑтуп разрешен, X – доÑтуп запрещен):
+<table align="center" cellpadding="5" border="1">
+ <tr>
+ <td align="center">Кто / Куда</td>
+ <td align="center">Кабина</td>
+ <td align="center">ПаÑÑажирÑкий зал</td>
+ <td align="center">Оружие</td>
+ <td align="center">Машинный зал</td>
+ </tr>
+ <tr>
+ <td align="center">Хан
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ </tr>
+ <tr>
+ <td align="center">Чуви
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">Оби-Ван
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">Люк
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">R2-D2
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">C3PO
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="red">X
+ </tr>
+</table>
+<p>Колонки показывают ÑпиÑок комнат, к которым Хан может ограничить доÑтуп, а Ñ€Ñды показывают перÑон, которые могли бы запроÑить доÑтуп к тем или иным комнатам. Более широкое объÑÑнение:
+<p>“комнаты†- Ñто вещи (объекты) Ð´Ð»Ñ ÑƒÐ¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа к ним. Мы называем Ñти объекты <strong>ACO</strong> (<em>Access Control Objects</em> - Объекты ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð´Ð¾Ñтупа);
+<p>“люди†- “вещи (объекты), запрашивающие доÑтупâ€. Мы называем их <strong>ARO</strong> (<em>Access Request Objects</em> - Объекты запроÑа доÑтупа). Люди запрашивают доÑтуп к комнатам, или, в нашей терминологии, AROs запрашивают доÑтуп к ACOs.
+<p>Так же еÑÑ‚ÑŒ третий тип объекта – <strong>AXO</strong> (<em>Access eXtension Objects</em> – Объекты раÑÑˆÐ¸Ñ€ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа), но о нем мы поговорим позже. Эти объекты имеют много атрибутов и упоминаютÑÑ Ð²Ð¼ÐµÑте как Объекты доÑтупа.
+<p>Управление доÑтупом, иÑÐ¿Ð¾Ð»ÑŒÐ·ÑƒÑ Ð¼Ð°Ñ‚Ñ€Ð¸Ñ†Ñƒ доÑтупа, подобной выше, имеет преимущеÑтва и недоÑтатки:
+<p>ПлюÑÑ‹:
+<ul>
+<li>очень подробный – еÑÑ‚ÑŒ возможноÑÑ‚ÑŒ ÑƒÐ¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупом на уровне конкретного человека, еÑли еÑÑ‚ÑŒ Ñ‚Ð°ÐºÐ°Ñ Ð½ÐµÐ¾Ð±Ñ…Ð¾Ð´Ð¸Ð¼Ð¾ÑÑ‚ÑŒ;
+<li>легко увидеть, <u>кто</u> имеет доÑтуп и <u>к чему</u>. Ответ находитÑÑ Ð² переÑечении человека и комнаты.
+</ul>
+<p>МинуÑÑ‹:
+<ul>
+<li>трудно управлÑÑ‚ÑŒ на крупной матрице доÑтупа. 6 паÑÑажиров и 4 меÑта – Ñто проÑто, но что, еÑли у Ð²Ð°Ñ Ñ‚Ñ‹ÑÑчи паÑÑажиров и Ñотни меÑÑ‚, и вы должны ограничить доÑтуп большими группами и Ñразу, но Ñохранить при Ñтом подробный контроль Ð´Ð»Ñ Ð¾Ñ‚Ð´ÐµÐ»ÑŒÐ½Ð¾Ð³Ð¾ индивидуума? Это означало бы большое и трудоемкое регулирование матрицы, а так же поÑтавило бы очень трудную задачу проверки матрицы на правильноÑÑ‚ÑŒ;
+<li>трудно Ñуммировать и визуализировать. Предыдущий пример довольно проÑÑ‚, его можно запиÑать в неÑколько предложений (Ñмотрите выÑказывание Хана), но что, еÑли матрица напоминает такую?
+</ul>
+<table align="center" cellpadding="5" border="1">
+ <tr>
+ <td align="center">Кто / Куда</td>
+ <td align="center">Кабина</td>
+ <td align="center">ПаÑÑажирÑкий зал</td>
+ <td align="center">Оружие</td>
+ <td align="center">Машинный зал</td>
+ </tr>
+ <tr>
+ <td align="center">Хан
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">O
+ </tr>
+ <tr>
+ <td align="center">Чуви
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">Оби-Ван
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">Люк
+ <td align="center" bgcolor="green">0
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="green">0
+ <td align="center" bgcolor="red">X
+ </tr>
+ <tr>
+ <td align="center">R2-D2
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">0
+ </tr>
+ <tr>
+ <td align="center">C3PO
+ <td align="center" bgcolor="green">0
+ <td align="center" bgcolor="green">O
+ <td align="center" bgcolor="red">X
+ <td align="center" bgcolor="green">0
+ </tr>
+</table>
+<p>Эта матрица не на Ñтолько очевидна Ð´Ð»Ñ ÑуммированиÑ, и не понÑтна Ð´Ð»Ñ Ñ‡Ð¸Ñ‚Ð°Ñ‚ÐµÐ»Ñ, почему те или иные Ñ€ÐµÑˆÐµÐ½Ð¸Ñ Ð±Ñ‹Ð»Ð¸ принÑÑ‚Ñ‹.
+<h2>Управление контролем доÑтупа при помощи phpGACL</h2>
+<p>ЯÑно, что Ð´Ð»Ñ ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð½Ð°Ð´ большими ÑиÑтемами и Ñложными ÑитуациÑми Ñтот подход “матрицы доÑтупа†ÑвлÑетÑÑ Ð½ÐµÐ¿Ð¾Ð´Ñ…Ð¾Ð´Ñщим. Мы нуждаемÑÑ Ð² лучшей ÑиÑтеме, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð¿Ð¾Ð´Ð´ÐµÑ€Ð¶Ð¸Ð²Ð°ÐµÑ‚ плюÑÑ‹ (подробный контроль и понÑтную визуализацию того, <u>кто</u> имеет имеет доÑтуп и <u>к чему</u>) и удалÑет неудобÑтва (трудноÑÑ‚ÑŒ ÑуммированиÑ, трудноÑÑ‚ÑŒ ÑƒÐ¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð±Ð¾Ð»ÑŒÑˆÐ¸Ð¼Ð¸ группами людей Ñразу). Одно решение – phpGACL.
+<p>PhpGACL не опиÑывает доÑтуп от “воÑходÑщего†подобно матрице доÑтупа выше. ВмеÑто Ñтого, опиÑывает доÑтуп Ñверху вниз, подобно текÑтовому опиÑанию политики доÑтупа Хана. Это – очень Ð³Ð¸Ð±ÐºÐ°Ñ ÑиÑтема, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð¿Ð¾Ð·Ð²Ð¾Ð»Ñет вам управлÑÑ‚ÑŒ доÑтупом в больших группах, так же позволÑет аккуратно Ñуммировать политику доÑтупа и легко видеть, <u>кто</u> имеет право на доÑтуп и <u>к чему</u>.
+<p>ARO-дерево определÑет иерархию групп AROs (объектов запроÑа доÑтупа). Это подобно предÑтавлению дерева папок и файлов. “Папки†- группы, “файлы†- AROs.
+<p>Давайте попробуем ÑоÑтавить ACL-дерево Ð´Ð»Ñ Ð»ÑŽÐ´ÐµÐ¹ на Ñудне Хана. Сначала мы определим некоторые категории Ð´Ð»Ñ Ð»ÑŽÐ´ÐµÐ¹. ЯÑно, что Хан и Чуви управлÑÑŽÑ‚ Ñудном, а оÑтальные объекты – Ñто только паÑÑажиры.
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑÑ‡Ð¸Ð»ÐµÑ‚Ð¸Ñ Ð“Ñ€ÑƒÐ¿Ð¿Ð°
+├─Команда Группа
+│ ├─Хан ARO
+│ └─Чуви ARO
+└─ПаÑÑажиры Группа
+ ├─Оби-Ван ARO
+ ├─Люк ARO
+ ├─R2-D2 ARO
+ └─C3PO ARO
+</pre>
+<p>Это дерево не определÑет никакой политики, оно проÑто показывает, каким образом мы группируем людей, которые могли бы запроÑить доÑтуп (AROs).
+<p>Мы задаем Ð¾Ð³Ñ€Ð°Ð½Ð¸Ñ‡ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа, ÑÐ¾Ð·Ð´Ð°Ð²Ð°Ñ Ð¸Ð½Ñтрукции Ð´Ð»Ñ Ð¾Ð¿Ñ€ÐµÐ´ÐµÐ»ÐµÐ½Ð½Ð¾Ð¹ комнаты (ACO) какой-то группе или AROs в дереве. Хан говорит: “По умолчанию никому Ð½ÐµÐ»ÑŒÐ·Ñ Ð½Ð°Ð·Ð½Ð°Ñ‡Ð¸Ñ‚ÑŒ доÑтуп ни к одной из комнат на Соколе Ñ‚Ñ‹ÑÑчелетиÑ. Ðо команда должна иметь доÑтуп к каждой комнате. ПаÑÑажиры должны иметь доÑтуп только к паÑÑажирÑкому залуâ€.
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчилетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ └─Чуви
+└─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+ ├─Оби-Ван
+ ├─Люк
+ ├─R2D2
+ └─C3PO
+</pre>
+<p>Чтобы интерпретировать наше ARO-дерево, мы начинаем Ñ Ð²ÐµÑ€ÑˆÐ¸Ð½Ñ‹ и двигаемÑÑ Ð²Ð½Ð¸Ð·.
+<p>Во-первых, политика по умолчанию ÑоÑтоит в том, чтобы запретить доÑтуп ко вÑему. ÐžÐ³Ñ€Ð°Ð½Ð¸Ñ‡ÐµÐ½Ð¸Ñ Ð±Ñ‹Ð»Ð¸ изменены только Ð´Ð»Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´Ñ‹, так что они теперь имеют доÑтуп ко вÑему (ALL – Ñиноним Ð´Ð»Ñ Ð²Ñех комнат (кабина, машинный зал, паÑÑажирÑкий зал и оружие). ПаÑÑажиры имеют только доÑтуп к паÑÑажирÑкому залу.
+<p>Такой ÑпоÑоб опиÑывать политику доÑтупа более ÑÑен чем матрица доÑтупа. Ð’Ñ‹ можете легко видеть кто имеет доÑтуп к чему, а так же более легко определить, почему они имеют Ñтот доÑтуп (кажетÑÑ Ð¾Ñ‡ÐµÐ²Ð¸Ð´Ð½Ñ‹Ð¼, что Хан и Чуви имеют доÑтуп ко вÑему, так как они Ñгруппированы в “Командуâ€).
+<p>Суммируем:
+<ul>
+<li>ACO (объекты ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð´Ð¾Ñтупа) – вещи, доÑтупом к которым мы хотим управлÑÑ‚ÑŒ (например Ñтраницы Ñети, базы данных, комнаты и так далее);
+<li>ARO (объекты запроÑа доÑтупа) – вещи, которые запрашивают доÑтуп (например, люди, отдаленные компьютеры и так далее);
+<li>ARO-Ð´ÐµÑ€ÐµÐ²ÑŒÑ â€“ определÑÑŽÑ‚ иерархию <strong>Групп</strong> и AROs. Группы могут Ñодержать другие группы и AROs;
+<li>политика по умолчанию Ð´Ð»Ñ Ð´ÐµÑ€ÐµÐ²Ð° – запретить вÑе (DENY: ALL);
+<li>чтобы определить политику доÑтупа, двигайтеÑÑŒ вниз по дереву, Ñвно Ð½Ð°Ð·Ð½Ð°Ñ‡Ð°Ñ Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ñ Ð“Ñ€ÑƒÐ¿Ð¿Ð°Ð¼ и AROs Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ ACO, еÑли в Ñтом возникает потребноÑÑ‚ÑŒ.
+</ul>
+<h2>Подробный контроль доÑтупа</h2>
+<p>Ой, мы кажетÑÑ Ð·Ð°Ð±Ñ‹Ð»Ð¸ про Чуви! ОтнеÑÑ ÐµÐ³Ð¾ к команде Хан коÑвенно дал ему доÑтуп в машинный зал! Ðо, еÑли помните, он не хотел Ñтого делать. Он не хочет Ñтого поÑле того, как Чуви недавно ремонтировал гипердвигатель. Хан добавлÑет правило Ð·Ð°Ð¿Ñ€ÐµÑ‰ÐµÐ½Ð¸Ñ Ð´Ð»Ñ Ð§ÑƒÐ²Ð¸:
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчилетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ └─Чуви <strong>[DENY: Engines] (запретить: машинный зал)</strong>
+└─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+ ├─Оби-Ван
+ ├─Люк
+ ├─R2D2
+ └─C3PO
+</pre>
+<p>Это пример того, как вы можете управлÑÑ‚ÑŒ политикой доÑтупа в подробной манере. Ðет необходимоÑти перемещать Чуви в другую группу, мы проÑто запрещаем ему на более низком уровне.
+<p>Другой пример подробного ÐºÐ¾Ð½Ñ‚Ñ€Ð¾Ð»Ñ Ð¼Ð¾Ð¶ÐµÑ‚ возникнуть, когда на корабль напала ИмпериÑ. Хан должен позволить человеку Люку иÑпользовать оружие и позволить роботу R2D2 воÑÑтановить гипердвигатель в машинном зале. Он может Ñделать Ñто раÑширив их полномочиÑ, которые определены им общим ÑтатуÑом группы “ПаÑÑажирâ€:
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчилетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ └─Чуви [DENY: Engines] (запретить: машинный зал)
+└─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+ ├─Оби-Ван
+ ├─Люк <strong>[ALLOW: Guns] (разрешить: оружие)</strong>
+ ├─R2D2 <strong>[ALLOW: Engines] (разрешить: машинный зал)</strong>
+ └─C3PO
+</pre>
+<h2>Многоуровневые группы</h2>
+<p>Группы могут быть раÑширены на любой уровень в ARO-дереве. Ðапример, мы могли бы добавить группу “Джедаи†к “ПаÑÑажирамâ€. БольшинÑтво паÑÑажиров было бы категоризировано при “ПаÑÑажирахâ€, но Люк и Оби-Ван будут выделены в “Джедаи†и поÑтому могут иметь некоторые привелегии (например, доÑтуп в кабину):
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчилетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ └─Чуви [DENY: Engines] (запретить: машинный зал)
+└─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+ ├─Джедаи <strong>[ALLOW: Cockpit] (разрешить: кабину)</strong>
+ │ ├─<strong>Оби-Ван</strong>
+ │ └─<strong>Люк</strong> [ALLOW: Guns] (разрешить: оружие)
+ ├─R2D2 [ALLOW: Engines] (разрешить: машинное отделение)
+ └─C3PO
+</pre>
+<h2>Как phpGACL определÑет разрешениÑ?</h2>
+<p>Когда компьютер Ñудна (Ñ Ð·Ð°Ð¿ÑƒÑ‰ÐµÐ½Ð½Ñ‹Ð¼ phpGACL конечно же) проверÑет доÑтуп, единÑтвенный вопроÑ, который он может задать Ñебе - “имеет ли человек X доÑтуп к меÑту Y?†Ðа Ñзыке phpGACL Ñто будет выглÑдеть так: “Может ли ARO X иметь доÑтуп к ACO Y?â€
+<p>phpGACL определÑет, имеет ли определенный человек доÑтуп к определенному меÑту ÑÐ»ÐµÐ´ÑƒÑ Ð¾Ñ‚ вершины дерева к указанному человеку, Ð¾Ñ‚Ð¼ÐµÑ‡Ð°Ñ Ð¿Ð¾ пути Ñвный контроль доÑтупа Ð´Ð»Ñ Ñ‚Ð¾Ð³Ð¾ меÑта. Когда мы доÑтигаем нужного человека, получаем конкретный уровень доÑтупа который и ÑвлÑетÑÑ ÐºÐ¾Ð½ÐµÑ‡Ð½Ñ‹Ð¼ результатом Ð´Ð»Ñ Ð²Ð¾Ð·Ð²Ñ€Ð°Ñ‰ÐµÐ½Ð¸Ñ. Таким образом мы оÑущеÑтвлÑем контроль доÑтупа Ð´Ð»Ñ Ð³Ñ€ÑƒÐ¿Ð¿, людей, но имеем возможноÑÑ‚ÑŒ раÑширÑÑ‚ÑŒ Ñти уровни еÑли нужно.
+<p><strong>Пример 1.</strong> Мы Ñпрашиваем: Имеет ли Люк доÑтуп к паÑÑажирÑкому залу?â€
+<ul>
+<li>уÑтанавливаем правило по умолчанию DENY (запретить);
+<li>двигаемÑÑ Ð¿Ð¾ дереву к Люку: <em>ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑÑ‡ÐµÐ»ÐµÑ‚Ð¸Ñ -> ПаÑÑажиры -> Джедаи -> Люк</em>;
+<li>начинаем Ñ Ð²ÐµÑ€ÑˆÐ¸Ð½Ñ‹ дерева и двигаемÑÑ Ðº Люку: “узе놓ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетицне говорит ни ничего не об одном из ACO. ОÑтавлÑем DENY (запрет);
+<li>идем дальше, “ПаÑÑажиры†- Ñвно говорит, что “ПаÑÑажиры†имеют доÑтуп к “паÑÑажирÑкому залуâ€. МенÑем внутренний результат на “ALLOW†(разрешить);
+<li>двигаемÑÑ Ð² узел “Джедаи†- он не упоминает “паÑÑажирÑкого зала†вообще – оÑтавлÑем предыдущий результат;
+<li>двигаемÑÑ Ð² узел “Люк†- Ñнова нет ничего о “паÑÑажирÑком зале†- оÑтавлÑем предыдущий результат;
+<li>идти дальше некуда – оÑтанавливаемÑÑ. Возвращаемый результат будет “ALLOW†(разрешить).
+</ul>
+<p><strong>Пример 2.</strong> Мы Ñпрашиваем: “Имеет ли Чуви доÑтуп в машинный зал?â€
+<ul>
+<li>уÑтанавливаем правило по умолчанию DENY (запретить);
+<li>двигаемÑÑ Ð¿Ð¾ дереву к Чуви: <em>ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑÑ‡ÐµÐ»ÐµÑ‚Ð¸Ñ -> Команда -> Чуви</em>;
+<li>начинаем Ñ Ð²ÐµÑ€ÑˆÐ¸Ð½Ñ‹ дерева и двигаемÑÑ Ðº Чуви: “узе놓ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетицне говорит ни ничего не об одном из ACO. ОÑтавлÑем DENY (запрет);
+<li>идем дальше в узел “Команда†- Ñвно говорит нам - “Команда†имеет доÑтуп к “машинному залу†- менÑем внутренний результат на “ALLOW†(разрешить);
+<li>двигаемÑÑ Ð² узел “Чуви†- еÑÑ‚ÑŒ Ñвное запрещение, которое говорит нам, что доÑтуп в “машинный зал†закрыт. МенÑем внутренний результат на “DENY†(запретить);
+<li>идти дальше некуда, возвращаем результат “DENY†(запретить).
+</ul>
+<p>Ð’Ñ‹ можете видеть, что еÑли группа Ñвно не определÑет никаких прав, то она наÑледует их от родительÑкой группы (предыдущей).ЕÑли узел ÐºÐ¾Ñ€Ð½Ñ (“ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетиÑâ€) не определÑет никаких разрешений, то он наÑледует Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ñ Ð¿Ð¾ умолчанию. Ð’ данном Ñлучае “DENY ALL†(запретить вÑе).
+<p>Это подразумевает неÑколько интереÑных моментов об ARO-дереве:
+<ul>
+<li>ARO-дерево вÑегда показывает полный ÑпиÑок AROs. ПоÑтому не имеет ÑмыÑл Ñпрашивать, имеет ли доÑтуп к кабине Джабба, поÑкольку он не был определен в ÑиÑтеме. Однако, phpGACL не проверÑет ÑущеÑтвует ли ARO или ACO перед выполнением проверки. Так, еÑли бы такой Ð²Ð¾Ð¿Ñ€Ð¾Ñ Ð´ÐµÐ¹Ñтвительно имел бы меÑто, ответ тыл бы “DENY†(запретить);
+<li>ARO-дерево может не показывать некоторые Ð¾Ð¿Ñ€ÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ ACO еÑли они Ñпециально не определены в ARO-дереве. Ðапример, Хан определил ACO â€œÐ²Ð°Ð½Ð½Ð°Ñ ÐºÐ¾Ð¼Ð½Ð°Ñ‚Ð°â€. Любой вопроÑ, подобный Ñтому: “имеет ли Люк доÑтуп в ванную комнату?â€, даÑÑ‚ отрицательный ответ “DENY†(запрещено), поÑкольку нигде в ARO-дереве â€œÐ²Ð°Ð½Ð½Ð°Ñ ÐºÐ¾Ð¼Ð½Ð°Ñ‚Ð°â€ Ð½Ðµ упоминаетÑÑ. Имейте ввиду, при иÑÑледовании ARO-дерева, некоторые ACO могут быть не видимыми.
+</ul>
+<p><span class="P1">Обратите внимание:</span> при выÑÑнении через phpGACL вопроÑов о доÑтупе невозможно иÑпользовать Группы как AROs (даже при том, что Ñто может казатьÑÑ Ð¿Ñ€Ð°Ð²Ð¸Ð»ÑŒÐ½Ñ‹Ð¼). Ðапример, невозможно ответить на Ð²Ð¾Ð¿Ñ€Ð¾Ñ â€œÐšÐ°ÐºÐ¸Ðµ паÑÑажиры имеют доÑтуп к оружию?†Полный ответ не Boolean (не Булевый) – DENY / ALLOW (отрицаю / позволÑÑŽ), а более Ñложный “Люк и Оби-Ван могут, а R2D2 и С3PO нетâ€. PhpGACL не предназначен Ð´Ð»Ñ Ñ‚Ð°ÐºÐ¾Ð³Ð¾ вида ответов.
+
+
+
+<h2>Добавление групп</h2>
+<p>Хан видит, что ACL начинает выглÑдеть очень Ñложно. ЕÑÑ‚ÑŒ очень много иÑключений. Возможно, Ñледует Ñделать подругому, например, Ñоздать новую группу “Инженерыâ€, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð±ÑƒÐ´ÐµÑ‚ Ñодержать людей, которым позволен доÑтуп в машинное отделение и оружию. Эта группа должна Ñодержать Хана и R2D2, так как они могут воÑÑтановить двигатель и оружие. Это позволÑет Хану удалить некоторые из “грÑзных†правил-иÑключений, Ñто дает определенную выгоду в том, что дает ÑÑное опиÑание:
+<pre>
+По умолчанию: [DENY: ALL] (запретить: вÑе)
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчилетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ └─Чуви [DENY: Engines] (запретить: машинный зал)
+├─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+│ ├─Джедаи [ALLOW: Cockpit] (разрешить: кабину)
+│ │ ├─Оби-Ван
+│ │ └─Люк [ALLOW: Guns] (разрешить: оружие)
+│ ├─R2D2
+│ └─C3PO
+└─Инженеры <strong>[ALLOW: Engines, Guns] (разрешить: маш.зал, оружие)</strong>
+ ├─<strong>Хан</strong>
+ └─<strong>R2D2</strong>
+</pre>
+<p>Ð’Ñ‹ можете прочитать Ñто Ñледующим образом: по умолчанию никто никуда не имеет право заходить, команда имеет доÑтуп вÑюду (кроме Чуви, он не имеет доÑтупа в машинное отделение). ПаÑÑажиры имеют доÑтуп только к паÑÑажирÑкому залу, кроме Джедаев, они имеют доÑтуп к кабине. Люк также имеет доÑтуп к оружию. Инженеры имеют доÑтуп к оружию и машинному отделению.
+<p>Ðаиболее важно, мы можем видеть, что Хан и R2D2 находÑÑ‚ÑÑ Ñ‚ÐµÐ¿ÐµÑ€ÑŒ в двух меÑтах ACL. Им нет необходимоÑти быть уникальными. Это делает политики более ÑÑными Ð´Ð»Ñ Ñ‡Ð¸Ñ‚Ð°Ñ‚ÐµÐ»Ñ: “ÐÑ…, Хан и R2D2 имеют доÑтуп к оружию и машинному залу, потому что они инженерыâ€.
+<h2>Добавление людей</h2>
+<p>Хан идет в Город облаков, чтобы повидать Ландо и Ñделать некоторый ремонт. Ландо – предыдущий хозÑин Сокола Ñ‚Ñ‹ÑÑчелетиÑ, Хан предполагает отнеÑти его к группе “Командаâ€. Ландо так же предлагает уÑлуги Ñвоего главного инженера Хонтука, Ð´Ð»Ñ Ð¿Ð¾Ð¼Ð¾Ñ‰Ð¸ в воÑÑтановлении Ñудна, пока оно находитÑÑ Ð² доке.
+<pre>
+По умолчанию: [DENY: ALL] (запретить: вÑе)
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ ├─Чуви [DENY: Engines] (запретить: машинный зал)
+│ └─<strong>Ландо</strong>
+├─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+│ ├─Джедаи [ALLOW: Cockpit] (разрешить: кабина)
+│ │ ├─Оби-Ван
+│ │ └─Люк [ALLOW: Guns] (разрешить: оружие)
+│ ├─R2D2
+│ └─C3PO
+└─Инженеры [ALLOW: Engines, Guns] (разрешить: маш.зал, оружие)
+ ├─Хан
+ ├─R2D2
+ └─<strong>Хантук</strong>
+</pre>
+<p>Это дерево показывает как легко можно предоÑтавлÑÑ‚ÑŒ доÑтуп новым людÑм. ЕÑли бы мы иÑпользовали первоначальную матричную Ñхему, мы должны были бы уÑтановить Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ñ Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ меÑта на корабле и Ð´Ð»Ñ Ð¥Ð°Ð½ÑƒÐºÐ° и Ð´Ð»Ñ Ð›Ð°Ð½Ð´Ð¾. ВмеÑто Ñтого, мы проÑто добавлÑем их к нужным группам, в результате чего, их доÑтуп неÑвно и легко определен.
+<h2>УÑтранение конфликтов</h2>
+<p>Что ÑлучитÑÑ, еÑли мы добавим Чуви к ÑпиÑку инженеров?
+<pre>
+По умолчанию: [DENY: ALL] (запретить: вÑе)
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетиÑ
+├─Команда [ALLOW: ALL] (разрешить: вÑе)
+│ ├─Хан
+│ ├─<strong>Чуви</strong> [DENY: Engines] (запретить: машинный зал)
+│ └─Ландо
+├─ПаÑÑажиры [ALLOW: Lounge] (разрешить: паÑÑажирÑкий зал)
+│ ├─Джедаи [ALLOW: Cockpit] (разрешить: кабина)
+│ │ ├─Оби-Ван
+│ │ └─Люк [ALLOW: Guns] (разрешить: оружие)
+│ ├─R2D2
+│ └─C3PO
+└─Инженеры [ALLOW: Engines, Guns] (разрешить: маш.зал, оружие)
+ ├─Хан
+ ├─R2D2
+ ├─Ханук
+ └─<strong>Чуви</strong>
+</pre>
+<p>Это делает доÑтуп Чуви к машинному залу неоднозначным, потому что теперь еÑÑ‚ÑŒ две дорожки от ÐºÐ¾Ñ€Ð½Ñ Ð´ÐµÑ€ÐµÐ²Ð° до Чуви. ЕÑли компьютер поÑледует по одной дорожке, то результат будет “DENY†(запрещаю), а еÑли он поÑледует за другой дорожкой, то результат будет “ALLOW†(разрешаю). Так вÑе же, ему запрещен или разрешен доÑтуп?
+<p>PhpGACL предупредит ваÑ, еÑли вы Ñгруппируете ARO таким образом, что доÑтуп ARO к произвольному ACO будет неоднозначным. Ðо <u>решать</u> конфликт придетÑÑ <u>вам</u>.
+<p>ЕÑли при такой неоднозначноÑти ÑпроÑить компьютер “Имеет ли Чуви доÑтуп к машинному залу?â€, то ответ будет “ALLOW†(разрешаю), потому что ÑиÑтема вернет вам <u>поÑледний измененный параметр</u> (Ñто политика phpGACL). Ð’ Ñтом Ñлучае результат “ALLOWâ€, потому что разрешение “ALLOW: Engines, Guns†(разрешить: машинный зал, оружие), назначенное на группу “Инженерыâ€, ÑвлÑетÑÑ Ð±Ð¾Ð»ÐµÐµ Ñвежим, по Ñравнению Ñ â€œDENY: Engines†(запретить: машинный зал) группы “Чувиâ€.
+<p>Ð’ Ñлучае, еÑли ACL Ñодержит неоднозначноÑти, такую ACL называют <strong>непоÑледовательной</strong>. ÐепоÑÐ»ÐµÐ´Ð¾Ð²Ð°Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ ACL может быть очень опаÑна, вы можете невольно обеÑпечить доÑтуп неÑоответÑтвующим людÑм. Когда phpGACL предупреждает Ð²Ð°Ñ Ð¾ том, что ACL непоÑледовательна, разрешите конфликт как можно более оперативно, чтобы Ñразу воÑÑтановить поÑледовательноÑÑ‚ÑŒ.
+<p>Чтобы решить конфликт, вы могли Ñделать Ñледующее:
+<ul>
+<li>удалить дерективу “DENY: Engines†у группы “Чуви†в группе “Командаâ€;
+<li>добавить дерективу “DENY: Engines†у группы “Чуви†в группе “Инженерыâ€;
+<li>удалить Чуви из группы “Инженерыâ€, так как Хан вÑеравно не Ñчитает его доÑтойным инженером.
+</ul>
+<p>Ха выбрал поÑледний вариант, он удалил Чуви из группы “Инженерыâ€.
+<h2>Обозначение объектов доÑтупа</h2>
+<p>phpGACL уникально идентифицирует каждый объект доÑтупа (ARO, AXO, ACO) комбинацией их двух ключевых Ñлов и их типа объекта доÑтупа.
+<p>Кортеж “(Тип объекта доÑтупа, Раздел, Значение)†уникально идентифицирует любой объект доÑтупа.
+<p>Первый Ñлемент кортежа – тип объекта доÑтупа (ARO, AXO, ACO).
+<p>Второй Ñлемент кортежа, названный <strong>Разделом</strong>, ÑвлÑетÑÑ, заданной пользователем, Ñтрокой, ÐºÐ¾Ñ‚Ð¾Ñ€Ð°Ñ Ð½Ð°Ð·Ñ‹Ð²Ð°ÐµÑ‚ общую категорию объекта доÑтупа. Объекты Ñ Ð½ÐµÑколькими доÑтупами могут иметь тоже Ñамое название Раздела. Ðазвание раздела должно быть короткое, но опиÑательное (наглÑдное). Это иÑпользуетÑÑ Ð² пользовательÑком интерфейÑе в ÑпиÑках выбора, поÑтому логично не делать их Ñлишком длинными.
+<p>Разделы ÑохранÑÑŽÑ‚ÑÑ Ð² Ñчейке namespace. Разделы не имеют никакого Ð¾Ñ‚Ð½Ð¾ÑˆÐµÐ½Ð¸Ñ Ðº группам или ARO / AXO-деревьÑм – они проÑто механизм, Ð´Ð»Ñ Ñ‚Ð¾Ð³Ð¾ чтобы помочь поддерживать большее количеÑтво объектов доÑтупа.
+<p>Третий Ñлемент кортежа – определенное пользователем, название Ð´Ð»Ñ Ð¾Ð±ÑŠÐµÐºÑ‚Ð° доÑтупа, и называетÑÑ <strong>Значение</strong>. <u>Значение не может Ñодержать пробелы</u> (однако, Раздел – может).
+<p><u>ÐÐ°Ð·Ð²Ð°Ð½Ð¸Ñ Ð Ð°Ð·Ð´ÐµÐ»Ð¾Ð² и Значение региÑтрозавиÑимы.</u>
+<p><strong>Примечание:</strong> обычно Ñпрашивают, почему Ð´Ð»Ñ Ð¸Ð´ÐµÐ½Ñ‚Ð¸Ñ„Ð¸ÐºÐ°Ñ†Ð¸Ð¸ объектов доÑтупа иÑпользуютÑÑ Ñтроки а не целые чиÑла, которые, Ñкобы, кажутÑÑ Ð±Ñ‹Ñтрее. Ответ – Ð´Ð»Ñ ÑÑноÑти. Ðа много более легко понÑÑ‚ÑŒ:
+<p>acl_check('system', 'login', 'user', 'john_doe');
+чем:
+<p>acl_check(10, 21004, 15, 20304);
+<p>Так как из контекÑта чаÑто очевидно к какому типу объекта доÑтупа мы обращаемÑÑ, Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ Ð´Ð»Ñ phpGACL (и Ñта документациÑ) опуÑкает тип объекта доÑтупа и иÑпользует формат “Раздел -> Ð—Ð½Ð°Ñ‡ÐµÐ½Ð¸Ðµâ€ Ð´Ð»Ñ Ð¿Ð¾ÐºÐ°Ð·Ð° объекта доÑтупа. Однако, программный Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ Ð¿Ñ€Ð¸Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ñ‚Ñ€ÐµÐ±ÑƒÐµÑ‚ “Раздел†объекта доÑтупа и “Значениеâ€, которые должны быть определены в отдельных аргументах функции (тип объекта доÑтупа обычно неÑвен в опиÑании аргумента).
+<p><strong>Пример ACO “Раздел -> Значениеâ€:</strong>
+<ul>
+<li>“Floors -> 1st†(“Этажи -> 1-йâ€);
+<li>“Floors -> 2nd†(“Этажи -> 2-йâ€);
+<li>“Rooms -> Engines†(“Комнаты -> машинный_залâ€).
+</ul>
+<p><strong>Пример ARO “Раздел -> Значениеâ€:</strong>
+<ul>
+<li>“People -> John_Smith†(“Люди -> Джон_Смитâ€);
+<li>“People -> Cathy_Jones†(“Люди -> КÑти_ДжонÑâ€);
+<li>“Hosts -> sandbox.something.com†(“ХоÑÑ‚Ñ‹ -> sandbox.something.comâ€).
+</ul>
+<p><strong>Пример иÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ API:</strong>
+<ul>
+<li>acl_check(aro_section, aro_value, aco_section, aco_value);
+<li>acl_check('People', 'John_Smith', 'Floor', '2nd');
+</ul>
+<p><strong>Примеры правильного именованиÑ:</strong>
+<ul>
+<li>“ACO - Frob > Flergâ€, “ARO – Frob -> Flerg†(Раздел и Значение ÑвлÑÑŽÑ‚ÑÑ Ð¾Ð´Ð¸Ð½Ð°ÐºÐ¾Ð²Ñ‹Ð¼Ð¸, но Ñто хорошо, поÑкольку namespaces разные Ð´Ð»Ñ Ñ€Ð°Ð·Ð½Ñ‹Ñ… типов объектов доÑтупа);
+<li>“ACO – Frob -> Flergâ€, “ACO – Frob -> Queegle†(тип объекта доÑтупа и название Раздела одинаковые, Ñто хорошо, поÑкольку у них разные ЗначениÑ);
+<li>“AXO – Frob Hrung -> Flerg†(Разделы могут Ñодержать пробелы).
+</ul>
+<p><strong>Пример неправильного именованиÑ:</strong>
+<ul>
+<li>“ACO – Frob -> Flergâ€, “ACO – Frob -> Flerg†(тип объекта доÑтупа – Раздел -> Значение должны быть уникальными);
+<li>“ACO – Frob -> Flerg Habit†(Значение не может Ñодержать пробелов).
+</ul>
+<h2>Добавление разделов</h2>
+<p>Прежде чем добавить новый объект доÑтупа вы должны Ñоздать Раздел. Ð”Ð»Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð½Ð¾Ð²Ð¾Ð³Ð¾ раздела иÑпользуйте функцию add_object_section().
+<table align="center" cellpadding="5"><tr><td bgcolor="lightgrey">
+<pre>
+add_object_section(
+ string NAME, Короткое опиÑание того, Ð´Ð»Ñ Ñ‡ÐµÐ³Ð¾ Ñтот Раздел
+ иÑпользуетÑÑ (пример, 'Levels in building'
+ (“Этажи в зданииâ€)).
+ string VALUE, Ðазвание Раздела (пример, 'Floors' (“Этажиâ€)).
+ int ORDER, ЦенноÑÑ‚ÑŒ раздела, влиÑет на то, каким по Ñчету в ÑпиÑке
+ в интерфейÑе Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ Ð¿Ð¾ÑвитÑÑ Ñтот Раздел.
+ bool HIDDEN Показывает, должен ли Ñтот раздел быть виден в
+ пользовательÑком интерфейÑе.
+ string GROUP_TYPE); Тип объекта доÑтупа (ACO, ARO, AXO).
+</pre>
+</td></tr></table>
+<p>Хан Ñоздал 3 раздела Ð´Ð»Ñ AROs “Людиâ€, “Чужие†и “Ðндроиды†Давайте поÑмотрим, как будет выглÑдеть AROs Ñ Ð¸Ñ… полными названиÑми:
+<pre>
+ПаÑÑажиры Сокола Ñ‚Ñ‹ÑÑчелетиÑ
+├─Команда [ALLOW: ALL]
+│ ├─<strong>"Люди > Хан"</strong>
+│ ├─<strong>"Чужие > Чуви"</strong> [DENY: Engines]
+│ └─<strong>"Люди > Ландо"</strong>
+├─ПаÑÑажиры [ALLOW: Lounge]
+│ ├─Джедаи [ALLOW: Cockpit]
+│ │ ├─<strong>"Люди > Оби-Ван"</strong>
+│ │ └─<strong>"Люди > Люк"</strong> [ALLOW: Guns]
+│ ├─<strong>"Ðндроиды > R2D2"</strong>
+│ └─<strong>"Ðндроиды > C3PO"</strong>
+└─Инженеры [ALLOW: Engines, Guns]
+ ├─<strong>"Люди > Хан"</strong>
+ ├─<strong>"Ðндроиды > R2D2"</strong>
+ └─<strong>"Чужие > Хантук"</strong>
+</pre>
+<p>Разделы – только ÑпоÑоб категоризировать объекты доÑтупа, Ñделать пользовательÑкий Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ Ð±Ð¾Ð»ÐµÐµ пригодным к иÑпользованию, а так же Ñделать функцию acl_check() более читаемой. Они не затрагивают путь phpGACL Ð´Ð»Ñ Ð¾Ð¿Ñ€ÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ Ð¿Ñ€Ð°Ð² объекта доÑтупа. Также, разделы не могут быть вложенными, то еÑÑ‚ÑŒ вы не можете Ñоздать “Мужчин†внутри “Людейâ€. Ð’Ñ‹ должны будете Ñоздать раздел “Люди мужÑкого пола†или подобный.
+<h2>МножеÑтво целей</h2>
+<p>Возможно, вы будете иÑпользовать phpGACL Ñразу Ð´Ð»Ñ Ð½ÐµÑкольких целей, например, ограничить пользовательÑкий доÑтуп к Ñтраницам, а так же удаленный доÑтуп к Ñтраницам вашего Ñервера. Эти две задачи не ÑвÑзаны.
+<p>PhpGACL предлагает реализовать Ñто Ñ‚Ñ€ÐµÐ¼Ñ Ñ€Ð°Ð·Ð»Ð¸Ñ‡Ð½Ñ‹Ð¼Ð¸ путÑми:
+<ul>
+<li>вы можете иÑпользовать дополнительные базы данных Ð´Ð»Ñ Ñ…Ñ€Ð°Ð½ÐµÐ½Ð¸Ñ Ñтих данных;
+<li>вы можете иÑпользовать туже Ñамую базу данных но Ñ Ð´Ñ€ÑƒÐ³Ð¸Ð¼Ð¸ именами таблиц (вÑеже, Ñта возможноÑÑ‚ÑŒ пока не поддерживаетÑÑ);
+<li>вы можете хранить объекты доÑтупа в тех же Ñамых таблицах, и очень тщательно управлÑÑ‚ÑŒ ими, так, чтобы они не вÑтупали в противоречиÑ.
+</ul>
+<p>Чтобы выбрать первый или второй ÑпоÑоб (когда он будет доÑтупен) иÑпользуйте маÑÑив $gacl_options, когда Ñоздаете новый клаÑÑ phpGACL. Это позволит вам определить базу и Ð¿Ñ€ÐµÑ„Ð¸ÐºÑ Ð´Ð»Ñ Ñ‚Ð°Ð±Ð»Ð¸Ñ†:
+<table align="center" cellpadding="5"><tr><td bgcolor="lightgrey">
+<pre>
+$gacl_options = array(
+ 'db_table_prefix' => 'gacl_',
+ 'db_type' => 'mysql',
+ 'db_host' => 'host1',
+ 'db_user' => 'user',
+ 'db_password' => 'passwd',
+ 'db_name' => 'gacl');
+
+$gacl_host1 = new gacl($gacl_options);
+</pre>
+</td></tr></table>
+<p>Будьте очень оÑторожны, еÑли вы выберите третий вариант, поÑкольку phpGACL ничего не знает об отношениÑÑ… между вашими задачами, а, Ñледовательно, не Ñможет контролировать различные беÑÑмыÑленные директивы политики доÑтупа.
+<p>Ðапример, Хан может решить запретить доÑтуп кораблÑм, которые вÑтупают в контакт Ñ ÐµÐ³Ð¾ компьютером, к каким-либо комнатам на корабле. Ð”Ð»Ñ Ñтого он может Ñоздать “Корабль Люка†как внешний корабль ARO в Ñтом же Ñамом ARO-дереве. Ð’ результате чего, Ñтанет возможным Ñоздать APD (правило автоматичеÑкой обработки): “Корабли -> Корабль Люка†и назначить ему права “ALLOW (разрешить): “Комнаты -> паÑÑажирÑкий залâ€. СоглаÑитеÑÑŒ, Ñто полноÑтью беÑÑмыÑленно! Чтобы помочь в разрешении таких противоречий, давайте правильное (информативное) название Разделам, чтобы они четко давали понÑÑ‚ÑŒ, чем на Ñамом деле ÑвлÑетÑÑ Ð¾Ð±ÑŠÐµÐºÑ‚ доÑтупа и Ð´Ð»Ñ ÐºÐ°ÐºÐ¸Ñ… задач иÑпользуютÑÑ. Это должно быть очевидно Ð´Ð»Ñ Ð»ÑŽÐ±Ð¾Ð³Ð¾ админиÑтратора, что беÑÑмыÑленно назначать Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ñ ÐºÐ¾Ñ€Ð°Ð±Ð»Ñм Ð´Ð»Ñ Ð´Ð¾Ñтупа в какую-либо комнату.
+<h2>Объекты раÑÑˆÐ¸Ñ€ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа (AXO)</h2>
+<p>Объекты раÑÑˆÐ¸Ñ€ÐµÐ½Ð¸Ñ Ð´Ð¾Ñтупа могут добавлÑÑ‚ÑŒ третье измерение к разрешениÑм, которые могут формироватьÑÑ Ð² phpGACL. Мы Ñ Ð²Ð°Ð¼Ð¸ видели, как phpGACL позволÑет комбинировать объекты ARO и ACO (2 измерениÑ) Ð´Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ð¿Ð¾Ð»Ð¸Ñ‚Ð¸ÐºÐ¸ доÑтупа. Это очень хорошо Ð´Ð»Ñ Ð¿Ñ€Ð¾ÑÑ‚Ñ‹Ñ… разрешений, например:
+<p>Люк (ARO) проÑит разрешение на доÑтуп к Оружию (ACO).
+<p>ЕÑли Ñто вÑе, чего вы хотите, прекраÑно – AXO ÑвлÑетÑÑ Ð¿Ð¾Ð»Ð½Ð¾Ñтью дополнительным (то еÑÑ‚ÑŒ может отÑутÑтвовать).
+<p>Ðо, поÑкольку вÑе ACOs ÑвлÑÑŽÑ‚ÑÑ Ñ€Ð°Ð²Ð½Ñ‹Ð¼Ð¸, Ñто мешает ÑправлÑÑ‚ÑŒÑÑ Ñ Ð½Ð¸Ð¼Ð¸ еÑли их очень много. ЕÑли Ñто так, то мы можем изменить ÑпоÑоб, которым мы Ñмотрим на объекты доÑтупа, Ð´Ð»Ñ Ð±Ð¾Ð»ÐµÐµ легкого ÑƒÐ¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð¸Ð¼Ð¸.
+<p>AXOs идентичны AROs во многих отношениÑÑ…. ЕÑÑ‚ÑŒ дерево AXO (отдельное от дерева ARO), Ñо Ñвоими ÑобÑтвенными Группами и AXOs. Когда вы будете иметь дело Ñ AXO, думайте, что AXO берет на ÑÐµÐ±Ñ Ñтарую роль ACO (то еÑÑ‚ÑŒ ÑвлÑетÑÑ â€œÐ²ÐµÑ‰Ð°Ð¼Ð¸, к которым требуетÑÑ Ð´Ð¾Ñтупâ€), и изменÑÑŽÑ‚ предÑтавление ACOs Ñ â€œÐ²ÐµÑ‰Ð¸, к которым требуетÑÑ Ð´Ð¾Ñтуп†на “дейÑтвие, которое требуетÑÑ Ñовершитьâ€.
+<p><strong>ПоÑмотрим только на ARO и ACO:</strong>
+<ul>
+<li>ARO – вещи, проÑÑщие доÑтуп;
+<li>ACO – вещи, к которым нужен доÑтуп.
+</ul>
+<p><strong>ПоÑмотрим на ARO, ACO и AXO:</strong>
+<ul>
+<li>ARO – вещи, которые проÑÑÑ‚ доÑтуп;
+<li>ACO – дейÑтвиÑ, которые требуетÑÑ Ñовершить
+<li>AXO – вещи, к которым нужен доÑтуп.
+</ul>
+<p><strong>Пример:</strong>
+<p>Менеджер Ñайта пытаетÑÑ ÑƒÐ¿Ñ€Ð°Ð²Ð»ÑÑ‚ÑŒ доÑтупом к проектам на вебÑайте. Дерево ARO ÑоÑтоит из вÑех пользователей:
+<pre>
+ВебÑайт
+├─ÐдминиÑтраторы
+│ ├─ЭлиÑ
+│ └─КÑрол
+└─Пользователи
+ ├─Боб
+ └─Ðлан
+</pre>
+<p>Проекты организованы по принципу иÑпользуемой операционной ÑиÑтемы в Группах AXO:
+<pre>
+Проекты
+├─Linux
+│ ├─SpamFilter2
+│ └─AutoLinusWorshipper
+└─Windows
+ ├─PaperclipKiller
+ └─PopupStopper
+</pre>
+<p>ДейÑтвиÑ, которы могут выполнÑÑ‚ÑŒÑÑ Ð½Ð°Ð´ каждым объектом - “ПроÑмотр†и “Редактирование†- Ñто ACOs.
+<p>И так, мы хотим, чтобы Боб имел возможноÑÑ‚ÑŒ проÑмотра вÑех проектов Linux. Это возможно при помощи Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ADP (автоматичеÑкой обработки) ÑвÑзки ARO Боба Ñ ACO “ПроÑмотр†и AXO Linux. Теперь мы можем задать вопроÑ:
+<p>“Боб†(ARO) проÑит дейÑÑ‚Ð²Ð¸Ñ â€œÐŸÑ€Ð¾Ñмотр†(ACO) Ð´Ð»Ñ Ð¿Ñ€Ð¾ÐµÐºÑ‚Ð° “Linux†(AXO).
+<p>Обращаю ваше внимание на то, что AXO ÑвлÑетÑÑ Ð´Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ñ‹Ð¼, еÑли вы не определите AXO, Ð²Ñ‹Ð·Ñ‹Ð²Ð°Ñ acl_check(), то ADP (автоматичеÑÐºÐ°Ñ Ð¾Ð±Ñ€Ð°Ð±Ð¾Ñ‚ÐºÐ°) оÑущеÑтвитÑÑ Ð±ÐµÐ· учета AXO. Однако, еÑли APD (автоматичеÑÐºÐ°Ñ Ð¾Ð±Ñ€Ð°Ð±Ð¾Ñ‚ÐºÐ°) ÑущеÑтвует только Ñ AXO, а вы вызовите acl_check() без ÑƒÐºÐ°Ð·Ð°Ð½Ð¸Ñ AXO, вы потерпите неудачу.
+<p>И так, еÑли вы при вызове acl_check() определÑете AXO, то Ñта Ñ„ÑƒÐ½ÐºÑ†Ð¸Ñ Ð±ÑƒÐ´ÐµÑ‚ иÑкать в ACL только Ñодержание AXO. ЕÑли никакой AXO не определен, только будет раÑÑмотрены только ACL. Это (в теории) дает нам небольшое увеличение ÑкороÑти работы.
+<h1>ИнÑталлÑциÑ</h1>
+<h2>Ð‘Ð°Ð·Ð¾Ð²Ð°Ñ Ð½Ð°Ñтройка</h2>
+<ol>
+<li>РаÑпакуйте архив диÑтрибутива в корень или нужную вам папку Ñайта. Возможно, вы захотите переименовать ее во что-то более подходÑщее.
+<br><img src="manual_html_m48c2db5c.png">
+<li>Редактируйте файл phpgacl/gacl.class.php. УÑтановите db_type, db_host, db_user, db_password и db_name, которые вы предполагаете иÑпользовать.
+<br><img src="manual_html_m6a630ca2.png">
+<p>Теперь необходимо отредактировать phpgacl/admin/gacl_admin.inc.php, внеÑÑ Ð² него туже Ñамую информацию. Этот файл нужен Ð´Ð»Ñ Ð°Ð´Ð¼Ð¸Ð½Ð¸Ñтративной чаÑти Ñкрипта.
+<p>Причина, почему необходимо дважды ввеÑти одинаковые данные, заключаетÑÑ Ð² том, что клаÑÑ gacl.calss.php намного меньше по объему, чем веÑÑŒ программный интерфейÑ. И нет необходимоÑти Ñ‚Ñнуть за Ñобой вÑе Ñкрипты, еÑли вам вÑего лишь необходимо вызвать функцию acl_check().
+<li>Создайте базу данных Ñ Ð¸Ð¼ÐµÐ½ÐµÐ¼, которое вы задали в db_name.
+<li>ЗапуÑтите http://your_site.net/phpgacl/setup.php. Этот Ñкрипт ÑоздаÑÑ‚ необходимые таблицы. Ðе бойтеÑÑŒ Ñложной информации, Ñкрипт покажет вам только ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ð± уÑпешной работе.
+<br><img src="manual_html_7dced6ce.png">
+<li>Ð¡Ð»ÐµÐ´ÑƒÑ Ð·Ð°Ð¼ÐµÑ‡ÐµÐ½Ð¸ÑŽ на картинке (Перевод Ð·Ð°Ð¼ÐµÑ‡Ð°Ð½Ð¸Ñ Ð½Ð° картинке: ПожалуйÑта, Ñоздайте директорию <phpGACL root>/admin/templates_c и уÑтановите на нее права доÑтупа. Ðажмите “Go here!â€ Ð´Ð»Ñ Ð½Ð°Ñ‡Ð°Ð»Ð° работы), Ñоздайте необходимую директорию. Права доÑтупа должны позволÑÑ‚ÑŒ запиÑÑŒ в Ñту директорию.
+<li>Ðажмите на “Go here!†и вы перенеÑетеÑÑŒ Ñюда: http://your_site.net/admin/acl_admin.php.
+</ol>
+<h2>Дополнительные наÑтройки</h2>
+<p><strong>ЕÑли вы уже иÑпользуете ADOdb</strong> в Ñвоих Ñкриптах, то вы можете указать phpGACL иÑпользовать уже имеющуюÑÑ ÑƒÑтановку:
+<ol>
+<li>Отредактируйте phpgacl/gacl.class.php переменную ADODB_DIR, указав в ней путь к уÑтановленной библиотеке.
+<li>Переименуйте директорию phpgacl/adodb в какую-нибудь другую, например adodb_x и перезапуÑтите phpgacl/admin/acl_admin.php Ð´Ð»Ñ Ð¿Ñ€Ð¾Ñмотра изменений.
+<li>Удалите директорию adodb, уÑтановленную вмеÑте Ñ phpGACL.
+</ol>
+<p><strong>ЕÑли вы уже иÑпользуете Smarty</strong> в Ñвоих Ñкриптах, то вы можете указать phpGACL иÑпользовать уже имеющуюÑÑ ÑƒÑтановку:
+<ol>
+<li>Отредактируйте Ñкрипт phpgacl/admin/gacl_admin.inc.php, уÑтановив нем Ñледующие переменные: $smarty_dir и $smarty_compile_dir, чтобы они указывали на каталог, где у Ð²Ð°Ñ ÑƒÐ¶Ðµ уÑтановлен Smarty. ПеремеÑтите директорию Ñ ÑˆÐ°Ð±Ð»Ð¾Ð½Ð°Ð¼Ð¸ phpGACL в другую директорию (например в ту, которую вы на данный момент уже иÑпользуете).
+<li>Переименуйте папку phpgacl/smarty в другую, например smarty_x. И перезапуÑтите phpgacl/admin/acl_admin.php Ð´Ð»Ñ Ð¿Ñ€Ð¾Ñмотра изменений.
+<li>Удалите папку smarty инÑталлÑции phpGACL.
+</ol>
+<p><strong>Как можно перемеÑтить phpGACL файлы из моего дерева вебÑайта Ñ Ñохранением ÑвÑзей Ñ Ð´ÐµÑ€ÐµÐ²Ð¾Ð¼ Ð´Ð»Ñ Ð°Ð´Ð¼Ð¸Ð½Ð¸ÑтрированиÑ?</strong>
+<ol>
+<li>Перейдите в корень вашего вебÑайта.
+<li>ПеремеÑтите директорию phpGACL в необходимую вам директорию и Ñоздайте Ñимлинк (ÑÑылку) на админиÑтративную директорию там, где вы хотите его запуÑкать.
+<table align="center" cellpadding="5"><tr><td bgcolor="lightgrey">
+<pre>
+mv phpgacl/ /www/includes_directory
+ln -s /www/includes_directory/phpgacl/admin/ gacl
+</pre>
+</td></tr></table>
+<li>Теперь попробуйте запуÑтить phpgacl. ЕÑли он не Ñтал работать, то, возможно, ваш Ñайт не поддерживает Ñимлинки( ÑÑылки).
+</ol>
+<h1>ИÑпользование phpGACL в вашей программе</h1>
+<h2>Базовое иÑпользование</h2>
+<p>Этот пример показывает оÑновной ÑпоÑоб иÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ phpGACL в вашей программе. Он так же показывает иÑпользование абÑтрактного клаÑÑа Ð´Ð»Ñ Ð´Ð¾Ñтупа к базам данных ADOdb. Пример иллюÑтрирует проÑтой ÑпоÑоб проверки логина и паролÑ.
+<table align="center" cellpadding="5"><tr><td bgcolor="lightgrey">
+<pre>
+// Подключаем базовый API
+include('phpgacl/gacl.class.php');
+$gacl = new gacl();
+$username = $db->quote($_POST['username']);
+$password = $db->quote(md5($_POST['password']));
+$sql = 'SELECT name FROM users WHERE name=';
+$sql .= $username.' AND password='.$password;
+$row = $db->GetRow($sql);
+if($gacl->acl_check('system','login','user',$row['name'])){
+ $_SESSION['username'] = $row['name'];
+ return true;
+}
+else
+ return false;
+</pre>
+</td></tr></table>
+<p>Вы видете только один вызов acl_check(), что же он означает?
+<ul>
+<li>ПроверÑет ARO-объект $row['name'] в ARO-разделе 'user'.
+<li>Ртакже ACO-объект 'login' в ACO-разделе 'system'.
+</ul>
+<h2>ПрофеÑÑиональное иÑпользование</h2>
+<h2>ИÑпользование админиÑтративного интерфейÑа</h2>
+<p>ОтÑутÑтвует в оригинальной документации
+<h2>ОпиÑание API</h2>
+<h2>ACL</h2>
+<strong>add_acl()</strong>
+<p>ДобавлÑет права доÑтупа в лиÑÑ‚ контролÑ.
+<pre>
+add_acl(
+ array ACO Ids,
+ array ARO_IDs,
+ array ARO_GROUP_IDs,
+ array AXO_IDs,
+ array AXO_GROUP_IDs,
+ bool ALLOW,
+ bool ENABLED
+ [, int ACL_ID])
+</pre>
+<p>Возвращает:
+<p>int ACL_ID, еÑли вÑе прошло хорошо и FALSE, в Ñлучае неудачи.
+
+<br><br><br><strong>edit_acl()</strong>
+<p>Редактирует права доÑтупа, которые уже уÑтановлены в лиÑте контролÑ.
+<pre>
+edit_acl (
+ array ACO IDs,
+ array ARO_IDs,
+ array ARO_GROUP_IDs,
+ array AXO_IDs,
+ array AXO_GROUP_IDs,
+ bool ALLOW,
+ bool ENABLED
+ [, int ACL_ID] )
+</pre>
+<p>Возвращает:
+<p>int ACL_ID еÑли вÑе прошло хорошо и FALSE, в Ñлучае неудачи.
+
+<br><br><strong>del_acl()</strong>
+<p>УдалÑет права доÑтупа, которые уже заданы в лиÑте контролÑ.
+<pre>
+del_acl (
+ int ACL ID)
+</pre>
+<p>Возвращает:
+<p>TRUE еÑли вÑе прошло уÑпешно, FALSE, в Ñлучае неудачи.
+
+<h2>Groups (Группы)</h2>
+<strong>get_group_id()</strong>
+<p>Возвращает ID группы.
+<pre>
+get_group_id (
+ string GROUP NAME) Тип объекта доÑтупа (ARO, ACO, AXO)
+</pre>
+<p>Возвращает:
+<p>int GROUP_ID в Ñлучае уÑпеха, FALSE, еÑли неудача.
+
+<br><br><strong>get_group_parent_id()</strong>
+<p>Возвращает ID непоÑредÑтвенного Ñ€Ð¾Ð´Ð¸Ñ‚ÐµÐ»Ñ Ð³Ñ€ÑƒÐ¿Ð¿Ñ‹.
+<pre>
+get_group_parent_id (
+ int GROUP_ID)
+</pre>
+<p>Возвращает:
+<p>int GROUP_PARENT_ID еÑли удача, FALSE – еÑли неудача.
+
+<br><br><strong>add_group()</strong>
+<p>ДобавлÑет группу в дерево групп.
+<pre>
+add_group (
+ string NAME
+ [, int GROUP_PARENT_ID]
+ [, string OBJECT_TYPE])
+</pre>
+<p>Возвращает:
+<p>int GROUP_ID еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>get_group_objects()</strong>
+<p>Возвращает впиÑок вÑех объектов отнеÑенных к группе.
+<pre>
+get_group_aro (
+ int GROUP_ID,
+ string GROUP_TYPE)
+</pre>
+<p>Возвращает:
+<p>array SECTION_VALUE, VALUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>add_group_object()</strong>
+<p>СоотноÑит ARO Ñ Ð³Ñ€ÑƒÐ¿Ð¿Ð¾Ð¹.
+<pre>
+add_group_aro (
+ int GROUP_ID,
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int TRUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>del_group_object()</strong>
+<p>УдалÑет ARO из группы.
+<pre>
+del_group_aro (
+ int GROUP_ID,
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int TRUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>edit_group()</strong>
+<p>Редактирует группы
+<pre>
+edit_group (
+ int GROUP_ID,
+ string NAME,
+ int GROUP_PARENT_ID,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int TRUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>del_group()</strong>
+<p>УдалÑет группу, перераÑпределÑет детей (еÑли еÑÑ‚ÑŒ) или удалÑет их.
+<pre>
+del_group (
+ int GROUP_ID,
+ bool REPARENT_CHILDREN,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int TRUE еÑли удача, FALSE еÑли неудача.
+
+<h2>Access Objects (ARO/ACO/AXO)</h2>
+<p>Этот раздел API управлÑет объектами доÑтупа, такими как ACO, ARO, AXO.
+
+<br><br><strong>get_object()</strong>
+<p>Возвращает маÑÑив информации обо вÑех объектах указанного типа.
+<pre>
+get_object (
+ [string SECTION_VALUE], ÐеобÑзательный, название Раздела (как фильтр)
+ bool RETURN_HIDDEN, Возвращать ли объекты Ñ Ñ‚Ð¸Ð¿Ð¾Ð¼ “Ñкрытыйâ€
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>array OBJECT_ID еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>get_object_data()</strong>
+<p>Возвращает маÑÑив информации об объекте доÑтупа Ñ ÐºÐ¾Ð½ÐºÑ€ÐµÑ‚Ð½Ñ‹Ð¼ ID.
+<pre>
+get_object_data (
+ int OBJECT_ID,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>array (section_value, value, order_value, name) еÑли удача, FALSE еÑди неудача.
+
+<br><br><strong>get_object_id()</strong>
+<p>Возвращает ID объекта.
+<pre>
+get_object_id (
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int OBJECT_ID еÑди удача, FALSE еÑли неудача.
+
+<br><br><strong>get_object_section_value()</strong>
+ Возвращает ID раздела к которому припиÑан объект.
+<pre>
+get_object_section_value (
+ int OBJECT_ID,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int SECTION_VALUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>add_object()</strong>
+<p>ДобавлÑет объект.
+<pre>
+add_object (
+ string SECTION_VALUE,
+ string NAME,
+ string VALUE,
+ int ORDER,
+ bool HIDDEN,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>array OBJECT_ID еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>edit_object()</strong>
+<p>Редактирование объекта.
+<pre>
+edit_object (
+ string SECTION_VALUE,
+ string NAME,
+ string VALUE,
+ int ORDER,
+ bool HIDDEN,
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>array OBJECT_ID еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>del_object()</strong>
+<p>УдалÑет объект.
+<pre>
+del_object (
+ int OBJECT_ID,
+ string GROUP_TYPE, Тип объекта доÑтупа (ARO, AXO, ACO)
+ bool ERASE)
+</pre>
+<p>Возвращает:
+<p>int TRUE еÑли удача, FALSE еÑли неудача.
+
+<h2>Access Object Sections (Разделы объектов доÑтупа)</h2>
+<p>Этот раздел API позволÑет управлÑÑ‚ÑŒ Разделами, которые ÑвлÑÑŽÑ‚ÑÑ Ñ‡Ð°Ñтью уникального Ð½Ð°Ð·Ð²Ð°Ð½Ð¸Ñ Ð¾Ð±ÑŠÐµÐºÑ‚Ð° доÑтупа (Ñм. â€œÐ Ð°Ð·Ð´ÐµÐ»Ñ‹â€ Ð´Ð»Ñ Ð´Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð¾Ð¹ информации).
+
+<br><br><strong>get_object_section_section_id()</strong>
+<p>Возвращает ID ÑущеÑтвующего Раздела. Ð’Ñ‹ должны указать название Раздела или его значение, или оба параметра.
+<p>ЕÑли вы определите только название, то возможны неоднозначные результаты (так как название не обÑзано быть уникальным). Ð’ Ñтом Ñлучае вы получите Ñообщение об ошибке.
+<pre>
+get_object_section_section_id (
+ string NAME, Короткое опиÑание того, Ð´Ð»Ñ Ñ‡ÐµÐ³Ð¾ предназначин Раздел
+ (например, Этажи в зданииâ€)
+ string VALUE, Ðазвание Раздела (например, “Этажâ€)
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int SECTION_ID еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>add_object_section()</strong>
+<p>ДобавлÑет новый Раздел объектов.
+<pre>
+add_object_section(
+ string NAME, Короткое опиÑание того, Ð´Ð»Ñ Ñ‡ÐµÐ³Ð¾ предназначин Раздел
+ (например, Этажи в зданииâ€)
+ string VALUE, Ðазвание Раздела (например, “Этажâ€)
+ int ORDER, ЦенноÑÑ‚ÑŒ Раздела. УчитываетÑÑ Ð² пользовательÑком интерфейÑе при выводе ÑпиÑка выбора.
+ bool HIDDEN, TRUE – Раздел будет Ñкрыт из ÑпиÑка в пользовательÑком интерфейÑе.
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>int SECTION_ID еÑли удачно, FALSE еÑли неудачно.
+
+<br><br><strong>edit_object_section()</strong>
+<p>ИзменÑет атрибуты Раздела. Ð¤ÑƒÐ½ÐºÑ†Ð¸Ñ Ð½Ðµ может изменить тип объекта доÑтупа (Ð´Ð»Ñ Ð´Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð¾Ð¹ информации Ñмотрите add_object_section).
+<pre>
+edit_object_section (
+ int OBJECT_SECTION_ID, ID раздела (вы можете получить его при помощи
+ функции get_object_section_section_id).
+ string NAME, Ðовое название Раздела.
+ string VALUE, Ðовое значение Раздела.
+ int ORDER, ÐÐ¾Ð²Ð°Ñ Ñ†ÐµÐ½Ð½Ð¾ÑÑ‚ÑŒ раздела.
+ bool HIDDEN, Ðовый ÑÑ‚Ð°Ñ‚ÑƒÑ Ñ€Ð°Ð·Ð´ÐµÐ»Ð° (Ñкрыт или нет)
+ string GROUP_TYPE) Тип объекта доÑтупа (ARO, AXO, ACO)
+</pre>
+<p>Возвращает:
+<p>TRUE еÑли удача, FALSE еÑли неудача.
+
+<br><br><strong>del_object_section()</strong>
+<p>УдалÑет Раздел. Ð’Ñе объекты Раздела также будут удалены!!!
+<pre>
+del_object_section (
+ int SECTION_ID, ID Раздела
+ string GROUP_TYPE, Тип объекта доÑтупа (ARO, AXO, ACO)
+ bool ERASE) ЕÑли TRUE - вÑе объекты Раздела будут удалены.
+ ЕÑли FALSE, то вы получите Ñообщение об ошибке в Ñлучае,
+ еÑли Раздел Ñодержит объекты, Раздел удален не будет,
+ еÑли Раздел не Ñодержит объектов, он будет удален.
+</pre>
+<p>Возвращает:
+<p>TRUE еÑли удача, FALSE еÑди неудача.
+<hr>
+</body>
+</html> \ No newline at end of file
diff --git a/html/phpgacl/docs/translations/russian/manual_rus.pdf b/html/phpgacl/docs/translations/russian/manual_rus.pdf
new file mode 100644
index 0000000..8ea695e
--- /dev/null
+++ b/html/phpgacl/docs/translations/russian/manual_rus.pdf
Binary files differ
diff --git a/html/phpgacl/docs/translations/russian/manual_rus.sxw b/html/phpgacl/docs/translations/russian/manual_rus.sxw
new file mode 100644
index 0000000..ed0355c
--- /dev/null
+++ b/html/phpgacl/docs/translations/russian/manual_rus.sxw
Binary files differ
diff --git a/html/phpgacl/docs/translations/russian/manual_rus.txt b/html/phpgacl/docs/translations/russian/manual_rus.txt
new file mode 100644
index 0000000..471dfe7
--- /dev/null
+++ b/html/phpgacl/docs/translations/russian/manual_rus.txt
@@ -0,0 +1,674 @@
+phpGACL - ðóññêàÿ äîêóìåíòàöèÿ
+Ñîäåðæàíèå
+Ñîäåðæàíèå
+Î ñêðèïòå
+ ×òî ýòî?
+ Ãäå âçÿòü?
+ ×òî íóæíî äëÿ çàïóñêà?
+ Àâòîðû
+Ââåäåíèå
+ Ïîíèìàíèå êîíòðîëÿ äåéñòâèÿ
+ Óïðàâëåíèå êîíòðîëåì äîñòóïà ïðè ïîìîùè phpGACL
+ Ïîäðîáíûé êîíòðîëü äîñòóïà
+ Ìíîãîóðîâíåâûå ãðóïïû
+ Êàê phpGACL îïðåäåëÿåò ðàçðåøåíèÿ?
+ Äîáàâëåíèå ãðóïïû Äîáàâëåíèå ëþäåé
+ Óñòðàíåíèå êîíôëèêòîâ
+ Îáîçíà÷åíèå îáúåêòîâ äîñòóïà
+ Äîáàâëåíèå ðàçäåëîâ
+ Ìíîæåñòâî öåëåé
+ Îáúåêòû ðàñøèðåíèÿ äîñòóïà (AXO)
+Èíñòàëëÿöèÿ
+ Áàçîâàÿ íàñòðîéêà
+ Äîïîëíèòåëüíàÿ íàñòðîéêà
+Èñïîëüçîâàíèå phpGACL â âàøåé ïðîãðàììå
+ Áàçîâîå èñïîëüçîâàíèå
+ Ïðîôåññèîíàëüíîå èñïîëüçîâàíèå
+ Èñïîëüçîâàíèå àäìèíèñòðàòèâíîãî èíòåðôåéñà
+ Îïèñàíèå API
+ ACL
+ Groups (Ãðóïïû)
+ Access Objects (ACO, ARO, AXO) (Îáúåêòû äîñòóïà)
+ Access Objects Section (ðàçäåëû îáúåêòîâ äîñòóïà)
+
+
+
+
+
+
+
+
+
+
+
+Mike Benoit (ipso@snappymail.ca)
+James Russell (james-phpgacl@ps2-pro.com)
+Karsten Dambekalns (k.dambekalns@fishfarm.de)
+Ðóññêèé ïåðåâîä Ôåñüêîâ Êóçüìà (kuzma@russofile.ru) (http://php.russofile.ru)
+Copyright © 2002,2003, Mike Benoit
+Copyright © 2003, James Russell
+Copyright © 2003, Karsten Dambekalns
+Document Version: 672
+Last Updated: 5/20/03 - 18:55:08
+phpGACL
+×òî ýòî?
+PhpGACL – ýòî íàáîð ôóíêöèé, êîòîðûé ïîçâîëÿåò îïðåäåëèòü ïðàâà äîñòóïà ê ïðîèçâîëüíûì îáúåêòàì (íàïðèìåð, ñòðàíèöàì, áàçàì äàííûõ è òàê äàëåå) äðóãèì îáúåêòàì (íàïðèìåð, ïîëüçîâàòåëÿìè, óäàëåííûìè õîñòàìè è òàê äàëåå).
+Ýòî ïðåäïîëàãàåò ïîäðîáíûé êîíòðîëü äîñòóïà ñ ïðîñòûì óïðàâëåíèåì è âûñîêîé ñêîðîñòüþ.
+Ñêðèïò íàïèñàí íà PHP (îòñþäà åãî íàçâàíèå – phpGACL) – ýòî ïîïóëÿðíûé ñêðèïòîâûé ÿçûê, êîòîðûé îáû÷íî èñïîëüçóåòñÿ äëÿ äèíàìè÷åñêîãî ñîçäàíèÿ ñòðàíèö ñåòè. GACL ÷àñòü phpGACL – Ðîäîâîé ñïèñîê êîíòðîëÿ äîñòóïà.
+Ãäå âçÿòü?
+PhpGACL õîñòèòñÿ íà sourceforge.net çäåñü http://phpGACL.sourceforge.net/
+×òî íóæíî äëÿ çàïóñêà?
+PhpGACL òðåáóåò ðåëÿöèîííóþ áàçó äàííûõ äëÿ õðàíåíèÿ èíôîðìàöèè î ïðàâàõ. Äîñòóï ê áàçå äàííûõ îñóùåñòâëÿåòñÿ ÷åðåç àáñòðàêòíûé êëàññ äîñòóïà ê áàçàì äàííûõ ADOdb (http://php.weblogs.com/adodb). Äàííûé êëàññ ïîçâîëÿåò ðàáîòàòü ñ òàêèìè áàçàìè äàííûõ êàê: PostgreSQL, MySQL, Oracle.
+Ïîñêîëüêó phpGACL íàïèñàí íà ÿçûêå PHP, òî îí òðåáóåò óñòàíîâêè PHP âåðñèè íå íèæå 4.2. ACL (Àäìèíèñòðèðîâàíèå ñïèñêà êîíòðîëÿ äîñòóïà) äîïîëíåíà âåá-èíòåðôåéñîì, ïîòîìó íåîáõîäèìî íàëè÷èå âåá-ñåðâåðà ñ ïîääåðæêîé PHP, íàïðèìåð, Apache (http://httpd.apache.org/).
+Àâòîðû
+Mike Benoit (ipso@snappymail.ca) – àâòîð è ìåíåäæåð ïðîåêòà.
+James Russel (james-phpgacl@ps2-pro.com) è
+Karsten Dambekalns (k.dambekalns@fishfarm.de) – àâòîðû äîêóìåíòàöèè.
+Feskov Kuzma (kuzma@russofile.ru) – ðóññêèé ïåðåâîä
+Ïîñëåäíÿÿ âåðñèÿ ïåðåâîäà âñåãäà çäåñü: http://php.russofile.ru
+Ââåäåíèå
+Ïîíèìàíèå êîíòðîëÿ äåéñòâèÿ
+Õàí – êàïèòàí “Ñîêîëà òûñÿ÷åëåòèÿ” è ×óâè – åãî âòîðîé îôèöåð. Îíè âçÿëè íà áîðò íåñêîëüêî ïàññàæèðîâ: Ëþêà, Îáè-Âàíà, R2-D2 è C3PO. Õàí äîëæåí îïðåäåëèòü îãðàíè÷åíèÿ äîñòóïà äëÿ ðàçëè÷íûõ ìåñò (êîìíàò) êîðàáëÿ, íàïðèìåð: êàáèíà, ìàøèííûé çàë, äâèãàòåëè è âíåøíåå îðóæèå.
+Õàí ñêàçàë: “ß è ×óâè ìîãóò èìåòü äîñòóï âñþäó, íî, ïîñëå îñîáåííî ãðÿçíîãî ðåìîíòà ãèïåðäâèãàòåëÿ, ÿ çàïðåùàþ ×óâè êîãäà-ëèáî ïîäõîäèòü ê ìàøèííîìó çàëó. Ïàññàæèðû îãðàíè÷åíû ïàññàæèðñêèì çàëîì”.
+Ñ ýòîãî ìîìåíòà, äàâàéòå áóäåì ñ÷èòàòü, ÷òî äîñòóï ÿâëÿåòñÿ Boolean (Áóëåâûì), òî åñòü, ðåçóëüòàò çàïðîñà íà äîñòóï ïåðñîíàæà ê êàêîìó-ëèáî ïîìåùåíèþ ÿâëÿåòñÿ “Ðàçðåøèòü” èëè “Íå ðàçðåøèòü”, è íåò íèêàêîãî ñðåäíåãî ðåçóëüòàòà.
+Åñëè ìû íàíåñåì ýòî óòâåðæäåíèå íà ìàòðèöó äîñòóïà, ïîêàçûâàþùóþ, êòî èìååò äîñòóï êóäà-ëèáî, òî ýòî áû âûãëÿäåëî ïðèìåðíî òàê (O – äîñòóï ðàçðåøåí, X – äîñòóï çàïðåùåí):
+
+Êòî / Êóäà Êàáèíà Ïàññàæèðñêèé çàë Îðóæèå Ìàøèííûé çàë
+ Õàí O O O O
+ ×óâè O O O X
+ Îáè-Âàí X O X X
+ Ëþê X O X X
+ R2D2 X O X X
+ C3PO X O X X
+
+
+Êîëîíêè ïîêàçûâàþò ñïèñîê êîìíàò, ê êîòîðûì Õàí ìîæåò îãðàíè÷èòü äîñòóï, à ðÿäû ïîêàçûâàþò ïåðñîí, êîòîðûå ìîãëè áû çàïðîñèòü äîñòóï ê òåì èëè èíûì êîìíàòàì. Áîëåå øèðîêîå îáúÿñíåíèå:
+“êîìíàòû” - ýòî âåùè (îáúåêòû) äëÿ óïðàâëåíèÿ äîñòóïà ê íèì. Ìû íàçûâàåì ýòè îáúåêòû ACO (Access Control Objects - Îáúåêòû êîíòðîëÿ äîñòóïà);
+“ëþäè” - “âåùè (îáúåêòû), çàïðàøèâàþùèå äîñòóï”. Ìû íàçûâàåì èõ ARO (Access Request Objects - Îáúåêòû çàïðîñà äîñòóïà). Ëþäè çàïðàøèâàþò äîñòóï ê êîìíàòàì, èëè, â íàøåé òåðìèíîëîãèè, AROs çàïðàøèâàþò äîñòóï ê ACOs.
+Òàê æå åñòü òðåòèé òèï îáúåêòà – AXO (Access eXtension Objects – Îáúåêòû ðàñøèðåíèÿ äîñòóïà), íî î íåì ìû ïîãîâîðèì ïîçæå. Ýòè îáúåêòû èìåþò ìíîãî àòðèáóòîâ è óïîìèíàþòñÿ âìåñòå êàê Îáúåêòû äîñòóïà.
+Óïðàâëåíèå äîñòóïîì, èñïîëüçóÿ ìàòðèöó äîñòóïà, ïîäîáíîé âûøå, èìååò ïðåèìóùåñòâà è íåäîñòàòêè:
+Ïëþñû:
+î÷åíü ïîäðîáíûé – åñòü âîçìîæíîñòü óïðàâëåíèÿ äîñòóïîì íà óðîâíå êîíêðåòíîãî ÷åëîâåêà, åñëè åñòü òàêàÿ íåîáõîäèìîñòü;
+ëåãêî óâèäåòü, êòî èìååò äîñòóï è ê ÷åìó. Îòâåò íàõîäèòñÿ â ïåðåñå÷åíèè ÷åëîâåêà è êîìíàòû.
+Ìèíóñû:
+òðóäíî óïðàâëÿòü íà êðóïíîé ìàòðèöå äîñòóïà. 6 ïàññàæèðîâ è 4 ìåñòà – ýòî ïðîñòî, íî ÷òî, åñëè ó âàñ òûñÿ÷è ïàññàæèðîâ è ñîòíè ìåñò, è âû äîëæíû îãðàíè÷èòü äîñòóï áîëüøèìè ãðóïïàìè è ñðàçó, íî ñîõðàíèòü ïðè ýòîì ïîäðîáíûé êîíòðîëü äëÿ îòäåëüíîãî èíäèâèäóóìà? Ýòî îçíà÷àëî áû áîëüøîå è òðóäîåìêîå ðåãóëèðîâàíèå ìàòðèöû, à òàê æå ïîñòàâèëî áû î÷åíü òðóäíóþ çàäà÷ó ïðîâåðêè ìàòðèöû íà ïðàâèëüíîñòü;
+òðóäíî ñóììèðîâàòü è âèçóàëèçèðîâàòü. Ïðåäûäóùèé ïðèìåð äîâîëüíî ïðîñò, åãî ìîæíî çàïèñàòü â íåñêîëüêî ïðåäëîæåíèé (ñìîòðèòå âûñêàçûâàíèå Õàíà), íî ÷òî, åñëè ìàòðèöà íàïîìèíàåò òàêóþ?
+
+Êòî / Êóäà Êàáèíà Ïàññàæèðñêèé çàë Îðóæèå Ìàøèííûé çàë
+ Õàí O O O O
+ ×óâè O X O X
+ Îáè-Âàí X O X X
+ Ëþê O O O X
+ R2D2 X O X O
+ C3PO O O X O
+
+Ýòà ìàòðèöà íå íà ñòîëüêî î÷åâèäíà äëÿ ñóììèðîâàíèÿ, è íå ïîíÿòíà äëÿ ÷èòàòåëÿ, ïî÷åìó òå èëè èíûå ðåøåíèÿ áûëè ïðèíÿòû.
+Óïðàâëåíèå êîíòðîëåì äîñòóïà ïðè ïîìîùè phpGACL
+ßñíî, ÷òî äëÿ êîíòðîëÿ íàä áîëüøèìè ñèñòåìàìè è ñëîæíûìè ñèòóàöèÿìè ýòîò ïîäõîä “ìàòðèöû äîñòóïà” ÿâëÿåòñÿ íåïîäõîäÿùèì. Ìû íóæäàåìñÿ â ëó÷øåé ñèñòåìå, êîòîðàÿ ïîääåðæèâàåò ïëþñû (ïîäðîáíûé êîíòðîëü è ïîíÿòíóþ âèçóàëèçàöèþ òîãî, êòî èìååò èìååò äîñòóï è ê ÷åìó) è óäàëÿåò íåóäîáñòâà (òðóäíîñòü ñóììèðîâàíèÿ, òðóäíîñòü óïðàâëåíèÿ áîëüøèìè ãðóïïàìè ëþäåé ñðàçó). Îäíî ðåøåíèå – phpGACL.
+PhpGACL íå îïèñûâàåò äîñòóï îò “âîñõîäÿùåãî” ïîäîáíî ìàòðèöå äîñòóïà âûøå. Âìåñòî ýòîãî, îïèñûâàåò äîñòóï ñâåðõó âíèç, ïîäîáíî òåêñòîâîìó îïèñàíèþ ïîëèòèêè äîñòóïà Õàíà. Ýòî – î÷åíü ãèáêàÿ ñèñòåìà, êîòîðàÿ ïîçâîëÿåò âàì óïðàâëÿòü äîñòóïîì â áîëüøèõ ãðóïïàõ, òàê æå ïîçâîëÿåò àêêóðàòíî ñóììèðîâàòü ïîëèòèêó äîñòóïà è ëåãêî âèäåòü, êòî èìååò ïðàâî íà äîñòóï è ê ÷åìó.
+ARO-äåðåâî îïðåäåëÿåò èåðàðõèþ ãðóïï AROs (îáúåêòîâ çàïðîñà äîñòóïà). Ýòî ïîäîáíî ïðåäñòàâëåíèþ äåðåâà ïàïîê è ôàéëîâ. “Ïàïêè” - ãðóïïû, “ôàéëû” - AROs.
+Äàâàéòå ïîïðîáóåì ñîñòàâèòü ACL-äåðåâî äëÿ ëþäåé íà ñóäíå Õàíà. Ñíà÷àëà ìû îïðåäåëèì íåêîòîðûå êàòåãîðèè äëÿ ëþäåé. ßñíî, ÷òî Õàí è ×óâè óïðàâëÿþò ñóäíîì, à îñòàëüíûå îáúåêòû – ýòî òîëüêî ïàññàæèðû.
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ Ãðóïïà
+??Êîìàíäà Ãðóïïà
+? ??Õàí ARO
+? ??×óâè ARO
+??Ïàññàæèðû Ãðóïïà
+ ??Îáè-Âàí ARO
+ ??Ëþê ARO
+ ??R2-D2 ARO
+ ??C3PO ARO
+Ýòî äåðåâî íå îïðåäåëÿåò íèêàêîé ïîëèòèêè, îíî ïðîñòî ïîêàçûâàåò, êàêèì îáðàçîì ìû ãðóïïèðóåì ëþäåé, êîòîðûå ìîãëè áû çàïðîñèòü äîñòóï (AROs).
+Ìû çàäàåì îãðàíè÷åíèÿ äîñòóïà, ñîçäàâàÿ èíñòðóêöèè äëÿ îïðåäåëåííîé êîìíàòû (ACO) êàêîé-òî ãðóïïå èëè AROs â äåðåâå. Õàí ãîâîðèò: “Ïî óìîë÷àíèþ íèêîìó íåëüçÿ íàçíà÷èòü äîñòóï íè ê îäíîé èç êîìíàò íà Ñîêîëå òûñÿ÷åëåòèÿ. Íî êîìàíäà äîëæíà èìåòü äîñòóï ê êàæäîé êîìíàòå. Ïàññàæèðû äîëæíû èìåòü äîñòóï òîëüêî ê ïàññàæèðñêîìó çàëó”.
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+ ??Îáè-Âàí
+ ??Ëþê
+ ??R2D2
+ ??C3PO
+×òîáû èíòåðïðåòèðîâàòü íàøå ARO-äåðåâî, ìû íà÷èíàåì ñ âåðøèíû è äâèãàåìñÿ âíèç.
+Âî-ïåðâûõ, ïîëèòèêà ïî óìîë÷àíèþ ñîñòîèò â òîì, ÷òîáû çàïðåòèòü äîñòóï êî âñåìó. Îãðàíè÷åíèÿ áûëè èçìåíåíû òîëüêî äëÿ êîìàíäû, òàê ÷òî îíè òåïåðü èìåþò äîñòóï êî âñåìó (ALL – ñèíîíèì äëÿ âñåõ êîìíàò (êàáèíà, ìàøèííûé çàë, ïàññàæèðñêèé çàë è îðóæèå). Ïàññàæèðû èìåþò òîëüêî äîñòóï ê ïàññàæèðñêîìó çàëó.
+Òàêîé ñïîñîá îïèñûâàòü ïîëèòèêó äîñòóïà áîëåå ÿñåí ÷åì ìàòðèöà äîñòóïà. Âû ìîæåòå ëåãêî âèäåòü êòî èìååò äîñòóï ê ÷åìó, à òàê æå áîëåå ëåãêî îïðåäåëèòü, ïî÷åìó îíè èìåþò ýòîò äîñòóï (êàæåòñÿ î÷åâèäíûì, ÷òî Õàí è ×óâè èìåþò äîñòóï êî âñåìó, òàê êàê îíè ñãðóïïèðîâàíû â “Êîìàíäó”).
+Ñóììèðóåì:
+ACO (îáúåêòû êîíòðîëÿ äîñòóïà) – âåùè, äîñòóïîì ê êîòîðûì ìû õîòèì óïðàâëÿòü (íàïðèìåð ñòðàíèöû ñåòè, áàçû äàííûõ, êîìíàòû è òàê äàëåå);
+ARO (îáúåêòû çàïðîñà äîñòóïà) – âåùè, êîòîðûå çàïðàøèâàþò äîñòóï (íàïðèìåð, ëþäè, îòäàëåííûå êîìïüþòåðû è òàê äàëåå);
+ARO-äåðåâüÿ – îïðåäåëÿþò èåðàðõèþ Ãðóïï è AROs. Ãðóïïû ìîãóò ñîäåðæàòü äðóãèå ãðóïïû è AROs;
+ïîëèòèêà ïî óìîë÷àíèþ äëÿ äåðåâà – çàïðåòèòü âñå (DENY: ALL);
+÷òîáû îïðåäåëèòü ïîëèòèêó äîñòóïà, äâèãàéòåñü âíèç ïî äåðåâó, ÿâíî íàçíà÷àÿ ðàçðåøåíèÿ Ãðóïïàì è AROs äëÿ êàæäîãî ACO, åñëè â ýòîì âîçíèêàåò ïîòðåáíîñòü.
+Ïîäðîáíûé êîíòðîëü äîñòóïà
+Îé, ìû êàæåòñÿ çàáûëè ïðî ×óâè! Îòíåñÿ åãî ê êîìàíäå Õàí êîñâåííî äàë åìó äîñòóï â ìàøèííûé çàë! Íî, åñëè ïîìíèòå, îí íå õîòåë ýòîãî äåëàòü. Îí íå õî÷åò ýòîãî ïîñëå òîãî, êàê ×óâè íåäàâíî ðåìîíòèðîâàë ãèïåðäâèãàòåëü. Õàí äîáàâëÿåò ïðàâèëî çàïðåùåíèÿ äëÿ ×óâè:
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+ ??Îáè-Âàí
+ ??Ëþê
+ ??R2D2
+ ??C3PO
+Ýòî ïðèìåð òîãî, êàê âû ìîæåòå óïðàâëÿòü ïîëèòèêîé äîñòóïà â ïîäðîáíîé ìàíåðå. Íåò íåîáõîäèìîñòè ïåðåìåùàòü ×óâè â äðóãóþ ãðóïïó, ìû ïðîñòî çàïðåùàåì åìó íà áîëåå íèçêîì óðîâíå.
+Äðóãîé ïðèìåð ïîäðîáíîãî êîíòðîëÿ ìîæåò âîçíèêíóòü, êîãäà íà êîðàáëü íàïàëà Èìïåðèÿ. Õàí äîëæåí ïîçâîëèòü ÷åëîâåêó Ëþêó èñïîëüçîâàòü îðóæèå è ïîçâîëèòü ðîáîòó R2D2 âîññòàíîâèòü ãèïåðäâèãàòåëü â ìàøèííîì çàëå. Îí ìîæåò ñäåëàòü ýòî ðàñøèðèâ èõ ïîëíîìî÷èÿ, êîòîðûå îïðåäåëåíû èì îáùèì ñòàòóñîì ãðóïïû “Ïàññàæèð”:
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+ ??Îáè-Âàí
+ ??Ëþê [ALLOW: Guns] (ðàçðåøèòü: îðóæèå)
+ ??R2D2 [ALLOW: Engines] (ðàçðåøèòü: ìàøèííûé çàë)
+ ??C3PO
+Ìíîãîóðîâíåâûå ãðóïïû
+Ãðóïïû ìîãóò áûòü ðàñøèðåíû íà ëþáîé óðîâåíü â ARO-äåðåâå. Íàïðèìåð, ìû ìîãëè áû äîáàâèòü ãðóïïó “Äæåäàè” ê “Ïàññàæèðàì”. Áîëüøèíñòâî ïàññàæèðîâ áûëî áû êàòåãîðèçèðîâàíî ïðè “Ïàññàæèðàõ”, íî Ëþê è Îáè-Âàí áóäóò âûäåëåíû â “Äæåäàè” è ïîýòîìó ìîãóò èìåòü íåêîòîðûå ïðèâåëåãèè (íàïðèìåð, äîñòóï â êàáèíó):
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+ ??Äæåäàè [ALLOW: Cockpit] (ðàçðåøèòü: êàáèíó)
+ ? ??Îáè-Âàí
+ ? ??Ëþê [ALLOW: Guns] (ðàçðåøèòü: îðóæèå)
+ ??R2D2 [ALLOW: Engines] (ðàçðåøèòü: ìàøèííîå îòäåëåíèå)
+ ??C3PO
+Êàê phpGACL îïðåäåëÿåò ðàçðåøåíèÿ?
+Êîãäà êîìïüþòåð ñóäíà (ñ çàïóùåííûì phpGACL êîíå÷íî æå) ïðîâåðÿåò äîñòóï, åäèíñòâåííûé âîïðîñ, êîòîðûé îí ìîæåò çàäàòü ñåáå - “èìååò ëè ÷åëîâåê X äîñòóï ê ìåñòó Y?” Íà ÿçûêå phpGACL ýòî áóäåò âûãëÿäåòü òàê: “Ìîæåò ëè ARO X èìåòü äîñòóï ê ACO Y?”
+phpGACL îïðåäåëÿåò, èìååò ëè îïðåäåëåííûé ÷åëîâåê äîñòóï ê îïðåäåëåííîìó ìåñòó ñëåäóÿ îò âåðøèíû äåðåâà ê óêàçàííîìó ÷åëîâåêó, îòìå÷àÿ ïî ïóòè ÿâíûé êîíòðîëü äîñòóïà äëÿ òîãî ìåñòà. Êîãäà ìû äîñòèãàåì íóæíîãî ÷åëîâåêà, ïîëó÷àåì êîíêðåòíûé óðîâåíü äîñòóïà êîòîðûé è ÿâëÿåòñÿ êîíå÷íûì ðåçóëüòàòîì äëÿ âîçâðàùåíèÿ. Òàêèì îáðàçîì ìû îñóùåñòâëÿåì êîíòðîëü äîñòóïà äëÿ ãðóïï, ëþäåé, íî èìååì âîçìîæíîñòü ðàñøèðÿòü ýòè óðîâíè åñëè íóæíî.
+Ïðèìåð 1. Ìû ñïðàøèâàåì: Èìååò ëè Ëþê äîñòóï ê ïàññàæèðñêîìó çàëó?”
+óñòàíàâëèâàåì ïðàâèëî ïî óìîë÷àíèþ DENY (çàïðåòèòü);
+äâèãàåìñÿ ïî äåðåâó ê Ëþêó: Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ -> Ïàññàæèðû -> Äæåäàè -> Ëþê;
+íà÷èíàåì ñ âåðøèíû äåðåâà è äâèãàåìñÿ ê Ëþêó: “óçåë” “Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ” íå ãîâîðèò íè íè÷åãî íå îá îäíîì èç ACO. Îñòàâëÿåì DENY (çàïðåò);
+èäåì äàëüøå, “Ïàññàæèðû” - ÿâíî ãîâîðèò, ÷òî “Ïàññàæèðû” èìåþò äîñòóï ê “ïàññàæèðñêîìó çàëó”. Ìåíÿåì âíóòðåííèé ðåçóëüòàò íà “ALLOW” (ðàçðåøèòü);
+äâèãàåìñÿ â óçåë “Äæåäàè” - îí íå óïîìèíàåò “ïàññàæèðñêîãî çàëà” âîîáùå – îñòàâëÿåì ïðåäûäóùèé ðåçóëüòàò;
+äâèãàåìñÿ â óçåë “Ëþê” - ñíîâà íåò íè÷åãî î “ïàññàæèðñêîì çàëå” - îñòàâëÿåì ïðåäûäóùèé ðåçóëüòàò;
+èäòè äàëüøå íåêóäà – îñòàíàâëèâàåìñÿ. Âîçâðàùàåìûé ðåçóëüòàò áóäåò “ALLOW” (ðàçðåøèòü).
+Ïðèìåð 2. Ìû ñïðàøèâàåì: “Èìååò ëè ×óâè äîñòóï â ìàøèííûé çàë?”
+óñòàíàâëèâàåì ïðàâèëî ïî óìîë÷àíèþ DENY (çàïðåòèòü);
+äâèãàåìñÿ ïî äåðåâó ê ×óâè: Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ -> Êîìàíäà -> ×óâè;
+íà÷èíàåì ñ âåðøèíû äåðåâà è äâèãàåìñÿ ê ×óâè: “óçåë” “Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ” íå ãîâîðèò íè íè÷åãî íå îá îäíîì èç ACO. Îñòàâëÿåì DENY (çàïðåò);
+èäåì äàëüøå â óçåë “Êîìàíäà” - ÿâíî ãîâîðèò íàì - “Êîìàíäà” èìååò äîñòóï ê “ìàøèííîìó çàëó” - ìåíÿåì âíóòðåííèé ðåçóëüòàò íà “ALLOW” (ðàçðåøèòü);
+äâèãàåìñÿ â óçåë “×óâè” - åñòü ÿâíîå çàïðåùåíèå, êîòîðîå ãîâîðèò íàì, ÷òî äîñòóï â “ìàøèííûé çàë” çàêðûò. Ìåíÿåì âíóòðåííèé ðåçóëüòàò íà “DENY” (çàïðåòèòü);
+èäòè äàëüøå íåêóäà, âîçâðàùàåì ðåçóëüòàò “DENY” (çàïðåòèòü).
+Âû ìîæåòå âèäåòü, ÷òî åñëè ãðóïïà ÿâíî íå îïðåäåëÿåò íèêàêèõ ïðàâ, òî îíà íàñëåäóåò èõ îò ðîäèòåëüñêîé ãðóïïû (ïðåäûäóùåé).Åñëè óçåë êîðíÿ (“Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ”) íå îïðåäåëÿåò íèêàêèõ ðàçðåøåíèé, òî îí íàñëåäóåò ðàçðåøåíèÿ ïî óìîë÷àíèþ.  äàííîì ñëó÷àå “DENY ALL” (çàïðåòèòü âñå).
+Ýòî ïîäðàçóìåâàåò íåñêîëüêî èíòåðåñíûõ ìîìåíòîâ îá ARO-äåðåâå:
+ARO-äåðåâî âñåãäà ïîêàçûâàåò ïîëíûé ñïèñîê AROs. Ïîýòîìó íå èìååò ñìûñë ñïðàøèâàòü, èìååò ëè äîñòóï ê êàáèíå Äæàááà, ïîñêîëüêó îí íå áûë îïðåäåëåí â ñèñòåìå. Îäíàêî, phpGACL íå ïðîâåðÿåò ñóùåñòâóåò ëè ARO èëè ACO ïåðåä âûïîëíåíèåì ïðîâåðêè. Òàê, åñëè áû òàêîé âîïðîñ äåéñòâèòåëüíî èìåë áû ìåñòî, îòâåò òûë áû “DENY” (çàïðåòèòü);
+ARO-äåðåâî ìîæåò íå ïîêàçûâàòü íåêîòîðûå îïðåäåëåíèÿ ACO åñëè îíè ñïåöèàëüíî íå îïðåäåëåíû â ARO-äåðåâå. Íàïðèìåð, Õàí îïðåäåëèë ACO “âàííàÿ êîìíàòà”. Ëþáîé âîïðîñ, ïîäîáíûé ýòîìó: “èìååò ëè Ëþê äîñòóï â âàííóþ êîìíàòó?”, äàñò îòðèöàòåëüíûé îòâåò “DENY” (çàïðåùåíî), ïîñêîëüêó íèãäå â ARO-äåðåâå “âàííàÿ êîìíàòà” íå óïîìèíàåòñÿ. Èìåéòå ââèäó, ïðè èññëåäîâàíèè ARO-äåðåâà, íåêîòîðûå ACO ìîãóò áûòü íå âèäèìûìè.
+Îáðàòèòå âíèìàíèå: ïðè âûÿñíåíèè ÷åðåç phpGACL âîïðîñîâ î äîñòóïå íåâîçìîæíî èñïîëüçîâàòü Ãðóïïû êàê AROs (äàæå ïðè òîì, ÷òî ýòî ìîæåò êàçàòüñÿ ïðàâèëüíûì). Íàïðèìåð, íåâîçìîæíî îòâåòèòü íà âîïðîñ “Êàêèå ïàññàæèðû èìåþò äîñòóï ê îðóæèþ?” Ïîëíûé îòâåò íå Boolean (íå Áóëåâûé) – DENY / ALLOW (îòðèöàþ / ïîçâîëÿþ), à áîëåå ñëîæíûé “Ëþê è Îáè-Âàí ìîãóò, à R2D2 è Ñ3PO íåò”. PhpGACL íå ïðåäíàçíà÷åí äëÿ òàêîãî âèäà îòâåòîâ.
+Äîáàâëåíèå ãðóïï
+Õàí âèäèò, ÷òî ACL íà÷èíàåò âûãëÿäåòü î÷åíü ñëîæíî. Åñòü î÷åíü ìíîãî èñêëþ÷åíèé. Âîçìîæíî, ñëåäóåò ñäåëàòü ïîäðóãîìó, íàïðèìåð, ñîçäàòü íîâóþ ãðóïïó “Èíæåíåðû”, êîòîðàÿ áóäåò ñîäåðæàòü ëþäåé, êîòîðûì ïîçâîëåí äîñòóï â ìàøèííîå îòäåëåíèå è îðóæèþ. Ýòà ãðóïïà äîëæíà ñîäåðæàòü Õàíà è R2D2, òàê êàê îíè ìîãóò âîññòàíîâèòü äâèãàòåëü è îðóæèå. Ýòî ïîçâîëÿåò Õàíó óäàëèòü íåêîòîðûå èç “ãðÿçíûõ” ïðàâèë-èñêëþ÷åíèé, ýòî äàåò îïðåäåëåííóþ âûãîäó â òîì, ÷òî äàåò ÿñíîå îïèñàíèå:
+Ïî óìîë÷àíèþ: [DENY: ALL] (çàïðåòèòü: âñå)
+Ïàññàæèðû Ñîêîëà òûñÿ÷èëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+? ??Äæåäàè [ALLOW: Cockpit] (ðàçðåøèòü: êàáèíó)
+? ? ??Îáè-Âàí
+? ? ??Ëþê [ALLOW: Guns] (ðàçðåøèòü: îðóæèå)
+? ??R2D2
+? ??C3PO
+??Èíæåíåðû [ALLOW: Engines, Guns] (ðàçðåøèòü: ìàø.çàë, îðóæèå)
+ ??Õàí
+ ??R2D2
+Âû ìîæåòå ïðî÷èòàòü ýòî ñëåäóþùèì îáðàçîì: ïî óìîë÷àíèþ íèêòî íèêóäà íå èìååò ïðàâî çàõîäèòü, êîìàíäà èìååò äîñòóï âñþäó (êðîìå ×óâè, îí íå èìååò äîñòóïà â ìàøèííîå îòäåëåíèå). Ïàññàæèðû èìåþò äîñòóï òîëüêî ê ïàññàæèðñêîìó çàëó, êðîìå Äæåäàåâ, îíè èìåþò äîñòóï ê êàáèíå. Ëþê òàêæå èìååò äîñòóï ê îðóæèþ. Èíæåíåðû èìåþò äîñòóï ê îðóæèþ è ìàøèííîìó îòäåëåíèþ.
+Íàèáîëåå âàæíî, ìû ìîæåì âèäåòü, ÷òî Õàí è R2D2 íàõîäÿòñÿ òåïåðü â äâóõ ìåñòàõ ACL. Èì íåò íåîáõîäèìîñòè áûòü óíèêàëüíûìè. Ýòî äåëàåò ïîëèòèêè áîëåå ÿñíûìè äëÿ ÷èòàòåëÿ: “Àõ, Õàí è R2D2 èìåþò äîñòóï ê îðóæèþ è ìàøèííîìó çàëó, ïîòîìó ÷òî îíè èíæåíåðû”.
+Äîáàâëåíèå ëþäåé
+Õàí èäåò â Ãîðîä îáëàêîâ, ÷òîáû ïîâèäàòü Ëàíäî è ñäåëàòü íåêîòîðûé ðåìîíò. Ëàíäî – ïðåäûäóùèé õîçÿèí Ñîêîëà òûñÿ÷åëåòèÿ, Õàí ïðåäïîëàãàåò îòíåñòè åãî ê ãðóïïå “Êîìàíäà”. Ëàíäî òàê æå ïðåäëàãàåò óñëóãè ñâîåãî ãëàâíîãî èíæåíåðà Õîíòóêà, äëÿ ïîìîùè â âîññòàíîâëåíèè ñóäíà, ïîêà îíî íàõîäèòñÿ â äîêå.
+Ïî óìîë÷àíèþ: [DENY: ALL] (çàïðåòèòü: âñå)
+Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+? ??Ëàíäî
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+? ??Äæåäàè [ALLOW: Cockpit] (ðàçðåøèòü: êàáèíà)
+? ? ??Îáè-Âàí
+? ? ??Ëþê [ALLOW: Guns] (ðàçðåøèòü: îðóæèå)
+? ??R2D2
+? ??C3PO
+??Èíæåíåðû [ALLOW: Engines, Guns] (ðàçðåøèòü: ìàø.çàë, îðóæèå)
+ ??Õàí
+ ??R2D2
+ ??Õàíòóê
+Ýòî äåðåâî ïîêàçûâàåò êàê ëåãêî ìîæíî ïðåäîñòàâëÿòü äîñòóï íîâûì ëþäÿì. Åñëè áû ìû èñïîëüçîâàëè ïåðâîíà÷àëüíóþ ìàòðè÷íóþ ñõåìó, ìû äîëæíû áûëè áû óñòàíîâèòü ðàçðåøåíèÿ äëÿ êàæäîãî ìåñòà íà êîðàáëå è äëÿ Õàíóêà è äëÿ Ëàíäî. Âìåñòî ýòîãî, ìû ïðîñòî äîáàâëÿåì èõ ê íóæíûì ãðóïïàì, â ðåçóëüòàòå ÷åãî, èõ äîñòóï íåÿâíî è ëåãêî îïðåäåëåí.
+Óñòðàíåíèå êîíôëèêòîâ
+×òî ñëó÷èòñÿ, åñëè ìû äîáàâèì ×óâè ê ñïèñêó èíæåíåðîâ?
+Ïî óìîë÷àíèþ: [DENY: ALL] (çàïðåòèòü: âñå)
+Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ
+??Êîìàíäà [ALLOW: ALL] (ðàçðåøèòü: âñå)
+? ??Õàí
+? ??×óâè [DENY: Engines] (çàïðåòèòü: ìàøèííûé çàë)
+? ??Ëàíäî
+??Ïàññàæèðû [ALLOW: Lounge] (ðàçðåøèòü: ïàññàæèðñêèé çàë)
+? ??Äæåäàè [ALLOW: Cockpit] (ðàçðåøèòü: êàáèíà)
+? ? ??Îáè-Âàí
+? ? ??Ëþê [ALLOW: Guns] (ðàçðåøèòü: îðóæèå)
+? ??R2D2
+? ??C3PO
+??Èíæåíåðû [ALLOW: Engines, Guns] (ðàçðåøèòü: ìàø.çàë, îðóæèå)
+ ??Õàí
+ ??R2D2
+ ??Õàíóê
+ ??×óâè
+Ýòî äåëàåò äîñòóï ×óâè ê ìàøèííîìó çàëó íåîäíîçíà÷íûì, ïîòîìó ÷òî òåïåðü åñòü äâå äîðîæêè îò êîðíÿ äåðåâà äî ×óâè. Åñëè êîìïüþòåð ïîñëåäóåò ïî îäíîé äîðîæêå, òî ðåçóëüòàò áóäåò “DENY” (çàïðåùàþ), à åñëè îí ïîñëåäóåò çà äðóãîé äîðîæêîé, òî ðåçóëüòàò áóäåò “ALLOW” (ðàçðåøàþ). Òàê âñå æå, åìó çàïðåùåí èëè ðàçðåøåí äîñòóï?
+PhpGACL ïðåäóïðåäèò âàñ, åñëè âû ñãðóïïèðóåòå ARO òàêèì îáðàçîì, ÷òî äîñòóï ARO ê ïðîèçâîëüíîìó ACO áóäåò íåîäíîçíà÷íûì. Íî ðåøàòü êîíôëèêò ïðèäåòñÿ âàì.
+Åñëè ïðè òàêîé íåîäíîçíà÷íîñòè ñïðîñèòü êîìïüþòåð “Èìååò ëè ×óâè äîñòóï ê ìàøèííîìó çàëó?”, òî îòâåò áóäåò “ALLOW” (ðàçðåøàþ), ïîòîìó ÷òî ñèñòåìà âåðíåò âàì ïîñëåäíèé èçìåíåííûé ïàðàìåòð (ýòî ïîëèòèêà phpGACL).  ýòîì ñëó÷àå ðåçóëüòàò “ALLOW”, ïîòîìó ÷òî ðàçðåøåíèå “ALLOW: Engines, Guns” (ðàçðåøèòü: ìàøèííûé çàë, îðóæèå), íàçíà÷åííîå íà ãðóïïó “Èíæåíåðû”, ÿâëÿåòñÿ áîëåå ñâåæèì, ïî ñðàâíåíèþ ñ “DENY: Engines” (çàïðåòèòü: ìàøèííûé çàë) ãðóïïû “×óâè”.
+ ñëó÷àå, åñëè ACL ñîäåðæèò íåîäíîçíà÷íîñòè, òàêóþ ACL íàçûâàþò íåïîñëåäîâàòåëüíîé. Íåïîñëåäîâàòåëüíàÿ ACL ìîæåò áûòü î÷åíü îïàñíà, âû ìîæåòå íåâîëüíî îáåñïå÷èòü äîñòóï íåñîîòâåòñòâóþùèì ëþäÿì. Êîãäà phpGACL ïðåäóïðåæäàåò âàñ î òîì, ÷òî ACL íåïîñëåäîâàòåëüíà, ðàçðåøèòå êîíôëèêò êàê ìîæíî áîëåå îïåðàòèâíî, ÷òîáû ñðàçó âîññòàíîâèòü ïîñëåäîâàòåëüíîñòü.
+×òîáû ðåøèòü êîíôëèêò, âû ìîãëè ñäåëàòü ñëåäóþùåå:
+óäàëèòü äåðåêòèâó “DENY: Engines” ó ãðóïïû “×óâè” â ãðóïïå “Êîìàíäà”;
+äîáàâèòü äåðåêòèâó “DENY: Engines” ó ãðóïïû “×óâè” â ãðóïïå “Èíæåíåðû”;
+óäàëèòü ×óâè èç ãðóïïû “Èíæåíåðû”, òàê êàê Õàí âñåðàâíî íå ñ÷èòàåò åãî äîñòîéíûì èíæåíåðîì.
+Õà âûáðàë ïîñëåäíèé âàðèàíò, îí óäàëèë ×óâè èç ãðóïïû “Èíæåíåðû”.
+Îáîçíà÷åíèå îáúåêòîâ äîñòóïà
+phpGACL óíèêàëüíî èäåíòèôèöèðóåò êàæäûé îáúåêò äîñòóïà (ARO, AXO, ACO) êîìáèíàöèåé èõ äâóõ êëþ÷åâûõ ñëîâ è èõ òèïà îáúåêòà äîñòóïà.
+Êîðòåæ “(Òèï îáúåêòà äîñòóïà, Ðàçäåë, Çíà÷åíèå)” óíèêàëüíî èäåíòèôèöèðóåò ëþáîé îáúåêò äîñòóïà.
+Ïåðâûé ýëåìåíò êîðòåæà – òèï îáúåêòà äîñòóïà (ARO, AXO, ACO).
+Âòîðîé ýëåìåíò êîðòåæà, íàçâàííûé Ðàçäåëîì, ÿâëÿåòñÿ, çàäàííîé ïîëüçîâàòåëåì, ñòðîêîé, êîòîðàÿ íàçûâàåò îáùóþ êàòåãîðèþ îáúåêòà äîñòóïà. Îáúåêòû ñ íåñêîëüêèìè äîñòóïàìè ìîãóò èìåòü òîæå ñàìîå íàçâàíèå Ðàçäåëà. Íàçâàíèå ðàçäåëà äîëæíî áûòü êîðîòêîå, íî îïèñàòåëüíîå (íàãëÿäíîå). Ýòî èñïîëüçóåòñÿ â ïîëüçîâàòåëüñêîì èíòåðôåéñå â ñïèñêàõ âûáîðà, ïîýòîìó ëîãè÷íî íå äåëàòü èõ ñëèøêîì äëèííûìè.
+Ðàçäåëû ñîõðàíÿþòñÿ â ÿ÷åéêå namespace. Ðàçäåëû íå èìåþò íèêàêîãî îòíîøåíèÿ ê ãðóïïàì èëè ARO / AXO-äåðåâüÿì – îíè ïðîñòî ìåõàíèçì, äëÿ òîãî ÷òîáû ïîìî÷ü ïîääåðæèâàòü áîëüøåå êîëè÷åñòâî îáúåêòîâ äîñòóïà.
+Òðåòèé ýëåìåíò êîðòåæà – îïðåäåëåííîå ïîëüçîâàòåëåì, íàçâàíèå äëÿ îáúåêòà äîñòóïà, è íàçûâàåòñÿ Çíà÷åíèå. Çíà÷åíèå íå ìîæåò ñîäåðæàòü ïðîáåëû (îäíàêî, Ðàçäåë – ìîæåò).
+Íàçâàíèÿ Ðàçäåëîâ è Çíà÷åíèå ðåãèñòðîçàâèñèìû.
+Ïðèìå÷àíèå: îáû÷íî ñïðàøèâàþò, ïî÷åìó äëÿ èäåíòèôèêàöèè îáúåêòîâ äîñòóïà èñïîëüçóþòñÿ ñòðîêè à íå öåëûå ÷èñëà, êîòîðûå, ÿêîáû, êàæóòñÿ áûñòðåå. Îòâåò – äëÿ ÿñíîñòè. Íà ìíîãî áîëåå ëåãêî ïîíÿòü:
+acl_check('system', 'login', 'user', 'john_doe'); ÷åì:
+acl_check(10, 21004, 15, 20304);
+Òàê êàê èç êîíòåêñòà ÷àñòî î÷åâèäíî ê êàêîìó òèïó îáúåêòà äîñòóïà ìû îáðàùàåìñÿ, èíòåðôåéñ äëÿ phpGACL (è ýòà äîêóìåíòàöèÿ) îïóñêàåò òèï îáúåêòà äîñòóïà è èñïîëüçóåò ôîðìàò “Ðàçäåë -> Çíà÷åíèå” äëÿ ïîêàçà îáúåêòà äîñòóïà. Îäíàêî, ïðîãðàììíûé èíòåðôåéñ ïðèëîæåíèÿ òðåáóåò “Ðàçäåë” îáúåêòà äîñòóïà è “Çíà÷åíèå”, êîòîðûå äîëæíû áûòü îïðåäåëåíû â îòäåëüíûõ àðãóìåíòàõ ôóíêöèè (òèï îáúåêòà äîñòóïà îáû÷íî íåÿâåí â îïèñàíèè àðãóìåíòà).
+Ïðèìåð ACO “Ðàçäåë -> Çíà÷åíèå”:
+“Floors -> 1st” (“Ýòàæè -> 1-é”);
+“Floors -> 2nd” (“Ýòàæè -> 2-é”);
+“Rooms -> Engines” (“Êîìíàòû -> ìàøèííûé_çàë”).
+Ïðèìåð ARO “Ðàçäåë -> Çíà÷åíèå”:
+“People -> John_Smith” (“Ëþäè -> Äæîí_Ñìèò”);
+“People -> Cathy_Jones” (“Ëþäè -> Êýòè_Äæîíñ”);
+“Hosts -> sandbox.something.com” (“Õîñòû -> sandbox.something.com”).
+Ïðèìåð èñïîëüçîâàíèÿ API:
+acl_check(aro_section, aro_value, aco_section, aco_value);
+acl_check('People', 'John_Smith', 'Floor', '2nd');
+Ïðèìåðû ïðàâèëüíîãî èìåíîâàíèÿ:
+“ACO - Frob > Flerg”, “ARO – Frob -> Flerg” (Ðàçäåë è Çíà÷åíèå ÿâëÿþòñÿ îäèíàêîâûìè, íî ýòî õîðîøî, ïîñêîëüêó namespaces ðàçíûå äëÿ ðàçíûõ òèïîâ îáúåêòîâ äîñòóïà);
+“ACO – Frob -> Flerg”, “ACO – Frob -> Queegle” (òèï îáúåêòà äîñòóïà è íàçâàíèå Ðàçäåëà îäèíàêîâûå, ýòî õîðîøî, ïîñêîëüêó ó íèõ ðàçíûå Çíà÷åíèÿ);
+“AXO – Frob Hrung -> Flerg” (Ðàçäåëû ìîãóò ñîäåðæàòü ïðîáåëû).
+Ïðèìåð íåïðàâèëüíîãî èìåíîâàíèÿ:
+“ACO – Frob -> Flerg”, “ACO – Frob -> Flerg” (òèï îáúåêòà äîñòóïà – Ðàçäåë -> Çíà÷åíèå äîëæíû áûòü óíèêàëüíûìè);
+“ACO – Frob -> Flerg Habit” (Çíà÷åíèå íå ìîæåò ñîäåðæàòü ïðîáåëîâ).
+Äîáàâëåíèå ðàçäåëîâ
+Ïðåæäå ÷åì äîáàâèòü íîâûé îáúåêò äîñòóïà âû äîëæíû ñîçäàòü Ðàçäåë. Äëÿ äîáàâëåíèÿ íîâîãî ðàçäåëà èñïîëüçóéòå ôóíêöèþ add_object_section().
+add_object_section(
+ string NAME, Êîðîòêîå îïèñàíèå òîãî, äëÿ ÷åãî ýòîò Ðàçäåë
+ èñïîëüçóåòñÿ (ïðèìåð, 'Levels in building'
+ (“Ýòàæè â çäàíèè”)).
+ string VALUE, Íàçâàíèå Ðàçäåëà (ïðèìåð, 'Floors' (“Ýòàæè”)).
+ int ORDER, Öåííîñòü ðàçäåëà, âëèÿåò íà òî, êàêèì ïî ñ÷åòó â ñïèñêå
+ â èíòåðôåéñå ïîëüçîâàòåëÿ ïîÿâèòñÿ ýòîò Ðàçäåë.
+ bool HIDDEN Ïîêàçûâàåò, äîëæåí ëè ýòîò ðàçäåë áûòü âèäåí â
+ ïîëüçîâàòåëüñêîì èíòåðôåéñå.
+ string GROUP_TYPE); Òèï îáúåêòà äîñòóïà (ACO, ARO, AXO).
+Õàí ñîçäàë 3 ðàçäåëà äëÿ AROs “Ëþäè”, “×óæèå” è “Àíäðîèäû” Äàâàéòå ïîñìîòðèì, êàê áóäåò âûãëÿäåòü AROs ñ èõ ïîëíûìè íàçâàíèÿìè:
+Ïàññàæèðû Ñîêîëà òûñÿ÷åëåòèÿ
+??Êîìàíäà [ALLOW: ALL]
+? ??"Ëþäè > Õàí"
+? ??"×óæèå > ×óâè" [DENY: Engines]
+? ??"Ëþäè > Ëàíäî"
+??Ïàññàæèðû [ALLOW: Lounge]
+? ??Äæåäàè [ALLOW: Cockpit]
+? ? ??"Ëþäè > Îáè-Âàí"
+? ? ??"Ëþäè > Ëþê" [ALLOW: Guns]
+? ??"Àíäðîèäû > R2D2"
+? ??"Àíäðîèäû > C3PO"
+??Èíæåíåðû [ALLOW: Engines, Guns]
+ ??"Ëþäè > Õàí"
+ ??"Àíäðîèäû > R2D2"
+ ??"×óæèå > Õàíòóê"
+Ðàçäåëû – òîëüêî ñïîñîá êàòåãîðèçèðîâàòü îáúåêòû äîñòóïà, ñäåëàòü ïîëüçîâàòåëüñêèé èíòåðôåéñ áîëåå ïðèãîäíûì ê èñïîëüçîâàíèþ, à òàê æå ñäåëàòü ôóíêöèþ acl_check() áîëåå ÷èòàåìîé. Îíè íå çàòðàãèâàþò ïóòü phpGACL äëÿ îïðåäåëåíèÿ ïðàâ îáúåêòà äîñòóïà. Òàêæå, ðàçäåëû íå ìîãóò áûòü âëîæåííûìè, òî åñòü âû íå ìîæåòå ñîçäàòü “Ìóæ÷èí” âíóòðè “Ëþäåé”. Âû äîëæíû áóäåòå ñîçäàòü ðàçäåë “Ëþäè ìóæñêîãî ïîëà” èëè ïîäîáíûé.
+Ìíîæåñòâî öåëåé
+Âîçìîæíî, âû áóäåòå èñïîëüçîâàòü phpGACL ñðàçó äëÿ íåñêîëüêèõ öåëåé, íàïðèìåð, îãðàíè÷èòü ïîëüçîâàòåëüñêèé äîñòóï ê ñòðàíèöàì, à òàê æå óäàëåííûé äîñòóï ê ñòðàíèöàì âàøåãî ñåðâåðà. Ýòè äâå çàäà÷è íå ñâÿçàíû.
+PhpGACL ïðåäëàãàåò ðåàëèçîâàòü ýòî òðåìÿ ðàçëè÷íûìè ïóòÿìè:
+âû ìîæåòå èñïîëüçîâàòü äîïîëíèòåëüíûå áàçû äàííûõ äëÿ õðàíåíèÿ ýòèõ äàííûõ;
+âû ìîæåòå èñïîëüçîâàòü òóæå ñàìóþ áàçó äàííûõ íî ñ äðóãèìè èìåíàìè òàáëèö (âñåæå, ýòà âîçìîæíîñòü ïîêà íå ïîääåðæèâàåòñÿ);
+âû ìîæåòå õðàíèòü îáúåêòû äîñòóïà â òåõ æå ñàìûõ òàáëèöàõ, è î÷åíü òùàòåëüíî óïðàâëÿòü èìè, òàê, ÷òîáû îíè íå âñòóïàëè â ïðîòèâîðå÷èÿ.
+×òîáû âûáðàòü ïåðâûé èëè âòîðîé ñïîñîá (êîãäà îí áóäåò äîñòóïåí) èñïîëüçóéòå ìàññèâ $gacl_options, êîãäà ñîçäàåòå íîâûé êëàññ phpGACL. Ýòî ïîçâîëèò âàì îïðåäåëèòü áàçó è ïðåôèêñ äëÿ òàáëèö:
+$gacl_options = array(
+ 'db_table_prefix' => 'gacl_',
+ 'db_type' => 'mysql',
+ 'db_host' => 'host1',
+ 'db_user' => 'user',
+ 'db_password' => 'passwd',
+ 'db_name' => 'gacl');
+
+$gacl_host1 = new gacl($gacl_options);
+Áóäüòå î÷åíü îñòîðîæíû, åñëè âû âûáåðèòå òðåòèé âàðèàíò, ïîñêîëüêó phpGACL íè÷åãî íå çíàåò îá îòíîøåíèÿõ ìåæäó âàøèìè çàäà÷àìè, à, ñëåäîâàòåëüíî, íå ñìîæåò êîíòðîëèðîâàòü ðàçëè÷íûå áåññìûñëåííûå äèðåêòèâû ïîëèòèêè äîñòóïà.
+Íàïðèìåð, Õàí ìîæåò ðåøèòü çàïðåòèòü äîñòóï êîðàáëÿì, êîòîðûå âñòóïàþò â êîíòàêò ñ åãî êîìïüþòåðîì, ê êàêèì-ëèáî êîìíàòàì íà êîðàáëå. Äëÿ ýòîãî îí ìîæåò ñîçäàòü “Êîðàáëü Ëþêà” êàê âíåøíèé êîðàáëü ARO â ýòîì æå ñàìîì ARO-äåðåâå.  ðåçóëüòàòå ÷åãî, ñòàíåò âîçìîæíûì ñîçäàòü APD (ïðàâèëî àâòîìàòè÷åñêîé îáðàáîòêè): “Êîðàáëè -> Êîðàáëü Ëþêà” è íàçíà÷èòü åìó ïðàâà “ALLOW (ðàçðåøèòü): “Êîìíàòû -> ïàññàæèðñêèé çàë”. Ñîãëàñèòåñü, ýòî ïîëíîñòüþ áåññìûñëåííî! ×òîáû ïîìî÷ü â ðàçðåøåíèè òàêèõ ïðîòèâîðå÷èé, äàâàéòå ïðàâèëüíîå (èíôîðìàòèâíîå) íàçâàíèå Ðàçäåëàì, ÷òîáû îíè ÷åòêî äàâàëè ïîíÿòü, ÷åì íà ñàìîì äåëå ÿâëÿåòñÿ îáúåêò äîñòóïà è äëÿ êàêèõ çàäà÷ èñïîëüçóþòñÿ. Ýòî äîëæíî áûòü î÷åâèäíî äëÿ ëþáîãî àäìèíèñòðàòîðà, ÷òî áåññìûñëåííî íàçíà÷àòü ðàçðåøåíèÿ êîðàáëÿì äëÿ äîñòóïà â êàêóþ-ëèáî êîìíàòó.
+Îáúåêòû ðàñøèðåíèÿ äîñòóïà (AXO)
+Îáúåêòû ðàñøèðåíèÿ äîñòóïà ìîãóò äîáàâëÿòü òðåòüå èçìåðåíèå ê ðàçðåøåíèÿì, êîòîðûå ìîãóò ôîðìèðîâàòüñÿ â phpGACL. Ìû ñ âàìè âèäåëè, êàê phpGACL ïîçâîëÿåò êîìáèíèðîâàòü îáúåêòû ARO è ACO (2 èçìåðåíèÿ) äëÿ ñîçäàíèÿ ïîëèòèêè äîñòóïà. Ýòî î÷åíü õîðîøî äëÿ ïðîñòûõ ðàçðåøåíèé, íàïðèìåð:
+Ëþê (ARO) ïðîñèò ðàçðåøåíèå íà äîñòóï ê Îðóæèþ (ACO).
+Åñëè ýòî âñå, ÷åãî âû õîòèòå, ïðåêðàñíî – AXO ÿâëÿåòñÿ ïîëíîñòüþ äîïîëíèòåëüíûì (òî åñòü ìîæåò îòñóòñòâîâàòü).
+Íî, ïîñêîëüêó âñå ACOs ÿâëÿþòñÿ ðàâíûìè, ýòî ìåøàåò ñïðàâëÿòüñÿ ñ íèìè åñëè èõ î÷åíü ìíîãî. Åñëè ýòî òàê, òî ìû ìîæåì èçìåíèòü ñïîñîá, êîòîðûì ìû ñìîòðèì íà îáúåêòû äîñòóïà, äëÿ áîëåå ëåãêîãî óïðàâëåíèÿ èìè.
+AXOs èäåíòè÷íû AROs âî ìíîãèõ îòíîøåíèÿõ. Åñòü äåðåâî AXO (îòäåëüíîå îò äåðåâà ARO), ñî ñâîèìè ñîáñòâåííûìè Ãðóïïàìè è AXOs. Êîãäà âû áóäåòå èìåòü äåëî ñ AXO, äóìàéòå, ÷òî AXO áåðåò íà ñåáÿ ñòàðóþ ðîëü ACO (òî åñòü ÿâëÿåòñÿ “âåùàìè, ê êîòîðûì òðåáóåòñÿ äîñòóï”), è èçìåíÿþò ïðåäñòàâëåíèå ACOs ñ “âåùè, ê êîòîðûì òðåáóåòñÿ äîñòóï” íà “äåéñòâèå, êîòîðîå òðåáóåòñÿ ñîâåðøèòü”.
+Ïîñìîòðèì òîëüêî íà ARO è ACO:
+ARO – âåùè, ïðîñÿùèå äîñòóï;
+ACO – âåùè, ê êîòîðûì íóæåí äîñòóï.
+Ïîñìîòðèì íà ARO, ACO è AXO:
+ARO – âåùè, êîòîðûå ïðîñÿò äîñòóï;
+ACO – äåéñòâèÿ, êîòîðûå òðåáóåòñÿ ñîâåðøèòü
+AXO – âåùè, ê êîòîðûì íóæåí äîñòóï.
+Ïðèìåð:
+Ìåíåäæåð ñàéòà ïûòàåòñÿ óïðàâëÿòü äîñòóïîì ê ïðîåêòàì íà âåáñàéòå. Äåðåâî ARO ñîñòîèò èç âñåõ ïîëüçîâàòåëåé:
+Âåáñàéò
+??Àäìèíèñòðàòîðû
+? ??Ýëèñ
+? ??Êýðîë
+??Ïîëüçîâàòåëè
+ ??Áîá
+ ??Àëàí
+Ïðîåêòû îðãàíèçîâàíû ïî ïðèíöèïó èñïîëüçóåìîé îïåðàöèîííîé ñèñòåìû â Ãðóïïàõ AXO:
+Ïðîåêòû
+??Linux
+? ??SpamFilter2
+? ??AutoLinusWorshipper
+??Windows
+ ??PaperclipKiller
+ ??PopupStopper
+Äåéñòâèÿ, êîòîðû ìîãóò âûïîëíÿòüñÿ íàä êàæäûì îáúåêòîì - “Ïðîñìîòð” è “Ðåäàêòèðîâàíèå” - ýòî ACOs.
+È òàê, ìû õîòèì, ÷òîáû Áîá èìåë âîçìîæíîñòü ïðîñìîòðà âñåõ ïðîåêòîâ Linux. Ýòî âîçìîæíî ïðè ïîìîùè äîáàâëåíèÿ ADP (àâòîìàòè÷åñêîé îáðàáîòêè) ñâÿçêè ARO Áîáà ñ ACO “Ïðîñìîòð” è AXO Linux. Òåïåðü ìû ìîæåì çàäàòü âîïðîñ:
+“Áîá” (ARO) ïðîñèò äåéñòâèÿ “Ïðîñìîòð” (ACO) äëÿ ïðîåêòà “Linux” (AXO).
+Îáðàùàþ âàøå âíèìàíèå íà òî, ÷òî AXO ÿâëÿåòñÿ äîïîëíèòåëüíûì, åñëè âû íå îïðåäåëèòå AXO, âûçûâàÿ acl_check(), òî ADP (àâòîìàòè÷åñêàÿ îáðàáîòêà) îñóùåñòâèòñÿ áåç ó÷åòà AXO. Îäíàêî, åñëè APD (àâòîìàòè÷åñêàÿ îáðàáîòêà) ñóùåñòâóåò òîëüêî ñ AXO, à âû âûçîâèòå acl_check() áåç óêàçàíèÿ AXO, âû ïîòåðïèòå íåóäà÷ó.
+È òàê, åñëè âû ïðè âûçîâå acl_check() îïðåäåëÿåòå AXO, òî ýòà ôóíêöèÿ áóäåò èñêàòü â ACL òîëüêî ñîäåðæàíèå AXO. Åñëè íèêàêîé AXO íå îïðåäåëåí, òîëüêî áóäåò ðàññìîòðåíû òîëüêî ACL. Ýòî (â òåîðèè) äàåò íàì íåáîëüøîå óâåëè÷åíèå ñêîðîñòè ðàáîòû.
+
+
+
+
+Èíñòàëëÿöèÿ
+Áàçîâàÿ íàñòðîéêà
+1.Ðàñïàêóéòå àðõèâ äèñòðèáóòèâà â êîðåíü èëè íóæíóþ âàì ïàïêó ñàéòà. Âîçìîæíî, âû çàõîòèòå ïåðåèìåíîâàòü åå âî ÷òî-òî áîëåå ïîäõîäÿùåå.
+
+2.Ðåäàêòèðóéòå ôàéë phpgacl/gacl.class.php. Óñòàíîâèòå db_type, db_host, db_user, db_password è db_name, êîòîðûå âû ïðåäïîëàãàåòå èñïîëüçîâàòü.
+
+Òåïåðü íåîáõîäèìî îòðåäàêòèðîâàòü phpgacl/admin/gacl_admin.inc.php, âíåñÿ â íåãî òóæå ñàìóþ èíôîðìàöèþ. Ýòîò ôàéë íóæåí äëÿ àäìèíèñòðàòèâíîé ÷àñòè ñêðèïòà.
+Ïðè÷èíà, ïî÷åìó íåîáõîäèìî äâàæäû ââåñòè îäèíàêîâûå äàííûå, çàêëþ÷àåòñÿ â òîì, ÷òî êëàññ gacl.calss.php íàìíîãî ìåíüøå ïî îáúåìó, ÷åì âåñü ïðîãðàììíûé èíòåðôåéñ. È íåò íåîáõîäèìîñòè òÿíóòü çà ñîáîé âñå ñêðèïòû, åñëè âàì âñåãî ëèøü íåîáõîäèìî âûçâàòü ôóíêöèþ acl_check().
+3.Ñîçäàéòå áàçó äàííûõ ñ èìåíåì, êîòîðîå âû çàäàëè â db_name.
+4.Çàïóñòèòå http://your_site.net/phpgacl/setup.php. Ýòîò ñêðèïò ñîçäàñò íåîáõîäèìûå òàáëèöû. Íå áîéòåñü ñëîæíîé èíôîðìàöèè, ñêðèïò ïîêàæåò âàì òîëüêî ñîîáùåíèÿ îá óñïåøíîé ðàáîòå.
+
+5.Ñëåäóÿ çàìå÷åíèþ íà êàðòèíêå (Ïåðåâîä çàìå÷àíèÿ íà êàðòèíêå: Ïîæàëóéñòà, ñîçäàéòå äèðåêòîðèþ /admin/templates_c è óñòàíîâèòå íà íåå ïðàâà äîñòóïà. Íàæìèòå “Go here!” äëÿ íà÷àëà ðàáîòû), ñîçäàéòå íåîáõîäèìóþ äèðåêòîðèþ. Ïðàâà äîñòóïà äîëæíû ïîçâîëÿòü çàïèñü â ýòó äèðåêòîðèþ.
+6.Íàæìèòå íà “Go here!” è âû ïåðåíåñåòåñü ñþäà: http://your_site.net/admin/acl_admin.php.
+Äîïîëíèòåëüíûå íàñòðîéêè
+Åñëè âû óæå èñïîëüçóåòå ADOdb â ñâîèõ ñêðèïòàõ, òî âû ìîæåòå óêàçàòü phpGACL èñïîëüçîâàòü óæå èìåþùóþñÿ óñòàíîâêó:
+1.Îòðåäàêòèðóéòå phpgacl/gacl.class.php ïåðåìåííóþ ADODB_DIR, óêàçàâ â íåé ïóòü ê óñòàíîâëåííîé áèáëèîòåêå.
+2.Ïåðåèìåíóéòå äèðåêòîðèþ phpgacl/adodb â êàêóþ-íèáóäü äðóãóþ, íàïðèìåð adodb_x è ïåðåçàïóñòèòå phpgacl/admin/acl_admin.php äëÿ ïðîñìîòðà èçìåíåíèé.
+3.Óäàëèòå äèðåêòîðèþ adodb, óñòàíîâëåííóþ âìåñòå ñ phpGACL.
+Åñëè âû óæå èñïîëüçóåòå Smarty â ñâîèõ ñêðèïòàõ, òî âû ìîæåòå óêàçàòü phpGACL èñïîëüçîâàòü óæå èìåþùóþñÿ óñòàíîâêó:
+1.Îòðåäàêòèðóéòå ñêðèïò phpgacl/admin/gacl_admin.inc.php, óñòàíîâèâ íåì ñëåäóþùèå ïåðåìåííûå: $smarty_dir è $smarty_compile_dir, ÷òîáû îíè óêàçûâàëè íà êàòàëîã, ãäå ó âàñ óæå óñòàíîâëåí Smarty. Ïåðåìåñòèòå äèðåêòîðèþ ñ øàáëîíàìè phpGACL â äðóãóþ äèðåêòîðèþ (íàïðèìåð â òó, êîòîðóþ âû íà äàííûé ìîìåíò óæå èñïîëüçóåòå).
+2.Ïåðåèìåíóéòå ïàïêó phpgacl/smarty â äðóãóþ, íàïðèìåð smarty_x. È ïåðåçàïóñòèòå phpgacl/admin/acl_admin.php äëÿ ïðîñìîòðà èçìåíåíèé.
+3.Óäàëèòå ïàïêó smarty èíñòàëëÿöèè phpGACL.
+Êàê ìîæíî ïåðåìåñòèòü phpGACL ôàéëû èç ìîåãî äåðåâà âåáñàéòà ñ ñîõðàíåíèåì ñâÿçåé ñ äåðåâîì äëÿ àäìèíèñòðèðîâàíèÿ?
+1.Ïåðåéäèòå â êîðåíü âàøåãî âåáñàéòà.
+2.Ïåðåìåñòèòå äèðåêòîðèþ phpGACL â íåîáõîäèìóþ âàì äèðåêòîðèþ è ñîçäàéòå ñèìëèíê (ññûëêó) íà àäìèíèñòðàòèâíóþ äèðåêòîðèþ òàì, ãäå âû õîòèòå åãî çàïóñêàòü.
+mv phpgacl/ /www/includes_directory
+ln -s /www/includes_directory/phpgacl/admin/ gacl
+3.Òåïåðü ïîïðîáóéòå çàïóñòèòü phpgacl. Åñëè îí íå ñòàë ðàáîòàòü, òî, âîçìîæíî, âàø ñàéò íå ïîääåðæèâàåò ñèìëèíêè( ññûëêè).
+
+
+
+
+
+
+
+Èñïîëüçîâàíèå phpGACL â âàøåé ïðîãðàììå
+Áàçîâîå èñïîëüçîâàíèå
+Ýòîò ïðèìåð ïîêàçûâàåò îñíîâíîé ñïîñîá èñïîëüçîâàíèÿ phpGACL â âàøåé ïðîãðàììå. Îí òàê æå ïîêàçûâàåò èñïîëüçîâàíèå àáñòðàêòíîãî êëàññà äëÿ äîñòóïà ê áàçàì äàííûõ ADOdb. Ïðèìåð èëëþñòðèðóåò ïðîñòîé ñïîñîá ïðîâåðêè ëîãèíà è ïàðîëÿ.
+// Ïîäêëþ÷àåì áàçîâûé API
+include('phpgacl/gacl.class.php');
+$gacl = new gacl();
+$username = $db->quote($_POST['username']);
+$password = $db->quote(md5($_POST['password']));
+$sql = 'SELECT name FROM users WHERE name=';
+$sql .= $username.' AND password='.$password;
+$row = $db->GetRow($sql);
+if($gacl->acl_check('system','login','user',$row['name'])){
+ $_SESSION['username'] = $row['name'];
+ return true;
+}
+else
+ return false;
+Âû âèäåòå òîëüêî îäèí âûçîâ acl_check(), ÷òî æå îí îçíà÷àåò?
+Ïðîâåðÿåò ARO-îáúåêò $row['name'] â ARO-ðàçäåëå 'user'.
+À òàêæå ACO-îáúåêò 'login' â ACO-ðàçäåëå 'system'.
+
+
+
+
+
+
+
+
+
+Ïðîôåññèîíàëüíîå èñïîëüçîâàíèå
+Èñïîëüçîâàíèå àäìèíèñòðàòèâíîãî èíòåðôåéñà
+Îòñóòñòâóåò â îðèãèíàëüíîé äîêóìåíòàöèè
+
+
+
+
+Îïèñàíèå API
+ACL
+add_acl()
+Äîáàâëÿåò ïðàâà äîñòóïà â ëèñò êîíòðîëÿ.
+add_acl(
+ array ACO Ids,
+ array ARO_IDs,
+ array ARO_GROUP_IDs,
+ array AXO_IDs,
+ array AXO_GROUP_IDs,
+ bool ALLOW,
+ bool ENABLED
+ [, int ACL_ID])
+Âîçâðàùàåò:
+int ACL_ID, åñëè âñå ïðîøëî õîðîøî è FALSE, â ñëó÷àå íåóäà÷è.
+
+
+edit_acl()
+Ðåäàêòèðóåò ïðàâà äîñòóïà, êîòîðûå óæå óñòàíîâëåíû â ëèñòå êîíòðîëÿ.
+edit_acl (
+ array ACO IDs,
+ array ARO_IDs,
+ array ARO_GROUP_IDs,
+ array AXO_IDs,
+ array AXO_GROUP_IDs,
+ bool ALLOW,
+ bool ENABLED
+ [, int ACL_ID] )
+Âîçâðàùàåò:
+int ACL_ID åñëè âñå ïðîøëî õîðîøî è FALSE, â ñëó÷àå íåóäà÷è.
+
+del_acl()
+Óäàëÿåò ïðàâà äîñòóïà, êîòîðûå óæå çàäàíû â ëèñòå êîíòðîëÿ.
+del_acl (
+ int ACL ID)
+Âîçâðàùàåò:
+TRUE åñëè âñå ïðîøëî óñïåøíî, FALSE, â ñëó÷àå íåóäà÷è.
+Groups (Ãðóïïû)
+get_group_id()
+Âîçâðàùàåò ID ãðóïïû.
+get_group_id (
+ string GROUP NAME) Òèï îáúåêòà äîñòóïà (ARO, ACO, AXO)
+Âîçâðàùàåò:
+int GROUP_ID â ñëó÷àå óñïåõà, FALSE, åñëè íåóäà÷à.
+
+get_group_parent_id()
+Âîçâðàùàåò ID íåïîñðåäñòâåííîãî ðîäèòåëÿ ãðóïïû.
+get_group_parent_id (
+ int GROUP_ID)
+Âîçâðàùàåò:
+int GROUP_PARENT_ID åñëè óäà÷à, FALSE – åñëè íåóäà÷à.
+
+add_group()
+Äîáàâëÿåò ãðóïïó â äåðåâî ãðóïï.
+add_group (
+ string NAME
+ [, int GROUP_PARENT_ID]
+ [, string OBJECT_TYPE])
+Âîçâðàùàåò:
+int GROUP_ID åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+get_group_objects()
+Âîçâðàùàåò âïèñîê âñåõ îáúåêòîâ îòíåñåííûõ ê ãðóïïå.
+get_group_aro (
+ int GROUP_ID,
+ string GROUP_TYPE)
+Âîçâðàùàåò:
+array SECTION_VALUE, VALUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+add_group_object()
+Ñîîòíîñèò ARO ñ ãðóïïîé.
+add_group_aro (
+ int GROUP_ID,
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+del_group_object()
+Óäàëÿåò ARO èç ãðóïïû.
+del_group_aro (
+ int GROUP_ID,
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+edit_group()
+Ðåäàêòèðóåò ãðóïïû
+edit_group (
+ int GROUP_ID,
+ string NAME,
+ int GROUP_PARENT_ID,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+del_group()
+Óäàëÿåò ãðóïïó, ïåðåðàñïðåäåëÿåò äåòåé (åñëè åñòü) èëè óäàëÿåò èõ.
+del_group (
+ int GROUP_ID,
+ bool REPARENT_CHILDREN,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+Access Objects (ARO/ACO/AXO) (Îáúåêòû äîñòóïà)
+Ýòîò ðàçäåë API óïðàâëÿåò îáúåêòàìè äîñòóïà, òàêèìè êàê ACO, ARO, AXO.
+
+get_object()
+Âîçâðàùàåò ìàññèâ èíôîðìàöèè îáî âñåõ îáúåêòàõ óêàçàííîãî òèïà.
+get_object (
+ [string SECTION_VALUE], Íåîáÿçàòåëüíûé, íàçâàíèå Ðàçäåëà (êàê ôèëüòð)
+ bool RETURN_HIDDEN, Âîçâðàùàòü ëè îáúåêòû ñ òèïîì “ñêðûòûé”
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+array OBJECT_ID åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+get_object_data()
+Âîçâðàùàåò ìàññèâ èíôîðìàöèè îá îáúåêòå äîñòóïà ñ êîíêðåòíûì ID.
+get_object_data (
+ int OBJECT_ID,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+array (section_value, value, order_value, name) åñëè óäà÷à, FALSE åñäè íåóäà÷à.
+
+get_object_id()
+Âîçâðàùàåò ID îáúåêòà.
+get_object_id (
+ string OBJECT_SECTION_VALUE,
+ string OBJECT_VALUE,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int OBJECT_ID åñäè óäà÷à, FALSE åñëè íåóäà÷à.
+
+get_object_section_value() Âîçâðàùàåò ID ðàçäåëà ê êîòîðîìó ïðèïèñàí îáúåêò.
+get_object_section_value (
+ int OBJECT_ID,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int SECTION_VALUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+add_object()
+Äîáàâëÿåò îáúåêò.
+add_object (
+ string SECTION_VALUE,
+ string NAME,
+ string VALUE,
+ int ORDER,
+ bool HIDDEN,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+array OBJECT_ID åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+edit_object()
+Ðåäàêòèðîâàíèå îáúåêòà.
+edit_object (
+ string SECTION_VALUE,
+ string NAME,
+ string VALUE,
+ int ORDER,
+ bool HIDDEN,
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+array OBJECT_ID åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+del_object()
+Óäàëÿåò îáúåêò.
+del_object (
+ int OBJECT_ID,
+ string GROUP_TYPE, Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+ bool ERASE)
+Âîçâðàùàåò:
+int TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+Access Object Sections (Ðàçäåëû îáúåêòîâ äîñòóïà)
+Ýòîò ðàçäåë API ïîçâîëÿåò óïðàâëÿòü Ðàçäåëàìè, êîòîðûå ÿâëÿþòñÿ ÷àñòüþ óíèêàëüíîãî íàçâàíèÿ îáúåêòà äîñòóïà (ñì. “Ðàçäåëû” äëÿ äîïîëíèòåëüíîé èíôîðìàöèè).
+
+get_object_section_section_id()
+Âîçâðàùàåò ID ñóùåñòâóþùåãî Ðàçäåëà. Âû äîëæíû óêàçàòü íàçâàíèå Ðàçäåëà èëè åãî çíà÷åíèå, èëè îáà ïàðàìåòðà.
+Åñëè âû îïðåäåëèòå òîëüêî íàçâàíèå, òî âîçìîæíû íåîäíîçíà÷íûå ðåçóëüòàòû (òàê êàê íàçâàíèå íå îáÿçàíî áûòü óíèêàëüíûì).  ýòîì ñëó÷àå âû ïîëó÷èòå ñîîáùåíèå îá îøèáêå.
+get_object_section_section_id (
+ string NAME, Êîðîòêîå îïèñàíèå òîãî, äëÿ ÷åãî ïðåäíàçíà÷èí Ðàçäåë
+ (íàïðèìåð, Ýòàæè â çäàíèè”)
+ string VALUE, Íàçâàíèå Ðàçäåëà (íàïðèìåð, “Ýòàæ”)
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int SECTION_ID åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+add_object_section()
+Äîáàâëÿåò íîâûé Ðàçäåë îáúåêòîâ.
+add_object_section(
+ string NAME, Êîðîòêîå îïèñàíèå òîãî, äëÿ ÷åãî ïðåäíàçíà÷èí Ðàçäåë
+ (íàïðèìåð, Ýòàæè â çäàíèè”)
+ string VALUE, Íàçâàíèå Ðàçäåëà (íàïðèìåð, “Ýòàæ”)
+ int ORDER, Öåííîñòü Ðàçäåëà. Ó÷èòûâàåòñÿ â ïîëüçîâàòåëüñêîì èíòåðôåéñå ïðè âûâîäå ñïèñêà âûáîðà.
+ bool HIDDEN, TRUE – Ðàçäåë áóäåò ñêðûò èç ñïèñêà â ïîëüçîâàòåëüñêîì èíòåðôåéñå.
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+int SECTION_ID åñëè óäà÷íî, FALSE åñëè íåóäà÷íî.
+
+edit_object_section()
+Èçìåíÿåò àòðèáóòû Ðàçäåëà. Ôóíêöèÿ íå ìîæåò èçìåíèòü òèï îáúåêòà äîñòóïà (äëÿ äîïîëíèòåëüíîé èíôîðìàöèè ñìîòðèòå add_object_section).
+edit_object_section (
+ int OBJECT_SECTION_ID, ID ðàçäåëà (âû ìîæåòå ïîëó÷èòü åãî ïðè ïîìîùè
+ ôóíêöèè get_object_section_section_id).
+ string NAME, Íîâîå íàçâàíèå Ðàçäåëà.
+ string VALUE, Íîâîå çíà÷åíèå Ðàçäåëà.
+ int ORDER, Íîâàÿ öåííîñòü ðàçäåëà.
+ bool HIDDEN, Íîâûé ñòàòóñ ðàçäåëà (ñêðûò èëè íåò)
+ string GROUP_TYPE) Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+Âîçâðàùàåò:
+TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
+del_object_section()
+Óäàëÿåò Ðàçäåë. Âñå îáúåêòû Ðàçäåëà òàêæå áóäóò óäàëåíû!!!
+del_object_section (
+ int SECTION_ID, ID Ðàçäåëà
+ string GROUP_TYPE, Òèï îáúåêòà äîñòóïà (ARO, AXO, ACO)
+ bool ERASE) Åñëè TRUE - âñå îáúåêòû Ðàçäåëà áóäóò óäàëåíû.
+ Åñëè FALSE, òî âû ïîëó÷èòå ñîîáùåíèå îá îøèáêå â ñëó÷àå,
+ åñëè Ðàçäåë ñîäåðæèò îáúåêòû, Ðàçäåë óäàëåí íå áóäåò,
+ åñëè Ðàçäåë íå ñîäåðæèò îáúåêòîâ, îí áóäåò óäàëåí.
+Âîçâðàùàåò:
+TRUE åñëè óäà÷à, FALSE åñëè íåóäà÷à.
+
diff --git a/html/phpgacl/gacl.class.php b/html/phpgacl/gacl.class.php
new file mode 100644
index 0000000..368e1c3
--- /dev/null
+++ b/html/phpgacl/gacl.class.php
@@ -0,0 +1,629 @@
+<?php
+// $Id: gacl.class.php,v 1.53 2005/10/13 19:53:08 ipso Exp $
+
+/**
+ * phpGACL - Generic Access Control List
+ * Copyright (C) 2002,2003 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ * @package phpGACL
+ */
+
+/*
+ * Path to ADODB.
+ */
+if ( !defined('ADODB_DIR') ) {
+ define('ADODB_DIR', dirname(__FILE__).'/adodb');
+}
+
+/**
+* phpGACL main class
+*
+* Class gacl should be used in applications where only querying the phpGACL
+* database is required.
+*
+* @package phpGACL
+* @author Mike Benoit <ipso@snappymail.ca>
+*/
+class gacl {
+ /*
+ --- phpGACL Configuration path/file ---
+ */
+ var $config_file = './gacl.ini.php';
+
+ /*
+ --- Private properties ---
+ */
+ /** @var boolean Enables Debug output if true */
+ var $_debug = FALSE;
+
+ /*
+ --- Database configuration. ---
+ */
+ /** @var string Prefix for all the phpgacl tables in the database */
+ var $_db_table_prefix = 'gacl_';
+
+ /** @var string The database type, based on available ADODB connectors - mysql, postgres7, sybase, oci8po See here for more: http://php.weblogs.com/adodb_manual#driverguide */
+ var $_db_type = 'mysql';
+
+ /** @var string The database server */
+ var $_db_host = 'localhost';
+
+ /** @var string The database user name */
+ var $_db_user = 'hobbit';
+
+ /** @var string The database user password */
+ var $_db_password = 'hobbitpassword';
+
+ /** @var string The database name */
+ var $_db_name = 'moria';
+
+ /** @var object An ADODB database connector object */
+ var $_db = '';
+
+ /*
+ * NOTE: This cache must be manually cleaned each time ACL's are modified.
+ * Alternatively you could wait for the cache to expire.
+ */
+
+ /** @var boolean Caches queries if true */
+ var $_caching = FALSE;
+
+ /** @var boolean Force cache to expire */
+ var $_force_cache_expire = TRUE;
+
+ /** @var string The directory for cache file to eb written (ensure write permission are set) */
+ var $_cache_dir = '/tmp/phpgacl_cache'; // NO trailing slash
+
+ /** @var int The time for the cache to expire in seconds - 600 == Ten Minutes */
+ var $_cache_expire_time=600;
+
+ /** @var string A switch to put acl_check into '_group_' mode */
+ var $_group_switch = '_group_';
+
+ /**
+ * Constructor
+ * @param array An arry of options to oeverride the class defaults
+ */
+ function gacl($options = NULL) {
+
+ $available_options = array('db','debug','items_per_page','max_select_box_items','max_search_return_items','db_table_prefix','db_type','db_host','db_user','db_password','db_name','caching','force_cache_expire','cache_dir','cache_expire_time');
+
+ //Values supplied in $options array overwrite those in the config file.
+ if ( file_exists($this->config_file) ) {
+ $config = parse_ini_file($this->config_file);
+
+ if ( is_array($config) ) {
+ $gacl_options = array_merge($config, $options);
+ }
+
+ unset($config);
+ }
+
+ if (is_array($options)) {
+ foreach ($options as $key => $value) {
+ $this->debug_text("Option: $key");
+
+ if (in_array($key, $available_options) ) {
+ $this->debug_text("Valid Config options: $key");
+ $property = '_'.$key;
+ $this->$property = $value;
+ } else {
+ $this->debug_text("ERROR: Config option: $key is not a valid option");
+ }
+ }
+ }
+
+ require_once( ADODB_DIR .'/adodb.inc.php');
+ require_once( ADODB_DIR .'/adodb-pager.inc.php');
+
+ //Use NUM for slight performance/memory reasons.
+ //Leave this in for backwards compatibility with older ADODB installations.
+ //If your using ADODB v3.5+ feel free to comment out the following line if its giving you problems.
+ $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+
+ if (is_object($this->_db)) {
+ $this->db = &$this->_db;
+ } else {
+ $this->db = ADONewConnection($this->_db_type);
+ $this->db->SetFetchMode(ADODB_FETCH_NUM);
+ $this->db->PConnect($this->_db_host, $this->_db_user, $this->_db_password, $this->_db_name);
+ }
+ $this->db->debug = $this->_debug;
+
+ if ( $this->_caching == TRUE ) {
+ if (!class_exists('Hashed_Cache_Lite')) {
+ require_once(dirname(__FILE__) .'/Cache_Lite/Hashed_Cache_Lite.php');
+ }
+
+ /*
+ * Cache options. We default to the highest performance. If you run in to cache corruption problems,
+ * Change all the 'false' to 'true', this will slow things down slightly however.
+ */
+
+ $cache_options = array(
+ 'caching' => $this->_caching,
+ 'cacheDir' => $this->_cache_dir.'/',
+ 'lifeTime' => $this->_cache_expire_time,
+ 'fileLocking' => TRUE,
+ 'writeControl' => FALSE,
+ 'readControl' => FALSE,
+ 'memoryCaching' => TRUE,
+ 'automaticSerialization' => FALSE
+ );
+ $this->Cache_Lite = new Hashed_Cache_Lite($cache_options);
+ }
+
+ return true;
+ }
+
+ /**
+ * Prints debug text if debug is enabled.
+ * @param string THe text to output
+ * @return boolean Always returns true
+ */
+ function debug_text($text) {
+
+ if ($this->_debug) {
+ echo "$text<br>\n";
+ }
+
+ return true;
+ }
+
+ /**
+ * Prints database debug text if debug is enabled.
+ * @param string The name of the function calling this method
+ * @return string Returns an error message
+ */
+ function debug_db($function_name = '') {
+ if ($function_name != '') {
+ $function_name .= ' (): ';
+ }
+
+ return $this->debug_text ($function_name .'database error: '. $this->db->ErrorMsg() .' ('. $this->db->ErrorNo() .')');
+ }
+
+ /**
+ * Wraps the actual acl_query() function.
+ *
+ * It is simply here to return TRUE/FALSE accordingly.
+ * @param string The ACO section value
+ * @param string The ACO value
+ * @param string The ARO section value
+ * @param string The ARO section
+ * @param string The AXO section value (optional)
+ * @param string The AXO section value (optional)
+ * @param integer The group id of the ARO ??Mike?? (optional)
+ * @param integer The group id of the AXO ??Mike?? (optional)
+ * @return boolean TRUE if the check succeeds, false if not.
+ */
+ function acl_check($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group=NULL, $root_axo_group=NULL) {
+ $acl_result = $this->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value, $root_aro_group, $root_axo_group);
+
+ return $acl_result['allow'];
+ }
+
+ /**
+ * Wraps the actual acl_query() function.
+ *
+ * Quick access to the return value of an ACL.
+ * @param string The ACO section value
+ * @param string The ACO value
+ * @param string The ARO section value
+ * @param string The ARO section
+ * @param string The AXO section value (optional)
+ * @param string The AXO section value (optional)
+ * @param integer The group id of the ARO (optional)
+ * @param integer The group id of the AXO (optional)
+ * @return string The return value of the ACL
+ */
+ function acl_return_value($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group=NULL, $root_axo_group=NULL) {
+ $acl_result = $this->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value, $root_aro_group, $root_axo_group);
+
+ return $acl_result['return_value'];
+ }
+
+ /**
+ * Handles ACL lookups over arrays of AROs
+ * @param string The ACO section value
+ * @param string The ACO value
+ * @param array An named array of arrays, each element in the format aro_section_value=>array(aro_value1,aro_value1,...)
+ * @return mixed The same data format as inputted.
+ \*======================================================================*/
+ function acl_check_array($aco_section_value, $aco_value, $aro_array) {
+ /*
+ Input Array:
+ Section => array(Value, Value, Value),
+ Section => array(Value, Value, Value)
+
+ */
+
+ if (!is_array($aro_array)) {
+ $this->debug_text("acl_query_array(): ARO Array must be passed");
+ return false;
+ }
+
+ foreach($aro_array as $aro_section_value => $aro_value_array) {
+ foreach ($aro_value_array as $aro_value) {
+ $this->debug_text("acl_query_array(): ARO Section Value: $aro_section_value ARO VALUE: $aro_value");
+
+ if( $this->acl_check($aco_section_value, $aco_value, $aro_section_value, $aro_value) ) {
+ $this->debug_text("acl_query_array(): ACL_CHECK True");
+ $retarr[$aro_section_value][] = $aro_value;
+ } else {
+ $this->debug_text("acl_query_array(): ACL_CHECK False");
+ }
+ }
+ }
+
+ return $retarr;
+
+ }
+
+ /**
+ * The Main function that does the actual ACL lookup.
+ * @param string The ACO section value
+ * @param string The ACO value
+ * @param string The ARO section value
+ * @param string The ARO section
+ * @param string The AXO section value (optional)
+ * @param string The AXO section value (optional)
+ * @param string The value of the ARO group (optional)
+ * @param string The value of the AXO group (optional)
+ * @param boolean Debug the operation if true (optional)
+ * @return array Returns as much information as possible about the ACL so other functions can trim it down and omit unwanted data.
+ */
+ function acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group=NULL, $root_axo_group=NULL, $debug=NULL) {
+
+ $cache_id = 'acl_query_'.$aco_section_value.'-'.$aco_value.'-'.$aro_section_value.'-'.$aro_value.'-'.$axo_section_value.'-'.$axo_value.'-'.$root_aro_group.'-'.$root_axo_group.'-'.$debug;
+
+ $retarr = $this->get_cache($cache_id);
+
+ if (!$retarr) {
+ /*
+ * Grab all groups mapped to this ARO/AXO
+ */
+ $aro_group_ids = $this->acl_get_groups($aro_section_value, $aro_value, $root_aro_group, 'ARO');
+
+ if (is_array($aro_group_ids) AND !empty($aro_group_ids)) {
+ $sql_aro_group_ids = implode(',', $aro_group_ids);
+ }
+
+ if ($axo_section_value != '' AND $axo_value != '') {
+ $axo_group_ids = $this->acl_get_groups($axo_section_value, $axo_value, $root_axo_group, 'AXO');
+
+ if (is_array($axo_group_ids) AND !empty($axo_group_ids)) {
+ $sql_axo_group_ids = implode(',', $axo_group_ids);
+ }
+ }
+
+ /*
+ * This query is where all the magic happens.
+ * The ordering is very important here, as well very tricky to get correct.
+ * Currently there can be duplicate ACLs, or ones that step on each other toes. In this case, the ACL that was last updated/created
+ * is used.
+ *
+ * This is probably where the most optimizations can be made.
+ */
+
+ $order_by = array();
+
+ $query = '
+ SELECT a.id,a.allow,a.return_value
+ FROM '. $this->_db_table_prefix .'acl a
+ LEFT JOIN '. $this->_db_table_prefix .'aco_map ac ON ac.acl_id=a.id';
+
+ if ($aro_section_value != $this->_group_switch) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'aro_map ar ON ar.acl_id=a.id';
+ }
+
+ if ($axo_section_value != $this->_group_switch) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'axo_map ax ON ax.acl_id=a.id';
+ }
+
+ /*
+ * if there are no aro groups, don't bother doing the join.
+ */
+ if (isset($sql_aro_group_ids)) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'aro_groups_map arg ON arg.acl_id=a.id
+ LEFT JOIN '. $this->_db_table_prefix .'aro_groups rg ON rg.id=arg.group_id';
+ }
+
+ // this join is necessary to weed out rules associated with axo groups
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups_map axg ON axg.acl_id=a.id';
+
+ /*
+ * if there are no axo groups, don't bother doing the join.
+ * it is only used to rank by the level of the group.
+ */
+ if (isset($sql_axo_group_ids)) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups xg ON xg.id=axg.group_id';
+ }
+
+ //Move the below line to the LEFT JOIN above for PostgreSQL's sake.
+ //AND ac.acl_id=a.id
+ $query .= '
+ WHERE a.enabled=1
+ AND (ac.section_value='. $this->db->quote($aco_section_value) .' AND ac.value='. $this->db->quote($aco_value) .')';
+
+ // if we are querying an aro group
+ if ($aro_section_value == $this->_group_switch) {
+ // if acl_get_groups did not return an array
+ if ( !isset ($sql_aro_group_ids) ) {
+ $this->debug_text ('acl_query(): Invalid ARO Group: '. $aro_value);
+ return FALSE;
+ }
+
+ $query .= '
+ AND rg.id IN ('. $sql_aro_group_ids .')';
+
+ $order_by[] = '(rg.rgt-rg.lft) ASC';
+ } else {
+ $query .= '
+ AND ((ar.section_value='. $this->db->quote($aro_section_value) .' AND ar.value='. $this->db->quote($aro_value) .')';
+
+ if ( isset ($sql_aro_group_ids) ) {
+ $query .= ' OR rg.id IN ('. $sql_aro_group_ids .')';
+
+ $order_by[] = '(CASE WHEN ar.value IS NULL THEN 0 ELSE 1 END) DESC';
+ $order_by[] = '(rg.rgt-rg.lft) ASC';
+ }
+
+ $query .= ')';
+ }
+
+
+ // if we are querying an axo group
+ if ($axo_section_value == $this->_group_switch) {
+ // if acl_get_groups did not return an array
+ if ( !isset ($sql_axo_group_ids) ) {
+ $this->debug_text ('acl_query(): Invalid AXO Group: '. $axo_value);
+ return FALSE;
+ }
+
+ $query .= '
+ AND xg.id IN ('. $sql_axo_group_ids .')';
+
+ $order_by[] = '(xg.rgt-xg.lft) ASC';
+ } else {
+ $query .= '
+ AND (';
+
+ if ($axo_section_value == '' AND $axo_value == '') {
+ $query .= '(ax.section_value IS NULL AND ax.value IS NULL)';
+ } else {
+ $query .= '(ax.section_value='. $this->db->quote($axo_section_value) .' AND ax.value='. $this->db->quote($axo_value) .')';
+ }
+
+ if (isset($sql_axo_group_ids)) {
+ $query .= ' OR xg.id IN ('. $sql_axo_group_ids .')';
+
+ $order_by[] = '(CASE WHEN ax.value IS NULL THEN 0 ELSE 1 END) DESC';
+ $order_by[] = '(xg.rgt-xg.lft) ASC';
+ } else {
+ $query .= ' AND axg.group_id IS NULL';
+ }
+
+ $query .= ')';
+ }
+
+ /*
+ * The ordering is always very tricky and makes all the difference in the world.
+ * Order (ar.value IS NOT NULL) DESC should put ACLs given to specific AROs
+ * ahead of any ACLs given to groups. This works well for exceptions to groups.
+ */
+
+ $order_by[] = 'a.updated_date DESC';
+
+ $query .= '
+ ORDER BY '. implode (',', $order_by) . '
+ ';
+
+ // we are only interested in the first row
+ $rs = $this->db->SelectLimit($query, 1);
+
+ if (!is_object($rs)) {
+ $this->debug_db('acl_query');
+ return FALSE;
+ }
+
+ $row =& $rs->FetchRow();
+
+ /*
+ * Return ACL ID. This is the key to "hooking" extras like pricing assigned to ACLs etc... Very useful.
+ */
+ if (is_array($row)) {
+ // Permission granted?
+ // This below oneliner is very confusing.
+ //$allow = (isset($row[1]) AND $row[1] == 1);
+
+ //Prefer this.
+ if ( isset($row[1]) AND $row[1] == 1 ) {
+ $allow = TRUE;
+ } else {
+ $allow = FALSE;
+ }
+
+ $retarr = array('acl_id' => &$row[0], 'return_value' => &$row[2], 'allow' => $allow);
+ } else {
+ // Permission denied.
+ $retarr = array('acl_id' => NULL, 'return_value' => NULL, 'allow' => FALSE);
+ }
+
+ /*
+ * Return the query that we ran if in debug mode.
+ */
+ if ($debug == TRUE) {
+ $retarr['query'] = &$query;
+ }
+
+ //Cache data.
+ $this->put_cache($retarr, $cache_id);
+ }
+
+ $this->debug_text("<b>acl_query():</b> ACO Section: $aco_section_value ACO Value: $aco_value ARO Section: $aro_section_value ARO Value $aro_value ACL ID: ". $retarr['acl_id'] .' Result: '. $retarr['allow']);
+ return $retarr;
+ }
+
+ /**
+ * Grabs all groups mapped to an ARO. You can also specify a root_group for subtree'ing.
+ * @param string The section value or the ARO or ACO
+ * @param string The value of the ARO or ACO
+ * @param integer The group id of the group to start at (optional)
+ * @param string The type of group, either ARO or AXO (optional)
+ */
+ function acl_get_groups($section_value, $value, $root_group=NULL, $group_type='ARO') {
+
+ switch(strtolower($group_type)) {
+ case 'axo':
+ $group_type = 'axo';
+ $object_table = $this->_db_table_prefix .'axo';
+ $group_table = $this->_db_table_prefix .'axo_groups';
+ $group_map_table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ default:
+ $group_type = 'aro';
+ $object_table = $this->_db_table_prefix .'aro';
+ $group_table = $this->_db_table_prefix .'aro_groups';
+ $group_map_table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ }
+
+ //$profiler->startTimer( "acl_get_groups()");
+
+ //Generate unique cache id.
+ $cache_id = 'acl_get_groups_'.$section_value.'-'.$value.'-'.$root_group.'-'.$group_type;
+
+ $retarr = $this->get_cache($cache_id);
+
+ if (!$retarr) {
+
+ // Make sure we get the groups
+ $query = '
+ SELECT DISTINCT g2.id';
+
+ if ($section_value == $this->_group_switch) {
+ $query .= '
+ FROM ' . $group_table . ' g1,' . $group_table . ' g2';
+
+ $where = '
+ WHERE g1.value=' . $this->db->quote( $value );
+ } else {
+ $query .= '
+ FROM '. $object_table .' o,'. $group_map_table .' gm,'. $group_table .' g1,'. $group_table .' g2';
+
+ $where = '
+ WHERE (o.section_value='. $this->db->quote($section_value) .' AND o.value='. $this->db->quote($value) .')
+ AND gm.'. $group_type .'_id=o.id
+ AND g1.id=gm.group_id';
+ }
+
+ /*
+ * If root_group_id is specified, we have to narrow this query down
+ * to just groups deeper in the tree then what is specified.
+ * This essentially creates a virtual "subtree" and ignores all outside groups.
+ * Useful for sites like sourceforge where you may seperate groups by "project".
+ */
+ if ( $root_group != '') {
+ //It is important to note the below line modifies the tables being selected.
+ //This is the reason for the WHERE variable.
+ $query .= ','. $group_table .' g3';
+
+ $where .= '
+ AND g3.value='. $this->db->quote( $root_group ) .'
+ AND ((g2.lft BETWEEN g3.lft AND g1.lft) AND (g2.rgt BETWEEN g1.rgt AND g3.rgt))';
+ } else {
+ $where .= '
+ AND (g2.lft <= g1.lft AND g2.rgt >= g1.rgt)';
+ }
+
+ $query .= $where;
+
+ // $this->debug_text($query);
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('acl_get_groups');
+ return FALSE;
+ }
+
+ $retarr = array();
+
+ //Unbuffered query?
+ while (!$rs->EOF) {
+ $retarr[] = reset($rs->fields);
+ $rs->MoveNext();
+ }
+
+ //Cache data.
+ $this->put_cache($retarr, $cache_id);
+ }
+
+ return $retarr;
+ }
+
+ /**
+ * Uses PEAR's Cache_Lite package to grab cached arrays, objects, variables etc...
+ * using unserialize() so it can handle more then just text string.
+ * @param string The id of the cached object
+ * @return mixed The cached object, otherwise FALSE if the object identifier was not found
+ */
+ function get_cache($cache_id) {
+
+ if ( $this->_caching == TRUE ) {
+ $this->debug_text("get_cache(): on ID: $cache_id");
+
+ if ( is_string($this->Cache_Lite->get($cache_id) ) ) {
+ return unserialize($this->Cache_Lite->get($cache_id) );
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Uses PEAR's Cache_Lite package to write cached arrays, objects, variables etc...
+ * using serialize() so it can handle more then just text string.
+ * @param mixed A variable to cache
+ * @param string The id of the cached variable
+ */
+ function put_cache($data, $cache_id) {
+
+ if ( $this->_caching == TRUE ) {
+ $this->debug_text("put_cache(): Cache MISS on ID: $cache_id");
+
+ return $this->Cache_Lite->save(serialize($data), $cache_id);
+ }
+
+ return false;
+ }
+}
+?>
diff --git a/html/phpgacl/gacl.ini.php b/html/phpgacl/gacl.ini.php
new file mode 100644
index 0000000..fe5d6f5
--- /dev/null
+++ b/html/phpgacl/gacl.ini.php
@@ -0,0 +1,42 @@
+;<? if (; //Cause parse error to hide from prying eyes?>
+;
+; *WARNING*
+;
+; DO NOT PUT THIS FILE IN YOUR WEBROOT DIRECTORY.
+;
+; *WARNING*
+;
+; Anyone can view your database password if you do!
+;
+debug = FALSE
+
+;
+;Database
+;
+db_type = "mysql"
+db_host = "localhost"
+db_user = "hobbit"
+db_password = "hobbitpassword"
+db_name = "moria"
+db_table_prefix = "gacl_"
+
+;
+;Caching
+;
+caching = FALSE
+force_cache_expire = TRUE
+cache_dir = "/tmp/phpgacl_cache"
+cache_expire_time = 600
+
+;
+;Admin interface
+;
+items_per_page = 100
+max_select_box_items = 100
+max_search_return_items = 200
+
+;NO Trailing slashes
+smarty_dir = "/usr/lib/php/Smarty"
+smarty_template_dir = "templates"
+smarty_compile_dir = "templates_c"
+
diff --git a/html/phpgacl/gacl_api.class.php b/html/phpgacl/gacl_api.class.php
new file mode 100644
index 0000000..70833fc
--- /dev/null
+++ b/html/phpgacl/gacl_api.class.php
@@ -0,0 +1,3899 @@
+<?php
+/**
+ * phpGACL - Generic Access Control List
+ * Copyright (C) 2002,2003 Mike Benoit
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For questions, help, comments, discussion, etc., please join the
+ * phpGACL mailing list. http://sourceforge.net/mail/?group_id=57103
+ *
+ * You may contact the author of phpGACL by e-mail at:
+ * ipso@snappymail.ca
+ *
+ * The latest version of phpGACL can be obtained from:
+ * http://phpgacl.sourceforge.net/
+ *
+ * @package phpGACL
+ *
+ */
+
+/*
+ *
+ * For examples, see example.php or the Administration interface,
+ * as it makes use of nearly every API Call.
+ *
+ */
+/**
+ * gacl_api Extended API Class
+ *
+ * Class gacl_api should be used for applications that must interface directly with
+ * phpGACL's data structures, objects, and rules.
+ *
+ * @package phpGACL
+ * @author Mike Benoit <ipso@snappymail.ca>
+ *
+ */
+
+class gacl_api extends gacl {
+
+ /*
+ *
+ * Misc helper functions.
+ *
+ */
+
+ /**
+ * showarray()
+ *
+ * Dump all contents of an array in HTML (kinda)
+ *
+ * @param array
+ *
+ */
+ function showarray($array) {
+ echo "<br><pre>\n";
+ var_dump($array);
+ echo "</pre><br>\n";
+ }
+
+ /**
+ * count_all()
+ *
+ * Recursively counts elements in an array and sub-arrays.
+ *
+ * This is different from count($arg, COUNT_RECURSIVE)
+ * in PHP >= 4.2.0, which includes sub-arrays in the count.
+ *
+ * @return int The returned count is a count of all scalar elements found.
+ *
+ * @param array Array to count
+ */
+ function count_all($arg = NULL) {
+ switch (TRUE) {
+ case is_scalar($arg):
+ case is_object($arg):
+ // single object
+ return 1;
+ case is_array($arg):
+ // call recursively for all elements of $arg
+ $count = 0;
+ foreach ($arg as $val) {
+ $count += $this->count_all($val);
+ }
+ return $count;
+ }
+ return FALSE;
+ }
+
+ /**
+ * get_version()
+ *
+ * Grabs phpGACL version from the database.
+ *
+ * @return string Version of phpGACL
+ */
+ function get_version() {
+ $query = "select value from ".$this->_db_table_prefix."phpgacl where name = 'version'";
+ $version = $this->db->GetOne($query);
+
+ return $version;
+ }
+
+ /**
+ * get_schema_version()
+ *
+ * Grabs phpGACL schema version from the database.
+ *
+ * @return string Schema Version
+ */
+ function get_schema_version() {
+ $query = "select value from ".$this->_db_table_prefix."phpgacl where name = 'schema_version'";
+ $version = $this->db->GetOne($query);
+
+ return $version;
+ }
+
+ /*
+ *
+ * ACL
+ *
+ */
+
+ /**
+ * consolidated_edit_acl()
+ *
+ * Add's an ACL but checks to see if it can consolidate it with another one first.
+ *
+ * This ONLY works with ACO's and ARO's. Groups, and AXO are excluded.
+ * As well this function is designed for handling ACLs with return values,
+ * and consolidating on the return_value, in hopes of keeping the ACL count to a minimum.
+ *
+ * A return value of false must _always_ be handled outside this function.
+ * As this function will remove AROs from ACLs and return false, in most cases
+ * you will need to a create a completely new ACL on a false return.
+ *
+ * @return bool Special boolean return value. See note.
+ *
+ * @param string ACO Section Value
+ * @param string ACO Value
+ * @param string ARO Section Value
+ * @param string ARO Value
+ * @param string Return Value of ACL
+ */
+ function consolidated_edit_acl($aco_section_value, $aco_value, $aro_section_value, $aro_value, $return_value) {
+
+ $this->debug_text("consolidated_edit_acl(): ACO Section Value: $aco_section_value ACO Value: $aco_value ARO Section Value: $aro_section_value ARO Value: $aro_value Return Value: $return_value");
+
+ $acl_ids = array();
+
+ if (empty($aco_section_value) ) {
+ $this->debug_text("consolidated_edit_acl(): ACO Section Value ($aco_section_value) is empty, this is required!");
+ return false;
+ }
+
+ if (empty($aco_value) ) {
+ $this->debug_text("consolidated_edit_acl(): ACO Value ($aco_value) is empty, this is required!");
+ return false;
+ }
+
+ if (empty($aro_section_value) ) {
+ $this->debug_text("consolidated_edit_acl(): ARO Section Value ($aro_section_value) is empty, this is required!");
+ return false;
+ }
+
+ if (empty($aro_value) ) {
+ $this->debug_text("consolidated_edit_acl(): ARO Value ($aro_value) is empty, this is required!");
+ return false;
+ }
+
+ if (empty($return_value) ) {
+ $this->debug_text("consolidated_edit_acl(): Return Value ($return_value) is empty, this is required!");
+ return false;
+ }
+
+ //See if a current ACL exists with the current objects, excluding return value
+ $current_acl_ids = $this->search_acl($aco_section_value, $aco_value, $aro_section_value, $aro_value, FALSE, FALSE, FALSE, FALSE, FALSE);
+ //showarray($current_acl_ids);
+
+ if (is_array($current_acl_ids)) {
+ $this->debug_text("add_consolidated_acl(): Found current ACL_IDs, counting ACOs");
+
+ foreach ($current_acl_ids as $current_acl_id) {
+ //Check to make sure these ACLs only have a single ACO mapped to them.
+ $current_acl_array = &$this->get_acl($current_acl_id);
+
+ //showarray($current_acl_array);
+ $this->debug_text("add_consolidated_acl(): Current Count: ".$this->count_all($current_acl_array['aco'])."");
+
+ if ( $this->count_all($current_acl_array['aco']) == 1) {
+ $this->debug_text("add_consolidated_acl(): ACL ID: $current_acl_id has 1 ACO.");
+
+ //Test to see if the return values match, if they do, no need removing or appending ARO. Just return true.
+ if ($current_acl_array['return_value'] == $return_value) {
+ $this->debug_text("add_consolidated_acl(): ACL ID: $current_acl_id has 1 ACO, and the same return value. No need to modify.");
+ return true;
+ }
+
+ $acl_ids[] = $current_acl_id;
+ }
+
+ }
+ }
+
+ //showarray($acl_ids);
+ $acl_ids_count = count($acl_ids);
+
+ //If acl_id's turns up more then one ACL, lets remove the ARO from all of them in hopes to
+ //eliminate any conflicts.
+ if (is_array($acl_ids) AND $acl_ids_count > 0) {
+ $this->debug_text("add_consolidated_acl(): Removing specified ARO from existing ACL.");
+
+ foreach ($acl_ids as $acl_id) {
+ //Remove ARO from current ACLs, so we don't create conflicting ACLs later on.
+ if (!$this->shift_acl($acl_id, array($aro_section_value => array($aro_value)) ) ) {
+ $this->debug_text("add_consolidated_acl(): Error removing specified ARO from ACL ID: $acl_id");
+ return false;
+ }
+ }
+ } else {
+ $this->debug_text("add_consolidated_acl(): Didn't find any current ACLs with a single ACO. ");
+ }
+ //unset($acl_ids);
+ $acl_ids = array();
+ unset($acl_ids_count);
+
+ //At this point there should be no conflicting ACLs, searching for an existing ACL with the new values.
+ $new_acl_ids = $this->search_acl($aco_section_value, $aco_value, FALSE, FALSE, NULL, NULL, NULL, NULL, $return_value);
+ $new_acl_count = count($new_acl_ids);
+ //showarray($new_acl_ids);
+
+ if (is_array($new_acl_ids)) {
+ $this->debug_text("add_consolidated_acl(): Found new ACL_IDs, counting ACOs");
+
+ foreach ($new_acl_ids as $new_acl_id) {
+ //Check to make sure these ACLs only have a single ACO mapped to them.
+ $new_acl_array = &$this->get_acl($new_acl_id);
+ //showarray($new_acl_array);
+ $this->debug_text("add_consolidated_acl(): New Count: ".$this->count_all($new_acl_array['aco'])."");
+ if ( $this->count_all($new_acl_array['aco']) == 1) {
+
+ $this->debug_text("add_consolidated_acl(): ACL ID: $new_acl_id has 1 ACO, append should be able to take place.");
+ $acl_ids[] = $new_acl_id;
+ }
+
+ }
+ }
+
+ //showarray($acl_ids);
+ $acl_ids_count = count($acl_ids);
+
+ if (is_array($acl_ids) AND $acl_ids_count == 1) {
+ $this->debug_text("add_consolidated_acl(): Appending specified ARO to existing ACL.");
+
+ $acl_id=$acl_ids[0];
+
+ if (!$this->append_acl($acl_id, array($aro_section_value => array($aro_value)) ) ) {
+ $this->debug_text("add_consolidated_acl(): Error appending specified ARO to ACL ID: $acl_id");
+ return false;
+ }
+
+ $this->debug_text("add_consolidated_acl(): Hot damn, ACL consolidated!");
+ return true;
+ } elseif($acl_ids_count > 1) {
+ $this->debug_text("add_consolidated_acl(): Found more then one ACL with a single ACO. Possible conflicting ACLs.");
+ return false;
+ } elseif ($acl_ids_count == 0) {
+ $this->debug_text("add_consolidated_acl(): No existing ACLs found, create a new one.");
+
+ if (!$this->add_acl( array( $aco_section_value => array($aco_value) ),
+ array( $aro_section_value => array($aro_value) ),
+ NULL,
+ NULL,
+ NULL,
+ TRUE,
+ TRUE,
+ $return_value,
+ NULL)
+ ) {
+ $this->debug_text("add_consolidated_acl(): Error adding new ACL for ACO Section: $aco_section_value ACO Value: $aco_value Return Value: $return_value");
+ return false;
+ }
+
+ $this->debug_text("add_consolidated_acl(): ADD_ACL() successfull, returning True.");
+ return true;
+ }
+
+ $this->debug_text("add_consolidated_acl(): Returning false.");
+ return false;
+ }
+
+ /**
+ * search_acl()
+ *
+ * Searches for ACL's with specified objects mapped to them.
+ *
+ * NULL values are included in the search, if you want to ignore
+ * for instance aro_groups use FALSE instead of NULL.
+ *
+ * @return array containing ACL IDs if search is successful
+ *
+ * @param string ACO Section Value
+ * @param string ACO Value
+ * @param string ARO Section Value
+ * @param string ARO Value
+ * @param string ARO Group Name
+ * @param string AXO Section Value
+ * @param string AXO Value
+ * @param string AXO Group Name
+ * @param string Return Value
+ */
+ function search_acl($aco_section_value=NULL, $aco_value=NULL, $aro_section_value=NULL, $aro_value=NULL, $aro_group_name=NULL, $axo_section_value=NULL, $axo_value=NULL, $axo_group_name=NULL, $return_value=NULL) {
+ $this->debug_text("search_acl(): aco_section_value: $aco_section_value aco_value: $aco_value, aro_section_value: $aro_section_value, aro_value: $aro_value, aro_group_name: $aro_group_name, axo_section_value: $axo_section_value, axo_value: $axo_value, axo_group_name: $axo_group_name, return_value: $return_value");
+
+ $query = '
+ SELECT a.id
+ FROM '. $this->_db_table_prefix .'acl a';
+
+ $where_query = array();
+
+ // ACO
+ if ($aco_section_value !== FALSE AND $aco_value !== FALSE) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'aco_map ac ON a.id=ac.acl_id';
+
+ if ($aco_section_value == NULL AND $aco_value == NULL) {
+ $where_query[] = '(ac.section_value IS NULL AND ac.value IS NULL)';
+ } else {
+ $where_query[] = '(ac.section_value='. $this->db->quote($aco_section_value) .' AND ac.value='. $this->db->quote($aco_value) .')';
+ }
+ }
+
+ // ARO
+ if ($aro_section_value !== FALSE AND $aro_value !== FALSE) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'aro_map ar ON a.id=ar.acl_id';
+
+ if ($aro_section_value == NULL AND $aro_value == NULL) {
+ $where_query[] = '(ar.section_value IS NULL AND ar.value IS NULL)';
+ } else {
+ $where_query[] = '(ar.section_value='. $this->db->quote($aro_section_value) .' AND ar.value='. $this->db->quote($aro_value) .')';
+ }
+ }
+
+ // AXO
+ if ($axo_section_value !== FALSE AND $axo_value !== FALSE) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'axo_map ax ON a.id=ax.acl_id';
+
+ if ($axo_section_value == NULL AND $axo_value == NULL) {
+ $where_query[] = '(ax.section_value IS NULL AND ax.value IS NULL)';
+ } else {
+ $where_query[] = '(ax.section_value='. $this->db->quote($axo_section_value) .' AND ax.value='. $this->db->quote($axo_value) .')';
+ }
+ }
+
+ // ARO Group
+ if ($aro_group_name !== FALSE) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'aro_groups_map arg ON a.id=arg.acl_id
+ LEFT JOIN '. $this->_db_table_prefix .'aro_groups rg ON arg.group_id=rg.id';
+
+ if ($aro_group_name == NULL) {
+ $where_query[] = '(rg.name IS NULL)';
+ } else {
+ $where_query[] = '(rg.name='. $this->db->quote($aro_group_name) .')';
+ }
+ }
+
+ // AXO Group
+ if ($axo_group_name !== FALSE) {
+ $query .= '
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups_map axg ON a.id=axg.acl_id
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups xg ON axg.group_id=xg.id';
+
+ if ($axo_group_name == NULL) {
+ $where_query[] = '(xg.name IS NULL)';
+ } else {
+ $where_query[] = '(xg.name='. $this->db->quote($axo_group_name) .')';
+ }
+ }
+ if ($return_value != FALSE) {
+ if ($return_value == NULL) {
+ $where_query[] = '(a.return_value IS NULL)';
+ } else {
+ $where_query[] = '(a.return_value='. $this->db->quote($return_value) .')';
+ }
+ }
+
+ if (count($where_query) > 0) {
+ $query .= '
+ WHERE '. implode (' AND ', $where_query);
+ }
+
+ return $this->db->GetCol($query);
+ }
+
+ /**
+ * append_acl()
+ *
+ * Appends objects on to a specific ACL.
+ *
+ * @return bool TRUE if successful, FALSE otherwise.
+ *
+ * @param int ACL ID #
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ */
+ function append_acl($acl_id, $aro_array=NULL, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $aco_array=NULL) {
+ $this->debug_text("append_acl(): ACL_ID: $acl_id");
+
+ $update = 0;
+
+ if (empty($acl_id)) {
+ $this->debug_text("append_acl(): No ACL_ID specified! ACL_ID: $acl_id");
+ return false;
+ }
+
+ //Grab ACL data.
+ $acl_array = &$this->get_acl($acl_id);
+
+ //Append each object type seperately.
+ if (is_array($aro_array) AND count($aro_array) > 0) {
+ $this->debug_text("append_acl(): Appending ARO's");
+
+ while (list($aro_section_value,$aro_value_array) = @each($aro_array)) {
+ foreach ($aro_value_array as $aro_value) {
+ if ( count($acl_array['aro'][$aro_section_value]) != 0 ) {
+ if (!in_array($aro_value, $acl_array['aro'][$aro_section_value])) {
+ $this->debug_text("append_acl(): ARO Section Value: $aro_section_value ARO VALUE: $aro_value");
+ $acl_array['aro'][$aro_section_value][] = $aro_value;
+ $update=1;
+ } else {
+ $this->debug_text("append_acl(): Duplicate ARO, ignoring... ");
+ }
+ } else { //Array is empty so add this aro value.
+ $acl_array['aro'][$aro_section_value][] = $aro_value;
+ $update = 1;
+ }
+ }
+ }
+ }
+
+ if (is_array($aro_group_ids) AND count($aro_group_ids) > 0) {
+ $this->debug_text("append_acl(): Appending ARO_GROUP_ID's");
+
+ while (list(,$aro_group_id) = @each($aro_group_ids)) {
+ if (!is_array($acl_array['aro_groups']) OR !in_array($aro_group_id, $acl_array['aro_groups'])) {
+ $this->debug_text("append_acl(): ARO Group ID: $aro_group_id");
+ $acl_array['aro_groups'][] = $aro_group_id;
+ $update = 1;
+ } else {
+ $this->debug_text("append_acl(): Duplicate ARO_Group_ID, ignoring... ");
+ }
+ }
+ }
+
+ if (is_array($axo_array) AND count($axo_array) > 0) {
+ $this->debug_text("append_acl(): Appending AXO's");
+
+ while (list($axo_section_value,$axo_value_array) = @each($axo_array)) {
+ foreach ($axo_value_array as $axo_value) {
+ if (!in_array($axo_value, $acl_array['axo'][$axo_section_value])) {
+ $this->debug_text("append_acl(): AXO Section Value: $axo_section_value AXO VALUE: $axo_value");
+ $acl_array['axo'][$axo_section_value][] = $axo_value;
+ $update = 1;
+ } else {
+ $this->debug_text("append_acl(): Duplicate AXO, ignoring... ");
+ }
+
+ }
+ }
+ }
+
+ if (is_array($axo_group_ids) AND count($axo_group_ids) > 0) {
+ $this->debug_text("append_acl(): Appending AXO_GROUP_ID's");
+ while (list(,$axo_group_id) = @each($axo_group_ids)) {
+ if (!is_array($acl_array['axo_groups']) OR !in_array($axo_group_id, $acl_array['axo_groups'])) {
+ $this->debug_text("append_acl(): AXO Group ID: $axo_group_id");
+ $acl_array['axo_groups'][] = $axo_group_id;
+ $update = 1;
+ } else {
+ $this->debug_text("append_acl(): Duplicate ARO_Group_ID, ignoring... ");
+ }
+ }
+ }
+
+ if (is_array($aco_array) AND count($aco_array) > 0) {
+ $this->debug_text("append_acl(): Appending ACO's");
+
+ while (list($aco_section_value,$aco_value_array) = @each($aco_array)) {
+ foreach ($aco_value_array as $aco_value) {
+ if (!in_array($aco_value, $acl_array['aco'][$aco_section_value])) {
+ $this->debug_text("append_acl(): ACO Section Value: $aco_section_value ACO VALUE: $aco_value");
+ $acl_array['aco'][$aco_section_value][] = $aco_value;
+ $update = 1;
+ } else {
+ $this->debug_text("append_acl(): Duplicate ACO, ignoring... ");
+ }
+ }
+ }
+ }
+
+ if ($update == 1) {
+ $this->debug_text("append_acl(): Update flag set, updating ACL.");
+ //function edit_acl($acl_id, $aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL) {
+ return $this->edit_acl($acl_id, $acl_array['aco'], $acl_array['aro'], $acl_array['aro_groups'], $acl_array['axo'], $acl_array['axo_groups'], $acl_array['allow'], $acl_array['enabled'], $acl_array['return_value'], $acl_array['note']);
+ }
+
+ //Return true if everything is duplicate and no ACL id updated.
+ $this->debug_text("append_acl(): Update flag not set, NOT updating ACL.");
+ return true;
+ }
+
+ /**
+ * shift_acl()
+ *
+ * Opposite of append_acl(). Removes objects from a specific ACL. (named after PHP's array_shift())
+ *
+ * @return bool TRUE if successful, FALSE otherwise.
+ *
+ * @param int ACL ID #
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ */
+ function shift_acl($acl_id, $aro_array=NULL, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $aco_array=NULL) {
+ $this->debug_text("shift_acl(): ACL_ID: $acl_id");
+
+ $update = 0;
+
+ if (empty($acl_id)) {
+ $this->debug_text("shift_acl(): No ACL_ID specified! ACL_ID: $acl_id");
+ return false;
+ }
+
+ //Grab ACL data.
+ $acl_array = &$this->get_acl($acl_id);
+
+ //showarray($acl_array);
+ //Remove each object type seperately.
+ if (is_array($aro_array) AND count($aro_array) > 0) {
+ $this->debug_text("shift_acl(): Removing ARO's");
+
+ while (list($aro_section_value,$aro_value_array) = @each($aro_array)) {
+ foreach ($aro_value_array as $aro_value) {
+ $this->debug_text("shift_acl(): ARO Section Value: $aro_section_value ARO VALUE: $aro_value");
+
+ //Only search if aro array contains data.
+ if ( count($acl_array['aro'][$aro_section_value]) != 0 ) {
+ $aro_key = array_search($aro_value, $acl_array['aro'][$aro_section_value]);
+
+ if ($aro_key !== FALSE) {
+ $this->debug_text("shift_acl(): Removing ARO. ($aro_key)");
+ unset($acl_array['aro'][$aro_section_value][$aro_key]);
+ $update = 1;
+ } else {
+ $this->debug_text("shift_acl(): ARO doesn't exist, can't remove it.");
+ }
+ }
+
+ }
+ }
+ }
+
+ if (is_array($aro_group_ids) AND count($aro_group_ids) > 0) {
+ $this->debug_text("shift_acl(): Removing ARO_GROUP_ID's");
+
+ while (list(,$aro_group_id) = @each($aro_group_ids)) {
+ $this->debug_text("shift_acl(): ARO Group ID: $aro_group_id");
+ $aro_group_key = array_search($aro_group_id, $acl_array['aro_groups']);
+
+ if ($aro_group_key !== FALSE) {
+ $this->debug_text("shift_acl(): Removing ARO Group. ($aro_group_key)");
+ unset($acl_array['aro_groups'][$aro_group_key]);
+ $update = 1;
+ } else {
+ $this->debug_text("shift_acl(): ARO Group doesn't exist, can't remove it.");
+ }
+ }
+ }
+
+ if (is_array($axo_array) AND count($axo_array) > 0) {
+ $this->debug_text("shift_acl(): Removing AXO's");
+
+ while (list($axo_section_value,$axo_value_array) = @each($axo_array)) {
+ foreach ($axo_value_array as $axo_value) {
+ $this->debug_text("shift_acl(): AXO Section Value: $axo_section_value AXO VALUE: $axo_value");
+ $axo_key = array_search($axo_value, $acl_array['axo'][$axo_section_value]);
+
+ if ($axo_key !== FALSE) {
+ $this->debug_text("shift_acl(): Removing AXO. ($axo_key)");
+ unset($acl_array['axo'][$axo_section_value][$axo_key]);
+ $update = 1;
+ } else {
+ $this->debug_text("shift_acl(): AXO doesn't exist, can't remove it.");
+ }
+ }
+ }
+ }
+
+ if (is_array($axo_group_ids) AND count($axo_group_ids) > 0) {
+ $this->debug_text("shift_acl(): Removing AXO_GROUP_ID's");
+
+ while (list(,$axo_group_id) = @each($axo_group_ids)) {
+ $this->debug_text("shift_acl(): AXO Group ID: $axo_group_id");
+ $axo_group_key = array_search($axo_group_id, $acl_array['axo_groups']);
+
+ if ($axo_group_key !== FALSE) {
+ $this->debug_text("shift_acl(): Removing AXO Group. ($axo_group_key)");
+ unset($acl_array['axo_groups'][$axo_group_key]);
+ $update = 1;
+ } else {
+ $this->debug_text("shift_acl(): AXO Group doesn't exist, can't remove it.");
+ }
+ }
+ }
+
+ if (is_array($aco_array) AND count($aco_array) > 0) {
+ $this->debug_text("shift_acl(): Removing ACO's");
+
+ while (list($aco_section_value,$aco_value_array) = @each($aco_array)) {
+ foreach ($aco_value_array as $aco_value) {
+ $this->debug_text("shift_acl(): ACO Section Value: $aco_section_value ACO VALUE: $aco_value");
+ $aco_key = array_search($aco_value, $acl_array['aco'][$aco_section_value]);
+
+ if ($aco_key !== FALSE) {
+ $this->debug_text("shift_acl(): Removing ACO. ($aco_key)");
+ unset($acl_array['aco'][$aco_section_value][$aco_key]);
+ $update = 1;
+ } else {
+ $this->debug_text("shift_acl(): ACO doesn't exist, can't remove it.");
+ }
+ }
+ }
+ }
+
+ if ($update == 1) {
+ //We know something was changed, so lets see if no ACO's or no ARO's are left assigned to this ACL, if so, delete the ACL completely.
+ //$this->showarray($acl_array);
+ $this->debug_text("shift_acl(): ACOs: ". $this->count_all($acl_array['aco']) ." AROs: ".$this->count_all($acl_array['aro'])."");
+
+ if ( $this->count_all($acl_array['aco']) == 0
+ OR ( $this->count_all($acl_array['aro']) == 0
+ AND ( $this->count_all($acl_array['axo']) == 0 OR $acl_array['axo'] == FALSE)
+ AND (count($acl_array['aro_groups']) == 0 OR $acl_array['aro_groups'] == FALSE)
+ AND (count($acl_array['axo_groups']) == 0 OR $acl_array['axo_groups'] == FALSE)
+ ) ) {
+ $this->debug_text("shift_acl(): No ACOs or ( AROs AND AXOs AND ARO Groups AND AXO Groups) left assigned to this ACL (ID: $acl_id), deleting ACL.");
+
+ return $this->del_acl($acl_id);
+ }
+
+ $this->debug_text("shift_acl(): Update flag set, updating ACL.");
+
+ return $this->edit_acl($acl_id, $acl_array['aco'], $acl_array['aro'], $acl_array['aro_groups'], $acl_array['axo'], $acl_array['axo_groups'], $acl_array['allow'], $acl_array['enabled'], $acl_array['return_value'], $acl_array['note']);
+ }
+
+ //Return true if everything is duplicate and no ACL id updated.
+ $this->debug_text("shift_acl(): Update flag not set, NOT updating ACL.");
+ return true;
+ }
+
+ /**
+ * get_acl()
+ *
+ * Grabs ACL data.
+ *
+ * @return bool FALSE if not found, or Associative Array with the following items:
+ *
+ * - 'aco' => Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * - 'aro' => Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * - 'axo' => Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * - 'aro_groups' => Array of Group IDs
+ * - 'axo_groups' => Array of Group IDs
+ * - 'acl_id' => int ACL ID #
+ * - 'allow' => int Allow flag
+ * - 'enabled' => int Enabled flag
+ * - 'return_value' => string Return Value
+ * - 'note' => string Note
+ *
+ * @param int ACL ID #
+ */
+ function get_acl($acl_id) {
+
+ $this->debug_text("get_acl(): ACL_ID: $acl_id");
+
+ if (empty($acl_id)) {
+ $this->debug_text("get_acl(): No ACL_ID specified! ACL_ID: $acl_id");
+ return false;
+ }
+
+ //Grab ACL information
+ $query = "select id, allow, enabled, return_value, note from ".$this->_db_table_prefix."acl where id = ".$acl_id."";
+ $acl_row = $this->db->GetRow($query);
+
+ // return false if not found
+ if (!$acl_row) {
+ $this->debug_text("get_acl(): No ACL found for that ID! ACL_ID: $acl_id");
+ return false;
+ }
+
+ list($retarr['acl_id'], $retarr['allow'], $retarr['enabled'], $retarr['return_value'], $retarr['note']) = $acl_row;
+
+ //Grab selected ACO's
+ $query = "select distinct a.section_value, a.value, c.name, b.name from ".$this->_db_table_prefix."aco_map a, ".$this->_db_table_prefix."aco b, ".$this->_db_table_prefix."aco_sections c
+ where ( a.section_value=b.section_value AND a.value = b.value) AND b.section_value=c.value AND a.acl_id = $acl_id";
+ $rs = $this->db->Execute($query);
+ $rows = $rs->GetRows();
+
+ $retarr['aco'] = array();
+ while (list(,$row) = @each($rows)) {
+ list($section_value, $value, $section, $aco) = $row;
+ $this->debug_text("Section Value: $section_value Value: $value Section: $section ACO: $aco");
+
+ $retarr['aco'][$section_value][] = $value;
+
+ }
+ //showarray($aco);
+
+ //Grab selected ARO's
+ $query = "select distinct a.section_value, a.value, c.name, b.name from ".$this->_db_table_prefix."aro_map a, ".$this->_db_table_prefix."aro b, ".$this->_db_table_prefix."aro_sections c
+ where ( a.section_value=b.section_value AND a.value = b.value) AND b.section_value=c.value AND a.acl_id = $acl_id";
+ $rs = $this->db->Execute($query);
+ $rows = $rs->GetRows();
+
+ $retarr['aro'] = array();
+ while (list(,$row) = @each($rows)) {
+ list($section_value, $value, $section, $aro) = $row;
+ $this->debug_text("Section Value: $section_value Value: $value Section: $section ARO: $aro");
+
+ $retarr['aro'][$section_value][] = $value;
+
+ }
+ //showarray($options_aro);
+
+ //Grab selected AXO's
+ $query = "select distinct a.section_value, a.value, c.name, b.name from ".$this->_db_table_prefix."axo_map a, ".$this->_db_table_prefix."axo b, ".$this->_db_table_prefix."axo_sections c
+ where ( a.section_value=b.section_value AND a.value = b.value) AND b.section_value=c.value AND a.acl_id = $acl_id";
+ $rs = $this->db->Execute($query);
+ $rows = $rs->GetRows();
+
+ $retarr['axo'] = array();
+ while (list(,$row) = @each($rows)) {
+ list($section_value, $value, $section, $axo) = $row;
+ $this->debug_text("Section Value: $section_value Value: $value Section: $section AXO: $axo");
+
+ $retarr['axo'][$section_value][] = $value;
+
+ }
+ //showarray($options_aro);
+
+ //Grab selected ARO groups.
+ $retarr['aro_groups'] = array();
+ $query = "select distinct group_id from ".$this->_db_table_prefix."aro_groups_map where acl_id = $acl_id";
+ $retarr['aro_groups'] = $this->db->GetCol($query);
+ //showarray($selected_groups);
+
+ //Grab selected AXO groups.
+ $retarr['axo_groups'] = array();
+ $query = "select distinct group_id from ".$this->_db_table_prefix."axo_groups_map where acl_id = $acl_id";
+ $retarr['axo_groups'] = $this->db->GetCol($query);
+ //showarray($selected_groups);
+
+ return $retarr;
+ }
+
+ /**
+ * is_conflicting_acl()
+ *
+ * Checks for conflicts when adding a specific ACL.
+ *
+ * @return bool Returns true if conflict is found.
+ *
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Array of ACL IDs to ignore from the result set.
+ *
+ */
+ function is_conflicting_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $ignore_acl_ids=NULL) {
+ //Check for potential conflicts. Ignore groups, as groups will almost always have "conflicting" ACLs.
+ //Thats part of inheritance.
+
+ if (!is_array($aco_array)) {
+ $this->debug_text('is_conflicting_acl(): Invalid ACO Array.');
+ return FALSE;
+ }
+
+ if (!is_array($aro_array)) {
+ $this->debug_text('is_conflicting_acl(): Invalid ARO Array.');
+ return FALSE;
+ }
+
+ $query = '
+ SELECT a.id
+ FROM '. $this->_db_table_prefix .'acl a
+ LEFT JOIN '. $this->_db_table_prefix .'aco_map ac ON ac.acl_id=a.id
+ LEFT JOIN '. $this->_db_table_prefix .'aro_map ar ON ar.acl_id=a.id
+ LEFT JOIN '. $this->_db_table_prefix .'axo_map ax ON ax.acl_id=a.id
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups_map axg ON axg.acl_id=a.id
+ LEFT JOIN '. $this->_db_table_prefix .'axo_groups xg ON xg.id=axg.group_id
+ ';
+
+ //ACO
+ foreach ($aco_array as $aco_section_value => $aco_value_array) {
+ $this->debug_text("is_conflicting_acl(): ACO Section Value: $aco_section_value ACO VALUE: $aco_value_array");
+ //showarray($aco_array);
+
+ if (!is_array($aco_value_array)) {
+ $this->debug_text('is_conflicting_acl(): Invalid Format for ACO Array item. Skipping...');
+ continue;
+ // return TRUE;
+ }
+ //Move the below line in to the LEFT JOIN above for PostgreSQL sake.
+ //'ac1' => 'ac.acl_id=a.id',
+ $where_query = array(
+ 'ac2' => '(ac.section_value='. $this->db->quote($aco_section_value) .' AND ac.value IN (\''. implode ('\',\'', $aco_value_array) .'\'))'
+ );
+
+ //ARO
+ foreach ($aro_array as $aro_section_value => $aro_value_array) {
+ $this->debug_text("is_conflicting_acl(): ARO Section Value: $aro_section_value ARO VALUE: $aro_value_array");
+
+ if (!is_array($aro_value_array))
+ {
+ $this->debug_text('is_conflicting_acl(): Invalid Format for ARO Array item. Skipping...');
+ continue;
+ // return TRUE;
+ }
+
+ $this->debug_text("is_conflicting_acl(): Search: ACO Section: $aco_section_value ACO Value: $aco_value_array ARO Section: $aro_section_value ARO Value: $aro_value_array");
+
+ //Move the below line in to the LEFT JOIN above for PostgreSQL sake.
+ //$where_query['ar1'] = 'ar.acl_id=a.id';
+ $where_query['ar2'] = '(ar.section_value='. $this->db->quote($aro_section_value) .' AND ar.value IN (\''. implode ('\',\'', $aro_value_array) .'\'))';
+
+ if (is_array($axo_array) AND count($axo_array) > 0) {
+ foreach ($axo_array as $axo_section_value => $axo_value_array) {
+ $this->debug_text("is_conflicting_acl(): AXO Section Value: $axo_section_value AXO VALUE: $axo_value_array");
+
+ if (!is_array($axo_value_array)) {
+ $this->debug_text('is_conflicting_acl(): Invalid Format for AXO Array item. Skipping...');
+ continue;
+ // return TRUE;
+ }
+
+ $this->debug_text("is_conflicting_acl(): Search: ACO Section: $aco_section_value ACO Value: $aco_value_array ARO Section: $aro_section_value ARO Value: $aro_value_array AXO Section: $axo_section_value AXO Value: $axo_value_array");
+
+ //$where_query['ax1'] = 'ax.acl_id=x.id';
+ $where_query['ax1'] = 'ax.acl_id=a.id';
+ $where_query['ax2'] = '(ax.section_value='. $this->db->quote($axo_section_value) .' AND ax.value IN (\''. implode ('\',\'', $axo_value_array) .'\'))';
+
+ $where = 'WHERE ' . implode(' AND ', $where_query);
+
+ $conflict_result = $this->db->GetCol($query . $where);
+
+ if (is_array($conflict_result) AND !empty($conflict_result)) {
+ // showarray($conflict_result);
+
+ if (is_array($ignore_acl_ids)) {
+ $conflict_result = array_diff($conflict_result, $ignore_acl_ids);
+ }
+
+ if (count($conflict_result) > 0) {
+ $conflicting_acls_str = implode(',', $conflict_result);
+ $this->debug_text("is_conflicting_acl(): Conflict FOUND!!! ACL_IDS: ($conflicting_acls_str)");
+ return TRUE;
+ }
+ }
+ }
+ } else {
+ $where_query['ax1'] = '(ax.section_value IS NULL AND ax.value IS NULL)';
+ $where_query['ax2'] = 'xg.name IS NULL';
+
+ $where = 'WHERE ' . implode(' AND ', $where_query);
+
+ $conflict_result = $this->db->GetCol($query . $where);
+
+ if (is_array($conflict_result) AND !empty($conflict_result)) {
+ // showarray($conflict_result);
+
+ if (is_array($ignore_acl_ids)) {
+ $conflict_result = array_diff($conflict_result, $ignore_acl_ids);
+ }
+
+ if (count($conflict_result) > 0) {
+ $conflicting_acls_str = implode(',', $conflict_result);
+ $this->debug_text("is_conflicting_acl(): Conflict FOUND!!! ACL_IDS: ($conflicting_acls_str)");
+ return TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ $this->debug_text('is_conflicting_acl(): No conflicting ACL found.');
+ return FALSE;
+ }
+
+ /**
+ * add_acl()
+ *
+ * Add's an ACL. ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.
+ *
+ * @return bool Return ACL ID of new ACL if successful, FALSE otherewise.
+ *
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param int Allow flag
+ * @param int Enabled flag
+ * @param string Return Value
+ * @param string Note
+ * @param string ACL Section Value
+ * @param int ACL ID # Specific Request
+
+ */
+ function add_acl($aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $section_value=NULL, $acl_id=FALSE ) {
+
+ $this->debug_text("add_acl():");
+
+ if (count($aco_array) == 0) {
+ $this->debug_text("Must select at least one Access Control Object");
+ return false;
+ }
+
+ if (count($aro_array) == 0 AND count($aro_group_ids) == 0) {
+ $this->debug_text("Must select at least one Access Request Object or Group");
+ return false;
+ }
+
+ if (empty($allow)) {
+ $allow=0;
+ }
+
+ if (empty($enabled)) {
+ $enabled=0;
+ }
+
+ if (!empty($section_value)
+ AND !$this->get_object_section_section_id(NULL, $section_value, 'ACL')) {
+ $this->debug_text("add_acl(): Section Value: $section_value DOES NOT exist in the database.");
+ return false;
+ }
+
+ //Unique the group arrays. Later one we unique ACO/ARO/AXO arrays.
+ if (is_array($aro_group_ids)) {
+ $aro_group_ids = array_unique($aro_group_ids);
+ }
+ if (is_array($axo_group_ids)) {
+ $axo_group_ids = array_unique($axo_group_ids);
+ }
+
+ //Check for conflicting ACLs.
+ if ($this->is_conflicting_acl($aco_array,$aro_array,$aro_group_ids,$axo_array,$axo_group_ids,array($acl_id))) {
+ $this->debug_text("add_acl(): Detected possible ACL conflict, not adding ACL!");
+ return false;
+ }
+
+ //Edit ACL if acl_id is set. This is simply if we're being called by edit_acl().
+ if ($this->get_acl($acl_id) == FALSE) {
+ if ( empty($section_value) ) {
+ $section_value='system';
+ if( !$this->get_object_section_section_id(NULL, $section_value, 'ACL') ) {
+ // Use the acl section with the lowest order value.
+ $acl_sections_table = $this->_db_table_prefix .'acl_sections';
+ $acl_section_order_value = $this->db->GetOne("SELECT min(order_value) from $acl_sections_table");
+
+ $query = "
+ SELECT value
+ FROM $acl_sections_table
+ WHERE order_value = $acl_section_order_value
+ ";
+ $section_value = $this->db->GetOne($query);
+
+ if ( empty($section_value) ) {
+ $this->debug_text("add_acl(): No valid acl section found.");
+ return false;
+ } else {
+ $this->debug_text("add_acl(): Using default section value: $section_value.");
+ }
+ }
+ }
+
+ //ACL not specified, so create acl_id
+ if (empty($acl_id)) {
+ //Create ACL row first, so we have the acl_id
+ $acl_id = $this->db->GenID($this->_db_table_prefix.'acl_seq',10);
+
+ //Double check the ACL ID was generated.
+ if (empty($acl_id)) {
+ $this->debug_text("add_acl(): ACL_ID generation failed!");
+ return false;
+ }
+ }
+
+ //Begin transaction _after_ GenID. Because on the first run, if GenID has to create the sequence,
+ //the transaction will fail.
+ $this->db->BeginTrans();
+
+ $query = 'INSERT INTO '.$this->_db_table_prefix.'acl (id,section_value,allow,enabled,return_value,note,updated_date) VALUES('. $acl_id .','. $this->db->quote($section_value) .','. $allow .','. $enabled .','. $this->db->quote($return_value) .', '. $this->db->quote($note) .','. time() .')';
+ $result = $this->db->Execute($query);
+ } else {
+ $section_sql = '';
+ if ( !empty($section_value) ) {
+ $section_sql = 'section_value='. $this->db->quote ($section_value) .',';
+ }
+
+ $this->db->BeginTrans();
+
+ //Update ACL row, and remove all mappings so they can be re-inserted.
+ $query = '
+ UPDATE '. $this->_db_table_prefix .'acl
+ SET ' . $section_sql . '
+ allow='. $allow .',
+ enabled='. $enabled .',
+ return_value='. $this->db->quote($return_value) .',
+ note='. $this->db->quote($note) .',
+ updated_date='. time() .'
+ WHERE id='. $acl_id;
+ $result = $this->db->Execute($query);
+
+ if ($result) {
+ $this->debug_text("Update completed without error, delete mappings...");
+ //Delete all mappings so they can be re-inserted.
+ foreach (array('aco_map', 'aro_map', 'axo_map', 'aro_groups_map', 'axo_groups_map') as $map) {
+ $query = 'DELETE FROM '. $this->_db_table_prefix . $map .' WHERE acl_id='. $acl_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs))
+ {
+ $this->debug_db('add_acl');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ if (!is_object($result)) {
+ $this->debug_db('add_acl');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $this->debug_text("Insert or Update completed without error, insert new mappings.");
+ // Insert ACO/ARO/AXO mappings
+ foreach (array('aco', 'aro', 'axo') as $map) {
+ $map_array = ${$map .'_array'};
+
+ if (!is_array ($map_array)) {
+ continue;
+ }
+
+ foreach ($map_array as $section_value => $value_array) {
+ $this->debug_text ('Insert: '. strtoupper($map) .' Section Value: '. $section_value .' '. strtoupper($map) .' VALUE: '. $value_array);
+ // $this->showarray ($aco_value_array);
+
+ if (!is_array($value_array)) {
+ $this->debug_text ('add_acl (): Invalid Format for '. strtoupper ($map) .' Array item. Skipping...');
+ continue;
+ // return true;
+ }
+
+ $value_array = array_unique($value_array);
+
+ foreach ($value_array as $value) {
+ $object_id = &$this->get_object_id($section_value, $value, $map);
+
+ if (empty($object_id))
+ {
+ $this->debug_text('add_acl(): '. strtoupper($map) . " Object Section Value: $section_value Value: $value DOES NOT exist in the database. Skipping...");
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $query = 'INSERT INTO '. $this->_db_table_prefix . $map .'_map (acl_id,section_value,value) VALUES ('. $acl_id .', '. $this->db->quote($section_value) .', '. $this->db->quote($value) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs))
+ {
+ $this->debug_db('add_acl');
+ $this->db->RollBackTrans();
+ return false;
+ }
+ }
+ }
+ }
+
+ // Insert ARO/AXO GROUP mappings
+ foreach (array('aro', 'axo') as $map) {
+ $map_group_ids = ${$map .'_group_ids'};
+
+ if (!is_array($map_group_ids)) {
+ continue;
+ }
+
+ foreach ($map_group_ids as $group_id) {
+ $this->debug_text ('Insert: '. strtoupper($map) .' GROUP ID: '. $group_id);
+
+ $group_data = &$this->get_group_data($group_id, $map);
+
+ if (empty($group_data)) {
+ $this->debug_text('add_acl(): '. strtoupper($map) . " Group: $group_id DOES NOT exist in the database. Skipping...");
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $query = 'INSERT INTO '. $this->_db_table_prefix . $map .'_groups_map (acl_id,group_id) VALUES ('. $acl_id .', '. $group_id .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_acl');
+ $this->db->RollBackTrans();
+ return false;
+ }
+ }
+ }
+
+ $this->db->CommitTrans();
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ //Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ //Return only the ID in the first row.
+ return $acl_id;
+ }
+
+ /**
+ * edit_acl()
+ *
+ * Edit's an ACL, ACO_IDS, ARO_IDS, GROUP_IDS must all be arrays.
+ *
+ * @return bool Return TRUE if successful, FALSE otherewise.
+ *
+ * @param int ACL ID # to edit
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ * @param array Array of Group IDs
+ * @param int Allow flag
+ * @param int Enabled flag
+ * @param string Return Value
+ * @param string Note
+ * @param string ACL Section Value
+ */
+ function edit_acl($acl_id, $aco_array, $aro_array, $aro_group_ids=NULL, $axo_array=NULL, $axo_group_ids=NULL, $allow=1, $enabled=1, $return_value=NULL, $note=NULL, $section_value=NULL) {
+
+ $this->debug_text("edit_acl():");
+
+ if (empty($acl_id) ) {
+ $this->debug_text("edit_acl(): Must specify a single ACL_ID to edit");
+ return false;
+ }
+ if (count($aco_array) == 0) {
+ $this->debug_text("edit_acl(): Must select at least one Access Control Object");
+ return false;
+ }
+
+ if (count($aro_array) == 0 AND count($aro_group_ids) == 0) {
+ $this->debug_text("edit_acl(): Must select at least one Access Request Object or Group");
+ return false;
+ }
+
+ if (empty($allow)) {
+ $allow=0;
+ }
+
+ if (empty($enabled)) {
+ $enabled=0;
+ }
+
+ //if ($this->add_acl($aco_array, $aro_array, $group_ids, $allow, $enabled, $acl_id)) {
+ if ($this->add_acl($aco_array, $aro_array, $aro_group_ids, $axo_array, $axo_group_ids, $allow, $enabled, $return_value, $note, $section_value, $acl_id)) {
+ return true;
+ } else {
+ $this->debug_text("edit_acl(): error in add_acl()");
+ return false;
+ }
+ }
+
+ /**
+ * del_acl()
+ *
+ * Deletes a given ACL
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise.
+ *
+ * @param int ACL ID # to delete
+ */
+ function del_acl($acl_id) {
+
+ $this->debug_text("del_acl(): ID: $acl_id");
+
+ if (empty($acl_id) ) {
+ $this->debug_text("del_acl(): ACL_ID ($acl_id) is empty, this is required");
+ return false;
+ }
+
+ $this->db->BeginTrans();
+
+ // Delete all mappings to the ACL first
+ foreach (array('aco_map', 'aro_map', 'axo_map', 'aro_groups_map', 'axo_groups_map') as $map) {
+ $query = 'DELETE FROM '. $this->_db_table_prefix . $map .' WHERE acl_id='. $acl_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('del_acl');
+ $this->db->RollBackTrans();
+ return false;
+ }
+ }
+
+ // Delete the ACL
+ $query = 'DELETE FROM '. $this->_db_table_prefix .'acl WHERE id='. $acl_id;
+ $this->debug_text('delete query: '. $query);
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('del_acl');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $this->debug_text("del_acl(): deleted ACL ID: $acl_id");
+ $this->db->CommitTrans();
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ //Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ return TRUE;
+ }
+
+
+ /*
+ *
+ * Groups
+ *
+ */
+
+ /**
+ * sort_groups()
+ *
+ * Grabs all the groups from the database doing preliminary grouping by parent
+ *
+ * @return array Returns 2-Dimensional array: $array[<parent_id>][<group_id>] = <group_name>
+ *
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function sort_groups($group_type='ARO') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ //Grab all groups from the database.
+ $query = 'SELECT id, parent_id, name FROM '. $table .' ORDER BY parent_id, name';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('sort_groups');
+ return false;
+ }
+
+ /*
+ * Save groups in an array sorted by parent. Should be make it easier for later on.
+ */
+ $sorted_groups = array();
+
+ while ($row = $rs->FetchRow()) {
+ $id = &$row[0];
+ $parent_id = &$row[1];
+ $name = &$row[2];
+
+ $sorted_groups[$parent_id][$id] = $name;
+ }
+
+ return $sorted_groups;
+ }
+
+ /**
+ * format_groups()
+ *
+ * Takes the array returned by sort_groups() and formats for human
+ * consumption. Recursively calls itself to produce the desired output.
+ *
+ * @return array Array of formatted text, ordered by group id, formatted according to $type
+ *
+ * @param array Output from gacl_api->sorted_groups($group_type)
+ * @param array Output type desired, either 'TEXT', 'HTML', or 'ARRAY'
+ * @param int Root of tree to produce
+ * @param int Current level of depth
+ * @param array Pass the current formatted groups object for appending via recursion.
+ */
+ function format_groups($sorted_groups, $type='TEXT', $root_id=0, $level=0, $formatted_groups=NULL) {
+ if ( !is_array ($sorted_groups) ) {
+ return FALSE;
+ }
+
+ if ( !is_array ($formatted_groups) ) {
+ $formatted_groups = array ();
+ }
+
+ //$this->showarray($formatted_groups);
+
+ //while (list($id,$name) = @each($sorted_groups[$root_id])) {
+ if (isset($sorted_groups[$root_id])) {
+ //$last_id = end( array_keys($sorted_groups[$root_id]));
+ //PHP5 compatibility
+ $keys = array_keys($sorted_groups[$root_id]);
+ $last_id = end($keys);
+ unset($keys);
+
+ foreach ($sorted_groups[$root_id] as $id => $name) {
+ switch (strtoupper($type)) {
+ case 'TEXT':
+ /*
+ * Formatting optimized for TEXT (combo box) output.
+ */
+
+ if ( is_numeric($level) ) {
+ $level = str_repeat('&nbsp;&nbsp; ', $level);
+ }
+
+ if ( strlen($level) >= 8 ) {
+ if ( $id == $last_id ) {
+ $spacing = substr($level, 0, -8) .'\'- ';
+ $level = substr($level, 0, -8) .'&nbsp;&nbsp; ';
+ } else {
+ $spacing = substr($level, 0, -8) .'|- ';
+ }
+ } else {
+ $spacing = $level;
+ }
+
+ $next = $level .'|&nbsp; ';
+ $text = $spacing.$name;
+ break;
+ case 'HTML':
+ /*
+ * Formatting optimized for HTML (tables) output.
+ */
+ $width= $level * 20;
+ $spacing = "<img src=\"s.gif\" width=\"$width\">";
+ $next = $level + 1;
+ $text = $spacing." ".$name;
+ break;
+ case 'ARRAY':
+ $next = $level;
+ $text = $name;
+ break;
+ default:
+ return FALSE;
+ }
+
+ $formatted_groups[$id] = $text;
+ /*
+ * Recurse if we can.
+ */
+
+ //if (isset($sorted_groups[$id]) AND count($sorted_groups[$id]) > 0) {
+ if (isset($sorted_groups[$id]) ) {
+ //$this->debug_text("format_groups(): Recursing! Level: $level");
+ $formatted_groups = $this->format_groups($sorted_groups, $type, $id, $next, $formatted_groups);
+ } else {
+ //$this->debug_text("format_groups(): Found last branch!");
+ }
+ }
+ }
+
+ //$this->debug_text("format_groups(): Returning final array.");
+
+ return $formatted_groups;
+ }
+
+ /**
+ * get_group_id()
+ *
+ * Gets the group_id given the name or value.
+ *
+ * Will only return one group id, so if there are duplicate names, it will return false.
+ *
+ * @return int Returns Group ID if found and Group ID is unique in database, otherwise, returns FALSE
+ *
+ * @param string Group Value
+ * @param string Group Name
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function get_group_id($value = NULL, $name = NULL, $group_type = 'ARO') {
+
+ $this->debug_text("get_group_id(): Value: $value, Name: $name, Type: $group_type" );
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ $name = trim($name);
+ $value = trim($value);
+
+ if (empty($name) AND empty($value) ) {
+ $this->debug_text("get_group_id(): name and value, at least one is required");
+ return false;
+ }
+
+ $query = 'SELECT id FROM '. $table .' WHERE ';
+ if ( !empty($value) ) {
+ $query .= ' value='. $this->db->quote($value);
+ } else {
+ $query .= ' name='. $this->db->quote($name);
+ }
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_group_id');
+ return false;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ if ($row_count > 1) {
+ $this->debug_text("get_group_id(): Returned $row_count rows, can only return one. Please make your names unique.");
+ return false;
+ }
+
+ if ($row_count == 0) {
+ $this->debug_text("get_group_id(): Returned $row_count rows");
+ return false;
+ }
+
+ $row = $rs->FetchRow();
+
+ //Return the ID.
+ return $row[0];
+ }
+
+ /**
+ * get_group_children()
+ *
+ * Gets a groups child IDs
+ *
+ * @return array Array of Child ID's of the referenced group
+ *
+ * @param int Group ID #
+ * @param int Group Type, either 'ARO' or 'AXO'
+ * @param string Either 'RECURSE' or 'NO_RECURSE', to recurse while fetching group children.
+ */
+ function get_group_children($group_id, $group_type = 'ARO', $recurse = 'NO_RECURSE') {
+ $this->debug_text("get_group_children(): Group_ID: $group_id Group Type: $group_type Recurse: $recurse");
+
+ switch (strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ }
+
+ if (empty($group_id)) {
+ $this->debug_text("get_group_children(): ID ($group_id) is empty, this is required");
+ return FALSE;
+ }
+
+ $query = '
+ SELECT g1.id
+ FROM '. $table .' g1';
+
+ //FIXME-mikeb: Why is group_id in quotes?
+ switch (strtoupper($recurse)) {
+ case 'RECURSE':
+ $query .= '
+ LEFT JOIN '. $table .' g2 ON g2.lft<g1.lft AND g2.rgt>g1.rgt
+ WHERE g2.id='. $group_id;
+ break;
+ default:
+ $query .= '
+ WHERE g1.parent_id='. $group_id;
+ }
+
+ $query .= '
+ ORDER BY g1.value';
+
+ return $this->db->GetCol($query);
+ }
+
+ /**
+ * get_group_data()
+ *
+ * Gets the group data given the GROUP_ID.
+ *
+ * @return array Returns numerically indexed array with the following columns:
+ * - array[0] = (int) Group ID #
+ * - array[1] = (int) Parent Group ID #
+ * - array[2] = (string) Group Value
+ * - array[3] = (string) Group Name
+ * - array[4] = (int) lft MPTT Value
+ * - array[5] = (int) rgt MPTT Value
+ *
+ * @param int Group ID #
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function get_group_data($group_id, $group_type = 'ARO') {
+
+ $this->debug_text("get_group_data(): Group_ID: $group_id Group Type: $group_type");
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ if (empty($group_id) ) {
+ $this->debug_text("get_group_data(): ID ($group_id) is empty, this is required");
+ return false;
+ }
+
+ $query = 'SELECT id, parent_id, value, name, lft, rgt FROM '. $table .' WHERE id='. $group_id;
+ //$rs = $this->db->Execute($query);
+ $row = $this->db->GetRow($query);
+
+ if ($row) {
+ return $row;
+ }
+
+ $this->debug_text("get_object_data(): Group does not exist.");
+ return false;
+ }
+
+ /**
+ * get_group_parent_id()
+ *
+ * Grabs the parent_id of a given group
+ *
+ * @return int Parent ID of the Group
+ *
+ * @param int Group ID #
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function get_group_parent_id($id, $group_type='ARO') {
+
+ $this->debug_text("get_group_parent_id(): ID: $id Group Type: $group_type");
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ if (empty($id) ) {
+ $this->debug_text("get_group_parent_id(): ID ($id) is empty, this is required");
+ return false;
+ }
+
+ $query = 'SELECT parent_id FROM '. $table .' WHERE id='. $id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_group_parent_id');
+ return false;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ if ($row_count > 1) {
+ $this->debug_text("get_group_parent_id(): Returned $row_count rows, can only return one. Please make your names unique.");
+ return false;
+ }
+
+ if ($row_count == 0) {
+ $this->debug_text("get_group_parent_id(): Returned $row_count rows");
+ return false;
+ }
+
+ $row = $rs->FetchRow();
+
+ //Return the ID.
+ return $row[0];
+ }
+
+
+ /**
+ * get_root_group_id ()
+ *
+ * Grabs the id of the root group for the specified tree
+ *
+ * @return int Root Group ID #
+ *
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function get_root_group_id($group_type='ARO') {
+
+ $this->debug_text('get_root_group_id(): Group Type: '. $group_type);
+
+ switch (strtolower($group_type)) {
+ case 'axo':
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ case 'aro':
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ default:
+ $this->debug_text('get_root_group_id(): Invalid Group Type: '. $group_type);
+ return FALSE;
+ }
+
+ $query = 'SELECT id FROM '. $table .' WHERE parent_id=0';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_root_group_id');
+ return FALSE;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ switch ($row_count) {
+ case 1:
+ $row = $rs->FetchRow();
+ // Return the ID.
+ return $row[0];
+ case 0:
+ $this->debug_text('get_root_group_id(): Returned 0 rows, you do not have a root group defined yet.');
+ return FALSE;
+ }
+
+ $this->debug_text('get_root_group_id(): Returned '. $row_count .' rows, can only return one. Your tree is very broken.');
+ return FALSE;
+ }
+
+ /*======================================================================*\
+ Function: map_path_to_root()
+ Purpose: Maps a unique path to root to a specific group. Each group can only have
+ one path to root.
+ \*======================================================================*/
+ /** REMOVED **/
+ /*======================================================================*\
+ Function: put_path_to_root()
+ Purpose: Writes the unique path to root to the database. There should really only be
+ one path to root for each level "deep" the groups go. If the groups are branched
+ 10 levels deep, there should only be 10 unique path to roots. These of course
+ overlap each other more and more the closer to the root/trunk they get.
+ \*======================================================================*/
+ /** REMOVED **/
+ /*======================================================================*\
+ Function: clean_path_to_root()
+ Purpose: Cleans up any paths that are not being used.
+ \*======================================================================*/
+ /** REMOVED **/
+ /*======================================================================*\
+ Function: get_path_to_root()
+ Purpose: Generates the path to root for a given group.
+ \*======================================================================*/
+ /** REMOVED **/
+
+ /**
+ * add_group()
+ *
+ * Inserts a group, defaults to be on the "root" branch.
+ *
+ * Since v3.3.x you can only create one group with Parent_ID=0
+ * So, its a good idea to create a "Virtual Root" group with Parent_ID=0
+ * Then assign other groups to that.
+ *
+ * @return int New Group ID # if successful, FALSE if otherwise.
+ *
+ * @param string Group Value
+ * @param string Group Name
+ * @param int Parent Group ID #
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function add_group($value, $name, $parent_id=0, $group_type='ARO') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ $this->debug_text("add_group(): Name: $name Value: $value Parent ID: $parent_id Group Type: $group_type");
+
+ $name = trim($name);
+ $value = trim($value);
+
+ if ( $name == '' ) {
+ $this->debug_text("add_group(): name ($name) OR parent id ($parent_id) is empty, this is required");
+ return false;
+ }
+
+ //This has to be outside the transaction, because the first time it is run, it will say the sequence
+ //doesn't exist. Then try to create it, but the transaction will already by aborted by then.
+ $insert_id = $this->db->GenID($this->_db_table_prefix.$group_type.'_groups_id_seq',10);
+ if ( $value === '' ) {
+ $value = $insert_id;
+ }
+
+ $this->db->BeginTrans();
+
+ // special case for root group
+ if ($parent_id == 0) {
+ // check a root group is not already defined
+ $query = 'SELECT id FROM '. $table .' WHERE parent_id=0';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ if ($rs->RowCount() > 0) {
+ $this->debug_text('add_group (): A root group already exists.');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ $parent_lft = 0;
+ $parent_rgt = 1;
+ } else {
+ if (empty($parent_id)) {
+ $this->debug_text("add_group (): parent id ($parent_id) is empty, this is required");
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+
+ // grab parent details from database
+ $query = 'SELECT id, lft, rgt FROM '. $table .' WHERE id='. $parent_id;
+ $row = $this->db->GetRow($query);
+
+ if (!is_array($row)) {
+ $this->debug_db('add_group');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ if (empty($row)) {
+ $this->debug_text('add_group (): Parent ID: '. $parent_id .' not found.');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ $parent_lft = &$row[1];
+ $parent_rgt = &$row[2];
+
+ // make room for the new group
+ $query = 'UPDATE '. $table .' SET rgt=rgt+2 WHERE rgt>='. $parent_rgt;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ $query = 'UPDATE '. $table .' SET lft=lft+2 WHERE lft>'. $parent_rgt;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+ }
+
+ $query = 'INSERT INTO '. $table .' (id,parent_id,name,value,lft,rgt) VALUES ('. $insert_id .','. $parent_id .','. $this->db->quote($name) .','. $this->db->quote($value) .','. $parent_rgt .','. ($parent_rgt + 1) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ $this->db->CommitTrans();
+
+ $this->debug_text('add_group (): Added group as ID: '. $insert_id);
+ return $insert_id;
+ }
+
+ /**
+ * get_group_objects()
+ *
+ * Gets all objects assigned to a group.
+ *
+ * If $option == 'RECURSE' it will get all objects in child groups as well.
+ * defaults to omit child groups.
+ *
+ * @return array Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+
+ *
+ * @param int Group ID #
+ * @param string Group Type, either 'ARO' or 'AXO'
+ * @param string Option, either 'RECURSE' or 'NO_RECURSE'
+ */
+ function get_group_objects($group_id, $group_type='ARO', $option='NO_RECURSE') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $object_table = $this->_db_table_prefix .'axo';
+ $group_table = $this->_db_table_prefix .'axo_groups';
+ $map_table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ default:
+ $group_type = 'aro';
+ $object_table = $this->_db_table_prefix .'aro';
+ $group_table = $this->_db_table_prefix .'aro_groups';
+ $map_table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ }
+
+ $this->debug_text("get_group_objects(): Group ID: $group_id");
+
+ if (empty($group_id)) {
+ $this->debug_text("get_group_objects(): Group ID: ($group_id) is empty, this is required");
+ return false;
+ }
+
+ $query = '
+ SELECT o.section_value,o.value';
+
+ if ($option == 'RECURSE') {
+ $query .= '
+ FROM '. $group_table .' g2
+ JOIN '. $group_table .' g1 ON g1.lft>=g2.lft AND g1.rgt<=g2.rgt
+ JOIN '. $map_table .' gm ON gm.group_id=g1.id
+ JOIN '. $object_table .' o ON o.id=gm.'. $group_type .'_id
+ WHERE g2.id='. $group_id;
+ } else {
+ $query .= '
+ FROM '. $map_table .' gm
+ JOIN '. $object_table .' o ON o.id=gm.'. $group_type .'_id
+ WHERE gm.group_id='. $group_id;
+ }
+
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_group_objects');
+ return false;
+ }
+
+ $this->debug_text("get_group_objects(): Got group objects, formatting array.");
+
+ $retarr = array();
+
+ //format return array.
+ while ($row = $rs->FetchRow()) {
+ $section = &$row[0];
+ $value = &$row[1];
+
+ $retarr[$section][] = $value;
+ }
+
+ return $retarr;
+ }
+
+ /**
+ * add_group_object()
+ *
+ * Assigns an Object to a group
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise.
+ *
+ * @param int Group ID #
+ * @param string Object Section Value
+ * @param string Object Value
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function add_group_object($group_id, $object_section_value, $object_value, $group_type='ARO') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'groups_axo_map';
+ $object_table = $this->_db_table_prefix .'axo';
+ $group_table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'groups_aro_map';
+ $object_table = $this->_db_table_prefix .'aro';
+ $group_table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ $this->debug_text("add_group_object(): Group ID: $group_id Section Value: $object_section_value Value: $object_value Group Type: $group_type");
+
+ $object_section_value = trim($object_section_value);
+ $object_value = trim($object_value);
+
+ if (empty($group_id) OR empty($object_value) OR empty($object_section_value)) {
+ $this->debug_text("add_group_object(): Group ID: ($group_id) OR Value ($object_value) OR Section value ($object_section_value) is empty, this is required");
+ return false;
+ }
+
+ // test to see if object & group exist and if object is already a member
+ $query = '
+ SELECT o.id AS id,g.id AS group_id,gm.group_id AS member
+ FROM '. $object_table .' o
+ LEFT JOIN '. $group_table .' g ON g.id='. $group_id .'
+ LEFT JOIN '. $table .' gm ON (gm.'. $group_type .'_id=o.id AND gm.group_id=g.id)
+ WHERE (o.section_value='. $this->db->quote($object_section_value) .' AND o.value='. $this->db->quote($object_value) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group_object');
+ return FALSE;
+ }
+
+ if ($rs->RecordCount() != 1) {
+ $this->debug_text('add_group_object(): Value ('. $object_value .') OR Section value ('. $object_section_value .') is invalid. Does this object exist?');
+ return FALSE;
+ }
+
+ $row = $rs->FetchRow();
+
+ if ($row[1] != $group_id) {
+ $this->debug_text('add_group_object(): Group ID ('. $group_id .') is invalid. Does this group exist?');
+ return FALSE;
+ }
+
+ //Group_ID == Member
+ if ($row[1] == $row[2]) {
+ $this->debug_text('add_group_object(): Object: ('. $object_section_value .' -> '. $object_value .') is already a member of Group: ('. $group_id .')');
+ //Object is already assigned to group. Return true.
+ return TRUE;
+ }
+
+ $object_id = $row[0];
+
+ $query = 'INSERT INTO '. $table .' (group_id,'. $group_type .'_id) VALUES ('. $group_id .','. $object_id .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_group_object');
+ return FALSE;
+ }
+
+ $this->debug_text('add_group_object(): Added Object: '. $object_id .' to Group ID: '. $group_id);
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ //Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * del_group_object()
+ *
+ * Removes an Object from a group.
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param int Group ID #
+ * @param string Object Section Value
+ * @param string Object Value
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function del_group_object($group_id, $object_section_value, $object_value, $group_type='ARO') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ }
+
+ $this->debug_text("del_group_object(): Group ID: $group_id Section value: $object_section_value Value: $object_value");
+
+ $object_section_value = trim($object_section_value);
+ $object_value = trim($object_value);
+
+ if (empty($group_id) OR empty($object_value) OR empty($object_section_value)) {
+ $this->debug_text("del_group_object(): Group ID: ($group_id) OR Section value: $object_section_value OR Value ($object_value) is empty, this is required");
+ return false;
+ }
+
+ if (!$object_id = $this->get_object_id($object_section_value, $object_value, $group_type)) {
+ $this->debug_text ("del_group_object (): Group ID ($group_id) OR Value ($object_value) OR Section value ($object_section_value) is invalid. Does this object exist?");
+ return FALSE;
+ }
+
+ $query = 'DELETE FROM '. $table .' WHERE group_id='. $group_id .' AND '. $group_type .'_id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('del_group_object');
+ return false;
+ }
+
+ $this->debug_text("del_group_object(): Deleted Value: $object_value to Group ID: $group_id assignment");
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ //Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ return true;
+ }
+
+ /**
+ * edit_group()
+ *
+ * Edits a group
+ *
+ * @returns bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param int Group ID #
+ * @param string Group Value
+ * @param string Group Name
+ * @param int Parent ID #
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function edit_group($group_id, $value=NULL, $name=NULL, $parent_id=NULL, $group_type='ARO') {
+ $this->debug_text("edit_group(): ID: $group_id Name: $name Value: $value Parent ID: $parent_id Group Type: $group_type");
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ if (empty($group_id) ) {
+ $this->debug_text('edit_group(): Group ID ('. $group_id .') is empty, this is required');
+ return FALSE;
+ }
+
+ if ( !is_array($curr = $this->get_group_data($group_id, $group_type)) ) {
+ $this->debug_text('edit_group(): Invalid Group ID: '. $group_id);
+ return FALSE;
+ }
+
+ $name = trim($name);
+
+ // don't set name if it is unchanged
+ if ($name == $curr[3]) {
+ unset($name);
+ }
+
+ // don't set parent_id if it is unchanged
+ if ($parent_id == $curr[1]) {
+ unset($parent_id);
+ }
+
+ if (!empty($parent_id)) {
+ if ($group_id == $parent_id) {
+ $this->debug_text('edit_group(): Groups can\'t be a parent to themselves. Incest is bad. ;)');
+ return FALSE;
+ }
+
+ //Make sure we don't re-parent to our own children.
+ //Grab all children of this group_id.
+ $children_ids = $this->get_group_children($group_id, $group_type, 'RECURSE');
+ if (is_array($children_ids)) {
+ if (@in_array($parent_id, $children_ids) ) {
+ $this->debug_text('edit_group(): Groups can\'t be re-parented to their own children, this would be incestuous!');
+ return FALSE;
+ }
+ }
+ unset($children_ids);
+
+ // make sure parent exists
+ if (!$this->get_group_data($parent_id, $group_type)) {
+ $this->debug_text('edit_group(): Parent Group ('. $parent_id .') doesn\'t exist');
+ return FALSE;
+ }
+ }
+
+ $set = array();
+
+ // update name if it is specified.
+ if (!empty($name)) {
+ $set[] = 'name='. $this->db->quote($name);
+ }
+
+ // update parent_id if it is specified.
+ if (!empty($parent_id)) {
+ $set[] = 'parent_id='. $parent_id;
+ }
+
+ // update value if it is specified.
+ if (!empty($value)) {
+ $set[] = 'value='. $this->db->quote($value);
+ }
+
+ if (empty($set)) {
+ $this->debug_text('edit_group(): Nothing to update.');
+ return FALSE;
+ }
+
+ $this->db->BeginTrans();
+
+ $query = 'UPDATE '. $table .' SET '. implode(',', $set) .' WHERE id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_group');
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+
+ $this->debug_text('edit_group(): Modified group ID: '. $group_id);
+
+ // rebuild group tree if parent_id has changed
+ if (!empty($parent_id)) {
+ if (!$this->_rebuild_tree($table, $this->get_root_group_id($group_type))) {
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+ }
+
+ $this->db->CommitTrans();
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ // Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * rebuild_tree ()
+ *
+ * rebuilds the group tree for the given type
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param string Group Type, either 'ARO' or 'AXO'
+ * @param int Group ID #
+ * @param int Left value of Group
+ */
+ function rebuild_tree($group_type = 'ARO', $group_id = NULL, $left = 1) {
+ $this->debug_text("rebuild_tree(): Group Type: $group_type Group ID: $group_id Left: $left");
+
+ switch (strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ break;
+ }
+
+ if (!isset($group_id)) {
+ if ($group_id = $this->get_root_group_id($group_type)) {
+ $left = 1;
+ $this->debug_text('rebuild_tree(): No Group ID Specified, using Root Group ID: '. $group_id);
+ } else {
+ $this->debug_text('rebuild_tree(): A Root group could not be found, are there any groups defined?');
+ return FALSE;
+ }
+ }
+
+ $this->db->BeginTrans();
+ $rebuilt = $this->_rebuild_tree($table, $group_id, $left);
+
+ if ($rebuilt === FALSE) {
+ $this->debug_text('rebuild_tree(): Error rebuilding tree!');
+ $this->db->RollBackTrans();
+ return FALSE;
+ }
+
+ $this->db->CommitTrans();
+ $this->debug_text('rebuild_tree(): Tree rebuilt.');
+ return TRUE;
+ }
+ /**
+ * _rebuild_tree ()
+ *
+ * Utility recursive function called by rebuild_tree()
+ *
+ * @return int Returns right value of this node + 1
+ *
+ * @param string Table name of group type
+ * @param int Group ID #
+ * @param int Left value of Group
+ */
+ function _rebuild_tree($table, $group_id, $left = 1) {
+ $this->debug_text("_rebuild_tree(): Table: $table Group ID: $group_id Left: $left");
+
+ // get all children of this node
+ $query = 'SELECT id FROM '. $table .' WHERE parent_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('_rebuild_tree');
+ return FALSE;
+ }
+
+ // the right value of this node is the left value + 1
+ $right = $left + 1;
+
+ while ($row = $rs->FetchRow()) {
+ // recursive execution of this function for each
+ // child of this node
+ // $right is the current right value, which is
+ // incremented by the rebuild_tree function
+ $right = $this->_rebuild_tree($table, $row[0], $right);
+
+ if ($right === FALSE) {
+ return FALSE;
+ }
+ }
+
+ // we've got the left value, and now that we've processed
+ // the children of this node we also know the right value
+ $query = 'UPDATE '. $table .' SET lft='. $left .', rgt='. $right .' WHERE id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('_rebuild_tree');
+ return FALSE;
+ }
+
+ // return the right value of this node + 1
+ return $right + 1;
+ }
+
+ /**
+ * del_group()
+ *
+ * deletes a given group
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise.
+ *
+ * @param int Group ID #
+ * @param bool If TRUE, child groups of this group will be reparented to the current group's parent.
+ * @param string Group Type, either 'ARO' or 'AXO'
+ */
+ function del_group($group_id, $reparent_children=TRUE, $group_type='ARO') {
+
+ switch(strtolower(trim($group_type))) {
+ case 'axo':
+ $group_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_groups';
+ $groups_map_table = $this->_db_table_prefix .'axo_groups_map';
+ $groups_object_map_table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ default:
+ $group_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_groups';
+ $groups_map_table = $this->_db_table_prefix .'aro_groups_map';
+ $groups_object_map_table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ }
+
+ $this->debug_text("del_group(): ID: $group_id Reparent Children: $reparent_children Group Type: $group_type");
+
+ if (empty($group_id) ) {
+ $this->debug_text("del_group(): Group ID ($group_id) is empty, this is required");
+ return false;
+ }
+
+ // Get details of this group
+ $query = 'SELECT id, parent_id, name, lft, rgt FROM '. $table .' WHERE id='. $group_id;
+ $group_details = $this->db->GetRow($query);
+
+ if (!is_array($group_details)) {
+ $this->debug_db('del_group');
+ return false;
+ }
+
+ $parent_id = $group_details[1];
+
+ $left = $group_details[3];
+ $right = $group_details[4];
+
+ $this->db->BeginTrans();
+
+ // grab list of all children
+ $children_ids = $this->get_group_children($group_id, $group_type, 'RECURSE');
+
+ // prevent deletion of root group & reparent of children if it has more than one immediate child
+ if ($parent_id == 0) {
+ $query = 'SELECT count(*) FROM '. $table .' WHERE parent_id='. $group_id;
+ $child_count = $this->db->GetOne($query);
+
+ if (($child_count > 1) AND $reparent_children) {
+ $this->debug_text ('del_group (): You cannot delete the root group and reparent children, this would create multiple root groups.');
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+ }
+
+ $success = FALSE;
+
+ /*
+ * Handle children here.
+ */
+ switch (TRUE) {
+ // there are no child groups, just delete group
+ case !is_array($children_ids):
+ case count($children_ids) == 0:
+ // remove acl maps
+ $query = 'DELETE FROM '. $groups_map_table .' WHERE group_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove group object maps
+ $query = 'DELETE FROM '. $groups_object_map_table .' WHERE group_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove group
+ $query = 'DELETE FROM '. $table .' WHERE id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // move all groups right of deleted group left by width of deleted group
+ $query = 'UPDATE '. $table .' SET lft=lft-'. ($right-$left+1) .' WHERE lft>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $query = 'UPDATE '. $table .' SET rgt=rgt-'. ($right-$left+1) .' WHERE rgt>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $success = TRUE;
+ break;
+ case $reparent_children == TRUE:
+ // remove acl maps
+ $query = 'DELETE FROM '. $groups_map_table .' WHERE group_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove group object maps
+ $query = 'DELETE FROM '. $groups_object_map_table .' WHERE group_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove group
+ $query = 'DELETE FROM '. $table .' WHERE id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // set parent of immediate children to parent group
+ $query = 'UPDATE '. $table .' SET parent_id='. $parent_id .' WHERE parent_id='. $group_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // move all children left by 1
+ $query = 'UPDATE '. $table .' SET lft=lft-1, rgt=rgt-1 WHERE lft>'. $left .' AND rgt<'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // move all groups right of deleted group left by 2
+ $query = 'UPDATE '. $table .' SET lft=lft-2 WHERE lft>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $query = 'UPDATE '. $table .' SET rgt=rgt-2 WHERE rgt>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $success = TRUE;
+ break;
+ default:
+ // make list of group and all children
+ $group_ids = $children_ids;
+ $group_ids[] = $group_id;
+
+ // remove acl maps
+ $query = 'DELETE FROM '. $groups_map_table .' WHERE group_id IN ('. implode (',', $group_ids) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove group object maps
+ $query = 'DELETE FROM '. $groups_object_map_table .' WHERE group_id IN ('. implode (',', $group_ids) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // remove groups
+ $query = 'DELETE FROM '. $table .' WHERE id IN ('. implode (',', $group_ids) .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ // move all groups right of deleted group left by width of deleted group
+ $query = 'UPDATE '. $table .' SET lft=lft-'. ($right - $left + 1) .' WHERE lft>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $query = 'UPDATE '. $table .' SET rgt=rgt-'. ($right - $left + 1) .' WHERE rgt>'. $right;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ break;
+ }
+
+ $success = TRUE;
+ }
+
+ // if the delete failed, rollback the trans and return false
+ if (!$success) {
+
+ $this->debug_db('del_group');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $this->debug_text("del_group(): deleted group ID: $group_id");
+ $this->db->CommitTrans();
+
+ if ($this->_caching == TRUE AND $this->_force_cache_expire == TRUE) {
+ //Expire all cache.
+ $this->Cache_Lite->clean('default');
+ }
+
+ return true;
+
+ }
+
+
+ /*
+ *
+ * Objects (ACO/ARO/AXO)
+ *
+ */
+
+ /**
+ * get_object()
+ *
+ * Grabs all Objects's in the database, or specific to a section_value
+ *
+ * @return ADORecordSet Returns recordset directly, with object ID only selected:
+ *
+ * @param string Filter to this section value
+ * @param int Returns hidden objects if 1, leaves them out otherwise.
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
+ */
+ function get_object($section_value = null, $return_hidden=1, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ case 'acl':
+ $object_type = 'acl';
+ $table = $this->_db_table_prefix .'acl';
+ break;
+ default:
+ $this->debug_text('get_object(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_object(): Section Value: $section_value Object Type: $object_type");
+
+ $query = 'SELECT id FROM '. $table;
+
+ $where = array();
+
+ if (!empty($section_value)) {
+ $where[] = 'section_value='. $this->db->quote($section_value);
+ }
+
+ if ($return_hidden==0 AND $object_type != 'acl') {
+ $where[] = 'hidden=0';
+ }
+
+ if (!empty($where)) {
+ $query .= ' WHERE '. implode(' AND ', $where);
+ }
+
+ $rs = $this->db->GetCol($query);
+
+ if (!is_array($rs)) {
+ $this->debug_db('get_object');
+ return false;
+ }
+
+ // Return Object IDs
+ return $rs;
+ }
+ /**
+ * get_ungrouped_objects()
+ *
+ * Grabs ID's of all Objects (ARO's and AXO's only) in the database not assigned to a Group.
+ *
+ * This function is useful for applications that synchronize user databases with an outside source.
+ * If syncrhonization doesn't automatically place users in an appropriate group, this function can
+ * quickly identify them so that they can be assigned to the correct group.
+ *
+ * @return array Returns an array of object ID's
+ *
+ * @param int Returns hidden objects if 1, does not if 0.
+ * @param string Object Type, either 'ARO' or 'AXO' (groupable types)
+ */
+
+ function get_ungrouped_objects($return_hidden=1, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ default:
+ $this->debug_text('get_ungrouped_objects(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_ungrouped_objects(): Object Type: $object_type");
+
+ $query = 'SELECT id FROM '. $table. ' a
+ LEFT JOIN ' . $this->_db_table_prefix. 'groups_'.$object_type.'_map b ON a.id = b.'. $object_type .'_id';
+
+ $where = array();
+ $where[] = 'b.group_id IS NULL';
+
+ if ($return_hidden==0) {
+ $where[] = 'a.hidden=0';
+ }
+
+ if (!empty($where)) {
+ $query .= ' WHERE '. implode(' AND ', $where);
+ }
+
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_ungrouped_objects');
+ return false;
+ }
+
+ while(!$rs->EOF) {
+ $retarr[] = $rs->fields[0];
+ $rs->MoveNext();
+ }
+
+ // Return Array of object IDS
+ return $retarr;
+ }
+
+
+ /**
+ * get_objects ()
+ *
+ * Grabs all Objects in the database, or specific to a section_value
+ *
+ * @return array Returns objects in format suitable for add_acl and is_conflicting_acl
+ * - i.e. Associative array, item={Section Value}, key={Array of Object Values} i.e. ["<Section Value>" => ["<Value 1>", "<Value 2>", "<Value 3>"], ...]
+ *
+ * @param string Filter for section value
+ * @param int Returns hidden objects if 1, does not if 0
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO'
+ */
+ function get_objects($section_value = NULL, $return_hidden = 1, $object_type = NULL) {
+ switch (strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ default:
+ $this->debug_text('get_objects(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_objects(): Section Value: $section_value Object Type: $object_type");
+
+ $query = 'SELECT section_value,value FROM '. $table;
+
+ $where = array();
+
+ if (!empty($section_value)) {
+ $where[] = 'section_value='. $this->db->quote($section_value);
+ }
+
+ if ($return_hidden==0) {
+ $where[] = 'hidden=0';
+ }
+
+ if (!empty($where)) {
+ $query .= ' WHERE '. implode(' AND ', $where);
+ }
+
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_objects');
+ return FALSE;
+ }
+
+ $retarr = array();
+
+ while ($row = $rs->FetchRow()) {
+ $retarr[$row[0]][] = $row[1];
+ }
+
+ // Return objects
+ return $retarr;
+ }
+
+ /**
+ * get_object_data()
+ *
+ * Gets all data pertaining to a specific Object.
+ *
+ * @return array Returns 2-Dimensional array of rows with columns = ( section_value, value, order_value, name, hidden )
+ *
+ * @param int Object ID #
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO'
+ */
+ function get_object_data($object_id, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ default:
+ $this->debug_text('get_object_data(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_object_data(): Object ID: $object_id Object Type: $object_type");
+
+ if (empty($object_id) ) {
+ $this->debug_text("get_object_data(): Object ID ($object_id) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("get_object_data(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $query = 'SELECT section_value,value,order_value,name,hidden FROM '. $table .' WHERE id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_object_data');
+ return false;
+ }
+
+ if ($rs->RecordCount() < 1) {
+ $this->debug_text('get_object_data(): Returned '. $row_count .' rows');
+ return FALSE;
+ }
+
+ // Return all objects
+ return $rs->GetRows();
+ }
+
+ /**
+ * get_object_id()
+ *
+ * Gets the object_id given the section_value AND value of the object.
+ *
+ * @return int Object ID #
+ *
+ * @param string Object Section Value
+ * @param string Object Value
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO'
+ */
+ function get_object_id($section_value, $value, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ default:
+ $this->debug_text('get_object_id(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_object_id(): Section Value: $section_value Value: $value Object Type: $object_type");
+
+ $section_value = trim($section_value);
+ $value = trim($value);
+
+ if (empty($section_value) AND empty($value) ) {
+ $this->debug_text("get_object_id(): Section Value ($value) AND value ($value) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("get_object_id(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $query = 'SELECT id FROM '. $table .' WHERE section_value='. $this->db->quote($section_value) .' AND value='. $this->db->quote($value);
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_object_id');
+ return false;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ if ($row_count > 1) {
+ $this->debug_text("get_object_id(): Returned $row_count rows, can only return one. This should never happen, the database may be missing a unique key.");
+ return false;
+ }
+
+ if ($row_count == 0) {
+ $this->debug_text("get_object_id(): Returned $row_count rows");
+ return false;
+ }
+
+ $row = $rs->FetchRow();
+
+ //Return the ID.
+ return $row[0];
+ }
+
+ /**
+ * get_object_section_value()
+ *
+ * Gets the object_section_value given object id
+ *
+ * @return string Object Section Value
+ *
+ * @param int Object ID #
+ * @param string Object Type, either 'ACO', 'ARO', or 'AXO'
+ */
+ function get_object_section_value($object_id, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ break;
+ default:
+ $this->debug_text('get_object_section_value(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_object_section_value(): Object ID: $object_id Object Type: $object_type");
+
+ if (empty($object_id) ) {
+ $this->debug_text("get_object_section_value(): Object ID ($object_id) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("get_object_section_value(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $query = 'SELECT section_value FROM '. $table .' WHERE id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_object_section_value');
+ return false;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ if ($row_count > 1) {
+ $this->debug_text("get_object_section_value(): Returned $row_count rows, can only return one.");
+ return false;
+ }
+
+ if ($row_count == 0) {
+ $this->debug_text("get_object_section_value(): Returned $row_count rows");
+ return false;
+ }
+
+ $row = $rs->FetchRow();
+
+ //Return the ID.
+ return $row[0];
+ }
+
+ /**
+ * get_object_groups()
+ *
+ * Gets all groups an object is a member of.
+ *
+ * If $option == 'RECURSE' it will get all ancestor groups.
+ * defaults to only get direct parents.
+ *
+ * @return array Array of Group ID #'s, or FALSE if Failed
+ *
+ * @param int Object ID #
+ * @param string Object Type, either 'ARO' or 'AXO'
+ * @param string Option, either 'RECURSE', or 'NO_RECURSE'
+ */
+ function get_object_groups($object_id, $object_type = 'ARO', $option = 'NO_RECURSE') {
+ $this->debug_text('get_object_groups(): Object ID: '. $object_id .' Object Type: '. $object_type .' Option: '. $option);
+
+ switch(strtolower(trim($object_type))) {
+ case 'axo':
+ $object_type = 'axo';
+ $group_table = $this->_db_table_prefix .'axo_groups';
+ $map_table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $group_table = $this->_db_table_prefix .'aro_groups';
+ $map_table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ default:
+ $this->debug_text('get_object_groups(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ if (empty($object_id)) {
+ $this->debug_text('get_object_groups(): Object ID: ('. $object_id .') is empty, this is required');
+ return FALSE;
+ }
+
+ if (strtoupper($option) == 'RECURSE') {
+ $query = '
+ SELECT DISTINCT g.id AS group_id
+ FROM '. $map_table .' gm
+ LEFT JOIN '. $group_table .' g1 ON g1.id=gm.group_id
+ LEFT JOIN '. $group_table .' g ON g.lft<=g1.lft AND g.rgt>=g1.rgt';
+ } else {
+ $query = '
+ SELECT gm.group_id
+ FROM '. $map_table .' gm';
+ }
+
+ $query .= '
+ WHERE gm.'. $object_type .'_id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_object_groups');
+ return FALSE;
+ }
+
+ $retarr = array();
+
+ while ($row = $rs->FetchRow()) {
+ $retarr[] = $row[0];
+ }
+
+ return $retarr;
+ }
+
+ /**
+ * add_object()
+ *
+ * Inserts a new object
+ *
+ * @return int Returns the ID # of the new object if successful, FALSE otherwise
+ *
+ * @param string Object Section Value
+ * @param string Object Name
+ * @param string Object Value
+ * @param int Display Order
+ * @param int Hidden Flag, either 1 to hide, or 0 to show.
+ * @param string Object Type, either 'ACO', 'ARO', or 'AXO'
+ */
+ function add_object($section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ $object_sections_table = $this->_db_table_prefix .'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ $object_sections_table = $this->_db_table_prefix .'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ $object_sections_table = $this->_db_table_prefix .'axo_sections';
+ break;
+ default:
+ $this->debug_text('add_object(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("add_object(): Section Value: $section_value Value: $value Order: $order Name: $name Object Type: $object_type");
+
+ $section_value = trim($section_value);
+ $name = trim($name);
+ $value = trim($value);
+ $order = trim($order);
+ $hidden = intval($hidden);
+
+ if ($order == NULL OR $order == '') {
+ $order = 0;
+ }
+
+ if (empty($name) OR empty($section_value) ) {
+ $this->debug_text("add_object(): name ($name) OR section value ($section_value) is empty, this is required");
+ return false;
+ }
+
+ if (strlen($name) >= 255 OR strlen($value) >= 230 ) {
+ $this->debug_text("add_object(): name ($name) OR value ($value) is too long.");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("add_object(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ // Test to see if the section is invalid or object already exists.
+ $query = '
+ SELECT CASE WHEN o.id IS NULL THEN 0 ELSE 1 END AS object_exists
+ FROM '. $object_sections_table .' s
+ LEFT JOIN '. $table .' o ON (s.value=o.section_value AND o.value='. $this->db->quote($value) .')
+ WHERE s.value='. $this->db->quote($section_value);
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_object');
+ return FALSE;
+ }
+
+ if ($rs->RecordCount() != 1) {
+ // Section is invalid
+ $this->debug_text("add_object(): Section Value: $section_value Object Type ($object_type) does not exist, this is required");
+ return false;
+ }
+
+ $row = $rs->FetchRow();
+
+ if ($row[0] == 1) {
+ //Object is already created.
+ return true;
+ }
+
+ $insert_id = $this->db->GenID($this->_db_table_prefix.$object_type.'_seq',10);
+ $query = 'INSERT INTO '. $table .' (id,section_value,value,order_value,name,hidden) VALUES('. $insert_id .','. $this->db->quote($section_value) .','. $this->db->quote($value) .','. $order .','. $this->db->quote($name) .','. $hidden .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_object');
+ return false;
+ }
+
+ $this->debug_text("add_object(): Added object as ID: $insert_id");
+ return $insert_id;
+ }
+
+ /**
+ * edit_object()
+ *
+ * Edits a given Object
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param int Object ID #
+ * @param string Object Section Value
+ * @param string Object Name
+ * @param string Object Value
+ * @param int Display Order
+ * @param int Hidden Flag, either 1 to hide, or 0 to show
+ * @param string Object Type, either 'ACO', 'ARO', or 'AXO'
+ */
+ function edit_object($object_id, $section_value, $name, $value=0, $order=0, $hidden=0, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ $object_map_table = $this->_db_table_prefix .'aco_map';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ $object_map_table = $this->_db_table_prefix .'aro_map';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ $object_map_table = $this->_db_table_prefix .'axo_map';
+ break;
+ }
+
+ $this->debug_text("edit_object(): ID: $object_id Section Value: $section_value Value: $value Order: $order Name: $name Object Type: $object_type");
+
+ $section_value = trim($section_value);
+ $name = trim($name);
+ $value = trim($value);
+ $order = trim($order);
+ $hidden = intval($hidden);
+
+ if (empty($object_id) OR empty($section_value) ) {
+ $this->debug_text("edit_object(): Object ID ($object_id) OR Section Value ($section_value) is empty, this is required");
+ return false;
+ }
+
+ if (empty($name) ) {
+ $this->debug_text("edit_object(): name ($name) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("edit_object(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $this->db->BeginTrans();
+
+ //Get old value incase it changed, before we do the update.
+ $query = 'SELECT value, section_value FROM '. $table .' WHERE id='. $object_id;
+ $old = $this->db->GetRow($query);
+
+ $query = '
+ UPDATE '. $table .'
+ SET section_value='. $this->db->quote($section_value) .',
+ value='. $this->db->quote($value) .',
+ order_value='. $this->db->quote($order) .',
+ name='. $this->db->quote($name) .',
+ hidden='. $hidden .'
+ WHERE id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object');
+ $this->db->RollbackTrans();
+ return false;
+ }
+
+ $this->debug_text('edit_object(): Modified '. strtoupper($object_type) .' ID: '. $object_id);
+
+ if ($old[0] != $value OR $old[1] != $section_value) {
+ $this->debug_text("edit_object(): Value OR Section Value Changed, update other tables.");
+
+ $query = '
+ UPDATE '. $object_map_table .'
+ SET value='. $this->db->quote($value) .',
+ section_value='. $this->db->quote($section_value) .'
+ WHERE section_value='. $this->db->quote($old[1]) .'
+ AND value='. $this->db->quote($old[0]);
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object');
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+
+ $this->debug_text ('edit_object(): Modified Map Value: '. $value .' Section Value: '. $section_value);
+ }
+
+ $this->db->CommitTrans();
+
+ return TRUE;
+ }
+
+ /**
+ * del_object()
+ *
+ * Deletes a given Object and, if instructed to do so, erase all referencing objects
+ *
+ * ERASE feature by: Martino Piccinato
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise.
+ *
+ * @param int Object ID #
+ * @param string Object Type, either 'ACO', 'ARO', or 'AXO'
+ * @param bool Erases all referencing objects if TRUE, leaves them alone otherwise.
+ */
+ function del_object($object_id, $object_type=NULL, $erase=FALSE) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ $object_map_table = $this->_db_table_prefix .'aco_map';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ $object_map_table = $this->_db_table_prefix .'aro_map';
+ $groups_map_table = $this->_db_table_prefix .'aro_groups_map';
+ $object_group_table = $this->_db_table_prefix .'groups_aro_map';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ $object_map_table = $this->_db_table_prefix .'axo_map';
+ $groups_map_table = $this->_db_table_prefix .'axo_groups_map';
+ $object_group_table = $this->_db_table_prefix .'groups_axo_map';
+ break;
+ default:
+ $this->debug_text('del_object(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("del_object(): ID: $object_id Object Type: $object_type, Erase all referencing objects: $erase");
+
+ if (empty($object_id) ) {
+ $this->debug_text("del_object(): Object ID ($object_id) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("del_object(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $this->db->BeginTrans();
+
+ // Get Object section_value/value (needed to look for referencing objects)
+ $query = 'SELECT section_value,value FROM '. $table .' WHERE id='. $object_id;
+ $object = $this->db->GetRow($query);
+
+ if (empty($object)) {
+ $this->debug_text('del_object(): The specified object ('. strtoupper($object_type) .' ID: '. $object_id .') could not be found.');
+ $this->db->RollbackTrans();
+ return FALSE;
+ }
+
+ $section_value = $object[0];
+ $value = $object[1];
+
+ // Get ids of acl referencing the Object (if any)
+ $query = "SELECT acl_id FROM $object_map_table WHERE value='$value' AND section_value='$section_value'";
+ $acl_ids = $this->db->GetCol($query);
+
+ if ($erase) {
+ // We were asked to erase all acl referencing it
+
+ $this->debug_text("del_object(): Erase was set to TRUE, delete all referencing objects");
+
+ if ($object_type == "aro" OR $object_type == "axo") {
+ // The object can be referenced in groups_X_map tables
+ // in the future this branching may become useless because
+ // ACO might me "groupable" too
+
+ // Get rid of groups_map referencing the Object
+ $query = 'DELETE FROM '. $object_group_table .' WHERE '. $object_type .'_id='. $object_id;
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object');
+ $this->db->RollBackTrans();
+ return false;
+ }
+ }
+
+ if (!empty($acl_ids)) {
+ //There are acls actually referencing the object
+
+ if ($object_type == 'aco') {
+ // I know it's extremely dangerous but
+ // if asked to really erase an ACO
+ // we should delete all acl referencing it
+ // (and relative maps)
+
+ // Do this below this branching
+ // where it uses $orphan_acl_ids as
+ // the array of the "orphaned" acl
+ // in this case all referenced acl are
+ // orhpaned acl
+
+ $orphan_acl_ids = $acl_ids;
+ } else {
+ // The object is not an ACO and might be referenced
+ // in still valid acls regarding also other object.
+ // In these cases the acl MUST NOT be deleted
+
+ // Get rid of $object_id map referencing erased objects
+ $query = "DELETE FROM $object_map_table WHERE section_value='$section_value' AND value='$value'";
+ $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ // Find the "orphaned" acl. I mean acl referencing the erased Object (map)
+ // not referenced anymore by other objects
+
+ $sql_acl_ids = implode(",", $acl_ids);
+
+ $query = '
+ SELECT a.id
+ FROM '. $this->_db_table_prefix .'acl a
+ LEFT JOIN '. $object_map_table .' b ON a.id=b.acl_id
+ LEFT JOIN '. $groups_map_table .' c ON a.id=c.acl_id
+ WHERE b.value IS NULL
+ AND b.section_value IS NULL
+ AND c.group_id IS NULL
+ AND a.id in ('. $sql_acl_ids .')';
+ $orphan_acl_ids = $this->db->GetCol($query);
+
+ } // End of else section of "if ($object_type == "aco")"
+
+ if ($orphan_acl_ids) {
+ // If there are orphaned acls get rid of them
+
+ foreach ($orphan_acl_ids as $acl) {
+ $this->del_acl($acl);
+ }
+ }
+
+ } // End of if ($acl_ids)
+
+ // Finally delete the Object itself
+ $query = "DELETE FROM $table WHERE id='$object_id'";
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $this->db->CommitTrans();
+ return true;
+
+ } // End of "if ($erase)"
+
+ $groups_ids = FALSE;
+
+ if ($object_type == 'axo' OR $object_type == 'aro') {
+ // If the object is "groupable" (may become unnecessary,
+ // see above
+
+ // Get id of groups where the object is assigned:
+ // you must explicitly remove the object from its groups before
+ // deleting it (don't know if this is really needed, anyway it's safer ;-)
+
+ $query = 'SELECT group_id FROM '. $object_group_table .' WHERE '. $object_type .'_id='. $object_id;
+ $groups_ids = $this->db->GetCol($query);
+ }
+
+ if ( ( isset($acl_ids) AND !empty($acl_ids) ) OR ( isset($groups_ids) AND !empty($groups_ids) ) ) {
+ // The Object is referenced somewhere (group or acl), can't delete it
+
+ $this->debug_text("del_object(): Can't delete the object as it is being referenced by GROUPs (".@implode($groups_ids).") or ACLs (".@implode($acl_ids,",").")");
+ $this->db->RollBackTrans();
+ return false;
+ } else {
+ // The Object is NOT referenced anywhere, delete it
+
+ $query = "DELETE FROM $table WHERE id='$object_id'";
+ $rs = $this->db->Execute($query);
+
+ if ( !is_object($rs) ) {
+ $this->debug_db('edit_object');
+ $this->db->RollBackTrans();
+ return false;
+ }
+
+ $this->db->CommitTrans();
+ return true;
+ }
+
+ $this->db->RollbackTrans();
+ return false;
+ }
+
+ /*
+ *
+ * Object Sections
+ *
+ */
+
+ /**
+ * get_object_section_section_id()
+ *
+ * Gets the object_section_id given the name AND/OR value of the section.
+ *
+ * Will only return one section id, so if there are duplicate names it will return false.
+ *
+ * @return int Object Section ID if the object section is found AND is unique, or FALSE otherwise.
+ *
+ * @param string Object Name
+ * @param string Object Value
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
+ *
+ */
+ function get_object_section_section_id($name = NULL, $value = NULL, $object_type = NULL) {
+ $this->debug_text("get_object_section_section_id(): Value: $value Name: $name Object Type: $object_type");
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ case 'aro':
+ case 'axo':
+ case 'acl':
+ $object_type = strtolower(trim($object_type));
+ $table = $this->_db_table_prefix . $object_type;
+ $object_sections_table = $this->_db_table_prefix . $object_type .'_sections';
+ break;
+ default:
+ $this->debug_text('get_object_section_section_id(): Invalid Object Type ('. $object_type . ')');
+ return FALSE;
+ }
+
+ $name = trim($name);
+ $value = trim($value);
+
+ if (empty($name) AND empty($value) ) {
+ $this->debug_text('get_object_section_section_id(): Both Name ('. $name .') and Value ('. $value .') are empty, you must specify at least one.');
+ return FALSE;
+ }
+
+ $query = 'SELECT id FROM '. $object_sections_table;
+ $where = ' WHERE ';
+
+ // limit by value if specified
+ if (!empty($value)) {
+ $query .= $where .'value='. $this->db->quote($value);
+ $where = ' AND ';
+ }
+
+ // only use name if asked, this is SLOW
+ if (!empty($name)) {
+ $query .= $where .'name='. $this->db->quote($name);
+ }
+
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('get_object_section_section_id');
+ return FALSE;
+ }
+
+ $row_count = $rs->RecordCount();
+
+ // If only one row is returned
+ if ($row_count == 1) {
+ // Return only the ID in the first row.
+ $row = $rs->FetchRow();
+ return $row[0];
+ }
+
+ // If more than one row is returned
+ // should only ever occur when using name as values are unique.
+ if ($row_count > 1) {
+ $this->debug_text('get_object_section_section_id(): Returned '. $row_count .' rows, can only return one. Please search by value not name, or make your names unique.');
+ return FALSE;
+ }
+
+ // No rows returned, no matching section found
+ $this->debug_text('get_object_section_section_id(): Returned '. $row_count .' rows, no matching section found.');
+ return FALSE;
+ }
+
+ /**
+ * add_object_section()
+ *
+ * Inserts an object Section
+ *
+ * @return int Object Section ID of new section
+ *
+ * @param string Object Name
+ * @param string Object Value
+ * @param int Display Order
+ * @param int Hidden flag, hides section if 1, shows section if 0
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
+ */
+ function add_object_section($name, $value=0, $order=0, $hidden=0, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $object_sections_table = $this->_db_table_prefix .'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $object_sections_table = $this->_db_table_prefix .'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $object_sections_table = $this->_db_table_prefix .'axo_sections';
+ break;
+ case 'acl':
+ $object_type = 'acl';
+ $object_sections_table = $this->_db_table_prefix .'acl_sections';
+ break;
+ }
+
+ $this->debug_text("add_object_section(): Value: $value Order: $order Name: $name Object Type: $object_type");
+
+ $name = trim($name);
+ $value = trim($value);
+ $order = trim($order);
+ $hidden = intval($hidden);
+
+ if ($order == NULL OR $order == '') {
+ $order = 0;
+ }
+
+ if (empty($name) ) {
+ $this->debug_text("add_object_section(): name ($name) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("add_object_section(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $insert_id = $this->db->GenID($this->_db_table_prefix.$object_type.'_sections_seq',10);
+ $query = 'insert into '. $object_sections_table .' (id,value,order_value,name,hidden) VALUES( '. $insert_id .', '. $this->db->quote($value) .', '. $order .', '. $this->db->quote($name) .', '. $hidden .')';
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('add_object_section');
+ return false;
+ } else {
+ $this->debug_text("add_object_section(): Added object_section as ID: $insert_id");
+ return $insert_id;
+ }
+ }
+
+ /**
+ * edit_object_section()
+ *
+ * Edits a given Object Section
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param int Object Section ID #
+ * @param string Object Section Name
+ * @param string Object Section Value
+ * @param int Display Order
+ * @param int Hidden Flag, hide object section if 1, show if 0
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
+ */
+ function edit_object_section($object_section_id, $name, $value=0, $order=0, $hidden=0, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco';
+ $object_sections_table = $this->_db_table_prefix .'aco_sections';
+ $object_map_table = $this->_db_table_prefix .'aco_map';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro';
+ $object_sections_table = $this->_db_table_prefix .'aro_sections';
+ $object_map_table = $this->_db_table_prefix .'aro_map';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo';
+ $object_sections_table = $this->_db_table_prefix .'axo_sections';
+ $object_map_table = $this->_db_table_prefix .'axo_map';
+ break;
+ case 'acl':
+ $object_type = 'acl';
+ $table = $this->_db_table_prefix .'acl';
+ $object_sections_table = $this->_db_table_prefix .'acl_sections';
+ break;
+ default:
+ $this->debug_text('edit_object_section(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("edit_object_section(): ID: $object_section_id Value: $value Order: $order Name: $name Object Type: $object_type");
+
+ $name = trim($name);
+ $value = trim($value);
+ $order = trim($order);
+ $hidden = intval($hidden);
+
+ if (empty($object_section_id) ) {
+ $this->debug_text("edit_object_section(): Section ID ($object_section_id) is empty, this is required");
+ return false;
+ }
+
+ if (empty($name) ) {
+ $this->debug_text("edit_object_section(): name ($name) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("edit_object_section(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $this->db->BeginTrans();
+
+ //Get old value incase it changed, before we do the update.
+ $query = "select value from $object_sections_table where id=$object_section_id";
+ $old_value = $this->db->GetOne($query);
+
+ $query = "update $object_sections_table set
+ value='$value',
+ order_value='$order',
+ name='$name',
+ hidden=$hidden
+ where id=$object_section_id";
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object_section');
+
+ $this->db->RollbackTrans();
+
+ return false;
+ } else {
+ $this->debug_text("edit_object_section(): Modified aco_section ID: $object_section_id");
+
+ if ($old_value != $value) {
+ $this->debug_text("edit_object_section(): Value Changed, update other tables.");
+
+ $query = "update $table set
+ section_value='$value'
+ where section_value = '$old_value'";
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('edit_object_section');
+
+ $this->db->RollbackTrans();
+
+ return false;
+ } else {
+ if (!empty($object_map_table)) {
+ $query = "update $object_map_table set
+ section_value='$value'
+ where section_value = '$old_value'";
+ $rs = $this->db->Execute($query);
+
+ if ( !is_object($rs) ) {
+ $this->debug_db('edit_object_section');
+
+ $this->db->RollbackTrans();
+
+ return false;
+ } else {
+ $this->debug_text("edit_object_section(): Modified ojbect_map value: $value");
+
+ $this->db->CommitTrans();
+ return true;
+ }
+ } else {
+ //ACL sections, have no mapping table. Return true.
+
+ $this->db->CommitTrans();
+
+ return true;
+ }
+ }
+ }
+
+ $this->db->CommitTrans();
+ return true;
+ }
+ }
+
+ /**
+ * del_object_section()
+ *
+ * Deletes a given Object Section and, if explicitly asked, all the section objects
+ *
+ * ERASE feature by: Martino Piccinato
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ * @param int Object Section ID # to delete
+ * @param string Object Type, either 'ACO', 'ARO', 'AXO', or 'ACL'
+ * @param bool Erases all section objects assigned to the section
+ */
+ function del_object_section($object_section_id, $object_type=NULL, $erase=FALSE) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $object_sections_table = $this->_db_table_prefix .'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $object_sections_table = $this->_db_table_prefix .'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $object_sections_table = $this->_db_table_prefix .'axo_sections';
+ break;
+ case 'acl':
+ $object_type = 'acl';
+ $object_sections_table = $this->_db_table_prefix .'acl_sections';
+ break;
+ }
+
+ $this->debug_text("del_object_section(): ID: $object_section_id Object Type: $object_type, Erase all: $erase");
+
+ if (empty($object_section_id) ) {
+ $this->debug_text("del_object_section(): Section ID ($object_section_id) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("del_object_section(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ // Get the value of the section
+ $query="SELECT value FROM $object_sections_table WHERE id='$object_section_id'";
+ $section_value = $this->db->GetOne($query);
+
+ // Get all objects ids in the section
+ $object_ids = $this->get_object($section_value, 1, $object_type);
+
+ if($erase) {
+ // Delete all objects in the section and for
+ // each object delete the referencing object
+ // (see del_object method)
+ if (is_array($object_ids)) {
+ foreach ($object_ids as $id) {
+ if ( $object_type === 'acl' ) {
+ $this->del_acl($id);
+ } else {
+ $this->del_object($id, $object_type, TRUE);
+ }
+ }
+ }
+ }
+
+ if($object_ids AND !$erase) {
+ // There are objects in the section and we
+ // were not asked to erase them: don't delete it
+
+ $this->debug_text("del_object_section(): Could not delete the section ($section_value) as it is not empty.");
+
+ return false;
+
+ } else {
+ // The section is empty (or emptied by this method)
+
+ $query = "DELETE FROM $object_sections_table where id='$object_section_id'";
+ $rs = $this->db->Execute($query);
+
+ if (!is_object($rs)) {
+ $this->debug_db('del_object_section');
+ return false;
+ } else {
+ $this->debug_text("del_object_section(): deleted section ID: $object_section_id Value: $section_value");
+ return true;
+ }
+
+ }
+
+ return false;
+ }
+
+ /**
+ * get_section_data()
+ *
+ * Gets the section data given the Section Value
+ *
+ * @return array Returns numerically indexed array with the following columns:
+ * - array[0] = (int) Section ID #
+ * - array[1] = (string) Section Value
+ * - array[2] = (int) Section Order
+ * - array[3] = (string) Section Name
+ * - array[4] = (int) Section Hidden?
+ * @param string Section Value
+ * @param string Object Type, either 'ACO', 'ARO', or 'AXO'
+ */
+ function get_section_data($section_value, $object_type=NULL) {
+
+ switch(strtolower(trim($object_type))) {
+ case 'aco':
+ $object_type = 'aco';
+ $table = $this->_db_table_prefix .'aco_sections';
+ break;
+ case 'aro':
+ $object_type = 'aro';
+ $table = $this->_db_table_prefix .'aro_sections';
+ break;
+ case 'axo':
+ $object_type = 'axo';
+ $table = $this->_db_table_prefix .'axo_sections';
+ break;
+ default:
+ $this->debug_text('get_section_data(): Invalid Object Type: '. $object_type);
+ return FALSE;
+ }
+
+ $this->debug_text("get_section_data(): Section Value: $section_value Object Type: $object_type");
+
+ if (empty($section_value) ) {
+ $this->debug_text("get_section_data(): Section Value ($section_value) is empty, this is required");
+ return false;
+ }
+
+ if (empty($object_type) ) {
+ $this->debug_text("get_section_data(): Object Type ($object_type) is empty, this is required");
+ return false;
+ }
+
+ $query = "SELECT id, value, order_value, name, hidden FROM '. $table .' WHERE value='$section_value'";
+ $row = $this->db->GetRow($query);
+
+ if ($row) {
+ return $row;
+ }
+
+ $this->debug_text("get_section_data(): Section does not exist.");
+ return false;
+ }
+
+ /**
+ * clear_database()
+ *
+ * Deletes all data from the phpGACL tables. USE WITH CAUTION.
+ *
+ * @return bool Returns TRUE if successful, FALSE otherwise
+ *
+ */
+ function clear_database(){
+
+ $tablesToClear = array(
+ $this->_db_table_prefix.'acl',
+ $this->_db_table_prefix.'aco',
+ $this->_db_table_prefix.'aco_map',
+ $this->_db_table_prefix.'aco_sections',
+ $this->_db_table_prefix.'aro',
+ $this->_db_table_prefix.'aro_groups',
+ $this->_db_table_prefix.'aro_groups_map',
+ $this->_db_table_prefix.'aro_map',
+ $this->_db_table_prefix.'aro_sections',
+ $this->_db_table_prefix.'axo',
+ $this->_db_table_prefix.'axo_groups',
+ $this->_db_table_prefix.'axo_groups_map',
+ $this->_db_table_prefix.'axo_map',
+ $this->_db_table_prefix.'axo_sections',
+ $this->_db_table_prefix.'groups_aro_map',
+ $this->_db_table_prefix.'groups_axo_map'
+ );
+
+ // Get all the table names and loop
+ $tableNames = $this->db->MetaTables('TABLES');
+ $query = array();
+ foreach ($tableNames as $key => $value){
+ if (in_array($value, $tablesToClear) ) {
+ $query[] = 'TRUNCATE TABLE '.$value.';';
+ }
+ }
+
+ // Loop the queries and return.
+ foreach ($query as $key => $value){
+ $result = $this->db->Execute($value);
+ }
+
+ return TRUE;
+ }
+
+}
+?>
diff --git a/html/phpgacl/other_languages/perl/perlGACL-check-1.0.tar.gz b/html/phpgacl/other_languages/perl/perlGACL-check-1.0.tar.gz
new file mode 100644
index 0000000..464a140
--- /dev/null
+++ b/html/phpgacl/other_languages/perl/perlGACL-check-1.0.tar.gz
Binary files differ
diff --git a/html/phpgacl/phpdoc.phpgacl.ini b/html/phpgacl/phpdoc.phpgacl.ini
new file mode 100644
index 0000000..4cf777e
--- /dev/null
+++ b/html/phpgacl/phpdoc.phpgacl.ini
@@ -0,0 +1,98 @@
+;; phpDocumentor parse configuration file
+;;
+;; This file is designed to cut down on repetitive typing on the command-line or web interface
+;; You can copy this file to create a number of configuration files that can be used with the
+;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web
+;; interface will automatically generate a list of .ini files that can be used.
+;;
+;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs
+;;
+;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini
+;;
+;; Copyright 2002, Greg Beaver <cellog@users.sourceforge.net>
+;;
+;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them
+
+[Parse Data]
+;; title of all the documentation
+;; legal values: any string
+title = phpGACL 3.3.6 Developer's Manual
+
+;; parse files that start with a . like .bash_profile
+;; legal values: true, false
+hidden = false
+
+;; show elements marked @access private in documentation by setting this to on
+;; legal values: on, off
+parseprivate = off
+
+;; parse with javadoc-like description (first sentence is always the short description)
+;; legal values: on, off
+javadocdesc = off
+
+;; add any custom @tags separated by commas here
+;; legal values: any legal tagname separated by commas.
+;customtags = mytag1,mytag2
+
+;; This is only used by the XML:DocBook/peardoc2 converter
+defaultcategoryname = Documentation
+
+;; what is the main package?
+;; legal values: alphanumeric string plus - and _
+defaultpackagename = phpGACL
+
+;; output any parsing information? set to on for cron jobs
+;; legal values: on
+;quiet = on
+
+;; parse a PEAR-style repository. Do not turn this on if your project does
+;; not have a parent directory named "pear"
+;; legal values: on/off
+;pear = on
+
+;; where should the documentation be written?
+;; legal values: a legal path
+target = ./docs/phpdoc/
+
+;; Which files should be parsed out as special documentation files, such as README,
+;; INSTALL and CHANGELOG? This overrides the default files found in
+;; phpDocumentor.ini (this file is not a user .ini file, but the global file)
+readmeinstallchangelog = README, INSTALL, CHANGELOG, NEWS, FAQ, LICENSE
+
+;; limit output to the specified packages, even if others are parsed
+;; legal values: package names separated by commas
+;packageoutput = package1,package2
+
+;; comma-separated list of files to parse
+;; legal values: paths separated by commas
+;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory
+filename = ./gacl.class.php,gacl_api.class.php
+
+;; comma-separated list of directories to parse
+;; legal values: directory paths separated by commas
+;directory = /path1,/path2,.,..,subdirectory
+;directory = /home/jeichorn/cvs/pear
+
+;; template base directory (the equivalent directory of <installdir>/phpDocumentor)
+;templatebase = /path/to/my/templates
+
+;; directory to find any example files in through @example and {@example} tags
+;examplesdir = /path/to/my/templates
+
+;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore
+;; legal values: any wildcard strings separated by commas
+;ignore = /path/to/ignore*,*list.php,myfile.php,subdirectory/
+ignore = templates_c/,*HTML/default/*,spec/
+
+;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format
+;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib,
+;; HTML:frames:earthli,
+;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de,
+;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli
+;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS
+;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default
+output=HTML:frames:earthli
+
+;; turn this option on if you want highlighted source code for every file
+;; legal values: on/off
+sourcecode = off
diff --git a/html/phpgacl/profiler.inc b/html/phpgacl/profiler.inc
new file mode 100644
index 0000000..3389e47
--- /dev/null
+++ b/html/phpgacl/profiler.inc
@@ -0,0 +1,218 @@
+<?php
+/********************************************************************************\
+ * Copyright (C) Carl Taylor (cjtaylor@adepteo.com) *
+ * Copyright (C) Torben Nehmer (torben@nehmer.net) for Code Cleanup *
+ * *
+ * This program is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU General Public License *
+ * as published by the Free Software Foundation; either version 2 *
+ * of the License, or (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+\********************************************************************************/
+
+/// Enable multiple timers to aid profiling of performance over sections of code
+class Profiler {
+ var $description;
+ var $startTime;
+ var $endTime;
+ var $initTime;
+ var $cur_timer;
+ var $stack;
+ var $trail;
+ var $trace;
+ var $count;
+ var $running;
+
+ /**
+ * Initialise the timer. with the current micro time
+ */
+ function Profiler( $output_enabled=false, $trace_enabled=false)
+ {
+ $this->description = array();
+ $this->startTime = array();
+ $this->endTime = array();
+ $this->initTime = 0;
+ $this->cur_timer = "";
+ $this->stack = array();
+ $this->trail = "";
+ $this->trace = "";
+ $this->count = array();
+ $this->running = array();
+ $this->initTime = $this->getMicroTime();
+ $this->output_enabled = $output_enabled;
+ $this->trace_enabled = $trace_enabled;
+ $this->startTimer('unprofiled');
+ }
+
+ // Public Methods
+
+ /**
+ * Start an individual timer
+ * This will pause the running timer and place it on a stack.
+ * @param string $name name of the timer
+ * @param string optional $desc description of the timer
+ */
+ function startTimer($name, $desc="" ){
+ $this->trace.="start $name\n";
+ $n=array_push( $this->stack, $this->cur_timer );
+ $this->__suspendTimer( $this->stack[$n-1] );
+ $this->startTime[$name] = $this->getMicroTime();
+ $this->cur_timer=$name;
+ $this->description[$name] = $desc;
+ if (!array_key_exists($name,$this->count))
+ $this->count[$name] = 1;
+ else
+ $this->count[$name]++;
+ }
+
+ /**
+ * Stop an individual timer
+ * Restart the timer that was running before this one
+ * @param string $name name of the timer
+ */
+ function stopTimer($name){
+ $this->trace.="stop $name\n";
+ $this->endTime[$name] = $this->getMicroTime();
+ if (!array_key_exists($name, $this->running))
+ $this->running[$name] = $this->elapsedTime($name);
+ else
+ $this->running[$name] += $this->elapsedTime($name);
+ $this->cur_timer=array_pop($this->stack);
+ $this->__resumeTimer($this->cur_timer);
+ }
+
+ /**
+ * measure the elapsed time of a timer without stoping the timer if
+ * it is still running
+ */
+ function elapsedTime($name){
+ // This shouldn't happen, but it does once.
+ if (!array_key_exists($name,$this->startTime))
+ return 0;
+
+ if(array_key_exists($name,$this->endTime)){
+ return ($this->endTime[$name] - $this->startTime[$name]);
+ } else {
+ $now=$this->getMicroTime();
+ return ($now - $this->startTime[$name]);
+ }
+ }//end start_time
+
+ /**
+ * Measure the elapsed time since the profile class was initialised
+ *
+ */
+ function elapsedOverall(){
+ $oaTime = $this->getMicroTime() - $this->initTime;
+ return($oaTime);
+ }//end start_time
+
+ /**
+ * print out a log of all the timers that were registered
+ *
+ */
+ function printTimers($enabled=false)
+ {
+ if($this->output_enabled||$enabled){
+ $TimedTotal = 0;
+ $tot_perc = 0;
+ ksort($this->description);
+ print("<pre>\n");
+ $oaTime = $this->getMicroTime() - $this->initTime;
+ echo"============================================================================\n";
+ echo " PROFILER OUTPUT\n";
+ echo"============================================================================\n";
+ print( "Calls Time Routine\n");
+ echo"-----------------------------------------------------------------------------\n";
+ while (list ($key, $val) = each ($this->description)) {
+ $t = $this->elapsedTime($key);
+ $total = $this->running[$key];
+ $count = $this->count[$key];
+ $TimedTotal += $total;
+ $perc = ($total/$oaTime)*100;
+ $tot_perc+=$perc;
+ // $perc=sprintf("%3.2f", $perc );
+ printf( "%3d %3.4f ms (%3.2f %%) %s\n", $count, $total*1000, $perc, $key);
+ }
+
+ echo "\n";
+
+ $missed=$oaTime-$TimedTotal;
+ $perc = ($missed/$oaTime)*100;
+ $tot_perc+=$perc;
+ // $perc=sprintf("%3.2f", $perc );
+ printf( " %3.4f ms (%3.2f %%) %s\n", $missed*1000,$perc, "Missed");
+
+ echo"============================================================================\n";
+
+ printf( " %3.4f ms (%3.2f %%) %s\n", $oaTime*1000,$tot_perc, "OVERALL TIME");
+
+ echo"============================================================================\n";
+
+ print("</pre>");
+ }
+ }
+
+ function printTrace( $enabled=false )
+ {
+ if($this->trace_enabled||$enabled){
+ print("<pre>");
+ print("Trace\n$this->trace\n\n");
+ print("</pre>");
+ }
+ }
+
+ /// Internal Use Only Functions
+
+ /**
+ * Get the current time as accuratly as possible
+ *
+ */
+ function getMicroTime(){
+ $tmp=split(" ",microtime());
+ $rt=$tmp[0]+$tmp[1];
+ return $rt;
+ }
+
+ /**
+ * resume an individual timer
+ *
+ */
+ function __resumeTimer($name){
+ $this->trace.="resume $name\n";
+ $this->startTime[$name] = $this->getMicroTime();
+ }
+
+ /**
+ * suspend an individual timer
+ *
+ */
+ function __suspendTimer($name){
+ $this->trace.="suspend $name\n";
+ $this->endTime[$name] = $this->getMicroTime();
+ if (!array_key_exists($name, $this->running))
+ $this->running[$name] = $this->elapsedTime($name);
+ else
+ $this->running[$name] += $this->elapsedTime($name);
+ }
+}
+
+function profiler_start($name) {
+ if (array_key_exists("midcom_profiler",$GLOBALS))
+ $GLOBALS["midcom_profiler"]->startTimer ($name);
+}
+
+function profiler_stop($name) {
+ if (array_key_exists("midcom_profiler",$GLOBALS))
+ $GLOBALS["midcom_profiler"]->stopTimer ($name);
+}
+
+?>
diff --git a/html/phpgacl/schema.xml b/html/phpgacl/schema.xml
new file mode 100644
index 0000000..383dafd
--- /dev/null
+++ b/html/phpgacl/schema.xml
@@ -0,0 +1,513 @@
+<?xml version="1.0"?>
+<schema version="0.2">
+
+ <!-- phpGACL Table -->
+ <table name="phpgacl">
+ <field name="name" type="C" size="230">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ </table>
+ <sql>
+ <descr>SQL to be executed only to insert default rows</descr>
+ <query>
+ DELETE FROM phpgacl WHERE name='version'
+ </query>
+ <query>
+ INSERT INTO phpgacl (name,value) VALUES ('version','3.3.6')
+ </query>
+ <query>
+ DELETE FROM phpgacl WHERE name='schema_version'
+ </query>
+ <query>
+ INSERT INTO phpgacl (name,value) VALUES ('schema_version','2.1')
+ </query>
+ </sql>
+
+ <!-- ACL Table -->
+ <table name="acl">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="230">
+ <DEFAULT value="system"/>
+ <NOTNULL/>
+ </field>
+ <field name="allow" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="enabled" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="return_value" type="X">
+ </field>
+ <field name="note" type="X">
+ </field>
+ <field name="updated_date" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="enabled_acl">
+ <col>enabled</col>
+ </index>
+ <index name="section_value_acl">
+ <col>section_value</col>
+ </index>
+ <index name="updated_date_acl">
+ <col>updated_date</col>
+ </index>
+ </table>
+
+ <!-- ACL Section Table -->
+ <table name="acl_sections">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="value_acl_sections">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_acl_sections">
+ <col>hidden</col>
+ </index>
+ </table>
+ <sql>
+ <descr>SQL to be executed only to insert default rows</descr>
+ <query>
+ DELETE FROM acl_sections WHERE id=1 AND value='system'
+ </query>
+ <query>
+ INSERT INTO acl_sections (id,value,order_value,name) VALUES (1,'system',1,'System')
+ </query>
+ <query>
+ DELETE FROM acl_sections WHERE id=2 AND value='user'
+ </query>
+ <query>
+ INSERT INTO acl_sections (id,value,order_value,name) VALUES (2,'user',2,'User')
+ </query>
+ </sql>
+
+ <!-- ACO Table -->
+ <table name="aco">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="240">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="value" type="C" size="240">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="255">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="section_value_value_aco">
+ <col>section_value</col>
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_aco">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- ACL to ACO Map Table -->
+ <table name="aco_map">
+ <field name="acl_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="230">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ </table>
+
+ <!-- ACO Section Table -->
+ <table name="aco_sections">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="value_aco_sections">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_aco_sections">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- ARO Table -->
+ <table name="aro">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="240">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="value" type="C" size="240">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="255">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="section_value_value_aro">
+ <col>section_value</col>
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_aro">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- ACL to ARO Map Table -->
+ <table name="aro_map">
+ <field name="acl_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="230">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ </table>
+
+ <!-- ARO Section Table -->
+ <table name="aro_sections">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="value_aro_sections">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_aro_sections">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- AXO Table -->
+ <table name="axo">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="240">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="value" type="C" size="240">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="255">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="section_value_value_axo">
+ <col>section_value</col>
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_axo">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- ACL to AXO Map Table -->
+ <table name="axo_map">
+ <field name="acl_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="section_value" type="C" size="230">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ </table>
+
+ <!-- AXO Section Table -->
+ <table name="axo_sections">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="value" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="order_value" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="230">
+ <NOTNULL/>
+ </field>
+ <field name="hidden" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+
+ <index name="value_axo_sections">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="hidden_axo_sections">
+ <col>hidden</col>
+ </index>
+ </table>
+
+ <!-- ARO Group Table -->
+ <table name="aro_groups">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="parent_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="lft" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="rgt" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="255">
+ <NOTNULL/>
+ </field>
+ <field name="value" type="C" size="255">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+
+ <index name="parent_id_aro_groups">
+ <col>parent_id</col>
+ </index>
+ <index name="value_aro_groups">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="lft_rgt_aro_groups">
+ <col>lft</col>
+ <col>rgt</col>
+ </index>
+ </table>
+
+ <!-- ARO to ARO Group Map Table -->
+ <table name="groups_aro_map">
+ <field name="group_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="aro_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <index name="aro_id">
+ <descr>Index on aro_id</descr>
+ <col>aro_id</col>
+ </index>
+ </table>
+
+ <!-- ACL to ARO Group Map Table -->
+ <table name="aro_groups_map">
+ <field name="acl_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="group_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ </table>
+
+ <!-- AXO Group Table -->
+ <table name="axo_groups">
+ <field name="id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="parent_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="lft" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="rgt" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ </field>
+ <field name="name" type="C" size="255">
+ <NOTNULL/>
+ </field>
+ <field name="value" type="C" size="255">
+ <NOTNULL/>
+ <KEY/>
+ </field>
+
+ <index name="parent_id_axo_groups">
+ <col>parent_id</col>
+ </index>
+ <index name="value_axo_groups">
+ <col>value</col>
+ <UNIQUE/>
+ </index>
+ <index name="lft_rgt_axo_groups">
+ <col>lft</col>
+ <col>rgt</col>
+ </index>
+ </table>
+
+ <!-- AXO to AXO Group Map Table -->
+ <table name="groups_axo_map">
+ <field name="group_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="axo_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <index name="axo_id">
+ <descr>Index on axo_id</descr>
+ <col>axo_id</col>
+ </index>
+ </table>
+
+ <!-- ACL to AXO Group Map Table -->
+ <table name="axo_groups_map">
+ <field name="acl_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ <field name="group_id" type="I">
+ <DEFAULT value="0"/>
+ <NOTNULL/>
+ <KEY/>
+ </field>
+ </table>
+</schema>
diff --git a/html/phpgacl/setup.php b/html/phpgacl/setup.php
new file mode 100644
index 0000000..c6d6a80
--- /dev/null
+++ b/html/phpgacl/setup.php
@@ -0,0 +1,206 @@
+<?php
+
+$config_file = './gacl.ini.php';
+
+require_once('./admin/gacl_admin.inc.php');
+require_once(ADODB_DIR .'/adodb-xmlschema.inc.php');
+
+$db_table_prefix = $gacl->_db_table_prefix;
+$db_type = $gacl->_db_type;
+$db_name = $gacl->_db_name;
+$db_host = $gacl->_db_host;
+$db_user = $gacl->_db_user;
+$db_password = $gacl->_db_password;
+$db_name = $gacl->_db_name;
+
+$failed = 0;
+
+echo '<h1>phpGACL Database Setup</h1>
+<p><b>Configuration:</b><br/>
+driver = <b>'.$db_type.'</b>,<br/>
+host = <b>'.$db_host.'</b>,<br/>
+user = <b>'.$db_user.'</b>,<br/>
+database = <b>'.$db_name.'</b>,<br/>
+table prefix = <b>'.$db_table_prefix.'</b></p>';
+
+function echo_success($text) {
+ echo '<font color="green"><b>Success!</b></font> '.$text."<br/>\n";
+}
+
+function echo_failed($text) {
+ global $failed;
+ echo '<font color="red"><b>Failed!</b></font> '.$text."<br/>\n";
+ $failed++;
+}
+
+function echo_normal($text) {
+ echo $text."<br/>\n";
+}
+
+/*
+ * Test database connection
+ */
+echo '<hr/><h2>Testing database connection...</h2>'."\n";
+
+if (is_resource($db->_connectionID)) {
+ echo_success('Connected to &quot;<b>'.$db_type.'</b>&quot; database on &quot;<b>'.$db_host.'</b>&quot;.');
+} else {
+ echo_failed('<b>ERROR</b> connecting to database,<br/>
+ are you sure you specified the proper host, user name, password, and database in <b>admin/gacl_admin.inc.php</b>?<br/>
+ Did you create the database, and give read/write permissions to &quot;<b>'.$db_user.'</b>&quot; already?');
+ exit;
+}
+
+/*
+ * Do database specific stuff.
+ */
+echo '<hr/><h2>Testing database type...</h2>'."\n";
+
+switch ($db_type) {
+ case "mysql":
+ echo_success("Compatible database type \"<b>$db_type</b>\" detected!");
+ echo_normal("Making sure database \"<b>$db_name</b>\" exists...");
+
+ $databases = $db->GetCol("show databases");
+
+ if (in_array($db_name, $databases) ) {
+ echo_success("Good, database \"<b>$db_name</b>\" already exists!");
+ } else {
+ echo_normal("Database \"<b>$db_name</b>\" does not exist!");
+ echo_normal("Lets try to create it...");
+
+ if (!$db->Execute("create database $db_name") ) {
+ echo_failed("Database \"<b>$db_name</b>\" could not be created, please do so manually.");
+ } else {
+ echo_success("Good, database \"<b>$db_name</b>\" has been created!!");
+
+ //Reconnect. Hrmm, this is kinda weird.
+ $db->Connect($db_host, $db_user, $db_password, $db_name);
+ }
+ }
+
+ break;
+ case "postgres7":
+ echo_success("Compatible database type \"<b>$db_type</b>\" detected!");
+
+ echo_normal("Making sure database \"<b>$db_name</b>\" exists...");
+
+ $databases = $db->GetCol("select datname from pg_database");
+
+ if (in_array($db_name, $databases) ) {
+ echo_success("Good, database \"<b>$db_name</b>\" already exists!");
+ } else {
+ echo_normal("Database \"<b>$db_name</b>\" does not exist!");
+ echo_normal("Lets try to create it...");
+
+ if (!$db->Execute("create database $db_name") ) {
+ echo_failed("Database \"<b>$db_name</b>\" could not be created, please do so manually.");
+ } else {
+ echo_success("Good, database \"<b>$db_name</b>\" has been created!!");
+
+ //Reconnect. Hrmm, this is kinda weird.
+ $db->Connect($db_host, $db_user, $db_password, $db_name);
+ }
+ }
+
+ break;
+
+ case "oci8-po":
+ echo_success("Compatible database type \"<b>$db_type</b>\" detected!");
+
+ echo_normal("Making sure database \"<b>$db_name</b>\" exists...");
+
+ $databases = $db->GetCol("select '$db_name' from dual");
+
+ if (in_array($db_name, $databases) ) {
+ echo_success("Good, database \"<b>$db_name</b>\" already exists!");
+ } else {
+ echo_normal("Database \"<b>$db_name</b>\" does not exist!");
+ echo_normal("Lets try to create it...");
+
+ if (!$db->Execute("create database $db_name") ) {
+ echo_failed("Database \"<b>$db_name</b>\" could not be created, please do so manually.");
+ } else {
+ echo_success("Good, database \"<b>$db_name</b>\" has been created!!");
+
+ //Reconnect. Hrmm, this is kinda weird.
+ $db->Connect($db_host, $db_user, $db_password, $db_name);
+ }
+ }
+
+ break;
+
+ case "mssql":
+ echo_success("Compatible database type \"<b>$db_type</b>\" detected!");
+
+ echo_normal("Making sure database \"<b>$db_name</b>\" exists...");
+
+ $databases = $db->GetCol("select CATALOG_NAME from INFORMATION_SCHEMA.SCHEMATA");
+
+ if (in_array($db_name, $databases) ) {
+ echo_success("Good, database \"<b>$db_name</b>\" already exists!");
+ } else {
+ echo_normal("Database \"<b>$db_name</b>\" does not exist!");
+ echo_normal("Lets try to create it...");
+
+ if (!$db->Execute("create database $db_name") ) {
+ echo_failed("Database \"<b>$db_name</b>\" could not be created, please do so manually.");
+ } else {
+ echo_success("Good, database \"<b>$db_name</b>\" has been created!!");
+
+ //Reconnect. Hrmm, this is kinda weird.
+ $db->Connect($db_host, $db_user, $db_password, $db_name);
+ }
+ }
+
+ break;
+
+ default:
+ echo_normal("Sorry, <b>setup.php</b> currently does not fully support \"<b>$db_type</b>\" databases.
+ <br>I'm assuming you've already created the database \"$db_name\", attempting to create tables.
+ <br> Please email <b>$author_email</b> code to detect if a database is created or not so full support for \"<b>$db_type</b>\" can be added.");
+}
+
+
+/*
+ * Attempt to create tables
+ */
+// Create the schema object and build the query array.
+$schema = new adoSchema($db);
+$schema->SetPrefix($db_table_prefix);
+
+// Build the SQL array
+$schema->ParseSchema('schema.xml');
+
+// maybe display this if $gacl->debug is true?
+if ($gacl->_debug) {
+ print "Here's the SQL to do the build:<br />\n<code>";
+ print $schema->getSQL('html');
+ print "</code>\n";
+ // exit;
+}
+
+// Execute the SQL on the database
+#ADODB's xmlschema is being lame, continue on error.
+$schema->ContinueOnError(TRUE);
+$result = $schema->ExecuteSchema();
+
+if ($result != 2) {
+ echo_failed('Failed creating tables. Please enable DEBUG mode (set it to TRUE in $gacl_options near top of admin/gacl_admin.inc.php) to see the error and try again. You will most likely need to delete any tables already created.');
+}
+
+if ( $failed <= 0 ) {
+ echo_success('
+Installation Successful!!!
+<div align="center">
+<font color="red"><b>*IMPORTANT*</b></font><br/>
+<p>Please make sure you create the <b>&lt;phpGACL root&gt;/admin/templates_c</b> directory,
+and give it <b>write permissions</b> for the user your web server runs as.</p>
+<p>Please read the manual, and docs/examples/* to familiarize yourself with phpGACL.</p>
+<a href="admin/about.php?first_run=1"><b>Let\'s get started!</b></a>
+</div>
+');
+} else {
+ echo_failed('Please fix the above errors and try again.');
+}
+?>
diff --git a/html/phpgacl/soap/clients/perl_client.pl b/html/phpgacl/soap/clients/perl_client.pl
new file mode 100644
index 0000000..2334133
--- /dev/null
+++ b/html/phpgacl/soap/clients/perl_client.pl
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+#
+# SOAP Lite needs to be installed for this to work correctly.
+#
+use SOAP::Lite;
+
+#
+# EDIT THE BELOW URL TO MATCH YOUR SERVER.
+#
+sub soap_init {
+ my $soap = new SOAP::Lite
+ uri => 'http://localhost/phpgacl/soap/server.php',
+ proxy => 'http://localhost/phpgacl/soap/server.php'
+ or die "Failed SOAP connection: $! \n";
+}
+
+$soap = soap_init();
+
+sub acl_check {
+ my ($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value, $root_aro_group_id, $root_axo_group_id) = @_;
+
+ return $soap->call('acl_check',$aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value,$axo_value, $root_aro_group_id, $root_axo_group_id)->result
+}
+
+if ( acl_check('system','login','users','john_doe') ) {
+ print "John Doe has been granted access to login!<br>\n";
+} else {
+ print "John Doe has been denied access to login!<br>\n";
+}
+
diff --git a/html/phpgacl/soap/clients/php_client.php b/html/phpgacl/soap/clients/php_client.php
new file mode 100644
index 0000000..411f80c
--- /dev/null
+++ b/html/phpgacl/soap/clients/php_client.php
@@ -0,0 +1,24 @@
+<?php
+require_once('../nusoap.php');
+
+/*
+ * EDIT THE BELOW URL TO MATCH YOUR SERVER.
+ */
+$soapclient = new soapclient('http://localhost/phpgacl/soap/server.php');
+
+function acl_check($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group_id=NULL, $root_axo_group_id=NULL) {
+ global $soapclient;
+
+ $parameters = array($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value, $root_aro_group_id, $root_axo_group_id);
+
+ return $soapclient->call('acl_check',$parameters);
+}
+
+if ( acl_check('system','login','users','john_doe') ) {
+ echo "John Doe has been granted access to login!<br>\n";
+} else {
+ echo "John Doe has been denied access to login!<br>\n";
+}
+
+?>
+
diff --git a/html/phpgacl/soap/clients/python_client.py b/html/phpgacl/soap/clients/python_client.py
new file mode 100644
index 0000000..4e2a1df
--- /dev/null
+++ b/html/phpgacl/soap/clients/python_client.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+#
+# This uses the Python ZSI SOAP Infrastructure from: http://pywebsvcs.sourceforge.net/
+#
+
+import sys;
+from ZSI.client import Binding;
+
+#soapclient = Binding(url='/phpgacl/soap/server.php', host='hubcap.netnation.com', tracefile=sys.stdout);
+soapclient = Binding(url='/phpgacl/soap/server.php', host='hubcap.netnation.com');
+
+def acl_check(aco_section_value, aco_value, aro_section_value, aro_value, axo_section_value=0, axo_value=0, root_aro_group_id=0, root_axo_group_id=0):
+ return soapclient.acl_check(aco_section_value, aco_value, aro_section_value, aro_value, axo_section_value, axo_value, root_aro_group_id, root_axo_group_id);
+
+
+if ( acl_check('system','login','users','john_doe') ):
+ print "John Doe has been granted access to login!<br>\n";
+else:
+ print "John Doe has been denied access to login!<br>\n";
+
+
+
+
+
diff --git a/html/phpgacl/soap/nusoap.php b/html/phpgacl/soap/nusoap.php
new file mode 100644
index 0000000..9ee7ff3
--- /dev/null
+++ b/html/phpgacl/soap/nusoap.php
@@ -0,0 +1,4098 @@
+<?php
+
+/*
+
+NuSOAP - Web Services Toolkit for PHP
+
+Copyright (c) 2002 NuSphere Corporation
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+If you have any questions or comments, please email:
+
+Dietrich Ayala
+dietrich@ganx4.com
+http://dietrich.ganx4.com/nusoap
+
+NuSphere Corporation
+http://www.nusphere.com
+
+*/
+
+/* load classes
+
+// necessary classes
+require_once('class.soapclient.php');
+require_once('class.soap_val.php');
+require_once('class.soap_parser.php');
+require_once('class.soap_fault.php');
+
+// transport classes
+require_once('class.soap_transport_http.php');
+
+// optional add-on classes
+require_once('class.xmlschema.php');
+require_once('class.wsdl.php');
+
+// server class
+require_once('class.soap_server.php');*/
+
+/**
+*
+* nusoap_base
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class nusoap_base {
+
+ var $title = 'NuSOAP';
+ var $version = '0.6.3';
+ var $error_str = false;
+ var $debug_str = '';
+ // toggles automatic encoding of special characters
+ var $charencoding = true;
+
+ /**
+ * set schema version
+ *
+ * @var XMLSchemaVersion
+ * @access public
+ */
+ var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
+
+ /**
+ * set default encoding
+ *
+ * @var soap_defencoding
+ * @access public
+ */
+ //var $soap_defencoding = 'UTF-8';
+ var $soap_defencoding = 'ISO-8859-1';
+
+ /**
+ * load namespace uris into an array of uri => prefix
+ *
+ * @var namespaces
+ * @access public
+ */
+ var $namespaces = array(
+ 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
+ 'xsd' => 'http://www.w3.org/2001/XMLSchema',
+ 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
+ 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
+ 'si' => 'http://soapinterop.org/xsd');
+ /**
+ * load types into typemap array
+ * is this legacy yet?
+ * no, this is used by the xmlschema class to verify type => namespace mappings.
+ * @var typemap
+ * @access public
+ */
+ var $typemap = array(
+ 'http://www.w3.org/2001/XMLSchema' => array(
+ 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
+ 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
+ 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
+ // derived datatypes
+ 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
+ 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
+ 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
+ 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
+ 'http://www.w3.org/1999/XMLSchema' => array(
+ 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
+ 'float'=>'double','dateTime'=>'string',
+ 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
+ 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
+ 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
+ 'http://xml.apache.org/xml-soap' => array('Map')
+ );
+
+ /**
+ * entities to convert
+ *
+ * @var xmlEntities
+ * @access public
+ */
+ var $xmlEntities = array('quot' => '"','amp' => '&',
+ 'lt' => '<','gt' => '>','apos' => "'");
+
+ /**
+ * adds debug data to the class level debug string
+ *
+ * @param string $string debug data
+ * @access private
+ */
+ function debug($string){
+ $this->debug_str .= get_class($this).": $string\n";
+ }
+
+ /**
+ * returns error string if present
+ *
+ * @return boolean $string error string
+ * @access public
+ */
+ function getError(){
+ if($this->error_str != ''){
+ return $this->error_str;
+ }
+ return false;
+ }
+
+ /**
+ * sets error string
+ *
+ * @return boolean $string error string
+ * @access private
+ */
+ function setError($str){
+ $this->error_str = $str;
+ }
+
+ /**
+ * serializes PHP values in accordance w/ section 5. Type information is
+ * not serialized if $use == 'literal'.
+ *
+ * @return string
+ * @access public
+ */
+ function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded'){
+ if(is_object($val) && get_class($val) == 'soapval'){
+ return $val->serialize($use);
+ }
+ $this->debug( "in serialize_val: $val, $name, $type, $name_ns, $type_ns, $attributes, $use");
+ // if no name, use item
+ $name = (!$name|| is_numeric($name)) ? 'soapVal' : $name;
+ // if name has ns, add ns prefix to name
+ $xmlns = '';
+ if($name_ns){
+ $prefix = 'nu'.rand(1000,9999);
+ $name = $prefix.':'.$name;
+ $xmlns .= " xmlns:$prefix=\"$name_ns\"";
+ }
+ // if type is prefixed, create type prefix
+ if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
+ // need to fix this. shouldn't default to xsd if no ns specified
+ // w/o checking against typemap
+ $type_prefix = 'xsd';
+ } elseif($type_ns){
+ $type_prefix = 'ns'.rand(1000,9999);
+ $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
+ }
+ // serialize attributes if present
+ if($attributes){
+ foreach($attributes as $k => $v){
+ $atts .= " $k=\"$v\"";
+ }
+ }
+ // serialize if an xsd built-in primitive type
+ if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
+ if ($use == 'literal') {
+ return "<$name$xmlns>$val</$name>";
+ } else {
+ return "<$name$xmlns xsi:type=\"xsd:$type\">$val</$name>";
+ }
+ }
+ // detect type and serialize
+ $xml = '';
+ $atts = '';
+ switch(true) {
+ case ($type == '' && is_null($val)):
+ if ($use == 'literal') {
+ // TODO: depends on nillable
+ $xml .= "<$name$xmlns/>";
+ } else {
+ $xml .= "<$name$xmlns xsi:type=\"xsd:nil\"/>";
+ }
+ break;
+ case (is_bool($val) || $type == 'boolean'):
+ if(!$val){
+ $val = 0;
+ }
+ if ($use == 'literal') {
+ $xml .= "<$name$xmlns $atts>$val</$name>";
+ } else {
+ $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
+ }
+ break;
+ case (is_int($val) || is_long($val) || $type == 'int'):
+ if ($use == 'literal') {
+ $xml .= "<$name$xmlns $atts>$val</$name>";
+ } else {
+ $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
+ }
+ break;
+ case (is_float($val)|| is_double($val) || $type == 'float'):
+ if ($use == 'literal') {
+ $xml .= "<$name$xmlns $atts>$val</$name>";
+ } else {
+ $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
+ }
+ break;
+ case (is_string($val) || $type == 'string'):
+ if($this->charencoding){
+ $val = htmlspecialchars($val, ENT_QUOTES);
+ }
+ if ($use == 'literal') {
+ $xml .= "<$name$xmlns $atts>$val</$name>";
+ } else {
+ $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
+ }
+ break;
+ case is_object($val):
+ $name = get_class($val);
+ foreach(get_object_vars($val) as $k => $v){
+ $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use);
+ }
+ $xml .= '<'.$name.'>'.$pXml.'</'.$name.'>';
+ break;
+ break;
+ case (is_array($val) || $type):
+ // detect if struct or array
+ $keyList = array_keys($val);
+ $valueType = 'arraySimple';
+ foreach($keyList as $keyListValue){
+ if(!is_int($keyListValue)){
+ $valueType = 'arrayStruct';
+ break;
+ }
+ }
+ if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){
+ $i = 0;
+ if(is_array($val) && count($val)> 0){
+ foreach($val as $v){
+ if(is_object($v) && get_class($v) == 'soapval'){
+ $tt = $v->type;
+ } else {
+ $tt = gettype($v);
+ }
+ $array_types[$tt] = 1;
+ $xml .= $this->serialize_val($v,'item',false,false,false,false,$use);
+ if(is_array($v) && is_numeric(key($v))){
+ $i += sizeof($v);
+ } else {
+ ++$i;
+ }
+ }
+ if(count($array_types) > 1){
+ $array_typename = 'xsd:ur-type';
+ } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
+ $array_typename = 'xsd:'.$tt;
+ } elseif($tt == 'array' || $tt == 'Array'){
+ $array_typename = 'SOAP-ENC:Array';
+ } else {
+ $array_typename = $tt;
+ }
+ if(isset($array_types['array'])){
+ $array_type = $i.",".$i;
+ } else {
+ $array_type = $i;
+ }
+ if ($use == 'literal') {
+ $xml = "<$name $atts>".$xml."</$name>";
+ } else {
+ $xml = "<$name xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"$atts>".$xml."</$name>";
+ }
+ // empty array
+ } else {
+ if ($use == 'literal') {
+ $xml = "<$name $atts>".$xml."</$name>";;
+ } else {
+ $xml = "<$name xsi:type=\"SOAP-ENC:Array\" $atts>".$xml."</$name>";;
+ }
+ }
+ } else {
+ // got a struct
+ if(isset($type) && isset($type_prefix)){
+ $type_str = " xsi:type=\"$type_prefix:$type\"";
+ } else {
+ $type_str = '';
+ }
+ if ($use == 'literal') {
+ $xml .= "<$name$xmlns $atts>";
+ } else {
+ $xml .= "<$name$xmlns$type_str$atts>";
+ }
+ foreach($val as $k => $v){
+ $xml .= $this->serialize_val($v,$k,false,false,false,false,$use);
+ }
+ $xml .= "</$name>";
+ }
+ break;
+ default:
+ $xml .= 'not detected, got '.gettype($val).' for '.$val;
+ break;
+ }
+ return $xml;
+ }
+
+ /**
+ * serialize message
+ *
+ * @param string body
+ * @param string headers
+ * @param array namespaces
+ * @param string style
+ * @return string message
+ * @access public
+ */
+ function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc'){
+ // serialize namespaces
+ $ns_string = '';
+ foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
+ $ns_string .= " xmlns:$k=\"$v\"";
+ }
+ if($style == 'rpc') {
+ $ns_string = ' SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string;
+ }
+
+ // serialize headers
+ if($headers){
+ $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
+ }
+ // serialize envelope
+ return
+ '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">".
+ '<SOAP-ENV:Envelope'.$ns_string.">".
+ $headers.
+ "<SOAP-ENV:Body>".
+ $body.
+ "</SOAP-ENV:Body>".
+ "</SOAP-ENV:Envelope>";
+ }
+
+ function formatDump($str){
+ $str = htmlspecialchars($str);
+ return nl2br($str);
+ }
+
+ /**
+ * returns the local part of a prefixed string
+ * returns the original string, if not prefixed
+ *
+ * @param string
+ * @return string
+ * @access public
+ */
+ function getLocalPart($str){
+ if($sstr = strrchr($str,':')){
+ // get unqualified name
+ return substr( $sstr, 1 );
+ } else {
+ return $str;
+ }
+ }
+
+ /**
+ * returns the prefix part of a prefixed string
+ * returns false, if not prefixed
+ *
+ * @param string
+ * @return mixed
+ * @access public
+ */
+ function getPrefix($str){
+ if($pos = strrpos($str,':')){
+ // get prefix
+ return substr($str,0,$pos);
+ }
+ return false;
+ }
+
+ function varDump($data) {
+ ob_start();
+ var_dump($data);
+ $ret_val = ob_get_contents();
+ ob_end_clean();
+ return $ret_val;
+ }
+}
+
+// XML Schema Datatype Helper Functions
+
+//xsd:dateTime helpers
+
+/**
+* convert unix timestamp to ISO 8601 compliant date string
+*
+* @param string $timestamp Unix time stamp
+* @access public
+*/
+function timestamp_to_iso8601($timestamp,$utc=true){
+ $datestr = date('Y-m-d\TH:i:sO',$timestamp);
+ if($utc){
+ $eregStr =
+ '([0-9]{4})-'. // centuries & years CCYY-
+ '([0-9]{2})-'. // months MM-
+ '([0-9]{2})'. // days DD
+ 'T'. // separator T
+ '([0-9]{2}):'. // hours hh:
+ '([0-9]{2}):'. // minutes mm:
+ '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
+ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
+
+ if(ereg($eregStr,$datestr,$regs)){
+ return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
+ }
+ return false;
+ } else {
+ return $datestr;
+ }
+}
+
+/**
+* convert ISO 8601 compliant date string to unix timestamp
+*
+* @param string $datestr ISO 8601 compliant date string
+* @access public
+*/
+function iso8601_to_timestamp($datestr){
+ $eregStr =
+ '([0-9]{4})-'. // centuries & years CCYY-
+ '([0-9]{2})-'. // months MM-
+ '([0-9]{2})'. // days DD
+ 'T'. // separator T
+ '([0-9]{2}):'. // hours hh:
+ '([0-9]{2}):'. // minutes mm:
+ '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
+ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
+ if(ereg($eregStr,$datestr,$regs)){
+ // not utc
+ if($regs[8] != 'Z'){
+ $op = substr($regs[8],0,1);
+ $h = substr($regs[8],1,2);
+ $m = substr($regs[8],strlen($regs[8])-2,2);
+ if($op == '-'){
+ $regs[4] = $regs[4] + $h;
+ $regs[5] = $regs[5] + $m;
+ } elseif($op == '+'){
+ $regs[4] = $regs[4] - $h;
+ $regs[5] = $regs[5] - $m;
+ }
+ }
+ return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
+ } else {
+ return false;
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+* soap_fault class, allows for creation of faults
+* mainly used for returning faults from deployed functions
+* in a server instance.
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soap_fault extends nusoap_base {
+
+ var $faultcode;
+ var $faultactor;
+ var $faultstring;
+ var $faultdetail;
+
+ /**
+ * constructor
+ *
+ * @param string $faultcode (client | server)
+ * @param string $faultactor only used when msg routed between multiple actors
+ * @param string $faultstring human readable error message
+ * @param string $faultdetail
+ */
+ function soap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
+ $this->faultcode = $faultcode;
+ $this->faultactor = $faultactor;
+ $this->faultstring = $faultstring;
+ $this->faultdetail = $faultdetail;
+ }
+
+ /**
+ * serialize a fault
+ *
+ * @access public
+ */
+ function serialize(){
+ $ns_string = '';
+ foreach($this->namespaces as $k => $v){
+ $ns_string .= "\n xmlns:$k=\"$v\"";
+ }
+ $return_msg =
+ '<?xml version="1.0"?'.">\n".
+ '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
+ '<SOAP-ENV:Body>'.
+ '<SOAP-ENV:Fault>'.
+ '<faultcode>'.$this->faultcode.'</faultcode>'.
+ '<faultactor>'.$this->faultactor.'</faultactor>'.
+ '<faultstring>'.$this->faultstring.'</faultstring>'.
+ '<detail>'.$this->serialize_val($this->faultdetail).'</detail>'.
+ '</SOAP-ENV:Fault>'.
+ '</SOAP-ENV:Body>'.
+ '</SOAP-ENV:Envelope>';
+ return $return_msg;
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+* parses an XML Schema, allows access to it's data, other utility methods
+* no validation... yet.
+* very experimental and limited. As is discussed on XML-DEV, I'm one of the people
+* that just doesn't have time to read the spec(s) thoroughly, and just have a couple of trusty
+* tutorials I refer to :)
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class XMLSchema extends nusoap_base {
+
+ // files
+ var $schema = '';
+ var $xml = '';
+ // define internal arrays of bindings, ports, operations, messages, etc.
+ var $complexTypes = array();
+ // target namespace
+ var $schemaTargetNamespace = '';
+ // parser vars
+ var $parser;
+ var $position;
+ var $depth = 0;
+ var $depth_array = array();
+
+ /**
+ * constructor
+ *
+ * @param string $schema schema document URI
+ * @param string $xml xml document URI
+ * @access public
+ */
+ function XMLSchema($schema='',$xml=''){
+
+ $this->debug('xmlschema class instantiated, inside constructor');
+ // files
+ $this->schema = $schema;
+ $this->xml = $xml;
+
+ // parse schema file
+ if($schema != ''){
+ $this->debug('initial schema file: '.$schema);
+ $this->parseFile($schema);
+ }
+
+ // parse xml file
+ if($xml != ''){
+ $this->debug('initial xml file: '.$xml);
+ $this->parseFile($xml);
+ }
+
+ }
+
+ /**
+ * parse an XML file
+ *
+ * @param string $xml, path/URL to XML file
+ * @param string $type, (schema | xml)
+ * @return boolean
+ * @access public
+ */
+ function parseFile($xml,$type){
+ // parse xml file
+ if($xml != ""){
+ $this->debug('parsing $xml');
+ $xmlStr = @join("",@file($xml));
+ if($xmlStr == ""){
+ $this->setError('No file at the specified URL: '.$xml);
+ return false;
+ } else {
+ $this->parseString($xmlStr,$type);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * parse an XML string
+ *
+ * @param string $xml path or URL
+ * @param string $type, (schema|xml)
+ * @access private
+ */
+ function parseString($xml,$type){
+ // parse xml string
+ if($xml != ""){
+
+ // Create an XML parser.
+ $this->parser = xml_parser_create();
+ // Set the options for parsing the XML data.
+ xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
+
+ // Set the object for the parser.
+ xml_set_object($this->parser, $this);
+
+ // Set the element handlers for the parser.
+ if($type == "schema"){
+ xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
+ xml_set_character_data_handler($this->parser,'schemaCharacterData');
+ } elseif($type == "xml"){
+ xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
+ xml_set_character_data_handler($this->parser,'xmlCharacterData');
+ }
+
+ // Parse the XML file.
+ if(!xml_parse($this->parser,$xml,true)){
+ // Display an error message.
+ $errstr = sprintf('XML error on line %d: %s',
+ xml_get_current_line_number($this->parser),
+ xml_error_string(xml_get_error_code($this->parser))
+ );
+ $this->debug('XML parse error: '.$errstr);
+ $this->setError('Parser error: '.$errstr);
+ }
+
+ xml_parser_free($this->parser);
+ } else{
+ $this->debug('no xml passed to parseString()!!');
+ $this->setError('no xml passed to parseString()!!');
+ }
+ }
+
+ /**
+ * start-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @param string $attrs associative array of attributes
+ * @access private
+ */
+ function schemaStartElement($parser, $name, $attrs) {
+
+ // position in the total number of elements, starting from 0
+ $pos = $this->position++;
+ $depth = $this->depth++;
+ // set self as current value for this depth
+ $this->depth_array[$depth] = $pos;
+
+ // get element prefix
+ if($prefix = $this->getPrefix($name)){
+ // get unqualified name
+ $name = $this->getLocalPart($name);
+ } else {
+ $prefix = '';
+ }
+
+ // loop thru attributes, expanding, and registering namespace declarations
+ if(count($attrs) > 0){
+ foreach($attrs as $k => $v){
+ // if ns declarations, add to class level array of valid namespaces
+ if(ereg("^xmlns",$k)){
+ //$this->xdebug("$k: $v");
+ //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
+ if($ns_prefix = substr(strrchr($k,':'),1)){
+ $this->namespaces[$ns_prefix] = $v;
+ } else {
+ $this->namespaces['ns'.(count($this->namespaces)+1)] = $v;
+ }
+ if($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema'){
+ $this->XMLSchemaVersion = $v;
+ $this->namespaces['xsi'] = $v.'-instance';
+ }
+ }
+ }
+ foreach($attrs as $k => $v){
+ // expand each attribute
+ $k = strpos($k,':') ? $this->expandQname($k) : $k;
+ $v = strpos($v,':') ? $this->expandQname($v) : $v;
+ $eAttrs[$k] = $v;
+ }
+ $attrs = $eAttrs;
+ } else {
+ $attrs = array();
+ }
+ // find status, register data
+ switch($name){
+ case ('all'|'choice'|'sequence'):
+ //$this->complexTypes[$this->currentComplexType]['compositor'] = 'all';
+ $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
+ if($name == 'all'){
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
+ }
+ break;
+ case 'attribute':
+ //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
+ if(isset($attrs['name'])){
+ $this->attributes[$attrs['name']] = $attrs;
+ $aname = $attrs['name'];
+ } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){
+ $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
+ } elseif(isset($attrs['ref'])){
+ $aname = $attrs['ref'];
+ $this->attributes[$attrs['ref']] = $attrs;
+ }
+
+ if(isset($this->currentComplexType)){
+ $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
+ } elseif(isset($this->currentElement)){
+ $this->elements[$this->currentElement]['attrs'][$aname] = $attrs;
+ }
+ // arrayType attribute
+ if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
+ $prefix = $this->getPrefix($aname);
+ if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){
+ $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
+ } else {
+ $v = '';
+ }
+ if(strpos($v,'[,]')){
+ $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
+ }
+ $v = substr($v,0,strpos($v,'[')); // clip the []
+ if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){
+ $v = $this->XMLSchemaVersion.':'.$v;
+ }
+ $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
+ }
+ break;
+ case 'complexType':
+ if(isset($attrs['name'])){
+ $this->currentElement = false;
+ $this->currentComplexType = $attrs['name'];
+ $this->complexTypes[$this->currentComplexType] = $attrs;
+ $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
+ if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
+ } else {
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
+ }
+ $this->xdebug('processing complexType '.$attrs['name']);
+ }
+ break;
+ case 'element':
+ if(isset($attrs['type'])){
+ $this->xdebug("processing element ".$attrs['name']);
+ $this->currentElement = $attrs['name'];
+ $this->elements[ $attrs['name'] ] = $attrs;
+ $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
+ $ename = $attrs['name'];
+ } elseif(isset($attrs['ref'])){
+ $ename = $attrs['ref'];
+ } else {
+ $this->xdebug('adding complexType '.$attrs['name']);
+ $this->currentComplexType = $attrs['name'];
+ $this->complexTypes[ $attrs['name'] ] = $attrs;
+ $this->complexTypes[ $attrs['name'] ]['element'] = 1;
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
+ }
+ if(isset($ename) && $this->currentComplexType){
+ $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
+ }
+ break;
+ case 'restriction':
+ $this->xdebug("in restriction for ct: $this->currentComplexType and ce: $this->currentElement");
+ if($this->currentElement){
+ $this->elements[$this->currentElement]['type'] = $attrs['base'];
+ } elseif($this->currentComplexType){
+ $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
+ if(strstr($attrs['base'],':') == ':Array'){
+ $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
+ }
+ }
+ break;
+ case 'schema':
+ $this->schema = $attrs;
+ $this->schema['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
+ break;
+ case 'simpleType':
+ $this->currentElement = $attrs['name'];
+ $this->elements[ $attrs['name'] ] = $attrs;
+ $this->elements[ $attrs['name'] ]['typeClass'] = 'element';
+ break;
+ }
+ }
+
+ /**
+ * end-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @access private
+ */
+ function schemaEndElement($parser, $name) {
+ // position of current element is equal to the last value left in depth_array for my depth
+ if(isset($this->depth_array[$this->depth])){
+ $pos = $this->depth_array[$this->depth];
+ }
+ // bring depth down a notch
+ $this->depth--;
+ // move on...
+ if($name == 'complexType'){
+ $this->currentComplexType = false;
+ $this->currentElement = false;
+ }
+ if($name == 'element'){
+ $this->currentElement = false;
+ }
+ }
+
+ /**
+ * element content handler
+ *
+ * @param string $parser XML parser object
+ * @param string $data element content
+ * @access private
+ */
+ function schemaCharacterData($parser, $data){
+ $pos = $this->depth_array[$this->depth];
+ $this->message[$pos]['cdata'] .= $data;
+ }
+
+ /**
+ * serialize the schema
+ *
+ * @access public
+ */
+ function serializeSchema(){
+
+ $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
+ $xml = '';
+ // complex types
+ foreach($this->complexTypes as $typeName => $attrs){
+ $contentStr = '';
+ // serialize child elements
+ if(count($attrs['elements']) > 0){
+ foreach($attrs['elements'] as $element => $eParts){
+ if(isset($eParts['ref'])){
+ $contentStr .= "<element ref=\"$element\"/>";
+ } else {
+ $contentStr .= "<element name=\"$element\" type=\"$eParts[type]\"/>";
+ }
+ }
+ }
+ // attributes
+ if(count($attrs['attrs']) >= 1){
+ foreach($attrs['attrs'] as $attr => $aParts){
+ $contentStr .= '<attribute ref="'.$aParts['ref'].'"';
+ if(isset($aParts['wsdl:arrayType'])){
+ $contentStr .= ' wsdl:arrayType="'.$aParts['wsdl:arrayType'].'"';
+ }
+ $contentStr .= '/>';
+ }
+ }
+ // if restriction
+ if( isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != ''){
+ $contentStr = "<$schemaPrefix:restriction base=\"".$attrs['restrictionBase']."\">".$contentStr."</$schemaPrefix:restriction>";
+ }
+ // "all" compositor obviates complex/simple content
+ if(isset($attrs['compositor']) && $attrs['compositor'] == 'all'){
+ $contentStr = "<$schemaPrefix:$attrs[compositor]>".$contentStr."</$schemaPrefix:$attrs[compositor]>";
+ }
+ // complex or simple content
+ elseif( count($attrs['elements']) > 0 || count($attrs['attrs']) > 0){
+ $contentStr = "<$schemaPrefix:complexContent>".$contentStr."</$schemaPrefix:complexContent>";
+ }
+ // compositors
+ if(isset($attrs['compositor']) && $attrs['compositor'] != '' && $attrs['compositor'] != 'all'){
+ $contentStr = "<$schemaPrefix:$attrs[compositor]>".$contentStr."</$schemaPrefix:$attrs[compositor]>";
+ }
+ // finalize complex type
+ if($contentStr != ''){
+ $contentStr = "<$schemaPrefix:complexType name=\"$typeName\">".$contentStr."</$schemaPrefix:complexType>";
+ } else {
+ $contentStr = "<$schemaPrefix:complexType name=\"$typeName\"/>";
+ }
+ $xml .= $contentStr;
+ }
+ // elements
+ if(isset($this->elements) && count($this->elements) > 0){
+ foreach($this->elements as $element => $eParts){
+ $xml .= "<$schemaPrefix:element name=\"$element\" type=\"".$eParts['type']."\"/>";
+ }
+ }
+ // attributes
+ if(isset($this->attributes) && count($this->attributes) > 0){
+ foreach($this->attributes as $attr => $aParts){
+ $xml .= "<$schemaPrefix:attribute name=\"$attr\" type=\"".$aParts['type']."\"/>";
+ }
+ }
+ // finish 'er up
+ $xml = "<$schemaPrefix:schema xmlns=\"$this->XMLSchemaVersion\" targetNamespace=\"$this->schemaTargetNamespace\">".$xml."</$schemaPrefix:schema>";
+ return $xml;
+ }
+
+ /**
+ * expands a qualified name
+ *
+ * @param string $string qname
+ * @return string expanded qname
+ * @access private
+ */
+ function expandQname($qname){
+ // get element prefix
+ if(strpos($qname,':') && !ereg('^http://',$qname)){
+ // get unqualified name
+ $name = substr(strstr($qname,':'),1);
+ // get ns prefix
+ $prefix = substr($qname,0,strpos($qname,':'));
+ if(isset($this->namespaces[$prefix])){
+ return $this->namespaces[$prefix].':'.$name;
+ } else {
+ return $qname;
+ }
+ } else {
+ return $qname;
+ }
+ }
+
+ /**
+ * adds debug data to the clas level debug string
+ *
+ * @param string $string debug data
+ * @access private
+ */
+ function xdebug($string){
+ $this->debug(' xmlschema: '.$string);
+ }
+
+ /**
+ * get the PHP type of a user defined type in the schema
+ * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
+ * returns false if no type exists, or not w/ the given namespace
+ * else returns a string that is either a native php type, or 'struct'
+ *
+ * @param string $type, name of defined type
+ * @param string $ns, namespace of type
+ * @return mixed
+ * @access public
+ */
+ function getPHPType($type,$ns){
+ global $typemap;
+ if(isset($typemap[$ns][$type])){
+ //print "found type '$type' and ns $ns in typemap<br>";
+ return $typemap[$ns][$type];
+ } elseif(isset($this->complexTypes[$type])){
+ //print "getting type '$type' and ns $ns from complexTypes array<br>";
+ return $this->complexTypes[$type]['phpType'];
+ }
+ return false;
+ }
+
+ /**
+ * returns the local part of a prefixed string
+ * returns the original string, if not prefixed
+ *
+ * @param string
+ * @return string
+ * @access public
+ */
+ function getLocalPart($str){
+ if($sstr = strrchr($str,':')){
+ // get unqualified name
+ return substr( $sstr, 1 );
+ } else {
+ return $str;
+ }
+ }
+
+ /**
+ * returns the prefix part of a prefixed string
+ * returns false, if not prefixed
+ *
+ * @param string
+ * @return mixed
+ * @access public
+ */
+ function getPrefix($str){
+ if($pos = strrpos($str,':')){
+ // get prefix
+ return substr($str,0,$pos);
+ }
+ return false;
+ }
+
+ /**
+ * pass it a prefix, it returns a namespace
+ * returns false if no namespace registered with the given prefix
+ *
+ * @param string
+ * @return mixed
+ * @access public
+ */
+ function getNamespaceFromPrefix($prefix){
+ if(isset($this->namespaces[$prefix])){
+ return $this->namespaces[$prefix];
+ }
+ //$this->setError("No namespace registered for prefix '$prefix'");
+ return false;
+ }
+
+ /**
+ * returns the prefix for a given namespace (or prefix)
+ * or false if no prefixes registered for the given namespace
+ *
+ * @param string
+ * @return mixed
+ * @access public
+ */
+ function getPrefixFromNamespace($ns){
+ foreach($this->namespaces as $p => $n){
+ if($ns == $n || $ns == $p){
+ $this->usedNamespaces[$p] = $n;
+ return $p;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * returns an array of information about a given type
+ * returns false if no type exists by the given name
+ *
+ * typeDef = array(
+ * 'elements' => array(), // refs to elements array
+ * 'restrictionBase' => '',
+ * 'phpType' => '',
+ * 'order' => '(sequence|all)',
+ * 'attrs' => array() // refs to attributes array
+ * )
+ *
+ * @param string
+ * @return mixed
+ * @access public
+ */
+ function getTypeDef($type){
+ if(isset($this->complexTypes[$type])){
+ return $this->complexTypes[$type];
+ } elseif(isset($this->elements[$type])){
+ return $this->elements[$type];
+ } elseif(isset($this->attributes[$type])){
+ return $this->attributes[$type];
+ }
+ return false;
+ }
+
+ /**
+ * returns a sample serialization of a given type, or false if no type by the given name
+ *
+ * @param string $type, name of type
+ * @return mixed
+ * @access public
+ */
+ function serializeTypeDef($type){
+ //print "in sTD() for type $type<br>";
+ if($typeDef = $this->getTypeDef($type)){
+ $str .= '<'.$type;
+ if(is_array($typeDef['attrs'])){
+ foreach($attrs as $attName => $data){
+ $str .= " $attName=\"{type = ".$data['type']."}\"";
+ }
+ }
+ $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
+ if(count($typeDef['elements']) > 0){
+ $str .= ">";
+ foreach($typeDef['elements'] as $element => $eData){
+ $str .= $this->serializeTypeDef($element);
+ }
+ $str .= "</$type>";
+ } elseif($typeDef['typeClass'] == 'element') {
+ $str .= "></$type>";
+ } else {
+ $str .= "/>";
+ }
+ return $str;
+ }
+ return false;
+ }
+
+ /**
+ * returns HTML form elements that allow a user
+ * to enter values for creating an instance of the given type.
+ *
+ * @param string $name, name for type instance
+ * @param string $type, name of type
+ * @return string
+ * @access public
+ */
+ function typeToForm($name,$type){
+ // get typedef
+ if($typeDef = $this->getTypeDef($type)){
+ // if struct
+ if($typeDef['phpType'] == 'struct'){
+ $buffer .= '<table>';
+ foreach($typeDef['elements'] as $child => $childDef){
+ $buffer .= "
+ <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
+ <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
+ }
+ $buffer .= '</table>';
+ // if array
+ } elseif($typeDef['phpType'] == 'array'){
+ $buffer .= '<table>';
+ for($i=0;$i < 3; $i++){
+ $buffer .= "
+ <tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
+ <td><input type='text' name='parameters[".$name."][]'></td></tr>";
+ }
+ $buffer .= '</table>';
+ // if scalar
+ } else {
+ $buffer .= "<input type='text' name='parameters[$name]'>";
+ }
+ } else {
+ $buffer .= "<input type='text' name='parameters[$name]'>";
+ }
+ return $buffer;
+ }
+
+ /**
+ * adds an XML Schema complex type to the WSDL types
+ *
+ * example: array
+ *
+ * addType(
+ * 'ArrayOfstring',
+ * 'complexType',
+ * 'array',
+ * '',
+ * 'SOAP-ENC:Array',
+ * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
+ * 'xsd:string'
+ * );
+ *
+ * example: PHP associative array ( SOAP Struct )
+ *
+ * addType(
+ * 'SOAPStruct',
+ * 'complexType',
+ * 'struct',
+ * 'all',
+ * array('myVar'=> array('name'=>'myVar','type'=>'string')
+ * );
+ *
+ * @param name
+ * @param typeClass (complexType|simpleType|attribute)
+ * @param phpType: currently supported are array and struct (php assoc array)
+ * @param compositor (all|sequence|choice)
+ * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
+ * @param elements = array ( name = array(name=>'',type=>'') )
+ * @param attrs = array(
+ * array(
+ * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
+ * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
+ * )
+ * )
+ * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string)
+ *
+ */
+ function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){
+ $this->complexTypes[$name] = array(
+ 'name' => $name,
+ 'typeClass' => $typeClass,
+ 'phpType' => $phpType,
+ 'compositor'=> $compositor,
+ 'restrictionBase' => $restrictionBase,
+ 'elements' => $elements,
+ 'attrs' => $attrs,
+ 'arrayType' => $arrayType
+ );
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+* for creating serializable abstractions of native PHP types
+* NOTE: this is only really used when WSDL is not available.
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soapval extends nusoap_base {
+ /**
+ * constructor
+ *
+ * @param string $name optional name
+ * @param string $type optional type name
+ * @param mixed $value optional value
+ * @param string $namespace optional namespace of value
+ * @param string $type_namespace optional namespace of type
+ * @param array $attributes associative array of attributes to add to element serialization
+ * @access public
+ */
+ function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
+ $this->name = $name;
+ $this->value = $value;
+ $this->type = $type;
+ $this->element_ns = $element_ns;
+ $this->type_ns = $type_ns;
+ $this->attributes = $attributes;
+ }
+
+ /**
+ * return serialized value
+ *
+ * @return string XML data
+ * @access private
+ */
+ function serialize($use='encoded') {
+ return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,$this->attributes,$use);
+ }
+
+ /**
+ * decodes a soapval object into a PHP native type
+ *
+ * @param object $soapval optional SOAPx4 soapval object, else uses self
+ * @return mixed
+ * @access public
+ */
+ function decode(){
+ return $this->value;
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+* transport class for sending/receiving data via HTTP and HTTPS
+* NOTE: PHP must be compiled with the CURL extension for HTTPS support
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soap_transport_http extends nusoap_base {
+
+ var $username = '';
+ var $password = '';
+ var $url = '';
+ var $proxyhost = '';
+ var $proxyport = '';
+ var $scheme = '';
+ var $request_method = 'POST';
+ var $protocol_version = '1.0';
+ var $encoding = '';
+ var $outgoing_headers = array();
+ var $incoming_headers = array();
+ var $outgoing_payload = '';
+ var $incoming_payload = '';
+ var $useSOAPAction = true;
+
+ /**
+ * constructor
+ */
+ function soap_transport_http($url){
+ $this->url = $url;
+ $u = parse_url($url);
+ foreach($u as $k => $v){
+ $this->debug("$k = $v");
+ $this->$k = $v;
+ }
+ if(isset($u['query']) && $u['query'] != ''){
+ $this->path .= '?' . $u['query'];
+ }
+ if(!isset($u['port']) && $u['scheme'] == 'http'){
+ $this->port = 80;
+ }
+ }
+
+ function connect($timeout){
+
+ // proxy
+ if($this->proxyhost != '' && $this->proxyport != ''){
+ $host = $this->proxyhost;
+ $port = $this->proxyport;
+ $this->debug("using http proxy: $host, $port");
+ } else {
+ $host = $this->host;
+ $port = $this->port;
+ }
+ // ssl
+ if($this->scheme == 'https'){
+ $host = 'ssl://'.$host;
+ $port = 443;
+ }
+
+ $this->debug("connection params: $host, $port");
+ // timeout
+ if($timeout > 0){
+ $fp = fsockopen($host, $port, $this->errno, $this->error_str, $timeout);
+ } else {
+ $fp = fsockopen($host, $port, $this->errno, $this->error_str);
+ }
+
+ // test pointer
+ if(!$fp) {
+ $this->debug('Couldn\'t open socket connection to server '.$this->url.', Error: '.$this->error_str);
+ $this->setError('Couldn\'t open socket connection to server: '.$this->url.', Error: '.$this->error_str);
+ return false;
+ }
+ return $fp;
+ }
+
+ /**
+ * send the SOAP message via HTTP
+ *
+ * @param string $data message data
+ * @param integer $timeout set timeout in seconds
+ * @return string data
+ * @access public
+ */
+ function send($data, $timeout=0) {
+ $this->debug('entered send() with data of length: '.strlen($data));
+ // get connnection
+ if(!$fp = $this->connect($timeout)){
+ return false;
+ }
+ $this->debug('socket connected');
+
+ // start building outgoing payload:
+ // swap url for path if going through a proxy
+ if($this->proxyhost != '' && $this->proxyport != ''){
+ $this->outgoing_payload = "$this->request_method $this->url ".strtoupper($this->scheme)."/$this->protocol_version\r\n";
+ } else {
+ $this->outgoing_payload = "$this->request_method $this->path ".strtoupper($this->scheme)."/$this->protocol_version\r\n";
+ }
+ // make payload
+ $this->outgoing_payload .=
+ "User-Agent: $this->title/$this->version\r\n".
+ "Host: ".$this->host."\r\n";
+ // http auth
+ $credentials = '';
+ if($this->username != '') {
+ $this->debug('setting http auth credentials');
+ $this->outgoing_payload .= 'Authorization: Basic '.base64_encode("$this->username:$this->password")."\r\n";
+ }
+ // set content type
+ $this->outgoing_payload .= 'Content-Type: text/xml; charset='.$this->soap_defencoding."\r\nContent-Length: ".strlen($data)."\r\n";
+ // http encoding
+ if($this->encoding != '' && function_exists('gzdeflate')){
+ $this->outgoing_payload .= "Accept-Encoding: $this->encoding\r\n".
+ "Connection: close\r\n";
+ set_magic_quotes_runtime(0);
+ }
+ // set soapaction
+ if($this->useSOAPAction){
+ $this->outgoing_payload .= "SOAPAction: \"$this->soapaction\""."\r\n";
+ }
+ $this->outgoing_payload .= "\r\n";
+ // add data
+ $this->outgoing_payload .= $data;
+
+ // send payload
+ if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
+ $this->setError('couldn\'t write message data to socket');
+ $this->debug('Write error');
+ }
+ $this->debug('wrote data to socket');
+
+ // get response
+ $this->incoming_payload = '';
+ //$strlen = 0;
+ while( $data = fread($fp, 32768) ){
+ $this->incoming_payload .= $data;
+ //$strlen += strlen($data);
+ }
+ $this->debug('received '.strlen($this->incoming_payload).' bytes of data from server');
+
+ // close filepointer
+ fclose($fp);
+ $this->debug('closed socket');
+
+ // connection was closed unexpectedly
+ if($this->incoming_payload == ''){
+ $this->setError('no response from server');
+ return false;
+ }
+
+ $this->debug('received incoming payload: '.strlen($this->incoming_payload));
+ $data = $this->incoming_payload."\r\n\r\n\r\n\r\n";
+
+ // remove 100 header
+ if(ereg('^HTTP/1.1 100',$data)){
+ if($pos = strpos($data,"\r\n\r\n") ){
+ $data = ltrim(substr($data,$pos));
+ } elseif($pos = strpos($data,"\n\n") ){
+ $data = ltrim(substr($data,$pos));
+ }
+ }//
+
+ // separate content from HTTP headers
+ if( $pos = strpos($data,"\r\n\r\n") ){
+ $lb = "\r\n";
+ } elseif( $pos = strpos($data,"\n\n") ){
+ $lb = "\n";
+ } else {
+ $this->setError('no proper separation of headers and document');
+ return false;
+ }
+ $header_data = trim(substr($data,0,$pos));
+ $header_array = explode($lb,$header_data);
+ $data = ltrim(substr($data,$pos));
+ $this->debug('found proper separation of headers and document');
+ $this->debug('cleaned data, stringlen: '.strlen($data));
+ // clean headers
+ foreach($header_array as $header_line){
+ $arr = explode(':',$header_line);
+ if(count($arr) >= 2){
+ $headers[trim($arr[0])] = trim($arr[1]);
+ }
+ }
+ //print "headers: <pre>$header_data</pre><br>";
+ //print "data: <pre>$data</pre><br>";
+
+ // decode transfer-encoding
+ if(isset($headers['Transfer-Encoding']) && $headers['Transfer-Encoding'] == 'chunked'){
+ //$timer->setMarker('starting to decode chunked content');
+ if(!$data = $this->decodeChunked($data)){
+ $this->setError('Decoding of chunked data failed');
+ return false;
+ }
+ //$timer->setMarker('finished decoding of chunked content');
+ //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
+ }
+
+ // decode content-encoding
+ if(isset($headers['Content-Encoding']) && $headers['Content-Encoding'] != ''){
+ if($headers['Content-Encoding'] == 'deflate' || $headers['Content-Encoding'] == 'gzip'){
+ // if decoding works, use it. else assume data wasn't gzencoded
+ if(function_exists('gzinflate')){
+ //$timer->setMarker('starting decoding of gzip/deflated content');
+ if($headers['Content-Encoding'] == 'deflate' && $degzdata = @gzinflate($data)){
+ $data = $degzdata;
+ } elseif($headers['Content-Encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))){
+ $data = $degzdata;
+ } else {
+ $this->setError('Errors occurred when trying to decode the data');
+ }
+ //$timer->setMarker('finished decoding of gzip/deflated content');
+ //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
+ } else {
+ $this->setError('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ }
+ }
+ }
+
+ if(strlen($data) == 0){
+ $this->debug('no data after headers!');
+ $this->setError('no data present after HTTP headers');
+ return false;
+ }
+ $this->debug('end of send()');
+ return $data;
+ }
+
+
+ /**
+ * send the SOAP message via HTTPS 1.0 using CURL
+ *
+ * @param string $msg message data
+ * @param integer $timeout set timeout in seconds
+ * @return string data
+ * @access public
+ */
+ function sendHTTPS($data, $timeout=0) {
+ //global $t;
+ //$t->setMarker('inside sendHTTPS()');
+ $this->debug('entered sendHTTPS() with data of length: '.strlen($data));
+ // init CURL
+ $ch = curl_init();
+ //$t->setMarker('got curl handle');
+ // set proxy
+ if($this->proxyhost && $this->proxyport){
+ $host = $this->proxyhost;
+ $port = $this->proxyport;
+ } else {
+ $host = $this->host;
+ $port = $this->port;
+ }
+ // set url
+ $hostURL = ($port != '') ? "https://$host:$port" : "https://$host";
+ // add path
+ $hostURL .= $this->path;
+ curl_setopt($ch, CURLOPT_URL, $hostURL);
+ // set other options
+ curl_setopt($ch, CURLOPT_HEADER, 1);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ // encode
+ if(function_exists('gzinflate')){
+ curl_setopt($ch, CURLOPT_ENCODING, 'deflate');
+ }
+ // persistent connection
+ //curl_setopt($ch, CURL_HTTP_VERSION_1_1, true);
+
+ // set timeout
+ if($timeout != 0){
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+ }
+
+ $credentials = '';
+ if($this->username != '') {
+ $credentials = 'Authorization: Basic '.base64_encode("$this->username:$this->password").'\r\n';
+ }
+
+ if($this->encoding != ''){
+ if(function_exists('gzdeflate')){
+ $encoding_headers = "Accept-Encoding: $this->encoding\r\n".
+ "Connection: close\r\n";
+ set_magic_quotes_runtime(0);
+ }
+ }
+
+ if($this->proxyhost && $this->proxyport){
+ $this->outgoing_payload = "POST $this->url HTTP/$this->protocol_version\r\n";
+ } else {
+ $this->outgoing_payload = "POST $this->path HTTP/$this->protocol_version\r\n";
+ }
+
+ $this->outgoing_payload .=
+ "User-Agent: $this->title v$this->version\r\n".
+ "Host: ".$this->host."\r\n".
+ $encoding_headers.
+ $credentials.
+ "Content-Type: text/xml; charset=\"$this->soap_defencoding\"\r\n".
+ "Content-Length: ".strlen($data)."\r\n".
+ "SOAPAction: \"$this->soapaction\""."\r\n\r\n".
+ $data;
+
+ // set payload
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
+ //$t->setMarker('set curl options, executing...');
+ // send and receive
+ $this->incoming_payload = curl_exec($ch);
+ //$t->setMarker('executed transfer');
+ $data = $this->incoming_payload;
+
+ $cErr = curl_error($ch);
+
+ if($cErr != ''){
+ $err = 'cURL ERROR: '.curl_errno($ch).': '.$cErr.'<br>';
+ foreach(curl_getinfo($ch) as $k => $v){
+ $err .= "$k: $v<br>";
+ }
+ $this->setError($err);
+ curl_close($ch);
+ return false;
+ } else {
+ //echo '<pre>';
+ //var_dump(curl_getinfo($ch));
+ //echo '</pre>';
+ }
+ // close curl
+ curl_close($ch);
+ //$t->setMarker('closed curl');
+
+ // remove 100 header
+ if(ereg('^HTTP/1.1 100',$data)){
+ if($pos = strpos($data,"\r\n\r\n") ){
+ $data = ltrim(substr($data,$pos));
+ } elseif($pos = strpos($data,"\n\n") ){
+ $data = ltrim(substr($data,$pos));
+ }
+ }//
+
+ // separate content from HTTP headers
+ if( $pos = strpos($data,"\r\n\r\n") ){
+ $lb = "\r\n";
+ } elseif( $pos = strpos($data,"\n\n") ){
+ $lb = "\n";
+ } else {
+ $this->setError('no proper separation of headers and document');
+ return false;
+ }
+ $header_data = trim(substr($data,0,$pos));
+ $header_array = explode($lb,$header_data);
+ $data = ltrim(substr($data,$pos));
+ $this->debug('found proper separation of headers and document');
+ $this->debug('cleaned data, stringlen: '.strlen($data));
+ // clean headers
+ foreach($header_array as $header_line){
+ $arr = explode(':',$header_line);
+ $headers[trim($arr[0])] = trim($arr[1]);
+ }
+ if(strlen($data) == 0){
+ $this->debug('no data after headers!');
+ $this->setError('no data present after HTTP headers.');
+ return false;
+ }
+
+ // decode transfer-encoding
+ if($headers['Transfer-Encoding'] == 'chunked'){
+ if(!$data = $this->decodeChunked($data)){
+ $this->setError('Decoding of chunked data failed');
+ return false;
+ }
+ }
+ // decode content-encoding
+ if($headers['Content-Encoding'] != ''){
+ if($headers['Content-Encoding'] == 'deflate' || $headers['Content-Encoding'] == 'gzip'){
+ // if decoding works, use it. else assume data wasn't gzencoded
+ if(function_exists('gzinflate')){
+ if($headers['Content-Encoding'] == 'deflate' && $degzdata = @gzinflate($data)){
+ $data = $degzdata;
+ } elseif($headers['Content-Encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))){
+ $data = $degzdata;
+ } else {
+ $this->setError('Errors occurred when trying to decode the data');
+ }
+ } else {
+ $this->setError('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ }
+ }
+ }
+ // set decoded payload
+ $this->incoming_payload = $header_data."\r\n\r\n".$data;
+ return $data;
+ }
+
+ /**
+ * if authenticating, set user credentials here
+ *
+ * @param string $user
+ * @param string $pass
+ * @access public
+ */
+ function setCredentials($username, $password) {
+ $this->username = $username;
+ $this->password = $password;
+ }
+
+ /**
+ * set the soapaction value
+ *
+ * @param string $soapaction
+ * @access public
+ */
+ function setSOAPAction($soapaction) {
+ $this->soapaction = $soapaction;
+ }
+
+ /**
+ * use http encoding
+ *
+ * @param string $enc encoding style. supported values: gzip, deflate, or both
+ * @access public
+ */
+ function setEncoding($enc='gzip, deflate'){
+ $this->encoding = $enc;
+ $this->protocol_version = '1.1';
+ }
+
+ /**
+ * set proxy info here
+ *
+ * @param string $proxyhost
+ * @param string $proxyport
+ * @access public
+ */
+ function setProxy($proxyhost, $proxyport) {
+ $this->proxyhost = $proxyhost;
+ $this->proxyport = $proxyport;
+ }
+
+ /**
+ * decode a string that is encoded w/ "chunked' transfer encoding
+ * as defined in RFC2068 19.4.6
+ *
+ * @param string $buffer
+ * @returns string
+ * @access public
+ */
+ function decodeChunked($buffer){
+ // length := 0
+ $length = 0;
+ $new = '';
+
+ // read chunk-size, chunk-extension (if any) and CRLF
+ // get the position of the linebreak
+ $chunkend = strpos($buffer,"\r\n") + 2;
+ $temp = substr($buffer,0,$chunkend);
+ $chunk_size = hexdec( trim($temp) );
+ $chunkstart = $chunkend;
+ // while (chunk-size > 0) {
+ while ($chunk_size > 0) {
+
+ $chunkend = strpos( $buffer, "\r\n", $chunkstart + $chunk_size);
+
+ // Just in case we got a broken connection
+ if ($chunkend == FALSE) {
+ $chunk = substr($buffer,$chunkstart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ $length += strlen($chunk);
+ break;
+ }
+
+ // read chunk-data and CRLF
+ $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ // length := length + chunk-size
+ $length += strlen($chunk);
+ // read chunk-size and CRLF
+ $chunkstart = $chunkend + 2;
+
+ $chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
+ if ($chunkend == FALSE) {
+ break; //Just in case we got a broken connection
+ }
+ $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
+ $chunk_size = hexdec( trim($temp) );
+ $chunkstart = $chunkend;
+ }
+ // Update headers
+ //$this->Header['content-length'] = $length;
+ //unset($this->Header['transfer-encoding']);
+ return $new;
+ }
+
+}
+
+
+
+?><?php
+
+
+
+/**
+*
+* soap_server allows the user to create a SOAP server
+* that is capable of receiving messages and returning responses
+*
+* NOTE: WSDL functionality is experimental
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soap_server extends nusoap_base {
+
+ var $service = ''; // service name
+ var $operations = array(); // assoc array of operations => opData
+ var $responseHeaders = false;
+ var $headers = '';
+ var $request = '';
+ var $charset_encoding = 'UTF-8';
+ var $fault = false;
+ var $result = 'successful';
+ var $wsdl = false;
+ var $externalWSDLURL = false;
+ var $debug_flag = true;
+
+ /**
+ * constructor
+ * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
+ *
+ * @param string $wsdl path or URL to a WSDL file
+ * @access public
+ */
+ function soap_server($wsdl=false){
+
+ // turn on debugging?
+ global $debug;
+ if(isset($debug)){
+ $this->debug_flag = 1;
+ }
+
+ // wsdl
+ if($wsdl){
+ $this->wsdl = new wsdl($wsdl);
+ $this->externalWSDLURL = $wsdl;
+ if($err = $this->wsdl->getError()){
+ die('WSDL ERROR: '.$err);
+ }
+ }
+ }
+
+ /**
+ * processes request and returns response
+ *
+ * @param string $data usually is the value of $HTTP_RAW_POST_DATA
+ * @access public
+ */
+ function service($data){
+ // print wsdl
+ global $QUERY_STRING;
+ if(isset($_SERVER['QUERY_STRING'])){
+ $qs = $_SERVER['QUERY_STRING'];
+ } elseif(isset($GLOBALS['QUERY_STRING'])){
+ $qs = $GLOBALS['QUERY_STRING'];
+ } elseif(isset($QUERY_STRING) && $QUERY_STRING != ''){
+ $qs = $QUERY_STRING;
+ }
+ // gen wsdl
+ if(isset($qs) && ereg('wsdl', $qs) ){
+ if($this->externalWSDLURL){
+ header('Location: '.$this->externalWSDLURL);
+ exit();
+ } else {
+ header("Content-Type: text/xml\r\n");
+ print $this->wsdl->serialize();
+ exit();
+ }
+ }
+
+ // print web interface
+ if($data == '' && $this->wsdl){
+ print $this->webDescription();
+ } else {
+
+ // $response is the serialized response message
+ $response = $this->parse_request($data);
+ $this->debug('server sending...');
+ $payload = $response;
+ // add debug data if in debug mode
+ if(isset($this->debug_flag) && $this->debug_flag == 1){
+ $payload .= "<!--\n".str_replace('--','- -',$this->debug_str)."\n-->";
+ }
+ // print headers
+ if($this->fault){
+ $header[] = "HTTP/1.0 500 Internal Server Error\r\n";
+ $header[] = "Status: 500 Internal Server Error\r\n";
+ } else {
+ $header[] = "Status: 200 OK\r\n";
+ }
+ $header[] = "Server: $this->title Server v$this->version\r\n";
+ $header[] = "Connection: Close\r\n";
+ $header[] = "Content-Type: text/xml; charset=$this->charset_encoding\r\n";
+ $header[] = "Content-Length: ".strlen($payload)."\r\n\r\n";
+ reset($header);
+ foreach($header as $hdr){
+ header($hdr);
+ }
+ $this->response = join("\r\n",$header).$payload;
+ print $payload;
+ }
+ }
+
+ /**
+ * parses request and posts response
+ *
+ * @param string $data XML string
+ * @return string XML response msg
+ * @access private
+ */
+ function parse_request($data='') {
+ $this->debug('entering parseRequest() on '.date('H:i Y-m-d'));
+ $dump = '';
+ // get headers
+ if(function_exists('getallheaders')){
+ $this->headers = getallheaders();
+ foreach($this->headers as $k=>$v){
+ $dump .= "$k: $v\r\n";
+ $this->debug("$k: $v");
+ }
+ // get SOAPAction header
+ if(isset($this->headers['SOAPAction'])){
+ $this->SOAPAction = str_replace('"','',$this->headers['SOAPAction']);
+ }
+ // get the character encoding of the incoming request
+ if(strpos($this->headers['Content-Type'],'=')){
+ $enc = str_replace('"','',substr(strstr($this->headers["Content-Type"],'='),1));
+ if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
+ $this->xml_encoding = $enc;
+ } else {
+ $this->xml_encoding = 'us-ascii';
+ }
+ }
+ $this->debug('got encoding: '.$this->charset_encoding);
+ } elseif(is_array($_SERVER)){
+ $this->headers['User-Agent'] = $_SERVER['HTTP_USER_AGENT'];
+ $this->SOAPAction = isset($_SERVER['SOAPAction']) ? $_SERVER['SOAPAction'] : '';
+ }
+ $this->request = $dump."\r\n\r\n".$data;
+ // parse response, get soap parser obj
+ $parser = new soap_parser($data,$this->charset_encoding);
+ // if fault occurred during message parsing
+ if($err = $parser->getError()){
+ // parser debug
+ $this->debug("parser debug: \n".$parser->debug_str);
+ $this->result = 'fault: error in msg parsing: '.$err;
+ $this->fault('Server',"error in msg parsing:\n".$err);
+ // return soapresp
+ return $this->fault->serialize();
+ // else successfully parsed request into soapval object
+ } else {
+ // get/set methodname
+ $this->methodname = $parser->root_struct_name;
+ $this->debug('method name: '.$this->methodname);
+ // does method exist?
+ if(!function_exists($this->methodname)){
+ // "method not found" fault here
+ $this->debug("method '$this->methodname' not found!");
+ $this->debug("parser debug: \n".$parser->debug_str);
+ $this->result = 'fault: method not found';
+ $this->fault('Server',"method '$this->methodname' not defined in service '$this->service'");
+ return $this->fault->serialize();
+ }
+ if($this->wsdl){
+ if(!$this->opData = $this->wsdl->getOperationData($this->methodname)){
+ //if(
+ $this->fault('Server',"Operation '$this->methodname' is not defined in the WSDL for this service");
+ return $this->fault->serialize();
+ }
+ }
+ $this->debug("method '$this->methodname' exists");
+ // evaluate message, getting back parameters
+ $this->debug('calling parser->get_response()');
+ $request_data = $parser->get_response();
+ // parser debug
+ $this->debug("parser debug: \n".$parser->debug_str);
+ // verify that request parameters match the method's signature
+ if($this->verify_method($this->methodname,$request_data)){
+ // if there are parameters to pass
+ $this->debug('params var dump '.$this->varDump($request_data));
+ if($request_data){
+ $this->debug("calling '$this->methodname' with params");
+ if (! function_exists('call_user_func_array')) {
+ $this->debug('calling method using eval()');
+ $funcCall = $this->methodname.'(';
+ foreach($request_data as $param) {
+ $funcCall .= "\"$param\",";
+ }
+ $funcCall = substr($funcCall, 0, -1).')';
+ $this->debug('function call:<br>'.$funcCall);
+ @eval("\$method_response = $funcCall;");
+ } else {
+ $this->debug('calling method using call_user_func_array()');
+ $method_response = call_user_func_array("$this->methodname",$request_data);
+ }
+ $this->debug('response var dump'.$this->varDump($method_response));
+ } else {
+ // call method w/ no parameters
+ $this->debug("calling $this->methodname w/ no params");
+ $m = $this->methodname;
+ $method_response = @$m();
+ }
+ $this->debug("done calling method: $this->methodname, received $method_response of type".gettype($method_response));
+ // if we got nothing back. this might be ok (echoVoid)
+ if(isset($method_response) && $method_response != '' || is_bool($method_response)) {
+ // if fault
+ if(get_class($method_response) == 'soap_fault'){
+ $this->debug('got a fault object from method');
+ $this->fault = $method_response;
+ return $method_response->serialize();
+ // if return val is soapval object
+ } elseif(get_class($method_response) == 'soapval'){
+ $this->debug('got a soapval object from method');
+ $return_val = $method_response->serialize();
+ // returned other
+ } else {
+ $this->debug('got a(n) '.gettype($method_response).' from method');
+ $this->debug('serializing return value');
+ if($this->wsdl){
+ // weak attempt at supporting multiple output params
+ if(sizeof($this->opData['output']['parts']) > 1){
+ $opParams = $method_response;
+ } else {
+ $opParams = array($method_response);
+ }
+ $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
+ } else {
+ $return_val = $this->serialize_val($method_response);
+ }
+ }
+ $this->debug('return val:'.$this->varDump($return_val));
+ } else {
+ $return_val = '';
+ $this->debug('got no response from method');
+ }
+ $this->debug('serializing response');
+ $payload = '<'.$this->methodname."Response>".$return_val.'</'.$this->methodname."Response>";
+ $this->result = 'successful';
+ if($this->wsdl){
+ //if($this->debug_flag){
+ $this->debug("WSDL debug data:\n".$this->wsdl->debug_str);
+ // }
+ // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
+ return $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style']);
+ } else {
+ return $this->serializeEnvelope($payload,$this->responseHeaders);
+ }
+ } else {
+ // debug
+ $this->debug('ERROR: request not verified against method signature');
+ $this->result = 'fault: request failed validation against method signature';
+ // return fault
+ $this->fault('Server',"Operation '$this->methodname' not defined in service.");
+ return $this->fault->serialize();
+ }
+ }
+ }
+
+ /**
+ * takes the value that was created by parsing the request
+ * and compares to the method's signature, if available.
+ *
+ * @param mixed
+ * @return boolean
+ * @access private
+ */
+ function verify_method($operation,$request){
+ if(isset($this->wsdl) && is_object($this->wsdl)){
+ if($this->wsdl->getOperationData($operation)){
+ return true;
+ }
+ } elseif(isset($this->operations[$operation])){
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * add a method to the dispatch map
+ *
+ * @param string $methodname
+ * @param string $in array of input values
+ * @param string $out array of output values
+ * @access public
+ */
+ function add_to_map($methodname,$in,$out){
+ $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
+ }
+
+ /**
+ * register a service with the server
+ *
+ * @param string $methodname
+ * @param string $in assoc array of input values: key = param name, value = param type
+ * @param string $out assoc array of output values: key = param name, value = param type
+ * @param string $namespace
+ * @param string $soapaction
+ * @param string $style (rpc|literal)
+ * @access public
+ */
+ function register($name,$in=false,$out=false,$namespace=false,$soapaction=false,$style=false,$use=false){
+ if($this->externalWSDLURL){
+ die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
+ }
+ if(false == $in) {
+ }
+ if(false == $out) {
+ }
+ if(false == $namespace) {
+ }
+ if(false == $soapaction) {
+ global $SERVER_NAME, $SCRIPT_NAME;
+ $soapaction = "http://$SERVER_NAME$SCRIPT_NAME";
+ }
+ if(false == $style) {
+ $style = "rpc";
+ }
+ if(false == $use) {
+ $use = "encoded";
+ }
+
+ $this->operations[$name] = array(
+ 'name' => $name,
+ 'in' => $in,
+ 'out' => $out,
+ 'namespace' => $namespace,
+ 'soapaction' => $soapaction,
+ 'style' => $style);
+ if($this->wsdl){
+ $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use);
+ }
+ return true;
+ }
+
+ /**
+ * create a fault. this also acts as a flag to the server that a fault has occured.
+ *
+ * @param string faultcode
+ * @param string faultactor
+ * @param string faultstring
+ * @param string faultdetail
+ * @access public
+ */
+ function fault($faultcode,$faultactor,$faultstring='',$faultdetail=''){
+ $this->fault = new soap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
+ }
+
+ /**
+ * prints html description of services
+ *
+ * @access private
+ */
+ function webDescription(){
+ $b = '
+ <html><head><title>NuSOAP: '.$this->wsdl->serviceName.'</title>
+ <style type="text/css">
+ body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
+ p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
+ pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
+ ul { margin-top: 10px; margin-left: 20px; }
+ li { list-style-type: none; margin-top: 10px; color: #000000; }
+ .content{
+ margin-left: 0px; padding-bottom: 2em; }
+ .nav {
+ padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
+ margin-top: 10px; margin-left: 0px; color: #000000;
+ background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
+ .title {
+ font-family: arial; font-size: 26px; color: #ffffff;
+ background-color: #999999; width: 105%; margin-left: 0px;
+ padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
+ .hidden {
+ position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
+ font-family: arial; overflow: hidden; width: 600;
+ padding: 20px; font-size: 10px; background-color: #999999;
+ layer-background-color:#FFFFFF; }
+ a,a:active { color: charcoal; font-weight: bold; }
+ a:visited { color: #666666; font-weight: bold; }
+ a:hover { color: cc3300; font-weight: bold; }
+ </style>
+ <script language="JavaScript" type="text/javascript">
+ <!--
+ // POP-UP CAPTIONS...
+ function lib_bwcheck(){ //Browsercheck (needed)
+ this.ver=navigator.appVersion
+ this.agent=navigator.userAgent
+ this.dom=document.getElementById?1:0
+ this.opera5=this.agent.indexOf("Opera 5")>-1
+ this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
+ this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
+ this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
+ this.ie=this.ie4||this.ie5||this.ie6
+ this.mac=this.agent.indexOf("Mac")>-1
+ this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
+ this.ns4=(document.layers && !this.dom)?1:0;
+ this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
+ return this
+ }
+ var bw = new lib_bwcheck()
+ //Makes crossbrowser object.
+ function makeObj(obj){
+ this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
+ if(!this.evnt) return false
+ this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
+ this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
+ this.writeIt=b_writeIt;
+ return this
+ }
+ // A unit of measure that will be added when setting the position of a layer.
+ //var px = bw.ns4||window.opera?"":"px";
+ function b_writeIt(text){
+ if (bw.ns4){this.wref.write(text);this.wref.close()}
+ else this.wref.innerHTML = text
+ }
+ //Shows the messages
+ var oDesc;
+ function popup(divid){
+ if(oDesc = new makeObj(divid)){
+ oDesc.css.visibility = "visible"
+ }
+ }
+ function popout(){ // Hides message
+ if(oDesc) oDesc.css.visibility = "hidden"
+ }
+ //-->
+ </script>
+ </head>
+ <body>
+ <div class=content>
+ <br><br>
+ <div class=title>'.$this->wsdl->serviceName.'</div>
+ <div class=nav>
+ <p>View the <a href="'.$GLOBALS['PHP_SELF'].'?wsdl">WSDL</a> for the service.
+ Click on an operation name to view it&apos;s details.</p>
+ <ul>';
+ foreach($this->wsdl->getOperations() as $op => $data){
+ $b .= "<li><a href='#' onclick=\"popup('$op')\">$op</a></li>";
+ // create hidden div
+ $b .= "<div id='$op' class='hidden'>
+ <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
+ foreach($data as $donnie => $marie){ // loop through opdata
+ if($donnie == 'input' || $donnie == 'output'){ // show input/output data
+ $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
+ foreach($marie as $captain => $tenille){ // loop through data
+ if($captain == 'parts'){ // loop thru parts
+ $b .= "&nbsp;&nbsp;$captain:<br>";
+ //if(is_array($tenille)){
+ foreach($tenille as $joanie => $chachi){
+ $b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
+ }
+ //}
+ } else {
+ $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
+ }
+ }
+ } else {
+ $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
+ }
+ }
+ $b .= '</div>';
+ }
+ $b .= '
+ <ul>
+ </div>
+ </div></body></html>';
+ return $b;
+ }
+
+ /**
+ * sets up wsdl object
+ * this acts as a flag to enable internal WSDL generation
+ * NOTE: NOT FUNCTIONAL
+ *
+ * @param string $serviceName, name of the service
+ * @param string $namespace, tns namespace
+ */
+ function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http')
+ {
+ $SERVER_NAME = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $GLOBALS['SERVER_NAME'];
+ $SCRIPT_NAME = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $GLOBALS['SCRIPT_NAME'];
+ if(false == $namespace) {
+ $namespace = "http://$SERVER_NAME/soap/$serviceName";
+ }
+
+ if(false == $endpoint) {
+ $endpoint = "http://$SERVER_NAME$SCRIPT_NAME";
+ }
+
+ $this->wsdl = new wsdl;
+ $this->wsdl->serviceName = $serviceName;
+ $this->wsdl->endpoint = $endpoint;
+ $this->wsdl->namespaces['tns'] = $namespace;
+ $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
+ $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
+ $this->wsdl->bindings[$serviceName.'Binding'] = array(
+ 'name'=>$serviceName.'Binding',
+ 'style'=>$style,
+ 'transport'=>$transport,
+ 'portType'=>$serviceName.'PortType');
+ $this->wsdl->ports[$serviceName.'Port'] = array(
+ 'binding'=>$serviceName.'Binding',
+ 'location'=>$endpoint,
+ 'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+* parses a WSDL file, allows access to it's data, other utility methods
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class wsdl extends XMLSchema {
+ var $wsdl;
+ // define internal arrays of bindings, ports, operations, messages, etc.
+ var $message = array();
+ var $complexTypes = array();
+ var $messages = array();
+ var $currentMessage;
+ var $currentOperation;
+ var $portTypes = array();
+ var $currentPortType;
+ var $bindings = array();
+ var $currentBinding;
+ var $ports = array();
+ var $currentPort;
+ var $opData = array();
+ var $status = '';
+ var $documentation = false;
+ var $endpoint = '';
+ // array of wsdl docs to import
+ var $import = array();
+ // parser vars
+ var $parser;
+ var $position = 0;
+ var $depth = 0;
+ var $depth_array = array();
+ var $usedNamespaces = array();
+ // for getting wsdl
+ var $proxyhost = '';
+ var $proxyport = '';
+
+ /**
+ * constructor
+ *
+ * @param string $wsdl WSDL document URL
+ * @access public
+ */
+ function wsdl($wsdl = '',$proxyhost=false,$proxyport=false){
+ $this->wsdl = $wsdl;
+ $this->proxyhost = $proxyhost;
+ $this->proxyport = $proxyport;
+
+ // parse wsdl file
+ if ($wsdl != "") {
+ $this->debug('initial wsdl file: ' . $wsdl);
+ $this->parseWSDL($wsdl);
+ }
+ // imports
+ if (sizeof($this->import) > 0) {
+ foreach($this->import as $ns => $url) {
+ $this->debug('importing wsdl from ' . $url);
+ $this->parseWSDL($url);
+ }
+ }
+ }
+
+ /**
+ * parses the wsdl document
+ *
+ * @param string $wsdl path or URL
+ * @access private
+ */
+ function parseWSDL($wsdl = '')
+ {
+ if ($wsdl == '') {
+ $this->debug('no wsdl passed to parseWSDL()!!');
+ $this->setError('no wsdl passed to parseWSDL()!!');
+ return false;
+ }
+
+ $this->debug('getting ' . $wsdl);
+
+ // parse $wsdl for url format
+ $wsdl_props = parse_url($wsdl);
+
+ if (isset($wsdl_props['host'])) {
+
+ // get wsdl
+ $tr = new soap_transport_http($wsdl);
+ $tr->request_method = 'GET';
+ $tr->useSOAPAction = false;
+ if($this->proxyhost && $this->proxyport){
+ $tr->setProxy($this->proxyhost,$this->proxyport);
+ }
+ if (isset($wsdl_props['user'])) {
+ $tr->setCredentials($wsdl_props['user'],$wsdl_props['pass']);
+ }
+ $wsdl_string = $tr->send('');
+ // catch errors
+ if($err = $tr->getError() ){
+ $this->debug('HTTP ERROR: '.$err);
+ $this->setError('HTTP ERROR: '.$err);
+ return false;
+ }
+ unset($tr);
+ /* $wsdl seems to be a valid url, not a file path, do an fsockopen/HTTP GET
+ $fsockopen_timeout = 30;
+ // check if a port value is supplied in url
+ if (isset($wsdl_props['port'])) {
+ // yes
+ $wsdl_url_port = $wsdl_props['port'];
+ } else {
+ // no, assign port number, based on url protocol (scheme)
+ switch ($wsdl_props['scheme']) {
+ case ('https') :
+ case ('ssl') :
+ case ('tls') :
+ $wsdl_url_port = 443;
+ break;
+ case ('http') :
+ default :
+ $wsdl_url_port = 80;
+ }
+ }
+ // FIXME: should implement SSL/TLS support here if CURL is available
+ if ($fp = fsockopen($wsdl_props['host'], $wsdl_url_port, $fsockopen_errnum, $fsockopen_errstr, $fsockopen_timeout)) {
+ // perform HTTP GET for WSDL file
+ // 10.9.02 - added poulter fix for doing this properly
+ $sHeader = "GET " . $wsdl_props['path'];
+ if (isset($wsdl_props['query'])) {
+ $sHeader .= "?" . $wsdl_props['query'];
+ }
+ $sHeader .= " HTTP/1.0\r\n";
+
+ if (isset($wsdl_props['user'])) {
+ $base64auth = base64_encode($wsdl_props['user'] . ":" . $wsdl_props['pass']);
+ $sHeader .= "Authorization: Basic $base64auth\r\n";
+ }
+ $sHeader .= "Host: " . $wsdl_props['host'] . ( isset($wsdl_props['port']) ? ":".$wsdl_props['port'] : "" ) . "\r\n\r\n";
+ fputs($fp, $sHeader);
+
+ while (fgets($fp, 1024) != "\r\n") {
+ // do nothing, just read/skip past HTTP headers
+ // FIXME: should actually detect HTTP response code, and act accordingly if error
+ // HTTP headers end with extra CRLF before content body
+ }
+ // read in WSDL just like regular fopen()
+ $wsdl_string = '';
+ while ($data = fread($fp, 32768)) {
+ $wsdl_string .= $data;
+ }
+ fclose($fp);
+ } else {
+ $this->setError('bad path to WSDL file.');
+ return false;
+ }
+ */
+ } else {
+ // $wsdl seems to be a non-url file path, do the regular fopen
+ if ($fp = @fopen($wsdl, 'r')) {
+ $wsdl_string = '';
+ while ($data = fread($fp, 32768)) {
+ $wsdl_string .= $data;
+ }
+ fclose($fp);
+ } else {
+ $this->setError('bad path to WSDL file.');
+ return false;
+ }
+ }
+ // end new code added
+ // Create an XML parser.
+ $this->parser = xml_parser_create();
+ // Set the options for parsing the XML data.
+ // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
+ // Set the object for the parser.
+ xml_set_object($this->parser, $this);
+ // Set the element handlers for the parser.
+ xml_set_element_handler($this->parser, 'start_element', 'end_element');
+ xml_set_character_data_handler($this->parser, 'character_data');
+ // Parse the XML file.
+ if (!xml_parse($this->parser, $wsdl_string, true)) {
+ // Display an error message.
+ $errstr = sprintf(
+ 'XML error on line %d: %s',
+ xml_get_current_line_number($this->parser),
+ xml_error_string(xml_get_error_code($this->parser))
+ );
+ $this->debug('XML parse error: ' . $errstr);
+ $this->setError('Parser error: ' . $errstr);
+ return false;
+ }
+ // free the parser
+ xml_parser_free($this->parser);
+ // catch wsdl parse errors
+ if($this->getError()){
+ return false;
+ }
+ // add new data to operation data
+ foreach($this->bindings as $binding => $bindingData) {
+ if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
+ foreach($bindingData['operations'] as $operation => $data) {
+ $this->debug('post-parse data gathering for ' . $operation);
+ $this->bindings[$binding]['operations'][$operation]['input'] =
+ isset($this->bindings[$binding]['operations'][$operation]['input']) ?
+ array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
+ $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
+ $this->bindings[$binding]['operations'][$operation]['output'] =
+ isset($this->bindings[$binding]['operations'][$operation]['output']) ?
+ array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
+ $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
+ if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
+ $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
+ }
+ if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
+ $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
+ }
+ if (isset($bindingData['style'])) {
+ $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
+ }
+ $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
+ $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
+ $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * start-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @param string $attrs associative array of attributes
+ * @access private
+ */
+ function start_element($parser, $name, $attrs)
+ {
+ if ($this->status == 'schema' || ereg('schema$', $name)) {
+ // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
+ $this->status = 'schema';
+ $this->schemaStartElement($parser, $name, $attrs);
+ } else {
+ // position in the total number of elements, starting from 0
+ $pos = $this->position++;
+ $depth = $this->depth++;
+ // set self as current value for this depth
+ $this->depth_array[$depth] = $pos;
+ $this->message[$pos] = array('cdata' => '');
+ // get element prefix
+ if (ereg(':', $name)) {
+ // get ns prefix
+ $prefix = substr($name, 0, strpos($name, ':'));
+ // get ns
+ $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
+ // get unqualified name
+ $name = substr(strstr($name, ':'), 1);
+ }
+
+ if (count($attrs) > 0) {
+ foreach($attrs as $k => $v) {
+ // if ns declarations, add to class level array of valid namespaces
+ if (ereg("^xmlns", $k)) {
+ if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
+ $this->namespaces[$ns_prefix] = $v;
+ } else {
+ $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
+ }
+ if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema') {
+ $this->XMLSchemaVersion = $v;
+ $this->namespaces['xsi'] = $v . '-instance';
+ }
+ } //
+ // expand each attribute
+ $k = strpos($k, ':') ? $this->expandQname($k) : $k;
+ if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
+ $v = strpos($v, ':') ? $this->expandQname($v) : $v;
+ }
+ $eAttrs[$k] = $v;
+ }
+ $attrs = $eAttrs;
+ } else {
+ $attrs = array();
+ }
+ // find status, register data
+ switch ($this->status) {
+ case 'message':
+ if ($name == 'part') {
+ if (isset($attrs['type'])) {
+ $this->debug("msg " . $this->currentMessage . ": found part $attrs[name]: " . implode(',', $attrs));
+ $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
+ }
+ if (isset($attrs['element'])) {
+ $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'];
+ }
+ }
+ break;
+ case 'portType':
+ switch ($name) {
+ case 'operation':
+ $this->currentPortOperation = $attrs['name'];
+ $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
+ if (isset($attrs['parameterOrder'])) {
+ $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
+ }
+ break;
+ case 'documentation':
+ $this->documentation = true;
+ break;
+ // merge input/output data
+ default:
+ $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
+ $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
+ break;
+ }
+ break;
+ case 'binding':
+ switch ($name) {
+ case 'binding':
+ // get ns prefix
+ if (isset($attrs['style'])) {
+ $this->bindings[$this->currentBinding]['prefix'] = $prefix;
+ }
+ $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
+ break;
+ case 'header':
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
+ break;
+ case 'operation':
+ if (isset($attrs['soapAction'])) {
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
+ }
+ if (isset($attrs['style'])) {
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
+ }
+ if (isset($attrs['name'])) {
+ $this->currentOperation = $attrs['name'];
+ $this->debug("current binding operation: $this->currentOperation");
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
+ }
+ break;
+ case 'input':
+ $this->opStatus = 'input';
+ break;
+ case 'output':
+ $this->opStatus = 'output';
+ break;
+ case 'body':
+ if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
+ } else {
+ $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
+ }
+ break;
+ }
+ break;
+ case 'service':
+ switch ($name) {
+ case 'port':
+ $this->currentPort = $attrs['name'];
+ $this->debug('current port: ' . $this->currentPort);
+ $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
+
+ break;
+ case 'address':
+ $this->ports[$this->currentPort]['location'] = $attrs['location'];
+ $this->ports[$this->currentPort]['bindingType'] = $namespace;
+ $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
+ $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
+ break;
+ }
+ break;
+ }
+ // set status
+ switch ($name) {
+ case "import":
+ if (isset($attrs['location'])) {
+ $this->import[$attrs['namespace']] = $attrs['location'];
+ }
+ break;
+ case 'types':
+ $this->status = 'schema';
+ break;
+ case 'message':
+ $this->status = 'message';
+ $this->messages[$attrs['name']] = array();
+ $this->currentMessage = $attrs['name'];
+ break;
+ case 'portType':
+ $this->status = 'portType';
+ $this->portTypes[$attrs['name']] = array();
+ $this->currentPortType = $attrs['name'];
+ break;
+ case "binding":
+ if (isset($attrs['name'])) {
+ // get binding name
+ if (strpos($attrs['name'], ':')) {
+ $this->currentBinding = $this->getLocalPart($attrs['name']);
+ } else {
+ $this->currentBinding = $attrs['name'];
+ }
+ $this->status = 'binding';
+ $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
+ $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
+ }
+ break;
+ case 'service':
+ $this->serviceName = $attrs['name'];
+ $this->status = 'service';
+ $this->debug('current service: ' . $this->serviceName);
+ break;
+ case 'definitions':
+ foreach ($attrs as $name => $value) {
+ $this->wsdl_info[$name] = $value;
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * end-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @access private
+ */
+ function end_element($parser, $name){
+ // unset schema status
+ if (ereg('types$', $name) || ereg('schema$', $name)) {
+ $this->status = "";
+ }
+ if ($this->status == 'schema') {
+ $this->schemaEndElement($parser, $name);
+ } else {
+ // bring depth down a notch
+ $this->depth--;
+ }
+ // end documentation
+ if ($this->documentation) {
+ $this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
+ $this->documentation = false;
+ }
+ }
+
+ /**
+ * element content handler
+ *
+ * @param string $parser XML parser object
+ * @param string $data element content
+ * @access private
+ */
+ function character_data($parser, $data)
+ {
+ $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
+ if (isset($this->message[$pos]['cdata'])) {
+ $this->message[$pos]['cdata'] .= $data;
+ }
+ if ($this->documentation) {
+ $this->documentation .= $data;
+ }
+ }
+
+ function getBindingData($binding)
+ {
+ if (is_array($this->bindings[$binding])) {
+ return $this->bindings[$binding];
+ }
+ }
+
+ /**
+ * returns an assoc array of operation names => operation data
+ * NOTE: currently only supports multiple services of differing binding types
+ * This method needs some work
+ *
+ * @param string $bindingType eg: soap, smtp, dime (only soap is currently supported)
+ * @return array
+ * @access public
+ */
+ function getOperations($bindingType = 'soap')
+ {
+ if ($bindingType == 'soap') {
+ $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
+ }
+ // loop thru ports
+ foreach($this->ports as $port => $portData) {
+ // binding type of port matches parameter
+ if ($portData['bindingType'] == $bindingType) {
+ // get binding
+ return $this->bindings[ $portData['binding'] ]['operations'];
+ }
+ }
+ return array();
+ }
+
+ /**
+ * returns an associative array of data necessary for calling an operation
+ *
+ * @param string $operation , name of operation
+ * @param string $bindingType , type of binding eg: soap
+ * @return array
+ * @access public
+ */
+ function getOperationData($operation, $bindingType = 'soap')
+ {
+ if ($bindingType == 'soap') {
+ $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
+ }
+ // loop thru ports
+ foreach($this->ports as $port => $portData) {
+ // binding type of port matches parameter
+ if ($portData['bindingType'] == $bindingType) {
+ // get binding
+ //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
+ foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
+ if ($operation == $bOperation) {
+ $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
+ return $opData;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * serialize the parsed wsdl
+ *
+ * @return string , serialization of WSDL
+ * @access public
+ */
+ function serialize()
+ {
+ $xml = '<?xml version="1.0"?><definitions';
+ foreach($this->namespaces as $k => $v) {
+ $xml .= " xmlns:$k=\"$v\"";
+ }
+ // 10.9.02 - add poulter fix for wsdl and tns declarations
+ if (isset($this->namespaces['wsdl'])) {
+ $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
+ }
+ if (isset($this->namespaces['tns'])) {
+ $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
+ }
+ $xml .= '>';
+ // imports
+ if (sizeof($this->import) > 0) {
+ foreach($this->import as $ns => $url) {
+ $xml .= '<import location="' . $url . '" namespace="' . $ns . '" />';
+ }
+ }
+ // types
+ if (count($this->complexTypes)>=1) {
+ $xml .= '<types>';
+ $xml .= $this->serializeSchema();
+ $xml .= '</types>';
+ }
+ // messages
+ if (count($this->messages) >= 1) {
+ foreach($this->messages as $msgName => $msgParts) {
+ $xml .= '<message name="' . $msgName . '">';
+ foreach($msgParts as $partName => $partType) {
+ // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
+ if (strpos($partType, ':')) {
+ $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
+ } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
+ // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
+ $typePrefix = 'xsd';
+ } else {
+ foreach($this->typemap as $ns => $types) {
+ if (isset($types[$partType])) {
+ $typePrefix = $this->getPrefixFromNamespace($ns);
+ }
+ }
+ if (!isset($typePrefix)) {
+ die("$partType has no namespace!");
+ }
+ }
+ $xml .= '<part name="' . $partName . '" type="' . $typePrefix . ':' . $this->getLocalPart($partType) . '" />';
+ }
+ $xml .= '</message>';
+ }
+ }
+ // bindings & porttypes
+ if (count($this->bindings) >= 1) {
+ $binding_xml = '';
+ $portType_xml = '';
+ foreach($this->bindings as $bindingName => $attrs) {
+ $binding_xml .= '<binding name="' . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
+ $binding_xml .= '<soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
+ $portType_xml .= '<portType name="' . $attrs['portType'] . '">';
+ foreach($attrs['operations'] as $opName => $opParts) {
+ $binding_xml .= '<operation name="' . $opName . '">';
+ $binding_xml .= '<soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $attrs['style'] . '"/>';
+ $binding_xml .= '<input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '" encodingStyle="' . $opParts['input']['encodingStyle'] . '"/></input>';
+ $binding_xml .= '<output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '" encodingStyle="' . $opParts['output']['encodingStyle'] . '"/></output>';
+ $binding_xml .= '</operation>';
+ $portType_xml .= '<operation name="' . $opParts['name'] . '"';
+ if (isset($opParts['parameterOrder'])) {
+ $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
+ }
+ $portType_xml .= '>';
+ $portType_xml .= '<input message="tns:' . $opParts['input']['message'] . '"/>';
+ $portType_xml .= '<output message="tns:' . $opParts['output']['message'] . '"/>';
+ $portType_xml .= '</operation>';
+ }
+ $portType_xml .= '</portType>';
+ $binding_xml .= '</binding>';
+ }
+ $xml .= $portType_xml . $binding_xml;
+ }
+ // services
+ $xml .= '<service name="' . $this->serviceName . '">';
+ if (count($this->ports) >= 1) {
+ foreach($this->ports as $pName => $attrs) {
+ $xml .= '<port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
+ $xml .= '<soap:address location="' . $attrs['location'] . '"/>';
+ $xml .= '</port>';
+ }
+ }
+ $xml .= '</service>';
+ return $xml . '</definitions>';
+ }
+
+ /**
+ * serialize a PHP value according to a WSDL message definition
+ *
+ * TODO
+ * - multi-ref serialization
+ * - validate PHP values against type definitions, return errors if invalid
+ *
+ * @param string $ type name
+ * @param mixed $ param value
+ * @return mixed new param or false if initial value didn't validate
+ */
+ function serializeRPCParameters($operation, $direction, $parameters)
+ {
+ $this->debug('in serializeRPCParameters with operation '.$operation.', direction '.$direction.' and '.count($parameters).' param(s), and xml schema version ' . $this->XMLSchemaVersion);
+
+ if ($direction != 'input' && $direction != 'output') {
+ $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
+ $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
+ return false;
+ }
+ if (!$opData = $this->getOperationData($operation)) {
+ $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
+ $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
+ return false;
+ }
+ $this->debug($this->varDump($opData));
+ // set input params
+ $xml = '';
+ if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
+
+ $use = $opData[$direction]['use'];
+ $this->debug("use=$use");
+ $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
+ foreach($opData[$direction]['parts'] as $name => $type) {
+ $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
+ // NOTE: add error handling here
+ // if serializeType returns false, then catch global error and fault
+ if (isset($parameters[$name])) {
+ $this->debug('calling serializeType w/ named param');
+ $xml .= $this->serializeType($name, $type, $parameters[$name], $use);
+ } elseif(is_array($parameters)) {
+ $this->debug('calling serializeType w/ unnamed param');
+ $xml .= $this->serializeType($name, $type, array_shift($parameters), $use);
+ } else {
+ $this->debug('no parameters passed.');
+ }
+ }
+ }
+ return $xml;
+ }
+
+ /**
+ * serializes a PHP value according a given type definition
+ *
+ * @param string $name , name of type (part)
+ * @param string $type , type of type, heh (type or element)
+ * @param mixed $value , a native PHP value (parameter value)
+ * @param string $use , use for part (encoded|literal)
+ * @return string serialization
+ * @access public
+ */
+ function serializeType($name, $type, $value, $use='encoded')
+ {
+ $this->debug("in serializeType: $name, $type, $value, $use");
+ $xml = '';
+ if (strpos($type, ':')) {
+ $uqType = substr($type, strrpos($type, ':') + 1);
+ $ns = substr($type, 0, strrpos($type, ':'));
+ $this->debug("got a prefixed type: $uqType, $ns");
+
+ if($ns == $this->XMLSchemaVersion ||
+ ($this->getNamespaceFromPrefix($ns)) == $this->XMLSchemaVersion){
+
+ if ($uqType == 'boolean' && !$value) {
+ $value = 0;
+ } elseif ($uqType == 'boolean') {
+ $value = 1;
+ }
+ if ($this->charencoding && $uqType == 'string' && gettype($value) == 'string') {
+ $value = htmlspecialchars($value);
+ }
+ // it's a scalar
+ if ($use == 'literal') {
+ return "<$name>$value</$name>";
+ } else {
+ return "<$name xsi:type=\"" . $this->getPrefixFromNamespace($this->XMLSchemaVersion) . ":$uqType\">$value</$name>";
+ }
+ }
+ } else {
+ $uqType = $type;
+ }
+ if(!$typeDef = $this->getTypeDef($uqType)){
+ $this->setError("$uqType is not a supported type.");
+ return false;
+ } else {
+ //foreach($typeDef as $k => $v) {
+ //$this->debug("typedef, $k: $v");
+ //}
+ }
+ $phpType = $typeDef['phpType'];
+ $this->debug("serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
+ // if php type == struct, map value to the <all> element names
+ if ($phpType == 'struct') {
+ if (isset($typeDef['element']) && $typeDef['element']) {
+ $elementName = $uqType;
+ // TODO: use elementFormDefault="qualified|unqualified" to determine
+ // how to scope the namespace
+ $elementNS = " xmlns=\"$ns\"";
+ } else {
+ $elementName = $name;
+ $elementNS = '';
+ }
+ if ($use == 'literal') {
+ $xml = "<$elementName$elementNS>";
+ } else {
+ $xml = "<$elementName$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
+ }
+
+ if (isset($this->complexTypes[$uqType]['elements']) && is_array($this->complexTypes[$uqType]['elements'])) {
+
+ //if (is_array($this->complexTypes[$uqType]['elements'])) {
+ // toggle whether all elements are present - ideally should validate against schema
+ if(count($this->complexTypes[$uqType]['elements']) != count($value)){
+ $optionals = true;
+ }
+ foreach($this->complexTypes[$uqType]['elements'] as $eName => $attrs) {
+ // if user took advantage of a minOccurs=0, then only serialize named parameters
+ if(isset($optionals) && !isset($value[$eName])){
+ // do nothing
+ } else {
+ // get value
+ if (isset($value[$eName])) {
+ $v = $value[$eName];
+ } elseif (is_array($value)) {
+ $v = array_shift($value);
+ }
+ // serialize schema-defined type
+ if (!isset($attrs['type'])) {
+ $xml .= $this->serializeType($eName, $attrs['name'], $v, $use);
+ // serialize generic type
+ } else {
+ $this->debug("calling serialize_val() for $eName, $v, " . $this->getLocalPart($attrs['type']), false, $use);
+ $xml .= $this->serialize_val($v, $eName, $this->getLocalPart($attrs['type']), null, $this->getNamespaceFromPrefix($this->getPrefix($attrs['type'])), false, $use);
+ }
+ }
+ }
+ }
+ $xml .= "</$elementName>";
+ } elseif ($phpType == 'array') {
+ $rows = sizeof($value);
+ if (isset($typeDef['multidimensional'])) {
+ $nv = array();
+ foreach($value as $v) {
+ $cols = ',' . sizeof($v);
+ $nv = array_merge($nv, $v);
+ }
+ $value = $nv;
+ } else {
+ $cols = '';
+ }
+ if (is_array($value) && sizeof($value) >= 1) {
+ $contents = '';
+ foreach($value as $k => $v) {
+ $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
+ //if (strpos($typeDef['arrayType'], ':') ) {
+ if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
+ $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
+ } else {
+ $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
+ }
+ }
+ $this->debug('contents: '.$this->varDump($contents));
+ } else {
+ $contents = null;
+ }
+ if ($use == 'literal') {
+ $xml = "<$name>"
+ .$contents
+ ."</$name>";
+ } else {
+ $xml = "<$name xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
+ $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
+ .':arrayType="'
+ .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
+ .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
+ .$contents
+ ."</$name>";
+ }
+ }
+ $this->debug('returning: '.$this->varDump($xml));
+ return $xml;
+ }
+
+ /**
+ * register a service with the server
+ *
+ * @param string $methodname
+ * @param string $in assoc array of input values: key = param name, value = param type
+ * @param string $out assoc array of output values: key = param name, value = param type
+ * @param string $namespace
+ * @param string $soapaction
+ * @param string $style (rpc|literal)
+ * @access public
+ */
+ function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '')
+ {
+ if ($style == 'rpc' && $use == 'encoded') {
+ $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
+ } else {
+ $encodingStyle = '';
+ }
+ // get binding
+ $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
+ array(
+ 'name' => $name,
+ 'binding' => $this->serviceName . 'Binding',
+ 'endpoint' => $this->endpoint,
+ 'soapAction' => $soapaction,
+ 'style' => $style,
+ 'input' => array(
+ 'use' => $use,
+ 'namespace' => $namespace,
+ 'encodingStyle' => $encodingStyle,
+ 'message' => $name . 'Request',
+ 'parts' => $in),
+ 'output' => array(
+ 'use' => $use,
+ 'namespace' => $namespace,
+ 'encodingStyle' => $encodingStyle,
+ 'message' => $name . 'Response',
+ 'parts' => $out),
+ 'namespace' => $namespace,
+ 'transport' => 'http://schemas.xmlsoap.org/soap/http',
+ 'documentation' => $documentation);
+ // add portTypes
+ // add messages
+ if($in)
+ {
+ foreach($in as $pName => $pType)
+ {
+ if(strpos($pType,':')) {
+ $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
+ }
+ $this->messages[$name.'Request'][$pName] = $pType;
+ }
+ }
+
+ if($out)
+ {
+ foreach($out as $pName => $pType)
+ {
+ if(strpos($pType,':')) {
+ $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
+ }
+ $this->messages[$name.'Response'][$pName] = $pType;
+ }
+ }
+ return true;
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+*
+* soap_parser class parses SOAP XML messages into native PHP values
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soap_parser extends nusoap_base {
+
+ var $xml = '';
+ var $xml_encoding = '';
+ var $method = '';
+ var $root_struct = '';
+ var $root_struct_name = '';
+ var $root_header = '';
+ var $document = '';
+ // determines where in the message we are (envelope,header,body,method)
+ var $status = '';
+ var $position = 0;
+ var $depth = 0;
+ var $default_namespace = '';
+ var $namespaces = array();
+ var $message = array();
+ var $parent = '';
+ var $fault = false;
+ var $fault_code = '';
+ var $fault_str = '';
+ var $fault_detail = '';
+ var $depth_array = array();
+ var $debug_flag = true;
+ var $soapresponse = NULL;
+ var $responseHeaders = '';
+ var $body_position = 0;
+ // for multiref parsing:
+ // array of id => pos
+ var $ids = array();
+ // array of id => hrefs => pos
+ var $multirefs = array();
+
+ /**
+ * constructor
+ *
+ * @param string $xml SOAP message
+ * @param string $encoding character encoding scheme of message
+ * @access public
+ */
+ function soap_parser($xml,$encoding='UTF-8',$method=''){
+ $this->xml = $xml;
+ $this->xml_encoding = $encoding;
+ $this->method = $method;
+
+ // Check whether content has been read.
+ if(!empty($xml)){
+ $this->debug('Entering soap_parser()');
+ // Create an XML parser.
+ $this->parser = xml_parser_create($this->xml_encoding);
+ // Set the options for parsing the XML data.
+ //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
+ // Set the object for the parser.
+ xml_set_object($this->parser, $this);
+ // Set the element handlers for the parser.
+ xml_set_element_handler($this->parser, 'start_element','end_element');
+ xml_set_character_data_handler($this->parser,'character_data');
+
+ // Parse the XML file.
+ if(!xml_parse($this->parser,$xml,true)){
+ // Display an error message.
+ $err = sprintf('XML error on line %d: %s',
+ xml_get_current_line_number($this->parser),
+ xml_error_string(xml_get_error_code($this->parser)));
+ $this->debug('parse error: '.$err);
+ $this->errstr = $err;
+ } else {
+ $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
+ // get final value
+ $this->soapresponse = $this->message[$this->root_struct]['result'];
+ // get header value
+ if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
+ $this->responseHeaders = $this->message[$this->root_header]['result'];
+ }
+ // resolve hrefs/ids
+ if(sizeof($this->multirefs) > 0){
+ foreach($this->multirefs as $id => $hrefs){
+ $this->debug('resolving multirefs for id: '.$id);
+ $idVal = $this->buildVal($this->ids[$id]);
+ foreach($hrefs as $refPos => $ref){
+ $this->debug('resolving href at pos '.$refPos);
+ $this->multirefs[$id][$refPos] = $idVal;
+ }
+ }
+ }
+ }
+ xml_parser_free($this->parser);
+ } else {
+ $this->debug('xml was empty, didn\'t parse!');
+ $this->errstr = 'xml was empty, didn\'t parse!';
+ }
+ }
+
+ /**
+ * start-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @param string $attrs associative array of attributes
+ * @access private
+ */
+ function start_element($parser, $name, $attrs) {
+ // position in a total number of elements, starting from 0
+ // update class level pos
+ $pos = $this->position++;
+ // and set mine
+ $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
+ // depth = how many levels removed from root?
+ // set mine as current global depth and increment global depth value
+ $this->message[$pos]['depth'] = $this->depth++;
+
+ // else add self as child to whoever the current parent is
+ if($pos != 0){
+ $this->message[$this->parent]['children'] .= '|'.$pos;
+ }
+ // set my parent
+ $this->message[$pos]['parent'] = $this->parent;
+ // set self as current parent
+ $this->parent = $pos;
+ // set self as current value for this depth
+ $this->depth_array[$this->depth] = $pos;
+ // get element prefix
+ if(strpos($name,':')){
+ // get ns prefix
+ $prefix = substr($name,0,strpos($name,':'));
+ // get unqualified name
+ $name = substr(strstr($name,':'),1);
+ }
+ // set status
+ if($name == 'Envelope'){
+ $this->status = 'envelope';
+ } elseif($name == 'Header'){
+ $this->root_header = $pos;
+ $this->status = 'header';
+ } elseif($name == 'Body'){
+ $this->status = 'body';
+ $this->body_position = $pos;
+ // set method
+ } elseif($this->status == 'body' && $pos == ($this->body_position+1)){
+ $this->status = 'method';
+ $this->root_struct_name = $name;
+ $this->root_struct = $pos;
+ $this->message[$pos]['type'] = 'struct';
+ $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
+ }
+ // set my status
+ $this->message[$pos]['status'] = $this->status;
+ // set name
+ $this->message[$pos]['name'] = htmlspecialchars($name);
+ // set attrs
+ $this->message[$pos]['attrs'] = $attrs;
+
+ // loop through atts, logging ns and type declarations
+ $attstr = '';
+ foreach($attrs as $key => $value){
+ $key_prefix = $this->getPrefix($key);
+ $key_localpart = $this->getLocalPart($key);
+ // if ns declarations, add to class level array of valid namespaces
+ if($key_prefix == 'xmlns'){
+ if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){
+ $this->XMLSchemaVersion = $value;
+ $this->namespaces['xsd'] = $this->XMLSchemaVersion;
+ $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
+ }
+ $this->namespaces[$key_localpart] = $value;
+ // set method namespace
+ if($name == $this->root_struct_name){
+ $this->methodNamespace = $value;
+ }
+ // if it's a type declaration, set type
+ } elseif($key_localpart == 'type'){
+ $value_prefix = $this->getPrefix($value);
+ $value_localpart = $this->getLocalPart($value);
+ $this->message[$pos]['type'] = $value_localpart;
+ $this->message[$pos]['typePrefix'] = $value_prefix;
+ if(isset($this->namespaces[$value_prefix])){
+ $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
+ } else if(isset($attrs['xmlns:'.$value_prefix])) {
+ $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
+ }
+ // should do something here with the namespace of specified type?
+ } elseif($key_localpart == 'arrayType'){
+ $this->message[$pos]['type'] = 'array';
+ /* do arrayType ereg here
+ [1] arrayTypeValue ::= atype asize
+ [2] atype ::= QName rank*
+ [3] rank ::= '[' (',')* ']'
+ [4] asize ::= '[' length~ ']'
+ [5] length ::= nextDimension* Digit+
+ [6] nextDimension ::= Digit+ ','
+ */
+ $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]';
+ if(ereg($expr,$value,$regs)){
+ $this->message[$pos]['typePrefix'] = $regs[1];
+ $this->message[$pos]['arraySize'] = $regs[3];
+ $this->message[$pos]['arrayCols'] = $regs[4];
+ }
+ }
+ // log id
+ if($key == 'id'){
+ $this->ids[$value] = $pos;
+ }
+ // root
+ if($key_localpart == 'root' && $value == 1){
+ $this->status = 'method';
+ $this->root_struct_name = $name;
+ $this->root_struct = $pos;
+ $this->debug("found root struct $this->root_struct_name, pos $pos");
+ }
+ // for doclit
+ $attstr .= " $key=\"$value\"";
+ }
+ // get namespace - must be done after namespace atts are processed
+ if(isset($prefix)){
+ $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
+ $this->default_namespace = $this->namespaces[$prefix];
+ } else {
+ $this->message[$pos]['namespace'] = $this->default_namespace;
+ }
+ if($this->status == 'header'){
+ $this->responseHeaders .= "<$name$attstr>";
+ } elseif($this->root_struct_name != ''){
+ $this->document .= "<$name$attstr>";
+ }
+ }
+
+ /**
+ * end-element handler
+ *
+ * @param string $parser XML parser object
+ * @param string $name element name
+ * @access private
+ */
+ function end_element($parser, $name) {
+ // position of current element is equal to the last value left in depth_array for my depth
+ $pos = $this->depth_array[$this->depth--];
+
+ // get element prefix
+ if(strpos($name,':')){
+ // get ns prefix
+ $prefix = substr($name,0,strpos($name,':'));
+ // get unqualified name
+ $name = substr(strstr($name,':'),1);
+ }
+
+ // build to native type
+ if(isset($this->body_position) && $pos > $this->body_position){
+ // deal w/ multirefs
+ if(isset($this->message[$pos]['attrs']['href'])){
+ // get id
+ $id = substr($this->message[$pos]['attrs']['href'],1);
+ // add placeholder to href array
+ $this->multirefs[$id][$pos] = "placeholder";
+ // add set a reference to it as the result value
+ $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
+ // build complex values
+ } elseif($this->message[$pos]['children'] != ""){
+ $this->message[$pos]['result'] = $this->buildVal($pos);
+ } else {
+ $this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
+ if(is_numeric($this->message[$pos]['cdata']) ){
+ if( strpos($this->message[$pos]['cdata'],'.') ){
+ $this->message[$pos]['result'] = doubleval($this->message[$pos]['cdata']);
+ } else {
+ $this->message[$pos]['result'] = intval($this->message[$pos]['cdata']);
+ }
+ } else {
+ $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
+ }
+ }
+ }
+
+ // switch status
+ if($pos == $this->root_struct){
+ $this->status = 'body';
+ } elseif($name == 'Body'){
+ $this->status = 'header';
+ } elseif($name == 'Header'){
+ $this->status = 'envelope';
+ } elseif($name == 'Envelope'){
+ //
+ }
+ // set parent back to my parent
+ $this->parent = $this->message[$pos]['parent'];
+ // for doclit
+ if($this->status == 'header'){
+ $this->responseHeaders .= "</$name>";
+ } elseif($pos >= $this->root_struct){
+ $this->document .= "</$name>";
+ }
+ }
+
+ /**
+ * element content handler
+ *
+ * @param string $parser XML parser object
+ * @param string $data element content
+ * @access private
+ */
+ function character_data($parser, $data){
+ $pos = $this->depth_array[$this->depth];
+ if ($this->xml_encoding=='UTF-8'){
+ $data = utf8_decode($data);
+ }
+ $this->message[$pos]['cdata'] .= $data;
+ // for doclit
+ if($this->status == 'header'){
+ $this->responseHeaders .= $data;
+ } else {
+ $this->document .= $data;
+ }
+ }
+
+ /**
+ * get the parsed message
+ *
+ * @return mixed
+ * @access public
+ */
+ function get_response(){
+ return $this->soapresponse;
+ }
+
+ /**
+ * get the parsed headers
+ *
+ * @return string XML or empty if no headers
+ * @access public
+ */
+ function getHeaders(){
+ return $this->responseHeaders;
+ }
+
+ /**
+ * decodes entities
+ *
+ * @param string $text string to translate
+ * @access private
+ */
+ function decode_entities($text){
+ foreach($this->entities as $entity => $encoded){
+ $text = str_replace($encoded,$entity,$text);
+ }
+ return $text;
+ }
+
+ /**
+ * builds response structures for compound values (arrays/structs)
+ *
+ * @param string $pos position in node tree
+ * @access private
+ */
+ function buildVal($pos){
+ if(!isset($this->message[$pos]['type'])){
+ $this->message[$pos]['type'] = '';
+ }
+ $this->debug('inside buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
+ // if there are children...
+ if($this->message[$pos]['children'] != ''){
+ $children = explode('|',$this->message[$pos]['children']);
+ array_shift($children); // knock off empty
+ // md array
+ if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
+ $r=0; // rowcount
+ $c=0; // colcount
+ foreach($children as $child_pos){
+ $this->debug("got an MD array element: $r, $c");
+ $params[$r][] = $this->message[$child_pos]['result'];
+ $c++;
+ if($c == $this->message[$pos]['arrayCols']){
+ $c = 0;
+ $r++;
+ }
+ }
+ // array
+ } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
+ $this->debug('adding array '.$this->message[$pos]['name']);
+ foreach($children as $child_pos){
+ $params[] = &$this->message[$child_pos]['result'];
+ }
+ // apache Map type: java hashtable
+ } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
+ foreach($children as $child_pos){
+ $kv = explode("|",$this->message[$child_pos]['children']);
+ $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
+ }
+ // generic compound type
+ //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
+ } else {
+ // is array or struct? better way to do this probably
+ foreach($children as $child_pos){
+ if(isset($keys) && isset($keys[$this->message[$child_pos]['name']])){
+ $struct = 1;
+ break;
+ }
+ $keys[$this->message[$child_pos]['name']] = 1;
+ }
+ //
+ foreach($children as $child_pos){
+ if(isset($struct)){
+ $params[] = &$this->message[$child_pos]['result'];
+ } else {
+ $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
+ }
+ }
+ }
+ return is_array($params) ? $params : array();
+ } else {
+ $this->debug('no children');
+ if(strpos($this->message[$pos]['cdata'],'&')){
+ return strtr($this->message[$pos]['cdata'],array_flip($this->entities));
+ } else {
+ return $this->message[$pos]['cdata'];
+ }
+ }
+ }
+}
+
+
+
+?><?php
+
+
+
+/**
+*
+* soapclient higher level class for easy usage.
+*
+* usage:
+*
+* // instantiate client with server info
+* $soapclient = new soapclient( string path [ ,boolean wsdl] );
+*
+* // call method, get results
+* echo $soapclient->call( string methodname [ ,array parameters] );
+*
+* // bye bye client
+* unset($soapclient);
+*
+* @author Dietrich Ayala <dietrich@ganx4.com>
+* @version v 0.6.3
+* @access public
+*/
+class soapclient extends nusoap_base {
+
+ var $username = '';
+ var $password = '';
+ var $requestHeaders = false;
+ var $responseHeaders;
+ var $endpoint;
+ var $error_str = false;
+ var $proxyhost = '';
+ var $proxyport = '';
+ var $xml_encoding = '';
+ var $http_encoding = false;
+ var $timeout = 0;
+ var $endpointType = '';
+ var $persistentConnection = false;
+ var $defaultRpcParams = false;
+
+ /**
+ * fault related variables
+ *
+ * @var fault
+ * @var faultcode
+ * @var faultstring
+ * @var faultdetail
+ * @access public
+ */
+ var $fault, $faultcode, $faultstring, $faultdetail;
+
+ /**
+ * constructor
+ *
+ * @param string $endpoint SOAP server or WSDL URL
+ * @param bool $wsdl optional, set to true if using WSDL
+ * @param int $portName optional portName in WSDL document
+ * @access public
+ */
+ function soapclient($endpoint,$wsdl = false){
+ $this->endpoint = $endpoint;
+
+ // make values
+ if($wsdl){
+ $this->endpointType = 'wsdl';
+ $this->wsdlFile = $this->endpoint;
+
+ // instantiate wsdl object and parse wsdl file
+ $this->debug('instantiating wsdl class with doc: '.$endpoint);
+ $this->wsdl =& new wsdl($this->wsdlFile,$this->proxyhost,$this->proxyport);
+ $this->debug("wsdl debug: \n".$this->wsdl->debug_str);
+ $this->wsdl->debug_str = '';
+ // catch errors
+ if($errstr = $this->wsdl->getError()){
+ $this->debug('got wsdl error: '.$errstr);
+ $this->setError('wsdl error: '.$errstr);
+ } elseif($this->operations = $this->wsdl->getOperations()){
+ $this->debug( 'got '.count($this->operations).' operations from wsdl '.$this->wsdlFile);
+ } else {
+ $this->debug( 'getOperations returned false');
+ $this->setError('no operations defined in the WSDL document!');
+ }
+ }
+ }
+
+ /**
+ * calls method, returns PHP native type
+ *
+ * @param string $method SOAP server URL or path
+ * @param array $params array of parameters, can be associative or not
+ * @param string $namespace optional method namespace
+ * @param string $soapAction optional SOAPAction value
+ * @param boolean $headers optional array of soapval objects for headers
+ * @param boolean $rpcParams optional treat params as RPC for use="literal"
+ * This can be used on a per-call basis to overrider defaultRpcParams.
+ * @return mixed
+ * @access public
+ */
+ function call($operation,$params=array(),$namespace='',$soapAction='',$headers=false,$rpcParams=null){
+ $this->operation = $operation;
+ $this->fault = false;
+ $this->error_str = '';
+ $this->request = '';
+ $this->response = '';
+ $this->faultstring = '';
+ $this->faultcode = '';
+ $this->opData = array();
+
+ $this->debug("call: $operation, $params, $namespace, $soapAction, $headers, $rpcParams");
+ $this->debug("endpointType: $this->endpointType");
+ // if wsdl, get operation data and process parameters
+ if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
+
+ $this->opData = $opData;
+ foreach($opData as $key => $value){
+ $this->debug("$key -> $value");
+ }
+ $soapAction = $opData['soapAction'];
+ $this->endpoint = $opData['endpoint'];
+ $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : 'http://testuri.org';
+ $style = $opData['style'];
+ // add ns to ns array
+ if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
+ $this->wsdl->namespaces['nu'] = $namespace;
+ }
+ // serialize payload
+
+ if($opData['input']['use'] == 'literal') {
+ if (is_null($rpcParams)) {
+ $rpcParams = $this->defaultRpcParams;
+ }
+ if ($rpcParams) {
+ $this->debug("serializing literal params for operation $operation");
+ $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params);
+ $defaultNamespace = $this->wsdl->wsdl_info['targetNamespace'];
+ } else {
+ $this->debug("serializing literal document for operation $operation");
+ $payload = is_array($params) ? array_shift($params) : $params;
+ }
+ } else {
+ $this->debug("serializing encoded params for operation $operation");
+ $payload = "<".$this->wsdl->getPrefixFromNamespace($namespace).":$operation>".
+ $this->wsdl->serializeRPCParameters($operation,'input',$params).
+ '</'.$this->wsdl->getPrefixFromNamespace($namespace).":$operation>";
+ }
+ $this->debug('payload size: '.strlen($payload));
+ // serialize envelope
+ $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$this->wsdl->usedNamespaces,$style);
+ $this->debug("wsdl debug: \n".$this->wsdl->debug_str);
+ $this->wsdl->debug_str = '';
+ } elseif($this->endpointType == 'wsdl') {
+ $this->setError( 'operation '.$operation.' not present.');
+ $this->debug("operation '$operation' not present.");
+ $this->debug("wsdl debug: \n".$this->wsdl->debug_str);
+ return false;
+ // no wsdl
+ } else {
+ // make message
+ if(!isset($style)){
+ $style = 'rpc';
+ }
+ if($namespace == ''){
+ $namespace = 'http://testuri.org';
+ $this->wsdl->namespaces['ns1'] = $namespace;
+ }
+ // serialize envelope
+ $payload = '';
+ foreach($params as $k => $v){
+ $payload .= $this->serialize_val($v,$k);
+ }
+ $payload = "<ns1:$operation xmlns:ns1=\"$namespace\">\n".$payload."</ns1:$operation>\n";
+ $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders);
+ }
+ $this->debug("endpoint: $this->endpoint, soapAction: $soapAction, namespace: $namespace");
+ // send
+ $this->debug('sending msg (len: '.strlen($soapmsg).") w/ soapaction '$soapAction'...");
+ $return = $this->send($soapmsg,$soapAction,$this->timeout);
+ if($errstr = $this->getError()){
+ $this->debug('Error: '.$errstr);
+ return false;
+ } else {
+ $this->return = $return;
+ $this->debug('sent message successfully and got a(n) '.gettype($return).' back');
+
+ // fault?
+ if(is_array($return) && isset($return['faultcode'])){
+ $this->debug('got fault');
+ $this->setError($return['faultcode'].': '.$return['faultstring']);
+ $this->fault = true;
+ foreach($return as $k => $v){
+ $this->$k = $v;
+ $this->debug("$k = $v<br>");
+ }
+ return $return;
+ } else {
+ // array of return values
+ if(is_array($return)){
+ // multiple 'out' parameters
+ if(sizeof($return) > 1){
+ return $return;
+ }
+ // single 'out' parameter
+ return array_shift($return);
+ // nothing returned (ie, echoVoid)
+ } else {
+ return "";
+ }
+ }
+ }
+ }
+
+ /**
+ * get available data pertaining to an operation
+ *
+ * @param string $operation operation name
+ * @return array array of data pertaining to the operation
+ * @access public
+ */
+ function getOperationData($operation){
+ if(isset($this->operations[$operation])){
+ return $this->operations[$operation];
+ }
+ $this->debug("No data for operation: $operation");
+ }
+
+ /**
+ * send the SOAP message
+ *
+ * Note: if the operation has multiple return values
+ * the return value of this method will be an array
+ * of those values.
+ *
+ * @param string $msg a SOAPx4 soapmsg object
+ * @param string $soapaction SOAPAction value
+ * @param integer $timeout set timeout in seconds
+ * @return mixed native PHP types.
+ * @access private
+ */
+ function send($msg, $soapaction = '', $timeout=0) {
+ // detect transport
+ switch(true){
+ // http(s)
+ case ereg('^http',$this->endpoint):
+ $this->debug('transporting via HTTP');
+ if($this->persistentConnection && is_object($this->persistentConnection)){
+ $http =& $this->persistentConnection;
+ } else {
+ $http = new soap_transport_http($this->endpoint);
+ // pass encoding into transport layer, so appropriate http headers are sent
+ $http->soap_defencoding = $this->soap_defencoding;
+ }
+ $http->setSOAPAction($soapaction);
+ if($this->proxyhost && $this->proxyport){
+ $http->setProxy($this->proxyhost,$this->proxyport);
+ }
+ if($this->username != '' && $this->password != '') {
+ $http->setCredentials($this->username,$this->password);
+ }
+ if($this->http_encoding != ''){
+ $http->setEncoding($this->http_encoding);
+ }
+ $this->debug('sending message, length: '.strlen($msg));
+ if(ereg('^http:',$this->endpoint)){
+ //if(strpos($this->endpoint,'http:')){
+ $response = $http->send($msg,$timeout);
+ } elseif(ereg('^https',$this->endpoint)){
+ //} elseif(strpos($this->endpoint,'https:')){
+ //if(phpversion() == '4.3.0-dev'){
+ //$response = $http->send($msg,$timeout);
+ //$this->request = $http->outgoing_payload;
+ //$this->response = $http->incoming_payload;
+ //} else
+ if (extension_loaded('curl')) {
+ $response = $http->sendHTTPS($msg,$timeout);
+ } else {
+ $this->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
+ }
+ } else {
+ $this->setError('no http/s in endpoint url');
+ }
+ $this->request = $http->outgoing_payload;
+ $this->response = $http->incoming_payload;
+ $this->debug("transport debug data...\n".$http->debug_str);
+ // save transport object if using persistent connections
+ if($this->persistentConnection && !is_object($this->persistentConnection)){
+ $this->persistentConnection = $http;
+ }
+ if($err = $http->getError()){
+ $this->setError('HTTP Error: '.$err);
+ return false;
+ } elseif($this->getError()){
+ return false;
+ } else {
+ $this->debug('got response, length: '.strlen($response));
+ return $this->parseResponse($response);
+ }
+ break;
+ default:
+ $this->setError('no transport found, or selected transport is not yet supported!');
+ return false;
+ break;
+ }
+ }
+
+ /**
+ * processes SOAP message returned from server
+ *
+ * @param string unprocessed response data from server
+ * @return mixed value of the message, decoded into a PHP type
+ * @access private
+ */
+ function parseResponse($data) {
+ $this->debug('Entering parseResponse(), about to create soap_parser instance');
+ $parser = new soap_parser($data,$this->xml_encoding,$this->operation);
+ // if parse errors
+ if($errstr = $parser->getError()){
+ $this->setError( $errstr);
+ // destroy the parser object
+ unset($parser);
+ return false;
+ } else {
+ // get SOAP headers
+ $this->responseHeaders = $parser->getHeaders();
+ // get decoded message
+ $return = $parser->get_response();
+ // add parser debug data to our debug
+ $this->debug($parser->debug_str);
+ // add document for doclit support
+ $this->document = $parser->document;
+ // destroy the parser object
+ unset($parser);
+ // return decode message
+ return $return;
+ }
+ }
+
+ /**
+ * set the SOAP headers
+ *
+ * @param $headers string XML
+ * @access public
+ */
+ function setHeaders($headers){
+ $this->requestHeaders = $headers;
+ }
+
+ /**
+ * get the response headers
+ *
+ * @return mixed object SOAPx4 soapval object or empty if no headers
+ * @access public
+ */
+ function getHeaders(){
+ if($this->responseHeaders != '') {
+ return $this->responseHeaders;
+ }
+ }
+
+ /**
+ * set proxy info here
+ *
+ * @param string $proxyhost
+ * @param string $proxyport
+ * @access public
+ */
+ function setHTTPProxy($proxyhost, $proxyport) {
+ $this->proxyhost = $proxyhost;
+ $this->proxyport = $proxyport;
+ }
+
+ /**
+ * if authenticating, set user credentials here
+ *
+ * @param string $username
+ * @param string $password
+ * @access public
+ */
+ function setCredentials($username, $password) {
+ $this->username = $username;
+ $this->password = $password;
+ }
+
+ /**
+ * use HTTP encoding
+ *
+ * @param string $enc
+ * @access public
+ */
+ function setHTTPEncoding($enc='gzip, deflate'){
+ $this->http_encoding = $enc;
+ }
+
+ /**
+ * use HTTP persistent connections if possible
+ *
+ * @access public
+ */
+ function useHTTPPersistentConnection(){
+ $this->persistentConnection = true;
+ }
+
+ /**
+ * gets the default RPC parameter setting.
+ * If true, default is that call params are like RPC even for document style.
+ * Each call() can override this value.
+ *
+ * @access public
+ */
+ function getDefaultRpcParams() {
+ return $this->defaultRpcParams;
+ }
+
+ /**
+ * sets the default RPC parameter setting.
+ * If true, default is that call params are like RPC even for document style
+ * Each call() can override this value.
+ *
+ * @param boolean $rpcParams
+ * @access public
+ */
+ function setDefaultRpcParams($rpcParams) {
+ $this->defaultRpcParams = $rpcParams;
+ }
+
+ /**
+ * dynamically creates proxy class, allowing user to directly call methods from wsdl
+ *
+ * @return object soap_proxy object
+ * @access public
+ */
+ function getProxy(){
+ $evalStr = '';
+ foreach($this->operations as $operation => $opData){
+ if($operation != ''){
+ // create param string
+ $paramStr = '';
+ if(sizeof($opData['input']['parts']) > 0){
+ foreach($opData['input']['parts'] as $name => $type){
+ $paramStr .= "\$$name,";
+ }
+ $paramStr = substr($paramStr,0,strlen($paramStr)-1);
+ }
+ $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
+ $evalStr .= "function $operation ($paramStr){
+ // load params into array
+ \$params = array($paramStr);
+ return \$this->call('$operation',\$params,'".$opData['namespace']."','".$opData['soapAction']."');
+ }";
+ unset($paramStr);
+ }
+ }
+ $r = rand();
+ $evalStr = 'class soap_proxy_'.$r.' extends soapclient {
+ '.$evalStr.'
+ }';
+ //print "proxy class:<pre>$evalStr</pre>";
+ // eval the class
+ eval($evalStr);
+ // instantiate proxy object
+ eval("\$proxy = new soap_proxy_$r('');");
+ // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
+ $proxy->endpointType = 'wsdl';
+ $proxy->wsdlFile = $this->wsdlFile;
+ $proxy->wsdl = $this->wsdl;
+ $proxy->operations = $this->operations;
+ $proxy->defaultRpcParams = $this->defaultRpcParams;
+ return $proxy;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/soap/server.php b/html/phpgacl/soap/server.php
new file mode 100644
index 0000000..bfe131c
--- /dev/null
+++ b/html/phpgacl/soap/server.php
@@ -0,0 +1,33 @@
+<?php
+/*
+ * MAKE SURE phpGACL's DEBUG IS DISABLED... Otherwise the SOAP server will break.
+ *
+ *
+ * Currently, only the acl_check() function is exported to the SOAP server.
+ *
+ */
+
+/*
+ * A small speed improvement can be made if you copy the $gacl_options array from gacl_admin.inc.php
+ * into this file, and only include the ../gacl.class.php file.
+ */
+require_once('../admin/gacl_admin.inc.php');
+require_once('nusoap.php');
+
+$s = new soap_server;
+
+$s->register('acl_check');
+$s->register('test');
+
+function acl_check($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value=NULL, $axo_value=NULL, $root_aro_group_id=NULL, $root_axo_group_id=NULL) {
+ global $gacl;
+
+ return $gacl->acl_check($aco_section_value, $aco_value, $aro_section_value, $aro_value, $axo_section_value, $axo_value, $root_aro_group_id, $root_axo_group_id);
+}
+
+function test($text) {
+ return $text;
+}
+
+$s->service($HTTP_RAW_POST_DATA);
+?>
diff --git a/html/phpgacl/test_suite/acl_tests.php b/html/phpgacl/test_suite/acl_tests.php
new file mode 100644
index 0000000..b44498c
--- /dev/null
+++ b/html/phpgacl/test_suite/acl_tests.php
@@ -0,0 +1,223 @@
+<?php
+
+class acl_setup {
+
+ var $gacl_api;
+
+ var $aco_section = array();
+ var $aco = array();
+
+ var $aro_section = array();
+ var $aro = array();
+ var $aro_group = array();
+
+ var $axo_section = array();
+ var $axo = array();
+ var $axo_group = array();
+
+ var $acl = array();
+
+ function acl_setup() {
+ $this->gacl_api = &$GLOBALS['gacl_api'];
+ }
+
+ function setup() {
+ // ACO
+ $this->aco_section[] = $this->gacl_api->add_object_section ('Test','test_aco',0,0,'ACO');
+ $this->aco[] = $this->gacl_api->add_object ('test_aco','Access','access',0,0,'ACO');
+
+ // ARO
+ $this->aro_section[] = $this->gacl_api->add_object_section ('Human', 'test_human',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_human','Han','han',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_human','Lando','lando',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_human','Obi-wan','obiwan',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_human','Luke','luke',0,0,'ARO');
+
+ $this->aro_section[] = $this->gacl_api->add_object_section ('Android', 'test_android',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_android','R2D2','r2d2',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_android','C3PO','c3po',0,0,'ARO');
+
+ $this->aro_section[] = $this->gacl_api->add_object_section ('Alien', 'test_alien',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_alien','Chewie','chewie',0,0,'ARO');
+ $this->aro[] = $this->gacl_api->add_object ('test_alien','Hontook','hontook',0,0,'ARO');
+
+ // ARO groups
+ $this->aro_group['root'] = $this->gacl_api->add_group('millennium_falcon_passengers', 'Millennium Falcon Passengers',0,'ARO');
+ $this->aro_group['crew'] = $this->gacl_api->add_group('crew', 'Crew',$this->aro_group['root'],'ARO');
+ $this->aro_group['passengers'] = $this->gacl_api->add_group('passengers','Passengers',$this->aro_group['root'],'ARO');
+ $this->aro_group['jedi'] = $this->gacl_api->add_group('jedi', 'Jedi',$this->aro_group['passengers'],'ARO');
+ $this->aro_group['engineers'] = $this->gacl_api->add_group('engineers', 'Engineers',$this->aro_group['root'],'ARO');
+
+ // add AROs to groups
+ $this->gacl_api->add_group_object($this->aro_group['crew'],'test_alien','chewie','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['crew'],'test_human','han','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['crew'],'test_human','lando','ARO');
+
+ $this->gacl_api->add_group_object($this->aro_group['passengers'],'test_android','c3po','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['passengers'],'test_android','r2d2','ARO');
+
+ $this->gacl_api->add_group_object($this->aro_group['jedi'],'test_human','luke','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['jedi'],'test_human','obiwan','ARO');
+
+ $this->gacl_api->add_group_object($this->aro_group['engineers'],'test_alien','hontook','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['engineers'],'test_android','r2d2','ARO');
+ $this->gacl_api->add_group_object($this->aro_group['engineers'],'test_human','han','ARO');
+
+ // AXO
+ $this->axo_section[] = $this->gacl_api->add_object_section ('Location', 'test_location',0,0,'AXO');
+ $this->axo[] = $this->gacl_api->add_object ('test_location','Engines','engines',0,0,'AXO');
+ $this->axo[] = $this->gacl_api->add_object ('test_location','Lounge','lounge',0,0,'AXO');
+ $this->axo[] = $this->gacl_api->add_object ('test_location','Cockpit','cockpit',0,0,'AXO');
+ $this->axo[] = $this->gacl_api->add_object ('test_location','Guns','guns',0,0,'AXO');
+
+ // AXO Groups
+ $this->axo_group['locations'] = $this->gacl_api->add_group('locations', 'Locations',0,'AXO');
+
+ // add AXOs to groups
+ $this->gacl_api->add_group_object($this->axo_group['locations'],'test_location','engines','AXO');
+ $this->gacl_api->add_group_object($this->axo_group['locations'],'test_location','lounge','AXO');
+ $this->gacl_api->add_group_object($this->axo_group['locations'],'test_location','cockpit','AXO');
+ $this->gacl_api->add_group_object($this->axo_group['locations'],'test_location','guns','AXO');
+
+ // create ACLs
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),NULL,array($this->aro_group['crew']),NULL,array($this->axo_group['locations']),1,1,NULL,'Crew can go anywhere');
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),array('test_alien'=>array('chewie')),NULL,array('test_location'=>array('engines')),NULL,0,1,NULL,'Chewie can\'t access the engines');
+
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),NULL,array($this->aro_group['passengers']),array('test_location'=>array('lounge')),NULL,1,1,NULL,'Passengers are allowed in the lounge');
+
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),NULL,array($this->aro_group['jedi']),array('test_location'=>array('cockpit')),NULL,1,1,NULL,'Jedi are allowed in the cockpit');
+
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),array('test_human'=>array('luke')),NULL,array('test_location'=>array('guns')),NULL,1,1,NULL,'Luke can access the guns');
+
+ $this->acl[] = $this->gacl_api->add_acl(array('test_aco'=>array('access')),NULL,array($this->aro_group['engineers']),array('test_location'=>array('engines','guns')),NULL,1,1,NULL,'Engineers can access the engines and guns');
+
+ }
+
+ function teardown() {
+ // delete ACLs
+ foreach ($this->acl as $id) {
+ $this->gacl_api->del_acl($id);
+ }
+
+ // delete AXO groups
+ foreach (array_reverse($this->axo_group) as $id) {
+ $this->gacl_api->del_group($id,TRUE,'AXO');
+ }
+
+ // delete AXOs
+ foreach ($this->axo as $id) {
+ $this->gacl_api->del_object($id,'AXO');
+ }
+
+ // delete AXO sections
+ foreach ($this->axo_section as $id) {
+ $this->gacl_api->del_object_section($id,'AXO');
+ }
+
+ // delete ARO groups
+ foreach (array_reverse($this->aro_group) as $id) {
+ $this->gacl_api->del_group($id,TRUE,'ARO');
+ }
+
+ // delete AROs
+ foreach ($this->aro as $id) {
+ $this->gacl_api->del_object($id,'ARO');
+ }
+
+ // delete ARO sections
+ foreach ($this->aro_section as $id) {
+ $this->gacl_api->del_object_section($id,'ARO');
+ }
+
+ // delete ACOs
+ foreach ($this->aco as $id) {
+ $this->gacl_api->del_object($id,'ACO');
+ }
+
+ // delete ACO sections
+ foreach ($this->aco_section as $id) {
+ $this->gacl_api->del_object_section($id,'ACO');
+ }
+ }
+}
+
+class acl_test extends gacl_test_case {
+
+ var $acl_setup;
+
+ function acl_test($name) {
+ $this->gacl_test_case($name);
+ $this->acl_setup = &$GLOBALS['acl_setup'];
+ }
+
+ function test_check_luke_lounge() {
+ $result = $this->gacl_api->acl_check('test_aco','access','test_human','luke','test_location','lounge');
+ $message = 'Luke should have access to the Lounge';
+ $this->assertEquals(TRUE, $result, $message);
+ }
+
+ function test_check_luke_engines() {
+ $result = $this->gacl_api->acl_check('test_aco','access','test_human','luke','test_location','engines');
+ $message = 'Luke shouldn\'t have access to the Engines';
+ $this->assertEquals(FALSE, $result, $message);
+ }
+
+ function test_check_chewie_guns() {
+ $result = $this->gacl_api->acl_check('test_aco','access','test_alien','chewie','test_location','guns');
+ $message = 'Chewie should have access to the Guns';
+ $this->assertEquals(TRUE, $result, $message);
+ }
+
+ function test_check_chewie_engines() {
+ $result = $this->gacl_api->acl_check('test_aco','access','test_alien','chewie','test_location','engines');
+ $message = 'Chewie shouldn\'t have access to the Engines';
+ $this->assertEquals(FALSE, $result, $message);
+ }
+
+ function test_query_luke_lounge() {
+ $result = $this->gacl_api->acl_query('test_aco','access','test_human','luke','test_location','lounge');
+ $expected = array(
+ 'acl_id' => $this->acl_setup->acl[2],
+ 'return_value' => '',
+ 'allow' => TRUE
+ );
+ $message = 'Luke should have access to the Lounge';
+
+ $this->assertEquals($expected, $result, $message);
+ }
+}
+
+// check no previous tests failed
+if ( $result->failureCount() > 0 )
+{
+ echo '<p>Previous test failed, not running ACL check tests.</p>';
+ return;
+}
+
+echo '<p>Running ACL tests...<br />';
+
+// set up test environment
+$acl_setup = new acl_setup;
+
+echo '&nbsp;&nbsp;Setting Up... ';
+$acl_setup->setup();
+echo 'Done<br/>';
+
+// run tests & destroy suite
+$suite = new gacl_test_suite('acl_test');
+
+echo '&nbsp;&nbsp;Running Tests... ';
+$suite->run($result);
+echo 'Done<br />';
+unset ($suite);
+
+// tear down test environment;
+echo '&nbsp;&nbsp;Cleaning Up... ';
+$acl_setup->teardown();
+unset ($acl_setup);
+echo 'Done<br />';
+
+echo '<b>Done</b></p>';
+// done.
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/test_suite/phpunit/ChangeLog b/html/phpgacl/test_suite/phpunit/ChangeLog
new file mode 100644
index 0000000..5ee718d
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/ChangeLog
@@ -0,0 +1,69 @@
+2002-10-31 Fred Yankowski <fred@ontosys.com>
+
+ * stylesheet.css: Add classes for "meta-results" types.
+
+ * runtests.php: Explain expected results.
+ Accomodate tabular format of results.
+
+ * phpunit_test.php: Use CSS formatting of results.
+ Use tabular layout similar to PrettyTestResult.
+
+2002-10-30 Fred Yankowski <fred@ontosys.com>
+
+ * phpunit_test.php: (SelfTestResult): New class for reporting self-tests.
+
+ * phpunit.php (Exception): Record type, error or failure.
+ (Assert::assertEquals): Generate new error exception.
+ (Assert::_formatValue): Display serialized value of arrays and objects.
+ (TestCase::error): Record error as Exception.
+ (TestCase::failed): Check for failure exceptions.
+ (TestFailure): Record only single exception per instance.
+ (TestResult): Record errors separately from failures.
+ (TestResult::errorCount): New function.
+ (TestResult::failureCount): New function.
+ (TextTestResult::report): List failures and errors separately.
+
+2002-10-22 Fred Yankowski <fred@ontosys.com>
+
+ * phpunit.php (TextTestUnit::_startTest): Print class name too. (per Ryan King).
+
+2002-05-08 Fred Yankowski <fred@ontosys.com>
+
+ * phpunit_test.php: New tests for assertEqualsMultilineStrings method.
+
+ * phpunit.php: New assertEqualsMultilineStrings method.
+
+2002-04-12 Fred Yankowski <fred@ontosys.com>
+
+ * phpunit_test.php: New TestClassNameStartingWithTest class.
+
+ * phpunit.php (runTest): Add defensive check on test method name.
+ (TestSuite): Smarter filtering of test method names.
+
+2002-04-10 Fred Yankowski <fred@ontosys.com>
+
+ * runtests.php: New file -- example driver script.
+
+ * runtests2.php: New file.
+
+2002-03-27 Fred Yankowski <fred@ontosys.com>
+
+ * phpunit_test.php (AssertEqualsTests): test bug 535772
+
+ * phpunit.php (assertEquals): use equals() method if avail
+ (_formatValue): new method for bug 535772
+ (failNotEquals): use _formatValue()
+
+ * phpunit_test.php (AssertEqualsTests): tests for bug 498937
+
+ * phpunit.php (assertEquals): finer-grained tests per bug 498937
+
+ * stylesheet.css: new file, used along with PrettyTestResult
+
+ * phpunit_test.php: remove HTML page context
+
+ * phpunit.php: new PrettyTestResult class
+
+ * README: new file
+
+
diff --git a/html/phpgacl/test_suite/phpunit/README b/html/phpgacl/test_suite/phpunit/README
new file mode 100644
index 0000000..4d915ee
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/README
@@ -0,0 +1,24 @@
+DEPENDENCIES
+
+phpUnit runs on PHP3 or PHP4.
+
+phpUnit uses PCRE (Perl Compatible Regular Expressions). PCRE is
+normally compiled into PHP, but it might be missing from custom builds
+of PHP.
+
+
+INSTALLATION
+
+Place the phpunit.php file so that it is in the PHP include_path for
+the PHP code to be tested. Installing it in the same directory as the
+code-under-test should work.
+
+The same phpunit.php file can be shared by any number of test suites.
+You may wish to install phpunit.php in just one place and adjust the
+PHP include_path to include that place.
+
+
+EXAMPLES
+
+The self-test suite for phpUnit itself is currently the best (only)
+example distributed with phpUnit. See phpunit_test.php.
diff --git a/html/phpgacl/test_suite/phpunit/phpunit.php b/html/phpgacl/test_suite/phpunit/phpunit.php
new file mode 100644
index 0000000..ab6216a
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/phpunit.php
@@ -0,0 +1,633 @@
+<?php
+//
+// PHP framework for testing, based on the design of "JUnit".
+//
+// Written by Fred Yankowski <fred@ontosys.com>
+// OntoSys, Inc <http://www.OntoSys.com>
+//
+// $Id: phpunit.php,v 1.1 2003/10/07 02:12:56 ipso Exp $
+
+// Copyright (c) 2000 Fred Yankowski
+
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use, copy,
+// modify, merge, publish, distribute, sublicense, and/or sell copies
+// of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//
+error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE |
+ E_CORE_ERROR | E_CORE_WARNING);
+
+/*
+interface Test {
+ function run(&$aTestResult);
+ function countTestCases();
+}
+*/
+
+function trace($msg) {
+ return;
+ print($msg);
+ flush();
+}
+
+if (phpversion() >= '4') {
+ function PHPUnit_error_handler($errno, $errstr, $errfile, $errline) {
+ global $PHPUnit_testRunning;
+ $PHPUnit_testRunning[0]->fail("<B>PHP ERROR:</B> ".$errstr." <B>in</B> ".$errfile." <B>at line</B> ".$errline);
+ }
+}
+
+class Exception {
+ /* Emulate a Java exception, sort of... */
+ var $message;
+ var $type;
+ function Exception($message, $type = 'FAILURE') {
+ $this->message = $message;
+ $this->type = $type;
+ }
+ function getMessage() {
+ return $this->message;
+ }
+ function getType() {
+ return $this->type;
+ }
+}
+
+class Assert {
+ function assert($boolean, $message=0) {
+ if (! $boolean)
+ $this->fail($message);
+ }
+
+ function assertEquals($expected, $actual, $message=0) {
+ if (gettype($expected) != gettype($actual)) {
+ $this->failNotEquals($expected, $actual, "expected", $message);
+ return;
+ }
+ if (phpversion() < '4') {
+ if (is_object($expected) or is_object($actual)
+ or is_array($expected) or is_array($actual)) {
+ $this->error("INVALID TEST: cannot compare arrays or objects in PHP3");
+ return;
+ }
+ }
+ if (phpversion() >= '4' && is_object($expected)) {
+ if (get_class($expected) != get_class($actual)) {
+ $this->failNotEquals($expected, $actual, "expected", $message);
+ return;
+ }
+ if (method_exists($expected, "equals")) {
+ if (! $expected->equals($actual)) {
+ $this->failNotEquals($expected, $actual, "expected", $message);
+ }
+ return; // no further tests after equals()
+
+ }
+ }
+ if (phpversion() >= '4.0.4') {
+ if (is_null($expected) != is_null($actual)) {
+ $this->failNotEquals($expected, $actual, "expected", $message);
+ return;
+ }
+ }
+ if ($expected != $actual) {
+ $this->failNotEquals($expected, $actual, "expected", $message);
+ }
+ }
+
+ function assertRegexp($regexp, $actual, $message=false) {
+ if (! preg_match($regexp, $actual)) {
+ $this->failNotEquals($regexp, $actual, "pattern", $message);
+ }
+ }
+
+ function assertEqualsMultilineStrings($string0, $string1,
+ $message="") {
+ $lines0 = split("\n",$string0);
+ $lines1 = split("\n",$string1);
+ if (sizeof($lines0) != sizeof($lines1)) {
+ $this->failNotEquals(sizeof($lines0)." line(s)",
+ sizeof($lines1)." line(s)", "expected", $message);
+ }
+ for($i=0; $i< sizeof($lines0); $i++) {
+ $this->assertEquals(trim($lines0[$i]),
+ trim($lines1[$i]),
+ "line ".($i+1)." of multiline strings differ. ".$message);
+ }
+ }
+
+ function _formatValue($value, $class="") {
+ $translateValue = $value;
+ if (phpversion() >= '4.0.0') {
+ if (is_object($value)) {
+ if (method_exists($value, "toString") ) {
+ $translateValue = $value->toString();
+ }
+ else {
+ $translateValue = serialize($value);
+ }
+ }
+ else if (is_array($value)) {
+ $translateValue = serialize($value);
+ }
+ }
+ $htmlValue = "<code class=\"$class\">"
+ . htmlspecialchars($translateValue) . "</code>";
+ if (phpversion() >= '4.0.0') {
+ if (is_bool($value)) {
+ $htmlValue = $value ? "<i>true</i>" : "<i>false</i>";
+ }
+ elseif (phpversion() >= '4.0.4' && is_null($value)) {
+ $htmlValue = "<i>null</i>";
+ }
+ $htmlValue .= "&nbsp;&nbsp;&nbsp;<span class=\"typeinfo\">";
+ $htmlValue .= "type:" . gettype($value);
+ $htmlValue .= is_object($value) ? ", class:" . get_class($value) : "";
+ $htmlValue .= "</span>";
+ }
+ return $htmlValue;
+ }
+
+ function failNotEquals($expected, $actual, $expected_label, $message=0) {
+ // Private function for reporting failure to match.
+ $str = $message ? ($message . ' ') : '';
+ //$str .= "($expected_label/actual)<br>";
+ $str .= "<br>";
+ $str .= sprintf("%s<br>%s",
+ $this->_formatValue($expected, "expected"),
+ $this->_formatValue($actual, "actual"));
+ $this->fail($str);
+ }
+}
+
+class TestCase extends Assert /* implements Test */ {
+ /* Defines context for running tests. Specific context -- such as
+ instance variables, global variables, global state -- is defined
+ by creating a subclass that specializes the setUp() and
+ tearDown() methods. A specific test is defined by a subclass
+ that specializes the runTest() method. */
+ var $fName;
+ var $fClassName;
+ var $fResult;
+ var $fExceptions = array();
+
+ function TestCase($name) {
+ $this->fName = $name;
+ }
+
+ function run($testResult=0) {
+ /* Run this single test, by calling the run() method of the
+ TestResult object which will in turn call the runBare() method
+ of this object. That complication allows the TestResult object
+ to do various kinds of progress reporting as it invokes each
+ test. Create/obtain a TestResult object if none was passed in.
+ Note that if a TestResult object was passed in, it must be by
+ reference. */
+ if (! $testResult)
+ $testResult = $this->_createResult();
+ $this->fResult = $testResult;
+ $testResult->run(&$this);
+ $this->fResult = 0;
+ return $testResult;
+ }
+
+ function classname() {
+ if (isset($this->fClassName)) {
+ return $this->fClassName;
+ } else {
+ return get_class($this);
+ }
+ }
+
+ function countTestCases() {
+ return 1;
+ }
+
+ function runTest() {
+ if (phpversion() >= '4') {
+ global $PHPUnit_testRunning;
+ eval('$PHPUnit_testRunning[0] = & $this;');
+ // Saved ref to current TestCase, so that the error handler
+ // can access it. This code won't even parse in PHP3, so we
+ // hide it in an eval.
+ $old_handler = set_error_handler("PHPUnit_error_handler");
+ // errors will now be handled by our error handler
+ }
+
+ $name = $this->name();
+ if (phpversion() >= '4' && ! method_exists($this, $name)) {
+ $this->error("Method '$name' does not exist");
+ }
+ else
+ $this->$name();
+
+ /*
+ if (phpversion() >= '4') {
+ set_error_handler($old_handler); // revert to prior error handler
+ $PHPUnit_testRunning = null;
+ }
+ */
+ }
+
+ function setUp() /* expect override */ {
+ //print("TestCase::setUp()<br>\n");
+ }
+
+ function tearDown() /* possible override */ {
+ //print("TestCase::tearDown()<br>\n");
+ }
+
+ ////////////////////////////////////////////////////////////////
+
+
+ function _createResult() /* protected */ {
+ /* override this to use specialized subclass of TestResult */
+ return new TestResult;
+ }
+
+ function fail($message=0) {
+ //printf("TestCase::fail(%s)<br>\n", ($message) ? $message : '');
+ /* JUnit throws AssertionFailedError here. We just record the
+ failure and carry on */
+ $this->fExceptions[] = new Exception(&$message, 'FAILURE');
+ }
+
+ function error($message) {
+ /* report error that requires correction in the test script
+ itself, or (heaven forbid) in this testing infrastructure */
+ $this->fExceptions[] = new Exception(&$message, 'ERROR');
+ $this->fResult->stop(); // [does not work]
+ }
+
+ function failed() {
+ reset($this->fExceptions);
+ while (list($key, $exception) = each($this->fExceptions)) {
+ if ($exception->type == 'FAILURE')
+ return true;
+ }
+ return false;
+ }
+ function errored() {
+ reset($this->fExceptions);
+ while (list($key, $exception) = each($this->fExceptions)) {
+ if ($exception->type == 'ERROR')
+ return true;
+ }
+ return false;
+ }
+
+ function getExceptions() {
+ return $this->fExceptions;
+ }
+
+ function name() {
+ return $this->fName;
+ }
+
+ function runBare() {
+ $this->setup();
+ $this->runTest();
+ $this->tearDown();
+ }
+}
+
+
+class TestSuite /* implements Test */ {
+ /* Compose a set of Tests (instances of TestCase or TestSuite), and
+ run them all. */
+ var $fTests = array();
+ var $fClassname;
+
+ function TestSuite($classname=false) {
+ // Find all methods of the given class whose name starts with
+ // "test" and add them to the test suite.
+
+ // PHP3: We are just _barely_ able to do this with PHP's limited
+ // introspection... Note that PHP seems to store method names in
+ // lower case, and we have to avoid the constructor function for
+ // the TestCase class superclass. Names of subclasses of TestCase
+ // must not start with "Test" since such a class will have a
+ // constructor method name also starting with "test" and we can't
+ // distinquish such a construtor from the real test method names.
+ // So don't name any TestCase subclasses as "Test..."!
+
+ // PHP4: Never mind all that. We can now ignore constructor
+ // methods, so a test class may be named "Test...".
+
+ if (empty($classname))
+ return;
+ $this->fClassname = $classname;
+
+ if (floor(phpversion()) >= 4) {
+ // PHP4 introspection, submitted by Dylan Kuhn
+
+ $names = get_class_methods($classname);
+ while (list($key, $method) = @each($names)) {
+ if (preg_match('/^test/', $method)) {
+ $test = new $classname($method);
+ if (strcasecmp($method, $classname) == 0 || is_subclass_of($test, $method)) {
+ // Ignore the given method name since it is a constructor:
+ // it's the name of our test class or it is the name of a
+ // superclass of our test class. (This code smells funny.
+ // Anyone got a better way?)
+
+ //print "skipping $method<br>";
+ }
+ else {
+ $this->addTest($test);
+ }
+ }
+ }
+ }
+ else { // PHP3
+ $dummy = new $classname("dummy");
+ $names = (array) $dummy;
+ while (list($key, $value) = each($names)) {
+ $type = gettype($value);
+ if ($type == "user function" && preg_match('/^test/', $key)
+ && $key != "testcase") {
+ $this->addTest(new $classname($key));
+ }
+ }
+ }
+ }
+
+ function addTest($test) {
+ /* Add TestCase or TestSuite to this TestSuite */
+ $this->fTests[] = $test;
+ }
+
+ function run(&$testResult) {
+ /* Run all TestCases and TestSuites comprising this TestSuite,
+ accumulating results in the given TestResult object. */
+ reset($this->fTests);
+ while (list($na, $test) = each($this->fTests)) {
+ if ($testResult->shouldStop())
+ break;
+ $test->run(&$testResult);
+ }
+ }
+
+ function countTestCases() {
+ /* Number of TestCases comprising this TestSuite (including those
+ in any constituent TestSuites) */
+ $count = 0;
+ reset($fTests);
+ while (list($na, $test_case) = each($this->fTests)) {
+ $count += $test_case->countTestCases();
+ }
+ return $count;
+ }
+}
+
+
+class TestFailure {
+ /* Record failure of a single TestCase, associating it with the
+ exception that occurred */
+ var $fFailedTestName;
+ var $fException;
+
+ function TestFailure(&$test, &$exception) {
+ $this->fFailedTestName = $test->name();
+ $this->fException = $exception;
+ }
+
+ function getExceptions() {
+ // deprecated
+ return array($this->fException);
+ }
+ function getException() {
+ return $this->fException;
+ }
+
+ function getTestName() {
+ return $this->fFailedTestName;
+ }
+}
+
+
+class TestResult {
+ /* Collect the results of running a set of TestCases. */
+ var $fFailures = array();
+ var $fErrors = array();
+ var $fRunTests = 0;
+ var $fStop = false;
+
+ function TestResult() { }
+
+ function _endTest($test) /* protected */ {
+ /* specialize this for end-of-test action, such as progress
+ reports */
+ }
+
+ function addError($test, $exception) {
+ $this->fErrors[] = new TestFailure(&$test, &$exception);
+ }
+
+ function addFailure($test, $exception) {
+ $this->fFailures[] = new TestFailure(&$test, &$exception);
+ }
+
+ function getFailures() {
+ return $this->fFailures;
+ }
+
+ function run($test) {
+ /* Run a single TestCase in the context of this TestResult */
+ $this->_startTest($test);
+ $this->fRunTests++;
+
+ $test->runBare();
+
+ /* this is where JUnit would catch AssertionFailedError */
+ $exceptions = $test->getExceptions();
+ reset($exceptions);
+ while (list($key, $exception) = each($exceptions)) {
+ if ($exception->type == 'ERROR')
+ $this->addError($test, $exception);
+ else if ($exception->type == 'FAILURE')
+ $this->addFailure($test, $exception);
+ }
+ // if ($exceptions)
+ // $this->fFailures[] = new TestFailure(&$test, &$exceptions);
+ $this->_endTest($test);
+ }
+
+ function countTests() {
+ return $this->fRunTests;
+ }
+
+ function shouldStop() {
+ return $this->fStop;
+ }
+
+ function _startTest($test) /* protected */ {
+ /* specialize this for start-of-test actions */
+ }
+
+ function stop() {
+ /* set indication that the test sequence should halt */
+ $fStop = true;
+ }
+
+ function errorCount() {
+ return count($this->fErrors);
+ }
+ function failureCount() {
+ return count($this->fFailures);
+ }
+ function countFailures() {
+ // deprecated
+ return $this->failureCount();
+ }
+}
+
+
+class TextTestResult extends TestResult {
+ /* Specialize TestResult to produce text/html report */
+ function TextTestResult() {
+ $this->TestResult(); // call superclass constructor
+ }
+
+ function report() {
+ /* report result of test run */
+ $nRun = $this->countTests();
+ $nFailures = $this->failureCount();
+ $nErrors = $this->errorCount();
+ printf("<p>%s test%s run<br>", $nRun, ($nRun == 1) ? '' : 's');
+ printf("%s failure%s<br>\n", $nFailures, ($nFailures == 1) ? '' : 's');
+ printf("%s error%s.<br>\n", $nErrors, ($nErrors == 1) ? '' : 's');
+
+ if ($nFailures > 0) {
+ print("<h2>Failures</h2>");
+ print("<ol>\n");
+ $failures = $this->getFailures();
+ while (list($i, $failure) = each($failures)) {
+ $failedTestName = $failure->getTestName();
+ printf("<li>%s\n", $failedTestName);
+
+ $exceptions = $failure->getExceptions();
+ print("<ul>");
+ while (list($na, $exception) = each($exceptions))
+ printf("<li>%s\n", $exception->getMessage());
+ print("</ul>");
+ }
+ print("</ol>\n");
+ }
+
+ if ($nErrors > 0) {
+ print("<h2>Errors</h2>");
+ print("<ol>\n");
+ reset($this->fErrors);
+ while (list($i, $error) = each($this->fErrors)) {
+ $erroredTestName = $error->getTestName();
+ printf("<li>%s\n", $failedTestName);
+
+ $exception = $error->getException();
+ print("<ul>");
+ printf("<li>%s\n", $exception->getMessage());
+ print("</ul>");
+ }
+ print("</ol>\n");
+
+ }
+ }
+
+ function _startTest($test) {
+ if (phpversion() > '4') {
+ printf("%s - %s ", get_class($test), $test->name());
+ } else {
+ printf("%s ", $test->name());
+ }
+ flush();
+ }
+
+ function _endTest($test) {
+ $outcome = $test->failed()
+ ? "<font color=\"red\">FAIL</font>"
+ : "<font color=\"green\">ok</font>";
+ printf("$outcome<br>\n");
+ flush();
+ }
+}
+
+// PrettyTestResult created by BJG 17/11/01
+// beacuse the standard test result provided looks
+// rubbish.
+class PrettyTestResult extends TestResult {
+ /* Specialize TestResult to produce text/html report */
+ function PrettyTestResult() {
+ $this->TestResult(); // call superclass constructor
+ echo "<h2>Tests</h2>";
+
+ echo "<TABLE CELLSPACING=\"1\" CELLPADDING=\"1\" BORDER=\"0\" WIDTH=\"90%\" ALIGN=\"CENTER\" class=\"details\">";
+ echo "<TR><TH>Class</TH><TH>Function</TH><TH>Success?</TH></TR>";
+ }
+
+ function report() {
+ echo "</TABLE>";
+ /* report result of test run */
+ $nRun = $this->countTests();
+ $nFailures = $this->countFailures();
+ echo "<h2>Summary</h2>";
+
+ printf("<p>%s test%s run<br>", $nRun, ($nRun == 1) ? '' : 's');
+ printf("%s failure%s.<br>\n", $nFailures, ($nFailures == 1) ? '' : 's');
+ if ($nFailures == 0)
+ return;
+
+ echo "<h2>Failure Details</h2>";
+ print("<ol>\n");
+ $failures = $this->getFailures();
+ while (list($i, $failure) = each($failures)) {
+ $failedTestName = $failure->getTestName();
+ printf("<li>%s\n", $failedTestName);
+
+ $exceptions = $failure->getExceptions();
+ print("<ul>");
+ while (list($na, $exception) = each($exceptions))
+ printf("<li>%s\n", $exception->getMessage());
+ print("</ul>");
+ }
+ print("</ol>\n");
+ }
+
+ function _startTest($test) {
+ printf("<TR><TD>%s </TD><TD>%s </TD>", $test->classname(),$test->name());
+ flush();
+ }
+
+ function _endTest($test) {
+ $outcome = $test->failed()
+ ? " class=\"Failure\">FAIL"
+ : " class=\"Pass\">OK";
+ printf("<TD$outcome</TD></TR>");
+ flush();
+ }
+}
+
+class TestRunner {
+ /* Run a suite of tests and report results. */
+ function run($suite) {
+ $result = new TextTestResult;
+ $suite->run($result);
+ $result->report();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/html/phpgacl/test_suite/phpunit/phpunit_test.php b/html/phpgacl/test_suite/phpunit/phpunit_test.php
new file mode 100644
index 0000000..01c6dd9
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/phpunit_test.php
@@ -0,0 +1,268 @@
+<?php
+require "phpunit.php";
+
+class SelfTestResult extends TextTestResult {
+ /* Specialize result class for use in self-tests, to handle
+ special situation where many tests are expected to fail. */
+ function SelfTestResult() {
+ $this->TextTestResult();
+ echo '<table class="details">';
+ echo '<tr><th>Test name</th><th>Result</th><th>Meta-result</th></tr>';
+ }
+
+ function _startTest($test) {
+ print('<tr><td>');
+ if (phpversion() > '4') {
+ printf("%s - %s ", get_class($test), $test->name());
+ } else {
+ printf("%s ", $test->name());
+ }
+ print('</td>');
+ flush();
+ }
+
+ function _endTest($test) {
+ /* Report both the test result and, for this special situation
+ where some tests are expected to fail, a "meta" test result
+ which indicates whether the test result matches the
+ expected result. */
+ $expect_failure = preg_match('/fail/i', $test->name());
+ $test_passed = ($test->failed() == 0);
+
+ if ($test->errored())
+ $outcome = "<span class=\"Error\">ERROR</span>";
+ else if ($test->failed())
+ $outcome = "<span class=\"Failure\">FAIL</span>";
+ else
+ $outcome = "<span class=\"Pass\">OK</span>";
+
+ if ($test->errored())
+ $meta_outcome = '<span class="Unknown">unknown</span>';
+ else
+ $meta_outcome = ($expect_failure xor $test_passed)
+ ? '<span class="Expected">as expected</span>'
+ : '<span class="Unexpected">UNEXPECTED</span>';
+
+ printf("<td>$outcome</td><td>$meta_outcome</td></tr>\n");
+ flush();
+ }
+}
+
+
+class TestFixture extends TestCase {
+ function TestFixture($name) {
+ $this->TestCase($name);
+ }
+
+ function setUp() {
+ /* put any common setup here */
+ $this->intVal = 1;
+ $this->strVal = 'foo';
+ }
+
+ function testFail1() {
+ $this->assert($this->intVal == 0, "1 == 0");
+ }
+
+ function testFail2() {
+ $this->assert($this->strVal == 'bar');
+ }
+
+ function testPass1() {
+ $this->assert($this->intVal == 1);
+ }
+}
+
+$suite = new TestSuite;
+$suite->addTest(new TestFixture("testFail1"));
+$suite->addTest(new TestFixture("testFail2"));
+$suite->addTest(new TestFixture("testPass1"));
+//$suite->addTest(new TestFixture("testNotExistFail"));
+
+
+class Fixture2 extends TestCase {
+ function Fixture2($name) {
+ $this->TestCase($name);
+ }
+ function setUp() {
+ $this->str1 = 'foo';
+ $this->str2 = 'bar';
+ }
+ function runTest() {
+ $this->testStrNotEqual();
+ $this->testStrAppend();
+ }
+ function testStrNotEqual() {
+ $this->assert($this->str1 == $this->str2, 'str equal');
+ }
+ function testStrAppend() {
+ $this->assertEquals($this->str1 . 'bar', 'foobars', 'str append');
+ }
+}
+
+$suite->addTest(new Fixture2("Fail3"));
+
+
+class TestPass2 extends TestFixture {
+ function TestPass2($name) { $this->TestFixture($name); }
+ function runTest() {
+ $this->assertEquals($this->strVal . 'x', $this->strVal . 'x');
+ $this->assertEquals($this->strVal . 'x', $this->strVal . 'y');
+ $this->assertEquals(1, 0);
+ $this->assertEquals(1, "1", 'equals int and str');
+ }
+}
+$suite->addTest(new TestPass2("Fail4"));
+
+
+class MoreTesterTests extends TestCase {
+ function MoreTesterTests($name) { $this->TestCase($name); }
+
+ function testRegexpPass() {
+ $this->assertRegexp('/fo+ba[^a-m]/', 'foobar');
+ }
+
+ function testRegexpFail() {
+ $this->assertRegexp('/fo+ba[^m-z]/', 'foobar');
+ }
+
+ function testRegexpFailWithMessage() {
+ $this->assertRegexp('/fo+ba[^m-z]/', 'foobar', "This is the message");
+ }
+}
+$suite->addTest(new TestSuite("MoreTesterTests"));
+
+class ManyFailingTests extends TestCase {
+ function ManyFailingTests($name) { $this->TestCase($name); }
+
+ function testPass1() { $this->assertEquals(0, 0); }
+ function testPass2() { $this->assertEquals(0, 0); }
+ function testFail1() { $this->assertEquals(1, 0); }
+ function testFail2() { $this->assertEquals(1, 0); }
+ function testFail3() { $this->assertEquals(1, 0); }
+ function testFail4() { $this->assertEquals(1, 0); }
+ function testFail5() { $this->assertEquals(1, 0); }
+ function testFail6() { $this->assertEquals(1, 0); }
+ function testPass3() { $this->assertEquals(0, 0); }
+ function testFail7() { $this->assertEquals(1, 0); }
+ function testPass4() { $this->assertEquals(0, 0); }
+ function testFail8() { $this->assertEquals(1, 0); }
+ function testPass5() { $this->assertEquals(0, 0); }
+ function testPass6() { $this->assertEquals(0, 0); }
+ function testFail9() { $this->assertEquals(1, 0); }
+ function testPass7() { $this->assertEquals(0, 0); }
+ function testPass8() { $this->assertEquals(0, 0); }
+}
+
+$suite->addTest(new TestSuite("ManyFailingTests"));
+
+class DummyClass1 {
+ var $fX;
+}
+
+class DummyClass2 {
+ var $fX;
+ var $fY;
+ function DummyClass2($x="", $y="") {
+ $this->fX = $x;
+ $this->fY = $y;
+ }
+ function equals($another) {
+ return $another->fX == $this->fX;
+ }
+ function toString() {
+ return sprintf("DummyClass2(%s, %s)", $this->fX, $this->fY);
+ }
+}
+
+class AssertEqualsTests extends TestCase {
+ function AssertEqualsTests($name) { $this->TestCase($name); }
+
+ function testDiffTypesFail() {
+ $this->assertEquals(0, "");
+ }
+ function testMultiLinePass() {
+ $str1 = "line1\nline2\nline3";
+ $str2 = "line1\nline2\nline3";
+ $this->assertEqualsMultilineStrings($str1, $str2);
+ }
+ function testMultiLineFail() {
+ $str1 = "line1\nline2\nline3";
+ $str2 = "line1\nline2 modified\nline3";
+ $this->assertEqualsMultilineStrings($str1, $str2);
+ }
+ function testMultiLineFail2() {
+ $str1 = "line1\nline2\nline3";
+ $str2 = "line1\nline2\nline3\nline4";
+ $this->assertEqualsMultilineStrings($str1, $str2);
+ }
+}
+$suite->addTest(new TestSuite("AssertEqualsTests"));
+
+class AssertEqualsPhp3ErrorTests extends TestCase {
+ /* These tests create an ERROR in PHP3 and work as expected in PHP4. */
+ function AssertEqualsPhp3ErrorTests($name) { $this->TestCase($name); }
+ function testDiffClassFail() {
+ $this->assertEquals(new DummyClass1, new DummyClass2);
+ }
+ function testSameClassPass() {
+ $this->assertEquals(new DummyClass1, new DummyClass1);
+ }
+ function testSameClassFail() {
+ $dummy1 = new DummyClass1;
+ $dummy2 = new DummyClass1;
+ $dummy1->fX = 1;
+ $dummy2->fX = 2;
+ $this->assertEquals($dummy1, $dummy2);
+ }
+ function testSameClassEqualsFail() {
+ $dummy1 = new DummyClass2(3);
+ $dummy2 = new DummyClass2(4);
+ $this->assertEquals($dummy1, $dummy2);
+ }
+ function testSameClassEqualsPass() {
+ $dummy1 = new DummyClass2(5, 6);
+ $dummy2 = new DummyClass2(5, 7);
+ $this->assertEquals($dummy1, $dummy2);
+ }
+}
+$suite->addTest(new TestSuite("AssertEqualsPhp3ErrorTests"));
+
+if (phpversion() >= '4') {
+ class AssertEqualsTests4 extends TestCase {
+ /* these tests only make sense starting with PHP4 */
+ function AssertEqualsTests($name) { $this->TestCase($name); }
+
+ function testNullFail() {
+ $this->assertEquals(0, NULL);
+ }
+ function testNullPass() {
+ $this->assertEquals(NULL, NULL);
+ }
+ function testArrayValuesPass1() {
+ $a1 = array('first' => 10, 'second' => 20);
+ $a2 = array('first' => 10, 'second' => 20);
+ $this->assertEquals($a1, $a2);
+ }
+ function testArrayValuesFail1() {
+ $a1 = array('first' => 10, 'second' => 20);
+ $a2 = array('first' => 10, 'second' => 22);
+ $this->assertEquals($a1, $a2);
+ }
+ }
+ $suite->addTest(new TestSuite("AssertEqualsTests4"));
+
+ class TestClassNameStartingWithTest extends TestCase {
+ function TestClassNameStartingWithTest($name) {
+ $this->TestCase($name);
+ }
+ function testWhateverPass() {
+ $this->assert(true);
+ }
+ }
+ $suite->addTest(new TestSuite("TestClassNameStartingWithTest"));
+}
+
+
+// $suite now consists of phpUnit self-test suite
+?>
diff --git a/html/phpgacl/test_suite/phpunit/runtests.php b/html/phpgacl/test_suite/phpunit/runtests.php
new file mode 100644
index 0000000..91a21e3
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/runtests.php
@@ -0,0 +1,45 @@
+<?php // -*- mode: html; mmm-classes: html-php -*-
+
+include("phpunit_test.php");
+// above set $suite to self-test suite
+
+$title = 'PhpUnit test run';
+?>
+<html>
+ <head>
+ <title><?php echo $title; ?></title>
+ <STYLE TYPE="text/css">
+ <?php
+ include ("stylesheet.css");
+?>
+ </STYLE>
+ </head>
+ <body>
+ <h1><?php echo $title; ?></h1>
+ <p>
+ Unlike a typical test run, <strong>expect many test cases to
+ fail</strong>. Exactly those with <code>pass</code> in their
+ name should succeed.
+ <p>
+ For each test we display both the test result -- <span
+ class="Pass">ok</span>, <span class="Failure">FAIL</span>, or
+ <span class="Error">ERROR</span> -- and also a meta-result --
+ <span class="Expected">as expected</span>, <span
+ class="Unexpected">UNEXPECTED</span>, or <span
+ class="Unknown">unknown</span> -- that indicates whether the
+ expected test result occurred. Although many test results will
+ be 'FAIL' here, all meta-results should be 'as expected', except
+ for a few 'unknown' meta-results (because of errors) when running
+ in PHP3.
+ <h2>Test Results</h2>
+ <?php
+ if (isset($only))
+ $suite = new TestSuite($only);
+ $result = new SelfTestResult;
+
+ $suite->run($result);
+ print('</table>');
+ $result->report();
+ ?>
+ </body>
+</html>
diff --git a/html/phpgacl/test_suite/phpunit/runtests2.php b/html/phpgacl/test_suite/phpunit/runtests2.php
new file mode 100644
index 0000000..34261bc
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/runtests2.php
@@ -0,0 +1,39 @@
+<?php // -*- mode: sgml-html; mmm-classes: html-php -*-
+
+include("phpunit_test.php");
+// above set $suite to self-test suite
+
+$title = 'PhpUnit test run, different output format';
+?>
+ <html>
+ <head>
+ <title><?php echo $title; ?></title>
+ <STYLE TYPE="text/css">
+ <?php
+ include ("stylesheet.css");
+ ?>
+ </STYLE>
+ </head>
+ <body>
+ <h1><?php echo $title; ?></h1>
+ <p>
+ This page runs all the phpUnit self-tests, and uses the
+ PrettyTestResult subclass of TestResult to produce nice HTML output.
+ </p>
+ <p>
+ Unlike typical test run, <strong>expect many test cases to
+ fail</strong>. Exactly those with <code>pass</code> in their name
+ should succeed.
+ </p>
+ <p>
+ <?php
+ if (isset($only)) {
+ $suite = new TestSuite($only);
+ }
+
+ $result = new PrettyTestResult;
+ $suite->run($result);
+ $result->report();
+ ?>
+ </body>
+ </html>
diff --git a/html/phpgacl/test_suite/phpunit/stylesheet.css b/html/phpgacl/test_suite/phpunit/stylesheet.css
new file mode 100644
index 0000000..b244825
--- /dev/null
+++ b/html/phpgacl/test_suite/phpunit/stylesheet.css
@@ -0,0 +1,64 @@
+
+body {
+ font:normal 68% verdana,arial,helvetica;
+ color:#000000;
+}
+table tr td, table tr th {
+ font-size: 68%;
+}
+table.details tr th{
+ font-weight: bold;
+ text-align:left;
+ background:#a6caf0;
+}
+table.details tr{
+ background:#eeeee0;
+}
+
+p {
+ line-height:1.5em;
+ margin-top:0.5em; margin-bottom:1.0em;
+}
+h1 {
+ margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
+}
+h2 {
+ margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
+}
+h3 {
+ margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
+}
+h4 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+h5 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+h6 {
+ margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
+}
+.Error {
+ font-weight:bold; color:red;
+}
+.Failure, .Unexpected {
+ background:#ff0000; font-weight:bold; color:black;
+}
+.Unknown {
+ background:#ffff00; font-weight:bold; color:black;
+}
+.Pass, .Expected {
+ background:#00ff00; font-weight:bold; color:black;
+}
+.Properties {
+ text-align:right;
+}
+
+CODE.expected {
+ color: green; background: none; font-weight: normal;
+}
+CODE.actual {
+ color: red; background: none; font-weight: normal;
+}
+.typeinfo {
+ color: gray;
+}
diff --git a/html/phpgacl/test_suite/random_acl_check.php b/html/phpgacl/test_suite/random_acl_check.php
new file mode 100644
index 0000000..2b3f60a
--- /dev/null
+++ b/html/phpgacl/test_suite/random_acl_check.php
@@ -0,0 +1,201 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Random ACL Check</title>
+</head>
+<body>
+<pre>
+<?php
+
+set_time_limit (6000);
+
+/*! function
+ get time accurate to the nearest microsecond, used for script timing
+ !*/
+function getmicrotime ()
+{
+ list ($usec, $sec) = explode (' ', microtime ());
+ return (float)$usec + (float)$sec;
+}
+
+/*! function
+ a better array_rand, this one actualluy works on windows
+ !*/
+function array_mt_rand ($array, $items)
+{
+ $keys = array_keys ($array);
+ $max = count ($keys) - 1;
+
+ if ( $items == 1 )
+ {
+ return $keys[mt_rand (0, $max)];
+ }
+
+ $return = array ();
+
+ for ( $i = 1; $i <= $items; $i++ )
+ {
+ $return[] = $keys[mt_rand (0, $max)];
+ }
+
+ return $return;
+}
+
+/*! function
+ grab random objects from the database
+ !*/
+function random_objects ($type, $limit = NULL)
+{
+ $sql = 'SELECT id, section_value, value FROM ' . $GLOBALS['gacl_api']->_db_table_prefix . $type . ' ORDER BY RAND()';
+
+ if ( is_scalar ($limit) )
+ {
+ $rs = $GLOBALS['gacl_api']->db->SelectLimit ($sql,$limit);
+ }
+ else
+ {
+ $rs = $GLOBALS['gacl_api']->db->Execute ($sql);
+ }
+
+ if ( !is_object ($rs) )
+ {
+ return FALSE;
+ }
+
+ $retarr = array ();
+
+ while ( $row = $rs->FetchRow () )
+ {
+ $retarr[$row[0]] = array (
+ $row[1],
+ $row[2]
+ );
+ }
+
+ return $retarr;
+}
+
+// require gacl
+require_once (dirname (__FILE__) . '/../admin/gacl_admin.inc.php');
+
+/*
+ * Let's get ready to RUMBLE!!!
+ */
+$scale = 100;
+
+echo '<b>Random ACL Check</b>' . "\n";
+echo ' Scale: ' . $scale . "\n\n";
+
+$overall_start = getmicrotime ();
+
+mt_srand ((double)microtime () *10000);
+
+echo "<b>Generating Test Data Set</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 5 * $scale;
+// $max = 1;
+
+$check = array ();
+
+$aco = random_objects ('aco', $max);
+$aro = random_objects ('aro', $max);
+$axo = random_objects ('axo', $max);
+
+for ( $i = $start; $i <= $max; $i++ )
+{
+ $rand_aco_id = array_mt_rand ($aco, 1);
+ $rand_aro_id = array_mt_rand ($aro, 1);
+ $rand_axo_id = array_mt_rand ($axo, 1);
+
+ // echo ' Rand ACO: '. $rand_aco_id .' ARO: '. $rand_aro_id . ' AXO: ' . $rand_axo_id . "\n";
+
+ $check[$i] = array (
+ 'aco' => $aco[$rand_aco_id],
+ 'aro' => $aro[$rand_aro_id],
+ 'axo' => $axo[$rand_axo_id]
+ );
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+echo "<b>Testing...</b>\n";
+flush ();
+
+$best = 99999;
+$worst = 0;
+$total = 0;
+
+$allowed = 0;
+$denied = 0;
+
+$allowed_time = 0;
+$denied_time = 0;
+
+foreach ( $check as $i => $data )
+{
+ echo ' Trying: ACO Section: '. $data['aco'][0] .' Value: '. $data['aco'][1] .' ARO Section: '. $data['aro'][0] .' Value: '. $data['aro'][1] . ' ARO Section: '. $data['axo'][0] .' Value: '. $data['axo'][1] . "\n";
+
+ $check_start = getmicrotime ();
+
+ $allow = $gacl_api->acl_check ($data['aco'][0],$data['aco'][1],$data['aro'][0],$data['aro'][1],$data['axo'][0],$data['axo'][1]);
+
+ $check_time = getmicrotime () - $check_start;
+
+ if ( $allow ) {
+ echo '<font color="#00ff00"> ' . $i . ". Access Granted</font>";
+ $allowed++;
+ $allowed_time += $check_time;
+ } else {
+ echo '<font color="#ff0000"> ' . $i . ". Access Denied</font>";
+ $denied++;
+ $denied_time += $check_time;
+ }
+
+ echo ' - ' . $check_time . " s\n";
+
+ $best = min ($best, $check_time);
+ $worst = max ($worst, $check_time);
+ $total = $total + $check_time;
+}
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Total: ' . $total . " s\n";
+echo ' Average: ' . $total/$max . " s\n\n";
+
+echo ' Allowed: ' . $allowed . "\n";
+echo ' Total: ' . $allowed_time . " s\n";
+echo ' Average: ' . $allowed_time/$allowed . " s\n\n";
+
+echo ' Denied: ' . $denied . "\n";
+echo ' Total: ' . $denied_time . " s\n";
+echo ' Average: ' . $denied_time/$denied . " s\n\n";
+
+echo ' Best: ' . $best . " s\n";
+echo ' Worst: ' . $worst . " s\n\n";
+
+// print_r ($gacl_api->db);
+
+
+$elapsed = getmicrotime () - $overall_start;
+
+echo '<b>All Finished</b>' . "\n";
+echo ' Total Time: ' . $elapsed . " s\n";
+
+/*
+ * end of script
+ */
+
+?>
+</pre>
+</body>
+</html>
diff --git a/html/phpgacl/test_suite/run.php b/html/phpgacl/test_suite/run.php
new file mode 100644
index 0000000..1fce633
--- /dev/null
+++ b/html/phpgacl/test_suite/run.php
@@ -0,0 +1,161 @@
+<?php
+ // require gacl & phpunit
+ require_once(dirname(__FILE__).'/../admin/gacl_admin.inc.php');
+ require_once(dirname(__FILE__).'/phpunit/phpunit.php');
+
+ /*! class
+ custom test result class for pretty results
+ !*/
+ class gacl_test_result extends TestResult {
+
+ var $output = '';
+ var $class_name;
+
+ function report() {
+ /* results table */
+ echo '<h2>Test Results</h2>' . "\n";
+ echo '<table cellspacing="1" cellpadding="1" border="1" class="details">'."\n";
+ echo '<tr><th>Function</th><th width="10%">Success?</th></tr>'."\n";
+ echo $this->output;
+ echo '</table>'."\n";
+
+ /* summary */
+ $nRun = $this->countTests();
+ $nFailures = $this->countFailures();
+ echo '<h2>Summary</h2>'."\n";
+ printf('<div class="indent"><p>%s test%s run<br />', $nRun, ($nRun == 1) ? '' : 's');
+ printf("%s failure%s.</p></div>\n", $nFailures, ($nFailures == 1) ? '' : 's');
+ }
+
+ function _startTest($test) {
+ }
+
+ function _endTest($test) {
+ if ( $test->classname() != $this->class_name ) {
+ $this->class_name = $test->classname();
+ $this->output .= '<tr><td colspan="2" class="class_name">'. $test->classname() .'</td></tr>'."\n";
+ }
+
+ $this->output .= '<tr><td class="function">'. $test->name();
+ if ($test->failed()) {
+ $this->output .= "<ul>\n";
+ foreach ($test->getExceptions() as $exception) {
+ $this->output .= '<li>'. $exception->getMessage() ."</li>\n";
+ }
+ $this->output .= "</ul>\n";
+
+ $outcome = ' class="fail">FAIL';
+ } else {
+ $outcome = ' class="pass">OK';
+ }
+
+ $this->output .= '</td><td'. $outcome .'</td></tr>'."\n";
+ }
+ }
+
+ /*! class
+ custom TestCase class to allow control of error formatting
+
+ can also be used for custom assert functions
+ !*/
+ class gacl_test_case extends TestCase {
+
+ var $gacl_api;
+
+ function gacl_test_case($name) {
+ $this->TestCase($name);
+ $this->gacl_api = &$GLOBALS['gacl_api'];
+ }
+
+ function setUp() {
+ }
+
+ function tearDown() {
+ }
+
+ function _formatValue($value, $class='') {
+ if (phpversion() < '4.0.0') {
+ return '<code class="'. $class .'">'. htmlentities((string)$value) .'</code>';
+ }
+
+ switch (TRUE)
+ {
+ case is_object($value):
+ if (method_exists($value, 'toString')) {
+ $translateValue = $value->toString();
+ } else {
+ $translateValue = serialize($value);
+ }
+
+ $htmlValue = htmlentities($translateValue);
+ break;
+ case is_array($value):
+ ob_start();
+ print_r($value);
+ $translateValue = ob_get_contents();
+ ob_end_clean();
+
+ $htmlValue = nl2br(str_replace(' ', '&nbsp; &nbsp; ', htmlentities(rtrim($translateValue))));
+ break;
+ case is_bool($value):
+ $htmlValue = $value ? '<i>true</i>' : '<i>false</i>';
+ break;
+ case phpversion() >= '4.0.4' && is_null($value):
+ $htmlValue = '<i>null</i>';
+ break;
+ default:
+ $htmlValue = htmlentities(strval($value));
+ }
+
+ $htmlValue = '<code class="'. $class . '">' . $htmlValue . '</code>';
+ $htmlValue .= '&nbsp;&nbsp;<span class="typeinfo">';
+ $htmlValue .= 'type:' . gettype($value);
+
+ if (is_object($value)) {
+ $htmlValue .= ', class:' . get_class($value);
+ }
+
+ $htmlValue .= '</span>';
+
+ return $htmlValue;
+ }
+ }
+
+ /*! class
+ custom TestSuite class for future expansion
+ !*/
+ class gacl_test_suite extends TestSuite {
+
+ }
+
+ $title = 'phpGACL Test Suite';
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title><?php echo $title; ?></title>
+ <link rel="stylesheet" href="styles.css" type="text/css" title="GACL Test Suite Styles"/>
+ </head>
+ <body>
+ <h1><?php echo $title; ?></h1>
+ <h2>Running Tests</h2>
+ <div class="indent">
+<?php
+ // initialise result
+ $result = new gacl_test_result;
+
+ // run api tests
+ include('unit_tests.php');
+
+ // run acl tests
+ include('acl_tests.php');
+
+ echo '
+ </div>
+ ';
+
+ // show report
+ $result->report();
+?>
+ </body>
+</html>
diff --git a/html/phpgacl/test_suite/stress_test.php b/html/phpgacl/test_suite/stress_test.php
new file mode 100644
index 0000000..3707dea
--- /dev/null
+++ b/html/phpgacl/test_suite/stress_test.php
@@ -0,0 +1,419 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Stress Test</title>
+</head>
+<body>
+<pre>
+<?php
+
+/*! var
+ test scale
+
+ This script will create:
+ $scale * 10 ACOs
+ $scale * 10 ARO groups
+ $scale * 1000 AROs
+ $scale * 10 AXO groups
+ $scale * 1000 AXOs
+ $scale * 10 ACLs
+
+ 1 normal ~5 seconds
+ 10 heavy ~1 minute
+ 100 crazy ~1 hour
+ !*/
+$scale = 10;
+
+set_time_limit (6000);
+
+/*! function
+ get time accurate to the nearest microsecond, used for script timing
+ !*/
+function getmicrotime ()
+{
+ list ($usec, $sec) = explode (' ', microtime ());
+ return (float)$usec + (float)$sec;
+}
+
+/*! function
+ a better array_rand, this one actually works on windows
+ !*/
+function array_mt_rand ($array, $items)
+{
+ $keys = array_keys ($array);
+ $max = count ($keys) - 1;
+
+ if ( $items == 1 )
+ {
+ return $keys[mt_rand (0, $max)];
+ }
+
+ $return = array ();
+
+ for ( $i = 1; $i <= $items; $i++ )
+ {
+ $return[] = $keys[mt_rand (0, $max)];
+ }
+
+ return $return;
+}
+
+// require gacl
+require_once (dirname (__FILE__) . '/../admin/gacl_admin.inc.php');
+
+/*
+ * Let's get ready to RUMBLE!!!
+ */
+
+echo '<b>Stress Test</b>' . "\n";
+echo ' Scale: ' . $scale . "\n\n";
+
+$overall_start = getmicrotime ();
+
+mt_srand ((double)microtime () *10000);
+
+$gacl_api->add_object_section ('System', 'system', 0, 0, 'ACO');
+
+echo "<b>Create ACOs</b>\n";
+flush ();
+
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 10 * $scale;
+for ( $i = $start; $i <= $max; $i++ )
+{
+ if ( $gacl_api->add_object ('system', 'ACO: ' . $i, $i, 10, 0, 'ACO') == FALSE )
+ {
+ echo " Error creating ACO: $i.\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ }
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+
+$gacl_api->add_object_section ('Users', 'users', 0, 0, 'ARO');
+
+echo "<b>Create many ARO Groups.</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$query = 'SELECT id FROM '.$gacl_api->_db_table_prefix.'aro_groups';
+$ids = $gacl_api->db->GetCol($query);
+
+// print_r ($ids);
+
+$start = 1;
+$max = 10 * $scale;
+
+// function add_group ($name, $parent_id=0, $group_type='ARO') {
+for ( $i = $start; $i <= $max; $i++ )
+{
+ // Find a random parent
+ if ( !empty ($ids) ) {
+ $parent_id = $ids[array_mt_rand ($ids, 1)];
+ } else {
+ $parent_id = 0;
+ }
+
+ $result = $gacl_api->add_group ('aro_group'.$i,'ARO Group: '. $i, $parent_id, 'ARO');
+
+ if ( $result == FALSE )
+ {
+ echo " Error creating ARO Group: $i.\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ }
+ else
+ {
+ $ids[] = $result;
+ }
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+
+echo "<b>Create AROs & assign to ARO Groups</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 1000 * $scale;
+
+$groups = array_keys ($gacl_api->format_groups ($gacl_api->sort_groups ('ARO'), 'ARRAY'));
+$randmax = count ($groups) - 1;
+
+for ( $i = $start; $i <= $max; $i++ )
+{
+ if ( $gacl_api->add_object ('users', 'ARO: '. $i, $i, 10, 0, 'ARO') == FALSE )
+ {
+ echo " Error creating ARO: $i.<br />\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ }
+ else
+ {
+ // Assign to random groups.
+ $rand_key = $groups[mt_rand (0, $randmax)];
+ $gacl_api->add_group_object ($rand_key, 'users', $i, 'ARO');
+ }
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+
+
+$gacl_api->add_object_section ('Users', 'users', 0, 0, 'AXO');
+
+echo "<b>Create many AXO Groups.</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$query = 'SELECT id FROM '.$gacl_api->_db_table_prefix.'axo_groups';
+$ids = $gacl_api->db->GetCol($query);
+
+$start = 1;
+$max = 10 * $scale;
+
+// function add_group ($name, $parent_id=0, $group_type='ARO') {
+for ( $i = $start; $i <= $max; $i++ )
+{
+ // Find a random parent
+ if ( !empty ($ids) ) {
+ $parent_id = $ids[array_mt_rand ($ids, 1)];
+ } else {
+ $parent_id = 0;
+ }
+
+ $result = $gacl_api->add_group ('axo_group'.$i,'AXO Group: '. $i, $parent_id, 'AXO');
+ if ( $result == FALSE )
+ {
+ echo " Error creating AXO Group: $i.\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ }
+ else
+ {
+ $ids[] = $result;
+ }
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+
+echo "<b>Create AXOs & assign to AXO Groups</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 1000 * $scale;
+
+// $groups = array_keys ($gacl_api->format_groups ($gacl_api->sort_groups ('AXO'), 'ARRAY'));
+$rand_max = count ($groups) - 1;
+
+for ( $i = $start; $i <= $max; $i++ )
+{
+ if ( $gacl_api->add_object ('users', 'AXO: ' . $i, $i, 10, 0, 'AXO') == FALSE )
+ {
+ echo " Error creating ARO: $i.<br />\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ }
+ else
+ {
+ // Assign to random groups.
+ $rand_key = $groups[mt_rand (0, $rand_max)];
+ $gacl_api->add_group_object ($rand_key, 'users', $i, 'AXO');
+ }
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+
+echo "<b>Generate random ACLs now.</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 10 * $scale;
+
+$aco_list = $gacl_api->get_object ('system', 1, 'ACO');
+
+$query = 'SELECT id, name FROM '.$gacl_api->_db_table_prefix.''. $gacl_.'aro_groups ORDER BY parent_id DESC LIMIT 100';
+$rs = $gacl_api->db->Execute($query);
+$aro_groups = $rs->GetAssoc();
+
+$query = 'SELECT id, name FROM '.$gacl_api->_db_table_prefix.'axo_groups ORDER BY parent_id DESC LIMIT 100';
+$rs = $gacl_api->db->Execute($query);
+$axo_groups = $rs->GetAssoc();
+
+// $aro_groups = $gacl_api->format_groups ($gacl_api->sort_groups ('ARO'), 'ARRAY');
+
+print_r ($aro_groups);
+
+// $axo_groups = $gacl_api->format_groups ($gacl_api->sort_groups ('AXO'), 'ARRAY');
+
+print_r ($axo_groups);
+
+for ( $i = $start; $i <= $max; $i++ )
+{
+ $rand_aco_key = array_mt_rand ($aco_list, mt_rand (2, 10));
+ $rand_aro_key = array_mt_rand ($aro_groups, mt_rand(2,10));
+ $rand_axo_key = array_mt_rand ($axo_groups, mt_rand(2,10));
+
+ $aco_array = array ();
+
+ foreach ( $rand_aco_key as $aco_key )
+ {
+ $aco_data = $gacl_api->get_object_data ($aco_list[$aco_key], 'ACO');
+ $aco_array[$aco_data[0][0]][] = $aco_data[0][1];
+ }
+
+ // Randomly create ACLs with AXOs assigned to them.
+ // if ($i % 2 == 0) {
+ $axo_array = $rand_axo_key;
+ // }
+
+ if ( $gacl_api->add_acl ($aco_array, NULL, $rand_aro_key, NULL, $axo_array) == FALSE )
+ {
+ echo " Error creating ACL: $i.\n";
+ echo ' ' . $gacl_api->_debug_msg . "\n";
+ // print_r (array_slice ($gacl_api->_debug_msg, -2));
+ }
+
+ unset ($axo_array);
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+
+echo "<b>Generating Test Data Set</b>\n";
+flush ();
+
+$start_time = getmicrotime ();
+
+$start = 1;
+$max = 5 * $scale;
+// $max = 1;
+
+$check = array ();
+
+for ( $i = $start; $i <= $max; $i++ )
+{
+ $rand_aco_key = mt_rand (10,10 * $scale);
+ $rand_aro_key = mt_rand (10,1000 * $scale);
+ $rand_axo_key = mt_rand (10,1000 * $scale);
+
+ // echo ' Rand ACO: '. $rand_aco_key .' ARO: '. $rand_aro_key . ' AXO: ' . $rand_axo_key . "\n";
+
+ $aco_data = &$gacl_api->get_object_data ($rand_aco_key, 'ACO');
+ $aro_data = &$gacl_api->get_object_data ($rand_aro_key, 'ARO');
+ $axo_data = &$gacl_api->get_object_data ($rand_axo_key, 'AXO');
+
+ $check[$i] = array (
+ 'aco' => $aco_data[0],
+ 'aro' => $aro_data[0],
+ 'axo' => $axo_data[0]
+ );
+}
+
+$elapsed = getmicrotime () - $start_time;
+
+echo "Done\n\n";
+echo ' Count: ' . $max . "\n";
+echo ' Time: ' . $elapsed . " s\n";
+echo ' Average: ' . $elapsed/$max . " s\n\n";
+
+echo "<b>Testing...</b>\n";
+flush ();
+
+$best = 99999;
+$worst = 0;
+$total = 0;
+
+foreach ( $check as $i => $data )
+{
+ echo ' Trying: ACO Section: '. $data['aco'][0] .' Value: '. $data['aco'][1] .' ARO Section: '. $data['aro'][0] .' Value: '. $data['aro'][1] . ' ARO Section: '. $data['axo'][0] .' Value: '. $data['axo'][1] . "\n";
+
+ $check_start = getmicrotime ();
+
+ $allow = $gacl_api->acl_check ($data['aco'][0],$data['aco'][1],$data['aro'][0],$data['aro'][1],$data['axo'][0],$data['axo'][1]);
+
+ $check_time = getmicrotime () - $check_start;
+
+ if ( $allow ) {
+ echo '<font color="#00ff00"> ' . $i . ". Access Granted!</font>";
+ } else {
+ echo '<font color="#ff0000"> ' . $i . ". Access Denied!</font>";
+ }
+
+ echo ' - ' . $check_time . " s\n";
+
+ $best = min ($best, $check_time);
+ $worst = max ($worst, $check_time);
+ $total = $total + $check_time;
+}
+
+echo "Done\n";
+echo ' Count: ' . $max . "\n\n";
+
+echo ' Total: ' . $total . " s\n";
+echo ' Average: ' . $total/$max . " s\n\n";
+
+echo ' Best: ' . $best . " s\n";
+echo ' Worst: ' . $worst . " s\n\n";
+
+// print_r ($gacl_api->db);
+
+
+$elapsed = getmicrotime () - $overall_start;
+
+echo '<b>All Finished</b>' . "\n";
+echo ' Total Time: ' . $elapsed . " s\n";
+
+/*
+ * end of script
+ */
+
+?>
+</pre>
+</body>
+</html>
diff --git a/html/phpgacl/test_suite/styles.css b/html/phpgacl/test_suite/styles.css
new file mode 100644
index 0000000..d2aeeea
--- /dev/null
+++ b/html/phpgacl/test_suite/styles.css
@@ -0,0 +1,101 @@
+body {
+ font-size: x-small;
+ font-family: Verdana,Arial,Helvetica,sans-serif;
+
+ background-color: #ffffff;
+ color: #000000;
+}
+
+h1 {
+ margin: 4px 0px;
+ text-align: center;
+ font-weight: bold;
+}
+
+h2 {
+ margin: 4px 0px 0px;
+}
+
+p {
+ margin: 4px 0px;
+}
+
+ul {
+ margin: 2px 0px;
+ padding-left: 20px;
+}
+
+div.indent {
+ margin-left: 3%;
+ margin-right: 3%;
+}
+
+table.details {
+ margin-top: 4px;
+ width: 94%;
+
+ border-width: 0px;
+
+ margin-left: 3%;
+ margin-right: 3%;
+}
+
+table.details th {
+ font-weight: bold;
+ text-align: left;
+ background: #a6caf0;
+
+ border-width: 0px;
+}
+
+table.details tr {
+ background: #eeeee0;
+}
+
+table.details td {
+ border-width: 0px;
+}
+
+table.details td.class_name {
+ font-weight: bold;
+ background-color: #eeeec0;
+ padding-left: 2px;
+}
+
+table.details td.function {
+ vertical-align: top;
+ padding-left: 10px;
+}
+
+table.details td.fail {
+ background-color: #ff0000;
+ font-weight: bold;
+
+ vertical-align: middle;
+ text-align: center;
+}
+
+table.details td.pass {
+ background-color: #00ff00;
+ font-weight: bold;
+
+ vertical-align: middle;
+ text-align: center;
+}
+
+.error {
+ color: #ff0000;
+ font-weight: bold;
+}
+
+code.expected {
+ color: #00ff00;
+}
+
+code.actual {
+ color: #ff0000;
+}
+
+span.typeinfo {
+ color: #999999;
+}
diff --git a/html/phpgacl/test_suite/unit_tests.php b/html/phpgacl/test_suite/unit_tests.php
new file mode 100644
index 0000000..16b115b
--- /dev/null
+++ b/html/phpgacl/test_suite/unit_tests.php
@@ -0,0 +1,563 @@
+<?php
+class phpgacl_api_test extends gacl_test_case {
+
+ /** VERSION **/
+
+ function get_version() {
+ $result = $this->gacl_api->get_version();
+ //$expected = '/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}$/i';
+ $expected = '/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}[a-zA-Z]{0,1}[0-9]{0,1}$/i';
+
+ $this->assertRegexp($expected, $result, 'Version incorrect.');
+ }
+ function get_schema_version() {
+ $result = $this->gacl_api->get_schema_version();
+ $expected = '/^[0-9]{1,2}.[0-9]{1,2}$/i';
+
+ $this->assertRegexp($expected, $result, 'Schema Version incorrect.');
+ }
+
+ /** GENERAL **/
+
+ function count_all() {
+ //Create array
+ $arr = array(
+ 'Level1a' => array(
+ 'Level2a' => array(
+ 'Level3a' => 1,
+ 'Level3b' => 2
+ ),
+ 'Level2b' => 3,
+ ),
+ 'Level1b' => 4,
+ 'Level1c' => array(
+ 'Level2c' => array(
+ 'Level3c' => 5,
+ 'Level3d' => 6
+ ),
+ 'Level2d' => 7,
+ ),
+ 'Level1d' => 8
+ );
+
+ //Keep in mind count_all only counts actual values. So array()'s don't count as +1
+ $result = $this->gacl_api->count_all($arr);
+
+ $this->assertEquals(8, $result, 'Incorrect array count, Should be 8.');
+ }
+
+ /** ACO SECTION **/
+
+ function get_object_section_section_id_aco() {
+ $result = $this->gacl_api->get_object_section_section_id('unit_test', 'unit_test', 'ACO');
+ $message = 'get_object_section_section_id failed';
+
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_object_section_aco() {
+ $result = $this->gacl_api->add_object_section('unit_test', 'unit_test', 999, 0, 'ACO');
+ $message = 'add_object_section failed';
+
+ $this->assert($result, $message);
+ }
+
+ function del_object_section_aco() {
+ $result = $this->gacl_api->del_object_section($this->get_object_section_section_id_aco(), 'ACO');
+ $message = 'del_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ /** ACO **/
+
+ function get_object_id_aco() {
+ $result = $this->gacl_api->get_object_id('unit_test','enable_tests', 'ACO');
+ $message = 'get_object_id failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_object_aco() {
+ $result = $this->gacl_api->add_object('unit_test', 'Enable - Tests', 'enable_tests', 999, 0, 'ACO');
+ $message = 'add_object failed';
+ $this->assert($result, $message);
+ }
+
+ function del_object_aco() {
+ $result = $this->gacl_api->del_object($this->get_object_id_aco(), 'ACO');
+ $message = 'del_object failed';
+ $this->assert($result, $message);
+ }
+
+ /** ARO SECTION **/
+
+ function get_object_section_section_id_aro() {
+ $result = $this->gacl_api->get_object_section_section_id('unit_test', 'unit_test', 'ARO');
+ $this->_aco_section_id = $result;
+ $message = 'get_object_section_section_id failed';
+ $this->assert($result >= 0, $message);
+
+ return $result;
+ }
+
+ function add_object_section_aro() {
+ $result = $this->gacl_api->add_object_section('unit_test', 'unit_test', 999, 0, 'ARO');
+ $message = 'add_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ function edit_object_section_aro() {
+ $object_id = $this->get_object_section_section_id_aro();
+
+ $rename_result = $this->gacl_api->edit_object_section($object_id, 'unit_test_tmp', 'unit_test_tmp', 999, 0, 'ARO');
+ $rename2_result = $this->gacl_api->edit_object_section($object_id, 'unit_test', 'unit_test', 999, 0, 'ARO');
+
+ if ($rename_result === TRUE AND $rename2_result === TRUE) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+
+ $message = 'edit_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ function del_object_section_aro() {
+ $result = $this->gacl_api->del_object_section($this->get_object_section_section_id_aro(), 'ARO');
+ $message = 'del_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ /** ARO **/
+
+ function get_object_id_aro() {
+ $result = $this->gacl_api->get_object_id('unit_test','john_doe', 'ARO');
+ $message = 'get_object_id failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_object2_id_aro() {
+ $result = $this->gacl_api->get_object_id('unit_test','jane_doe', 'ARO');
+ $message = 'get_object2_id failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_object_aro() {
+ $result = $this->gacl_api->add_object('unit_test', 'John Doe', 'john_doe', 999, 0, 'ARO');
+ $message = 'add_object failed';
+ $this->assert($result, $message);
+ }
+ function del_object_aro() {
+ $result = $this->gacl_api->del_object($this->get_object_id_aro(), 'ARO');
+ $message = 'del_object failed';
+ $this->assert($result, $message);
+ }
+
+ function add_object2_aro() {
+ $result = $this->gacl_api->add_object('unit_test', 'Jane Doe', 'jane_doe', 998, 0, 'ARO');
+ $message = 'add_object2 failed';
+ $this->assert($result, $message);
+ }
+ function del_object2_aro() {
+ $result = $this->gacl_api->del_object($this->get_object2_id_aro(), 'ARO');
+ $message = 'del_object2 failed';
+ $this->assert($result, $message);
+ }
+
+ /** AXO SECTION **/
+
+ function get_object_section_section_id_axo() {
+ $result = $this->gacl_api->get_object_section_section_id('unit_test', 'unit_test', 'AXO');
+ $message = 'get_object_section_section_id failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_object_section_axo() {
+ $result = $this->gacl_api->add_object_section('unit_test', 'unit_test', 999, 0, 'AXO');
+ $this->_aco_section_id = $result;
+ $message = 'add_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ function del_object_section_axo() {
+ $result = $this->gacl_api->del_object_section($this->get_object_section_section_id_axo(), 'AXO');
+ $message = 'del_object_section failed';
+ $this->assert($result, $message);
+ }
+
+ /** AXO **/
+
+ function get_object_id_axo() {
+ $result = $this->gacl_api->get_object_id('unit_test','object_1', 'AXO');
+ $message = 'get_object_id failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_object_axo() {
+ $result = $this->gacl_api->add_object('unit_test', 'Object 1', 'object_1', 999, 0, 'AXO');
+ $message = 'add_object failed';
+ $this->assert($result, $message);
+ }
+
+ function del_object_axo() {
+ $result = $this->gacl_api->del_object($this->get_object_id_axo(), 'AXO');
+ $message = 'del_object failed';
+ $this->assert($result, $message);
+ }
+
+ /** ARO GROUP **/
+
+ function get_group_id_parent_aro() {
+ $result = $this->gacl_api->get_group_id(NULL, 'ARO Group 1', 'ARO');
+ $message = 'get_group_id_parent_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_id_child_aro() {
+ $result = $this->gacl_api->get_group_id(NULL, 'ARO Group 2', 'ARO');
+ $message = 'get_group_id_child_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_parent_id_aro() {
+ $parent_id = $this->gacl_api->get_group_parent_id($this->get_group_id_child_aro(), 'ARO');
+ //Make sure it matches with the actual parent.
+ if ($parent_id === $this->get_group_id_parent_aro() ) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'get_group_parent_id_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_data_aro() {
+ list($id, $parent_id, $value, $name, $lft, $rgt) = $this->gacl_api->get_group_data($this->get_group_id_parent_aro(), 'ARO');
+ //Check all values in the resulting array.
+ if ( $id > 0 AND $parent_id >= 0 AND strlen($name) > 0 AND $lft >= 1 AND $rgt > 1) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'get_group_data_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_parent_group_objects_aro() {
+ $group_objects = $this->gacl_api->get_group_objects($this->get_group_id_parent_aro(), 'ARO');
+ if (count($group_objects, COUNT_RECURSIVE) == 2 AND $group_objects['unit_test'][0] == 'john_doe') {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'get_parent_group_objects_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_parent_group_objects_recurse_aro() {
+ $group_objects = $this->gacl_api->get_group_objects($this->get_group_id_parent_aro(), 'ARO', 'RECURSE');
+
+ switch (TRUE) {
+ case count($group_objects) != 1:
+ case !isset($group_objects['unit_test']):
+ case count($group_objects['unit_test']) != 2:
+ case !in_array('john_doe', $group_objects['unit_test']):
+ case !in_array('jane_doe', $group_objects['unit_test']):
+ $result = FALSE;
+ break;
+ default:
+ $result = TRUE;
+ }
+
+ $message = 'get_parent_group_objects_recurse_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_group_parent_aro() {
+ $result = $this->gacl_api->add_group('group_1', 'ARO Group 1', 0, 'ARO');
+ $message = 'add_group_parent_aro failed';
+ $this->assert($result, $message);
+ }
+
+ function edit_group_parent_aro() {
+ $group_id = $this->get_group_id_parent_aro();
+
+ $first_rename = $this->gacl_api->edit_group($group_id, 'group_1_tmp', 'ARO Group 1 - tmp', 0, 'ARO');
+ $second_rename = $this->gacl_api->edit_group($group_id,'group_1', 'ARO Group 1', 0, 'ARO');
+ $reparent_to_self = $this->gacl_api->edit_group($group_id,'group_1', 'ARO Group 1', $group_id, 'ARO');
+
+ if ($first_rename === TRUE AND $second_rename === TRUE AND $reparent_to_self === FALSE) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'edit_group_parent_aro failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_parent_reparent_aro() {
+ $this->add_group_parent_aro();
+ $this->add_group_child_aro();
+ $this->add_parent_group_object_aro();
+ $this->add_child_group_object_aro();
+
+ $result = $this->gacl_api->del_group($this->get_group_id_parent_aro(), TRUE, 'ARO');
+
+ $this->del_child_group_object_aro();
+ $this->del_group_child_aro();
+
+ $message = 'del_group_parent_no_reparent_aro failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_parent_no_reparent_aro() {
+ $this->add_group_parent_aro();
+ $this->add_group_child_aro();
+ $this->add_parent_group_object_aro();
+ $this->add_child_group_object_aro();
+
+ $result = $this->gacl_api->del_group($this->get_group_id_parent_aro(), FALSE, 'ARO');
+
+ $message = 'del_group_parent_reparent_aro failed';
+ $this->assert($result, $message);
+ }
+
+
+ function del_group_parent_aro() {
+ $result = $this->gacl_api->del_group($this->get_group_id_parent_aro(), TRUE, 'ARO');
+ $message = 'del_group_parent_aro failed';
+ $this->assert($result, $message);
+ }
+
+ function add_group_child_aro() {
+ $result = $this->gacl_api->add_group('group_2', 'ARO Group 2', $this->get_group_id_parent_aro(), 'ARO');
+ $message = 'add_group_child failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_child_aro() {
+ $result = $this->gacl_api->del_group($this->get_group_id_child_aro(), TRUE, 'ARO');
+ $message = 'del_group failed';
+ $this->assert($result, $message);
+ }
+
+ function add_parent_group_object_aro() {
+ $result = $this->gacl_api->add_group_object($this->get_group_id_parent_aro(), 'unit_test', 'john_doe', 'ARO');
+ $message = 'add_parent_group_object failed';
+ $this->assert($result, $message);
+ }
+ function del_parent_group_object_aro() {
+ $result = $this->gacl_api->del_group_object($this->get_group_id_parent_aro(), 'unit_test', 'john_doe', 'ARO');
+ $message = 'del_group_object failed';
+ $this->assert($result, $message);
+ }
+
+ function add_child_group_object_aro() {
+ $result = $this->gacl_api->add_group_object($this->get_group_id_child_aro(), 'unit_test', 'jane_doe', 'ARO');
+ $message = 'add_child_group_object failed';
+ $this->assert($result, $message);
+ }
+ function del_child_group_object_aro() {
+ $result = $this->gacl_api->del_group_object($this->get_group_id_child_aro(), 'unit_test', 'jane_doe', 'ARO');
+ $message = 'del_child_group_object failed';
+ $this->assert($result, $message);
+ }
+
+ /** AXO GROUP **/
+
+ function get_group_id_parent_axo() {
+ $result = $this->gacl_api->get_group_id(NULL, 'AXO Group 1', 'AXO');
+ $message = 'get_group_id_parent_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_id_child_axo() {
+ $result = $this->gacl_api->get_group_id(NULL, 'AXO Group 2', 'AXO');
+ $message = 'get_group_id_child_axo failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_parent_id_axo() {
+ $parent_id = $this->gacl_api->get_group_parent_id($this->get_group_id_child_axo(), 'AXO');
+ //Make sure it matches with the actual parent.
+ if ($parent_id === $this->get_group_id_parent_axo() ) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'get_group_parent_id_aro failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function get_group_data_axo() {
+ list($id, $parent_id, $value, $name, $lft, $rgt) = $this->gacl_api->get_group_data($this->get_group_id_parent_axo(), 'AXO');
+ //Check all values in the resulting array.
+ if ( $id > 0 AND $parent_id >= 0 AND strlen($name) > 0 AND $lft >= 1 AND $rgt > 1) {
+ $result = TRUE;
+ } else {
+ $result = FALSE;
+ }
+ $message = 'get_group_data_axo failed';
+ $this->assert($result, $message);
+
+ return $result;
+ }
+
+ function add_group_parent_axo() {
+ $result = $this->gacl_api->add_group('group_1', 'AXO Group 1', 0, 'AXO');
+ $message = 'add_group failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_parent_axo() {
+ $result = $this->gacl_api->del_group($this->get_group_id_parent_axo(), TRUE, 'AXO');
+ $message = 'del_group failed';
+ $this->assert($result, $message);
+ }
+
+ function add_group_child_axo() {
+ $result = $this->gacl_api->add_group('group_2', 'AXO Group 2', $this->get_group_id_parent_axo(), 'AXO');
+ $message = 'add_group failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_child_axo() {
+ $result = $this->gacl_api->del_group($this->get_group_id_child_axo(), TRUE, 'AXO');
+ $message = 'del_group failed';
+ $this->assert($result, $message);
+ }
+
+ function add_group_object_axo() {
+ $result = $this->gacl_api->add_group_object($this->get_group_id_parent_axo(), 'unit_test', 'object_1', 'AXO');
+ $message = 'add_group_object failed';
+ $this->assert($result, $message);
+ }
+
+ function del_group_object_axo() {
+ $result = $this->gacl_api->del_group_object($this->get_group_id_parent_axo(), 'unit_test', 'object_1', 'AXO');
+ $message = 'del_group_object failed';
+ $this->assert($result, $message);
+ }
+}
+
+// initialise test suite
+$suite = new gacl_test_suite;
+
+//This comes in handy.
+//$suite->gacl_api->db->debug=TRUE;
+
+// general
+$suite->addTest(new phpgacl_api_test('get_version'));
+$suite->addTest(new phpgacl_api_test('get_schema_version'));
+
+$suite->addTest(new phpgacl_api_test('count_all'));
+
+// build structure
+$suite->addTest(new phpgacl_api_test('add_object_section_aco'));
+$suite->addTest(new phpgacl_api_test('get_object_section_section_id_aco'));
+$suite->addTest(new phpgacl_api_test('add_object_aco'));
+$suite->addTest(new phpgacl_api_test('get_object_id_aco'));
+
+$suite->addTest(new phpgacl_api_test('add_object_section_aro'));
+$suite->addTest(new phpgacl_api_test('get_object_section_section_id_aco'));
+$suite->addTest(new phpgacl_api_test('add_object_aro'));
+//Test the below with ACLs as well... I haven't gotten around to that just yet.
+$suite->addTest(new phpgacl_api_test('edit_object_section_aro'));
+$suite->addTest(new phpgacl_api_test('get_object_id_aro'));
+$suite->addTest(new phpgacl_api_test('add_object2_aro'));
+$suite->addTest(new phpgacl_api_test('get_object2_id_aro'));
+
+$suite->addTest(new phpgacl_api_test('add_object_section_axo'));
+$suite->addTest(new phpgacl_api_test('get_object_section_section_id_axo'));
+$suite->addTest(new phpgacl_api_test('add_object_axo'));
+$suite->addTest(new phpgacl_api_test('get_object_id_axo'));
+
+$suite->addTest(new phpgacl_api_test('add_group_parent_aro'));
+$suite->addTest(new phpgacl_api_test('edit_group_parent_aro'));
+$suite->addTest(new phpgacl_api_test('get_group_id_parent_aro'));
+$suite->addTest(new phpgacl_api_test('get_group_data_aro'));
+$suite->addTest(new phpgacl_api_test('add_group_child_aro'));
+$suite->addTest(new phpgacl_api_test('get_group_id_child_aro'));
+$suite->addTest(new phpgacl_api_test('get_group_parent_id_aro'));
+
+$suite->addTest(new phpgacl_api_test('add_parent_group_object_aro'));
+//Try adding twice. Both times should return true.
+$suite->addTest(new phpgacl_api_test('add_parent_group_object_aro'));
+$suite->addTest(new phpgacl_api_test('add_child_group_object_aro'));
+
+$suite->addTest(new phpgacl_api_test('get_parent_group_objects_aro'));
+$suite->addTest(new phpgacl_api_test('get_parent_group_objects_recurse_aro'));
+
+
+$suite->addTest(new phpgacl_api_test('add_group_parent_axo'));
+$suite->addTest(new phpgacl_api_test('get_group_id_parent_axo'));
+$suite->addTest(new phpgacl_api_test('get_group_data_axo'));
+$suite->addTest(new phpgacl_api_test('add_group_child_axo'));
+$suite->addTest(new phpgacl_api_test('get_group_id_child_axo'));
+$suite->addTest(new phpgacl_api_test('add_group_object_axo'));
+$suite->addTest(new phpgacl_api_test('get_group_parent_id_axo'));
+
+
+// clean up...
+$suite->addTest(new phpgacl_api_test('del_parent_group_object_aro'));
+$suite->addTest(new phpgacl_api_test('del_child_group_object_aro'));
+$suite->addTest(new phpgacl_api_test('del_group_child_aro'));
+$suite->addTest(new phpgacl_api_test('del_group_parent_aro'));
+
+$suite->addTest(new phpgacl_api_test('del_group_object_axo'));
+$suite->addTest(new phpgacl_api_test('del_group_child_axo'));
+$suite->addTest(new phpgacl_api_test('del_group_parent_axo'));
+
+$suite->addTest(new phpgacl_api_test('del_object_aco'));
+$suite->addTest(new phpgacl_api_test('del_object_section_aco'));
+
+//Test group reparenting - Order of this test is important.
+$suite->addTest(new phpgacl_api_test('del_group_parent_no_reparent_aro'));
+$suite->addTest(new phpgacl_api_test('del_group_parent_reparent_aro'));
+
+$suite->addTest(new phpgacl_api_test('del_object_aro'));
+$suite->addTest(new phpgacl_api_test('del_object2_aro'));
+$suite->addTest(new phpgacl_api_test('del_object_section_aro'));
+
+$suite->addTest(new phpgacl_api_test('del_object_axo'));
+$suite->addTest(new phpgacl_api_test('del_object_section_axo'));
+
+// run tests
+echo '<p>Running API tests... ';
+$suite->run($result);
+echo '<b>Done</b></p>';
+
+unset ($suite);
+
+// done.
+
+?> \ No newline at end of file
diff --git a/html/templates/admin.tpl b/html/templates/admin.tpl
new file mode 100644
index 0000000..daf7cb5
--- /dev/null
+++ b/html/templates/admin.tpl
@@ -0,0 +1,27 @@
+{include file="header.tpl" title="GIMLI - Administration Page"}
+Admin-y page here.
+List of administrative tasks:
+<hr>
+<table>
+<tr><td><a href="admin/create_user.php">Create a User</a></td></tr>
+<tr><td><a href="admin/edit_user.php">Edit a User</a></td></tr>
+<tr><td><a href="admin/delete_user.php">Delete a User</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/create_usergroup.php">Create a UserGroup</a></td></tr>
+<tr><td><a href="admin/edit_usergroup.php">Edit a UserGroup</a></td></tr>
+<tr><td><a href="admin/delete_usergroup.php">Delete a UserGroup</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/add_permission.php">Add Permission</a></td></tr>
+<tr><td><a href="admin/edit_permission.php">Edit Permission</a></td></tr>
+<tr><td><a href="admin/delete_permission.php">Delete Permission</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/add_client.php">Add Client Manually</a></td></tr>
+<tr><td><a href="admin/edit_client.php">Edit Clients</a></td></tr>
+<tr><td><a href="admin/delete_client.php">Delete Client from GIMLI</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="create_clientgroup.php">Create a ClientGroup</a></td></tr>
+<tr><td><a href="edit_clientgroup.php">Edit a ClientGroup</a></td></tr>
+<tr><td><a href="delte_clientgroup.php">Delete a ClientGroup</a></td></tr>
+</table>
+<hr>
+Maybe some Certificate Authority tasks?
diff --git a/html/templates/admin/add_client.tpl b/html/templates/admin/add_client.tpl
new file mode 100644
index 0000000..39f2bf0
--- /dev/null
+++ b/html/templates/admin/add_client.tpl
@@ -0,0 +1,51 @@
+{include file="header.tpl" title="GIMLI - Admin - Add a Client"}
+<h2>Add a client:</h2>
+<form id="form1" name="form1" method="post" action="">
+ <table width="733" border="1">
+ <tr>
+ <td width="75%"><label>
+ Hostname:
+ <input name="hostname" type="text" id="hostname" />
+ </label>
+ <p>
+ <label>MAC:
+ <input name="mac" type="text" id="mac" maxlength="17" />
+ </label>
+ </p>
+ <p>
+ <label>IP:
+ <input name="ip" type="text" id="ip" maxlength="15" />
+ </label>
+ </p>
+ <p>
+ <label>Gentoo Profile Name (optional)
+ <input name="profile" type="text" id="profile" />
+ </label>
+ </p>
+ <p>
+ <label>Distribution (optional)
+ <input name="distribution" type="text" id="distribution" maxlength="50" />
+ </label>
+ </p>
+ <p>
+ <label>Administrator (optional)
+ <input name="administrator" type="text" id="administrator" maxlength="50" />
+ </label>
+ </p>
+ <p>
+ <label>Status:
+ <input name="status" type="text" id="status" maxlength="100" />
+ </label>
+ </p>
+ </td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ {html_options values=$ids output=$groupnames selected="1"}
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <label><br />
+ </label>
+ <p><input type="submit" name="submit" value="Add Client"></p>
+</form>
diff --git a/html/templates/admin/add_permission.tpl b/html/templates/admin/add_permission.tpl
new file mode 100644
index 0000000..5338deb
--- /dev/null
+++ b/html/templates/admin/add_permission.tpl
@@ -0,0 +1,27 @@
+{include file="header.tpl" title="GIMLI - Admin - Add a Permission"}
+<h2>Add a permission:</h2>
+<form name="form7" method="post" action="">
+ <p>Add Permission:</p>
+ <p>Name:
+ <input name="permname" type="text" id="permname">
+</p>
+ <p>Description:
+ <input name="permdesc" type="text" id="permdesc">
+</p>
+ <p>Built-in Abilities/Scripts: These currently do NOTHING</p>
+ <p>
+ <input name="scripts" type="checkbox" id="scripts" value="update_gentoo">
+ Gentoo update</p>
+ <p>
+ <input type="scripts" name="checkbox" value="update_debian">
+ Debian update</p>
+ <p>
+ <input type="scripts" name="checkbox" value="upgrade_debian">
+Debian upgrade </p>
+ <p>
+ <input type="scripts" name="checkbox" value="checkbox">
+Gentoo emerge</p>
+ <p>
+ <input type="submit" name="Submit" value="Add Permission">
+ </p>
+</form>
diff --git a/html/templates/admin/assign_permissions.tpl b/html/templates/admin/assign_permissions.tpl
new file mode 100644
index 0000000..b7dcdd1
--- /dev/null
+++ b/html/templates/admin/assign_permissions.tpl
@@ -0,0 +1,74 @@
+{include file="header.tpl" title="GIMLI - Admin - Assign Permissions"}
+<form name="form1" method="post" action="">
+ <p>Assign Permissions:</p>
+ <p> Select a user or group to add/remove permissions to a machine or group of machines: </p>
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col" width="5%">Select</th>
+ <th scope="col" width="80%">User/UserGroup Name </th>
+ </tr>
+ {foreach from=$usergroups name=ugroup item=item key=id}
+ <tr bgcolor="#00FFFF">
+ <td><input type="radio" name="id" value="g_{$id}"></td>
+ <td>Group: {$item}</td>
+ </tr>
+ {section name=users loop=$users}
+ {foreach from=$users[users][2] name=in_groups item=in_group}
+ {if $in_group eq $id}
+ <tr bgcolor="#008800">
+ <td><input type="radio" name="id" value="u_{$users[users][0]}"></td>
+ <td>USER: {$users[users][1]}</td>
+ </tr>
+ {/if}
+ {/foreach}
+ {/section}
+ {/foreach}
+
+ <tr>
+ <td>Sample Group Na</td>
+ <td><input name="SubmitAdd" type="submit" id="SubmitAdd" value="Add"></td>
+ <td><input name="SubmitRemove" type="submit" id="SubmitRemove" value="Remove"></td>
+ </tr>
+ <tr>
+ <td> |---Sample User Name </td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+</form>
+<hr>
+<form name="form2" method="post" action="">
+ <p>Assign Permissions to User/Group: ________ on a specified machine or machine group. </p>
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col">Permission</th>
+ <th scope="col">&nbsp;</th>
+ <th scope="col">Machine</th>
+ </tr>
+ <tr>
+ <td rowspan="2"><p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+ Permission1</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission2</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission3</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission4</p>
+ <p></p></td>
+ <td> --&gt; to Machine/MachineGroup : --&gt; </td>
+ <td rowspan="2"><select name="machine" size="10" id="machine">
+ </select></td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+ <p align="right">
+ <input type="submit" name="Submit" value="Add Permissions">
+</p>
+</form>
+<hr>
diff --git a/html/templates/admin/create_clientgroup.tpl b/html/templates/admin/create_clientgroup.tpl
new file mode 100644
index 0000000..cb97d7f
--- /dev/null
+++ b/html/templates/admin/create_clientgroup.tpl
@@ -0,0 +1,15 @@
+{include file="header.tpl" title="GIMLI - Admin - Create a ClientGroup"}
+<h2>Create a ClientGroup:</h2>
+<form name="form3" method="post" action="">
+ <p>Add Client Group:</p>
+ <p>
+ <label>Name:
+ <input name="groupname" type="text" id="groupname">
+ </label>
+ as subgroup of
+ <select name="parentgroup" id="parentgroup">
+{html_options values=$ids output=$groupnames selected="1"}
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+</form>
diff --git a/html/templates/admin/create_user.tpl b/html/templates/admin/create_user.tpl
new file mode 100644
index 0000000..219023d
--- /dev/null
+++ b/html/templates/admin/create_user.tpl
@@ -0,0 +1,38 @@
+{include file="header.tpl" title="GIMLI - Admin - Create a User"}
+<h2>Create a user:</h2>
+<form id="form1" name="form1" method="post" action="">
+ <table width="733" border="1">
+ <tr>
+ <td width="75%"><label>
+User name:
+ <input name="username" type="text" id="username" />
+ </label>
+ <p>
+ <label>Password:
+ <input name="passwd" type="password" id="passwd" />
+ </label>
+ <label>confirm
+ <input name="passwd2" type="password" id="passwd2" />
+ </label>
+ </p>
+ <p>
+ <label>Real name:
+ <input name="realname" type="text" id="realname" />
+ </label>
+ </p>
+ <p>
+ <label>Comment
+ <input name="comment" type="text" id="comment" />
+ </label>
+ </p></td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ {html_options values=$ids output=$groupnames selected="1"}
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <label><br />
+ </label>
+ <p><input type="submit" name="submit" value="Add User"></p>
+</form>
diff --git a/html/templates/admin/create_usergroup.tpl b/html/templates/admin/create_usergroup.tpl
new file mode 100644
index 0000000..26f99b9
--- /dev/null
+++ b/html/templates/admin/create_usergroup.tpl
@@ -0,0 +1,15 @@
+{include file="header.tpl" title="GIMLI - Admin - Create a UserGroup"}
+<h2>Create a UserGroup:</h2>
+<form name="form3" method="post" action="">
+ <p>Add UserGroup:</p>
+ <p>
+ <label>Name:
+ <input name="groupname" type="text" id="groupname">
+ </label>
+ as subgroup of
+ <select name="parentgroup" id="parentgroup">
+{html_options values=$ids output=$groupnames selected="1"}
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+</form>
diff --git a/html/templates/admin/delete_client.tpl b/html/templates/admin/delete_client.tpl
new file mode 100644
index 0000000..33a09cf
--- /dev/null
+++ b/html/templates/admin/delete_client.tpl
@@ -0,0 +1,23 @@
+{include file="header.tpl" title="GIMLI - Admin - DELETE a Client"}
+DELETE a client:
+<form id="form1" name="form1" method="post" action="#">
+{if $clients}
+ <table border="2" cellpadding="4" bgcolor="#FF0000">
+ <tr>
+ <td><b>DELETE</b></td><td>Client Hostname</td><td>Client IP</td><td>Profile</td><td>Distribution</td><td>Status</td>
+ </tr>
+ {section name=clients loop=$clients}
+ <tr>
+ <td><input type="radio" name="delclient" value="{$clients[clients].client_id}"></td>
+ <td><b>{$clients[clients].hostname}</b></td>
+ <td><b>{$clients[clients].ip}</b></td>
+ <td><b>{$clients[clients].profile}</b></td>
+ <td><b>{$clients[clients].distribution}</b></td>
+ <td><b>{$clients[clients].status}</b></td>
+ </tr>
+ {/section}
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected Client">
+{/if}
+</form>
diff --git a/html/templates/admin/delete_clientgroup.tpl b/html/templates/admin/delete_clientgroup.tpl
new file mode 100644
index 0000000..9131870
--- /dev/null
+++ b/html/templates/admin/delete_clientgroup.tpl
@@ -0,0 +1,22 @@
+{include file="header.tpl" title="GIMLI - Admin - DELETE a ClientGroup"}
+DELETE a ClientGroup (subgroups will be automatically reparented):
+<form id="form1" name="form1" method="post" action="#">
+{if $clientgroups}
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ {foreach from=$clientgroups item=cgroup key=key}
+ <tr>
+ <td><div align="center">
+ <input name="delgroup" type="radio" value="{$key}">
+ </div></td>
+ <td>{$cgroup}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected ClientGroup">
+{/if}
+</form>
diff --git a/html/templates/admin/delete_permission.tpl b/html/templates/admin/delete_permission.tpl
new file mode 100644
index 0000000..cc20621
--- /dev/null
+++ b/html/templates/admin/delete_permission.tpl
@@ -0,0 +1,26 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a Permission"}
+<h2>Edit a permission:</h2>
+<form name="form7" method="post" action="">
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Permission Name </th>
+ <th scope="col">Permission Description </th>
+ </tr>
+ {section name=perms loop=$permissions}
+ <tr bgcolor="#FF0000">
+ <td><div align="center"><input type="radio" name="delperm" value="{$permissions[perms][0]}"></div></td>
+ <td>{$permissions[perms][0]}</td>
+ <td>{$permissions[perms][1]}</td>
+ <td>{$permissions[perms][2]}</td>
+ </tr>
+ {/section}
+ </table>
+ <p>
+ <input name="iamsure" type="checkbox" id="iamsure" value="yes">
+ I am <strong>sure</strong> I want to do this!</p>
+ <p align="left">
+ <input name="delsubmit" type="submit" id="delsubmit" value="DELETE">
+ </p>
+ <p>&nbsp; </p>
+</form>
diff --git a/html/templates/admin/delete_user.tpl b/html/templates/admin/delete_user.tpl
new file mode 100644
index 0000000..2f4182c
--- /dev/null
+++ b/html/templates/admin/delete_user.tpl
@@ -0,0 +1,21 @@
+{include file="header.tpl" title="GIMLI - Admin - DELETE a User"}
+DELETE a user:
+<form id="form1" name="form1" method="post" action="#">
+{if $users}
+ <table border="2" cellpadding="4" bgcolor="#FF0000">
+ <tr>
+ <td><b>DELETE</b></td><td><b>User Name</b></td><td><b>User Description</b></td><td><b>Creator</b></td>
+ </tr>
+ {section name=users loop=$users}
+ <tr>
+ <td><input type="radio" name="deluser" value="{$users[users][0]}"></td>
+ <td><b>{$users[users][0]}</b></td>
+ <td><b>{$users[users][1]}</b></td>
+ <td><b>{$users[users][2]}</b></td>
+ </tr>
+ {/section}
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected User">
+{/if}
+</form>
diff --git a/html/templates/admin/delete_usergroup.tpl b/html/templates/admin/delete_usergroup.tpl
new file mode 100644
index 0000000..13ed884
--- /dev/null
+++ b/html/templates/admin/delete_usergroup.tpl
@@ -0,0 +1,22 @@
+{include file="header.tpl" title="GIMLI - Admin - DELETE a UserGroup"}
+DELETE a UserGroup (subgroups will be automatically reparented):
+<form id="form1" name="form1" method="post" action="#">
+{if $usergroups}
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ {foreach from=$usergroups item=ugroup key=key}
+ <tr>
+ <td><div align="center">
+ <input name="delgroup" type="radio" value="{$key}">
+ </div></td>
+ <td>{$ugroup}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected UserGroup">
+{/if}
+</form>
diff --git a/html/templates/admin/edit_client.tpl b/html/templates/admin/edit_client.tpl
new file mode 100644
index 0000000..f77fb6c
--- /dev/null
+++ b/html/templates/admin/edit_client.tpl
@@ -0,0 +1,70 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a Client"}
+Edit a Client:
+<form id="form1" name="form1" method="post" action="#">
+{if $clients}
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>Client Hostname</td><td>Client IP</td><td>Profile</td><td>Distribution</td><td>Status</td>
+ </tr>
+ {section name=clients loop=$clients}
+ <tr>
+ <td><input type="radio" name="editclient" value="{$clients[clients].client_id}"></td>
+ <td>{$clients[clients].hostname}</td>
+ <td>{$clients[clients].ip}</td>
+ <td>{$clients[clients].profile}</td>
+ <td>{$clients[clients].distribution}</td>
+ <td>{$clients[clients].status}</td>
+ </tr>
+ {/section}
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected Client">
+{/if}
+{if $cdata}
+ <table width="733" border="1">
+ <tr>
+ <td width="75%">
+ <input type="hidden" name="client_id" value="{$cdata.client_id}" />
+ <label>Hostname:
+ <input name="hostname" type="text" id="hostname" value="{$cdata.hostname}" />
+ </label>
+ <p>
+ <label>MAC:
+ <input name="mac" type="text" id="mac" maxlength="17" value="{$cdata.mac}" />
+ </label>
+ </p>
+ <p>
+ <label>IP:
+ <input name="ip" type="text" id="ip" maxlength="15" value="{$cdata.ip}" />
+ </label>
+ </p>
+ <p>
+ <label>Gentoo Profile Name (optional)
+ <input name="profile" type="text" id="profile" value="{$cdata.profile}" />
+ </label>
+ </p>
+ <p>
+ <label>Distribution (optional)
+ <input name="distribution" type="text" id="distribution" maxlength="50" value="{$cdata.distribution}" />
+ </label>
+ </p>
+ <p>
+ <label>Administrator (optional)
+ <input name="administrator" type="text" id="administrator" maxlength="50" value="{$cdata.administrator}" />
+ </label>
+ </p>
+ <p>
+ <label>Status:
+ <input name="status" type="text" id="status" maxlength="100" value="{$cdata.status}" />
+ </label>
+ </p>
+ </td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ {html_options values=$ids output=$groupnames selected="1"}
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+{/if}
+</form>
diff --git a/html/templates/admin/edit_clientgroup.tpl b/html/templates/admin/edit_clientgroup.tpl
new file mode 100644
index 0000000..e0379bb
--- /dev/null
+++ b/html/templates/admin/edit_clientgroup.tpl
@@ -0,0 +1,33 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a ClientGroup"}
+<h2>Edit a ClientGroup: {$editgroupdata[3]}</h2>
+<form name="form4" method="post" action="">
+{if $editgroup}
+ <input type="hidden" name="groupid" value="{$editgroup}">
+ <p>Group name:
+ <input name="groupname" type="text" id="groupname" value="{$editgroupdata[3]}">
+ is subgroup of
+ <select name="parentgroup" id="parentgroup">
+ {html_options values=$ids output=$groupnames selected="$editgroupdata[1]"}
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+{else}
+<table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ {foreach from=$clientgroups item=cgroup key=key}
+ <tr>
+ <td><div align="center">
+ <input name="editgroup" type="radio" value="{$key}">
+ </div></td>
+ <td>{$cgroup}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <p>
+ <input type="submit" name="Submit" value="EDIT">
+ </p>
+{/if}
+</form>
diff --git a/html/templates/admin/edit_permission.tpl b/html/templates/admin/edit_permission.tpl
new file mode 100644
index 0000000..22fba1b
--- /dev/null
+++ b/html/templates/admin/edit_permission.tpl
@@ -0,0 +1,41 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a Permission"}
+<h2>Edit a permission:</h2>
+<form name="form7" method="post" action="">
+{if $permissions}
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Permission Name</th>
+ <th scope="col">Permission Description</th>
+ <th scope="col">Creator</th>
+ </tr>
+ {section name=perms loop=$permissions}
+ <tr>
+ <td><input type="radio" name="editperm" value="{$permissions[perms][0]}"></td>
+ <input type="hidden" name="{$permissions[perms][0]}_desc" value="{$permissions[perms][1]}">
+ <td>{$permissions[perms][0]}</td>
+ <td>{$permissions[perms][1]}</td>
+ <td>{$permissions[perms][2]}</td>
+ </tr>
+ {/section}
+ </table>
+ <p>
+ <p align="left">
+ <input name="submit" type="submit" id="submit" value="Edit this Permission">
+ </p>
+ <p>&nbsp; </p>
+{/if}
+{if $permname}
+ <label>Permission Name: {$permname}
+ <input type="text" name="permname" value="{$permname}" disabled>
+ </label>
+ <p>
+ <label>Description
+ <input name="permdesc" type="text" id="permdesc" value="{$permdesc}" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+{/if}
+</form>
diff --git a/html/templates/admin/edit_user.tpl b/html/templates/admin/edit_user.tpl
new file mode 100644
index 0000000..19e1fda
--- /dev/null
+++ b/html/templates/admin/edit_user.tpl
@@ -0,0 +1,35 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a User"}
+Edit a User:
+<form id="form1" name="form1" method="post" action="#">
+{if $users}
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>User Name</td><td>User Description</td><td>Creator</td>
+ </tr>
+ {section name=users loop=$users}
+ <tr>
+ <td><input type="radio" name="edituser" value="{$users[users][0]}"></td>
+ <input type="hidden" name="{$users[users][0]}_desc" value="{$users[users][1]}">
+
+ <td>{$users[users][0]}</td>
+ <td>{$users[users][1]}</td>
+ <td>{$users[users][2]}</td>
+ </tr>
+ {/section}
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected User">
+{/if}
+{if $username}
+ <label>User Name: {$username}
+ <input type="hidden" name="username" value="{$username}">
+ </label>
+ <p>
+ <label>Description
+ <input name="userdesc" type="text" id="userdesc" value="{$userdesc}" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+{/if}
+</form>
diff --git a/html/templates/admin/edit_usergroup.tpl b/html/templates/admin/edit_usergroup.tpl
new file mode 100644
index 0000000..4a5faf8
--- /dev/null
+++ b/html/templates/admin/edit_usergroup.tpl
@@ -0,0 +1,33 @@
+{include file="header.tpl" title="GIMLI - Admin - Edit a UserGroup"}
+<h2>Edit a UserGroup: {$editgroupdata[3]}</h2>
+<form name="form4" method="post" action="">
+{if $editgroup}
+ <input type="hidden" name="groupid" value="{$editgroup}">
+ <p>Group name:
+ <input name="groupname" type="text" id="groupname" value="{$editgroupdata[3]}">
+ is subgroup of
+ <select name="parentgroup" id="parentgroup">
+ {html_options values=$ids output=$groupnames selected="$editgroupdata[1]"}
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+{else}
+<table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ {foreach from=$usergroups item=ugroup key=key}
+ <tr>
+ <td><div align="center">
+ <input name="editgroup" type="radio" value="{$key}">
+ </div></td>
+ <td>{$ugroup}</td>
+ </tr>
+ {/foreach}
+ </table>
+ <p>
+ <input type="submit" name="Submit" value="EDIT">
+ </p>
+{/if}
+</form>
diff --git a/html/templates/header.tpl b/html/templates/header.tpl
new file mode 100755
index 0000000..f641576
--- /dev/null
+++ b/html/templates/header.tpl
@@ -0,0 +1,21 @@
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>{$title|default:"GIMLI"}</title>
+<link rel="stylesheet" href="2col_leftNav.css" type="text/css" />
+</head>
+<body>
+<div id="masthead">
+<table><tr><td><a href="index.php"><img src="tux_large.png" alt="Linux Logo" height="60"></a></td><td>
+<h1 id="siteName"> Generic Interface for the Management of Linux Installations </h1></td></tr></table>
+<div id="globalNav" align="center">
+{section name=top_nav_bar loop=$topbar}
+ <a href="{$topbar[top_nav_bar].link}">{$topbar[top_nav_bar].name}</a> |
+{/section}
+
+</div>
+<!-- end masthead -->
+<hr>
+<div id="content">
+{if $status}
+<h3>{$status}</h3>
+{/if}
diff --git a/html/templates/index.tpl b/html/templates/index.tpl
new file mode 100755
index 0000000..b1efbc0
--- /dev/null
+++ b/html/templates/index.tpl
@@ -0,0 +1 @@
+{include file="header.tpl" title="GIMLI - Main Page"}
diff --git a/html/templates/leftbar.tpl b/html/templates/leftbar.tpl
new file mode 100644
index 0000000..d8afa57
--- /dev/null
+++ b/html/templates/leftbar.tpl
@@ -0,0 +1,43 @@
+</div>
+<div id="navBar">
+<div id="search">
+ <form action="#">
+ <label>search</label>
+ <input name="searchFor" type="text" size="10" />
+ <input name="goButton" type="button" value="go" />
+ </form>
+</div>
+<div id="sectionLinks">
+ <h3>{$left_section_header}</h3>
+ <ul>
+ {foreach item=leftitem from=$leftnav}
+ <li><a href="{$leftitem[0]}">{$leftitem[1]}</a></li>
+ {/foreach}
+ </ul>
+</div>
+<div class="relatedLinks">
+ <h3>Most Recently Used Clients</h3>
+ <ul>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ </ul>
+</div>
+<div class="relatedLinks">
+ <h3>Related Link Category</h3>
+ <ul>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ </ul>
+</div>
+</div>
+<!--end navbar -->
+</body>
+</html>
diff --git a/html/templates_c/%%05^059^0591EA96%%delete_client.tpl.php b/html/templates_c/%%05^059^0591EA96%%delete_client.tpl.php
new file mode 100644
index 0000000..81479f4
--- /dev/null
+++ b/html/templates_c/%%05^059^0591EA96%%delete_client.tpl.php
@@ -0,0 +1,58 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 23:02:15
+ compiled from admin/delete_client.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - DELETE a Client")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+DELETE a client:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['clients']): ?>
+ <table border="2" cellpadding="4" bgcolor="#FF0000">
+ <tr>
+ <td><b>DELETE</b></td><td>Client Hostname</td><td>Client IP</td><td>Profile</td><td>Distribution</td><td>Status</td>
+ </tr>
+ <?php unset($this->_sections['clients']);
+$this->_sections['clients']['name'] = 'clients';
+$this->_sections['clients']['loop'] = is_array($_loop=$this->_tpl_vars['clients']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['clients']['show'] = true;
+$this->_sections['clients']['max'] = $this->_sections['clients']['loop'];
+$this->_sections['clients']['step'] = 1;
+$this->_sections['clients']['start'] = $this->_sections['clients']['step'] > 0 ? 0 : $this->_sections['clients']['loop']-1;
+if ($this->_sections['clients']['show']) {
+ $this->_sections['clients']['total'] = $this->_sections['clients']['loop'];
+ if ($this->_sections['clients']['total'] == 0)
+ $this->_sections['clients']['show'] = false;
+} else
+ $this->_sections['clients']['total'] = 0;
+if ($this->_sections['clients']['show']):
+
+ for ($this->_sections['clients']['index'] = $this->_sections['clients']['start'], $this->_sections['clients']['iteration'] = 1;
+ $this->_sections['clients']['iteration'] <= $this->_sections['clients']['total'];
+ $this->_sections['clients']['index'] += $this->_sections['clients']['step'], $this->_sections['clients']['iteration']++):
+$this->_sections['clients']['rownum'] = $this->_sections['clients']['iteration'];
+$this->_sections['clients']['index_prev'] = $this->_sections['clients']['index'] - $this->_sections['clients']['step'];
+$this->_sections['clients']['index_next'] = $this->_sections['clients']['index'] + $this->_sections['clients']['step'];
+$this->_sections['clients']['first'] = ($this->_sections['clients']['iteration'] == 1);
+$this->_sections['clients']['last'] = ($this->_sections['clients']['iteration'] == $this->_sections['clients']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="delclient" value="<?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['client_id']; ?>
+"></td>
+ <td><b><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['hostname']; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['ip']; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['profile']; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['distribution']; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['status']; ?>
+</b></td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected Client">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%20^20E^20ED0D17%%delete_clientgroup.tpl.php b/html/templates_c/%%20^20E^20ED0D17%%delete_clientgroup.tpl.php
new file mode 100644
index 0000000..263eb68
--- /dev/null
+++ b/html/templates_c/%%20^20E^20ED0D17%%delete_clientgroup.tpl.php
@@ -0,0 +1,32 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 23:22:58
+ compiled from admin/delete_clientgroup.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - DELETE a ClientGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+DELETE a ClientGroup (subgroups will be automatically reparented):
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['clientgroups']): ?>
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ <?php $_from = $this->_tpl_vars['clientgroups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['cgroup']):
+?>
+ <tr>
+ <td><div align="center">
+ <input name="delgroup" type="radio" value="<?php echo $this->_tpl_vars['key']; ?>
+">
+ </div></td>
+ <td><?php echo $this->_tpl_vars['cgroup']; ?>
+</td>
+ </tr>
+ <?php endforeach; endif; unset($_from); ?>
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected ClientGroup">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%25^255^255963FB%%leftbar.tpl.php b/html/templates_c/%%25^255^255963FB%%leftbar.tpl.php
new file mode 100644
index 0000000..5a2e1c4
--- /dev/null
+++ b/html/templates_c/%%25^255^255963FB%%leftbar.tpl.php
@@ -0,0 +1,50 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 16:31:32
+ compiled from leftbar.tpl */ ?>
+</div>
+<div id="navBar">
+<div id="search">
+ <form action="#">
+ <label>search</label>
+ <input name="searchFor" type="text" size="10" />
+ <input name="goButton" type="button" value="go" />
+ </form>
+</div>
+<div id="sectionLinks">
+ <h3><?php echo $this->_tpl_vars['left_section_header']; ?>
+</h3>
+ <ul>
+ <?php $_from = $this->_tpl_vars['leftnav']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['leftitem']):
+?>
+ <li><a href="<?php echo $this->_tpl_vars['leftitem'][0]; ?>
+"><?php echo $this->_tpl_vars['leftitem'][1]; ?>
+</a></li>
+ <?php endforeach; endif; unset($_from); ?>
+ </ul>
+</div>
+<div class="relatedLinks">
+ <h3>Most Recently Used Clients</h3>
+ <ul>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ </ul>
+</div>
+<div class="relatedLinks">
+ <h3>Related Link Category</h3>
+ <ul>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ <li><a href="#">Related Link</a></li>
+ </ul>
+</div>
+</div>
+<!--end navbar -->
+</body>
+</html> \ No newline at end of file
diff --git a/html/templates_c/%%2D^2D5^2D54479D%%add_permission.tpl.php b/html/templates_c/%%2D^2D5^2D54479D%%add_permission.tpl.php
new file mode 100644
index 0000000..84cc1a1
--- /dev/null
+++ b/html/templates_c/%%2D^2D5^2D54479D%%add_permission.tpl.php
@@ -0,0 +1,33 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 17:12:05
+ compiled from admin/add_permission.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Add a Permission")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Add a permission:</h2>
+<form name="form7" method="post" action="">
+ <p>Add Permission:</p>
+ <p>Name:
+ <input name="permname" type="text" id="permname">
+</p>
+ <p>Description:
+ <input name="permdesc" type="text" id="permdesc">
+</p>
+ <p>Built-in Abilities/Scripts: These currently do NOTHING</p>
+ <p>
+ <input name="scripts" type="checkbox" id="scripts" value="update_gentoo">
+ Gentoo update</p>
+ <p>
+ <input type="scripts" name="checkbox" value="update_debian">
+ Debian update</p>
+ <p>
+ <input type="scripts" name="checkbox" value="upgrade_debian">
+Debian upgrade </p>
+ <p>
+ <input type="scripts" name="checkbox" value="checkbox">
+Gentoo emerge</p>
+ <p>
+ <input type="submit" name="Submit" value="Add Permission">
+ </p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%40^40A^40A26E7D%%assign_permissions.tpl.php b/html/templates_c/%%40^40A^40A26E7D%%assign_permissions.tpl.php
new file mode 100644
index 0000000..c70cc5f
--- /dev/null
+++ b/html/templates_c/%%40^40A^40A26E7D%%assign_permissions.tpl.php
@@ -0,0 +1,115 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-26 00:48:30
+ compiled from admin/assign_permissions.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Assign Permissions")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<form name="form1" method="post" action="">
+ <p>Assign Permissions:</p>
+ <p> Select a user or group to add/remove permissions to a machine or group of machines: </p>
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col" width="5%">Select</th>
+ <th scope="col" width="80%">User/UserGroup Name </th>
+ </tr>
+ <?php $_from = $this->_tpl_vars['usergroups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['ugroup'] = array('total' => count($_from), 'iteration' => 0);
+if ($this->_foreach['ugroup']['total'] > 0):
+ foreach ($_from as $this->_tpl_vars['id'] => $this->_tpl_vars['item']):
+ $this->_foreach['ugroup']['iteration']++;
+?>
+ <tr bgcolor="#00FFFF">
+ <td><input type="radio" name="id" value="g_<?php echo $this->_tpl_vars['id']; ?>
+"></td>
+ <td>Group: <?php echo $this->_tpl_vars['item']; ?>
+</td>
+ </tr>
+ <?php unset($this->_sections['users']);
+$this->_sections['users']['name'] = 'users';
+$this->_sections['users']['loop'] = is_array($_loop=$this->_tpl_vars['users']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['users']['show'] = true;
+$this->_sections['users']['max'] = $this->_sections['users']['loop'];
+$this->_sections['users']['step'] = 1;
+$this->_sections['users']['start'] = $this->_sections['users']['step'] > 0 ? 0 : $this->_sections['users']['loop']-1;
+if ($this->_sections['users']['show']) {
+ $this->_sections['users']['total'] = $this->_sections['users']['loop'];
+ if ($this->_sections['users']['total'] == 0)
+ $this->_sections['users']['show'] = false;
+} else
+ $this->_sections['users']['total'] = 0;
+if ($this->_sections['users']['show']):
+
+ for ($this->_sections['users']['index'] = $this->_sections['users']['start'], $this->_sections['users']['iteration'] = 1;
+ $this->_sections['users']['iteration'] <= $this->_sections['users']['total'];
+ $this->_sections['users']['index'] += $this->_sections['users']['step'], $this->_sections['users']['iteration']++):
+$this->_sections['users']['rownum'] = $this->_sections['users']['iteration'];
+$this->_sections['users']['index_prev'] = $this->_sections['users']['index'] - $this->_sections['users']['step'];
+$this->_sections['users']['index_next'] = $this->_sections['users']['index'] + $this->_sections['users']['step'];
+$this->_sections['users']['first'] = ($this->_sections['users']['iteration'] == 1);
+$this->_sections['users']['last'] = ($this->_sections['users']['iteration'] == $this->_sections['users']['total']);
+?>
+ <?php $_from = $this->_tpl_vars['users'][$this->_sections['users']['index']][2]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['in_groups'] = array('total' => count($_from), 'iteration' => 0);
+if ($this->_foreach['in_groups']['total'] > 0):
+ foreach ($_from as $this->_tpl_vars['in_group']):
+ $this->_foreach['in_groups']['iteration']++;
+?>
+ <?php if ($this->_tpl_vars['in_group'] == $this->_tpl_vars['id']): ?>
+ <tr bgcolor="#008800">
+ <td><input type="radio" name="id" value="u_<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+"></td>
+ <td>USER: <?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+</td>
+ </tr>
+ <?php endif; ?>
+ <?php endforeach; endif; unset($_from); ?>
+ <?php endfor; endif; ?>
+ <?php endforeach; endif; unset($_from); ?>
+
+ <tr>
+ <td>Sample Group Na</td>
+ <td><input name="SubmitAdd" type="submit" id="SubmitAdd" value="Add"></td>
+ <td><input name="SubmitRemove" type="submit" id="SubmitRemove" value="Remove"></td>
+ </tr>
+ <tr>
+ <td> |---Sample User Name </td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+</form>
+<hr>
+<form name="form2" method="post" action="">
+ <p>Assign Permissions to User/Group: ________ on a specified machine or machine group. </p>
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col">Permission</th>
+ <th scope="col">&nbsp;</th>
+ <th scope="col">Machine</th>
+ </tr>
+ <tr>
+ <td rowspan="2"><p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+ Permission1</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission2</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission3</p>
+ <p>
+ <input name="permisions" type="checkbox" id="permisions" value="perm">
+Permission4</p>
+ <p></p></td>
+ <td> --&gt; to Machine/MachineGroup : --&gt; </td>
+ <td rowspan="2"><select name="machine" size="10" id="machine">
+ </select></td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+ <p align="right">
+ <input type="submit" name="Submit" value="Add Permissions">
+</p>
+</form>
+<hr> \ No newline at end of file
diff --git a/html/templates_c/%%45^45E^45E480CD%%index.tpl.php b/html/templates_c/%%45^45E^45E480CD%%index.tpl.php
new file mode 100644
index 0000000..4ac39b4
--- /dev/null
+++ b/html/templates_c/%%45^45E^45E480CD%%index.tpl.php
@@ -0,0 +1,7 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-12 22:50:44
+ compiled from index.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Main Page")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?> \ No newline at end of file
diff --git a/html/templates_c/%%45^45E^45EE95AC%%edit_client.tpl.php b/html/templates_c/%%45^45E^45EE95AC%%edit_client.tpl.php
new file mode 100644
index 0000000..0507b29
--- /dev/null
+++ b/html/templates_c/%%45^45E^45EE95AC%%edit_client.tpl.php
@@ -0,0 +1,115 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 22:42:14
+ compiled from admin/edit_client.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/edit_client.tpl', 63, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a Client")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+Edit a Client:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['clients']): ?>
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>Client Hostname</td><td>Client IP</td><td>Profile</td><td>Distribution</td><td>Status</td>
+ </tr>
+ <?php unset($this->_sections['clients']);
+$this->_sections['clients']['name'] = 'clients';
+$this->_sections['clients']['loop'] = is_array($_loop=$this->_tpl_vars['clients']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['clients']['show'] = true;
+$this->_sections['clients']['max'] = $this->_sections['clients']['loop'];
+$this->_sections['clients']['step'] = 1;
+$this->_sections['clients']['start'] = $this->_sections['clients']['step'] > 0 ? 0 : $this->_sections['clients']['loop']-1;
+if ($this->_sections['clients']['show']) {
+ $this->_sections['clients']['total'] = $this->_sections['clients']['loop'];
+ if ($this->_sections['clients']['total'] == 0)
+ $this->_sections['clients']['show'] = false;
+} else
+ $this->_sections['clients']['total'] = 0;
+if ($this->_sections['clients']['show']):
+
+ for ($this->_sections['clients']['index'] = $this->_sections['clients']['start'], $this->_sections['clients']['iteration'] = 1;
+ $this->_sections['clients']['iteration'] <= $this->_sections['clients']['total'];
+ $this->_sections['clients']['index'] += $this->_sections['clients']['step'], $this->_sections['clients']['iteration']++):
+$this->_sections['clients']['rownum'] = $this->_sections['clients']['iteration'];
+$this->_sections['clients']['index_prev'] = $this->_sections['clients']['index'] - $this->_sections['clients']['step'];
+$this->_sections['clients']['index_next'] = $this->_sections['clients']['index'] + $this->_sections['clients']['step'];
+$this->_sections['clients']['first'] = ($this->_sections['clients']['iteration'] == 1);
+$this->_sections['clients']['last'] = ($this->_sections['clients']['iteration'] == $this->_sections['clients']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="editclient" value="<?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['client_id']; ?>
+"></td>
+ <td><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['hostname']; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['ip']; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['profile']; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['distribution']; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['clients'][$this->_sections['clients']['index']]['status']; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected Client">
+<?php endif; if ($this->_tpl_vars['cdata']): ?>
+ <table width="733" border="1">
+ <tr>
+ <td width="75%">
+ <input type="hidden" name="client_id" value="<?php echo $this->_tpl_vars['cdata']['client_id']; ?>
+" />
+ <label>Hostname:
+ <input name="hostname" type="text" id="hostname" value="<?php echo $this->_tpl_vars['cdata']['hostname']; ?>
+" />
+ </label>
+ <p>
+ <label>MAC:
+ <input name="mac" type="text" id="mac" maxlength="17" value="<?php echo $this->_tpl_vars['cdata']['mac']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <label>IP:
+ <input name="ip" type="text" id="ip" maxlength="15" value="<?php echo $this->_tpl_vars['cdata']['ip']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <label>Gentoo Profile Name (optional)
+ <input name="profile" type="text" id="profile" value="<?php echo $this->_tpl_vars['cdata']['profile']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <label>Distribution (optional)
+ <input name="distribution" type="text" id="distribution" maxlength="50" value="<?php echo $this->_tpl_vars['cdata']['distribution']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <label>Administrator (optional)
+ <input name="administrator" type="text" id="administrator" maxlength="50" value="<?php echo $this->_tpl_vars['cdata']['administrator']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <label>Status:
+ <input name="status" type="text" id="status" maxlength="100" value="<?php echo $this->_tpl_vars['cdata']['status']; ?>
+" />
+ </label>
+ </p>
+ </td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ <?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => '1'), $this);?>
+
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%57^57F^57F47D92%%edit_clientgroup.tpl.php b/html/templates_c/%%57^57F^57F47D92%%edit_clientgroup.tpl.php
new file mode 100644
index 0000000..ff6d6c0
--- /dev/null
+++ b/html/templates_c/%%57^57F^57F47D92%%edit_clientgroup.tpl.php
@@ -0,0 +1,49 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 23:22:41
+ compiled from admin/edit_clientgroup.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/edit_clientgroup.tpl', 10, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a ClientGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Edit a ClientGroup: <?php echo $this->_tpl_vars['editgroupdata'][3]; ?>
+</h2>
+<form name="form4" method="post" action="">
+<?php if ($this->_tpl_vars['editgroup']): ?>
+ <input type="hidden" name="groupid" value="<?php echo $this->_tpl_vars['editgroup']; ?>
+">
+ <p>Group name:
+ <input name="groupname" type="text" id="groupname" value="<?php echo $this->_tpl_vars['editgroupdata'][3]; ?>
+">
+ is subgroup of
+ <select name="parentgroup" id="parentgroup">
+ <?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => ($this->_tpl_vars['editgroupdata'][1])), $this);?>
+
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+<?php else: ?>
+<table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ <?php $_from = $this->_tpl_vars['clientgroups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['cgroup']):
+?>
+ <tr>
+ <td><div align="center">
+ <input name="editgroup" type="radio" value="<?php echo $this->_tpl_vars['key']; ?>
+">
+ </div></td>
+ <td><?php echo $this->_tpl_vars['cgroup']; ?>
+</td>
+ </tr>
+ <?php endforeach; endif; unset($_from); ?>
+ </table>
+ <p>
+ <input type="submit" name="Submit" value="EDIT">
+ </p>
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%62^620^6206D997%%admin.tpl.php b/html/templates_c/%%62^620^6206D997%%admin.tpl.php
new file mode 100644
index 0000000..74d42bd
--- /dev/null
+++ b/html/templates_c/%%62^620^6206D997%%admin.tpl.php
@@ -0,0 +1,33 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 23:18:45
+ compiled from admin.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Administration Page")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+Admin-y page here.
+List of administrative tasks:
+<hr>
+<table>
+<tr><td><a href="admin/create_user.php">Create a User</a></td></tr>
+<tr><td><a href="admin/edit_user.php">Edit a User</a></td></tr>
+<tr><td><a href="admin/delete_user.php">Delete a User</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/create_usergroup.php">Create a UserGroup</a></td></tr>
+<tr><td><a href="admin/edit_usergroup.php">Edit a UserGroup</a></td></tr>
+<tr><td><a href="admin/delete_usergroup.php">Delete a UserGroup</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/add_permission.php">Add Permission</a></td></tr>
+<tr><td><a href="admin/edit_permission.php">Edit Permission</a></td></tr>
+<tr><td><a href="admin/delete_permission.php">Delete Permission</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="admin/add_client.php">Add Client Manually</a></td></tr>
+<tr><td><a href="admin/edit_client.php">Edit Clients</a></td></tr>
+<tr><td><a href="admin/delete_client.php">Delete Client from GIMLI</a></td></tr>
+<tr><td></td></tr>
+<tr><td><a href="create_clientgroup.php">Create a ClientGroup</a></td></tr>
+<tr><td><a href="edit_clientgroup.php">Edit a ClientGroup</a></td></tr>
+<tr><td><a href="delte_clientgroup.php">Delete a ClientGroup</a></td></tr>
+</table>
+<hr>
+Maybe some Certificate Authority tasks? \ No newline at end of file
diff --git a/html/templates_c/%%76^76E^76E347F5%%create_clientgroup.tpl.php b/html/templates_c/%%76^76E^76E347F5%%create_clientgroup.tpl.php
new file mode 100644
index 0000000..01ebc34
--- /dev/null
+++ b/html/templates_c/%%76^76E^76E347F5%%create_clientgroup.tpl.php
@@ -0,0 +1,24 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 23:22:21
+ compiled from admin/create_clientgroup.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/create_clientgroup.tpl', 11, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Create a ClientGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Create a ClientGroup:</h2>
+<form name="form3" method="post" action="">
+ <p>Add Client Group:</p>
+ <p>
+ <label>Name:
+ <input name="groupname" type="text" id="groupname">
+ </label>
+ as subgroup of
+ <select name="parentgroup" id="parentgroup">
+<?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => '1'), $this);?>
+
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%82^82E^82E719A3%%create_user.tpl.php b/html/templates_c/%%82^82E^82E719A3%%create_user.tpl.php
new file mode 100644
index 0000000..73dc144
--- /dev/null
+++ b/html/templates_c/%%82^82E^82E719A3%%create_user.tpl.php
@@ -0,0 +1,47 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-24 12:19:11
+ compiled from admin/create_user.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/create_user.tpl', 30, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Create a User")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Create a user:</h2>
+<form id="form1" name="form1" method="post" action="">
+ <table width="733" border="1">
+ <tr>
+ <td width="75%"><label>
+User name:
+ <input name="username" type="text" id="username" />
+ </label>
+ <p>
+ <label>Password:
+ <input name="passwd" type="password" id="passwd" />
+ </label>
+ <label>confirm
+ <input name="passwd2" type="password" id="passwd2" />
+ </label>
+ </p>
+ <p>
+ <label>Real name:
+ <input name="realname" type="text" id="realname" />
+ </label>
+ </p>
+ <p>
+ <label>Comment
+ <input name="comment" type="text" id="comment" />
+ </label>
+ </p></td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ <?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => '1'), $this);?>
+
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <label><br />
+ </label>
+ <p><input type="submit" name="submit" value="Add User"></p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%8B^8B9^8B93D9A4%%edit_usergroup.tpl.php b/html/templates_c/%%8B^8B9^8B93D9A4%%edit_usergroup.tpl.php
new file mode 100644
index 0000000..46551bc
--- /dev/null
+++ b/html/templates_c/%%8B^8B9^8B93D9A4%%edit_usergroup.tpl.php
@@ -0,0 +1,115 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 15:55:13
+ compiled from admin/edit_usergroup.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/edit_usergroup.tpl', 10, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a UserGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Edit a UserGroup: <?php echo $this->_tpl_vars['editgroupdata'][3]; ?>
+</h2>
+<form name="form4" method="post" action="">
+<?php if ($this->_tpl_vars['editgroup']): ?>
+ <input type="hidden" name="groupid" value="<?php echo $this->_tpl_vars['editgroup']; ?>
+">
+ <p>Group name:
+ <input name="groupname" type="text" id="groupname" value="<?php echo $this->_tpl_vars['editgroupdata'][3]; ?>
+">
+ is subgroup of
+ <select name="parentgroup" id="parentgroup">
+ <?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => ($this->_tpl_vars['editgroupdata'][1])), $this);?>
+
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+<?php else: ?>
+<table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ <?php $_from = $this->_tpl_vars['usergroups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['ugroup']):
+?>
+ <tr>
+ <td><div align="center">
+ <input name="editgroup" type="radio" value="<?php echo $this->_tpl_vars['key']; ?>
+">
+ </div></td>
+ <td><?php echo $this->_tpl_vars['ugroup']; ?>
+</td>
+ </tr>
+ <?php endforeach; endif; unset($_from); ?>
+ </table>
+ <p>
+ <input type="submit" name="Submit" value="EDIT">
+ </p>
+<?php endif; ?>
+</form>
+<!--
+
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['users']): ?>
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>User Name</td><td>User Description</td><td>Creator</td>
+ </tr>
+ <?php unset($this->_sections['users']);
+$this->_sections['users']['name'] = 'users';
+$this->_sections['users']['loop'] = is_array($_loop=$this->_tpl_vars['users']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['users']['show'] = true;
+$this->_sections['users']['max'] = $this->_sections['users']['loop'];
+$this->_sections['users']['step'] = 1;
+$this->_sections['users']['start'] = $this->_sections['users']['step'] > 0 ? 0 : $this->_sections['users']['loop']-1;
+if ($this->_sections['users']['show']) {
+ $this->_sections['users']['total'] = $this->_sections['users']['loop'];
+ if ($this->_sections['users']['total'] == 0)
+ $this->_sections['users']['show'] = false;
+} else
+ $this->_sections['users']['total'] = 0;
+if ($this->_sections['users']['show']):
+
+ for ($this->_sections['users']['index'] = $this->_sections['users']['start'], $this->_sections['users']['iteration'] = 1;
+ $this->_sections['users']['iteration'] <= $this->_sections['users']['total'];
+ $this->_sections['users']['index'] += $this->_sections['users']['step'], $this->_sections['users']['iteration']++):
+$this->_sections['users']['rownum'] = $this->_sections['users']['iteration'];
+$this->_sections['users']['index_prev'] = $this->_sections['users']['index'] - $this->_sections['users']['step'];
+$this->_sections['users']['index_next'] = $this->_sections['users']['index'] + $this->_sections['users']['step'];
+$this->_sections['users']['first'] = ($this->_sections['users']['iteration'] == 1);
+$this->_sections['users']['last'] = ($this->_sections['users']['iteration'] == $this->_sections['users']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="edituser" value="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+"></td>
+ <input type="hidden" name="edituser_desc" value="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+">
+
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][2]; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected User">
+<?php endif; if ($this->_tpl_vars['username']): ?>
+ <label>User Name: <?php echo $this->_tpl_vars['username']; ?>
+
+ <input type="hidden" name="username" value="<?php echo $this->_tpl_vars['username']; ?>
+">
+ </label>
+ <p>
+ <label>Description
+ <input name="userdesc" type="text" id="userdesc" value="<?php echo $this->_tpl_vars['userdesc']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+<?php endif; ?>
+</form>
+--> \ No newline at end of file
diff --git a/html/templates_c/%%9E^9E0^9E0AB182%%delete_user.tpl.php b/html/templates_c/%%9E^9E0^9E0AB182%%delete_user.tpl.php
new file mode 100644
index 0000000..8e5b2fe
--- /dev/null
+++ b/html/templates_c/%%9E^9E0^9E0AB182%%delete_user.tpl.php
@@ -0,0 +1,54 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-24 12:36:16
+ compiled from admin/delete_user.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - DELETE a User")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+DELETE a user:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['users']): ?>
+ <table border="2" cellpadding="4" bgcolor="#FF0000">
+ <tr>
+ <td><b>DELETE</b></td><td><b>User Name</b></td><td><b>User Description</b></td><td><b>Creator</b></td>
+ </tr>
+ <?php unset($this->_sections['users']);
+$this->_sections['users']['name'] = 'users';
+$this->_sections['users']['loop'] = is_array($_loop=$this->_tpl_vars['users']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['users']['show'] = true;
+$this->_sections['users']['max'] = $this->_sections['users']['loop'];
+$this->_sections['users']['step'] = 1;
+$this->_sections['users']['start'] = $this->_sections['users']['step'] > 0 ? 0 : $this->_sections['users']['loop']-1;
+if ($this->_sections['users']['show']) {
+ $this->_sections['users']['total'] = $this->_sections['users']['loop'];
+ if ($this->_sections['users']['total'] == 0)
+ $this->_sections['users']['show'] = false;
+} else
+ $this->_sections['users']['total'] = 0;
+if ($this->_sections['users']['show']):
+
+ for ($this->_sections['users']['index'] = $this->_sections['users']['start'], $this->_sections['users']['iteration'] = 1;
+ $this->_sections['users']['iteration'] <= $this->_sections['users']['total'];
+ $this->_sections['users']['index'] += $this->_sections['users']['step'], $this->_sections['users']['iteration']++):
+$this->_sections['users']['rownum'] = $this->_sections['users']['iteration'];
+$this->_sections['users']['index_prev'] = $this->_sections['users']['index'] - $this->_sections['users']['step'];
+$this->_sections['users']['index_next'] = $this->_sections['users']['index'] + $this->_sections['users']['step'];
+$this->_sections['users']['first'] = ($this->_sections['users']['iteration'] == 1);
+$this->_sections['users']['last'] = ($this->_sections['users']['iteration'] == $this->_sections['users']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="deluser" value="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+"></td>
+ <td><b><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][2]; ?>
+</b></td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected User">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%BF^BFC^BFC0C69B%%edit_role.tpl.php b/html/templates_c/%%BF^BFC^BFC0C69B%%edit_role.tpl.php
new file mode 100644
index 0000000..240a3b5
--- /dev/null
+++ b/html/templates_c/%%BF^BFC^BFC0C69B%%edit_role.tpl.php
@@ -0,0 +1,71 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-18 22:23:37
+ compiled from admin/edit_role.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a Role")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+Edit a role:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['roles']): ?>
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>Role Name</td><td>Role Description</td><td>Creator</td>
+ </tr>
+ <?php unset($this->_sections['roles']);
+$this->_sections['roles']['name'] = 'roles';
+$this->_sections['roles']['loop'] = is_array($_loop=$this->_tpl_vars['roles']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['roles']['show'] = true;
+$this->_sections['roles']['max'] = $this->_sections['roles']['loop'];
+$this->_sections['roles']['step'] = 1;
+$this->_sections['roles']['start'] = $this->_sections['roles']['step'] > 0 ? 0 : $this->_sections['roles']['loop']-1;
+if ($this->_sections['roles']['show']) {
+ $this->_sections['roles']['total'] = $this->_sections['roles']['loop'];
+ if ($this->_sections['roles']['total'] == 0)
+ $this->_sections['roles']['show'] = false;
+} else
+ $this->_sections['roles']['total'] = 0;
+if ($this->_sections['roles']['show']):
+
+ for ($this->_sections['roles']['index'] = $this->_sections['roles']['start'], $this->_sections['roles']['iteration'] = 1;
+ $this->_sections['roles']['iteration'] <= $this->_sections['roles']['total'];
+ $this->_sections['roles']['index'] += $this->_sections['roles']['step'], $this->_sections['roles']['iteration']++):
+$this->_sections['roles']['rownum'] = $this->_sections['roles']['iteration'];
+$this->_sections['roles']['index_prev'] = $this->_sections['roles']['index'] - $this->_sections['roles']['step'];
+$this->_sections['roles']['index_next'] = $this->_sections['roles']['index'] + $this->_sections['roles']['step'];
+$this->_sections['roles']['first'] = ($this->_sections['roles']['iteration'] == 1);
+$this->_sections['roles']['last'] = ($this->_sections['roles']['iteration'] == $this->_sections['roles']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="editrole" value="<?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][0]; ?>
+"></td>
+ <input type="hidden" name="editrole_desc" value="<?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][1]; ?>
+">
+
+ <td><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][0]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][1]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][2]; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected Role">
+<?php endif; if ($this->_tpl_vars['rolename']): ?>
+ <label>Role Name: <?php echo $this->_tpl_vars['rolename']; ?>
+
+ <input type="hidden" name="rolename" value="<?php echo $this->_tpl_vars['rolename']; ?>
+">
+ </label>
+ <p>
+ <label>Description
+ <input name="roledesc" type="text" id="roledesc" value="<?php echo $this->_tpl_vars['roledesc']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%C1^C17^C17E547B%%delete_role.tpl.php b/html/templates_c/%%C1^C17^C17E547B%%delete_role.tpl.php
new file mode 100644
index 0000000..1fa2177
--- /dev/null
+++ b/html/templates_c/%%C1^C17^C17E547B%%delete_role.tpl.php
@@ -0,0 +1,54 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-18 23:31:04
+ compiled from admin/delete_role.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - DELETE a Role")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+DELETE a role:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['roles']): ?>
+ <table border="2" cellpadding="4" bgcolor="#FF0000">
+ <tr>
+ <td><b>DELETE</b></td><td><b>Role Name</b></td><td><b>Role Description</b></td><td><b>Creator</b></td>
+ </tr>
+ <?php unset($this->_sections['roles']);
+$this->_sections['roles']['name'] = 'roles';
+$this->_sections['roles']['loop'] = is_array($_loop=$this->_tpl_vars['roles']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['roles']['show'] = true;
+$this->_sections['roles']['max'] = $this->_sections['roles']['loop'];
+$this->_sections['roles']['step'] = 1;
+$this->_sections['roles']['start'] = $this->_sections['roles']['step'] > 0 ? 0 : $this->_sections['roles']['loop']-1;
+if ($this->_sections['roles']['show']) {
+ $this->_sections['roles']['total'] = $this->_sections['roles']['loop'];
+ if ($this->_sections['roles']['total'] == 0)
+ $this->_sections['roles']['show'] = false;
+} else
+ $this->_sections['roles']['total'] = 0;
+if ($this->_sections['roles']['show']):
+
+ for ($this->_sections['roles']['index'] = $this->_sections['roles']['start'], $this->_sections['roles']['iteration'] = 1;
+ $this->_sections['roles']['iteration'] <= $this->_sections['roles']['total'];
+ $this->_sections['roles']['index'] += $this->_sections['roles']['step'], $this->_sections['roles']['iteration']++):
+$this->_sections['roles']['rownum'] = $this->_sections['roles']['iteration'];
+$this->_sections['roles']['index_prev'] = $this->_sections['roles']['index'] - $this->_sections['roles']['step'];
+$this->_sections['roles']['index_next'] = $this->_sections['roles']['index'] + $this->_sections['roles']['step'];
+$this->_sections['roles']['first'] = ($this->_sections['roles']['iteration'] == 1);
+$this->_sections['roles']['last'] = ($this->_sections['roles']['iteration'] == $this->_sections['roles']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="delrole" value="<?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][0]; ?>
+"></td>
+ <td><b><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][0]; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][1]; ?>
+</b></td>
+ <td><b><?php echo $this->_tpl_vars['roles'][$this->_sections['roles']['index']][2]; ?>
+</b></td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected Role">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%CA^CA7^CA72B036%%delete_usergroup.tpl.php b/html/templates_c/%%CA^CA7^CA72B036%%delete_usergroup.tpl.php
new file mode 100644
index 0000000..b217ac6
--- /dev/null
+++ b/html/templates_c/%%CA^CA7^CA72B036%%delete_usergroup.tpl.php
@@ -0,0 +1,32 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 16:18:36
+ compiled from admin/delete_usergroup.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - DELETE a UserGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+DELETE a UserGroup:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['usergroups']): ?>
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Group Name </th>
+ </tr>
+ <?php $_from = $this->_tpl_vars['usergroups']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
+ foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['ugroup']):
+?>
+ <tr>
+ <td><div align="center">
+ <input name="delgroup" type="radio" value="<?php echo $this->_tpl_vars['key']; ?>
+">
+ </div></td>
+ <td><?php echo $this->_tpl_vars['ugroup']; ?>
+</td>
+ </tr>
+ <?php endforeach; endif; unset($_from); ?>
+ </table>
+ <input name="iamsure" type="checkbox" value="yes">I am <b>certain</b> I want to do this. <br><br>
+ <input name="delsubmit" type="Submit" value="DELETE Selected UserGroup">
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%CB^CB4^CB4A447D%%add_client.tpl.php b/html/templates_c/%%CB^CB4^CB4A447D%%add_client.tpl.php
new file mode 100644
index 0000000..9ab8977
--- /dev/null
+++ b/html/templates_c/%%CB^CB4^CB4A447D%%add_client.tpl.php
@@ -0,0 +1,60 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 21:47:40
+ compiled from admin/add_client.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/add_client.tpl', 43, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Add a Client")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Add a client:</h2>
+<form id="form1" name="form1" method="post" action="">
+ <table width="733" border="1">
+ <tr>
+ <td width="75%"><label>
+ Hostname:
+ <input name="hostname" type="text" id="hostname" />
+ </label>
+ <p>
+ <label>MAC:
+ <input name="mac" type="text" id="mac" maxlength="17" />
+ </label>
+ </p>
+ <p>
+ <label>IP:
+ <input name="ip" type="text" id="ip" maxlength="15" />
+ </label>
+ </p>
+ <p>
+ <label>Gentoo Profile Name (optional)
+ <input name="profile" type="text" id="profile" />
+ </label>
+ </p>
+ <p>
+ <label>Distribution (optional)
+ <input name="distribution" type="text" id="distribution" maxlength="50" />
+ </label>
+ </p>
+ <p>
+ <label>Administrator (optional)
+ <input name="administrator" type="text" id="administrator" maxlength="50" />
+ </label>
+ </p>
+ <p>
+ <label>Status:
+ <input name="status" type="text" id="status" maxlength="100" />
+ </label>
+ </p>
+ </td>
+ <td width="25%"><label>Groups:<br>
+ <select name="groups[]" size="10" multiple="multiple" id="groups">
+ <?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => '1'), $this);?>
+
+ </select>
+ </label></td>
+ </tr>
+ </table>
+ <label><br />
+ </label>
+ <p><input type="submit" name="submit" value="Add Client"></p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%DD^DD9^DD93FC5A%%create_role.tpl.php b/html/templates_c/%%DD^DD9^DD93FC5A%%create_role.tpl.php
new file mode 100644
index 0000000..b504a36
--- /dev/null
+++ b/html/templates_c/%%DD^DD9^DD93FC5A%%create_role.tpl.php
@@ -0,0 +1,21 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-18 23:16:54
+ compiled from admin/create_role.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Create a Role")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+Create a role:
+<form id="form1" name="form1" method="post" action="#">
+ <label>Role Name
+ <input name="rolename" type="text" id="rolename" />
+ </label>
+ <p>
+ <label>Description
+ <input name="roledesc" type="text" id="roledesc" />
+ </label>
+ </p>
+ <p>
+ <input name="submit" type="Submit" value="Create Role">
+ </p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%E0^E0B^E0B42362%%edit_user.tpl.php b/html/templates_c/%%E0^E0B^E0B42362%%edit_user.tpl.php
new file mode 100644
index 0000000..12f44de
--- /dev/null
+++ b/html/templates_c/%%E0^E0B^E0B42362%%edit_user.tpl.php
@@ -0,0 +1,72 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 22:03:34
+ compiled from admin/edit_user.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a User")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+Edit a User:
+<form id="form1" name="form1" method="post" action="#">
+<?php if ($this->_tpl_vars['users']): ?>
+ <table border="2" cellpadding="4">
+ <tr>
+ <td>EDIT</td><td>User Name</td><td>User Description</td><td>Creator</td>
+ </tr>
+ <?php unset($this->_sections['users']);
+$this->_sections['users']['name'] = 'users';
+$this->_sections['users']['loop'] = is_array($_loop=$this->_tpl_vars['users']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['users']['show'] = true;
+$this->_sections['users']['max'] = $this->_sections['users']['loop'];
+$this->_sections['users']['step'] = 1;
+$this->_sections['users']['start'] = $this->_sections['users']['step'] > 0 ? 0 : $this->_sections['users']['loop']-1;
+if ($this->_sections['users']['show']) {
+ $this->_sections['users']['total'] = $this->_sections['users']['loop'];
+ if ($this->_sections['users']['total'] == 0)
+ $this->_sections['users']['show'] = false;
+} else
+ $this->_sections['users']['total'] = 0;
+if ($this->_sections['users']['show']):
+
+ for ($this->_sections['users']['index'] = $this->_sections['users']['start'], $this->_sections['users']['iteration'] = 1;
+ $this->_sections['users']['iteration'] <= $this->_sections['users']['total'];
+ $this->_sections['users']['index'] += $this->_sections['users']['step'], $this->_sections['users']['iteration']++):
+$this->_sections['users']['rownum'] = $this->_sections['users']['iteration'];
+$this->_sections['users']['index_prev'] = $this->_sections['users']['index'] - $this->_sections['users']['step'];
+$this->_sections['users']['index_next'] = $this->_sections['users']['index'] + $this->_sections['users']['step'];
+$this->_sections['users']['first'] = ($this->_sections['users']['iteration'] == 1);
+$this->_sections['users']['last'] = ($this->_sections['users']['iteration'] == $this->_sections['users']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="edituser" value="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+"></td>
+ <input type="hidden" name="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+_desc" value="<?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+">
+
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][0]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][1]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['users'][$this->_sections['users']['index']][2]; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <input name="editsubmit" type="Submit" value="Edit Selected User">
+<?php endif; if ($this->_tpl_vars['username']): ?>
+ <label>User Name: <?php echo $this->_tpl_vars['username']; ?>
+
+ <input type="hidden" name="username" value="<?php echo $this->_tpl_vars['username']; ?>
+">
+ </label>
+ <p>
+ <label>Description
+ <input name="userdesc" type="text" id="userdesc" value="<?php echo $this->_tpl_vars['userdesc']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%E1^E1D^E1DC02AD%%delete_permission.tpl.php b/html/templates_c/%%E1^E1D^E1DC02AD%%delete_permission.tpl.php
new file mode 100644
index 0000000..1bcac3d
--- /dev/null
+++ b/html/templates_c/%%E1^E1D^E1DC02AD%%delete_permission.tpl.php
@@ -0,0 +1,59 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 17:48:50
+ compiled from admin/delete_permission.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a Permission")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Edit a permission:</h2>
+<form name="form7" method="post" action="">
+ <table width="100%" border="1">
+ <tr bgcolor="#FF0000">
+ <th scope="col" width="10%"><div align="center">DELETE</div></th>
+ <th scope="col">Permission Name </th>
+ <th scope="col">Permission Description </th>
+ </tr>
+ <?php unset($this->_sections['perms']);
+$this->_sections['perms']['name'] = 'perms';
+$this->_sections['perms']['loop'] = is_array($_loop=$this->_tpl_vars['permissions']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['perms']['show'] = true;
+$this->_sections['perms']['max'] = $this->_sections['perms']['loop'];
+$this->_sections['perms']['step'] = 1;
+$this->_sections['perms']['start'] = $this->_sections['perms']['step'] > 0 ? 0 : $this->_sections['perms']['loop']-1;
+if ($this->_sections['perms']['show']) {
+ $this->_sections['perms']['total'] = $this->_sections['perms']['loop'];
+ if ($this->_sections['perms']['total'] == 0)
+ $this->_sections['perms']['show'] = false;
+} else
+ $this->_sections['perms']['total'] = 0;
+if ($this->_sections['perms']['show']):
+
+ for ($this->_sections['perms']['index'] = $this->_sections['perms']['start'], $this->_sections['perms']['iteration'] = 1;
+ $this->_sections['perms']['iteration'] <= $this->_sections['perms']['total'];
+ $this->_sections['perms']['index'] += $this->_sections['perms']['step'], $this->_sections['perms']['iteration']++):
+$this->_sections['perms']['rownum'] = $this->_sections['perms']['iteration'];
+$this->_sections['perms']['index_prev'] = $this->_sections['perms']['index'] - $this->_sections['perms']['step'];
+$this->_sections['perms']['index_next'] = $this->_sections['perms']['index'] + $this->_sections['perms']['step'];
+$this->_sections['perms']['first'] = ($this->_sections['perms']['iteration'] == 1);
+$this->_sections['perms']['last'] = ($this->_sections['perms']['iteration'] == $this->_sections['perms']['total']);
+?>
+ <tr bgcolor="#FF0000">
+ <td><div align="center"><input type="radio" name="delperm" value="<?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][0]; ?>
+"></div></td>
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][0]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][1]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][2]; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <p>
+ <input name="iamsure" type="checkbox" id="iamsure" value="yes">
+ I am <strong>sure</strong> I want to do this!</p>
+ <p align="left">
+ <input name="delsubmit" type="submit" id="delsubmit" value="DELETE">
+ </p>
+ <p>&nbsp; </p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%F7^F7F^F7F34188%%header.tpl.php b/html/templates_c/%%F7^F7F^F7F34188%%header.tpl.php
new file mode 100644
index 0000000..f9b3b29
--- /dev/null
+++ b/html/templates_c/%%F7^F7F^F7F34188%%header.tpl.php
@@ -0,0 +1,52 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 17:12:05
+ compiled from header.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('modifier', 'default', 'header.tpl', 3, false),)), $this); ?>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title><?php echo ((is_array($_tmp=@$this->_tpl_vars['title'])) ? $this->_run_mod_handler('default', true, $_tmp, 'GIMLI') : smarty_modifier_default($_tmp, 'GIMLI')); ?>
+</title>
+<link rel="stylesheet" href="2col_leftNav.css" type="text/css" />
+</head>
+<body>
+<div id="masthead">
+<table><tr><td><a href="index.php"><img src="tux_large.png" alt="Linux Logo" height="60"></a></td><td>
+<h1 id="siteName"> Generic Interface for the Management of Linux Installations </h1></td></tr></table>
+<div id="globalNav" align="center">
+<?php unset($this->_sections['top_nav_bar']);
+$this->_sections['top_nav_bar']['name'] = 'top_nav_bar';
+$this->_sections['top_nav_bar']['loop'] = is_array($_loop=$this->_tpl_vars['topbar']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['top_nav_bar']['show'] = true;
+$this->_sections['top_nav_bar']['max'] = $this->_sections['top_nav_bar']['loop'];
+$this->_sections['top_nav_bar']['step'] = 1;
+$this->_sections['top_nav_bar']['start'] = $this->_sections['top_nav_bar']['step'] > 0 ? 0 : $this->_sections['top_nav_bar']['loop']-1;
+if ($this->_sections['top_nav_bar']['show']) {
+ $this->_sections['top_nav_bar']['total'] = $this->_sections['top_nav_bar']['loop'];
+ if ($this->_sections['top_nav_bar']['total'] == 0)
+ $this->_sections['top_nav_bar']['show'] = false;
+} else
+ $this->_sections['top_nav_bar']['total'] = 0;
+if ($this->_sections['top_nav_bar']['show']):
+
+ for ($this->_sections['top_nav_bar']['index'] = $this->_sections['top_nav_bar']['start'], $this->_sections['top_nav_bar']['iteration'] = 1;
+ $this->_sections['top_nav_bar']['iteration'] <= $this->_sections['top_nav_bar']['total'];
+ $this->_sections['top_nav_bar']['index'] += $this->_sections['top_nav_bar']['step'], $this->_sections['top_nav_bar']['iteration']++):
+$this->_sections['top_nav_bar']['rownum'] = $this->_sections['top_nav_bar']['iteration'];
+$this->_sections['top_nav_bar']['index_prev'] = $this->_sections['top_nav_bar']['index'] - $this->_sections['top_nav_bar']['step'];
+$this->_sections['top_nav_bar']['index_next'] = $this->_sections['top_nav_bar']['index'] + $this->_sections['top_nav_bar']['step'];
+$this->_sections['top_nav_bar']['first'] = ($this->_sections['top_nav_bar']['iteration'] == 1);
+$this->_sections['top_nav_bar']['last'] = ($this->_sections['top_nav_bar']['iteration'] == $this->_sections['top_nav_bar']['total']);
+?>
+ <a href="<?php echo $this->_tpl_vars['topbar'][$this->_sections['top_nav_bar']['index']]['link']; ?>
+"><?php echo $this->_tpl_vars['topbar'][$this->_sections['top_nav_bar']['index']]['name']; ?>
+</a> |
+<?php endfor; endif; ?>
+
+</div>
+<!-- end masthead -->
+<hr>
+<div id="content">
+<?php if ($this->_tpl_vars['status']): ?>
+<h3><?php echo $this->_tpl_vars['status']; ?>
+</h3>
+<?php endif; ?> \ No newline at end of file
diff --git a/html/templates_c/%%F9^F94^F94199C6%%create_usergroup.tpl.php b/html/templates_c/%%F9^F94^F94199C6%%create_usergroup.tpl.php
new file mode 100644
index 0000000..b8ea85f
--- /dev/null
+++ b/html/templates_c/%%F9^F94^F94199C6%%create_usergroup.tpl.php
@@ -0,0 +1,24 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 15:16:05
+ compiled from admin/create_usergroup.tpl */ ?>
+<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
+smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'admin/create_usergroup.tpl', 11, false),)), $this); ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Create a UserGroup")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Create a UserGroup:</h2>
+<form name="form3" method="post" action="">
+ <p>Add User/Machines Group:</p>
+ <p>
+ <label>Name:
+ <input name="groupname" type="text" id="groupname">
+ </label>
+ as subgroup of
+ <select name="parentgroup" id="parentgroup">
+<?php echo smarty_function_html_options(array('values' => $this->_tpl_vars['ids'],'output' => $this->_tpl_vars['groupnames'],'selected' => '1'), $this);?>
+
+ </select>
+ <input type="submit" name="Submit" value="Submit">
+ </p>
+</form> \ No newline at end of file
diff --git a/html/templates_c/%%FF^FF9^FF9C11AC%%edit_permission.tpl.php b/html/templates_c/%%FF^FF9^FF9C11AC%%edit_permission.tpl.php
new file mode 100644
index 0000000..7261726
--- /dev/null
+++ b/html/templates_c/%%FF^FF9^FF9C11AC%%edit_permission.tpl.php
@@ -0,0 +1,78 @@
+<?php /* Smarty version 2.6.10, created on 2006-03-25 17:41:21
+ compiled from admin/edit_permission.tpl */ ?>
+<?php $_smarty_tpl_vars = $this->_tpl_vars;
+$this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array('title' => "GIMLI - Admin - Edit a Permission")));
+$this->_tpl_vars = $_smarty_tpl_vars;
+unset($_smarty_tpl_vars);
+ ?>
+<h2>Edit a permission:</h2>
+<form name="form7" method="post" action="">
+<?php if ($this->_tpl_vars['permissions']): ?>
+ <table width="100%" border="1">
+ <tr>
+ <th scope="col" width="10%"><div align="center">EDIT</div></th>
+ <th scope="col">Permission Name</th>
+ <th scope="col">Permission Description</th>
+ <th scope="col">Creator</th>
+ </tr>
+ <?php unset($this->_sections['perms']);
+$this->_sections['perms']['name'] = 'perms';
+$this->_sections['perms']['loop'] = is_array($_loop=$this->_tpl_vars['permissions']) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
+$this->_sections['perms']['show'] = true;
+$this->_sections['perms']['max'] = $this->_sections['perms']['loop'];
+$this->_sections['perms']['step'] = 1;
+$this->_sections['perms']['start'] = $this->_sections['perms']['step'] > 0 ? 0 : $this->_sections['perms']['loop']-1;
+if ($this->_sections['perms']['show']) {
+ $this->_sections['perms']['total'] = $this->_sections['perms']['loop'];
+ if ($this->_sections['perms']['total'] == 0)
+ $this->_sections['perms']['show'] = false;
+} else
+ $this->_sections['perms']['total'] = 0;
+if ($this->_sections['perms']['show']):
+
+ for ($this->_sections['perms']['index'] = $this->_sections['perms']['start'], $this->_sections['perms']['iteration'] = 1;
+ $this->_sections['perms']['iteration'] <= $this->_sections['perms']['total'];
+ $this->_sections['perms']['index'] += $this->_sections['perms']['step'], $this->_sections['perms']['iteration']++):
+$this->_sections['perms']['rownum'] = $this->_sections['perms']['iteration'];
+$this->_sections['perms']['index_prev'] = $this->_sections['perms']['index'] - $this->_sections['perms']['step'];
+$this->_sections['perms']['index_next'] = $this->_sections['perms']['index'] + $this->_sections['perms']['step'];
+$this->_sections['perms']['first'] = ($this->_sections['perms']['iteration'] == 1);
+$this->_sections['perms']['last'] = ($this->_sections['perms']['iteration'] == $this->_sections['perms']['total']);
+?>
+ <tr>
+ <td><input type="radio" name="editperm" value="<?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][0]; ?>
+"></td>
+ <input type="hidden" name="<?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][0]; ?>
+_desc" value="<?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][1]; ?>
+">
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][0]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][1]; ?>
+</td>
+ <td><?php echo $this->_tpl_vars['permissions'][$this->_sections['perms']['index']][2]; ?>
+</td>
+ </tr>
+ <?php endfor; endif; ?>
+ </table>
+ <p>
+ <p align="left">
+ <input name="submit" type="submit" id="submit" value="Edit this Permission">
+ </p>
+ <p>&nbsp; </p>
+<?php endif; if ($this->_tpl_vars['permname']): ?>
+ <label>Permission Name: <?php echo $this->_tpl_vars['permname']; ?>
+
+ <input type="text" name="permname" value="<?php echo $this->_tpl_vars['permname']; ?>
+" disabled>
+ </label>
+ <p>
+ <label>Description
+ <input name="permdesc" type="text" id="permdesc" value="<?php echo $this->_tpl_vars['permdesc']; ?>
+" />
+ </label>
+ </p>
+ <p>
+ <input name="savesubmit" type="Submit" value="Save Changes">
+ </p>
+<?php endif; ?>
+</form> \ No newline at end of file
diff --git a/html/tux_large.png b/html/tux_large.png
new file mode 100755
index 0000000..cfe8c5a
--- /dev/null
+++ b/html/tux_large.png
Binary files differ
diff --git a/moria/moria.sql b/moria/moria.sql
index 9d4d1de..271d2b6 100644
--- a/moria/moria.sql
+++ b/moria/moria.sql
@@ -13,18 +13,17 @@ homepage VARCHAR(90),
PRIMARY KEY (id)
) TYPE=MyISAM;
-drop table if exists machines;
-create table machines (
-machine_id INT NOT NULL default '0',
+drop table if exists clients;
+create table clients (
+client_id INT NOT NULL AUTO_INCREMENT,
hostname VARCHAR(30) NOT NULL default 'hostname',
mac VARCHAR(17) NOT NULL default '00:01:02:03:04:05',
ip VARCHAR(15) NOT NULL default 'dhcp',
profile VARCHAR(30),
distribution VARCHAR(50),
-role VARCHAR(30),
administrator VARCHAR(50),
status VARCHAR(100),
-PRIMARY KEY (machine_id)
+PRIMARY KEY (client_id)
) TYPE=MyISAM;
drop table if exists profiles;
@@ -47,23 +46,19 @@ create table users (
username VARCHAR(30) NOT NULL,
password VARCHAR(50) NOT NULL default 'invalid',
real_name VARCHAR(60),
+comment VARCHAR(90),
PRIMARY KEY (username)
) TYPE=MyISAM;
-drop table if exists roles;
-create table roles (
-role_name VARCHAR(30) NOT NULL,
+drop table if exists permissions;
+create table permissions (
+perm_name VARCHAR(30) NOT NULL,
description VARCHAR(90),
creator VARCHAR(30),
-PRIMARY KEY (role_name)
+PRIMARY KEY (perm_name)
) TYPE=MyISAM;
-drop table if exists user_role;
-create table user_role (
-username VARCHAR(30) NOT NULL,
-role_name VARCHAR(30) NOT NULL,
-PRIMARY KEY (username, role_name)
-) TYPE=MyISAM;
+
--INSERT INTO jobs (client, cliengroup, jobtype, priority, jobparam) VALUES ("boxa", "webserver", "pkgupdate", 2, "apache")
--INSERT INTO jobs (client, cliengroup, jobtype, priority, jobparam) VALUES ("boxa", "webserver", "cfgupdate", 3, "scp://server/etc/apache2/httpd2.conf")
diff --git a/moria/moria2.sql b/moria/moria2.sql
index 68147ec..108ebb8 100644
--- a/moria/moria2.sql
+++ b/moria/moria2.sql
@@ -2,23 +2,16 @@ use moria;
INSERT INTO modules values (1,'GLIMD','Gentoo Linux Installation Mangement Daemon','Description goes here and all that good stuff.','glimd.txt','Preston Cody','gentoo','deployment','http://www.gentoo.org/proj/en/releng/gli/');
INSERT INTO modules values (2,'Exporter','Server Information Exporter','This is a utility that will take selected data from the central server about machines and export it into an XML format.','Exporter.php','Preston Cody',NULL,'information','http://www.gentoo.org/proj/en/releng/gli/');
-INSERT INTO machines values (1, 'testhostlead', '00:0a:0b:0c:0d:0e', '192.168.3.4', 'printerserver', 'gentoo', 'lead', 'Preston Cody', 'Installed');
+INSERT INTO clients values (1, 'testhostlead', '00:0a:0b:0c:0d:0e', '192.168.3.4', 'printerserver', 'gentoo', 'Preston Cody', 'Installed');
-INSERT INTO machines values (2, 'testhostslave', '00:0a:0a:0a:0d:0e', '192.168.3.5', 'printerserver', 'gentoo', 'clone', 'Preston Cody', 'Not Installed');
+INSERT INTO clients values (2, 'testhostslave', '00:0a:0a:0a:0d:0e', '192.168.3.5', 'printerserver', 'gentoo', 'Preston Cody', 'Not Installed');
-INSERT INTO machines values (3, 'testhostmtalead', '0b:0b:0b:0c:0d:0e', '192.168.3.6', 'mta', 'gentoo', 'lead', 'Preston Cody', 'Installed');
+INSERT INTO clients values (3, 'testhostmtalead', '0b:0b:0b:0c:0d:0e', '192.168.3.6', 'mta', 'gentoo', 'Preston Cody', 'Installed');
-INSERT INTO machines values (4, 'testhostmtaslave', '0c:0c:0c:0c:0d:0e', '192.168.3.7', 'mta', 'gentoo', 'clone', 'Preston Cody', 'Installed');
+INSERT INTO clients values (4, 'testhostmtaslave', '0c:0c:0c:0c:0d:0e', '192.168.3.7', 'mta', 'gentoo', 'Preston Cody', 'Installed');
INSERT INTO profiles values ('printerserver', 'printerserverprofile.xml', 'Printer Servers use this profile', 'gentoo');
INSERT INTO profiles values ('mta', 'mtaprofile.xml', 'MTAs use this profile', 'gentoo');
INSERT INTO users values ('root','444mwGdhEKuO.','Root User');
-INSERT INTO roles values ('root','Administrative Role','root');
-INSERT INTO user_role values ('root','root');
---create table profiles (
---profile_name VARCHAR(30),
---filename VARCHAR(90) NOT NULL,
---description VARCHAR(250),
---distribution VARCHAR(50),