Пример #1
0
 public function execute()
 {
     $documents = array();
     foreach ($this->url_queue as $url) {
         if ($this->config['timeout']) {
             usleep($this->config['timeout']);
         }
         $download = new Downloader($url, $this->config['referer'], $this->config['user_agent']);
         $documents[] = array('url' => $url, 'doc' => $download->execute());
         if ($download->get_status() == '404') {
             $this->count_404++;
         } else {
             $this->count_404 = 0;
         }
         if ($this->config['give_up_404'] && $this->count_404 >= $this->config['give_up_404']) {
             $this->last_error = 'Maximum 404s hit';
             return false;
         }
     }
     return $documents;
 }
Пример #2
0
<thead>
<?php 
$downloader = new Downloader();
$status_files = $downloader->get_status_files();
?>
        <tr>
<th style="min-width:400px; height:35px">Title</th>
<th style="min-width:80px">Size</th>
<th style="min-width:200px">Percentage</th>
<th style="min-width:80px">Speed</th>
<th style="min-width:110px">ETA</th>
</tr>
      <?php 
foreach ($status_files as $status_file) {
    //$data=$downloader->get_status_file($status_file);
    $status = $downloader->get_status($status_file);
    if (is_array($status)) {
        if ($status['percentage'] == '100.0%') {
            $status['eta'] = 'Complete';
        }
        $status_file = str_replace('.json', "", $status_file);
        $status_file = str_replace('status-', "", $status_file);
        echo '<tr>
                <td>' . $status_file . '</td>
                <td>' . $status['size'] . '</td>
                <td><div class="progress">
                                                        <div class="progress-bar" role="progressbar" aria-valuenow="' . str_replace("%", "", $status['percentage']) . '" aria-valuemin="0" aria-valuemax="100" style="width:' . $status['percentage'] . ' ;">
                                                            <span class="sr-only">' . $status['percentage'] . ' Complete</span>
                                                        </div>
                                                </div>' . $status['percentage'] . '</td>
                <td>' . $status['speed'] . '</td>