<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: home.php
  Description: Admin Home

  ++++++++++++++++++++++++++++++++++++++++*/

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}
 
?>
<div align="center">
<?php

if (isset($INSTALL_FILE))
{
?>
<table width="100%" cellpadding="0" cellspacing="1" border="0" style="margin-bottom:5px;border: 2px solid #083253">
<tr>
    <td align="center" class="error"><?php echo $msg_home; ?></td>
</tr>
</table>
<?php
}

?>
<table width="100%" cellspacing="1" cellpadding="0" border="0">
<tr>
    <td align="left">
    <table border="0" cellpadding="0" cellspacing="1" width="100%" style="border: 2px solid #083253">
    <tr>
        <td align="left" class="msgBox"><?php echo $msg_home2; ?><br><br>
        <?php echo $msg_home3; ?>,<br><br>David.<br><a href="http://www.maianscriptworld.co.uk" target="_blank" title="Maian Script World">www.maianscriptworld.co.uk</a></td>
    </tr>
    </table>
    <table cellpadding="0" cellspacing="0" width="100%" class="menutable">
    <tr>
        <td align="left" class="leftPad">&raquo; <b><?php echo $msg_home4; ?></b></td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="1" width="100%" style="border: 2px solid #083253">
    <tr>
        <td align="left" class="msgBox">
        <?php echo str_replace(array('{images}','{cats}','{comments}'),
                               array(
                               rowCount('images')>0 ? '<a href="index.php?cmd=manage" title="'.$msg_adminmenu7.'">'.rowCount('images').'</a>' : 0,
                               rowCount('categories')>0 ? '<a href="index.php?cmd=cats" title="'.$msg_adminmenu4.'">'.rowCount('categories').'</a>' : 0,
                               rowCount('comments',' WHERE is_active = \'0\' AND is_approved = \'1\'')>0 ? '<a href="index.php?cmd=comments" title="'.$msg_adminmenu14.'">'.rowCount('comments',' WHERE is_active = \'0\' AND is_approved = \'1\'').'</a>' : 0
                               ),
                               $msg_home8
                               ).'<br><br>';
        
        // Get 5 most viewed images..
        // Increase limit if you want to show more..
        $q_top = mysql_query("SELECT * FROM ".$database['prefix']."images
                              ORDER BY visits DESC
                              LIMIT 5
                              ") or die(mysql_error());
         
        while ($IMG = mysql_fetch_object($q_top))
        {
        ?>
        &#8226; <a href="<?php echo ($SETTINGS->modr ? '../picture/'.$IMG->id.'/'.addTitleToUrl(getCategoryName($IMG->cat)).'/'.addTitleToUrl($IMG->name).'.html' : '../index.php?cmd=pictures&amp;picture='.$IMG->id); ?>" target="_blank" title="<?php echo cleanData($IMG->name); ?>"><?php echo cleanData($IMG->name); ?></a><br>
        <?php
        }
        
        ?><br>
        <?php echo str_replace(array('{count}','{total}','{fees}'),array(
                               rowCount('ipndata',' WHERE activeCart = \'1\''),
                               get_cur_symbol(saleTotal('gross'),$PP->ppCurrency),
                               get_cur_symbol(saleTotal('fee'),$PP->ppCurrency)
                               ),$msg_home12); ?>
        </td>
    </tr>
    </table>
    <table cellpadding="0" cellspacing="0" width="100%" class="menutable">
    <tr>
        <td align="left" class="leftPad">&raquo; <b><?php echo str_replace("{count}",LATEST_COMMENTS,$msg_home9); ?></b></td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="1" width="100%" style="border: 2px solid #083253">
    <tr>
        <td align="left" class="msgBox">
        <?php
        if ($SETTINGS->comments) {
          $query = mysql_query("SELECT *,DATE_FORMAT(addDate,'".$SETTINGS->mysql_date."') AS c_date 
                                FROM ".$database['prefix']."comments 
                                WHERE is_active = '1' 
                                AND is_approved = '0' 
                                ORDER BY id DESC
                                LIMIT ".LATEST_COMMENTS."
                                ") or die(mysql_error());
          
          if (mysql_num_rows($query)>0) {       
            while ($row = mysql_fetch_object($query)) {
            ?>
            <p class="comment_message"><?php echo cleanData(nl2br($row->comments),COMMENTS_TEXT_WRAP); ?></p>
            <p class="comment_date"><?php echo $msg_pictures14.'<b>'.cleanData($row->name); ?></b> (<?php echo $row->c_date; ?>)</p>
            <?php
            }
          } else {
          ?>
          <p><?php echo $msg_home11; ?></p>
          <?php
          }  
        } else {
        ?>
        <p><?php echo $msg_home10; ?></p>
        <?php
        }
        ?>
        </td>
    </tr>
    </table>
    <table cellpadding="0" cellspacing="0" width="100%" align="center" class="menutable">
    <tr>
        <td align="left" class="leftPad">&raquo; <b><?php echo $msg_home5; ?></b></td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="1" width="100%" style="border: 2px solid #083253">
    <tr>
        <td align="left" class="msgBox"><?php echo $msg_home6; ?>:<br><br>
        <a href="http://www.maiangallery.com/" target="_blank"><img src="images/donation.gif" border="0" alt="<?php echo $msg_home5; ?>" title="<?php echo $msg_home5; ?>"></a><br><br>
        <?php echo $msg_home7; ?>
        </td>
    </tr>
    </table>
    </td>
</tr>
</table>
</div>
