PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/01.Source/01.CORE/modules/download/admin/main.php

http://creative-portal.googlecode.com/
PHP | 597 lines | 483 code | 83 blank | 31 comment | 59 complexity | 6935ffe3f39827a1784bdb436510c157 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. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  222. exit();
  223. }
  224. }
  225. }
  226. else
  227. {
  228. $array['catid'] = ( int )$row['catid'];
  229. $array['title'] = $row['title'];
  230. $array['description'] = nv_editor_br2nl( $row['description'] );
  231. $array['introtext'] = nv_br2nl( $row['introtext'] );
  232. $array['author_name'] = $row['author_name'];
  233. $array['author_email'] = $row['author_email'];
  234. $array['author_url'] = $row['author_url'];
  235. $array['fileupload'] = $row['fileupload'];
  236. $array['linkdirect'] = $row['linkdirect'];
  237. $array['version'] = $row['version'];
  238. $array['filesize'] = ( int )$row['filesize'];
  239. $array['fileimage'] = $row['fileimage'];
  240. $array['copyright'] = $row['copyright'];
  241. $array['comment_allow'] = ( int )$row['comment_allow'];
  242. $array['who_comment'] = ( int )$row['who_comment'];
  243. $array['groups_comment'] = $row['groups_comment'];
  244. $array['fileupload'] = ! empty( $array['fileupload'] ) ? explode( "[NV]", $array['fileupload'] ) : array();
  245. if ( ! empty( $array['linkdirect'] ) )
  246. {
  247. $array['linkdirect'] = explode( "[NV]", $array['linkdirect'] );
  248. $array['linkdirect'] = array_map( "nv_br2nl", $array['linkdirect'] );
  249. }
  250. else
  251. {
  252. $array['linkdirect'] = array();
  253. }
  254. $array['groups_comment'] = ! empty( $array['groups_comment'] ) ? explode( ",", $array['groups_comment'] ) : array();
  255. $array['is_del_report'] = 1;
  256. }
  257. if ( ! empty( $array['description'] ) ) $array['description'] = nv_htmlspecialchars( $array['description'] );
  258. if ( ! empty( $array['introtext'] ) ) $array['introtext'] = nv_htmlspecialchars( $array['introtext'] );
  259. if ( ! count( $array['fileupload'] ) ) array_push( $array['fileupload'], "" );
  260. if ( ! count( $array['linkdirect'] ) ) array_push( $array['linkdirect'], "" );
  261. $array['fileupload_num'] = count( $array['fileupload'] );
  262. $array['linkdirect_num'] = count( $array['linkdirect'] );
  263. $listcats = nv_listcats( $array['catid'] );
  264. if ( empty( $listcats ) )
  265. {
  266. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" );
  267. exit();
  268. }
  269. $array['comment_allow'] = $array['comment_allow'] ? " checked=\"checked\"" : "";
  270. $array['is_del_report'] = $array['is_del_report'] ? " checked=\"checked\"" : "";
  271. $who_comment = $array['who_comment'];
  272. $array['who_comment'] = array();
  273. foreach ( $array_who as $key => $who )
  274. {
  275. $array['who_comment'][] = array( //
  276. 'key' => $key, //
  277. 'title' => $who, //
  278. 'selected' => $key == $who_comment ? " selected=\"selected\"" : "" //
  279. );
  280. }
  281. $groups_comment = $array['groups_comment'];
  282. $array['groups_comment'] = array();
  283. if ( ! empty( $groups_list ) )
  284. {
  285. foreach ( $groups_list as $key => $title )
  286. {
  287. $array['groups_comment'][] = array( //
  288. 'key' => $key, //
  289. 'title' => $title, //
  290. 'checked' => in_array( $key, $groups_comment ) ? " checked=\"checked\"" : "" //
  291. );
  292. }
  293. }
  294. if ( defined( 'NV_EDITOR' ) )
  295. {
  296. require_once ( NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php' );
  297. }
  298. if ( defined( 'NV_EDITOR' ) and function_exists( 'nv_aleditor' ) )
  299. {
  300. $array['description'] = nv_aleditor( 'description', '100%', '300px', $array['description'] );
  301. }
  302. else
  303. {
  304. $array['description'] = "<textarea style=\"width:100%; height:300px\" name=\"description\" id=\"description\">" . $array['description'] . "</textarea>";
  305. }
  306. $sql = "SELECT `config_value` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_config` WHERE `config_name`='upload_dir'";
  307. $result = $db->sql_query( $sql );
  308. list( $upload_dir ) = $db->sql_fetchrow( $result );
  309. if ( ! $array['filesize'] ) $array['filesize'] = "";
  310. $xtpl = new XTemplate( "content.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  311. $report = $report ? "&amp;report=1" : "";
  312. $xtpl->assign( 'FORM_ACTION', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;edit=1&amp;id=" . $id . $report );
  313. $xtpl->assign( 'LANG', $lang_module );
  314. $xtpl->assign( 'DATA', $array );
  315. $xtpl->assign( 'NV_BASE_ADMINURL', NV_BASE_ADMINURL );
  316. $xtpl->assign( 'NV_NAME_VARIABLE', NV_NAME_VARIABLE );
  317. $xtpl->assign( 'IMG_DIR', NV_UPLOADS_DIR . '/' . $module_name . '/images' );
  318. $xtpl->assign( 'FILES_DIR', NV_UPLOADS_DIR . '/' . $module_name . '/' . $upload_dir );
  319. if ( ! empty( $error ) )
  320. {
  321. $xtpl->assign( 'ERROR', $error );
  322. $xtpl->parse( 'main.error' );
  323. }
  324. foreach ( $listcats as $cat )
  325. {
  326. $xtpl->assign( 'LISTCATS', $cat );
  327. $xtpl->parse( 'main.catid' );
  328. }
  329. $a = 0;
  330. foreach ( $array['fileupload'] as $file )
  331. {
  332. $xtpl->assign( 'FILEUPLOAD', array(
  333. 'value' => $file, 'key' => $a
  334. ) );
  335. $xtpl->parse( 'main.fileupload' );
  336. $a ++;
  337. }
  338. $a = 0;
  339. foreach ( $array['linkdirect'] as $link )
  340. {
  341. $xtpl->assign( 'LINKDIRECT', array(
  342. 'value' => $link, 'key' => $a
  343. ) );
  344. $xtpl->parse( 'main.linkdirect' );
  345. $a ++;
  346. }
  347. foreach ( $array['who_comment'] as $who )
  348. {
  349. $xtpl->assign( 'WHO_COMMENT', $who );
  350. $xtpl->parse( 'main.who_comment' );
  351. }
  352. if ( ! empty( $array['groups_comment'] ) )
  353. {
  354. foreach ( $array['groups_comment'] as $group )
  355. {
  356. $xtpl->assign( 'GROUPS_COMMENT', $group );
  357. $xtpl->parse( 'main.group_empty.groups_comment' );
  358. }
  359. $xtpl->parse( 'main.group_empty' );
  360. }
  361. $xtpl->parse( 'main.is_del_report' );
  362. $xtpl->parse( 'main' );
  363. $contents = $xtpl->text( 'main' );
  364. include ( NV_ROOTDIR . "/includes/header.php" );
  365. echo nv_admin_theme( $contents );
  366. include ( NV_ROOTDIR . "/includes/footer.php" );
  367. exit();
  368. }
  369. //Kich hoat - dinh chi
  370. if ( $nv_Request->isset_request( 'changestatus', 'post' ) )
  371. {
  372. if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' );
  373. $id = $nv_Request->get_int( 'id', 'post', 0 );
  374. if ( empty( $id ) ) die( "NO" );
  375. $query = "SELECT `status` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  376. $result = $db->sql_query( $query );
  377. $numrows = $db->sql_numrows( $result );
  378. if ( $numrows != 1 ) die( 'NO' );
  379. list( $status ) = $db->sql_fetchrow( $result );
  380. $status = $status ? 0 : 1;
  381. $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "` SET `status`=" . $status . " WHERE `id`=" . $id;
  382. $db->sql_query( $sql );
  383. die( "OK" );
  384. }
  385. //Delete file
  386. if ( $nv_Request->isset_request( 'del', 'post' ) )
  387. {
  388. if ( ! defined( 'NV_IS_AJAX' ) ) die( 'Wrong URL' );
  389. $id = $nv_Request->get_int( 'id', 'post', 0 );
  390. if ( ! $id ) die( "NO" );
  391. $query = "SELECT `fileupload`, `fileimage` FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  392. $result = $db->sql_query( $query );
  393. $numrows = $db->sql_numrows( $result );
  394. if ( $numrows != 1 ) die( "NO" );
  395. $row = $db->sql_fetchrow( $result );
  396. //Khong xao file vi co the co truong hop file dung chung
  397. /*
  398. if(!empty($fileupload))
  399. {
  400. $fileupload = explode("[NV]",$fileupload);
  401. foreach($fileupload as $file)
  402. {
  403. $file = substr($file,strlen(NV_BASE_SITEURL));
  404. if ( ! empty( $file ) and file_exists( NV_ROOTDIR . '/' . $file ) )
  405. {
  406. @nv_deletefile( NV_ROOTDIR . '/' . $file );
  407. }
  408. }
  409. }
  410. $fileimage = substr($array['fileimage'],strlen(NV_BASE_SITEURL));
  411. if ( ! empty( $fileimage ) and file_exists( NV_ROOTDIR . '/' . $fileimage ) )
  412. {
  413. @nv_deletefile( NV_ROOTDIR . '/' . $fileimage );
  414. }*/
  415. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_comments` WHERE `fid`=" . $id;
  416. $db->sql_query( $sql );
  417. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "_report` WHERE `fid`=" . $id;
  418. $db->sql_query( $sql );
  419. $sql = "DELETE FROM `" . NV_PREFIXLANG . "_" . $module_data . "` WHERE `id`=" . $id;
  420. $db->sql_query( $sql );
  421. die( "OK" );
  422. }
  423. //List file
  424. $sql = "FROM `" . NV_PREFIXLANG . "_" . $module_data . "`";
  425. $base_url = NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name;
  426. $listcats = nv_listcats( 0 );
  427. if ( empty( $listcats ) )
  428. {
  429. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=cat&add=1" );
  430. exit();
  431. }
  432. if ( $nv_Request->isset_request( "catid", "get" ) )
  433. {
  434. $catid = $nv_Request->get_int( 'catid', 'get', 0 );
  435. if ( ! $catid or ! isset( $listcats[$catid] ) )
  436. {
  437. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  438. exit();
  439. }
  440. $page_title = sprintf( $lang_module['file_list_by_cat'], $listcats[$catid]['title'] );
  441. $sql .= " WHERE `catid`=" . $catid;
  442. $base_url .= "&amp;catid=" . $catid;
  443. }
  444. else
  445. {
  446. $page_title = $lang_module['download_filemanager'];
  447. }
  448. $sql1 = "SELECT COUNT(*) " . $sql;
  449. $result1 = $db->sql_query( $sql1 );
  450. list( $all_page ) = $db->sql_fetchrow( $result1 );
  451. if ( ! $all_page )
  452. {
  453. if ( $catid )
  454. {
  455. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name );
  456. exit();
  457. }
  458. else
  459. {
  460. Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=add" );
  461. exit();
  462. }
  463. }
  464. $sql .= " ORDER BY `uploadtime` DESC";
  465. $page = $nv_Request->get_int( 'page', 'get', 0 );
  466. $per_page = 30;
  467. $sql2 = "SELECT * " . $sql . " LIMIT " . $page . ", " . $per_page;
  468. $query2 = $db->sql_query( $sql2 );
  469. $array = array();
  470. while ( $row = $db->sql_fetchrow( $query2 ) )
  471. {
  472. $array[$row['id']] = array( //
  473. 'id' => ( int )$row['id'], //
  474. 'title' => $row['title'], //
  475. 'cattitle' => $listcats[$row['catid']]['title'], //
  476. 'catlink' => NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;catid=" . $row['catid'], //
  477. 'uploadtime' => nv_date( "d/m/Y H:i", $row['uploadtime'] ), //
  478. 'status' => $row['status'] ? " checked=\"checked\"" : "", //
  479. 'view_hits' => ( int )$row['view_hits'], //
  480. 'download_hits' => ( int )$row['download_hits'], //
  481. 'comment_hits' => ( int )$row['comment_hits'] //
  482. );
  483. }
  484. $generate_page = nv_generate_page( $base_url, $all_page, $per_page, $page );
  485. $xtpl = new XTemplate( "main.tpl", NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $module_file );
  486. $xtpl->assign( 'LANG', $lang_module );
  487. $xtpl->assign( 'GLANG', $lang_global );
  488. $xtpl->assign( 'TABLE_CAPTION', $page_title );
  489. $xtpl->assign( 'ADD_NEW_FILE', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=add" );
  490. if ( ! empty( $array ) )
  491. {
  492. $a = 0;
  493. foreach ( $array as $row )
  494. {
  495. $xtpl->assign( 'CLASS', $a % 2 == 1 ? " class=\"second\"" : "" );
  496. $xtpl->assign( 'ROW', $row );
  497. $xtpl->assign( 'EDIT_URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;edit=1&amp;id=" . $row['id'] );
  498. $xtpl->parse( 'main.row' );
  499. $a ++;
  500. }
  501. }
  502. if ( ! empty( $generate_page ) )
  503. {
  504. $xtpl->assign( 'GENERATE_PAGE', $generate_page );
  505. $xtpl->parse( 'main.generate_page' );
  506. }
  507. $xtpl->parse( 'main' );
  508. $contents = $xtpl->text( 'main' );
  509. include ( NV_ROOTDIR . "/includes/header.php" );
  510. echo nv_admin_theme( $contents );
  511. include ( NV_ROOTDIR . "/includes/footer.php" );
  512. ?>