<?php
/*
* Script name: Points4Prize
* Author: Soft Projects
* Date created: 15/07/2015
*/
$ID = (int) htmlspecialchars($_GET['id']);
include "common.php";
head();
?>
<div class="body content rows scroll-y">
<!-- Page header -->
<div class="page-heading">
<h1><b>View user</b> </h1>
</div>
<!-- End page header -->
<!-- Begin info box -->
<div class="row">
<div class="col-md-12">
<div class="box-info">
<h2>View user </h2>
<?php
if (isset($_POST['edit'])) {
$email = htmlspecialchars($_POST['email']);
$about = htmlspecialchars($_POST['about']);
$points = (int) htmlspecialchars($_POST['points']);
mysql_query("UPDATE `vn_users` SET "
. "`email` = '$email', "
. "`about`='$about',"
. "`points`='$points'"
. " WHERE `id` =$ID");
echo '<div class="alert alert-success" role="alert">The user was successfully edited.</div>';
}
$result = mysql_query("SELECT * FROM `vn_users` WHERE `id`= $ID");
$row = mysql_fetch_array($result);
?>
<form action="" method="post">
<div class="row">
<div class="col-md-8">
Edit user
<hr />
<p>
<label>
Avatar
</label>
<br />
<img style="width:90px;float:left;margin-right:5px;" src="<?php echo $GLOBALS['site_url'];?><?php
if(empty($row['avatar'])){
echo 'assets/img/noavatar.png';
}else{
echo $row['avatar'];
}
?>" />
<a href="delete_avatar.php?id=<?php echo $row['id'];?>" class="btn btn-danger">Set default avatar</a>
</p>
<br />
<div class="clearfix"></div>
<p>
<label>
Email
</label>
<input name="email" value="<?php echo $row['email']; ?>" class="form-control" type="email">
</p>
<p>
<label>
About
</label>
<textarea name="about" class="form-control" rows="3"><?php echo $row['about']; ?></textarea>
</p>
<p>
<label>
Points
</label>
<input name="points" value="<?php echo $row['points']; ?>" class="form-control" style="width:150px" type="number">
</p>
<input type="submit" class="btn btn-success" name="edit" value="Edit user" />
<a href="block_user.php?id=<?php echo $row['id'];?>" class="btn btn-danger">Block user</a>
</div>
<div class="col-md-4">
Personal information
<hr />
<p>
<img style="width:100px;float:right;" src="<?php echo $GLOBALS['site_url'];?><?php
if(empty($row['avatar'])){
echo 'assets/img/noavatar.png';
}else{
echo $row['avatar'];
}
?>" />
</p>
<p>
<label>
User:
</label> <?php echo $row['user'];?>
</p>
<p>
<label>
Active user:
</label>
<?php
echo $row['active'];
?>
</p>
<p>
<label>
Won prizes:
</label> <?php echo $row['wonprizes'];?>
</p>
<p>
<label>
Registration date:
</label> <?php echo date("F j, Y, g:i a", $row['regtime']);?>
</p>
<p>
<label>
Registration IP:
</label> <?php echo $row['regip'];?>
</p>
<p>
<label>
Last login IP:
</label> <?php echo $row['lastip'];?>
</p>
<p>
<label>
Last login activity:
</label> <?php echo date("F j, Y, g:i a", $row['lastact']);?>
</p>
</div>
</form>
</div>
</div>
<div class="box-info">
<h2>Voted IP's for this user</h2>
<?php
$checkalln = mysql_query("SELECT userid FROM vn_votes WHERE userid='$ID'");
$broi = mysql_num_rows($checkalln);
if ($broi > 0) {
echo "
<table style='width:100%;' >
<tr>
<th>#</th>
<th>User</th>
<th>Added points</th>
<th>Date</th>
</tr>";
$result2 = mysql_query("SELECT fromw,time,ip,points FROM vn_votes WHERE userid='$ID' ORDER by time DESC LIMIT 0,10") or die(mysql_error());
for ($i = 0; $i < mysql_num_rows($result2); ++$i) {
$row2 = mysql_fetch_array($result2);
$rank = $i + 1;
$date = date("d.m.Y H(idea)", $row2['time'] - 86400);
if ($row2['fromw'] == "0") {
$fromw = "IP:" . $row2['ip'];
} else {
$fromw = "<a href='/u:$row2[fromw]' style='color:#545454;'>$row2[fromw]</a>";
}
echo "
<tr>
<td>$rank</td>
<td>$fromw</td>
<td>$row2[points]</td>
<td>$date</td>
</tr>";
}
echo "</table>";
} else {
echo "<br /><div class='alert alert-info'>Still nobody voted for this user.</div>";
}
?>
</div>
<?php
footer();
?>
</div>