PageRenderTime 28ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/download/admin/main.php

http://viet-group.googlecode.com/
PHP | 597 lines | 485 code | 81 blank | 31 comment | 59 complexity | e6384038338682f9c5738a69e37d9df2 MD5 | raw file
Possible License(s): BSD-3-Clause
  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 2-9-2010 14:43
  7. */
  8. if ( ! defined( 'NV_IS_FILE_ADMIN' ) ) die( 'Stop!!!' );
  9. //edit file
  10. if ( $nv_Request->isset_request( 'edit', 'get' ) )
  11. {
  12. $report = $nv_Request->isset_request( 'report', 'get' );
  13. $id = $nv_Request->get_int( 'id', 'get', 0 );
  14. if ( $id )
  15. {
  16. $query = "SELECT * FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  17. $result = $db->sql_query( $query );
  18. $numrows = $db->sql_numrows( $result );
  19. if ( $numrows != 1 )
  20. {
  21. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  22. exit();
  23. }
  24. define( 'IS_EDIT', true );
  25. $page_title = $lang_module['download_editfile'];
  26. $row = $db->sql_fetchrow( $result );
  27. }
  28. else
  29. {
  30. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  31. exit();
  32. }
  33. $groups_list = nv_groups_list();
  34. $array_who = array(
  35. $lang_global['who_view0'], $lang_global['who_view1'], $lang_global['who_view2']
  36. );
  37. if ( ! empty( $groups_list ) )
  38. {
  39. $array_who[] = $lang_global['who_view3'];
  40. }
  41. $array = array();
  42. $is_error = false;
  43. $error = "";
  44. if ( $nv_Request->isset_request( 'submit', 'post' ) )
  45. {
  46. $array['catid'] = $nv_Request->get_int( 'catid', 'post', 0 );
  47. $array['title'] = filter_text_input( 'title', 'post', '', 1 );
  48. $array['description'] = nv_editor_filter_textarea( 'description', '', NV_ALLOWED_HTML_TAGS );
  49. $array['introtext'] = filter_text_textarea( 'introtext', '', NV_ALLOWED_HTML_TAGS );
  50. $array['author_name'] = filter_text_input( 'author_name', 'post', '', 1 );
  51. $array['author_email'] = filter_text_input( 'author_email', 'post', '' );
  52. $array['author_url'] = filter_text_input( 'author_url', 'post', '' );
  53. $array['fileupload'] = $nv_Request->get_typed_array( 'fileupload', 'post', 'string' );
  54. $array['linkdirect'] = $nv_Request->get_typed_array( 'linkdirect', 'post', 'string' );
  55. $array['version'] = filter_text_input( 'version', 'post', '', 1 );
  56. $array['fileimage'] = filter_text_input( 'fileimage', 'post', '' );
  57. $array['copyright'] = filter_text_input( 'copyright', 'post', '', 1 );
  58. $array['comment_allow'] = $nv_Request->get_int( 'comment_allow', 'post', 0 );
  59. $array['who_comment'] = $nv_Request->get_int( 'who_comment', 'post', 0 );
  60. $array['groups_comment'] = $nv_Request->get_typed_array( 'groups_comment', 'post', 'int' );
  61. $array['is_del_report'] = $nv_Request->get_int( 'is_del_report', 'post', 0 );
  62. if ( ! empty( $array['author_url'] ) )
  63. {
  64. if ( ! preg_match( "#^(http|https|ftp|gopher)\:\/\/#", $array['author_url'] ) )
  65. {
  66. $array['author_url'] = "http://" . $array['author_url'];
  67. }
  68. }
  69. $array['filesize'] = 0;
  70. if ( ! empty( $array['fileupload'] ) )
  71. {
  72. $fileupload = $array['fileupload'];
  73. $array['fileupload'] = array();
  74. foreach ( $fileupload as $file )
  75. {
  76. if ( ! empty( $file ) )
  77. {
  78. $file2 = substr( $file, strlen( NV_BASE_SITEURL ) );
  79. if ( file_exists( NV_ROOTDIR . '/' . $file2 ) and ( $filesize = filesize( NV_ROOTDIR . '/' . $file2 ) ) != 0 )
  80. {
  81. $array['fileupload'][] = $file;
  82. $array['filesize'] += $filesize;
  83. }
  84. }
  85. }
  86. }
  87. else
  88. {
  89. $array['fileupload'] = array();
  90. }
  91. if ( ! empty( $array['linkdirect'] ) )
  92. {
  93. $linkdirect = $array['linkdirect'];
  94. $array['linkdirect'] = array();
  95. foreach ( $linkdirect as $links )
  96. {
  97. $linkdirect2 = array();
  98. if ( ! empty( $links ) )
  99. {
  100. $links = nv_nl2br( $links, "<br />" );
  101. $links = explode( "<br />", $links );
  102. $links = array_map( "trim", $links );
  103. $links = array_unique( $links );
  104. foreach ( $links as $link )
  105. {
  106. if ( ! preg_match( "#^(http|https|ftp|gopher)\:\/\/#", $link ) )
  107. {
  108. $link = "http://" . $link;
  109. }
  110. if ( nv_is_url( $link ) )
  111. {
  112. $linkdirect2[] = $link;
  113. }
  114. }
  115. }
  116. if ( ! empty( $linkdirect2 ) )
  117. {
  118. $array['linkdirect'][] = implode( "\n", $linkdirect2 );
  119. }
  120. }
  121. }
  122. else
  123. {
  124. $array['linkdirect'] = array();
  125. }
  126. if ( ! empty( $array['linkdirect'] ) )
  127. {
  128. $array['linkdirect'] = array_unique( $array['linkdirect'] );
  129. }
  130. if ( ! empty( $array['linkdirect'] ) and empty( $array['fileupload'] ) )
  131. {
  132. $array['filesize'] = $nv_Request->get_int( 'filesize', 'post', 0 );
  133. }
  134. $alias = change_alias( $array['title'] );
  135. $sql = "SELECT COUNT(*) FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`!=" . $id . " AND `alias`=" . $db->dbescape( $alias );
  136. $result = $db->sql_query( $sql );
  137. list( $is_exists ) = $db->sql_fetchrow( $result );
  138. if ( ! $is_exists )
  139. {
  140. $sql = "SELECT COUNT(*) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_tmp` WHERE `title`=" . $db->dbescape( $array['title'] );
  141. $result = $db->sql_query( $sql );
  142. list( $is_exists ) = $db->sql_fetchrow( $result );
  143. }
  144. if ( empty( $array['title'] ) )
  145. {
  146. $is_error = true;
  147. $error = $lang_module['file_error_title'];
  148. }
  149. elseif ( $is_exists )
  150. {
  151. $is_error = true;
  152. $error = $lang_module['file_title_exists'];
  153. }
  154. elseif ( ! empty( $array['author_email'] ) and ( $check_valid_email = nv_check_valid_email( $array['author_email'] ) ) != "" )
  155. {
  156. $is_error = true;
  157. $error = $check_valid_email;
  158. }
  159. elseif ( ! empty( $array['author_url'] ) and ! nv_is_url( $array['author_url'] ) )
  160. {
  161. $is_error = true;
  162. $error = $lang_module['file_error_author_url'];
  163. }
  164. elseif ( empty( $array['fileupload'] ) and empty( $array['linkdirect'] ) )
  165. {
  166. $is_error = true;
  167. $error = $lang_module['file_error_fileupload'];
  168. }
  169. else
  170. {
  171. $array['introtext'] = ! empty( $array['introtext'] ) ? nv_nl2br( $array['introtext'], "<br />" ) : "";
  172. $array['description'] = ! empty( $array['description'] ) ? nv_editor_nl2br( $array['description'] ) : $array['introtext'];
  173. $array['fileupload'] = ( ! empty( $array['fileupload'] ) ) ? implode( "[NV]", $array['fileupload'] ) : "";
  174. if ( ( ! empty( $array['linkdirect'] ) ) )
  175. {
  176. $array['linkdirect'] = array_map( "nv_nl2br", $array['linkdirect'] );
  177. $array['linkdirect'] = implode( "[NV]", $array['linkdirect'] );
  178. }
  179. else
  180. {
  181. $array['linkdirect'] = "";
  182. }
  183. if ( ! in_array( $array['who_comment'], array_keys( $array_who ) ) )
  184. {
  185. $array['who_comment'] = 0;
  186. }
  187. $array['groups_comment'] = ( ! empty( $array['groups_comment'] ) ) ? implode( ',', $array['groups_comment'] ) : '';
  188. $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET
  189. `catid`=" . $array['catid'] . ",
  190. `title`=" . $db->dbescape( $array['title'] ) . ",
  191. `alias`=" . $db->dbescape( $alias ) . ",
  192. `description`=" . $db->dbescape( $array['description'] ) . ",
  193. `introtext`=" . $db->dbescape( $array['introtext'] ) . ",
  194. `updatetime`=" . NV_CURRENTTIME . ",
  195. `author_name`=" . $db->dbescape( $array['author_name'] ) . ",
  196. `author_email`=" . $db->dbescape( $array['author_email'] ) . ",
  197. `author_url`=" . $db->dbescape( $array['author_url'] ) . ",
  198. `fileupload`=" . $db->dbescape( $array['fileupload'] ) . ",
  199. `linkdirect`=" . $db->dbescape( $array['linkdirect'] ) . ",
  200. `version`=" . $db->dbescape( $array['version'] ) . ",
  201. `filesize`=" . $array['filesize'] . ",
  202. `fileimage`=" . $db->dbescape( $array['fileimage'] ) . ",
  203. `copyright`=" . $db->dbescape( $array['copyright'] ) . ",
  204. `comment_allow`=" . $array['comment_allow'] . ",
  205. `who_comment`=" . $array['who_comment'] . ",
  206. `groups_comment`=" . $db->dbescape( $array['groups_comment'] ) . "
  207. WHERE `id`=" . $id;
  208. $result = $db->sql_query( $sql );
  209. if ( ! $result )
  210. {
  211. $is_error = true;
  212. $error = $lang_module['file_error1'];
  213. }
  214. else
  215. {
  216. if ( $report and $array['is_del_report'] )
  217. {
  218. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_report` WHERE `fid`=" . $id;
  219. $db->sql_query( $sql );
  220. }
  221. nv_insert_logs( NV_LANG_DATA, $module_name, $lang_module['download_editfile'], $array['title'], $admin_info['userid'] );
  222. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  223. exit();
  224. }
  225. }
  226. }
  227. else
  228. {
  229. $array['catid'] = ( int )$row['catid'];
  230. $array['title'] = $row['title'];
  231. $array['description'] = nv_editor_br2nl( $row['description'] );
  232. $array['introtext'] = nv_br2nl( $row['introtext'] );
  233. $array['author_name'] = $row['author_name'];
  234. $array['author_email'] = $row['author_email'];
  235. $array['author_url'] = $row['author_url'];
  236. $array['fileupload'] = $row['fileupload'];
  237. $array['linkdirect'] = $row['linkdirect'];
  238. $array['version'] = $row['version'];
  239. $array['filesize'] = ( int )$row['filesize'];
  240. $array['fileimage'] = $row['fileimage'];
  241. $array['copyright'] = $row['copyright'];
  242. $array['comment_allow'] = ( int )$row['comment_allow'];
  243. $array['who_comment'] = ( int )$row['who_comment'];
  244. $array['groups_comment'] = $row['groups_comment'];
  245. $array['fileupload'] = ! empty( $array['fileupload'] ) ? explode( "[NV]", $array['fileupload'] ) : array();
  246. if ( ! empty( $array['linkdirect'] ) )
  247. {
  248. $array['linkdirect'] = explode( "[NV]", $array['linkdirect'] );
  249. $array['linkdirect'] = array_map( "nv_br2nl", $array['linkdirect'] );
  250. }
  251. else
  252. {
  253. $array['linkdirect'] = array();
  254. }
  255. $array['groups_comment'] = ! empty( $array['groups_comment'] ) ? explode( ",", $array['groups_comment'] ) : array();
  256. $array['is_del_report'] = 1;
  257. }
  258. if ( ! empty( $array['description'] ) ) $array['description'] = nv_htmlspecialchars( $array['description'] );
  259. if ( ! empty( $array['introtext'] ) ) $array['introtext'] = nv_htmlspecialchars( $array['introtext'] );
  260. if ( ! count( $array['fileupload'] ) ) array_push( $array['fileupload'], "" );
  261. if ( ! count( $array['linkdirect'] ) ) array_push( $array['linkdirect'], "" );
  262. $array['fileupload_num'] = count( $array['fileupload'] );
  263. $array['linkdirect_num'] = count( $array['linkdirect'] );
  264. $listcats = nv_listcats( $array['catid'] );
  265. if ( empty( $listcats ) )
  266. {
  267. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" );
  268. exit();
  269. }
  270. $array['comment_allow'] = $array['comment_allow'] ? " checked=\"checked\"" : "";
  271. $array['is_del_report'] = $array['is_del_report'] ? " checked=\"checked\"" : "";
  272. $who_comment = $array['who_comment'];
  273. $array['who_comment'] = array();
  274. foreach ( $array_who as $key => $who )
  275. {
  276. $array['who_comment'][] = array( //
  277. 'key' => $key, //
  278. 'title' => $who, //
  279. 'selected' => $key == $who_comment ? " selected=\"selected\"" : "" //
  280. );
  281. }
  282. $groups_comment = $array['groups_comment'];
  283. $array['groups_comment'] = array();
  284. if ( ! empty( $groups_list ) )
  285. {
  286. foreach ( $groups_list as $key => $title )
  287. {
  288. $array['groups_comment'][] = array( //
  289. 'key' => $key, //
  290. 'title' => $title, //
  291. 'checked' => in_array( $key, $groups_comment ) ? " checked=\"checked\"" : "" //
  292. );
  293. }
  294. }
  295. if ( defined( 'NV_EDITOR' ) )
  296. {
  297. require_once ( NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php' );
  298. }
  299. if ( defined( 'NV_EDITOR' ) and nv_function_exists( 'nv_aleditor' ) )
  300. {
  301. $array['description'] = nv_aleditor( 'description', '100%', '300px', $array['description'] );
  302. }
  303. else
  304. {
  305. $array['description'] = "<textarea style=\"width:100%; height:300px\" name=\"description\" id=\"description\">" . $array['description'] . "</textarea>";
  306. }
  307. $sql = "SELECT `config_value` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_config` WHERE `config_name`='upload_dir'";
  308. $result = $db->sql_query( $sql );
  309. list( $upload_dir ) = $db->sql_fetchrow( $result );
  310. if ( ! $array['filesize'] ) $array['filesize'] = "";
  311. $xtpl = new XTemplate( "content.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  312. $report = $report ? "&amp;report=1" : "";
  313. $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;edit=1&amp;id=" . $id . $report );
  314. $xtpl->assign( 'LANG', $lang_module );
  315. $xtpl->assign( 'DATA', $array );
  316. $xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL );
  317. $xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE );
  318. $xtpl->assign( 'IMG_DIR', NV_UPLOADS_DIR . '/' . $module_name . '/images' );
  319. $xtpl->assign( 'FILES_DIR', NV_UPLOADS_DIR . '/' . $module_name . '/' . $upload_dir );
  320. if ( ! empty( $error ) )
  321. {
  322. $xtpl->assign( 'ERROR', $error );
  323. $xtpl->parse( 'main.error' );
  324. }
  325. foreach ( $listcats as $cat )
  326. {
  327. $xtpl->assign( 'LISTCATS', $cat );
  328. $xtpl->parse( 'main.catid' );
  329. }
  330. $a = 0;
  331. foreach ( $array['fileupload'] as $file )
  332. {
  333. $xtpl->assign( 'FILEUPLOAD', array(
  334. 'value' => $file, 'key' => $a
  335. ) );
  336. $xtpl->parse( 'main.fileupload' );
  337. $a ++;
  338. }
  339. $a = 0;
  340. foreach ( $array['linkdirect'] as $link )
  341. {
  342. $xtpl->assign( 'LINKDIRECT', array(
  343. 'value' => $link, 'key' => $a
  344. ) );
  345. $xtpl->parse( 'main.linkdirect' );
  346. $a ++;
  347. }
  348. foreach ( $array['who_comment'] as $who )
  349. {
  350. $xtpl->assign( 'WHO_COMMENT', $who );
  351. $xtpl->parse( 'main.who_comment' );
  352. }
  353. if ( ! empty( $array['groups_comment'] ) )
  354. {
  355. foreach ( $array['groups_comment'] as $group )
  356. {
  357. $xtpl->assign( 'GROUPS_COMMENT', $group );
  358. $xtpl->parse( 'main.group_empty.groups_comment' );
  359. }
  360. $xtpl->parse( 'main.group_empty' );
  361. }
  362. $xtpl->parse( 'main.is_del_report' );
  363. $xtpl->parse( 'main' );
  364. $contents = $xtpl->text( 'main' );
  365. include ( NV_ROOTDIR . "/includes/header.php" );
  366. echo nv_admin_theme( $contents );
  367. include ( NV_ROOTDIR . "/includes/footer.php" );
  368. exit();
  369. }
  370. //Kich hoat - dinh chi
  371. if ( $nv_Request->isset_request( 'changestatus', 'post' ) )
  372. {
  373. if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' );
  374. $id = $nv_Request->get_int( 'id', 'post', 0 );
  375. if ( empty( $id ) ) die( "NO" );
  376. $query = "SELECT `status` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  377. $result = $db->sql_query( $query );
  378. $numrows = $db->sql_numrows( $result );
  379. if ( $numrows != 1 ) die( 'NO' );
  380. list( $status ) = $db->sql_fetchrow( $result );
  381. $status = $status ? 0 : 1;
  382. $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `status`=" . $status . " WHERE `id`=" . $id;
  383. $db->sql_query( $sql );
  384. die( "OK" );
  385. }
  386. //Delete file
  387. if ( $nv_Request->isset_request( 'del', 'post' ) )
  388. {
  389. if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' );
  390. $id = $nv_Request->get_int( 'id', 'post', 0 );
  391. if ( ! $id ) die( "NO" );
  392. $query = "SELECT `fileupload`, `fileimage`,`title` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  393. $result = $db->sql_query( $query );
  394. $numrows = $db->sql_numrows( $result );
  395. if ( $numrows != 1 ) die( "NO" );
  396. $row = $db->sql_fetchrow( $result );
  397. //Khong xao file vi co the co truong hop file dung chung
  398. /*
  399. if(!empty($fileupload))
  400. {
  401. $fileupload = explode("[NV]",$fileupload);
  402. foreach($fileupload as $file)
  403. {
  404. $file = substr($file,strlen(NV_BASE_SITEURL));
  405. if ( ! empty( $file ) and file_exists( NV_ROOTDIR . '/' . $file ) )
  406. {
  407. @nv_deletefile( NV_ROOTDIR . '/' . $file );
  408. }
  409. }
  410. }
  411. $fileimage = substr($array['fileimage'],strlen(NV_BASE_SITEURL));
  412. if ( ! empty( $fileimage ) and file_exists( NV_ROOTDIR . '/' . $fileimage ) )
  413. {
  414. @nv_deletefile( NV_ROOTDIR . '/' . $fileimage );
  415. }*/
  416. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_comments` WHERE `fid`=" . $id;
  417. $db->sql_query( $sql );
  418. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_report` WHERE `fid`=" . $id;
  419. $db->sql_query( $sql );
  420. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  421. $db->sql_query( $sql );
  422. nv_insert_logs( NV_LANG_DATA, $module_data, $lang_module['download_filequeue_del'] ,$row['title'], $admin_info['userid'] );
  423. die( "OK" );
  424. }
  425. //List file
  426. $sql = "FROM `" . NV_PREFIXLANG . "_" . $module_data . "`";
  427. $base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name;
  428. $listcats = nv_listcats( 0 );
  429. if ( empty( $listcats ) )
  430. {
  431. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" );
  432. exit();
  433. }
  434. if ( $nv_Request->isset_request( "catid", "get" ) )
  435. {
  436. $catid = $nv_Request->get_int( 'catid', 'get', 0 );
  437. if ( ! $catid or ! isset( $listcats[$catid] ) )
  438. {
  439. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  440. exit();
  441. }
  442. $page_title = sprintf( $lang_module['file_list_by_cat'], $listcats[$catid]['title'] );
  443. $sql .= " WHERE `catid`=" . $catid;
  444. $base_url .= "&amp;catid=" . $catid;
  445. }
  446. else
  447. {
  448. $page_title = $lang_module['download_filemanager'];
  449. }
  450. $sql1 = "SELECT COUNT(*) " . $sql;
  451. $result1 = $db->sql_query( $sql1 );
  452. list( $all_page ) = $db->sql_fetchrow( $result1 );
  453. if ( ! $all_page )
  454. {
  455. if ( $catid )
  456. {
  457. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  458. exit();
  459. }
  460. else
  461. {
  462. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=add" );
  463. exit();
  464. }
  465. }
  466. $sql .= " ORDER BY `uploadtime` DESC";
  467. $page = $nv_Request->get_int( 'page', 'get', 0 );
  468. $per_page = 30;
  469. $sql2 = "SELECT * " . $sql . " LIMIT " . $page . ", " . $per_page;
  470. $query2 = $db->sql_query( $sql2 );
  471. $array = array();
  472. while ( $row = $db->sql_fetchrow( $query2 ) )
  473. {
  474. $array[$row['id']] = array( //
  475. 'id' => ( int )$row['id'], //
  476. 'title' => $row['title'], //
  477. 'cattitle' => $listcats[$row['catid']]['title'], //
  478. 'catlink' => NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;catid=" . $row['catid'], //
  479. 'uploadtime' => nv_date( "d/m/Y H:i", $row['uploadtime'] ), //
  480. 'status' => $row['status'] ? " checked=\"checked\"" : "", //
  481. 'view_hits' => ( int )$row['view_hits'], //
  482. 'download_hits' => ( int )$row['download_hits'], //
  483. 'comment_hits' => ( int )$row['comment_hits'] //
  484. );
  485. }
  486. $generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page );
  487. $xtpl = new XTemplate( "main.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  488. $xtpl->assign( 'LANG', $lang_module );
  489. $xtpl->assign( 'GLANG', $lang_global );
  490. $xtpl->assign( 'TABLE_CAPTION', $page_title );
  491. $xtpl->assign( 'ADD_NEW_FILE', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=add" );
  492. if ( ! empty( $array ) )
  493. {
  494. $a = 0;
  495. foreach ( $array as $row )
  496. {
  497. $xtpl->assign( 'CLASS', $a % 2 == 1 ? " class=\"second\"" : "" );
  498. $xtpl->assign( 'ROW', $row );
  499. $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;edit=1&amp;id=" . $row['id'] );
  500. $xtpl->parse( 'main.row' );
  501. $a ++;
  502. }
  503. }
  504. if ( ! empty( $generate_page ) )
  505. {
  506. $xtpl->assign( 'GENERATE_PAGE', $generate_page );
  507. $xtpl->parse( 'main.generate_page' );
  508. }
  509. $xtpl->parse( 'main' );
  510. $contents = $xtpl->text( 'main' );
  511. include ( NV_ROOTDIR . "/includes/header.php" );
  512. echo nv_admin_theme( $contents );
  513. include ( NV_ROOTDIR . "/includes/footer.php" );
  514. ?>