Get expired but incomplete uploads.

@param array|null $contents

@return bool
966759
protected function isExpired($contents) : bool
    {
        $isExpired = empty($contents['expires_at']) || Carbon::parse($contents['expires_at'])->lt(Carbon::now());

        if ($isExpired && $contents['offset'] !== $contents['size']) {
            return true;
        }

        return false;
    }
400056
public function isExpired($path)
    {
        $cachePath = $this->getCacheFile($this->getCacheKey($path));

        if (!is_file($cachePath)) {
            return true;
        }

        return filemtime($path) >= filemtime($cachePath);
    }
1018690
public static function create(array $content)
    {
        $access = static::arrayGet($content, 'access');
        $token = static::arrayGet($access, 'token');
        $tokenid = static::arrayGet($token, 'id');
        $expires = static::arrayGet($token, 'expires');

        try {
            $expireDate = new \DateTime($expires);
        } catch (\Exception $e) {
            throw new TokenException(sprintf('Invalid expiration date: %s', $e->getMessage()), null, $e);
        }

        $token = new static($tokenid, $expireDate);

        $catalogs = static::arrayGet($access, 'serviceCatalog');
        if (is_array($catalogs)) {
            foreach ($catalogs as $catalog) {
                $type = static::arrayGet($catalog, 'type');
                $name = static::arrayGet($catalog, 'name');
                $endpoints = static::arrayGet($catalog, 'endpoints');

                if (!is_array($endpoints)) {
                    throw new TokenException(sprintf('Invalid endpoints: %s', json_encode($endpoints)));
                }

                $token->addServiceCatalog($type, $name, $endpoints);
            }
        }

        return $token;
    }
820346
public function getDescendantsContentUids($contents)
    {
        if (false === is_array($contents)) {
            $contents = array($contents);
        }

        $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');

        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('c.'.$meta->getColumnName('subcontent_uid'))
                ->from($meta->getTableName(), 'c');

        $index = 0;
        $atleastone = false;
        foreach ($contents as $content) {
            if (false === ($content instanceof AbstractClassContent)) {
                continue;
            }

            if (true === $content->isElementContent()) {
                continue;
            }

            $q->orWhere('c.'.$meta->getColumnName('content_uid').' = :uid'.$index)
                    ->setParameter('uid'.$index, $content->getUid());

            $index++;
            $atleastone = true;
        }

        return (true === $atleastone) ? array_unique($q->execute()->fetchAll(\PDO::FETCH_COLUMN)) : array();
    }
436953
protected function set_data(array $contents = [])
    {
        $definition = [
            'REQUEST_METHOD' => [
                'filter' => FILTER_CALLBACK,
                'options' => function ($method) {
                    return \strtoupper(\filter_var($method, FILTER_SANITIZE_STRING));
                },
            ],
            'QUERY_STRING' => FILTER_UNSAFE_RAW,
            'REMOTE_ADDR' => FILTER_VALIDATE_IP,
            'SERVER_PORT' => FILTER_SANITIZE_NUMBER_INT,
            'SERVER_NAME' => FILTER_SANITIZE_STRING,
            'HTTP_HOST' => FILTER_SANITIZE_URL,
            'HTTP_REFERER' => FILTER_SANITIZE_URL,
            'HTTP_USER_AGENT' => FILTER_SANITIZE_STRING,
        ];

        $server = \filter_input_array(INPUT_SERVER, $definition);

        if ('' !== \preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $server['HTTP_HOST'])) {
            \wp_die('This site has been temporarily disabled due to suspicious activity');
        }

        $this->data = $server;
    }
604242
public function checkAccessTokenExpired()
    {
        // don't have the data? Let's assume the token has expired
        if (!isset($this->token['created_at']) || !isset($this->token['expires_in'])) {
            return true;
        }

        return ($this->token['created_at'] + $this->token['expires_in']) < time();
    }
924972
public function getIsExpired()
    {
        $createdAt = $this->getCreatedAt();
        if ($this->getExpiredAfter() === false || $createdAt === null) {
            return false;
        }
        if ($this->timeType == static::$timeTypeLocal) {
            return $this->getDatetimeOffset($this->offsetDatetime($this->currentDatetime(), -$this->getExpiredAfter()), $createdAt) > 0;
        } elseif ($this->timeType == static::$timeTypeUtc) {
            return $this->getDatetimeOffset($this->offsetDatetime($this->currentUtcDatetime(), -$this->getExpiredAfter()), $createdAt) > 0;
        }
        return false;
    }
395836
public function expired()
    {
        if (empty($this->expiresOn)) {
            return false;
        }

        return AnDomainAttributeDate::getInstance()->toDate()->compare($this->expiresOn) > 0;
    }
1245344
public function isExpired( $path )
	{
		$compiled = $this->getCompiledPath( $path );

		// If the compiled file doesn't exist we will indicate that the view is expired
		// so that it can be re-compiled. Else, we will verify the last modification
		// of the views is less than the modification times of the compiled views.
		if ( !$this->files->exists( $compiled ) )
		{
			return true;
		}

		$lastModified = $this->files->lastModified( $path );

		return $lastModified >= $this->files->lastModified( $compiled );
	}
1048472
public function save($contents)
	{
		// get the formatted output
		$output = $this->export_format($contents);

		if ( ! $output)
		{
			return false;
		}

		if ( ! $path = \Finder::search('config', $this->file, $this->ext))
		{
			if ($pos = strripos($this->file, '::'))
			{
				// get the namespace path
				if ($path = \Autoloader::namespace_path('\\'.ucfirst(substr($this->file, 0, $pos))))
				{
					// strip the namespace from the filename
					$this->file = substr($this->file, $pos+2);

					// strip the classes directory as we need the module root
					$path = substr($path,0, -8).'config'.DS.$this->file.$this->ext;
				}
				else
				{
					// invalid namespace requested
					return false;
				}
			}
		}

		// absolute path requested?
		if ($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':'))
		{
			$path = $this->file;
		}

		// make sure we have a fallback
		$path or $path = APPPATH.'config'.DS.$this->file.$this->ext;

		$path = pathinfo($path);
		if ( ! is_dir($path['dirname']))
		{
			mkdir($path['dirname'], 0777, true);
		}

		$return = \File::update($path['dirname'], $path['basename'], $output);
		if ($return)
		{
			try
			{
				\Config::load('file', true);
				chmod($path['dirname'].DS.$path['basename'], \Config::get('file.chmod.files', 0666));
			}
			catch (\PhpErrorException $e)
			{
				// if we get something else then a chmod error, bail out
				if (substr($e->getMessage(),0,8) !== 'chmod():')
				{
					throw new $e;
				}
			}
		}
		return $return;
	}
127200
private function isCacheExpired()
    {
        if (empty($this->cacheInterval)) {
            return true;
        }

        $cache_file = $this->cacheDirectory.'/translations/cache_timestamp';
        $cache_dir  =$this->cacheDirectory.'/translations';
        if ('\\' === DIRECTORY_SEPARATOR) {
            $cache_file = strtr($cache_file, '/', '\\');
            $cache_dir = strtr($cache_dir, '/', '\\');
        }
        if (!\is_dir($cache_dir)) {
            \mkdir($cache_dir);
        }        
        if (!\file_exists($cache_file)) {
            \touch($cache_file);
            return true;
        }
        $expired = false;
        if ((\time() - \filemtime($cache_file)) > $this->cacheInterval) {
            \file_put_contents($cache_file, \time());
            $expired = true;
        }

        return $expired;
    }
179946
public static function moveTemporaryUploads($content, $destFolder, &$tmpFiles)
    {
        $replace = [];

        $folder = Folder::find_or_make($destFolder);

        /* @var $file File */
        foreach ($tmpFiles as $file) {

            // Keep a copy of the old url to remplace with a new one in the html content
            $oldURL = $file->getURL();

            $name = pathinfo($file->Name, PATHINFO_FILENAME);
            $ext = pathinfo($file->Name, PATHINFO_EXTENSION);

            $file->Name = $name . '_' . time() . '.' . $ext;
            $file->ParentID = $folder->ID;
            $file->write();

            $replace[$oldURL] = $file->getURL();
        }

        $content = str_replace(array_keys($replace), array_values($replace), $content);

        return $content;
    }
358969
protected function isCacheExpired()
    {
        $ts = filemtime($this->filePath);
        if (!$this->cacheOnly && time() - $ts >= $this->refreshInterval) {
            $this->log->debug("Cache content {$this->filePath} expired ({$this->refreshInterval})");

            return true;
        }

        return false;
    }
820399
private function getAClassContentUids(array $contents)
    {
        $contentUids = array();
        foreach ($contents as $content) {
            if ($content instanceof AbstractClassContent &&
                    false === $content->isElementContent()) {
                $contentUids[] = $content->getUid();
            }
        }

        return $contentUids;
    }
200100
public function cleanUp( $expires = 0 )
	{
		$expires	= $expires ? $expires : $this->expires;
		if( !$expires )
			throw new InvalidArgumentException( 'No expire time given or set on construction.' );

		$number	= 0;
		$index	= new DirectoryIterator( $this->path );
		foreach( $index as $entry )
		{
			if( $entry->isDot() || $entry->isDir() )
				continue;
			$pathName	= $entry->getPathname();
			if( substr( $pathName, -7 ) !== ".serial" )
				continue;
			if( $this->isExpired( $pathName, $expires ) )
				$number	+= (int) @unlink( $pathName );
		}
		return $number;
	}
45174
protected function save($contents)
    {
        $fp = fopen($this->fileName, $this->openMode);
        fwrite($fp, $contents);
        fclose($fp);

        chmod($this->fileName, $this->getPermission());
    }
1063789
public function isCheckRequired()
    {
        if ($this->expired === false) {
            return false;
        }

        if ($this->cacheFile->exists()) {
            $expiryTimestamp = (int) $this->cacheFile->read();
        } else {
            $expiryTimestamp = 0;
        }
        $ts = Carbon::createFromTimestamp($expiryTimestamp + self::CHECK_INTERVAL);

        return $this->expired = $ts->isPast();
    }