Пример #1
0
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('messages'));
$INSTALLER09['sub_up_dir'] = "C:/appserv/www/uploadsub";
$action = isset($_POST["action"]) ? $_POST["action"] : "";
if ($action == "download") {
    $id = isset($_POST["sid"]) ? 0 + $_POST["sid"] : 0;
    if ($id == 0) {
        stderr("Err", "Not a valid id");
    } else {
        $res = sql_query("SELECT id, name, filename FROM subtitles WHERE id={$id} ") or sqlerr(__FILE__, __LINE__);
        $arr = mysql_fetch_assoc($res);
        $ext = substr($arr["filename"], -3);
        $fileName = str_replace(array(" ", ".", "-"), "_", $arr["name"]) . '.' . $ext;
        $file = $INSTALLER09['sub_up_dir'] . "/" . $arr["filename"];
        $fileContent = file_get_contents($file);
        $newFile = fopen("{$INSTALLER09['sub_up_dir']}/{$fileName}", "w");
        @fwrite($newFile, $fileContent);
        @fclose($newFile);
        $file = array();
        $zip = new PHPZip();
        $file[] = "{$INSTALLER09['sub_up_dir']}/{$fileName}";
        $fName = "{$INSTALLER09['sub_up_dir']}/" . str_replace(array(" ", ".", "-"), "_", $arr["name"]) . ".zip";
        $zip->Zip($file, $fName);
        $zip->forceDownload($fName);
        @unlink($fName);
        @unlink("{$INSTALLER09['sub_up_dir']}/{$fileName}");
        sql_query("UPDATE subtitles SET hits=hits+1 where id={$id}");
    }
} else {
    stderr("Err", "No way");
}
Пример #2
0
    $dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
    $dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass='******'torrent_pass'];
}
$dict['uid'] = (int) $CURUSER['id'];
$tor = bencdec::encode($dict);
if ($zipuse) {
    require_once INCL_DIR . 'phpzip.php';
    $row['name'] = str_replace(array(' ', '.', '-'), '_', $row['name']);
    $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent';
    if (file_put_contents($file_name, $tor)) {
        $zip = new PHPZip();
        $files = array($file_name);
        $file_name = $INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip';
        $zip->Zip($files, $file_name);
        $zip->forceDownload($file_name);
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.torrent');
        unlink($INSTALLER09['torrent_dir'] . '/' . $row['name'] . '.zip');
    } else {
        stderr('Error', 'Can\'t create the new file, please contatct staff');
    }
} else {
    if ($text) {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['name'] . '.txt"');
        header("Content-Type: text/plain");
        echo $tor;
    } else {
        header('Content-Disposition: attachment; filename="[' . $INSTALLER09['site_name'] . ']' . $row['filename'] . '"');
        header("Content-Type: application/x-bittorrent");
        echo $tor;
    }