Location: PHPKode > scripts > QT-registrations > qt-registrations/qtregistrations/qtr_usr.php
<?php

/*
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license. If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to hide@address.com so we can mail you a copy immediately.
 *
 * @category   Safety
 * @package    QT-registerations
 * @author     Philippe Vandenberghe <hide@address.com>
 * @copyright  2008-2012 The PHP Group
 * @license    http://www.php.net/license  PHP License 3.0
 * @version    1.3 build:20080923
 * @link       http://www.qt-cute.org/doc/package/qtr
 * @since      File available since Release 1.0.0
 * @deprecated File deprecated in Release 2.0.0
 *
 */

session_start();
require_once('bin/qtr_init.php');
if ( !$oVIP->CanAccess('MUV',4,true) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);

// INITIALISE

  function show_ban($strRole='V',$intBan=0,$L)
  {
    if ( $intBan<1 ) return '';
    if ( $strRole=='A' || $strRole=='M' )
    {
    if ( $intBan>1 ) $intBan=($intBan-1)*10;
    Return '<p class="small error">'.$L['Is_banned'].' '.strtolower(LangS('Day',$intBan,$L)).' '.$L['Since'].' '.strtolower($L['Last_message']).'</p>';
    }
  }

include('bin/qt_lib_smtp.php');
include($_SESSION[QT]['language'].'/qtr_lang_reg.inc');

$bMap = UseModule('map');
if ( $bMap ) { if ( empty($_SESSION[QT]['m_map_gkey']) ) $bMap=false; }
if ( $bMap ) { require_once('qtrm_map_lib.php'); if ( !QTgcanmap('U') ) $bMap=false; }
if ( $bMap ) include(Translate('qtrm_map.inc'));

$id = -1;
if (isset($_GET['id'])) $id = intval($_GET['id']);
if (isset($_POST['id'])) $id = intval($_POST['id']);

$bEdit = false;
if ( $oVIP->id==$id ) $bEdit=true;
if ( $oVIP->role=='A' || $oVIP->role=='M' ) $bEdit=true;
if ( $id==0 ) $bEdit=false;

$oVIP->selfurl = 'qtr_usr.php';
$oVIP->selfname = $L['Profile'];

// --------
// SUBMITTED
// --------

if ( isset($_POST['ok']) )
{
  // check form

  $strLoca = trim($_POST['location']); if ( get_magic_quotes_gpc() ) $strLoca = stripslashes($strLoca);
  $strLoca = QTconv($strLoca,'3',QTR_CONVERT_AMP,true);

  if ( empty($qtr_error) )
  {
    $strMail = trim($_POST['mail']);
    $strMail = str_replace(';',' ; ',$strMail);
    $strMail = str_replace('  ',' ',$strMail);
    if ( !empty($strMail) && !QTismail($strMail) ) $qtr_error=$L['Email'].S.$strMail.' '.$L['E_invalid'];
  }

  if ( empty($qtr_error) )
  {
    $strPhone = QTconv($_POST['phone'],'2');
  }

  if ( empty($qtr_error) )
  {
    $strChild='0';
    $strParentmail = '';
    if ( QTR_USE_COPPA )
    {
    $strChild=$_POST['child'];
    if ( $id=='1' && $strChild!='0' ) $qtr_error='user id[1] is admin and child status cannot be changed...';
    if ( $id=='0' && $strChild!='0' ) $qtr_error='user id[0] is visitor and child status cannot be changed...';
    $strParentmail = trim($_POST['parentmail']);
      if ( !empty($strParentmail) )
      {
      if ( !QTismail($strParentmail) ) $qtr_error=$L['Parent_mail'].S.$L['E_invalid'];
      }
    }
  }

  if ( empty($qtr_error) )
  {
    $strWww = QTconv($_POST['www'],'2');
    if ( !empty($strWww) && substr($strWww,0,4)!='http' ) $qtr_error=$L['Website'].S.$L['E_invalid'];
    if ( $strWww=='http://' || $strWww=='https://' ) $strWww='';
  }

  // save

  if ( empty($qtr_error) )
  {
    $oDB->Query('UPDATE '.TABUSER.' SET location="'.addslashes($strLoca).'", mail="'.$strMail.'", phone="'.addslashes($strPhone).'", www="'.addslashes($strWww).'", privacy="'.$_POST['privacy'].'", children="'.$strChild.'", parentmail="'.$strParentmail.'" WHERE id='.$id);
    if ( isset($_POST['m_map_gcenter']) )
    {
      if ( empty($_POST['m_map_gcenter']) )
      {
      QTgpointdelete($oDB,TABUSER,$id);
      }
      else
      {
      QTgpoint($oDB,TABUSER,$id,QTgety($_POST['m_map_gcenter']),QTgetx($_POST['m_map_gcenter']));
      }
    }

    // parent warning if coppa
    if ( QTR_USE_COPPA && $strChild!='0' )
    {
    $strSubject = $_SESSION[QT]['site_name'].' - Profile updated';
    $strMessage = "Your children (login: %s) has modified his/her profile on the board {$_SESSION[QT]['site_name']}.";
    $strFile = $_SESSION[QT]['language'].'/mail_profile_coppa.inc';
    if ( file_exists($strFile) ) include($strFile);
    $strMessage = sprintf($strMessage, $_POST['name']);
    QTmail($_POST['parentmail'],QTconv($strSubject,'-4'),QTconv($strMessage,'-4'),QTR_HTML_CHAR);
    }

    // exit
    unset($_SESSION['qtrSec']);
    $oVIP->exiturl = "qtr_usr.php?id=$id";
    $oVIP->exitname = $L['Profile'];
    $oVIP->EndMessage(NULL,$L['S_save'],$_SESSION[QT]['skin_dir'],2);
  }
}

// --------
// STATS AND USER
// --------

// -- COUNT TOPICS --

$oDB->Query('SELECT count(id) as countid FROM '.TABTOPIC.' WHERE firstpostuser='.$id);
$row = $oDB->Getrow();
$counttopics = $row['countid'];

// -- COUNT MESSAGES --

$oDB->Query('SELECT count(id) as countid FROM '.TABPOST.' WHERE userid='.$id);
$row = $oDB->Getrow();
$countmessages = $row['countid'];

// -- QUERY USER --

$oDB->Query('SELECT * FROM '.TABUSER.' WHERE id='.$id);
$row = $oDB->Getrow();

// --------
// HTML START
// --------

if ( $bMap )
{
  $strHeaderAddScript = QTgmapheader();
  $strBodyAddOnunload='GUnload()';
}

include('qtr_p_header.php');

if ( $id<0 ) die('Wrong id');

// -- PARTICIPATION INFO --

$strParticip = '';
if ( $counttopics>0 )
{
$strParticip .= '<a href="qtr_search_ov.php?a=user&amp;id='.$id.'&amp;n='.urlencode($row['name']).'">'.LangS('Topic',$counttopics,$L).'</a>, ';
}
if ( $countmessages>0 )
{
  $strParticip .= '<span class="small">'.LangS('Message',$countmessages,$L).', '.strtolower($L['Last_message']).' '.QTdate($row['lastdate'],$arrQTdate);
  $oDB->Query( 'SELECT p.id,p.topic,p.section FROM '.TABPOST.' p WHERE p.userid='.$id.' ORDER BY p.issuedate DESC' );
  $row2 = $oDB->Getrow();
  $strParticip .= ' <a class="small" href="qtr_topic.php?s='.$row2['section'].'&amp;t='.$row2['topic'].'&amp;tt=messages#p'.$row2['id'].'" title="'.$L['H_Goto_message'].'">'.$L['Goto_message'].'</a></span>';

}

// -- STAFF MENU --

if ( $oVIP->role=='A' )
{
echo '<form method="get" action="qtr_cmd.php" id="m-form">
<div class="div_modboard">
<span class="span_modboard">',$L['Userrole']['A'],'
<select name="a" class="small" onchange="',"if (this.value!='') { document.getElementById('m-form').submit(); }",'">
<option value="">',S,'</option>
<option value="pwdreset">',$L['Reset_pwd'],'...</option>',
($id>1 ? '<option value="userrole">'.$L['Change_role'].'...</option>
<option value="user_ban">'.$L['Ban_user'].'...</option>
<option value="user_del">'.$L['User_del'].'...</option>
' :''),'
<input type="submit" name="m-ok" value="',$L['Ok'],'" class="small" id="m-ok"/>
<input type="hidden" name="s" value="',$id,'"/>
<script type="text/javascript">document.getElementById("m-ok").style.visibility="hidden";document.getElementById("m-ok").value="";</script>
</span>
</div>
</form>
';
}

// -- DISPLAY PROFILE --

$strMail = S;
  if ( !empty($row['mail']) )
  {
  $strMail = AsEmails($row['mail'],$id,'0','txt'.($_SESSION[QT]['javamail']=='1' ? 'java' : ''),false,$_SESSION[QT]['skin_dir'],$L['E_javamail']);
  if ( $row['privacy']=='0' && $oVIP->role!='A' ) $strMail = S;
  if ( $row['privacy']=='1' && $oVIP->role=='V' ) $strMail = S;
  if ( $strMail!=S && ($oVIP->id==$id || $oVIP->role=='A' || $oVIP->role=='M') ) $strMail .= ' <span class="disabled">('.$L['Privacy_visible'][$row['privacy']].')</span>';
  }
$strPhone = S;
  if ( !empty($row['phone']) )
  {
  $strPhone = $row['phone'];
  if ( $row['privacy']=='0' && $oVIP->role!='A' ) $strPhone = S;
  if ( $row['privacy']=='1' && $oVIP->role=='V' ) $strPhone = S;
  if ( $strPhone!=S && ($oVIP->id==$id || $oVIP->role=='A' || $oVIP->role=='M') ) $strPhone .= ' <span class="disabled">('.$L['Privacy_visible'][$row['privacy']].')</span>';
  }

echo '
<table class="ta_hidden" cellspacing="0">
<colgroup span="2"><col width="175"></col><col></col></colgroup>
<tr class="tr_hidden">
<td class="td_hidden"><h2>',$oVIP->selfname,'</h2><br/>',AsImgBox(AsImg( (!empty($row['avatar']) ? 'avatar/'.$id.'.'.$row['avatar'] : ''),null,$row['name']),'div_pic_box',null,$row['name']),show_ban($oVIP->role,$row['closed'],$L),'</td>
<td class="td_hidden">
';
echo '
<table class="ta ta_o" cellspacing="0">
<colgroup span="2"><col width="150"></col><col></col></colgroup>
<tr><th class="th_o th_o_first">',$L['Username'],'</th><td class="td_o"><b>',$row['name'],'</b>',($row['role']!='U' ? ' ('.$L['Userrole'][$row['role']].')' : ''),($oVIP->role=='A' && $id>1 ? ' &nbsp; <a href="qtr_usr_rename.php?id='.$id.'">'.$L['Rename'].'</a>' : ''),'</td></tr>
<tr><th class="th_o th_o_first">',$L['Location'],'</th><td class="td_o">',$row['location'],'&nbsp;</td></tr>
<tr><th class="th_o th_o_first">',$L['Email'],'</th><td class="td_o">',$strMail,'</td></tr>
<tr><th class="th_o th_o_first">',$L['Phone'],'</th><td class="td_o">',$strPhone,'</td></tr>
<tr><th class="th_o th_o_first">',$L['Website'],'</th><td class="td_o">',(empty($row['www']) ? S : '<a href="'.$row['www'].'" target="_blank">'.$row['www'].'</a>'),'</td></tr>
<tr><th class="th_o th_o_first">',$L['Joined'],'</th><td class="td_o">',QTdate($row['firstdate'],$arrQTdate),'&nbsp;</td></tr>
<tr><th class="th_o th_o_first">',$L['Topics'],'</th><td class="td_o">',$strParticip,'</td></tr>
';
if ( !$bEdit ) {
if ( $bMap ) {
if ( !empty($row['x']) && !empty($row['y']) ) {

  $strPosition = '<div id="map_canvas" style="width:100%; height:340px;"></div>';
  if ( $row['privacy']=='0' && $oVIP->role!='A' ) $strPosition = S;
  if ( $row['privacy']=='1' && $oVIP->role=='V' ) $strPosition = S;
  echo '<tr><th class="th_o th_o_first">',$L['map']['position'],'</th><td class="td_o">',$strPosition,'</td></tr>';

}}}

echo '</table>
';
echo '
</td>
</tr>
</table>
';

// -- EDIT PROFILE --
if ( $bEdit ) {
// -- EDIT PROFILE --

echo '
<div class="div_hidden_sep"></div>
';
echo '
<table class="ta_hidden" cellspacing="0">
<colgroup span="2"><col width="175"></col><col></col></colgroup>
<tr class="tr_hidden">
<td>
';
echo '<h2>',$L['User_upd'],'</h2>',N;
if ( $_SESSION[QT]['avatar']!='0' )
{
echo '<p><a href="qtr_usr_img.php?id=',$id,'">',$L['Change_avatar'],'</a></p>',N;
}
echo '<p><a href="qtr_usr_sign.php?id=',$id,'">',$L['Change_signature'],'</a></p>',N;
echo '<p><a href="qtr_usr_pwd_chg.php?id=',$id,'">',$L['Change_password'],'</a></p>',N;
echo '</td>',N;
echo '<td>',N;

echo '
<form method="post" action="qtr_usr.php?id=',$id,'">
<table class="ta ta_o" cellspacing="0">
<colgroup span="2"><col width="150"></col><col></col></colgroup>
<tr><th class="th_o th_o_first">',$L['Location'],'</th><td class="td_o"><input type="text" name="location" size="35" maxlength="24" value="',(empty($row['location']) ? '' : QTconv($row['location'],'I')),'"/></td></tr>
<tr><th class="th_o th_o_first">',$L['Email'],'</th><td class="td_o"><input type="text" name="mail" size="35" maxlength="64" value="',$row['mail'],'"/></td></tr>
<tr><th class="th_o th_o_first">',$L['Phone'],'</th><td class="td_o"><input type="text" name="phone" size="35" maxlength="64" value="',(empty($row['phone']) ? '' : QTconv($row['phone'],'I')),'"/></td></tr>
<tr>
<th class="th_o th_o_first">',$L['Privacy'],'</th>
<td class="td_o">',$L['Email'],'/',$L['Phone'],($bMap ? '/'.$L['map']['position'] : ''),' <select size="1" name="privacy">
<option value="2"',($row['privacy']=='2' ? QSEL : ''),'>',$L['Privacy_visible'][2],'</option>
<option value="1"',($row['privacy']=='1' ? QSEL : ''),'>',$L['Privacy_visible'][1],'</option>
<option value="0"',($row['privacy']=='0' ? QSEL : ''),'>',$L['Privacy_visible'][0],'</option>
</select></td>
</tr>
<tr>
<th class="th_o">',$L['Website'],'</th><td class="td_o"><input type="text" name="www" size="35" maxlength="64" value="',(!empty($row['www']) ? $row['www'] : 'http://'),'" title="',$L['H_Website'],'"/></td>
</tr>
';
if ( $oVIP->role=='A' )
{
  if ( QTR_USE_COPPA )
  {
  echo '<tr>';
  echo '<th class="th_o th_o_first">',$L['Child'],'</th>';
  echo '<td class="td_o">';
  echo '<select size="1" name="child">';
  echo '<option value="0"',($row['children']=='0' ? QSEL : ''),'>',$L['N'],'</option>';
  echo '<option value="1"',($row['children']=='1' ? QSEL : ''),'>',$L['Y'],' ',$L['With_parent_agree'],'</option>';
  echo '<option value="2"',($row['children']=='2' ? QSEL : ''),'>',$L['Y'],' ',$L['Without_parent_agree'],'</option>';
  echo '</select>';
  echo '</td>';
  echo '</tr>',N;
  echo '<tr>';
  echo '<th class="th_o th_o_first">',$L['Parent_mail'],'</th>';
  echo '<td class="td_o"><input type="text" name="parentmail" size="32" maxlength="64" value="',$row['parentmail'],'"/></td>';
  echo '</tr>',N;
  }
}

if ( $bMap )
{
  $strPosition = '<p class="small" style="margin:2px 0 4px 2px;text-align:right">'.$L['map']['cancreate'];
  $strPosition .= ' | <a class="small" href="javascript:void(0)" onclick="createMarker(); return false;" title="'.$L['map']['H_pntadd'].'"/>'.$L['map']['pntadd'].'</a>';
  if ( !empty($row['x']) || !empty($row['y']) )
  {
    $strPosition = '<p class="small" style="margin:2px 0 4px 2px;text-align:right">'.$L['map']['canmove'];
    $strPosition .= ' | <a class="small" href="javascript:void(0)" onclick="deleteMarker(); return false;"/>'.$L['map']['pntdelete'].'</a>';
  }
  $strPosition .= ' | <a class="small" href="javascript:void(0)" onclick="undoChanges(); return false;"/>'.$L['map']['undo'].'</a></p>';
  $strPosition .= '
  <div id="map_canvas" style="width:100%; height:345px;"></div>
  <input type="hidden" id="m_map_gcenter" name="m_map_gcenter" value="'.(!empty($row['y']) ? $row['y'].','.$row['x'] : '').'"/>
  ';
  $strPosition .= '<p class="small" style="margin:4px 0 2px 2px;text-align:right">'.$L['map']['addrlatlng'].' <input type="text" size="24" id="find" name="find" class="small" value="'.$_SESSION[QT]['m_map_gfind'].'" onKeyUp="handle_keypress(event,\'findit\')" title="'.$L['map']['H_addrlatlng'].'"/> <input type="submit" id="findit" class="small" onclick="showLocation(document.getElementById(\'find\').value); return false;" value="'.$L['Search'].'"/></p>';
  if ( $row['privacy']=='0' && $oVIP->role!='A' ) $strPosition = S;
  if ( $row['privacy']=='1' && $oVIP->role=='V' ) $strPosition = S;
  echo '<tr><th class="th_o th_o_first">',$L['map']['position'],'</th><td class="td_o">',$strPosition,'</td></tr>';
}

echo '<tr>
<th class="th_o th_o_first"><input type="hidden" name="id" value="',$id,'"/><input type="hidden" name="name" value="',$row['name'],'"/></th>
<td class="td_o"><input type="submit" name="ok" value="',$L['Save'],'"/>',( !empty($qtr_error) ? ' <span class="error">'.$qtr_error.'</span>' : '' ),'</td>
</tr>
</table>
</form>
';
echo '</td>
</tr>
</table>
';

// -- END EDIT PROFILE --
}
// -- END EDIT PROFILE --

// HTML END

if ( $bMap ) {

  // center
  if ( !empty($row['x']) && !empty($row['y']) )
  {
    $x = floatval($row['x']);
    $y = floatval($row['y']);
    $strUsername = QTconv($row['name'],'U');

    $oMapPoint = new cMapPoint($y,$x,$strUsername);
    if ( isset($_SESSION[QT]['m_map']['U']['icon']) )        $oMapPoint->icon        = $_SESSION[QT]['m_map']['U']['icon'];
    if ( isset($_SESSION[QT]['m_map']['U']['shadow']) )      $oMapPoint->shadow      = $_SESSION[QT]['m_map']['U']['shadow'];
    if ( isset($_SESSION[QT]['m_map']['U']['printicon']) )   $oMapPoint->printicon   = $_SESSION[QT]['m_map']['U']['printicon'];
    if ( isset($_SESSION[QT]['m_map']['U']['printshadow']) ) $oMapPoint->printshadow = $_SESSION[QT]['m_map']['U']['printshadow'];
    $arrMapPoints = array( $oMapPoint );
  }
  else
  {
    $x = QTgetx($_SESSION[QT]['m_map_gcenter']);
    $y = QTgety($_SESSION[QT]['m_map_gcenter']);
    $arrMapPoints = array();
  }

  if ( $bEdit )
  {
  $strFooterAddScript = QTgmappoints($L['map'],$y,$x,'drag',$arrMapPoints,true,false).N.'mapload();';
  }
  else
  {
  $strFooterAddScript = QTgmappoints($L['map'],$y,$x,'',$arrMapPoints,false,false).N.'mapload();';
  }

}

include('qtr_p_footer.php');

?>
Return current item: QT-registrations