Guest User

Untitled

a guest
Jan 10th, 2013
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.29 KB | None | 0 0
  1. <?php
  2. /*
  3. =====================================================
  4. DataLife Engine - by SoftNews Media Group
  5. -----------------------------------------------------
  6. http://dle-news.ru/
  7. -----------------------------------------------------
  8. Copyright (c) 2004,2012 SoftNews Media Group
  9. =====================================================
  10. Данный код защищен авторскими правами
  11. =====================================================
  12. Файл: show.short.php
  13. -----------------------------------------------------
  14. Назначение: вывод новостей
  15. =====================================================
  16. */
  17.  
  18. if( ! defined( 'DATALIFEENGINE' ) ) {
  19. die( "Hacking attempt!" );
  20. }
  21.  
  22. if( $allow_active_news ) {
  23.  
  24. if( $config['allow_banner'] ) include_once ENGINE_DIR . '/modules/banners.php';
  25.  
  26. $i = $cstart;
  27. $news_found = FALSE;
  28.  
  29. if( isset( $view_template ) and $view_template == "rss" ) {
  30. } elseif( $category_id and $cat_info[$category_id]['short_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['short_tpl'] . '.tpl' );
  31. else $tpl->load_template( 'shortstory.tpl' );
  32.  
  33. if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) { $xfound = true; $xfields = xfieldsload();}
  34. else $xfound = false;
  35.  
  36. if( count( $banners ) AND $config['allow_banner'] AND !$smartphone_detected) {
  37.  
  38. $news_c = 1;
  39.  
  40. if( isset( $ban_short ) ) {
  41. for($indx = 0, $max = sizeof( $ban_short['top'] ), $banners_topz = ''; $indx < $max; $indx ++)
  42. if( $ban_short['top'][$indx]['zakr'] ) {
  43. $banners_topz .= $ban_short['top'][$indx]['text'];
  44. unset( $ban_short['top'][$indx] );
  45. }
  46.  
  47. for($indx = 0, $max = sizeof( $ban_short['cen'] ), $banners_cenz = ''; $indx < $max; $indx ++)
  48. if( $ban_short['cen'][$indx]['zakr'] ) {
  49. $banners_cenz .= $ban_short['cen'][$indx]['text'];
  50. unset( $ban_short['cen'][$indx] );
  51. }
  52.  
  53. for($indx = 0, $max = sizeof( $ban_short['down'] ), $banners_downz = ''; $indx < $max; $indx ++)
  54. if( $ban_short['down'][$indx]['zakr'] ) {
  55. $banners_downz .= $ban_short['down'][$indx]['text'];
  56. unset( $ban_short['down'][$indx] );
  57. }
  58.  
  59. $middle = floor( $config['news_number'] / 2 );
  60. $middle_s = floor( ($middle - 1) / 2 );
  61. $middle_e = floor( $middle + (($config['news_number'] - $middle) / 2) + 1 );
  62. }
  63. }
  64.  
  65. $sql_result = $db->query( $sql_select );
  66.  
  67. if( ! isset( $view_template ) ) {
  68.  
  69. $count_all = $db->super_query( $sql_count );
  70. $count_all = $count_all['count'];
  71.  
  72. } else
  73. $count_all = 0;
  74.  
  75. while ( $row = $db->get_row( $sql_result ) ) {
  76.  
  77. $news_found = TRUE;
  78. $attachments[] = $row['id'];
  79. $row['date'] = strtotime( $row['date'] );
  80.  
  81. if( isset( $middle ) ) {
  82.  
  83. if( $news_c == $middle_s ) {
  84. $tpl->copy_template .= bannermass( $banners_topz, $ban_short['top'] );
  85. } else if( $news_c == $middle ) {
  86. $tpl->copy_template .= bannermass( $banners_cenz, $ban_short['cen'] );
  87. } else if( $news_c == $middle_e ) {
  88. $tpl->copy_template .= bannermass( $banners_downz, $ban_short['down'] );
  89. }
  90. $news_c ++;
  91. }
  92.  
  93. $i ++;
  94.  
  95. if( ! $row['category'] ) {
  96. $my_cat = "---";
  97. $my_cat_link = "---";
  98. } else {
  99.  
  100. $my_cat = array ();
  101. $my_cat_link = array ();
  102. $cat_list = explode( ',', $row['category'] );
  103.  
  104. if( count( $cat_list ) == 1 OR ($view_template == "rss" AND $config['rss_format'] == 2)) {
  105.  
  106. $my_cat[] = $cat_info[$cat_list[0]]['name'];
  107.  
  108. $my_cat_link = get_categories( $cat_list[0] );
  109.  
  110. } else {
  111.  
  112. foreach ( $cat_list as $element ) {
  113. if( $element ) {
  114. $my_cat[] = $cat_info[$element]['name'];
  115. if( $config['allow_alt_url'] == "yes" ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
  116. else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  117. }
  118. }
  119.  
  120. $my_cat_link = implode( ', ', $my_cat_link );
  121. }
  122.  
  123. $my_cat = implode( ', ', $my_cat );
  124. }
  125.  
  126. if( strpos( $tpl->copy_template, "[catlist=" ) !== false ) {
  127. $tpl->copy_template = preg_replace( "#\\[catlist=(.+?)\\](.*?)\\[/catlist\\]#ies", "check_category('\\1', '\\2', '{$row['category']}')", $tpl->copy_template );
  128. }
  129.  
  130. if( strpos( $tpl->copy_template, "[not-catlist=" ) !== false ) {
  131. $tpl->copy_template = preg_replace( "#\\[not-catlist=(.+?)\\](.*?)\\[/not-catlist\\]#ies", "check_category('\\1', '\\2', '{$row['category']}', false)", $tpl->copy_template );
  132. }
  133.  
  134. $row['category'] = intval( $row['category'] );
  135.  
  136. $news_find = array ('{comments-num}' => $row['comm_num'], '{views}' => $row['news_read'], '{category}' => $my_cat, '{link-category}' => $my_cat_link, '{news-id}' => $row['id'], '{PAGEBREAK}' => '' );
  137.  
  138. $tpl->set( '', $news_find );
  139.  
  140. if( $cat_info[$row['category']]['icon'] ) {
  141.  
  142. $tpl->set( '{category-icon}', $cat_info[$row['category']]['icon'] );
  143.  
  144. } else {
  145.  
  146. $tpl->set( '{category-icon}', "{THEME}/dleimages/no_icon.gif" );
  147.  
  148. }
  149.  
  150. if ( $row['category'] )
  151. $tpl->set( '{category-url}', $config['http_home_url'] . get_url( $row['category'] ) . "/" );
  152. else
  153. $tpl->set( '{category-url}', "#" );
  154.  
  155. if( date( 'Ymd', $row['date'] ) == date( 'Ymd', $_TIME ) ) {
  156.  
  157. $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) );
  158.  
  159. } elseif( date( 'Ymd', $row['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
  160.  
  161. $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) );
  162.  
  163. } else {
  164.  
  165. $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) );
  166.  
  167. }
  168.  
  169. $tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template );
  170.  
  171.  
  172. if ( $row['fixed'] ) {
  173.  
  174. $tpl->set( '[fixed]', "" );
  175. $tpl->set( '[/fixed]', "" );
  176. $tpl->set_block( "'\\[not-fixed\\](.*?)\\[/not-fixed\\]'si", "" );
  177.  
  178. } else {
  179.  
  180. $tpl->set( '[not-fixed]', "" );
  181. $tpl->set( '[/not-fixed]', "" );
  182. $tpl->set_block( "'\\[fixed\\](.*?)\\[/fixed\\]'si", "" );
  183. }
  184.  
  185. if ( $row['comm_num'] ) {
  186.  
  187. $tpl->set( '[comments]', "" );
  188. $tpl->set( '[/comments]', "" );
  189. $tpl->set_block( "'\\[not-comments\\](.*?)\\[/not-comments\\]'si", "" );
  190.  
  191. } else {
  192.  
  193. $tpl->set( '[not-comments]', "" );
  194. $tpl->set( '[/not-comments]', "" );
  195. $tpl->set_block( "'\\[comments\\](.*?)\\[/comments\\]'si", "" );
  196. }
  197.  
  198. if ( $row['votes'] ) {
  199.  
  200. $tpl->set( '[poll]', "" );
  201. $tpl->set( '[/poll]', "" );
  202. $tpl->set_block( "'\\[not-poll\\](.*?)\\[/not-poll\\]'si", "" );
  203.  
  204. } else {
  205.  
  206. $tpl->set( '[not-poll]', "" );
  207. $tpl->set( '[/not-poll]', "" );
  208. $tpl->set_block( "'\\[poll\\](.*?)\\[/poll\\]'si", "" );
  209. }
  210.  
  211.  
  212.  
  213. if( $row['view_edit'] and $row['editdate'] ) {
  214.  
  215. if( date( Ymd, $row['editdate'] ) == date( Ymd, $_TIME ) ) {
  216.  
  217. $tpl->set( '{edit-date}', $lang['time_heute'] . langdate( ", H:i", $row['editdate'] ) );
  218.  
  219. } elseif( date( Ymd, $row['editdate'] ) == date( Ymd, ($_TIME - 86400) ) ) {
  220.  
  221. $tpl->set( '{edit-date}', $lang['time_gestern'] . langdate( ", H:i", $row['editdate'] ) );
  222.  
  223. } else {
  224.  
  225. $tpl->set( '{edit-date}', langdate( $config['timestamp_active'], $row['editdate'] ) );
  226.  
  227. }
  228.  
  229. $tpl->set( '{editor}', $row['editor'] );
  230. $tpl->set( '{edit-reason}', $row['reason'] );
  231.  
  232. if( $row['reason'] ) {
  233.  
  234. $tpl->set( '[edit-reason]', "" );
  235. $tpl->set( '[/edit-reason]', "" );
  236.  
  237. } else
  238. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  239.  
  240. $tpl->set( '[edit-date]', "" );
  241. $tpl->set( '[/edit-date]', "" );
  242.  
  243. } else {
  244.  
  245. $tpl->set( '{edit-date}', "" );
  246. $tpl->set( '{editor}', "" );
  247. $tpl->set( '{edit-reason}', "" );
  248. $tpl->set_block( "'\\[edit-date\\](.*?)\\[/edit-date\\]'si", "" );
  249. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  250. }
  251.  
  252. if( $config['allow_tags'] and $row['tags'] ) {
  253.  
  254. $tpl->set( '[tags]', "" );
  255. $tpl->set( '[/tags]', "" );
  256.  
  257. $tags = array ();
  258.  
  259. $row['tags'] = explode( ",", $row['tags'] );
  260.  
  261. foreach ( $row['tags'] as $value ) {
  262.  
  263. $value = trim( $value );
  264.  
  265. if( $config['allow_alt_url'] == "yes" ) $tags[] = "<a href=\"" . $config['http_home_url'] . "tags/" . urlencode( $value ) . "/\">" . $value . "</a>";
  266. else $tags[] = "<a href=\"$PHP_SELF?do=tags&amp;tag=" . urlencode( $value ) . "\">" . $value . "</a>";
  267.  
  268. }
  269.  
  270. $tpl->set( '{tags}', implode( ", ", $tags ) );
  271.  
  272. } else {
  273.  
  274. $tpl->set_block( "'\\[tags\\](.*?)\\[/tags\\]'si", "" );
  275. $tpl->set( '{tags}', "" );
  276.  
  277. }
  278.  
  279. if( $row['allow_rate'] ) {
  280.  
  281. if( $config['short_rating'] and $user_group[$member_id['user_group']]['allow_rating'] ) $tpl->set( '{rating}', ShortRating( $row['id'], $row['rating'], $row['vote_num'], 1 ) );
  282. else $tpl->set( '{rating}', ShortRating( $row['id'], $row['rating'], $row['vote_num'], 0 ) );
  283.  
  284. $tpl->set( '{vote-num}', $row['vote_num'] );
  285.  
  286. } else {
  287. $tpl->set( '{rating}', "" );
  288. $tpl->set( '{vote-num}', "" );
  289. }
  290.  
  291. if( $config['allow_alt_url'] == "yes" ) {
  292.  
  293. $go_page = $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/";
  294. $tpl->set( '[day-news]', "<a href=\"".$config['http_home_url'] . date( 'Y/m/d/', $row['date'])."\" >" );
  295.  
  296. } else {
  297.  
  298. $go_page = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode( $row['autor'] );
  299. $tpl->set( '[day-news]', "<a href=\"$PHP_SELF?year=".date( 'Y', $row['date'])."&amp;month=".date( 'm', $row['date'])."&amp;day=".date( 'd', $row['date'])."\" >" );
  300.  
  301. }
  302.  
  303. $tpl->set( '[/day-news]', "</a>" );
  304. $tpl->set( '[profile]', "<a href=\"" . $go_page . "\">" );
  305. $tpl->set( '[/profile]', "</a>" );
  306.  
  307. $tpl->set( '{login}', $row['autor'] );
  308.  
  309. $tpl->set( '{author}', "<a onclick=\"ShowProfile('" . urlencode( $row['autor'] ) . "', '" . $go_page . "', '" . $user_group[$member_id['user_group']]['admin_editusers'] . "'); return false;\" href=\"" . $go_page . "\">" . $row['autor'] . "</a>" );
  310.  
  311. if( $allow_userinfo and ! $row['approve'] and ($member_id['name'] == $row['autor'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) {
  312. $tpl->set( '[edit]', "<a href=\"" . $config['http_home_url'] . "index.php?do=addnews&id=" . $row['id'] . "\" >" );
  313. $tpl->set( '[/edit]', "</a>" );
  314. } elseif( $is_logged and (($member_id['name'] == $row['autor'] and $user_group[$member_id['user_group']]['allow_edit']) or $user_group[$member_id['user_group']]['allow_all_edit']) ) {
  315.  
  316. $_SESSION['referrer'] = $_SERVER['REQUEST_URI'];
  317. $tpl->set( '[edit]', "<a onclick=\"return dropdownmenu(this, event, MenuNewsBuild('" . $row['id'] . "', 'short'), '170px')\" href=\"#\">" );
  318. $tpl->set( '[/edit]', "</a>" );
  319. $allow_comments_ajax = true;
  320. } else
  321. $tpl->set_block( "'\\[edit\\](.*?)\\[/edit\\]'si", "" );
  322.  
  323. if( $config['allow_alt_url'] == "yes" ) {
  324.  
  325. if( $row['flag'] and $config['seo_type'] ) {
  326.  
  327. if( $row['category'] and $config['seo_type'] == 2 ) {
  328.  
  329. $full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
  330.  
  331. } else {
  332.  
  333. $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
  334.  
  335. }
  336.  
  337. } else {
  338.  
  339. $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
  340. }
  341.  
  342. } else {
  343.  
  344. $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
  345.  
  346. }
  347.  
  348. if( (strlen( $row['full_story'] ) < 13) and $config['hide_full_link'] == "yes" ) $tpl->set_block( "'\\[full-link\\](.*?)\\[/full-link\\]'si", "" );
  349. else {
  350.  
  351. $tpl->set( '[full-link]', "<a href=\"" . $full_link . "\">" );
  352.  
  353. $tpl->set( '[/full-link]', "</a>" );
  354. }
  355.  
  356. $tpl->set( '{full-link}', $full_link );
  357.  
  358. if( $row['allow_comm'] ) {
  359.  
  360. $tpl->set( '[com-link]', "<a href=\"" . $full_link . "#comment\">" );
  361. $tpl->set( '[/com-link]', "</a>" );
  362.  
  363. } else
  364. $tpl->set_block( "'\\[com-link\\](.*?)\\[/com-link\\]'si", "" );
  365.  
  366. if( strpos( $tpl->copy_template, "[category=" ) !== false ) {
  367. $tpl->copy_template = preg_replace( "#\\[category=(.+?)\\](.*?)\\[/category\\]#ies", "check_category('\\1', '\\2', '{$category_id}')", $tpl->copy_template );
  368. }
  369.  
  370. if( strpos( $tpl->copy_template, "[not-category=" ) !== false ) {
  371. $tpl->copy_template = preg_replace( "#\\[not-category=(.+?)\\](.*?)\\[/not-category\\]#ies", "check_category('\\1', '\\2', '{$category_id}', false)", $tpl->copy_template );
  372. }
  373.  
  374. if( $is_logged ) {
  375.  
  376. $fav_arr = explode( ',', $member_id['favorites'] );
  377.  
  378. if( ! in_array( $row['id'], $fav_arr ) or $config['allow_cache'] == "yes" ) $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=add&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/plus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'plus'); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
  379. else $tpl->set( '{favorites}', "<a id=\"fav-id-" . $row['id'] . "\" href=\"$PHP_SELF?do=favorites&amp;doaction=del&amp;id=" . $row['id'] . "\"><img src=\"" . $config['http_home_url'] . "templates/{$config['skin']}/dleimages/minus_fav.gif\" onclick=\"doFavorites('" . $row['id'] . "', 'minus'); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
  380.  
  381. $tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">" );
  382. $tpl->set( '[/complaint]', "</a>" );
  383.  
  384.  
  385. } else {
  386. $tpl->set( '{favorites}', "" );
  387. $tpl->set_block( "'\\[complaint\\](.*?)\\[/complaint\\]'si", "" );
  388. }
  389.  
  390.  
  391. if( $allow_userinfo and ! $row['approve'] ) {
  392.  
  393. $tpl->set( '{approve}', $lang['approve'] );
  394.  
  395. } else
  396. $tpl->set( '{approve}', "" );
  397.  
  398. // Обработка дополнительных полей
  399. if( $xfound ) {
  400. $xfieldsdata = xfieldsdataload( $row['xfields'] );
  401.  
  402. foreach ( $xfields as $value ) {
  403. $preg_safe_name = preg_quote( $value[0], "'" );
  404.  
  405. if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  406. $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  407. $value3 = array();
  408.  
  409. foreach ($temp_array as $value2) {
  410.  
  411. $value2 = trim($value2);
  412. $value2 = str_replace("&#039;", "'", $value2);
  413.  
  414. if( $config['allow_alt_url'] == "yes" ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  415. else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  416. }
  417.  
  418. $xfieldsdata[$value[0]] = implode(", ", $value3);
  419.  
  420. unset($temp_array);
  421. unset($value2);
  422. unset($value3);
  423.  
  424. }
  425.  
  426. if( empty( $xfieldsdata[$value[0]] ) ) {
  427. $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  428. $tpl->copy_template = str_replace( "[xfnotgiven_{$preg_safe_name}]", "", $tpl->copy_template );
  429. $tpl->copy_template = str_replace( "[/xfnotgiven_{$preg_safe_name}]", "", $tpl->copy_template );
  430. } else {
  431. $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  432. $tpl->copy_template = str_replace( "[xfgiven_{$preg_safe_name}]", "", $tpl->copy_template );
  433. $tpl->copy_template = str_replace( "[/xfgiven_{$preg_safe_name}]", "", $tpl->copy_template );
  434. }
  435.  
  436. $tpl->copy_template = str_replace( "[xfvalue_{$preg_safe_name}]", stripslashes( $xfieldsdata[$value[0]] ), $tpl->copy_template );
  437. }
  438. }
  439. // Обработка дополнительных полей
  440.  
  441.  
  442. if( isset($view_template) AND $view_template == "rss" ) {
  443.  
  444. $tpl->set( '{rsslink}', $full_link );
  445. $tpl->set( '{rssauthor}', $row['autor'] );
  446. $tpl->set( '{rssdate}', date( "r", $row['date'] ) );
  447. $tpl->set( '{title}', htmlspecialchars( strip_tags( stripslashes( $row['title'] ) ) ) );
  448.  
  449. if( $config['rss_format'] != 1 ) {
  450. $row['short_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['short_story'] );
  451. $row['short_story'] = trim (htmlspecialchars( strip_tags( stripslashes( str_replace( "<br />", " ", $row['short_story'] ) ) ) ) );
  452.  
  453. } else {
  454.  
  455. $row['short_story'] = stripslashes( $row['short_story'] );
  456.  
  457. }
  458.  
  459. $tpl->set( '{short-story}', $row['short_story'] );
  460.  
  461. if( $config['rss_format'] == 2 ) {
  462.  
  463. $row['full_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['full_story'] );
  464.  
  465. $row['full_story'] = trim (htmlspecialchars( strip_tags( stripslashes( str_replace( "<br />", " ", $row['full_story'] ) ), '<a>' ), ENT_QUOTES ) );
  466.  
  467. if( $row['full_story'] == "" ) $row['full_story'] = $row['short_story'];
  468.  
  469. $tpl->set( '{full-story}', $row['full_story'] );
  470.  
  471. }
  472.  
  473. } else {
  474.  
  475. if ($smartphone_detected) {
  476.  
  477. if (!$config['allow_smart_format']) {
  478.  
  479. $row['short_story'] = strip_tags( $row['short_story'], '<p><br><a>' );
  480.  
  481. } else {
  482.  
  483.  
  484. if ( !$config['allow_smart_images'] ) {
  485.  
  486. $row['short_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['short_story'] );
  487. $row['short_story'] = preg_replace( "#<img(.+?)>#is", "", $row['short_story'] );
  488.  
  489. }
  490.  
  491. if ( !$config['allow_smart_video'] ) {
  492.  
  493. $row['short_story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['short_story'] );
  494. $row['short_story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['short_story'] );
  495.  
  496. }
  497.  
  498. }
  499.  
  500. }
  501.  
  502. $tpl->set( '{title}', stripslashes( $row['title'] ) );
  503. $tpl->set( '{short-story}', stripslashes( "<div id=\"news-id-" . $row['id'] . "\" style=\"display:inline;\">" . $row['short_story'] . "</div>" ) );
  504.  
  505. }
  506.  
  507. $tpl->compile( 'content' );
  508.  
  509. if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
  510. else $tpl->result['content'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content'] );
  511.  
  512. }
  513.  
  514. $tpl->clear();
  515. $db->free( $sql_result );
  516.  
  517. if( $do == "" ) $do = $subaction;
  518. if( $do == "" and $year ) $do = "date";
  519. $ban_short = array ();
  520. unset( $ban_short );
  521.  
  522. if( ! $news_found and $allow_userinfo and $member_id['name'] == $user and $user_group[$member_id['user_group']]['allow_adds'] ) {
  523. $tpl->load_template( 'info.tpl' );
  524. $tpl->set( '{error}', $lang['mod_list_f'] );
  525. $tpl->set( '{title}', $lang['all_info'] );
  526. $tpl->compile( 'content' );
  527. $tpl->clear();
  528. } elseif( !$news_found and $do == 'newposts' and $view_template != 'rss') {
  529. msgbox( $lang['all_info'], $lang['newpost_notfound'] );
  530. } elseif( ! $news_found and ! $allow_userinfo and $do != '' and $do != 'favorites' and $view_template != 'rss' ) {
  531. if ( $newsmodule ) @header( "HTTP/1.0 404 Not Found" );
  532. msgbox( $lang['all_err_1'], $lang['news_err_27'] );
  533. } elseif( ! $news_found and $catalog != "" ) {
  534. if ( $newsmodule ) @header( "HTTP/1.0 404 Not Found" );
  535. msgbox( $lang['all_err_1'], $lang['news_err_27'] );
  536. } elseif( ! $news_found and $do == 'favorites' ) {
  537.  
  538. if ( $member_id['favorites'] AND !$count_all ) $db->query( "UPDATE " . USERPREFIX . "_users SET favorites='' WHERE user_id = '{$member_id['user_id']}'" );
  539.  
  540. if (!$count_all) msgbox( $lang['all_info'], $lang['fav_notfound'] ); else msgbox( $lang['all_info'], $lang['fav_notfound_1'] );
  541. }
  542.  
  543. //####################################################################################################################
  544. // Навигация по новостям
  545. //####################################################################################################################
  546. if( ! isset( $view_template ) AND $count_all AND $config['news_navigation'] ) {
  547.  
  548. $tpl->load_template( 'navigation.tpl' );
  549.  
  550. //----------------------------------
  551. // Previous link
  552. //----------------------------------
  553.  
  554.  
  555. $no_prev = false;
  556. $no_next = false;
  557.  
  558. if( isset( $cstart ) and $cstart != "" and $cstart > 0 ) {
  559. $prev = $cstart / $config['news_number'];
  560.  
  561. if( $config['allow_alt_url'] == "yes" ) {
  562.  
  563. if ($prev == 1)
  564. $prev_page = $url_page . "/";
  565. else
  566. $prev_page = $url_page . "/page/" . $prev . "/";
  567.  
  568. $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
  569.  
  570. } else {
  571.  
  572. if ($prev == 1)
  573. $prev_page = $PHP_SELF . "?" . $user_query;
  574. else
  575. $prev_page = $PHP_SELF . "?cstart=" . $prev . "&amp;" . $user_query;
  576.  
  577. $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=\"" . $prev_page . "\">\\1</a>" );
  578. }
  579.  
  580. } else {
  581. $tpl->set_block( "'\[prev-link\](.*?)\[/prev-link\]'si", "<span>\\1</span>" );
  582. $no_prev = TRUE;
  583. }
  584.  
  585. //----------------------------------
  586. // Pages
  587. //----------------------------------
  588. if( $config['news_number'] ) {
  589.  
  590. $pages = "";
  591.  
  592. if( $count_all > $config['news_number'] ) {
  593.  
  594. $enpages_count = @ceil( $count_all / $config['news_number'] );
  595.  
  596. $cstart = ($cstart / $config['news_number']) + 1;
  597.  
  598. if( $enpages_count <= 10 ) {
  599.  
  600. for($j = 1; $j <= $enpages_count; $j ++) {
  601.  
  602. if( $j != $cstart ) {
  603.  
  604. if( $config['allow_alt_url'] == "yes" ) {
  605.  
  606. if ($j == 1)
  607. $pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
  608. else
  609. $pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
  610.  
  611. } else {
  612.  
  613. if ($j == 1)
  614. $pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
  615. else
  616. $pages .= "<a href=\"$PHP_SELF?cstart=$j&amp;$user_query\">$j</a> ";
  617.  
  618. }
  619.  
  620. } else {
  621.  
  622. $pages .= "<span>$j</span> ";
  623. }
  624.  
  625. }
  626.  
  627. } else {
  628.  
  629. $start = 1;
  630. $end = 10;
  631. $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  632.  
  633. if( $cstart > 0 ) {
  634.  
  635. if( $cstart > 6 ) {
  636.  
  637. $start = $cstart - 4;
  638. $end = $start + 8;
  639.  
  640. if( $end >= $enpages_count ) {
  641. $start = $enpages_count - 9;
  642. $end = $enpages_count - 1;
  643. $nav_prefix = "";
  644. } else
  645. $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  646.  
  647. }
  648.  
  649. }
  650.  
  651. if( $start >= 2 ) {
  652.  
  653. if( $config['allow_alt_url'] == "yes" ) $pages .= "<a href=\"" . $url_page . "/\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  654. else $pages .= "<a href=\"$PHP_SELF?{$user_query}\">1</a> <span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  655.  
  656. }
  657.  
  658. for($j = $start; $j <= $end; $j ++) {
  659.  
  660. if( $j != $cstart ) {
  661.  
  662. if( $config['allow_alt_url'] == "yes" ) {
  663.  
  664. if ($j == 1)
  665. $pages .= "<a href=\"" . $url_page . "/\">$j</a> ";
  666. else
  667. $pages .= "<a href=\"" . $url_page . "/page/" . $j . "/\">$j</a> ";
  668.  
  669. } else {
  670.  
  671. if ($j == 1)
  672. $pages .= "<a href=\"$PHP_SELF?{$user_query}\">$j</a> ";
  673. else
  674. $pages .= "<a href=\"$PHP_SELF?cstart=$j&amp;$user_query\">$j</a> ";
  675.  
  676. }
  677.  
  678. } else {
  679.  
  680. $pages .= "<span>$j</span> ";
  681. }
  682.  
  683. }
  684.  
  685. if( $cstart != $enpages_count ) {
  686.  
  687. if( $config['allow_alt_url'] == "yes" ) $pages .= $nav_prefix . "<a href=\"" . $url_page . "/page/{$enpages_count}/\">{$enpages_count}</a>";
  688. else $pages .= $nav_prefix . "<a href=\"$PHP_SELF?cstart={$enpages_count}&amp;$user_query\">{$enpages_count}</a>";
  689.  
  690. } else
  691. $pages .= "<span>{$enpages_count}</span> ";
  692.  
  693. }
  694.  
  695. }
  696. $tpl->set( '{pages}', $pages );
  697. }
  698.  
  699. //----------------------------------
  700. // Next link
  701. //----------------------------------
  702. if( $config['news_number'] AND $config['news_number'] < $count_all and $i < $count_all ) {
  703. $next_page = $i / $config['news_number'] + 1;
  704.  
  705. if( $config['allow_alt_url'] == "yes" ) {
  706. $next = $url_page . '/page/' . $next_page . '/';
  707. $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
  708. } else {
  709. $next = $PHP_SELF . "?cstart=" . $next_page . "&amp;" . $user_query;
  710. $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<a href=\"" . $next . "\">\\1</a>" );
  711. }
  712.  
  713. } else {
  714. $tpl->set_block( "'\[next-link\](.*?)\[/next-link\]'si", "<span>\\1</span>" );
  715. $no_next = TRUE;
  716. }
  717.  
  718. if( !$no_prev OR !$no_next ) {
  719. $tpl->compile( 'navi' );
  720.  
  721. switch ( $config['news_navigation'] ) {
  722.  
  723. case "2" :
  724.  
  725. $tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'];
  726. break;
  727.  
  728. case "3" :
  729.  
  730. $tpl->result['content'] = $tpl->result['navi'].$tpl->result['content'].$tpl->result['navi'];
  731. break;
  732.  
  733. default :
  734. $tpl->result['content'] .= $tpl->result['navi'];
  735. break;
  736.  
  737. }
  738. }
  739.  
  740. $tpl->clear();
  741. }
  742. }
  743. ?>
Advertisement
Add Comment
Please, Sign In to add comment