PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/system/phpgacl/acl_test2.php

https://github.com/radicaldesigns/amp
PHP | 110 lines | 72 code | 26 blank | 12 comment | 6 complexity | e84affad54046bb5ac9a7d1a4899cc07 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. /*
  3. if (!empty($_GET['debug'])) {
  4. $debug = $_GET['debug'];
  5. }
  6. */
  7. @set_time_limit(600);
  8. require_once('../profiler.inc');
  9. $profiler = new Profiler(true,true);
  10. require_once("gacl_admin.inc.php");
  11. $query = '
  12. SELECT a.value AS a_value, a.name AS a_name,
  13. b.value AS b_value, b.name AS b_name,
  14. c.value AS c_value, c.name AS c_name,
  15. d.value AS d_value, d.name AS d_name
  16. FROM '. $gacl_api->_db_table_prefix .'aco_sections a
  17. LEFT JOIN '. $gacl_api->_db_table_prefix .'aco b ON a.value=b.section_value,
  18. '. $gacl_api->_db_table_prefix .'aro_sections c
  19. LEFT JOIN '. $gacl_api->_db_table_prefix .'aro d ON c.value=d.section_value
  20. ORDER BY a.value, b.value, c.value, d.value';
  21. //$rs = $db->Execute($query);
  22. $rs = $db->pageexecute($query, $gacl_api->_items_per_page, $_GET['page']);
  23. $rows = $rs->GetRows();
  24. /*
  25. echo("<pre>");
  26. print_r($rows);
  27. echo("</pre>");
  28. */
  29. $total_rows = count($rows);
  30. while (list(,$row) = @each(&$rows)) {
  31. list( $aco_section_value,
  32. $aco_section_name,
  33. $aco_value,
  34. $aco_name,
  35. $aro_section_value,
  36. $aro_section_name,
  37. $aro_value,
  38. $aro_name
  39. ) = $row;
  40. $acl_check_begin_time = $profiler->getMicroTime();
  41. $acl_result = $gacl->acl_query($aco_section_value, $aco_value, $aro_section_value, $aro_value);
  42. $acl_check_end_time = $profiler->getMicroTime();
  43. $access = &$acl_result['allow'];
  44. $return_value = &$acl_result['return_value'];
  45. $acl_check_time = ($acl_check_end_time - $acl_check_begin_time) * 1000;
  46. $total_acl_check_time += $acl_check_time;
  47. if ($aco_section_name != $tmp_aco_section_name OR $aco_name != $tmp_aco_name) {
  48. $display_aco_name = "$aco_section_name > $aco_name";
  49. } else {
  50. $display_aco_name = "<br>";
  51. }
  52. $acls[] = array(
  53. 'aco_section_value' => $aco_section_value,
  54. 'aco_section_name' => $aco_section_name,
  55. 'aco_value' => $aco_value,
  56. 'aco_name' => $aco_name,
  57. 'aro_section_value' => $aro_section_value,
  58. 'aro_section_name' => $aro_section_name,
  59. 'aro_value' => $aro_value,
  60. 'aro_name' => $aro_name,
  61. 'access' => $access,
  62. 'return_value' => $return_value,
  63. 'acl_check_time' => number_format($acl_check_time, 2),
  64. 'display_aco_name' => $display_aco_name,
  65. );
  66. $tmp_aco_section_name = $aco_section_name;
  67. $tmp_aco_name = $aco_name;
  68. }
  69. //echo "<br><br>$x ACL_CHECK()'s<br>\n";
  70. $smarty->assign("acls", $acls);
  71. $smarty->assign("total_acl_checks", $total_rows);
  72. $smarty->assign("total_acl_check_time", $total_acl_check_time);
  73. if ($total_rows > 0) {
  74. $avg_acl_check_time = $total_acl_check_time / $total_rows;
  75. }
  76. $smarty->assign("avg_acl_check_time", number_format( ($avg_acl_check_time + 0) ,2));
  77. $smarty->assign("paging_data", $gacl_api->get_paging_data($rs));
  78. $smarty->assign("return_page", $_SERVER['PHP_SELF'] );
  79. $smarty->assign('current','acl_test');
  80. $smarty->assign('page_title', '2-dim. ACL Test');
  81. $smarty->assign("phpgacl_version", $gacl_api->get_version() );
  82. $smarty->assign("phpgacl_schema_version", $gacl_api->get_schema_version() );
  83. $smarty->display('phpgacl/acl_test2.tpl');
  84. ?>