<?

/************************************************************************/
/* XAlbum Version 0.9.8                                                 */
/* ==================================================================== */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

function top() {
        global $font, $galleryvar, $baseurl, $bgcolor1, $bgcolor2, $user, $prefix, $name, $adminpath;

        galleryHeader();
        $result = mysql_query("select pid, name, counter, rate, votes, visible from $prefix"._4nalbum_pictures." p, $prefix"._4nalbum_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 $prefix"._4nalbum_pictures." p, $prefix"._4nalbum_categories." c WHERE p.gid=c.gallid AND c.visible>0 order by rate DESC, votes ASC, counter DESC");

        $nav = navigationGall();
         if ($galleryvar['allowrate'])
                 $col = 4;
         else
                $col = 3;
        OpenTable();
         echo "
        <table border=\"0\" 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="'.$bgcolor1.'">
        <tr>
          <td colspan="'.$col.'" width="100%" align="center"  bgcolor="'.$bgcolor2.'"><font class="'.$font['title'].'">'._GALTOP10.'</font><br><font class="'.$font['normal'].'">'._GALTOP10HITS.'</font></td>
        </tr>
        <tr>
          <td align="center" colspan="'.$col.'"></td>
        </tr>
        <tr>
          <td align="center"><font class="'.$font['normal'].'">'._GALTOPPOS.'</font></td>
          <td align="center"><font class="'.$font['normal'].'">'._GALTOPHITS.'</font></td>';
        if ($allowrate) echo '<td align="center"><font class="'.$font['title'].'">'._GALTOPRATING.'</font></td>';
          echo '<td align="left"><font class="'.$font['normal'].'">'._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="'.$font['normal'].'">'.$pos.'</font></td>
                <td align="center"><font class="'.$font['normal'].'">'.$counter.'</font></td>';
                if ($allowrate) echo '<td align="center"><font class="'.$font['normal'].'">'.$rate.'</font></td>';
                if ($visible==1) {
                        if (is_user($user))
                                echo "<td align=\"left\"><a class=\"".$font['normal']."\" href=\"".$baseurl."&amp;do=showpic&amp;pid=$pid\">$name</a></td>";
                        else
                                echo "<td align=\"left\"><font class=\"".$font['normal']."\"> $name (*)</font></td";
                }
                else
                        echo "<td align=\"left\"><a class=\"".$font['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 ($galleryvar['allowrate']) {
// pk
                       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="'.$bgcolor1.'">
                <tr>
                  <td colspan="4" width="100%" align="center" bgcolor="'.$bgcolor2.'"><font class="'.$font['title'].'">'._GALTOP10.'</font><br><font class="'.$font['normal'].'">'._GALTOP10RATING.'</font></td>
                </tr>
                <tr>
                  <td colspan="4"></td>
                </tr>
                <tr>
                  <td align="center"><font class="'.$font['normal'].'">'._GALTOPPOS.'</font></td>
                  <td align="center"><font class="'.$font['normal'].'">'._GALTOPRATING.'</font></td>
                  <td align="center"><font class="'.$font['normal'].'">'._GALTOPVOTES.'</font></td>
                  <td align="left"><font class="'.$font['normal'].'">'._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="'.$font['normal'].'">'.$pos.'</font></td>
                                        <td align="center"><font class="'.$font['normal'].'">'.$rate.'</font></td>
                                        <td align="center"><font class="'.$font['normal'].'">'.$votes.'</font></td>
                                        <td align="left"><a class="'.$font['normal'].'" href="'.$baseurl.'&amp;do=showpic&amp;pid='.$pid.'">'.$name.'</a></font></td>
                                        </tr>';
                                else
                                        echo '
                                        <tr>
                                        <td align="center"><font class="'.$font['normal'].'">'.$pos.'</font></td>
                                        <td align="center"><font class="'.$font['normal'].'">'.$rate.'</font></td>
                                        <td align="center"><font class="'.$font['normal'].'">'.$votes.'</font></td>
                                        <td align="left"><font class="'.$font['normal'].'">'.$name.' (*)</font></td>
                                        </tr>';
                        }
                        else
                                echo '
                                <tr>
                                <td align="center"><font class="'.$font['normal'].'">'.$pos.'</font></td>
                                <td align="center"><font class="'.$font['normal'].'">'.$rate.'</font></td>
                                <td align="center"><font class="'.$font['normal'].'">'.$votes.'</font></td>
                                <td align="left"><a class="'.$font['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="'.$font['tiny'].'"><i>'._GALCATMEMBERS.'</i></font></center>';

        }
        echo "<br></td><td>&nbsp;</td>
        </tr></table>";
        CloseTable();
        galleryFooter();

}

?>