Subversion Repositories oidplus

Rev

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

Rev 1308 Rev 1469
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);
505
    }
506
        }
-
 
507
        // catch openbasedir exceptions which are not caught by @ on is_file()
-
 
508
        catch (\Exception $e) {
-
 
509
            return false;
-
 
510
        }
-
 
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
     *
510
     * @param string $path The path to the file
516
     * @param string $path The path to the file
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