/** * 压缩文件(zip格式) */ public function tozip($items) { $zip = new ZipArchive(); $zipname = date('YmdHis', time()); if (!file_exists($zipname)) { $zip->open($savepath . $zipname . '.zip', ZipArchive::OVERWRITE); //创建一个空的zip文件 for ($i = 0; $i < count($items); $i++) { $zip->addFile($this->currentdir . '/' . $items[$i], $items[$i]); } $zip->close(); $dw = new download($zipname . '.zip', $savepath); //下载文件 $dw->getfiles(); unlink($savepath . $zipname . '.zip'); //下载完成后要进行删除 } }
/** * Render content of main page. */ public function render() { // Attach widgets to the view to render them in the view. $this->view->account = account::getInstance(); $this->view->device = device::getInstance(); $this->view->download = download::getInstance(); $this->_render(); exit; }
function isImageFile($afile) { // Added by hoshiba-farm.com 2006.03.02 $t = "/^" . ereg_replace("/", "\\/", XOOPS_ROOT_PATH) . ereg_replace("/", "\\/", $GLOBALS['BlogCNF']['thumb_dir']) . "(.+\\.(gif|jpe?g|png|bmp)\$)/i"; $o = "/^" . ereg_replace("/", "\\/", XOOPS_ROOT_PATH) . ereg_replace("/", "\\/", $GLOBALS['BlogCNF']['img_dir']) . "(.+\\.(gif|jpe?g|png|bmp)\$)/i"; if (preg_match($t, $afile, $ss) || preg_match($o, $afile, $ss)) { $res = download::get_original_name($ss[count($ss) - 2]); // thumbnail file } else { $res = null; } return $res; }
function adminDownload() { global $pref; parent::download(); $this->userclassOptions = 'blank,nobody,guest,public,main,admin,member,classes'; // Save basic search string if (isset($_POST['download-search-text'])) { $this->searchField = $_POST['download-search-text']; } // Save advanced search criteria if (isset($_POST['download_advanced_search_submit'])) { $this->advancedSearchFields = $_POST['download_advanced_search']; } }
public function search($type, $query) { $result = ""; if ($type == "samples") { $result = Sample::where('title', 'LIKE', "%{$query}%")->paginate(24); } elseif ($type == "blogs") { $result = Blog::where('title', 'LIKE', "%{$query}%")->paginate(24); } elseif ($type == "downloads") { $result = download::where('title', 'LIKE', "%{$query}%")->paginate(24); } else { return redirect()->route('home')->with('error', 'مشکل در جستجو دوباره تلاش کنید'); } $type = str_singular($type); return view('search', compact('result', 'type')); }
public function send($id) { $item = ORM::factory("item", $id); access::required("view_full", $item); if (module::is_active("keeporiginal") && $item->is_photo() && module::get_var("downloadfullsize", "DownloadOriginalImage")) { $original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path()); if (file_exists($original_image)) { download::force($original_image); } else { download::force($item->file_path()); } } else { download::force($item->file_path()); } }
function create_download() { $action = $this->action; $subAction = $this->subAction; $id = $this->id; $sql = e107::getDb(); $tp = e107::getParser(); $fl = e107::getFile(); $mes = e107::getMessage(); // print_a($this); global $e107, $cal, $rs, $ns, $file_array, $image_array, $thumb_array; require_once e_PLUGIN . 'download/download_shortcodes.php'; require_once e_PLUGIN . 'download/handlers/download_class.php'; require_once e_HANDLER . "form_handler.php"; $download = new download(); if ($file_array = $fl->get_files(e_DOWNLOAD, "", "standard", 5)) { sort($file_array); } if ($public_array = $fl->get_files(e_UPLOAD)) { foreach ($public_array as $key => $val) { $file_array[] = str_replace(e_UPLOAD, "", $val); } } /* if ($sql->select("rbinary")) //TODO Remove me. { while ($row = $sql->fetch()) { extract($row); $file_array[] = "Binary ".$binary_id."/".$binary_name; } } */ if ($image_array = $fl->get_files(e_FILE . 'downloadimages/', '\\.gif$|\\.jpg$|\\.png$|\\.GIF$|\\.JPG$|\\.PNG$', 'standard', 2)) { sort($image_array); } if ($thumb_array = $fl->get_files(e_FILE . 'downloadthumbs/', '\\.gif$|\\.jpg$|\\.png$|\\.GIF$|\\.JPG$|\\.PNG$', 'standard', 2)) { sort($thumb_array); } $frm = new e_form(); $mirrorArray = array(); $download_status[0] = DOWLAN_122; $download_status[1] = DOWLAN_123; $download_status[2] = DOWLAN_124; if (!$sql->select("download_category")) { //$ns->tablerender(ADLAN_24, "<div style='text-align:center'>".DOWLAN_5."</div>"); $mes->addInfo(DOWLAN_5); return; } $download_active = 1; if ($_GET['action'] == "edit" && !$_POST['submit']) { if ($sql->select("download", "*", "download_id=" . intval($_GET['id']))) { $row = $sql->fetch(); extract($row); $mirrorArray = $this->makeMirrorArray($row['download_mirror']); } } if ($subAction == "dlm" && !$_POST['submit']) { require_once e_PLUGIN . 'download/download_shortcodes.php'; if ($sql->select("upload", "*", "upload_id=" . $id)) { $row = $sql->fetch(); $download_category = $row['upload_category']; $download_name = $row['upload_name'] . ($row['upload_version'] ? " v" . $row['upload_version'] : ""); $download_url = $row['upload_file']; $download_author_email = $row['upload_email']; $download_author_website = $row['upload_website']; $download_description = $row['upload_description']; $download_image = $row['upload_ss']; $download_filesize = $row['upload_filesize']; $image_array[] = array("path" => "", "fname" => $row['upload_ss']); $download_author = substr($row['upload_poster'], strpos($row['upload_poster'], ".") + 1); } } $text = "\n\t \n\t <ul class='nav nav-tabs'>\n\t <li class='active'><a data-toggle='tab' href='#download-create'>" . DOWLAN_175 . "</a></li>\n\t <li><a data-toggle='tab' href='#download-edit-external'>" . DOWLAN_176 . "</a></li>\n\t <li><a data-toggle='tab' href='#download-edit-mirror'>" . DOWLAN_128 . "</a></li>\n\t </ul>\n\t <form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='myform'>\n\t <div class='tab-content'>\n\t <div class='tab-pane active' id='download-create'>\n\t \n\t \n\t <table class='table adminform' style='margin:0'>\n\t <tr>\n\t <td>" . DOWLAN_13 . "</td>\n\t <td style='width:80%'>\n\t <div>" . DOWLAN_131 . " "; // $text .= "<select name='download_url' class='tbox'> // <option value=''> </option>\n"; $counter = 0; while (isset($file_array[$counter])) { $fpath = str_replace(e_DOWNLOAD, "", $file_array[$counter]['path']) . $file_array[$counter]['fname']; $selected = ''; if (stristr($fpath, $download_url) !== FALSE) { $selected = " selected='selected'"; $found = 1; } // $text .= "<option value='".$fpath."' $selected>".$fpath."</option>\n"; $counter++; } if (preg_match("/http:|https:|ftp:/", $download_url)) { $download_url_external = $download_url; $download_url = ''; } $etext = " - (" . DOWLAN_68 . ")"; if (file_exists(e_UPLOAD . $download_url)) { $etext = ""; } if (!$found && $download_url) { // $text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n"; } // $text .= " </select>"; $text .= e107::getForm()->filepicker("download_url", $download_url, DOWLAN_131, "media=download_file&title=Choose a file"); $text .= "\n\t </div>\n\t </td>\n\t </tr>\n\t </table>\n\t </div>\n\t <div class='tab-pane' id='download-edit-external'>\n\t <table class='table adminform' style='margin:0'>\n\t <tr>\n\t <td>" . DOWLAN_149 . "</td>\n\t <td style='width:80%;'>\n\t <input class='tbox input-xxlarge' type='text' name='download_url_external' size='90' value='{$download_url_external}' maxlength='255'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td>" . DOWLAN_66 . "</td>\n\t <td>\n\t <input class='tbox' type='text' name='download_filesize_external' size='8' value='{$download_filesize}' maxlength='10'/>\n\t \t <select class='tbox' name='download_filesize_unit'>\n\t\t\t\t\t\t <option value='B'{$b_sel}>" . CORE_LAN_B . "</option>\n\t\t\t\t\t\t <option value='KB'{$kb_sel}>" . CORE_LAN_KB . "</option>\n\t\t\t\t\t\t <option value='MB'>" . CORE_LAN_MB . "</option>\n\t\t\t\t\t\t <option value='GB'>" . CORE_LAN_GB . "</option>\n\t\t\t\t\t\t <option value='TB'>" . CORE_LAN_TB . "</option>\n\t\t\t\t\t\t\t </select>\n\t </td>\n\t </tr>\n\t </table>\n\t </div>\n\t <div class='tab-pane' id='download-edit-mirror'>\n\t <table class='table adminlist'>\n\t <tr>\n\t <td style='width:20%'><span title='" . DOWLAN_129 . "' style='cursor:help'>" . DOWLAN_128 . "</span></td>\n\t <td style='width:80%'>"; // See if any mirrors to display if (!$sql->select("download_mirror")) { // No mirrors defined here $text .= DOWLAN_144 . "</td></tr>"; } else { $text .= DOWLAN_132 . "<div id='mirrorsection'>"; $mirrorList = $sql->db_getList(); // Get the list of possible mirrors $m_count = count($mirrorArray) ? count($mirrorArray) : 1; // Count of mirrors actually in use (or count of 1 if none defined yet) for ($count = 1; $count <= $m_count; $count++) { $opt = $count == 1 ? "id='mirror'" : ""; $text .= "\n\t <div {$opt}>\n\t <select name='download_mirror_name[]' class='tbox'>\n\t <option value=''> </option>"; foreach ($mirrorList as $mirror) { extract($mirror); $text .= "<option value='{$mirror_id}'" . ($mirror_id == $mirrorArray[$count - 1]['id'] ? " selected='selected'" : "") . ">{$mirror_name}</option>\n"; } $text .= "</select>\n\t <input class='tbox' type='text' name='download_mirror[]' style='width: 60%;' value=\"" . $mirrorArray[$count - 1]['url'] . "\" maxlength='200'/>\n\t <input class='tbox' type='text' name='download_mirror_size[]' style='width: 15%;' value=\"" . $mirrorArray[$count - 1]['filesize'] . "\" maxlength='10'/>"; if (DOWNLOAD_DEBUG) { if ($id) { $text .= '(' . $mirrorArray[$count - 1]['requests'] . ')'; } else { $text .= "<input class='tbox' type='text' name='download_mirror_requests[]' style='width: 10%;' value=\"" . $mirrorArray[$count - 1]['requests'] . "\" maxlength='10'/>"; } } $text .= " </div>"; } $text .= " </div>\n\t <input class='btn btn-default button' type='button' name='addoption' value='" . DOWLAN_130 . "' onclick=\"duplicateHTML('mirror','mirrorsection')\"/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%' ><span style='cursor:help' title='" . DOWLAN_154 . "'>" . DOWLAN_155 . "</span></td>\n\t <td style='width:80%'>\n\t <input type='radio' name='download_mirror_type' value='1'" . ($download_mirror_type ? " checked='checked'" : "") . "/> " . DOWLAN_156 . "<br/>\n\t <input type='radio' name='download_mirror_type' value='0'" . (!$download_mirror_type ? " checked='checked'" : "") . "/> " . DOWLAN_157 . "\n\t </td>\n\t </tr>"; } // End of mirror-related stuff $download_author = $subAction != "edit" && $download_author == "" ? USERNAME : $download_author; //TODO what if editing an no author specified $download_author_email = $subAction != "edit" && $download_author_email == "" ? USEREMAIL : $download_author_email; $text .= "\n\t </table>\n\t </div>\n\t </div>\n\t <fieldset id='download-edit-therest'>\n\t <table class='table adminform' >\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_11 . "</td>\n\t <td style='width:80%'>"; $text .= $download->getCategorySelectList($download_category); // $text .= download::getCategorySelectList($download_category); $text .= " </td>\n\t </tr>\n\t <tr>\n\t <td >" . DOWLAN_12 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox input-xxlarge' type='text' name='download_name' size='60' value=\"" . $tp->toForm($download_name) . "\" maxlength='200'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_15 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author' size='60' value='{$download_author}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_16 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author_email' size='60' value='{$download_author_email}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_17 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author_website' size='60' value='{$download_author_website}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_18 . "</td>\n\t <td style='width:80%'>\n\t "; $text .= $frm->bbarea('download_description', $download_description); $text .= " </td>\n\t </tr>\n\t \n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_19 . "</td>\n\t <td style='width:80%'>"; /* $text = "<select name='download_image' class='tbox'> <option value=''> </option>"; foreach($image_array as $img) { $fpath = str_replace(e_FILE."downloadimages/","",$img['path'].$img['fname']); $sel = ($download_image == $fpath) ? " selected='selected'" : ""; $text .= "<option value='".$fpath."' $sel>".$fpath."</option>\n"; } $text .= " </select>"; */ $text .= $frm->imagepicker('download_image', $download_image, '', 'download_image'); if ($subAction == "dlm" && $download_image) { $text .= "\n\t <input type='hidden' name='move_image' value='1'/>\n"; } $text .= " </td>\n\t </tr>"; if (is_dir(e_FILE . "downloadthumbs")) { $text .= "\n\t <tr>\n\t\t\t <td style='width:20%'>" . DOWLAN_20 . "</td>\n\t\t\t <td style='width:80%'>"; /* $text .= " <select name='download_thumb' class='tbox'> <option value=''> </option>"; foreach($thumb_array as $thm){ $tpath = str_replace(e_FILE."downloadthumbs/","",$thm['path'].$thm['fname']); $sel = ($download_thumb == $tpath) ? " selected='selected'" : ""; $text .= "<option value='".$tpath."' $sel>".$tpath."</option>\n"; } $text .= " </select>"; */ $text .= $frm->imagepicker('download_thumb', $download_thumb, '', 'download_thumb'); $text .= "\n\t\t\t </td>\n\t\t\t </tr>"; } $text .= "\n\t <tr>\n\t <td style='width:20%'>" . LAN_DATESTAMP . "</td>\n\t <td style='width:80%'>"; if (!$download_datestamp) { $download_datestamp = time(); } $text .= $frm->datepicker('download_datestamp', $download_datestamp); // $update_checked = ($_POST['update_datestamp']) ? "checked='checked'" : ""; // $text .= " <span><input type='checkbox' value='1' name='update_datestamp' $update_checked/>".DOWLAN_148."</span>"; $text .= "\n\t </td>\n\t </tr>\n\t \n\t \t\t\t <tr>\n\t <td >" . LAN_SEFURL . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox input-xxlarge' type='text' name='download_sef' size='60' value=\"" . $tp->toForm($download_sef) . "\" maxlength='250'/>\n\t </td>\n\t </tr> \n\t \n\t \n\t <tr>\n\t <td >" . LAN_KEYWORDS . "</td>\n\t <td style='width:80%'>" . $frm->tags('download_keywords', $download_keywords) . "\n\t \n\t </td>\n\t </tr> \n\t \n\t\t\t\t\t \n\t \n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_21 . "</td>\n\t <td style='width:80%'>\n\t <select name='download_active' class='tbox'>"; foreach ($download_status as $key => $val) { $sel = $download_active == $key ? " selected = 'selected' " : ""; $text .= "<option value='{$key}' {$sel}>{$val}</option>\n"; } $text .= " </select>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_102 . "</td>\n\t <td style='width:80%'>"; if ($download_comment == "0") { $text .= LAN_YES . ": <input type='radio' name='download_comment' value='1'/>\n\t " . LAN_NO . ": <input type='radio' name='download_comment' value='0' checked='checked'/>"; } else { $text .= LAN_YES . ": <input type='radio' name='download_comment' value='1' checked='checked'/>\n\t " . LAN_NO . ": <input type='radio' name='download_comment' value='0'/>"; } $text .= " </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_145 . "</td>\n\t <td style='width:80%'>" . r_userclass('download_visible', $download_visible, 'off', 'public, nobody, member, admin, classes, language') . "</td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_106 . "</td>\n\t <td style='width:80%'>" . r_userclass('download_class', $download_class, 'off', 'public, nobody, member, admin, classes, language') . "</td>\n\t </tr>"; if ($subAction == "dlm") { $text .= "\n\t <tr>\n\t <td style='width:30%'>" . DOWLAN_153 . "</td>\n\t <td style='width:70%'>\n\t <select name='move_file' class='tbox'>\n\t <option value=''>" . LAN_NO . "</option>"; $dl_dirlist = $fl->get_dirs(e_DOWNLOAD); if ($dl_dirlist) { sort($dl_dirlist); $text .= "<option value='" . e_DOWNLOAD . "'>/</option>\n"; foreach ($dl_dirlist as $dirs) { $text .= "<option value='" . e_DOWNLOAD . $dirs . "/'>" . $dirs . "/</option>\n"; } } else { $text .= "<option value='" . e_DOWNLOAD . "'>" . LAN_YES . "</option>\n"; } $text .= " </select>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:30%'>" . DOWLAN_103 . "</td>\n\t <td style='width:70%'>\n\t <input type='checkbox' name='remove_upload' value='1'/>\n\t <input type='hidden' name='remove_id' value='{$id}'/>\n\t </td>\n\t </tr>"; } //triggerHook $data = array('method' => 'form', 'table' => 'download', 'id' => $id, 'plugin' => 'download', 'function' => 'create_download'); $text .= $frm->renderHooks($data); $text .= "\n\t \t \n\t </table>\n\t <div class='buttonsbar center'>"; if ($id && $subAction == "edit") { $text .= "<input class='btn btn-default button' type='submit' name='submit_download' value='" . DOWLAN_24 . "'/> "; } else { $text .= "<input class='btn btn-default button' type='submit' name='submit_download' value='" . DOWLAN_25 . "'/>"; } $text .= "\n\t </div>\n\t \n\t </fieldset>\n\t </form>\n\t \n\t \n\t "; // $ns->tablerender(ADLAN_24, $text); echo $text; }
if(file_exists($file)) { $len = filesize($file); $filename = "performance_status_report_$user_id.txt"; header("content-type: application/stream"); header("content-length: $len"); header("content-disposition: attachment; filename=$filename"); $fp=fopen($file,"r"); fpassthru($fp); exit; } else { $str=<<<EOD <script> alert( '$err[cEmptyrecords]' ); window.location=document.referrer; </script> EOD; echo $str; } } }//end class $ob = new download; $ob->download_file($db_object,$common,$user_id,$uid,$default,$error_msg); ?>
/** * Test CSV Download * @test */ public function testDownloadCSV() { // Test to ensure validation passed $this->assertEquals(TRUE, download::validate($this->post), 'Report download validation failed'); // If we have no reports if (count($this->incident) == 0) { $this->markTestSkipped('There are no reports, CSV Download test skipped'); } $expected_csv_content = "\"#\",\"FORM #\",\"INCIDENT TITLE\",\"INCIDENT DATE\""; // Include location information? if (in_array(1, $this->post['data_include'])) { $expected_csv_content .= ",\"LOCATION\""; } // Include description information? if (in_array(2, $this->post['data_include'])) { $expected_csv_content .= ",\"DESCRIPTION\""; } // Include category information? if (in_array(3, $this->post['data_include'])) { $expected_csv_content .= ",\"CATEGORY\""; } // Include latitude information? if (in_array(4, $this->post['data_include'])) { $expected_csv_content .= ",\"LATITUDE\""; } // Include longitude information? if (in_array(5, $this->post['data_include'])) { $expected_csv_content .= ",\"LONGITUDE\""; } // Include custom forms information? if (in_array(6, $this->post['data_include'])) { foreach ($this->custom_forms as $field_name) { $expected_csv_content .= ",\"" . $field_name['field_name'] . "-" . $field_name['form_id'] . "\""; } } // Include personal information? if (in_array(7, $this->post['data_include'])) { $expected_csv_content .= ",\"FIRST NAME\",\"LAST NAME\",\"EMAIL\""; } $expected_csv_content .= ",\"APPROVED\",\"VERIFIED\""; $expected_csv_content .= "\r\n"; // Add Report information $report = $this->incident[0]; // Report id, form_id, title, and date $expected_csv_content .= '"' . $report->id . '",' . '"' . $report->form_id . '",' . '"' . $report->incident_title . '",' . '"' . $report->incident_date . '"'; // Include location information? if (in_array(1, $this->post['data_include'])) { $expected_csv_content .= ',"' . $report->location->location_name . '"'; } // Include description information? if (in_array(2, $this->post['data_include'])) { $expected_csv_content .= ',"' . $report->incident_description . '"'; } // Include category information? if (in_array(3, $this->post['data_include'])) { $cat = array(); foreach ($report->incident_category as $category) { if ($category->category->category_title) { $cat[] = $category->category->category_title; } } $expected_csv_content .= ',"' . implode($cat, ',') . '"'; } // Include latitude information? if (in_array(4, $this->post['data_include'])) { $expected_csv_content .= ',"' . $report->location->latitude . '"'; } // Include longitude information? if (in_array(5, $this->post['data_include'])) { $expected_csv_content .= ',"' . $report->location->longitude . '"'; } // Include custom forms information? if (in_array(6, $this->post['data_include'])) { $custom_fields = customforms::get_custom_form_fields($report->id, '', false); if (!empty($custom_fields)) { foreach ($custom_fields as $custom_field) { $expected_csv_content .= ',"' . $custom_field['field_response'] . '"'; } } else { foreach ($this->custom_forms as $custom) { $expected_csv_content .= ',""'; } } } // Include personal information? if (in_array(7, $this->post['data_include'])) { $person = $report->incident_person; if ($person->loaded) { $expected_csv_content .= ',"' . $person->person_first . '"' . ',"' . $person->person_last . '"' . ',"' . $person->person_email . '"'; } else { $expected_csv_content .= ',""' . ',""' . ',""'; } } // Approved status if ($report->incident_active) { $expected_csv_content .= ",\"YES\""; } else { $expected_csv_content .= ",\"NO\""; } // Verified Status if ($report->incident_verified) { $expected_csv_content .= ",\"YES\""; } else { $expected_csv_content .= ",\"NO\""; } // End Expected output $expected_csv_content .= "\r\n"; // Grab actual output $actual_csv_content = download::download_csv($this->post, $this->incident, $this->custom_forms); // Test CSV Output $this->assertEquals($expected_csv_content, $actual_csv_content, 'CSV Download failed. Content mismatch'); }
<?php if (tg('id') != 0) { global $db; $sql = "SELECT img,titr" . LANG . " as titre from document where id=" . tg('id') . " and titr" . LANG . " IS NOT NULL limit 0,1 "; if (!$db->Query($sql)) { $db->Kill($sql); } if ($db->RowCount() > 0) { $array = $db->RowArray(); $file = $array['img']; $ext = '.' . str_replace(".", "", strrchr($array['img'], '.')); $titrefile = fl($array['titre']) . $ext; $download_path = "upload/doc/"; $args = array('download_path' => $download_path, 'file' => $file, 'extension_check' => FALSE, 'referrer_check' => FALSE, 'referrer' => NULL); $download = new download($args); /* |----------------- | Pre Download Hook |------------------ */ $download_hook = $download->get_download_hook(); //$download->chip_print($download_hook); //exit; /* |----------------- | Download |------------------ */ if ($download_hook['download'] == TRUE) { /* You can write your logic before proceeding to download */
/** * Forces a download of a created archive. * * @param string name of the file that will be downloaded * @return void */ public function download($filename) { download::force($filename, $this->driver->create($this->paths)); }
$_SERVER['HTTP_REFERER'] = reset_url($_SERVER['HTTP_REFERER']); $_SERVER['HTTP_HOST'] = reset_url($_SERVER['HTTP_HOST']); if ($_SERVER['HTTP_HOST'] != $_SERVER['HTTP_REFERER']) { @header('Location: ' . $config['http_home_url']); die("Access denied!!!<br /><br />Please visit <a href=\"{$config['http_home_url']}\">{$config['http_home_url']}</a>"); } } $id = intval($_REQUEST['id']); if ($_REQUEST['area'] == "static") { $row = $db->super_query("SELECT name, onserver FROM " . PREFIX . "_static_files WHERE id ='{$id}'"); } else { $row = $db->super_query("SELECT name, onserver FROM " . PREFIX . "_files WHERE id ='{$id}'"); } if (!$row) { die("Access denied"); } $config['files_max_speed'] = intval($config['files_max_speed']); $row['onserver'] = totranslit($row['onserver'], false); $file = new download(FILE_DIR . $row['onserver'], $row['name'], $config['files_force'], $config['files_max_speed']); if ($_REQUEST['area'] == "static") { if ($config['files_count'] == "yes" and !$file->range) { $db->query("UPDATE " . PREFIX . "_static_files SET dcount=dcount+1 WHERE id ='{$id}'"); } } else { if ($config['files_count'] == "yes" and !$file->range) { $db->query("UPDATE " . PREFIX . "_files SET dcount=dcount+1 WHERE id ='{$id}'"); } } $db->close(); session_write_close(); $file->download_file();
/** * Download Reports in CSV format * JP: Added filter by search option. Also added HTML download. */ public function download() { // If user doesn't have access, redirect to dashboard if (!$this->auth->has_permission("reports_download")) { url::redirect(url::site() . 'admin/dashboard'); } $this->template->content = new View('admin/reports/download'); $this->template->content->title = Kohana::lang('ui_admin.download_reports'); $errors = $form = array('format' => '', 'data_active' => array(), 'data_verified' => array(), 'data_include' => array(), 'from_date' => '', 'to_date' => '', 'form_auth_token' => '', 'filter_search' => ''); // Default to all selected $form['data_active'] = array(0, 1); $form['data_verified'] = array(0, 1); $form['data_include'] = array(1, 2, 3, 4, 5, 6, 7); $form_error = FALSE; // Check, has the form been submitted, if so, setup validation if ($_POST) { // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things $post = array_merge($_POST, $_FILES); // Test to see if things passed the rule checks if (download::validate($post)) { // Set filter $filter = '( '; // Report Type Filter $show_active = FALSE; $show_inactive = FALSE; $show_verified = FALSE; $show_not_verified = FALSE; $filter_search = FALSE; if (in_array(1, $post->data_active)) { $show_active = TRUE; } if (in_array(0, $post->data_active)) { $show_inactive = TRUE; } if (in_array(1, $post->data_verified)) { $show_verified = TRUE; } if (in_array(0, $post->data_verified)) { $show_not_verified = TRUE; } if (!empty($post->filter_search)) { $filter_search = TRUE; } // Handle active or not active if ($show_active && !$show_inactive) { $filter .= ' incident_active = 1 '; } elseif (!$show_active && $show_inactive) { $filter .= ' incident_active = 0 '; } elseif ($show_active && $show_inactive) { $filter .= ' (incident_active = 1 OR incident_active = 0) '; } elseif (!$show_active && !$show_inactive) { // Equivalent to 1 = 0 $filter .= ' (incident_active = 0 AND incident_active = 1) '; } $filter .= ' AND '; // Handle verified if ($show_verified && !$show_not_verified) { $filter .= ' incident_verified = 1 '; } elseif (!$show_verified && $show_not_verified) { $filter .= ' incident_verified = 0 '; } elseif ($show_verified && $show_not_verified) { $filter .= ' (incident_verified = 0 OR incident_verified = 1) '; } elseif (!$show_verified && !$show_not_verified) { $filter .= ' (incident_verified = 0 AND incident_verified = 1) '; } $filter .= ') '; // Report Date Filter if (!empty($post->from_date)) { $filter .= " AND incident_date >= '" . date("Y-m-d H:i:s", strtotime($post->from_date)) . "' "; } if (!empty($post->to_date)) { $filter .= " AND incident_date <= '" . date("Y-m-d H:i:s", strtotime($post->to_date)) . "' "; } // JP: Search Filter if ($filter_search) { $where_string = ""; $or = ""; // Stop words that we won't search for // Add words as needed!! $stop_words = array('the', 'and', 'a', 'to', 'of', 'in', 'i', 'is', 'that', 'it', 'on', 'you', 'this', 'for', 'but', 'with', 'are', 'have', 'be', 'at', 'or', 'as', 'was', 'so', 'if', 'out', 'not'); // Phase 1 - Fetch the search string and perform initial sanitization $keyword_raw = preg_replace('#/\\w+/#', '', $post->filter_search); // Phase 2 - Strip the search string of any HTML and PHP tags that may be present for additional safety $keyword_raw = strip_tags($keyword_raw); // Phase 3 - Apply Kohana's XSS cleaning mechanism $keyword_raw = $this->input->xss_clean($keyword_raw); // Database instance $db = new Database(); $keywords = explode(' ', $keyword_raw); if (is_array($keywords) and !empty($keywords)) { array_change_key_case($keywords, CASE_LOWER); $i = 0; foreach ($keywords as $value) { if (!in_array($value, $stop_words) and !empty($value)) { // Escape the string for query safety $chunk = $db->escape_str($value); if ($i > 0) { $or = ' OR '; } $where_string = $where_string . $or . "(incident_title LIKE '%{$chunk}%' OR incident_description LIKE '%{$chunk}%')"; $i++; } } } $filter .= " AND " . $where_string; } // Retrieve reports $incidents = ORM::factory('incident')->where($filter)->orderby('incident_dateadd', 'desc')->find_all(); // Retrieve categories $categories = Category_Model::get_categories(FALSE, FALSE, FALSE); // Retrieve Forms $forms = ORM::Factory('form')->find_all(); // Retrieve Custom forms $custom_forms = customforms::get_custom_form_fields(); // If CSV format is selected if ($post->format == 'csv') { $report_csv = download::download_csv($post, $incidents, $custom_forms); // Output to browser header("Content-type: text/x-csv"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=" . time() . ".csv"); header("Content-Length: " . strlen($report_csv)); echo $report_csv; exit; } // If XML format is selected if ($post->format == 'xml') { header('Content-type: text/xml; charset=UTF-8'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=" . time() . ".xml"); $content = download::download_xml($post, $incidents, $categories, $forms); echo $content; exit; } // JP: If HTML format is selected... if ($post->format == 'html') { $content = download::download_html($post, $incidents, $custom_forms); header("Content-type: text/html; charset=UTF-8"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=" . time() . ".html"); header("Content-Length: " . strlen($content)); echo $content; exit; } } else { // Repopulate the form fields $form = arr::overwrite($form, $post->as_array()); // Populate the error fields, if any $errors = arr::merge($errors, $post->errors('report')); $form_error = TRUE; } } $this->template->content->form = $form; $this->template->content->errors = $errors; $this->template->content->form_error = $form_error; // Javascript Header $this->themes->js = new View('admin/reports/download_js'); $this->themes->js->calendar_img = url::base() . "media/img/icon-calendar.gif"; }
/** * Force the download of a file by the user's browser by preventing any * caching. Contains a workaround for Internet Explorer. * * @link http://support.microsoft.com/kb/316431 * @link http://support.microsoft.com/kb/812935 * * @uses download::dialog() * @uses download::send() * * @param string a file path or file name * @param mixed data to be sent if the filename does not exist * @param string suggested filename to display in the download * @return void */ public static function force($filename = NULL, $data = NULL, $nicename = NULL) { download::dialog(empty($nicename) ? $filename : $nicename); // Prevent caching header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); if (request::user_agent('browser') === 'Internet Explorer' and request::user_agent('version') <= '6.0') { // HTTP 1.0 header('Pragma:'); // HTTP 1.1 with IE extensions header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); } else { // HTTP 1.0 header('Pragma: no-cache'); // HTTP 1.1 header('Cache-Control: no-cache, max-age=0'); } if (is_file($filename)) { download::send($filename); } else { download::send($filename, $data); } }
public function send($id) { $item = ORM::factory("item", $id); access::required("view_full", $item); download::force($item->file_path()); }
* Copyright (C) 2008-2013 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * */ if (!defined('e107_INIT')) { require_once "../../class2.php"; } if (!e107::isInstalled('download')) { header("location:" . e_BASE . "index.php"); } e107::lan('download', false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php' require_once e_PLUGIN . 'download/handlers/download_class.php'; require_once e_PLUGIN . 'download/handlers/category_class.php'; $dl = new download(); if (!defined("USER_WIDTH") && !deftrue('BOOTSTRAP')) { define("USER_WIDTH", "width:100%"); } /* define images */ if (deftrue('BOOTSTRAP')) { define("IMAGE_DOWNLOAD", file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : e_IMAGE . "generic/download.png"); define("IMAGE_NEW", file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : 'icon-star.glyph'); } else { define("IMAGE_DOWNLOAD", file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : e_IMAGE . "generic/download.png"); define("IMAGE_NEW", file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : e_IMAGE . "generic/new.png"); } $dl->init(); // Legacy Comment Save. if (isset($_POST['commentsubmit'])) { if (!$sql->select("download", "download_comment", "download_id = '{$id}' ")) {
function showMaint() { $mes = e107::getMessage(); $mes->addInfo("Deprecated Area - please use filter instead under 'Manage' "); global $pref; $ns = e107::getRender(); $sql = e107::getDb(); $frm = e107::getForm(); $tp = e107::getParser(); if (isset($_POST['dl_maint'])) { switch ($_POST['dl_maint']) { case 'duplicates': $title = DOWLAN_166; $query = 'SELECT GROUP_CONCAT(d.download_id SEPARATOR ",") as gc, d.download_id, d.download_name, d.download_url, dc.download_category_name FROM #download as d LEFT JOIN #download_category AS dc ON dc.download_category_id=d.download_category GROUP BY d.download_url HAVING COUNT(d.download_id) > 1 '; $text = ""; $count = $sql->db_Select_gen($query); $foundSome = false; if ($count) { $currentURL = ""; while ($row = $sql->db_Fetch()) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . DOWLAN_67 . '</th>'; $text .= '<th>' . DOWLAN_27 . '</th>'; $text .= '<th>' . DOWLAN_11 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $query = "SELECT d.*, dc.* FROM `#download` AS d\n LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category\n WHERE download_id IN (" . $row['gc'] . ")\n ORDER BY download_id ASC"; $count = $sql2->db_Select_gen($query); while ($row = $sql2->db_Fetch()) { $text .= '<tr>'; if ($currentURL != $row['download_url']) { $text .= '<td>' . $tp->toHTML($row['download_url']) . '</td>'; $currentURL = $row['download_url']; } else { $text .= '<td>*</td>'; } $text .= '<td>' . $row['download_id'] . '</td>'; $text .= "<td><a href='" . e_PLUGIN . "download/download.php?view." . $row['download_id'] . "'>" . $e107->tp->toHTML($row['download_name']) . '</a></td>'; $text .= '<td>' . $tp->toHTML($row['download_category_name']) . '</td>'; $text .= '<td> <a href="' . e_SELF . '?create.edit.' . $row["download_id"] . '.maint.duplicates">' . ADMIN_EDIT_ICON . '</a> <input type="image" title="' . LAN_DELETE . '" name="delete[main_' . $row["download_id"] . ']" src="' . ADMIN_DELETE_ICON_PATH . '" onclick=\'return jsconfirm("' . $tp->toJS(DOWLAN_33 . ' [ID: ' . $row["download_id"] . ' ]') . '") \'/> </td>'; $text .= '</tr>'; } } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_172); } break; case 'orphans': $title = DOWLAN_167; $text = ""; require_once e_HANDLER . "file_class.php"; $efile = new e_file(); $files = $efile->get_files(e_DOWNLOAD); $foundSome = false; foreach ($files as $file) { if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='" . $file['fname'] . "'")) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . DOWLAN_182 . '</th>'; $text .= '<th>' . DOWLAN_66 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $filesize = is_readable(e_DOWNLOAD . $row['download_url']) ? $e107->parseMemorySize(filesize(e_DOWNLOAD . $file['fname'])) : DOWLAN_181; $filets = is_readable(e_DOWNLOAD . $row['download_url']) ? $gen->convert_date(filectime(e_DOWNLOAD . $file['fname']), "long") : DOWLAN_181; $text .= '<tr>'; $text .= '<td>' . $tp->toHTML($file['fname']) . '</td>'; $text .= '<td>' . $filets . '</td>'; $text .= '<td>' . $filesize . '</td>'; //TODO $text .= '<td> //TODO <a href="'.e_SELF.'?create.add.'. urlencode($file["fname"]).'">'.E_16_CREATE.'</a> //TODO <input type="image" title="'.LAN_DELETE.'" name="delete[main_'.$file["fname"].']" src="'.ADMIN_DELETE_ICON_PATH.'" onclick=\'return jsconfirm("'.$tp->toJS(DOWLAN_173.' [ '.$file["fname"].' ]').'") \'/> //TODO </td>'; $text .= '</tr>'; } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_174); } break; case 'missing': $title = DOWLAN_168; $text = ""; $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category"; $count = $sql->db_Select_gen($query); $foundSome = false; if ($count) { while ($row = $sql->db_Fetch()) { if (!is_readable(e_DOWNLOAD . $row['download_url'])) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_67 . '</th>'; $text .= '<th>' . DOWLAN_27 . '</th>'; $text .= '<th>' . DOWLAN_11 . '</th>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $text .= '<tr>'; $text .= '<td>' . $row['download_id'] . '</td>'; $text .= "<td><a href='" . e_PLUGIN . "download/download.php?view." . $row['download_id'] . "'>" . $tp->toHTML($row['download_name']) . '</a></td>'; $text .= '<td>' . $tp->toHTML($row['download_category_name']) . '</td>'; $text .= '<td>' . $tp->toHTML($row['download_url']) . '</td>'; $text .= '<td> <a href="' . e_SELF . '?create.edit.' . $row["download_id"] . '.maint.missing">' . ADMIN_EDIT_ICON . '</a> <input type="image" title="' . LAN_DELETE . '" name="delete[main_' . $row["download_id"] . ']" src="' . ADMIN_DELETE_ICON_PATH . '" onclick=\'return jsconfirm("' . $tp->toJS(DOWLAN_33 . ' [ID: ' . $row["download_id"] . ' ]') . '") \'/> </td>'; $text .= '</tr>'; } } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_172); // $text = DOWLAN_172; } break; case 'inactive': $title = DOWLAN_169; $text = ""; $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category WHERE download_active=0"; $count = $sql->db_Select_gen($query); $foundSome = false; if ($count) { while ($row = $sql->db_Fetch()) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_67 . '</th>'; $text .= '<th>' . DOWLAN_27 . '</th>'; $text .= '<th>' . DOWLAN_11 . '</th>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $text .= '<tr>'; $text .= '<td>' . $row['download_id'] . '</td>'; $text .= "<td><a href='" . e_PLUGIN . "download/download.php?view." . $row['download_id'] . "'>" . $e107->tp->toHTML($row['download_name']) . '</a></td>'; $text .= '<td>' . $e107->tp->toHTML($row['download_category_name']) . '</td>'; if (strlen($row['download_url']) > 0) { $text .= '<td>' . $row['download_url'] . '</td>'; } else { $mirrorArray = download::makeMirrorArray($row['download_mirror'], TRUE); $text .= '<td>'; foreach ($mirrorArray as $mirror) { $text .= $mirror['url'] . '<br/>'; } $text .= '</td>'; } $text .= '<td> <a href="' . e_SELF . '?create.edit.' . $row["download_id"] . '.maint.inactive">' . ADMIN_EDIT_ICON . '</a> <input type="image" title="' . LAN_DELETE . '" name="delete[main_' . $row["download_id"] . ']" src="' . ADMIN_DELETE_ICON_PATH . '" onclick=\'return jsconfirm("' . $tp->toJS(DOWLAN_33 . ' [ID: ' . $row["download_id"] . ' ]') . '") \'/> </td>'; $text .= '</tr>'; } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_172); // $text = DOWLAN_172; } break; case 'nocategory': $title = DOWLAN_178; $text = ""; $query = "SELECT * FROM `#download` WHERE download_category=0"; $count = $sql->db_Select_gen($query); $foundSome = false; if ($count) { while ($row = $sql->db_Fetch()) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= ' <form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_67 . '</th>'; $text .= '<th>' . DOWLAN_27 . '</th>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $text .= '<tr>'; $text .= '<td>' . $row['download_id'] . '</td>'; $text .= "<td><a href='" . e_PLUGIN . "download/download.php?view." . $row['download_id'] . "'>" . $e107->tp->toHTML($row['download_name']) . '</a></td>'; if (strlen($row['download_url']) > 0) { $text .= '<td>' . $e107->tp->toHTML($row['download_url']) . '</td>'; } else { $mirrorArray = download::makeMirrorArray($row['download_mirror'], TRUE); $text .= '<td>'; foreach ($mirrorArray as $mirror) { $text .= $mirror['url'] . '<br/>'; } $text .= '</td>'; } $text .= '<td> <a href="' . e_SELF . '?create.edit.' . $row["download_id"] . '.maint.nocategory">' . ADMIN_EDIT_ICON . '</a> <input type="image" title="' . LAN_DELETE . '" name="delete[main_' . $row["download_id"] . ']" src="' . ADMIN_DELETE_ICON_PATH . '" onclick=\'return jsconfirm("' . $tp->toJS(DOWLAN_33 . ' [ID: ' . $row["download_id"] . ' ]') . '") \'/> </td>'; $text .= '</tr>'; } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_172); // $text = DOWLAN_172; } break; case 'filesize': $title = DOWLAN_66; $text = ""; $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc.download_category_id=d.download_category WHERE d.download_url<>''"; $count = $sql->db_Select_gen($query); $foundSome = false; if ($count) { while ($row = $sql->db_Fetch()) { if (is_readable(e_DOWNLOAD . $row['download_url'])) { $filesize = filesize(e_DOWNLOAD . $row['download_url']); if ($filesize != $row['download_filesize']) { if (!$foundSome) { // $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= '<form method="post" action="' . e_SELF . '?' . e_QUERY . '" id="myform"> <table class="adminlist">'; $text .= '<tr>'; $text .= '<th>' . DOWLAN_67 . '</th>'; $text .= '<th>' . DOWLAN_27 . '</th>'; $text .= '<th>' . DOWLAN_11 . '</th>'; $text .= '<th>' . DOWLAN_13 . '</th>'; $text .= '<th>' . DOWLAN_180 . '</th>'; $text .= '<th>' . LAN_OPTIONS . '</th>'; $text .= '</tr>'; $foundSome = true; } $text .= '<tr>'; $text .= '<td>' . $row['download_id'] . '</td>'; $text .= "<td><a href='" . e_PLUGIN . "download/download.php?view." . $row['download_id'] . "'>" . $e107->tp->toHTML($row['download_name']) . '</a></td>'; $text .= '<td>' . $e107->tp->toHTML($row['download_category_name']) . '</td>'; $text .= '<td>' . $e107->tp->toHTML($row['download_url']) . '</td>'; $text .= '<td>' . $row['download_filesize'] . ' / '; $text .= $filesize; $text .= '</td>'; $text .= '<td> <a href="' . e_SELF . '?create.edit.' . $row["download_id"] . '.maint.filesize">' . ADMIN_EDIT_ICON . '</a> <input type="image" title="' . LAN_DELETE . '" name="delete[main_' . $row["download_id"] . ']" src="' . ADMIN_DELETE_ICON_PATH . '" onclick=\'return jsconfirm("' . $tp->toJS(DOWLAN_33 . ' [ID: ' . $row["download_id"] . ' ]') . '") \'/> </td>'; $text .= '</tr>'; } } } } if ($foundSome) { $text .= '</table></form>'; } else { e107::getMessage()->addInfo(DOWLAN_172); // $text = DOWLAN_172; } break; case 'log': $text = "log - view manage download history log"; header('location: ' . e_ADMIN . 'admin_log.php?downlog'); exit; break; } } else { $title = DOWLAN_193; $text = DOWLAN_179; $eform = new e_form(); $text = "\n \t<form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='core-db-main-form'>\n \t\t<fieldset id='core-db-plugin-scan'>\n \t\t<legend class='e-hideme'>" . DOWLAN_10 . "</legend>\n \t\t\t<table cellpadding='0' cellspacing='0' class='adminlist'>\n \t\t\t<colgroup span='2'>\n \t\t\t\t<col style='width: 40%'></col>\n \t\t\t\t<col style='width: 60%'></col>\n \t\t\t</colgroup>\n \t\t\t<tbody>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_166 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'duplicates') . $eform->label(DOWLAN_185, 'dl_maint', 'duplicates') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_167 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'orphans') . $eform->label(DOWLAN_186, 'dl_maint', 'orphans') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_168 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'missing') . $eform->label(DOWLAN_187, 'dl_maint', 'missing') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_169 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'inactive') . $eform->label(DOWLAN_188, 'dl_maint', 'inactive') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_178 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'nocategory') . $eform->label(DOWLAN_189, 'dl_maint', 'nocategory') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_66 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'filesize') . $eform->label(DOWLAN_190, 'dl_maint', 'filesize') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n \t\t\t\t<tr>\n \t\t\t\t\t<td>" . DOWLAN_171 . "</td>\n \t\t\t\t\t<td>\n \t\t\t\t\t\t" . $eform->radio('dl_maint', 'log') . $eform->label(DOWLAN_191, 'dl_maint', 'log') . "\n \t\t\t\t\t</td>\n \t\t\t\t</tr>\n\n \t\t\t\t</tbody>\n \t\t\t</table>\n \t\t\t<div class='buttons-bar center'>\n \t\t\t\t" . $eform->admin_button('trigger_db_execute', DOWLAN_192, 'execute') . "\n \t\t\t</div>\n \t\t</fieldset>\n \t</form>\n \t"; } echo $text; // $ns->tablerender(DOWLAN_165.$title, $text); }
fpassthru($fp); exit; } else { $str=<<<EOD <script> alert( '$err[cEmptyrecords]' ); window.location=document.referrer; </script> EOD; //echo $str; } } }//end class $ob = new download; $user_id=$_GET["user_id"]; $load=$_GET["load"]; $ob->download_file($db_object,$common,$user_id,$load); ?>
<?php include "../../../system.php"; include "../../system.php"; include "../../../function/new_function.php"; include "download_unit.php"; //System----------------------------------------------------------- $now_table = $pro_download_table; //System----------------------------------------------------------- $unit = new download(); $id = $_POST['id']; $unit->table = $now_table; $unit->id = $id; $unit->get_db_var(); $unit->del(); @unlink("../" . $unit->file); //刪除檔案
// if (preg_match("/^ed2k*:\\/\\//i", $url)) { echo "<html><head><meta http-equiv=\"Refresh\" content=\"0; URL=" . $myts->oopsHtmlSpecialChars($url) . "\"></meta></head><body></body></html>"; } // // From outside server // $xoopsurl = preg_replace("/\\//", "\\\\/", XOOPS_URL); if (!preg_match("/^" . $xoopsurl . "/i", $url)) { Header("Location: {$url}"); } // // From my server // $mb = new mb_func(); $down = new download($url); $filename = $down->fnameOnServer(); $ctype = $down->contentType(); $fpathname = XOOPS_ROOT_PATH . "/uploads/mydownloads/" . $down->fnameOnServer(); $fpathname = $mb->internal2x($fpathname, $xoopsModuleConfig['filename_code']); if (!file_exists($fpathname)) { redirect_header("brokenfile.php?lid={$lid}", 3, sprintf(_MD_FILEPATHNOTEXIST, $filename)); exit; } ob_clean(); $browser = $version = 0; UsrBrowserAgent($browser, $version); @ignore_user_abort(); @set_time_limit(0); if ($browser == 'IE' && ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off');
$str=<<<EOD <script> alert( '$err[cEmptyrecords]' ); window.location=document.referrer; </script> EOD; echo $str; } } function changedate_display($date) { list($year,$month,$date)=explode("-",$date); //$newdate=""; $newdate=$month.'.'.$date.'.'.$year; return ($newdate); } }//end class $ob = new download; $ob->download_file($db_object,$common,$employee_id,$default,$error_msg,$plan_id); ?>
$filename = "learning_solution_$user_id.txt"; header("content-type: application/stream"); header("content-length: $len"); header("content-disposition: attachment; filename=$filename"); $fp=fopen($file,"r"); fpassthru($fp); exit; } else { $str=<<<EOD <script> alert( '$err[cEmptyrecords]' ); window.location=document.referrer; </script> EOD; echo $str; } } }//end class $ob = new download; $ob->download_file($db_object,$common,$approved_on,$default,$err,$_POST); ?>
/** * Download Reports in CSV format */ public function download() { // If user doesn't have access, redirect to dashboard if (!$this->auth->has_permission("reports_download")) { url::redirect(url::site() . 'admin/dashboard'); } $this->template->content = new View('admin/reports/download'); $this->template->content->title = Kohana::lang('ui_admin.download_reports'); $errors = $form = array('format' => '', 'data_active' => array(), 'data_verified' => array(), 'data_include' => array(), 'from_date' => '', 'to_date' => '', 'form_auth_token' => ''); // Default to all selected $form['data_active'] = array(0, 1); $form['data_verified'] = array(0, 1); $form['data_include'] = array(1, 2, 3, 4, 5, 6, 7); $form_error = FALSE; // Check, has the form been submitted, if so, setup validation if ($_POST) { // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things $post = array_merge($_POST, $_FILES); // Test to see if things passed the rule checks if (download::validate($post)) { // Set filter $filter = '( '; // Report Type Filter $show_active = FALSE; $show_inactive = FALSE; $show_verified = FALSE; $show_not_verified = FALSE; if (in_array(1, $post->data_active)) { $show_active = TRUE; } if (in_array(0, $post->data_active)) { $show_inactive = TRUE; } if (in_array(1, $post->data_verified)) { $show_verified = TRUE; } if (in_array(0, $post->data_verified)) { $show_not_verified = TRUE; } // Handle active or not active if ($show_active && !$show_inactive) { $filter .= ' incident_active = 1 '; } elseif (!$show_active && $show_inactive) { $filter .= ' incident_active = 0 '; } elseif ($show_active && $show_inactive) { $filter .= ' (incident_active = 1 OR incident_active = 0) '; } elseif (!$show_active && !$show_inactive) { // Equivalent to 1 = 0 $filter .= ' (incident_active = 0 AND incident_active = 1) '; } $filter .= ' AND '; // Handle verified if ($show_verified && !$show_not_verified) { $filter .= ' incident_verified = 1 '; } elseif (!$show_verified && $show_not_verified) { $filter .= ' incident_verified = 0 '; } elseif ($show_verified && $show_not_verified) { $filter .= ' (incident_verified = 0 OR incident_verified = 1) '; } elseif (!$show_verified && !$show_not_verified) { $filter .= ' (incident_verified = 0 AND incident_verified = 1) '; } $filter .= ') '; // Report Date Filter if (!empty($post->from_date)) { $filter .= " AND incident_date >= '" . date("Y-m-d H:i:s", strtotime($post->from_date)) . "' "; } if (!empty($post->to_date)) { $filter .= " AND incident_date <= '" . date("Y-m-d H:i:s", strtotime($post->to_date)) . "' "; } // Retrieve reports $incidents = ORM::factory('incident')->where($filter)->orderby('incident_dateadd', 'desc')->find_all(); // Retrieve categories $categories = Category_Model::get_categories(FALSE, FALSE, FALSE); // Retrieve Forms $forms = ORM::Factory('form')->find_all(); // Retrieve Custom forms $custom_forms = customforms::get_custom_form_fields(); // If CSV format is selected if ($post->format == 'csv') { $report_csv = download::download_csv($post, $incidents, $custom_forms); // Output to browser header("Content-type: text/x-csv"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=" . time() . ".csv"); header("Content-Length: " . strlen($report_csv)); echo $report_csv; exit; } // If XML format is selected if ($post->format == 'xml') { header('Content-type: text/xml; charset=UTF-8'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Disposition: attachment; filename=" . time() . ".xml"); $content = download::download_xml($post, $incidents, $categories, $forms); echo $content; exit; } } else { // Repopulate the form fields $form = arr::overwrite($form, $post->as_array()); // Populate the error fields, if any $errors = arr::merge($errors, $post->errors('report')); $form_error = TRUE; } } $this->template->content->form = $form; $this->template->content->errors = $errors; $this->template->content->form_error = $form_error; // Javascript Header $this->themes->js = new View('admin/reports/download_js'); $this->themes->js->calendar_img = url::base() . "media/img/icon-calendar.gif"; }
public function media($type = NULL, $file = NULL) { // Get the file path from the request $file = implode('/', URI::instance()->segment_array(2)); // Find the file extension $ext = pathinfo($file, PATHINFO_EXTENSION); // Remove the extension from the filename $file = substr($file, 0, -(strlen($ext) + 1)); // Find the file if (!($file = Kohana::find_file('media', $file, FALSE, $ext))) { Event::run('system.404'); } // Tell browsers to cache the file for an hour. Chrome especially seems to not want to cache things expires::check(3600); // Send the file content as the response, and send some basic headers download::send($file); }
$current_products_id = (int) $_GET['products_id']; if (isset($_SESSION['languages_id']) && $languages_id == '') { $languages_id = (int) $_SESSION['languages_id']; } $sql_query = tep_db_query("SELECT lp.library_id, lf.files_name, lfde.files_descriptive_name, fi.icon_small, lf.files_name \r\n from " . TABLE_LIBRARY_FILES . " lf, \r\n " . TABLE_LIBRARY_FILES_DESCRIPTION . " lfde, \r\n " . TABLE_LIBRARY_PRODUCTS . " lp, \r\n " . TABLE_FILE_ICONS . " fi \r\n WHERE lfde.language_id = '" . $languages_id . "' \r\n and lp.library_id = lf.files_id \r\n and lf.files_id = lfde.files_id \r\n and lf.files_icon = fi.icon_id \r\n and lf.files_status = '1' \r\n and lp.products_id ='" . $current_products_id . "'\r\n ORDER BY lfde.files_descriptive_name"); $num_files_related = tep_db_num_rows($sql_query); if ($num_files_related > 0) { $info_box_contents = array(); $info_box_contents[] = array('text' => TEXT_RELATED_FILES); new contentBoxHeading($info_box_contents); $info_box_contents = array(); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TEXT_DOWNLOAD_FILE); $info_box_contents[0][] = array('params' => 'class="productListing-heading"', 'text' => TEXT_MORE_INFO); $info_box_contents[0][] = array('align' => 'center', 'params' => 'class="productListing-heading"', 'text' => TEXT_FILE_NAME); require_once DIR_WS_CLASSES . FILENAME_DOWNLOAD; $download = new download(); $n = 0; while ($listing_array = tep_db_fetch_array($sql_query)) { $download->process($listing_array['library_id'], $_SESSION['customer_id']); $download_criteria = $download->file_content; if ($n / 2 == floor($n / 2)) { $info_box_contents[] = array('params' => 'class="productListing-odd"'); } else { $info_box_contents[] = array('params' => 'class="productListing-even"'); } $cur_row = sizeof($info_box_contents) - 1; $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', 'text' => $download_criteria); $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', 'text' => '<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing_array['library_id']) . '">' . $listing_array['files_descriptive_name'] . '</a>'); $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"', 'text' => '<a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing_array['library_id']) . '">' . tep_image('images/file_icons/' . $listing_array['icon_small']) . '</a> <a href="' . tep_href_link(FILENAME_FILE_DETAIL, 'file_id=' . $listing_array['library_id']) . '">' . $listing_array['files_name'] . '</a>'); $n++; }
* $Revision$ * $Date$ * $Author$ */ if (!defined('e107_INIT')) { require_once "../../class2.php"; } if (!e107::isInstalled('download')) { header("location:" . e_BASE . "index.php"); } include_lan(e_PLUGIN . 'download/languages/' . e_LANGUAGE . '/download.php'); require_once e_PLUGIN . 'download/handlers/download_class.php'; require_once e_PLUGIN . 'download/handlers/category_class.php'; require_once e_PLUGIN . 'download/download_shortcodes.php'; require_once e_HANDLER . 'comment_class.php'; $dl = new download(); $cobj = new comment(); $dl_text = ''; // Output variable if (!defined("USER_WIDTH")) { define("USER_WIDTH", "width:100%"); } /* define images */ define("IMAGE_DOWNLOAD", file_exists(THEME . "images/download.png") ? THEME . "images/download.png" : e_IMAGE . "generic/download.png"); define("IMAGE_NEW", file_exists(THEME . "images/new.png") ? THEME . "images/new.png" : e_IMAGE . "generic/new.png"); $template_load_core = ' $template_name = $load_template.".php"; if (is_readable(THEME."templates/".$template_name)) { require_once(THEME."templates/".$template_name); }
require_once e_HANDLER . "form_handler.php"; require_once e_HANDLER . "userclass_class.php"; require_once e_HANDLER . "file_class.php"; $fl = new e_file(); // -------- Presets. ------------ require_once e_HANDLER . "preset_class.php"; $pst = new e_preset(); $pst->form = array("myform", "dlform"); // form id of the form that will have it's values saved. $pst->page = array("download.php?create", "download.php?cat"); // display preset options on which page(s). $pst->id = array("admin_downloads", "admin_dl_cat"); // ------------------------------- $rs = new form(); $frm = new e_form(); $download = new download(); require_once "auth.php"; /* One form example (no arrays needed) $pst->form = "myform"; // form id of the form that will have it's values saved. $pst->page = "download.php?create"; // display preset options on which page. $pst->save_preset("admin_downloads"); // unique name for the preset */ $sub_action = ''; if (e_QUERY) { $tmp = explode(".", e_QUERY); $action = $tmp[0]; $sub_action = varset($tmp[1], ''); $id = intval(varset($tmp[2], '')); $from = varset($tmp[3], 0); unset($tmp);
rename($home . $name, $backup . $name); } } $data = $home . 'data' . DIRECTORY_SEPARATOR . $_SERVER['HTTP_HOST']; $old = $home . 'data' . DIRECTORY_SEPARATOR . 'old'; if (is_dir($data) && !is_dir($old)) { rename($data, $old); } tmigratedata::$dir = $old . DIRECTORY_SEPARATOR; } set_time_limit(120); date_default_timezone_set("Europe/Moscow"); movefolders(); $data = new tmigratedata(); $data->loadfile('options'); if (download::install()) { $params = sprintf('&lang=%s&name=%s&description=%s&email=%s', rawurlencode($data->language), rawurlencode($data->name), rawurlencode($data->description), rawurlencode($data->email)); if (isset($dbversion) && $dbversion) { //test connect $host = isset($dbhost) ? $dbhost : 'localhost'; if (isset($dbport)) { $host .= ':' . $dbport; } $handle = mysql_connect($host, $dblogin, $dbpassword); if (!$handle) { die('Error connect to database'); } if (!mysql_select_db($dbname, $handle)) { die('Error select database'); } $params .= "&dbversion=1&dbname={$dbname}&dblogin={$dblogin}&dbpassword={$dbpassword}&dbprefix={$dbprefix}";
} elseif (!is_array($tables)) { $tables = array($tables); } $tab_list = array(); $result = $db->query("SHOW TABLES LIKE '" . $db_config['prefix'] . "_%'"); while ($item = $result->fetch(3)) { $tab_list[] = $item[0]; } $result->closeCursor(); $contents = array(); $contents['tables'] = empty($tables) ? $tab_list : array_values(array_intersect($tab_list, $tables)); $contents['type'] = $type != 'str' ? 'all' : 'str'; $contents['savetype'] = $ext != 'sql' ? 'gz' : 'sql'; $contents['filename'] = tempnam(NV_ROOTDIR . '/' . NV_TEMP_DIR, NV_TEMPNAM_PREFIX); include NV_ROOTDIR . '/includes/core/dump.php'; $result = nv_dump_save($contents); if (!empty($result)) { nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['download'], 'File name: ' . basename($contents['filename']), $admin_info['userid']); $content['mime'] = $contents['savetype'] == 'gz' ? 'application/x-gzip' : 'text/x-sql'; $contents['fname'] = $db->dbname . '.sql'; if ($contents['savetype'] == 'gz') { $contents['fname'] .= '.gz'; } //Download file require_once NV_ROOTDIR . '/includes/class/download.class.php'; $download = new download($result[0], NV_ROOTDIR . '/' . NV_TEMP_DIR, basename($contents['fname'])); $download->download_file(); exit; } } die;
$file_basename = $subfile . '.zip'; $directory = NV_ROOTDIR . '/' . NV_TEMP_DIR; } else { if ($file_exists) { @nv_deletefile($tem_file); } $zip = new PclZip($tem_file); $zip->add($file_src, PCLZIP_OPT_REMOVE_PATH, $upload_dir); if (isset($global_config['site_logo']) and !empty($global_config['site_logo']) and file_exists(NV_ROOTDIR . '/' . $global_config['site_logo'])) { $paths = explode('/', $global_config['site_logo']); array_pop($paths); $paths = implode('/', $paths); $zip->add(NV_ROOTDIR . '/' . $global_config['site_logo'], PCLZIP_OPT_REMOVE_PATH, NV_ROOTDIR . '/' . $paths); } if (file_exists(NV_ROOTDIR . '/' . NV_DATADIR . '/README.txt')) { $zip->add(NV_ROOTDIR . '/' . NV_DATADIR . '/README.txt', PCLZIP_OPT_REMOVE_PATH, NV_ROOTDIR . '/' . NV_DATADIR); } if (file_exists($tem_file)) { $file_src = $tem_file; $file_basename = $subfile . '.zip'; $directory = NV_ROOTDIR . '/' . NV_TEMP_DIR; } } } $download = new download($file_src, $directory, $file_basename, $is_resume, $max_speed); if ($is_zip) { $mtime = ($mtime = filemtime($session_files['fileupload'][$filename]['src'])) > 0 ? $mtime : NV_CURRENTTIME; $download->set_property('mtime', $mtime); } $download->download_file(); exit;