本文整理汇总了PHP中file_download函数的典型用法代码示例。如果您正苦于以下问题:PHP file_download函数的具体用法?PHP file_download怎么用?PHP file_download使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_download函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: db_query
<?php
include "../../include.php";
$return = '
<table width="100%" cellpadding="3" cellspacing="1" border="1">
<tr class="helptext" bgcolor="#CCCCCC">
<td>Due Date</td>
<td>Funder / Award</td>
<td>Report</td>
<td>Staff</td>
<td>Status</td>
</tr>';
$result = db_query("SELECT\n\t\t\tan.awardID, \n\t\t\tan.activityTitle,\n\t\t\tan.activityText,\n\t\t\tan.activityDate,\n\t\t\tu.lastname,\n\t\t\ta.awardTitle,\n\t\t\tf.name,\n\t\t\tf.funderID\n\t\tFROM funders_activity an\n\t\tINNER JOIN users u ON an.activityAssignedTo = u.id\n\t\tINNER JOIN funders_awards a ON an.awardID = a.awardID\n\t\tINNER JOIN funders f ON a.funderID = f.funderID\n\t\tWHERE an.isReport = 1 AND an.isComplete = 0\n\t\tORDER BY activityDate");
while ($r = db_fetch($result)) {
$date = $r["activityDate"] ? date("M j, Y", strtotime($r["activityDate"])) : "N/A";
$return .= '<tr class="helptext';
if ($r["statusDesc"] == "Overdue") {
$return .= '-b';
}
$return .= '" bgcolor="#FFFFFF" valign="top">
<td><nobr>' . $date . '</nobr></td>
<td><a href="http://' . $_josh["request"]["host"] . '/programs/resources_funder_view.php?id=' . $r["funderID"] . '">' . $r["name"] . '</a> /<br><a href="http://' . $_josh["request"]["host"] . '/programs/resources_award_view.php?id=' . $r["awardID"] . '">' . $r["awardTitle"] . '</a></td>
<td>' . $r["activityTitle"] . '</td>
<td>' . $r["lastname"] . '</td>
<td>' . $r["activityText"] . '</td>
</tr>';
}
$return .= '</table>';
file_download($return, "Report Due Dates - " . date("m/d/y"), "xls");
示例2: db_grab
<?php
include "../include.php";
$d = db_grab("SELECT \r\n\t\td.title,\r\n\t\td.extension, \r\n\t\td.content \r\n\tFROM helpdesk_tickets_attachments d \r\n\tWHERE d.id = " . $_GET["id"]);
//db_query("INSERT INTO docs_views ( documentID, user_id, viewedOn ) VALUES ( {$_GET["id"]}, {$_SESSION["user_id"]}, GETDATE() )");
file_download($d["content"], $d["title"], $d["extension"]);
示例3: foreach
foreach ($messages as $pm) {
// turn all single \n into \r\n
$pm['message'] = preg_replace("/(\r\n|\r|\n)/s", "\r\n", $pm['message']);
$pm['message'] = fetch_censored_text($pm['message']);
($hook = vBulletinHook::fetch_hook('private_downloadpm_bit')) ? eval($hook) : false;
$txt .= "================================================================================\r\n";
$txt .= "{$vbphrase['dump_from']} :\t{$pm['fromuser']}\r\n";
$txt .= "{$vbphrase['dump_to']} :\t" . fetch_touser_string($pm) . "\r\n";
$txt .= "{$vbphrase['date']} :\t" . vbdate('Y-m-d H:i', $pm['datestamp'], false, false) . "\r\n";
$txt .= "{$vbphrase['title']} :\t" . unhtmlspecialchars($pm['title']) . "\r\n";
$txt .= "--------------------------------------------------------------------------------\r\n";
$txt .= "{$pm['message']}\r\n\r\n";
}
}
// download the file
file_download($txt, str_replace(array('\\', '/'), '-', "{$vbphrase['dump_privatemessages']}-" . $vbulletin->userinfo['username'] . "-" . vbdate($vbulletin->options['dateformat'], TIMENOW) . '.txt'), 'text/plain');
break;
// *****************************
// unknown download format
// *****************************
// unknown download format
default:
eval(standard_error(fetch_error('invalidid', $vbphrase['file_type'], $vbulletin->options['contactuslink'])));
break;
}
}
// ############################### start insert pm ###############################
// either insert a pm into the database, or process the preview and fall back to newpm
if ($_POST['do'] == 'insertpm') {
$vbulletin->input->clean_array_gpc('p', array('wysiwyg' => TYPE_BOOL, 'title' => TYPE_NOHTML, 'message' => TYPE_STR, 'parseurl' => TYPE_BOOL, 'savecopy' => TYPE_BOOL, 'signature' => TYPE_BOOL, 'disablesmilies' => TYPE_BOOL, 'receipt' => TYPE_BOOL, 'preview' => TYPE_STR, 'recipients' => TYPE_STR, 'bccrecipients' => TYPE_STR, 'iconid' => TYPE_UINT, 'forward' => TYPE_BOOL, 'folderid' => TYPE_INT, 'sendanyway' => TYPE_BOOL));
if ($permissions['pmquota'] < 1) {
示例4: foreach
foreach ($projects as $p) {
$file .= '<td>';
if (isset($totals[$p])) {
$counter += round($totals[$p] / $e["total"] * 100, 2);
$file .= round($totals[$p] / $e["total"] * 100, 2) . "%";
//$total = round($rh["total"] / $rh["totaltotal"] * 100, 2);
//} else {
//$file .= "-";
}
$file .= '</td>';
}
$file .= '<td align="right">' . $counter . '</td></tr>';
}
$file .= '</table>';
//die($file);
file_download($file, $reportname, "xls");
}
echo drawTop();
?>
<table class="left" cellspacing="1">
<?php
echo drawHeaderRow("Percentages Report (without Vacation)", 2);
?>
<form method="post" action="<?php
echo $_josh["request"]["path_query"];
?>
">
<tr>
<td class="left">Start Date</td>
<td><?php
echo draw_form_select_month("start", "1/2005", false, false, "field", false, true);
示例5: fetch_illegal_usernames
function fetch_illegal_usernames($download = false)
{
global $vbulletin, $upgradecore_phrases;
$users = $vbulletin->db->query_read("\n\t\tSELECT userid, username FROM user\n\t\tWHERE username LIKE('%;%')\n\t");
if ($vbulletin->db->num_rows($users)) {
$illegals = array();
while ($user = $vbulletin->db->fetch_array($users)) {
$user['uusername'] = unhtmlspecialchars($user['username']);
if (strpos($user['uusername'], ';') !== false) {
$illegals["{$user['userid']}"] = $user['uusername'];
}
}
if (empty($illegals)) {
return false;
} else {
if ($download) {
$txt = "{$upgradecore_phrases['semicolons_file_intro']}\r\n";
foreach ($illegals as $userid => $username) {
$txt .= "--------------------------------------------------------------------------------\r\n";
$txt .= $username;
$padlength = 70 - strlen($username) - strlen("{$userid}");
for ($i = 0; $i < $padlength; $i++) {
$txt .= ' ';
}
$txt .= "(userid: {$userid})\r\n";
}
$txt .= '--------------------------------------------------------------------------------';
require_once DIR . '/includes/functions_file.php';
file_download($txt, $upgradecore_phrases['illegal_user_names'], 'text/plain');
} else {
return $illegals;
}
}
} else {
return false;
}
}
示例6: iif
case 'database':
case 'security':
if ($vbulletin->GPC['filename'] = trim($vbulletin->options["errorlog{$type}"])) {
$vbulletin->GPC['filename'] = $vbulletin->GPC['filename'] . iif($date, $date) . '.log';
if (file_exists($vbulletin->GPC['filename'])) {
if ($vbulletin->GPC['delete']) {
if (can_access_logs($vbulletin->config['SpecialUsers']['canpruneadminlog'], 0, '<p>' . $vbphrase['log_file_deletion_restricted'] . '</p>')) {
if (@unlink($vbulletin->GPC['filename'])) {
print_stop_message('deleted_file_successfully');
} else {
print_stop_message('unable_to_delete_file');
}
}
} else {
require_once DIR . '/includes/functions_file.php';
file_download(implode('', file($vbulletin->GPC['filename'])), substr($vbulletin->GPC['filename'], strrpos($vbulletin->GPC['filename'], '/') + 1), 'baa');
}
} else {
print_stop_message('invalid_file_specified');
}
}
}
$_REQUEST['do'] = 'logfiles';
}
// #############################################################################
print_cp_header($vbphrase['control_panel_log']);
// #############################################################################
if (empty($_REQUEST['do'])) {
$_REQUEST['do'] = 'choose';
}
// ###################### Start view db error log #######################
示例7: contactAttachmentGet
/**
* Метод, предназначенный для скачивания прикреплённых к сообщению файлов
*
* @param file $file
*/
function contactAttachmentGet($file)
{
$file_ex = get_mime_type($file);
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: ' . $file_ex);
header('Content-Disposition: attachment; filename=' . $file);
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . @filesize(BASE_DIR . '/attachments/' . $file));
@set_time_limit(0);
if (false === file_download(BASE_DIR . '/attachments/' . $file)) {
die('File not found.');
}
}
示例8: file_download
<?php
include_once "download_function.php";
if (isset($_GET['file_path']) && $_GET['file_path'] != '') {
$path = $_GET['file_path'];
$name = $_GET['file_name'];
file_download($path, $name = '');
exit;
}
示例9: hf_id_user
}
}
}
$qn = "";
if (isset($_GET['q'])) {
$qn = $_GET['q'];
}
if (strlen($qn) > 0) {
if (isset($_GET['file'])) {
if ($_GET['file'] == "hisfunctionxmlexport") {
$u->build();
$q = new hf_id_user();
$q->get_from_hashrange($u->id_user, $qn);
$q->build();
$hf_name = $q->name;
$chars = ' !@#$%^&*()_+-=[]{}\\|;\':"<>?,./;';
for ($i = 0; $i < strlen($chars) - 2; $i++) {
$char = substr($chars, $i, 1);
$hf_name = str_replace($char, "_", $hf_name);
}
//$hf_name = urlencode($hf_name);
$hf_name = "" . $hf_name . ".hf.xml";
$export = $q->toxml(true);
$export = $q->toxml(true);
file_download($hf_name, $export);
exit;
}
}
}
// end if
exit;
示例10: db_query
<?php
include "../../include.php";
//download
if (url_action("delete")) {
db_query("UPDATE policy_docs SET is_active = 0, deleted_date = GETDATE(), deleted_user = {$_SESSION["user_id"]} WHERE id = " . $_GET["id"]);
url_drop("id, action");
} elseif (url_id()) {
$d = db_grab("SELECT d.name, t.extension, d.content FROM policy_docs d JOIN docs_types t ON d.type_id = t.id WHERE d.id = " . $_GET["id"]);
//db_query("INSERT INTO docs_views ( documentID, user_id, viewedOn ) VALUES ( {$_GET["id"]}, {$_SESSION["user_id"]}, GETDATE() )");
file_download($d["content"], $d["name"], $d["extension"]);
}
//get nav options
$options = array();
$categories = db_query("SELECT id, description FROM policy_categories ORDER BY description");
while ($c = db_fetch($categories)) {
if (!isset($_GET["category"])) {
url_query_add(array("category" => $c["id"]));
}
$options[str_replace(url_base(), "", url_query_add(array("category" => $c["id"]), false))] = $c["description"];
}
echo drawTop();
echo drawNavigationRow($options, "areas", true);
?>
<table class="left">
<?php
if ($page['is_admin']) {
echo drawheaderRow("", 4, "add", "edit/");
} else {
echo drawheaderRow("", 3);
}
示例11: header
} else {
$set = 'fns';
$path = Path::theme($file, $set);
}
}
if (!$path) {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
header('Status: 404 Not Found');
exit;
} else {
$ext = false;
$dyn = preg_match('/\\?/', $path);
if (!$dyn) {
preg_match('/.*\\.(.*)$/', '.' . $path, $match);
$ext = mb_strtolower($match[1]);
$file_types_user = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'rtf' => 'text/rtf', 'png' => 'image/png', 'mht' => 'application/msword', 'doc' => 'application/msword', 'docx' => 'application/msword', 'avi' => 'video/x-msvideo', 'xls' => 'application/msexcel', 'tpl' => 'text/html', 'html' => 'text/html', 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'doc' => 'application/msword', 'docx' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet');
$file_types_admin = array('php' => 'text/html');
}
if (!$dyn && $ext && $file_types_user[$ext]) {
//header( "Content-type: ".$file_types[$ext] ) ;
//header( "Last-Modified: ".gmdate("D, d M Y H:i:s",filemtime($path))." GMT" );
file_download($path, $file_types_user[$ext]);
} else {
Access::admin(true);
if (!$dyn && $ext && $file_types_admin[$ext]) {
file_download($path, $file_types_admin[$ext]);
} else {
die('Исключение');
}
}
}
示例12: header
//header("Content-Description: File Transfer");
//Use the switch-generated Content-Type
header("Content-Type: {$ctype}");
header('Content-Transfer-Encoding: Binary');
//Force the download
header("Accept-Ranges: bytes");
header("Content-Length: {$download_size}");
//header('Content-Disposition: attachment; filename="'.$filename.'";'); // suman
header('Content-Disposition: attachment; filename="' . $name . '";');
/* /////////////////////////////
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
// change, added quotes to allow spaces in filenames, by Rajkumar Singh
header("Content-Disposition: attachment; filename=\"".basename($name)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($name));
//////////////////////////// */
//ob_end_clean();
readfile($file);
}
if (isset($_GET['filepath']) && $_GET['filepath'] != '') {
include_once 'config.php';
$path = '../image/' . $_GET['filepath'];
$nameexp = explode('/', $_GET['filepath']);
$name = $nameexp[1];
file_download($path, $name);
exit;
}
示例13: array_push
array_push($fields, $name->name . "|||" . db_field_type($result, $i));
}
$return = '
<table border="1">
<tr bgcolor="#fffceo">';
foreach ($fields as $field) {
list($name, $datatype) = explode("|||", $field);
$return .= '
<td><b>' . trim(str_replace("_", " ", $name)) . '</b></td>
';
}
$return .= '</tr>';
while ($r = db_fetch($result)) {
$return .= '<tr>';
reset($fields);
foreach ($fields as $field) {
list($name, $datatype) = explode("|||", $field);
if ($datatype == "datetime") {
$r[$name] = format_date_excel($r[$name]);
}
$return .= '<td>' . $r[$name] . '</td>';
}
$return .= '</tr>';
$num_rows++;
}
$return .= '</table>';
//save exec info
db_switch($_josh["db"]["database"]);
db_query("INSERT INTO queries_executions ( \n\t\t\t\tqueryID, \n\t\t\t\tuserID, \n\t\t\t\texecutedOn, \n\t\t\t\tnum_rows, \n\t\t\t\tnum_columns\n\t\t\t) VALUES (\n\t\t\t\t{$_GET["id"]},\n\t\t\t\t{$_SESSION["user_id"]},\n\t\t\t\tGETDATE(),\n\t\t\t\t{$num_rows},\n\t\t\t\t{$num_columns}\n\t\t\t)");
file_download($return, $filename, "xls");
示例14: date
$return .= '<td>' . date("M, Y", strToTime($r["awardStartDate"])) . ' - ' . date("M, Y", strToTime($r["awardEndDate"])) . '</td>';
} else {
$return .= '<td>';
if ($r["pastActivityTitle"]) {
$return .= $r["pastActivityTitle"] . ' (' . format_date($r["pastActivityDate"]) . ')';
}
$return .= '</td>';
}
$return .= '<td>';
if ($r["activityTitle"]) {
$return .= $r["activityTitle"] . ' (' . format_date($r["activityDate"]) . ')';
}
$return .= '</td>
<td align="right">$' . number_format($r["awardAmount"]) . '</td>
<td>' . $r["last_name"] . '</td>
</tr>';
}
$result = db_query("SELECT\n\t\t\t\t\t\tf.funderID,\n\t\t\t\t\t\tf.name,\n\t\t\t\t\t\ta.awardID,\n\t\t\t\t\t\ta.awardTitle,\n\t\t\t\t\t\tp.programDesc\n\t\t\t\t\tFROM funders_awards a \n\t\t\t\t\tINNER JOIN funders f ON f.funderID = a.funderID\n\t\t\t\t\tINNER JOIN funders_programs p ON a.awardProgramID = p.programID\n\t\t\t\t\tWHERE a.awardStatusID = " . $rs["awardStatusID"] . " AND a.awardProgramID2 = " . $rp["programID"]);
while ($r = db_fetch($result)) {
$return .= '
<tr bgcolor="#FFFFFF" class="helptext">
<td><a href="http://' . $_josh["request"]["host"] . '/funders/funder_view.php?id=' . $r["funderID"] . '">' . $r["name"] . '</a></td>
<td><a href="http://' . $_josh["request"]["host"] . '/funders/award_view.php?id=' . $r["awardID"] . '">' . $r["awardTitle"] . '</a></td>
<td colspan="4">(See <i>' . $r["programDesc"] . '</i>)</td>
</tr>';
}
}
}
$return .= '</table>';
file_download($return, "Big List - " . date("m/d/y"), "xls");
示例15: foreach
}
foreach ($contacts as $email => $name) {
$output .= $name . '<' . $email . '>' . PHP_EOL;
}
$output .= PHP_EOL;
}
$transports = '';
$x = 0;
foreach ($config['alert']['transports'] as $name => $v) {
if ($config['alert']['transports'][$name] === true) {
$transports .= 'Transport: ' . $name . PHP_EOL;
$x++;
}
}
if (!empty($transports)) {
$output .= 'Found ' . $x . ' transports to send alerts to.' . PHP_EOL;
$output .= $transports;
}
break;
default:
echo 'You must specify a valid type';
exit;
}
// ---- Output ----
if ($_GET['format'] == 'text') {
header("Content-type: text/plain");
header('X-Accel-Buffering: no');
echo $output;
} elseif ($_GET['format'] == 'download') {
file_download($filename, $output);
}