Location: PHPKode > projects > SMBindex > smbindex-2.62-r2/web/smbindex.php
<?php /*********************************************[ SMBindex 2.62 ]

Copyright 2004-2006 SunHateR Home Studio
Programmer & Graphical design:    Pavel Tzonkov <hide@address.com>
http://smbindex.no-ip.org
http://sourceforge.net/projects/smbindex


This file is part of SMBindex.

SMBindex 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, or
(at your option) any later version.

SMBindex is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with SMBindex; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

********************************************************************/

if (!check_IP($_SERVER["REMOTE_ADDR"])) die;

session_start();

include "common.php";

$self_filename = substr($_SERVER[SCRIPT_NAME], strrpos($_SERVER[SCRIPT_NAME], "/") + 1);

$page = $_REQUEST[page];
$search = $_REQUEST[search];
$search = str_replace("\\\\", "\\", $search);
$search = str_replace("\\'", "'", $search);
$search = str_replace("\\\"", "\"", $search);

if     ($_REQUEST[results])  $results = $_REQUEST[results];
elseif ($_COOKIE[c_results]) $results = $_COOKIE[c_results];
else                         $results = 50;

if     ($results > 100)      $results = 100;

$dirnames = ($_COOKIE[c_dirnames] && !$page) ? $_COOKIE[c_dirnames] : $_REQUEST[dirnames];

# Setting cookies
$cookie_area = substr(substr($_SERVER[SCRIPT_FILENAME], 0, strrpos($_SERVER[SCRIPT_FILENAME], "/")), strlen($_SERVER[DOCUMENT_ROOT]));
$expired = time() + 60 * 60 * 24 * 365.25;
$set_lang_cookie = substr($lang, 5, -4);

setcookie("c_lang", $set_lang_cookie, $expired, $cookie_area);
setcookie("c_results", $results, $expired, $cookie_area);
setcookie("c_dirnames", $dirnames, $expired, $cookie_area);

$filetype = get_filetypes();

if ($_REQUEST[cb]) $_SESSION[cb] = $_REQUEST[cb];

if (!$_SESSION[cb] || $_REQUEST[check_all]) {
    $_SESSION[cb] = array();
    foreach ($PCs as $PC) $_SESSION[cb][$PC[IP]] = "1";
} 

foreach ($PCs as $PC)
    if (!isset($_SESSION[cb][$PC[IP]]))
        $_SESSION[cb][$PC[IP]] = "1";

header("Content-type: text/html; charset=$charset");

?><HTML>
<HEAD>
<TITLE><?= $label[topic] ?></TITLE>
<LINK HREF="style.css" REL="stylesheet" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript"><!--

function cb_transfer() { // On submit, transfer status of computer checkboxes
                         // into the form
    d = document;
    f = window.frames['fr_comps'].document;

<?php

foreach ($PCs as $PC)
    echo "    d.getElementById('cb_$PC[IP]').value = (f.getElementById('cb_$PC[IP]').checked) ? '1' : '0';\n";

?>

}

function check_all(cb_all) { // On click the top checkbox, check/uncheck all
                             // computer checkboxes
    f = window.frames['fr_comps'].document;
<?php

foreach ($PCs as $PC)
    echo "\n    f.getElementById('cb_$PC[IP]').checked =";

?> cb_all.checked;
}


function on_body_load () { // On load the page, hide searching <DIV>
                           // and show the page
    if (document.getElementById('searching')) 
        document.getElementById('searching').style.visibility='hidden';

    document.getElementById('div_content').style.visibility='visible';

    document.form.search.focus();
}


--></SCRIPT>
</HEAD>

<BODY onLoad="on_body_load()" MARGINWIDTH="0" MARGINHEIGHT="0" STYLE="margin:16px; margin-right:4px"><?php

if ($share_limit && !check_sharesize($_SERVER["REMOTE_ADDR"])) {

?><CENTER><B><?= $label[share_denied] ?></B></CENTER>
<SCRIPT LANGUAGE="JavaScript"><!--

function on_body_load() {
    return true;
}

--></SCRIPT>
</BODY>
</HTML><?php

    die;
}

if ($page) {

?><DIV ID="searching" STYLE="position:absolute; left:0px; top:16px; width:100%; height:20px">
<CENTER><B><?= $label[searching] ?>...</B></CENTER>
</DIV><?

}

?><DIV ID="div_content" STYLE="visibility:hidden; height:100%; width:100%">
<TABLE WIDTH="780" HEIGHT="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ALIGN="CENTER">
  <TR>
      <TD VALIGN="TOP"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
        <TR>
          <TD ALIGN="LEFT" VALIGN="TOP" BACKGROUND="img/bg_topic.png"><A HREF="<?= $self_filename ?>?check_all=1"><IMG SRC="img/logo.png" WIDTH="154" HEIGHT="21" BORDER="0"></A></TD>
          <TD ALIGN="LEFT" VALIGN="TOP"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <TR>
                <TD HEIGHT="21" BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
                <TD VALIGN="MIDDLE" NOWRAP BACKGROUND="img/bg_version.png">&nbsp;<?= $label[version] . " $version" ?>&nbsp;</TD>
                <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
              </TR>
              <TR>
                <TD HEIGHT="6"></TD>
                <TD></TD>
                <TD></TD>
              </TR>
          </TABLE></TD>
          <TD WIDTH="14" ALIGN="LEFT"><IMG SRC="img/sttc_topic_left.png" WIDTH="14" HEIGHT="27"></TD>
          <TD WIDTH="100%" BACKGROUND="img/bg_topic.png">&nbsp;</TD>
          <TD WIDTH="16" ALIGN="RIGHT"><IMG SRC="img/sttc_topic_right.png" WIDTH="16" HEIGHT="27"></TD>
          <TD WIDTH="241" ALIGN="LEFT" VALIGN="TOP"><IMG SRC="img/descr.png" WIDTH="241" HEIGHT="21"></TD>
        </TR>
      </TABLE>
      <TABLE WIDTH="100%" HEIGHT="25" BORDER="0" CELLPADDING="0" CELLSPACING="0">
        <TR>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD WIDTH="100%" VALIGN="MIDDLE" BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="25" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" CLASS="tbl_header"><?= $label[form][topic] ?></TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="214" HEIGHT="2"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="25" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD VALIGN="MIDDLE" CLASS="tbl_header"><?php

if (count($PCs) > 6) {

?><DIV STYLE="position:absolute; width:100px; height:18px" ALIGN="LEFT" VALIGN="MIDDLE"><TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0"><TR><TD HEIGHT="<?= $is_win ? 16 : 18 ?>"><INPUT TYPE="CHECKBOX" STYLE="height:13px" ID="cb_all"<?php

    if (!array_search("0", $_SESSION[cb])) echo " CHECKED";

?> onClick="check_all(this)"></TD></TR></TABLE></DIV><?php

}

?><CENTER><?= $label[form][online_pcs] ?></CENTER></TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="214" HEIGHT="2"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="1"></TD>
        </TR>
      </TABLE>
      <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
        <TR>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <TR>
                <TD HEIGHT="90" VALIGN="MIDDLE" BGCOLOR="#E0F0F8"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
                    <FORM METHOD="POST" ACTION="<?= $self_filename ?>" NAME="form" ID="form" onSubmit="cb_transfer()">
                      <INPUT TYPE="HIDDEN" NAME="page" VALUE="1">
                      <TR>
                        <TD HEIGHT="22" VALIGN="BOTTOM"><IMG SRC="img/form_left.png" WIDTH="19" HEIGHT="12"></TD>
                        <TD WIDTH="100%" HEIGHT="22" ALIGN="CENTER" BACKGROUND="img/form_bg.png"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#E0F0F8">
                            <TR>
                              <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                              <TD VALIGN="MIDDLE" NOWRAP><B><?= $label[form][search] ?></B></TD>
                              <TD WIDTH="4"></TD>
                              <TD VALIGN="MIDDLE"><INPUT TYPE="TEXT" NAME="search" STYLE="height:18" VALUE="<?= str_replace("\"", "&quot;", $search) ?>"></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><SELECT NAME="type"><?php

foreach ($filetype as $key) {
    echo '<OPTION VALUE="' . $key . '"';
    if ($_REQUEST[type] == $key) echo " SELECTED";
    echo ">" . $label[form][$key] . "</OPTION>\n";
}

                                ?></SELECT></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><INPUT TYPE="SUBMIT" VALUE="<?= $label[form][submit] ?>" STYLE="height:20"></TD>
                             <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                           </TR>
                       </TABLE></TD>
                       <TD HEIGHT="22" VALIGN="BOTTOM"><IMG SRC="img/form_right.png" WIDTH="19" HEIGHT="12"></TD>
                     </TR>
                     <TR>
                       <TD HEIGHT="22" VALIGN="TOP"><IMG SRC="img/form_left.png" WIDTH="19" HEIGHT="14"></TD>
                       <TD WIDTH="100%" HEIGHT="22" ALIGN="CENTER" BACKGROUND="img/form_bg.png"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#E0F0F8">
                           <TR>
                             <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                             <TD VALIGN="MIDDLE" NOWRAP><B><?= $label[form][results] ?></B></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><SELECT NAME="results">
                               <OPTION VALUE="15"<?php if ($results == "10") echo " SELECTED"; ?>>10</OPTION>
                               <OPTION VALUE="20"<?php if ($results == "20") echo " SELECTED"; ?>>20</OPTION>
                               <OPTION VALUE="50"<?php if ($results == "50") echo " SELECTED"; ?>>50</OPTION>
                               <OPTION VALUE="100"<?php if ($results == "100") echo " SELECTED"; ?>>100</OPTION>
                             </SELECT></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><INPUT ID="checkbox" TYPE="CHECKBOX" NAME="dirnames" STYLE="width:15px"<?php

if ($dirnames) echo " CHECKED";

                                ?>></TD>
                             <TD VALIGN="MIDDLE" NOWRAP><B><LABEL FOR="checkbox"><?= $label[form][dirnames] ?></LABEL></B></TD>
                             <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                           </TR>
                       </TABLE></TD>
                       <TD HEIGHT="22" VALIGN="TOP"><IMG SRC="img/form_right.png" WIDTH="19" HEIGHT="14"></TD>
                     </TR>
                     <TR>
                       <TD HEIGHT="22" VALIGN="BOTTOM"><IMG SRC="img/form_left.png" WIDTH="19" HEIGHT="12"></TD>
                       <TD WIDTH="100%" HEIGHT="22" ALIGN="CENTER" BACKGROUND="img/form_bg.png" BGCOLOR="#E0F0F8"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#E0F0F8">
                           <TR>
                             <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                             <TD VALIGN="MIDDLE" NOWRAP><B><?= $label[form][sort] ?></B></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><SELECT NAME="sort">
                               <OPTION VALUE=""><?= $label[form][unsorted] ?></OPTION>
                               <OPTION VALUE="filename"<?php if ($_REQUEST[sort] == "filename") echo " SELECTED"; ?>><?= $label[form][filename] ?></OPTION>
                               <OPTION VALUE="location"<?php if ($_REQUEST[sort] == "location") echo " SELECTED"; ?>><?= $label[form][location] ?></OPTION>
                               <OPTION VALUE="size"<?php if ($_REQUEST[sort] == "size") echo " SELECTED"; ?>><?= $label[form][size2] ?></OPTION>
                               <OPTION VALUE="date"<?php if ($_REQUEST[sort] == "date") echo " SELECTED"; ?>><?= $label[form][date] ?></OPTION>
                             </SELECT></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><INPUT TYPE="RADIO" ID="asc" NAME="order" VALUE="asc" STYLE="width:15px"<?php if (($_REQUEST[order] == "asc") || !$_REQUEST[order]) echo " CHECKED"; ?>></TD>
                             <TD VALIGN="MIDDLE" NOWRAP><B><LABEL FOR="asc"><?= $label[form][asc] ?></LABEL></B></TD>
                             <TD WIDTH="4"></TD>
                             <TD VALIGN="MIDDLE"><INPUT TYPE="RADIO" ID="desc" NAME="order" VALUE="desc" STYLE="width:15px"<?php if ($_REQUEST[order] == "desc") echo " CHECKED"; ?>></TD>
                             <TD VALIGN="MIDDLE" NOWRAP><B><LABEL FOR="desc"><?= $label[form][desc] ?></LABEL></B></TD>
                             <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                           </TR>
                       </TABLE></TD>
                       <TD HEIGHT="22" VALIGN="BOTTOM"><IMG SRC="img/form_right.png" WIDTH="19" HEIGHT="12"></TD>
                     </TR>
                     <TR>
                        <TD HEIGHT="22" VALIGN="TOP"><IMG SRC="img/form_left.png" WIDTH="19" HEIGHT="14"></TD>
                        <TD WIDTH="100%" HEIGHT="22" ALIGN="CENTER" BACKGROUND="img/form_bg.png"><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#E0F0F8">
                            <TR>
                              <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                              <TD VALIGN="MIDDLE"><B><?= $label[form][size]; ?></B></TD>
                              <TD WIDTH="4"></TD>
                              <TD VALIGN="MIDDLE"><SELECT NAME="size_minmax">
                                <OPTION VALUE="max"><?= $label[form][maximum] ?></OPTION>
                                <OPTION VALUE="min"<?php if ($_REQUEST[size_minmax] == "min") echo " SELECTED"; ?>><?= $label[form][minimum] ?></OPTION>
                              </SELECT></TD>
                              <TD WIDTH="4"></TD>
                              <TD VALIGN="MIDDLE"><INPUT TYPE="TEXT" NAME="size" SIZE="4" CLASS="input" VALUE="<?= $_REQUEST[size] ?>"></TD>
                              <TD WIDTH="4"></TD>
                              <TD VALIGN="MIDDLE"><INPUT TYPE="RADIO" ID="mb" NAME="size_mbkb" VALUE="mb" STYLE="width:15px"<?php if (($_REQUEST[size_mbkb] == "mb") || !$_REQUEST[size_mbkb]) echo " CHECKED"; ?>></TD>
                              <TD VALIGN="MIDDLE"><B><LABEL FOR="mb"><?= $label[mb] ?></LABEL></B></TD>
                              <TD WIDTH="4"></TD>
                              <TD VALIGN="MIDDLE"><INPUT TYPE="RADIO" ID="kb" NAME="size_mbkb" VALUE="kb" STYLE="width:15px"<?php if ($_REQUEST[size_mbkb] == "kb") echo " CHECKED"; ?>></TD>
                              <TD VALIGN="MIDDLE"><B><LABEL FOR="kb"><?= $label[kb] ?></LABEL></B></TD>
                              <TD><IMG SRC="img/form_dots.png" WIDTH="28" HEIGHT="22"></TD>
                            </TR>
                        </TABLE></TD>
                        <TD HEIGHT="22" VALIGN="TOP"><IMG SRC="img/form_right.png" WIDTH="19" HEIGHT="14"></TD>
                      </TR>
                    <INPUT TYPE="HIDDEN" NAME="page" VALUE="1"><?php

foreach($PCs as $PC) {

?><INPUT TYPE="HIDDEN" NAME="cb[<?= $PC[IP] ?>]" ID="cb_<?= $PC[IP] ?>" VALUE="<?= $_SESSION[cb][$PC[IP]] ?>"><?php

}

                  ?></FORM>
                </TABLE></TD>
              </TR>
              <TR>
                <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
                    <TR>
                      <TD HEIGHT="6" BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" WIDTH="214" HEIGHT="1"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
                    </TR>
                </TABLE></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
              <TR>
                <TD WIDTH="241" HEIGHT="90"><IFRAME SRC="comps.php" WIDTH="100%" HEIGHT="90" ALIGN="TOP" SCROLLING="auto" FRAMEBORDER="0" NAME="fr_comps"></IFRAME></TD>
              </TR>
              <TR>
                <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
                    <TR>
                      <TD HEIGHT="6" BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" WIDTH="214" HEIGHT="1"></TD>
                      <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
                      <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="6"></TD>
                    </TR>
                </TABLE></TD>
              </TR>
          </TABLE></TD>
        </TR>
      </TABLE></TD>
  </TR><?php

if ($page) {

    if (preg_match("/['\"\%\*:<>\|\/\\\\]/", $search)) {
        error_message($label[error][wrong_search]);
        $page = 0;
    
    } elseif (($_REQUEST[size]) && !ereg("^[0-9]+$", $_REQUEST[size])) {
        error_message($label[error][wrong_size]);
        $page = 0;
    
    } else {

        $mysql_link = mysql_connect($MySQL[host], $MySQL[user], $MySQL[pass]);
        mysql_select_db($MySQL[base], $mysql_link);
        $query_footer = query_footer();
        
        if ($query_footer) {
            $result = mysql_query("SELECT COUNT(*) FROM FILES " . $query_footer, $mysql_link);
            $rows = mysql_result($result, 0);
            mysql_close($mysql_link);
        }

        if (!$rows || !$query_footer) {
            error_message($label[error][no_results]);
            $page = 0;
        } else {

?><TR>
    <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR>
          <TD></TD>
          <TD ALIGN="RIGHT"><IMG SRC="img/sttc_middle-dot.png" WIDTH="243" HEIGHT="6"></TD>
        </TR>
      </TABLE>
      <TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0" ID="header_table">
        <TR>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" VALIGN="MIDDLE" CLASS="tbl_header">&nbsp;<?= $label[results][pc] ?>&nbsp;</TD>
              </TR>
              <TR>
                <TD NAME="header_comp_td" ID="header_comp_td"><IMG SRC="img/transperant.png" NAME="header_comp" WIDTH="1" HEIGHT="1" ID="header_comp"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
          <TD BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" VALIGN="MIDDLE" CLASS="tbl_header">&nbsp;<?= $label[results][dir] ?>&nbsp;</TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="27" HEIGHT="1"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
          <TD WIDTH="100%" ID="cell_filename" BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" VALIGN="MIDDLE" CLASS="tbl_header"><?= $label[results][file] ?></TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" VALIGN="MIDDLE" CLASS="tbl_header"><?= $label[results][modified] ?></TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="134" HEIGHT="1"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
          <TD BACKGROUND="img/bg_header.png"><TABLE WIDTH="100%" HEIGHT="23" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD ALIGN="CENTER" VALIGN="MIDDLE" CLASS="tbl_header"><?= $label[results][size] ?></TD>
              </TR>
              <TR>
                <TD><IMG SRC="img/transperant.png" WIDTH="79" HEIGHT="1"></TD>
              </TR>
          </TABLE></TD>
          <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
          <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="1"></TD>
        </TR>
      </TABLE></TD>
  </TR>
  <TR>
    <TD HEIGHT="100%"><IFRAME ID="results" NAME="results" SRC="<?php

            $url = submit_link();
            $url = "results.php" . substr($url, strlen($self_filename));
            echo "$url&page=$page";

        ?>" WIDTH="100%" MARGINWIDTH="6" HEIGHT="100%" MARGINHEIGHT="2" ALIGN="TOP" SCROLLING="auto" FRAMEBORDER="0"></IFRAME></TD>
  </TR>
  <TR>
    <TD><TABLE WIDTH="100%" HEIGHT="6" BORDER="0" CELLPADDING="0" CELLSPACING="0">
      <TR>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
        <TD BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" NAME="footer_comp" WIDTH="1" HEIGHT="1" ID="footer_comp"></TD>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
        <TD BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" WIDTH="27" HEIGHT="1"></TD>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
        <TD WIDTH="100%" BACKGROUND="img/bg_table_bottom.png"></TD>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
        <TD BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" WIDTH="134" HEIGHT="1"></TD>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="1" HEIGHT="1"></TD>
        <TD BACKGROUND="img/bg_table_bottom.png"><IMG SRC="img/transperant.png" WIDTH="79" HEIGHT="1"></TD>
        <TD BGCOLOR="#000000"><IMG SRC="img/transperant.png" WIDTH="2" HEIGHT="1"></TD>
        <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="6"></TD>
      </TR>
    </TABLE></TD>
  </TR><?php

        }
    }
}

?><TR>
    <TD HEIGHT="6"></TD>
  </TR>
  <TR>
    <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
      <TR>
        <TD WIDTH="100%" BGCOLOR="#000000"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="2"><?php

if ($page) { // Show paging if it's necessary

          ?><TR>
              <TD HEIGHT="16" BGCOLOR="#FFFFFF"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
                  <TR>
                    <TD ALIGN="LEFT"><?php 

    $pages_total = (int) ($rows / $results) + 1;
    $pages_displ = 21;
    $submit_link = submit_link();

    echo '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" HEIGHT="16"><TR><TD NOWRAP><B>&nbsp;' . $label[results][pages] . "&nbsp;";
    if ($page > 1) echo '<A HREF="' . $submit_link . "&page=" . ($page - 1) . '"> &laquo;&nbsp;</A>'; else echo "&nbsp;";
    echo '</B></TD><TD>';

    if (($page < (int) ($pages_displ / 2) + 1) || ($pages_total <= $pages_displ))
        $start_page = 1;
    elseif ($page > (int) ($pages_total - ($pages_displ / 2)))
        $start_page = $pages_total - $pages_displ + 1;
    else
        $start_page = $page - (int) ($pages_displ / 2);

    for ($i = 0, $page_i = $start_page;
         ($i < $pages_displ) && ($i < $pages_total);
         $i++, $page_i++
        ) {
            if ($page_i == $page) echo "<FONT STYLE=\"background-color: #AFE2DE;\"><B>&nbsp;$page_i&nbsp;</B></FONT>";
            else echo '<A HREF="' . $submit_link . "&page=$page_i" . "\">&nbsp;" . $page_i . "&nbsp;</A>";
    }

    echo "</TD>";

    if ($page < $pages_total) echo '<TD><A HREF="' . $submit_link . "&page=" . ($page + 1) . '">&nbsp;&raquo;&nbsp;</A></TD>';
    if (($pages_total - 1) && (($page_i - 1) < $pages_total) && (($_REQUEST[type] == "music") || ($_REQUEST[type] == "video")))
	echo '<TD NOWRAP>&nbsp;| ' . 
	     $label[results][total] . "&nbsp;$pages_total&nbsp;</TD>";

    echo "</TR></TABLE>";

                  ?></TD><?php
		  
    if (($_REQUEST[type] == "music") || ($_REQUEST[type] == "video")) {

		  ?><TD ALIGN="RIGHT" NOWRAP>&nbsp;<B>[<A HREF="<?php
		    
        $pl_url = $submit_link . "&page=$page";
        $pl_url = "playlist.php" . substr($pl_url, strlen($self_filename));
        echo $pl_url;

		    ?>"> <?= $label[results][playlist] ?> </A>]</B>&nbsp;</TD><?php

    } elseif (($pages_total - 1) && (($page_i - 1) < $pages_total))
        echo '<TD ALIGN="RIGHT" NOWRAP>&nbsp;' . $label[results][total] . "&nbsp;$pages_total&nbsp;" . "</TD>";

              ?></TR>
              </TABLE></TD>
            </TR><?php

}

          ?><TR>
              <TD BGCOLOR="#CDE7F5"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
                  <TR>
                    <TD><IMG SRC="img/corner_bottom_left.png" WIDTH="19" HEIGHT="16"></TD>
                    <TD WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
                        <TR>
                          <TD ALIGN="LEFT"><?php

    if (file_exists("/var/tmp/smbindex/timestamp")) { // Show statistics if indexing is done

                        ?><IFRAME SRC="db_age.php" WIDTH="100%" HEIGHT="16" ALIGN="TOP" SCROLLING="NO" FRAMEBORDER="0"></IFRAME></TD>
                          <TD ALIGN="RIGHT"><?php

        $mysql_link = mysql_connect($MySQL[host], $MySQL[user], $MySQL[pass]);
        mysql_select_db($MySQL[base]);

        $result = mysql_query("SELECT COUNT(*), SUM(files), SUM(size) FROM ONLINE", $mysql_link);
        $row = mysql_fetch_array($result);
        $row[2] = size_conv($row[2]);
        echo $label[status][comps] . " $row[0] &nbsp;" . $label[status][files] . " $row[1] &nbsp;" . $label[status][total_size] . " $row[2]";
    }

                        ?></TD>
                        </TR>
                    </TABLE></TD>
                    <TD><IMG SRC="img/corner_bottom_right.png" WIDTH="19" HEIGHT="16"></TD>
                  </TR>
              </TABLE></TD>
            </TR>
        </TABLE></TD>
        <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="1"></TD>
      </TR>
    </TABLE>
      <TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
        <TR>
          <TD WIDTH="100%"><TABLE WIDTH="100%" HEIGHT="26" BORDER="0" CELLPADDING="0" CELLSPACING="0">
              <TR>
                <TD COLSPAN="2" HEIGHT="4" NOWRAP></TD>
              </TR>
              <TR>
                <TD ALIGN="LEFT" VALIGN="MIDDLE" CLASS="copyright" NOWRAP>Powered by <A HREF="http://smbindex.no-ip.org" TARGET="_blank">SMBindex <?= $version ?></A> &copy; 2004-<?= date("Y") ?> Designed by SunHateR</TD>
                <TD><IMG SRC="img/sttc_bottomic_left.png" WIDTH="18" HEIGHT="26"></TD>
                <TD WIDTH="100%" BACKGROUND="img/bg_bottomic.png"></TD>
                <TD><IMG SRC="img/sttc_bottomic_right.png" WIDTH="18" HEIGHT="26"></TD>
                <TD ALIGN="RIGHT" NOWRAP><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
                  <FORM METHOD="GET">
                    <TR>
                      <TD VALIGN="MIDDLE"><B><?= $label[language]; ?>&nbsp;</B></TD>
                      <TD ALIGN="RIGHT" VALIGN="MIDDLE"><?php

# Language
$dir = opendir("lang");
while ($file = readdir($dir)) $files[] = $file;
closedir($dir);
array_shift($files); array_shift($files);
sort($files);

?><SELECT NAME="lang_change" onChange="self.document.location.href='<?= submit_link() ?>&page=<?= $page ?>&lang_change='+this.options[this.selectedIndex].value"><?php

foreach ($files as $file) {
    $language = substr($file, 0, strpos($file, "."));
    echo '<OPTION VALUE="' . $language . '"';
    if ($lang == "lang/" . $file) echo " SELECTED";
    echo ">" . ucfirst($language) . "</OPTION>";
}

                    ?></SELECT></TD>
                    </TR>
                  </FORM>
                </TABLE></TD>
              </TR>
          </TABLE></TD>
          <TD><IMG SRC="img/transperant.png" WIDTH="25" HEIGHT="8"></TD>
        </TR>
      </TABLE></TD>
  </TR><?php

if (!$page) echo '<TR><TD HEIGHT="100%"></TD></TR>';

?></TABLE>
</BODY>
</DIV>
</HTML><?php


function error_message($error_message) {
    ?><TR><TD HEIGHT="6"></TD></TR><TR><TD ALIGN="CENTER"><B><?= $error_message ?></B></TD></TR><?php
}


function submit_link() {
    global $_REQUEST, $_SESSION, $dirnames, $self_filename;

    if ($dirnames) $dirs = "&dirnames=1"; else $dirs = "";
    $srch_str = urlencode($_REQUEST[search]);
    $link = "$self_filename?search=$srch_str&type=$_REQUEST[type]&results=$_REQUEST[results]&sort=$_REQUEST[sort]&order=$_REQUEST[order]&size=$_REQUEST[size]&size_minmax=$_REQUEST[size_minmax]&size_mbkb=$_REQUEST[size_mbkb]";

    if (array_search("0", $_SESSION[cb]))
        foreach($_SESSION[cb] as $IP => $checked) 
            $link .= "&cb[$IP]=$checked";

    else    $link .= "&check_all=1";

    $link .= $dirs;
    return $link;
}


function check_IP($IP) {

    $allow_file = "/etc/smbindex/hosts.allow";
    $deny_file = "/etc/smbindex/hosts.deny";
    
    if (file_exists($allow_file) && file_exists($deny_file)) {
        die("Both files hosts.allow and hosts.deny exists in /etc/smbindex. Delete one of them!");
    } elseif (file_exists($allow_file)) {
        $file = $allow_file;
        $reverse = false;
    } elseif (file_exists($deny_file)) {
        $file = $deny_file;
        $reverse = true;
    } else return true;

    $IP_long = ip2long($IP);
    $content = file_get_contents($file);
    $nets = preg_split('/[ \n\t]+/', $content);

    $match = false;
    foreach ($nets as $net) {
        $net = ltrim(rtrim($net));

        if (substr($net, 0, 1) == "#") continue; // Skip comments

        $patt1 = "/^([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})\/(\d{1,2})$/";
        $patt2 = "/^([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})\/([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})\.([012]?\d{1,2})$/";

        $ok = false;

        if (preg_match($patt1, $net, $matches)) {
            if (($matches[1] > 0) && ($matches[1] < 255) &&
                ($matches[2] >= 0) && ($matches[2] < 255) &&
                ($matches[3] >= 0) && ($matches[3] < 255) &&
                ($matches[4] >= 0) && ($matches[4] < 255) &&
                ($matches[5] >= 0) && ($matches[5] <= 32)
               ) {
                $mask = 0;
                for ($i = 1; $i <= $matches[5]; $i++) $mask |= (1 << (32 - $i));
                $ok = true;
            }

        } elseif (preg_match($patt2, $net, $matches)) {
            if (($matches[1] > 0) && ($matches[1] < 255) &&
                ($matches[2] >= 0) && ($matches[2] < 255) &&
                ($matches[3] >= 0) && ($matches[3] < 255) &&
                ($matches[4] >= 0) && ($matches[4] < 255) &&
                ($matches[5] >= 0) && ($matches[5] <= 255) &&
                ($matches[6] >= 0) && ($matches[6] <= 255) &&
                ($matches[7] >= 0) && ($matches[7] <= 255) &&
                ($matches[8] >= 0) && ($matches[8] <= 255)
               ) {
                $mask = ip2long("$matches[5].$matches[6].$matches[7].$matches[8]");
                $ok = true;
            }
        }

        if ($ok) {
            $ip_long = ip2long("$matches[1].$matches[2].$matches[3].$matches[4]");

            if (($IP_long & $mask) == ($ip_long & $mask)) {
                $match = true;
                break;
            }
        }
    }

    return $reverse ? !$match : $match;
}


function check_sharesize($IP) {
    global $MySQL, $share_limit;
    $mysql_link = mysql_connect($MySQL[host], $MySQL[user], $MySQL[pass]);
    mysql_select_db($MySQL[base], $mysql_link);
    list($size) = mysql_fetch_row(mysql_query("SELECT size FROM ONLINE WHERE IP='$IP'", $mysql_link));
    mysql_close($mysql_link);
    return ($size > $share_limit);
}

?>
Return current item: SMBindex