Hi, joined up yesterday and decided to create a nice and simple interface for the user profile and share it with you guys. May hopefully have more content coming in the future, see how it goes i guess. Here are some images:
Screenshot (default layout so others may vary):
[ATTACH=CONFIG]774[/ATTACH]
Default profile image:
[ATTACH=CONFIG]775[/ATTACH]
Here is the code, it should work without any modification however this it without any mods so any mods would need to be added:
<?php
include_once('globals.php');
// simple array of the user levels, would be better in globals.php or something
$levels = array(
0 => 'NPC',
1 => 'Player',
2 => 'Admin',
3 => 'Secretary',
4 => 'Assistant'
);
// create a username function to format the username correctly
// parse the id, name & user_level
// using each of the classes in css each name can be formatted acordingly
function username($id, $name, $user_level,$nolink = false) {
global $levels;
return ($nolink == true) ?
'<a href="viewuser.php?u='.$id.'" class="'.$levels[$user_level].'">'.$name.' ['.$id.']</a>' :
'<span class="'.$levels[$user_level].'">'.$name.' ['.$id.']</span>';
}
// says how long ago a timestamp was
// just parse the value in and it returns a string
function timeago($time) {
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
return 'Just now';
}
return $difference .' '. $periods[$j] .' '. $tense;
}
$_GET['u'] = isset($_GET['u']) && ctype_digit($_GET['u']) ? abs((int) $_GET['u']) : 0;
if(!empty($_GET['u']) && $_GET['u'] > 0) {
// get the generic sql resultset
$sql = sprintf(
'SELECT u.*,us.*,c.*,h.*,g.*,f.*,COUNT(r.refREFER) AS ref_count
FROM users u LEFT JOIN userstats us ON u.userid=us.userid
LEFT JOIN cities c ON u.location=c.cityid
LEFT JOIN houses h ON u.maxwill=h.hWILL
LEFT JOIN gangs g ON g.gangID=u.gang
LEFT JOIN fedjail f ON f.fed_userid=u.userid
LEFT JOIN referals r ON r.refREFER = u.userid
WHERE u.userid = %u;',
$_GET['u']
);
// query the results and if the resultset is empty then error
$result = $db->query($sql);
if($db->num_rows($result) == 0) {
echo
'<h2>Error</h2>
<p>Sorry but we could not find this user you are looking for.
Please try again another time</p>';
$h->endpage();
die();
}
// get the results ready to display
$r = $db->fetch_row($result);
} else {
// error so just redirect the page
// more than likely just decided to type int he filename directly
header('Location:index.php');
}
?>
<style type="text/css">
.Admin { color: #f00; }
div#profilewrap {
width: 660px;
}
div#generalinfo {
padding: 0px 12px 12px 0px;
text-align: left;
font-size: 1.3em;
width: 346px;
float: left;
}
div#additionalinfo {
float: right;
width: 300px;
}
div#additionalinfo div#photo {
background: #f5f5f5;
}
div#additionalinfo ul#links {
padding: 0;
}
div#additionalinfo ul#links li {
list-style: none;
padding: 0;
margin: 0;
}
div#additionalinfo ul#links li a {
display: block;
text-align: left;
background: #f5f5f5;
border: 1px solid #999;
font-size: 1.1em;
padding: 8px;
margin: 6px 0px;
text-shadow: 1px 1px 1px #fff;
filter: dropshadow(color=#fff, offx=1, offy=1);
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
/* CSS3 ELEMENTS: GRADIENT BACKGROUND */
background-image: linear-gradient(bottom, rgb(230,230,230) 50%, rgb(245,245,245) 100%);
background-image: -o-linear-gradient(bottom, rgb(230,230,230) 50%, rgb(245,245,245) 100%);
background-image: -moz-linear-gradient(bottom, rgb(230,230,230) 50%, rgb(245,245,245) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(230,230,230) 50%, rgb(245,245,245) 100%);
background-image: -ms-linear-gradient(bottom, rgb(230,230,230) 50%, rgb(245,245,245) 100%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.5, rgb(230,230,230)),
color-stop(1, rgb(245,245,245))
);
}
div#additionalinfo ul#links li a:hover {
background: #ccc;
text-shadow: 0;
filter: 0;
}
div#staffinfo {
text-align: left;
padding: 24px;
margin: 24px 48px;
background: #f5f5f5;
}
div#staffinfo div#info {
width: 260px;
float:left;
}
div#staffinfo div#notes {
float:left;
width: 340px;
}
div#staffinfo div#notes textarea {
display: block;
width: 316px;
height: 10em;
border: 1px solid #ccc;
padding: 12px;
}
span.vlabel {
clear: left;
float: left;
display: block;
width: 45%;
margin-bottom: 6px;
}
span vv {
clear: right;
float: left;
margin-bottom: 6px;
}
.well {
color: #300;
text-shadow: 1px 1px 1px #999;
filter: dropshadow(color=#999, offx=1, offy=1);
margin-bottom: 12px;
}
.alert {
background: #ffc;
padding: 0px 12px 6px 12px;
border: 1px solid #fc3;
margin-bottom: 12px;
text-shadow: 1px 1px 1px #fff;
filter: dropshadow(color=#fff, offx=1, offy=1);
}
.warning {
background: #fcc;
padding: 0px 12px 6px 12px;
border: 1px solid #933;
margin-bottom: 12px;
color: #933;
text-shadow: 1px 1px 1px #fff;
filter: dropshadow(color=#fff, offx=1, offy=1);
}
.alert p, .warning p {margin: 6px 0;}
.alert p.b, .warning p.b {margin: 12px 0;color:#600;}
.pageTitle{font-size:24px;}
.b{font-weight: 600;}
.hdr{font-weight:bold;}
.push {margin-top:12px;margin-bottom:12px;}
.clear{clear:both;}
</style>
<h2 class="pageTitle"><?php echo username($r['userid'],$r['username'],$r['user_level']); ?></h2>
<div id="profilewrap">
<div id="generalinfo">
<? if($r['user_level'] != 1) : ?>
<div class="well">
<span class="vlabel">User Level</span><span class="vv"><? echo $r['user_level']; ?></span><br class="clear" />
<span class="vlabel">Duties</span><span class="vv"><? echo $r['duties']; ?></span><br class="clear" />
</div>
<? endif; ?>
<? if($r['fedjail']): ?>
<div class="warning">
<p class="b">Fed Jail</p>
<p>This user is in federal jail for <? echo number_format($r['fedjail']); ?> days.</p>
<? if($r['fb_reason']): ?><p><? echo $r['fb_reason']; ?></p><? endif; ?>
</div>
<? endif; ?>
<? if($r['hospital'] || $r['jail']): ?>
<div class="alert">
<? if($r['hospital']): ?>
<p class="b">Hospitalised</p>
<p>This user is in hospital for <? echo $r['hospital']; ?> minutes.</p>
<? if($r['hospreason']): ?><p><? echo $r['hospreason']; ?></p><? endif; ?>
<? endif; ?>
<? if($r['jail']): ?>
<p class="b">Jailed</p>
<p>This user is in jail for <? echo $r['jail']; ?> minutes.</p>
<? if($r['jail_reason']): ?><p><? echo $r['jail_reason']; ?></p><? endif; ?>
<? endif; ?>
</div>
<? endif; ?>
<span class="vlabel push hdr">General</span><br class="clear" />
<span class="vlabel">Gender</span><span class="vv"><? echo $r['gender']; ?></span><br class="clear" />
<span class="vlabel">Days Old</span><span class="vv"><? echo $r['daysold']; ?></span><br class="clear" />
<span class="vlabel">Joined</span><span class="vv"><? echo date('j F, Y',$r['signedup']); ?></span><br class="clear" />
<span class="vlabel">Last Action</span><span class="vv"><? echo timeago($r['laston']); ?></span><br class="clear" />
<span class="vlabel">Location</span><span class="vv"><? echo $r['cityname']; ?></span><br class="clear" />
<span class="vlabel push hdr">Physical</span><br class="clear" />
<span class="vlabel">Level</span><span class="vv"><? echo $r['level']; ?></span><br class="clear" />
<span class="vlabel">Health</span><span class="vv"><? echo $r['hp'] .'/'. $r['maxhp']; ?></span><br class="clear" />
<span class="vlabel">Gang</span><span class="vv"><?
echo ($r['gang']) ? '<a href="gangs.php?action=view&ID='.$r['gang'].'">'.$r['gangNAME'].'</a>' : 'N/A';
?></span><br class="clear" />
<span class="vlabel push hdr">Social</span><br class="clear" />
<span class="vlabel">Property</span><span class="vv"><? echo $r['hNAME']; ?></span><br class="clear" />
<span class="vlabel">Friends</span><span class="vv"><? echo $r['friend_count']; ?></span><br class="clear" />
<span class="vlabel">Enemies</span><span class="vv"><? echo $r['enemy_count']; ?></span><br class="clear" />
<span class="vlabel">Referals</span><span class="vv"><? echo $r['ref_count']; ?></span><br class="clear" />
</div>
<div id="additionalinfo">
<div id="photo">
<img src="<? echo $r['display_pic'] ? $r['display_pic'] : 'noimg.png'; ?>" width="300" height="380" title="Profile Image" alt="Profile Image" />
</div>
<ul id="links">
<? if($r['userid'] != $userid) : ?>
<? if($ir['mailban'] == 0 && $r['mailban'] == 0): ?>
<li><a href="mailbox.php?action=compose&ID=<? echo $r['userid']; ?>">Send Mail</a></li>
<? endif; ?>
<li><a href="sendcrys.php?ID=<? echo $r['userid']; ?>">Send Crystals</a></li>
<li><a href="sendcash.php?ID=<? echo $r['userid']; ?>">Send Money</a></li>
<? if($r['jail'] == 0 && $r['hospital'] == 0 && $r['fedjail'] == 0): ?>
<li><a href="contactlist.php?action=add&ID=<? echo $r['userid']; ?>">Attack</a></li>
<? endif; ?>
<? if($ir['donatordays'] > 0): ?>
<li><a href="friendslist.php?action=add&ID=<? echo $r['userid']; ?>">Add Friend</a></li>
<li><a href="blacklist.php?action=add&ID=<? echo $r['userid']; ?>">Add Enemy</a></li>
<? endif; ?>
<? if($ir['user_level'] > 1): ?>
<li><a href="jailuser.php?userid=<? echo $r['userid']; ?>">Jail</a></li>
<li><a href="mailban.php?userid=<? echo $r['userid']; ?>">Mail Ban</a></li>
<? endif; ?>
<? endif; ?>
</ul>
</div>
<br class="clear" />
</div>
<? if(in_array($ir['user_level'], array(2,3,4,5)) && $userid != $r['userid']): ?>
<div id="staffinfo">
<div id="info">
<span class="vlabel">Last Hit</span><span class="vv"><? echo $r['lastip'] .' ('. @gethostbyaddr($r['lastip']).')'; ?></span><br class="clear" />
<span class="vlabel">Last Login</span><span class="vv"><? echo $r['lastip_login'] .' ('. @gethostbyaddr($r['lastip_login']).')'; ?></span><br class="clear" />
<span class="vlabel">Signup</span><span class="vv"><? echo $r['lastip_signup'] .' ('. @gethostbyaddr($r['lastip_signup']).')'; ?></span><br class="clear" />
</div>
<div id="notes">
<form action="staffnotes.php" method="post">
<textarea name="staffnotes"><? echo $r['staffnotes']; ?></textarea>
<input type="hidden" name="ID" value="<? echo $r['userid']; ?>" />
<p><input type="submit" value="Change" /></p>
</form>
</div>
<br class="clear" />
</div>
<? endif; ?>
<? $h->endpage(); ?>