ChangeUser.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // class name must have the same name as file
  8. // index.php?_route=UrlAction_ChangeUser - uruchamia defaultAction
  9. class RouteTool_ChangeUser extends RouteToolBase {
  10. function handleAuth() {
  11. $id = V::get('id', '', $_POST);
  12. $authIds = (!empty($_SESSION['PANEL_BN_USERS'])) ? array_map(V::makePick('ID'), $_SESSION['PANEL_BN_USERS']) : [];
  13. // trigger_error(date("Y-m-d H:i:s") . "\t" . "panel_bn/RouteTool_ChangeUser to({$id}) ids:[".implode(",", $authIds)."]", E_USER_NOTICE);
  14. if (!$id || !in_array($id, $authIds)) {
  15. return Response::sendRedirect( "index.php" );
  16. }
  17. foreach ($_SESSION['PANEL_BN_USERS'] as $item) {
  18. if ($id != $item['ID']) continue;
  19. // trigger_error(date("Y-m-d H:i:s") . "\t" . "panel_bn/RouteTool_ChangeUser changed to({$id})", E_USER_NOTICE);
  20. @session_start();
  21. $_SESSION['ADM_ID'] = $item['ID'];
  22. // 'ADM_ACCOUNT' => $item['LOGIN'], // AUTHORIZE_USER, ADM_ACCOUNT
  23. $_SESSION['ADM_NAME'] = implode(" ", [ $item['P_NAME'], $item['P_NAME_SECOND'] ]); // ADM_NAME
  24. $_SESSION['ADM_COMPANY'] = $item['BILLING_OWNER']; // ADM_COMPANY
  25. session_write_close();
  26. sleep(1);
  27. // trigger_error(date("Y-m-d H:i:s") . "\t" . "panel_bn/RouteTool_ChangeUser ses: { ID: {$_SESSION['ID']}, ADM_NAME: {$_SESSION['ADM_NAME']} }", E_USER_NOTICE);
  28. }
  29. Response::sendRedirect( "index.php" );
  30. exit;
  31. }
  32. function defaultAction() {
  33. UI::gora();
  34. echo '<h1>ChangeUser Tool</h1>';
  35. UI::dol();
  36. }
  37. }