Ejemplo n.º 1
0
 public function download($params)
 {
     if (!is_admin()) {
         error('must be admin');
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'memory_limit')) {
         ini_set('memory_limit', '512M');
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
         set_time_limit(0);
     }
     if (isset($params['id'])) {
         $id = $params['id'];
     } elseif (isset($_GET['filename'])) {
         $id = $params['filename'];
     } elseif (isset($_GET['file'])) {
         $id = $params['file'];
     }
     $id = str_replace('..', '', $id);
     if ($id == null) {
         return array('error' => 'You have not provided filename to download.');
     }
     $here = $this->get_bakup_location();
     $filename = $here . $id;
     $filename = str_replace('..', '', $filename);
     if (!is_file($filename)) {
         return array('error' => 'You have not provided a existing filename to download.');
     }
     $dl = new \Microweber\Utils\Files();
     return $dl->download_to_browser($filename);
 }
Ejemplo n.º 2
0
 function download($params)
 {
     if (!is_admin()) {
         error("must be admin");
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'memory_limit')) {
         ini_set('memory_limit', '512M');
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
         set_time_limit(0);
     }
     if (isset($params['id'])) {
         $id = $params['id'];
     } else {
         if (isset($_GET['filename'])) {
             $id = $params['filename'];
         } else {
             if (isset($_GET['file'])) {
                 $id = $params['file'];
             }
         }
     }
     $id = str_replace('..', '', $id);
     // Check if the file has needed args
     if ($id == NULL) {
         return array('error' => "You have not provided filename to download.");
         die;
     }
     $here = $this->get_bakup_location();
     // Generate filename and set error variables
     $filename = $here . $id;
     $filename = str_replace('..', '', $filename);
     if (!is_file($filename)) {
         return array('error' => "You have not provided a existing filename to download.");
         die;
     }
     if (is_file($filename)) {
         $dl = new \Microweber\Utils\Files();
         return $dl->download_to_browser($filename);
     }
 }