コード例 #1
0
ファイル: backup.php プロジェクト: OmondiKevin/CD4
 public function routine_backup($download_option = false, $ftp_servers = array())
 {
     $tables = array("activation_link", "assay", "book", "calibur_upload", "cd4_test", "commodity", "commodity_temp", "county", "district", "district_user", "equipment", "equipment_category", "equipment_status", "facility", "facility_equipment", "facility_equipment_request", "facility_pima", "facility_type", "facility_user", "fcdrr", "fcdrr_temp", "partner", "partner_regions", "partner_user", "password_log", "patient_age_group", "pima_control", "pima_error", "pima_error_type", "pima_failed_upload_devices", "pima_test", "pima_test_pass_fail", "pima_upload", "reagent", "reagent_category", "region", "region_user", "status", "user", "user_access_level", "user_group", "user_status", "userlog");
     $prefs = array('format' => 'zip', 'tables' => $tables);
     $backup =& $this->dbutil->backup($prefs);
     $db_name = 'cd4' . time() . '.zip';
     $save = 'backup/' . $db_name;
     write_file($save, $backup);
     if ($download_option) {
         force_download($db_name, $backup);
     }
     $all_ftp_servers = $this->config->item("ftp_backup");
     foreach ($ftp_servers as $key => $value) {
         $config = $all_ftp_servers[$value];
         $config["from"] = $save;
         $config["to"] = $db_name;
         $this->ftp_send($config);
         // $this->ftp->connect($config);
         // print_r($config);
         // echo $string = read_file('backup/cd41411795771.zip');
         // $this->ftp->upload('backup/cd41411795771.zip', 'z.zip', 'ascii', 0775);
         // $list = $this->ftp->list_files('/');
         // print_r($list);
         // $this->ftp->close();
     }
 }
コード例 #2
0
 /**
  * 导出csv数据报表
  * @author yugang@ymt360.com
  * @since 2015-01-30
  */
 public function export_csv($title_arr, $data, $file_path = 'default.csv')
 {
     array_unshift($data, $title_arr);
     // 在公共的方法中使用导出时间不限制
     // 以防止数据表太大造成csv文件过大,造成超时
     set_time_limit(0);
     $temp_file_path = BASEPATH . '../application/temp/' . uniqid() . '.csv';
     $file = fopen($temp_file_path, 'w');
     $keys = array_keys($title_arr);
     foreach ($data as $item) {
         // 对数组中的内容按照标题的顺序排序,去除不需要的内容
         $info = array();
         foreach ($keys as $v) {
             $info[$v] = isset($item[$v]) ? $item[$v] : '';
         }
         fputcsv($file, $info);
     }
     fclose($file);
     //在win下看utf8的csv会有点问题
     $str = file_get_contents($temp_file_path);
     $str = iconv('UTF-8', 'GBK', $str);
     unlink($temp_file_path);
     // 下载文件
     $this->load->helper('download');
     force_download($file_path, $str);
 }
コード例 #3
0
ファイル: master.php プロジェクト: gukefei/xcenter
 public function backupData()
 {
     $tables = $this->input->post();
     unset($tables['Submit']);
     unset($tables['checkall']);
     unset($tables['local']);
     if (!count($tables)) {
         message($this->lang->line('master_select_table'), 'master/backup');
     }
     $config = array('tables' => $tables, 'format' => 'zip');
     $name = date('Y-m-d H-i-s', time()) . '_' . md5(uniqid(mt_rand()));
     $filename = $name . '.zip';
     if (file_exists(FCPATH . 'data/' . $filename)) {
         for ($i = 1; $i <= 100; $i++) {
             $filename = $name . '_v' . $i . '.zip';
             if (!file_exists(FCPATH . 'data/' . $filename)) {
                 break;
             }
         }
     }
     $config['filename'] = $filename;
     $this->load->dbutil();
     $backup =& $this->dbutil->backup($config);
     $this->load->helper(array('file', 'download'));
     write_file(FCPATH . 'data/' . $config['filename'], $backup);
     $local = trim($this->input->post('local'));
     if ($local == 1) {
         force_download($config['filename'], $backup);
     }
     message($this->lang->line('success'), 'master/backup');
 }
コード例 #4
0
 function download($file_name, $name)
 {
     $this->load->helper('download');
     $data = file_get_contents(realpath(APPPATH . '../uploads/' . $file_name));
     $name_n = $name . '.pdf';
     force_download($name_n, $data);
 }
コード例 #5
0
ファイル: Download.php プロジェクト: ChathunKurera/JMS-V1
 private function downloadBlindCopy($id)
 {
     $this->load->helper('download');
     $data = file_get_contents("./uploads/BlindCopy/" . $id . ".docx");
     $filename = "BC_" . $id . ".docx";
     force_download($filename, $data);
 }
コード例 #6
0
ファイル: Welcome.php プロジェクト: siraj-notion/report
 public function download()
 {
     $this->load->helper('download');
     $data = 'Here is some text!';
     $name = 'mytext.txt';
     force_download($name, $data);
 }
コード例 #7
0
 public function export($type = 'xml')
 {
     $this->load->helper('download');
     $this->load->library('Format');
     $subscribers = $this->db->get('newsletter_emails')->result_array();
     force_download('subscribers.' . $type, $this->format->factory($subscribers)->{'to_' . $type}());
 }
コード例 #8
0
ファイル: formams.php プロジェクト: codethics/proteoerp
 function _msxml($fnombre, $data)
 {
     if (!$this->db->table_exists('formaesp')) {
         $mSQL = "CREATE TABLE `formaesp` (  `nombre` varchar(20) NOT NULL DEFAULT '',  `descrip` varchar(200) DEFAULT NULL,  `word` longtext,  PRIMARY KEY (`nombre`),  UNIQUE KEY `nombre` (`nombre`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Formatos especiales'";
         $this->db->simple_query($mSQL);
     }
     $this->load->helper('download');
     $query = $this->db->query('SELECT word FROM formaesp WHERE nombre=' . $this->db->escape($fnombre));
     if ($query->num_rows() > 0) {
         $row = $query->row();
         $word = utf8_encode($row->word);
         preg_match_all('/\\{(?<vars>[^\\}\\{]+)\\}/', $word, $matches);
         $var = array();
         $tword = $word;
         if (count($matches['vars']) > 0) {
             foreach ($matches['vars'] as $val) {
                 $pivot = preg_replace('/<[^>]*>/', '', $val);
                 $var[$pivot] = $val;
                 if (isset($data[$pivot])) {
                     $tword = str_replace('{' . $val . '}', $data[$pivot], $tword);
                 }
             }
             $nom = 'contrato.xml';
             force_download($nom, $tword);
         }
     } else {
         echo 'Formato no existe';
     }
 }
コード例 #9
0
 public function export()
 {
     date_default_timezone_set("Asia/Jakarta");
     $data = array('header' => 'Pembukaan Virtual Account', 'status' => '', 'pesan' => '', 'list_file' => array());
     if ($this->session->userdata('username') === '' || array_key_exists('username', $this->session->all_userdata()) === false) {
         $this->load->view('errors/html/custom_error_401');
     } else {
         $bank = $this->input->post('pilihan_bank');
         $start_date = $this->input->post('start_date');
         $end_date = $this->input->post('end_date');
         if ($bank === '0') {
             $data['status'] = 'Error';
             $data['pesan'] = 'Mohon untuk memilih nama bank';
             $this->load->view('virtual/pembukaan', $data);
         } else {
             if ($bank === 'BRI') {
                 $this->load->model('virtualaccount_models');
                 $pembukaan_briva = $this->virtualaccount_models->get_pembukaan_briva($start_date, $end_date, $this->session->userdata('username'));
                 $file_download_path = getcwd() . '/downloads/virtual/convert/mandiri/PEMBUKAAN_BRIVA_' . $start_date . '_' . $end_date . '_' . date("Ymdhis") . '.csv';
                 $file_download = fopen($file_download_path, 'w');
                 for ($i = 0; $i < sizeof($pembukaan_briva); $i++) {
                     fwrite($file_download, $pembukaan_briva[$i]['Pembukaan'] . "\r\n");
                 }
                 fclose($file_download_path);
                 force_download($file_download_path, NULL);
             }
         }
     }
 }
コード例 #10
0
ファイル: Savefile.php プロジェクト: skybee/cctv-pro
 function goods_list()
 {
     //        print_r($_POST); exit();
     $cnt_position = count($_POST['name']);
     if ($cnt_position < 1) {
         exit('Форма не заполнена');
     }
     $resultAr = array();
     $summ_all = 0;
     for ($i = 0; $i < $cnt_position; $i++) {
         $resultAr[$i]['name'] = $_POST['name'][$i];
         $resultAr[$i]['units'] = $_POST['units'][$i];
         $resultAr[$i]['count'] = $_POST['count'][$i];
         $resultAr[$i]['price'] = $_POST['price'][$i];
         if (empty($_POST['price'][$i]) || empty($_POST['name'][$i]) || empty($_POST['count'][$i])) {
             continue;
         }
         $cnt_unit = trim($_POST['count'][$i]);
         $price = trim(str_replace(',', '.', str_replace(' ', '', $_POST['price'][$i])));
         $summ = $price * $cnt_unit;
         $summ_all = $summ_all + $summ;
     }
     $summ_all_str = number_format($summ_all, 2, '.', '');
     $data = json_encode($resultAr);
     $name = 'Форма__' . date("Y.m.d__") . $summ_all_str . '_грн.json';
     force_download($name, $data);
 }
コード例 #11
0
 public function download()
 {
     $filename = $this->input->post('hiddendownload');
     $this->load->helper('download');
     $data = file_get_contents($filename);
     force_download($filename, $data);
 }
コード例 #12
0
ファイル: c_regulasi.php プロジェクト: ekospinach/sideka
 function downloadRegulasiByIdRegulasi($id)
 {
     $file_regulasi = $this->m_regulasi->getFileRegulasiByIdRegulasi($id_regulasi);
     $nama_file = str_replace('uploads/files/', '', $file_regulasi);
     $data = file_get_contents("uploads/files/" . $nama_file);
     force_download($nama_file, $data);
 }
コード例 #13
0
 function index()
 {
     $this->load->dbutil();
     $this->load->helper('download');
     /* Check access */
     if (!check_access('backup account')) {
         $this->messages->add('Permission denied.', 'error');
         redirect('setting');
         return;
     }
     $backup_filename = "backup" . date("dmYHis") . ".gz";
     /* Backup your entire database and assign it to a variable */
     $backup_data =& $this->dbutil->backup();
     /* Write the backup file to server */
     if (!write_file($this->config->item('backup_path') . $backup_filename, $backup_data)) {
         $this->messages->add('Error saving backup file to server.' . ' Check if "' . $this->config->item('backup_path') . '" folder is writable.', 'error');
         redirect('setting');
         return;
     }
     /* Send the file to your desktop */
     force_download($backup_filename, $backup_data);
     $this->logger->write_message("success", "Downloaded account backup");
     redirect('setting');
     return;
 }
コード例 #14
0
 public function approval()
 {
     $this->load->helper('download');
     $data = file_get_contents(base_url() . 'download/' . 'approval_manual.pdf');
     $name = 'রেজিষ্ট্রেশন অনুমোদনের পদ্ধতি.pdf';
     force_download($name, $data);
 }
コード例 #15
0
 public function downloadAction($name = null)
 {
     $this->load->helper('download');
     $name = hex2bin($name);
     $array = $this->_get($name, true);
     force_download($name . '.php', $array, true);
 }
コード例 #16
0
ファイル: file.php プロジェクト: kimjbrandon/pibi
    function download()
    {
        $ordernumber = $this->uri->segment(4);
        $token = $this->uri->segment(6);
        $filename = $this->uri->segment(8);
        $type = $this->uri->segment(10);
        $url = "http://52.68.221.38/index.php/order/file/id/" . $ordernumber . '/token/' . $token . '/type/' . $type . '/format/json';
        if (empty($ordernumber) || empty($token)) {
            echo 'ordernumber and token must be provided';
        } else {
            $this->load->library('user_agent');
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, $this->agent->agent_string());
            // adding the post variables to the request
            $output = curl_exec($ch);
            // $result is always false when on the same server for some reason
            curl_close($ch);
            if ($output != false) {
                $this->load->helper('download');
                force_download($filename, $output);
            } else {
                echo $output;
                ?>

			<script>
				alert('Please try again');
				window.close();
			</script>	
			
			<?php 
            }
        }
    }
コード例 #17
0
ファイル: Registration_form.php プロジェクト: saj696/dcms_new
 public function index()
 {
     $this->load->helper('download');
     $data = file_get_contents(base_url() . 'download/' . 'protibedon.pdf');
     $name = 'রেজিস্ট্রেশন ফরম.pdf';
     force_download($name, $data);
 }
コード例 #18
0
ファイル: Salva_restaura.php プロジェクト: neomicho85/Destajo
 /**
  * Salva
  * 
  * Crear una salva de la base de datos y la exporta al usuario
  * Los ficheros de salva se almacenan en la carpeta backup del server 
  * @return object
  */
 public function salva()
 {
     // Salvar
     if ($this->input->post('exportar')) {
         // Asignar un nombre de fichero de salva
         $file_name = $this->input->post('filename');
         if (!$file_name or $file_name == "") {
             $file_name = "mybackup";
         }
         // Agregar fecha y hora al nombre del fichero
         if ($this->input->post('fn_datetime') == TRUE) {
             $date_str = date("d_m_Y_g;i;a");
             $file_name .= $date_str;
         }
         // Agregar extencion al fichero
         $file_name .= ".sql";
         // Load the DB utility class
         $this->load->dbutil();
         // Backup your entire database and assign it to a variable
         $prefs = array('ignore' => array(), 'format' => 'txt', 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n", 'fk_checks' => FALSE);
         $backup =& $this->dbutil->backup($prefs);
         // Load the file helper and write the file to
         // your browser download default directory
         $this->load->helper('file');
         write_file('backup/' . $file_name, $backup);
         // Load the download helper and send the file to your desktop
         $this->load->helper('download');
         force_download($file_name, $backup, TRUE);
         $x = array();
         $x['ok'] = "ok";
         echo json_encode($x);
     } else {
         $this->load->view('salva_restaura/salva_v');
     }
 }
コード例 #19
0
ファイル: products.php プロジェクト: sspat/citest
	function export()
	{
		$this->load->helper('download');
		$csv = $this->MProducts->exportCsv();
		$name = "product_export.csv";
		force_download($name, $csv);
	}
コード例 #20
0
ファイル: formatos.php プロジェクト: enderochoa/tortuga
 function descargar()
 {
     $this->load->helper('download');
     $parametros = func_get_args();
     if (count($parametros) > 0) {
         $_arch_nombre = implode('-', $parametros);
         $_fnombre = array_shift($parametros);
         //$this->rapyd->load('dataobject');
         $this->db->_escape_char = '';
         $this->db->_protect_identifiers = false;
         $query = $this->db->query("SELECT proteo FROM formatos WHERE nombre='{$_fnombre}'");
         if ($query->num_rows() > 0) {
             $row = $query->row();
             ob_start();
             echo eval('?>' . preg_replace("/;*\\s*\\?>/", "; ?>", str_replace('<?=', '<?php echo ', $row->proteo)) . '<?php ');
             $_html = ob_get_contents();
             @ob_end_clean();
             force_download($_arch_nombre . ".tortuga", $_html);
         } else {
             echo 'Formato no existe';
         }
     } else {
         echo 'Faltan parametros';
     }
 }
コード例 #21
0
 public function index()
 {
     $this->load->helper('download');
     $data = file_get_contents(base_url() . 'download/' . 'instructions.pdf');
     $name = 'রেজিস্ট্রেশন নির্দেশনা.pdf';
     force_download($name, $data);
 }
コード例 #22
0
ファイル: Friends.php プロジェクト: neo1125/petplace_server
 public function get_json()
 {
     $this->load->helper('download');
     $rows = $this->friends_model->lists('lat is not null and lan is not null');
     $data['friends'] = $rows->result_array();
     force_download('friends.json', json_encode($data));
 }
コード例 #23
0
ファイル: customers.php プロジェクト: nebjak/GoCart
 function export_xml()
 {
     $this->load->helper('download_helper');
     $data['customers'] = (array) $this->Customer_model->get_customers();
     force_download('users.xml', $this->load->view($this->config->item('admin_folder') . '/customers_xml', $data, true));
     //$this->load->view($this->config->item('admin_folder').'/customers_xml', $data);
 }
コード例 #24
0
ファイル: download.php プロジェクト: aidear/100event
 /**
  * xingde.wei
  * 修改下载方法,所有调用下载的地方都要用到这里
  */
 function downloads()
 {
     $ua = $_SERVER["HTTP_USER_AGENT"];
     $file = $_GET['file'];
     $file = mb_convert_encoding($file, 'gbk', 'utf-8');
     $file = base_url() . $file;
     $this->load->helper('download');
     $data = file_get_contents($file);
     // 读文件内容
     $name = basename($file);
     force_download($name, $data);
     //$file ='http://localhost/huizhanwang2014/upload/album/201409/29/5428aa297ffac.zip';
     // 		if (file_exists($file))
     // 		{
     // 			header('Content-Description: File Transfer');
     // 			header('Content-Type: application/octet-stream');
     // 			header('Content-Disposition: attachment; filename='.basename($file));
     // 			header('Content-Transfer-Encoding: binary');
     // 			header('Expires: 0');
     // 			header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     // 			header('Pragma: public');
     // 			header('Content-Length: ' . filesize($file));
     // 			ob_clean();
     // 			flush();
     // 			readfile($file);
     // 			exit;
     // 		}
 }
コード例 #25
0
 function download()
 {
     $data = file_get_contents("http://d2anjul3ixu9f5.cloudfront.net/resume/neil-girardi-resume-august-2012.pdf");
     // Read the file's contents
     $name = 'Neil-Girardi-Resume.pdf';
     force_download($name, $data);
 }
コード例 #26
0
ファイル: Excel.php プロジェクト: rudrashrestha/ecommerce
 public function to_excel($query, $filename = 'exceloutput', $headers_labels = NULL)
 {
     $char_encoding = 'windows-1255';
     $headers = '';
     // just creating the var for field headers to append to below
     $data = '';
     // just creating the var for field data to append to below
     if ($headers_labels != NULL) {
         foreach ($headers_labels as $field) {
             $headers .= iconv(mb_detect_encoding($field), $char_encoding, $field) . "\t";
         }
     }
     foreach ($query as $row) {
         $line = '';
         foreach ($row as $value) {
             if (!isset($value) or $value == "") {
                 $value = "\t";
             } else {
                 $value = str_replace('"', '""', $value);
                 $value = '"' . $value . '"' . "\t";
                 $value = iconv(mb_detect_encoding($value), $char_encoding, $value);
             }
             $line .= $value;
         }
         $data .= trim($line) . "\n";
     }
     $data = str_replace("\r", "", $data);
     force_download($filename . ".xls", $headers . "\n" . $data);
 }
コード例 #27
0
ファイル: Dbtools.php プロジェクト: urangawak/minangcms
 function backupdb()
 {
     $this->m_security->filterPost('nama', 'required');
     $this->m_security->filterPost('tipe', 'required');
     if ($this->m_security->startPost() == TRUE) {
         $nama = $this->input->post('nama', TRUE) . '-' . stringRandom(3, TRUE);
         $tipe = $this->input->post('tipe', TRUE);
         $addinsert = $this->input->post('addinsert', TRUE);
         $adddrop = $this->input->post('adddrop', TRUE);
         $refinsert = FALSE;
         $refdrop = FALSE;
         if ($addinsert == "on") {
             $refinsert = TRUE;
         } else {
             $refinsert = FALSE;
         }
         if ($adddrop == "on") {
             $refdrop = TRUE;
         } else {
             $refdrop = FALSE;
         }
         $prefs = array('format' => $tipe, 'filename' => $nama . '.sql', 'add_drop' => $refdrop, 'add_insert' => $refinsert, 'newline' => "\n");
         $backup = $this->dbutil->backup($prefs);
         $this->load->helper('download');
         force_download($nama . '.' . $tipe, $backup);
     } else {
         redirect(base_url(roleUser() . 'config/dbtools'), 'refresh');
     }
 }
コード例 #28
0
ファイル: savedb.php プロジェクト: simplonco/sos_femmes
 public function index()
 {
     $this->load->dbutil();
     $this->load->helper('download');
     $backup =& $this->dbutil->backup();
     force_download('mybackup.gz', $backup);
 }
コード例 #29
0
ファイル: export.php プロジェクト: TrinataBhayanaka/damkar
 function csv()
 {
     $this->load->helper("download");
     $data = $this->input->post("tbl", true);
     $name = $this->input->post("filename", true);
     force_download($name, $data);
 }
コード例 #30
0
ファイル: document.php プロジェクト: wildanSawaludin/ci-cms
 function get($file)
 {
     $file = urldecode($file);
     $file = html_entity_decode($file);
     $row = $this->downloads->get_doc(array('download_files.file' => $file));
     if ($row) {
         /**
          * @since 2.1.0
          * is allowed?
          */
         if (!in_array($row['acces'], $this->user->groups)) {
             if (!$this->user->logged_in) {
                 $this->user->require_login();
             } else {
                 $this->template['title'] = __("Forbidden", 'downloads');
                 $this->layout->load($this->template, '403');
                 return;
             }
         }
         $fn = $this->downloads->settings['upload_path'] . $file;
         if (file_exists($fn)) {
             //counter hit
             if ($this->session->userdata('download_file' . $row['id']) != $row['id']) {
                 $this->session->set_userdata('download_file' . $row['id'], $row['id']);
                 $this->downloads->update_doc(array('hit' => $row['hit'] + 1), $row['id']);
             }
             if (function_exists('apache_request_headers')) {
                 $headers = apache_request_headers();
             }
             // Checking if the client is validating his cache and if it is current.
             /*
             			    if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == filemtime($fn))) 
             				{
             			        // Client's cache IS current, so we just respond '304 Not Modified'.
             			        header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 304);
             			    } 
             				else 
             				{
             					$this->load->helper('file');
             			        
             			        header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($fn)).' GMT', true, 200);
             			        header('Content-Length: '.filesize($fn));
             					header('Content-Type: ' . get_mime_by_extension($file));
             					header("Content-Disposition: attachment; filename=\"$file\""); 
             					
             			        print file_get_contents($fn);
             			    }
             * 
             */
             $this->load->helper('download');
             force_download($file, file_get_contents($fn));
         } else {
             $this->output->set_header("HTTP/1.0 404 Not Found");
             $this->layout->load($this->template, '404');
         }
     } else {
         //$this->output->set_header("HTTP/1.0 404 Not Found");
         $this->layout->load($this->template, '404');
     }
 }