예제 #1
0
파일: csv.php 프로젝트: slaFFik/l10n-ru
header("Content-Type: application/vnd.ms-excel");
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
/**
 * Escape CSV values
 *
 * @param string $value Original value to escape
 * @return string Escaped value
 **/
global $drainhole;
if ($type == 'stats') {
    $file = DH_File::get($id);
    header('Content-Disposition: attachment; filename="' . basename($file->file) . '.csv"');
    $stats = DH_Access::get_all($id);
    if (count($stats) > 0) {
        foreach ($stats as $stat) {
            $csv = array();
            $csv[] = $drainhole->csv_escape(date('Y-m-d', $stat->created_at));
            $csv[] = $drainhole->csv_escape(date('H:i', $stat->created_at));
            $csv[] = $drainhole->csv_escape($stat->ip);
            $csv[] = $drainhole->csv_escape($stat->speed);
            $csv[] = $drainhole->csv_escape($stat->time_taken);
            echo implode(',', $csv) . "\r\n";
        }
    }
} else {
    if ($type == 'files') {
        $hole = DH_Hole::get($id);
        header('Content-Disposition: attachment; filename="' . basename($hole->url) . '.csv"');
예제 #2
0
파일: ajax.php 프로젝트: slaFFik/l10n-ru
 function delete_stats($id)
 {
     if (check_ajax_referer('drainhole-delete_items')) {
         DH_Access::delete($_POST['checkall']);
     }
 }
예제 #3
0
파일: access.php 프로젝트: slaFFik/l10n-ru
 /**
  * Create a new statistic item in the database.  Certain data is extracted from the web environment (REMOTE_ADDR and HTTP_REFERER)
  *
  * @static
  * @param int $file File ID
  * @return int Access statistic ID
  **/
 function create($file, $version)
 {
     global $wpdb;
     $user = wp_get_current_user();
     if ($user) {
         $user = $user->data->ID;
     } else {
         $user = 0;
     }
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $ip = $_SERVER['REMOTE_ADDR'];
     } else {
         if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
         }
     }
     $ip = sprintf('%u', ip2long($ip));
     $referrer = DH_Access::get_referrer(wpdb::escape($_SERVER['HTTP_REFERER']));
     $wpdb->query("INSERT INTO {$wpdb->prefix}drainhole_access (file_id,created_at,ip,referrer,version_id,user_id) VALUES ({$file},NOW(),{$ip},'{$referrer}','{$version}','{$user}')");
     return $wpdb->insert_id;
 }
예제 #4
0
파일: drain-hole.php 프로젝트: Jintha/cama
 function screen_stats($id)
 {
     if (isset($_POST['clear_stats']) && check_admin_referer('drainhole-clear_stats')) {
         DH_Access::delete_by_file($id);
     }
     global $wpdb;
     $pager = new DH_Pager($_GET, $_SERVER['REQUEST_URI'], 'created_at', 'DESC', 'drain-hole-downloads', array('users' => $wpdb->users . '.ID'));
     $files = DH_Access::get_by_file($id, $pager);
     $file = DH_File::get($id);
     $hole = DH_Hole::get($file->hole_id);
     $this->render_admin('downloads', array('stats' => $files, 'file' => $file, 'pager' => $pager, 'hole' => $hole));
 }
예제 #5
0
파일: file.php 프로젝트: slaFFik/l10n-ru
         $max = $max + (10 - $max % 10);
         $min = $min - $min % 10;
         $chart['chart_data'] = array($axis, $data);
         $chart['axis_value'] = array('min' => 0, 'max' => $max, 'size' => 14, 'show_min' => true, 'steps' => 10);
         $chart['axis_category'] = array('size' => 14, 'orientation' => 'horizontal', 'skip' => count($data) > 5 ? 2 : 0);
         if (count($data) > 4) {
             $chart['chart_type'] = 'line';
         } else {
             $chart['chart_type'] = 'column';
         }
         $text = sprintf(__('Daily downloads over time (%1s %2s)', 'drain-hole'), $wp_locale->get_month(intval($_GET['month'])), intval($_GET['year']));
     }
 } else {
     if ($_GET['display'] == 'monthly') {
         $file = DH_File::get(intval($_GET['file']));
         $items = DH_Access::get_file_hits_per_year(intval($_GET['file']), intval($_GET['year']));
         if (count($items) > 0) {
             foreach ($items as $month => $hits) {
                 $axis[] = sprintf('%1s %2s', $wp_locale->get_month_abbrev($wp_locale->get_month($month)), $day);
                 $data[] = $hits;
             }
             // Work out the max and min values
             $max = max(array_slice($data, 1));
             $min = min(array_slice($data, 1));
             $max = $max + (10 - $max % 10);
             $min = $min - $min % 10;
             $chart['chart_data'] = array($axis, $data);
             $chart['axis_value'] = array('min' => 0, 'max' => $max, 'size' => 14, 'show_min' => true, 'steps' => 10);
             $chart['axis_category'] = array('size' => 14, 'orientation' => 'horizontal', 'skip' => count($data) > 5 ? 2 : 0);
             if (count($data) > 4) {
                 $chart['chart_type'] = 'line';
예제 #6
0
파일: file.php 프로젝트: Jintha/cama
 /**
  * Load the file and feed it to the user's browser (after registering a hit).  Execution is halted
  *
  * @param DH_Hole $hole Hole in which the file lives
  **/
 function download($hole, $version = '')
 {
     // Is this a local or a remote file?
     $download_as = $this->download_as(true);
     if (strpos($download_as, '://') !== false && $version == '') {
         $id = $this->hit($version);
         header('Location: ' . $download_as);
         exit;
     } else {
         if ($this->exists($hole, $version)) {
             // Calculate download as name
             $download_as = $this->download_as(true);
             // Record a hit
             $id = $this->hit($version);
             // Detect MIME type
             $mime = $this->mime_type($hole);
             // Send out the data
             header("Content-Type: {$mime}");
             header("Last-Modified: " . gmdate("D, d M Y H:i:s", mysql2date('U', $this->updated_at)) . " GMT");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             // HTTP/1.1
             header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
             // Date in the past
             header("Content-Length: " . $this->filesize($hole, $version));
             if ($this->options['force_download'] == true) {
                 header('Content-Disposition: attachment; filename="' . basename($download_as) . '"');
             }
             header("Content-Transfer-Encoding: binary");
             if (!ini_get('safe_mode')) {
                 set_time_limit(0);
             }
             readfile($this->file($hole, $version));
             if ($id) {
                 DH_Access::finished($id, $this->filesize($hole, $version));
             }
             exit;
         }
     }
 }