Example #1
0
/******************************************************************************/
/******************************************************************************/
$Tmp = System_Element('tmp');
if (Is_Error($Tmp)) {
    return ERROR | @Trigger_Error(500);
}
#-------------------------------------------------------------------------------
$Folder = SPrintF('%s/files', $Tmp);
#-------------------------------------------------------------------------------
if (File_Exists($Folder)) {
    #-----------------------------------------------------------------------------
    $Files = IO_Scan($Folder);
    if (Is_Error($Files)) {
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    foreach ($Files as $File) {
        #---------------------------------------------------------------------------
        $Path = SPrintF('%s/%s', $Folder, $File);
        #---------------------------------------------------------------------------
        if (Time() - FileMTime($Path) > 86400) {
            #-------------------------------------------------------------------------
            if (!@UnLink($Path)) {
                return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Temp]: не удалось удалить файл (%s)', $Path));
            }
        }
    }
}
#-------------------------------------------------------------------------------
return 86400;
#-------------------------------------------------------------------------------
Example #2
0
        return ERROR | @Trigger_Error(500);
    }
    #-----------------------------------------------------------------------------
    foreach ($Files as $Log) {
        #---------------------------------------------------------------------------
        $Path = SPrintF('%s/%s', $Logs, $Log);
        #---------------------------------------------------------------------------
        if (Preg_Match('/^.+\\.log+$/', $Log)) {
            #-------------------------------------------------------------------------
            if (FileSize($Path) > 1048576) {
                #-----------------------------------------------------------------------
                $Time = Date('[d.m.Y]');
                #-----------------------------------------------------------------------
                if (!ReName($Path, SPrintF('%s/%s%s', $Logs, $Log, $Time))) {
                    return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Logs]: не удалось произвести ротацию лога (%s)', $Path));
                }
            }
        } else {
            #-------------------------------------------------------------------------
            if (Time() - FileMTime($Path) > 604800) {
                #-----------------------------------------------------------------------
                if (!@UnLink($Path)) {
                    return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Logs]: не удалось удалить устаревший лог (%s)', $Path));
                }
            }
        }
    }
}
#-------------------------------------------------------------------------------
return 86400;
#-------------------------------------------------------------------------------
Example #3
0
 private function CreateHandle($Master, $URL)
 {
     $Slave = cURL_Init();
     $File = $URL['File'];
     $Options = $this->Options;
     $Options[CURLOPT_URL] = $this->GenerateURL($URL['URL']);
     $this->Requests[(int) $Slave] = $File;
     if ($this->UseCache) {
         // If we have an ETag saved, add If-None-Match header
         if (Array_Key_Exists($File, $this->ETags)) {
             $Options[CURLOPT_HTTPHEADER] = array('If-None-Match: ' . $this->ETags[$File]);
         } else {
             if (File_Exists($File)) {
                 $Options[CURLOPT_HTTPHEADER] = array('If-Modified-Since: ' . GMDate('D, d M Y H:i:s \\G\\M\\T', FileMTime($File)));
             }
         }
     }
     cURL_SetOpt_Array($Slave, $Options);
     cURL_Multi_Add_Handle($Master, $Slave);
     return $Slave;
 }
 function Resampled_Image_URL($attachment_id, $width = 0, $height = 0, $crop = False, $grayscale = False, $negate = False, $qualy = 80)
 {
     global $blog_id;
     // Mime Type
     list($attachment_mime, $attachment_type) = Explode('/', get_post_mime_type($attachment_id));
     // Attachment file
     $attachment_file = RealPath(get_attached_file($attachment_id));
     // Read Cache Directory and URL
     $cache_file_name = '/image_thumbs/' . IntVal($blog_id) . '-' . IntVal($attachment_id) . '-' . IntVal($width) . '-' . IntVal($height) . '-' . IntVal($crop) . '-' . IntVal($grayscale) . '-' . IntVal($negate) . '-' . IntVal($qualy) . '.' . $attachment_type;
     if (Is_File(WP_CONTENT_DIR . $cache_file_name) && Is_File($attachment_file) && FileSize(WP_CONTENT_DIR . $cache_file_name) > 0 && FileMTime(WP_CONTENT_DIR . $cache_file_name) > FileMTime($attachment_file)) {
         return WP_CONTENT_URL . $cache_file_name;
     } else {
         return $this->base_url . '/wp-thumb.php?' . HTTP_Build_Query(array('a' => IntVal($attachment_id), 'w' => IntVal($width), 'h' => IntVal($height), 'c' => IntVal($crop), 'g' => IntVal($grayscale), 'n' => IntVal($negate), 'q' => IntVal($qualy)));
     }
 }
Example #5
0
 #-------------------------------------------------------------------------------
 $Files = IO_Scan($Sessions);
 if (Is_Error($Files)) {
     return ERROR | @Trigger_Error(500);
 }
 #-------------------------------------------------------------------------------
 foreach ($Files as $File) {
     #-------------------------------------------------------------------------------
     $Path = SPrintF('%s/%s', $Sessions, $File);
     #-------------------------------------------------------------------------------
     if (Preg_Match('/^REMEBMER/', $File) && Time() - FileMTime($Path) < 24 * 3600 * $Params['Sessions']['RememberTTL']) {
         continue;
     }
     #-------------------------------------------------------------------------------
     #-------------------------------------------------------------------------------
     if (Time() - FileMTime($Path) > $Params['Sessions']['SessionTTL']) {
         #-------------------------------------------------------------------------------
         if (UnLink($Path)) {
             #-------------------------------------------------------------------------------
             $Count++;
             #-------------------------------------------------------------------------------
         } else {
             #-------------------------------------------------------------------------------
             return ERROR | @Trigger_Error(SPrintF('[comp/Tasks/Sessions]: не удалось удалить файл сессии (%s)', $Path));
             #-------------------------------------------------------------------------------
         }
         #-------------------------------------------------------------------------------
     }
     #-------------------------------------------------------------------------------
 }
 #-------------------------------------------------------------------------------
Example #6
0
 function check_for_cached_file()
 {
     // Take a look over the cache. Maybe there is this file already
     if ($this->use_cache && Is_File($this->cache_file_path) && FileSize($this->cache_file_path) > 0 && FileMTime($this->cache_file_path) > FileMTime($this->attachment_file)) {
         Header('Location: ' . $this->cache_file_url);
         exit;
     }
 }