Beispiel #1
0
     $darr[] = cleanInput($row['datetime']);
 }
 echo "<tbody>";
 for ($i = $from1; $i < $from2; $i++) {
     $id = $idarr[$i];
     $ip = $iparr[$i];
     $uid = $uarr[$i];
     $date = $darr[$i];
     /*
     fetching the user's name from the database
     */
     $name = get_username($uid);
     /*
     fetching country name for the specific ip address
     */
     $country = $ip2country->get_country_name($ip);
     echo "<tr>";
     echo "<td>{$id}</td>";
     echo "<td>{$ip}</td>";
     echo "<td><a href=\"{$website}/" . ADMIN_DIRECTORY . "/manageuser/{$uid}#/logs\">{$name}</a></td>";
     echo "<td>{$country}</td>";
     echo "<td><abbr class=\"micro\" title=\"{$date}\"></abbr></td>";
     echo "</tr>";
 }
 echo "</tbody>";
 echo "</table>";
 /*
 displaying pagination below the table.
 */
 if ($number > $max_show) {
     $p->show();
Beispiel #2
0
function admin_edit_user($id)
{
    global $db, $err, $log, $website;
    $current_url = current_url();
    try {
        $sql = "SELECT * FROM `members` WHERE `id` = :id";
        $sql_do = $db->prepare($sql);
        $sql_do->bindParam(':id', $id, PDO::PARAM_INT);
        $sql_do->execute();
        $number = $db->query("SELECT FOUND_ROWS()")->fetchColumn();
    } catch (PDOException $e) {
        $log->logError($e . " - " . basename(__FILE__));
    }
    if (!empty($number)) {
        $f = $sql_do->fetch(PDO::FETCH_ASSOC);
        $verified = intval($f['verified']);
        $email_user = cleanInput($f['email']);
        $first_name = cleanInput($f['first_name']);
        $last_name = cleanInput($f['last_name']);
        $banned = intval($f['banned']);
        $joined_on = cleanInput($f['join']);
        $last_access = cleanInput($f['access']);
        $user_bio = cleanInput($f['bio']);
        /*
        displaying gravatar photo over here if email is associated with a gravatar account.
        */
        $default = $website . "/images/anonuser_50px.gif";
        $gravatar = new Gravatar($email_user, $default);
        $gravatar->size = 50;
        ?>
	<div class="page-header no-border">
		<h1><img class="profilephoto thumbnail" src="<?php 
        echo $gravatar->getSrc();
        ?>
" />&nbsp;&nbsp;<?php 
        echo $first_name . " " . $last_name;
        ?>
</h1>
	</div>
<?php 
        echo "<ul class=\"breadcrumb\">\n<li><a href=\"{$website}/" . ADMIN_DIRECTORY . "/settings\">" . _("Home") . "</a> <span class=\"divider\">/</span></li>\n<li><a href=\"{$website}/" . ADMIN_DIRECTORY . "/users\">" . _("Users") . "</a> <span class=\"divider\">/</span></li>\n<li class=\"active\">{$first_name} {$last_name}</li>\n</ul>";
        ?>
	<div class="tabs-left">
		<ul class="nav nav-tabs" id="usermanage">
			<li class="active"><a href="#general" data-toggle="tab"><i class="icon-cog"></i> <?php 
        echo _("General");
        ?>
</a></li>
			<li><a href="#profile" data-toggle="tab"><i class="icon-user"></i> <?php 
        echo _("Profile");
        ?>
</a></li>
			<li><a href="#logs" data-toggle="tab"><i class="icon-list-alt"></i> <?php 
        echo _("Access Logs");
        ?>
</a></li>
		</ul>

	<form class="form-horizontal" method="POST" action="<?php 
        echo $current_url;
        ?>
">
	<div class="tab-content">
		<div class="tab-pane active" id="general">
			<fieldset>
				<legend><?php 
        echo _("General");
        ?>
</legend>
				<?php 
        echo $err;
        ?>
				<div class="control-group">
					<label class="control-label" for="first_name"><?php 
        echo _("First Name");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge" id="first_name" name="first_name" value="<?php 
        echo $first_name;
        ?>
">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="last_name"><?php 
        echo _("Last Name");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge" id="last_name" name="last_name" value="<?php 
        echo $last_name;
        ?>
">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="email"><?php 
        echo _("Email");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge disabled" id="email" name="email" value="<?php 
        echo $email_user;
        ?>
" disabled>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="pass"><?php 
        echo _("Password");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge disabled" id="pass" name="pass" value="<?php 
        echo $f['password'];
        ?>
" disabled>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="verified"><?php 
        echo _("Verified");
        ?>
</label>
					<div class="controls">
						<select name="verified" id="verified">
							<option value="1"<?php 
        if ($verified == 1) {
            echo " selected=\"selected\"";
        }
        ?>
><?php 
        echo _("Yes");
        ?>
</option>
							<option value="0"<?php 
        if ($verified == 0) {
            echo " selected=\"selected\"";
        }
        ?>
><?php 
        echo _("No");
        ?>
</option>
						</select>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="join"><?php 
        echo _("Joined On");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge disabled" id="join" name="join" value="<?php 
        echo $joined_on;
        ?>
" disabled>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="access"><?php 
        echo _("Last Access");
        ?>
</label>
					<div class="controls">
						<input type="text" class="input-xlarge disabled" id="access" name="access" value="<?php 
        echo $last_access;
        ?>
" disabled>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="ban"><?php 
        echo _("Banned");
        ?>
</label>
					<div class="controls">
						<select name="ban" id="ban">
							<option value="1"<?php 
        if ($banned == 1) {
            echo " selected=\"selected\"";
        }
        ?>
><?php 
        echo _("Yes");
        ?>
</option>
							<option value="0"<?php 
        if ($banned == 0) {
            echo " selected=\"selected\"";
        }
        ?>
><?php 
        echo _("No");
        ?>
</option>
						</select>
					</div>
				</div>
			</fieldset>
		</div>
		<div class="tab-pane" id="profile">
			<fieldset>
				<legend><?php 
        echo _("Profile");
        ?>
</legend>
				<?php 
        echo $err;
        ?>
				<div class="control-group">
					<label class="control-label" for="bio"><?php 
        echo _("Bio");
        ?>
</label>
					<div class="controls">
						<textarea class="input-xxlarge" id="bio" name="bio" rows="8"><?php 
        echo $user_bio;
        ?>
</textarea>
					</div>
				</div>
			</fieldset>
		</div>
		<div class="tab-pane" id="logs">
		<fieldset>
			<legend><?php 
        echo _("Access Logs");
        ?>
</legend>
<?php 
        try {
            $q = "SELECT * FROM `access` WHERE `userid` = :userid ORDER BY `id` DESC";
            $q_do = $db->prepare($q);
            $q_do->bindParam(':userid', $id, PDO::PARAM_INT);
            $q_do->execute();
            $number = $db->query("SELECT FOUND_ROWS()")->fetchColumn();
        } catch (PDOException $e) {
            $log->logError($e . " - " . basename(__FILE__));
        }
        if (!empty($number)) {
            echo "<table class=\"table table-condensed\">\n\t\t\t<thead>\n\t\t\t<tr>\n\t\t\t<th>" . _("IP Address") . "</th>\n\t\t\t<th>" . _("Country") . "</th>\n\t\t\t<th>" . _("Access") . "</th>\n\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>";
            /*
            initializing the ip2country class for converting ip address to country.
            */
            $ip2country = new ip2country($db);
            /*
            displaying the information in a while loop.
            */
            while ($row = $q_do->fetch(PDO::FETCH_ASSOC)) {
                $ip = cleanInput($row['ip_address']);
                $date = cleanInput($row['datetime']);
                /*
                fetching country name for the specific ip address
                */
                $country = $ip2country->get_country_name($ip);
                echo "<tr>";
                echo "<td>{$ip}</td>";
                echo "<td>{$country}</td>";
                echo "<td><abbr class=\"micro\" title=\"{$date}\"></abbr></td>";
                echo "</tr>";
            }
            echo "</tbody>\n\t\t\t</table>";
        } else {
            echo "<div class=\"alert\"><strong>" . _("No Access Records.") . "</strong><br/>" . _("There are no access records for this user in the database.") . "</div>";
        }
        ?>
		</fieldset>
		</div>
		<div class="form-actions">
			<input type="submit" class="btn btn-primary" name="edituser" value="<?php 
        echo _("Update User");
        ?>
">
		</div>
	</div>
	</form>
	</div>
<?php 
    } else {
        echo "<div class=\"alert alert-error\"><strong>" . _("Not Found.") . "</strong><br/>" . _("User does not exist in the database. There are no records matching the user ID specified.") . "</div>";
    }
}