connect( $GLOBAL['db']['host'], $GLOBAL['db']['user'], $GLOBAL['db']['pass'], $GLOBAL['db']['name'] ) ) { echo $db->error(); exit(); } //msg("саапщение", "http://www.filezz.net", "FILEZZ"); $g_xml = new XMLWriter; // initialize XML class $g_xml->openMemory(); $g_xml->startDocument('1.0','UTF-8'); $g_xml->startElement("document"); $g_xml->writeAttribute("title", text("Страничга")); $match = array(); require_once "./i_auth.php"; if (preg_match("/^\/captcha\/([0-9a-z]{32})\.png$/i", $uri, $match)) { $sess_id = $match[1]; require_once './i_captcha.php'; } elseif (preg_match("/^\/([0-9A-Za-z]{32})\/(.+)\.html$/", $uri, $match)) { $filehash = $match[1]; $filename = $match[2]; require_once './i_download.php'; } elseif (preg_match("/^\/login[\/]{0,1}$/i", $uri)) { $login = mysql_escape_string($_POST['login']); $pwd = $_POST['pwd']; $q = array(); $db->q("SELECT * FROM {$GLOBAL['db']['pref']}_admins WHERE `login`='{$login}'"); if ( $db->rows() > 0 ) { $db->store($q); if ( md5($q[0]['salt'] . md5($pwd)) == $q[0]['pwd_hash'] ) { setcookie("alogin", $login, 0, "/"); setcookie("apwd", $q[0]['pwd_hash'], 0, "/"); header("Location: /?acp"); $db->close(); exit(); } } msg("Login or password is incorrect"); } elseif (preg_match("/^\/admins[\/]{0,1}$/i", $uri)) { if ( !$USER['super_user'] ) msg("You have not access to this list"); require_once './i_admins.php'; } elseif (preg_match("/^\/logout[\/]{0,1}$/i", $uri)) { setcookie("alogin", "deleted", 0, "/"); setcookie("apwd", "deleted", 0, "/"); header("Location: /"); $db->close(); exit(); } else { require_once './i_upload.php'; } $g_xml->endElement(); // EOF 'document' $g_xml->endDocument(); $xml = $g_xml->outputMemory(); if ($stdout) { $dom_xml = new DOMDocument; $dom_xml->loadXML($xml); $dom_xsl = new DOMDocument; $dom_xsl->load('./tpl/index.xsl'); $proc_xsl = new XSLTProcessor; $proc_xsl->importStyleSheet($dom_xsl); // echo trim($proc_xsl->transformToXML($dom_xml)); echo $proc_xsl->transformToXML($dom_xml); } $db->close(); function text($txt) { return iconv("WINDOWS-1251", "UTF-8", $txt); } function msg($txt, $link = '', $link_title = '') { global $db; $xml = new XMLWriter; $xml->openMemory(); $xml->startDocument('1.0','UTF-8'); $xml->startElement("document"); $xml->writeAttribute("title", text("Сообщение")); $xml->startElement("message"); $xml->writeAttribute("message", text($txt)); if ($link != '') { $link_title = ($link_title == '' ? $link : $link_title); $xml->writeAttribute("link", $link); $xml->writeAttribute("link_title", $link_title); } $xml->endElement(); $xml->endElement(); // EOF 'document' $xml->endDocument(); $dom_xml = new DOMDocument; $dom_xml->loadXML($xml->outputMemory()); $dom_xsl = new DOMDocument; $dom_xsl->load('./tpl/index.xsl'); $proc_xsl = new XSLTProcessor; $proc_xsl->importStyleSheet($dom_xsl); echo $proc_xsl->transformToXML($dom_xml); $db->close(); exit(); } function http_auth($login, $pass) { $plogin = $_SERVER['PHP_AUTH_USER']; $ppass = $_SERVER['PHP_AUTH_PW']; if ($plogin != $login || $ppass != $pass) { Status(401, array("WWW-Authenticate" => "Basic realm=\"Authorization required\"") ); echo "Authorization required"; exit(); } return true; } function Status($status, $additional_headers = false) { header("", false, $status); if ($additional_headers) { foreach($additional_headers as $k => $v) { header("{$k}: {$v}"); } } } function formatsize($size) { $gb = 1024 * 1024 * 1024; $mb = 1024 * 1024; $kb = 1024; settype($size, 'float'); if ($size > 1.3 * $gb) { return round($size / $gb, 3) . " GB"; } else if ($size > 1.3 * $mb) { return round($size / $mb, 3) . " MB"; } else if ($size > 1.3 * $kb) { return round($size / $kb, 3) . " kB"; } else { return $size . " Bytes"; } return 0; } ?>