<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/

require_once('./includes/core.php');
require_once('./includes/session.php');
$data = new me_sql;
$lang->addLocale("home.me");

$page['id'] = "me";
$page['name'] = $lang->loc['pagename.me'];
$page['bodyid'] = "home";
$page['cat'] = "home";
require_once('./templates/community_header.php');
?>

<div id="container">
	<div id="content">
    <div id="column1" class="column">
				<div class="habblet-container ">

						<div id="new-personal-info" style="background-image:url(<?php echo PATH; ?>/web-gallery/v2/images/personal_info/hotel_views/<?php echo $settings->find("site_hotel_image"); ?>)" />
<div id="badge-back">
        <img src="./web-gallery/v2/images/personal_info/badgeback.png">
        <img src="./web-gallery/v2/images/personal_info/badgeback.png">
        <img src="./web-gallery/v2/images/personal_info/badgeback.png">
        <img src="./web-gallery/v2/images/personal_info/badgeback.png">
        <img src="./web-gallery/v2/images/personal_info/badgeback.png">
</div>
<?php

    $sql = mysql_query("SELECT * FROM users_badges WHERE userid = '".$user->user['0']."' ORDER BY badgeid ASC LIMIT 5");
    $count = mysql_num_rows($sql);
?>

<div id="badge-back">
    <?php
    if($count == 0){
        echo " ";
    }else{
    ?>
    <ul class="badge-back"><br>
<?php
    while($badgerow = mysql_fetch_assoc($sql)){
                echo "
&nbsp; &nbsp;<img src='".$settings->find('site_c_images_path').$settings->find('site_badges_path').$badgerow['badgeid'].".gif'/> &nbsp; ";
}
}
    ?>

    </div>

    <div class="enter-hotel-btn">
<?php if(HotelStatus() == "online"){ ?>
        <div class="open enter-btn">
                <a href="<?php echo PATH; ?>/client" target="client" onclick="openOrFocusHabbo(this); return false;"><?php echo $lang->loc['enter.short']; ?><i></i></a>
            <b></b>
        </div>
<?php } else { ?>
<div class="closed enter-btn">
    <span><?php echo $lang->loc['closed.short']; ?></span>
    <b></b>
</div>
<?php } ?>
    </div>

    <div id="habbo-plate">
        <a href="<?php echo PATH; ?>/profile">
            <img alt="<?php echo $user->name; ?>" src="<?php echo $user->avatarURL("self","b,3,3,sml,1,0"); ?>" width="64" height="110" />
        </a>
    </div>

    <div id="habbo-info">
        <div id="motto-container" class="clearfix">
            <strong><?php echo $user->name; ?>:</strong>
            <div>
                <?php if($user->user("mission") != ""){ echo $input->unicodeToImage($input->HoloText($user->user("mission"))); } else { echo $lang->loc['change.motto']; } ?>

            </div>
        </div>
        <div id="motto-links" style="display: none"><a href="#" id="motto-cancel"><?php echo $lang->loc['cancel']; ?></a></div>
    </div>

    <ul id="link-bar" class="clearfix">
        <li class="change-looks"><a href="<?php echo PATH; ?>/profile"><?php echo $lang->loc['change.looks']; ?> &raquo;</a></li>
        <li class="credits">
            <a href="<?php echo PATH; ?>/credits"><?php echo $user->user("credits"); ?></a> <?php echo $lang->loc['credits']; ?>

		</li>
                   	<li class="credits">
		 <?php echo $fetch_array ['bank']; ?> in bank
		</li>
	</ul>

    <div id="habbo-feed">
        <ul id="feed-items">
<br>

 <li id="feed-item-tutor-score">


						<div style="float: left; background-image: url(web-gallery/v2/images/personal_info/info_icons.png); background-position: 0 -433px; background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Stamina</div></div><div align="right" style=" padding-top:4px" >

						0</div>
						<div style="float: left; background-image: url(int.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Intelligence</div></div><div align="right" style=" padding-top:4px">
						0</div>
						<div style="float: left; background-image: url(str.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Strength</div></div><div align="right" style=" padding-top:4px">
						0</div>
						<div style="float: left; background-image: url(health.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Health Points</div></div><div align="right" style=" padding-top:4px">

						100</div>
						<div style="float: left; background-image: url(immunity.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Immunity</div></div><div align="right" style=" padding-top:4px">
						0</div>
 </li>

<?php
if($serverdb->result($data->select1($user->id), 0) == "1" && $serverdb->result($core->select9($user->id), 0) == 0) {
$removed = $db->result($db->query("SELECT COUNT(*) FROM ".PREFIX."alerts WHERE userid = '".$user->id."' AND alert = 'clubalert' AND type = '-1'"));
if($removed < 1){ ?>
<li id="feed-item-hc-reminder">
    <a href="#" class="remove-feed-item" id="remove-hc-reminder" title="<?php echo $lang->loc['remove.hc.notice']; ?>"><?php echo $lang->loc['remove.hc.notice']; ?></a>

	<div>
				</div>

</li>
<script type="text/javascript">
L10N.put("subscription.title", "<?php echo addslashes($lang->loc['habbo.club']); ?>");
</script>
<?php
}
}

if($user->user("rank") > 4){
    $sql = $db->query("SELECT COUNT(*) FROM ".PREFIX."help WHERE picked_up = '0'");
    if($db->result($sql) > 0){
            echo "            <li class=\"small\" id=\"feed-group-discussion\">
                <strong>".$lang->loc['staff.messages']."</strong><br />".$lang->loc['there.are']." <strong><a href=\"".PATH."/housekeeping/help\" target=\"_self\">".$db->result($sql)."</a></strong> ".$lang->loc['help.quries']."
            </li>";
    }
}

$sql = $db->query("SELECT * FROM ".PREFIX."alerts WHERE userid = '".$user->id."' AND type > -1 ORDER BY id DESC");
    if($db->num_rows($sql) > 0){
		while($row = $db->fetch_assoc($sql)) {
	        if($row['type'] == 2){
				$heading = $lang->loc['notification'];
	        }else{
				$heading = $lang->loc['message'];
			}
?>
			<li id="feed-item-campaign" class="contributed">
			    <a href="#" class="remove-feed-item" title="<?php echo $lang->loc['remove.notification']; ?>"><?php echo $lang->loc['remove.notification']; ?></a>
			    <div>
			            <b><?php echo $heading; ?></b><br />
			            <?php echo nl2br($input->HoloText($row['alert'],true)); ?>
			    </div>
			</li>

<?php
        }
    }
$dob = $user->user("birth");
$bits = explode("-", $dob);
$day = $bits[0];
$month2 = $bits[1];
$year2 = $bits[2];
$date = HoloDate();
if($day == $date['today'] && $month2 == $date['month']){
?>
			<li id="feed-birthday">
			    <div>
			            <?php echo $lang->loc['happy.birthday'].", ".$user->name."!"; ?>
			    </div>
			</li>
<?php }
$cutoff = (time() - 1801);
$sql = $data->select4($cutoff, $user->id);
$count = $serverdb->num_rows($sql);
$i = 0;
if($db->num_rows($sql) > 0){
?>
			<li id="feed-friends">
				<?php echo $lang->loc['you.have']; ?> <strong><?php echo $count; ?></strong> <?php echo $lang->loc['friends.online']; ?>
				<span>
			<?php while($row = $db->fetch_row($sql)){
					$i++;
					echo $row[0];
					if($i < $count){ echo ", "; }
					echo "\n";
				} ?>
				</span>
			</li>
<?php } 

$sql = $data->select14($user->id);
$i = 0;
$groups = "";
while($row = $db->fetch_row($sql)){
	$row2 = $db->fetch_assoc($db->query("SELECT MAX(".PREFIX."forum_posts.time) AS lastpost_time FROM ".PREFIX."forum_threads,".PREFIX."forum_posts WHERE groupid = '".$row[0]."' LIMIT 1"));
	if($row2['lastpost_time'] > $user->user("lastvisit")){
		$i++;
		$groups = $groups."\n<a href=\"".groupURL($row[0])."/discussions\">".$row[1]."</a>, ";
	}
}
if($i > 0 && $groups != ""){
$groups = substr($groups,0,-2);
?>
            <li class="small" id="feed-group-discussion">
            	<strong><?php echo $i; ?></strong> <?php echo $lang->loc['groups.new.messages']; ?>:
            	<span><?php echo $groups; ?>
            	</span>
            </li>
<?php } ?>

            <li class="small" id="feed-lastlogin">
                <?php echo $lang->loc['last.online']; ?>:
                <?php echo date('M j, Y g:i:s A', $user->user("lastvisit")); ?>
            </li>


        </ul>
    </div>
    <p class="last"></p>
</div>

<script type="text/javascript">
    HabboView.add(function() {
        L10N.put("personal_info.motto_editor.spamming", "<?php echo addslashes($lang->loc['no.spam']); ?>");
        PersonalInfo.init("");
    });
</script>



                </div>
                <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
				
<?php $lang->addLocale("widget.campaigns"); ?>
				<div class="habblet-container ">		
						<div class="cbb clearfix green ">

	
							<h2 class="title"><span style="float: left;">Campaigns</span>
							</h2>
						<div id="hotcampaigns-habblet-list-container">
    <ul id="hotcampaigns-habblet-list">
<?php
$i = 0; $sql = $db->query("SELECT * FROM ".PREFIX."campaigns WHERE visible = '1' ORDER BY id DESC");
while($row = $db->fetch_assoc($sql)){
if($input->IsEven($i)){ $even = "even"; }else{ $even = "odd"; }
?>

        <li class="<?php echo $even; ?>">
            <div class="hotcampaign-container">
                <a href="<?php echo str_replace("%path%",PATH,$row['url']); ?>"><img src="<?php echo str_replace("%path%",PATH,$row['image']); ?>" align="left" alt="" /></a>
                <h3><?php echo $input->HoloText($row['name'],true); ?></h3>
                <p><?php echo $input->HoloText($row['desc'],true); ?></p>

                <p class="link"><a href="<?php echo str_replace("%path%",PATH,$row['url']); ?>"><?php echo $lang->loc['go.there']; ?> &raquo;</a></p>
            </div>
        </li>

<?php $i++; } ?>
    </ul>
</div>
	
						
					</div>
				</div>
				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>

</div>
				<script type='text/javascript'>if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
<div id="column2" class="column">
<?php $lang->addLocale("widget.news"); ?>
				<div class="habblet-container news-promo">
						<div class="cbb clearfix notitle ">

<?php $sql = $db->query("SELECT * FROM ".PREFIX."news ORDER BY id DESC LIMIT 5");
$i = 0;
while($row = $db->fetch_assoc($sql)){
	$row['summary'] = nl2br($input->HoloText($row['summary'], true));
	$row['title'] = $input->HoloText($row['title'], true);
	$row['title_safe'] = $input->stringToURL($input->HoloText($row['title'],true),true,true);
	$row['date'] = date('M j, Y', $row['time']);
	$news[$i] = $row;
	$i++;
}
?>
						<div id="newspromo">
        <div id="topstories">
	        <div class="topstory" style="background-image: url(<?php echo $news[0]['header_image']; ?>)">
	            <h4><?php echo $lang->loc['latest.news']; ?></a></h4>
	            <h3><a href="<?php echo PATH."/articles/".$news[0]['id']."-".$news[0]['title_safe']; ?>"><?php echo $news[0]['title']; ?></a></h3>
	            <p class="summary">
	            <?php echo $news[0]['summary']; ?>
	            </p>
	            <p>
	                <a href="<?php echo PATH."/articles/".$news[0]['id']."-".$news[0]['title_safe']; ?>"><?php echo $lang->loc['read.more']; ?></a>
	            </p>
	        </div>
            <div id="topstories-nav" style="display: none"><a href="#" class="prev"><?php echo $lang->loc['news.previous']; ?></a><span>1</span> / 3<a href="#" class="next"><?php echo $lang->loc['news.next']; ?></a></div>
        </div>
        <ul class="widelist">
            <li class="even">
                <a href="<?php echo PATH."/articles/".$news[1]['id']."-".$news[1]['title_safe']; ?>"><?php echo $news[1]['title']; ?></a><div class="newsitem-date"><?php echo $news[1]['date']; ?></div>
            </li>
            <li class="odd">
                <a href="<?php echo PATH."/articles/".$news[2]['id']."-".$news[2]['title_safe']; ?>"><?php echo $news[2]['title']; ?></a><div class="newsitem-date"><?php echo $news[2]['date']; ?></div>
            </li>
            <li class="last"><a href="<?php echo PATH; ?>/articles"><?php echo $lang->loc['news.more']; ?></a></li>
        </ul>
</div>
<script type="text/javascript">
	document.observe("dom:loaded", function() { NewsPromo.init(); });
</script>
</div>
                        

				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>

</div>

<script type="text/javascript">
	HabboView.add(LoginFormUI.init);
</script>
<?php


require('./templates/community_footer.php');

?>