<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: displayTop.php,v 1.3.2.2 2004/04/18 12:47:18 ajvwaay Exp $




function top()
{
    global $version, $bgcolor2, $textcolor1, $textcolor2, $allowrate, $user, $baseurl, $modulepath, $mpnTables;
    galleryHeader();
    $result = mysql_query("select pid, name, counter, rate, votes, visible from ".$mpnTables['gallery_pictures']." p, ".$mpnTables['gallery_categories']." c WHERE p.gid=c.gallid AND c.visible>0 order by counter DESC, rate DESC");
    $result1 = mysql_query("select pid, name, counter, rate, votes, visible from ".$mpnTables['gallery_pictures']." p, ".$mpnTables['gallery_categories']." c WHERE p.gid=c.gallid AND c.visible>0 order by rate DESC, votes ASC, counter DESC");

    $nav = navigationGall();
    if ($allowrate)
    {
        $col = 4;
    }
    else
    {
        $col = 3;
    }

    OpenTable();
    echo "<table border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
          <tr>
          <td colspan=3 align=\"center\">
      $nav<br>
          </td>
          </tr>
          <tr>
          <td>&nbsp;</td>
          <td width=\"70%\" align=\"center\">";
    echo '<table width="400" align="center" border="0" cellspacing="0" cellpadding="1" bgcolor="#000000">
          <tr><td>
      <table width="100%" align="center" border="0" cellspacing="0" cellpadding="3" bgcolor="#FFFFFF">
      <tr>
      <td colspan="'.$col.'" width="100%" align="center"  bgcolor="'.$bgcolor2.'"><font class="meg-title">'._GALTOP10.'<br>'._GALTOP10HITS.'</font></td>
      </tr>
      <tr>
      <td align="center" colspan="'.$col.'"><br></td>
      </tr>
      <tr>
      <td align="center"><font class="meg-title">'._GALTOPPOS.'</font></td>
      <td align="center"><font class="meg-title">'._GALTOPHITS.'</font></td>';

    if ($allowrate)
    {
        echo '<td align="center"><font class="meg-title">'._GALTOPRATING.'</font></td>';
    }

    echo '<td align="left"><font class="meg-title">'._GALTOPMEDIA.'</font></td></tr>';
    $pos = 1;
    while((list($pid, $name, $counter, $rate, $votes, $visible) = mysql_fetch_array($result)) && $pos<=10)
    {
        echo '<tr>
          <td align="center"><font class="meg-normal">'.$pos.'</font></td>
          <td align="center"><font class="meg-normal">'.$counter.'</font></td>';
    if ($allowrate)
        {
            echo '<td align="center"><font class="meg-normal">'.$rate.'</font></td>';
        }

        if ($visible == 1)
        {
            if (is_user($user))
            {
                echo "<td align=\"left\"><a class=\"meg-normal\"href=\"$baseurl&amp;do=showpic&amp;pid=$pid\">$name</a></td>";
            }
            else
            {
                echo "<td align=\"left\"><font class=\"meg-normal\">$name (*)</font></td";
            }
        }
        else
        {
            echo "<td align=\"left\"><a class=\"meg-normal\" href=\"$baseurl&amp;do=showpic&amp;pid=$pid\">$name</a></td>";
        echo "</tr>";
        $pos += 1;
        }
    } // While

    echo "</table></td></tr></table>";
    echo "<br><br>";
    if ($allowrate)
    {
        echo '<table width="400" align="center" border="0" cellspacing="0" cellpadding="1" bgcolor="#000000">
          <tr><td>
          <table width="100%" align="center" border="0" cellspacing="0" cellpadding="3" bgcolor="#FFFFFF">
          <tr>
          <td colspan="4" width="100%" align="center" bgcolor="'.$bgcolor2.'"><font class="meg-title">'._GALTOP10.'<br>'._GALTOP10RATING.'</font></td>
          </tr>
          <tr>
          <td colspan="4"><br></td>
          </tr>
          <tr>
          <td align="center"><font class="meg-title">'._GALTOPPOS.'</font></td>
          <td align="center"><font class="meg-title">'._GALTOPRATING.'</font></td>
          <td align="center"><font class="meg-title">'._GALTOPVOTES.'</font></td>
          <td align="left"><font class="meg-title">'._GALTOPMEDIA.'</font></td>
          </tr>';
    $pos = 1;
    while((list($pid, $name, $counter, $rate, $votes, $visible) = mysql_fetch_array($result1)) && $pos<=10)
        {
            if ($visible == 1)
            {
                if (is_user($user))
                {
                    echo '<tr><td align="center"><font class="meg-normal">'.$pos.'</font></td>
              <td align="center"><font class="meg-normal">'.$rate.'</font></td>
              <td align="center"><font class="meg-normal">'.$votes.'</font></td>
              <td align="left"><a class="meg-normal" href="'.$baseurl.'&amp;do=showpic&amp;pid='.$pid.'">'.$name.'</a></font></td>
              </tr>';
                }
                else
                {
                    echo '<tr><td align="center"><font class="meg-normal">'.$pos.'</font></td>
              <td align="center"><font class="meg-normal">'.$rate.'</font></td>
              <td align="center"><font class="meg-normal">'.$votes.'</font></td>
              <td align="left"><font class="meg-normal">'.$name.' (*)</font></td>
              </tr>';
        }
            }
            else
            {
                echo '<tr><td align="center"><font class="meg-normal">'.$pos.'</font></td>
                      <td align="center"><font class="meg-normal">'.$rate.'</font></td>
              <td align="center"><font class="meg-normal">'.$votes.'</font></td>
              <td align="left"><a class="meg-normal" href="'.$baseurl.'&amp;do=showpic&amp;pid='.$pid.'">'.$name.'</a></td>
              </tr>';
            }

        $pos += 1;
    } // While

        echo "</table>
          </td>
          </tr></table>";
        if (!is_user($user))
        {
            print '<br><center><font class="meg-sub"><i>'._GALCATMEMBERS.'</i></font></center>';
        }
    }

    echo "<br></td><td>&nbsp;</td>
          </tr></table>";
    CloseTable();
    print '<p align="right">'
     .'<font class="meg-sub">'
     .sprintf(_GALCOPYRIGHT, _GALVERSION, "$modulepath/credits")
     .'</font>'
     .'</p>';

    mysql_free_result($result);
    include("footer.php");
}

?>
