hooligan

Untitled

Feb 26th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 52.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,2013 SoftNews Media Group
  9. =====================================================
  10. Данный код защищен авторскими правами
  11. =====================================================
  12. Файл: show.full.php
  13. -----------------------------------------------------
  14. Назначение: Просмотр полной новости и комментариев
  15. =====================================================
  16. */
  17. if( ! defined( 'DATALIFEENGINE' ) ) {
  18. die( "Hacking attempt!" );
  19. }
  20.  
  21. function filmix( $url = false )
  22. {
  23. if ( $url == '' )
  24. {
  25. return '';
  26. }
  27.  
  28. $url = base64_encode($url);
  29.  
  30. $content = <<<JS
  31. <script type="text/javascript">
  32. $(document).ready(function() {
  33. $.get(dle_root+'filmix.php', { url: encodeURIComponent('{$url}') },function(data) {
  34. $("#filmix-player").html(data);
  35. });
  36. });
  37. </script>
  38. JS;
  39.  
  40. return $content;
  41. }
  42.  
  43.  
  44. $allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
  45. $perm = 1;
  46. $i = 0;
  47. $news_found = false;
  48. $allow_full_cache = false;
  49.  
  50. if ( $config['allow_alt_url'] == "yes" AND !$config['seo_type'] ) $cprefix = "full"; else $cprefix = "full_".$newsid;
  51.  
  52. $row = dle_cache ( $cprefix, $sql_news );
  53.  
  54. if( $row ) {
  55. $row = unserialize($row);
  56. $full_cache = true;
  57. } else {
  58. $row = $db->super_query( $sql_news );
  59. $full_cache = false;
  60. }
  61.  
  62. $options = news_permission( $row['access'] );
  63. if( $options[$member_id['user_group']] AND $options[$member_id['user_group']] != 3 ) $perm = 1;
  64. if( $options[$member_id['user_group']] == 3 ) $perm = 0;
  65.  
  66. if( $options[$member_id['user_group']] == 1 ) $user_group[$member_id['user_group']]['allow_addc'] = 0;
  67. if( $options[$member_id['user_group']] == 2 ) $user_group[$member_id['user_group']]['allow_addc'] = 1;
  68.  
  69. if( $row['id'] AND !$row['approve'] AND $member_id['name'] != $row['autor'] AND $member_id['user_group'] != '1' ) $perm = 0;
  70. if( !$row['approve'] ) $allow_comments = false;
  71.  
  72. if( ! $row['category'] ) {
  73. $my_cat = "---";
  74. $my_cat_link = "---";
  75. } else {
  76.  
  77. $my_cat = array ();
  78. $my_cat_link = array ();
  79. $cat_list = explode( ',', $row['category'] );
  80.  
  81. if( count( $cat_list ) == 1 ) {
  82.  
  83. if( $allow_list[0] != "all" and ! in_array( $cat_list[0], $allow_list ) ) $perm = 0;
  84.  
  85. $my_cat[] = $cat_info[$cat_list[0]]['name'];
  86.  
  87. $my_cat_link = get_categories( $cat_list[0] );
  88.  
  89. } else {
  90.  
  91. foreach ( $cat_list as $element ) {
  92.  
  93. if( $allow_list[0] != "all" and ! in_array( $element, $allow_list ) ) $perm = 0;
  94.  
  95. if( $element ) {
  96. $my_cat[] = $cat_info[$element]['name'];
  97. if( $config['allow_alt_url'] == "yes" ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
  98. else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  99. }
  100. }
  101.  
  102. $my_cat_link = implode( ', ', $my_cat_link );
  103. }
  104.  
  105. $my_cat = implode( ', ', $my_cat );
  106. }
  107.  
  108. if ( $row['id'] AND $perm ) {
  109.  
  110. if( strtotime($row['date']) >= ($_TIME - 2592000) ) {
  111.  
  112. $allow_full_cache = true;
  113.  
  114. }
  115.  
  116. define( 'NEWS_ID', $row['id'] );
  117.  
  118. $disable_index = $row['disable_index'];
  119.  
  120. if ($allow_full_cache AND !$full_cache) create_cache ( $cprefix, serialize($row), $sql_news );
  121.  
  122. $xfields = xfieldsload();
  123.  
  124. if( $row['votes'] and $view_template != "print" ) include_once ENGINE_DIR . '/modules/poll.php';
  125.  
  126. $category_id = intval( $row['category'] );
  127.  
  128. if( isset( $view_template ) and $view_template == "print" ) $tpl->load_template( 'print.tpl' );
  129. elseif( $category_id and $cat_info[$category_id]['full_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['full_tpl'] . '.tpl' );
  130. else $tpl->load_template( 'fullstory.tpl' );
  131.  
  132. if( $config['allow_read_count'] == "yes" AND !$news_page AND !$cstart) {
  133. if( $config['cache_count'] ) $db->query( "INSERT INTO " . PREFIX . "_views (news_id) VALUES ('{$row['id']}')" );
  134. else $db->query( "UPDATE " . PREFIX . "_post_extras SET news_read=news_read+1 where news_id='{$row['id']}'" );
  135. }
  136.  
  137. $news_found = TRUE;
  138. $row['date'] = strtotime( $row['date'] );
  139.  
  140. if( (strlen( $row['full_story'] ) < 13) and (strpos( $tpl->copy_template, "{short-story}" ) === false) ) {
  141. $row['full_story'] = $row['short_story'];
  142. }
  143.  
  144. if( ! $news_page ) {
  145. $news_page = 1;
  146. }
  147.  
  148. if( $config['allow_alt_url'] == "yes" ) {
  149.  
  150. if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
  151.  
  152. if( $category_id AND $config['seo_type'] == 2 ) {
  153.  
  154. $c_url = get_url( $category_id );
  155. $full_link = $config['http_home_url'] . $c_url . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
  156.  
  157. if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
  158.  
  159. if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] != $c_url OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
  160.  
  161. if ($view_template == "print") {
  162.  
  163. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  164. $re_url = reset ( $re_url );
  165.  
  166. } else {
  167.  
  168. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  169. $re_url = reset ( $re_url );
  170.  
  171. }
  172.  
  173. header("HTTP/1.0 301 Moved Permanently");
  174. header("Location: {$re_url}{$c_url}/{$row['id']}-{$row['alt_name']}.html");
  175. die("Redirect");
  176.  
  177. }
  178.  
  179. }
  180.  
  181. $print_link = $config['http_home_url'] . $c_url . "/print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
  182. $short_link = $config['http_home_url'] . $c_url . "/";
  183. $row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
  184. $link_page = $config['http_home_url'] . $c_url . "/" . 'page,' . $news_page . ',';
  185. $news_name = $row['alt_name'];
  186.  
  187. } else {
  188.  
  189. $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
  190.  
  191. if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
  192.  
  193. if ($_GET['seourl'] != $row['alt_name'] OR $_GET['seocat'] OR $_GET['news_name'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
  194.  
  195. if ($view_template == "print") {
  196.  
  197. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  198. $re_url = reset ( $re_url );
  199.  
  200. } else {
  201.  
  202. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  203. $re_url = reset ( $re_url );
  204.  
  205. }
  206.  
  207. header("HTTP/1.0 301 Moved Permanently");
  208. header("Location: {$re_url}{$row['id']}-{$row['alt_name']}.html");
  209. die("Redirect");
  210.  
  211. }
  212.  
  213. }
  214.  
  215. $print_link = $config['http_home_url'] . "print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
  216. $short_link = $config['http_home_url'];
  217. $row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
  218. $link_page = $config['http_home_url'] . 'page,' . $news_page . ',';
  219. $news_name = $row['alt_name'];
  220.  
  221. }
  222.  
  223. } else {
  224.  
  225. $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
  226.  
  227. if ( $config['seo_control'] ) {
  228.  
  229. if ($_GET['newsid'] OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false OR ($_GET['news_page'] == 1 AND $cstart < 2 AND $view_template != "print") OR ($view_template == "print" AND $news_page > 1) ) {
  230.  
  231. if ($view_template == "print") {
  232.  
  233. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  234. $re_url = reset ( $re_url );
  235.  
  236. } else {
  237.  
  238. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  239. $re_url = reset ( $re_url );
  240.  
  241. }
  242.  
  243. header("HTTP/1.0 301 Moved Permanently");
  244. header("Location: {$re_url}".date( 'Y/m/d/', $row['date'] ).$row['alt_name'].".html");
  245. die("Redirect");
  246.  
  247. }
  248.  
  249. }
  250.  
  251. $print_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . "print:page,1," . $row['alt_name'] . ".html";
  252. $short_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] );
  253. $link_page = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . 'page,' . $news_page . ',';
  254. $news_name = $row['alt_name'];
  255.  
  256. }
  257.  
  258. } else {
  259.  
  260. $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
  261. $print_link = $config['http_home_url'] . "engine/print.php?newsid=" . $row['id'];
  262. $short_link = "";
  263. $link_page = "";
  264. $news_name = "";
  265.  
  266. }
  267.  
  268. $i ++;
  269. //
  270. // обработка страниц
  271. //
  272.  
  273. $news_seiten = explode( "{PAGEBREAK}", $row['full_story'] );
  274. $anzahl_seiten = count( $news_seiten );
  275.  
  276. if( $news_page <= 0 OR $news_page > $anzahl_seiten OR $_GET['news_page'] === "0" ) {
  277.  
  278. $news_page = 1;
  279.  
  280. if ( $config['seo_control'] ) {
  281. $re_url = str_replace( $config['http_home_url'], "/", $full_link );
  282. header("HTTP/1.0 301 Moved Permanently");
  283. header("Location: {$re_url}");
  284. die("Redirect");
  285. }
  286. }
  287.  
  288. if( isset($view_template) AND $view_template == "print" ) {
  289.  
  290. $row['full_story'] = str_replace( "{PAGEBREAK}", "", $row['full_story'] );
  291. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "\\2", $row['full_story'] );
  292. $tpl->set_block( "'\\[pages\\](.*?)\\[/pages\\]'si", "" );
  293. $tpl->set( '{pages}', "" );
  294.  
  295. } else {
  296.  
  297. $row['full_story'] = $news_seiten[$news_page - 1];
  298.  
  299. $row['full_story'] = preg_replace( '#(\A[\s]*<br[^>]*>[\s]*|<br[^>]*>[\s]*\Z)#is', '', $row['full_story'] ); // remove <br/> at end of string
  300. $news_seiten = "";
  301. unset( $news_seiten );
  302.  
  303. if( $anzahl_seiten > 1 ) {
  304.  
  305. if( $news_page < $anzahl_seiten ) {
  306. $pages = $news_page + 1;
  307.  
  308. if( $config['allow_alt_url'] == "yes" ) {
  309. $nextpage = " | <a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">" . $lang['news_next'] . "</a>";
  310. } else {
  311. $nextpage = " | <a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">" . $lang['news_next'] . "</a>";
  312. }
  313. }
  314.  
  315. if( $news_page > 1 ) {
  316. $pages = $news_page - 1;
  317.  
  318. if( $config['allow_alt_url'] == "yes" ) {
  319. if ( $pages == 1 ) $prevpage = "<a href=\"" . $full_link . "\">" . $lang['news_prev'] . "</a> | ";
  320. else $prevpage = "<a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">" . $lang['news_prev'] . "</a> | ";
  321. } else {
  322. if ( $pages == 1 ) $prevpage = "<a href=\"" . $full_link. "\">" . $lang['news_prev'] . "</a> | ";
  323. else $prevpage = "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">" . $lang['news_prev'] . "</a> | ";
  324. }
  325. }
  326.  
  327. $tpl->set( '{pages}', $prevpage . $lang['news_site'] . " " . $news_page . $lang['news_iz'] . $anzahl_seiten . $nextpage );
  328.  
  329. if( $config['allow_alt_url'] == "yes" ) {
  330.  
  331. $replacepage = "<a href=\"" . $short_link . "page," . "\\1" . "," . $row['alt_name'] . ".html\">\\2</a>";
  332.  
  333. } else {
  334.  
  335. $replacepage = "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=\\1\">\\2</a>";
  336. }
  337.  
  338. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", $replacepage, $row['full_story'] );
  339. $tpl->set( '[pages]', "" );
  340. $tpl->set( '[/pages]', "" );
  341.  
  342. } else {
  343.  
  344. $tpl->set( '{pages}', '' );
  345. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "", $row['full_story'] );
  346. $tpl->set_block( "'\\[pages\\](.*?)\\[/pages\\]'si", "" );
  347. }
  348. }
  349.  
  350. $row['title'] = stripslashes( $row['title'] );
  351. $metatags['title'] = $row['title'];
  352. $comments_num = $row['comm_num'];
  353.  
  354. $news_find = array ('{comments-num}' => $comments_num, '{views}' => $row['news_read'], '{category}' => $my_cat, '{link-category}' => $my_cat_link, '{news-id}' => $row['id'] );
  355.  
  356. if( date( 'Ymd', $row['date'] ) == date( 'Ymd', $_TIME ) ) {
  357.  
  358. $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) );
  359.  
  360. } elseif( date( 'Ymd', $row['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
  361.  
  362. $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) );
  363.  
  364. } else {
  365.  
  366. $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) );
  367.  
  368. }
  369.  
  370. $tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template );
  371.  
  372. if ( $row['fixed'] ) {
  373.  
  374. $tpl->set( '[fixed]', "" );
  375. $tpl->set( '[/fixed]', "" );
  376. $tpl->set_block( "'\\[not-fixed\\](.*?)\\[/not-fixed\\]'si", "" );
  377.  
  378. } else {
  379.  
  380. $tpl->set( '[not-fixed]', "" );
  381. $tpl->set( '[/not-fixed]', "" );
  382. $tpl->set_block( "'\\[fixed\\](.*?)\\[/fixed\\]'si", "" );
  383. }
  384.  
  385. if ( $comments_num ) {
  386.  
  387. $tpl->set( '[comments]', "" );
  388. $tpl->set( '[/comments]', "" );
  389. $tpl->set_block( "'\\[not-comments\\](.*?)\\[/not-comments\\]'si", "" );
  390.  
  391. } else {
  392.  
  393. $tpl->set( '[not-comments]', "" );
  394. $tpl->set( '[/not-comments]', "" );
  395. $tpl->set_block( "'\\[comments\\](.*?)\\[/comments\\]'si", "" );
  396. }
  397.  
  398. if ( $row['votes'] ) {
  399.  
  400. $tpl->set( '[poll]', "" );
  401. $tpl->set( '[/poll]', "" );
  402. $tpl->set_block( "'\\[not-poll\\](.*?)\\[/not-poll\\]'si", "" );
  403.  
  404. } else {
  405.  
  406. $tpl->set( '[not-poll]', "" );
  407. $tpl->set( '[/not-poll]', "" );
  408. $tpl->set_block( "'\\[poll\\](.*?)\\[/poll\\]'si", "" );
  409. }
  410.  
  411. if( $row['editdate'] ) $_DOCUMENT_DATE = $row['editdate'];
  412. else $_DOCUMENT_DATE = $row['date'];
  413.  
  414. if( $row['view_edit'] and $row['editdate'] ) {
  415.  
  416. if( date( Ymd, $row['editdate'] ) == date( Ymd, $_TIME ) ) {
  417.  
  418. $tpl->set( '{edit-date}', $lang['time_heute'] . langdate( ", H:i", $row['editdate'] ) );
  419.  
  420. } elseif( date( Ymd, $row['editdate'] ) == date( Ymd, ($_TIME - 86400) ) ) {
  421.  
  422. $tpl->set( '{edit-date}', $lang['time_gestern'] . langdate( ", H:i", $row['editdate'] ) );
  423.  
  424. } else {
  425.  
  426. $tpl->set( '{edit-date}', langdate( $config['timestamp_active'], $row['editdate'] ) );
  427.  
  428. }
  429.  
  430. $tpl->set( '{editor}', $row['editor'] );
  431. $tpl->set( '{edit-reason}', $row['reason'] );
  432.  
  433. if( $row['reason'] ) {
  434.  
  435. $tpl->set( '[edit-reason]', "" );
  436. $tpl->set( '[/edit-reason]', "" );
  437.  
  438. } else
  439. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  440.  
  441. $tpl->set( '[edit-date]', "" );
  442. $tpl->set( '[/edit-date]', "" );
  443.  
  444. } else {
  445.  
  446. $tpl->set( '{edit-date}', "" );
  447. $tpl->set( '{editor}', "" );
  448. $tpl->set( '{edit-reason}', "" );
  449. $tpl->set_block( "'\\[edit-date\\](.*?)\\[/edit-date\\]'si", "" );
  450. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  451. }
  452.  
  453. if( $config['allow_tags'] and $row['tags'] ) {
  454.  
  455. $tpl->set( '[tags]', "" );
  456. $tpl->set( '[/tags]', "" );
  457.  
  458. $tags = array ();
  459.  
  460. $row['tags'] = explode( ",", $row['tags'] );
  461.  
  462. foreach ( $row['tags'] as $value ) {
  463.  
  464. $value = trim( $value );
  465.  
  466. if( $config['allow_alt_url'] == "yes" ) $tags[] = "<a href=\"" . $config['http_home_url'] . "tags/" . urlencode( $value ) . "/\">" . $value . "</a>";
  467. else $tags[] = "<a href=\"$PHP_SELF?do=tags&amp;tag=" . urlencode( $value ) . "\">" . $value . "</a>";
  468.  
  469. }
  470.  
  471. $tpl->set( '{tags}', implode( ", ", $tags ) );
  472.  
  473. } else {
  474.  
  475. $tpl->set_block( "'\\[tags\\](.*?)\\[/tags\\]'si", "" );
  476. $tpl->set( '{tags}', "" );
  477.  
  478. }
  479.  
  480. $tpl->set( '', $news_find );
  481.  
  482. if( strpos( $tpl->copy_template, "[catlist=" ) !== false ) {
  483. $tpl->copy_template = preg_replace( "#\\[catlist=(.+?)\\](.*?)\\[/catlist\\]#ies", "check_category('\\1', '\\2', '{$row['category']}')", $tpl->copy_template );
  484. }
  485.  
  486. if( strpos( $tpl->copy_template, "[not-catlist=" ) !== false ) {
  487. $tpl->copy_template = preg_replace( "#\\[not-catlist=(.+?)\\](.*?)\\[/not-catlist\\]#ies", "check_category('\\1', '\\2', '{$row['category']}', false)", $tpl->copy_template );
  488. }
  489.  
  490. if( $cat_info[$category_id]['icon'] ) {
  491.  
  492. $tpl->set( '{category-icon}', $cat_info[$category_id]['icon'] );
  493.  
  494. } else {
  495.  
  496. $tpl->set( '{category-icon}', "{THEME}/dleimages/no_icon.gif" );
  497.  
  498. }
  499.  
  500. if ( $category_id )
  501. $tpl->set( '{category-url}', $config['http_home_url'] . get_url( $category_id ) . "/" );
  502. else
  503. $tpl->set( '{category-url}', "#" );
  504.  
  505. // Ссылки на версию для печати
  506. if ($config['allow_search_print']) {
  507.  
  508. $tpl->set( '[print-link]', "<a href=\"" . $print_link . "\">" );
  509. $tpl->set( '[/print-link]', "</a>" );
  510.  
  511. } else {
  512.  
  513. $tpl->set( '[print-link]', "<a href=\"" . $print_link . "\" rel=\"nofollow\">" );
  514. $tpl->set( '[/print-link]', "</a>" );
  515.  
  516. }
  517. // Ссылки на версию для печати
  518.  
  519.  
  520. if( $row['allow_rate'] ) {
  521.  
  522. $tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
  523. $tpl->set( '{vote-num}', "<span id=\"vote-num-id-".$row['id']."\">".$row['vote_num']."</span>" );
  524. $tpl->set( '[rating]', "" );
  525. $tpl->set( '[/rating]', "" );
  526.  
  527. } else {
  528.  
  529. $tpl->set( '{rating}', "" );
  530. $tpl->set( '{vote-num}', "" );
  531. $tpl->set_block( "'\\[rating\\](.*?)\\[/rating\\]'si", "" );
  532. }
  533.  
  534. if( $config['allow_alt_url'] == "yes" ) {
  535.  
  536. $go_page = $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/";
  537. $tpl->set( '[day-news]', "<a href=\"".$config['http_home_url'] . date( 'Y/m/d/', $row['date'])."\" >" );
  538.  
  539. } else {
  540.  
  541. $go_page = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode( $row['autor'] );
  542. $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'])."\" >" );
  543.  
  544. }
  545.  
  546. $tpl->set( '[/day-news]', "</a>" );
  547. $tpl->set( '[profile]', "<a href=\"" . $go_page . "\">" );
  548. $tpl->set( '[/profile]', "</a>" );
  549.  
  550. $tpl->set( '{login}', $row['autor'] );
  551.  
  552. $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>" );
  553.  
  554. $_SESSION['referrer'] = $_SERVER['REQUEST_URI'];
  555.  
  556. $tpl->set( '[full-link]', "<a href=\"" . $full_link . "\">" );
  557. $tpl->set( '[/full-link]', "</a>" );
  558.  
  559. $tpl->set( '{full-link}', $full_link );
  560.  
  561. if( $row['allow_comm'] ) {
  562.  
  563. $tpl->set( '[com-link]', "<a id=\"dle-comm-link\" href=\"" . $full_link . "#comment\">" );
  564. $tpl->set( '[/com-link]', "</a>" );
  565.  
  566. } else
  567. $tpl->set_block( "'\\[com-link\\](.*?)\\[/com-link\\]'si", "" );
  568.  
  569. if( ! $row['approve'] and ($member_id['name'] == $row['autor'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) {
  570. $tpl->set( '[edit]', "<a href=\"" . $config['http_home_url'] . "index.php?do=addnews&amp;id=" . $row['id'] . "\" >" );
  571. $tpl->set( '[/edit]', "</a>" );
  572. if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
  573. } 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']) ) {
  574. $tpl->set( '[edit]', "<a onclick=\"return dropdownmenu(this, event, MenuNewsBuild('" . $row['id'] . "', 'full'), '170px')\" href=\"#\">" );
  575. $tpl->set( '[/edit]', "</a>" );
  576. if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
  577. } else
  578. $tpl->set_block( "'\\[edit\\](.*?)\\[/edit\\]'si", "" );
  579.  
  580. if( $config['related_news'] AND $view_template != "print") {
  581.  
  582. if ( $allow_full_cache ) $related_buffer = dle_cache( "related", $row['id'].$config['skin'], true ); else $related_buffer = false;
  583.  
  584. if( $related_buffer === FALSE ) {
  585.  
  586. if ( $row['related_ids'] ) {
  587. $db->query( "SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE id IN({$row['related_ids']}) ORDER BY id DESC");
  588. $first_show = false;
  589.  
  590. } else {
  591. $first_show = true;
  592. $related_ids = array();
  593.  
  594. if( strlen( $row['full_story'] ) < strlen( $row['short_story'] ) ) $body = $row['short_story'];
  595. else $body = $row['full_story'];
  596.  
  597. $body = $db->safesql( strip_tags( stripslashes( $metatags['title'] . " " . $body ) ) );
  598.  
  599. $config['related_number'] = intval( $config['related_number'] );
  600. if( $config['related_number'] < 1 ) $config['related_number'] = 5;
  601.  
  602. $allowed_cats = array();
  603.  
  604. foreach ($user_group as $value) {
  605. if ($value['allow_cats'] != "all" AND !$value['allow_short'] ) $allowed_cats[] = $db->safesql($value['allow_cats']);
  606. }
  607.  
  608. if (count($allowed_cats)) {
  609. $allowed_cats = implode(",", $allowed_cats);
  610. $allowed_cats = explode(",", $allowed_cats);
  611. $allowed_cats = array_unique($allowed_cats);
  612. sort($allowed_cats);
  613.  
  614. if ($config['allow_multi_category']) {
  615.  
  616. $allowed_cats = "category regexp '[[:<:]](" . implode ( '|', $allowed_cats ) . ")[[:>:]]' AND ";
  617.  
  618. } else {
  619.  
  620. $allowed_cats = "category IN ('" . implode ( "','", $allowed_cats ) . "') AND ";
  621.  
  622. }
  623. } else $allowed_cats="";
  624.  
  625. $db->query( "SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE {$allowed_cats}MATCH (title, short_story, full_story, xfields) AGAINST ('$body') AND id != " . $row['id'] . " AND approve=1" . $where_date . " LIMIT " . $config['related_number'] );
  626. }
  627.  
  628. $tpl2 = new dle_template();
  629. $tpl2->dir = TEMPLATE_DIR;
  630. $tpl2->load_template( 'relatednews.tpl' );
  631.  
  632. if( strpos( $tpl2->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl2->copy_template, "[xfgiven_" ) !== false ) { $xfound = true; }
  633. else $xfound = false;
  634.  
  635. while ( $related = $db->get_row() ) {
  636.  
  637. if ( $first_show ) $related_ids[] = $related['id'];
  638.  
  639. $related['date'] = strtotime( $related['date'] );
  640.  
  641. if( ! $related['category'] ) {
  642. $my_cat = "---";
  643. $my_cat_link = "---";
  644. } else {
  645.  
  646. $my_cat = array ();
  647. $my_cat_link = array ();
  648. $rel_cat_list = explode( ',', $related['category'] );
  649.  
  650. if( count( $rel_cat_list ) == 1 ) {
  651.  
  652. $my_cat[] = $cat_info[$rel_cat_list[0]]['name'];
  653.  
  654. $my_cat_link = get_categories( $rel_cat_list[0] );
  655.  
  656. } else {
  657.  
  658. foreach ( $rel_cat_list as $element ) {
  659. if( $element ) {
  660. $my_cat[] = $cat_info[$element]['name'];
  661. if( $config['allow_alt_url'] == "yes" ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
  662. else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  663. }
  664. }
  665.  
  666. $my_cat_link = implode( ', ', $my_cat_link );
  667. }
  668.  
  669. $my_cat = implode( ', ', $my_cat );
  670. }
  671.  
  672. $related['category'] = intval( $related['category'] );
  673.  
  674. if( dle_strlen( $related['title'], $config['charset'] ) > 75 ) $related['title'] = dle_substr( $related['title'], 0, 75, $config['charset'] ) . " ...";
  675.  
  676. if( $config['allow_alt_url'] == "yes" ) {
  677.  
  678. if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
  679.  
  680. if( $related['category'] and $config['seo_type'] == 2 ) {
  681.  
  682. $rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
  683.  
  684. } else {
  685.  
  686. $rel_full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
  687.  
  688. }
  689.  
  690. } else {
  691.  
  692. $rel_full_link = $config['http_home_url'] . date( 'Y/m/d/', $related['date'] ) . $related['alt_name'] . ".html";
  693. }
  694.  
  695. } else {
  696.  
  697. $rel_full_link = $config['http_home_url'] . "index.php?newsid=" . $related['id'];
  698.  
  699. }
  700.  
  701. $tpl2->set( '{title}', strip_tags( stripslashes( $related['title'] ) ) );
  702. $tpl2->set( '{link}', $rel_full_link );
  703. $tpl2->set( '{category}', $my_cat );
  704. $tpl2->set( '{link-category}', $my_cat_link );
  705.  
  706. $related['short_story'] = stripslashes( $related['short_story'] );
  707.  
  708. if( $user_group[$member_id['user_group']]['allow_hide'] ) $related['short_story'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $related['short_story']) );
  709. else $related['short_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $related['short_story'] );
  710.  
  711. if (stripos ( $tpl2->copy_template, "{image-" ) !== false) {
  712.  
  713. $images = array();
  714. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $related['short_story'], $media);
  715. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  716.  
  717. foreach($data as $url) {
  718. $info = pathinfo($url);
  719. if (isset($info['extension'])) {
  720. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
  721. $info['extension'] = strtolower($info['extension']);
  722. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  723. }
  724. }
  725.  
  726. if ( count($images) ) {
  727. $i=0;
  728. foreach($images as $url) {
  729. $i++;
  730. $tpl2->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl2->copy_template );
  731. $tpl2->copy_template = str_replace( '[image-'.$i.']', "", $tpl2->copy_template );
  732. $tpl2->copy_template = str_replace( '[/image-'.$i.']', "", $tpl2->copy_template );
  733. }
  734.  
  735. }
  736.  
  737. $tpl2->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl2->copy_template );
  738. $tpl2->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl2->copy_template );
  739.  
  740. }
  741.  
  742. if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
  743. $count= intval($matches[1]);
  744.  
  745. $related['short_story'] = str_replace( "</p><p>", " ", $related['short_story'] );
  746.  
  747. $related['short_story'] = strip_tags( $related['short_story'], "<br>" );
  748. $related['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $related['short_story'] ) ) ) ));
  749. if( $count AND dle_strlen( $related['short_story'], $config['charset'] ) > $count ) {
  750.  
  751. $related['short_story'] = dle_substr( $related['short_story'], 0, $count, $config['charset'] );
  752.  
  753. if( ($temp_dmax = dle_strrpos( $related['short_story'], ' ', $config['charset'] )) ) $related['short_story'] = dle_substr( $related['short_story'], 0, $temp_dmax, $config['charset'] );
  754.  
  755. }
  756.  
  757. $tpl2->set( $matches[0], $related['short_story'] );
  758.  
  759. } else $tpl2->set( '{text}', $related['short_story'] );
  760.  
  761. if( $xfound ) {
  762. $xfieldsdata = xfieldsdataload( $related['xfields'] );
  763.  
  764. foreach ( $xfields as $value ) {
  765. $preg_safe_name = preg_quote( $value[0], "'" );
  766.  
  767. if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  768. $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  769. $value3 = array();
  770.  
  771. foreach ($temp_array as $value2) {
  772.  
  773. $value2 = trim($value2);
  774. $value2 = str_replace("&#039;", "'", $value2);
  775.  
  776. if( $config['allow_alt_url'] == "yes" ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  777. else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  778. }
  779.  
  780. $xfieldsdata[$value[0]] = implode(", ", $value3);
  781.  
  782. unset($temp_array);
  783. unset($value2);
  784. unset($value3);
  785.  
  786. }
  787.  
  788. if( empty( $xfieldsdata[$value[0]] ) ) {
  789. $tpl2->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
  790. $tpl2->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl2->copy_template );
  791. $tpl2->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl2->copy_template );
  792. } else {
  793. $tpl2->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
  794. $tpl2->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl2->copy_template );
  795. $tpl2->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl2->copy_template );
  796. }
  797.  
  798. $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );
  799.  
  800. if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl2->copy_template, $matches ) ) {
  801. $count= intval($matches[1]);
  802.  
  803. $xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
  804. $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
  805. $xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
  806.  
  807. if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
  808.  
  809. $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
  810.  
  811. if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
  812.  
  813. }
  814.  
  815. $tpl2->set( $matches[0], $xfieldsdata[$value[0]] );
  816.  
  817. } else $tpl2->copy_template = str_replace( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl2->copy_template );
  818.  
  819. }
  820. }
  821.  
  822. $tpl2->compile( 'content' );
  823.  
  824. }
  825.  
  826. $related_buffer = $tpl2->result['content'];
  827. unset($tpl2);
  828. $db->free();
  829.  
  830. if ( $first_show ) {
  831. if ( count($related_ids) ) {
  832. $related_ids = implode(",",$related_ids);
  833. $db->query( "UPDATE " . PREFIX . "_post_extras SET related_ids='{$related_ids}' WHERE news_id='{$row['id']}'" );
  834. }
  835. }
  836.  
  837. if ( $allow_full_cache ) create_cache( "related", $related_buffer, $row['id'].$config['skin'], true );
  838. }
  839.  
  840. if ( $related_buffer ) {
  841.  
  842. $tpl->set( '[related-news]', "" );
  843. $tpl->set( '[/related-news]', "" );
  844.  
  845. } else $tpl->set_block( "'\\[related-news\\](.*?)\\[/related-news\\]'si", "" );
  846.  
  847. $tpl->set( '{related-news}', $related_buffer );
  848.  
  849. }
  850.  
  851. if( $is_logged ) {
  852.  
  853. $fav_arr = explode( ',', $member_id['favorites'] );
  854.  
  855. if( ! in_array( $row['id'], $fav_arr ) ) $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>" );
  856. 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>" );
  857.  
  858. $tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">" );
  859. $tpl->set( '[/complaint]', "</a>" );
  860.  
  861. } else {
  862. $tpl->set( '{favorites}', "" );
  863. $tpl->set_block( "'\\[complaint\\](.*?)\\[/complaint\\]'si", "" );
  864. }
  865.  
  866. if( $row['votes'] ) $tpl->set( '{poll}', $tpl->result['poll'] );
  867. else $tpl->set( '{poll}', '' );
  868.  
  869. if( $config['allow_banner'] ) include_once ENGINE_DIR . '/modules/banners.php';
  870.  
  871. if( $config['allow_banner'] AND count( $banners ) ) {
  872.  
  873. foreach ( $banners as $name => $value ) {
  874. $tpl->copy_template = str_replace( "{banner_" . $name . "}", $value, $tpl->copy_template );
  875.  
  876. if ( $value ) {
  877. $tpl->copy_template = str_replace ( "[banner_" . $name . "]", "", $tpl->copy_template );
  878. $tpl->copy_template = str_replace ( "[/banner_" . $name . "]", "", $tpl->copy_template );
  879. }
  880. }
  881. }
  882.  
  883. $tpl->set_block( "'{banner_(.*?)}'si", "" );
  884. $tpl->set_block ( "'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", "" );
  885.  
  886. if (stripos ( $tpl->copy_template, "{custom" ) !== false) {
  887. $tpl->copy_template = preg_replace_callback ( "#\\{custom(.+?)\\}#i", "custom_print", $tpl->copy_template );
  888. }
  889.  
  890. $tpl->set( '{title}', $row['title'] );
  891.  
  892. if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
  893. $count= intval($matches[1]);
  894. $row['title'] = strip_tags( $row['title'] );
  895.  
  896. if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
  897.  
  898. $row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
  899.  
  900. if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] );
  901.  
  902. }
  903. $tpl->set( $matches[0], $row['title'] );
  904.  
  905. }
  906.  
  907. $row['short_story'] = stripslashes($row['short_story']);
  908. $row['full_story'] = stripslashes($row['full_story']);
  909.  
  910. if (stripos ( $tpl->copy_template, "{image-" ) !== false) {
  911.  
  912. $images = array();
  913. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
  914. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  915.  
  916. foreach($data as $url) {
  917. $info = pathinfo($url);
  918. if (isset($info['extension'])) {
  919. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
  920. $info['extension'] = strtolower($info['extension']);
  921. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  922. }
  923. }
  924.  
  925. if ( count($images) ) {
  926. $i=0;
  927. foreach($images as $url) {
  928. $i++;
  929. $tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
  930. $tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
  931. $tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
  932. }
  933.  
  934. }
  935.  
  936. $tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
  937. $tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  938.  
  939. }
  940.  
  941.  
  942. if (stripos ( $tpl->copy_template, "{fullimage-" ) !== false) {
  943.  
  944. $images = array();
  945. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_story'], $media);
  946. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  947.  
  948. foreach($data as $url) {
  949. $info = pathinfo($url);
  950. if (isset($info['extension'])) {
  951. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
  952. $info['extension'] = strtolower($info['extension']);
  953. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  954. }
  955. }
  956.  
  957. if ( count($images) ) {
  958. $i=0;
  959. foreach($images as $url) {
  960. $i++;
  961. $tpl->copy_template = str_replace( '{fullimage-'.$i.'}', $url, $tpl->copy_template );
  962. $tpl->copy_template = str_replace( '[fullimage-'.$i.']', "", $tpl->copy_template );
  963. $tpl->copy_template = str_replace( '[/fullimage-'.$i.']', "", $tpl->copy_template );
  964. }
  965.  
  966. }
  967.  
  968. $tpl->copy_template = preg_replace( "#\[fullimage-(.+?)\](.+?)\[/fullimage-(.+?)\]#is", "", $tpl->copy_template );
  969. $tpl->copy_template = preg_replace( "#\\{fullimage-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  970.  
  971. }
  972.  
  973. if ($smartphone_detected) {
  974.  
  975. if (!$config['allow_smart_format']) {
  976.  
  977. $row['short_story'] = strip_tags( $row['short_story'], '<p><br><a>' );
  978. $row['full_story'] = strip_tags( $row['full_story'], '<p><br><a>' );
  979.  
  980. } else {
  981.  
  982. if ( !$config['allow_smart_images'] ) {
  983.  
  984. $row['short_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['short_story'] );
  985. $row['short_story'] = preg_replace( "#<img(.+?)>#is", "", $row['short_story'] );
  986. $row['full_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['full_story'] );
  987. $row['full_story'] = preg_replace( "#<img(.+?)>#is", "", $row['full_story'] );
  988.  
  989. }
  990.  
  991. if ( !$config['allow_smart_video'] ) {
  992.  
  993. $row['short_story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['short_story'] );
  994. $row['short_story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['short_story'] );
  995. $row['full_story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['full_story'] );
  996. $row['full_story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['full_story'] );
  997.  
  998. }
  999.  
  1000. }
  1001.  
  1002. }
  1003. $tpl->set( '{comments}', "<!--dlecomments-->" );
  1004. $tpl->set( '{addcomments}', "<!--dleaddcomments-->" );
  1005. $tpl->set( '{navigation}', "<!--dlenavigationcomments-->" );
  1006.  
  1007. $tpl->set( '{short-story}', $row['short_story'] );
  1008.  
  1009. $tpl->set( '{full-story}', "<div id=\"news-id-" . $row['id'] . "\" style=\"display:inline;\">" . $row['full_story'] . "</div>");
  1010.  
  1011. if ( preg_match( "#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
  1012. $count= intval($matches[1]);
  1013.  
  1014. $row['full_story'] = str_replace( "</p><p>", " ", $row['full_story'] );
  1015. $row['full_story'] = strip_tags( $row['full_story'], "<br>" );
  1016. $row['full_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['full_story'] ) ) ) ));
  1017.  
  1018. if( $count AND dle_strlen( $row['full_story'], $config['charset'] ) > $count ) {
  1019.  
  1020. $row['full_story'] = dle_substr( $row['full_story'], 0, $count, $config['charset'] );
  1021.  
  1022. if( ($temp_dmax = dle_strrpos( $row['full_story'], ' ', $config['charset'] )) ) $row['full_story'] = dle_substr( $row['full_story'], 0, $temp_dmax, $config['charset'] );
  1023.  
  1024. }
  1025.  
  1026. $tpl->set( $matches[0], "<div id=\"news-id-" . $row['id'] . "\" style=\"display:inline;\">" .$row['full_story'] . "</div>" );
  1027.  
  1028. }
  1029.  
  1030. if( $row['keywords'] == '' and $row['descr'] == '' ) create_keywords( $row['short_story'] . $row['full_story'] );
  1031. else {
  1032. $metatags['keywords'] = $row['keywords'];
  1033. $metatags['description'] = $row['descr'];
  1034. }
  1035.  
  1036. if ($row['metatitle']) $metatags['header_title'] = $row['metatitle'];
  1037.  
  1038. if( strpos( $tpl->copy_template, "[xfvalue_" ) !== false OR strpos( $tpl->copy_template, "[xfgiven_" ) !== false ) {
  1039.  
  1040. $xfieldsdata = xfieldsdataload( $row['xfields'] );
  1041.  
  1042. foreach ( $xfields as $value ) {
  1043. $preg_safe_name = preg_quote( $value[0], "'" );
  1044.  
  1045. if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  1046. $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  1047. $value3 = array();
  1048.  
  1049. foreach ($temp_array as $value2) {
  1050.  
  1051. $value2 = trim($value2);
  1052. $value2 = str_replace("&#039;", "'", $value2);
  1053.  
  1054. if( $config['allow_alt_url'] == "yes" ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" . urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  1055. else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  1056. }
  1057.  
  1058. $xfieldsdata[$value[0]] = implode(", ", $value3);
  1059.  
  1060. unset($temp_array);
  1061. unset($value2);
  1062. unset($value3);
  1063.  
  1064. }
  1065.  
  1066. if( empty( $xfieldsdata[$value[0]] ) ) {
  1067. $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  1068. $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  1069. $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  1070. } else {
  1071. $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  1072. $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
  1073. $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
  1074. }
  1075.  
  1076. $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );
  1077.  
  1078. if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches ) ) {
  1079. $count= intval($matches[1]);
  1080.  
  1081. $xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
  1082. $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
  1083. $xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
  1084.  
  1085. if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
  1086.  
  1087. $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
  1088.  
  1089. if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
  1090.  
  1091. }
  1092.  
  1093. $tpl->set( $matches[0], $xfieldsdata[$value[0]] );
  1094.  
  1095. } else $tpl->copy_template = str_replace( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl->copy_template );
  1096. }
  1097. }
  1098.  
  1099. $category_id = $row['category'];
  1100.  
  1101. $tpl->compile( 'content' );
  1102.  
  1103. if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
  1104. else $tpl->result['content'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content'] );
  1105.  
  1106. $news_id = $row['id'];
  1107. $allow_comments = $row['allow_comm'];
  1108.  
  1109. $allow_add = true;
  1110.  
  1111. if ( $config['max_comments_days'] ) {
  1112.  
  1113. if ($row['date'] < ($_TIME - ($config['max_comments_days'] * 3600 * 24)) ) $allow_add = false;
  1114.  
  1115. }
  1116.  
  1117. if( isset( $view_template ) ) $allow_comments = false;
  1118.  
  1119. }
  1120.  
  1121. $tpl->clear();
  1122. unset( $row );
  1123.  
  1124. if( $config['files_allow'] == "yes" ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
  1125. $tpl->result['content'] = show_attach( $tpl->result['content'], $news_id );
  1126. }
  1127.  
  1128. if( !$news_found AND !$perm ) msgbox( $lang['all_err_1'], "<b>{$user_group[$member_id['user_group']]['group_name']}</b> " . $lang['news_err_28'] );
  1129. elseif( !$news_found ) {
  1130. @header( "HTTP/1.0 404 Not Found" );
  1131. msgbox( $lang['all_err_1'], $lang['news_err_12'] );
  1132. }
  1133.  
  1134. //####################################################################################################################
  1135. // Просмотр комментариев
  1136. //####################################################################################################################
  1137. if( $allow_comments AND $news_found) {
  1138.  
  1139. if( $comments_num > 0 ) {
  1140.  
  1141. include_once ENGINE_DIR . '/classes/comments.class.php';
  1142. $comments = new DLE_Comments( $db, $comments_num, intval($config['comm_nummers']) );
  1143.  
  1144. if( $config['comm_msort'] == "" ) $config['comm_msort'] = "ASC";
  1145.  
  1146. if( $config['allow_cmod'] ) $where_approve = " AND " . PREFIX . "_comments.approve=1";
  1147. else $where_approve = "";
  1148.  
  1149. $comments->query = "SELECT " . PREFIX . "_comments.id, post_id, " . PREFIX . "_comments.user_id, date, autor as gast_name, " . PREFIX . "_comments.email as gast_email, text, ip, is_register, name, " . USERPREFIX . "_users.email, news_num, comm_num, user_group, lastdate, reg_date, signature, foto, fullname, land, icq, xfields FROM " . PREFIX . "_comments LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_comments.user_id=" . USERPREFIX . "_users.user_id WHERE " . PREFIX . "_comments.post_id = '$news_id'" . $where_approve . " ORDER BY date " . $config['comm_msort'];
  1150.  
  1151. if ( $allow_full_cache AND $config['allow_comments_cache'] ) $allow_full_cache = $news_id; else $allow_full_cache = false;
  1152.  
  1153. $comments->build_comments('comments.tpl', 'news', $allow_full_cache, $full_link );
  1154.  
  1155. unset ($tpl->result['comments']);
  1156.  
  1157. if( isset($_GET['news_page']) AND $_GET['news_page'] ) $user_query = "newsid=" . $newsid . "&amp;news_page=" . intval( $_GET['news_page'] ); else $user_query = "newsid=" . $newsid;
  1158.  
  1159. $comments->build_navigation('navigation.tpl', $link_page . "{page}," . $news_name . ".html#comment", $user_query, $full_link);
  1160.  
  1161. unset ($comments);
  1162. unset ($tpl->result['commentsnavigation']);
  1163.  
  1164. }
  1165.  
  1166. if ($is_logged AND $config['comments_restricted'] AND (($_TIME - $member_id['reg_date']) < ($config['comments_restricted'] * 86400)) ) {
  1167.  
  1168. $lang['news_info_6'] = str_replace( '{days}', intval($config['comments_restricted']), $lang['news_info_8'] );
  1169. $allow_add = false;
  1170.  
  1171. }
  1172.  
  1173. if (!isset($member_id['restricted'])) $member_id['restricted'] = false;
  1174.  
  1175. if( $member_id['restricted'] AND $member_id['restricted_days'] AND $member_id['restricted_date'] < $_TIME ) {
  1176.  
  1177. $member_id['restricted'] = 0;
  1178. $db->query( "UPDATE LOW_PRIORITY " . USERPREFIX . "_users SET restricted='0', restricted_days='0', restricted_date='' WHERE user_id='{$member_id['user_id']}'" );
  1179.  
  1180. }
  1181.  
  1182. if( $user_group[$member_id['user_group']]['allow_addc'] AND $config['allow_comments'] == "yes" AND $allow_add AND ($member_id['restricted'] != 2 AND $member_id['restricted'] != 3) ) {
  1183.  
  1184. if( !$comments_num ) {
  1185. if( strpos ( $tpl->result['content'], "<!--dlecomments-->" ) !== false ) {
  1186.  
  1187. $tpl->result['content'] = str_replace ( "<!--dlecomments-->", "\n<div id=\"dle-ajax-comments\"></div>\n", $tpl->result['content'] );
  1188.  
  1189. } else $tpl->result['content'] .= "\n<div id=\"dle-ajax-comments\"></div>\n";
  1190. }
  1191.  
  1192. $tpl->load_template( 'addcomments.tpl' );
  1193.  
  1194. if ($config['allow_subscribe'] AND $user_group[$member_id['user_group']]['allow_subscribe']) $allow_subscribe = true; else $allow_subscribe = false;
  1195.  
  1196. if( $config['allow_comments_wysiwyg'] ) {
  1197. include_once ENGINE_DIR . '/editor/comments.php';
  1198. $bb_code = "";
  1199. $allow_comments_ajax = true;
  1200. } else
  1201. include_once ENGINE_DIR . '/modules/bbcode.php';
  1202.  
  1203. if ( $is_logged AND $user_group[$member_id['user_group']]['disable_comments_captcha'] AND $member_id['comm_num'] >= $user_group[$member_id['user_group']]['disable_comments_captcha'] ) {
  1204.  
  1205. $user_group[$member_id['user_group']]['comments_question'] = false;
  1206. $user_group[$member_id['user_group']]['captcha'] = false;
  1207.  
  1208. }
  1209.  
  1210. if( $user_group[$member_id['user_group']]['comments_question'] ) {
  1211.  
  1212. $tpl->set( '[question]', "" );
  1213. $tpl->set( '[/question]', "" );
  1214.  
  1215. $question = $db->super_query("SELECT id, question FROM " . PREFIX . "_question ORDER BY RAND() LIMIT 1");
  1216. $tpl->set( '{question}', "<span id=\"dle-question\">".htmlspecialchars( stripslashes( $question['question'] ), ENT_QUOTES, $config['charset'] )."</span>" );
  1217.  
  1218. $_SESSION['question'] = $question['id'];
  1219.  
  1220. } else {
  1221.  
  1222. $tpl->set_block( "'\\[question\\](.*?)\\[/question\\]'si", "" );
  1223. $tpl->set( '{question}', "" );
  1224.  
  1225. }
  1226.  
  1227. if( $user_group[$member_id['user_group']]['captcha'] ) {
  1228.  
  1229. if ( $config['allow_recaptcha'] ) {
  1230.  
  1231. $tpl->set( '[recaptcha]', "" );
  1232. $tpl->set( '[/recaptcha]', "" );
  1233.  
  1234. $tpl->set( '{recaptcha}', '<div id="dle_recaptcha"></div>' );
  1235.  
  1236. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  1237. $tpl->set( '{reg_code}', "" );
  1238.  
  1239. } else {
  1240.  
  1241. $tpl->set( '[sec_code]', "" );
  1242. $tpl->set( '[/sec_code]', "" );
  1243. $path = parse_url( $config['http_home_url'] );
  1244. $tpl->set( '{sec_code}', "<span id=\"dle-captcha\"><img src=\"" . $path['path'] . "engine/modules/antibot.php\" alt=\"${lang['sec_image']}\" /><br /><a onclick=\"reload(); return false;\" href=\"#\">{$lang['reload_code']}</a></span>" );
  1245. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  1246. $tpl->set( '{recaptcha}', "" );
  1247. }
  1248.  
  1249. } else {
  1250. $tpl->set( '{sec_code}', "" );
  1251. $tpl->set( '{recaptcha}', "" );
  1252. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  1253. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  1254. }
  1255.  
  1256. if( $config['allow_comments_wysiwyg'] ) {
  1257.  
  1258. $tpl->set( '{editor}', $wysiwyg );
  1259.  
  1260. } else {
  1261. $tpl->set( '{editor}', $bb_code );
  1262.  
  1263. }
  1264.  
  1265. $tpl->set( '{text}', '' );
  1266. $tpl->set( '{title}', $lang['news_addcom'] );
  1267.  
  1268. if( ! $is_logged ) {
  1269. $tpl->set( '[not-logged]', '' );
  1270. $tpl->set( '[/not-logged]', '' );
  1271. } else
  1272. $tpl->set_block( "'\\[not-logged\\](.*?)\\[/not-logged\\]'si", "" );
  1273.  
  1274. if( $is_logged ) $hidden = "<input type=\"hidden\" name=\"name\" id=\"name\" value=\"{$member_id['name']}\" /><input type=\"hidden\" name=\"mail\" id=\"mail\" value=\"\" />";
  1275. else $hidden = "";
  1276.  
  1277. $tpl->copy_template = "<form method=\"post\" name=\"dle-comments-form\" id=\"dle-comments-form\" action=\"{$_SESSION['referrer']}\">" . $tpl->copy_template . "
  1278. <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />{$hidden}
  1279. <input type=\"hidden\" name=\"post_id\" id=\"post_id\" value=\"$news_id\" /></form>";
  1280.  
  1281. if (!isset($path['path'])) $path['path'] = "/";
  1282.  
  1283. $tpl->copy_template .= <<<HTML
  1284. <script language="javascript" type="text/javascript">
  1285. <!--
  1286. $(function(){
  1287.  
  1288. $('#dle-comments-form').submit(function() {
  1289. doAddComments();
  1290. return false;
  1291. });
  1292.  
  1293. });
  1294.  
  1295. function reload () {
  1296.  
  1297. var rndval = new Date().getTime();
  1298.  
  1299. document.getElementById('dle-captcha').innerHTML = '<img src="{$path['path']}engine/modules/antibot.php?rndval=' + rndval + '" width="120" height="50" alt="" /><br /><a onclick="reload(); return false;" href="#">{$lang['reload_code']}</a>';
  1300.  
  1301. };
  1302. //-->
  1303. </script>
  1304. HTML;
  1305.  
  1306. if ( $user_group[$member_id['user_group']]['captcha'] AND $config['allow_recaptcha'] ) {
  1307.  
  1308. $tpl->copy_template .= <<<HTML
  1309. <script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js"></script>
  1310. <script language="javascript" type="text/javascript">
  1311. <!--
  1312. $(function(){
  1313. Recaptcha.create("{$config['recaptcha_public_key']}",
  1314. "dle_recaptcha",
  1315. {
  1316. theme: "{$config['recaptcha_theme']}",
  1317. lang: "{$lang['wysiwyg_language']}"
  1318. }
  1319. );
  1320. });
  1321. //-->
  1322. </script>
  1323. HTML;
  1324.  
  1325. }
  1326.  
  1327. $tpl->compile( 'addcomments' );
  1328. $tpl->clear();
  1329.  
  1330. if ( strpos ( $tpl->result['content'], "<!--dleaddcomments-->" ) !== false ) {
  1331.  
  1332. $tpl->result['content'] = str_replace ( "<!--dleaddcomments-->", $tpl->result['addcomments'], $tpl->result['content'] );
  1333.  
  1334. } else {
  1335.  
  1336. $tpl->result['content'] .= $tpl->result['addcomments'];
  1337.  
  1338. }
  1339.  
  1340. unset ($tpl->result['addcomments']);
  1341.  
  1342. } elseif( $member_id['restricted'] ) {
  1343.  
  1344. $tpl->load_template( 'info.tpl' );
  1345.  
  1346. if( $member_id['restricted_days'] ) {
  1347.  
  1348. $tpl->set( '{error}', $lang['news_info_2'] );
  1349. $tpl->set( '{date}', langdate( "j F Y H:i", $member_id['restricted_date'] ) );
  1350.  
  1351. } else
  1352. $tpl->set( '{error}', $lang['news_info_3'] );
  1353.  
  1354. $tpl->set( '{title}', $lang['all_info'] );
  1355. $tpl->compile( 'content' );
  1356. $tpl->clear();
  1357.  
  1358. } elseif( !$allow_add ) {
  1359.  
  1360. $tpl->load_template( 'info.tpl' );
  1361. $tpl->set( '{error}', $lang['news_info_6'] );
  1362. $tpl->set( '{days}', $config['max_comments_days'] );
  1363. $tpl->set( '{title}', $lang['all_info'] );
  1364. $tpl->compile( 'content' );
  1365. $tpl->clear();
  1366.  
  1367. } elseif( $config['allow_comments'] != "no") {
  1368.  
  1369. $tpl->load_template( 'info.tpl' );
  1370. $tpl->set( '{error}', $lang['news_info_1'] );
  1371. $tpl->set( '{group}', $user_group[$member_id['user_group']]['group_name'] );
  1372. $tpl->set( '{title}', $lang['all_info'] );
  1373. $tpl->compile( 'content' );
  1374. $tpl->clear();
  1375.  
  1376. }
  1377. }
  1378. ?>
Add Comment
Please, Sign In to add comment