throw new RuntimeException("Failed to fetch file metadata for '{$filepath}'");
        }
        if ($stmt->rowCount() == 0) {
            return false;
        }
        return $stmt->fetch(PDO::FETCH_ASSOC);
    }
    public function passthrough($filepath, $filesize, $offset = false, $length = false)
    {
        $dfsFilePath = CLUSTER_MOUNT_POINT_PATH . '/' . $filepath;
        if (!file_exists($dfsFilePath)) {
            throw new RuntimeException("Unable to open DFS file '{$dfsFilePath}'");
        }
        $fp = fopen($dfsFilePath, 'rb');
        if ($offset !== false && @fseek($fp, $offset) === -1) {
            throw new RuntimeException("Failed to seek offset {$offset} on file '{$filepath}'");
        }
        if ($offset === false && $length === false) {
            fpassthru($fp);
        } else {
            echo fread($fp, $length);
        }
        fclose($fp);
    }
    public function close()
    {
        unset($this->db);
    }
}
ezpClusterGateway::setGatewayClass('ezpDfsPostgresqlClusterGateway');
Exemple #2
0
        if (!($res = mysql_query($sql, $this->db))) {
            throw new RuntimeException("Failed to fetch file metadata for '{$filepath}' " . "(error #" . mysql_errno($this->db) . ": " . mysql_error($this->db));
        }
        if (mysql_num_rows($res) == 0) {
            return false;
        }
        $metadata = mysql_fetch_assoc($res);
        mysql_free_result($res);
        return $metadata;
    }
    public function passthrough($filepath, $filesize, $offset = false, $length = false)
    {
        if ($offset !== false) {
            throw new UnexpectedValueException("HTTP Range is not supported by " . __CLASS__);
        }
        if (!($res = mysql_query("SELECT filedata FROM ezdbfile_data WHERE name_hash=MD5('{$filepath}') ORDER BY offset ASC", $this->db))) {
            throw new RuntimeException("Unable to open file data for '{$filepath}' " . "(error #" . mysql_errno($this->db) . ": " . mysql_error($this->db));
        }
        while ($row = mysql_fetch_row($res)) {
            echo $row[0];
        }
        mysql_free_result($res);
    }
    public function close()
    {
        mysql_close($this->db);
        unset($this->db);
    }
}
ezpClusterGateway::setGatewayClass('ezpDbMySQLClusterGateway');
        mysqli_free_result( $res );
        return $metadata;
    }

    public function passthrough( $filepath, $filesize, $offset = false, $length = false )
    {
        $dfsFilePath = CLUSTER_MOUNT_POINT_PATH . '/' . $filepath;

        if ( !file_exists( $dfsFilePath ) )
            throw new RuntimeException( "Unable to open DFS file '$dfsFilePath'" );

        $fp = fopen( $dfsFilePath, 'rb' );
        if ( $offset !== false && @fseek( $fp, $offset ) === -1 )
            throw new RuntimeException( "Failed to seek offset $offset on file '$filepath'" );
        if ( $offset === false && $length === false )
            fpassthru( $fp );
        else
            echo fread( $fp, $length );

        fclose( $fp );
    }

    public function close()
    {
        mysqli_close( $this->db );
        unset( $this->db );
    }
}

ezpClusterGateway::setGatewayClass( 'ezpDfsMySQLiClusterGateway' );