$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 the_excerpt() {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_smilies($excerpt);
$excerpt = convert_chars($excerpt, 'html');
$excerpt = apply_filters('the_excerpt', $excerpt);
echo $excerpt;
}
function the_excerpt_rss($cut = 0, $encode_html = 0) {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_chars($excerpt, 'unicode');
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$excerpt = htmlspecialchars($excerpt);
$cut = 0;
} elseif ($encode_html == 0) {
$excerpt = make_url_footnote($excerpt);
} elseif ($encode_html == 2) {
$excerpt = strip_tags($excerpt);
}
if ($cut) {
$blah = explode(' ', $excerpt);
if (count($blah) > $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) ? '...' : '';
$excerpt = $excerpt;
}
echo $excerpt;
}
function the_excerpt_unicode() {
$excerpt = get_the_excerpt();
$excerpt = convert_bbcode($excerpt);
$excerpt = convert_gmcode($excerpt);
$excerpt = convert_smilies($excerpt);
$excerpt = convert_chars($excerpt, 'unicode');
$excerpt = apply_filters('the_excerpt_unicode', $excerpt);
echo $excerpt;
}
function get_the_excerpt() {
global $id,$postdata;
global $HTTP_SERVER_VARS, $preview;
$output = '';
$output = $postdata['Excerpt'];
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', $list=true) {
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);
if ($list) echo "\n\t