require_once "kernel/clustering/gateway.php"; if (defined('CLUSTER_STORAGE_GATEWAY_PATH') && CLUSTER_STORAGE_GATEWAY_PATH) { $clusterGatewayFile = CLUSTER_STORAGE_GATEWAY_PATH; } else { $clusterGatewayFile = "kernel/clustering/" . CLUSTER_STORAGE_BACKEND . ".php"; } if (!file_exists($clusterGatewayFile)) { if (CLUSTER_ENABLE_DEBUG) { $message = "Unable to open storage backend gateway class definition file '{$clusterGatewayFile}'"; } else { $message = "An error has occured"; } header($_SERVER['SERVER_PROTOCOL'] . " 500 Internal Server Error"); echo <<<EOF <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>500 Internal Server Error</title> </head><body> <h1>{$message}</h1> </body></html> EOF; trigger_error($message, E_USER_ERROR); } // We use require_once as the gateway file may have been included before for initialization purpose require_once $clusterGatewayFile; $gateway = ezpClusterGateway::getGateway(); $filename = ltrim($_SERVER['REQUEST_URI'], '/'); if (($queryPos = strpos($filename, '?')) !== false) { $filename = substr($filename, 0, $queryPos); } $gateway->retrieve($filename);
/** * Sets the gateway class to $gatewayClass * * @param string $gatewayClass */ public static function setGatewayClass($gatewayClass) { self::$gatewayClass = $gatewayClass; }
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');
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' );