本文整理汇总了PHP中PHPZip::forceDownload方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPZip::forceDownload方法的具体用法?PHP PHPZip::forceDownload怎么用?PHP PHPZip::forceDownload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPZip
的用法示例。
在下文中一共展示了PHPZip::forceDownload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isset
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: PHPZip
$dict['announce'] = $INSTALLER09['xbt_prefix'] . $CURUSER['torrent_pass'] . $INSTALLER09['xbt_suffix'];
} else {
$dict['announce'] = $INSTALLER09['announce_urls'][$ssluse] . '?torrent_pass=' . $CURUSER['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;
}