baseroad

show.full

Apr 8th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 80.18 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-2017 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.  
  22. $allow_list = explode( ',', $user_group[$member_id['user_group']]['allow_cats'] );
  23. $not_allow_cats = explode ( ',', $user_group[$member_id['user_group']]['not_allow_cats'] );
  24.  
  25. $perm = 1;
  26. $i = 0;
  27. $news_found = false;
  28. $allow_full_cache = false;
  29.  
  30. if ( $config['allow_alt_url'] AND !$config['seo_type'] ) $cprefix = "full"; else $cprefix = "full_".$newsid;
  31.  
  32. $row = dle_cache ( $cprefix, $sql_news );
  33.  
  34. if( $row ) {
  35.  
  36. $row = unserialize($row);
  37.  
  38. if ( !is_array($row) ) die( "Cache data not correct" );
  39.  
  40. $full_cache = true;
  41.  
  42. } else {
  43. $row = $db->super_query( $sql_news );
  44. $full_cache = false;
  45. }
  46.  
  47. $options = news_permission( $row['access'] );
  48. if( $options[$member_id['user_group']] AND $options[$member_id['user_group']] != 3 ) $perm = 1;
  49. if( $options[$member_id['user_group']] == 3 ) $perm = 0;
  50.  
  51. if( $options[$member_id['user_group']] == 1 ) $user_group[$member_id['user_group']]['allow_addc'] = 0;
  52. if( $options[$member_id['user_group']] == 2 ) $user_group[$member_id['user_group']]['allow_addc'] = 1;
  53.  
  54. if( $row['id'] AND !$row['approve'] AND $member_id['name'] != $row['autor'] AND !$user_group[$member_id['user_group']]['allow_all_edit'] ) $perm = 0;
  55. if( !$row['approve'] ) $allow_comments = false;
  56.  
  57. if ($row['id'] AND $config['no_date'] AND !$config['news_future'] AND !$user_group[$member_id['user_group']]['allow_all_edit']) {
  58.  
  59. if( strtotime($row['date']) > $_TIME ) {
  60. $perm = 0;
  61. }
  62.  
  63. }
  64.  
  65. if ($config['category_separator'] != ',') $config['category_separator'] = ' '.$config['category_separator'];
  66.  
  67. if( ! $row['category'] ) {
  68. $my_cat = "---";
  69. $my_cat_link = "---";
  70. } else {
  71.  
  72. $my_cat = array ();
  73. $my_cat_link = array ();
  74. $cat_list = explode( ',', $row['category'] );
  75.  
  76. if( count( $cat_list ) == 1 ) {
  77.  
  78. if( $allow_list[0] != "all" AND !in_array( $cat_list[0], $allow_list ) ) $perm = 0;
  79.  
  80. if( $not_allow_cats[0] != "" AND in_array( $cat_list[0], $not_allow_cats ) ) $perm = 0;
  81.  
  82. $my_cat[] = $cat_info[$cat_list[0]]['name'];
  83.  
  84. $my_cat_link = get_categories( $cat_list[0], $config['category_separator'] );
  85.  
  86. } else {
  87.  
  88. foreach ( $cat_list as $element ) {
  89.  
  90. if( $allow_list[0] != "all" AND !in_array( $element, $allow_list ) ) $perm = 0;
  91.  
  92. if( $not_allow_cats[0] != "" AND in_array( $element, $not_allow_cats ) ) $perm = 0;
  93.  
  94. if( $element ) {
  95. $my_cat[] = $cat_info[$element]['name'];
  96. if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
  97. else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&amp;category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  98. }
  99. }
  100.  
  101. $my_cat_link = implode( "{$config['category_separator']} ", $my_cat_link );
  102. }
  103.  
  104. //$my_cat = implode( "{$config['category_separator']} ", $my_cat );
  105.  
  106. $my_cat = end( $my_cat );
  107. }
  108.  
  109. if ( $row['id'] AND $perm ) {
  110.  
  111. $config['fullcache_days'] = intval($config['fullcache_days']);
  112.  
  113. if( $config['fullcache_days'] < 1 ) $config['fullcache_days'] = 30;
  114.  
  115. if( strtotime($row['date']) >= ($_TIME - ($config['fullcache_days'] * 86400)) ) {
  116.  
  117. $allow_full_cache = true;
  118.  
  119. }
  120.  
  121. define( 'NEWS_ID', $row['id'] );
  122.  
  123. $disable_index = $row['disable_index'];
  124. $news_author = $row['user_id'];
  125.  
  126. if ($allow_full_cache AND !$full_cache) create_cache ( $cprefix, serialize($row), $sql_news );
  127.  
  128. $xfields = xfieldsload();
  129.  
  130. if( $row['votes'] AND $view_template != "print" ) include_once ENGINE_DIR . '/modules/poll.php';
  131.  
  132. $category_id = intval( $row['category'] );
  133.  
  134. if( $view_template == "print" ) $tpl->load_template( 'print.tpl' );
  135. elseif( $category_id and $cat_info[$category_id]['full_tpl'] != '' ) $tpl->load_template( $cat_info[$category_id]['full_tpl'] . '.tpl' );
  136. else $tpl->load_template( 'fullstory.tpl' );
  137.  
  138. if( $config['allow_read_count'] AND !$news_page AND !$cstart) {
  139. if ( $config['allow_read_count'] == 2 ) {
  140.  
  141. $readcount = $db->super_query( "SELECT count(*) as count FROM " . PREFIX . "_read_log WHERE news_id='{$row['id']}' AND ip='{$_IP}'" );
  142.  
  143. if( !$readcount['count'] ) {
  144.  
  145. if( $config['cache_count'] ) $db->query( "INSERT INTO " . PREFIX . "_views (news_id) VALUES ('{$row['id']}')" );
  146. else $db->query( "UPDATE " . PREFIX . "_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'" );
  147.  
  148. $db->query( "INSERT INTO " . PREFIX . "_read_log (news_id, ip) VALUES ('{$row['id']}', '{$_IP}')" );
  149. }
  150.  
  151. } else {
  152.  
  153. if( $config['cache_count'] ) $db->query( "INSERT INTO " . PREFIX . "_views (news_id) VALUES ('{$row['id']}')" );
  154. else $db->query( "UPDATE " . PREFIX . "_post_extras SET news_read=news_read+1 WHERE news_id='{$row['id']}'" );
  155. }
  156. }
  157.  
  158. $news_found = TRUE;
  159. $row['date'] = strtotime( $row['date'] );
  160.  
  161. if( (strlen( $row['full_story'] ) < 13) and (strpos( $tpl->copy_template, "{short-story}" ) === false) ) {
  162. $row['full_story'] = $row['short_story'];
  163. }
  164.  
  165. if( ! $news_page ) {
  166. $news_page = 1;
  167. }
  168.  
  169. if( $config['allow_alt_url'] ) {
  170.  
  171. if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
  172.  
  173. if( $category_id AND $config['seo_type'] == 2 ) {
  174.  
  175. $c_url = get_url( $category_id );
  176. $full_link = $config['http_home_url'] . $c_url . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
  177.  
  178. if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
  179.  
  180. 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) ) {
  181.  
  182. if ($view_template == "print") {
  183.  
  184. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  185. $re_url = reset ( $re_url );
  186.  
  187. } else {
  188.  
  189. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  190. $re_url = reset ( $re_url );
  191.  
  192. }
  193.  
  194. header("HTTP/1.0 301 Moved Permanently");
  195. header("Location: {$re_url}{$c_url}/{$row['id']}-{$row['alt_name']}.html");
  196. die("Redirect");
  197.  
  198. }
  199.  
  200. }
  201.  
  202. $print_link = $config['http_home_url'] . $c_url . "/print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
  203. $short_link = $config['http_home_url'] . $c_url . "/";
  204. $row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
  205. $link_page = $config['http_home_url'] . $c_url . "/" . 'page,' . $news_page . ',';
  206. $news_name = $row['alt_name'];
  207.  
  208. } else {
  209.  
  210. $full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
  211.  
  212. if ($config['seo_control'] AND ( isset($_GET['seourl']) OR strpos ( $_SERVER['REQUEST_URI'], "?" ) !== false ) ) {
  213.  
  214. 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) ) {
  215.  
  216. if ($view_template == "print") {
  217.  
  218. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  219. $re_url = reset ( $re_url );
  220.  
  221. } else {
  222.  
  223. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  224. $re_url = reset ( $re_url );
  225.  
  226. }
  227.  
  228. header("HTTP/1.0 301 Moved Permanently");
  229. header("Location: {$re_url}{$row['id']}-{$row['alt_name']}.html");
  230. die("Redirect");
  231.  
  232. }
  233.  
  234. }
  235.  
  236. $print_link = $config['http_home_url'] . "print:page,1," . $row['id'] . "-" . $row['alt_name'] . ".html";
  237. $short_link = $config['http_home_url'];
  238. $row['alt_name'] = $row['id'] . "-" . $row['alt_name'];
  239. $link_page = $config['http_home_url'] . 'page,' . $news_page . ',';
  240. $news_name = $row['alt_name'];
  241.  
  242. }
  243.  
  244. } else {
  245.  
  246. $full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
  247.  
  248. if ( $config['seo_control'] ) {
  249.  
  250. 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) ) {
  251.  
  252. if ($view_template == "print") {
  253.  
  254. $re_url = explode ( "engine/print.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  255. $re_url = reset ( $re_url );
  256.  
  257. } else {
  258.  
  259. $re_url = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );
  260. $re_url = reset ( $re_url );
  261.  
  262. }
  263.  
  264. header("HTTP/1.0 301 Moved Permanently");
  265. header("Location: {$re_url}".date( 'Y/m/d/', $row['date'] ).$row['alt_name'].".html");
  266. die("Redirect");
  267.  
  268. }
  269.  
  270. }
  271.  
  272. $print_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . "print:page,1," . $row['alt_name'] . ".html";
  273. $short_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] );
  274. $link_page = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . 'page,' . $news_page . ',';
  275. $news_name = $row['alt_name'];
  276.  
  277. }
  278.  
  279. } else {
  280.  
  281. $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
  282. $print_link = $config['http_home_url'] . "engine/print.php?newsid=" . $row['id'];
  283. $short_link = "";
  284. $link_page = "";
  285. $news_name = "";
  286.  
  287. }
  288.  
  289. $i ++;
  290. //
  291. // обработка страниц
  292. //
  293.  
  294. $news_seiten = explode( "{PAGEBREAK}", $row['full_story'] );
  295. $anzahl_seiten = count( $news_seiten );
  296.  
  297. if( $news_page <= 0 OR $news_page > $anzahl_seiten OR (isset($_GET['news_page']) AND $_GET['news_page'] === "0") ) {
  298.  
  299. $news_page = 1;
  300.  
  301. if ( $config['seo_control'] ) {
  302. $re_url = str_replace( $config['http_home_url'], "/", $full_link );
  303. header("HTTP/1.0 301 Moved Permanently");
  304. header("Location: {$re_url}");
  305. die("Redirect");
  306. }
  307. }
  308.  
  309. if( $view_template == "print" ) {
  310.  
  311. $row['full_story'] = str_replace( "{PAGEBREAK}", "", $row['full_story'] );
  312. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "\\2", $row['full_story'] );
  313. $tpl->set_block( "'\\[pages\\](.*?)\\[/pages\\]'si", "" );
  314. $tpl->set( '{pages}', "" );
  315.  
  316. } else {
  317.  
  318. $row['full_story'] = $news_seiten[$news_page - 1];
  319.  
  320. $row['full_story'] = preg_replace( '#(\A[\s]*<br[^>]*>[\s]*|<br[^>]*>[\s]*\Z)#is', '', $row['full_story'] ); // remove <br/> at end of string
  321. $news_seiten = "";
  322. unset( $news_seiten );
  323.  
  324. if( $anzahl_seiten > 1 ) {
  325.  
  326. $tpl2 = new dle_template();
  327. $tpl2->dir = TEMPLATE_DIR;
  328. $tpl2->load_template( 'splitnewsnavigation.tpl' );
  329.  
  330. if( $news_page < $anzahl_seiten ) {
  331. $pages = $news_page + 1;
  332.  
  333. if( $config['allow_alt_url'] ) {
  334. $nextpage = "<a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">";
  335. } else {
  336. $nextpage = "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">";
  337. }
  338.  
  339. $tpl2->set( '[next-link]', $nextpage );
  340. $tpl2->set( '[/next-link]', "</a>" );
  341.  
  342. } else {
  343.  
  344. $tpl2->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>" );
  345.  
  346. }
  347.  
  348. if( $news_page > 1 ) {
  349. $pages = $news_page - 1;
  350.  
  351. if( $config['allow_alt_url'] ) {
  352. if ( $pages == 1 ) $prevpage = "<a href=\"" . $full_link . "\">";
  353. else $prevpage = "<a href=\"" . $short_link . "page," . $pages . "," . $row['alt_name'] . ".html\">";
  354. } else {
  355. if ( $pages == 1 ) $prevpage = "<a href=\"" . $full_link. "\">";
  356. else $prevpage = "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $pages . "\">";
  357. }
  358.  
  359. $tpl2->set( '[prev-link]', $prevpage );
  360. $tpl2->set( '[/prev-link]', "</a>" );
  361.  
  362. } else {
  363.  
  364. $tpl2->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<span>\\1</span>" );
  365.  
  366. }
  367.  
  368. $listpages ="";
  369.  
  370. if( $anzahl_seiten <= 10 ) {
  371.  
  372. for($j = 1; $j <= $anzahl_seiten; $j ++) {
  373.  
  374. if( $j != $news_page ) {
  375.  
  376. if( $config['allow_alt_url'] ) {
  377.  
  378. if ($j == 1)
  379. $listpages .= "<a href=\"" . $full_link . "\">$j</a> ";
  380. else
  381. $listpages .= "<a href=\"" . $short_link . "page," . $j . "," . $row['alt_name'] . ".html\">$j</a> ";
  382.  
  383. } else {
  384.  
  385. if ($j == 1)
  386. $listpages .= "<a href=\"{$full_link}\">$j</a> ";
  387. else
  388. $listpages .= "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $j . "\">$j</a> ";
  389.  
  390. }
  391.  
  392. } else {
  393.  
  394. $listpages .= "<span>$j</span> ";
  395. }
  396.  
  397. }
  398.  
  399. } else {
  400.  
  401. $start = 1;
  402. $end = 10;
  403. $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  404.  
  405. if( $news_page > 1 ) {
  406.  
  407. if( $news_page > 6 ) {
  408.  
  409. $start = $news_page - 4;
  410. $end = $start + 8;
  411.  
  412. if( $end >= $anzahl_seiten-1 ) {
  413. $start = $anzahl_seiten - 9;
  414. $end = $anzahl_seiten - 1;
  415. }
  416.  
  417. }
  418.  
  419. }
  420.  
  421. if( $end >= $anzahl_seiten-1 ) $nav_prefix = ""; else $nav_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> ";
  422.  
  423. if( $start >= 2 ) {
  424.  
  425. if( $start >= 3 ) $before_prefix = "<span class=\"nav_ext\">{$lang['nav_trennen']}</span> "; else $before_prefix = "";
  426.  
  427. $listpages .= "<a href=\"" . $full_link . "\">1</a> ".$before_prefix;
  428.  
  429. }
  430.  
  431. for($j = $start; $j <= $end; $j ++) {
  432.  
  433. if( $j != $news_page ) {
  434.  
  435. if( $config['allow_alt_url'] ) {
  436.  
  437. if ($j == 1)
  438. $listpages .= "<a href=\"" . $full_link . "\">$j</a> ";
  439. else
  440. $listpages .= "<a href=\"" . $short_link . "page," . $j . "," . $row['alt_name'] . ".html\">$j</a> ";
  441.  
  442. } else {
  443.  
  444. if ($j == 1)
  445. $listpages .= "<a href=\"{$full_link}\">$j</a> ";
  446. else
  447. $listpages .= "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $j . "\">$j</a> ";
  448.  
  449. }
  450.  
  451. } else {
  452.  
  453. $listpages .= "<span>$j</span> ";
  454. }
  455.  
  456. }
  457.  
  458. if( $news_page != $anzahl_seiten ) {
  459.  
  460. if( $config['allow_alt_url'] ) $listpages .= $nav_prefix . "<a href=\"" . $short_link . "page," . $anzahl_seiten . "," . $row['alt_name'] . ".html\">{$anzahl_seiten}</a>";
  461. else $listpages .= $nav_prefix . "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=" . $anzahl_seiten . "\">{$anzahl_seiten}</a>";
  462.  
  463. } else
  464. $listpages .= "<span>{$anzahl_seiten}</span> ";
  465.  
  466. }
  467.  
  468. $tpl2->set( '{pages}', $listpages );
  469. $tpl2->compile( 'content' );
  470.  
  471. $tpl->set( '{pages}', $tpl2->result['content'] );
  472. unset($tpl2);
  473.  
  474. if( $config['allow_alt_url'] ) {
  475.  
  476. $replacepage = "<a href=\"" . $short_link . "page," . "\\1" . "," . $row['alt_name'] . ".html\">\\2</a>";
  477.  
  478. } else {
  479.  
  480. $replacepage = "<a href=\"$PHP_SELF?newsid=" . $row['id'] . "&amp;news_page=\\1\">\\2</a>";
  481. }
  482.  
  483. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", $replacepage, $row['full_story'] );
  484. $tpl->set( '[pages]', "" );
  485. $tpl->set( '[/pages]', "" );
  486.  
  487.  
  488. } else {
  489.  
  490. $tpl->set( '{pages}', '' );
  491. $row['full_story'] = preg_replace( "'\[page=(.*?)\](.*?)\[/page\]'si", "", $row['full_story'] );
  492. $tpl->set_block( "'\\[pages\\](.*?)\\[/pages\\]'si", "" );
  493. }
  494. }
  495.  
  496. $row['title'] = stripslashes( $row['title'] );
  497. $metatags['title'] = $row['title'];
  498.  
  499. if( $row['keywords'] == '' AND $row['descr'] == '' AND $config['create_metatags'] ) {
  500. create_keywords( $row['full_story'] );
  501. } else {
  502. $metatags['keywords'] = $row['keywords'];
  503. if( $row['descr'] ) $metatags['description'] = $row['descr']; else $metatags['description'] = $row['title'];
  504. }
  505.  
  506. if ($row['metatitle']) $metatags['header_title'] = $row['metatitle'];
  507.  
  508. $social_tags['site_name'] = $config['home_title'];
  509. $social_tags['type'] = 'article';
  510. $social_tags['title'] = htmlspecialchars( $row['title'], ENT_QUOTES, $config['charset'] );
  511. $social_tags['url'] = $full_link;
  512.  
  513. $comments_num = $row['comm_num'];
  514.  
  515. $news_find = array ('{comments-num}' => number_format($row['comm_num'], 0, ',', ' '), '{views}' => number_format($row['news_read'], 0, ',', ' '), '{category}' => $my_cat, '{link-category}' => $my_cat_link, '{news-id}' => $row['id'] );
  516.  
  517. if( date( 'Ymd', $row['date'] ) == date( 'Ymd', $_TIME ) ) {
  518.  
  519. $tpl->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $row['date'] ) );
  520.  
  521. } elseif( date( 'Ymd', $row['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
  522.  
  523. $tpl->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $row['date'] ) );
  524.  
  525. } else {
  526.  
  527. $tpl->set( '{date}', langdate( $config['timestamp_active'], $row['date'] ) );
  528.  
  529. }
  530. $news_date = $row['date'];
  531. $tpl->copy_template = preg_replace_callback ( "#\{date=(.+?)\}#i", "formdate", $tpl->copy_template );
  532.  
  533. if ( $row['fixed'] ) {
  534.  
  535. $tpl->set( '[fixed]', "" );
  536. $tpl->set( '[/fixed]', "" );
  537. $tpl->set_block( "'\\[not-fixed\\](.*?)\\[/not-fixed\\]'si", "" );
  538.  
  539. } else {
  540.  
  541. $tpl->set( '[not-fixed]', "" );
  542. $tpl->set( '[/not-fixed]', "" );
  543. $tpl->set_block( "'\\[fixed\\](.*?)\\[/fixed\\]'si", "" );
  544. }
  545.  
  546. if ( $comments_num ) {
  547.  
  548. $tpl->set( '[comments]', "" );
  549. $tpl->set( '[/comments]', "" );
  550. $tpl->set_block( "'\\[not-comments\\](.*?)\\[/not-comments\\]'si", "" );
  551.  
  552. } else {
  553.  
  554. $tpl->set( '[not-comments]', "" );
  555. $tpl->set( '[/not-comments]', "" );
  556. $tpl->set_block( "'\\[comments\\](.*?)\\[/comments\\]'si", "" );
  557. }
  558.  
  559. if ( $row['votes'] ) {
  560.  
  561. $tpl->set( '[poll]', "" );
  562. $tpl->set( '[/poll]', "" );
  563. $tpl->set_block( "'\\[not-poll\\](.*?)\\[/not-poll\\]'si", "" );
  564.  
  565. } else {
  566.  
  567. $tpl->set( '[not-poll]', "" );
  568. $tpl->set( '[/not-poll]', "" );
  569. $tpl->set_block( "'\\[poll\\](.*?)\\[/poll\\]'si", "" );
  570. }
  571.  
  572. if( $vk_url ) {
  573. $tpl->set( '[vk]', "" );
  574. $tpl->set( '[/vk]', "" );
  575. $tpl->set( '{vk_url}', $vk_url );
  576. } else {
  577. $tpl->set_block( "'\\[vk\\](.*?)\\[/vk\\]'si", "" );
  578. $tpl->set( '{vk_url}', '' );
  579. }
  580. if( $odnoklassniki_url ) {
  581. $tpl->set( '[odnoklassniki]', "" );
  582. $tpl->set( '[/odnoklassniki]', "" );
  583. $tpl->set( '{odnoklassniki_url}', $odnoklassniki_url );
  584. } else {
  585. $tpl->set_block( "'\\[odnoklassniki\\](.*?)\\[/odnoklassniki\\]'si", "" );
  586. $tpl->set( '{odnoklassniki_url}', '' );
  587. }
  588. if( $facebook_url ) {
  589. $tpl->set( '[facebook]', "" );
  590. $tpl->set( '[/facebook]', "" );
  591. $tpl->set( '{facebook_url}', $facebook_url );
  592. } else {
  593. $tpl->set_block( "'\\[facebook\\](.*?)\\[/facebook\\]'si", "" );
  594. $tpl->set( '{facebook_url}', '' );
  595. }
  596. if( $google_url ) {
  597. $tpl->set( '[google]', "" );
  598. $tpl->set( '[/google]', "" );
  599. $tpl->set( '{google_url}', $google_url );
  600. } else {
  601. $tpl->set_block( "'\\[google\\](.*?)\\[/google\\]'si", "" );
  602. $tpl->set( '{google_url}', '' );
  603. }
  604. if( $mailru_url ) {
  605. $tpl->set( '[mailru]', "" );
  606. $tpl->set( '[/mailru]', "" );
  607. $tpl->set( '{mailru_url}', $mailru_url );
  608. } else {
  609. $tpl->set_block( "'\\[mailru\\](.*?)\\[/mailru\\]'si", "" );
  610. $tpl->set( '{mailru_url}', '' );
  611. }
  612. if( $yandex_url ) {
  613. $tpl->set( '[yandex]', "" );
  614. $tpl->set( '[/yandex]', "" );
  615. $tpl->set( '{yandex_url}', $yandex_url );
  616. } else {
  617. $tpl->set_block( "'\\[yandex\\](.*?)\\[/yandex\\]'si", "" );
  618. $tpl->set( '{yandex_url}', '' );
  619. }
  620.  
  621. if( $row['editdate'] ) $_DOCUMENT_DATE = $row['editdate'];
  622.  
  623. else $_DOCUMENT_DATE = $row['date'];
  624.  
  625. if( $row['view_edit'] and $row['editdate'] ) {
  626.  
  627. if( date( Ymd, $row['editdate'] ) == date( Ymd, $_TIME ) ) {
  628.  
  629. $tpl->set( '{edit-date}', $lang['time_heute'] . langdate( ", H:i", $row['editdate'] ) );
  630.  
  631. } elseif( date( Ymd, $row['editdate'] ) == date( Ymd, ($_TIME - 86400) ) ) {
  632.  
  633. $tpl->set( '{edit-date}', $lang['time_gestern'] . langdate( ", H:i", $row['editdate'] ) );
  634.  
  635. } else {
  636.  
  637. $tpl->set( '{edit-date}', langdate( $config['timestamp_active'], $row['editdate'] ) );
  638.  
  639. }
  640.  
  641. $tpl->set( '{editor}', $row['editor'] );
  642. $tpl->set( '{edit-reason}', $row['reason'] );
  643.  
  644. if( $row['reason'] ) {
  645.  
  646. $tpl->set( '[edit-reason]', "" );
  647. $tpl->set( '[/edit-reason]', "" );
  648.  
  649. } else
  650. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  651.  
  652. $tpl->set( '[edit-date]', "" );
  653. $tpl->set( '[/edit-date]', "" );
  654.  
  655. } else {
  656.  
  657. $tpl->set( '{edit-date}', "" );
  658. $tpl->set( '{editor}', "" );
  659. $tpl->set( '{edit-reason}', "" );
  660. $tpl->set_block( "'\\[edit-date\\](.*?)\\[/edit-date\\]'si", "" );
  661. $tpl->set_block( "'\\[edit-reason\\](.*?)\\[/edit-reason\\]'si", "" );
  662. }
  663.  
  664. if( $config['allow_tags'] and $row['tags'] ) {
  665.  
  666. $tpl->set( '[tags]', "" );
  667. $tpl->set( '[/tags]', "" );
  668.  
  669. $social_tags['news_keywords'] = $row['tags'];
  670.  
  671. $tags = array ();
  672.  
  673. $row['tags'] = explode( ",", $row['tags'] );
  674.  
  675. foreach ( $row['tags'] as $value ) {
  676.  
  677. $value = trim( $value );
  678.  
  679. if( $config['allow_alt_url'] ) $tags[] = "<span><a href=\"" . $config['http_home_url'] . "tags/" . urlencode( $value ) . "/\">" . $value . "</a></span>";
  680. else $tags[] = "<span><a href=\"$PHP_SELF?do=tags&amp;tag=" . urlencode( $value ) . "\">" . $value . "</a></span>";
  681.  
  682. }
  683.  
  684. $tpl->set( '{tags}', implode( " ", $tags ) );
  685.  
  686. } else {
  687.  
  688. $tpl->set_block( "'\\[tags\\](.*?)\\[/tags\\]'si", "" );
  689. $tpl->set( '{tags}', "" );
  690.  
  691. }
  692.  
  693. $tpl->set( '', $news_find );
  694.  
  695. $url_cat = $category_id;
  696. $category_id = $row['category'];
  697.  
  698. if( strpos( $tpl->copy_template, "[catlist=" ) !== false ) {
  699. $tpl->copy_template = preg_replace_callback ( "#\\[(catlist)=(.+?)\\](.*?)\\[/catlist\\]#is", "check_category", $tpl->copy_template );
  700. }
  701.  
  702. if( strpos( $tpl->copy_template, "[not-catlist=" ) !== false ) {
  703. $tpl->copy_template = preg_replace_callback ( "#\\[(not-catlist)=(.+?)\\](.*?)\\[/not-catlist\\]#is", "check_category", $tpl->copy_template );
  704. }
  705.  
  706. $category_id = $url_cat;
  707.  
  708. if( $category_id AND $cat_info[$category_id]['icon'] ) {
  709.  
  710. $tpl->set( '{category-icon}', $cat_info[$category_id]['icon'] );
  711.  
  712. } else {
  713.  
  714. $tpl->set( '{category-icon}', "{THEME}/dleimages/no_icon.gif" );
  715.  
  716. }
  717.  
  718. if ( $category_id ) {
  719.  
  720. if( $config['allow_alt_url'] ) $tpl->set( '{category-url}', $config['http_home_url'] . get_url( $category_id ) . "/" );
  721. else $tpl->set( '{category-url}', "$PHP_SELF?do=cat&category={$cat_info[$category_id]['alt_name']}" );
  722.  
  723. } else $tpl->set( '{category-url}', "#" );
  724.  
  725. if ($config['allow_search_print']) {
  726.  
  727. $tpl->set( '[print-link]', "<a href=\"" . $print_link . "\">" );
  728. $tpl->set( '[/print-link]', "</a>" );
  729.  
  730. } else {
  731.  
  732. $tpl->set( '[print-link]', "<a href=\"" . $print_link . "\" rel=\"nofollow\">" );
  733. $tpl->set( '[/print-link]', "</a>" );
  734.  
  735. }
  736.  
  737. if ( $config['rating_type'] == "1" ) {
  738. $tpl->set( '[rating-type-2]', "" );
  739. $tpl->set( '[/rating-type-2]', "" );
  740. $tpl->set_block( "'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", "" );
  741. $tpl->set_block( "'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", "" );
  742. } elseif ( $config['rating_type'] == "2" ) {
  743. $tpl->set( '[rating-type-3]', "" );
  744. $tpl->set( '[/rating-type-3]', "" );
  745. $tpl->set_block( "'\\[rating-type-1\\](.*?)\\[/rating-type-1\\]'si", "" );
  746. $tpl->set_block( "'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", "" );
  747. } else {
  748. $tpl->set( '[rating-type-1]', "" );
  749. $tpl->set( '[/rating-type-1]', "" );
  750. $tpl->set_block( "'\\[rating-type-3\\](.*?)\\[/rating-type-3\\]'si", "" );
  751. $tpl->set_block( "'\\[rating-type-2\\](.*?)\\[/rating-type-2\\]'si", "" );
  752. }
  753.  
  754. if( $row['allow_rate'] ) {
  755.  
  756. $tpl->set( '{rating}', ShowRating( $row['id'], $row['rating'], $row['vote_num'], $user_group[$member_id['user_group']]['allow_rating'] ) );
  757. $tpl->set( '{vote-num}', "<span id=\"vote-num-id-".$row['id']."\">".$row['vote_num']."</span>" );
  758. $tpl->set( '[rating]', "" );
  759. $tpl->set( '[/rating]', "" );
  760.  
  761. if( $user_group[$member_id['user_group']]['allow_rating'] ) {
  762.  
  763. if ( $config['rating_type'] ) {
  764.  
  765. $tpl->set( '[rating-plus]', "<a href=\"#\" onclick=\"doRate('plus', '{$row['id']}'); return false;\" >" );
  766. $tpl->set( '[/rating-plus]', '</a>' );
  767.  
  768. if ( $config['rating_type'] == "2" ) {
  769.  
  770. $tpl->set( '[rating-minus]', "<a href=\"#\" onclick=\"doRate('minus', '{$row['id']}'); return false;\" >" );
  771. $tpl->set( '[/rating-minus]', '</a>' );
  772.  
  773. } else {
  774. $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
  775. }
  776.  
  777. } else {
  778. $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
  779. $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
  780. }
  781.  
  782. } else {
  783. $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
  784. $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
  785. }
  786.  
  787. } else {
  788.  
  789. $tpl->set( '{rating}', "" );
  790. $tpl->set( '{vote-num}', "" );
  791. $tpl->set_block( "'\\[rating\\](.*?)\\[/rating\\]'si", "" );
  792. $tpl->set_block( "'\\[rating-plus\\](.*?)\\[/rating-plus\\]'si", "" );
  793. $tpl->set_block( "'\\[rating-minus\\](.*?)\\[/rating-minus\\]'si", "" );
  794. }
  795.  
  796. if ( $config['allow_comments'] AND $config['allow_subscribe'] AND $is_logged AND $row['allow_comm'] AND $user_group[$member_id['user_group']]['allow_subscribe'] ) {
  797. $tpl->set( '[comments-subscribe]', "<a href=\"#\" onclick=\"subscribe('{$row['id']}'); return false;\" >" );
  798. $tpl->set( '[/comments-subscribe]', '</a>' );
  799. } else {
  800. $tpl->set_block( "'\\[comments-subscribe\\](.*?)\\[/comments-subscribe\\]'si", "" );
  801. }
  802.  
  803. if( $config['allow_alt_url'] ) {
  804.  
  805. $go_page = $config['http_home_url'] . "user/" . urlencode( $row['autor'] ) . "/";
  806. $tpl->set( '[day-news]', "<a href=\"".$config['http_home_url'] . date( 'Y/m/d/', $row['date'])."\" >" );
  807.  
  808. } else {
  809.  
  810. $go_page = "$PHP_SELF?subaction=userinfo&amp;user=" . urlencode( $row['autor'] );
  811. $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'])."\" >" );
  812.  
  813. }
  814.  
  815. $tpl->set( '[/day-news]', "</a>" );
  816. $tpl->set( '[profile]', "<a href=\"" . $go_page . "\">" );
  817. $tpl->set( '[/profile]', "</a>" );
  818.  
  819. $tpl->set( '{login}', $row['autor'] );
  820.  
  821. $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>" );
  822.  
  823. $_SESSION['referrer'] = $_SERVER['REQUEST_URI'];
  824.  
  825. $tpl->set( '[full-link]', "<a href=\"" . $full_link . "\">" );
  826. $tpl->set( '[/full-link]', "</a>" );
  827.  
  828. $tpl->set( '{full-link}', $full_link );
  829.  
  830. if( $row['allow_comm'] ) {
  831.  
  832. $tpl->set( '[com-link]', "<a id=\"dle-comm-link\" href=\"" . $full_link . "#comment\">" );
  833. $tpl->set( '[/com-link]', "</a>" );
  834.  
  835. } else
  836. $tpl->set_block( "'\\[com-link\\](.*?)\\[/com-link\\]'si", "" );
  837.  
  838. if( ! $row['approve'] and ($member_id['name'] == $row['autor'] and ! $user_group[$member_id['user_group']]['allow_all_edit']) ) {
  839. $tpl->set( '[edit]', "<a href=\"" . $config['http_home_url'] . "index.php?do=addnews&amp;id=" . $row['id'] . "\" >" );
  840. $tpl->set( '[/edit]', "</a>" );
  841. if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
  842. } 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']) ) {
  843. $tpl->set( '[edit]', "<a onclick=\"return dropdownmenu(this, event, MenuNewsBuild('" . $row['id'] . "', 'full'), '170px')\" href=\"#\">" );
  844. $tpl->set( '[/edit]', "</a>" );
  845. if( $config['allow_quick_wysiwyg'] ) $allow_comments_ajax = true;
  846. } else
  847. $tpl->set_block( "'\\[edit\\](.*?)\\[/edit\\]'si", "" );
  848.  
  849. if( $config['related_news'] AND $view_template != "print") {
  850.  
  851. if ( $allow_full_cache ) $related_buffer = dle_cache( "related", $row['id'].$config['skin'], true ); else $related_buffer = false;
  852.  
  853. if( $related_buffer === false ) {
  854.  
  855. if ( $row['related_ids'] ) {
  856.  
  857. $id_list = array();
  858. $id_temp = explode(",", $row['related_ids']);
  859.  
  860. foreach ( $id_temp as $value ) {
  861.  
  862. $value = intval($value);
  863.  
  864. if ( $value > 0 ) $id_list[] = $value;
  865.  
  866. }
  867.  
  868. $row['related_ids'] = implode( ',', $id_list );
  869.  
  870. unset($id_list);
  871. unset($id_temp);
  872.  
  873. $db->query( "SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE id IN({$row['related_ids']}) AND approve=1 ORDER BY id DESC");
  874. $first_show = false;
  875.  
  876. } else {
  877. $first_show = true;
  878. $related_ids = array();
  879.  
  880. if( strlen( $row['full_story'] ) < strlen( $row['short_story'] ) ) $body = $row['short_story'];
  881. else $body = $row['full_story'];
  882.  
  883. $body = strip_tags( stripslashes( $metatags['title'] . " " . $body ) );
  884.  
  885. if( dle_strlen( $body, $config['charset'] ) > 1000 ) {
  886. $body = dle_substr( $body, 0, 1000, $config['charset'] );
  887. }
  888.  
  889. $body = $db->safesql( $body );
  890.  
  891. $config['related_number'] = intval( $config['related_number'] );
  892. if( $config['related_number'] < 1 ) $config['related_number'] = 5;
  893.  
  894. $allowed_cats = array();
  895.  
  896. foreach ($user_group as $value) {
  897. if ($value['allow_cats'] != "all" AND !$value['allow_short'] ) $allowed_cats[] = $db->safesql($value['allow_cats']);
  898. }
  899.  
  900. if (count($allowed_cats)) {
  901.  
  902. $allowed_cats = implode(",", $allowed_cats);
  903. $allowed_cats = explode(",", $allowed_cats);
  904. $allowed_cats = array_unique($allowed_cats);
  905. sort($allowed_cats);
  906.  
  907. if ($config['allow_multi_category']) {
  908.  
  909. $allowed_cats = "category regexp '[[:<:]](" . implode ( '|', $allowed_cats ) . ")[[:>:]]' AND ";
  910.  
  911. } else {
  912.  
  913. $allowed_cats = "category IN ('" . implode ( "','", $allowed_cats ) . "') AND ";
  914.  
  915. }
  916.  
  917. } else $allowed_cats="";
  918.  
  919. $not_allowed_cats = array();
  920.  
  921. foreach ($user_group as $value) {
  922. if ($value['not_allow_cats'] != "" AND !$value['allow_short'] ) $not_allowed_cats[] = $db->safesql($value['not_allow_cats']);
  923. }
  924.  
  925. if (count($not_allowed_cats)) {
  926.  
  927. $not_allowed_cats = implode(",", $not_allowed_cats);
  928. $not_allowed_cats = explode(",", $not_allowed_cats);
  929. $not_allowed_cats = array_unique($not_allowed_cats);
  930. sort($not_allowed_cats);
  931.  
  932. if ($config['allow_multi_category']) {
  933.  
  934. $not_allowed_cats = "category NOT REGEXP '[[:<:]](" . implode ( '|', $not_allowed_cats ) . ")[[:>:]]' AND ";
  935.  
  936. } else {
  937.  
  938. $not_allowed_cats = "category NOT IN ('" . implode ( "','", $not_allowed_cats ) . "') AND ";
  939.  
  940. }
  941.  
  942. } else $not_allowed_cats="";
  943.  
  944. if ($config['related_only_cats'] AND $row['category'] ) {
  945.  
  946. $allowed_cats="";
  947. $not_allowed_cats = "";
  948. $allow_sub_cats = true;
  949. $all_cats = explode(",", $row['category']);
  950. $get_cats = array();
  951.  
  952. foreach ($all_cats as $value) {
  953.  
  954. if ( $cat_info[$value]['show_sub'] ) {
  955.  
  956. if ( $cat_info[$value]['show_sub'] == 1 ) $get_cats[] = get_sub_cats ( $value );
  957. else { $get_cats[] = $value; }
  958.  
  959. } else {
  960.  
  961. if ( $config['show_sub_cats'] ) $get_cats[] = get_sub_cats ( $value );
  962. else { $get_cats[] = $value; }
  963.  
  964. }
  965.  
  966. }
  967.  
  968. $get_cats = implode("|", $get_cats);
  969. $get_cats = explode("|", $get_cats);
  970.  
  971. if ( count($get_cats) < 2 ) $allow_sub_cats = false;
  972.  
  973. $get_cats = implode("|", $get_cats);
  974.  
  975. if ($config['allow_multi_category']) {
  976.  
  977. $where_category = "category regexp '[[:<:]](" . $get_cats . ")[[:>:]]' AND ";
  978.  
  979. } else {
  980.  
  981. if ( $allow_sub_cats ) {
  982.  
  983. $get_cats = str_replace ( "|", "','", $get_cats );
  984. $where_category = "category IN ('" . $get_cats . "') AND ";
  985.  
  986. } else {
  987.  
  988. $where_category = "category = '{$get_cats}' AND ";
  989.  
  990. }
  991.  
  992. }
  993.  
  994. } else $where_category = "";
  995.  
  996. $db->query( "SELECT id, date, short_story, xfields, title, category, alt_name FROM " . PREFIX . "_post WHERE {$where_category}{$allowed_cats}{$not_allowed_cats}MATCH (title, short_story, full_story, xfields) AGAINST ('$body') AND id != " . $row['id'] . " AND approve=1" . $where_date . " LIMIT " . $config['related_number'] );
  997. }
  998.  
  999. $tpl2 = new dle_template();
  1000. $tpl2->dir = TEMPLATE_DIR;
  1001. $tpl2->load_template( 'relatednews.tpl' );
  1002.  
  1003. while ( $related = $db->get_row() ) {
  1004.  
  1005. if ( $first_show ) $related_ids[] = $related['id'];
  1006.  
  1007. $related['date'] = strtotime( $related['date'] );
  1008.  
  1009. if( ! $related['category'] ) {
  1010. $my_cat = "---";
  1011. $my_cat_link = "---";
  1012. } else {
  1013.  
  1014. $my_cat = array ();
  1015. $my_cat_link = array ();
  1016. $rel_cat_list = explode( ',', $related['category'] );
  1017.  
  1018. if( count( $rel_cat_list ) == 1 ) {
  1019.  
  1020. $my_cat[] = $cat_info[$rel_cat_list[0]]['name'];
  1021.  
  1022. $my_cat_link = get_categories( $rel_cat_list[0], $config['category_separator'] );
  1023.  
  1024. } else {
  1025.  
  1026. foreach ( $rel_cat_list as $element ) {
  1027. if( $element ) {
  1028. $my_cat[] = $cat_info[$element]['name'];
  1029. if( $config['allow_alt_url'] ) $my_cat_link[] = "<a href=\"" . $config['http_home_url'] . get_url( $element ) . "/\">{$cat_info[$element]['name']}</a>";
  1030. else $my_cat_link[] = "<a href=\"$PHP_SELF?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
  1031. }
  1032. }
  1033.  
  1034. $my_cat_link = implode( "{$config['category_separator']} ", $my_cat_link );
  1035. }
  1036.  
  1037. //$my_cat = implode( "{$config['category_separator']} ", $my_cat );
  1038.  
  1039. $my_cat = end( $my_cat );
  1040. }
  1041.  
  1042. $related['category'] = intval( $related['category'] );
  1043.  
  1044. if( $config['allow_alt_url'] ) {
  1045.  
  1046. if( $config['seo_type'] == 1 OR $config['seo_type'] == 2 ) {
  1047.  
  1048. if( $related['category'] and $config['seo_type'] == 2 ) {
  1049.  
  1050. $rel_full_link = $config['http_home_url'] . get_url( $related['category'] ) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
  1051.  
  1052. } else {
  1053.  
  1054. $rel_full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
  1055.  
  1056. }
  1057.  
  1058. } else {
  1059.  
  1060. $rel_full_link = $config['http_home_url'] . date( 'Y/m/d/', $related['date'] ) . $related['alt_name'] . ".html";
  1061. }
  1062.  
  1063. } else {
  1064.  
  1065. $rel_full_link = $config['http_home_url'] . "index.php?newsid=" . $related['id'];
  1066.  
  1067. }
  1068.  
  1069. $related['title'] = strip_tags( stripslashes( $related['title'] ) );
  1070.  
  1071. $tpl2->set( '{title}', $related['title'] );
  1072. $tpl2->set( '{link}', $rel_full_link );
  1073. $tpl2->set( '{category}', $my_cat );
  1074. $tpl2->set( '{link-category}', $my_cat_link );
  1075.  
  1076. if( date( 'Ymd', $related['date'] ) == date( 'Ymd', $_TIME ) ) {
  1077.  
  1078. $tpl2->set( '{date}', $lang['time_heute'] . langdate( ", H:i", $related['date'] ) );
  1079.  
  1080. } elseif( date( 'Ymd', $related['date'] ) == date( 'Ymd', ($_TIME - 86400) ) ) {
  1081.  
  1082. $tpl2->set( '{date}', $lang['time_gestern'] . langdate( ", H:i", $related['date'] ) );
  1083.  
  1084. } else {
  1085.  
  1086. $tpl2->set( '{date}', langdate( $config['timestamp_active'], $related['date'] ) );
  1087.  
  1088. }
  1089. $news_date = $related['date'];
  1090. $tpl2->copy_template = preg_replace_callback ( "#\{date=(.+?)\}#i", "formdate", $tpl2->copy_template );
  1091.  
  1092. $related['short_story'] = stripslashes( $related['short_story'] );
  1093.  
  1094. if( $user_group[$member_id['user_group']]['allow_hide'] ) $related['short_story'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $related['short_story']) );
  1095. else $related['short_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $related['short_story'] );
  1096.  
  1097. if (stripos ( $tpl2->copy_template, "{image-" ) !== false) {
  1098.  
  1099. $images = array();
  1100. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $related['short_story'], $media);
  1101. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  1102.  
  1103. foreach($data as $url) {
  1104. $info = pathinfo($url);
  1105. if (isset($info['extension'])) {
  1106. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-minus" OR strpos($info['dirname'], 'engine/data/emoticons') !== false) continue;
  1107. $info['extension'] = strtolower($info['extension']);
  1108. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  1109. }
  1110. }
  1111.  
  1112. if ( count($images) ) {
  1113. $i=0;
  1114. foreach($images as $url) {
  1115. $i++;
  1116. $tpl2->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl2->copy_template );
  1117. $tpl2->copy_template = str_replace( '[image-'.$i.']', "", $tpl2->copy_template );
  1118. $tpl2->copy_template = str_replace( '[/image-'.$i.']', "", $tpl2->copy_template );
  1119. }
  1120.  
  1121. }
  1122.  
  1123. $tpl2->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl2->copy_template );
  1124. $tpl2->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl2->copy_template );
  1125.  
  1126. }
  1127.  
  1128. if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
  1129. $count= intval($matches[1]);
  1130.  
  1131. $related['short_story'] = preg_replace( "#<!--TBegin(.+?)<!--TEnd-->#is", "", $related['short_story'] );
  1132. $related['short_story'] = preg_replace( "#<!--MBegin(.+?)<!--MEnd-->#is", "", $related['short_story'] );
  1133. $related['short_story'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $related['short_story'] );
  1134. $related['short_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "", $related['short_story'] );
  1135.  
  1136. $related['short_story'] = str_replace( "</p><p>", " ", $related['short_story'] );
  1137.  
  1138. $related['short_story'] = strip_tags( $related['short_story'], "<br>" );
  1139. $related['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $related['short_story'] ) ) ) ));
  1140. if( $count AND dle_strlen( $related['short_story'], $config['charset'] ) > $count ) {
  1141.  
  1142. $related['short_story'] = dle_substr( $related['short_story'], 0, $count, $config['charset'] );
  1143.  
  1144. if( ($temp_dmax = dle_strrpos( $related['short_story'], ' ', $config['charset'] )) ) $related['short_story'] = dle_substr( $related['short_story'], 0, $temp_dmax, $config['charset'] );
  1145.  
  1146. }
  1147.  
  1148. $tpl2->set( $matches[0], $related['short_story'] );
  1149.  
  1150. } else $tpl2->set( '{text}', $related['short_story'] );
  1151.  
  1152. if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl2->copy_template, $matches ) ) {
  1153. $count= intval($matches[1]);
  1154.  
  1155. if( $count AND dle_strlen( $related['title'], $config['charset'] ) > $count ) {
  1156.  
  1157. $related['title'] = dle_substr( $related['title'], 0, $count, $config['charset'] );
  1158.  
  1159. if( ($temp_dmax = dle_strrpos( $related['title'], ' ', $config['charset'] )) ) $related['title'] = dle_substr( $related['title'], 0, $temp_dmax, $config['charset'] );
  1160.  
  1161. }
  1162. $tpl2->set( $matches[0], $related['title'] );
  1163.  
  1164. }
  1165.  
  1166. if( count($xfields) ) {
  1167. $xfieldsdata = xfieldsdataload( $related['xfields'] );
  1168.  
  1169. foreach ( $xfields as $value ) {
  1170. $preg_safe_name = preg_quote( $value[0], "'" );
  1171.  
  1172. $xfieldsdata[$value[0]] = stripslashes( $xfieldsdata[$value[0]] );
  1173.  
  1174. if( $value[20] ) {
  1175.  
  1176. $value[20] = explode( ',', $value[20] );
  1177.  
  1178. if( $value[20][0] AND !in_array( $member_id['user_group'], $value[20] ) ) {
  1179. $xfieldsdata[$value[0]] = "";
  1180. }
  1181.  
  1182. }
  1183.  
  1184. if ( $value[3] == "yesorno" ) {
  1185.  
  1186. if( intval($xfieldsdata[$value[0]]) ) {
  1187. $xfgiven = true;
  1188. $xfieldsdata[$value[0]] = $lang['xfield_xyes'];
  1189. } else {
  1190. $xfgiven = false;
  1191. $xfieldsdata[$value[0]] = $lang['xfield_xno'];
  1192. }
  1193.  
  1194. } else {
  1195. if($xfieldsdata[$value[0]] == "") $xfgiven = false; else $xfgiven = true;
  1196. }
  1197.  
  1198. if( !$xfgiven ) {
  1199. $tpl2->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
  1200. $tpl2->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl2->copy_template );
  1201. $tpl2->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl2->copy_template );
  1202. } else {
  1203. $tpl2->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl2->copy_template );
  1204. $tpl2->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl2->copy_template );
  1205. $tpl2->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl2->copy_template );
  1206. }
  1207.  
  1208. if(strpos( $tpl2->copy_template, "[ifxfvalue" ) !== false ) {
  1209. $tpl2->copy_template = preg_replace_callback ( "#\\[ifxfvalue(.+?)\\](.+?)\\[/ifxfvalue\\]#is", "check_xfvalue", $tpl2->copy_template );
  1210. }
  1211.  
  1212. if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  1213. $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  1214. $value3 = array();
  1215.  
  1216. foreach ($temp_array as $value2) {
  1217.  
  1218. $value2 = trim($value2);
  1219. $value2 = str_replace("&#039;", "'", $value2);
  1220.  
  1221. if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" .$value[0]."/". urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  1222. else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xfname=".$value[0]."&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  1223.  
  1224. }
  1225.  
  1226. $xfieldsdata[$value[0]] = implode(", ", $value3);
  1227.  
  1228. unset($temp_array);
  1229. unset($value2);
  1230. unset($value3);
  1231.  
  1232. }
  1233.  
  1234. if($value[3] == "image" AND $xfieldsdata[$value[0]] ) {
  1235. $path_parts = @pathinfo($xfieldsdata[$value[0]]);
  1236.  
  1237. if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
  1238. $thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
  1239. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1240. } else {
  1241. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1242. $thumb_url = "";
  1243. }
  1244.  
  1245. if($thumb_url) {
  1246. $xfieldsdata[$value[0]] = "<a href=\"$img_url\" class=\"highslide\" target=\"_blank\"><img class=\"xfieldimage {$value[0]}\" src=\"$thumb_url\" alt=\"\" /></a>";
  1247. } else $xfieldsdata[$value[0]] = "<img class=\"xfieldimage {$value[0]}\" src=\"{$img_url}\" alt=\"\" />";
  1248.  
  1249. $social_tags['image'] = $img_url;
  1250. }
  1251.  
  1252. if($value[3] == "image") {
  1253.  
  1254. if( $xfieldsdata[$value[0]] ) {
  1255. $tpl2->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", $thumb_url, $tpl2->copy_template );
  1256. $tpl2->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", $img_url, $tpl2->copy_template );
  1257. } else {
  1258. $tpl2->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", "", $tpl2->copy_template );
  1259. $tpl2->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", "", $tpl2->copy_template );
  1260. }
  1261. }
  1262.  
  1263. if($value[3] == "imagegalery" AND $xfieldsdata[$value[0]] AND stripos ( $tpl2->copy_template, "[xfvalue_{$value[0]}]" ) !== false ) {
  1264.  
  1265. $fieldvalue_arr = explode(',', $xfieldsdata[$value[0]]);
  1266. $gallery_image = array();
  1267.  
  1268. foreach ($fieldvalue_arr as $temp_value) {
  1269.  
  1270. $temp_value = trim($temp_value);
  1271.  
  1272. if($temp_value == "") continue;
  1273.  
  1274. $path_parts = @pathinfo($temp_value);
  1275.  
  1276. if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
  1277. $thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
  1278. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1279. } else {
  1280. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1281. $thumb_url = "";
  1282. }
  1283.  
  1284. if($thumb_url) {
  1285. $gallery_image[] = "<li><a href=\"$img_url\" onclick=\"return hs.expand(this, { slideshowGroup: 'xf_{$related['id']}_{$value[0]}' })\" target=\"_blank\"><img src=\"{$thumb_url}\" alt=\"\" /></a></li>";
  1286. } else $gallery_image[] = "<li><img src=\"{$img_url}\" alt=\"\" /></li>";
  1287.  
  1288. }
  1289.  
  1290. $xfieldsdata[$value[0]] = "<ul class=\"xfieldimagegallery {$value[0]}\">".implode($gallery_image)."</ul>";
  1291. $uniq_id = "xf_{$related['id']}_{$value[0]}";
  1292. $onload_scripts[$uniq_id] = "hs.addSlideshow({slideshowGroup: '{$uniq_id}', interval: 4000, repeat: false, useControls: true, fixedControls: 'fit', overlayOptions: { opacity: .75, position: 'bottom center', hideOnMouseOut: true } });";
  1293.  
  1294. }
  1295.  
  1296. $tpl2->set( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]] );
  1297.  
  1298. if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl2->copy_template, $matches ) ) {
  1299. $count= intval($matches[1]);
  1300.  
  1301. $xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
  1302. $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
  1303. $xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
  1304.  
  1305. if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
  1306.  
  1307. $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
  1308.  
  1309. if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
  1310.  
  1311. }
  1312.  
  1313. $tpl2->set( $matches[0], $xfieldsdata[$value[0]] );
  1314.  
  1315. }
  1316.  
  1317. }
  1318. }
  1319.  
  1320. $tpl2->compile( 'content' );
  1321.  
  1322. }
  1323.  
  1324. $related_buffer = $tpl2->result['content'];
  1325. unset($tpl2);
  1326. $db->free();
  1327.  
  1328. if ( $first_show ) {
  1329. if ( count($related_ids) ) {
  1330. $related_ids = implode(",",$related_ids);
  1331. $db->query( "UPDATE " . PREFIX . "_post_extras SET related_ids='{$related_ids}' WHERE news_id='{$row['id']}'" );
  1332. }
  1333. }
  1334.  
  1335. if ( $allow_full_cache ) create_cache( "related", $related_buffer, $row['id'].$config['skin'], true );
  1336. }
  1337.  
  1338. if ( $related_buffer ) {
  1339.  
  1340. $tpl->set( '[related-news]', "" );
  1341. $tpl->set( '[/related-news]', "" );
  1342.  
  1343. } else $tpl->set_block( "'\\[related-news\\](.*?)\\[/related-news\\]'si", "" );
  1344.  
  1345. $tpl->set( '{related-news}', $related_buffer );
  1346.  
  1347. }
  1348.  
  1349. if( $is_logged ) {
  1350.  
  1351. $fav_arr = explode( ',', $member_id['favorites'] );
  1352.  
  1353. if( ! in_array( $row['id'], $fav_arr ) ) {
  1354.  
  1355. $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', 0); return false;\" title=\"" . $lang['news_addfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
  1356. $tpl->set( '[add-favorites]', "<a id=\"fav-id-" . $row['id'] . "\" onclick=\"doFavorites('" . $row['id'] . "', 'plus', 1); return false;\" href=\"$PHP_SELF?do=favorites&amp;doaction=add&amp;id=" . $row['id'] . "\">" );
  1357. $tpl->set( '[/add-favorites]', "</a>" );
  1358. $tpl->set_block( "'\\[del-favorites\\](.*?)\\[/del-favorites\\]'si", "" );
  1359. } else {
  1360.  
  1361. $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', 0); return false;\" title=\"" . $lang['news_minfav'] . "\" style=\"vertical-align: middle;border: none;\" alt=\"\" /></a>" );
  1362. $tpl->set( '[del-favorites]', "<a id=\"fav-id-" . $row['id'] . "\" onclick=\"doFavorites('" . $row['id'] . "', 'minus', 1); return false;\" href=\"$PHP_SELF?do=favorites&amp;doaction=del&amp;id=" . $row['id'] . "\">" );
  1363. $tpl->set( '[/del-favorites]', "</a>" );
  1364. $tpl->set_block( "'\\[add-favorites\\](.*?)\\[/add-favorites\\]'si", "" );
  1365. }
  1366.  
  1367. $tpl->set( '[complaint]', "<a href=\"javascript:AddComplaint('" . $row['id'] . "', 'news')\">" );
  1368. $tpl->set( '[/complaint]', "</a>" );
  1369.  
  1370.  
  1371. } else {
  1372. $tpl->set( '{favorites}', "" );
  1373. $tpl->set_block( "'\\[complaint\\](.*?)\\[/complaint\\]'si", "" );
  1374. $tpl->set_block( "'\\[add-favorites\\](.*?)\\[/add-favorites\\]'si", "" );
  1375. $tpl->set_block( "'\\[del-favorites\\](.*?)\\[/del-favorites\\]'si", "" );
  1376. }
  1377.  
  1378. if( $row['votes'] ) $tpl->set( '{poll}', $tpl->result['poll'] );
  1379. else $tpl->set( '{poll}', '' );
  1380.  
  1381. if( $config['allow_banner'] ) include_once ENGINE_DIR . '/modules/banners.php';
  1382.  
  1383. if( $config['allow_banner'] AND count( $banners ) ) {
  1384.  
  1385. foreach ( $banners as $name => $value ) {
  1386. $tpl->copy_template = str_replace( "{banner_" . $name . "}", $value, $tpl->copy_template );
  1387.  
  1388. if ( $value ) {
  1389. $tpl->copy_template = str_replace ( "[banner_" . $name . "]", "", $tpl->copy_template );
  1390. $tpl->copy_template = str_replace ( "[/banner_" . $name . "]", "", $tpl->copy_template );
  1391. }
  1392. }
  1393. }
  1394.  
  1395. $tpl->set_block( "'{banner_(.*?)}'si", "" );
  1396. $tpl->set_block ( "'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", "" );
  1397.  
  1398. $tpl->set( '{title}', $row['title'] );
  1399.  
  1400. if ( preg_match( "#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
  1401. $count= intval($matches[1]);
  1402. $row['title'] = strip_tags( $row['title'] );
  1403.  
  1404. if( $count AND dle_strlen( $row['title'], $config['charset'] ) > $count ) {
  1405.  
  1406. $row['title'] = dle_substr( $row['title'], 0, $count, $config['charset'] );
  1407.  
  1408. if( ($temp_dmax = dle_strrpos( $row['title'], ' ', $config['charset'] )) ) $row['title'] = dle_substr( $row['title'], 0, $temp_dmax, $config['charset'] );
  1409.  
  1410. }
  1411. $tpl->set( $matches[0], $row['title'] );
  1412.  
  1413. }
  1414.  
  1415. $row['short_story'] = stripslashes($row['short_story']);
  1416. $row['full_story'] = stripslashes($row['full_story']);
  1417. $row['xfields'] = stripslashes( $row['xfields'] );
  1418.  
  1419. if ($config['allow_links'] AND function_exists('replace_links') AND isset($replace_links['news']) ) {
  1420. $row['short_story'] = replace_links ( $row['short_story'], $replace_links['news'] );
  1421. $row['full_story'] = replace_links ( $row['full_story'], $replace_links['news'] );
  1422. }
  1423.  
  1424. if (stripos ( $tpl->copy_template, "{image-" ) !== false) {
  1425.  
  1426. $images = array();
  1427. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'].$row['xfields'], $media);
  1428. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  1429.  
  1430. foreach($data as $url) {
  1431. $info = pathinfo($url);
  1432. if (isset($info['extension'])) {
  1433. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-minus" OR strpos($info['dirname'], 'engine/data/emoticons') !== false) continue;
  1434. $info['extension'] = strtolower($info['extension']);
  1435. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  1436. }
  1437. }
  1438.  
  1439. if ( count($images) ) {
  1440. $i=0;
  1441. foreach($images as $url) {
  1442. $i++;
  1443. $tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
  1444. $tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
  1445. $tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
  1446. }
  1447.  
  1448. }
  1449.  
  1450. $tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
  1451. $tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  1452.  
  1453. }
  1454.  
  1455.  
  1456. if (stripos ( $tpl->copy_template, "{fullimage-" ) !== false) {
  1457.  
  1458. $images = array();
  1459. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['full_story'], $media);
  1460. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  1461.  
  1462. foreach($data as $url) {
  1463. $info = pathinfo($url);
  1464. if (isset($info['extension'])) {
  1465. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-minus" OR strpos($info['dirname'], 'engine/data/emoticons') !== false) continue;
  1466. $info['extension'] = strtolower($info['extension']);
  1467. if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
  1468. }
  1469. }
  1470.  
  1471. if ( count($images) ) {
  1472. $i=0;
  1473. foreach($images as $url) {
  1474. $i++;
  1475. $tpl->copy_template = str_replace( '{fullimage-'.$i.'}', $url, $tpl->copy_template );
  1476. $tpl->copy_template = str_replace( '[fullimage-'.$i.']', "", $tpl->copy_template );
  1477. $tpl->copy_template = str_replace( '[/fullimage-'.$i.']', "", $tpl->copy_template );
  1478. }
  1479.  
  1480. }
  1481.  
  1482. $tpl->copy_template = preg_replace( "#\[fullimage-(.+?)\](.+?)\[/fullimage-(.+?)\]#is", "", $tpl->copy_template );
  1483. $tpl->copy_template = preg_replace( "#\\{fullimage-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
  1484.  
  1485. }
  1486.  
  1487. $images = array();
  1488. $allcontent = $row['full_story'].$row['short_story'].stripslashes($row['xfields']);
  1489. preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $allcontent, $media);
  1490. $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
  1491.  
  1492. foreach($data as $url) {
  1493. $info = pathinfo($url);
  1494. if (isset($info['extension'])) {
  1495. if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-minus" OR strpos($info['dirname'], 'engine/data/emoticons') !== false) continue;
  1496. $info['extension'] = strtolower($info['extension']);
  1497. if (($info['extension'] == 'jpg' || $info['extension'] == 'jpeg' || $info['extension'] == 'gif' || $info['extension'] == 'png') AND !in_array($url, $images) ) array_push($images, $url);
  1498. }
  1499. }
  1500.  
  1501. if ( count($images) ) $social_tags['image'] = $images[0];
  1502.  
  1503. if ( preg_match("#<!--dle_video_begin:(.+?)-->#is", $allcontent, $media) ){
  1504. $media[1] = explode( ",", trim( $media[1] ) );
  1505.  
  1506. if (count($media[1]) > 1 ) $media[1] = $media[1][1]; else $media[1] = $media[1][0];
  1507.  
  1508. $media[1] = explode( "|", $media[1] );
  1509. $social_tags['video'] = $media[1][0];
  1510.  
  1511. }
  1512.  
  1513. if ( preg_match("#<!--dle_audio_begin:(.+?)-->#is", $allcontent, $media) ){
  1514. $media[1] = explode( ",", trim( $media[1] ) );
  1515.  
  1516. if (count($media[1]) > 1 ) $media[1] = $media[1][1]; else $media[1] = $media[1][0];
  1517.  
  1518. $social_tags['audio'] = $media[1];
  1519.  
  1520. }
  1521.  
  1522. unset($allcontent);
  1523.  
  1524. if ($smartphone_detected) {
  1525.  
  1526. if (!$config['allow_smart_format']) {
  1527.  
  1528. $row['short_story'] = strip_tags( $row['short_story'], '<p><br><a>' );
  1529. $row['full_story'] = strip_tags( $row['full_story'], '<p><br><a>' );
  1530.  
  1531. } else {
  1532.  
  1533. if ( !$config['allow_smart_images'] ) {
  1534.  
  1535. $row['short_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['short_story'] );
  1536. $row['short_story'] = preg_replace( "#<img(.+?)>#is", "", $row['short_story'] );
  1537. $row['full_story'] = preg_replace( "#<!--TBegin-->(.+?)<!--TEnd-->#is", "", $row['full_story'] );
  1538. $row['full_story'] = preg_replace( "#<img(.+?)>#is", "", $row['full_story'] );
  1539.  
  1540. }
  1541.  
  1542. if ( !$config['allow_smart_video'] ) {
  1543.  
  1544. $row['short_story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['short_story'] );
  1545. $row['short_story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['short_story'] );
  1546. $row['short_story'] = preg_replace( "#<!--dle_media_begin(.+?)<!--dle_media_end-->#is", "", $row['short_story'] );
  1547. $row['full_story'] = preg_replace( "#<!--dle_video_begin(.+?)<!--dle_video_end-->#is", "", $row['full_story'] );
  1548. $row['full_story'] = preg_replace( "#<!--dle_audio_begin(.+?)<!--dle_audio_end-->#is", "", $row['full_story'] );
  1549. $row['full_story'] = preg_replace( "#<!--dle_media_begin(.+?)<!--dle_media_end-->#is", "", $row['full_story'] );
  1550.  
  1551. }
  1552.  
  1553. }
  1554.  
  1555. }
  1556. $tpl->set( '{comments}', "<!--dlecomments-->" );
  1557. $tpl->set( '{addcomments}', "<!--dleaddcomments-->" );
  1558. $tpl->set( '{navigation}', "<!--dlenavigationcomments-->" );
  1559.  
  1560. //Вставляем рекламу в середине статьи
  1561. if( dle_strlen($row['full_story'], $config['charset']) < 1500 ) {/* || $row['news_read'] < 150 ) { */ // По желанию можно добавить кол. просмотров
  1562. $txt = $row['full_story']; // Если в полной новости кол. символов меньше 150, пропускаем
  1563. } else {
  1564. $txt = stripslashes($row['full_story']);
  1565. $adv = '<div align="center"><noindex>
  1566. <!-- Полная новость (между абзацев) -->
  1567. <ins class="adsbygoogle"
  1568. style="display:block;"
  1569. data-ad-client="ca-pub-7486352048989874"
  1570. data-ad-slot="5803139342"
  1571. data-ad-format="rectangle"></ins>
  1572. <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
  1573. <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
  1574. </noindex></div>';
  1575. $pos = strpos($txt, '<br>', round(dle_strlen($txt, $config['charset'])/3));
  1576.  
  1577. if( $pos != 0 ) $txt = substr($txt, 0, $pos) . $adv . substr($txt, $pos);
  1578. }
  1579.  
  1580. $row['full_story'] = $txt;
  1581. //Вставляем рекламу в середине статьи
  1582.  
  1583. $tpl->set( '{short-story}', $row['short_story'] );
  1584.  
  1585. $tpl->set( '{full-story}', $row['full_story'] );
  1586.  
  1587. if ( preg_match( "#\\{full-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
  1588. $count= intval($matches[1]);
  1589.  
  1590. $row['full_story'] = preg_replace( "#<!--TBegin(.+?)<!--TEnd-->#is", "", $row['full_story'] );
  1591. $row['full_story'] = preg_replace( "#<!--MBegin(.+?)<!--MEnd-->#is", "", $row['full_story'] );
  1592. $row['full_story'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $row['full_story'] );
  1593. $row['full_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "", $row['full_story'] );
  1594.  
  1595. $row['full_story'] = str_replace( "</p><p>", " ", $row['full_story'] );
  1596. $row['full_story'] = strip_tags( $row['full_story'], "<br>" );
  1597. $row['full_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['full_story'] ) ) ) ));
  1598.  
  1599. if( $count AND dle_strlen( $row['full_story'], $config['charset'] ) > $count ) {
  1600.  
  1601. $row['full_story'] = dle_substr( $row['full_story'], 0, $count, $config['charset'] );
  1602.  
  1603. if( ($temp_dmax = dle_strrpos( $row['full_story'], ' ', $config['charset'] )) ) $row['full_story'] = dle_substr( $row['full_story'], 0, $temp_dmax, $config['charset'] );
  1604.  
  1605. }
  1606.  
  1607. $tpl->set( $matches[0], $row['full_story'] );
  1608.  
  1609. }
  1610.  
  1611. if( count($xfields) ) {
  1612.  
  1613. $xfieldsdata = xfieldsdataload( $row['xfields'] );
  1614.  
  1615. foreach ( $xfields as $value ) {
  1616. $preg_safe_name = preg_quote( $value[0], "'" );
  1617.  
  1618. if( $value[20] ) {
  1619.  
  1620. $value[20] = explode( ',', $value[20] );
  1621.  
  1622. if( $value[20][0] AND !in_array( $member_id['user_group'], $value[20] ) ) {
  1623. $xfieldsdata[$value[0]] = "";
  1624. }
  1625.  
  1626. }
  1627.  
  1628. if ( $value[3] == "yesorno" ) {
  1629.  
  1630. if( intval($xfieldsdata[$value[0]]) ) {
  1631. $xfgiven = true;
  1632. $xfieldsdata[$value[0]] = $lang['xfield_xyes'];
  1633. } else {
  1634. $xfgiven = false;
  1635. $xfieldsdata[$value[0]] = $lang['xfield_xno'];
  1636. }
  1637.  
  1638. } else {
  1639.  
  1640. if($xfieldsdata[$value[0]] == "") $xfgiven = false; else $xfgiven = true;
  1641.  
  1642. }
  1643.  
  1644. if( !$xfgiven ) {
  1645. $tpl->copy_template = preg_replace( "'\\[xfgiven_{$preg_safe_name}\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  1646. $tpl->copy_template = str_replace( "[xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  1647. $tpl->copy_template = str_replace( "[/xfnotgiven_{$value[0]}]", "", $tpl->copy_template );
  1648. } else {
  1649. $tpl->copy_template = preg_replace( "'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template );
  1650. $tpl->copy_template = str_replace( "[xfgiven_{$value[0]}]", "", $tpl->copy_template );
  1651. $tpl->copy_template = str_replace( "[/xfgiven_{$value[0]}]", "", $tpl->copy_template );
  1652. }
  1653.  
  1654. if(strpos( $tpl->copy_template, "[ifxfvalue" ) !== false ) {
  1655. $tpl->copy_template = preg_replace_callback ( "#\\[ifxfvalue(.+?)\\](.+?)\\[/ifxfvalue\\]#is", "check_xfvalue", $tpl->copy_template );
  1656. }
  1657.  
  1658. if ( $value[6] AND !empty( $xfieldsdata[$value[0]] ) ) {
  1659. $temp_array = explode( ",", $xfieldsdata[$value[0]] );
  1660. $value3 = array();
  1661.  
  1662. foreach ($temp_array as $value2) {
  1663.  
  1664. $value2 = trim($value2);
  1665. $value2 = str_replace("&#039;", "'", $value2);
  1666.  
  1667. if( $config['allow_alt_url'] ) $value3[] = "<a href=\"" . $config['http_home_url'] . "xfsearch/" .$value[0]."/". urlencode( $value2 ) . "/\">" . $value2 . "</a>";
  1668. else $value3[] = "<a href=\"$PHP_SELF?do=xfsearch&amp;xfname=".$value[0]."&amp;xf=" . urlencode( $value2 ) . "\">" . $value2 . "</a>";
  1669. }
  1670.  
  1671. $xfieldsdata[$value[0]] = implode(", ", $value3);
  1672.  
  1673. unset($temp_array);
  1674. unset($value2);
  1675. unset($value3);
  1676.  
  1677. }
  1678.  
  1679. if ($config['allow_links'] AND $value[3] == "textarea" AND function_exists('replace_links')) $xfieldsdata[$value[0]] = replace_links ( $xfieldsdata[$value[0]], $replace_links['news'] );
  1680.  
  1681. if($value[3] == "image" AND $xfieldsdata[$value[0]] ) {
  1682. $path_parts = @pathinfo($xfieldsdata[$value[0]]);
  1683.  
  1684. if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
  1685. $thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
  1686. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1687. } else {
  1688. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1689. $thumb_url = "";
  1690. }
  1691.  
  1692. if($thumb_url) {
  1693. $xfieldsdata[$value[0]] = "<a href=\"$img_url\" class=\"highslide\" target=\"_blank\"><img class=\"xfieldimage {$value[0]}\" src=\"$thumb_url\" alt=\"\" /></a>";
  1694. } else $xfieldsdata[$value[0]] = "<img class=\"xfieldimage {$value[0]}\" src=\"{$img_url}\" alt=\"\" />";
  1695.  
  1696. $social_tags['image'] = $img_url;
  1697. }
  1698.  
  1699. if($value[3] == "image") {
  1700.  
  1701. if( $xfieldsdata[$value[0]] ) {
  1702. $tpl->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", $thumb_url, $tpl->copy_template );
  1703. $tpl->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", $img_url, $tpl->copy_template );
  1704. } else {
  1705. $tpl->copy_template = str_replace( "[xfvalue_thumb_url_{$value[0]}]", "", $tpl->copy_template );
  1706. $tpl->copy_template = str_replace( "[xfvalue_image_url_{$value[0]}]", "", $tpl->copy_template );
  1707. }
  1708. }
  1709.  
  1710. if($value[3] == "imagegalery" AND $xfieldsdata[$value[0]] AND stripos ( $tpl->copy_template, "[xfvalue_{$value[0]}]" ) !== false) {
  1711.  
  1712. $fieldvalue_arr = explode(',', $xfieldsdata[$value[0]]);
  1713. $gallery_image = array();
  1714.  
  1715. foreach ($fieldvalue_arr as $temp_value) {
  1716.  
  1717. $temp_value = trim($temp_value);
  1718.  
  1719. if($temp_value == "") continue;
  1720.  
  1721. $path_parts = @pathinfo($temp_value);
  1722.  
  1723. if( $value[12] AND file_exists(ROOT_DIR . "/uploads/posts/" .$path_parts['dirname']."/thumbs/".$path_parts['basename']) ) {
  1724. $thumb_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/thumbs/".$path_parts['basename'];
  1725. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1726. } else {
  1727. $img_url = $config['http_home_url'] . "uploads/posts/" . $path_parts['dirname']."/".$path_parts['basename'];
  1728. $thumb_url = "";
  1729. }
  1730.  
  1731. if($thumb_url) {
  1732. $gallery_image[] = "<li><a href=\"$img_url\" onclick=\"return hs.expand(this, { slideshowGroup: 'xf_{$row['id']}_{$value[0]}' })\" target=\"_blank\"><img src=\"{$thumb_url}\" alt=\"\" /></a></li>";
  1733. } else $gallery_image[] = "<li><img src=\"{$img_url}\" alt=\"\" /></li>";
  1734.  
  1735. }
  1736.  
  1737. $xfieldsdata[$value[0]] = "<ul class=\"xfieldimagegallery {$value[0]}\">".implode($gallery_image)."</ul>";
  1738. $uniq_id = "xf_{$row['id']}_{$value[0]}";
  1739. $onload_scripts[$uniq_id] = "hs.addSlideshow({slideshowGroup: '{$uniq_id}', interval: 4000, repeat: false, useControls: true, fixedControls: 'fit', overlayOptions: { opacity: .75, position: 'bottom center', hideOnMouseOut: true } });";
  1740.  
  1741. }
  1742.  
  1743. $tpl->set( "[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]] );
  1744.  
  1745. if ( preg_match( "#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches ) ) {
  1746. $count= intval($matches[1]);
  1747.  
  1748. $xfieldsdata[$value[0]] = str_replace( "</p><p>", " ", $xfieldsdata[$value[0]] );
  1749. $xfieldsdata[$value[0]] = strip_tags( $xfieldsdata[$value[0]], "<br>" );
  1750. $xfieldsdata[$value[0]] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $xfieldsdata[$value[0]] ) ) ) ));
  1751.  
  1752. if( $count AND dle_strlen( $xfieldsdata[$value[0]], $config['charset'] ) > $count ) {
  1753.  
  1754. $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $count, $config['charset'] );
  1755.  
  1756. if( ($temp_dmax = dle_strrpos( $xfieldsdata[$value[0]], ' ', $config['charset'] )) ) $xfieldsdata[$value[0]] = dle_substr( $xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset'] );
  1757.  
  1758. }
  1759.  
  1760. $tpl->set( $matches[0], $xfieldsdata[$value[0]] );
  1761.  
  1762. }
  1763. }
  1764. }
  1765.  
  1766. $xfieldsdata = $row['xfields'];
  1767. $category_id = $row['category'];
  1768.  
  1769. $tpl->compile( 'content' );
  1770.  
  1771. if( $user_group[$member_id['user_group']]['allow_hide'] ) $tpl->result['content'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $tpl->result['content']) );
  1772. else $tpl->result['content'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content'] );
  1773.  
  1774. if ( $config['allow_banner'] AND count($banner_in_news) AND !$view_template ){
  1775.  
  1776. foreach ( $banner_in_news as $name) {
  1777. $tpl->result['content'] = str_replace( "{banner_" . $name . "}", $banners[$name], $tpl->result['content'] );
  1778.  
  1779. if( $banners[$name] ) {
  1780. $tpl->result['content'] = str_replace ( "[banner_" . $name . "]", "", $tpl->result['content'] );
  1781. $tpl->result['content'] = str_replace ( "[/banner_" . $name . "]", "", $tpl->result['content'] );
  1782. }
  1783. }
  1784.  
  1785. $tpl->result['content'] = preg_replace( "'\\[banner_(.*?)\\](.*?)\\[/banner_(.*?)\\]'si", '', $tpl->result['content'] );
  1786.  
  1787. }
  1788.  
  1789. $news_id = $row['id'];
  1790. $allow_comments = $row['allow_comm'];
  1791.  
  1792. $allow_add = true;
  1793.  
  1794. if ( $config['max_comments_days'] ) {
  1795.  
  1796. if ($row['date'] < ($_TIME - ($config['max_comments_days'] * 3600 * 24)) ) $allow_add = false;
  1797.  
  1798. }
  1799.  
  1800. if( $view_template ) $allow_comments = false;
  1801.  
  1802. }
  1803.  
  1804. $tpl->clear();
  1805. unset( $row );
  1806.  
  1807. if( $config['files_allow'] ) if( strpos( $tpl->result['content'], "[attachment=" ) !== false ) {
  1808. $tpl->result['content'] = show_attach( $tpl->result['content'], $news_id );
  1809. }
  1810.  
  1811. if( !$news_found AND !$perm ) msgbox( $lang['all_err_1'], "<b>{$user_group[$member_id['user_group']]['group_name']}</b> " . $lang['news_err_28'] );
  1812. // 301 редирект на главную, если новость не найдена/не существует
  1813. elseif( ! $news_found ) {
  1814. header("HTTP/1.0 301 Moved Permanently");
  1815. header("Location: {$config['http_home_url']}");
  1816. die("Redirect");
  1817. }
  1818. // 301 редирект на главную, если новость не найдена/не существует
  1819.  
  1820. //####################################################################################################################
  1821. // Просмотр комментариев
  1822. //####################################################################################################################
  1823. if( $allow_comments AND $news_found) {
  1824.  
  1825. if( $comments_num > 0 ) {
  1826.  
  1827. include_once ENGINE_DIR . '/classes/comments.class.php';
  1828. $comments = new DLE_Comments( $db, $comments_num, intval($config['comm_nummers']) );
  1829.  
  1830. if( $config['comm_msort'] == "" OR $config['comm_msort'] == "ASC" ) $comm_msort = "ASC"; else $comm_msort = "DESC";
  1831.  
  1832. if( $config['tree_comments'] ) $comm_msort = "ASC";
  1833.  
  1834. if( $config['allow_cmod'] ) $where_approve = " AND " . PREFIX . "_comments.approve=1";
  1835. else $where_approve = "";
  1836.  
  1837. $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, " . PREFIX . "_comments.rating, " . PREFIX . "_comments.vote_num, " . PREFIX . "_comments.parent, name, " . USERPREFIX . "_users.email, news_num, comm_num, user_group, lastdate, reg_date, signature, foto, fullname, land, 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 " . PREFIX . "_comments.id " . $comm_msort;
  1838.  
  1839. if ( $allow_full_cache AND $config['allow_comments_cache'] ) $allow_full_cache = $news_id; else $allow_full_cache = false;
  1840.  
  1841. $comments->build_comments('comments.tpl', 'news', $allow_full_cache, $full_link );
  1842.  
  1843. unset ($tpl->result['comments']);
  1844.  
  1845. 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;
  1846.  
  1847. $comments->build_navigation('navigation.tpl', $link_page . "{page}," . $news_name . ".html#comment", $user_query, $full_link);
  1848.  
  1849. unset ($comments);
  1850. unset ($tpl->result['commentsnavigation']);
  1851.  
  1852. }
  1853.  
  1854. if ($is_logged AND $config['comments_restricted'] AND (($_TIME - $member_id['reg_date']) < ($config['comments_restricted'] * 86400)) ) {
  1855.  
  1856. $lang['news_info_6'] = str_replace( '{days}', intval($config['comments_restricted']), $lang['news_info_8'] );
  1857. $allow_add = false;
  1858.  
  1859. }
  1860.  
  1861. if (!isset($member_id['restricted'])) $member_id['restricted'] = false;
  1862.  
  1863. if( $member_id['restricted'] AND $member_id['restricted_days'] AND $member_id['restricted_date'] < $_TIME ) {
  1864.  
  1865. $member_id['restricted'] = 0;
  1866. $db->query( "UPDATE LOW_PRIORITY " . USERPREFIX . "_users SET restricted='0', restricted_days='0', restricted_date='' WHERE user_id='{$member_id['user_id']}'" );
  1867.  
  1868. }
  1869.  
  1870. if( $user_group[$member_id['user_group']]['allow_addc'] AND $config['allow_comments'] AND $allow_add AND ($member_id['restricted'] != 2 AND $member_id['restricted'] != 3) ) {
  1871.  
  1872. if( !$comments_num ) {
  1873. if( strpos ( $tpl->result['content'], "<!--dlecomments-->" ) !== false ) {
  1874.  
  1875. $tpl->result['content'] = str_replace ( "<!--dlecomments-->", "\n<div id=\"dle-ajax-comments\"></div>\n", $tpl->result['content'] );
  1876.  
  1877. } else $tpl->result['content'] .= "\n<div id=\"dle-ajax-comments\"></div>\n";
  1878. }
  1879.  
  1880. $tpl->load_template( 'addcomments.tpl' );
  1881.  
  1882. if ($config['allow_subscribe'] AND $user_group[$member_id['user_group']]['allow_subscribe']) $allow_subscribe = true; else $allow_subscribe = false;
  1883.  
  1884. if( $config['allow_comments_wysiwyg'] > 0 ) {
  1885. $text='';
  1886. $p_name = urlencode($member_id['name']);
  1887. $p_id = 0;
  1888. include_once ENGINE_DIR . '/editor/comments.php';
  1889. $bb_code = "";
  1890. $allow_comments_ajax = true;
  1891. } else
  1892. include_once ENGINE_DIR . '/modules/bbcode.php';
  1893.  
  1894. 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'] ) {
  1895.  
  1896. $user_group[$member_id['user_group']]['comments_question'] = false;
  1897. $user_group[$member_id['user_group']]['captcha'] = false;
  1898.  
  1899. }
  1900.  
  1901. if( $user_group[$member_id['user_group']]['comments_question'] ) {
  1902.  
  1903. $tpl->set( '[question]', "" );
  1904. $tpl->set( '[/question]', "" );
  1905.  
  1906. $question = $db->super_query("SELECT id, question FROM " . PREFIX . "_question ORDER BY RAND() LIMIT 1");
  1907. $tpl->set( '{question}', "<span id=\"dle-question\">".htmlspecialchars( stripslashes( $question['question'] ), ENT_QUOTES, $config['charset'] )."</span>" );
  1908.  
  1909. $_SESSION['question'] = $question['id'];
  1910.  
  1911. } else {
  1912.  
  1913. $tpl->set_block( "'\\[question\\](.*?)\\[/question\\]'si", "" );
  1914. $tpl->set( '{question}', "" );
  1915.  
  1916. }
  1917.  
  1918. if( $user_group[$member_id['user_group']]['captcha'] ) {
  1919.  
  1920. if ( $config['allow_recaptcha'] ) {
  1921.  
  1922. $tpl->set( '[recaptcha]', "" );
  1923. $tpl->set( '[/recaptcha]', "" );
  1924.  
  1925. $tpl->set( '{recaptcha}', "<div class=\"g-recaptcha\" data-sitekey=\"{$config['recaptcha_public_key']}\" data-theme=\"{$config['recaptcha_theme']}\"></div>" );
  1926.  
  1927. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  1928. $tpl->set( '{reg_code}', "" );
  1929.  
  1930. } else {
  1931.  
  1932. $tpl->set( '[sec_code]', "" );
  1933. $tpl->set( '[/sec_code]', "" );
  1934. $path = parse_url( $config['http_home_url'] );
  1935. $tpl->set( '{sec_code}', "<a onclick=\"reload(); return false;\" title=\"{$lang['reload_code']}\" href=\"#\"><span id=\"dle-captcha\"><img src=\"" . $path['path'] . "engine/modules/antibot/antibot.php\" alt=\"{$lang['reload_code']}\" width=\"160\" height=\"80\" /></span></a>" );
  1936. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  1937. $tpl->set( '{recaptcha}', "" );
  1938. }
  1939.  
  1940. } else {
  1941. $tpl->set( '{sec_code}', "" );
  1942. $tpl->set( '{recaptcha}', "" );
  1943. $tpl->set_block( "'\\[recaptcha\\](.*?)\\[/recaptcha\\]'si", "" );
  1944. $tpl->set_block( "'\\[sec_code\\](.*?)\\[/sec_code\\]'si", "" );
  1945. }
  1946.  
  1947. if( $config['allow_comments_wysiwyg'] > 0 ) {
  1948.  
  1949. $tpl->set( '{editor}', $wysiwyg );
  1950.  
  1951. } else {
  1952. $tpl->set( '{editor}', $bb_code );
  1953.  
  1954. }
  1955.  
  1956. $tpl->set( '{text}', '' );
  1957. $tpl->set( '{title}', $lang['news_addcom'] );
  1958.  
  1959. if( $vk_url ) {
  1960. $tpl->set( '[vk]', "" );
  1961. $tpl->set( '[/vk]', "" );
  1962. $tpl->set( '{vk_url}', $vk_url );
  1963. } else {
  1964. $tpl->set_block( "'\\[vk\\](.*?)\\[/vk\\]'si", "" );
  1965. $tpl->set( '{vk_url}', '' );
  1966. }
  1967. if( $odnoklassniki_url ) {
  1968. $tpl->set( '[odnoklassniki]', "" );
  1969. $tpl->set( '[/odnoklassniki]', "" );
  1970. $tpl->set( '{odnoklassniki_url}', $odnoklassniki_url );
  1971. } else {
  1972. $tpl->set_block( "'\\[odnoklassniki\\](.*?)\\[/odnoklassniki\\]'si", "" );
  1973. $tpl->set( '{odnoklassniki_url}', '' );
  1974. }
  1975. if( $facebook_url ) {
  1976. $tpl->set( '[facebook]', "" );
  1977. $tpl->set( '[/facebook]', "" );
  1978. $tpl->set( '{facebook_url}', $facebook_url );
  1979. } else {
  1980. $tpl->set_block( "'\\[facebook\\](.*?)\\[/facebook\\]'si", "" );
  1981. $tpl->set( '{facebook_url}', '' );
  1982. }
  1983. if( $google_url ) {
  1984. $tpl->set( '[google]', "" );
  1985. $tpl->set( '[/google]', "" );
  1986. $tpl->set( '{google_url}', $google_url );
  1987. } else {
  1988. $tpl->set_block( "'\\[google\\](.*?)\\[/google\\]'si", "" );
  1989. $tpl->set( '{google_url}', '' );
  1990. }
  1991. if( $mailru_url ) {
  1992. $tpl->set( '[mailru]', "" );
  1993. $tpl->set( '[/mailru]', "" );
  1994. $tpl->set( '{mailru_url}', $mailru_url );
  1995. } else {
  1996. $tpl->set_block( "'\\[mailru\\](.*?)\\[/mailru\\]'si", "" );
  1997. $tpl->set( '{mailru_url}', '' );
  1998. }
  1999. if( $yandex_url ) {
  2000. $tpl->set( '[yandex]', "" );
  2001. $tpl->set( '[/yandex]', "" );
  2002. $tpl->set( '{yandex_url}', $yandex_url );
  2003. } else {
  2004. $tpl->set_block( "'\\[yandex\\](.*?)\\[/yandex\\]'si", "" );
  2005. $tpl->set( '{yandex_url}', '' );
  2006. }
  2007.  
  2008. if ( $is_logged AND $user_group[$member_id['user_group']]['allow_subscribe'] ) {
  2009. $tpl->set( '[comments-subscribe]', "<a href=\"#\" onclick=\"subscribe('{$news_id}'); return false;\" >" );
  2010. $tpl->set( '[/comments-subscribe]', '</a>' );
  2011. } else {
  2012. $tpl->set_block( "'\\[comments-subscribe\\](.*?)\\[/comments-subscribe\\]'si", "" );
  2013. }
  2014.  
  2015. if( ! $is_logged ) {
  2016. $tpl->set( '[not-logged]', '' );
  2017. $tpl->set( '[/not-logged]', '' );
  2018. } else $tpl->set_block( "'\\[not-logged\\](.*?)\\[/not-logged\\]'si", "" );
  2019.  
  2020. if( $is_logged ) $hidden = "<input type=\"hidden\" name=\"name\" id=\"name\" value=\"{$member_id['name']}\" /><input type=\"hidden\" name=\"mail\" id=\"mail\" value=\"\" />";
  2021. else $hidden = "";
  2022.  
  2023. $tpl->copy_template = "<form method=\"post\" name=\"dle-comments-form\" id=\"dle-comments-form\" >" . $tpl->copy_template . "
  2024. <input type=\"hidden\" name=\"subaction\" value=\"addcomment\" />{$hidden}
  2025. <input type=\"hidden\" name=\"post_id\" id=\"post_id\" value=\"{$news_id}\" /></form>";
  2026.  
  2027. $onload_scripts[] = <<<HTML
  2028. $('#dle-comments-form').submit(function() {
  2029. doAddComments();
  2030. return false;
  2031. });
  2032. HTML;
  2033.  
  2034.  
  2035. if ( $user_group[$member_id['user_group']]['captcha'] AND $config['allow_recaptcha'] ) {
  2036.  
  2037. $tpl->copy_template .= <<<HTML
  2038. <script src='https://www.google.com/recaptcha/api.js?hl={$lang['wysiwyg_language']}' async defer></script>
  2039. HTML;
  2040.  
  2041. }
  2042.  
  2043. $tpl->compile( 'addcomments' );
  2044. $tpl->clear();
  2045.  
  2046. if ( strpos ( $tpl->result['content'], "<!--dleaddcomments-->" ) !== false ) {
  2047.  
  2048. $tpl->result['content'] = str_replace ( "<!--dleaddcomments-->", $tpl->result['addcomments'], $tpl->result['content'] );
  2049.  
  2050. } else {
  2051.  
  2052. $tpl->result['content'] .= $tpl->result['addcomments'];
  2053.  
  2054. }
  2055.  
  2056. unset ($tpl->result['addcomments']);
  2057.  
  2058. } elseif( $member_id['restricted'] ) {
  2059.  
  2060. $tpl->load_template( 'info.tpl' );
  2061.  
  2062. if( $member_id['restricted_days'] ) {
  2063.  
  2064. $tpl->set( '{error}', $lang['news_info_2'] );
  2065. $tpl->set( '{date}', langdate( "j F Y H:i", $member_id['restricted_date'] ) );
  2066.  
  2067. } else
  2068. $tpl->set( '{error}', $lang['news_info_3'] );
  2069.  
  2070. $tpl->set( '{title}', $lang['all_info'] );
  2071. $tpl->compile( 'content' );
  2072. $tpl->clear();
  2073.  
  2074. } elseif( !$allow_add ) {
  2075.  
  2076. $tpl->load_template( 'info.tpl' );
  2077. $tpl->set( '{error}', $lang['news_info_6'] );
  2078. $tpl->set( '{days}', $config['max_comments_days'] );
  2079. $tpl->set( '{title}', $lang['all_info'] );
  2080. $tpl->compile( 'content' );
  2081. $tpl->clear();
  2082.  
  2083. } elseif( $config['allow_comments'] ) {
  2084.  
  2085. $tpl->load_template( 'info.tpl' );
  2086. $tpl->set( '{error}', $lang['news_info_1'] );
  2087. $tpl->set( '{group}', $user_group[$member_id['user_group']]['group_name'] );
  2088. $tpl->set( '{title}', $lang['all_info'] );
  2089. $tpl->compile( 'content' );
  2090. $tpl->clear();
  2091.  
  2092. }
  2093. }
  2094. ?>
Advertisement
Add Comment
Please, Sign In to add comment