From fed665d321c69c3b78514d52cfb688d55d6cdb70 Mon Sep 17 00:00:00 2001 From: Laurent Giovannoni <laurent.giovannoni@maarch.org> Date: Wed, 31 Aug 2011 10:19:46 +0000 Subject: [PATCH] fix : permission of folders in DS and WS fix with uri --- .../trunk/core/class/docservers_controler.php | 4 +- .../web_service/Maarch_SOAP_DISCO_Server.php | 56 +++++++++++++++++++ core/trunk/core/docservers_tools.php | 6 +- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 core/trunk/core/class/web_service/Maarch_SOAP_DISCO_Server.php diff --git a/core/trunk/core/class/docservers_controler.php b/core/trunk/core/class/docservers_controler.php index 59d5148219c..75631532f6d 100644 --- a/core/trunk/core/class/docservers_controler.php +++ b/core/trunk/core/class/docservers_controler.php @@ -1036,7 +1036,7 @@ class docservers_controler //Docserver is empty if ($nbFiles == 0 ) { //Creates the directory - if (!mkdir($pathOnDocserver . '0001', 0000700)) { + if (!mkdir($pathOnDocserver . '0001', 0770)) { return array( 'destinationDir' => '', 'fileDestinationName' => '', @@ -1077,7 +1077,7 @@ class docservers_controler $newDir = ($nbFiles) + 1; if (!mkdir( $pathOnDocserver - . str_pad($newDir, 4, '0', STR_PAD_LEFT), 0000700 + . str_pad($newDir, 4, '0', STR_PAD_LEFT), 0770 ) ) { return array( diff --git a/core/trunk/core/class/web_service/Maarch_SOAP_DISCO_Server.php b/core/trunk/core/class/web_service/Maarch_SOAP_DISCO_Server.php new file mode 100644 index 00000000000..b8b16505883 --- /dev/null +++ b/core/trunk/core/class/web_service/Maarch_SOAP_DISCO_Server.php @@ -0,0 +1,56 @@ +<?php + +require_once('SOAP/Disco.php'); + +class Maarch_SOAP_DISCO_Server extends SOAP_DISCO_Server +{ + public function __construct() + { + call_user_func_array(array(parent, 'SOAP_DISCO_Server'), + func_get_args()); + $this->host = array_key_exists('HTTP_X_FORWARDED_HOST', $_SERVER) + ? $_SERVER['HTTP_X_FORWARDED_HOST'] + : $_SERVER['HTTP_HOST']; + } + + private function selfUrl() + { + $rootUri = self::_getRootUri(); + $protocol = (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'on') + ? 'https://' : 'http://' ; + $selfFilename = basename(__file__); + return $protocol . $this->host . $rootUri; + } + + private static function _getRootUri() + { + $rootUri = array_key_exists('HTTP_X_BASE_URL', $_SERVER) + ? str_replace($_SERVER['HTTP_X_BASE_URL'], '', + $_SERVER['SCRIPT_NAME']) + : $_SERVER['SCRIPT_NAME']; + $endPos = strlen($rootUri) - strrpos($rootUri, '/'); + $rootUri = substr($rootUri, 0, $endPos); + return $rootUri; + } + + public function _generate_WSDL() + { + parent::_generate_WSDL(); + + $this->_wsdl['definitions']['service']['port']['soap:address']['attr']['location'] = + $this->selfUrl(); + + $this->_generate_WSDL_XML(); + } + + public function _generate_DISCO() + { + parent::_generate_DISCO(); + + $this->_disco['disco:discovery']['scl:contractRef']['attr']['ref'] = + $this->selfUrl() . '?wsdl'; + + // generate disco xml + $this->_generate_DISCO_XML($this->_disco); + } +} diff --git a/core/trunk/core/docservers_tools.php b/core/trunk/core/docservers_tools.php index 724e67f61c4..7ea4a1d5a36 100644 --- a/core/trunk/core/docservers_tools.php +++ b/core/trunk/core/docservers_tools.php @@ -109,7 +109,7 @@ function Ds_copyOnDocserver( function Ds_createPathOnDocServer($docServer) { if (!is_dir($docServer . date('Y') . DIRECTORY_SEPARATOR)) { - mkdir($docServer . date('Y') . DIRECTORY_SEPARATOR, 0777); + mkdir($docServer . date('Y') . DIRECTORY_SEPARATOR, 0770); Ds_setRights($docServer . date('Y') . DIRECTORY_SEPARATOR); } if (!is_dir( @@ -120,7 +120,7 @@ function Ds_createPathOnDocServer($docServer) mkdir( $docServer . date('Y') . DIRECTORY_SEPARATOR.date('m') . DIRECTORY_SEPARATOR, - 0777 + 0770 ); Ds_setRights( $docServer . date('Y') . DIRECTORY_SEPARATOR.date('m') @@ -131,7 +131,7 @@ function Ds_createPathOnDocServer($docServer) $path = $docServer . date('Y') . DIRECTORY_SEPARATOR.date('m') . DIRECTORY_SEPARATOR . $GLOBALS['wb'] . DIRECTORY_SEPARATOR; if (!is_dir($path)) { - mkdir($path, 0777); + mkdir($path, 0770); Ds_setRights($path); } else { return array( -- GitLab