Location: PHPKode > projects > Phpfastnews > phpfastnews/Lib/sideblocks.inc
<?php
/*	Copyright (c) 2001-02 by Ken Williams (hide@address.com)*/
/*	http://phpfastnews.sourceforge.net/ & http://www.phpfastnews.com*/
/*									*/
/*	You can redistribute and/or modify the following code under the	*/
/*	terms of the GNU General Public License as published by the	*/
/*	the Free Software Foundation.					*/
/*									*/
/*	LAST MODIFIED August 04, 2001 - 18:27:44 Eastern Standard Time	*/
/*	All code by Ken Williams (HDwebdev) unless otherwise noted	*/
/* This is an alpha test release -- not intended for live site	use	*/

class sideblocks {

function threeup()      {
              global $db,$ralph;
              $prods = mt_rand(16,32);
              $query = "select product_name,product_thumb_image,product_price from fn_cmrc_product,fn_cmrc_product_price where fn_cmrc_product.product_id = product_price_id and fn_cmrc_product.product_id > '$prods' limit 0, 3";
              $dbthree = newObject('Core::psDb');
              $dbthree->query($query);
              $ralph = "<table width=95% align=center><tr>";
              while($dbthree->next_record()) {
                $ralph .= "<td width=50%><center><img src = images/commerce/" . $dbthree->f('product_thumb_image') . "><br>" . $dbthree->f('product_name') . "<br>" . $dbthree->f('product_price') . "</center></td>";
                }
              $ralph .= "</tr></table>";
              return $ralph;
              }


function links($v)	{
		global $blocks;
	$tmp[0] = $blocks->bstyle[$v]["sb_head"];
	$tmp[1] = "<a href=news_index.php>News</a><br><a href=forum_index.php>Forums</a><br><a href=article_index.php>Articles</a><br><br><a href=' '><s>Product Reviews</s></a>";

	return array ($tmp[0],$tmp[1]);
	}

function login($v)	{
	global $blocks,$handle,$anonname,$auth;
	$tmp[0]= $blocks->bstyle[$v]["sb_head"];
	$tmp[1]= $blocks->bstyle[$v]["sb_content"];
	
	if ($handle == $anonname)	{
		$tmp[1] = str_replace('{REGISTER}','<a href=user_register.php>register</a>',$tmp[1]);
		$tmp[1] = str_replace('{LOGINOUT}','<a href=user_login.php>login</a>',$tmp[1]);
		}
		else
		{
		$tmp[1] = str_replace('{REGISTER}','',$tmp[1]);
		$tmp[1] = str_replace('{LOGINOUT}','<a href="news_index.php?func=Core::psUser->logout">LOGOUT</a>',$tmp[1]);
		}
	if (!$handle)	{
		$tmp[1] = str_replace('{LOGINNAME}',$auth["username"],$tmp[1]);
 		}
		else
		{
		$tmp[1] = str_replace('{LOGINNAME}',$handle,$tmp[1]);
		}
	return array ($tmp[0],$tmp[1]);
	}


function products($v)	{
		global $blocks;
                srand((double)microtime()*1000000);
	        $timeagain=rand(5,10000);
	$tmp[1] = '<br><img src="images/commerce/product/535a5fb32e0cda8c11c036c9bae38771.jpg" border="0" alt="product">
		<br>COMING SOON!<br><br>
	<img src="images/commerce/product/8ed617dad2be64a7a2124d984bbc73be.jpg" border="0" alt="product2">
		<br>COMING SOON!<br><br>
        <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=32234&type=1&time=' . $timeagain . '" width="88" height="31" border="0" alt="SourceForge.net
            Logo"></a>';


	return array ($tmp[0],$tmp[1]);
	}

function forumnewthread($v)	{
	global $handle,$anonname,$f_id;
	if($handle == $anonname)	{
		$tmp[0] = "Add Topic";
		$tmp[1] = "<s>New Thread</s><br>You must be logged in";
		}
		else
		{
		$tmp[0] = "Add Topic";
		$tmp[1] = "<a href=forum_newthread.php?f_id=" . $f_id . ">New Thread</a>";
		}
	return array($tmp[0],$tmp[1]);
	}


	function latestnews($v)	{
	global $db,$blocks;
		$tmp[0] = "Latest News";
		$query = 'select subject,handle,n_cdate,news_id from fn_news,fn_user
						where user_id2 = user_idfk
						order by n_cdate desc
						limit 3 ';
		$db->query($query);
		while ($db->next_record())	{
		$tmp[1] .= "<a href=news_view.php?r_id=" . $db->f('news_id') . ">" . $db->f('subject') . "</a><br>"
							. "by <b>" .$db->f('handle') . "</b><br><br>";
		}
		
	return array($tmp[0],$tmp[1]);
	}
	
	function latestforum($v)	{
	global $db,$blocks;
		$tmp[0] = "Latest Forum Subjects";
		$query = "select forum_id,post_id,subject,handle,fp_cdate from fn_fposts,fn_forum,fn_user
						where (parent = '0')
						and (user_id2 = user_idfk)
						and (forum_idfk = forum_id)
						order by fp_cdate desc
						limit 3";
						
		$db->query($query);
		while ($db->next_record())	{
			$tmp[1] .= "<a href=forum_posts.php?f_id=" . $db->f('forum_id') . "&r_id=" .
								$db->f('post_id') . ">" . $db->f("subject") . "</a>";
			$tmp[1] .= "<br>by <b>" . $db->f('handle') . "</b>";
			
			$date = time() - $db->f('fp_cdate');
			$date = round($date / 36) / 100;
			$tmp[1] .= "&nbsp; ($date hours ago)<br><br>";
		}
		return array($tmp[0],$tmp[1]);
	}
	
	function latestforumposts($v)	{
		global $db,$blocks;
		$tmp[0] = "Latest Forum Posts";
		$query = "select forum_id,post_id,subject,handle,fp_cdate from fn_fposts,fn_forum,fn_user
						where (user_id2 = user_idfk)
						and (forum_idfk = forum_id)
						and (parent > '0')
						order by fp_cdate desc
						limit 3";
						
		$db->query($query);
		while ($db->next_record())	{
			$tmp[1] .= "<a href=forum_posts.php?f_id=" . $db->f('forum_id') . "&r_id=" .
									$db->f('post_id') . ">" . $db->f("subject") . "</a>";
			$tmp[1] .= "<br>by <b>" . $db->f('handle') . "</b>";
			$date = time() - $db->f('fp_cdate');
			$date = round($date / 36) / 100;
			$tmp[1] .= "&nbsp; ($date hours ago)<br><br>";
		}
		
	return array($tmp[0],$tmp[1]);
	}
	
	function latestarticle($v)	{
	global $db,$blocks;
		$tmp[0] = "Latest Articles";
		$query = 'select article_id,subject from fn_article order by cdate desc limit 10';
		$db->query($query);
		while ($db->next_record())
			{
				$tmp[1] .= "<a href=article_view.php?r_id=" . $db->f('article_id') . ">" .
									$db->f('subject') . "</a><br><br>";
		}
	return array($tmp[0],$tmp[1]);
	}

}
?>
Return current item: Phpfastnews