TestUser.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. Lib::loadClass('RouteToolBase');
  3. Lib::loadClass('UI');
  4. Lib::loadClass('Response');
  5. Lib::loadClass('Theme');
  6. require_once dirname(__FILE__) . '/../auth.php'; // Theme_Auth_panel_biall_net
  7. // index.php?_route=UrlAction_TestUser - uruchamia defaultAction
  8. class RouteTool_TestUser extends RouteToolBase {
  9. function defaultAction() { UI::layout([ $this, 'defaultView' ]); }
  10. function defaultView() {
  11. if (!User::isAdmin()) throw new Exception("Access Denied");
  12. $email = V::get('email', '', $_POST);
  13. $postTask = V::get('_postTask', '', $_POST);
  14. $_testUserInfo = null;
  15. switch ($postTask) {
  16. case 'makeAccounts': {
  17. Theme_Auth_panel_biall_net::makeActiveUsers($email);
  18. } break;
  19. case 'resetPasswd': {
  20. Theme_Auth_panel_biall_net::makeActiveUsers($email);
  21. $remindKey = Theme_Auth_panel_biall_net::generateRemindKey($email);
  22. $resetLink = Router::getRoute('UrlAction_RemindPasswd')->getLink('rp', [ 'login' => $email, 'key' => $remindKey ]);
  23. Theme_Auth_panel_biall_net::sendRemindPasswd($email, $resetLink, $recipient = "piotrl86+bn-test-remind@gmail.com");
  24. } break;
  25. case 'testAuth': {
  26. $passwd = V::get('passwd', '', $_POST);
  27. $_testUserInfo = Theme_Auth_panel_biall_net::testAuth($email, $passwd);
  28. } break;
  29. }
  30. echo UI::h('form', [ 'method' => "POST" ], [
  31. UI::h('div', [ 'class' => "row" ], [
  32. UI::h('div', [ 'class' => "col-md-offset-3 col-md-6" ], [
  33. UI::h('div', [ 'class' => "form-group" ], [
  34. UI::h('label', [], "Adres email"),
  35. UI::h('input', [ 'type' => "text", 'name' => "email", 'value' => $email, 'class' => "form-control" ]),
  36. ]),
  37. UI::h('div', [ 'class' => "form-group" ], [
  38. UI::h('input', [ 'type' => "submit", 'value' => "Test", 'class' => "btn btn-primary" ]),
  39. ]),
  40. ]),
  41. ]),
  42. ]);
  43. if (empty($email)) throw new Exception("Proszę podać adres email");
  44. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new Exception("Proszę podać poprawny adres email");
  45. echo UI::h('div', [], [
  46. UI::h('p', [], UI::h('code', [], $email)),
  47. UI::h('form', [ 'method' => "POST", 'style' => "margin:24px 0" ], [
  48. UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
  49. UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'makeAccounts' ]),
  50. UI::h('input', [ 'type' => "submit", 'value' => "Utwórz konta w panelu klienta", 'class' => "btn btn-warning" ]),
  51. ]),
  52. UI::h('form', [ 'method' => "POST", 'class' => "form-horizontal", 'style' => "margin:24px 0" ], [
  53. UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
  54. UI::h('label', [ 'class' => "col-md-1 control-label" ], "Hasło:"),
  55. UI::h('div', [ 'method' => "POST", 'class' => "col-md-4" ], [
  56. UI::h('input', [ 'type' => "text", 'name' => "passwd", 'value' => '', 'class' => "form-control" ]),
  57. ]),
  58. UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'testAuth' ]),
  59. UI::h('input', [ 'type' => "submit", 'value' => "Testuj logowanie do panelu klienta", 'class' => "btn btn-default" ]),
  60. ($_testUserInfo)
  61. ? UI::h('div', [ 'class' => "alert alert-success" ], [
  62. UI::h('p', [], "Klient: [{$_testUserInfo['ID']}] '{$_testUserInfo['P_NAME']} {$_testUserInfo['P_NAME_SECOND']}'"),
  63. ])
  64. : UI::h('div', [], "..."),
  65. ]),
  66. UI::h('form', [ 'method' => "POST", 'style' => "margin:24px 0" ], [
  67. UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
  68. UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'resetPasswd' ]),
  69. UI::h('input', [ 'type' => "submit", 'value' => "Reset hasła do panelu klienta", 'class' => "btn btn-danger" ]),
  70. ]),
  71. UI::h('p', [], "All users:"),
  72. UI::hTable([ 'rows' => Theme_Auth_panel_biall_net::test_fetchAllUsers($email) ]),
  73. UI::h('p', [], "Active BIALL-NET users (BILLING_OWNER: 1 BN, 3 NETDAY):"),
  74. UI::hTable([ 'rows' => Theme_Auth_panel_biall_net::fetchActiveUsers($email) ]),
  75. ]);
  76. echo UI::h('div', [], [
  77. UI::h('p', [], "All auth:"),
  78. UI::hTable([ 'rows' => DB::getPDO()->fetchAll(" select * from PANEL_KLIENTA_BN_AUTH ") ]),
  79. ]);
  80. }
  81. }