Location: PHPKode > projects > Chirp: The Microblog > chirp.v.1.1/includes/followxxx.inc.php
<?php



function List_People($qry, $name='', $page=0){

	include("includes/config.inc.php");

	include("language/language.".$language.".php");



	$followblock = file_get_contents('themes/'.$theme.'/followxxx_block.theme.html');

	$num_per_page = $num_people_to_show;

	$curpage = 'is_empty';

	$friendlist = '';

	$username = '';

	$friendname = '';

	$people = '';

	$curpagenext = '';

	$curpageback = '';

	

	$query = $qry.' AND USERID != '.$_SESSION['USERID'].' ORDER BY `USERID` DESC';

	$result = mysql_query($query) or die(mysql_error());

//================== Top Pagination Section ======================================	

	$num = @mysql_num_rows($result);

	$pages = intval($num/$num_per_page); // Number of results pages.

	if ($num%$num_per_page) {

		$pages++;

	} // has remainder so add one page

	$current = ($page/$num_per_page) + 1; // Current page number.

	if (($pages < 1) || ($pages == 0)) {

		$total = 1;

	} else {

		$total = $pages;

	} // Else total pages is $pages value.

	$first = $page + 1; // The first result.

	if (!((($page + $num_per_page) / $num_per_page) >= $pages) && $pages != 1) {

		$last = $page + $num_per_page;

	} else {

		$last = $num;

	} // If last results page, last result equals total number of results.

//================== Top Pagination Section ======================================	

	$result = mysql_query($qry.' AND USERID != '.$_SESSION['USERID'].' ORDER BY USERID ASC LIMIT '.$page.', '.$num_per_page);

	if (mysql_errno()) {

          die("<br />" . mysql_errno() . ": " . mysql_error() . "<br />");

     }

	$num = mysql_num_rows($result);

	if ($num > 0){

		while ($row = @mysql_fetch_assoc($result)){

			$userimg = '<img src="%URL%image.php?img='. $row['USERID'].'" width="48" height="48" />';

			$username = '<a href="%URL%@'.$row['USERNAME'].'" title="'.$row['USERNAME'].'">'.$row['USERNAME'].'</a>';



			if(strlen($row['FIRSTNAME'] > 0)){

				$friendname = $row['FIRSTNAME']." ";

			}

			if(strlen($row['LASTNAME'] > 0)){

				$friendname .= $row['LASTNAME'];

			}

			$isfrnd = mysql_query("SELECT * FROM friends WHERE FRIENDID = ".$row['USERID']." AND USERID = ".$_SESSION['USERID']." LIMIT 1");

			if (mysql_errno()) {

          		die("<br />" . mysql_errno() . ": " . mysql_error() . "<br />");

      		} else {

        		$isfrndcnt = mysql_num_rows($isfrnd);

				if($isfrndcnt > 0){

					$isfrndact = $msgblock2;

					$isfrndimg = "greendot.gif";

				}else{

					$isfrndact = $msgblock1;

					$isfrndimg = "chat.gif";

				}

      		}

			$adDel = '<a href="%URL%index.php?loc=search&name='.$name.'&page='.$page.'&act=friend&actval='. $row['USERID'] . '" title="'.$isfrndact.'"><img src="%URL%themes/'.$theme.'/images/'.$isfrndimg.'" border="0" align="absmiddle"></a>';

			

			if(strpos($followblock,"%PROFPIX%") !== false){

				$friendlist = str_replace('%PROFPIX%',$userimg,$followblock);

			}

			if(strpos($friendlist,"%USERNAME%") !== false){

				$friendlist = str_replace('%USERNAME%',$username,$friendlist);

			}

			if(strpos($friendlist,"%FRIENDNAME%") !== false){

				$friendlist = str_replace('%FRIENDNAME%',$friendname,$friendlist);

			}

			if(strpos($friendlist,"%MSSGMENU%") !== false){

				$friendlist = str_replace('%MSSGMENU%',$adDel,$friendlist);

			}

			$people .= $friendlist;

		}

	}

//================== Bottom Pagination Section ======================================

	if ($page != 0) { // Don't show back link if current page is first page.

		$back_page = $page - $num_per_page;

		$people .= "<a href=\"%URL%index.php?loc=search&name=".$name."&page=" . $back_page . "\">".$peoplelst1."</a>&nbsp;&nbsp;\n";

	}

	if (!((($page+$num_per_page) / $num_per_page) >= $pages) && $pages != 1) { // If last page don't give next link.

		$next_page = $page + $num_per_page;

		$people .= "&nbsp;&nbsp;<a href=\"%URL%index.php?loc=search&name=".$name."&page=" . $next_page . "\" >".$peoplelst2."</a>\n";

	}

//================== Bottom Pagination Section ======================================	

	return $people;	

}



function List_Friends($sesID,$page=0){

	include("includes/config.inc.php");

	include("language/language.".$language.".php");

	

	$followblock = file_get_contents('themes/'.$theme.'/followxxx_block.theme.html');

	$num_per_page = $num_people_to_show;

	$curpage = 'is_empty';

	$friendlist = '';

	$username = '';

	$friendname = '';

	$curpagenext = '';

	$curpageback = '';

	

	$friendlist = '';

	$username = '';

	$friendname = '';

	$following = '';

	

	$query = "SELECT * FROM users WHERE USERID IN (SELECT FRIENDID FROM friends WHERE USERID = ". $_SESSION['USERID'] .") ORDER BY USERID DESC";

	$result = mysql_query($query) or die(mysql_error());

	

	//================== Top Pagination Section ======================================	

	$num = @mysql_num_rows($result);

	$pages = intval($num/$num_per_page); // Number of results pages.

	if ($num%$num_per_page) {

		$pages++;

	} // has remainder so add one page

	$current = ($page/$num_per_page) + 1; // Current page number.

	if (($pages < 1) || ($pages == 0)) {

		$total = 1;

	} else {

		$total = $pages;

	} // Else total pages is $pages value.

	$first = $page + 1; // The first result.

	if (!((($page + $num_per_page) / $num_per_page) >= $pages) && $pages != 1) {

		$last = $page + $num_per_page;

	} else {

		$last = $num;

	} // If last results page, last result equals total number of results.

//================== Top Pagination Section ======================================	

	$query = "SELECT * FROM users WHERE USERID IN (SELECT FRIENDID FROM friends WHERE USERID = ". $_SESSION['USERID'] .") ORDER BY USERID ASC LIMIT ".$page.", ".$num_per_page;

	$result = mysql_query($query) or die(mysql_error());

	

	$num = mysql_num_rows($result);

	if ($num > 0){

		while ($row = @mysql_fetch_assoc($result)){

			$userimg = '<img src="%URL%image.php?img='. $row['USERID'].'" width="48" height="48" />';

			$username = '<a href="%URL%@'.$row['USERNAME'].'" title="'.$row['USERNAME'].'">'.$row['USERNAME'].'</a>';



			if(strlen($row['FIRSTNAME'] > 0)){

				$friendname = $row['FIRSTNAME']." ";

			}

			if(strlen($row['LASTNAME'] > 0)){

				$friendname .= $row['LASTNAME'];

			}

			$adDel = '<a href="%URL%following/friend/'. $row['USERID'] . '" title="'.$msgblock2.'"><img src="%URL%themes/'.$theme.'/images/greendot.gif" border="0" align="absmiddle"></a>';

			if(strpos($followblock,"%PROFPIX%") !== false){

				$friendlist = str_replace('%PROFPIX%',$userimg,$followblock);

			}

			if(strpos($friendlist,"%USERNAME%") !== false){

				$friendlist = str_replace('%USERNAME%',$username,$friendlist);

			}

			if(strpos($friendlist,"%FRIENDNAME%") !== false){

				$friendlist = str_replace('%FRIENDNAME%',$friendname,$friendlist);

			}

			if(strpos($friendlist,"%MSSGMENU%") !== false){

				$friendlist = str_replace('%MSSGMENU%',$adDel,$friendlist);

			}

			$following .= $friendlist;

		}

	}



//================== Bottom Pagination Section ======================================

	if ($page != 0) { // Don't show back link if current page is first page.

		$back_page = $page - $num_per_page;

		$following .= "<a href=\"%URL%index.php?loc=following&page=" . $back_page . "\">".$peoplelst1."</a>&nbsp;&nbsp;\n";

	}

	if (!((($page+$num_per_page) / $num_per_page) >= $pages) && $pages != 1) { // If last page don't give next link.

		$next_page = $page + $num_per_page;

		$following .= "&nbsp;&nbsp;<a href=\"%URL%index.php?loc=following&page=" . $next_page . "\" >".$peoplelst2."</a>\n";

	}

//================== Bottom Pagination Section ======================================

	return $following;

}



function List_Followers($sesID,$page=0){

	include("includes/config.inc.php");

	include("language/language.".$language.".php");

	

	$followblock = file_get_contents('themes/'.$theme.'/followxxx_block.theme.html');

	$friendlist = '';

	$username = '';

	$friendname = '';

	$num_per_page = $num_people_to_show;

	

	$query = "SELECT * FROM users WHERE USERID IN (SELECT USERID FROM friends WHERE FRIENDID = ". $sesID .") ORDER BY USERID DESC";

	$result = mysql_query($query) or die(mysql_error());

	

	//================== Top Pagination Section ======================================	

	$num = @mysql_num_rows($result);

	$pages = intval($num/$num_per_page); // Number of results pages.

	if ($num%$num_per_page) {

		$pages++;

	} // has remainder so add one page

	$current = ($page/$num_per_page) + 1; // Current page number.

	if (($pages < 1) || ($pages == 0)) {

		$total = 1;

	} else {

		$total = $pages;

	} // Else total pages is $pages value.

	$first = $page + 1; // The first result.

	if (!((($page + $num_per_page) / $num_per_page) >= $pages) && $pages != 1) {

		$last = $page + $num_per_page;

	} else {

		$last = $num;

	} // If last results page, last result equals total number of results.

//================== Top Pagination Section ======================================	

	

	$query = "SELECT * FROM users WHERE USERID IN (SELECT USERID FROM friends WHERE FRIENDID = ". $sesID .") ORDER BY USERID ASC LIMIT ".$page.", ".$num_per_page;

	$result = mysql_query($query) or die(mysql_error());

	$num = mysql_num_rows($result);

	if ($num > 0){

		while ($row = @mysql_fetch_assoc($result)){

			$userimg = '<img src="%URL%image.php?img='. $row['USERID'].'" width="48" height="48" />';

			$username = '<a href="%URL%@'.$row['USERNAME'].'" title="'.$row['USERNAME'].'">'.$row['USERNAME'].'</a>';

			if(strlen($row['FIRSTNAME'] > 0)){

				$friendname = $row['FIRSTNAME']." ";

			}

			if(strlen($row['LASTNAME'] > 0)){

				$friendname .= $row['LASTNAME'];

			}

			$isfrnd = mysql_query("SELECT * FROM friends WHERE FRIENDID = ".$row['USERID']." AND USERID = ".$sesID." LIMIT 1");

			if (mysql_errno()) {

          		die("<br />" . mysql_errno() . ": " . mysql_error() . "<br />");

      		} else {

        		$isfrndcnt = mysql_num_rows($isfrnd);

				if($isfrndcnt > 0){

					$isfrndact = $msgblock2;

					$isfrndimg = "greendot.gif";

				}else{

					$isfrndact = $msgblock1;

					$isfrndimg = "chat.gif";

				}

      		}

      		

			$adDel = '<a href="%URL%/followers/friend/'. $row['USERID'] . '" title="'.$isfrndact.'"><img src="%URL%themes/'.$theme.'/images/'.$isfrndimg.'" border="0" align="absmiddle"></a>';

			if(strpos($followblock,"%PROFPIX%") !== false){

				$friendlist = str_replace('%PROFPIX%',$userimg,$followblock);

			}

			if(strpos($friendlist,"%USERNAME%") !== false){

				$friendlist = str_replace('%USERNAME%',$username,$friendlist);

			}

			if(strpos($friendlist,"%FRIENDNAME%") !== false){

				$friendlist = str_replace('%FRIENDNAME%',$friendname,$friendlist);

			}

			if(strpos($friendlist,"%MSSGMENU%") !== false){

				$friendlist = str_replace('%MSSGMENU%',$adDel,$friendlist);

			}

		}

	}

//================== Bottom Pagination Section ======================================

	if ($page != 0) { // Don't show back link if current page is first page.

		$back_page = $page - $num_per_page;

		$friendlist .= "<a href=\"%URL%index.php?loc=following&page=" . $back_page . "\">".$peoplelst1."</a>&nbsp;&nbsp;\n";

	}

	if (!((($page+$num_per_page) / $num_per_page) >= $pages) && $pages != 1) { // If last page don't give next link.

		$next_page = $page + $num_per_page;

		$friendlist .= "&nbsp;&nbsp;<a href=\"%URL%index.php?loc=following&page=" . $next_page . "\" >".$peoplelst2."</a>\n";

	}

//================== Bottom Pagination Section ======================================

	return $friendlist;

}



?>
Return current item: Chirp: The Microblog