Advertisement
butik

show.short.php dle 9.*

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