function update_data($f)
{
    reset_status_cantine();
    $new_f = str_replace(".csv", "_FAAA.csv", $f);
    //echo ($new_f)."<br>";
    $fr = fopen($f, 'r');
    $fw = fopen($new_f, 'w');
    $total = 0;
    $touteslettres = "";
    while (!feof($fr)) {
        $l = fgets($fr);
        $ar_l = explode(";", $l);
        if (is_numeric($ar_l[0])) {
            //echo "processing line ".$l."<br />";
            $cf = $ar_l[5] / 100;
            $debut = mysqldateformat($ar_l[6]);
            $fin = mysqldateformat($ar_l[7]);
            $days = (strtotime($fin) - strtotime($debut)) / 86400;
            $months = round($days / 30);
            $ar_l[8] = "DP";
            $ar_l[9] = $months;
            $ar_l[10] = 1600 * $cf;
            $ar_l[11] = $months * 1600 * $cf;
            $ar_l[12] = 0;
            $ar_l[13] = $ar_l[11];
            $ar_l[14] = 0;
            $ar_l[15] = 0;
            $ar_l[16] = $ar_l[11];
            $total += $ar_l[16];
            $touteslettres = chiffre_en_lettre($total);
            $l = join(";", $ar_l);
            fwrite($fw, $l);
            $cps = $ar_l[1];
            if ($ar_l[5] == "100") {
                $status = 15;
            } else {
                $status = 16;
            }
            update_enfant($cps, $status, $fin);
        } else {
            if (substr($l, 0, 3) == ";;;") {
                //end
                $l = str_replace("Total;;", "Total;{$total};", $l);
                $l = str_replace("(en toutes lettres) :", "(en toutes lettres) : {$touteslettres}", $l);
                fwrite($fw, $l);
            } else {
                //echo "ignoring line ".$l."<br />";
                fwrite($fw, $l);
            }
        }
        unset($ar_l);
    }
    fclose($fr);
    fclose($fw);
    output_file($new_f, substr($new_f, 4), "csv");
}
function update_data($f)
{
    $new_f = str_replace(".txt", "_ssBP.txt", $f);
    //echo ($new_f)."<br>";
    $fr = fopen($f, 'r');
    $fw = fopen($new_f, 'w');
    while (!feof($fr)) {
        $l = fgets($fr);
        $bp = substr($l, 206, 32);
        if (stripos($bp, 'bp') !== false) {
            fwrite($fw, $l);
        }
    }
    fclose($fr);
    fclose($fw);
    output_file($new_f, substr($new_f, 5), "txt");
}
Пример #3
0
        die('Error - can not open file.');
    }
    die;
}
/*********************************************
			Example of use
**********************************************/
set_time_limit(0);
$report = $_POST['report_type'] . "_" . $_POST['time_frame'];
/************
if($report=="all")
{
$file_path='parental_reports_sample.txt';
}
else if($report=="site")
{
$file_path='parental_reports_sample1.txt';
}
else if($report=="service")
{
$file_path='parental_reports_sample2.txt';
}
else
{
$file_path='parental_reports_sample3.txt';
}
***********/
$file_path = "/var/tmp/parental_reports_" . $report . ".txt";
$file_name = "parental_repotts_" . $report . ".txt";
output_file($file_path, $file_name, 'text/plain');
//output_file("parental_reports_sample.txt","parental_reports_sample.txt","text/plain");
Пример #4
0
            header("location: ./");
            exit;
        }
        if ($item["pdf"]) {
            // PDF ファイル
            $item["pdf_file"] = Image::getData($item["pdf"]);
        }
        $data["item"] = $item;
        //
        htmltemplate::t_include($item["propaty"]["item_html"], $data);
        exit;
    }
}
if ($act == "output_file") {
    $id = $_REQUEST["id"];
    output_file($id);
}
if ($act == "contact" || $act == "contact_reinput") {
    $id = $_REQUEST["id"];
    $item = get_info($id);
    //
    $data["item"] = $item;
    //
    $mode = $_REQUEST["mode"];
    if ($mode == "form") {
        $form = $_REQUEST;
        $form["title"] = $item["title"];
        $data["form"] = $form;
        // エラーチェック
        $msg = array();
        if (!$form["name"]) {
Пример #5
0
        if (isset($_SERVER['HTTP_RANGE'])) {
            fseek($file, $range);
        }
        while (!feof($file) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($file, $chunksize);
            echo $buffer;
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($file);
    } else {
        //If no permissiion
        die('Error - can not open file.');
    }
    //die
    die;
}
//Set the time out
set_time_limit(0);
$files = new Files();
$fileid = $_REQUEST['fileid'];
$data = $files->getFileData($fileid);
//path to the file
$file_path = $data->filepath;
$filename = $data->filename;
$createdate = $data->createdate;
$date = date_create($createdate);
$fileDate = date_format($date, 'd-m-Y');
//Call the download function with file path,file name and file type
output_file($file_path . '/' . $fileDate . '/' . $fileid . '_' . $filename, '' . $fileid . '_' . $filename . '');
Пример #6
0
<?php

include "db_functions.inc.php";
include "config.inc.php";
include "outputfile.php";
$get_id = intval($_GET['id']);
$select_link = yasDB_select("SELECT `id`, `file` FROM `downgames` WHERE `id` = {$get_id}");
if ($select_link->num_rows == 1) {
    $result = $select_link->fetch_array(MYSQLI_ASSOC);
    yasDB_update("UPDATE `downgames` SET `downloadtimes` = `downloadtimes` + 1 WHERE id = {$result['id']}");
    output_file($result['file'], basename($result['file']));
}
$select_link->close();
Пример #7
0
            } else {
                //If no permissiion
                die('Error - can not open file.');
            }
            //die
            die;
        }
        //Set the time out
        set_time_limit(0);
        //path to the file
        $filename = $row['url'];
        /*$file_path='files/'.$_REQUEST['filename'];*/
        $file_path = 'files/' . $filename;
        //Call the download function with file path,file name and file type
        /* output_file($file_path, ''.$_REQUEST['filename'].'', 'text/plain');*/
        output_file($file_path, $filename, 'video/mp4');
        /*
        //This application is developed by www.webinfopedia.com
        //visit www.webinfopedia.com for PHP,Mysql,html5 and Designing tutorials for FREE!!!
        */
    } else {
        echo 'You have already downloaded this content!';
    }
} else {
    echo 'Your token is invalid!';
}
?>



Пример #8
0
$start_epoch = gps_to_epoch($ride_data_array[ride_date]);
if ($target_array[object] === 'segment') {
    //segments have no time stamps
    $stop_at = count($stream_data->latlng) - 1;
} else {
    //stationary rides have no coordinates
    $stop_at = count($stream_data->time) - 1;
}
//TURNING THE CRANK
for ($i = 0; $i <= $stop_at; $i++) {
    $seconds_time = $stream_data->time[$i];
    $timestamp = gps_date($start_epoch + $seconds_time);
    $altitude = $stream_data->altitude[$i];
    $cadence = $stream_data->cadence[$i];
    $distance = $stream_data->distance[$i];
    $latlng = $stream_data->latlng[$i];
    $heartrate = $stream_data->heartrate[$i];
    $temp = $stream_data->temp[$i];
    if ($stream_data->watts[0] !== FALSE) {
        $watts = $stream_data->watts[$i];
    } else {
        $watts = $stream_data->watts_calc[$i];
    }
    $loop_result = array('time' => $timestamp, 'altitude' => $altitude, 'cadence' => $cadence, 'distance' => $distance, 'lat' => $latlng[0], 'lng' => $latlng[1], 'heartrate' => $heartrate, 'temp' => $temp, 'watts' => $watts);
    $data_line = datapoint_format($file_type, $loop_result);
    $trackpoints = $trackpoints . $data_line;
}
$footer = add_footer($file_type);
$contents = $header . $trackpoints . $footer;
$new_name = output_file($file_type, $target_array[id], $contents);
echo 'Congratulations - <a href="' . $target_array[id] . '.' . strtolower($file_type) . '">your file export</a> is ready.';
Пример #9
0
    /* output the file itself */
    $chunksize = 1 * (1024 * 1024);
    //you may want to change this
    $bytes_send = 0;
    if ($file = fopen($file, 'r')) {
        if (isset($_SERVER['HTTP_RANGE'])) {
            fseek($file, $range);
        }
        while (!feof($file) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($file, $chunksize);
            print $buffer;
            //echo($buffer); // is also possible
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($file);
    } else {
        die('Error - can not open file.');
    }
    die;
}
/* 
Make sure script execution doesn't time out.
Set maximum execution time in seconds (0 means no limit).
*/
set_time_limit(0);
switch ($_GET["file"]) {
    case "client":
        output_file("../../../pos_client/client.zip", 'client.zip', 'application/zip');
        break;
}
Пример #10
0
    if (!$attachment) {
        alert("文件不存在");
        exit;
    }
    $dt = $attachment['dt'];
    $file_dir = $cfg['AttachmentDir'] . date("Y-m", strtotime($attachment['dt'])) . "/";
    //if (!file_exists(Server_MapPath($file_dir.$attachment['filename']))) {
    //	$file_dir=getFileType($attachment['mime']).date("Y-m",strtotime($attachment['dt']))."/";
    //}
    //if (!file_exists(Server_MapPath($file_dir.$attachment['filename']))) {
    //	$file_dir=$cfg['_AttachmentDir'].date("Y-m",strtotime($attachment['dt']))."/";
    //}
    if (strlen(trim($attachment['filename'])) != 0) {
        output_file($cmd, $attachment['filename'], $file_dir, $attachment['formername'], $attachment['mime_type']);
    } else {
        output_file($cmd, $attachment['filename'], $file_dir, $attachment['formername']);
    }
}
function output_file($cmd, $file_name, $file_dir, $formername, $mime = 'application/octet-stream')
{
    $path = $file_dir . $file_name;
    if (!file_exists($path)) {
        echo "文件不存在";
        exit;
    } else {
        $file = fopen($path, "r");
        $filesize = filesize($path);
        Header("Content-type: {$mime}");
        Header("Accept-Ranges: bytes");
        Header("Accept-Length: " . $filesize);
        if ($cmd == "download") {
Пример #11
0
            fseek($Source_File, $range);
        }
        while (!feof($Source_File) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($Source_File, $chunksize);
            print $buffer;
            //echo($buffer); // is also possible
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($Source_File);
    } else {
        die('Error - can not open file.');
    }
    die;
}
$base_id = $_GET['base_id'];
$id = $_GET['id'];
try {
    if (!$base_id || !$id) {
        throw new Exception('Wrong Parameter');
    }
    $highResFile = dirname(__FILE__) . '/files/' . $base_id . '/boxed/' . $id;
    $thumbFile = dirname(__FILE__) . '/files/' . $base_id . '/boxed/thumbnail/' . $id;
    if (!is_file($highResFile) || !is_file($thumbFile)) {
        throw new Exception('File Not Found');
    }
    output_file($highResFile, $id);
} catch (Exception $e) {
    header('Location: 404.html');
    exit;
}
function writetocsv($ids_cantine, $ids_etal, $ids_amarrage_clients, $ids_amarrage_mandataires)
{
    $fw = fopen('extract/impayes.csv', 'w');
    if (strlen($ids_cantine) > 0) {
        $ar_cantine_details = get_details_cantine($ids_cantine, 'factures_cantine');
    }
    if (strlen($ids_etal) > 0) {
        $ar_etal_details = get_details_mandataire($ids_etal, 'factures_etal');
    }
    //print ($ids_amarrage_clients);
    if (strlen($ids_amarrage_clients) > 0) {
        $ar_amarrage_clients_details = get_details_client($ids_amarrage_clients, 'factures_amarrage');
    }
    if (strlen($ids_amarrage_mandataires) > 0) {
        $ar_amarrage_mandataires_details = get_details_mandataire($ids_amarrage_mandataires, 'factures_amarrage');
    }
    fwrite($fw, "type;communeid;datefacture;montant;restearegler;periode/obs;nom;prenom;telephone;telephone2;bp;cp;ville;commune;rib;obs;enfantnom;enfantprenom;ecole;classe;\n");
    $ar_types_clients = array("ar_cantine_details", "ar_amarrage_clients_details");
    $ar_types_mandataires = array("ar_etal_details", "ar_amarrage_mandataires_details");
    foreach ($ar_types_clients as &$type) {
        foreach (${$type} as &$ar) {
            fwrite($fw, $ar["0"] . ";");
            fwrite($fw, $ar["communeid"] . ";");
            fwrite($fw, $ar["datefacture"] . ";");
            fwrite($fw, $ar["montantfcp"] . ";");
            fwrite($fw, $ar["restearegler"] . ";");
            fwrite($fw, html_entity_decode($ar['obs'] . ";", ENT_QUOTES, "ISO-8859-1"));
            fwrite($fw, $ar["clientnom"] . ";");
            fwrite($fw, $ar["clientprenom"] . ";");
            fwrite($fw, $ar["clienttelephone"] . ";");
            fwrite($fw, $ar["clientfax"] . ";");
            fwrite($fw, $ar["clientbp"] . ";");
            fwrite($fw, $ar["clientcp"] . ";");
            fwrite($fw, $ar["clientville"] . ";");
            fwrite($fw, $ar["clientcommune"] . ";");
            fwrite($fw, $ar["clientrib"] . ";");
            $clientobs = preg_replace("/\r\n/", ' ', $ar["clientobs"]);
            fwrite($fw, $clientobs . ";");
            if ($type == "ar_cantine_details") {
                fwrite($fw, $ar["enfantnom"] . ";");
                fwrite($fw, $ar["enfantprenom"] . ";");
                fwrite($fw, $ar["nomecole"] . ";");
                fwrite($fw, $ar["classe"] . ";");
            }
            fwrite($fw, "\n");
        }
    }
    foreach ($ar_types_mandataires as &$type) {
        foreach (${$type} as &$ar) {
            fwrite($fw, $ar["0"] . ";");
            fwrite($fw, $ar["communeid"] . ";");
            fwrite($fw, $ar["datefacture"] . ";");
            fwrite($fw, $ar["montantfcp"] . ";");
            fwrite($fw, $ar["restearegler"] . ";");
            fwrite($fw, html_entity_decode($ar['obs'] . ";", ENT_QUOTES, "ISO-8859-1"));
            fwrite($fw, $ar["mandatairenom"] . ";");
            fwrite($fw, $ar["mandataireprenom"] . ";");
            fwrite($fw, $ar["mandatairetelephone"] . ";");
            fwrite($fw, $ar["mandatairetelephone2"] . ";");
            fwrite($fw, $ar["mandatairebp"] . ";");
            fwrite($fw, $ar["mandatairecp"] . ";");
            fwrite($fw, $ar["mandataireville"] . ";");
            fwrite($fw, $ar["mandatairecommune"] . ";");
            fwrite($fw, $ar["mandatairerib"] . ";");
            $mandataireobs = preg_replace("/\r\n/", ' ', $ar["mandataireobs"]);
            fwrite($fw, $mandataireobs . ";");
            fwrite($fw, "\n");
        }
    }
    fclose($fw);
    output_file('extract/impayes.csv', 'impayes.csv', 'csv');
}
Пример #13
0
<?php

include_once '../includes/common_functions.php';
$_date = $_SESSION['selected_value'];
$provid = $_SESSION['provider']['serviceprovider_id'];
$file = $_SESSION['csvfile'];
output_file($file, 'techmatcherdata.csv', 'application/csv');
Пример #14
0
                }
                //die
                die;
            }
            //Set the time out
            set_time_limit(0);
            //path to the file
            //$filename = $row_d['url'];
            /*$file_path='files/'.$_REQUEST['filename'];*/
            //$file_path='files/'.$filename;
            $filename = $sessionx;
            //$filename = 'The Best.mp4';
            $file_path = 'files/' . $filename;
            //Call the download function with file path,file name and file type
            /* output_file($file_path, ''.$_REQUEST['filename'].'', 'text/plain');*/
            output_file($file_path, $filename, 'audio/mp3');
            echo 'Your download is starting in a second...';
            // } else { echo 'Download not found!'; }
        } else {
            echo 'This token has already been used! You cannot Download this file.<br/>' . $_SESSION['url'];
        }
    } else {
        //             $sessionxx = 1;
        //             var_dump($_SESSION);
        echo 'This token does not exist!<br/>';
    }
    mssql_free_result($token_check_s);
}
/* 
//To store it
foreach ($_REQUEST['url_i'] as $key=>$url_k) {
Пример #15
0
function output_file($file_item, $current_path, $type)
{
    global $ignore_files, $template_exts, $total_reduce_size;
    if ($current_path !== '') {
        foreach ((array) $file_item['file'] as $file_name => $file_info) {
            if (false === strpos($current_path, 'views') && $file_name[0] === '_' || $file_name[0] == '.') {
                continue;
            }
            if (in_array($file_name, $ignore_files)) {
                continue;
            }
            $file_path = $current_path . '/' . $file_name;
            $result = true;
            $file_skiped = false;
            $ext = get_ext($file_name);
            if ('all' != $type && $ext != $type) {
                continue;
            }
            if ($ext == 'css') {
                if (strpos($file_name, 'min.') === 0) {
                    $result = compress_css($file_path);
                } else {
                    $file_skiped = true;
                }
            } elseif ($ext == 'js') {
                if (strpos($file_name, 'min.') === 0) {
                    $result = compress_js($file_path);
                } else {
                    $file_skiped = true;
                }
            } elseif ($ext == 'png') {
                compress_png($file_path);
            } elseif (in_array($ext, $template_exts)) {
                compress_template($file_path);
            } else {
                copy(ROOT_PATH . $file_path, OUTPUT_DIR . $file_path);
            }
            $file_size = 0;
            if ($file_skiped === false) {
                if (file_exists(OUTPUT_DIR . $file_path)) {
                    $file_size = filesize(OUTPUT_DIR . $file_path);
                    $total_reduce_size += $file_info['infor']['file_size'] - $file_size;
                    if ($file_size <= 0) {
                        $file_size = 'b style="color:#ff0000">' . $file_size . '</b>';
                    } else {
                        $file_size = human_file_size($file_size);
                    }
                } else {
                    $result = false;
                }
            }
            if (false === $result) {
                echo '<p style="color:#ff0000;font-weight:bold">' . $file_path . ' Error</p>';
            } else {
                if ($file_skiped === false) {
                    echo $file_path . ' <b style="color:#1EBC16">OK</b> <span style="color:#888">(' . human_file_size($file_info['infor']['file_size']) . ' → ' . $file_size . ')</span><br />';
                } else {
                    echo '<span style="color:#aaa">' . $file_path . ' <b>Skiped</b></span><br />';
                }
            }
        }
    }
    foreach ((array) $file_item['dir'] as $dir_name => $dir) {
        if ($dir_name[0] === '_' || $dir_name[0] == '.') {
            continue;
        }
        if (in_array($dir_name, $ignore_files)) {
            continue;
        }
        $dir_path = $current_path . '/' . $dir_name;
        echo '<h2>' . $dir_path . '</h2>';
        make_dir($dir_path, OUTPUT_DIR);
        output_file($dir, $dir_path, $type);
    }
}
Пример #16
0
///then write data
$data = getdata($year, $month, $agents);
fwrite($fh, $data);
///then write the rest
fwrite($fh, $therest);
/// finally write the end
$source = "excel/toe.xml";
$fr = fopen($source, 'r') or die("can't open file" . $source);
while (!feof($fr)) {
    $stringData = fgets($fr, 1024);
    fwrite($fh, $stringData);
}
fclose($fr);
//close the file
fclose($fh);
output_file($file, "extract.xml", "text/xml");
function output_file($file, $name, $mime_type = '')
{
    /*
    This function takes a path to a file to output ($file), 
    the filename that the browser will see ($name) and 
    the MIME type of the file ($mime_type, optional).
    
    If you want to do something on download abort/finish,
    register_shutdown_function('function_name');
    */
    if (!is_readable($file)) {
        die('File not found or inaccessible!');
    }
    $size = filesize($file);
    $name = rawurldecode($name);
include_once 'config.php';
$db = $_GET["db"];
$df = $_GET["df"];
$sql_db = $_GET["sql_db"];
$sql_df = $_GET["sql_df"];
$rol = $_GET["rol"];
$today = date("m.d.y");
$file = "extract/rolmre_cant_" . $rol . "_" . $today . ".txt";
$data = get_all($sql_db, $sql_df, $rol);
$rol_id = insert_rol("rolmre_cantine", $sql_db, $sql_df, $file, $rol);
update_rol($sql_db, $sql_df, $rol_id);
$fh = fopen($file, 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
//print_r($data);
output_file($file, "rolmre_cant_" . $rol . "_" . $today . ".txt", "text/txt");
function output_file($file, $name, $mime_type = '')
{
    /*
    This function takes a path to a file to output ($file), 
    the filename that the browser will see ($name) and 
    the MIME type of the file ($mime_type, optional).
    
    If you want to do something on download abort/finish,
    register_shutdown_function('function_name');
    */
    if (!is_readable($file)) {
        die('File not found or inaccessible!');
    }
    $size = filesize($file);
    $name = rawurldecode($name);
Пример #18
0
function ExportContest(&$arg)
{
    $cid = safefetch($arg, 'cid');
    $contest = new ContestsTbl($cid);
    $contest->Get() or error("Invalid cid");
    $contest = $contest->detail;
    $zip = new ZipArchive();
    $filename = tempnam(sys_get_temp_dir(), "export_contest") . '.zip';
    if (!$zip->open($filename, ZIPARCHIVE::CREATE)) {
        error("Error creating archive file");
    }
    $cpids = get_cpids($cid);
    $problem_files = array();
    foreach ($cpids as $pid => $cpid) {
        $file_path = ExportProblem2File($pid);
        if (!$zip->addFile($file_path, "{$cpid}.zip")) {
            error("Error adding file [{$cpid}.zip]");
        }
        $problem_files[] = $file_path;
    }
    if (!$zip->addFromString('metadata.json', json_encode(array_values($cpids)))) {
        error("Error writing meta data");
    }
    if (!$zip->addFromString('.SET', date(DATE_W3C))) {
        error("Error writing .SET file");
    }
    if (!$zip->close()) {
        error("Error compressing");
    }
    foreach ($problem_files as $file_path) {
        unlink($file_path);
    }
    output_file($filename, "{$cid} - {$contest['title']}.zip");
}
Пример #19
0
<?php

include "function.php";
set_time_limit(0);
$file_path = "phpgang.csv";
output_file($file_path, 'phpgang.csv', 'application/csv');
Пример #20
0
            imagesavealpha($image, true);
            imagealphablending($image, false);
            imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), gd_bkg());
            break;
    }
    if ($FLIR['postscript']) {
        imagepsfreefont($FLIR['ps']['font']);
    }
    if (false !== $image) {
        switch ($FLIR['output']) {
            default:
            case 'png':
                imagepng($image, $FLIR['cache']);
                break;
            case 'gif':
                imagegif($image, $FLIR['cache']);
                break;
            case 'jpg':
                $qual = is_number($FStyle['quality']) ? $FStyle['quality'] : 90;
                imagejpeg($image, $FLIR['cache'], $qual);
                break;
        }
        imagedestroy($image);
    }
    output_file($FLIR['cache']);
}
// if(file_exists($FLIR['cache'])) {
flush();
if (CACHE_CLEANUP_FREQ != -1 && rand(1, CACHE_CLEANUP_FREQ) == 1) {
    @cleanup_cache();
}
Пример #21
0
$thePathFileName = $_REQUEST['path_file_name'];
/**
 * 为了安全,去掉不规范路径
 * @author terry
 * @version 0.1.0
 * Sat Sep 29 12:30:07 CST 2007
 */
$thePathFileName = str_replace('../', '', $thePathFileName);
//$theFileName     = $_REQUEST['file_name'];
$theFileName = basenameEx($thePathFileName);
Pft_Log::addLog('Start download [' . $thePathFileName . ' as [' . $theFileName . ']. ', Pft_Log::LEVEL_INFO);
//setlocale(LC_ALL,"zh_CN");
//print "<pre>";var_dump( $thePathFileName );print "</pre>";
//print "<pre>";var_dump( $theFileName );print "</pre>";
//exit;
output_file($thePathFileName, $theFileName);
function basenameEx($filename)
{
    $pos = strrpos($filename, '/');
    if ($pos !== false) {
        return substr($filename, $pos + 1);
    } else {
        return $filename;
    }
}
function output_file($file, $name)
{
    $file = PATH_UPLOAD . $file;
    //do something on download abort/finish
    //register_shutdown_function( 'function_name'  );
    if (!file_exists($file)) {
Пример #22
0
        }
        while (!feof($file) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($file, $chunksize);
            echo $buffer;
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($file);
    } else {
        //If no permissiion
        die('Error - can not open file.');
    }
    //die
    die;
}
if (isset($_POST['h']) && $_POST['id'] != "" && $_POST['service'] == "download") {
    $fullfinalpath = $_POST['filepath'];
    $dir_name = substr($_POST['key'], 0, 1);
    $finalpath = $fullfinalpath . "/" . $dir_name . "/" . $_POST['key'];
    output_file($finalpath, '' . $_POST['name'] . '', $_POST['type']);
    exit;
} else {
    if (isset($_SERVER['HTTPS'])) {
        $protocol = $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off" ? "https" : "http";
    } else {
        $protocol = 'http';
    }
    $finalprotocol = $protocol . "://" . parse_url($_SERVER['SERVER_NAME'], PHP_URL_HOST);
    $home = $finalprotocol . $_SERVER['SERVER_NAME'];
    echo "Your not authorised to access this page directly.<br>Click here to go <a href=" . $home . ">home page</a>";
}
        header("Content-Length: {$new_length}");
        header("Content-Range: bytes {$range}-{$range_end}/{$size}");
    } else {
        $new_length = $size;
        header("Content-Length: " . $size);
    }
    $chunksize = 1 * (1024 * 1024);
    $bytes_send = 0;
    if ($file = fopen($file, 'r')) {
        if (isset($_SERVER['HTTP_RANGE'])) {
            fseek($file, $range);
        }
        while (!feof($file) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($file, $chunksize);
            print $buffer;
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($file);
    } else {
        die('Error - can not open file.');
    }
    die;
}
$f = @fopen("ipn/log_download/log.txt", 'a');
@fputs($f, date("d.m.Y H:i") . " || " . $_SERVER['REMOTE_ADDR'] . " || " . $product_id . " ||\n");
@fclose($f);
set_time_limit(0);
$file_path = $upload_folder . '/' . $product_id;
output_file($file_path, $product_id, '');
Пример #24
0
function download($ip)
{
    logdl($ip);
    if ($_REQUEST['filename'] == 'zipball') {
        $count = file_get_contents("downloads.txt");
        $count++;
        file_put_contents("downloads.txt", $count);
        @header('Location: https://github.com/articlefr/MyOCR/zipball/master');
    } else {
        if ($_REQUEST['filename'] == 'tarball') {
            $count = file_get_contents("downloads.txt");
            $count++;
            file_put_contents("downloads.txt", $count);
            @header('Location: https://github.com/articlefr/MyOCR/tarball/master');
        } else {
            $file_path = realpath(dirname(__FILE__) . '/downloads/' . $_REQUEST['filename']);
            output_file($file_path, $_REQUEST['filename'], 'application/zip');
        }
    }
}
Пример #25
0
                        //echo($buffer); // Can also possible
                        flush();
                        $bytes_send += strlen($buffer);
                    }
                    fclose($file);
                } else {
                    //If no permissiion
                    die('Error - can not open file.');
                }
                //die
                die;
            }
            //Set the time out
            set_time_limit(0);
            $filename = $url_i_;
            $file_path = '../games/' . $filename;
            //Call the download function with file path,file name and file type
            output_file($file_path, $filename, 'application/vnd.android.package-archive');
            echo 'Your download is starting in a second...';
        } else {
            echo 'This token has already been used! You cannot Download this file.<br/>' . $_SESSION['url'];
        }
    } else {
        echo 'This link does not exist or is already used! Token ' . $token . ' Invalid!<br/>';
    }
    mssql_free_result($token_check_s);
} else {
    echo 'Error validating your token number!. Please contact us.';
}
?>
           
Пример #26
0
		(!connection_aborted()) && 
		($bytes_send<$new_length)
	      )
	{
		$buffer = fread($file, $chunksize);
		print($buffer); //echo($buffer); // can also possible
		flush();
		$bytes_send += strlen($buffer);
	}
 fclose($file);
 } else
 //If no permissiion
 die('Error - can not open file.');
 //die
die();
}
//Set the time out
set_time_limit(0);

//path to the file
$file_path='tcpdftest/ex/allinvoice/'.$_REQUEST['filename'];


//Call the download function with file path,file name and file type
output_file($file_path, ''.$_REQUEST['filename'].'', 'application/pdf');

	/*
	//This application is developed by www.webinfopedia.com
	//visit www.webinfopedia.com for PHP,Mysql,html5 and Designing tutorials for FREE!!!
 	*/
?>
Пример #27
0
        }
        $new_length = $range_end - $range + 1;
        header("HTTP/1.1 206 Partial Content");
        header("Content-Length: {$new_length}");
        header("Content-Range: bytes {$range}-{$range_end}/{$size}");
    } else {
        $new_length = $size;
        header("Content-Length: " . $size);
    }
    $chunksize = 1 * (1024 * 1024);
    $bytes_send = 0;
    if ($file = fopen($file, 'r')) {
        if (isset($_SERVER['HTTP_RANGE'])) {
            fseek($file, $range);
        }
        while (!feof($file) && !connection_aborted() && $bytes_send < $new_length) {
            $buffer = fread($file, $chunksize);
            print $buffer;
            flush();
            $bytes_send += strlen($buffer);
        }
        fclose($file);
    } else {
        die('Error - can not open file.');
    }
    die;
}
set_time_limit(0);
$file_path = 'files/' . $_GET['filename'];
output_file($file_path, $_GET['filename']);
Пример #28
0
		   )
	 {
	  $buffer = fread($file, $chunksize);
	  print($buffer); //echo($buffer); // can also possible
	  flush();
	  $bytes_send += strlen($buffer);
	 }
	 fclose($file);
	 } else
	 //If no permissiion
	 die('Error - can not open file.');
	 //die
	die();
	}
	//Set the time out
	set_time_limit(0);

	//path to the file
	$file_path=$_SERVER['DOCUMENT_ROOT'].'/billing/'.$_REQUEST['filename'];


	//Call the download function with file path,file name and file type
	output_file($file_path, ''.$_REQUEST['filename'].'', 'text/plain');
}
else
{
	die("In-Authorized Access.");
}

?>
        }
        fclose($file);
    } else {
        //If no permissiion
        die('Error - can not open file.');
    }
    //die
    die;
}
//Set the time out
set_time_limit(0);
//path to the file
//$categoriCourse="Fisika/";
$id = $_REQUEST['id'];
$download = mysql_query("select * FROM tb_mdl_data_file WHERE id='{$id}'");
$row = mysql_fetch_array($download);
$namaFolder = $row['namafolder'];
$namaFile = $row['namafile'];
$namaTypeFile = $row['namatypefile'];
$idcategori = $row['idcategori'];
$sql = mysql_query("select * FROM tb_mdl_coursecategories WHERE id='{$idcategori}'");
$row = mysql_fetch_array($sql);
$categoriCourse = $row['name'] . "/";
$file_path = '../../tatausaha/upload/data/' . $categoriCourse . $namaFolder . $namaFile . "." . $namaTypeFile;
//echo $file_path;
//Call the download function with file path,file name and file type
output_file($file_path, $namaFile . '.' . $namaTypeFile, 'text/plain');
/*
	//This application is developed by www.webinfopedia.com
	//visit www.webinfopedia.com for PHP,Mysql,html5 and Designing tutorials for FREE!!!
*/