$cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
echo $content;
}
function the_content_unicode($more_link_text='(more...)', $stripteaser=0, $more_file='') {
$content = get_the_content($more_link_text,$stripteaser,$more_file);
$content = convert_bbcode($content);
$content = convert_gmcode($content);
$content = convert_smilies($content);
$content = convert_chars($content, 'unicode');
$content = apply_filters('the_content_unicode', $content);
echo $content;
}
function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
global $id,$postdata,$more,$c,$withcomments,$page,$pages,$multipage,$numpages;
global $HTTP_SERVER_VARS, $preview;
global $querystring_start, $querystring_equal, $querystring_separator;
global $pagenow;
$output = '';
if ($more_file != '') {
$file=$more_file;
} else {
$file=$pagenow; //$HTTP_SERVER_VARS['PHP_SELF'];
}
$content=$pages[$page-1];
$content=explode('', $content);
if ((preg_match('//', $postdata['Content']) && ((!$multipage) || ($page==1))))
$stripteaser=1;
$teaser=$content[0];
if (($more) && ($stripteaser))
$teaser='';
$output .= $teaser;
if (count($content)>1) {
if ($more) {
$output .= ''.$content[1];
} else {
$output .= ' '.$more_link_text.'';
}
}
if ($preview) { // preview fix for javascript bug with foreign languages
$output = preg_replace('/\%u([0-9A-F]{4,4})/e', "''.base_convert('\\1',16,10).';'", $output);
}
return($output);
}
function link_pages($before='
', $after='
', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', $pagelink='%', $more_file='') {
global $id,$page,$numpages,$multipage,$more;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($more_file != '') {
$file = $more_file;
} else {
$file = $pagenow;
}
if (($multipage)) { // && ($more)) {
if ($next_or_number=='number') {
echo $before;
for ($i = 1; $i < ($numpages+1); $i = $i + 1) {
$j=str_replace('%',"$i",$pagelink);
echo " ";
if (($i != $page) || ((!$more) && ($page==1)))
echo '';
echo $j;
if (($i != $page) || ((!$more) && ($page==1)))
echo '';
}
echo $after;
} else {
if ($more) {
echo $before;
$i=$page-1;
if ($i && $more)
echo ' '.
$previouspagelink.'';
$i=$page+1;
if ($i<=$numpages && $more)
echo ' '.
$nextpagelink.'';
echo $after;
}
}
}
}
function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') {
global $tableposts, $id, $postdata, $siteurl, $blogfilename, $querycount;
global $p, $posts, $posts_per_page, $s;
global $querystring_start, $querystring_equal, $querystring_separator;
if(($p) || ($posts_per_page==1)) {
$current_post_date = $postdata['Date'];
$current_category = $postdata['Category'];
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category='$current_category' ";
}
$sql_exclude_cats = '';
if (!empty($excluded_categories)) {
$blah = explode('and', $excluded_categories);
foreach($blah as $category) {
$category = intval($category);
$sql_exclude_cats .= " AND post_category != $category";
}
}
$limitprev--;
$sql = "SELECT ID,post_title FROM $tableposts WHERE post_date < '$current_post_date' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date DESC LIMIT $limitprev,1";
$query = @mysql_query($sql);
$querycount++;
if (($query) && (mysql_num_rows($query))) {
$p_info = mysql_fetch_object($query);
$p_title = $p_info->post_title;
$p_id = $p_info->ID;
$string = ''.$previous;
if (!($title!='yes')) {
$string .= stripslashes($p_title);
}
$string .= '';
$format = str_replace('%',$string,$format);
echo $format;
}
}
}
function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') {
global $tableposts, $p, $posts, $id, $postdata, $siteurl, $blogfilename, $querycount;
global $time_difference;
global $querystring_start, $querystring_equal, $querystring_separator;
if(($p) || ($posts==1)) {
$current_post_date = $postdata['Date'];
$current_category = $postdata['Category'];
$sqlcat = '';
if ($in_same_cat != 'no') {
$sqlcat = " AND post_category='$current_category' ";
}
$sql_exclude_cats = '';
if (!empty($excluded_categories)) {
$blah = explode('and', $excluded_categories);
foreach($blah as $category) {
$category = intval($category);
$sql_exclude_cats .= " AND post_category != $category";
}
}
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
$limitnext--;
$sql = "SELECT ID,post_title FROM $tableposts WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_category > 0 $sqlcat $sql_exclude_cats ORDER BY post_date ASC LIMIT $limitnext,1";
$query = @mysql_query($sql);
$querycount++;
if (($query) && (mysql_num_rows($query))) {
$p_info = mysql_fetch_object($query);
$p_title = $p_info->post_title;
$p_id = $p_info->ID;
$string = ''.$next;
if ($title=='yes') {
$string .= stripslashes($p_title);
}
$string .= '';
$format = str_replace('%',$string,$format);
echo $format;
}
}
}
function next_posts($max_page = 0) { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == 'paged')) {
$qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
if (!empty($qstr)) {
$qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
$qstr = preg_replace("/paged=\d{0,}/","",$qstr);
} elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {
if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',
$HTTP_SERVER_VARS['REQUEST_URI']) ) {
$qstr = preg_replace("/^\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
$qstr = preg_replace("/\/$/", "", $qstr);
}
}
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (!$max_page || $max_page >= $nextpage) {
echo $pagenow.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}
}
}
function next_posts_link($label='Next Page >>', $max_page=0) {
global $p, $paged, $result, $request, $posts_per_page, $what_to_show;
if ($what_to_show == 'paged') {
if (!$max_page) {
$nxt_request = $request;
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = mysql_query($nxt_request);
$numposts = mysql_num_rows($nxt_result);
$max_page = ceil($numposts / $posts_per_page);
}
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (empty($p) && (empty($paged) || $nextpage <= $max_page)) {
echo ''. htmlspecialchars($label) .'';
}
}
}
function previous_posts() { // original by cfactor at cooltux.org
global $HTTP_SERVER_VARS, $siteurl, $blogfilename, $p, $paged, $what_to_show, $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if (empty($p) && ($what_to_show == 'paged')) {
$qstr = $HTTP_SERVER_VARS['QUERY_STRING'];
if (!empty($qstr)) {
$qstr = preg_replace("/&paged=\d{0,}/","",$qstr);
$qstr = preg_replace("/paged=\d{0,}/","",$qstr);
} elseif (stristr($HTTP_SERVER_VARS['REQUEST_URI'], $HTTP_SERVER_VARS['SCRIPT_NAME'] )) {
if ('' != $qstr = str_replace($HTTP_SERVER_VARS['SCRIPT_NAME'], '',
$HTTP_SERVER_VARS['REQUEST_URI']) ) {
$qstr = preg_replace("/^\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}\//", "", $qstr);
$qstr = preg_replace("/paged\/\d{0,}/", "", $qstr);
$qstr = preg_replace("/\/$/", "", $qstr);
}
}
$nextpage = intval($paged) - 1;
if ($nextpage < 1) $nextpage = 1;
echo $pagenow.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}
}
function previous_posts_link($label='<< Previous Page') {
global $p, $paged, $what_to_show;
if (empty($p) && ($paged > 1) && ($what_to_show == 'paged')) {
echo ''. htmlspecialchars($label) .'';
}
}
function posts_nav_link($sep=' :: ', $prelabel='<< Previous Page', $nxtlabel='Next Page >>') {
global $p, $what_to_show, $request, $posts_per_page;
if (empty($p) && ($what_to_show == 'paged')) {
$nxt_request = $request;
if ($pos = strpos(strtoupper($request), 'LIMIT')) {
$nxt_request = substr($request, 0, $pos);
}
$nxt_result = mysql_query($nxt_request);
$numposts = mysql_num_rows($nxt_result);
$max_page = ceil($numposts / $posts_per_page);
if ($max_page > 1) {
previous_posts_link($prelabel);
echo htmlspecialchars($sep);
next_posts_link($nxtlabel, $max_page);
}
}
}
/***** // Post tags *****/
/***** Category tags *****/
function the_category() {
$category = get_the_category();
$category = apply_filters('the_category', $category);
echo convert_chars($category, 'html');
}
function the_category_rss() {
echo convert_chars(strip_tags(get_the_category()), 'xml');
}
function the_category_unicode() {
$category = get_the_category();
$category = apply_filters('the_category_unicode', $category);
echo convert_chars($category, 'unicode');
}
function get_the_category() {
global $id,$postdata,$tablecategories,$querycount,$cache_categories,$use_cache;
$cat_ID = $postdata['Category'];
if ((empty($cache_categories[$cat_ID])) OR (!$use_cache)) {
$query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'";
$result=mysql_query($query);
$querycount++;
$myrow = mysql_fetch_array($result);
$cat_name = $myrow[0];
$cache_categories[$cat_ID] = $cat_name;
} else {
$cat_name = $cache_categories[$cat_ID];
}
return(stripslashes($cat_name));
}
function get_the_category_by_ID($cat_ID) {
global $id,$tablecategories,$querycount,$cache_categories,$use_cache;
if ((!$cache_categories[$cat_ID]) OR (!$use_cache)) {
$query="SELECT cat_name FROM $tablecategories WHERE cat_ID = '$cat_ID'";
$result=mysql_query($query);
$querycount++;
$myrow = mysql_fetch_array($result);
$cat_name = $myrow[0];
$cache_categories[$cat_ID] = $cat_name;
} else {
$cat_name = $cache_categories[$cat_ID];
}
return(stripslashes($cat_name));
}
function the_category_ID() {
global $id,$postdata; echo $postdata['Category'];
}
function the_category_head($before='',$after='') {
global $id, $postdata, $currentcat, $previouscat,$dateformat,$newday;
$currentcat = $postdata['Category'];
if ($currentcat != $previouscat) {
echo $before;
echo get_the_category_by_ID($currentcat);
echo $after;
$previouscat = $currentcat;
}
}
// out of the b2 loop
function dropdown_cats($optionall = 1, $all = 'All') {
global $cat, $tablecategories, $querycount;
$query="SELECT * FROM $tablecategories";
$result=mysql_query($query);
$querycount++;
echo "\n";
}
// out of the b2 loop
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = 'blah') {
global $tablecategories,$querycount;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file == 'blah') ? $pagenow : $file;
$sort_column = 'cat_'.$sort_column;
$query="SELECT * FROM $tablecategories WHERE cat_ID > 0 ORDER BY $sort_column $sort_order";
$result=mysql_query($query);
$querycount++;
if (intval($optionall) == 1) {
$all = apply_filters('list_cats', $all);
echo "\t'.$all."
\n";
}
while($row = mysql_fetch_object($result)) {
$cat_name = $row->cat_name;
$cat_name = apply_filters('list_cats', $cat_name);
echo "\tcat_ID.'">';
echo stripslashes($cat_name)."
\n";
}
}
/***** // Category tags *****/
/***** tags *****/
/***** // tags *****/
/***** Comment tags *****/
// generic comments/trackbacks/pingbacks numbering
function generic_ctp_number($post_id, $mode = 'comments') {
global $postdata, $tablecomments, $querycount, $cache_ctp_number, $use_cache;
if (!isset($cache_ctp_number[$post_id]) || (!$use_cache)) {
$post_id = intval($post_id);
$query = "SELECT * FROM $tablecomments WHERE comment_post_ID = $post_id";
$result = mysql_query($query) or die('SQL query: '.$query.'
MySQL Error: '.mysql_error());
$querycount++;
$ctp_number = array();
while($row = mysql_fetch_object($result)) {
if (substr($row->comment_content, 0, 13) == '') {
$ctp_number['trackbacks']++;
} elseif (substr($row->comment_content, 0, 12) == '') {
$ctp_number['pingbacks']++;
} else {
$ctp_number['comments']++;
}
$ctp_number['ctp']++;
}
$cache_ctp_number[$post_id] = $ctp_number;
} else {
$ctp_number = $cache_ctp_number[$post_id];
}
if (($mode != 'comments') && ($mode != 'trackbacks') && ($mode != 'pingbacks') && ($mode != 'ctp')) {
$mode = 'ctp';
}
return $ctp_number[$mode];
}
function comments_number($zero='no comment', $one='1 comment', $more='% comments') {
// original hack by dodo@regretless.com
global $id,$postdata,$tablecomments,$c,$querycount,$cache_commentsnumber,$use_cache;
$number = generic_ctp_number($id, 'comments');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function comments_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1#comments';
}
function comments_popup_script($width=400, $height=400, $file='b2commentspopup.php', $trackbackfile='b2trackbackpopup.php', $pingbackfile='b2pingbackspopup.php') {
global $b2commentspopupfile, $b2trackbackpopupfile, $b2pingbackpopupfile, $b2commentsjavascript;
$b2commentspopupfile = $file;
$b2trackbackpopupfile = $trackbackfile;
$b2pingbackpopupfile = $pingbackfile;
$b2commentsjavascript = 1;
$javascript = "\n";
echo $javascript;
}
function comments_popup_link($zero='no comment', $one='1 comment', $more='% comments', $CSSclass='') {
global $id, $b2commentspopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
echo '';
comments_number($zero, $one, $more);
echo '';
}
function comment_ID() {
global $commentdata; echo $commentdata['comment_ID'];
}
function comment_author() {
global $commentdata; echo stripslashes($commentdata['comment_author']);
}
function comment_author_email() {
global $commentdata; echo antispambot(stripslashes($commentdata['comment_author_email']));
}
function comment_author_url() {
global $commentdata;
$url = trim(stripslashes($commentdata['comment_author_url']));
$url = (!stristr($url, '://')) ? 'http://'.$url : $url;
// convert & into &
$url = preg_replace('#&([^amp\;])#is', '&$1', $url);
if ($url != 'http://url') {
echo $url;
}
}
function comment_author_email_link($linktext='', $before='', $after='') {
global $commentdata;
$email=$commentdata['comment_author_email'];
if ((!empty($email)) && ($email != '@')) {
$display = ($linktext != '') ? $linktext : antispambot(stripslashes($email));
echo $before;
echo ''.$display.'';
echo $after;
}
}
function comment_author_url_link($linktext='', $before='', $after='') {
global $commentdata;
$url = trim(stripslashes($commentdata['comment_author_url']));
$url = preg_replace('#&([^amp\;])#is', '&$1', $url);
$url = (!stristr($url, '://')) ? 'http://'.$url : $url;
if ((!empty($url)) && ($url != 'http://') && ($url != 'http://url')) {
$display = ($linktext != '') ? $linktext : stripslashes($url);
echo $before;
echo ''.$display.'';
echo $after;
}
}
function comment_author_IP() {
global $commentdata; echo stripslashes($commentdata['comment_author_IP']);
}
function comment_text() {
global $commentdata;
$comment = stripslashes($commentdata['comment_content']);
$comment = str_replace('', '', $comment);
$comment = str_replace('', '', $comment);
$comment = convert_chars($comment);
$comment = convert_bbcode($comment);
$comment = convert_gmcode($comment);
$comment = convert_smilies($comment);
$comment = make_clickable($comment);
$comment = balanceTags($comment);
$comment = apply_filters('comment_text', $comment);
echo $comment;
}
function comment_date($d='') {
global $commentdata,$dateformat;
if ($d == '') {
echo mysql2date($dateformat, $commentdata['comment_date']);
} else {
echo mysql2date($d, $commentdata['comment_date']);
}
}
function comment_time($d='') {
global $commentdata,$timeformat;
if ($d == '') {
echo mysql2date($timeformat, $commentdata['comment_date']);
} else {
echo mysql2date($d, $commentdata['comment_date']);
}
}
/***** // Comment tags *****/
/***** TrackBack tags *****/
function trackback_url($display = 1) {
global $pathserver, $id;
$tb_url = $pathserver.'/b2trackback.php/'.$id;
if ($display) {
echo $tb_url;
} else {
return $tb_url;
}
}
function trackback_number($zero='no trackback', $one='1 trackback', $more='% trackbacks') {
global $id, $tablecomments, $tb, $querycount, $cache_trackbacknumber, $use_cache;
$number = generic_ctp_number($id, 'trackbacks');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function trackback_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'tb'.$querystring_equal.'1#trackback';
}
function trackback_popup_link($zero='no trackback', $one='1 trackback', $more='% trackbacks', $CSSclass='') {
global $id, $b2trackbackpopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
echo '';
trackback_number($zero, $one, $more);
echo '';
}
function trackback_rdf($timezone=0) {
global $pathserver, $id, $HTTP_SERVER_VARS;
if (!stristr($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'W3C_Validator')) {
echo ''."\n";
echo '\n";
echo '';
}
}
/***** // TrackBack tags *****/
/***** PingBack tags *****/
function pingback_number($zero='no pingback', $one='1 pingback', $more='% pingbacks') {
global $id, $tablecomments, $tb, $querycount, $cache_pingbacknumber, $use_cache;
$number = generic_ctp_number($id, 'pingbacks');
if ($number == 0) {
$blah = $zero;
} elseif ($number == 1) {
$blah = $one;
} elseif ($number > 1) {
$n = $number;
$more=str_replace('%', $n, $more);
$blah = $more;
}
echo $blah;
}
function pingback_link($file='') {
global $id,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file == '') $file = $pagenow;
if ($file == '/') $file = '';
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'pb'.$querystring_equal.'1#pingbacks';
}
function pingback_popup_link($zero='no pingback', $one='1 pingback', $more='% pingbacks', $CSSclass='') {
global $id, $b2pingbackpopupfile, $b2commentsjavascript;
global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
echo '';
pingback_number($zero, $one, $more);
echo '';
}
/***** // PingBack tags *****/
/***** Permalink tags *****/
function permalink_anchor($mode = 'id') {
global $id, $postdata;
switch(strtolower($mode)) {
case 'title':
$title = preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
echo '';
break;
case 'id':
default:
echo '';
break;
}
}
function permalink_link($file='', $mode = 'id') {
global $id, $postdata, $pagenow, $cacheweekly;
global $querystring_start, $querystring_equal, $querystring_separator;
$file = ($file=='') ? $pagenow : $file;
switch(strtolower($mode)) {
case 'title':
$title = preg_replace('/[^a-zA-Z0-9_\.-]/', '_', $postdata['Title']);
$anchor = $title;
break;
case 'id':
default:
$anchor = $id;
break;
}
$archive_mode = get_settings('archive_mode');
switch($archive_mode) {
case 'daily':
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).substr($postdata['Date'],5,2).substr($postdata['Date'],8,2).'#'.$anchor;
break;
case 'monthly':
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).substr($postdata['Date'],5,2).'#'.$anchor;
break;
case 'weekly':
if((!isset($cacheweekly)) || (empty($cacheweekly[$postdata['Date']]))) {
$sql = "SELECT WEEK('".$postdata['Date']."')";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
$cacheweekly[$postdata['Date']] = $row[0];
}
echo $file.$querystring_start.'m'.$querystring_equal.substr($postdata['Date'],0,4).$querystring_separator.'w'.$querystring_equal.$cacheweekly[$postdata['Date']].'#'.$anchor;
break;
case 'postbypost':
echo $file.$querystring_start.'p'.$querystring_equal.$id;
break;
}
}
function permalink_single($file='') {
global $id,$postdata,$pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if ($file=='')
$file=$pagenow;
echo $file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1';
}
function permalink_single_rss($file='b2rss.xml') {
global $id,$postdata,$pagenow,$siteurl,$blogfilename;
global $querystring_start, $querystring_equal, $querystring_separator;
echo $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'c'.$querystring_equal.'1';
}
/***** // Permalink tags *****/
// @@@ These aren't template tags, do not edit them
function start_b2() {
global $row, $id, $postdata, $authordata, $day, $preview, $page, $pages, $multipage, $more, $numpages;
global $preview_userid,$preview_date,$preview_content,$preview_title,$preview_category,$preview_notify,$preview_make_clickable,$preview_autobr;
global $pagenow;
global $HTTP_GET_VARS;
if (!$preview) {
$id = $row->ID;
$postdata=get_postdata2($id);
} else {
$id = 0;
$postdata = array (
'ID' => 0,
'Author_ID' => $HTTP_GET_VARS['preview_userid'],
'Date' => $HTTP_GET_VARS['preview_date'],
'Content' => $HTTP_GET_VARS['preview_content'],
'Title' => $HTTP_GET_VARS['preview_title'],
'Category' => $HTTP_GET_VARS['preview_category'],
'Notify' => 1,
'Clickable' => 1,
'Karma' => 0 // this isn't used yet
);
if (!empty($HTTP_GET_VARS['preview_autobr'])) {
$postdata['Content'] = autobrize($postdata['Content']);
}
}
$authordata = get_userdata($postdata['Author_ID']);
$day = mysql2date('d.m.y',$postdata['Date']);
$currentmonth = mysql2date('m',$postdata['Date']);
$numpages=1;
if (!$page)
$page=1;
if (isset($p))
$more=1;
$content = $postdata['Content'];
if (preg_match('//', $postdata['Content'])) {
if ($page > 1)
$more=1;
$multipage=1;
$content=stripslashes($postdata['Content']);
$content = str_replace("\n\n", '', $content);
$content = str_replace("\n", '', $content);
$content = str_replace("\n", '', $content);
$pages=explode('', $content);
$numpages=count($pages);
} else {
$pages[0]=stripslashes($postdata['Content']);
$multipage=0;
}
return true;
}
function is_new_day() {
global $day, $previousday;
if ($day != $previousday) {
return(1);
} else {
return(0);
}
}
function apply_filters($tag, $string) {
global $b2_filter;
if (isset($b2_filter['all'])) {
$b2_filter['all'] = (is_string($b2_filter['all'])) ? array($b2_filter['all']) : $b2_filter['all'];
$b2_filter[$tag] = array_merge($b2_filter['all'], $b2_filter[$tag]);
$b2_filter[$tag] = array_unique($b2_filter[$tag]);
}
if (isset($b2_filter[$tag])) {
$b2_filter[$tags] = (is_string($b2_filter[$tag])) ? array($b2_filter[$tag]) : $b2_filter[$tag];
$functions = $b2_filter[$tag];
foreach($functions as $function) {
$string = $function($string);
}
}
return $string;
}
function add_filter($tag, $function_to_add) {
global $b2_filter;
if (isset($b2_filter[$tag])) {
$functions = $b2_filter[$tag];
if (is_array($functions)) {
foreach($functions as $function) {
$new_functions[] = $function;
}
} elseif (is_string($functions)) {
$new_functions[] = $functions;
}
/* this is commented out because it just makes PHP die silently
for no apparent reason
if (is_array($function_to_add)) {
foreach($function_to_add as $function) {
if (!in_array($function, $b2_filter[$tag])) {
$new_functions[] = $function;
}
}
} else */if (is_string($function_to_add)) {
if (!@in_array($function_to_add, $b2_filter[$tag])) {
$new_functions[] = $function_to_add;
}
}
$b2_filter[$tag] = $new_functions;
} else {
$b2_filter[$tag] = array($function_to_add);
}
return true;
}
?>