本文整理汇总了PHP中download_file函数的典型用法代码示例。如果您正苦于以下问题:PHP download_file函数的具体用法?PHP download_file怎么用?PHP download_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了download_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_pull_request
/**
* Process a pull request creation or update event.
*
* @param object $payload
* The received data.
*/
function handle_pull_request($payload)
{
$issue_number = get_issue_number($payload->pull_request);
if (!$issue_number) {
exit;
}
$pull_request_url = $payload->pull_request->html_url;
switch ($payload->action) {
case 'synchronize':
$comment = '<a href="' . $payload->sender->html_url . '">' . $payload->sender->login . '</a> pushed some commits to the <a href="' . $pull_request_url . '">pull request</a>.' . "\n\nFor an interdiff please see the <a href=\"" . $pull_request_url . "/commits\">list of recent commits</a>.";
break;
case 'opened':
$comment = '<a href="' . $payload->pull_request->user->html_url . '">' . $payload->pull_request->user->login . '</a> opened a <a href="' . $pull_request_url . '">new pull request</a> for this issue.';
break;
default:
// Unknown action, so we just exit.
exit;
}
// Get node metadata to append comment number to patch file name.
$issue_meta = get_issue_meta($issue_number);
if (!empty($issue_meta['comment_count'])) {
$file_name = $issue_number . '-' . ($issue_meta['comment_count'] + 1) . '.patch';
} else {
$file_name = "{$issue_number}.patch";
}
$diff_url = $payload->pull_request->diff_url;
// Download the patch.
$file = download_file($diff_url, $file_name);
post_comment($issue_number, $comment, $file);
// Cleanup: remove the downloaded file and the temporary directory it is in.
unlink($file);
rmdir(dirname($file));
}
示例2: get_result
function get_result($id)
{
$result = Resources::get_result($id);
if ($result["success"] == false) {
show_message("Operation failed with status code " . $result['status-code']);
return;
}
download_file($result['data'], $id . ".zip", "application/zip");
}
示例3: download_fonts
function download_fonts($pack)
{
if (!isset($pack['fonts'])) {
return;
}
foreach ($pack['fonts'] as $font) {
download_file(github_or_network_for($font, $pack), get_libs_dir() . $pack['name'] . '/fonts/' . basename($font));
}
}
示例4: pre_process
public function pre_process($person)
{
parent::pre_process($person);
$res = false;
if ($this->person->isAuth()) {
if (isset($_GET['file_cert'])) {
$authKey = Input::sanitizeCertKey($_GET['file_cert']);
try {
$cert = $this->ca->getCert($authKey);
if (isset($cert) && $cert->isValid()) {
include 'file_download.php';
download_file($cert->getPEMContent(), 'usercert.pem');
exit(0);
}
} catch (ConfusaGenException $cge) {
Framework::error_output($this->translateMessageTag('downl_err_nodownload') . " " . htmlentities($cge->getMessage()));
}
} else {
if (isset($_GET['cert_status'])) {
$this->pollCertStatusAJAX(Input::sanitizeCertKey($_GET['cert_status']));
} else {
if (isset($_GET['certlist_all'])) {
$this->showAll = $_GET['certlist_all'] == "true";
} else {
if (isset($_GET['revoke']) && $_GET['revoke'] == 'revoke_single') {
$order_number = Input::sanitizeCertKey($_GET['order_number']);
/* sanitized by checking inclusion in the REVOCATION_REASONS
* array
*/
if (!array_key_exists('reason', $_GET)) {
Framework::error_output($this->translateMessageTag('rev_err_singlenoreason'));
return;
}
$reason = Input::sanitizeText(trim($_GET['reason']));
try {
if (!isset($order_number) || !isset($reason)) {
Framework::error_output("Revoke Certificate: Errors with parameters, not set properly");
} elseif (!$this->checkRevocationPermissions($order_number)) {
Framework::error_output($this->translateMessageTag('rev_err_singlenoperm'));
} elseif (!$this->ca->revokeCert($order_number, $reason)) {
Framework::error_output($this->translateMessageTag('rev_err_notyet1') . htmlentities($order_number) . $this->translateMessageTag('rev_err_notyet2') . htmlentities($reason));
} else {
Framework::message_output($this->translateMessageTag('rev_suc_single1') . htmlentities($order_number) . $this->translateMessageTag('rev_suc_single2'));
if (Config::get_config('ca_mode') === CA_COMODO && Config::get_config('capi_test') === true) {
Framework::message_output($this->translateTag('l10n_msg_revsim1', 'revocation'));
}
}
} catch (ConfusaGenException $cge) {
Framework::error_output($this->translateMessageTag('rev_err_singleunspec') . " " . htmlentities($cge->getMessage()));
}
}
}
}
}
}
return false;
}
示例5: download
public function download($type = '')
{
requireadmin();
$q = $this->input->get('q');
if ($type == 'files') {
if (is_file('backup/files/' . $q)) {
download_file('backup/files/' . $q, $q);
}
} else {
if (is_file('backup/database/' . $q)) {
download_file('backup/database/' . $q, $q);
}
}
}
示例6: plug_download
function plug_download($p, $o)
{
$dir = 'plug/_data/' . ses('qb') . '_';
$f = base64_decode($p);
if ($f != "../" && strpos($f, "params") === false && is_file($f)) {
//nb_of_dwnl
$nm = rednm($f);
$nmf = $nm . '.txt';
if (is_file($dir . $nmf)) {
$nb = read_file($dir . $nmf);
}
write_file($dir . $nmf, $nb = $nb ? $nb + 1 : 1);
//clients
$arr = array($f, hostname());
$dy = date('ymd-hi', time());
download_eye($arr, $dy);
download_file($f, $nm);
}
}
示例7: view
/**
* View single attachment (basically, load it and forward it to the user)
*
* @param void
* @return null
*/
function view()
{
if ($this->active_attachment->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$this->active_attachment->canView($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
// Fix problem with non-ASCII characters in IE
$filename = $this->active_attachment->getName();
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
$filename = urlencode($filename);
}
// if
$as_attachment = $this->request->get('disposition', 'attachment') == 'attachment';
download_file($this->active_attachment->getFilePath(), $this->active_attachment->getMimeType(), $filename, $as_attachment);
die;
}
示例8: file
public function file($id = 0)
{
$myID = getUserID();
$query = $this->mdb->get_attachment($id);
if ($query->num_rows()) {
$row = $query->row();
if (validate_access('valid_member', array('project_id' => $row->project_id, 'user_id' => $myID)) || $row->uploader == $myID) {
$filepath = 'uploads/files/' . $row->uploader . '/' . $row->filepath;
if (is_file($filepath)) {
download_file($filepath, $row->filename);
} else {
echo 'File does not exists in server.';
}
} else {
echo 'You are not allowed to download this file.';
}
} else {
echo 'file does not exists.';
}
}
示例9: install_playtomic
function install_playtomic($gameid)
{
$table = '';
$pre = 'ptomic';
global $mysqli;
$categories = array('Action' => 2, 'Adventure' => 3, 'Strategy' => 10, 'Multiplayer' => 2, 'Puzzle' => 1, 'Rhythm' => 7, 'Shooter' => 5, 'Sports' => 4, 'Other' => 7, 'RPG' => 3, 'Arcade' => 9, 'Driving' => 4, 'Defense' => 10, 'Rhythm' => 7, 'Education' => 7, 'Gadgets' => 1, 'Fighting' => 2, 'Dress Up' => 8, 'Board Game' => 7, 'Pimp & Customize' => 8, 'Pimp & Customize' => 8);
$query = yasDB_select("SELECT * FROM `playtomicfeed` WHERE `id` = '{$gameid}'", false);
$result = $query->fetch_array(MYSQLI_ASSOC);
$gamename = $result['name'];
$thumburl = $result['thumburl'];
$thumburl_200 = $result['thumbnail_200x200'];
$screen1_thumb = '';
$screen2_thumb = '';
$screen3_thumb = '';
$screen4_thumb = '';
$gameurl = $result['gameurl'];
$c = explode(",", $result['categories']);
// Remove comma delimiter and seperate categories into array in order to insert single category.
$category = $categories[$c[0]];
$slug = str_replace(array('-', '_'), '', $result['slug']);
// Download and save game file
$game_file = $pre . "_" . $slug . "." . GetFileExtension($result['gameurl']);
$game_url = '../swf/' . $game_file;
download_file($gameurl, $game_url);
$gamefile = 'swf/' . $game_file;
// Download and save 100x100 thumbnail pic
$smallthumb = $pre . "_" . $slug . "." . GetFileExtension($result['thumburl']);
$sm_thumb = '../img/' . $smallthumb;
download_file($thumburl, $sm_thumb);
$gamethumb = 'img/' . $smallthumb;
// Download and save 200x200 thumbnail pic
$gamethumb200 = '';
/*if(!empty($result['thumbnail_200x200']) || $type == 0) {
$t_url = str_replace("..", "", $result['thumbnail_200x200']);
$mediumthumb = $pre."_200_" . $slug . "." . GetFileExtension($result['thumbnail_200x200']);
$med_thumb = '../img/' . $mediumthumb;
download_file($t_url, $med_thumb);
$gamethumb200 = 'img/' . $mediumthumb;
} else {
$gamethumb200 = '';
}*/
/////////////////////////////////////////////////////////////////////////////////////////////////
// Remove code comment to download the game screen images - depends on availabilty in the feed //
/////////////////////////////////////////////////////////////////////////////////////////////////
/*
// Download and save screen 1 pic
if($result['screenthumburl1']) {
$t_url = str_replace("..", "", $result['screenthumburl1']);
$largethumb = $pre."_screen1_" . $slug . "." . GetFileExtension($result['screenthumburl1']);
$screen1_thumb = '../img/' . $largethumb;
download_file($t_url, $screen1_thumb);
}
// Download and save screen 2 pic
if($result['screenthumburl2']) {
$t_url = str_replace("..", "", $result['screenthumburl2']);
$largethumb = $pre."_screen2_" . $slug . "." . GetFileExtension($result['screenthumburl2']);
$screen2_thumb = '../img/' . $largethumb;
download_file($t_url, $screen2_thumb);
}
// Download and save screen 3 pic
if($result['screenthumburl3']) {
$t_url = str_replace("..", "", $result['screenthumburl3']);
$largethumb = $pre."_screen3_" . $slug . "." . GetFileExtension($result['screenthumburl3']);
$screen3_thumb = '../img/' . $largethumb;
download_file($t_url, $screen3_thumb);
}
// Download and save screen 4 pic
if($result['screenthumburl2']) {
$t_url = str_replace("..", "", $result['screenthumburl4']);
$largethumb = $pre."_screen4_" . $slug . "." . GetFileExtension($result['screenthumburl4']);
$screen4_thumb = '../img/' . $largethumb;
download_file($t_url, $screen4_thumb);
}
*/
$desc = yasDB_clean($result['description']);
// Prep for DB insert
$instructions = yasDB_clean($result['instructions']);
$keywords = $result['keywords'];
$keywords = yasDB_clean($keywords);
$gamename = yasDB_clean($gamename);
$gamefile = yasDB_clean($gamefile);
$gamethumb = yasDB_clean($gamethumb);
$height = $result['height'];
$width = $result['width'];
$query->close();
$query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`) VALUES (NULL, '{$gamename}', '{$desc}', '{$instructions}', '{$keywords}', '{$gamefile}', '{$height}', '{$width}', {$category}, 0, '', 'SWF', 'PLAYTOMIC', {$gameid}, '{$gamethumb}', '{$gamethumb200}', '{$screen1_thumb}', '{$screen2_thumb}','{$screen3_thumb}','{$screen4_thumb}')", false);
if (!$query) {
echo 'Error updating Games database';
return false;
}
$query = yasDB_update("UPDATE `playtomicfeed` SET isinstalled = 1 WHERE id = '{$result['id']}'", false);
if (!query) {
echo 'Error updating $table database';
return false;
}
return true;
}
示例10: download_exported_file
function download_exported_file() {
$filename = array_var($_SESSION, 'contact_export_filename', '');
if ($filename != '') {
$path = ROOT.'/tmp/'.$filename;
$size = filesize($path);
if (isset($_SESSION['fname'])) {
$name = $_SESSION['fname'];
unset($_SESSION['fname']);
}
else $name = (array_var($_SESSION, 'import_type', 'contact') == 'contact' ? 'contacts.csv' : 'companies.csv');
unset($_SESSION['contact_export_filename']);
unset($_SESSION['import_type']);
download_file($path, 'text/csv', $name, $size, true);
unlink($path);
die();
} else $this->setTemplate('csv_export');
}
示例11: process_job
function process_job(&$jobData)
{
$data = json_decode($jobData->getData());
if (!is_array($data)) {
echo "Found bad job:\n";
print_r($data);
echo "\n";
bs()->delete($jobData);
continue;
}
echo "===============================================\n";
echo "# Beginning job\n";
print_r($data);
foreach ($data as $job) {
// Get the instagram access token for this user ID
$user = ORM::for_table('users')->where('instagram_user_id', $job->object_id)->find_one();
if ($user) {
if ($user->micropub_success) {
// Retrieve recent photos for the user after the time specified in the post
// https://api.instagram.com/v1/users/self/media/recent?min_timestamp=1394295266
$timestamp = $job->time;
$media_id = $job->data->media_id;
if ($photo = IG\get_photo($user, $media_id)) {
$entry = h_entry_from_photo($user, $photo);
$photo_url = $photo->images->standard_resolution->url;
// Download the photo to a temp folder
echo "Downloading photo...\n";
$filename = download_file($photo_url);
if (property_exists($photo, 'videos')) {
$video_url = $photo->videos->standard_resolution->url;
echo "Downloading video...\n";
$video_filename = download_file($video_url, 'mp4');
} else {
$video_filename = false;
}
// Send the photo to the micropub endpoint
echo "Sending photo" . ($video_filename ? " and video" : "") . " to micropub endpoint: " . $user->micropub_endpoint . "\n";
// Collapse category to a comma-separated list if they haven't upgraded yet
if ($user->send_category_as_array != 1) {
if ($entry['category'] && is_array($entry['category']) && count($entry['category'])) {
$entry['category'] = implode(',', $entry['category']);
}
}
print_r($entry);
echo "\n";
$response = micropub_post($user->micropub_endpoint, $user->micropub_access_token, $entry, $filename, $video_filename);
print_r($response);
echo "\n";
unlink($filename);
if ($video_filename) {
unlink($video_filename);
}
// Store the request and response from the micropub endpoint in the DB so it can be displayed to the user
$user->last_micropub_response = json_encode($response);
$user->last_instagram_photo = $photo->id;
$user->last_photo_date = date('Y-m-d H:i:s');
$user->save();
/*
// Add the link to the photo caption
$comment_text = '';
if($photo->caption && $photo->caption->id) {
$comment_id = $photo->caption->id;
$comment_text = $photo->caption->text;
// Now delete the comment (caption) if there is one
$result = IG\delete_comment($user, $media_id, $comment_id);
print_r($result);
}
// Re-add the caption with the citation
$canonical = 'http://aaron.pk/xxxxx';
$comment_text .= ' ('.$canonical.')';
$result = IG\add_comment($user, $media_id, $comment_text);
print_r($result);
*/
}
} else {
echo "This user has not successfully completed a test micropub post yet\n";
}
} else {
echo "No user account found for Instagram user " . $job->object_id . "\n";
}
}
echo "# Job Complete\n-----------------------------------------------\n\n";
bs()->delete($jobData);
}
示例12: install_vascogame
function install_vascogame($gameid)
{
global $mysqli;
$query = yasDB_select("SELECT * FROM `vascogames` WHERE `id` = '{$gameid}'", false);
$result = $query->fetch_array(MYSQLI_ASSOC);
$categories = array('action games' => 2, 'adventure games' => 3, 'strategy games' => 10, 'skill games' => 10, 'puzzle games' => 1, 'arcade games' => 9, 'shooting games' => 5, 'sports games' => 4, 'misc games' => 7, 'car games' => 4);
//Strategy
// Download and save game file
if ($result['file']) {
$g_url = str_replace("..", "", $result['file']);
$game_file = basename($g_url);
$game_file = "vasco_" . preg_replace('#\\W#', '', $result['title']) . "." . GetFileExtension($result['file']);
$game_url = '../swf/' . $game_file;
download_file($g_url, $game_url);
} else {
return false;
}
// Download and save thumbnail pic
if ($result['thumbnail']) {
$t_url = str_replace("..", "", $result['thumbnail']);
$smallthumb = "vasco_" . preg_replace('#\\W#', '', $result['title']) . "." . GetFileExtension($result['thumbnail']);
$thumb = '../img/' . $smallthumb;
download_file($t_url, $thumb);
}
$desc = yasDB_clean($result['description']);
// Prep for DB insert
$gamename = yasDB_clean($result['title']);
$gamefile = yasDB_clean(str_replace("../", "", $game_url));
$gamethumb = yasDB_clean(str_replace("../", "", $thumb));
$height = $result['height'];
$width = $result['width'];
$c = $result['category'];
$category = $categories[$c];
$query->close();
if ($category == null || $category == '' || $category == 0) {
$category == 7;
}
$query = yasDB_insert("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `source`, `sourceid`, `thumbnail`, `thumbnail_200`, `screen1`, `screen2`, `screen3`, `screen4`) VALUES (NULL, '{$gamename}', '{$desc}', '', '', '{$gamefile}', {$height}, {$width}, {$category}, 0, '', 'SWF', 'VASCOGAMES', {$gameid}, '{$gamethumb}', '', '', '','','')", false);
if (!$query) {
echo 'Error updating Games database';
return false;
}
$query = yasDB_update("UPDATE `vascogames` SET `installed` = 1 WHERE `id` = {$result['id']}", false);
if (!query) {
echo 'Error updating vascogames database';
return false;
}
return true;
}
示例13: get_logged_in_user
echo "</pre>\n";
}
$user = get_logged_in_user();
//print_r($user);
$user_submit = BoincUserSubmit::lookup_userid($user->id);
if (!$user_submit) {
error_page("no job submission access");
}
$action = get_str('action', true);
if (!$action) {
$action = post_str('action', true);
}
switch ($action) {
case '':
list_files($user, "");
break;
case 'upload_file':
upload_file($user);
break;
case 'delete_file':
delete_file($user);
break;
case 'download_file':
download_file($user);
break;
case 'view_file':
view_file($user);
break;
default:
error_page("no such action: {$action}");
}
示例14: DOMPDF
<td>' . $row['dia'] . '</td>
<td>' . $row['total'] . '</td>
<td>' . $row['hr'] . '</td>
<td>' . $row['descueto'] . '</td>
</tr>';
}
$codigoHTML .= '
</table>
</div>
</body>
</html>';
$dompdf = new DOMPDF();
$dompdf->load_html($codigoHTML);
$dompdf->render();
file_put_contents('./reportes/reporte.pdf', $dompdf->output());
download_file("reportes/reporte.pdf", "reporte4.pdf");
} else {
echo "<script>\r\n\t\t\t\t\t\t\t swal(\"!Vacio¡\", \"No hay datos\", \"warning\");\r\n\t\t\t\t\t\t\t </script>";
}
$conn->close();
}
?>
<hr>
<center>
<table id="tabla1" border="1" width="100%">
<tr>
<th>Nombre</th>
<th>Dias laborados</th>
<th>Total (Q)</th>
<th>Total (hr)</th>
<th>Total descuentos(Q)</th>
示例15: downloadFromHttp
function downloadFromHttp()
{
$file = basename($this->main->download_url_f);
if (!$file) {
throw new lxexception('please_type_the_full_url_including_file_name', '');
}
$fullpath = $this->main->getFullPath() . "/" . $file;
check_file_if_owned_by_and_throw($fullpath, $this->main->__username_o);
if (lxfile_exists($fullpath) && !$this->main->isOn('download_overwrite_f')) {
throw new lxexception('file_exists', '', $file);
}
download_file($this->main->download_url_f, $fullpath);
return $fullpath;
}