I am currently in the process of creating a open source dating script. I am nearly there. Just one thing that I can see that is an error now. When a user completes there profile, other users can see the answers, but the person who the profile belongs to can't. I presume there is something in it that is stopping the user seeing there own profile. I just can't put my finger on it. The code is as follows:
Smarty TPL file
<link href="includes/livevalidation/livevalidation.css" rel="stylesheet" type="text/css" media="screen">
<script language="javascript" type="text/javascript" src="includes/livevalidation/livevalidation.js"></script>
<div class="profile tabs-main">
<h1>{$user.username} {lang mkey='profile'}</h1>
<ul class="tabNavigation-main">
<li><a class="selected" href="#0-main" onclick="return false;"><span>{lang mkey='pulse'}</span></a></li>
{if $found == 1}
{assign var="ctop" value=0}
{foreach item=item from=$pref}
{assign var="ctop" value=$ctop+1}
<li><a class="" href="#{$ctop}-main" onclick="return false;"><span>{$item.SectionName}</span></a></li>
{/foreach}
{else}
<li><a class="" href="#1-main" onclick="return false;"><span>{lang mkey='profile_details'}</span></a></li>
{/if}
</ul>
<div class="tabs-holder-main">
<div style="display:block;" id="0-main">
<div class="contentBox">
<div class="bgBtm">
<div class="bgTop">
<div class="holder searchContent">
{if $smarty.session.UserId != '' && $smarty.session.UserId == $smarty.get.id}
<form action="" onSubmit="javascript:changeStatus({if $smarty.session.UserId != ''}{if $smarty.session.UserId != ''}{$smarty.session.UserId}{else}0{/if}{else}0{/if}); return false;" name="search_form_status" method="post">
<div class="formSearch">
<div class="bgBot">
<label for="search5">Search field</label>
<span class="txt">
<input name="status" id="e8" maxlength="1000" value="What's on your mind?" type="text">
</span>
<div class="area">
<b>{lang mkey='toShare'}<br>
</div>
</div>
</div>
</form>
{/if}
<div id="home_whatsnew">
<div id="Bottom">
<ul class="userResults">
<div id="showing"><span style="color:#999;">{lang mkey='showing'} {$upr+1}{lang mkey='to'}{if $dataResults|@count > $psize+$upr}{$psize+$upr}{else}{$dataResults|@count}{/if} {lang mkey='of'} {$dataResults|@count}</span></div>
<div id="all_div"> {assign var="uprPSIZE" value=$psize+$upr+1}
{assign var="n" value="$upr"}
{assign var="pageno" value=$smarty.get.offset}
{if $pageno == ""}{assign var="pageno" value=1}{/if}
{foreach item="item" key=key from=$dataResults}
{math equation="$n+1" assign="n"}
{if $item.userid > 0}
{if $n < $psize+$upr}
<li id="action_{$item.id}">
<div class="item-holder">
<div class="txt-box">
<div class="container">
<div style="float: left; width: 440px;">
<p> {if $item.gender == 'M'}<img src="{$image_dir}icons/user.png" alt="{$item.gender}">{else}<img src="{$image_dir}icons/user_red.png" alt="{$item.gender}">{/if}<a href="index.php?page=profile&id={$item.userid}">{$item.username}</a> {$item.activity}</p>
</div>
<div class="row" style="float: left; width: 440px;">
<div class="via"> <span>{$item.rttime}</span> <img src="{$image_dir}realtime/ico-1.png" alt="{$config.site_name|stripslashes}" width="16" height="16"> </div>
</div>
</div>
</div>
<a href="index.php?page=profile&id={$item.userid}" class="photo"><img src="getsnap.php?id={$item.userid}&typ=small" height="48" width="48" /></a> </div>
<div style="display: block; width:100%;" class="comments active-text">
<div>
<ul style="display: block;">
<ul>
{foreach item="com" from=$getComsLikes}
{if $item.id == $com.comment_id}
<li><a style="float: left; margin: 3px;" class="photo" href="index.php?page=profile&id={$com.userid}"><img height="48" width="48" title="{$com.username}" src="getsnap.php?id={$com.userid}&typ=small"></a>
<p style="line-height: 22px; padding-left: 3px;"><a href="index.php?page=profile&id={$com.userid}" class="toc"><strong>{$com.username}</strong></a>: {$com.comment}</p>
</li>
{/if}
{/foreach}
</ul>
</ul>
</div>
</div>
<div class="pulse" id="reply_box_{$item.id}" style="display: none;">
<div class="comments">
<div class="block" id="like_count_{$item.id}" style="display: none;">
<div id="like_{$item.id}" style="display: none;"></div>
</div>
<div>
<div>
<ul id="reply_sec_{$item.id}">
</ul>
</div>
</li>
{/if}
{/if}
{/foreach} </div>
</ul>
</div>
</div>
{if $total_pages|@count > 1}
{assign var="pageno" value=$smarty.get.offset}
{if $pageno == ""}{assign var="pageno" value=1}{/if}
{if $pageno != "1"} <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset=1" class="btnBlueB"><span>{lang mkey='first'}</span><em></em></a> <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset={$pageno-1}" class="btnBlueB"><span>{lang mkey='previous'}</span><em></em></a>
{/if}
{if $total_pages|@count <= 5}
{foreach item=pagenos from=$total_pages}
{if $pageno != $pagenos} <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset={$pagenos}" class="btnBlueB"><span>{$pagenos}</span><em></em></a>
{else} <a href="#" class="btnBlueB"><span>{$pagenos}</span><em></em></a>
{/if}
{/foreach}
{else}
{foreach item=pagenos from=$pages_show}
{if $pageno != $pagenos} <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset={$pagenos}" class="btnBlueB"><span>{$pagenos}</span><em></em></a>
{else} <a href="#" class="btnBlueB"><span>{$pagenos}</span><em></em></a>
{/if}
{/foreach}
{/if}
{if $pageno != $total_pages|@count} <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset={$pageno+1}" class="btnBlueB"><span>{lang mkey='next'}</span><em></em></a> <a href="index.php?page=search&realtime&request={$RTrequest}{if $rtsortby}&sort={$rtsortby}{/if}&offset={$total_pages|@count}" class="btnBlueB"><span>{lang mkey='last'}</span><em></em></a>
{/if}
{/if}
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
{if $found == 1}
{assign var="ctop2" value=0}
{foreach item=item from=$pref}
{assign var="ctop2" value=$ctop2+1}
<div style="display:none;" id="{$ctop2}-main">
<div class="contentBox">
<div class="bgBtm">
<div class="bgTop">
<div class="holder profileDetails userDetails"> {assign var="previd" value="0"}
{assign var="prefCnt" value=0}
{foreach item=subitem from=$item.preferences}
{assign var="prefCnt" value=$prefCnt+1}
<div> {if $prefCnt == '1'}
<div class="box-ttl">
<h2><span>{$item.SectionName}</span></h2>
</div>
{/if}
<div class="heading" style="margin-left:-24px;">
<h3>{$subitem.extsearchhead}</h3>
</div>
{if $subitem.type == "select" || $subitem.type == "radio"}
<div class="tabs-holder">
<div id="first-4-{$prefCnt}">{if $subitem.options != ''}{$subitem.options|stripslashes }{else}{lang mkey='tell_later'}{/if} </div>
</div>
{elseif $subitem.type == "textarea"}
<div class="tabs-holder">
<div id="first-4-{$prefCnt}">{if $subitem.options != ''}{$subitem.options|stripslashes|nl2br}{else}{lang mkey='tell_later'}{/if} </div>
</div>
{elseif $subitem.type == "checkbox"}
<div class="tabs-holder">
<div id="first-4-{$prefCnt}">{if $subitem.options != '' and $subitem.options != ', '}{$subitem.options|stripslashes }{else}{lang mkey='tell_later'}{/if} </div>
</div>
{/if} </div>
{/foreach}
{assign var="previd" value=$item.id} </div>
</div>
</div>
</div>
</div>
{/foreach}
{else}
<div style="display:none;" id="1-main">
<div class="contentBox">
<div class="bgBtm">
<div class="bgTop">
<div class="holder profileDetails userDetails">
<div>
<div class="box-ttl">
<h2><span>{lang mkey='profile_details'}</span></h2>
</div>
<div class="tabs-holder"> {if $smarty.session.UserId != '' && $smarty.session.UserId == $smarty.get.id}
<div id="first-4-1"> {lang mkey='view_profile_errmsg1'} <a href="index.php?page=settings&profile">{lang mkey='view_profile_errmsg2'}</a> </div>
{else}
<div id="first-4-1">{lang mkey='view_profile_errmsg3'}</div>
{/if} </div>
</div>
</div>
</div>
</div>
</div>
</div>
{/if} </div>
{literal}
<script type="text/javascript">
initTabs('div.tabs-main','div.tabs-holder-main','ul.tabNavigation-main');
</script>
{/literal}
The PHP File
<?php
$cVersion = '1.0';
$cType = 'widget';
if ( $_SESSION['UserId'] =='' ) {
header('location: index.php?page=login');
exit;
}
$vCheck = $fDB->getOne ("SELECT count(*) from ! where name = ? and type = ?", array( FUSE_VERSIONS, $cName, $cType) );
if ($vCheck != '1') {
$fDB->query( 'insert into ! (name, version, type, date) values (?, ?, ?)', array( FUSE_VERSIONS, htmlentities($cName), htmlentities($cVersion), htmlentities($cType)) );
} else {
$fDB->query( "UPDATE ! SET version = ? WHERE name = ? and type = ?" ,array( FUSE_VERSIONS, htmlentities($cVersion), htmlentities($cName), htmlentities($cType) ) );
}
unset($cName, $cVersion, $vCheck, $cType);
$rType = isset($_GET['type'])?$_GET['type']:'activity';
$psize = getPageSize();
$t->assign ( 'psize', $psize );
$page_size = $psize;
$page = (int)(isset($_GET['offset'])?$_GET['offset']:1);
if( $page == 0 ) $page = 1;
$upr = ($page)*$page_size - $page_size;
$t->assign('getRTresultss', 'Yes');
if (!isset($_GET['request'])){
$_GET['request'] = '';
}
if (isset($_GET['request']) ) {
$t->assign('RTrequest', $_GET['request']);
$dataResults = $fDB->getAll('SELECT * FROM ! WHERE userid = '.$_REQUEST['id'].' ORDER by time desc LIMIT '.$upr.','.$page_size, array( REALTIME_ACTIVITY));
$reccount = $fDB->getOne('select FOUND_ROWS()');
foreach( $dataResults as $rtdata => $results ) {
$results['rttime'] = timeago($results['time']);
$results['age'] = $fDB->getOne('SELECT floor((to_days(curdate())-to_days(birth_date))/365.25) as age FROM ! WHERE id = ?' ,array( USER_TABLE, $results['userid'] ));
$results['country'] = $fDB->getOne( 'SELECT country FROM ! where id = ?', array( USER_TABLE, $results['userid'] ) );
$results['username'] = $fDB->getOne( 'SELECT username FROM ! where id = ?', array( USER_TABLE, $results['userid'] ) );
$results['state_province'] = $fDB->getOne( 'SELECT state_province FROM ! where id = ?', array( USER_TABLE, $results['userid'] ) );
$results['countryname'] = getCountryName( $results['country'] );
$results['statename'] = getStateName( $results['country'], $results['state_province'] );
$results['ref_username'] = $fDB->getOne( 'SELECT username FROM ! where id = ?', array( USER_TABLE, $results['ref_id'] ) );
$results['ref_gender'] = $fDB->getOne( 'SELECT gender FROM ! where id = ?', array( USER_TABLE, $results['ref_id'] ) );
if ($results['is_status'] != 'yes') {
if ($results['ref_id'] != 'NULL') {
$ref_username = $fDB->getOne( 'SELECT username FROM ! where id = ?', array( USER_TABLE, $results['ref_id'] ) );
$ref_link = '<a href="index.php?page=profile&id='.$results['ref_id'].'">'.$ref_username.'</a>';
$results['activity'] = get_lang($results['activity']).' '.$ref_link;
}
}
$dataResults[$rtdata] = $results;
}
$t->assign ( 'total_recs', $reccount );
$total_pages = ceil( $reccount / $page_size );
$pages_vals = array();
for( $i=1; $i<=$total_pages; $i++ ) { $pages_vals[$i] = $i; }
$t->assign ( 'total_pages', $pages_vals );
$page_limit = 5;
$j = 1;
if ( $page > 2 ) { $page = $page - 2; } else { $page = 1; }
for( $i=$page; $i<=$total_pages; $i++ ) {
$pages_show[$i] = $i;
$j++;
if ( $j > $page_limit ) break;
}
$t->assign ( 'pages_show', (isset($pages_show)?$pages_show:1) );
$t->assign ( 'reccount', $reccount );
$t->assign( 'upr', $upr );
$t->assign('dataResults', $dataResults);
}
?>
Any help would be appreciated.