当前位置: 首页>>代码示例>>PHP>>正文


PHP system::delete_marked_files方法代码示例

本文整理汇总了PHP中system::delete_marked_files方法的典型用法代码示例。如果您正苦于以下问题:PHP system::delete_marked_files方法的具体用法?PHP system::delete_marked_files怎么用?PHP system::delete_marked_files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system的用法示例。


在下文中一共展示了system::delete_marked_files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gallery_shutdown

 static function gallery_shutdown()
 {
     // Every 500th request, do a pass over var/logs and var/tmp and delete old files.
     // Limit ourselves to deleting a single file so that we don't spend too much CPU
     // time on it.  As long as servers call this at least twice a day they'll eventually
     // wind up with a clean var/logs directory because we only create 1 file a day there.
     // var/tmp might be stickier because theoretically we could wind up spamming that
     // dir with a lot of files.  But let's start with this and refine as we go.
     if (!(rand() % 500)) {
         // Note that this code is roughly duplicated in gallery_task::file_cleanup
         $threshold = time() - 1209600;
         // older than 2 weeks
         foreach (array("logs", "tmp") as $dir) {
             $dir = VARPATH . $dir;
             if ($dh = opendir($dir)) {
                 while (($file = readdir($dh)) !== false) {
                     if ($file[0] == ".") {
                         continue;
                     }
                     // Ignore directories for now, but we should really address them in the long term.
                     if (is_dir("{$dir}/{$file}")) {
                         continue;
                     }
                     if (filemtime("{$dir}/{$file}") <= $threshold) {
                         unlink("{$dir}/{$file}");
                         break;
                     }
                 }
             }
         }
     }
     // Delete all files marked using system::delete_later.
     system::delete_marked_files();
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:34,代码来源:gallery_event.php

示例2: add_watermark_reject_illegal_file_with_legal_extension_test

 public function add_watermark_reject_illegal_file_with_legal_extension_test()
 {
     // Source is a php file, watermark path has extension jpg
     $name = test::random_name();
     $source_path = MODPATH . "watermark/tests/Admin_Watermarks_Controller_Test.php";
     $watermark_path = TMPPATH . "uploadfile-123-{$name}.jpg";
     copy($source_path, $watermark_path);
     // Setup and run Admin_Watermarks_Controller::add
     $controller = new Admin_Watermarks_Controller();
     $_POST["file"] = $watermark_path;
     $_POST["csrf"] = access::csrf_token();
     ob_start();
     $controller->add();
     $results = ob_get_clean();
     // Delete all files marked using system::delete_later (from gallery_event::gallery_shutdown)
     system::delete_marked_files();
     // Add should *not* be successful, and watermark should be deleted
     $this->assert_equal("", $results);
     $this->assert_false(file_exists($watermark_path));
     $this->assert_false(file_exists(VARPATH . "modules/watermark/{$name}.php"));
     $this->assert_false(file_exists(VARPATH . "modules/watermark/{$name}.jpg"));
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:22,代码来源:Admin_Watermarks_Controller_Test.php


注:本文中的system::delete_marked_files方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。