","|",":","'","\"","#","№",";","$","%","^","&","*","(",")","@","[","]","{","}","~","«","»","\\","/"),"",$job); if ( !$job AND !$_POST[text] ) $job = "index"; if ( $_POST[text] && $_POST[bnic] ) // if there's a comment form request - do the "talk" job $job = "talk"; // --------------------------------------------------------------------------------------------------- // general part (similar for all pages, opening) $now = time(); // get current time (to filter the blog posts by time) $today = make_date(date("j M Y",$now)); // set the current time (can use it on blog pages) $searchit = "
"; $tagscloud = file_get_contents($templpath."tagscloud.inc"); // open SQLite db file $db = sqlite_open("$blogbase"); // making the background $bgroundraw = sqlite_fetch_single(sqlite_query($db,"SELECT text FROM pages WHERE num = '11';")); // get text from DB preg_match("/http.*jpg/", $bgroundraw, $bgroundarray); $bground = $bgroundarray[0]; if ( !strlen($bground) ) $bground = "http://le-to.com/images/bg-color.jpg"; // making the page texts $footer = sqlite_fetch_single(sqlite_query($db,"SELECT text FROM pages WHERE num = '6';")); // get text from DB $footer = format_bbcodes($footer); // security check $secured = 0; // default value (not secured) if ( isset($_COOKIE['hash']) ) { $checkpass = $_COOKIE['hash']; $checkname = $_COOKIE['bnic']; $loginexists = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM guests WHERE id = '$checkpass';")); if ( !$loginexists ) { if ( $checkpass != md5($adminpass) ) { setcookie("hash","",time()-3600); // delete cookie setcookie("bnic","",time()-3600); // delete cookie } } else $secured = 1; // default value (not secured) } if ( $secured ) $registerlink = "Регистрация"; else $registerlink = "Регистрация"; // making footer $foot1base = sqlite_array_query($db, "SELECT file,title FROM blog WHERE ( date < '$now' AND ( status IS NULL OR status != 'draft' ) ) ORDER BY date DESC LIMIT 5;"); foreach ($foot1base as $entry) { $desc = format_bbcodes($entry['title']); $blogentry = $entry['file']; $blogentry = $blogpath.$blogdir.$blogentry.".html"; $foot1 = $foot1."
$desc
"; } $foot2text = format_bbcodes(sqlite_fetch_single(sqlite_query($db,"SELECT text FROM pages WHERE num = '10';"))); $foot2rows = explode("
", $foot2text); //$foot2rows = preg_split('/\R/', $foot2text); foreach ( $foot2rows as $item ) { if ( $item != "" ) $foot2 = $foot2."
".$item."
"; } $foot2 = str_replace("", $foot3text); //$foot2rows = preg_split('/\R/', $foot2text); foreach ( $foot3rows as $item ) { if ( $item != "" ) $foot3 = $foot3."
".$item."
"; } $result = sqlite_array_query($db, "SELECT id,name FROM comments WHERE date < '$now' ORDER BY date DESC LIMIT $lastcomnum;"); foreach ($result as $entry) { $name = $entry['name']; $postentry = $entry['id']; $posttitle = sqlite_fetch_single(sqlite_query($db,"SELECT title FROM blog WHERE id = '$postentry';")); $posttitle = format_bbcodes($posttitle); $blogentry = sqlite_fetch_single(sqlite_query($db,"SELECT file FROM blog WHERE id = '$postentry';")); $blogentry = $blogpath.$blogdir.$blogentry; $lastcoms = $lastcoms."
  • $name оставил комментарий к записи $posttitle
  • "; } $result = sqlite_array_query($db, "SELECT date,file,desc FROM blog WHERE date < '$now' ORDER BY date DESC LIMIT $lastposnum;"); foreach ($result as $entry) { $showdate = $entry['date']; $desc = format_bbcodes($entry['desc']); $blogentry = $entry['file']; $blogentry = $blogpath.$blogdir.$blogentry; $showdate = date("d/m/y",$showdate); $post = trunc_title($desc); $lastpost = $lastpost."

    [$showdate] $post $cutstr

    "; } $cats_query = sqlite_array_query($db,"SELECT * FROM category;"); // make array of all the categories foreach ( $cats_query as $entry ) if ( sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM blog WHERE category LIKE '%".$entry['id']."%' AND date < '$now';")) ) // if category not empty $categorize = $categorize."
  • ".$entry['name']."
  • \n"; if ( $photozoom ) $jsheader = " "; // if $photozoom (highslide effect) add required js code to page header // general part (similar for all pages, ending) // --------------------------------------------------------------------------------------------------- // if job = "index" (show index page and subpages) if ( $job == "index" ) { // $pagetitle = $blogtitl.". Все новости, события и акции - в нашем блоге!"; // $pagedesc = "Веранда 32.05. Всё что вы хотели знать о дополнительном дне весны, вы прочитаете в нашем блоге. Right here, right now!"; // $pagekeys = "Веранда 32.05, Сад Эрмитаж, кафе, бар, ночной клуб, специальные акции, новости"; $datasize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM blog WHERE date < '$now';")); // get count of records by time $pages = ceil($datasize/$per_page); $showpage = $_GET[page]; if ( !$showpage ) // if not defined - it will be index page $showpage = 0; $showpage_num_only = preg_replace('/\D/','',$showpage); // remove all non-numeric characters // if ( $showpage != $showpage_num_only OR $showpage >= $pages ) { // header("HTTP/1.1 404 Not Found"); // if there was non-numeric symbols in request OR page number is out of range - give 404 error // exit(); // } $sql = "SELECT * FROM blog WHERE date < '$now' ORDER BY date DESC;"; $datafile = sqlite_query($db, $sql); if ( $datasize == 0 ) echo "

    В блоге нет записей.

    "; $counter1=0; $counter2=$datasize-$showpage*$per_page-1; sqlite_seek($datafile,$showpage*$per_page); while ( $counter1 < $per_page && $counter2 >= 0 && $entry = sqlite_fetch_array($datafile) ) { // walking through blog posts $showpagehash = $entry['id']; $showdate = $entry['date']; $text = format_bbcodes($entry['desc']); $fulltext = format_bbcodes($entry['fulldesc']); $photo = $entry['image']; $desc = format_bbcodes($entry['title']); $blogentry = $entry['file']; $tags = format_bbcodes($entry['keys']); $cats = format_bbcodes($entry['category']); $blogentry = $blogpath.$blogdir.$blogentry.".html"; $tagstring = ""; // clear the tags string $comsize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM comments WHERE id='$showpagehash' AND date < '$now';")); if ( !$comsize ) $comsize = 0; $showdate = make_date(date("j M Y",$showdate)); $tagarray = explode(",",$tags); // making a tags string $tagssize = count($tagarray); $counter3 = 0; while ( $counter3 < $tagssize ) { $tagstring = $tagstring."$tagarray[$counter3] "; $counter3++; } $catarray = explode(",",$cats); // making a tags string if ( $catarray[0] != "" ) $category = "".$catarray[0]."      "; else $category = "Без категории      "; $textuntouched = $text; // making the albums if ( preg_match("/\[album=(.*?)\]/iu", $text, $matches) ) { $albumn = sqlite_fetch_single(sqlite_query($db,"SELECT title FROM album WHERE num='".$matches[1]."';")); $albumc = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM photos WHERE album='".$matches[1]."';")); $albumq = sqlite_array_query($db,"SELECT * FROM photos WHERE album='".$matches[1]."' ORDER BY sort DESC;"); if ( $albumn AND $albumc ) { // if album exists and there are pics inside $albumstr = "
    Альбом \"".format_bbcodes($albumn)."\" ($albumc фотографий):
    "; } // making the blogroll element "post" // $output = $output."
    \n //

    $desc

    \n //
    $showdate
    \n"; $output = $output."\n
    \n

    $desc

    \n

    $showdate

    \n
    \n

    ${text}… Подробнее!

    \n
    \n
    \n \n"; $counter1++; $counter2--; } $apreloader = "
    ".$apreload."
    "; $albumstrhidden = "
    ".$albumstrhidden."
    "; // and here comes the footer navigation $footnavi = "
    "; if ( $showpage < $pages-1 ) { $page = $showpage+1; $goto = "${blogpath}page/".$page; $footnavi = $footnavi."$post_before"; } $footnavi = $footnavi." 
    "; /* $footnavi = $footnavi."
    "; if ( $navidrop AND $pages > 2 ) { // if dropdown navigation IS enabled and there's enough pages $footnavi = $footnavi.""; $footnavi = $footnavi."
    "; } else $footnavi = $footnavi." "; // else make $footnavi an empty page $footnavi = $footnavi."
    "; */ $footnavi = $footnavi."
     "; if ( $showpage > 0 ) { $page = $showpage-1; $goto = "${blogpath}page/".$page; if ( $page != 0 ) $footnavi = $footnavi." $post_after"; else $footnavi = $footnavi." $post_after"; } $footnavi = $footnavi."
    \n
    \n"; $footpage = ""; if ( $navipage AND $pages > 2 ) { // if all-pages navigation IS enabled and there's enough pages $footpage = "
    $navipage
    "; for ( $a=0; $a<$pages; $a++ ) { if ( $a == 0 && $showpage != 0 ) $footpage = $footpage."$navipage_up "; if ( $a == 0 && $showpage == 0 ) $footpage = $footpage.$navipage_up." "; if ( $a != $showpage && $a != 0 ) $footpage = $footpage."".$a." "; if ( $a == $showpage && $a != 0 ) $footpage = $footpage.$a." "; } $footpage = $footpage."
    "; } print eval(get_template('blog')); } // --------------------------------------------------------------------------------------------------- // if job = "show" (show specific post by id) if ( $job == "show" ) { session_start(); $showpage = $_GET[id]; $showpage = trim($showpage); $showpage = mb_strtolower($showpage,"utf-8"); $showpage = strip_tags($showpage); $showpage = stripslashes($showpage); $showpagehash = md5($showpage); $adminhere = 0; $secured = 0; $errflag = 1; // error flag: true (default) $output = ""; $datafile = sqlite_fetch_array(sqlite_query($db,"SELECT * FROM blog WHERE id='$showpagehash';")); if ( $datafile ) { // blog entry exists - show it $errflag = 0; // yes, this blog entry exists, no error $showdate = $datafile['date']; $photo = $datafile['image']; $desc = format_bbcodes($datafile['title']); $burl = $datafile['file']; $tags = format_bbcodes($datafile['keys']); $cats = format_bbcodes($datafile['category']); $text = format_bbcodes($datafile['fulldesc']); $status = $datafile['status']; $pagename = $datafile['title']; $tagstring = ""; // clear the tags string $tagarray = explode(",",$tags); $tagarray_compare = explode(",",str_replace(" ",",",$tags)); $tagssize = count($tagarray); $counter3 = 0; while ( $counter3 < $tagssize ) { $tagstring = $tagstring."$tagarray[$counter3] "; $counter3++; } $catarray = explode(",",$cats); // making a tags string if ( $catarray[0] != "" ) $category = "".$catarray[0]."      "; else $category = "Без категории      "; $pagetitle = "$desc"." - в блоге свадебного агентства Leto"; $pagedesc = trunc_title($text,200)." "; $pagekeys = $tags.", Leto, свадебное агентство, wedding agency, events, организация корпоративов и праздников"; if ( $adminname[0] ) { // if admin name is set if ( $adminname[1] ) { // if admin title is set if ( $adminname[2] AND $adminname[3] ) // if admin suffix decoration are set $admin_suffix = " ".$adminname[2].$adminname[1].$adminname[3]; else $admin_suffix = " - ".$adminname[1]; // or use default "name - title" } $adminname[4] = $adminname[0].$admin_suffix; // make admin name as "name [title]" (for example) } $lengthstr = explode("%%",$lengthover); $javascrp = "\n"; $editpost = ""; if ( isset($_COOKIE['hash']) AND md5($adminpass) === $_COOKIE['hash'] ) // if cookie is set and admin password is OK $editpost = " "; $showdate = make_date(date("j M Y",$showdate)); if ( preg_match("/\[album=(.*?)\]/iu", $text, $matches) ) { $albumn = sqlite_fetch_single(sqlite_query($db,"SELECT title FROM album WHERE num='".$matches[1]."';")); $albumc = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM photos WHERE album='".$matches[1]."';")); $albumq = sqlite_array_query($db,"SELECT * FROM photos WHERE album='".$matches[1]."' ORDER BY sort DESC;"); if ( $albumn AND $albumc ) { // if album exists and there are pics inside // $albumstr = "Альбом \"".format_bbcodes($albumn)."\" (всего $albumc фотографий):
    "; $albumstr = "
    Альбом \"".format_bbcodes($albumn)."\" (всего $albumc фотографий):
    "; } $output .= '
    Главная / Блог / ' . $desc . '
    '; $output = $output."

    Блог → $desc

    $showdate

    $editpost
    $text

    "; // $output = $output."
    \n //

    БЛОГ 32.05 → $desc

    \n //
    Теги: $tagstring
    \n //
    $showdate
    \n // $editpost //

    $text

    \n //
    \n"; } else { if ( !$stealthmode ) $output = $output."

    Ошибка! В блоге нет такой записи!

    "; else { // if hidden mode is active - implement 404 Error header("HTTP/1.1 404 Not Found"); exit(); } } // looking for similar posts here $counter1 = 1; $tags = ""; $result = sqlite_query($db,"SELECT id,file,title,keys FROM blog WHERE date < '$now';"); if ( $simpostnum > 0 ) { // if "similar posts" module IS active while ( $entry = sqlite_fetch_array($result) ) { $showid = $entry['id']; $eurl = $entry['file']; $desc = format_bbcodes($entry['title']); $tags = format_bbcodes($entry['keys']); $tags = str_replace(" ",",",$tags); if ( $showid != $showpagehash ) { // do not show this blog entry as similar one $tags2compare = explode(",",$tags); $res[$counter1][0] = count(array_intersect($tagarray_compare,$tags2compare)); $res[$counter1][1] = $eurl; $res[$counter1][2] = $desc; } $counter1++; } arsort($res); reset($res); $simposts = "
    "; $simposts = $simposts."

    ВАМ МОЖЕТ ПОНРАВИТЬСЯ:

    \n
      \n"; $counter1 = 0; while ( $counter1 < $simpostnum ) { $a_spice = each($res); if ( $a_spice !== false ) $simposts = $simposts."
    • ".$a_spice[value][2]."
    • \n"; $counter1++; } $simposts = $simposts."
    \n
    \n"; $simposts = $simposts."
    "; } $comments = sqlite_array_query($db,"SELECT * FROM comments WHERE ( id='$showpagehash' AND date < '$now' ) ORDER BY date DESC"); $comsize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM comments WHERE id='$showpagehash' AND date < '$now'")); $counter = 0; $postcoms = "

    КОММЕНТАРИИ


    \n"; if ( !$comsize ) $postcoms = $postcoms."
    ".$comtextno."
    "; // error - no comments for this blog entry else { $postcoms = $postcoms.""; foreach ($comments as $entry) { $showdate = $entry['date']; $name = $entry['name']; $text = format_bbcodes($entry['entry']); $comid = $entry['comid']; $date = make_date(date("j M Y",$showdate)); $date = $date."
    ".date("H:i",$showdate); if ( mb_strlen($name,"utf-8") > 30 ) $name = mb_substr($name,0,30,"utf-8"); // make long name a little shorter $edittalk = ""; if ( isset($_COOKIE['hash']) AND md5($adminpass) === $_COOKIE['hash'] ) // if cookie is set and admin password is OK $edittalk = "  "; if ( $counter%2 != 0 ) $comstyle = "#b9ab11"; else $comstyle = "#c2b312"; $postcoms = $postcoms."
    $name
    $date $edittalk
    $text
    \n"; $counter++; } } $postcoms = $postcoms."
    "; if ( $ranpostnum ) { // if random posts module IS active $result = sqlite_array_query($db, "SELECT * FROM blog WHERE ( date < '$now' AND image != '' AND id != '$showpagehash' ) ORDER BY RANDOM() LIMIT $ranpostnum;"); $tdcell = 100/$ranpostnum; // table cell width $randpost = ""; foreach ($result as $entry) { $title = $entry['title']; $blogentry = $entry['file']; $blogimage = $entry['image']; $title = str_replace(array("&squot;","&dquot;"),array("'","""),$title); $blogentry = $blogpath.$blogdir.$blogentry; $blogimage = $blogpath.$thumbsdir.$blogimage; $randpost = $randpost.""; } $randpost = $randpost."

    $title
    \n$divider\n"; } // make comments form html if ( !$errflag ) { // there is a blog entry, can post feedback form $comsform = "
    \n"; if ( isset($_COOKIE['bnic']) ) { $comsform = $comsform."Ваше имя:


    "; $comsform = $comsform.""; } else { $comsform = $comsform."Ваше имя:

    "; $comsform = $comsform."Ваш e-mail:


    "; } $comsform = $comsform."Текст:


    "; if (!isset($_COOKIE['bnic'])) { $comsform = $comsform."
    "; $comsform = $comsform."Введите строку с картинки:


    "; } $comsform = $comsform."
    \n"; } if ( stripos($status,"closed") !== false ) // if comments are closed for this post $comsform = "".$comtextof; print eval(get_template('blog-single')); } // --------------------------------------------------------------------------------------------------- // if job = "album" (show specific album by id) if ( $job == "album" ) { $showpage = $_GET[id]; $showpage = trim($showpage); $showpage = mb_strtolower($showpage,"utf-8"); $showpage = strip_tags($showpage); $showpage = stripslashes($showpage); // $showpagehash = md5($showpage); $adminhere = 0; $secured = 0; $errflag = 1; // error flag: true (default) $output = ""; $datafile = sqlite_fetch_single(sqlite_query($db,"SELECT * FROM album WHERE num='$showpage';")); if ( $datafile ) { // blog entry exists - show it $errflag = 0; // yes, this blog entry exists, no error // $showdate = $datafile['date']; // $photo = $datafile['image']; // $desc = mb_strtoupper(format_bbcodes($datafile['title']), 'UTF-8'); // $burl = $datafile['file']; // $tags = format_bbcodes($datafile['keys']); // $cats = format_bbcodes($datafile['category']); // $text = format_bbcodes($datafile['fulldesc']); // $status = $datafile['status']; // $pagename = $datafile['title']; // $tagstring = ""; // clear the tags string // $tagarray = explode(",",$tags); // $tagarray_compare = explode(",",str_replace(" ",",",$tags)); // $tagssize = count($tagarray); // $counter3 = 0; // while ( $counter3 < $tagssize ) { // $tagstring = $tagstring."$tagarray[$counter3] "; // $counter3++; // } // $catarray = explode(",",$cats); // making a tags string // if ( $catarray[0] != "" ) // $category = "".$catarray[0]."      "; // else // $category = "Без категории      "; // $pagetitle = "$desc"." - в блоге Веранды 32.05"; // $pagedesc = trunc_title($text,200)." "; // $pagekeys = $tags.",кафе, Сад Эрмитаж, где перекусить в центре, еда на Чеховской"; // if ( $adminname[0] ) { // if admin name is set if ( $adminname[1] ) { // if admin title is set if ( $adminname[2] AND $adminname[3] ) // if admin suffix decoration are set $admin_suffix = " ".$adminname[2].$adminname[1].$adminname[3]; else $admin_suffix = " - ".$adminname[1]; // or use default "name - title" } $adminname[4] = $adminname[0].$admin_suffix; // make admin name as "name [title]" (for example) } // $lengthstr = explode("%%",$lengthover); // $javascrp = "\n"; // $editpost = ""; // if ( isset($_COOKIE['hash']) AND md5($adminpass) === $_COOKIE['hash'] ) // if cookie is set and admin password is OK // $editpost = "\n
     "; // $showdate = make_date(date("j M Y",$showdate)); if ( 1 ) { $albumn = sqlite_fetch_single(sqlite_query($db,"SELECT title FROM album WHERE num='".$showpage."';")); $albumc = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM photos WHERE album='".$showpage."';")); $albumq = sqlite_array_query($db,"SELECT * FROM photos WHERE album='".$showpage."' ORDER BY sort ASC;"); if ( $albumn AND $albumc ) { // if album exists and there are pics inside // $albumstr = "Альбом \"".format_bbcodes($albumn)."\" (всего $albumc фотографий):
    "; $albumstr = "
    Альбом \"".format_bbcodes($albumn)."\" (всего $albumc фотографий):
    "; } $output = "

    $albumstr

    Вернуться к альбомам
    "; // $output = $output."
    \n //

    БЛОГ 32.05 → $desc

    \n //
    Теги: $tagstring
    \n //
    $showdate
    \n // $editpost //

    $text

    \n //
    \n"; } else { if ( !$stealthmode ) $output = $output."

    Ошибка! Нет такого альбома!

    "; else { // if hidden mode is active - implement 404 Error header("HTTP/1.1 404 Not Found"); exit(); } } print eval(get_template('album')); } // --------------------------------------------------------------------------------------------------- // if job = "cats" (show blog posts by category name) elseif ( $job == "cats" ) { $showpage = rawurldecode($_GET[id]); // which category to search for $showpage = trim($showpage); $showpage = mb_strtolower($showpage,"utf-8"); $showpage = strip_tags($showpage); $showpage = stripslashes($showpage); $showpage = str_replace(array("?","!",".","<",">","|",":","'","\"","#","№",";","$","%","^","&","*","(",")","@","[","]","{","}","~","«","»","\\","/"),"",$showpage); if ( mb_strlen($showpage,"utf-8") > 100 ) $showpage=mb_substr($showpage,0,100,"utf-8"); // cut category string (for security reasons) $datasize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM blog WHERE php('tagsmatch',category,'$showpage') = 1 AND date < '$now';")); // get count of records by time $result = sqlite_array_query($db, "SELECT * FROM blog WHERE php('tagsmatch',category,'$showpage') = 1 AND date < '$now' ORDER BY date DESC;"); if ( $datasize AND $showpage != "" ) { // there are entries with this category and it's not empty foreach ($result as $entry) { $showpagehash = $entry['id']; $showdate = $entry['date']; $text = format_bbcodes($entry['desc']); $desc = format_bbcodes($entry['title']); $blogentry = $entry['file']; $tags = $entry['keys']; $blogentry = $blogpath.$blogdir.$blogentry; $tagstring = ""; // clear the tags string $comsize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM comments WHERE id='$showpagehash' AND date < '$now';")); if ( !$comsize ) $comsize = 0; $showdate = make_date(date("j M Y",$showdate)); $tagarray = explode(",",$tags); $tagssize = count($tagarray); $counter3 = 0; while ( $counter3 < $tagssize ) { $tagstring = $tagstring."$tagarray[$counter3] "; $counter3++; } $text = format_bbcodes($text); $text = strip_tags($text); $text = stripslashes($text); $text = trunc_title($text,200); $output = $output."

    $desc

    Запись от $showdate
    Автор: ".$adminname[0]."

    "; } } else { if ( !$stealthmode ) $output = $output."

    Ошибка! В блоге $blogtitl нет записей в указанной категории!

    "; else { // hidden mode is active - implement 404 Error header("HTTP/1.1 404 Not Found"); exit(); } } if ( $datasize != 0 ) $howmany = " (".$datasize.")"; $pagetitle = "Записи в категории: ${showpage} ${howmany}. Всё о блоговых CMS'ках - на сайте $blogtitl"; $pagedesc = trunc_title($text,200)." "; $pagekeys = $tags.",блоговые CMS,простой движок блога,блог без MySQL,лёгкий скрипт для блога,ЦМС для блога,простой PHP скрипт блога без базы данных"; print eval(get_template('cats')); } // --------------------------------------------------------------------------------------------------- // if job = "tags" (show blog posts by tag name) elseif ( $job == "tags" ) { $showpage = rawurldecode($_GET[id]); // which tags to search for $showpage = trim($showpage); $showpage = mb_strtolower($showpage,"utf-8"); $showpage = strip_tags($showpage); $showpage = stripslashes($showpage); $showpage = str_replace(array("?","!",".","<",">","|",":","'","\"","#","№",";","$","%","^","&","*","(",")","@","[","]","{","}","~","«","»","\\","/"),"",$showpage); if ( mb_strlen($showpage,"utf-8") > 100 ) $showpage=mb_substr($showpage,0,100,"utf-8"); // cut tags string (for security reason) $datasize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM blog WHERE php('tagsmatch',keys,'$showpage') = 1 AND date < '$now';")); // get count of records by time $result = sqlite_array_query($db, "SELECT * FROM blog WHERE php('tagsmatch',keys,'$showpage') = 1 AND date < '$now' ORDER BY date DESC;"); $output = ""; $alltags = ""; if ( $datasize AND $showpage != "" ) { // there are entries with this tag and it's not empty foreach ($result as $entry) { $showpagehash = $entry['id']; $showdate = $entry['date']; $text = format_bbcodes($entry['desc']); $fulltext = format_bbcodes($entry['fulldesc']); $desc = mb_strtoupper(format_bbcodes($entry['title']), 'UTF-8'); $blogentry = $entry['file']; $tags = $entry['keys']; $blogentry = $blogpath.$blogdir.$blogentry; $tagstring = ""; // clear the tags string $comsize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM comments WHERE id='$showpagehash' AND date < '$now';")); if ( !$comsize ) $comsize = 0; $showdate = make_date(date("j M Y",$showdate)); $tagarray = explode(",",$tags); $tagssize = count($tagarray); $counter3 = 0; while ( $counter3 < $tagssize ) { $tagstring = $tagstring."$tagarray[$counter3] "; $counter3++; } // $text = strip_tags($text); // $text = stripslashes($text); // $text = trunc_title($text,200); $textuntouched = $text; // making the albums if ( preg_match("/\[album=(.*?)\]/iu", $text, $matches) ) { $albumn = sqlite_fetch_single(sqlite_query($db,"SELECT title FROM album WHERE num='".$matches[1]."';")); $albumc = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM photos WHERE album='".$matches[1]."';")); $albumq = sqlite_array_query($db,"SELECT * FROM photos WHERE album='".$matches[1]."' ORDER BY sort DESC;"); if ( $albumn AND $albumc ) { // if album exists and there are pics inside $albumstr = "Альбом \"".format_bbcodes($albumn)."\" ($albumc фотографий):
    "; $alcount = 1; foreach ($albumq as $entry) { $aimage = $entry['image']; $athumb = $entry['thumb']; if ( $alcount <= 3 ) { switch ($alcount) { case "1": $albumstr = $albumstr."\"\""; $apreload = $apreload.""; break; case "2": $albumstr = $albumstr."\"\""; $apreload = $apreload.""; break; /*Завершаем выполнение*/ case "3": $albumstr = $albumstr."\"\""; $apreload = $apreload.""; break; /*Завершаем выполнение*/ } } else { $albumstrhidden = $albumstrhidden."\"\""; $apreload = $apreload.""; } $alcount++; } $text = str_replace($matches[0],$albumstr,$text); } else $text = str_replace($matches[0],"",$text); } // making the blogroll element "post" $output = $output."
    \n

    $desc

    \n
    $showdate
    \n"; if ( $textuntouched == $fulltext ) $output = $output."

    $text"; else $output = $output."

    $text... Читать дальше!"; $output = $output."

    \n
    \n"; // $output = $output."
    \n //

    $desc

    \n //
    $showdate
    \n //

    $text... Читать дальше!\n //

    \n //
    \n"; } } else { if ( !$stealthmode ) $output = $output."

    Ошибка! В блоге $blogtitl нет записей с таким тегом!

    "; else { // hidden mode is active - implement 404 Error header("HTTP/1.1 404 Not Found"); exit(); } } $apreloader = "
    ".$apreload."
    "; $albumstrhidden = "
    ".$albumstrhidden."
    "; if ( $datasize != 0 ) $howmany = " (".$datasize.")"; $pagetitle = "Записи с тегом: ${showpage} ${howmany}. Всё о блоговых CMS'ках - на сайте $blogtitl"; $pagedesc = trunc_title($text,200)." "; $pagekeys = $tags.",скрипт блога без базы данных,flatfile blog cms,легкий движок дневника,блог на SQLite,скрипт блога без MySQL,блог без мускуля,заметки о cms"; print eval(get_template('tags')); } // --------------------------------------------------------------------------------------------------- // if job = "talk" (leave comment on some blog post) elseif ( $job == "talk" ) { session_start(); // GLOBAL $_SERVER['HTTP_REFERER']; $name = $_POST[bnic]; $mail = $_POST[bmai]; $text = $_POST[text]; $file = $_POST[entryid]; if ( $stealthmode AND !$text ) { // hidden mode is active - implement 404 Error header("HTTP/1.1 404 Not Found"); exit(); } $noneedcaptcha = 0; $date = time(); if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']) { // if captcha is OK $noneedcaptcha = 1; // captcha is OK flag unset($_SESSION['captcha_keystring']); } if (!isset($_COOKIE['bnic'])) { if ($noneedcaptcha != 0) { // if cookie not set and captcha is OK - set cookie setcookie('bnic',$name,0x6FFFFFFF); setcookie('bmai',$mail,0x6FFFFFFF); } else $noneedcaptcha = 0; // if cookie not set and captcha is WRONG } else { $mail = $_COOKIE['bmai']; $noneedcaptcha = 1; // captcha not needed - cookie found } function nl2br_limit($string, $num){ $dirty = preg_replace('/\r/', '', $string); $clean = preg_replace('/\n{4,}/', str_repeat('
    ', $num), preg_replace('/\r/', '', $dirty)); return nl2br($clean); } if ($noneedcaptcha != 0 ) { // if captcha is OK or not needed - write comment if ( !$name ) { $name="Гость"; } // if ( $text AND preg_match('/[а-Я]+/is',$text) ) { // if text field is not empty - do the work (else - do nothing) if ( $text AND preg_match('/[а-Я]+/is',$text) ) { $name = strip_tags($name); $name = process_text($name); $text = format_bbcodes($text); $text = strip_tags($text); $text = nl2br_limit($text,'2'); $text = process_text($text); $texthash = md5($text); // make the comment id (unique) if ( $adminname[0] ) { // if admin name is set if ( $adminname[1] ) { // if admin title is set if ( $adminname[2] AND $adminname[3] ) // if admin suffix decoration are set $admin_suffix = " ".$adminname[2].$adminname[1].$adminname[3]; else $admin_suffix = " - ".$adminname[1]; // or use default "name - title" } $adminname = $adminname[0].$admin_suffix; // make admin name as "name [title]" (for example) } if ( $name == $adminname ) if ( !isset($_COOKIE['hash']) OR md5($adminpass) !== $_COOKIE['hash'] ) $name = "Какой-то самозванец"; // take care of ones who wanna look like admin // making the SQL query $sql = "INSERT INTO comments(date,comid,id,name,mail,entry) VALUES($date,\"$texthash\",\"$file\",\"$name\",\"$mail\",\"$text\")"; $result = sqlite_query($db, $sql); if ( $result !== false AND $blogmail != "" ) { // if comment posted AND e-mail is set (for notifications) $posturl = $_SERVER['HTTP_REFERER']; // do the work if ( !strstr($posturl,'#comments') ) $posturl = $posturl."#comments"; $postauth = str_replace("
    ","\r\n",$name); $posttext = str_replace("
    ","\r\n",$text); $posttext = str_replace(array("&squot;","&dquot;","…"),array("'","\"","..."),$posttext); $subject = "Новый комментарий в блоге".$blogtitl; $headers = "From: $blogtitl Mailer <${blogmail}>\r\n"; $headers .= "Reply-To: $blogtitl Mailer <${blogmail}>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "X-Priority: 3 (Normal)\r\n"; $headers .= "X-MSMail-Priority: Normal\r\n"; $headers .= "Importance: Normal\r\n"; $headers .= "X-Mailer: PHP/".phpversion(); $message .= "В блоге $blogtitl появился новый комментарий.\r\n\r\n"; $message .= "URL: ".$posturl."\r\n"; $message .= "Автор: ".$postauth."\r\n"; $message .= "Текст: ".$posttext."\r\n"; $mail_sent = mail($blogmail,$subject,$message,$headers); } } if (empty($_SERVER['HTTP_REFERER'])) { echo "
    Спасибо за ваш комментарий!
    "; echo "Вернуться в блог.
    "; } else { $returl = $_SERVER['HTTP_REFERER']; if ( stripos($returl,'#comments') === false ) $returl=$returl."#comments"; header("Location: $returl"); } } else { // if captcha is WRONG echo ""; echo ""; echo "$blogtitl - Извините, ваш комментарий не был добавлен!\n"; echo ""; echo ""; echo "

    К сожалению, код, который вы ввели, не соответствует тексту на картинке!
    "; echo "Попытайтесь ещё раз!
    "; } } // --------------------------------------------------------------------------------------------------- // if job = "search" (search for key phrase in blog posts) elseif ( $job == "search" ) { function lowcaseutf($string) // lower case function for SQLite requests { return mb_strtolower($string,'utf-8'); } $datasize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM blog WHERE date < '$now'")); $dosearch = $_POST['dosearch']; $errflag = 1; // error flag: true (default) if ( $datasize && $dosearch ) { // blog entry exists - can do the search $dosearch = mb_strtolower($dosearch,'utf-8'); $dosearch = trim($dosearch); $dosearch = format_bbcodes($dosearch); $dosearch = strip_tags($dosearch); $dosearch = stripslashes($dosearch); $dosearch = str_replace(array("?","!",".","<",">","|",":","'","\"","#","№",";","$","%","^","&","*","(",")","@","[","]","{","}","—","~","-","«","»","\\","/","_","=","+","`","’"),"",$dosearch); $dosearch = preg_replace('/\s+/',' ',$dosearch); $searchar = explode(" ",$dosearch); // make an array of search words if ( $searchar[3] != "" ) { $errflag = 0; // search done $result = sqlite_array_query($db,"SELECT * FROM blog WHERE ( php('lowcaseutf',fulldesc) LIKE '%".$searchar[0]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[1]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[2]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[3]."%' ) AND date < '$now' ORDER BY date DESC;"); } if ( $errflag != 0 ) // search hasn't done if ( $searchar[2] != "" ) { $errflag = 0; // search done $result = sqlite_array_query($db,"SELECT * FROM blog WHERE ( php('lowcaseutf',fulldesc) LIKE '%".$searchar[0]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[1]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[2]."%' ) AND date < '$now' ORDER BY date DESC;"); } if ( $errflag != 0 ) // search hasn't done if ( $searchar[1] != "" ) { $errflag = 0; // search done $result = sqlite_array_query($db,"SELECT * FROM blog WHERE ( php('lowcaseutf',fulldesc) LIKE '%".$searchar[0]."%' AND php('lowcaseutf',fulldesc) LIKE '%".$searchar[1]."%' ) AND date < '$now' ORDER BY date DESC;"); } if ( $errflag != 0 ) // search hasn't done if ( $searchar[0] != "" ) { $errflag = 0; // search done $result = sqlite_array_query($db,"SELECT * FROM blog WHERE php('lowcaseutf',fulldesc) LIKE '%".$searchar[0]."%' AND date < '$now' ORDER BY date DESC;"); } $rescount = count($result); // how many entries are found $dosearch_print = "'".$dosearch."' (".$rescount.")"; $output = "

    Ищём в блоге ключевые слова: ${dosearch_print}.


    "; foreach ( $result as $entry ) { $showpagehash = $entry['id']; $showdate = $entry['date']; $text = format_bbcodes($entry['desc']); $photo = $entry['image']; $desc = format_bbcodes($entry['title']); $blogentry = $entry['file']; $tags = $entry['keys']; $blogentry = $blogpath.$blogdir.$blogentry; $tagstring = ""; // clear the tags string $comsize = sqlite_fetch_single(sqlite_query($db,"SELECT count(*) FROM comments WHERE id='$showpagehash' AND date < '$now';")); if ( !$comsize ) $comsize = 0; $showdate = make_date(date("j M Y",$showdate)); $tagarray = explode(",",$tags); $tagssize = count($tagarray); $counter3 = 0; while ( $counter3 < $tagssize ) { $tagstring = $tagstring."$tagarray[$counter3] "; $counter3++; } $text = format_bbcodes($text); $text = strip_tags($text); $text = stripslashes($text); $text = trunc_title($text,200); $output = $output."

    $desc

    Запись от $showdate
    Автор: touch

    "; } } if ( !$result && $dosearch ) // key phrase - YES, search results - NO $output = $output."
    К сожалению, ваш поиск не дал результатов. Попробуйте другие слова!

    \n

    \n

    \n"; elseif ( !$dosearch ) // key phrase - NO (direct access to search page) $output = "
    Укажите ключевые слова для поиска (до 4 слов, через пробел):

    \n

    \n

    \n"; // if ( !$dosearch_print ) $dosearch_print = $blogname; $pagetitle = "Поиск по ключевым словам ${dosearch_print}. Блог $blogtitl"; $pagedesc = "Поиск всех упоминаний ключевых слов: ${dosearch_print}. Сайт о легком блоговом движке Blog Micro и других CMS."; $pagekeys = str_replace(' ',',',$dosearch_print).",блог без базы данных,PHP скрипт для журнала,легкий блоговый движок,SQLite блог"; print eval(get_template('tags')); } // --------------------------------------------------------------------------------------------------- // close SQLite db file sqlite_close($db); ?>