<?php
/**
 * $Source: /home/cvs/nukescripts/modules/Your_Account/public/userinfo.php,v $
 * $Revision: 3.3.1-1 $
 * $Author: cyril $
 * $Date: 2006/07/01 12:15:04 $
 * Fix champs perso ( Bug 127 )
 */
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
/********************************************************/
/* NSN Your Account                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.fr                            */
/* Original Script www.nukescripst.net                  */
/* Copyright  2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");
defined('IN_YA') or die("You can't access this file directly.");

$resultbc = $GLOBALS['db']->sql_query("SELECT * FROM `".$prefix."_bbconfig`");
while($rowbc = $GLOBALS['db']->sql_fetchrow($resultbc)) {
    $board_config[$rowbc['config_name']] = $rowbc['config_value'];
}

$GLOBALS['db']->sql_query("UPDATE `".TABLE_USERS."` SET `dernpassage`=now() WHERE `username`='$username' ");
//require_once("includes/nbbcode.php");
$result  = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `username`='$username'");
$num     = $GLOBALS['db']->sql_numrows($result);
$usrinfo = $GLOBALS['db']->sql_fetchrow($result);
if(!$bypass) cookiedecode($user);
incoh();
global $prefix, $cookie, $admin_file;
$ip = getenv("REMOTE_ADDR");
ya_IPCheck($ip);
if ($num > 0) {
    if ($usrinfo['user_level'] > 0) {
        include_once('kernel/bbcode/bbcode.php');
        Max_OpenTable();
        echo "<center>";
        if ((strtolower($usrinfo['username']) == strtolower($cookie[1])) AND ($usrinfo['user_password'] == $cookie[2])) {
            echo "<font class=\"option\">$username, "._WELCOMETO." $sitename!</font>";
            br('2');
            echo "<font class=\"content\">"._THISISYOURPAGE."</font></center><br />";
	    $ip = getenv("REMOTE_ADDR");$current_time = time();
	    $GLOBALS['db']->sql_query("UPDATE `".TABLE_USERS."` SET `last_ip`='$ip', `user_lastvisit`='$current_time' WHERE `username`='$cookie[1]'");
            nav('1');
	    br('2');
    	    include_once('kernel/addons/dyn_readfolder.php');
	    Nav_Folder( "modules/Your_Account/dyn_navbar" , "links" );
            br('2');
        } else {
            echo "<font class='title'>"._PERSONALINFO.": ".$usrinfo['username']."</font></center><br />";
        }
        if($num == 1) {
            echo "<center>\n";
            echo "<table bgcolor=\"$bgcolor4\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" class=\"content\" width=\"70%\">\n";
            echo "<tr>\n<td align=\"center\" bgcolor=\"$bgcolor2\" class=\"title\" colspan=\"2\" width=\"100%\">";
if (!empty($usrinfo['user_avatar'])) {
            if ($usrinfo['user_avatar_type'] == 1) { // Type 1
                $user_avatar = $board_config['avatar_path']."/".$usrinfo['user_avatar'];
            } elseif($usrinfo['user_avatar_type'] == 2) { // Type 2
                echo "<img src='$usrinfo[user_avatar]'>";
            } elseif($usrinfo['user_avatar'] == "") { // Type 3
                echo "<img src='".$board_config['avatar_gallery_path']."/gallery/blank.gif'>";
            } else {
                echo "<img src='".$board_config['avatar_gallery_path']."/".$usrinfo['user_avatar']."'>";
            }
}
            echo "</td>\n</tr>\n";
            $usrinfo['user_website'] = strtolower($usrinfo['user_website']);
            $usrinfo['user_website'] = str_replace("http://", "", $usrinfo['user_website']);
            if ($usrinfo['user_website'] == "") {
                $userwebsite = _YA_NA;
            } else {
                $userwebsite = "<a href=\"http://$usrinfo[user_website]\" target=\"new\">$usrinfo[user_website]</a>";
            }
            if (defined('ADMIN_ALLOW') || $usrinfo['user_viewemail'] == 1) {
                $user_email = "<a href='mailto:$usrinfo[user_email]'>$usrinfo[user_email]</a>";
            } else {
                $user_email = _YA_NA;
            }
            $usrinfo['user_sig'] = nl2br($usrinfo['user_sig']);
            $usrinfo['user_bio'] = nl2br($usrinfo['user_bio']);
	    if ( $currentlang == "french" || $currentlang == "italian" ) {
	    $usrinfo['user_lastvisit'] = date("d-m-Y H:i:s", $usrinfo['user_lastvisit']);
	    } else {
            $usrinfo['user_lastvisit'] = date("D M j H:i:s T Y", $usrinfo['user_lastvisit']);
	    }
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._USERNAME."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[username]</b></td>\n</tr>\n";
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._REALNAME."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[name]</b></td>\n</tr>\n";
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._EMAIL."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$user_email</b></td>\n</tr>\n";
	    if ($userwebsite != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._WEBSITE."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$userwebsite</b></td>\n</tr>\n";}

if (ya_get_field(1) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='1' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field1` from `".TABLE_NSNYA_USERSFIELDS."`  where `user_id`='$usrinfo[user_id]' "));
$field1 = stripslashes(check_html($u['field1'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field1</b></td></tr>";	}
if (ya_get_field(2) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."`  where `id`='2' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field2` from `".TABLE_NSNYA_USERSFIELDS."`  where `user_id`='$usrinfo[user_id]' "));
$field2 = stripslashes(check_html($u['field2'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field2</b></td></tr>";	}
if (ya_get_field(3) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."`  where `id`='3' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field3` from `".TABLE_NSNYA_USERSFIELDS."`  where `user_id`='$usrinfo[user_id]' "));
$field3 = stripslashes(check_html($u['field3'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field3</b></td></tr>";	}
if (ya_get_field(4) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='4' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field4` from `".TABLE_NSNYA_USERSFIELDS."`  where `user_id`='$usrinfo[user_id]' "));
$field4 = stripslashes(check_html($u['field4'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field4</b></td></tr>";	}
if (ya_get_field(5) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='5' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field5` from `".TABLE_NSNYA_USERSFIELDS."` where `user_id`='$usrinfo[user_id]' "));
$field5 = stripslashes(check_html($u['field5'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field5</b></td></tr>";	}
if (ya_get_field(6) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='6' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field6` from `".TABLE_NSNYA_USERSFIELDS."`  where `user_id`='$usrinfo[user_id]' "));
$field6 = stripslashes(check_html($u['field6'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field6</b></td></tr>";	}
if (ya_get_field(7) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='7' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field7` from `".TABLE_NSNYA_USERSFIELDS."` where `user_id`='$usrinfo[user_id]' "));
$field7 = stripslashes(check_html($u['field7'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field7</b></td></tr>";	}
if (ya_get_field(8) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='8' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field8` from `".TABLE_NSNYA_USERSFIELDS."` where `user_id`='$usrinfo[user_id]' "));
$field8 = stripslashes(check_html($u['field8'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field8</b></td></tr>";	}
if (ya_get_field(9) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='9' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field9` from `".TABLE_NSNYA_USERSFIELDS."` where `user_id`='$usrinfo[user_id]' "));
$field9 = stripslashes(check_html($u['field9'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field9</b></td></tr>";	}
if (ya_get_field(10) != "") {
$row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `titre` from `".TABLE_NSNYA_FIELDS."` where `id`='10' "));
$titre = stripslashes(check_html($row['titre'], "nohtml"));
$u = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("select `field10` from `".TABLE_NSNYA_USERSFIELDS."` where `user_id`='$usrinfo[user_id]' "));
$field10 = stripslashes(check_html($u['field10'], "nohtml"));
echo "<tr><td bgcolor=\"$bgcolor2\">$titre</td>";
echo "<td bgcolor=\"$bgcolor3\"><b>$field10</b></td></tr>";
	}

	    if ($usrinfo['user_icq'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._ICQ."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_icq]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_aim'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._AIM."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_aim]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_yim'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._YIM."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_yim]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_msnm'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._MSNM."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_msnm]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_from'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._CITY."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_from2]</b></td>\n</tr>\n";}

     $raw = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `country` FROM `".TABLE_USERS."_countries` WHERE `c2code`='".$usrinfo['user_from']."'"));
     $crow2 = stripslashes($raw['crow2']);
if (!empty($crow2)){
$userinfo['user_from'] = $usrinfo['user_from'];
}else{
$userinfo['user_from'] = "blank";
}
            echo "<tr bgcolor=\"$bgcolor2\"><td width=\"20%\">"._COUNTRY."</td><td width=\"80%\" bgcolor=\"$bgcolor3\"><img src=\"images/flags/".$usrinfo['user_from'].".png\" alt=\"$crow2\" title=\"$crow2\"><font size=\"2\"> $crow2</font></td></tr>\n";


	    if ($usrinfo['user_regdate'] != "") {
	    if (($currentlang = "french") OR ($currentlang = "italian")) {
            $usrinfo['user_regdate'] = french_date($usrinfo['user_regdate']);
	    }
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._REGDATE."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_regdate]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_occ'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._OCCUPATION."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_occ]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_interests'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._INTERESTS."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[user_interests]</b></td>\n</tr>\n";}
	    if ($usrinfo['user_sig'] != "") {
            $sign = stripslashes($usrinfo['user_sig']);
            $sign = bbcode_replace($sign, '');
            echo "<tr>\n<td width=\"30%\" valign='top' bgcolor=\"$bgcolor2\">"._SIGNATURE."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\">$sign</td>\n</tr>\n";}
	    if ($usrinfo['bio'] != "") {
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._EXTRAINFO."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[bio]</b></td>\n</tr>\n";}
	    $lasttime = formattimestamp($usrinfo['dernpassage']);
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._YA_LASTVISIT."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$lasttime</b></td>\n</tr>\n";
            $sql2 = "SELECT `uname` FROM `".TABLE_SESSION."` WHERE `uname`='$username'";
            $result2 = $GLOBALS['db']->sql_query($sql2);
            $row2 = $GLOBALS['db']->sql_fetchrow($result2);
            $username_pm = $username;
            $username = stripslashes($row2['uname']);
            if ($username == "") { $online = _OFFLINE; } else { $online = _ONLINE; }
            echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._USERSTATUS."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$online</b></td>\n</tr>\n";
          //  if (is_user($user) AND $cookie[1] == "$username" OR is_admin($admin)) {
           //     echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._YA_POINTS."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[points]</b></td>\n</tr>\n";
          //  }
            if (($usrinfo['newsletter'] == 1) AND ($username == $cookie[1]) AND ($usrinfo['user_password'] == $cookie[2]) OR (defined('ADMIN_ALLOW') AND ($usrinfo['newsletter'] == 1))) {
                echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._NEWSLETTER."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>"._SUBSCRIBED."</b></td>\n</tr>\n";
            } elseif (($usrinfo['newsletter'] == 0) AND ($username == $cookie[1]) AND ($usrinfo['user_password'] == $cookie[2]) OR (defined('ADMIN_ALLOW') AND ($usrinfo['newsletter'] == 0))) {
                echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._NEWSLETTER."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>"._NOTSUBSCRIBED."</b></td>\n</tr>\n";
            }
	    if (defined('ADMIN_ALLOW')) {
	      echo "<tr>\n<td width=\"30%\" bgcolor=\"$bgcolor2\">"._YA_LASTIP."</td>\n<td width=\"70%\" bgcolor=\"$bgcolor3\"><b>$usrinfo[last_ip]</b></td>\n</tr>\n";
            }
            echo "</table>\n";
            echo "</center><br />\n<center>\n";
            if (is_active("Journal") AND $cookie[1] != $username) {
                $sql3 = "SELECT `jid` FROM `".$prefix."_journal` WHERE `aid`='$username' AND `status`='yes' ORDER BY `pdate`,`jid` DESC LIMIT 0,1";
                $result3 = $GLOBALS['db']->sql_query($sq3);
                $row3    = $GLOBALS['db']->sql_fetchrow($result3);
                $jid     = intval($row3['jid']);
                if ($jid != "" AND isset($jid)) {
                    echo "[ <a href=\"modules.php?name=Journal&amp;file=search&amp;bywhat=aid&amp;forwhat=$username\">"._READMYJOURNAL."</a> ]<br />";
                }
            }
            if (defined('ADMIN_ALLOW')) {
                echo "[ <a href=\"".$admin_file.".php?op=modifyUser&amp;chng_uid=$usrinfo[user_id]\">"._EDITUSER."</a> ] ";
                echo "[ <a href=\"".$admin_file.".php?op=suspendUser&amp;chng_uid=$usrinfo[user_id]\">"._SUSPENDUSER."</a> ] ";
                echo "[ <a href=\"".$admin_file.".php?op=deleteUser&chng_uid=$usrinfo[user_id]\">"._DELETEUSER."</a> ]";
	        br('2');
		echo "[ <a href=\"modules.php?name=Your_Account&amp;op=ya_banuser&amp;userid=$usrinfo[user_id]&amp;username=$usrinfo[username]&amp;ip=$usrinfo[last_ip]\"><font color='blue'>"._YA_BANUSER."</FONT></a> ]<br />";
            }
            if (((defined('USER_ALLOW') AND $cookie[1] != $username) OR defined('ADMIN_ALLOW')) AND is_active("Private_Messages")) { echo "<br />[ <a href=\"modules.php?name=Private_Messages&amp;mode=post&amp;u=$usrinfo[user_id]\">"._USENDPRIVATEMSG." $usrinfo[username]</a> ]<br />\n"; }
            echo "</center></font>";
        } else {
            echo "<center>"._NOINFOFOR." $username</center>";
        }
        Max_CloseTable();

        $incsdir = dir("modules/$module_name/includes");
        while($func=$incsdir->read()) {
            if(substr($func, 0, 3) == "ui-") {
                $incslist .= "$func ";
            }
        }
        closedir($incsdir->handle);
        $incslist = explode(" ", $incslist);
        sort($incslist);
        for ($i=0; $i < sizeof($incslist); $i++) {
            if($incslist[$i]!="") {
                $counter = 0;
                include($incsdir->path."/$incslist[$i]");
            }
        }

    } else {
        Max_OpenTable();
        echo "<center><b>"._NOINFOFOR." <i>".$usrinfo['username']."</i></b></center>";
        if($usrinfo['user_level'] == 0) { echo "<br /><center><b>"._ACCSUSPENDED."</b></center>"; }
        if($usrinfo['user_level'] == -1) { echo "<br /><center><b>"._ACCDELETED."</b></center>"; }
        Max_CloseTable();
    }
} else {
    Max_OpenTable();
    echo "<center><b>"._NOINFOFOR." <i>".$usrinfo['username']."</i></b></center>"
        ."<br /><center><b>"._YA_ACCNOFIND."</b></center>";
    Max_CloseTable();
}
$GLOBALS['db']->sql_freeresult($result);
incof();