<?php

/**
* @package     JohnCMS
* @link        http://johncms.com
* @copyright   Copyright (C) 2008-2011 JohnCMS Community
* @license     LICENSE.txt (see attached file)
* @version     VERSION.txt (see attached file)
* @author      http://johncms.com/about
*/

defined('_IN_JOHNCMS') or die('Error: restricted access');
$textl = 'История переходов';
$headmod = 'link_history';
require('../incfiles/head.php');
echo '<div class="phdr"><b>История переходов</b></div>';
/*
-----------------------------------------------------------------
Чистим историю
-----------------------------------------------------------------
*/
if (isset($_POST['submit'])) {
	mysql_query("DELETE FROM `link_history` WHERE `user_id` = '$user_id'");
	echo '<div class="rmenu">Список очищен</div>';
}
/*
-----------------------------------------------------------------
Выводим список ссылок
-----------------------------------------------------------------
*/
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `link_history` WHERE `user_id`='$user_id'"), 0);
if($total) {
	$req = mysql_query("SELECT * FROM `link_history` WHERE `user_id`='$user_id' ORDER BY `time` DESC LIMIT $start, $kmess");
	$i = 0;
	while ($res = mysql_fetch_assoc($req)) {
    	echo $i % 2 ? '<div class="list2">' : '<div class="list1">';
		echo '<img src="' . $set['homeurl'] . '/images/info.png" width="16" height="16" alt="+" border="0" /> <a href="' . $set['homeurl'] . $res['text'] . '">' .
		$res['name'] . '</a><br /><small>' . $set['homeurl'] . $res['text'] . '</small></div>';
    	++$i;
	}
	echo '<form action="profile.php?act=link_history" method="post"><div class="rmenu"><input name="submit" type="submit" value=" ' . $lng['delete'] . ' "/></div></form>';
} else
	echo '<div class="menu"><p>Список пуст</p></div>';
echo '<div class="phdr">' . $lng['total'] . ': ' . $total . '</div>';
if ($total > $kmess) {
    echo '<p>' . functions::display_pagination('profile.php?act=link_history&amp;', $start, $total, $kmess) . '</p>' .
    '<p><form action="profile.php?act=link_history" method="post"><input type="text" name="page" size="2"/><input type="submit" value="' . $lng['to_page'] . ' &gt;&gt;"/></form></p>';
}

?>