Subversion Repositories oidplus

Rev

Rev 1308 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1308 Rev 1469
Line 268... Line 268...
268
        // First extract comments we want to keep, so they can be restored later
268
        // First extract comments we want to keep, so they can be restored later
269
        // PHP only supports $this inside anonymous functions since 5.4
269
        // PHP only supports $this inside anonymous functions since 5.4
270
        $minifier = $this;
270
        $minifier = $this;
271
        $callback = function ($match) use ($minifier) {
271
        $callback = function ($match) use ($minifier) {
272
            $count = count($minifier->extracted);
272
            $count = count($minifier->extracted);
273
            $placeholder = '/*'.$count.'*/';
273
            $placeholder = '/*' . $count . '*/';
274
            $minifier->extracted[$placeholder] = $match[0];
274
            $minifier->extracted[$placeholder] = $match[0];
275
 
275
 
276
            return $placeholder;
276
            return $placeholder;
277
        };
277
        };
278
        $this->registerPattern('/
278
        $this->registerPattern('/
Line 492... Line 492...
492
    protected function canImportFile($path)
492
    protected function canImportFile($path)
493
    {
493
    {
494
        $parsed = parse_url($path);
494
        $parsed = parse_url($path);
495
        if (
495
        if (
496
            // file is elsewhere
496
            // file is elsewhere
497
            isset($parsed['host']) ||
497
            isset($parsed['host'])
498
            // file responds to queries (may change, or need to bypass cache)
498
            // file responds to queries (may change, or need to bypass cache)
499
            isset($parsed['query'])
499
            || isset($parsed['query'])
500
        ) {
500
        ) {
501
            return false;
501
            return false;
502
        }
502
        }
503
 
503
 
-
 
504
        try {
504
        return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
505
            return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
-
 
506
        }
-
 
507
        // catch openbasedir exceptions which are not caught by @ on is_file()
-
 
508
        catch (\Exception $e) {
-
 
509
            return false;
-
 
510
        }
505
    }
511
    }
506
 
512
 
507
    /**
513
    /**
508
     * Attempts to open file specified by $path for writing.
514
     * Attempts to open file specified by $path for writing.
509
     *
515
     *
Line 532... Line 538...
532
     * @throws IOException
538
     * @throws IOException
533
     */
539
     */
534
    protected function writeToFile($handler, $content, $path = '')
540
    protected function writeToFile($handler, $content, $path = '')
535
    {
541
    {
536
        if (
542
        if (
537
            !is_resource($handler) ||
543
            !is_resource($handler)
538
            ($result = @fwrite($handler, $content)) === false ||
544
            || ($result = @fwrite($handler, $content)) === false
539
            ($result < strlen($content))
545
            || ($result < strlen($content))
540
        ) {
546
        ) {
541
            throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
547
            throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
542
        }
548
        }
543
    }
549
    }
544
 
550