user_log_edit.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. //includes files
  3. require_once dirname(__DIR__, 2) . "/resources/require.php";
  4. require_once "resources/check_auth.php";
  5. //check permissions
  6. if (permission_exists('user_log_view')) {
  7. //access granted
  8. }
  9. else {
  10. echo "access denied";
  11. exit;
  12. }
  13. //add multi-lingual support
  14. $language = new text;
  15. $text = $language->get();
  16. //get the uuid
  17. $user_log_uuid = $_GET['id'];
  18. //pre-populate the form
  19. if (!empty($_GET) && is_array($_GET) && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) {
  20. $sql = "select * from v_user_logs ";
  21. $sql .= "where user_log_uuid = :user_log_uuid ";
  22. //$sql .= "and domain_uuid = :domain_uuid ";
  23. //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  24. $parameters['user_log_uuid'] = $user_log_uuid;
  25. $database = new database;
  26. $row = $database->select($sql, $parameters, 'row');
  27. if (is_array($row) && @sizeof($row) != 0) {
  28. $domain_uuid = $row["domain_uuid"];
  29. $timestamp = $row["timestamp"];
  30. $user_uuid = $row["user_uuid"];
  31. $username = $row["username"];
  32. $type = $row["type"];
  33. $result = $row["result"];
  34. $remote_address = $row["remote_address"];
  35. $user_agent = $row["user_agent"];
  36. }
  37. unset($sql, $parameters, $row);
  38. }
  39. //create token
  40. $object = new token;
  41. $token = $object->create($_SERVER['PHP_SELF']);
  42. //show the header
  43. $document['title'] = $text['title-user_log'];
  44. require_once "resources/header.php";
  45. //get the users
  46. $sql = "SELECT user_uuid, username FROM v_users ";
  47. $sql .= "WHERE domain_uuid = :domain_uuid ";
  48. $sql .= "ORDER by username asc ";
  49. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  50. $database = new database;
  51. $users = $database->execute($sql, $parameters, 'all');
  52. unset ($sql, $parameters);
  53. //show the content
  54. echo "<form name='frm' id='frm' method='post' action=''>\n";
  55. echo "<input class='formfld' type='hidden' name='user_log_uuid' value='".escape($user_log_uuid)."'>\n";
  56. echo "<div class='action_bar' id='action_bar'>\n";
  57. echo " <div class='heading'><b>".$text['title-user_log']."</b></div>\n";
  58. echo " <div class='actions'>\n";
  59. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'user_logs.php']);
  60. echo " </div>\n";
  61. echo " <div style='clear: both;'></div>\n";
  62. echo "</div>\n";
  63. echo $text['title_description-user_logs']."\n";
  64. echo "<br /><br />\n";
  65. echo "<div class='card'>\n";
  66. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  67. echo "<tr>\n";
  68. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  69. echo " ".$text['label-domain_uuid']."\n";
  70. echo "</td>\n";
  71. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  72. echo " <select class='formfld' name='domain_uuid'>\n";
  73. if (empty($domain_uuid)) {
  74. echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
  75. }
  76. else {
  77. echo " <option value=''>".$text['label-global']."</option>\n";
  78. }
  79. foreach ($_SESSION['domains'] as $row) {
  80. if ($row['domain_uuid'] == $domain_uuid) {
  81. echo " <option value='".$row['domain_uuid']."' selected='selected'>".escape($row['domain_name'])."</option>\n";
  82. }
  83. else {
  84. echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
  85. }
  86. }
  87. echo " </select>\n";
  88. echo "<br />\n";
  89. echo $text['description-domain_uuid']."\n";
  90. echo "</td>\n";
  91. echo "</tr>\n";
  92. echo "<tr>\n";
  93. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  94. echo " ".$text['label-timestamp']."\n";
  95. echo "</td>\n";
  96. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  97. echo " <input class='formfld' type='text' name='timestamp' maxlength='255' value='".escape($timestamp)."'>\n";
  98. echo "<br />\n";
  99. echo $text['description-timestamp']."\n";
  100. echo "</td>\n";
  101. echo "</tr>\n";
  102. echo "<tr>\n";
  103. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  104. echo " ".$text['label-user_uuid']."\n";
  105. echo "</td>\n";
  106. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  107. echo " <select class='formfld' name='user_uuid'>\n";
  108. echo " <option value=''></option>\n";
  109. foreach($users as $field) {
  110. if ($field['user_uuid'] == $user_uuid) { $selected = "selected='selected'"; } else { $selected = ''; }
  111. echo " <option value='".$field['user_uuid']."' $selected>".escape($field['username'])."</option>\n";
  112. }
  113. echo " </select>\n";
  114. echo "<br />\n";
  115. echo $text['description-user_uuid']."\n";
  116. echo "</td>\n";
  117. echo "</tr>\n";
  118. echo "<tr>\n";
  119. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  120. echo " ".$text['label-username']."\n";
  121. echo "</td>\n";
  122. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  123. echo " <input class='formfld' type='text' name='username' maxlength='255' value='".escape($username)."'>\n";
  124. echo "<br />\n";
  125. echo $text['description-username']."\n";
  126. echo "</td>\n";
  127. echo "</tr>\n";
  128. echo "<tr>\n";
  129. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  130. echo " ".$text['label-type']."\n";
  131. echo "</td>\n";
  132. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  133. echo " <input class='formfld' type='text' name='type' maxlength='255' value='".escape($type)."'>\n";
  134. echo "<br />\n";
  135. echo $text['description-type']."\n";
  136. echo "</td>\n";
  137. echo "</tr>\n";
  138. echo "<tr>\n";
  139. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  140. echo " ".$text['label-result']."\n";
  141. echo "</td>\n";
  142. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  143. echo " <select class='formfld' name='result'>\n";
  144. echo " <option value=''></option>\n";
  145. if ($result == "success") {
  146. echo " <option value='success' selected='selected'>".$text['label-success']."</option>\n";
  147. }
  148. else {
  149. echo " <option value='success'>".$text['label-success']."</option>\n";
  150. }
  151. if ($result == "failure") {
  152. echo " <option value='failure' selected='selected'>".$text['label-failure']."</option>\n";
  153. }
  154. else {
  155. echo " <option value='failure'>".$text['label-failure']."</option>\n";
  156. }
  157. echo " </select>\n";
  158. echo "<br />\n";
  159. echo $text['description-result']."\n";
  160. echo "</td>\n";
  161. echo "</tr>\n";
  162. echo "<tr>\n";
  163. echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
  164. echo " ".$text['label-remote_address']."\n";
  165. echo "</td>\n";
  166. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  167. echo " <input class='formfld' type='text' name='remote_address' maxlength='255' value='".escape($remote_address)."'>\n";
  168. echo "<br />\n";
  169. echo $text['description-remote_address']."\n";
  170. echo "</td>\n";
  171. echo "</tr>\n";
  172. echo "<tr>\n";
  173. echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
  174. echo " ".$text['label-user_agent']."\n";
  175. echo "</td>\n";
  176. echo "<td class='vtable' style='position: relative;' align='left'>\n";
  177. echo " <input class='formfld' type='text' name='user_agent' maxlength='255' value='".escape($user_agent)."'>\n";
  178. echo "<br />\n";
  179. echo $text['description-user_agent']."\n";
  180. echo "</td>\n";
  181. echo "</tr>\n";
  182. echo "</table>";
  183. echo "</div>";
  184. echo "<br /><br />";
  185. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  186. echo "</form>";
  187. //include the footer
  188. require_once "resources/footer.php";
  189. ?>