Example #1
0
 /**
  * $file_pathが属するパッケージのパスを返す
  * @param $file_path ファイルパス
  * @return string
  */
 public static function module_root_path($file_path)
 {
     $package = File::dirname($file_path);
     while ($package !== null) {
         $package_class = File::basename($package);
         if ($package_class === null) {
             break;
         }
         if (ctype_upper($package_class[0]) && is_file($package . '/' . $package_class . '.php')) {
             return $package;
         }
         $package = File::dirname($package);
     }
     $file = new File($file_path);
     return substr($file->fullname(), 0, strlen($file->ext()) * -1);
 }
Example #2
0
 /**
  * attachmentで出力する
  * @param File $file 出力するファイル
  */
 public static function attach(File $file)
 {
     Log::disable_display();
     if (is_file($file->fullname()) || $file->value() !== null) {
         if ($file->update() > 0) {
             if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $file->update() <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
                 self::status_header(304);
                 exit;
             }
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file->update()) . ' GMT');
         }
         header(sprintf('Content-Type: ' . $file->mime() . '; name=%s', $file->name()));
         header(sprintf('Content-Disposition: attachment; filename=%s', $file->name()));
         if ($file->size() > 0) {
             header(sprintf('Content-length: %u', $file->size()));
         }
         $file->output();
     }
     self::status_header(404);
     exit;
 }