PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/vpsadmin/pages/page_transactions.php

http://pef.googlecode.com/
PHP | 84 lines | 47 code | 11 blank | 26 comment | 11 complexity | 4a3b91c638be405a5cdedcd80d88b145 MD5 | raw file
  1. <?php
  2. /*
  3. ./pages/page_transactions.php
  4. vpsAdmin
  5. Web-admin interface for OpenVZ (see http://openvz.org)
  6. Copyright (C) 2008-2009 Pavel Snajdr, snajpa@snajpa.net
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. if ($_SESSION["is_admin"]) {
  19. $xtpl->title(_("Transaction log"));
  20. $sql = 'SELECT COUNT(*) as `entries` FROM transactions, servers, members WHERE members.m_id = transactions.t_m_id AND transactions.t_server = servers.server_id ORDER BY t_id DESC;';
  21. $t = $db->fetch_array($db->query($sql));
  22. $entries = $t["entries"];
  23. $pages = ceil($entries/$cfg_transactions["per_page"]);
  24. if (isset($_GET["id"])) {
  25. /* $xtpl->table_add_category('');
  26. * $xtpl->table_add_category('');
  27. * $xtpl->table_td('Not Implemented Yet');
  28. * $xtpl->table_td('');
  29. * $xtpl->table_tr();
  30. * $xtpl->table_out();
  31. */}
  32. $xtpl->table_begin(gen_pages_listing($_GET["page_number"], $pages, $cfg_transactions["max_offset_listing"]));
  33. $xtpl->table_add_category('T_ID');
  34. $xtpl->table_add_category(strtoupper(_("time of addition")));
  35. $xtpl->table_add_category(strtoupper(_("member")));
  36. $xtpl->table_add_category(strtoupper(_("server")));
  37. $xtpl->table_add_category(strtoupper(_("vps")));
  38. $xtpl->table_add_category(strtoupper(_("type of action")));
  39. $xtpl->table_add_category(strtoupper(_("done")));
  40. $xtpl->table_add_category(strtoupper(_("ok?")));
  41. $sql = 'SELECT * FROM transactions
  42. LEFT JOIN members
  43. ON transactions.t_m_id = members.m_id
  44. LEFT JOIN servers
  45. ON transactions.t_server = servers.server_id
  46. ORDER BY transactions.t_id DESC LIMIT '.(($_GET["page_number"]*$cfg_transactions["per_page"])*1).','.$cfg_transactions["per_page"].';';
  47. if ($result = $db->query($sql))
  48. while ($t = $db->fetch_array($result)) {
  49. $xtpl->table_td($t["t_id"]);
  50. $xtpl->table_td(strftime("%Y-%m-%d %H:%M", $t["t_time"]));
  51. $xtpl->table_td($t["m_nick"]);
  52. $xtpl->table_td(($t["server_name"] == "") ? _("--Every--") : $t["server_name"]);
  53. $xtpl->table_td(($t["t_vps"] == 0) ? _("--Every--") : $t["t_vps"]);
  54. $xtpl->table_td(transaction_label($t["t_type"]));
  55. $xtpl->table_td($t["t_done"]);
  56. $xtpl->table_td($t["t_success"]);
  57. if ($t["t_done"]==1 && $t["t_success"]==1)
  58. $xtpl->table_tr(false, 'ok');
  59. elseif ($t["t_done"]==1 && $t["t_success"]==0)
  60. $xtpl->table_tr(false, 'error');
  61. elseif ($t["t_done"]==0 && $t["t_success"]==0)
  62. $xtpl->table_tr(false, 'pending');
  63. else
  64. $xtpl->table_tr();
  65. }
  66. $xtpl->table_end(gen_pages_listing($_GET["page_number"], $pages, $cfg_transactions["max_offset_listing"]));
  67. $xtpl->table_out();
  68. } else $xtpl->perex(_("Access forbidden"), _("You have to log in to be able to access vpsAdmin's functions"));
  69. ?>