Warning: include(.../cache/template/template63867.php): failed to open stream: No such file or directory in /home/codingta/public_html/includes/vb5/template.php on line 328 Warning: include(): Failed opening '.../cache/template/template63867.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/codingta/public_html/includes/vb5/template.php on line 328 How to fix “Function eregi() is deprecated” in PHP 5.3.0 - Coding-Talk

How to fix “Function eregi() is deprecated” in PHP 5.3.0

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to fix “Function eregi() is deprecated” in PHP 5.3.0

    ok just a tutorial for newbies ive been asked this question many times this is the answer

    Form validation is required to prevent web form abuse by malicious users . Improper validation of form data is one of the main causes of security vulnerabilities . It exposes your website to attacks such as header injections , cross-site scripting , and SQL injections .

    header injection attacks can be used to send email spam from your web server
    cross-site scripting may allow an attacker to post any data to your site
    SQL injection may corrupt your database backend

    A mandatory practice is to always implement client / server-side validation techniques on all input fields of submitted content by the user . This article will focus on validating the email-address field , I used to use eregi for validating email address input that matches to the regular expression . That would return true if given email address is matches to username@domain.com pattern. Unfortunately, after upgrading PHP to the earlier version (5.3.0), it wont work properly . This is because eregi is one of several functions that are deprecated in the new version of PHP . Solution : Use preg_match with the ‘i’ modifier instead. i means that regular expression is case insensitive . So the code become like this :
    PHP Code:
    01    function validate_email($email)
    02    {
    03     
    04    
    /* deprecated */
    05    if(eregi("^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$"$email)) {
    06    return "email is valid ";
    07    } else {
    08    return "email is not valid " ;
    09    }
    10     
    11    
    /* Solution */
    12    if(preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i"$email)) {
    13    return "email is valid ";
    14    } else {
    15    return "email is not valid " ;
    16    }
    17    }
    18    echo validate_email('your.domain@gmail.com'); //returns "email is valid"
    19    echo validate_email("your.domain@.com") ; //returns "email in not valid" 
    List of depreciated functions in PHP 5.3.x :

    call_user_method() (use call_user_func() instead)
    call_user_method_array() (use call_user_func_array() instead)
    define_syslog_variables()
    dl()
    ereg() (use preg_match() instead)
    ereg_replace() (use preg_replace() instead)
    eregi() (use preg_match() with the ‘i’ modifier instead)
    eregi_replace() (use preg_replace() with the ‘i’ modifier instead)
    set_magic_quotes_runtime() and its alias, magic_quotes_runtime()
    session_register() (use the $_SESSION superglobal instead)
    session_unregister() (use the $_SESSION superglobal instead)
    session_is_registered() (use the $_SESSION superglobal instead)
    set_socket_blocking() (use stream_set_blocking() instead)
    split() (use preg_split() instead)
    spliti() (use preg_split() with the ‘i’ modifier instead)
    sql_regcase()
    mysql_db_query() (use mysql_select_db() and mysql_query() instead)
    mysql_escape_string() (use mysql_real_escape_string() instead)
    Passing locale category names as strings is now deprecated. Use the LC_* family of constants instead.
    The is_dst parameter to mktime(). Use the new timezone handling functions instead.

    --------------------------------------------------------------------------------------

    I hope this information will help the newbies getting this type of error.

  • #2
    Deprecated: Function eregi() is deprecated in /home/MYSITE/public_html/func.php on line 1052

    how i put that in my func.php? sir?

    PHP Code:
    //Start of main Function

    function search_result($search$ur)
    {
    $nsearch=$search;
    $search=mysql_real_escape_string(trim($search));
    $search=preg_replace("/\\|'/",'',$search); 
    $show=$ur['blogperpage'];
    $p $_GET['p'];
    $title=implode("%' and title LIKE '%"explode(" ",$search));
    $text=implode("%' and text LIKE '%"explode(" ",$search));
    $count=mysql_query("SELECT id FROM blog WHERE title LIKE '%$title%' OR text LIKE '%$text%'") or die(mysql_error());
    $total=mysql_num_rows($count);
    if(
    $total=="0" || empty($search))
    {
    $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];
    $ur['meta_robots']="noindex,nofollow";
    pageheader($ur);
    echo 
    '<div class="blog">
    <div class="heading1">Search Result'
    .$hal.' for '.$nsearch.'</div></div>';
    echo 
    "<div class=\"text\">No result found.
    "
    ;
    }
    else
    {
    if(
    $p 1) {$hal=" Page #$p";}
    $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];
    $ur['meta_robots']="noindex,nofollow";
    pageheader($ur);
    echo 
    '<div class="blog">
    <div class="heading1">Search Result'
    .$hal.' for '.$nsearch.'</div></div>';
    $pg=ceil($total/$show);
    if(
    $p>$pg && $p!=1)
    $p=$pg
    if(
    $p<1)
    $p=1;
    $j = ($p-1) * $show;
    $huteri=mysql_query("select id, bloglink, title, text, cat_id, date_format(time, '%d %b %Y') as 'time', date_format(uptime, '%d %b %Y') as 'uptime', uptime as 'timeorder', hit, hittoday, user_id from blog  WHERE title LIKE '%$title%' OR text LIKE '%$text%' order by timeorder desc limit $j$show") or die(mysql_error());
    while(
    $manza=mysql_fetch_array($huteri))
    {
    bloglist($ur,$manza);
    }
    echo 
    "<div class=\"paging\">";
    $sc=$ur['linkperpage'];
    $st=floor($p/$sc)*$sc;
    $en=$st+$sc;
    $g=$st;
    if(
    $g<"2") print("");
    else
    if(
    $g>"0")
    print(
    "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".($g-1)."\">[&laquo;]</a> ");
    else
    print(
    "");

    for(
    $g;($g<$en);$g++)
        {
    if(
    $g==$p)
        {
    print(
    " [<b>".$g."</b>] ");
        }
    elseif(
    $g<=$pg)
        {
    if(
    $g>"0")
    print(
    "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">".$g."</a> ");
        }
    else
        {
    print(
    " ");
        }
        }
    if(
    $g<=$pg)
    print(
    "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">[&raquo;]</a>");
    else
    print(
    "");
        }
    echo 
    "</div>
    "
    ;
    quicknav($ur);
    }

    function 
    edit_save($_POST$ur)
    {
    if(empty(
    $_POST['title']) or empty($_POST['text'])) die("Data not complete.");
    $_POST['blog']=trim($_POST['blog']);
    $_POST['title']=$ur['idx_updatenot'].trim(addslashes(htmlentities($_POST['title'])));
    $_POST['bloglink']=trim(addslashes($_POST['bloglink']));
    $_POST['text']=trim(addslashes($_POST['text']));
    if(empty(
    $_POST['bloglink'])) $_POST['bloglink']=stripper($_POST['title']);

    mysql_query("update blog set title='{$_POST['title']}',bloglink='{$_POST['bloglink']}', text='{$_POST['text']}',cat_id='{$_POST['kategori']}' where id='{$_POST['blog']}'") or die(mysql_error());
    if (
    $_POST['commentonoff']!=""mysql_query("update blog set blogcmtonoff='{$_POST['commentonoff']}' where id='{$_POST['blog']}'") or die(mysql_error());
    if (
    $_POST['uptime']=="yes"mysql_query("update blog set uptime=now() where id='{$_POST['blog']}'") or die(mysql_error());
    $_SESSION['statusmsg']='<font class="saved">Blog was updated successfully</font>';
    header('location:'.$ur['blog_dir'].blogpermalink($_POST['blog']));
    die();
    }

    function 
    form_edit($id$ur)
    {
    $fe=mysql_query("select * from blog where id='$id'") or die(mysql_error());
    $r=mysql_fetch_array($fe);
    if(
    mysql_num_rows($fe)=="0") die("Invalid data");
    $r['title']=str_replace($ur['idx_updatenot'], ""stripslashes($r['title']));
    $r['text']=htmlentities(stripslashes($r['text']));
    $ur['title']="Edit Blog: ".$r['title']." | ".$ur['blog_name'];
    $ur['meta_robots']="noindex,nofollow";
    pageheader($ur);
    echo 
    '<div class="blog">
    <div class="heading1"><center>Edit Blog</center></div>
    <div class="bl_box">
    <form action="'
    .$ur['blog_dir'].'?blog&editsave" method="post">
    <input type="hidden" name="blog" value="'
    .$r['id'].'">

    Title:<br>
    <input type="text" name="title" size="'
    .$ur['wr_titlesize'].'" value="'.$r['title'].'"><br><br>
    Permalink:<br>
    <input type="text" name="bloglink" size="'
    .$ur['wr_titlesize'].'" value="'.$r['bloglink'].'"><br><br>
    Text: <br>
    <textarea cols="'
    .$ur['wr_textcols'].'" rows="'.$ur['wr_textrows'].'" name="text" wrap="virtual">'.$r['text'].'</textarea><br>
    Category: 
    <select name="kategori">
    '
    ;
    $ui=mysql_query("select id, kategori from kategori order by kategori") or die(mysql_error());
    while(
    $o=mysql_fetch_array($ui))
    {
    echo 
    '<option value="'.$o['id'].'"';
    if(
    $o['id']==$r['cat_id']) echo ' selected';
    echo 
    '>'.htmlentities($o['kategori']).'</option>
    '
    ;
    }
    echo 
    '</select><br>
    <input type="checkbox" name="commentonoff" value ='
    ;
    if (
    $r['blogcmtonoff']=="0") echo '"1"> Enable Comment<br>
    '
    ;
    else echo 
    '"0"> Disable Comment<br>
    '
    ;
    echo 
    '<input type="checkbox" name="uptime" value ="yes"> Update Time<br>
    <input type="submit" value="Edit"></form><br>
    <a href="'
    .$ur['blog_dir'].''.catlink($r['cat_id']).'/'.$r['bloglink'].'">Cancel</a>
    </div></div>
    '
    ;
    }

    function 
    blog_delete($id,$ur)
    {
    $id=str_replace("\""""str_replace("\'"""$id));
    $l=mysql_query("select id from blog where id='$id'") or die(mysql_error());
    if(
    mysql_num_rows($l)=="0") die("Invalid data");

    mysql_query("delete from blog where id='$id'") or die(mysql_error());
    mysql_query("delete from comment where blog_id='$id'") or die(mysql_error());

    $_SESSION['statusmsg']='Blog is successfully deleted';
    header('Location:'.$ur['blog_dir']);
    die();
    }

    function 
    _code($match)
    {
    $match[1]=htmlentities(str_replace('http','hxxp',$match[1]));
    return 
    '<div><b>Code:</b><div class="code">'.$match[1].'</div></div>';
    }

    function 
    _textarea($match)
    {
    return 
    '<textarea rows="4" cols="30">'.htmlentities($match[1]).'</textarea>';
    }

    function 
    bbcodes($pesan)
    {
    $bbcode = array(
    "/\[b\](.*?)\[\/b\]/is" => "<b>$1</b>",
    "/\[i\](.*?)\[\/i\]/is" => "<i>$1</i>",
    "/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",
    "/\[s\](.*?)\[\/s\]/is" => "<s>$1</s>",
    "/\[br\]|\[br\/\]/is" => "<br>",
    "/\[blink\](.*?)\[\/blink\]/is" => "<font style=\"text-decoration:blink\">$1</font>",
    "/\[center\](.*?)\[\/center\]/is" => "<center>$1</center>",
    "/\[red\](.*?)\[\/red\]/is" => "<font color=\"red\">$1</font>",
    "/\[blue\](.*?)\[\/blue\]/is" => "<font color=\"blue\">$1</font>",
    "/\[yellow\](.*?)\[\/yellow\]/is" => "<font color=\"yellow\">$1</font>",
    "/\[green\](.*?)\[\/green\]/is" => "<font color=\"green\">$1</font>",
    "/\[grey\](.*?)\[\/grey\]/is" => "<font color=\"grey\">$1</font>",
    "/\[aqua\](.*?)\[\/aqua\]/is" => "<font color=\"aqua\">$1</font>",
    "/\[black\](.*?)\[\/black\]/is" => "<font color=\"black\">$1</font>",
    "/\[white\](.*?)\[\/white\]/is" => "<font color=\"white\">$1</font>",
    "/\[img\](.*?)\[\/img\]/is" => "<img src=\"$1\" alt=\"img\">",
    "/\[url\=(.*?)\](.*?)\[\/url\]/is" => "<a href=\"$1\" target=\"_blank\">$2</a>",
    "/\[link\=(.*?)\](.*?)\[\/link\]/is" => "<a onclick=\"errr();\" href=\"$1\" target=\"_blank\">$2</a>",
    "/\[color\=(.*?)\](.*?)\[\/color\]/is" => "<font color='$1'>$2</font>",
    "/\[quote\=(.*?)\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote <b>\"$1\"</b>:</i><div class=\"quoted\">$2</div></div>",
    "/\[quote\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote:</i><div class=\"quoted\">$1</div></div>",
    "/\[right\](.*?)\[\/right\]/is" => "<div class=\"right\">$1</div>",
    "/\[textarea\](.*?)\[\/textarea\]/is" => "<textarea rows=\"4\" cols=\"30\">$1</textarea>",
    "/\[textarea=(.*?)\](.*?)\[\/textarea\]/is" => "<textarea rows=\"$1\" cols=\"30\">$2</textarea>",
    "#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#" => "\\1<a onclick=\"errr();\" href=\"\\2\" target=\"_blank\">\\2</a>"
    );
    $pesan preg_replace_callback("/\[code\](.*?)\[\/code\]/is"'_code'$pesan);
    $pesan=preg_replace(array_keys($bbcode), array_values($bbcode), $pesan);
    $pesan=str_replace('hxxp','http',$pesan);
    return 
    $pesan;
    }

    function 
    smiley($ur,$pesan)
    {
    $smiley = array(
    "/:@/i" => "<img src=\"{$ur['blog_dir']}images/smiley/angry.png\" alt=\":@\">",
    "/8-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/annoyed.png\" alt=\"8-)\">",
    "/(:p|:-p)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cheeky.png\" alt=\":p\">",
    "/B-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cool.png\" alt=\"B-)\">",
    "/:'\(/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cry.png\" alt=\":'(\">",
    "/\^o\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/curious.png\" alt=\"^o)\">",
    "/(:s|:-s)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/disgust.png\" alt=\":s\">",
    "/(:\)|:-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/happy.png\" alt=\":)\">",
    "/;-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/wink.png\" alt=\";)\">",
    "/(:\*|:-\*)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss.png\" alt=\":*\">",
    "/(:x)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love.png\" alt=\":x\">",
    "/8-\|/i" => "<img src=\"{$ur['blog_dir']}images/smiley/nerd.png\" alt=\"8-|\">",
    "/(:\(|:-\()/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sad.png\" alt=\":(\">",
    "/(:o|:-o)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/shocked.png\" alt=\":o\">",
    '/:\$/i' => "<img src=\"{$ur['blog_dir']}images/smiley/shy.png\" alt=\":$\">",
    "/(:\#|:-\#)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/silent.png\" alt=\":#\">",
    "/(\|\)|\|-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sleepy.png\" alt=\"|)\">",
    "/(:\||:-\|)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flat.png\" alt=\":-|\">",
    "/(:d|:-d)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/veryhappy.png\" alt=\":D\">",
    "/\(dies\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dies.png\" alt=\"(dies)\">",
    "/\(hypnotized\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dizzy.png\" alt=\"(hypnotized)\">",
    "/\(err\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/err.png\" alt=\":(err)\">",
    "/(:~|:-~)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flirt.png\" alt=\":~\">",
    "/%\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hypnotized.png\" alt=\"%)\">",
    "/(&\)|&amp;\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/insane.png\" alt=\"&amp)\">",
    "/:-=/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sttt.png\" alt=\":-=\">",
    "/:\\\/i" => "<img src=\"{$ur['blog_dir']}images/smiley/unimpressed.png\" alt=\":\\\">",
    "/:\{/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yuck.png\" alt=\":{\">",
    "/:\}/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yum.png\" alt=\":}\">",
    "/\(dog\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dog.png\" alt=\"(dog)\">",
    "/\(callme\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/callme.png\" alt=\"(callme)\">",
    "/\(headphones\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/headphones.png\" alt=\"(headphones)\">",
    "/\(love\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love2.png\" alt=\"(love)\">",
    "/\(hug\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hug.png\" alt=\"(hug)\">",
    "/\(beautiful\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/beautiful.png\" alt=\"(beautiful)\">",
    "/\(bum\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/bum.png\" alt=\"(bum)\">",
    "/\(devil\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/devil.png\" alt=\"(devil)\">",
    "/\(poo\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/poo.png\" alt=\"(poo)\">",
    "/\(reaper\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/reaper.png\" alt=\"(reaper)\">",
    "/\(scream\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/scream.png\" alt=\"(scream)\">",
    "/\(vamp\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vamp.png\" alt=\"(vamp)\">",
    "/\(vomit\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vomit.png\" alt=\"(vomit)\">",
    "/\(kiss\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss2.png\" alt=\"(kiss)\">",
    "/\(confused\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/confused.png\" alt=\"(confused)\">",
    "/\(drool\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/drool.png\" alt=\"(drool)\">",
    "/\(holdinghands\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/holdinghands.png\" alt=\"(holdinghands)\">",
    "/\(buzz\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/buzz.png\" alt=\"(buzz)\">",
    "/\(kick\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kick.png\" alt=\"(kick)\">",
    "/\(ok\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/ok.png\" alt=\"(ok)\">",
    "/\(punch\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/punch.png\" alt=\"(punch)\">",
    "/\(thumbsup\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsup.png\" alt=\"(thumbsup)\">",
    "/\(thumbsdown\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsdown.png\" alt=\"(thumbsdown)\">",
    "/:hammers/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/hammers.gif\" alt=\":hammers\">",
    "/:ngacir2/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir2.gif\" alt=\":hammers\">",
    "/:ngacir:/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir.gif\" alt=\":ngacir:\">"
    );
    $pesan=preg_replace(array_keys($smiley), array_values($smiley), $pesan);
    return 
    $pesan;
    }

    function 
    stripper($link)
    {
    $link=strtolower($link);
    $link=preg_replace('/[^a-z0-9]/',' ',$link);
    $link=preg_replace('/\s\s+/',' ',$link);
    $link=trim($link);
    $link=str_replace(' ','-',$link);
    return 
    $link;
    }

    function 
    signature($ur,$name)
    {
    $sgn=false;
    if(
    preg_match("/^admin|administrator|{$ur['name']}/i",$name)) $sgn='<div class="signature">_____________<br>
    '
    .bbcodes($ur['signature']).'</div>
    '
    ;
    return 
    $sgn;
    }

    function 
    post($comment$id$ur$bloglink$catlink)
    {

    $blogcek=mysql_query("SELECT id FROM blog WHERE bloglink='$bloglink'") or die(mysql_error());
    $res=mysql_num_rows($blogcek);

    if(
    $res<1)
    {
    $ridho=mysql_query("SELECT id FROM blog WHERE bloglink LIKE '%$bloglink%' limit 1") or die(mysql_error());
    $blog=mysql_fetch_row($ridho);
    if(empty(
    $blog[0]))
    {
    $ur['title']='Page Not Found';
    $ur['meta_robots']='noindex,nofollow';
    pageheader($ur);
    error404();
    }
    else
    {
    header('Location:'.$ur['blog_dir'].blogpermalink($blog[0]));
    die();
    }
    }

    elseif(
    $catlink!=catlink(blogcatid($bloglink)))
    {
    header('Location:'.$ur['blog_dir'].blogpermalink(bloglinkid($bloglink)));
    die();
    }

    else
    {
    if(!isset(
    $_SESSION['user'])) mysql_query("update blog set hittoday=hittoday+1 where bloglink='$bloglink'");
    $huteri=mysql_query("select id, title, bloglink, text,  date_format(time, '%d %b %Y %H:%i') as 'time', date_format(uptime, '%d %b %Y %H:%i') as 'uptime', time as 'timecek', uptime as 'uptimecek', cat_id, hit, hittoday, user_id, blogcmtonoff from blog where bloglink='$bloglink'") or die(mysql_error());
    if(
    mysql_num_rows($huteri)=="0") die("zero result");
    $manza=mysql_fetch_array($huteri);
    $manza['title']=str_replace($ur['idx_updatenot'], ""$manza['title']);
    $manza['text']=str_replace("[more]","",$manza['text']);
    $metadesc=htmlentities(strip_tags(substr(bbcodes($manza['text']),0,400)));
    $id=$manza['id'];
    if(
    $ur['bbcodeonoff']=="1"$manza['text']=bbcodes($manza['text']);
    if(
    $ur['smileyonoff']=="1"$manza['text']=smiley($ur,$manza['text']);
    $ur['title']=$manza['title']." | ".$ur['blog_name'];
    $ur['meta_robots']="all,index,follow";
    $ur['meta_description']=$metadesc;
    pageheader($ur);
    echo 
    '<div class="blog">
    <div class="heading1"><center><h1><a href="'
    .$ur['blog_dir'].blogpermalink($manza['id']).'">'.$manza['title'].'</a></h1></center></div>
    <div class="properties"><table border=0 cellspacing="0">
    <tr><td>Date</td><td>: '
    .$manza['time'].'</td></tr>
    '
    ;

    if(
    $manza['uptimecek'] > $manza['timecek']) echo '<tr><td>Last Update</td><td>: '.$manza['uptime'].'</td></tr>
    '
    ;
    echo 
    '<tr><td>Category</td><td>: <a href="'.$ur['blog_dir'].'category/'.catlink($manza['cat_id']).'">'.catname($manza['cat_id']).'</a></td></tr>
    <tr><td>Author</td><td>: '
    .username($manza['user_id']).'</td></tr>
    <tr><td>Hits</td><td>: '
    .$manza['hittoday'].'/'.($manza['hittoday']+$manza['hit']).'</td></tr>
    <td><tr><td>Share</td><td>: <a href="http://www.facebook.com/sharer.php?u=http://www.miserybd.com/'
    .$manza['id'].'" target="_blank" onclick="return fbb_share_js_794935();"><img src="http://3.bp.blogspot.com/_C6KkooKXCEw/TIBf2gtK0UI/AAAAAAAAGwE/Wml7-gPP17U/s200/facebook-c.png"></a> | <a href="http://twitter.com/share?url=http://www.miserybd.com/'.$manza['id'].'&via=abtmig&text='.$manza['title'].'" target="_blank"><img src="http://1.bp.blogspot.com/_C6KkooKXCEw/TIBf76kHm4I/AAAAAAAAGwk/RDwE7CSSsTc/s200/twitter-c.png"></a></td></tr>
    <td>Shorten</td><td>: <a href="http://www.miserybd.com/'
    .$manza['id'].'">http://www.miserybd.com/'.$manza['id'].'</a></td></tr>
    <center>
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-8834065160594185";
    /* Scripts(468x60) */
    google_ad_slot = "8804413658";
    google_ad_width = 468;
    google_ad_height = 60;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
    </center>
    </table>
    '
    ;
    if(isset(
    $_SESSION['user'])) echo '<small><a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&edit">[Edit]</a> <a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&delete"><font class="red">[Delete]</font></a></small>';
    echo 
    '</div>
    <div class="text">'
    .stripslashes(nl2br($manza['text'])).'
    </div></div>'
    ;

    if(
    $ur['blg_seealsoonoff']=="1")
    {
    if(
    $ur['blg_seealsoorder']=="kategori"$rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' and cat_id='{$manza['cat_id']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());
    else 
    $rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());
    echo 
    '<div class="blog">
    <div class="bl_title"><b>See Also:</b></div>
    <div class="bl_box">'
    ;
    while(
    $randt=mysql_fetch_array($rand))
    {
    $randt['title']=str_replace($ur['idx_updatenot'], ""$randt['title']);
    echo 
    '<img src="'.$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].''.catlink($randt['cat_id']).'/'.$randt['bloglink'].'">'.$randt['title'].'</a><br>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;
    }

    echo 
    '<div class="none"><a href="'.$ur['blog_dir'].'">Home</a></div>
    <div class="blog"><a name="comment"></a>
    <div class="bl_title"><img src="'
    .$ur['blog_dir'].'images/comments.png" alt=""> <b>Comment</b> ('.jmlkomen($id).')</div>
    <div class="bl_box">'
    ;

    if(isset(
    $_SESSION['cmtmsg']))
    {
    echo 
    $_SESSION['cmtmsg'].'<br>
    '
    ;
    unset(
    $_SESSION['cmtmsg']);
    }

    $c=mysql_query("select id, name, message, date_format(time, '%d %b %Y %H:%i') as 'time', blog_id, url from comment where blog_id='{$manza['id']}' order by id desc limit {$ur['blg_komenperpage']}") or die(mysql_error());
    if(
    mysql_num_rows($c)=="0") echo 'No Comment.';
    else
    {
    while(
    $huterim=mysql_fetch_array($c))
    {
    $huterim['name']=stripslashes($huterim['name']);
    $huterim['url']=stripslashes($huterim['url']);
    $huterim['message']=stripslashes($huterim['message']);
    $huterim['message']=nl2br($huterim['message']);
    if(
    $ur['bbcodeonoff']=="1"$huterim['message']=bbcodes($huterim['message']);
    if(
    $ur['smileyonoff']=="1"$huterim['message']=smiley($ur,$huterim['message']);

    echo 
    '<div id="comment">
    '
    ;
    if(isset(
    $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$huterim['blog_id'].'&del='.$huterim['id'].'"><small style="color:red">[<b>x</b>]</small></a>';
    if(
    $huterim['url']=="blank") echo '<a name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>
    '
    ;
    else echo 
    '<a href="'.$huterim['url'].'" target="_blank" name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>
    '
    ;

    echo 
    ' <sup>['.$huterim['time'].']</sup><br>
    '
    ;
    echo 
    $huterim['message'].signature($ur,$huterim['name']);

    echo 
    '
    </div>
    '
    ;
    }
    echo 
    '<a href="comment/">View All</a>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;

    $_SESSION['angka']=rand(1,10000);
    if(
    $manza['blogcmtonoff']==1)
    {
    echo 
    '<div class="blog"><a name="commentform"></a>
    <div class="bl_title"><img src="'
    .$ur['blog_dir'].'images/comment.png" alt=""> <b>Leave a Comment</b></div>
    <div class="bl_box">
    <form action="'
    .$ur['blog_dir'].'comment.php" method="post">
    <input type="hidden" name="blog_id" value="'
    .$manza['id'].'">
    '
    ;

    if(isset(
    $_SESSION['cmterror']))
    {
    echo 
    '<font class="error">Error: '.$_SESSION['cmterror'].'</font><br>
    '
    ;
    unset(
    $_SESSION['cmterror']);
    }

    if(isset(
    $_SESSION['user']))
    {
    echo 
    '<b>Comment as:</b><br>
    <select name="name">
    <option value="'
    .$ur['name'].'">'.$ur['name'].'</option>
    <option value="Admin">Admin</option>
    <option value="Administrator">Administrator</option>
    </select><br>
    <input type="checkbox" name="adminurl" value="1"><small><i>'
    .$ur['blog_url'].'</i></small><br>
    <textarea rows="'
    .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.$comment['comment'].'</textarea><br>
    '
    ;
    if(
    $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';
    else echo 
    'BB Code Disabled <br>
    '
    ;
    if(
    $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';
    else echo 
    'Smiley Disabled
    '
    ;
    echo 
    '<br>
    <input type="submit" value="Post" name="submit"></form>
    <small><a href="'
    .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=disable">[Disable Comment]</a></small>
    '
    ;
    }
    else
    {
    if(
    $_COOKIE['mb_comment_name']) $comment['name']=$_COOKIE['mb_comment_name'];
    if(
    $_COOKIE['mb_comment_url']) $comment['url']=$_COOKIE['mb_comment_url'];
    if(
    $_SESSION['cmtmessage']) 
    {
    $comment['comment']=$_SESSION['cmtmessage'];
    unset(
    $_SESSION['cmtmessage']);
    }
    echo 
    '<table border="0">
    <tr><td>Name<font color=red>*</font></td>
    <td>:</td><td><input type="text" name="name" size="'
    .$ur['blg_komennamesize'].'" value="'.$comment['name'].'"></td></tr>
    <tr><td>Url</td>
    <td>:</td><td><input type="text" name="url" size="'
    .$ur['blg_komenurlsize'].'" value="'.$comment['url'].'"></td></tr></table>
    <table border="0" width="100%">
    <tr><td>Comment<font color=red>*</font>:</td></tr>
    <tr><td><textarea rows="'
    .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.htmlentities($comment['comment']).'</textarea></td></tr>
    <tr><td>
    '
    ;
    if(
    $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';
    else echo 
    'BB Code Disabled<br>
    '
    ;
    if(
    $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';
    else echo 
    'Smiley Disabled
    '
    ;
    echo 
    '</td></tr></table>
    <table border="0">
    <tr><td>Code<font color=red>*</font>: <b>'
    .$_SESSION['angka'].'</b> <input type="text" name="kode" size="4"></td><td><input type="submit" value="Post" name="submit"></td></tr></table>
    </form>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;
    }

    else
    {
    echo 
    '<div class="blog">
    <div class="bl_title"><b>Leave a Comment</b></div>
    <div class="bl_box">Post comment is currently disabled.
    '
    ;
    if(isset(
    $_SESSION['user'])) echo '<br>
    <small><a href="'
    .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=enable">[Enable Comment]</a></small>';
    echo 
    '</div></div>
    '
    ;
    }
    }
    }

    function 
    bloglist($ur,$blog)
    {
    $cat=catname($blog['cat_id']);
    $user=username($blog['user_id']);
    $blog['title']=stripslashes($blog['title']);
    $blog['text']=stripslashes($blog['text']);
    $blog['text']=strip_tags(bbcodes($blog['text']));
    if(
    strstr($blog['text'],"[more]")) $ur['idx_textperblog']=strpos($blog['text'],"[more]");
    $blog['text']=nl2br(substr($blog['text'],0,$ur['idx_textperblog']));
    echo 
    '<div class="blog">
    <div class="bl_title">
    <b><a href="'
    .$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'">'.$blog['title'].'</a></b>';
    if(isset(
    $_SESSION['user']))
    {
    echo 
    ' <small><a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&edit">[Edit]</a> | <a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&delete"><font class="red">[Delete]</font></a></small>';
    $check=strpos($blog['title'], $ur['idx_updatenot']);
    if(
    $check!==false) echo ' | <a href="'.$ur['blog_dir'].'?delnot='.$blog['id'].'"><small>[Del Notify]</small></a>';
    }
    echo 
    '</div>
    <div class="bl_box">
    '
    .$blog['uptime'].' under <a href="'.$ur['blog_dir'].'category/'.catlink($blog['cat_id']).'">'.$cat.'</a> by '.$user.'<br>';
    if(
    $ur['idx_hitonoff']=="1")
    {
    if(
    $ur['idx_hittodayonoff']=="1") echo ' [View: '.$blog['hittoday'].'/'.($blog['hittoday']+$blog['hit']).']';
    else echo 
    ' [View: '.($blog['hittoday']+$blog['hit']).' ]';
    }
    if(
    $ur['idx_komenonoff']=="1")
    {
    if(
    $ur['idx_cmttodayonoff']=="1") echo ' [Comment: '.countcomment($blog['id']).'/'.jmlkomen($blog['id']).']';
    else echo 
    ' [Comment: '.jmlkomen($blog['id']).']';
    }

    echo 
    '</div>
    <div class="bl_box">
    '
    .$blog['text'].' <small>[...]</small> <i><a href="'.$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'"><small>Read More</small></a></i><br>
    '
    ;
    echo 
    '</div></div>
    '
    ;
    }

    function 
    commentlist($ur,$comment)
    {
    echo 
    '<div id="comment">';
    if(isset(
    $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$comment['blog_id'].'&del='.$comment['id'].'"><small style="color:red">[<b>x</b>]</small></a>';
    $comment['name']=htmlentities(stripslashes($comment['name']));
    $comment['message']=stripslashes($comment['message']);
    if(
    $ur['bbcodeonoff']=="1"$comment['message']=bbcodes($comment['message']);
    if(
    $ur['smileyonoff']=="1"$comment['message']=smiley($ur,$comment['message']);
    $comment['message']=nl2br($comment['message']);
    $comment['url']=htmlentities(stripslashes($comment['url']));

    if(
    $comment['url']=='blank') echo '<b>'.$comment['name'].'</b>';
    else echo 
    '<a href="'.$comment['url'].'" target="_blank"><b>'.$comment['name'].'</b></a>';

    $title=str_replace($ur['idx_updatenot'],"",blogtitle(bloglink($comment['blog_id'])));
    echo 
    ' on <a href="'.$ur['blog_dir'].blogpermalink($comment['blog_id']).'">'.$title.'</a><br>
    <small>At '
    .$comment['time'].'<br>
    IP: '
    .$comment['ip'].'<br>
    Browser: '
    .$comment['browser'].'</small><br>
    <div class="cmttext">'
    .$comment['message'].signature($ur,$comment['name']).'
    </div></div>'
    ;
    }

    function 
    error404()
    {
    echo 
    '<div class="text">
    <p align="center">
    <font size="5">Error 404 - Page Not Found.</font><br><br>
    Sorry Which Pages or files are u looking for thats not found.Please tell admin about this.<br><br>
    </p></div>'
    ;
    }

    //End of Main Function

    /***************************/

    //Start of Navigation Function

    function navbar($ur//panel navigasi untuk tampilan full
    {
    echo 
    '<div class="navbar">
    '
    ;
    search($ur);
    menu($ur);
    mosthittoday($ur);
    mosthitall($ur);
    listcat($ur);
    lastcomment($ur);
    echo 
    '</div>
    '
    ;
    echo 
    '<div class="leftsb">
    <div class="navbox"><div class="navtitle"><b>Left Slide Bar</b></div></div>
    <div class="navbox"><div class="navtitle"><b>Sponsors</b></div></div>
    <div class="navbox">
    <center>
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-8834065160594185";
    /* Scripts(160x600) */
    google_ad_slot = "5070042074";
    google_ad_width = 160;
    google_ad_height = 600;
    //-->
    </script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script></center>
    </div>
    </div>
    '
    ;
    }

    function 
    quicknav($ur//menu navigasi homepage untuk mobile
    {
    if(
    $ur['mobile'])
    {
    search($ur);
    menu($ur);
    listcat($ur);
    lastcomment($ur);
    mosthittoday($ur);
    mosthitall($ur);
    }
    }

    function 
    search($ur)
    {
    if(isset(
    $_SESSION['form']))
    {
    echo 
    $_SESSION['form'];
    }
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Search</b></div>
    <div class="navbox"><form action="'
    .$ur['blog_dir'].'?search" method="GET">
    <table border=0>
    <tr><td width="75%"><input class="searchbox" type="text" name="search" size="'
    .$ur['idx_searchsize'].'"></td><td><input type="submit" value="search"></td></tr>
    </table>
    </form></div></div>
    '
    ;
    }

    function 
    admin($ur)
    {
    if(isset(
    $_SESSION['user'])) echo '<br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php">Admin Area</a><br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php?postitem">Write Item</a><br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?logout">Log Out</a><br>
    '
    ;
    else echo 
    '<br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?login&forward='.urlencode($_SERVER['REQUEST_URI']).'">Login</a>';
    }

    function 
    menu($ur)
    {
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Menu</b></div>
    <div class="navbox">
    <img src="'
    .$ur['blog_dir'].'images/rssblue.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'rss">RSS Feed</a><br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'about">About</a><br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'archive">Archive</a><br>
    <img src="'
    .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'sitemap">Sitemap</a>';
    admin($ur);
    echo 
    '</div></div>
    '
    ;
    }

    function 
    listcat($ur)
    {
    $huteri=mysql_query("select * from kategori order by catlink") or die(mysql_error());
    $huterim=mysql_query("select count(id) from blog") or die(mysql_error());
    $c=mysql_fetch_row($huterim);
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Category:</b></div>
    <div class="navbox">
    <p><a href="'
    .$ur['blog_dir'].'">All</a> ['.$c[0].']</p>
    '
    ;
    while(
    $manza=mysql_fetch_row($huteri))
    {
    echo 
    '<p><a href="'.$ur['blog_dir'].'category/'.$manza[2].'">'.$manza[1].'</a> ['.jmlpercat($manza[0]).']
    '
    ;
    if(isset(
    $_SESSION['user'])) echo ' <small><a href="'.$ur['blog_dir'].'?edt='.$manza[0].'#edt">[E]</a> <a href="'.$ur['blog_dir'].'?del='.$manza[0].'"><font class="red">[D]</font></a></small>
    '
    ;
    echo 
    '</p>
    '
    ;
    }
    if(isset(
    $_GET['delsave']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>
    '
    ;
    $_GET['deluser']=trim($_GET['deluser']);
    mysql_query("delete from kategori where id='{$_GET['delsave']}'") or die(mysql_error());
    mysql_query("delete from blog where cat_id='{$_GET['delsave']}'") or die(mysql_error());
    mysql_query("delete from comment where cat_id='{$_GET['delsave']}'") or die(mysql_error());
    echo 
    "Category Deleted <a href=./>Refresh</a>
    "
    ;
    }
    elseif(isset(
    $_GET['del']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>
    '
    ;
    else
    {
    $p=mysql_query("select id from kategori where id='{$_GET['del']}'") or die(mysql_error());
    if(
    mysql_num_rows($p)=="0") echo 'No Data Found <a href=./>Refresh</a>
    '
    ;
    else echo 
    'Are you sure want to delete this Category? This\'ll delete all blog with this category.<br>
    <a href="'
    .$ur['blog_dir'].'?delsave='.$_GET['del'].'">Yes</a> | <a href="./">No</a>
    '
    ;
    }
    }
    elseif(isset(
    $_GET['edtsave']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>
    '
    ;
    else
    {
    $_POST['edit']=trim(addslashes($_POST['edit']));
    $catlink=stripper($_POST['edit']);
    if(empty(
    $_POST['edit'])) echo 'Empty Data <a href="'.$ur['blog_dir'].'">Refresh</a>
    '
    ;
    else
    {
    mysql_query("update kategori set kategori='{$_POST['edit']}', catlink='$catlink' where id='{$_POST['id']}'") or die(mysql_error());
    echo 
    'Update berhasil <a href="'.$ur['blog_dir'].'">Refresh</a>
    '
    ;
    }
    }
    }
    elseif(isset(
    $_GET['edt']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden <a href="'.$ur['blog_dir'].'">Refresh</a>
    '
    ;
    else
    {
    $_GET['edt']=trim($_GET['edt']);
    $g=mysql_query("select * from kategori where id='{$_GET['edt']}'") or die(mysql_error());
    $h=mysql_fetch_array($g);
    if(
    mysql_num_rows($g)=="0" or mysql_num_rows($g)>"1") echo 'Wrong Data <a href=./>Refresh</a>
    '
    ;
    else echo 
    '<form action="'.$ur['blog_dir'].'?edtsave" method="post"> <input type="hidden" name="id" value="'.$_GET['edt'].'">
    <a name="edt"></a>Edit:<br>
    <input type="text" name="edit" value="'
    .htmlentities($h['kategori']).'"><br>
    <input type="submit" value="OK"></form>
    '
    ;
    }
    }
    elseif(isset(
    $_GET['newcatsave']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>
    '
    ;
    else
    {
    $_POST['newcat']=trim(addslashes($_POST['newcat']));
    $catlink=stripper($_POST['newcat']);
    $newcategory=$_POST['newcat'];
    $u=mysql_query("select id from kategori where kategori='{$_POST['newcat']}'") or die(mysql_error());
    if(empty(
    $_POST['newcat'])) echo 'Empty Data <a href=./>Refresh</a>
    '
    ;
    elseif(
    mysql_num_rows($u)!="0") echo 'Category already exist <a href=./>Refresh</a>
    '
    ;
    else
    {
    mysql_query("insert into kategori (kategori, catlink) values ('$newcategory', '$catlink')") or die(mysql_error());
    echo 
    'Creating Success!! <a href="./">Refresh</a>
    '
    ;
    }
    }
    }
    elseif(isset(
    $_GET['newcat']))
    {
    if(!isset(
    $_SESSION['user'])) echo 'Forbidden. ';
    else echo 
    '<form action="'.$ur['blog_dir'].'?newcatsave" method="post">
    <a name="nc"></a>New:<br>
    <input type="text" name="newcat">
    <br>
    <input type="submit" value="OK"></form>
    '
    ;
    }
    else
    {
    if(isset(
    $_SESSION['user'])) echo '<a href="'.$ur['blog_dir'].'?newcat#nc">New Category</a>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;
    }

    function 
    mosthittoday($ur)
    {
    if(
    $ur['idx_mosthittodayonoff']=="1")
    {
    $huterimata=mysql_query("select * from blog order by hittoday desc limit {$ur['idx_jmlmosthittoday']}") or die(mysql_error());
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Most Hit Today:</b></div>
    <div class="navbox">'
    ;
    while(
    $f=mysql_fetch_array($huterimata))
    {
    $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);
    echo 
    '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hittoday'].' Hits)</p>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;
    }
    }

    function 
    mosthitall($ur)
    {
    if(
    $ur['idx_mosthitonoff']=="1")
    {
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Most Hit:</b></div>
    <div class="navbox">'
    ;
    $huterimata=mysql_query("select * from blog order by hit desc limit {$ur['idx_jmlmosthit']}") or die(mysql_error());
    while(
    $f=mysql_fetch_array($huterimata))
    {
    $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);
    echo 
    '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hit'].' Hits)</p>
    '
    ;
    }
    echo 
    '</div></div>
    '
    ;
    }
    }

    function 
    lastcomment($ur)
    {
    if(
    $ur['idx_lastcmtonoff']=="1")
    {
    $huterimata=mysql_query("select * from comment order by id desc limit {$ur['idx_jmllastcmt']}") or die(mysql_error());
    echo 
    '<div class="nav">
    <div class="navtitle"><b>Recent Comment:</b></div>
    <div class="navbox">'
    ;
    while(
    $holm=mysql_fetch_array($huterimata))
    {
    $holm['name']=substr(htmlentities($holm['name']), 0$ur['idx_lastcmtname']);
    $holm['message']=stripslashes(substr(strip_tags(bbcodes($holm['message'])), 0$ur['idx_lastcmtpesan']));
    echo 
    '<p id="lastcmt"><b>'.$holm['name'].'</b>: '.$holm['message'].' <a href="'.$ur['blog_dir'].blogpermalink($holm['blog_id']).'"><small>More..</small></a></p>
    '
    ;
    }
    echo 
    '<a href="'.$ur['blog_dir'].'recentcomment"><img src="'.$ur['blog_dir'].'images/comments.png" alt=""> <b>View Last 15 Comments</b></a></div></div>
    '
    ;
    }
    }

    //End of Navigation Function

    /***************************/

    //Start of Misc Function

    function admob_request($ur//admob_request($admob_params)
    {
    if(!
    eregi("localhost",$_SERVER['SERVER_NAME']))
    {
    $admob_params = array(
      
    'ANALYTICS_ID'      => ''
      
    'AD_REQUEST'        => true
      
    'ANALYTICS_REQUEST' => false
      
    'TEST_MODE'         => false
      
    'OPTIONAL'          => array()
    );
      static 
    $pixel_sent false;

      
    $ad_mode false;
      if (!empty(
    $ur['PUBLISHER_ID'])) $ad_mode true;
      
      
    $analytics_mode false;
      if (!empty(
    $admob_params['ANALYTICS_ID']) && !$pixel_sent$analytics_mode true;
      
      
    $protocol 'http';
      if (!empty(
    $_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'$protocol 'https';
      
      
    $rt $ad_mode ? ($analytics_mode 0) : ($analytics_mode : -1);
      if (
    $rt == -1) return '';
      
      list(
    $usec$sec) = explode(' 'microtime()); 
      
    $params = array('rt=' $rt,
                      
    'z=' . ($sec $usec),
                      
    'u=' urlencode($_SERVER['HTTP_USER_AGENT']), 
                      
    'i=' urlencode($_SERVER['REMOTE_ADDR']), 
                      
    'p=' urlencode("$protocol://" $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']),
                      
    'v=' urlencode('20081105-PHPCURL-acda0040bcdea222')); 

      
    $sid = empty($admob_params['SID']) ? session_id() : $admob_params['SID'];
      if (!empty(
    $sid)) $params[] = 't=' md5($sid);
      if (
    $ad_mode$params[] = 's=' $ur['PUBLISHER_ID'];
      if (
    $analytics_mode$params[] = 'a=' $admob_params['ANALYTICS_ID'];
      if (!empty(
    $_COOKIE['admobuu'])) $params[] = 'o=' $_COOKIE['admobuu'];
      if (!empty(
    $admob_params['TEST_MODE'])) $params[] = 'm=test';

      if (!empty(
    $admob_params['OPTIONAL'])) {
        foreach (
    $admob_params['OPTIONAL'] as $k => $v) {
          
    $params[] = urlencode($k) . '=' urlencode($v);
        }
      }

      
    $ignore = array('HTTP_PRAGMA' => true'HTTP_CACHE_CONTROL' => true'HTTP_CONNECTION' => true'HTTP_USER_AGENT' => true'HTTP_COOKIE' => true);
      foreach (
    $_SERVER as $k => $v) {
        if (
    substr($k04) == 'HTTP' && empty($ignore[$k]) && isset($v)) {
          
    $params[] = urlencode('h[' $k ']') . '=' urlencode($v);
        }
      }
      
      
    $post implode('&'$params);
      
    $request curl_init();
      
    $request_timeout 1// 1 second timeout
      
    curl_setopt($requestCURLOPT_URL'http://r.admob.com/ad_source.php');
      
    curl_setopt($requestCURLOPT_RETURNTRANSFER1);
      
    curl_setopt($requestCURLOPT_TIMEOUT$request_timeout);
      
    curl_setopt($requestCURLOPT_CONNECTTIMEOUT$request_timeout);
      
    curl_setopt($requestCURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded''Connection: Close'));
      
    curl_setopt($requestCURLOPT_POSTFIELDS$post);
      list(
    $usec_start$sec_start) = explode(' 'microtime());
      
    $contents curl_exec($request);
      list(
    $usec_end$sec_end) = explode(' 'microtime());
      
    curl_close($request);

      if (
    $contents === true || $contents === false$contents '';

      if (!
    $pixel_sent) {
        
    $pixel_sent true;
        
    $contents .= "<img src=\"$protocol://p.admob.com/e0?"
                  
    'rt=' $rt
                  
    '&amp;z=' . ($sec $usec)
                  . 
    '&amp;a=' . ($analytics_mode $admob_params['ANALYTICS_ID'] : '')
                  . 
    '&amp;s=' . ($ad_mode $ur['PUBLISHER_ID'] : '')
                  . 
    '&amp;o=' . (empty($_COOKIE['admobuu']) ? '' $_COOKIE['admobuu'])
                  . 
    '&amp;lt=' . ($sec_end $usec_end $sec_start $usec_start)
                  . 
    '&amp;to=' $request_timeout
                  
    '" alt="" width="1" height="1">';
      }
      
      return 
    $contents;
    }
    }

    function 
    cutter($content,$start,$end//ini buat grabber (fungsi potong)
    {
    if(
    $content && $start && $end
    {
    $r explode($start$content);
    if (isset(
    $r[1])){
    $r explode($end$r[1]);
    return 
    $r[0];
    }
    return 
    '';
    }
    }

    function 
    mobile() //return true jika terdeteksi user agen mobile
    {
    $text $_SERVER['HTTP_USER_AGENT'];
    $mobile=false;
    $var=array("Mozilla/4.",
    "Mozilla/3.0",
    "AvantGo",
    "ProxiNet",
    "Danger hiptop 1.0",
    "DoCoMo/",
    "Google CHTML Proxy/",
    "UP.Browser/",
    "SEMC-Browser/",
    "J-PHONE/",
    "PDXGW/",
    "ASTEL/",
    "Mozilla/1.22",
    "Handspring",
    "Windows CE",
    "PPC",
    "Mozilla/2.0",
    "Blazer/",
    "Palm",
    "WebPro/",
    "EPOC32-WTL/",
    "Tungsten",
    "Netfront/",
    "Mobile Content Viewer/",
    "PDA",
    "MMP/2.0",
    "Embedix/",
    "Qtopia/",
    "Xiino/",
    "BlackBerry",
    "Gecko/20031007",
    "MOT-",
    "UP.Link/",
    "Smartphone",
    "portalmmm/",
    "Nokia",
    "Symbian",
    "AppleWebKit/413",
    "UPG1 UP/",
    "RegKing",
    "STNC-WTL/",
    "J2ME",
    "Opera Mini/",
    "SEC-",
    "ReqwirelessWeb/",
    "AU-MIC/",
    "Sharp",
    "SIE-",
    "SonyEricsson",
    "Elaine/",
    "SAMSUNG-",
    "Panasonic",
    "Siemens",
    "Sony",
    "Verizon",
    "Cingular",
    "Sprint",
    "AT&T;",
    "Nextel",
    "Pocket PC",
    "T-Mobile';    
    'Orange"
    ,
    "Casio",
    "HTC",
    "Motorola",
    "Samsung",
    "NEC");
    $result count($var);
    for (
    $i=0;$i<$result;$i++)
    {    
    if(
    eregi($var[$i],$text)) $mobile=true;
    }
    return 
    $mobile;
    }

    function 
    visit($ur//User online, hits today dan total hits
    {
    $session=session_id();
    $time=time();
    $time_check=$time-400;
    $result=mysql_query("SELECT * FROM user_online WHERE user_ip='{$_SERVER['REMOTE_ADDR']}'");
    $count=mysql_num_rows($result);
    if(
    $count=="0")
    {
    $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));
    $result1=mysql_query("INSERT INTO user_online (session, time, user_ip, user_browser, user_location) VALUES('$session', '$time', '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_USER_AGENT']}', '{$_SERVER['REQUEST_URI']}')");
    }
    else
    {
    $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));
    $result2=mysql_query("UPDATE user_online SET time='$time', user_ip='{$_SERVER['REMOTE_ADDR']}', user_browser='{$_SERVER['HTTP_USER_AGENT']}', user_location='{$_SERVER['REQUEST_URI']}' WHERE session = '$session'");
    }
    $result3=mysql_query("SELECT * FROM user_online");
    $user_online=mysql_num_rows($result3);
    $result4=mysql_query("DELETE FROM user_online WHERE time<$time_check");
    if(!isset(
    $_SESSION['user']) && !eregi('bot',$_SERVER['HTTP_USER_AGENT']))
    {
    mysql_query("update user set hittoday=hittoday+1, hit=hit+1 where id='1'");
    }
    echo 
    '<div class="visit"><small><a href="'.$ur['blog_dir'].'whos" target="_blank">'.$user_online.'</a> Online | Today: '.$ur['hittoday'].' visit | Total: '.$ur['hit'].' visit</small></div>
    '
    ;
    }

    function 
    blogpermalink($id)
    {
    $per=mysql_query("select bloglink, cat_id from blog where id='$id'") or die(mysql_error());
    $ma=mysql_fetch_row($per);
    $link=catlink($ma[1]).'/'.$ma[0].'/';
    return 
    $link;
    }

    function 
    catpermalink($id)
    {
    $per=mysql_query("select catlink from kategori where id='$id'") or die(mysql_error());
    $ma=mysql_fetch_row($per);
    $link='category/'.$ma[0].'/';
    return 
    $link;
    }

    function 
    catname($cat_id)
    {
    $q=mysql_query("select kategori from kategori where id='$cat_id'") or die(mysql_error());
    $w=mysql_fetch_row($q);
    return 
    $w[0];
    }

    function 
    catlink($cat_id)
    {
    $ku=mysql_query("select catlink from kategori where id='$cat_id'") or die(mysql_error());
    $ci=mysql_fetch_row($ku);
    return 
    $ci[0];
    }

    function 
    bloglink($blog_id)
    {
    $bl=mysql_query("select bloglink from blog where id='$blog_id'") or die(mysql_error());
    $lk=mysql_fetch_row($bl);
    return 
    $lk[0];
    }

    function 
    catlinkid($cat_link)
    {
    $ct=mysql_query("select id from kategori where catlink='$cat_link'") or die(mysql_error());
    $cid=mysql_fetch_row($ct);
    return 
    $cid[0];
    }

    function 
    bloglinkid($blog_link)
    {
    $blg=mysql_query("select id from blog where bloglink='$blog_link'") or die(mysql_error());
    $blid=mysql_fetch_row($blg);
    return 
    $blid[0];
    }

    function 
    blogtitle($blog_link)
    {
    $blt=mysql_query("select title from blog where bloglink='$blog_link'") or die(mysql_error());
    $bltt=mysql_fetch_row($blt);
    return 
    $bltt[0];
    }

    function 
    blogcatid($blog_link)
    {
    $bci=mysql_query("select cat_id from blog where bloglink='$blog_link'") or die(mysql_error());
    $bcid=mysql_fetch_row($bci);
    return 
    $bcid[0];
    }

    function 
    username($user_id)
    {
    $huteri=mysql_query("select * from user where id='$user_id'") or die(mysql_error());
    $manza=mysql_fetch_array($huteri);
    return 
    $manza['name'];
    }

    function 
    userid($username)
    {
    $z=mysql_query("select id from user where name='$username' limit 1") or die(msyql_error());
    $x=mysql_fetch_row($z);
    return 
    $x[0];
    }

    function 
    catid($cat)
    {
    $v=mysql_query("select id from kategori where kategori='$cat'") or die(mysql_error());
    $n=mysql_fetch_row($v);
    return 
    $n[0];
    }

    function 
    jmlkomen($manzalog)
    {
    $huteri=mysql_query("select count(*) from comment where blog_id='$manzalog'");
    $k=mysql_fetch_row($huteri);
    return 
    $k[0];
    }

    function 
    cmtonoff($blog_id)
    {
    $co=mysql_query("select blogcmtonoff from blog where id='$blog_id'") or die(mysql_error());
    $coo=mysql_fetch_row($co);
    return 
    $coo[0];
    }

    function 
    jmlpercat($id)
    {
    $huteri=mysql_query("select count(id) from blog where cat_id='$id'") or die(mysql_error());
    $manza=mysql_fetch_row($huteri);
    return 
    $manza[0];
    }

    function 
    countcomment($id)
    {
    $count=mysql_query("select count(id) from comment where blog_id='$id' and date(time)=curdate()") or die(mysql_error());
    $hasil=mysql_fetch_row($count);
    return 
    $hasil[0];
    }

    //End of Misc Function 

    Comment


    • #3
      Originally posted by hi_jakkk View Post
      Deprecated: Function eregi() is deprecated in /home/MYSITE/public_html/func.php on line 1052

      how i put that in my func.php? sir?
      i could only find 3 eregi sections in your func file.

      i replaced all 3 with the preg_match.
      PHP Code:
      //Start of main Function  

      function search_result($search$ur)  
      {  
      $nsearch=$search;  
      $search=mysql_real_escape_string(trim($search));  
      $search=preg_replace("/\\|'/",'',$search);   
      $show=$ur['blogperpage'];  
      $p $_GET['p'];  
      $title=implode("%' and title LIKE '%"explode(" ",$search));  
      $text=implode("%' and text LIKE '%"explode(" ",$search));  
      $count=mysql_query("SELECT id FROM blog WHERE title LIKE '%$title%' OR text LIKE '%$text%'") or die(mysql_error());  
      $total=mysql_num_rows($count);  
      if(
      $total=="0" || empty($search))  
      {  
      $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];  
      $ur['meta_robots']="noindex,nofollow";  
      pageheader($ur);  
      echo 
      '<div class="blog">  
      <div class="heading1">Search Result'
      .$hal.' for '.$nsearch.'</div></div>';  
      echo 
      "<div class=\"text\">No result found.  
      "
      ;  
      }  
      else  
      {  
      if(
      $p 1) {$hal=" Page #$p";}  
      $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];  
      $ur['meta_robots']="noindex,nofollow";  
      pageheader($ur);  
      echo 
      '<div class="blog">  
      <div class="heading1">Search Result'
      .$hal.' for '.$nsearch.'</div></div>';  
      $pg=ceil($total/$show);  
      if(
      $p>$pg && $p!=1)  
      $p=$pg;   
      if(
      $p<1)  
      $p=1;  
      $j = ($p-1) * $show;  
      $huteri=mysql_query("select id, bloglink, title, text, cat_id, date_format(time, '%d %b %Y') as 'time', date_format(uptime, '%d %b %Y') as 'uptime', uptime as 'timeorder', hit, hittoday, user_id from blog  WHERE title LIKE '%$title%' OR text LIKE '%$text%' order by timeorder desc limit $j$show") or die(mysql_error());  
      while(
      $manza=mysql_fetch_array($huteri))  
      {  
      bloglist($ur,$manza);  
      }  
      echo 
      "<div class=\"paging\">";  
      $sc=$ur['linkperpage'];  
      $st=floor($p/$sc)*$sc;  
      $en=$st+$sc;  
      $g=$st;  
      if(
      $g<"2") print("");  
      else  
      if(
      $g>"0")  
      print(
      "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".($g-1)."\">[&laquo;]</a> ");  
      else  
      print(
      "");  

      for(
      $g;($g<$en);$g++)  
          {  
      if(
      $g==$p)  
          {  
      print(
      " [<b>".$g."</b>] ");  
          }  
      elseif(
      $g<=$pg)  
          {  
      if(
      $g>"0")  
      print(
      "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">".$g."</a> ");  
          }  
      else  
          {  
      print(
      " ");  
          }  
          }  
      if(
      $g<=$pg)  
      print(
      "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">[&raquo;]</a>");  
      else  
      print(
      "");  
          }  
      echo 
      "</div>  
      "
      ;  
      quicknav($ur);  
      }  

      function 
      edit_save($_POST$ur)  
      {  
      if(empty(
      $_POST['title']) or empty($_POST['text'])) die("Data not complete.");  
      $_POST['blog']=trim($_POST['blog']);  
      $_POST['title']=$ur['idx_updatenot'].trim(addslashes(htmlentities($_POST['title'])));  
      $_POST['bloglink']=trim(addslashes($_POST['bloglink']));  
      $_POST['text']=trim(addslashes($_POST['text']));  
      if(empty(
      $_POST['bloglink'])) $_POST['bloglink']=stripper($_POST['title']);  

      mysql_query("update blog set title='{$_POST['title']}',bloglink='{$_POST['bloglink']}', text='{$_POST['text']}',cat_id='{$_POST['kategori']}' where id='{$_POST['blog']}'") or die(mysql_error());  
      if (
      $_POST['commentonoff']!=""mysql_query("update blog set blogcmtonoff='{$_POST['commentonoff']}' where id='{$_POST['blog']}'") or die(mysql_error());  
      if (
      $_POST['uptime']=="yes"mysql_query("update blog set uptime=now() where id='{$_POST['blog']}'") or die(mysql_error());  
      $_SESSION['statusmsg']='<font class="saved">Blog was updated successfully</font>';  
      header('location:'.$ur['blog_dir'].blogpermalink($_POST['blog']));  
      die();  
      }  

      function 
      form_edit($id$ur)  
      {  
      $fe=mysql_query("select * from blog where id='$id'") or die(mysql_error());  
      $r=mysql_fetch_array($fe);  
      if(
      mysql_num_rows($fe)=="0") die("Invalid data");  
      $r['title']=str_replace($ur['idx_updatenot'], ""stripslashes($r['title']));  
      $r['text']=htmlentities(stripslashes($r['text']));  
      $ur['title']="Edit Blog: ".$r['title']." | ".$ur['blog_name'];  
      $ur['meta_robots']="noindex,nofollow";  
      pageheader($ur);  
      echo 
      '<div class="blog">  
      <div class="heading1"><center>Edit Blog</center></div>  
      <div class="bl_box">  
      <form action="'
      .$ur['blog_dir'].'?blog&editsave" method="post">  
      <input type="hidden" name="blog" value="'
      .$r['id'].'">  

      Title:<br>  
      <input type="text" name="title" size="'
      .$ur['wr_titlesize'].'" value="'.$r['title'].'"><br><br>  
      Permalink:<br>  
      <input type="text" name="bloglink" size="'
      .$ur['wr_titlesize'].'" value="'.$r['bloglink'].'"><br><br>  
      Text: <br>  
      <textarea cols="'
      .$ur['wr_textcols'].'" rows="'.$ur['wr_textrows'].'" name="text" wrap="virtual">'.$r['text'].'</textarea><br>  
      Category:   
      <select name="kategori">  
      '
      ;  
      $ui=mysql_query("select id, kategori from kategori order by kategori") or die(mysql_error());  
      while(
      $o=mysql_fetch_array($ui))  
      {  
      echo 
      '<option value="'.$o['id'].'"';  
      if(
      $o['id']==$r['cat_id']) echo ' selected';  
      echo 
      '>'.htmlentities($o['kategori']).'</option>  
      '
      ;  
      }  
      echo 
      '</select><br>  
      <input type="checkbox" name="commentonoff" value ='
      ;  
      if (
      $r['blogcmtonoff']=="0") echo '"1"> Enable Comment<br>  
      '
      ;  
      else echo 
      '"0"> Disable Comment<br>  
      '
      ;  
      echo 
      '<input type="checkbox" name="uptime" value ="yes"> Update Time<br>  
      <input type="submit" value="Edit"></form><br>  
      <a href="'
      .$ur['blog_dir'].''.catlink($r['cat_id']).'/'.$r['bloglink'].'">Cancel</a>  
      </div></div>  
      '
      ;  
      }  

      function 
      blog_delete($id,$ur)  
      {  
      $id=str_replace("\""""str_replace("\'"""$id));  
      $l=mysql_query("select id from blog where id='$id'") or die(mysql_error());  
      if(
      mysql_num_rows($l)=="0") die("Invalid data");  

      mysql_query("delete from blog where id='$id'") or die(mysql_error());  
      mysql_query("delete from comment where blog_id='$id'") or die(mysql_error());  

      $_SESSION['statusmsg']='Blog is successfully deleted';  
      header('Location:'.$ur['blog_dir']);  
      die();  
      }  

      function 
      _code($match)  
      {  
      $match[1]=htmlentities(str_replace('http','hxxp',$match[1]));  
      return 
      '<div><b>Code:</b><div class="code">'.$match[1].'</div></div>';  
      }  

      function 
      _textarea($match)  
      {  
      return 
      '<textarea rows="4" cols="30">'.htmlentities($match[1]).'</textarea>';  
      }  

      function 
      bbcodes($pesan)  
      {  
      $bbcode = array(  
      "/\[b\](.*?)\[\/b\]/is" => "<b>$1</b>",  
      "/\[i\](.*?)\[\/i\]/is" => "<i>$1</i>",  
      "/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",  
      "/\[s\](.*?)\[\/s\]/is" => "<s>$1</s>",  
      "/\[br\]|\[br\/\]/is" => "<br>",  
      "/\[blink\](.*?)\[\/blink\]/is" => "<font style=\"text-decoration:blink\">$1</font>",  
      "/\[center\](.*?)\[\/center\]/is" => "<center>$1</center>",  
      "/\[red\](.*?)\[\/red\]/is" => "<font color=\"red\">$1</font>",  
      "/\[blue\](.*?)\[\/blue\]/is" => "<font color=\"blue\">$1</font>",  
      "/\[yellow\](.*?)\[\/yellow\]/is" => "<font color=\"yellow\">$1</font>",  
      "/\[green\](.*?)\[\/green\]/is" => "<font color=\"green\">$1</font>",  
      "/\[grey\](.*?)\[\/grey\]/is" => "<font color=\"grey\">$1</font>",  
      "/\[aqua\](.*?)\[\/aqua\]/is" => "<font color=\"aqua\">$1</font>",  
      "/\[black\](.*?)\[\/black\]/is" => "<font color=\"black\">$1</font>",  
      "/\[white\](.*?)\[\/white\]/is" => "<font color=\"white\">$1</font>",  
      "/\[img\](.*?)\[\/img\]/is" => "<img src=\"$1\" alt=\"img\">",  
      "/\[url\=(.*?)\](.*?)\[\/url\]/is" => "<a href=\"$1\" target=\"_blank\">$2</a>",  
      "/\[link\=(.*?)\](.*?)\[\/link\]/is" => "<a onclick=\"errr();\" href=\"$1\" target=\"_blank\">$2</a>",  
      "/\[color\=(.*?)\](.*?)\[\/color\]/is" => "<font color='$1'>$2</font>",  
      "/\[quote\=(.*?)\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote <b>\"$1\"</b>:</i><div class=\"quoted\">$2</div></div>",  
      "/\[quote\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote:</i><div class=\"quoted\">$1</div></div>",  
      "/\[right\](.*?)\[\/right\]/is" => "<div class=\"right\">$1</div>",  
      "/\[textarea\](.*?)\[\/textarea\]/is" => "<textarea rows=\"4\" cols=\"30\">$1</textarea>",  
      "/\[textarea=(.*?)\](.*?)\[\/textarea\]/is" => "<textarea rows=\"$1\" cols=\"30\">$2</textarea>",  
      "#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#" => "\\1<a onclick=\"errr();\" href=\"\\2\" target=\"_blank\">\\2</a>"  
      );  
      $pesan preg_replace_callback("/\[code\](.*?)\[\/code\]/is"'_code'$pesan);  
      $pesan=preg_replace(array_keys($bbcode), array_values($bbcode), $pesan);  
      $pesan=str_replace('hxxp','http',$pesan);  
      return 
      $pesan;  
      }  

      function 
      smiley($ur,$pesan)  
      {  
      $smiley = array(  
      "/:@/i" => "<img src=\"{$ur['blog_dir']}images/smiley/angry.png\" alt=\":@\">",  
      "/8-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/annoyed.png\" alt=\"8-)\">",  
      "/(:p|:-p)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cheeky.png\" alt=\":p\">",  
      "/B-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cool.png\" alt=\"B-)\">",  
      "/:'\(/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cry.png\" alt=\":'(\">",  
      "/\^o\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/curious.png\" alt=\"^o)\">",  
      "/(:s|:-s)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/disgust.png\" alt=\":s\">",  
      "/(:\)|:-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/happy.png\" alt=\":)\">",  
      "/;-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/wink.png\" alt=\";)\">",  
      "/(:\*|:-\*)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss.png\" alt=\":*\">",  
      "/(:x)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love.png\" alt=\":x\">",  
      "/8-\|/i" => "<img src=\"{$ur['blog_dir']}images/smiley/nerd.png\" alt=\"8-|\">",  
      "/(:\(|:-\()/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sad.png\" alt=\":(\">",  
      "/(:o|:-o)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/shocked.png\" alt=\":o\">",  
      '/:\$/i' => "<img src=\"{$ur['blog_dir']}images/smiley/shy.png\" alt=\":$\">",  
      "/(:\#|:-\#)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/silent.png\" alt=\":#\">",  
      "/(\|\)|\|-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sleepy.png\" alt=\"|)\">",  
      "/(:\||:-\|)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flat.png\" alt=\":-|\">",  
      "/(:d|:-d)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/veryhappy.png\" alt=\":D\">",  
      "/\(dies\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dies.png\" alt=\"(dies)\">",  
      "/\(hypnotized\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dizzy.png\" alt=\"(hypnotized)\">",  
      "/\(err\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/err.png\" alt=\":(err)\">",  
      "/(:~|:-~)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flirt.png\" alt=\":~\">",  
      "/%\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hypnotized.png\" alt=\"%)\">",  
      "/(&\)|&amp;\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/insane.png\" alt=\"&amp)\">",  
      "/:-=/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sttt.png\" alt=\":-=\">",  
      "/:\\\/i" => "<img src=\"{$ur['blog_dir']}images/smiley/unimpressed.png\" alt=\":\\\">",  
      "/:\{/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yuck.png\" alt=\":{\">",  
      "/:\}/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yum.png\" alt=\":}\">",  
      "/\(dog\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dog.png\" alt=\"(dog)\">",  
      "/\(callme\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/callme.png\" alt=\"(callme)\">",  
      "/\(headphones\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/headphones.png\" alt=\"(headphones)\">",  
      "/\(love\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love2.png\" alt=\"(love)\">",  
      "/\(hug\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hug.png\" alt=\"(hug)\">",  
      "/\(beautiful\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/beautiful.png\" alt=\"(beautiful)\">",  
      "/\(bum\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/bum.png\" alt=\"(bum)\">",  
      "/\(devil\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/devil.png\" alt=\"(devil)\">",  
      "/\(poo\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/poo.png\" alt=\"(poo)\">",  
      "/\(reaper\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/reaper.png\" alt=\"(reaper)\">",  
      "/\(scream\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/scream.png\" alt=\"(scream)\">",  
      "/\(vamp\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vamp.png\" alt=\"(vamp)\">",  
      "/\(vomit\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vomit.png\" alt=\"(vomit)\">",  
      "/\(kiss\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss2.png\" alt=\"(kiss)\">",  
      "/\(confused\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/confused.png\" alt=\"(confused)\">",  
      "/\(drool\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/drool.png\" alt=\"(drool)\">",  
      "/\(holdinghands\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/holdinghands.png\" alt=\"(holdinghands)\">",  
      "/\(buzz\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/buzz.png\" alt=\"(buzz)\">",  
      "/\(kick\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kick.png\" alt=\"(kick)\">",  
      "/\(ok\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/ok.png\" alt=\"(ok)\">",  
      "/\(punch\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/punch.png\" alt=\"(punch)\">",  
      "/\(thumbsup\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsup.png\" alt=\"(thumbsup)\">",  
      "/\(thumbsdown\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsdown.png\" alt=\"(thumbsdown)\">",  
      "/:hammers/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/hammers.gif\" alt=\":hammers\">",  
      "/:ngacir2/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir2.gif\" alt=\":hammers\">",  
      "/:ngacir:/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir.gif\" alt=\":ngacir:\">"  
      );  
      $pesan=preg_replace(array_keys($smiley), array_values($smiley), $pesan);  
      return 
      $pesan;  
      }  

      function 
      stripper($link)  
      {  
      $link=strtolower($link);  
      $link=preg_replace('/[^a-z0-9]/',' ',$link);  
      $link=preg_replace('/\s\s+/',' ',$link);  
      $link=trim($link);  
      $link=str_replace(' ','-',$link);  
      return 
      $link;  
      }  

      function 
      signature($ur,$name)  
      {  
      $sgn=false;  
      if(
      preg_match("/^admin|administrator|{$ur['name']}/i",$name)) $sgn='<div class="signature">_____________<br>  
      '
      .bbcodes($ur['signature']).'</div>  
      '
      ;  
      return 
      $sgn;  
      }  

      function 
      post($comment$id$ur$bloglink$catlink)  
      {  

      $blogcek=mysql_query("SELECT id FROM blog WHERE bloglink='$bloglink'") or die(mysql_error());  
      $res=mysql_num_rows($blogcek);  

      if(
      $res<1)  
      {  
      $ridho=mysql_query("SELECT id FROM blog WHERE bloglink LIKE '%$bloglink%' limit 1") or die(mysql_error());  
      $blog=mysql_fetch_row($ridho);  
      if(empty(
      $blog[0]))  
      {  
      $ur['title']='Page Not Found';  
      $ur['meta_robots']='noindex,nofollow';  
      pageheader($ur);  
      error404();  
      }  
      else  
      {  
      header('Location:'.$ur['blog_dir'].blogpermalink($blog[0]));  
      die();  
      }  
      }  

      elseif(
      $catlink!=catlink(blogcatid($bloglink)))  
      {  
      header('Location:'.$ur['blog_dir'].blogpermalink(bloglinkid($bloglink)));  
      die();  
      }  

      else  
      {  
      if(!isset(
      $_SESSION['user'])) mysql_query("update blog set hittoday=hittoday+1 where bloglink='$bloglink'");  
      $huteri=mysql_query("select id, title, bloglink, text,  date_format(time, '%d %b %Y %H:%i') as 'time', date_format(uptime, '%d %b %Y %H:%i') as 'uptime', time as 'timecek', uptime as 'uptimecek', cat_id, hit, hittoday, user_id, blogcmtonoff from blog where bloglink='$bloglink'") or die(mysql_error());  
      if(
      mysql_num_rows($huteri)=="0") die("zero result");  
      $manza=mysql_fetch_array($huteri);  
      $manza['title']=str_replace($ur['idx_updatenot'], ""$manza['title']);  
      $manza['text']=str_replace("[more]","",$manza['text']);  
      $metadesc=htmlentities(strip_tags(substr(bbcodes($manza['text']),0,400)));  
      $id=$manza['id'];  
      if(
      $ur['bbcodeonoff']=="1"$manza['text']=bbcodes($manza['text']);  
      if(
      $ur['smileyonoff']=="1"$manza['text']=smiley($ur,$manza['text']);  
      $ur['title']=$manza['title']." | ".$ur['blog_name'];  
      $ur['meta_robots']="all,index,follow";  
      $ur['meta_description']=$metadesc;  
      pageheader($ur);  
      echo 
      '<div class="blog">  
      <div class="heading1"><center><h1><a href="'
      .$ur['blog_dir'].blogpermalink($manza['id']).'">'.$manza['title'].'</a></h1></center></div>  
      <div class="properties"><table border=0 cellspacing="0">  
      <tr><td>Date</td><td>: '
      .$manza['time'].'</td></tr>  
      '
      ;  

      if(
      $manza['uptimecek'] > $manza['timecek']) echo '<tr><td>Last Update</td><td>: '.$manza['uptime'].'</td></tr>  
      '
      ;  
      echo 
      '<tr><td>Category</td><td>: <a href="'.$ur['blog_dir'].'category/'.catlink($manza['cat_id']).'">'.catname($manza['cat_id']).'</a></td></tr>  
      <tr><td>Author</td><td>: '
      .username($manza['user_id']).'</td></tr>  
      <tr><td>Hits</td><td>: '
      .$manza['hittoday'].'/'.($manza['hittoday']+$manza['hit']).'</td></tr>  
      <td><tr><td>Share</td><td>: <a href="http://www.facebook.com/sharer.php?u=http://www.miserybd.com/'
      .$manza['id'].'" target="_blank" onclick="return fbb_share_js_794935();"><img src="http://3.bp.blogspot.com/_C6KkooKXCEw/TIBf2gtK0UI/AAAAAAAAGwE/Wml7-gPP17U/s200/facebook-c.png"></a> | <a href="http://twitter.com/share?url=http://www.miserybd.com/'.$manza['id'].'&via=abtmig&text='.$manza['title'].'" target="_blank"><img src="http://1.bp.blogspot.com/_C6KkooKXCEw/TIBf76kHm4I/AAAAAAAAGwk/RDwE7CSSsTc/s200/twitter-c.png"></a></td></tr>  
      <td>Shorten</td><td>: <a href="http://www.miserybd.com/'
      .$manza['id'].'">http://www.miserybd.com/'.$manza['id'].'</a></td></tr>  
      <center>  
      <script type="text/javascript"><!--  
      google_ad_client = "ca-pub-8834065160594185";  
      /* Scripts(468x60) */  
      google_ad_slot = "8804413658";  
      google_ad_width = 468;  
      google_ad_height = 60;  
      //-->  
      </script>  
      <script type="text/javascript"  
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
      </script>  
      </center>  
      </table>  
      '
      ;  
      if(isset(
      $_SESSION['user'])) echo '<small><a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&edit">[Edit]</a> <a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&delete"><font class="red">[Delete]</font></a></small>';  
      echo 
      '</div>  
      <div class="text">'
      .stripslashes(nl2br($manza['text'])).'  
      </div></div>'
      ;  

      if(
      $ur['blg_seealsoonoff']=="1")  
      {  
      if(
      $ur['blg_seealsoorder']=="kategori"$rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' and cat_id='{$manza['cat_id']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());  
      else 
      $rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());  
      echo 
      '<div class="blog">  
      <div class="bl_title"><b>See Also:</b></div>  
      <div class="bl_box">'
      ;  
      while(
      $randt=mysql_fetch_array($rand))  
      {  
      $randt['title']=str_replace($ur['idx_updatenot'], ""$randt['title']);  
      echo 
      '<img src="'.$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].''.catlink($randt['cat_id']).'/'.$randt['bloglink'].'">'.$randt['title'].'</a><br>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  
      }  

      echo 
      '<div class="none"><a href="'.$ur['blog_dir'].'">Home</a></div>  
      <div class="blog"><a name="comment"></a>  
      <div class="bl_title"><img src="'
      .$ur['blog_dir'].'images/comments.png" alt=""> <b>Comment</b> ('.jmlkomen($id).')</div>  
      <div class="bl_box">'
      ;  

      if(isset(
      $_SESSION['cmtmsg']))  
      {  
      echo 
      $_SESSION['cmtmsg'].'<br>  
      '
      ;  
      unset(
      $_SESSION['cmtmsg']);  
      }  

      $c=mysql_query("select id, name, message, date_format(time, '%d %b %Y %H:%i') as 'time', blog_id, url from comment where blog_id='{$manza['id']}' order by id desc limit {$ur['blg_komenperpage']}") or die(mysql_error());  
      if(
      mysql_num_rows($c)=="0") echo 'No Comment.';  
      else  
      {  
      while(
      $huterim=mysql_fetch_array($c))  
      {  
      $huterim['name']=stripslashes($huterim['name']);  
      $huterim['url']=stripslashes($huterim['url']);  
      $huterim['message']=stripslashes($huterim['message']);  
      $huterim['message']=nl2br($huterim['message']);  
      if(
      $ur['bbcodeonoff']=="1"$huterim['message']=bbcodes($huterim['message']);  
      if(
      $ur['smileyonoff']=="1"$huterim['message']=smiley($ur,$huterim['message']);  

      echo 
      '<div id="comment">  
      '
      ;  
      if(isset(
      $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$huterim['blog_id'].'&del='.$huterim['id'].'"><small style="color:red">[<b>x</b>]</small></a>';  
      if(
      $huterim['url']=="blank") echo '<a name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>  
      '
      ;  
      else echo 
      '<a href="'.$huterim['url'].'" target="_blank" name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>  
      '
      ;  

      echo 
      ' <sup>['.$huterim['time'].']</sup><br>  
      '
      ;  
      echo 
      $huterim['message'].signature($ur,$huterim['name']);  

      echo 
      '  
      </div>  
      '
      ;  
      }  
      echo 
      '<a href="comment/">View All</a>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  

      $_SESSION['angka']=rand(1,10000);  
      if(
      $manza['blogcmtonoff']==1)  
      {  
      echo 
      '<div class="blog"><a name="commentform"></a>  
      <div class="bl_title"><img src="'
      .$ur['blog_dir'].'images/comment.png" alt=""> <b>Leave a Comment</b></div>  
      <div class="bl_box">  
      <form action="'
      .$ur['blog_dir'].'comment.php" method="post">  
      <input type="hidden" name="blog_id" value="'
      .$manza['id'].'">  
      '
      ;  

      if(isset(
      $_SESSION['cmterror']))  
      {  
      echo 
      '<font class="error">Error: '.$_SESSION['cmterror'].'</font><br>  
      '
      ;  
      unset(
      $_SESSION['cmterror']);  
      }  

      if(isset(
      $_SESSION['user']))  
      {  
      echo 
      '<b>Comment as:</b><br>  
      <select name="name">  
      <option value="'
      .$ur['name'].'">'.$ur['name'].'</option>  
      <option value="Admin">Admin</option>  
      <option value="Administrator">Administrator</option>  
      </select><br>  
      <input type="checkbox" name="adminurl" value="1"><small><i>'
      .$ur['blog_url'].'</i></small><br>  
      <textarea rows="'
      .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.$comment['comment'].'</textarea><br>  
      '
      ;  
      if(
      $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';  
      else echo 
      'BB Code Disabled <br>  
      '
      ;  
      if(
      $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';  
      else echo 
      'Smiley Disabled  
      '
      ;  
      echo 
      '<br>  
      <input type="submit" value="Post" name="submit"></form>  
      <small><a href="'
      .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=disable">[Disable Comment]</a></small>  
      '
      ;  
      }  
      else  
      {  
      if(
      $_COOKIE['mb_comment_name']) $comment['name']=$_COOKIE['mb_comment_name'];  
      if(
      $_COOKIE['mb_comment_url']) $comment['url']=$_COOKIE['mb_comment_url'];  
      if(
      $_SESSION['cmtmessage'])   
      {  
      $comment['comment']=$_SESSION['cmtmessage'];  
      unset(
      $_SESSION['cmtmessage']);  
      }  
      echo 
      '<table border="0">  
      <tr><td>Name<font color=red>*</font></td>  
      <td>:</td><td><input type="text" name="name" size="'
      .$ur['blg_komennamesize'].'" value="'.$comment['name'].'"></td></tr>  
      <tr><td>Url</td>  
      <td>:</td><td><input type="text" name="url" size="'
      .$ur['blg_komenurlsize'].'" value="'.$comment['url'].'"></td></tr></table>  
      <table border="0" width="100%">  
      <tr><td>Comment<font color=red>*</font>:</td></tr>  
      <tr><td><textarea rows="'
      .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.htmlentities($comment['comment']).'</textarea></td></tr>  
      <tr><td>  
      '
      ;  
      if(
      $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';  
      else echo 
      'BB Code Disabled<br>  
      '
      ;  
      if(
      $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';  
      else echo 
      'Smiley Disabled  
      '
      ;  
      echo 
      '</td></tr></table>  
      <table border="0">  
      <tr><td>Code<font color=red>*</font>: <b>'
      .$_SESSION['angka'].'</b> <input type="text" name="kode" size="4"></td><td><input type="submit" value="Post" name="submit"></td></tr></table>  
      </form>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  
      }  

      else  
      {  
      echo 
      '<div class="blog">  
      <div class="bl_title"><b>Leave a Comment</b></div>  
      <div class="bl_box">Post comment is currently disabled.  
      '
      ;  
      if(isset(
      $_SESSION['user'])) echo '<br>  
      <small><a href="'
      .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=enable">[Enable Comment]</a></small>';  
      echo 
      '</div></div>  
      '
      ;  
      }  
      }  
      }  

      function 
      bloglist($ur,$blog)  
      {  
      $cat=catname($blog['cat_id']);  
      $user=username($blog['user_id']);  
      $blog['title']=stripslashes($blog['title']);  
      $blog['text']=stripslashes($blog['text']);  
      $blog['text']=strip_tags(bbcodes($blog['text']));  
      if(
      strstr($blog['text'],"[more]")) $ur['idx_textperblog']=strpos($blog['text'],"[more]");  
      $blog['text']=nl2br(substr($blog['text'],0,$ur['idx_textperblog']));  
      echo 
      '<div class="blog">  
      <div class="bl_title">  
      <b><a href="'
      .$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'">'.$blog['title'].'</a></b>';  
      if(isset(
      $_SESSION['user']))  
      {  
      echo 
      ' <small><a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&edit">[Edit]</a> | <a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&delete"><font class="red">[Delete]</font></a></small>';  
      $check=strpos($blog['title'], $ur['idx_updatenot']);  
      if(
      $check!==false) echo ' | <a href="'.$ur['blog_dir'].'?delnot='.$blog['id'].'"><small>[Del Notify]</small></a>';  
      }  
      echo 
      '</div>  
      <div class="bl_box">  
      '
      .$blog['uptime'].' under <a href="'.$ur['blog_dir'].'category/'.catlink($blog['cat_id']).'">'.$cat.'</a> by '.$user.'<br>';  
      if(
      $ur['idx_hitonoff']=="1")  
      {  
      if(
      $ur['idx_hittodayonoff']=="1") echo ' [View: '.$blog['hittoday'].'/'.($blog['hittoday']+$blog['hit']).']';  
      else echo 
      ' [View: '.($blog['hittoday']+$blog['hit']).' ]';  
      }  
      if(
      $ur['idx_komenonoff']=="1")  
      {  
      if(
      $ur['idx_cmttodayonoff']=="1") echo ' [Comment: '.countcomment($blog['id']).'/'.jmlkomen($blog['id']).']';  
      else echo 
      ' [Comment: '.jmlkomen($blog['id']).']';  
      }  

      echo 
      '</div>  
      <div class="bl_box">  
      '
      .$blog['text'].' <small>[...]</small> <i><a href="'.$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'"><small>Read More</small></a></i><br>  
      '
      ;  
      echo 
      '</div></div>  
      '
      ;  
      }  

      function 
      commentlist($ur,$comment)  
      {  
      echo 
      '<div id="comment">';  
      if(isset(
      $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$comment['blog_id'].'&del='.$comment['id'].'"><small style="color:red">[<b>x</b>]</small></a>';  
      $comment['name']=htmlentities(stripslashes($comment['name']));  
      $comment['message']=stripslashes($comment['message']);  
      if(
      $ur['bbcodeonoff']=="1"$comment['message']=bbcodes($comment['message']);  
      if(
      $ur['smileyonoff']=="1"$comment['message']=smiley($ur,$comment['message']);  
      $comment['message']=nl2br($comment['message']);  
      $comment['url']=htmlentities(stripslashes($comment['url']));  

      if(
      $comment['url']=='blank') echo '<b>'.$comment['name'].'</b>';  
      else echo 
      '<a href="'.$comment['url'].'" target="_blank"><b>'.$comment['name'].'</b></a>';  

      $title=str_replace($ur['idx_updatenot'],"",blogtitle(bloglink($comment['blog_id'])));  
      echo 
      ' on <a href="'.$ur['blog_dir'].blogpermalink($comment['blog_id']).'">'.$title.'</a><br>  
      <small>At '
      .$comment['time'].'<br>  
      IP: '
      .$comment['ip'].'<br>  
      Browser: '
      .$comment['browser'].'</small><br>  
      <div class="cmttext">'
      .$comment['message'].signature($ur,$comment['name']).'  
      </div></div>'
      ;  
      }  

      function 
      error404()  
      {  
      echo 
      '<div class="text">  
      <p align="center">  
      <font size="5">Error 404 - Page Not Found.</font><br><br>  
      Sorry Which Pages or files are u looking for thats not found.Please tell admin about this.<br><br>  
      </p></div>'
      ;  
      }  

      //End of Main Function  

      /***************************/  

      //Start of Navigation Function  

      function navbar($ur//panel navigasi untuk tampilan full  
      {  
      echo 
      '<div class="navbar">  
      '
      ;  
      search($ur);  
      menu($ur);  
      mosthittoday($ur);  
      mosthitall($ur);  
      listcat($ur);  
      lastcomment($ur);  
      echo 
      '</div>  
      '
      ;  
      echo 
      '<div class="leftsb">  
      <div class="navbox"><div class="navtitle"><b>Left Slide Bar</b></div></div>  
      <div class="navbox"><div class="navtitle"><b>Sponsors</b></div></div>  
      <div class="navbox">  
      <center>  
      <script type="text/javascript"><!--  
      google_ad_client = "ca-pub-8834065160594185";  
      /* Scripts(160x600) */  
      google_ad_slot = "5070042074";  
      google_ad_width = 160;  
      google_ad_height = 600;  
      //-->  
      </script>  
      <script type="text/javascript"  
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
      </script></center>  
      </div>  
      </div>  
      '
      ;  
      }  

      function 
      quicknav($ur//menu navigasi homepage untuk mobile  
      {  
      if(
      $ur['mobile'])  
      {  
      search($ur);  
      menu($ur);  
      listcat($ur);  
      lastcomment($ur);  
      mosthittoday($ur);  
      mosthitall($ur);  
      }  
      }  

      function 
      search($ur)  
      {  
      if(isset(
      $_SESSION['form']))  
      {  
      echo 
      $_SESSION['form'];  
      }  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Search</b></div>  
      <div class="navbox"><form action="'
      .$ur['blog_dir'].'?search" method="GET">  
      <table border=0>  
      <tr><td width="75%"><input class="searchbox" type="text" name="search" size="'
      .$ur['idx_searchsize'].'"></td><td><input type="submit" value="search"></td></tr>  
      </table>  
      </form></div></div>  
      '
      ;  
      }  

      function 
      admin($ur)  
      {  
      if(isset(
      $_SESSION['user'])) echo '<br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php">Admin Area</a><br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php?postitem">Write Item</a><br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?logout">Log Out</a><br>  
      '
      ;  
      else echo 
      '<br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?login&forward='.urlencode($_SERVER['REQUEST_URI']).'">Login</a>';  
      }  

      function 
      menu($ur)  
      {  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Menu</b></div>  
      <div class="navbox">  
      <img src="'
      .$ur['blog_dir'].'images/rssblue.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'rss">RSS Feed</a><br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'about">About</a><br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'archive">Archive</a><br>  
      <img src="'
      .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'sitemap">Sitemap</a>';  
      admin($ur);  
      echo 
      '</div></div>  
      '
      ;  
      }  

      function 
      listcat($ur)  
      {  
      $huteri=mysql_query("select * from kategori order by catlink") or die(mysql_error());  
      $huterim=mysql_query("select count(id) from blog") or die(mysql_error());  
      $c=mysql_fetch_row($huterim);  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Category:</b></div>  
      <div class="navbox">  
      <p><a href="'
      .$ur['blog_dir'].'">All</a> ['.$c[0].']</p>  
      '
      ;  
      while(
      $manza=mysql_fetch_row($huteri))  
      {  
      echo 
      '<p><a href="'.$ur['blog_dir'].'category/'.$manza[2].'">'.$manza[1].'</a> ['.jmlpercat($manza[0]).']  
      '
      ;  
      if(isset(
      $_SESSION['user'])) echo ' <small><a href="'.$ur['blog_dir'].'?edt='.$manza[0].'#edt">[E]</a> <a href="'.$ur['blog_dir'].'?del='.$manza[0].'"><font class="red">[D]</font></a></small>  
      '
      ;  
      echo 
      '</p>  
      '
      ;  
      }  
      if(isset(
      $_GET['delsave']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>  
      '
      ;  
      $_GET['deluser']=trim($_GET['deluser']);  
      mysql_query("delete from kategori where id='{$_GET['delsave']}'") or die(mysql_error());  
      mysql_query("delete from blog where cat_id='{$_GET['delsave']}'") or die(mysql_error());  
      mysql_query("delete from comment where cat_id='{$_GET['delsave']}'") or die(mysql_error());  
      echo 
      "Category Deleted <a href=./>Refresh</a>  
      "
      ;  
      }  
      elseif(isset(
      $_GET['del']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>  
      '
      ;  
      else  
      {  
      $p=mysql_query("select id from kategori where id='{$_GET['del']}'") or die(mysql_error());  
      if(
      mysql_num_rows($p)=="0") echo 'No Data Found <a href=./>Refresh</a>  
      '
      ;  
      else echo 
      'Are you sure want to delete this Category? This\'ll delete all blog with this category.<br>  
      <a href="'
      .$ur['blog_dir'].'?delsave='.$_GET['del'].'">Yes</a> | <a href="./">No</a>  
      '
      ;  
      }  
      }  
      elseif(isset(
      $_GET['edtsave']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>  
      '
      ;  
      else  
      {  
      $_POST['edit']=trim(addslashes($_POST['edit']));  
      $catlink=stripper($_POST['edit']);  
      if(empty(
      $_POST['edit'])) echo 'Empty Data <a href="'.$ur['blog_dir'].'">Refresh</a>  
      '
      ;  
      else  
      {  
      mysql_query("update kategori set kategori='{$_POST['edit']}', catlink='$catlink' where id='{$_POST['id']}'") or die(mysql_error());  
      echo 
      'Update berhasil <a href="'.$ur['blog_dir'].'">Refresh</a>  
      '
      ;  
      }  
      }  
      }  
      elseif(isset(
      $_GET['edt']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden <a href="'.$ur['blog_dir'].'">Refresh</a>  
      '
      ;  
      else  
      {  
      $_GET['edt']=trim($_GET['edt']);  
      $g=mysql_query("select * from kategori where id='{$_GET['edt']}'") or die(mysql_error());  
      $h=mysql_fetch_array($g);  
      if(
      mysql_num_rows($g)=="0" or mysql_num_rows($g)>"1") echo 'Wrong Data <a href=./>Refresh</a>  
      '
      ;  
      else echo 
      '<form action="'.$ur['blog_dir'].'?edtsave" method="post"> <input type="hidden" name="id" value="'.$_GET['edt'].'">  
      <a name="edt"></a>Edit:<br>  
      <input type="text" name="edit" value="'
      .htmlentities($h['kategori']).'"><br>  
      <input type="submit" value="OK"></form>  
      '
      ;  
      }  
      }  
      elseif(isset(
      $_GET['newcatsave']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>  
      '
      ;  
      else  
      {  
      $_POST['newcat']=trim(addslashes($_POST['newcat']));  
      $catlink=stripper($_POST['newcat']);  
      $newcategory=$_POST['newcat'];  
      $u=mysql_query("select id from kategori where kategori='{$_POST['newcat']}'") or die(mysql_error());  
      if(empty(
      $_POST['newcat'])) echo 'Empty Data <a href=./>Refresh</a>  
      '
      ;  
      elseif(
      mysql_num_rows($u)!="0") echo 'Category already exist <a href=./>Refresh</a>  
      '
      ;  
      else  
      {  
      mysql_query("insert into kategori (kategori, catlink) values ('$newcategory', '$catlink')") or die(mysql_error());  
      echo 
      'Creating Success!! <a href="./">Refresh</a>  
      '
      ;  
      }  
      }  
      }  
      elseif(isset(
      $_GET['newcat']))  
      {  
      if(!isset(
      $_SESSION['user'])) echo 'Forbidden. ';  
      else echo 
      '<form action="'.$ur['blog_dir'].'?newcatsave" method="post">  
      <a name="nc"></a>New:<br>  
      <input type="text" name="newcat">  
      <br>  
      <input type="submit" value="OK"></form>  
      '
      ;  
      }  
      else  
      {  
      if(isset(
      $_SESSION['user'])) echo '<a href="'.$ur['blog_dir'].'?newcat#nc">New Category</a>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  
      }  

      function 
      mosthittoday($ur)  
      {  
      if(
      $ur['idx_mosthittodayonoff']=="1")  
      {  
      $huterimata=mysql_query("select * from blog order by hittoday desc limit {$ur['idx_jmlmosthittoday']}") or die(mysql_error());  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Most Hit Today:</b></div>  
      <div class="navbox">'
      ;  
      while(
      $f=mysql_fetch_array($huterimata))  
      {  
      $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);  
      echo 
      '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hittoday'].' Hits)</p>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  
      }  
      }  

      function 
      mosthitall($ur)  
      {  
      if(
      $ur['idx_mosthitonoff']=="1")  
      {  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Most Hit:</b></div>  
      <div class="navbox">'
      ;  
      $huterimata=mysql_query("select * from blog order by hit desc limit {$ur['idx_jmlmosthit']}") or die(mysql_error());  
      while(
      $f=mysql_fetch_array($huterimata))  
      {  
      $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);  
      echo 
      '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hit'].' Hits)</p>  
      '
      ;  
      }  
      echo 
      '</div></div>  
      '
      ;  
      }  
      }  

      function 
      lastcomment($ur)  
      {  
      if(
      $ur['idx_lastcmtonoff']=="1")  
      {  
      $huterimata=mysql_query("select * from comment order by id desc limit {$ur['idx_jmllastcmt']}") or die(mysql_error());  
      echo 
      '<div class="nav">  
      <div class="navtitle"><b>Recent Comment:</b></div>  
      <div class="navbox">'
      ;  
      while(
      $holm=mysql_fetch_array($huterimata))  
      {  
      $holm['name']=substr(htmlentities($holm['name']), 0$ur['idx_lastcmtname']);  
      $holm['message']=stripslashes(substr(strip_tags(bbcodes($holm['message'])), 0$ur['idx_lastcmtpesan']));  
      echo 
      '<p id="lastcmt"><b>'.$holm['name'].'</b>: '.$holm['message'].' <a href="'.$ur['blog_dir'].blogpermalink($holm['blog_id']).'"><small>More..</small></a></p>  
      '
      ;  
      }  
      echo 
      '<a href="'.$ur['blog_dir'].'recentcomment"><img src="'.$ur['blog_dir'].'images/comments.png" alt=""> <b>View Last 15 Comments</b></a></div></div>  
      '
      ;  
      }  
      }  

      //End of Navigation Function  

      /***************************/  

      //Start of Misc Function  

      function admob_request($ur//admob_request($admob_params)  
      {  
      if(!
      preg_match('/^localhost$/i',$_SERVER['SERVER_NAME']))  
      {  
      $admob_params = array(  
        
      'ANALYTICS_ID'      => '',   
        
      'AD_REQUEST'        => true,   
        
      'ANALYTICS_REQUEST' => false,   
        
      'TEST_MODE'         => false,   
        
      'OPTIONAL'          => array()  
      );  
        static 
      $pixel_sent false;  

        
      $ad_mode false;  
        if (!empty(
      $ur['PUBLISHER_ID'])) $ad_mode true;  
          
        
      $analytics_mode false;  
        if (!empty(
      $admob_params['ANALYTICS_ID']) && !$pixel_sent$analytics_mode true;  
          
        
      $protocol 'http';  
        if (!empty(
      $_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'$protocol 'https';  
          
        
      $rt $ad_mode ? ($analytics_mode 0) : ($analytics_mode : -1);  
        if (
      $rt == -1) return '';  
          
        list(
      $usec$sec) = explode(' 'microtime());   
        
      $params = array('rt=' $rt,  
                        
      'z=' . ($sec $usec),  
                        
      'u=' urlencode($_SERVER['HTTP_USER_AGENT']),   
                        
      'i=' urlencode($_SERVER['REMOTE_ADDR']),   
                        
      'p=' urlencode("$protocol://" $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']),  
                        
      'v=' urlencode('20081105-PHPCURL-acda0040bcdea222'));   

        
      $sid = empty($admob_params['SID']) ? session_id() : $admob_params['SID'];  
        if (!empty(
      $sid)) $params[] = 't=' md5($sid);  
        if (
      $ad_mode$params[] = 's=' $ur['PUBLISHER_ID'];  
        if (
      $analytics_mode$params[] = 'a=' $admob_params['ANALYTICS_ID'];  
        if (!empty(
      $_COOKIE['admobuu'])) $params[] = 'o=' $_COOKIE['admobuu'];  
        if (!empty(
      $admob_params['TEST_MODE'])) $params[] = 'm=test';  

        if (!empty(
      $admob_params['OPTIONAL'])) {  
          foreach (
      $admob_params['OPTIONAL'] as $k => $v) {  
            
      $params[] = urlencode($k) . '=' urlencode($v);  
          }  
        }  

        
      $ignore = array('HTTP_PRAGMA' => true'HTTP_CACHE_CONTROL' => true'HTTP_CONNECTION' => true'HTTP_USER_AGENT' => true'HTTP_COOKIE' => true);  
        foreach (
      $_SERVER as $k => $v) {  
          if (
      substr($k04) == 'HTTP' && empty($ignore[$k]) && isset($v)) {  
            
      $params[] = urlencode('h[' $k ']') . '=' urlencode($v);  
          }  
        }  
          
        
      $post implode('&'$params);  
        
      $request curl_init();  
        
      $request_timeout 1// 1 second timeout  
        
      curl_setopt($requestCURLOPT_URL'http://r.admob.com/ad_source.php');  
        
      curl_setopt($requestCURLOPT_RETURNTRANSFER1);  
        
      curl_setopt($requestCURLOPT_TIMEOUT$request_timeout);  
        
      curl_setopt($requestCURLOPT_CONNECTTIMEOUT$request_timeout);  
        
      curl_setopt($requestCURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded''Connection: Close'));  
        
      curl_setopt($requestCURLOPT_POSTFIELDS$post);  
        list(
      $usec_start$sec_start) = explode(' 'microtime());  
        
      $contents curl_exec($request);  
        list(
      $usec_end$sec_end) = explode(' 'microtime());  
        
      curl_close($request);  

        if (
      $contents === true || $contents === false$contents '';  

        if (!
      $pixel_sent) {  
          
      $pixel_sent true;  
          
      $contents .= "<img src=\"$protocol://p.admob.com/e0?"  
                    
      'rt=' $rt  
                    
      '&amp;z=' . ($sec $usec)  
                    . 
      '&amp;a=' . ($analytics_mode $admob_params['ANALYTICS_ID'] : '')  
                    . 
      '&amp;s=' . ($ad_mode $ur['PUBLISHER_ID'] : '')  
                    . 
      '&amp;o=' . (empty($_COOKIE['admobuu']) ? '' $_COOKIE['admobuu'])  
                    . 
      '&amp;lt=' . ($sec_end $usec_end $sec_start $usec_start)  
                    . 
      '&amp;to=' $request_timeout  
                    
      '" alt="" width="1" height="1">';  
        }  
          
        return 
      $contents;  
      }  
      }  

      function 
      cutter($content,$start,$end//ini buat grabber (fungsi potong)  
      {  
      if(
      $content && $start && $end)   
      {  
      $r explode($start$content);  
      if (isset(
      $r[1])){  
      $r explode($end$r[1]);  
      return 
      $r[0];  
      }  
      return 
      '';  
      }  
      }  

      function 
      mobile() //return true jika terdeteksi user agen mobile  
      {  
      $text $_SERVER['HTTP_USER_AGENT'];  
      $mobile=false;  
      $var=array("Mozilla/4.",  
      "Mozilla/3.0",  
      "AvantGo",  
      "ProxiNet",  
      "Danger hiptop 1.0",  
      "DoCoMo/",  
      "Google CHTML Proxy/",  
      "UP.Browser/",  
      "SEMC-Browser/",  
      "J-PHONE/",  
      "PDXGW/",  
      "ASTEL/",  
      "Mozilla/1.22",  
      "Handspring",  
      "Windows CE",  
      "PPC",  
      "Mozilla/2.0",  
      "Blazer/",  
      "Palm",  
      "WebPro/",  
      "EPOC32-WTL/",  
      "Tungsten",  
      "Netfront/",  
      "Mobile Content Viewer/",  
      "PDA",  
      "MMP/2.0",  
      "Embedix/",  
      "Qtopia/",  
      "Xiino/",  
      "BlackBerry",  
      "Gecko/20031007",  
      "MOT-",  
      "UP.Link/",  
      "Smartphone",  
      "portalmmm/",  
      "Nokia",  
      "Symbian",  
      "AppleWebKit/413",  
      "UPG1 UP/",  
      "RegKing",  
      "STNC-WTL/",  
      "J2ME",  
      "Opera Mini/",  
      "SEC-",  
      "ReqwirelessWeb/",  
      "AU-MIC/",  
      "Sharp",  
      "SIE-",  
      "SonyEricsson",  
      "Elaine/",  
      "SAMSUNG-",  
      "Panasonic",  
      "Siemens",  
      "Sony",  
      "Verizon",  
      "Cingular",  
      "Sprint",  
      "AT&T;",  
      "Nextel",  
      "Pocket PC",  
      "T-Mobile';      
      'Orange"
      ,  
      "Casio",  
      "HTC",  
      "Motorola",  
      "Samsung",  
      "NEC");  
      $result count($var);  
      for (
      $i=0;$i<$result;$i++)  
      {      
      if(
      preg_match($var[$i],$text)) $mobile=true;  
      }  
      return 
      $mobile;  
      }  

      function 
      visit($ur//User online, hits today dan total hits  
      {  
      $session=session_id();  
      $time=time();  
      $time_check=$time-400;  
      $result=mysql_query("SELECT * FROM user_online WHERE user_ip='{$_SERVER['REMOTE_ADDR']}'");  
      $count=mysql_num_rows($result);  
      if(
      $count=="0")  
      {  
      $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));  
      $result1=mysql_query("INSERT INTO user_online (session, time, user_ip, user_browser, user_location) VALUES('$session', '$time', '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_USER_AGENT']}', '{$_SERVER['REQUEST_URI']}')");  
      }  
      else  
      {  
      $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));  
      $result2=mysql_query("UPDATE user_online SET time='$time', user_ip='{$_SERVER['REMOTE_ADDR']}', user_browser='{$_SERVER['HTTP_USER_AGENT']}', user_location='{$_SERVER['REQUEST_URI']}' WHERE session = '$session'");  
      }  
      $result3=mysql_query("SELECT * FROM user_online");  
      $user_online=mysql_num_rows($result3);  
      $result4=mysql_query("DELETE FROM user_online WHERE time<$time_check");  
      if(!isset(
      $_SESSION['user']) && !preg_match('/^bot$/i',$_SERVER['HTTP_USER_AGENT']))  
      {  
      mysql_query("update user set hittoday=hittoday+1, hit=hit+1 where id='1'");  
      }  
      echo 
      '<div class="visit"><small><a href="'.$ur['blog_dir'].'whos" target="_blank">'.$user_online.'</a> Online | Today: '.$ur['hittoday'].' visit | Total: '.$ur['hit'].' visit</small></div>  
      '
      ;  
      }  

      function 
      blogpermalink($id)  
      {  
      $per=mysql_query("select bloglink, cat_id from blog where id='$id'") or die(mysql_error());  
      $ma=mysql_fetch_row($per);  
      $link=catlink($ma[1]).'/'.$ma[0].'/';  
      return 
      $link;  
      }  

      function 
      catpermalink($id)  
      {  
      $per=mysql_query("select catlink from kategori where id='$id'") or die(mysql_error());  
      $ma=mysql_fetch_row($per);  
      $link='category/'.$ma[0].'/';  
      return 
      $link;  
      }  

      function 
      catname($cat_id)  
      {  
      $q=mysql_query("select kategori from kategori where id='$cat_id'") or die(mysql_error());  
      $w=mysql_fetch_row($q);  
      return 
      $w[0];  
      }  

      function 
      catlink($cat_id)  
      {  
      $ku=mysql_query("select catlink from kategori where id='$cat_id'") or die(mysql_error());  
      $ci=mysql_fetch_row($ku);  
      return 
      $ci[0];  
      }  

      function 
      bloglink($blog_id)  
      {  
      $bl=mysql_query("select bloglink from blog where id='$blog_id'") or die(mysql_error());  
      $lk=mysql_fetch_row($bl);  
      return 
      $lk[0];  
      }  

      function 
      catlinkid($cat_link)  
      {  
      $ct=mysql_query("select id from kategori where catlink='$cat_link'") or die(mysql_error());  
      $cid=mysql_fetch_row($ct);  
      return 
      $cid[0];  
      }  

      function 
      bloglinkid($blog_link)  
      {  
      $blg=mysql_query("select id from blog where bloglink='$blog_link'") or die(mysql_error());  
      $blid=mysql_fetch_row($blg);  
      return 
      $blid[0];  
      }  

      function 
      blogtitle($blog_link)  
      {  
      $blt=mysql_query("select title from blog where bloglink='$blog_link'") or die(mysql_error());  
      $bltt=mysql_fetch_row($blt);  
      return 
      $bltt[0];  
      }  

      function 
      blogcatid($blog_link)  
      {  
      $bci=mysql_query("select cat_id from blog where bloglink='$blog_link'") or die(mysql_error());  
      $bcid=mysql_fetch_row($bci);  
      return 
      $bcid[0];  
      }  

      function 
      username($user_id)  
      {  
      $huteri=mysql_query("select * from user where id='$user_id'") or die(mysql_error());  
      $manza=mysql_fetch_array($huteri);  
      return 
      $manza['name'];  
      }  

      function 
      userid($username)  
      {  
      $z=mysql_query("select id from user where name='$username' limit 1") or die(msyql_error());  
      $x=mysql_fetch_row($z);  
      return 
      $x[0];  
      }  

      function 
      catid($cat)  
      {  
      $v=mysql_query("select id from kategori where kategori='$cat'") or die(mysql_error());  
      $n=mysql_fetch_row($v);  
      return 
      $n[0];  
      }  

      function 
      jmlkomen($manzalog)  
      {  
      $huteri=mysql_query("select count(*) from comment where blog_id='$manzalog'");  
      $k=mysql_fetch_row($huteri);  
      return 
      $k[0];  
      }  

      function 
      cmtonoff($blog_id)  
      {  
      $co=mysql_query("select blogcmtonoff from blog where id='$blog_id'") or die(mysql_error());  
      $coo=mysql_fetch_row($co);  
      return 
      $coo[0];  
      }  

      function 
      jmlpercat($id)  
      {  
      $huteri=mysql_query("select count(id) from blog where cat_id='$id'") or die(mysql_error());  
      $manza=mysql_fetch_row($huteri);  
      return 
      $manza[0];  
      }  

      function 
      countcomment($id)  
      {  
      $count=mysql_query("select count(id) from comment where blog_id='$id' and date(time)=curdate()") or die(mysql_error());  
      $hasil=mysql_fetch_row($count);  
      return 
      $hasil[0];  
      }  

      //End of Misc Function 

      i did try to cover this the other day in another topic. but your attachment was broken. then your post was removed also.


      on another note:
      i have put a link to this topic on my post in the last topic this came up.
      also fixed a slight error i made in that post too.

      not sure why i didnt just copy and paste this thread from the link that ozzie got it from in the first place. but there you go.

      Edited
      Had To ReAdd Post, Some Code Got Cut Off.
      Fixed Now. Sorry.
      i should aslo note. i am not able to test the fixes. as i dont have the rest of the script.
      Last edited by Ghost; 08.08.12, 16:31.

      Comment


      • #4
        Originally posted by Ghost View Post
        i could only find 3 eregi sections in your func file.

        i replaced all 3 with the preg_match.
        PHP Code:
        //Start of main Function  

        function search_result($search$ur)  
        {  
        $nsearch=$search;  
        $search=mysql_real_escape_string(trim($search));  
        $search=preg_replace("/\\|'/",'',$search);   
        $show=$ur['blogperpage'];  
        $p $_GET['p'];  
        $title=implode("%' and title LIKE '%"explode(" ",$search));  
        $text=implode("%' and text LIKE '%"explode(" ",$search));  
        $count=mysql_query("SELECT id FROM blog WHERE title LIKE '%$title%' OR text LIKE '%$text%'") or die(mysql_error());  
        $total=mysql_num_rows($count);  
        if(
        $total=="0" || empty($search))  
        {  
        $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];  
        $ur['meta_robots']="noindex,nofollow";  
        pageheader($ur);  
        echo 
        '<div class="blog">  
        <div class="heading1">Search Result'
        .$hal.' for '.$nsearch.'</div></div>';  
        echo 
        "<div class=\"text\">No result found.  
        "
        ;  
        }  
        else  
        {  
        if(
        $p 1) {$hal=" Page #$p";}  
        $ur['title']="Result".$hal." for $nsearch | ".$ur['blog_name'];  
        $ur['meta_robots']="noindex,nofollow";  
        pageheader($ur);  
        echo 
        '<div class="blog">  
        <div class="heading1">Search Result'
        .$hal.' for '.$nsearch.'</div></div>';  
        $pg=ceil($total/$show);  
        if(
        $p>$pg && $p!=1)  
        $p=$pg;   
        if(
        $p<1)  
        $p=1;  
        $j = ($p-1) * $show;  
        $huteri=mysql_query("select id, bloglink, title, text, cat_id, date_format(time, '%d %b %Y') as 'time', date_format(uptime, '%d %b %Y') as 'uptime', uptime as 'timeorder', hit, hittoday, user_id from blog  WHERE title LIKE '%$title%' OR text LIKE '%$text%' order by timeorder desc limit $j$show") or die(mysql_error());  
        while(
        $manza=mysql_fetch_array($huteri))  
        {  
        bloglist($ur,$manza);  
        }  
        echo 
        "<div class=\"paging\">";  
        $sc=$ur['linkperpage'];  
        $st=floor($p/$sc)*$sc;  
        $en=$st+$sc;  
        $g=$st;  
        if(
        $g<"2") print("");  
        else  
        if(
        $g>"0")  
        print(
        "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".($g-1)."\">[&laquo;]</a> ");  
        else  
        print(
        "");  

        for(
        $g;($g<$en);$g++)  
            {  
        if(
        $g==$p)  
            {  
        print(
        " [<b>".$g."</b>] ");  
            }  
        elseif(
        $g<=$pg)  
            {  
        if(
        $g>"0")  
        print(
        "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">".$g."</a> ");  
            }  
        else  
            {  
        print(
        " ");  
            }  
            }  
        if(
        $g<=$pg)  
        print(
        "<a href=\"{$ur['blog_dir']}?search=".$search."&p=".$g."\">[&raquo;]</a>");  
        else  
        print(
        "");  
            }  
        echo 
        "</div>  
        "
        ;  
        quicknav($ur);  
        }  

        function 
        edit_save($_POST$ur)  
        {  
        if(empty(
        $_POST['title']) or empty($_POST['text'])) die("Data not complete.");  
        $_POST['blog']=trim($_POST['blog']);  
        $_POST['title']=$ur['idx_updatenot'].trim(addslashes(htmlentities($_POST['title'])));  
        $_POST['bloglink']=trim(addslashes($_POST['bloglink']));  
        $_POST['text']=trim(addslashes($_POST['text']));  
        if(empty(
        $_POST['bloglink'])) $_POST['bloglink']=stripper($_POST['title']);  

        mysql_query("update blog set title='{$_POST['title']}',bloglink='{$_POST['bloglink']}', text='{$_POST['text']}',cat_id='{$_POST['kategori']}' where id='{$_POST['blog']}'") or die(mysql_error());  
        if (
        $_POST['commentonoff']!=""mysql_query("update blog set blogcmtonoff='{$_POST['commentonoff']}' where id='{$_POST['blog']}'") or die(mysql_error());  
        if (
        $_POST['uptime']=="yes"mysql_query("update blog set uptime=now() where id='{$_POST['blog']}'") or die(mysql_error());  
        $_SESSION['statusmsg']='<font class="saved">Blog was updated successfully</font>';  
        header('location:'.$ur['blog_dir'].blogpermalink($_POST['blog']));  
        die();  
        }  

        function 
        form_edit($id$ur)  
        {  
        $fe=mysql_query("select * from blog where id='$id'") or die(mysql_error());  
        $r=mysql_fetch_array($fe);  
        if(
        mysql_num_rows($fe)=="0") die("Invalid data");  
        $r['title']=str_replace($ur['idx_updatenot'], ""stripslashes($r['title']));  
        $r['text']=htmlentities(stripslashes($r['text']));  
        $ur['title']="Edit Blog: ".$r['title']." | ".$ur['blog_name'];  
        $ur['meta_robots']="noindex,nofollow";  
        pageheader($ur);  
        echo 
        '<div class="blog">  
        <div class="heading1"><center>Edit Blog</center></div>  
        <div class="bl_box">  
        <form action="'
        .$ur['blog_dir'].'?blog&editsave" method="post">  
        <input type="hidden" name="blog" value="'
        .$r['id'].'">  

        Title:<br>  
        <input type="text" name="title" size="'
        .$ur['wr_titlesize'].'" value="'.$r['title'].'"><br><br>  
        Permalink:<br>  
        <input type="text" name="bloglink" size="'
        .$ur['wr_titlesize'].'" value="'.$r['bloglink'].'"><br><br>  
        Text: <br>  
        <textarea cols="'
        .$ur['wr_textcols'].'" rows="'.$ur['wr_textrows'].'" name="text" wrap="virtual">'.$r['text'].'</textarea><br>  
        Category:   
        <select name="kategori">  
        '
        ;  
        $ui=mysql_query("select id, kategori from kategori order by kategori") or die(mysql_error());  
        while(
        $o=mysql_fetch_array($ui))  
        {  
        echo 
        '<option value="'.$o['id'].'"';  
        if(
        $o['id']==$r['cat_id']) echo ' selected';  
        echo 
        '>'.htmlentities($o['kategori']).'</option>  
        '
        ;  
        }  
        echo 
        '</select><br>  
        <input type="checkbox" name="commentonoff" value ='
        ;  
        if (
        $r['blogcmtonoff']=="0") echo '"1"> Enable Comment<br>  
        '
        ;  
        else echo 
        '"0"> Disable Comment<br>  
        '
        ;  
        echo 
        '<input type="checkbox" name="uptime" value ="yes"> Update Time<br>  
        <input type="submit" value="Edit"></form><br>  
        <a href="'
        .$ur['blog_dir'].''.catlink($r['cat_id']).'/'.$r['bloglink'].'">Cancel</a>  
        </div></div>  
        '
        ;  
        }  

        function 
        blog_delete($id,$ur)  
        {  
        $id=str_replace("\""""str_replace("\'"""$id));  
        $l=mysql_query("select id from blog where id='$id'") or die(mysql_error());  
        if(
        mysql_num_rows($l)=="0") die("Invalid data");  

        mysql_query("delete from blog where id='$id'") or die(mysql_error());  
        mysql_query("delete from comment where blog_id='$id'") or die(mysql_error());  

        $_SESSION['statusmsg']='Blog is successfully deleted';  
        header('Location:'.$ur['blog_dir']);  
        die();  
        }  

        function 
        _code($match)  
        {  
        $match[1]=htmlentities(str_replace('http','hxxp',$match[1]));  
        return 
        '<div><b>Code:</b><div class="code">'.$match[1].'</div></div>';  
        }  

        function 
        _textarea($match)  
        {  
        return 
        '<textarea rows="4" cols="30">'.htmlentities($match[1]).'</textarea>';  
        }  

        function 
        bbcodes($pesan)  
        {  
        $bbcode = array(  
        "/\[b\](.*?)\[\/b\]/is" => "<b>$1</b>",  
        "/\[i\](.*?)\[\/i\]/is" => "<i>$1</i>",  
        "/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",  
        "/\[s\](.*?)\[\/s\]/is" => "<s>$1</s>",  
        "/\[br\]|\[br\/\]/is" => "<br>",  
        "/\[blink\](.*?)\[\/blink\]/is" => "<font style=\"text-decoration:blink\">$1</font>",  
        "/\[center\](.*?)\[\/center\]/is" => "<center>$1</center>",  
        "/\[red\](.*?)\[\/red\]/is" => "<font color=\"red\">$1</font>",  
        "/\[blue\](.*?)\[\/blue\]/is" => "<font color=\"blue\">$1</font>",  
        "/\[yellow\](.*?)\[\/yellow\]/is" => "<font color=\"yellow\">$1</font>",  
        "/\[green\](.*?)\[\/green\]/is" => "<font color=\"green\">$1</font>",  
        "/\[grey\](.*?)\[\/grey\]/is" => "<font color=\"grey\">$1</font>",  
        "/\[aqua\](.*?)\[\/aqua\]/is" => "<font color=\"aqua\">$1</font>",  
        "/\[black\](.*?)\[\/black\]/is" => "<font color=\"black\">$1</font>",  
        "/\[white\](.*?)\[\/white\]/is" => "<font color=\"white\">$1</font>",  
        "/\[img\](.*?)\[\/img\]/is" => "<img src=\"$1\" alt=\"img\">",  
        "/\[url\=(.*?)\](.*?)\[\/url\]/is" => "<a href=\"$1\" target=\"_blank\">$2</a>",  
        "/\[link\=(.*?)\](.*?)\[\/link\]/is" => "<a onclick=\"errr();\" href=\"$1\" target=\"_blank\">$2</a>",  
        "/\[color\=(.*?)\](.*?)\[\/color\]/is" => "<font color='$1'>$2</font>",  
        "/\[quote\=(.*?)\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote <b>\"$1\"</b>:</i><div class=\"quoted\">$2</div></div>",  
        "/\[quote\](.*?)\[\/quote\]/is" => "<div class=\"quote\"><i>Quote:</i><div class=\"quoted\">$1</div></div>",  
        "/\[right\](.*?)\[\/right\]/is" => "<div class=\"right\">$1</div>",  
        "/\[textarea\](.*?)\[\/textarea\]/is" => "<textarea rows=\"4\" cols=\"30\">$1</textarea>",  
        "/\[textarea=(.*?)\](.*?)\[\/textarea\]/is" => "<textarea rows=\"$1\" cols=\"30\">$2</textarea>",  
        "#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#" => "\\1<a onclick=\"errr();\" href=\"\\2\" target=\"_blank\">\\2</a>"  
        );  
        $pesan preg_replace_callback("/\[code\](.*?)\[\/code\]/is"'_code'$pesan);  
        $pesan=preg_replace(array_keys($bbcode), array_values($bbcode), $pesan);  
        $pesan=str_replace('hxxp','http',$pesan);  
        return 
        $pesan;  
        }  

        function 
        smiley($ur,$pesan)  
        {  
        $smiley = array(  
        "/:@/i" => "<img src=\"{$ur['blog_dir']}images/smiley/angry.png\" alt=\":@\">",  
        "/8-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/annoyed.png\" alt=\"8-)\">",  
        "/(:p|:-p)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cheeky.png\" alt=\":p\">",  
        "/B-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cool.png\" alt=\"B-)\">",  
        "/:'\(/i" => "<img src=\"{$ur['blog_dir']}images/smiley/cry.png\" alt=\":'(\">",  
        "/\^o\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/curious.png\" alt=\"^o)\">",  
        "/(:s|:-s)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/disgust.png\" alt=\":s\">",  
        "/(:\)|:-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/happy.png\" alt=\":)\">",  
        "/;-\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/wink.png\" alt=\";)\">",  
        "/(:\*|:-\*)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss.png\" alt=\":*\">",  
        "/(:x)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love.png\" alt=\":x\">",  
        "/8-\|/i" => "<img src=\"{$ur['blog_dir']}images/smiley/nerd.png\" alt=\"8-|\">",  
        "/(:\(|:-\()/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sad.png\" alt=\":(\">",  
        "/(:o|:-o)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/shocked.png\" alt=\":o\">",  
        '/:\$/i' => "<img src=\"{$ur['blog_dir']}images/smiley/shy.png\" alt=\":$\">",  
        "/(:\#|:-\#)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/silent.png\" alt=\":#\">",  
        "/(\|\)|\|-\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sleepy.png\" alt=\"|)\">",  
        "/(:\||:-\|)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flat.png\" alt=\":-|\">",  
        "/(:d|:-d)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/veryhappy.png\" alt=\":D\">",  
        "/\(dies\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dies.png\" alt=\"(dies)\">",  
        "/\(hypnotized\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dizzy.png\" alt=\"(hypnotized)\">",  
        "/\(err\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/err.png\" alt=\":(err)\">",  
        "/(:~|:-~)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/flirt.png\" alt=\":~\">",  
        "/%\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hypnotized.png\" alt=\"%)\">",  
        "/(&\)|&amp;\))/i" => "<img src=\"{$ur['blog_dir']}images/smiley/insane.png\" alt=\"&amp)\">",  
        "/:-=/i" => "<img src=\"{$ur['blog_dir']}images/smiley/sttt.png\" alt=\":-=\">",  
        "/:\\\/i" => "<img src=\"{$ur['blog_dir']}images/smiley/unimpressed.png\" alt=\":\\\">",  
        "/:\{/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yuck.png\" alt=\":{\">",  
        "/:\}/i" => "<img src=\"{$ur['blog_dir']}images/smiley/yum.png\" alt=\":}\">",  
        "/\(dog\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/dog.png\" alt=\"(dog)\">",  
        "/\(callme\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/callme.png\" alt=\"(callme)\">",  
        "/\(headphones\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/headphones.png\" alt=\"(headphones)\">",  
        "/\(love\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/love2.png\" alt=\"(love)\">",  
        "/\(hug\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/hug.png\" alt=\"(hug)\">",  
        "/\(beautiful\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/beautiful.png\" alt=\"(beautiful)\">",  
        "/\(bum\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/bum.png\" alt=\"(bum)\">",  
        "/\(devil\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/devil.png\" alt=\"(devil)\">",  
        "/\(poo\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/poo.png\" alt=\"(poo)\">",  
        "/\(reaper\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/reaper.png\" alt=\"(reaper)\">",  
        "/\(scream\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/scream.png\" alt=\"(scream)\">",  
        "/\(vamp\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vamp.png\" alt=\"(vamp)\">",  
        "/\(vomit\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/vomit.png\" alt=\"(vomit)\">",  
        "/\(kiss\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kiss2.png\" alt=\"(kiss)\">",  
        "/\(confused\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/confused.png\" alt=\"(confused)\">",  
        "/\(drool\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/drool.png\" alt=\"(drool)\">",  
        "/\(holdinghands\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/holdinghands.png\" alt=\"(holdinghands)\">",  
        "/\(buzz\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/buzz.png\" alt=\"(buzz)\">",  
        "/\(kick\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kick.png\" alt=\"(kick)\">",  
        "/\(ok\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/ok.png\" alt=\"(ok)\">",  
        "/\(punch\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/punch.png\" alt=\"(punch)\">",  
        "/\(thumbsup\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsup.png\" alt=\"(thumbsup)\">",  
        "/\(thumbsdown\)/i" => "<img src=\"{$ur['blog_dir']}images/smiley/thumbsdown.png\" alt=\"(thumbsdown)\">",  
        "/:hammers/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/hammers.gif\" alt=\":hammers\">",  
        "/:ngacir2/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir2.gif\" alt=\":hammers\">",  
        "/:ngacir:/i" => "<img src=\"{$ur['blog_dir']}images/smiley/kaskus/ngacir.gif\" alt=\":ngacir:\">"  
        );  
        $pesan=preg_replace(array_keys($smiley), array_values($smiley), $pesan);  
        return 
        $pesan;  
        }  

        function 
        stripper($link)  
        {  
        $link=strtolower($link);  
        $link=preg_replace('/[^a-z0-9]/',' ',$link);  
        $link=preg_replace('/\s\s+/',' ',$link);  
        $link=trim($link);  
        $link=str_replace(' ','-',$link);  
        return 
        $link;  
        }  

        function 
        signature($ur,$name)  
        {  
        $sgn=false;  
        if(
        preg_match("/^admin|administrator|{$ur['name']}/i",$name)) $sgn='<div class="signature">_____________<br>  
        '
        .bbcodes($ur['signature']).'</div>  
        '
        ;  
        return 
        $sgn;  
        }  

        function 
        post($comment$id$ur$bloglink$catlink)  
        {  

        $blogcek=mysql_query("SELECT id FROM blog WHERE bloglink='$bloglink'") or die(mysql_error());  
        $res=mysql_num_rows($blogcek);  

        if(
        $res<1)  
        {  
        $ridho=mysql_query("SELECT id FROM blog WHERE bloglink LIKE '%$bloglink%' limit 1") or die(mysql_error());  
        $blog=mysql_fetch_row($ridho);  
        if(empty(
        $blog[0]))  
        {  
        $ur['title']='Page Not Found';  
        $ur['meta_robots']='noindex,nofollow';  
        pageheader($ur);  
        error404();  
        }  
        else  
        {  
        header('Location:'.$ur['blog_dir'].blogpermalink($blog[0]));  
        die();  
        }  
        }  

        elseif(
        $catlink!=catlink(blogcatid($bloglink)))  
        {  
        header('Location:'.$ur['blog_dir'].blogpermalink(bloglinkid($bloglink)));  
        die();  
        }  

        else  
        {  
        if(!isset(
        $_SESSION['user'])) mysql_query("update blog set hittoday=hittoday+1 where bloglink='$bloglink'");  
        $huteri=mysql_query("select id, title, bloglink, text,  date_format(time, '%d %b %Y %H:%i') as 'time', date_format(uptime, '%d %b %Y %H:%i') as 'uptime', time as 'timecek', uptime as 'uptimecek', cat_id, hit, hittoday, user_id, blogcmtonoff from blog where bloglink='$bloglink'") or die(mysql_error());  
        if(
        mysql_num_rows($huteri)=="0") die("zero result");  
        $manza=mysql_fetch_array($huteri);  
        $manza['title']=str_replace($ur['idx_updatenot'], ""$manza['title']);  
        $manza['text']=str_replace("[more]","",$manza['text']);  
        $metadesc=htmlentities(strip_tags(substr(bbcodes($manza['text']),0,400)));  
        $id=$manza['id'];  
        if(
        $ur['bbcodeonoff']=="1"$manza['text']=bbcodes($manza['text']);  
        if(
        $ur['smileyonoff']=="1"$manza['text']=smiley($ur,$manza['text']);  
        $ur['title']=$manza['title']." | ".$ur['blog_name'];  
        $ur['meta_robots']="all,index,follow";  
        $ur['meta_description']=$metadesc;  
        pageheader($ur);  
        echo 
        '<div class="blog">  
        <div class="heading1"><center><h1><a href="'
        .$ur['blog_dir'].blogpermalink($manza['id']).'">'.$manza['title'].'</a></h1></center></div>  
        <div class="properties"><table border=0 cellspacing="0">  
        <tr><td>Date</td><td>: '
        .$manza['time'].'</td></tr>  
        '
        ;  

        if(
        $manza['uptimecek'] > $manza['timecek']) echo '<tr><td>Last Update</td><td>: '.$manza['uptime'].'</td></tr>  
        '
        ;  
        echo 
        '<tr><td>Category</td><td>: <a href="'.$ur['blog_dir'].'category/'.catlink($manza['cat_id']).'">'.catname($manza['cat_id']).'</a></td></tr>  
        <tr><td>Author</td><td>: '
        .username($manza['user_id']).'</td></tr>  
        <tr><td>Hits</td><td>: '
        .$manza['hittoday'].'/'.($manza['hittoday']+$manza['hit']).'</td></tr>  
        <td><tr><td>Share</td><td>: <a href="http://www.facebook.com/sharer.php?u=http://www.miserybd.com/'
        .$manza['id'].'" target="_blank" onclick="return fbb_share_js_794935();"><img src="http://3.bp.blogspot.com/_C6KkooKXCEw/TIBf2gtK0UI/AAAAAAAAGwE/Wml7-gPP17U/s200/facebook-c.png"></a> | <a href="http://twitter.com/share?url=http://www.miserybd.com/'.$manza['id'].'&via=abtmig&text='.$manza['title'].'" target="_blank"><img src="http://1.bp.blogspot.com/_C6KkooKXCEw/TIBf76kHm4I/AAAAAAAAGwk/RDwE7CSSsTc/s200/twitter-c.png"></a></td></tr>  
        <td>Shorten</td><td>: <a href="http://www.miserybd.com/'
        .$manza['id'].'">http://www.miserybd.com/'.$manza['id'].'</a></td></tr>  
        <center>  
        <script type="text/javascript"><!--  
        google_ad_client = "ca-pub-8834065160594185";  
        /* Scripts(468x60) */  
        google_ad_slot = "8804413658";  
        google_ad_width = 468;  
        google_ad_height = 60;  
        //-->  
        </script>  
        <script type="text/javascript"  
        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
        </script>  
        </center>  
        </table>  
        '
        ;  
        if(isset(
        $_SESSION['user'])) echo '<small><a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&edit">[Edit]</a> <a href="'.$ur['blog_dir'].'?blog='.$manza['id'].'&delete"><font class="red">[Delete]</font></a></small>';  
        echo 
        '</div>  
        <div class="text">'
        .stripslashes(nl2br($manza['text'])).'  
        </div></div>'
        ;  

        if(
        $ur['blg_seealsoonoff']=="1")  
        {  
        if(
        $ur['blg_seealsoorder']=="kategori"$rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' and cat_id='{$manza['cat_id']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());  
        else 
        $rand=mysql_query("select id, bloglink, title, cat_id from blog where bloglink<>'{$manza['bloglink']}' order by rand() limit {$ur['blg_seealsojml']}") or die(mysql_error());  
        echo 
        '<div class="blog">  
        <div class="bl_title"><b>See Also:</b></div>  
        <div class="bl_box">'
        ;  
        while(
        $randt=mysql_fetch_array($rand))  
        {  
        $randt['title']=str_replace($ur['idx_updatenot'], ""$randt['title']);  
        echo 
        '<img src="'.$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].''.catlink($randt['cat_id']).'/'.$randt['bloglink'].'">'.$randt['title'].'</a><br>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  
        }  

        echo 
        '<div class="none"><a href="'.$ur['blog_dir'].'">Home</a></div>  
        <div class="blog"><a name="comment"></a>  
        <div class="bl_title"><img src="'
        .$ur['blog_dir'].'images/comments.png" alt=""> <b>Comment</b> ('.jmlkomen($id).')</div>  
        <div class="bl_box">'
        ;  

        if(isset(
        $_SESSION['cmtmsg']))  
        {  
        echo 
        $_SESSION['cmtmsg'].'<br>  
        '
        ;  
        unset(
        $_SESSION['cmtmsg']);  
        }  

        $c=mysql_query("select id, name, message, date_format(time, '%d %b %Y %H:%i') as 'time', blog_id, url from comment where blog_id='{$manza['id']}' order by id desc limit {$ur['blg_komenperpage']}") or die(mysql_error());  
        if(
        mysql_num_rows($c)=="0") echo 'No Comment.';  
        else  
        {  
        while(
        $huterim=mysql_fetch_array($c))  
        {  
        $huterim['name']=stripslashes($huterim['name']);  
        $huterim['url']=stripslashes($huterim['url']);  
        $huterim['message']=stripslashes($huterim['message']);  
        $huterim['message']=nl2br($huterim['message']);  
        if(
        $ur['bbcodeonoff']=="1"$huterim['message']=bbcodes($huterim['message']);  
        if(
        $ur['smileyonoff']=="1"$huterim['message']=smiley($ur,$huterim['message']);  

        echo 
        '<div id="comment">  
        '
        ;  
        if(isset(
        $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$huterim['blog_id'].'&del='.$huterim['id'].'"><small style="color:red">[<b>x</b>]</small></a>';  
        if(
        $huterim['url']=="blank") echo '<a name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>  
        '
        ;  
        else echo 
        '<a href="'.$huterim['url'].'" target="_blank" name="'.$huterim['id'].'"><b><u>'.$huterim['name'].'</u></b></a>  
        '
        ;  

        echo 
        ' <sup>['.$huterim['time'].']</sup><br>  
        '
        ;  
        echo 
        $huterim['message'].signature($ur,$huterim['name']);  

        echo 
        '  
        </div>  
        '
        ;  
        }  
        echo 
        '<a href="comment/">View All</a>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  

        $_SESSION['angka']=rand(1,10000);  
        if(
        $manza['blogcmtonoff']==1)  
        {  
        echo 
        '<div class="blog"><a name="commentform"></a>  
        <div class="bl_title"><img src="'
        .$ur['blog_dir'].'images/comment.png" alt=""> <b>Leave a Comment</b></div>  
        <div class="bl_box">  
        <form action="'
        .$ur['blog_dir'].'comment.php" method="post">  
        <input type="hidden" name="blog_id" value="'
        .$manza['id'].'">  
        '
        ;  

        if(isset(
        $_SESSION['cmterror']))  
        {  
        echo 
        '<font class="error">Error: '.$_SESSION['cmterror'].'</font><br>  
        '
        ;  
        unset(
        $_SESSION['cmterror']);  
        }  

        if(isset(
        $_SESSION['user']))  
        {  
        echo 
        '<b>Comment as:</b><br>  
        <select name="name">  
        <option value="'
        .$ur['name'].'">'.$ur['name'].'</option>  
        <option value="Admin">Admin</option>  
        <option value="Administrator">Administrator</option>  
        </select><br>  
        <input type="checkbox" name="adminurl" value="1"><small><i>'
        .$ur['blog_url'].'</i></small><br>  
        <textarea rows="'
        .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.$comment['comment'].'</textarea><br>  
        '
        ;  
        if(
        $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';  
        else echo 
        'BB Code Disabled <br>  
        '
        ;  
        if(
        $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';  
        else echo 
        'Smiley Disabled  
        '
        ;  
        echo 
        '<br>  
        <input type="submit" value="Post" name="submit"></form>  
        <small><a href="'
        .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=disable">[Disable Comment]</a></small>  
        '
        ;  
        }  
        else  
        {  
        if(
        $_COOKIE['mb_comment_name']) $comment['name']=$_COOKIE['mb_comment_name'];  
        if(
        $_COOKIE['mb_comment_url']) $comment['url']=$_COOKIE['mb_comment_url'];  
        if(
        $_SESSION['cmtmessage'])   
        {  
        $comment['comment']=$_SESSION['cmtmessage'];  
        unset(
        $_SESSION['cmtmessage']);  
        }  
        echo 
        '<table border="0">  
        <tr><td>Name<font color=red>*</font></td>  
        <td>:</td><td><input type="text" name="name" size="'
        .$ur['blg_komennamesize'].'" value="'.$comment['name'].'"></td></tr>  
        <tr><td>Url</td>  
        <td>:</td><td><input type="text" name="url" size="'
        .$ur['blg_komenurlsize'].'" value="'.$comment['url'].'"></td></tr></table>  
        <table border="0" width="100%">  
        <tr><td>Comment<font color=red>*</font>:</td></tr>  
        <tr><td><textarea rows="'
        .$ur['blg_komenpesanrows'].'" cols="'.$ur['blg_komenpesancols'].'" name="comment">'.htmlentities($comment['comment']).'</textarea></td></tr>  
        <tr><td>  
        '
        ;  
        if(
        $ur['bbcodeonoff']=="1") echo '<a href="'.$ur['blog_dir'].'bbcode" target="_blank">[BB Code]</a> ';  
        else echo 
        'BB Code Disabled<br>  
        '
        ;  
        if(
        $ur['smileyonoff']=="1") echo '<a href="'.$ur['blog_dir'].'smiley" target="_blank">[Smiley]</a>';  
        else echo 
        'Smiley Disabled  
        '
        ;  
        echo 
        '</td></tr></table>  
        <table border="0">  
        <tr><td>Code<font color=red>*</font>: <b>'
        .$_SESSION['angka'].'</b> <input type="text" name="kode" size="4"></td><td><input type="submit" value="Post" name="submit"></td></tr></table>  
        </form>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  
        }  

        else  
        {  
        echo 
        '<div class="blog">  
        <div class="bl_title"><b>Leave a Comment</b></div>  
        <div class="bl_box">Post comment is currently disabled.  
        '
        ;  
        if(isset(
        $_SESSION['user'])) echo '<br>  
        <small><a href="'
        .$ur['blog_dir'].'?blog='.$manza['id'].'&comment=enable">[Enable Comment]</a></small>';  
        echo 
        '</div></div>  
        '
        ;  
        }  
        }  
        }  

        function 
        bloglist($ur,$blog)  
        {  
        $cat=catname($blog['cat_id']);  
        $user=username($blog['user_id']);  
        $blog['title']=stripslashes($blog['title']);  
        $blog['text']=stripslashes($blog['text']);  
        $blog['text']=strip_tags(bbcodes($blog['text']));  
        if(
        strstr($blog['text'],"[more]")) $ur['idx_textperblog']=strpos($blog['text'],"[more]");  
        $blog['text']=nl2br(substr($blog['text'],0,$ur['idx_textperblog']));  
        echo 
        '<div class="blog">  
        <div class="bl_title">  
        <b><a href="'
        .$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'">'.$blog['title'].'</a></b>';  
        if(isset(
        $_SESSION['user']))  
        {  
        echo 
        ' <small><a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&edit">[Edit]</a> | <a href="'.$ur['blog_dir'].'?blog='.$blog['id'].'&delete"><font class="red">[Delete]</font></a></small>';  
        $check=strpos($blog['title'], $ur['idx_updatenot']);  
        if(
        $check!==false) echo ' | <a href="'.$ur['blog_dir'].'?delnot='.$blog['id'].'"><small>[Del Notify]</small></a>';  
        }  
        echo 
        '</div>  
        <div class="bl_box">  
        '
        .$blog['uptime'].' under <a href="'.$ur['blog_dir'].'category/'.catlink($blog['cat_id']).'">'.$cat.'</a> by '.$user.'<br>';  
        if(
        $ur['idx_hitonoff']=="1")  
        {  
        if(
        $ur['idx_hittodayonoff']=="1") echo ' [View: '.$blog['hittoday'].'/'.($blog['hittoday']+$blog['hit']).']';  
        else echo 
        ' [View: '.($blog['hittoday']+$blog['hit']).' ]';  
        }  
        if(
        $ur['idx_komenonoff']=="1")  
        {  
        if(
        $ur['idx_cmttodayonoff']=="1") echo ' [Comment: '.countcomment($blog['id']).'/'.jmlkomen($blog['id']).']';  
        else echo 
        ' [Comment: '.jmlkomen($blog['id']).']';  
        }  

        echo 
        '</div>  
        <div class="bl_box">  
        '
        .$blog['text'].' <small>[...]</small> <i><a href="'.$ur['blog_dir'].''.catlink($blog['cat_id']).'/'.$blog['bloglink'].'"><small>Read More</small></a></i><br>  
        '
        ;  
        echo 
        '</div></div>  
        '
        ;  
        }  

        function 
        commentlist($ur,$comment)  
        {  
        echo 
        '<div id="comment">';  
        if(isset(
        $_SESSION['user'])) echo '<a class="x" href="'.$ur['blog_dir'].'comment.php?post='.$comment['blog_id'].'&del='.$comment['id'].'"><small style="color:red">[<b>x</b>]</small></a>';  
        $comment['name']=htmlentities(stripslashes($comment['name']));  
        $comment['message']=stripslashes($comment['message']);  
        if(
        $ur['bbcodeonoff']=="1"$comment['message']=bbcodes($comment['message']);  
        if(
        $ur['smileyonoff']=="1"$comment['message']=smiley($ur,$comment['message']);  
        $comment['message']=nl2br($comment['message']);  
        $comment['url']=htmlentities(stripslashes($comment['url']));  

        if(
        $comment['url']=='blank') echo '<b>'.$comment['name'].'</b>';  
        else echo 
        '<a href="'.$comment['url'].'" target="_blank"><b>'.$comment['name'].'</b></a>';  

        $title=str_replace($ur['idx_updatenot'],"",blogtitle(bloglink($comment['blog_id'])));  
        echo 
        ' on <a href="'.$ur['blog_dir'].blogpermalink($comment['blog_id']).'">'.$title.'</a><br>  
        <small>At '
        .$comment['time'].'<br>  
        IP: '
        .$comment['ip'].'<br>  
        Browser: '
        .$comment['browser'].'</small><br>  
        <div class="cmttext">'
        .$comment['message'].signature($ur,$comment['name']).'  
        </div></div>'
        ;  
        }  

        function 
        error404()  
        {  
        echo 
        '<div class="text">  
        <p align="center">  
        <font size="5">Error 404 - Page Not Found.</font><br><br>  
        Sorry Which Pages or files are u looking for thats not found.Please tell admin about this.<br><br>  
        </p></div>'
        ;  
        }  

        //End of Main Function  

        /***************************/  

        //Start of Navigation Function  

        function navbar($ur//panel navigasi untuk tampilan full  
        {  
        echo 
        '<div class="navbar">  
        '
        ;  
        search($ur);  
        menu($ur);  
        mosthittoday($ur);  
        mosthitall($ur);  
        listcat($ur);  
        lastcomment($ur);  
        echo 
        '</div>  
        '
        ;  
        echo 
        '<div class="leftsb">  
        <div class="navbox"><div class="navtitle"><b>Left Slide Bar</b></div></div>  
        <div class="navbox"><div class="navtitle"><b>Sponsors</b></div></div>  
        <div class="navbox">  
        <center>  
        <script type="text/javascript"><!--  
        google_ad_client = "ca-pub-8834065160594185";  
        /* Scripts(160x600) */  
        google_ad_slot = "5070042074";  
        google_ad_width = 160;  
        google_ad_height = 600;  
        //-->  
        </script>  
        <script type="text/javascript"  
        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
        </script></center>  
        </div>  
        </div>  
        '
        ;  
        }  

        function 
        quicknav($ur//menu navigasi homepage untuk mobile  
        {  
        if(
        $ur['mobile'])  
        {  
        search($ur);  
        menu($ur);  
        listcat($ur);  
        lastcomment($ur);  
        mosthittoday($ur);  
        mosthitall($ur);  
        }  
        }  

        function 
        search($ur)  
        {  
        if(isset(
        $_SESSION['form']))  
        {  
        echo 
        $_SESSION['form'];  
        }  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Search</b></div>  
        <div class="navbox"><form action="'
        .$ur['blog_dir'].'?search" method="GET">  
        <table border=0>  
        <tr><td width="75%"><input class="searchbox" type="text" name="search" size="'
        .$ur['idx_searchsize'].'"></td><td><input type="submit" value="search"></td></tr>  
        </table>  
        </form></div></div>  
        '
        ;  
        }  

        function 
        admin($ur)  
        {  
        if(isset(
        $_SESSION['user'])) echo '<br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php">Admin Area</a><br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'admin.php?postitem">Write Item</a><br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?logout">Log Out</a><br>  
        '
        ;  
        else echo 
        '<br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'?login&forward='.urlencode($_SERVER['REQUEST_URI']).'">Login</a>';  
        }  

        function 
        menu($ur)  
        {  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Menu</b></div>  
        <div class="navbox">  
        <img src="'
        .$ur['blog_dir'].'images/rssblue.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'rss">RSS Feed</a><br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'about">About</a><br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'archive">Archive</a><br>  
        <img src="'
        .$ur['blog_dir'].'images/right.png" alt="&raquo;"> <a href="'.$ur['blog_dir'].'sitemap">Sitemap</a>';  
        admin($ur);  
        echo 
        '</div></div>  
        '
        ;  
        }  

        function 
        listcat($ur)  
        {  
        $huteri=mysql_query("select * from kategori order by catlink") or die(mysql_error());  
        $huterim=mysql_query("select count(id) from blog") or die(mysql_error());  
        $c=mysql_fetch_row($huterim);  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Category:</b></div>  
        <div class="navbox">  
        <p><a href="'
        .$ur['blog_dir'].'">All</a> ['.$c[0].']</p>  
        '
        ;  
        while(
        $manza=mysql_fetch_row($huteri))  
        {  
        echo 
        '<p><a href="'.$ur['blog_dir'].'category/'.$manza[2].'">'.$manza[1].'</a> ['.jmlpercat($manza[0]).']  
        '
        ;  
        if(isset(
        $_SESSION['user'])) echo ' <small><a href="'.$ur['blog_dir'].'?edt='.$manza[0].'#edt">[E]</a> <a href="'.$ur['blog_dir'].'?del='.$manza[0].'"><font class="red">[D]</font></a></small>  
        '
        ;  
        echo 
        '</p>  
        '
        ;  
        }  
        if(isset(
        $_GET['delsave']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>  
        '
        ;  
        $_GET['deluser']=trim($_GET['deluser']);  
        mysql_query("delete from kategori where id='{$_GET['delsave']}'") or die(mysql_error());  
        mysql_query("delete from blog where cat_id='{$_GET['delsave']}'") or die(mysql_error());  
        mysql_query("delete from comment where cat_id='{$_GET['delsave']}'") or die(mysql_error());  
        echo 
        "Category Deleted <a href=./>Refresh</a>  
        "
        ;  
        }  
        elseif(isset(
        $_GET['del']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden <a href="./">Refresh</a>  
        '
        ;  
        else  
        {  
        $p=mysql_query("select id from kategori where id='{$_GET['del']}'") or die(mysql_error());  
        if(
        mysql_num_rows($p)=="0") echo 'No Data Found <a href=./>Refresh</a>  
        '
        ;  
        else echo 
        'Are you sure want to delete this Category? This\'ll delete all blog with this category.<br>  
        <a href="'
        .$ur['blog_dir'].'?delsave='.$_GET['del'].'">Yes</a> | <a href="./">No</a>  
        '
        ;  
        }  
        }  
        elseif(isset(
        $_GET['edtsave']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>  
        '
        ;  
        else  
        {  
        $_POST['edit']=trim(addslashes($_POST['edit']));  
        $catlink=stripper($_POST['edit']);  
        if(empty(
        $_POST['edit'])) echo 'Empty Data <a href="'.$ur['blog_dir'].'">Refresh</a>  
        '
        ;  
        else  
        {  
        mysql_query("update kategori set kategori='{$_POST['edit']}', catlink='$catlink' where id='{$_POST['id']}'") or die(mysql_error());  
        echo 
        'Update berhasil <a href="'.$ur['blog_dir'].'">Refresh</a>  
        '
        ;  
        }  
        }  
        }  
        elseif(isset(
        $_GET['edt']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden <a href="'.$ur['blog_dir'].'">Refresh</a>  
        '
        ;  
        else  
        {  
        $_GET['edt']=trim($_GET['edt']);  
        $g=mysql_query("select * from kategori where id='{$_GET['edt']}'") or die(mysql_error());  
        $h=mysql_fetch_array($g);  
        if(
        mysql_num_rows($g)=="0" or mysql_num_rows($g)>"1") echo 'Wrong Data <a href=./>Refresh</a>  
        '
        ;  
        else echo 
        '<form action="'.$ur['blog_dir'].'?edtsave" method="post"> <input type="hidden" name="id" value="'.$_GET['edt'].'">  
        <a name="edt"></a>Edit:<br>  
        <input type="text" name="edit" value="'
        .htmlentities($h['kategori']).'"><br>  
        <input type="submit" value="OK"></form>  
        '
        ;  
        }  
        }  
        elseif(isset(
        $_GET['newcatsave']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden <a href=./>Refresh</a>  
        '
        ;  
        else  
        {  
        $_POST['newcat']=trim(addslashes($_POST['newcat']));  
        $catlink=stripper($_POST['newcat']);  
        $newcategory=$_POST['newcat'];  
        $u=mysql_query("select id from kategori where kategori='{$_POST['newcat']}'") or die(mysql_error());  
        if(empty(
        $_POST['newcat'])) echo 'Empty Data <a href=./>Refresh</a>  
        '
        ;  
        elseif(
        mysql_num_rows($u)!="0") echo 'Category already exist <a href=./>Refresh</a>  
        '
        ;  
        else  
        {  
        mysql_query("insert into kategori (kategori, catlink) values ('$newcategory', '$catlink')") or die(mysql_error());  
        echo 
        'Creating Success!! <a href="./">Refresh</a>  
        '
        ;  
        }  
        }  
        }  
        elseif(isset(
        $_GET['newcat']))  
        {  
        if(!isset(
        $_SESSION['user'])) echo 'Forbidden. ';  
        else echo 
        '<form action="'.$ur['blog_dir'].'?newcatsave" method="post">  
        <a name="nc"></a>New:<br>  
        <input type="text" name="newcat">  
        <br>  
        <input type="submit" value="OK"></form>  
        '
        ;  
        }  
        else  
        {  
        if(isset(
        $_SESSION['user'])) echo '<a href="'.$ur['blog_dir'].'?newcat#nc">New Category</a>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  
        }  

        function 
        mosthittoday($ur)  
        {  
        if(
        $ur['idx_mosthittodayonoff']=="1")  
        {  
        $huterimata=mysql_query("select * from blog order by hittoday desc limit {$ur['idx_jmlmosthittoday']}") or die(mysql_error());  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Most Hit Today:</b></div>  
        <div class="navbox">'
        ;  
        while(
        $f=mysql_fetch_array($huterimata))  
        {  
        $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);  
        echo 
        '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hittoday'].' Hits)</p>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  
        }  
        }  

        function 
        mosthitall($ur)  
        {  
        if(
        $ur['idx_mosthitonoff']=="1")  
        {  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Most Hit:</b></div>  
        <div class="navbox">'
        ;  
        $huterimata=mysql_query("select * from blog order by hit desc limit {$ur['idx_jmlmosthit']}") or die(mysql_error());  
        while(
        $f=mysql_fetch_array($huterimata))  
        {  
        $f['title']=str_replace($ur['idx_updatenot'], ""$f['title']);  
        echo 
        '<p><a href="'.$ur['blog_dir'].blogpermalink($f['id']).'">'.$f['title'].'</a> ('.$f['hit'].' Hits)</p>  
        '
        ;  
        }  
        echo 
        '</div></div>  
        '
        ;  
        }  
        }  

        function 
        lastcomment($ur)  
        {  
        if(
        $ur['idx_lastcmtonoff']=="1")  
        {  
        $huterimata=mysql_query("select * from comment order by id desc limit {$ur['idx_jmllastcmt']}") or die(mysql_error());  
        echo 
        '<div class="nav">  
        <div class="navtitle"><b>Recent Comment:</b></div>  
        <div class="navbox">'
        ;  
        while(
        $holm=mysql_fetch_array($huterimata))  
        {  
        $holm['name']=substr(htmlentities($holm['name']), 0$ur['idx_lastcmtname']);  
        $holm['message']=stripslashes(substr(strip_tags(bbcodes($holm['message'])), 0$ur['idx_lastcmtpesan']));  
        echo 
        '<p id="lastcmt"><b>'.$holm['name'].'</b>: '.$holm['message'].' <a href="'.$ur['blog_dir'].blogpermalink($holm['blog_id']).'"><small>More..</small></a></p>  
        '
        ;  
        }  
        echo 
        '<a href="'.$ur['blog_dir'].'recentcomment"><img src="'.$ur['blog_dir'].'images/comments.png" alt=""> <b>View Last 15 Comments</b></a></div></div>  
        '
        ;  
        }  
        }  

        //End of Navigation Function  

        /***************************/  

        //Start of Misc Function  

        function admob_request($ur//admob_request($admob_params)  
        {  
        if(!
        preg_match('/^localhost$/i',$_SERVER['SERVER_NAME']))  
        {  
        $admob_params = array(  
          
        'ANALYTICS_ID'      => '',   
          
        'AD_REQUEST'        => true,   
          
        'ANALYTICS_REQUEST' => false,   
          
        'TEST_MODE'         => false,   
          
        'OPTIONAL'          => array()  
        );  
          static 
        $pixel_sent false;  

          
        $ad_mode false;  
          if (!empty(
        $ur['PUBLISHER_ID'])) $ad_mode true;  
            
          
        $analytics_mode false;  
          if (!empty(
        $admob_params['ANALYTICS_ID']) && !$pixel_sent$analytics_mode true;  
            
          
        $protocol 'http';  
          if (!empty(
        $_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off'$protocol 'https';  
            
          
        $rt $ad_mode ? ($analytics_mode 0) : ($analytics_mode : -1);  
          if (
        $rt == -1) return '';  
            
          list(
        $usec$sec) = explode(' 'microtime());   
          
        $params = array('rt=' $rt,  
                          
        'z=' . ($sec $usec),  
                          
        'u=' urlencode($_SERVER['HTTP_USER_AGENT']),   
                          
        'i=' urlencode($_SERVER['REMOTE_ADDR']),   
                          
        'p=' urlencode("$protocol://" $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']),  
                          
        'v=' urlencode('20081105-PHPCURL-acda0040bcdea222'));   

          
        $sid = empty($admob_params['SID']) ? session_id() : $admob_params['SID'];  
          if (!empty(
        $sid)) $params[] = 't=' md5($sid);  
          if (
        $ad_mode$params[] = 's=' $ur['PUBLISHER_ID'];  
          if (
        $analytics_mode$params[] = 'a=' $admob_params['ANALYTICS_ID'];  
          if (!empty(
        $_COOKIE['admobuu'])) $params[] = 'o=' $_COOKIE['admobuu'];  
          if (!empty(
        $admob_params['TEST_MODE'])) $params[] = 'm=test';  

          if (!empty(
        $admob_params['OPTIONAL'])) {  
            foreach (
        $admob_params['OPTIONAL'] as $k => $v) {  
              
        $params[] = urlencode($k) . '=' urlencode($v);  
            }  
          }  

          
        $ignore = array('HTTP_PRAGMA' => true'HTTP_CACHE_CONTROL' => true'HTTP_CONNECTION' => true'HTTP_USER_AGENT' => true'HTTP_COOKIE' => true);  
          foreach (
        $_SERVER as $k => $v) {  
            if (
        substr($k04) == 'HTTP' && empty($ignore[$k]) && isset($v)) {  
              
        $params[] = urlencode('h[' $k ']') . '=' urlencode($v);  
            }  
          }  
            
          
        $post implode('&'$params);  
          
        $request curl_init();  
          
        $request_timeout 1// 1 second timeout  
          
        curl_setopt($requestCURLOPT_URL'http://r.admob.com/ad_source.php');  
          
        curl_setopt($requestCURLOPT_RETURNTRANSFER1);  
          
        curl_setopt($requestCURLOPT_TIMEOUT$request_timeout);  
          
        curl_setopt($requestCURLOPT_CONNECTTIMEOUT$request_timeout);  
          
        curl_setopt($requestCURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded''Connection: Close'));  
          
        curl_setopt($requestCURLOPT_POSTFIELDS$post);  
          list(
        $usec_start$sec_start) = explode(' 'microtime());  
          
        $contents curl_exec($request);  
          list(
        $usec_end$sec_end) = explode(' 'microtime());  
          
        curl_close($request);  

          if (
        $contents === true || $contents === false$contents '';  

          if (!
        $pixel_sent) {  
            
        $pixel_sent true;  
            
        $contents .= "<img src=\"$protocol://p.admob.com/e0?"  
                      
        'rt=' $rt  
                      
        '&amp;z=' . ($sec $usec)  
                      . 
        '&amp;a=' . ($analytics_mode $admob_params['ANALYTICS_ID'] : '')  
                      . 
        '&amp;s=' . ($ad_mode $ur['PUBLISHER_ID'] : '')  
                      . 
        '&amp;o=' . (empty($_COOKIE['admobuu']) ? '' $_COOKIE['admobuu'])  
                      . 
        '&amp;lt=' . ($sec_end $usec_end $sec_start $usec_start)  
                      . 
        '&amp;to=' $request_timeout  
                      
        '" alt="" width="1" height="1">';  
          }  
            
          return 
        $contents;  
        }  
        }  

        function 
        cutter($content,$start,$end//ini buat grabber (fungsi potong)  
        {  
        if(
        $content && $start && $end)   
        {  
        $r explode($start$content);  
        if (isset(
        $r[1])){  
        $r explode($end$r[1]);  
        return 
        $r[0];  
        }  
        return 
        '';  
        }  
        }  

        function 
        mobile() //return true jika terdeteksi user agen mobile  
        {  
        $text $_SERVER['HTTP_USER_AGENT'];  
        $mobile=false;  
        $var=array("Mozilla/4.",  
        "Mozilla/3.0",  
        "AvantGo",  
        "ProxiNet",  
        "Danger hiptop 1.0",  
        "DoCoMo/",  
        "Google CHTML Proxy/",  
        "UP.Browser/",  
        "SEMC-Browser/",  
        "J-PHONE/",  
        "PDXGW/",  
        "ASTEL/",  
        "Mozilla/1.22",  
        "Handspring",  
        "Windows CE",  
        "PPC",  
        "Mozilla/2.0",  
        "Blazer/",  
        "Palm",  
        "WebPro/",  
        "EPOC32-WTL/",  
        "Tungsten",  
        "Netfront/",  
        "Mobile Content Viewer/",  
        "PDA",  
        "MMP/2.0",  
        "Embedix/",  
        "Qtopia/",  
        "Xiino/",  
        "BlackBerry",  
        "Gecko/20031007",  
        "MOT-",  
        "UP.Link/",  
        "Smartphone",  
        "portalmmm/",  
        "Nokia",  
        "Symbian",  
        "AppleWebKit/413",  
        "UPG1 UP/",  
        "RegKing",  
        "STNC-WTL/",  
        "J2ME",  
        "Opera Mini/",  
        "SEC-",  
        "ReqwirelessWeb/",  
        "AU-MIC/",  
        "Sharp",  
        "SIE-",  
        "SonyEricsson",  
        "Elaine/",  
        "SAMSUNG-",  
        "Panasonic",  
        "Siemens",  
        "Sony",  
        "Verizon",  
        "Cingular",  
        "Sprint",  
        "AT&T;",  
        "Nextel",  
        "Pocket PC",  
        "T-Mobile';      
        'Orange"
        ,  
        "Casio",  
        "HTC",  
        "Motorola",  
        "Samsung",  
        "NEC");  
        $result count($var);  
        for (
        $i=0;$i<$result;$i++)  
        {      
        if(
        preg_match($var[$i],$text)) $mobile=true;  
        }  
        return 
        $mobile;  
        }  

        function 
        visit($ur//User online, hits today dan total hits  
        {  
        $session=session_id();  
        $time=time();  
        $time_check=$time-400;  
        $result=mysql_query("SELECT * FROM user_online WHERE user_ip='{$_SERVER['REMOTE_ADDR']}'");  
        $count=mysql_num_rows($result);  
        if(
        $count=="0")  
        {  
        $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));  
        $result1=mysql_query("INSERT INTO user_online (session, time, user_ip, user_browser, user_location) VALUES('$session', '$time', '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_USER_AGENT']}', '{$_SERVER['REQUEST_URI']}')");  
        }  
        else  
        {  
        $_SERVER['HTTP_USER_AGENT']=strip_tags(addslashes($_SERVER['HTTP_USER_AGENT']));  
        $result2=mysql_query("UPDATE user_online SET time='$time', user_ip='{$_SERVER['REMOTE_ADDR']}', user_browser='{$_SERVER['HTTP_USER_AGENT']}', user_location='{$_SERVER['REQUEST_URI']}' WHERE session = '$session'");  
        }  
        $result3=mysql_query("SELECT * FROM user_online");  
        $user_online=mysql_num_rows($result3);  
        $result4=mysql_query("DELETE FROM user_online WHERE time<$time_check");  
        if(!isset(
        $_SESSION['user']) && !preg_match('/^bot$/i',$_SERVER['HTTP_USER_AGENT']))  
        {  
        mysql_query("update user set hittoday=hittoday+1, hit=hit+1 where id='1'");  
        }  
        echo 
        '<div class="visit"><small><a href="'.$ur['blog_dir'].'whos" target="_blank">'.$user_online.'</a> Online | Today: '.$ur['hittoday'].' visit | Total: '.$ur['hit'].' visit</small></div>  
        '
        ;  
        }  

        function 
        blogpermalink($id)  
        {  
        $per=mysql_query("select bloglink, cat_id from blog where id='$id'") or die(mysql_error());  
        $ma=mysql_fetch_row($per);  
        $link=catlink($ma[1]).'/'.$ma[0].'/';  
        return 
        $link;  
        }  

        function 
        catpermalink($id)  
        {  
        $per=mysql_query("select catlink from kategori where id='$id'") or die(mysql_error());  
        $ma=mysql_fetch_row($per);  
        $link='category/'.$ma[0].'/';  
        return 
        $link;  
        }  

        function 
        catname($cat_id)  
        {  
        $q=mysql_query("select kategori from kategori where id='$cat_id'") or die(mysql_error());  
        $w=mysql_fetch_row($q);  
        return 
        $w[0];  
        }  

        function 
        catlink($cat_id)  
        {  
        $ku=mysql_query("select catlink from kategori where id='$cat_id'") or die(mysql_error());  
        $ci=mysql_fetch_row($ku);  
        return 
        $ci[0];  
        }  

        function 
        bloglink($blog_id)  
        {  
        $bl=mysql_query("select bloglink from blog where id='$blog_id'") or die(mysql_error());  
        $lk=mysql_fetch_row($bl);  
        return 
        $lk[0];  
        }  

        function 
        catlinkid($cat_link)  
        {  
        $ct=mysql_query("select id from kategori where catlink='$cat_link'") or die(mysql_error());  
        $cid=mysql_fetch_row($ct);  
        return 
        $cid[0];  
        }  

        function 
        bloglinkid($blog_link)  
        {  
        $blg=mysql_query("select id from blog where bloglink='$blog_link'") or die(mysql_error());  
        $blid=mysql_fetch_row($blg);  
        return 
        $blid[0];  
        }  

        function 
        blogtitle($blog_link)  
        {  
        $blt=mysql_query("select title from blog where bloglink='$blog_link'") or die(mysql_error());  
        $bltt=mysql_fetch_row($blt);  
        return 
        $bltt[0];  
        }  

        function 
        blogcatid($blog_link)  
        {  
        $bci=mysql_query("select cat_id from blog where bloglink='$blog_link'") or die(mysql_error());  
        $bcid=mysql_fetch_row($bci);  
        return 
        $bcid[0];  
        }  

        function 
        username($user_id)  
        {  
        $huteri=mysql_query("select * from user where id='$user_id'") or die(mysql_error());  
        $manza=mysql_fetch_array($huteri);  
        return 
        $manza['name'];  
        }  

        function 
        userid($username)  
        {  
        $z=mysql_query("select id from user where name='$username' limit 1") or die(msyql_error());  
        $x=mysql_fetch_row($z);  
        return 
        $x[0];  
        }  

        function 
        catid($cat)  
        {  
        $v=mysql_query("select id from kategori where kategori='$cat'") or die(mysql_error());  
        $n=mysql_fetch_row($v);  
        return 
        $n[0];  
        }  

        function 
        jmlkomen($manzalog)  
        {  
        $huteri=mysql_query("select count(*) from comment where blog_id='$manzalog'");  
        $k=mysql_fetch_row($huteri);  
        return 
        $k[0];  
        }  

        function 
        cmtonoff($blog_id)  
        {  
        $co=mysql_query("select blogcmtonoff from blog where id='$blog_id'") or die(mysql_error());  
        $coo=mysql_fetch_row($co);  
        return 
        $coo[0];  
        }  

        function 
        jmlpercat($id)  
        {  
        $huteri=mysql_query("select count(id) from blog where cat_id='$id'") or die(mysql_error());  
        $manza=mysql_fetch_row($huteri);  
        return 
        $manza[0];  
        }  

        function 
        countcomment($id)  
        {  
        $count=mysql_query("select count(id) from comment where blog_id='$id' and date(time)=curdate()") or die(mysql_error());  
        $hasil=mysql_fetch_row($count);  
        return 
        $hasil[0];  
        }  

        //End of Misc Function 

        i did try to cover this the other day in another topic. but your attachment was broken. then your post was removed also.


        on another note:
        i have put a link to this topic on my post in the last topic this came up.
        also fixed a slight error i made in that post too.

        not sure why i didnt just copy and paste this thread from the link that ozzie got it from in the first place. but there you go.

        Edited
        Had To ReAdd Post, Some Code Got Cut Off.
        Fixed Now. Sorry.
        i should aslo note. i am not able to test the fixes. as i dont have the rest of the script.

        thanks for the effort...i hope it will work...

        Added after 3 minutes:

        here is the error sir ghost
        Attached Files
        Last edited by hi_jakkk; 08.08.12, 16:53.

        Comment


        • #5
          i could not find any syntax error while working on file.
          also this file was the original code not the changes i made.

          so ive made the changes again and modded the file.
          try this.
          Attached Files

          Comment


          • #6
            Originally posted by Ghost View Post
            i could not find any syntax error while working on file.
            also this file was the original code not the changes i made.

            so ive made the changes again and modded the file.
            try this.
            wow....nice done!!! thank you sir...im very happy...
            Last edited by hi_jakkk; 25.08.12, 10:09.

            Comment

            Working...
            X