diff --git a/include/class/package_repository.class.php b/include/class/package_repository.class.php index d78af3aba..cfb3026ac 100644 --- a/include/class/package_repository.class.php +++ b/include/class/package_repository.class.php @@ -42,9 +42,17 @@ class Package_Repository */ function __construct() { - $content=file_get_contents(NOALYSS_PACKAGE_REPOSITORY."/web.xml"); + // Check we can resolve the name + $host=parse_url(NOALYSS_PACKAGE_REPOSITORY,PHP_URL_HOST); + + if (gethostbyname($host) != $host) + { + $content=file_get_contents(NOALYSS_PACKAGE_REPOSITORY."/web.xml"); + $this->content=simplexml_load_string($content); + } else { + $this->content=NULL; + } - $this->content=simplexml_load_string($content); } public function getContent() @@ -72,6 +80,9 @@ class Package_Repository function display_noalyss_info() { global $g_user; + if ( $this->content == NULL ) { + throw new Exception(_("Problème réseau"),10); + } switch ($g_user->lang) { case 'fr_FR.utf8': @@ -94,6 +105,9 @@ class Package_Repository */ function find_plugin($p_code) { + if ( $this->content == NULL ) { + throw new Exception(_("Problème réseau"),10); + } $a_plugin=$this->content->xpath('//plugins/plugin'); $nb_plugin=count($a_plugin); for ($i=0; $i<$nb_plugin; $i++) @@ -114,6 +128,9 @@ class Package_Repository */ function find_template($p_code) { + if ( $this->content == NULL ) { + throw new Exception(_("Problème réseau"),10); + } $a_template=$this->content->xpath('//database_template/dbtemplate'); $nb_template=count($a_template); for ($i=0; $i<$nb_template; $i++) @@ -128,6 +145,9 @@ class Package_Repository function make_object($p_type, $p_id) { + if ( $this->content == NULL ) { + throw new Exception(_("Problème réseau"),10); + } switch ($p_type) { case "core": diff --git a/include/upgrade-core.php b/include/upgrade-core.php index db2997c1d..8ccd967fd 100644 --- a/include/upgrade-core.php +++ b/include/upgrade-core.php @@ -32,6 +32,18 @@ printf (_(" La version de votre installation est %s "),$version_noalyss); $core=new Package_Repository(); $xml=$core->getContent(); +/* + * If xml is null , it means it was not possible to get the file , could be + * a network problem or a misconfiguration + */ +if ( $xml == NULL) { + echo '

'; + printf (_("Désolé , impossible de se connecter au serveur %s"), + NOALYSS_PACKAGE_REPOSITORY); + echo '

'; + return; + +} printf(h1(_("Version %s du %s")),$xml->core->version,$xml->core->date); echo '

'; echo $xml->core->description; diff --git a/include/upgrade-plugin.php b/include/upgrade-plugin.php index 554df6e2f..d557e7cdf 100644 --- a/include/upgrade-plugin.php +++ b/include/upgrade-plugin.php @@ -35,6 +35,18 @@ require_once NOALYSS_INCLUDE.'/class/extension.class.php'; */ $package_repository=new Package_Repository(); $xml=$package_repository->getContent(); +/* + * If xml is null , it means it was not possible to get the file , could be + * a network problem or a misconfiguration + */ +if ( $xml == NULL) { + echo '

'; + printf (_("Désolé , impossible de se connecter au serveur %s"), + NOALYSS_PACKAGE_REPOSITORY); + echo '

'; + return; + +} $a_plugin=$xml->xpath('//plugins/plugin'); $nb_plugin=count($a_plugin); diff --git a/include/upgrade-template.php b/include/upgrade-template.php index 93732055a..3176d32fc 100644 --- a/include/upgrade-template.php +++ b/include/upgrade-template.php @@ -30,6 +30,18 @@ require_once NOALYSS_INCLUDE.'/class/extension.class.php'; $package_repository=new Package_Repository(); $xml=$package_repository->getContent(); +/* + * If xml is null , it means it was not possible to get the file , could be + * a network problem or a misconfiguration + */ +if ( $xml == NULL) { + echo '

'; + printf (_("Désolé , impossible de se connecter au serveur %s"), + NOALYSS_PACKAGE_REPOSITORY); + echo '

'; + return; + +} $a_template=$xml->xpath('//database_template/dbtemplate');