<?php
// checked whether user is logged in
if($Auth->loggedIn())
{
    // load recent from account
    $urls = shortUrl::loadAllRecentByAccount($Auth->id);
}
else
{
    // load recent from IP
    $urls = shortUrl::loadAllRecentByIp(getUsersIPAddress());
}
?>

<div class="rightContentWrapper ui-corner-all">
    <div class="rightContent">
        <div id="pageHeader">
            <h2><?php echo t("your_recent_urls", "Your Urls"); ?> <?php echo COUNT($urls)?'('.COUNT($urls).')':''; ?></h2>
        </div>
        <p>
            <?php
            // load all urls for current user  
            if(COUNT($urls))
            {
                $tracker = 0;
                foreach($urls AS $url)
                {
                    $class = 'divOdd';
                    if($tracker%2==1)
                    {
                        $class = 'divEven';
                    }
                    echo "<div class='".$class."'>";
                    echo "<div style='padding: 3px;'>";
                    echo "  <div style='float: right;'>";
                    echo "      <a href='".WEB_ROOT."/".$url['shortUrl']."~s'>".t("stats", "stats")."</a> | <a href='".WEB_ROOT."/index.html?u=".$url['id']."&success=1'>".t("info", "info")."</a>";
                    echo "  </div>";
                    echo "  <div style='float: left; overflow: auto;'>";
                    echo "      <a href='".WEB_ROOT."/".$url['shortUrl']."'>/".$url['shortUrl']."</a>";
                    echo "  </div>";
                    echo "  <div class='clear'></div>";
                    echo "</div>";
                    echo "<div class='clear'></div>";
                    echo "</div>";
                    echo "<div class='clear'></div>";
                    $tracker++;
                }
            }
            else
            {
                echo '- You have not created any recent urls. <a href="'.WEB_ROOT.'/index.'.SITE_CONFIG_PAGE_EXTENSION.'">Click here</a> to create one now.';
            }
            ?>
        </p>
    </div>
</div>
