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

	session_start();

	header ("Cache-control: private");

	error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

	

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

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

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

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

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

	

	$act = '';

	

	if(!isset($_GET['id']) && empty($_GET['id'])){

		die();

	}

	if(strpos($_GET['id'],'/') !== false){

		$breakout = explode("/",$_GET['id']);

		$uid = $breakout[0];

		$act = $breakout[1];

	}else{

		$uid = $_GET['id'];

	}



	

	$username = addslashes(mysql_real_escape_string(htmlspecialchars(@$uid,ENT_QUOTES)));

	

	if(strlen($act)>0){

		$act = addslashes(mysql_real_escape_string(htmlspecialchars(@$act,ENT_QUOTES)));

		switch($act){

			case 'friend':

				$friendresult = mysql_query('SELECT friends.FRIENDID FROM friends WHERE friends.FRIENDID = ((SELECT users.USERID FROM users WHERE users.USERNAME = "'.$username.'")) AND USERID = '.$_SESSION['USERID'].' LIMIT 1');

				$icnt = mysql_num_rows($friendresult);

				if ($icnt == 0){   

					mysql_query('INSERT INTO friends (FRIENDID,USERID) VALUES ((SELECT users.USERID FROM users WHERE users.USERNAME = "'.$username.'"),'.$_SESSION['USERID'].')');

					if(mysql_errno()){

						echo mysql_errno();

					}

				} 

				break;

			case 'unfriend':

				mysql_query('DELETE FROM friends WHERE friends.FRIENDID IN (SELECT users.USERID FROM users WHERE users.USERNAME = "'.$username.'") AND friends.USERID = '.$_SESSION['USERID'].' LIMIT 1');

				if(mysql_errno()){

					echo mysql_errno();

				} 

				break;	

		}

	}

	echo PAGE_PROCESSING($username);

	mysql_close($connection);



function PAGE_PROCESSING($uname=''){

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

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

	

	$wpage 	= file_get_contents('themes/'.$theme.'/profile.theme.html');

	$statmsg 	= '';

	$userid		= '';

	$userimg 	= '';

	$location	= ''; 

	$interests	= '';

	$about		= '';

	$website	= '';

	$portfolio	= '';

	$birthday	= '';

	$aim		= '';

	$icq		= '';

	$yim		= '';

	$msn		= '';

	$gtalk		= '';

	$flname		= '';

	$userinfo	= '';

	$adDel		= '';

	

	$sql = 'SELECT * FROM public_profile WHERE USERNAME = "'.$uname.'" LIMIT 1';

	$result = mysql_query($sql);

	if(!mysql_errno()){

		$cnt = mysql_num_rows($result);

		if ($cnt > 0){

			$row = mysql_fetch_array($result);

			$userid		= $row['USERID'];

			$uname		= $row['USERNAME'];

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

			$location	= $row['LOCATION'];

			$interests	= $row['INTERESTS'];

			$about		= $row['HOBBIES'];

			$website	= $row['WEBSITE'];

			$portfolio	= $row['PORTFOLIO'];

			$birthday	= $row['BDAY'];

			$aim		= $row['AIM'];

			$icq		= $row['ICQ'];

			$yim		= $row['YIM'];

			$msn		= $row['MSN'];

			$gtalk		= $row['GTALK'];

			$result = mysql_query('SELECT FIRSTNAME, LASTNAME FROM users WHERE USERID = '.$userid.' LIMIT 1');

			$cnt = mysql_num_rows($result);

			if ($cnt > 0){

				$row = mysql_fetch_array($result);

				$flname = $row['FIRSTNAME'].' '.$row['LASTNAME'];

			}

			if (strlen($aim) > 0){

				$userinfo .= "AIM : ".$aim."<BR />";

			}

			if (strlen($icq) > 0){

				$userinfo .= "ICQ : ".$icq."<BR />";

			}

			if (strlen($yim) > 0){

				$userinfo .= "YIM : ".$yim."<BR />";

			}

			if (strlen($msn) > 0){

				$userinfo .= "MSN : ".$msn."<BR />";

			}

			if (strlen($gtalk) > 0){

				$userinfo .= "GTalk : ".$gtalk."<BR />";

			}

			if (strlen($birthday) > 0){

				$birthday = $pmsg1.$birthday;

			}

		}else{

			$statmsg = $pmsg2;

		}

	}



	if (isset($_SESSION['loggedon']) && ($_SESSION['loggedon'] == true) && ($_SESSION['USERID'] != $userid)){

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

		if(!mysql_errno()){

			$cnt = mysql_num_rows($result);

			if(!mysql_errno()){

				if ($cnt > 0){

					$adDel = '<a href="%URL%@/'.$uname.'/unfriend" title="'.$uname.'"><span>Remove Friend</span></a><a href="%URL%users/messages/reply/@'.$uname.'" title="'.$uname.'"><span>Send Message</span></a>';

				}else{

					$adDel = '<a href="%URL%@/'.$uname.'/friend" title="'.$uname.'"><span>Make Friend</span></a>';

				}

			}

		}

	}



     $tags = array(

     	'%USERNAME%'	=> $uname,

     	'%FLNAME%'		=> $flname,

     	'%LOCATION%'	=> $location,

     	'%BIRTHDAY%'	=> $birthday,

     	'%WEBSITE%'		=> $website,

     	'%PORTFOLIO%'	=> $portfolio,

     	'%USERIMAGE%'	=> $userimg,

     	'%USERINFO%'	=> $userinfo,

     	'%INTERESTS%'	=> $interests,

     	'%ABOUT%'		=> $about,

     	'%USERMENU%'	=> $adDel,

     	'%STATMESSAGE%'	=> $statmsg

     );	

     

	$wpage = strtr($wpage, $tags);

	if(strpos($wpage,"%URL%") !== false){

		$wpage = str_replace('%URL%',$url,$wpage);

	}

	return $wpage;	

}



?>
Return current item: Chirp: The Microblog