function downloadCSV()
{
    $filename = "LandfillGasMonitoringData";
    header("Content-type: text/csv");
    header("Content-Disposition: attachment; filename={$filename}.csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    $data = getAllSensorData();
    return outputCSV($data);
}
function download()
{
    $category = $_GET["category"];
    header("Content-Type: text/csv");
    header("Content-Disposition: attachment; filename={$category}.csv");
    header("Cache-Control: no-cache, no-store, must-revalidate");
    // HTTP 1.1
    header("Pragma: no-cache");
    // HTTP 1.0
    header("Expires: 0");
    // Proxies
    $q = new mysql_squid_builder();
    $table = "category_" . $q->category_transform_name($category);
    $sql = "SELECT * FROM {$table} ORDER BY `pattern`";
    $results = $q->QUERY_SQL($sql);
    $f[] = array("Date", "Website");
    while ($ligne = mysql_fetch_assoc($results)) {
        $f[] = array($ligne['zDate'], $ligne["pattern"]);
    }
    outputCSV($f);
}
示例#3
0
            $field_data['label'] = urldecode($field_data['label']);
            $field_data['value'] = urldecode($field_data['value']);
            $array_search = array_search($field_data['label'], $final_data[1]);
            if ($field_data['label'] == $entry_content[$field_no - 1]['label'] && !empty($field_data['value'])) {
                $temp = $final_data[$row][$array_search];
                $final_data[$row][$array_search] = $temp . ', ' . $field_data['value'];
            } else {
                $final_data[$row][$array_search] = $field_data['value'];
            }
        }
    }
    $row++;
}
$size = sizeof($final_data[1]);
foreach ($final_data as $key => $val) {
    $i = 1;
    while ($i <= $size) {
        if (empty($val[$i])) {
            $final_data[$key][$i] = '';
        }
        $i++;
    }
    ksort($final_data[$key]);
}
$header = 'Form Submission Data';
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=Submissions.csv");
header("Pragma: no-cache");
header("Expires: 0");
$final_data = outputCSV($final_data);
{
    $t = func_get_args();
    global $TYPE;
    return call_user_func_array(__FUNCTION__ . "_{$TYPE}", $t);
}
if (!function_exists("export_csv_stats_{$TYPE}")) {
    die("I don't understand this type");
}
//$TITLE = "Event";
//$eee = sql_fetch_array(sql_query("SELECT eventTitle FROM eventitems WHERE eventId='$ROOT_EVENT'", $conn));
//if($eee) $TITLE = $eee[0];
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=stats.csv");
// Disable caching
header("Cache-Control: no-cache, no-store, must-revalidate");
// HTTP 1.1
header("Pragma: no-cache");
// HTTP 1.0
header("Expires: 0");
// Proxies
function outputCSV($data)
{
    $output = fopen("php://output", "w");
    foreach ($data as $row) {
        fputcsv($output, $row);
        // here you can change delimiter/enclosure
    }
    fclose($output);
}
outputCSV(export_csv_stats($ROOT_EVENT, $conn));
示例#5
0
}
/***************************************************************************************
 * Export .csv output
 **************************************************************************************/
function outputCSV($data)
{
    $output = fopen('php://output', 'w');
    foreach ($data as $row) {
        fputcsv($output, $row, ',');
    }
    fclose($output);
}
add_action('admin_init', function () {
    global $wpdb;
    if (isset($_POST['od_export'])) {
        $filename = 'subscribers_' . time() . '.csv';
        header("Content-type: text/csv");
        header("Content-Disposition: attachment; filename={$filename}");
        header("Pragma: no-cache");
        header("Expires: 0");
        $subscribers = $wpdb->get_results("SELECT * FROM {$wpdb->od_subscribers} ORDER BY id DESC");
        $subscribers_list = array(array('Email Address', 'First Name', 'Last Name'));
        if ($subscribers) {
            foreach ($subscribers as $subscriber) {
                $subscribers_list[] = array('email' => $subscriber->email, '', '');
            }
            outputCSV($subscribers_list);
            exit;
        }
    }
});
function csv_builder()
{
    $q = new mysql_squid_builder();
    $zmd5 = $_GET["zmd5"];
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT `params`,`values`,`report_type` FROM reports_cache WHERE `zmd5`='{$zmd5}'"));
    $values = $ligne["values"];
    $report_type = $ligne["report_type"];
    $MAIN = unserialize(base64_decode($values));
    $params = unserialize($ligne["params"]);
    echo "<center style='font-size:30px;margin-bottom:30px;margin-top:30px'>{$report_type}</center>\n\t<center style='width:95%'>\n\t";
    if ($report_type == "MEMBERS") {
        $f[] = array("Member", "Size Bytes");
        while (list($USER, $size) = each($MAIN)) {
            $f[] = array($USER, $size);
        }
        outputCSV($f, "ressources/logs/web/MEMBERS.csv");
        echo "<div style='float:left;margin:10px' class=form><center style='font-size:18px;margin-top:20px'>MEMBERS.csv</center>\n\t\t\t<center><a href='ressources/logs/web/MEMBERS.csv'><img src='img/csv-256.png'></a></center>\n\t\t\t</div>\n\t\t\t\t\n\t\t\t";
        echo "</center>";
        return;
    }
    if ($report_type == "CATEGORIES") {
        outputCSV($MAIN["csv"], "ressources/logs/web/CATEGORIES.csv");
        echo "<div style='margin:10px' class=form><center style='font-size:18px;margin-top:20px'>CATEGORIES.csv</center>\n\t\t\t<center><a href='ressources/logs/web/CATEGORIES.csv'><img src='img/csv-256.png'></a></center>\n\t\t\t</div>\n\t\n\t\t\t";
        echo "</center>";
        return;
    }
    if ($report_type == "WEBFILTERING") {
        outputCSV($MAIN["csv"], "ressources/logs/web/WEBFILTERING.csv");
        echo "<div style='margin:10px' class=form><center style='font-size:18px;margin-top:20px'>WEBFILTERING.csv</center>\n\t\t\t<center><a href='ressources/logs/web/WEBFILTERING.csv'><img src='img/csv-256.png'></a></center>\n\t\t\t</div>\n\t\n\t\t\t";
        echo "</center>";
        return;
    }
    if ($report_type == "FLOW") {
        $f = array();
        outputCSV($MAIN["CSV1"], "ressources/logs/web/FLOW.csv");
        echo "<div style='float:left;margin:10px' class=form><center style='font-size:18px;margin-top:20px'>FLOW.csv</center>\n\t\t\t<center><a href='ressources/logs/web/FLOW.csv'><img src='img/csv-256.png'></a></center></div>";
        $f = array();
        outputCSV($MAIN["CSV2"], "ressources/logs/web/MEMBERS.csv");
        echo "<div style='float:left;margin:10px' class=form><center style='font-size:18px;margin-top:20px'>MEMBERS.csv</center>\n\t\t\t<center><a href='ressources/logs/web/MEMBERS.csv'><img src='img/csv-256.png'></a></center></div>";
        echo "</center>";
        return;
    }
    if ($report_type == "MEMBER_UNIQ") {
        $ROWS = $MAIN["IDENT"];
        $f[] = array("MAC", "ipaddr", "userid");
        while (list($index, $array) = each($ROWS)) {
            $IPADDR = $array["IPADDR"];
            $USERID = $array["USERID"];
            $MAC = $array["MAC"];
            $f[] = array($MAC, $IPADDR, $USERID);
        }
        outputCSV($f, "ressources/logs/web/IDENTITY.csv");
        echo "\n\t\t\t<div style='float:left;margin:10px' class=form>\n\t\t\t<center style='font-size:18px;margin-top:20px'>IDENTITY.csv</center>\n\t\t\t<center><a href='ressources/logs/web/IDENTITY.csv'><img src='img/csv-256.png'></a></center>\n\t\t\t</div>";
        $f = array();
        $ROWS = $MAIN["FAMS"];
        $f[] = array("Webiste", "Size bytes");
        while (list($website, $size) = each($ROWS)) {
            $f[] = array($website, $size);
        }
        outputCSV($f, "ressources/logs/web/WEBSITES.csv");
        echo "\n\t\t\t<div style='float:left;margin:10px' class=form>\t\n\t\t\t<center style='font-size:18px;margin-top:20px'>WEBSITES.csv</center>\n\t\t\t<center><a href='ressources/logs/web/WEBSITES.csv'><img src='img/csv-256.png'></a></center></div>";
        $f = array();
        outputCSV($MAIN["CSV"], "ressources/logs/web/CHRONOLOGY.csv");
        echo "\n\t\t\t<div style='float:left;margin:10px' class=form>\n\t\t\t<center style='font-size:18px;margin-top:20px'>CHRONOLOGY.csv</center>\n\t\t\t<center><a href='ressources/logs/web/CHRONOLOGY.csv'><img src='img/csv-256.png'></a></center></div>";
        $f = array();
        $xdata = $MAIN["GRAPH1"]["xdata"];
        $ydata = $MAIN["GRAPH1"]["ydata"];
        $f[] = array("Time", "Size MB");
        while (list($index, $value) = each($xdata)) {
            $f[] = array($value, $ydata[$index]);
        }
        outputCSV($f, "ressources/logs/web/FLOW.csv");
        echo "<div style='float:left;margin:10px' class=form><center style='font-size:18px;margin-top:20px'>FLOW.csv</center>\n\t\t\t<center><a href='ressources/logs/web/FLOW.csv'><img src='img/csv-256.png'></a></center></div>";
        $f = array();
        $f[] = array("Site", "Size MB");
        while (list($index, $value) = each($MAIN["GRAPH2"]["TABLE"])) {
            $f[] = array($index, $value);
        }
        outputCSV($f, "ressources/logs/web/SITES_MB.csv");
        echo "<div style='float:left;margin:10px' class=form><center style='font-size:18px;margin-top:20px'>TOP_SITES.csv</center>\n\t\t\t<center><a href='ressources/logs/web/TOP_SITES.csv'><img src='img/csv-256.png'></a></center></div>";
        outputCSV($MAIN["WEBFILTERING"], "ressources/logs/web/WEBFILTERING.csv");
        echo "<div style='float:left;margin:10px' class=form>\n\t\t\t\t<center style='font-size:18px;margin-top:20px'>WEBFILTERING.csv</center>\n\t\t\t\t<center>\n\t\t\t\t\t<a href='ressources/logs/web/WEBFILTERING.csv'><img src='img/csv-256.png'></a>\n\t\t\t\t</center>\n\t\t\t</div>";
        echo "</center>";
        return;
    }
}
            $downloadData[] = $data;
        }
    }
    $header = 'Date,Time,Job,';
    $last_item = end($fieldsToDisplay);
    foreach ($fieldsToDisplay as $f) {
        $header .= $f;
        if ($f != $last_item) {
            $header .= ",";
        }
    }
    ob_get_clean();
    header("Content-Type: text/csv");
    header("Content-Disposition: attachment; filename=\"data-" . date('YMd_His', $startDateTime) . '-' . date('YMd_His', $endDateTime) . ".csv\"");
    echo $header . "\n";
    outputCSV($downloadData);
    exit;
}
// ************** Chart Processing **************
if ($_REQUEST['act'] == 'graph') {
    $smarty->assign('wptResultURL', $wptResult);
    $smarty->display('report/flashGraph.tpl');
}
function formatDate(&$aVal)
{
    $aVal = date('m/d H:i', $aVal);
}
function outputCSV($data)
{
    $outstream = fopen("php://output", 'w');
    function __outputCSV(&$vals, $key, $filehandler)
示例#8
0
    }
}
$finalArr = array();
//counting rows of csv
$a1Cnt = count($a1);
for ($i = 0; $i < $a1Cnt; $i++) {
    $finalArr[$i][0] = $a1[$i];
    $finalArr[$i][1] = $a3[$i];
    $finalArr[$i][2] = $a5[$i];
    $finalArr[$i][3] = $a6[$i];
    $finalArr[$i][4] = $b1[$i];
    $finalArr[$i][5] = $b3[$i];
    $finalArr[$i][6] = $b4[$i];
}
function outputCSV($data)
{
    $outstream = fopen("php://output", "w");
    function __outputCSV(&$vals, $key, $filehandler)
    {
        fputcsv($filehandler, $vals);
        // add parameters if you want
    }
    array_walk($data, "__outputCSV", $outstream);
    fclose($outstream);
}
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=merged_file.csv");
header("Pragma: no-cache");
header("Expires: 0");
outputCSV($finalArr);
    $sql = '';
    if ($grd == "1") {
        //print "global search\n";
        $sql = "select `r`.`name` as 'Restaurant_Name', `b`.`name` as 'Borough', `ig`.`grade` as 'Grade', count(`ig`.`grade`) as 'Received'\n" . "from `restaurant_inspection` as `ri`, `inspection_grading` as `ig`, `restaurant_borough` as `rb`, `restaurants` as `r`, `borough` as `b`\n" . "where `ri`.`inspection_id` = `ig`.`inspection_id` and `ri`.`restaurant_id` = `rb`.`id` and `r`.`id` = `rb`.`id` and `r`.`name` like '%{$keyword}%' and `ig`.`grade` like '%%' and `rb`.`borough` like '%{$bor}' and `b`.`id` = `rb`.`borough`\n" . "group by `ig`.`grade`, `r`.`name`\n" . "order by `r`.`name`, count(`ig`.`grade`) desc";
    } else {
        if ($grd != "1") {
            //print "search via grade given";
            $sql = "select `r`.`name` as 'Restaurant_Name', `b`.`name` as 'Borough', `ig`.`grade` as 'Grade', count(`ig`.`grade`) as 'Received'\n" . "from `restaurant_inspection` as `ri`, `inspection_grading` as `ig`, `restaurant_borough` as `rb`, `restaurants` as `r`, `borough` as `b`\n" . "where `ri`.`inspection_id` = `ig`.`inspection_id` and `ri`.`restaurant_id` = `rb`.`id` and `r`.`id` = `rb`.`id` and `r`.`name` like '%{$keyword}%' and `ig`.`grade` = '{$grd}' and `rb`.`borough` like '%{$bor}' and `b`.`id` = `rb`.`borough`\n" . "group by `ig`.`grade`, `r`.`name`\n" . "order by count(`ig`.`grade`) desc";
        }
    }
    $resultss = mysql_query($sql);
    $data = array();
    $results = array();
    $i = 0;
    while ($i < mysql_num_fields($resultss)) {
        array_push($results, mysql_fetch_field($resultss, $i)->name);
        $i++;
    }
    array_push($data, $results);
    while ($r = mysql_fetch_array($resultss)) {
        $results = array();
        array_push($results, $r['Restaurant_Name']);
        array_push($results, $r['Borough']);
        array_push($results, $r['Grade']);
        array_push($results, $r['Received']);
        array_push($data, $results);
    }
    mysql_free_result($resultss);
    mysql_close();
    outputCSV($data, 'download_data_report.csv');
}
示例#10
0
                    $set_it[$key] = 1;
                    $line[$key * $skey][1] = $row['id'];
                    $line[$key * $skey][2] = $seen;
                    $line[$key * $skey][3] = $row['added'];
                    $line[$key * $skey][4] = ' ';
                    $line[$key * $skey][5] = $form_name;
                    $line[$key * $skey][6] = urldecode($value['label']);
                    $line[$key * $skey][7] = urldecode($value['value']);
                    $temp_key = $key * $skey;
                } else {
                    if ($value['label'] != 'location' && $value['type'] != 'hidden') {
                        $line[$key * $skey][1] = ' ';
                        $line[$key * $skey][2] = ' ';
                        $line[$key * $skey][3] = ' ';
                        $line[$key * $skey][4] = ' ';
                        $line[$key * $skey][5] = ' ';
                        $line[$key * $skey][6] = urldecode($value['label']);
                        $line[$key * $skey][7] = urldecode($value['value']);
                    }
                }
            }
        }
    }
}
$header = 'Form Submission Data';
header("content-type: text/csv;charset=UTF-8");
header("Content-Disposition: attachment; filename=Submissions.csv");
header("Pragma: no-cache");
header("Expires: 0");
$line = outputCSV($line);
示例#11
0
 public function downloadExcel()
 {
     //        if ($this->checkCondition() == FALSE) {
     //            output_error('条件不足,不能执行该操作');
     //        }
     if ($this->input->get_post('tracking_number_ids')) {
         $tracking_number_ids = explode(',', $this->input->get_post('tracking_number_ids'));
         $tracking_numbers = $this->tracking_number_model->getTrackingNumberByIDS($tracking_number_ids);
     } else {
         $data = array('arrive_time_start' => $this->input->get_post('arrive_time_start'), 'arrive_time_end' => $this->input->get_post('arrive_time_end'), 'filter' => objectToArray(json_decode($this->input->get_post('filter'))));
         $tracking_numbers = $this->tracking_number_model->getTrackingNumbers($data);
     }
     //查询所有客户
     $all_customers = $this->customer_model->getAllCustomers();
     //查询所有快递
     $all_express = $this->express_company_model->getAllExpress();
     foreach ($tracking_numbers as $key => $val) {
         if ($val['account_status'] == 0) {
             $tracking_numbers[$key]['account_status_name'] = '未结算';
         } else {
             $tracking_numbers[$key]['account_status_name'] = '已结算';
         }
         //客户名字
         //$customer = $this->customer_model->getCustomer($val['customer_id']);
         //$tracking_numbers[$key]['customer_name'] = $customer['customer_name'];
         $tracking_numbers[$key]['customer_name'] = $all_customers[$tracking_numbers[$key]['customer_id']];
         //操作人名字
         $tracking_numbers[$key]['admin_name'] = $this->admin_name;
         //快递公司名字
         //$express = $this->express_company_model->getOne($val['express_id']);
         //$tracking_numbers[$key]['express_name'] = $express['express_name'];
         $tracking_numbers[$key]['express_name'] = $all_express[$tracking_numbers[$key]['express_id']];
     }
     $header = array('tracking_number_id' => '自动编号', 'tracking_number' => '运单号', 'weight' => '重量', 'arrive_express_point_name' => '网点名称', 'arrive_express_point_code' => '网点代码', 'arrive_time' => '揽收时间', 'income' => '收入(元)', 'cost' => '成本(元)', 'customer_name' => '客户名称', 'account_status_name' => '结算状态', 'express_name' => '快递公司');
     //outputExcel($tracking_numbers, $header);
     outputCSV($tracking_numbers, $header);
 }
$sql .= "WHERE ed_uid=" . $EXP->user_id() . " ORDER BY ed_date;";
$q = $EXP->db()->query($sql) or die("Error {$sql}");
$dat = [];
while ($r = $q->fetch(PDO::FETCH_ASSOC)) {
    $dat[] = $r;
}
/*
function maybeEncodeCSVField($string) {
    if(strpos($string, ',') !== false || strpos($string, '"') !== false || strpos($string, "\n") !== false) {
        $string = '"' . str_replace('"', '""', $string) . '"';
    }
    return $string;
}
*/
//echo "<pre>";
//print_r($dat);
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=expenses.csv");
header("Pragma: no-cache");
header("Expires: 0");
function outputCSV($data)
{
    $output = fopen("php://output", "w");
    foreach ($data as $row) {
        fputcsv($output, $row);
        // here you can change delimiter/enclosure
    }
    fclose($output);
}
outputCSV($dat);
示例#13
0
    fclose($output);
}
/**
 * Initialized the path and the name of csv file that to be fetched.
 */
$sheet1 = 'csv1/Sheet 1.csv';
$mainSheets = 'csv1/main.csv';
/**
 * Get the content and convert to array from the csv file
 */
$arraySheet1 = csv_to_array($sheet1);
$arrayMainSheets = csv_to_array($mainSheets);
//set header
$csv_header = array('Company', 'User ID', 'Username', 'User type', 'IP address', 'Time-stamp', 'Access Country', 'Access State');
$content = getContentCsv($arrayMainSheets, $arraySheet1, $csv_header);
outputCSV($content);
/**
 * This function is to get the csv file and return as array.
 * @param string $filename
 * @param string $delimiter
 * @return array|bool
 */
function csv_to_array($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename)) {
        return FALSE;
    }
    $header = NULL;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
示例#14
0
<?php

require_once '../inc/inc.php';
if (isset($_GET['task']) && $_GET['task'] == 'export') {
    $query = $mysqli->query('SELECT * FROM rsvps');
    $rsvps = array();
    $rsvps[] = ['ID', 'RSVP Code', 'First Name', 'Last Name', 'Email', 'Guest First Name', 'Guest Last Name', 'Questions', 'Submitted'];
    while ($rsvp = $query->fetch_array(MYSQLI_ASSOC)) {
        $rsvps[] = $rsvp;
    }
    $query->close();
    $mysqli->close();
    outputCSV('rsvp-export.csv', $rsvps, false);
}
$where = '';
$guest = false;
$current_page = 1;
if (isset($_GET['page'])) {
    $current_page = $_GET['page'];
}
$per_page = 20;
$count = $mysqli->query('SELECT COUNT(*) FROM rsvps' . $where);
$count_array = $count->fetch_array();
$count->close();
$total_rows = $count_array[0];
$total_pages = ceil($total_rows / $per_page);
if ($current_page < 1) {
    $current_page = 1;
}
if ($current_page > $total_pages) {
    $current_page = $total_pages;
示例#15
0
function parse($filename)
{
    $unix = new unix();
    $LastScannLine = 0;
    $GLOBALS["MYSQL_CATZ"] = new mysql_catz();
    $GLOBALS["SQUID_FAMILY_CLASS"] = new squid_familysite();
    if (!isset($GLOBALS["MYHOSTNAME"])) {
        $unix = new unix();
        $GLOBALS["MYHOSTNAME"] = $unix->hostname_g();
    }
    $filesource = dirname(__FILE__) . "/ressources/conf/upload/{$filename}";
    if (!is_file($filesource)) {
        build_progress(110, "{$filename} no such file");
        return;
    }
    $tmpfile = $unix->FILE_TEMP();
    if (!@copy($filesource, $tmpfile)) {
        @unlink($filesource);
        build_progress(110, "{$filename} -> {$tmpfile} {failed}");
        return;
    }
    @unlink($filesource);
    $SumOflines = $unix->COUNT_LINES_OF_FILE($tmpfile);
    echo "{$tmpfile} {$SumOflines} lines\n";
    $handle = @fopen($tmpfile, "r");
    if (!$handle) {
        echo "Fopen failed on {$tmpfile}\n";
        build_progress(110, "{$tmpfile} {failed}");
        @unlink($tmpfile);
        return false;
    }
    $c = 0;
    $d = 0;
    $e = 0;
    $prc = 0;
    $prc_text = 0;
    $mysql_first_time = 0;
    $SITES = array();
    $NOT_CATEGORIZED = array();
    $CATEGORIZED = array();
    $RQS = array();
    $IPClass = new IP();
    $FIRSTTIME = 0;
    $LASTTIME = 0;
    $TIME1 = time();
    while (!feof($handle)) {
        $c++;
        $d++;
        $e++;
        $prc = $c / $SumOflines;
        $prc = round($prc * 100);
        $buffer = trim(fgets($handle));
        if ($buffer == null) {
            continue;
        }
        $stats_sites = count($SITES);
        $stats_categorized = count($CATEGORIZED);
        $stats_not_categorized = count($NOT_CATEGORIZED);
        if (!isset($GLOBALS["LAST_PRC"])) {
            build_progress($prc, "{$c}/{$SumOflines} {please_wait}");
            $GLOBALS["LAST_PRC"] = $prc;
        }
        if ($prc > 5) {
            if ($prc < 95) {
                if ($GLOBALS["LAST_PRC"] != $prc) {
                    $array_load = sys_getloadavg();
                    $internal_load = $array_load[0];
                    $mem = round(memory_get_usage() / 1024 / 1000, 2);
                    echo "Load: {$internal_load}, Memory {$mem}MB\n";
                    echo "Categorized: " . FormatNumber($stats_categorized) . "\n";
                    echo "Unknown....: " . FormatNumber($stats_not_categorized) . "\n";
                    echo "Web sites..: " . FormatNumber($stats_sites) . "\n";
                    build_progress($prc, FormatNumber($c) . "/" . FormatNumber($SumOflines) . " {please_wait} - {$mem}MB {memory}");
                    $GLOBALS["LAST_PRC"] = $prc;
                }
            }
        }
        $array = parseAccessLine($buffer);
        if (count($array) == 0) {
            continue;
        }
        $TIME = $array["TIME"];
        $LASTTIME = $TIME;
        if ($FIRSTTIME == 0) {
            $FIRSTTIME = $TIME;
        }
        $CATEGORY = $array["CATEGORY"];
        $FAMILYSITE = $array["FAMILYSITE"];
        $SIZE = intval($array["SIZE"]);
        if ($IPClass->isIPAddress($FAMILYSITE)) {
            if (!isset($IPADDRESSES[$FAMILYSITE]["RQS"])) {
                $IPADDRESSES[$FAMILYSITE]["RQS"] = 1;
                $IPADDRESSES[$FAMILYSITE]["SIZE"] = 0;
                $IPADDRESSES[$FAMILYSITE]["CATEGORY"] = $CATEGORY;
            } else {
                $IPADDRESSES[$FAMILYSITE]["RQS"] = $IPADDRESSES[$FAMILYSITE]["RQS"] + 1;
                $IPADDRESSES[$FAMILYSITE]["SIZE"] = $IPADDRESSES[$FAMILYSITE]["SIZE"] + $SIZE;
            }
            continue;
        }
        if (!isset($SITES[$FAMILYSITE])) {
            $SITES[$FAMILYSITE] = 0;
        }
        if (!isset($RQS[$FAMILYSITE])) {
            $RQS[$FAMILYSITE] = 0;
        }
        $SITES[$FAMILYSITE] = $SITES[$FAMILYSITE] + $SIZE;
        $RQS[$FAMILYSITE] = $RQS[$FAMILYSITE] + 1;
        if ($CATEGORY != null) {
            $CATEGORIZED[$FAMILYSITE] = $CATEGORY;
            continue;
        }
        $NOT_CATEGORIZED[$FAMILYSITE] = true;
    }
    fclose($handle);
    @unlink($tmpfile);
    build_progress(91, "{building_report}");
    $TIME2 = time();
    $stats_sites = count($SITES);
    $stats_categorized = count($CATEGORIZED);
    $stats_not_categorized = count($NOT_CATEGORIZED);
    $ARRAY["DURATION"] = $unix->distanceOfTimeInWords($TIME1, $TIME2);
    $ARRAY["SumOflines"] = $SumOflines;
    $ARRAY["stats_sites"] = $stats_sites;
    $ARRAY["stats_ip"] = count($IPADDRESSES);
    $ARRAY["firsttime"] = $FIRSTTIME;
    $ARRAY["lasttime"] = $LASTTIME;
    $ARRAY["stats_categorized"] = $stats_categorized;
    $ARRAY["stats_not_categorized"] = $stats_not_categorized;
    build_progress(92, "{building_report}");
    $CSV1[] = array("website", "size", "requests");
    while (list($familysite, $ligne) = each($NOT_CATEGORIZED)) {
        $CSV1[] = array($familysite, $SITES[$familysite], $RQS[$familysite]);
    }
    build_progress(95, "{building_report}");
    $CSV2[] = array("website", "category", "size", "requests");
    while (list($familysite, $category) = each($CATEGORIZED)) {
        $CSV2[] = array($familysite, $category, $SITES[$familysite], $RQS[$familysite]);
    }
    build_progress(97, "{building_report}");
    $CSV3[] = array("Public IP addresses", "category", "size", "requests");
    while (list($ip, $ARRAYIPS) = each($IPADDRESSES)) {
        $category = $ARRAYIPS["CATEGORY"];
        $size = $ARRAYIPS["SIZE"];
        $RQS = $ARRAYIPS["RQS"];
        $CSV3[] = array($ip, $category, $size, $RQS);
    }
    build_progress(99, "{saving_reports}");
    outputCSV($CSV1, "/usr/share/artica-postfix/ressources/logs/notcategorized.csv");
    outputCSV($CSV2, "/usr/share/artica-postfix/ressources/logs/categorized.csv");
    outputCSV($CSV3, "/usr/share/artica-postfix/ressources/logs/ipcategorized.csv");
    @file_put_contents("/usr/share/artica-postfix/ressources/logs/categorized.array", serialize($ARRAY));
    @chmod("/usr/share/artica-postfix/ressources/logs/notcategorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/ipcategorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/categorized.csv", 0755);
    @chmod("/usr/share/artica-postfix/ressources/logs/categorized.array", 0755);
    build_progress(100, "{done}");
}
示例#16
0
 function downloadError()
 {
     $file = $this->session_token_model->getData($this->session_token, 'error_upload_number_file');
     if (!$file) {
         output_error('没有日志可供下载');
     }
     $pars_default = array('sheetIndex' => 0, 'headerKey' => TRUE, 'readColumn' => array('运单号码', '商家代码', '快递公司'));
     $data = loadExcel($file, $pars_default);
     if (!$data) {
         //output_error('数据有问题,列都不匹配');
         $msg = array('数据有问题,列都不匹配');
         $header = array('msg' => '消息');
         outputCSV($msg, $header);
     }
     $msg = $this->customer_number_model->validateData($data);
     $header = array('msg' => '消息');
     outputCSV($msg, $header);
 }
    $outstream = fopen("php://output", 'w');

    function __outputCSV(&$vals, $key, $filehandler) 
    {
      fputcsv($filehandler, $vals, ',', '"');
    }
    array_walk($data, '__outputCSV', $outstream);

    fclose($outstream);
  }


  $query = "select * from marital_satiffaction";
  $result = mysql_query($query);

  $data = array();

  $i = 0;
  while ($row = mysql_fetch_assoc($result))
  {
    if (!$i)
    {
      $i++;
      $data[] = array_keys(json_decode($row['data'], true));
    }
    $data[] = array_values(json_decode($row['data'], true));
  }
  
  outputCSV($data);
  
?>