12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- Lib::loadClass('RouteToolBase');
- Lib::loadClass('UI');
- Lib::loadClass('Response');
- Lib::loadClass('Theme');
- require_once dirname(__FILE__) . '/../auth.php'; // Theme_Auth_panel_biall_net
- // index.php?_route=UrlAction_TestUser - uruchamia defaultAction
- class RouteTool_TestUser extends RouteToolBase {
- function defaultAction() { UI::layout([ $this, 'defaultView' ]); }
- function defaultView() {
- if (!User::isAdmin()) throw new Exception("Access Denied");
- $email = V::get('email', '', $_POST);
- $postTask = V::get('_postTask', '', $_POST);
- $_testUserInfo = null;
- switch ($postTask) {
- case 'makeAccounts': {
- Theme_Auth_panel_biall_net::makeActiveUsers($email);
- } break;
- case 'resetPasswd': {
- Theme_Auth_panel_biall_net::makeActiveUsers($email);
- $remindKey = Theme_Auth_panel_biall_net::generateRemindKey($email);
- $resetLink = Router::getRoute('UrlAction_RemindPasswd')->getLink('rp', [ 'login' => $email, 'key' => $remindKey ]);
- Theme_Auth_panel_biall_net::sendRemindPasswd($email, $resetLink, $recipient = "piotrl86+bn-test-remind@gmail.com");
- } break;
- case 'testAuth': {
- $passwd = V::get('passwd', '', $_POST);
- $_testUserInfo = Theme_Auth_panel_biall_net::testAuth($email, $passwd);
- } break;
- }
- echo UI::h('form', [ 'method' => "POST" ], [
- UI::h('div', [ 'class' => "row" ], [
- UI::h('div', [ 'class' => "col-md-offset-3 col-md-6" ], [
- UI::h('div', [ 'class' => "form-group" ], [
- UI::h('label', [], "Adres email"),
- UI::h('input', [ 'type' => "text", 'name' => "email", 'value' => $email, 'class' => "form-control" ]),
- ]),
- UI::h('div', [ 'class' => "form-group" ], [
- UI::h('input', [ 'type' => "submit", 'value' => "Test", 'class' => "btn btn-primary" ]),
- ]),
- ]),
- ]),
- ]);
- if (empty($email)) throw new Exception("Proszę podać adres email");
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new Exception("Proszę podać poprawny adres email");
- echo UI::h('div', [], [
- UI::h('p', [], UI::h('code', [], $email)),
- UI::h('form', [ 'method' => "POST", 'style' => "margin:24px 0" ], [
- UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
- UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'makeAccounts' ]),
- UI::h('input', [ 'type' => "submit", 'value' => "Utwórz konta w panelu klienta", 'class' => "btn btn-warning" ]),
- ]),
- UI::h('form', [ 'method' => "POST", 'class' => "form-horizontal", 'style' => "margin:24px 0" ], [
- UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
- UI::h('label', [ 'class' => "col-md-1 control-label" ], "Hasło:"),
- UI::h('div', [ 'method' => "POST", 'class' => "col-md-4" ], [
- UI::h('input', [ 'type' => "text", 'name' => "passwd", 'value' => '', 'class' => "form-control" ]),
- ]),
- UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'testAuth' ]),
- UI::h('input', [ 'type' => "submit", 'value' => "Testuj logowanie do panelu klienta", 'class' => "btn btn-default" ]),
- ($_testUserInfo)
- ? UI::h('div', [ 'class' => "alert alert-success" ], [
- UI::h('p', [], "Klient: [{$_testUserInfo['ID']}] '{$_testUserInfo['P_NAME']} {$_testUserInfo['P_NAME_SECOND']}'"),
- ])
- : UI::h('div', [], "..."),
- ]),
- UI::h('form', [ 'method' => "POST", 'style' => "margin:24px 0" ], [
- UI::h('input', [ 'type' => "hidden", 'name' => "email", 'value' => $email ]),
- UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => 'resetPasswd' ]),
- UI::h('input', [ 'type' => "submit", 'value' => "Reset hasła do panelu klienta", 'class' => "btn btn-danger" ]),
- ]),
- UI::h('p', [], "All users:"),
- UI::hTable([ 'rows' => Theme_Auth_panel_biall_net::test_fetchAllUsers($email) ]),
- UI::h('p', [], "Active BIALL-NET users (BILLING_OWNER: 1 BN, 3 NETDAY):"),
- UI::hTable([ 'rows' => Theme_Auth_panel_biall_net::fetchActiveUsers($email) ]),
- ]);
- echo UI::h('div', [], [
- UI::h('p', [], "All auth:"),
- UI::hTable([ 'rows' => DB::getPDO()->fetchAll(" select * from PANEL_KLIENTA_BN_AUTH ") ]),
- ]);
- }
- }
|