Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*********************/
- /* */
- /* Version : 5.1.0 */
- /* Author : RM */
- /* Comment : 071223 */
- /* */
- /*********************/
- if ( !defined( "DATALIFEENGINE" ) )
- {
- exit( "Hacking attempt!" );
- }
- $sblocks = get_vars( "sblocks" );
- if ( !is_array( $sblocks ) )
- {
- $sblocks = array( );
- $db->query( "SELECT * FROM ".PREFIX."_sblocks ORDER BY id ASC" );
- while ( $row_s = $db->get_row( ) )
- {
- $sblocks[$row_s['title']] = array( );
- foreach ( $row_s as $key => $value )
- {
- $sblocks[$row_s['title']][$key] = stripslashes( $value );
- }
- }
- set_vars( "sblocks", $sblocks );
- $db->free( );
- }
- $sbl = array( );
- $ajax_prefix = "_page_1";
- if ( $ajax_title && $ajax_start )
- {
- $cstart = $ajax_start;
- $ajax_prefix = "_page_".$cstart;
- }
- if ( 0 < count( $sblocks ) )
- {
- require_once( ENGINE_DIR."/classes/parse.class.php" );
- $parse = new parsefilter( );
- function sblocks_descr( $story, $num = 0 )
- {
- global $db;
- global $parse;
- $fastquotes = array( "\"", "`", "\t", "\n", "\r", "\"", "\\r", "\\n", "/", "\\", "{", "}", "[", "]" );
- $story = preg_replace( "'\\[hide\\](.*?)\\[/hide\\]'si", "", $story );
- $story = preg_replace( "'\\[attachment=(.*?)\\]'si", "", $story );
- $story = preg_replace( "'\\[page=(.*?)\\](.*?)\\[/page\\]'si", "", $story );
- $story = str_replace( "{PAGEBREAK}", "", $story );
- $story = str_replace( " ", " ", $story );
- $story = str_replace( "<br />", " ", $story );
- $story = trim( strip_tags( $story ) );
- $story = str_replace( $fastquotes, "", $story );
- if ( $num )
- {
- $story = $db->safesql( substr( $story, 0, $num ) )."...";
- return $story;
- }
- $story = $db->safesql( $story );
- return $story;
- }
- function sblocks_attach( $id )
- {
- global $db;
- global $config;
- global $lang;
- global $user_group;
- global $member_id;
- if ( is_array( $id ) && count( $id ) )
- {
- $where = "news_id IN (".implode( ",", $id ).")";
- }
- else
- {
- $where = "news_id = '".$id."'";
- }
- $link = "";
- $sql_files = $db->query( "SELECT id, name, onserver, dcount FROM ".PREFIX.( "_files WHERE ".$where ) );
- while ( ( $row = $db->get_row( $sql_files ) ) && $row['id'] )
- {
- $size = formatsize( @filesize( ROOT_DIR."/uploads/files/".$row['onserver'] ) );
- $row['name'] = explode( "/", $row['name'] );
- $row['name'] = end( $row['name'] );
- if ( !$user_group[$member_id['user_group']]['allow_files'] )
- {
- $link .= "<span class=\"attachment\">".$lang['att_denied']."</span>";
- }
- else if ( $config['files_count'] == "yes" )
- {
- $link .= "<span class=\"attachment\"><a href=\"".$config['http_home_url']."engine/download.php?id={$row['id']}\" >{$row['name']}</a> [{$size}] ({$lang['att_dcount']} {$row['dcount']})</span>";
- }
- else
- {
- $link .= "<span class=\"attachment\"><a href=\"".$config['http_home_url']."engine/download.php?id={$row['id']}\" >{$row['name']}</a> [{$size}]</span>";
- }
- }
- $db->free( );
- return $link;
- }
- function sblocks_time( )
- {
- list( $usec, $sec ) = explode( " ", microtime( ) );
- return ( double )$usec + ( double )$sec;
- }
- function sblocks_thumb( $title, $image, $size = "auto" )
- {
- list( $width, $height ) = explode( ",", $size );
- if ( $width == "auto" )
- {
- $width = "";
- }
- else if ( $width )
- {
- $width = "width=\"".$width."px\"";
- }
- else
- {
- return;
- }
- if ( !$height && $height == "auto" )
- {
- $height = "";
- }
- else
- {
- $height = "height=\"".$height."px\"";
- }
- return "<img src=\"".$image."\" title=\"".$title."\" ".$width." ".$height." alt=\"\" />";
- }
- if ( isset( $_REQUEST['cstart'] ) )
- {
- $cstart = intval( $_GET['cstart'] );
- }
- else
- {
- $cstart = 1;
- }
- foreach ( $sblocks as $name => $value )
- {
- $sblocks_start = sblocks_time( );
- if ( !$value['approve'] && $ajax_title && $value['title'] != $ajax_title )
- {
- if ( $value['sertificate'] != md5( md5( md5( md5( md5( md5( trim( $value['title'].$value['sort'] ) ) ) ) ) ) ) )
- {
- $sbl[$value['title']][] = "<div style=\"margin:10px 0;padding:10px; text-align:center; background:#f00; color:#bbb;font: bold 11px Tahoma;border:1px solid #000;\">Unregistered copy of <a style=\"color:#fff;\">\"S-Blocks v1.7 by Sander\"</a><br/>Visit: <a style=\"color:#fff;\" href=\"http://nfhelp.ru/\">http://nfhelp.ru/</a><br/>ICQ: <a style=\"color:#fff;\">404-037-556</a></div>";
- }
- else
- {
- $cat_info = $cat_info ? $cat_info : get_vars( "category" );
- if ( $value['category'] != "all" )
- {
- $vald = explode( ",", $value['category'] );
- if ( $value['allow_sub_cats'] )
- {
- $i = 0;
- for ( ; $i < count( $vald ); ++$i )
- {
- $vald[$i] = get_sub_cats( $vald[$i] );
- }
- }
- $value['category'] = implode( "|", $vald );
- $valc = explode( "|", $value['category'] );
- }
- else
- {
- $valc = array( );
- foreach ( $cat_info as $cats )
- {
- $valc[] = $cats['id'];
- }
- }
- $lim = $value['rows'] * $value['cols'];
- if ( $value['title'] != "content" )
- {
- $begin = $ajax_start ? ( $ajax_start - 1 ) * $lim : 0;
- if ( $value['fromcat'] && $value['catsel'] )
- {
- if ( !$category_id && !in_array( $category_id, $valc ) )
- {
- if ( $value['allow_sub_cats'] )
- {
- $value['category'] = get_sub_cats( $category_id );
- }
- else
- {
- $value['category'] = $category_id;
- }
- }
- }
- if ( $value['catsel'] && !$value['fromcat'] )
- {
- if ( !$category_id && !in_array( $category_id, $valc ) )
- {
- $value['approve'] = "1";
- }
- }
- if ( $value['fromcat'] && !$value['catsel'] || $category_id )
- {
- $value['category'] = $category_id;
- }
- if ( $value['fromcat'] && $category_id )
- {
- $code = dle_cache( "sblocks_".$value['title']."_category_".$cat_info[$category_id]['alt_name'].$ajax_prefix );
- }
- else
- {
- $code = dle_cache( "sblocks_".$value['title'].$ajax_prefix );
- }
- }
- if ( $value['force_cache'] || $value['sort'] == "RAND()" || $value['title'] == "content" )
- {
- $code = "";
- }
- if ( !$code )
- {
- $now = date( "Y-m-d H:i:s", $_TIME );
- if ( !$value['data'] && $value['data'] < 1 )
- {
- $datag = " AND date<'".$now."'";
- }
- else
- {
- $datag = " AND date >= '".$now."' - INTERVAL ".$value['data'].( " DAY AND date < '".$now."'" );
- }
- if ( $value['from_date'] && $value['to_date'] )
- {
- $from_date = $value['from_date'];
- $to_date = $value['to_date'];
- if ( $now < $to_date )
- {
- $to_date = $now;
- }
- $datag = " AND date>='".$from_date."' AND date<='{$to_date}'";
- }
- $where = "";
- if ( preg_match( "#({thumb}|{image}|{scr.?|{r-img}|\\[thumb|\\[image)#ies", $value['code'], $check_thumb ) && !$value['def_img'] )
- {
- $where .= " short_story LIKE '%src=%' AND";
- if ( preg_match( "#({scr.?|{r-img})#ies", $value['code'], $check_fimg ) )
- {
- $where .= " full_story LIKE '%src=%' AND";
- }
- }
- if ( preg_match( "#(\\{video\\}|\\{video-link\\}|\\[video=(.+)\\])#ies", $value['code'], $check_video ) )
- {
- $where .= " (short_story LIKE '%_video_%' OR full_story LIKE '%_video_%') AND ";
- }
- if ( preg_match( "#(\\{audio\\}|\\{audio-link\\}|\\[audio=(.+)\\])#ies", $value['code'], $check_audio ) )
- {
- $where .= " (short_story LIKE '%_audio_%' OR full_story LIKE '%_audio_%') AND ";
- }
- if ( $value['byid'] )
- {
- $where = " id regexp '[[:<:]](".$value[byid].")[[:>:]]' AND";
- $datag = " AND date<'".$now."'";
- }
- else
- {
- if ( $value['title'] != "content" )
- {
- if ( $value['category'] != "all" )
- {
- $where .= " category regexp '[[:<:]](".$value[category].")[[:>:]]' AND";
- }
- if ( $value['from_main'] == 1 )
- {
- $where .= " allow_main AND";
- }
- else if ( $value['from_main'] == 2 )
- {
- $where .= " allow_main=0 AND";
- }
- if ( $value['sort'] == "RECOMMEND" )
- {
- $where = " short_story LIKE '%<!--sblocks_recommend-->%' AND ";
- $value['sort'] = "id ASC";
- }
- if ( preg_match( "#({reliz}|{reliz-date})#ies", $value['code'], $check_reliz ) )
- {
- $where = " short_story LIKE '%<!--sblocks_reliz_begin-->%' AND ";
- }
- }
- else if ( $newsid )
- {
- if ( !$cstart && $cstart < 1 )
- {
- $cstart = 1;
- }
- $begin = ( $cstart - 1 ) * $lim;
- $where = "";
- if ( $do == "lastnews" )
- {
- $where = " approve AND";
- $code = dle_cache( "sblocks_content_lastnews_page_".$cstart );
- }
- if ( $do == "tags" )
- {
- $where = " id IN ".$tag_array." AND";
- $code = dle_cache( "sblocks_content_tags_page_".$cstart );
- $tag_array = array( );
- unset( $tag_array );
- }
- if ( $subaction == "allnews" )
- {
- $where = " autor = '".$user."' AND";
- $code = dle_cache( "sblocks_content_allnews_page_".$cstart );
- }
- if ( $subaction == "newposts" )
- {
- $where = " date between '".$lasttime."' and '{$thistime}' AND";
- $code = dle_cache( "sblocks_content_newposts_page_".$cstart );
- }
- if ( $catalog != "" )
- {
- $where = " symbol = '".$catalog."' AND";
- $code = dle_cache( "sblocks_content_catalog_".$catalog."_page_".$cstart );
- }
- if ( $year != "" && $month == "" && $day == "" )
- {
- $where = " date < '".$year."-01-01' + INTERVAL 1 YEAR AND";
- $code = dle_cache( "sblocks_content_calendar_".$year."_page_".$cstart );
- }
- if ( $year != "" && $month != "" && $day == "" )
- {
- $where = " date >= '".$year."-{$month}-01'AND date < '{$year}-{$month}-01' + INTERVAL 1 MONTH AND";
- $code = dle_cache( "sblocks_content_calendar_".$year."_".$month."_page_".$cstart );
- }
- if ( $year != "" && $month != "" && $day != "" && $subaction == "" )
- {
- $where = " date >= '".$year."-{$month}-{$day}' AND date < '{$year}-{$month}-{$day}' + INTERVAL 24 HOUR AND";
- $code = dle_cache( "sblocks_content_calendar_".$year."_".$month."_".$day."_page_".$cstart );
- }
- if ( !$where )
- {
- if ( !$category_id )
- {
- if ( $value['from_main'] == 1 )
- {
- $where .= " allow_main AND";
- }
- else if ( $value['from_main'] == 2 )
- {
- $where .= " allow_main=0 AND";
- }
- }
- else if ( $value['allow_sub_cats'] )
- {
- $where .= " category regexp '[[:<:]](".get_sub_cats( $category_id ).")[[:>:]]' AND";
- }
- else
- {
- $where .= " category regexp '[[:<:]](".$category_id.")[[:>:]]' AND";
- }
- if ( $category_id && !$newsid )
- {
- $code = dle_cache( "sblocks_content_category_".$cat_info[$category_id]['alt_name']."_page_".$cstart );
- }
- else if ( $sblocks_content && !$newsid )
- {
- $code = dle_cache( "sblocks_content_page_".$cstart );
- }
- }
- if ( $check_thumb && !$value['def_img'] )
- {
- $where .= " short_story LIKE '%src=%' AND";
- }
- if ( $check_fimg && !$value['def_img'] )
- {
- $where .= " full_story LIKE '%src=%' AND";
- }
- }
- }
- if ( !$value['force_cache'] || $value['sort'] == "RAND()" )
- {
- $code = "";
- }
- if ( !$code )
- {
- $value['code'] = str_replace( "'", "'", $value['code'] );
- $colid = 0;
- $code = "<div id=\"sblocks_".$value['title']."\">\r";
- $sql_select = "SELECT id, autor, date, short_story, full_story, xfields, title, category, alt_name, comm_num, rating, vote_num, news_read, flag, descr FROM ".PREFIX."_post WHERE ".$where." approve ".$datag." ORDER BY ".$value[sort]." LIMIT ".$begin.", ".$lim;
- $sb_select = $db->query( $sql_select );
- while ( $rowc = $db->get_row( $sb_select ) )
- {
- if ( 1 < $value['cols'] )
- {
- $code_temp = "\t<div style=\"float:left;width:".floor( 100 / $value['cols'] )."%;margin:0;padding:0;\">".$value['code']."</div>\r";
- }
- else
- {
- $code_temp = "\t<div style=\"width:100%;margin:0;padding:0;\">".$value['code']."</div>\r";
- }
- $find = "";
- $replace = "";
- $findp = "";
- $replacep = "";
- $rowc['category'] = intval( $rowc['category'] );
- $rowc['date'] = strtotime( $rowc['date'] );
- if ( $value['title_words'] )
- {
- $temp_title = explode( " ", $rowc['title'] );
- }
- if ( $value['title_cut'] && $value['title_cut'] < strlen( $rowc['title'] ) )
- {
- $title = trim( substr( strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) ), 0, $value['title_cut'] ) )."...";
- $title_trimmed = true;
- }
- else
- {
- $title = strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) );
- }
- if ( $value['title_words'] && $title_trimmed )
- {
- $temp_title_trim = explode( " ", $title );
- if ( !in_array( end( $temp_title_trim ), $temp_title ) )
- {
- unset( $temp_title_trim[count( $temp_title_trim ) - 1] );
- }
- $title = implode( " ", $temp_title_trim );
- }
- $title = str_replace( "'", "`", $title );
- $title_full = strip_tags( stripslashes( htmlspecialchars( $rowc['title'] ) ) );
- $title_full = str_replace( "'", "`", $title_full );
- $find[] = "{title}";
- $replace[] = trim( $title );
- $find[] = "{title-full}";
- $replace[] = trim( $title_full );
- if ( $config['allow_alt_url'] == "yes" )
- {
- if ( $rowc['flag'] && $config['seo_type'] )
- {
- if ( $rowc['category'] && $config['seo_type'] == 2 )
- {
- $full_link = $config['http_home_url'].get_url( $rowc['category'] )."/".$rowc['id']."-".$rowc['alt_name'].".html";
- }
- else
- {
- $full_link = $config['http_home_url'].$rowc['id']."-".$rowc['alt_name'].".html";
- }
- }
- else
- {
- $full_link = $config['http_home_url'].date( "Y/m/d/", $rowc['date'] ).$rowc['alt_name'].".html";
- }
- }
- else
- {
- $full_link = $config['http_home_url']."index.php?newsid=".$rowc['id'];
- }
- $find[] = "{href}";
- $replace[] = $full_link;
- $find[] = "[full-link]";
- $replace[] = "<a href=\"".$full_link."\" title=\"".trim( $title_full )."\">";
- $find[] = "[/full-link]";
- $replace[] = "</a>";
- $find[] = "[com-link]";
- $replace[] = "<a href=\"".$full_link."#comment\" title=\"".trim( $title_full )." (комментарии)\">";
- $find[] = "[/com-link]";
- $replace[] = "</a>";
- if ( strstr( $value['code'], "{THEME}" ) )
- {
- $find[] = "{THEME}";
- $replace[] = $config['http_home_url']."templates/".$config['skin'];
- }
- if ( $check_thumb )
- {
- $shab = "#src=\\\\?['\"](.+?)\\\\?['\"]#ies";
- $shab_full = "#http://[^\"]+?(jpg|jpeg|png|gif|tga)#ies";
- preg_match( $shab, $rowc['short_story'], $thumb );
- $thumb = $thumb[1];
- preg_match( $shab_full, $rowc['short_story'], $image );
- $image = $image[0];
- if ( !$thumb )
- {
- $thumb = $image;
- }
- if ( $value['def_img'] && !$thumb )
- {
- $thumb = $config['http_home_url']."templates/".$config['skin']."/images/".$value['def_img'];
- $image = $config['http_home_url']."templates/".$config['skin']."/images/".$value['def_img'];
- }
- if ( $thumb )
- {
- if ( !$rowc['full_story'] )
- {
- $rowc['full_story'] = $rowc['short_story'];
- }
- preg_match_all( $shab, $rowc['full_story'], $imag );
- $id_img = 0;
- foreach ( $imag[1] as $imgs )
- {
- if ( $imgs )
- {
- $id_img += 1;
- $find[] = "{scr".$id_img."}";
- $replace[] = $imgs;
- }
- }
- $r_img = mt_rand( 0, count( $imag[0] ) - 1 );
- $r_img = $imag[1][$r_img];
- $find[] = "{thumb}";
- $replace[] = $thumb;
- $find[] = "{image}";
- $replace[] = $image;
- $find[] = "{r-img}";
- $replace[] = $r_img;
- if ( preg_match( "#(\\[thumb|\\[image)#ies", $value['code'] ) )
- {
- preg_match( "#\\[thumb=([^\\]]+)\\]#is", $value['code'], $th_size );
- $findp[] = "/\\[thumb=([^\\]]+)\\]/";
- $replacep[] = sblocks_thumb( trim( $title_full ), $thumb, $th_size[1] );
- $findp[] = "/\\[thumb\\]/";
- $replacep[] = sblocks_thumb( trim( $title_full ), $thumb );
- preg_match( "#\\[image=([^\\]]+)\\]#is", $value['code'], $im_size );
- $findp[] = "/\\[image=([^\\]]+)\\]/";
- $replacep[] = sblocks_thumb( trim( $title_full ), $image, $im_size[1] );
- $findp[] = "/\\[image\\]/";
- $replacep[] = sblocks_thumb( trim( $title_full ), $image );
- }
- }
- }
- if ( strstr( $value['code'], "{attachments}" ) )
- {
- $find[] = "{attachments}";
- $replace[] = sblocks_attach( $rowc['id'] );
- }
- if ( $check_video )
- {
- if ( !$rowc['full_story'] )
- {
- $rowc['full_story'] = $rowc['short_story'];
- }
- preg_match( "#<!--dle_video_begin:(.+?)-->(.+?)<!--dle_video_end-->#is", $rowc['full_story'], $video );
- $video = $video[1];
- if ( !$video )
- {
- preg_match( "#<!--dle_video_begin-->(.+?)src=\"(.+?)\"(.+?)<!--dle_video_end-->#is", $rowc['full_story'], $video );
- $video = $video[2];
- if ( !$video )
- {
- preg_match( "#<embed(.+?)file=([^&\"]+\\.(flv|mp4|m4v|m4a|mov|3gp|f4v|avi|divx))(&|\")(.+?)>#is", $rowc['full_story'], $video );
- $video = $video[2];
- if ( !$video )
- {
- $video = "Link not found";
- }
- }
- }
- preg_match( "#\\[video=([^\\]]+)\\]#is", $value['code'], $ssize );
- $find[] = "{video-link}";
- $replace[] = $video;
- $find[] = "{video}";
- $replace[] = $parse->build_video( $video );
- $findp[] = "/\\[video=([^\\]]+)\\]/";
- $replacep[] = $parse->build_video( $video, $ssize[1] );
- }
- if ( $check_audio )
- {
- if ( !$rowc['full_story'] )
- {
- $rowc['full_story'] = $rowc['short_story'];
- }
- preg_match( "#<!--dle_audio_begin:(.+?)-->(.+?)<!--dle_audio_end-->#is", $rowc['full_story'], $audio );
- $audio = $audio[1];
- if ( !$audio )
- {
- preg_match( "#<embed(.+?)file=([^&\"]+)(&|\")(.+?)>#is", $rowc['full_story'], $audio );
- $audio = $audio[2];
- if ( !$audio )
- {
- preg_match( "#<!--dle_audio_begin-->(.+?)src=\"(.+?)\"(.+?)<!--dle_audio_end-->#is", $rowc['full_story'], $audio );
- $audio = $audio[2];
- if ( !$audio )
- {
- $audio = "Link not found";
- }
- }
- }
- preg_match( "#\\[audio=([^\\]]+)\\]#is", $value['code'], $ssize );
- if ( !$ssize[1] )
- {
- $ssize[1] = 425;
- }
- $find[] = "{audio-link}";
- $replace[] = $audio;
- $find[] = "{audio}";
- $replace[] = $parse->build_audio( $audio );
- $findp[] = "/\\[audio=([^\\]]+)\\]/";
- $replacep[] = $parse->build_audio( $audio, $ssize[1] );
- }
- if ( preg_match( "#(\\[xfvalue_|\\[xfgiven_)#ies", $value['code'] ) )
- {
- $xfields = xfieldsload( );
- $xfieldsdata = xfieldsdataload( $rowc['xfields'] );
- foreach ( $xfields as $val )
- {
- $preg_safe_name = preg_quote( $val[0], "'" );
- if ( empty( $xfieldsdata[$val[0]] ) )
- {
- $findp[] = "'\\[xfgiven_".$preg_safe_name."\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is";
- $replacep[] = "";
- }
- else
- {
- $findp[] = "'\\[xfgiven_".$preg_safe_name."\\](.*?)\\[/xfgiven_{$preg_safe_name}\\]'is";
- $replacep[] = "\\1";
- }
- $findp[] = "/\\[xfvalue_".$preg_safe_name."\\]/";
- $replacep[] = $xfieldsdata[$val[0]];
- }
- }
- if ( preg_match( "#({category}|{link-category}|{category-link})#ies", $value['code'] ) )
- {
- if ( !$rowc['category'] )
- {
- $my_cat = "---";
- $my_cat_link = "---";
- $cat_link = "---";
- }
- else
- {
- $my_cat = array( );
- $my_cat_link = array( );
- $cat_list = explode( ",", $rowc['category'] );
- if ( count( $cat_list ) == 1 )
- {
- $my_cat[] = $cat_info[$cat_list[0]]['name'];
- $my_cat_link = get_categories( $cat_list[0] );
- }
- else
- {
- foreach ( $cat_list as $element )
- {
- if ( $element )
- {
- $my_cat[] = $cat_info[$element]['name'];
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('do=cat&category=".$cat_info[$element]['alt_name']."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- 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>" );
- }
- else
- {
- $my_cat_link[] = "<a ".$go_page."href=\"{$PHP_SELF}?do=cat&category={$cat_info[$element]['alt_name']}\">{$cat_info[$element]['name']}</a>";
- }
- }
- }
- $my_cat_link = implode( ", ", $my_cat_link );
- }
- $my_cat = implode( ", ", $my_cat );
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('do=cat&category=".$cat_info[$cat_list[0]]['alt_name']."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $cat_link = "<a ".$go_page."href=\"".$config['http_home_url'].get_url( $cat_list[0] ).( "/\">".$cat_info[$cat_list[0]]['name']."</a>" );
- }
- else
- {
- $cat_link = "<a ".$go_page."href=\"{$PHP_SELF}?do=cat&category={$cat_info[$cat_list[0]]['alt_name']}\">{$cat_info[$cat_list[0]]['name']}</a>";
- }
- }
- $find[] = "{category}";
- $replace[] = $my_cat;
- $find[] = "{link-category}";
- $replace[] = $my_cat_link;
- $find[] = "{category-link}";
- $replace[] = $cat_link;
- }
- if ( strstr( $value['code'], "{short-story}" ) )
- {
- $find[] = "{short-story}";
- if ( $config['rss_format'] != 1 )
- {
- $rowc['short_story'] = htmlspecialchars( strip_tags( stripslashes( str_replace( "<br />", " ", $rowc['short_story'] ) ) ) );
- }
- else
- {
- $rowc['short_story'] = stripslashes( $rowc['short_story'] );
- }
- $replace[] = trim( $rowc['short_story'] );
- }
- if ( strstr( $value['code'], "{full-story}" ) )
- {
- $rowc['full_story'] = str_replace( "{PAGEBREAK}", "", $rowc['full_story'] );
- $rowc['full_story'] = str_replace( "{pages}", "", $rowc['full_story'] );
- $rowc['full_story'] = preg_replace( "'\\[PAGE=(.*?)\\](.*?)\\[/PAGE\\]'si", "\\2", $rowc['full_story'] );
- $find[] = "{full-story}";
- $replace[] = trim( $rowc['full_story'] );
- }
- if ( preg_match( "#{date}|{date=.+?}|\\[day-news\\]#ies", $value['code'] ) )
- {
- if ( date( Ymd, $rowc['date'] ) == date( Ymd, $_TIME ) )
- {
- $date = $lang['time_heute'].langdate( ", H:i", $rowc['date'] );
- }
- else if ( date( Ymd, $rowc['date'] ) == date( Ymd, $_TIME - 86400 ) )
- {
- $date = $lang['time_gestern'].langdate( ", H:i", $rowc['date'] );
- }
- else
- {
- $date = langdate( $config['timestamp_active'], $rowc['date'] );
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $day_news = "<a href=\"".$config['http_home_url'].date( "Y/m/d/", $rowc['date'] )."\" >";
- }
- else
- {
- $day_news = "<a href=\"".$PHP_SELF."?year=".date( "Y", $rowc['date'] )."&month=".date( "m", $rowc['date'] )."&day=".date( "d", $rowc['date'] )."\" >";
- }
- $find[] = "{date}";
- $replace[] = $date;
- $find[] = "[day-news]";
- $replace[] = $day_news;
- $find[] = "[/day-news]";
- $replace[] = "</a>";
- $code_temp = preg_replace( "#\\{date=(.+?)\\}#ie", "langdate('\\1', '".$rowc['date']."')", $code_temp );
- }
- if ( $check_reliz )
- {
- preg_match( "#<!--sblocks_reliz_begin--><div style=\"display:none\">(.+?)</div><!--sblocks_reliz_end-->#is", $rowc['short_story'], $left );
- $left = strtotime( $left[1] );
- $reliz_date = langdate( "j F Y", $left );
- $hour_now = date( "H", $_TIME );
- $hour_reliz = date( "H", $left ) ? date( "H", $left ) : 1;
- $hour_erase = date( "i", $left ) ? date( "i", $left ) : 23;
- $left -= $_TIME;
- $ryear = floor( $left / 31536000 );
- $rmonth = date( "m", $left ) - 1;
- $rday = date( "j", $left );
- if ( $left <= 0 && -86000 < $left )
- {
- $ryear = 0;
- $rmonth = 0;
- $rday = 0;
- }
- else
- {
- if ( $left < -86000 )
- {
- break;
- }
- }
- if ( $ryear == 0 )
- {
- $ryear = "";
- }
- else if ( $ryear == 1 )
- {
- $ryear .= " Год";
- }
- else if ( 1 < $ryear && $ryear < 5 )
- {
- $ryear .= " Года";
- }
- else if ( 4 < $ryear )
- {
- $ryear .= " Лет";
- }
- if ( $rmonth == 0 )
- {
- $rmonth = "";
- }
- else if ( $rmonth == 1 )
- {
- $rmonth .= " Месяц";
- }
- else if ( 1 < $rmonth && $rmonth < 5 )
- {
- $rmonth .= " Месяца";
- }
- else if ( 4 < $rmonth )
- {
- $rmonth .= " Месяцев";
- }
- if ( $rday == 0 )
- {
- $rday = "";
- }
- else if ( $rday == 1 || $rday == 21 || $rday == 31 )
- {
- $rday .= " День";
- }
- else if ( 1 < $rday && $rday < 5 )
- {
- $rday .= " Дня";
- }
- else if ( 21 < $rday && $rday < 25 )
- {
- $rday .= " Дня";
- }
- else if ( 4 < $rday && $rday < 21 )
- {
- $rday .= " Дней";
- }
- else if ( 24 < $rday && $rday < 31 )
- {
- $rday .= " Дней";
- }
- if ( $ryear == "" && $rday == "" && $rmonth == "" && $hour_reliz <= $hour_now && $hour_now < $hour_erase )
- {
- $reliz = "Релиз состоялся";
- }
- else
- {
- $reliz = $ryear." ".$rmonth." ".$rday;
- }
- if ( !$reliz && ( $reliz = " " ) )
- {
- $find[] = "{reliz}";
- $replace[] = $reliz;
- $find[] = "{reliz-date}";
- $replace[] = $reliz_date;
- }
- }
- if ( preg_match( "#({rate}|{rating}|{rate-num}|{vote-num})#ies", $value['code'] ) )
- {
- if ( $config['short_rating'] && $user_group[$member_id['user_group']]['allow_rating'] )
- {
- $rating = shortrating( $rowc['id'], $rowc['rating'], $rowc['vote_num'], 1 );
- }
- else
- {
- $rating = shortrating( $rowc['id'], $rowc['rating'], $rowc['vote_num'], 0 );
- }
- $vote_num = $rowc['vote_num'] ? $rowc['vote_num'] : 1;
- if ( $rowc['rating'] )
- {
- $rate = round( $rowc['rating'] / $vote_num, 0 );
- }
- else
- {
- $rate = 0;
- }
- $find[] = "{rate}";
- $replace[] = $rate;
- $find[] = "{vote-num}";
- $replace[] = $vote_num;
- $find[] = "{rating}";
- $replace[] = $rating;
- $find[] = "{rate-num}";
- $replace[] = $rowc['rating'];
- }
- if ( preg_match( "#({descr-short}|{descr-full}|{descr})#ies", $value['code'] ) )
- {
- $find[] = "{descr-short}";
- $replace[] = sblocks_descr( $rowc['short_story'], $value['descr_cut'] );
- $find[] = "{descr-full}";
- $replace[] = sblocks_descr( $rowc['full_story'], $value['descr_cut'] );
- $find[] = "{descr}";
- $replace[] = sblocks_descr( $rowc['short_story'].$rowc['full_story'], $value['descr_cut'] );
- }
- if ( strstr( $value['code'], "{author-link}" ) )
- {
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage(\\'subaction=userinfo&user=".urlencode( $rowc['autor'] )."\\'); return false;\" ";
- $news_page = "onclick=\"DlePage(\\'subaction=allnews&user=".urlencode( $rowc['autor'] )."\\'); return false;\" ";
- }
- else
- {
- $go_page = "";
- $news_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $go_page .= "href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/\"";
- $news_page .= "href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/news/\"";
- $tpl->set( "[day-news]", "<a href=\"".$config['http_home_url'].date( "Y/m/d/", $rowc['date'] )."\" >" );
- }
- else
- {
- $go_page .= "href=\"".$PHP_SELF."?subaction=userinfo&user=".urlencode( $rowc['autor'] )."\"";
- $news_page .= "href=\"".$PHP_SELF."?subaction=allnews&user=".urlencode( $rowc['autor'] )."\"";
- }
- $go_page = "onclick=\"return dropdownmenu(this, event, UserNewsMenu('".htmlspecialchars( $go_page )."', '".htmlspecialchars( $news_page )."','".urlencode( $rowc['autor'] )."', '".$user_group[$member_id['user_group']]['admin_editusers']."'), '170px')\" onmouseout=\"delayhidemenu()\"";
- if ( $config['allow_alt_url'] == "yes" )
- {
- $autor_link = "<a ".$go_page." href=\"".$config['http_home_url']."user/".urlencode( $rowc['autor'] )."/\">".$rowc['autor']."</a>";
- }
- else
- {
- $autor_link = "<a ".$go_page." href=\"{$PHP_SELF}?subaction=userinfo&user=".urlencode( $rowc['autor'] )."\">".$rowc['autor']."</a>";
- }
- $find[] = "{author-link}";
- $replace[] = $autor_link;
- }
- if ( 1 < $value['rows'] )
- {
- ++$colid;
- if ( $colid % $value['cols'] == 0 )
- {
- $code_temp .= "<div style=\"clear:both;heght:0;overflow:hidden;\"></div>";
- }
- }
- $find[] = "{author}";
- $replace[] = $rowc['autor'];
- $find[] = "{views}";
- $replace[] = $rowc['news_read'];
- $find[] = "{comments-num}";
- $replace[] = $rowc['comm_num'];
- $code_temp = str_replace( $find, $replace, $code_temp );
- if ( $findp )
- {
- $code_temp = preg_replace( $findp, $replacep, $code_temp );
- }
- $code .= $code_temp;
- }
- $db->free( );
- $code .= "<div style=\"clear:both;heght:0;overflow:hidden;\"></div>";
- if ( $value['title'] != "content" )
- {
- if ( $value['pages'] )
- {
- $category = $category ? $category : 0;
- $count_all = $db->super_query( "SELECT COUNT(*) as count FROM ".PREFIX."_post WHERE ".$where." approve ".$datag );
- $count_all = $count_all['count'];
- if ( 0 < $value['pages_count'] && $value['pages_count'] * $lim < $count_all )
- {
- $count_all = $value['pages_count'] * $lim;
- }
- $no_prev = false;
- $no_next = false;
- $navcode = "";
- $ajax_start = $ajax_start ? $ajax_start : 1;
- if ( isset( $ajax_start ) && $ajax_start != "" && 1 < $ajax_start )
- {
- $prev = $ajax_start - 1;
- $navcode .= "<a title=\"Назад\" onClick=\"s_page('".$value['title']."',".$prev.",'".$category."')\">".$lang['sb_nav_prev']."</a>";
- }
- else
- {
- $navcode .= "<span>".$lang['sb_nav_prev']."</span>";
- $no_prev = TRUE;
- }
- if ( $lim < $count_all )
- {
- $enpages_count = @ceil( $count_all / $lim );
- $pages = "";
- if ( $enpages_count <= 10 )
- {
- $j = 1;
- for ( ; do
- {
- $j <= $enpages_count; ++$j )
- {
- if ( $j != $ajax_start )
- {
- $pages .= "<a title=\"Страница: #".$j."\" onClick=\"s_page('".$value['title']."',".$j.",'".$category."')\">".$j."</a>";
- }
- else
- {
- $pages .= "<span>".$j."</span>";
- }
- break;
- }
- } while ( 1 );
- }
- else
- {
- $start = 1;
- $end = 7;
- $nav_prefix = "..";
- if ( 0 < $ajax_start && 4 < $ajax_start )
- {
- $start = $ajax_start - 2;
- $end = $start + 4;
- if ( $enpages_count <= $end )
- {
- $start = $enpages_count - 5;
- $end = $enpages_count - 1;
- $nav_prefix = "";
- }
- else
- {
- $nav_prefix = "..";
- }
- }
- if ( 2 <= $start )
- {
- $pages .= "<a title=\"Страница: #1\" onClick=\"s_page('".$value['title']."',1,'".$category."')\">1</a>..";
- }
- $j = $start;
- for ( ; $j <= $end; ++$j )
- {
- if ( $j != $ajax_start )
- {
- $pages .= "<a title=\"Страница: #".$j."\" onClick=\"s_page('".$value['title']."',".$j.",'".$category."')\">".$j."</a>";
- }
- else
- {
- $pages .= "<span>".$j."</span>";
- }
- }
- if ( $ajax_start != $enpages_count )
- {
- $pages .= $nav_prefix."<a title=\"Страница: #".$enpages_count."\" onClick=\"s_page('".$value['title']."',".$enpages_count.",'".$category."')\">".$enpages_count."</a>";
- }
- else
- {
- $pages .= $nav_prefix.( "<span>".$enpages_count."</span>" );
- }
- }
- }
- $navcode .= $pages;
- if ( $lim && $lim < $count_all && $ajax_start * $lim < $count_all )
- {
- $next_page = $ajax_start + 1;
- $navcode .= "<a title=\"Вперед\" onClick=\"s_page('".$value['title']."',".$next_page.",'".$category."')\">".$lang['sb_nav_next']."</a>";
- }
- else
- {
- $no_next = TRUE;
- $navcode .= "<span>".$lang['sb_nav_next']."</span>";
- }
- if ( !$no_prev && !$no_next )
- {
- if ( !$value['custom_style'] )
- {
- $code .= "<div align=\"center\" class=\"snav_".$value['title']."\">".$navcode."</div>";
- }
- else
- {
- $code .= "<div align=\"center\" class=\"".$value['custom_style']."\">".$navcode."</div>";
- }
- }
- }
- }
- else
- {
- $tpl->load_template( "navigation.tpl" );
- $count_all = $db->super_query( "SELECT COUNT(*) as count FROM ".PREFIX."_post WHERE ".$where." approve ".$datag );
- $count_all = $count_all['count'];
- $no_prev = false;
- $no_next = false;
- if ( isset( $cstart ) && $cstart != "" && 1 < $cstart )
- {
- $prev = $cstart - 1;
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=".$prev."&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $prev_page = $url_page."/page/".$prev."/";
- $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a ".$go_page."href=\"".$prev_page."\">\\1</a>" );
- }
- else
- {
- $prev_page = $PHP_SELF."?cstart=".$prev."&".$user_query;
- $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<a ".$go_page."href=\"".$prev_page."\">\\1</a>" );
- }
- }
- else
- {
- $tpl->set_block( "'\\[prev-link\\](.*?)\\[/prev-link\\]'si", "<span>\\1</span>" );
- $no_prev = TRUE;
- }
- if ( $lim )
- {
- if ( $lim < $count_all )
- {
- $enpages_count = @ceil( $count_all / $lim );
- $pages = "";
- if ( $enpages_count <= 10 )
- {
- $j = 1;
- for ( ; do
- {
- $j <= $enpages_count; ++$j )
- {
- if ( $j != $cstart )
- {
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=".$j."&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $pages .= "<a ".$go_page."href=\"".$url_page."/page/".$j.( "/\">".$j."</a> " );
- }
- else
- {
- $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$j}&{$user_query}\">{$j}</a> ";
- }
- }
- else
- {
- $pages .= "<span>".$j."</span> ";
- }
- break;
- }
- } while ( 1 );
- }
- else
- {
- $start = 1;
- $end = 10;
- if ( $lang['nav_trennen'] )
- {
- $nav_trennen = "<span class=\"nav_ext\">".$lang['nav_trennen']."</span> ";
- }
- else
- {
- $nav_trennen = "... ";
- }
- $nav_prefix = $nav_trennen;
- if ( 0 < $cstart && 5 < $cstart )
- {
- $start = $cstart - 4;
- $end = $start + 8;
- if ( $enpages_count <= $end )
- {
- $start = $enpages_count - 9;
- $end = $enpages_count - 1;
- $nav_prefix = "";
- }
- else
- {
- $nav_prefix = $nav_trennen;
- }
- }
- if ( 2 <= $start )
- {
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=1&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $pages .= "<a ".$go_page."href=\"".$url_page.( "/page/1/\">1</a> ".$nav_trennen." " );
- }
- else
- {
- $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart=1&{$user_query}\">1</a> {$nav_trennen} ";
- }
- }
- $j = $start;
- for ( ; $j <= $end; ++$j )
- {
- if ( $j != $cstart )
- {
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=".$j."&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $pages .= "<a ".$go_page."href=\"".$url_page."/page/".$j.( "/\">".$j."</a> " );
- }
- else
- {
- $pages .= "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$j}&{$user_query}\">{$j}</a> ";
- }
- }
- else
- {
- $pages .= "<span>".$j."</span> ";
- }
- }
- if ( $cstart != $enpages_count )
- {
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=".$enpages_count."&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $pages .= $nav_prefix.( "<a ".$go_page."href=\"" ).$url_page.( "/page/".$enpages_count."/\">{$enpages_count}</a>" );
- }
- else
- {
- $pages .= $nav_prefix.( "<a ".$go_page."href=\"{$PHP_SELF}?cstart={$enpages_count}&{$user_query}\">{$enpages_count}</a>" );
- }
- }
- else
- {
- $pages .= "<span>".$enpages_count."</span> ";
- }
- }
- }
- $tpl->set( "{pages}", $pages );
- if ( $lim && $lim < $count_all && $cstart * $lim < $count_all )
- {
- $next_page = $cstart + 1;
- if ( $config['ajax'] )
- {
- $go_page = "onclick=\"DlePage('cstart=".$next_page."&".$user_query."'); return false;\" ";
- }
- else
- {
- $go_page = "";
- }
- if ( $config['allow_alt_url'] == "yes" )
- {
- $next = $url_page."/page/".$next_page."/";
- $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a ".$go_page."href=\"".$next."\">\\1</a>" );
- }
- else
- {
- $next = $PHP_SELF."?cstart=".$next_page."&".$user_query;
- $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<a ".$go_page."href=\"".$next."\">\\1</a>" );
- }
- }
- }
- else
- {
- $tpl->set_block( "'\\[next-link\\](.*?)\\[/next-link\\]'si", "<span>\\1</span>" );
- $no_next = TRUE;
- }
- if ( !$no_prev && !$no_next )
- {
- $tpl->compile( "navigation_content" );
- $code .= $tpl->result['navigation_content'];
- }
- $tpl->clear( );
- }
- $code .= "</div>";
- if ( $value['title'] == "content" )
- {
- do
- {
- if ( $do == "lastnews" )
- {
- $cstop = true;
- create_cache( "sblocks_content_lastnews_page_".$cstart, $code );
- }
- if ( $do == "tags" )
- {
- $cstop = true;
- create_cache( "sblocks_content_tags_page_".$cstart, $code );
- }
- if ( $subaction == "allnews" )
- {
- $cstop = true;
- create_cache( "sblocks_content_allnews_page_".$cstart, $code );
- }
- if ( $subaction == "newposts" )
- {
- $cstop = true;
- create_cache( "sblocks_content_newposts_page_".$cstart, $code );
- }
- if ( $catalog != "" )
- {
- $cstop = true;
- create_cache( "sblocks_content_catalog_".$catalog."_page_".$cstart, $code );
- }
- if ( $year != "" && $month == "" && $day == "" )
- {
- $cstop = true;
- create_cache( "sblocks_content_calendar_".$year."_page_".$cstart, $code );
- }
- if ( $year != "" && $month != "" && $day == "" )
- {
- $cstop = true;
- create_cache( "sblocks_content_calendar_".$year."_".$month."_page_".$cstart, $code );
- }
- if ( $year != "" && $month != "" && $day != "" && $subaction == "" )
- {
- $cstop = true;
- create_cache( "sblocks_content_calendar_".$year."_".$month."_".$day."_page_".$cstart, $code );
- }
- if ( !$cstop )
- {
- if ( $category_id && !$newsid )
- {
- create_cache( "sblocks_content_category_".$cat_info[$category_id]['alt_name']."_page_".$cstart, $code );
- }
- else
- {
- if ( $sblocks_content && !$newsid )
- {
- create_cache( "sblocks_content_page_".$cstart, $code );
- break;
- break;
- }
- }
- }
- else if ( !$value['fromcat'] && !$category_id )
- {
- }
- else if ( $newsid )
- {
- break;
- }
- create_cache( "sblocks_".$value['title']."_category_".$cat_info[$category_id]['alt_name'].$ajax_prefix, $code );
- } while ( 0 );
- }
- else
- {
- create_cache( "sblocks_".$value['title'].$ajax_prefix, $code );
- }
- }
- }
- $sbl[$value['title']][] = $code."\r<!--Время генерации блока: ".( sblocks_time( ) - $sblocks_start )." сек. S-Blocks by Sander-->\r";
- }
- }
- }
- }
- foreach ( $sbl as $key => $value )
- {
- $sb_key = array_rand( $sbl[$key] );
- $sbl[$key] = $sbl[$key][$sb_key];
- }
- $sblocks = $sbl;
- $sbl = array( );
- unset( $sbl );
- if ( $sblocks['content'] && $sblocks_content && !$newsid )
- {
- $tpl->result['content'] = $sblocks['content'];
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment