PageRenderTime 39ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/NukeViet3.3/admin/modules/webtools/main.php

http://nuke-viet.googlecode.com/
PHP | 160 lines | 128 code | 18 blank | 14 comment | 16 complexity | 864f71539cb52d6b53ffdc6566ae2810 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  6. * @Createdate 9/9/2010, 6:38
  7. */
  8. if (!defined('NV_IS_FILE_WEBTOOLS'))
  9. die('Stop!!!');
  10. $page_title = $lang_module['nukevietChange_caption'];
  11. /**
  12. * NukevietChange_getContents()
  13. *
  14. * @param bool $refresh
  15. * @return
  16. */
  17. function NukevietChange_getContents($refresh = false)
  18. {
  19. global $global_config;
  20. $url = "http://code.google.com/feeds/p/nuke-viet/svnchanges/basic";
  21. $xmlfile = "nukevietGoogleCode.cache";
  22. $load = false;
  23. $p = NV_CURRENTTIME - 18000;
  24. $p2 = NV_CURRENTTIME - 120;
  25. if (!file_exists(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $xmlfile))
  26. $load = true;
  27. else
  28. {
  29. $filemtime = @filemtime(NV_ROOTDIR . "/" . NV_CACHEDIR . "/" . $xmlfile);
  30. if ($filemtime < $p)
  31. $load = true;
  32. elseif ($refresh and $filemtime < $p2)
  33. $load = true;
  34. }
  35. if ($load)
  36. {
  37. include (NV_ROOTDIR . '/includes/class/geturl.class.php');
  38. $UrlGetContents = new UrlGetContents($global_config);
  39. $content = $UrlGetContents->get($url);
  40. if (!empty($content))
  41. {
  42. if (nv_function_exists('mb_convert_encoding'))
  43. $content = mb_convert_encoding($content, "utf-8");
  44. $content = simplexml_load_string($content);
  45. $content = nv_object2array($content);
  46. if (!empty($content))
  47. {
  48. $code = array();
  49. $code['updated'] = strtotime($content['updated']);
  50. $code['link'] = $content['link'][0]['@attributes']['href'];
  51. $code['entry'] = array();
  52. if (isset($content['entry']) and !empty($content['entry']))
  53. {
  54. foreach ($content['entry'] as $entry)
  55. {
  56. unset($matches);
  57. $cont = $entry['content'];
  58. preg_match_all("/(modify|add|delete)[^a-z0-9\/\.\-\_]+(\/trunk\/nukeviet3.3\/)([a-z0-9\/\.\-\_]+)/mi", $cont, $matches, PREG_SET_ORDER);
  59. $cont = array();
  60. if (!empty($matches))
  61. {
  62. foreach ($matches as $matche)
  63. {
  64. $key = strtolower($matche[1]);
  65. if (!isset($cont[$key]))
  66. $cont[$key] = array();
  67. $cont[$key][] = $matche[3];
  68. }
  69. }
  70. unset($matches2);
  71. preg_match("/Revision[\s]+([\d]*)[\s]*\:[\s]+(.*?)/Uis", $entry['title'], $matches2);
  72. $code['entry'][] = array(//
  73. 'updated' => strtotime($entry['updated']), //
  74. 'title' => $matches2[2], //
  75. 'id' => $matches2[1], //
  76. 'link' => $entry['link']['@attributes']['href'], //
  77. 'author' => $entry['author']['name'], //
  78. 'content' => $cont //
  79. );
  80. }
  81. nv_set_cache($xmlfile, serialize($code));
  82. return $code;
  83. }
  84. }
  85. }
  86. }
  87. $content = nv_get_cache($xmlfile);
  88. if (!$content)
  89. return false;
  90. $content = unserialize($content);
  91. return $content;
  92. }
  93. //Cap nhat thong tin tu du an NukeViet tren Google Code
  94. if ($nv_Request->isset_request('gcode', 'get') and ($gcode = $nv_Request->get_int('gcode', 'get', 0)))
  95. {
  96. if (!defined('NV_IS_SPADMIN')) die();
  97. if ($gcode != 1)
  98. $changes = NukevietChange_getContents(true);
  99. else
  100. $changes = NukevietChange_getContents();
  101. if (!empty($changes) and !empty($changes['entry']))
  102. {
  103. $xtpl = new XTemplate("googlecode.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file);
  104. $xtpl->assign('LANG', $lang_module);
  105. $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
  106. $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
  107. $xtpl->assign('MODULE_NAME', $module_name);
  108. $xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
  109. $xtpl->assign('UPDATED', $lang_module['nukevietChange_upd'] . nv_date(" d-m-Y H:i", $changes['updated']));
  110. $xtpl->assign('REFRESH', $lang_module['nukevietChange_refresh']);
  111. $xtpl->assign('VISIT', $changes['link']);
  112. foreach ($changes['entry'] as $key => $entry)
  113. {
  114. //if ( $key == 10 ) break;
  115. $entry['tooltip'] = array();
  116. foreach ($entry['content'] as $k => $v)
  117. {
  118. $entry['tooltip'][] = "<strong>" . $lang_module['nukevietChange_' . $k] . "</strong>: " . implode(", ", $v);
  119. }
  120. $entry['tooltip'] = !empty($entry['tooltip']) ? "<ul><li>" . implode("</li><li>", $entry['tooltip']) . "</li></ul>" : "";
  121. $entry['updated'] = nv_date("d-m-Y H:i", $entry['updated']);
  122. $xtpl->assign('CLASS', ($key % 2) ? " class=\"second\"" : "");
  123. $xtpl->assign('ENTRY', $entry);
  124. $xtpl->parse('NukevietChange.loop');
  125. }
  126. $xtpl->parse('NukevietChange');
  127. $contents = $xtpl->text('NukevietChange');
  128. include (NV_ROOTDIR . "/includes/header.php");
  129. echo $contents;
  130. include (NV_ROOTDIR . "/includes/footer.php");
  131. }
  132. die();
  133. }
  134. $xtpl = new XTemplate("main.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file);
  135. $xtpl->assign('LANG', $lang_module);
  136. $xtpl->assign('NV_BASE_SITEURL', NV_BASE_SITEURL);
  137. $xtpl->parse('main');
  138. $contents = $xtpl->text('main');
  139. include (NV_ROOTDIR . "/includes/header.php");
  140. echo nv_admin_theme($contents);
  141. include (NV_ROOTDIR . "/includes/footer.php");
  142. ?>