active_log_list.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <html>
  2. <body>
  3. <?php
  4. //显示log
  5. require_once '../path.php';
  6. require_once "../public/function.php";
  7. require_once "../public/php/define.php";
  8. if (isset($_COOKIE["uid"])) {
  9. $active_type[10] = "_CHANNEL_EDIT_";
  10. $active_type[11] = "_CHANNEL_NEW_";
  11. $active_type[20] = "_ARTICLE_EDIT_";
  12. $active_type[21] = "_ARTICLE_NEW_";
  13. $active_type[30] = "_DICT_LOOKUP_";
  14. $active_type[40] = "_TERM_EDIT_";
  15. $active_type[41] = "_TERM_LOOKUP_";
  16. $active_type[60] = "_WBW_EDIT_";
  17. $active_type[70] = "_SENT_EDIT_";
  18. $active_type[71] = "_SENT_NEW_";
  19. $active_type[80] = "_COLLECTION_EDIT_";
  20. $active_type[81] = "_COLLECTION_NEW_";
  21. $active_type[90] = "_NISSAYA_FIND_";
  22. $dns = "" . _FILE_DB_USER_ACTIVE_LOG_;
  23. $dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
  24. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  25. $query = "SELECT time,active,content,timezone FROM log WHERE user_id = ? ";
  26. $stmt = $dbh->prepare($query);
  27. $stmt->execute(array($_COOKIE["uid"]));
  28. echo "<table>";
  29. while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
  30. echo "<tr>";
  31. foreach ($row as $key => $value) {
  32. # code...
  33. switch ($key) {
  34. case 'active':
  35. # code...
  36. $output = isset($active_type[$value]) ? $active_type[$value] : $value;
  37. break;
  38. case 'time':
  39. # code...
  40. $output = gmdate("Y-m-d H:i:s", ($value + $row["timezone"]) / 1000);
  41. break;
  42. case 'timezone':
  43. # code...
  44. $output = round($value / 1000 / 60 / 60, 2);
  45. break;
  46. default:
  47. # code...
  48. $output = $value;
  49. break;
  50. }
  51. echo "<td>$output</td>";
  52. }
  53. echo "</tr>";
  54. }
  55. echo "</table>";
  56. } else {
  57. echo "尚未登录";
  58. }
  59. ?>
  60. </body>
  61. </html>