noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 11/11: Task #1610 - Problème dans le menu «i


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 11/11: Task #1610 - Problème dans le menu «installation» #0001610: Problème dans le menu «installation»
Date: Tue, 17 Jul 2018 04:04:30 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 9029b48a7890b599952a4acb728b05628712ca61
Author: Dany De Bontridder <address@hidden>
Date:   Tue Jul 17 10:01:22 2018 +0200

    Task #1610 - Problème dans le menu «installation»
    #0001610: Problème dans le menu «installation»
---
 include/class/package_repository.class.php | 24 ++++++++++++++++++++++--
 include/upgrade-core.php                   | 12 ++++++++++++
 include/upgrade-plugin.php                 | 12 ++++++++++++
 include/upgrade-template.php               | 12 ++++++++++++
 4 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/include/class/package_repository.class.php 
b/include/class/package_repository.class.php
index d78af3a..cfb3026 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 db2997c..8ccd967 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 '<h2 class="error">';
+    printf (_("Désolé , impossible de se connecter au serveur %s"),
+            NOALYSS_PACKAGE_REPOSITORY);
+    echo '</h2>';
+    return;
+    
+}
 printf(h1(_("Version %s du %s")),$xml->core->version,$xml->core->date);
 echo '<p>';
 echo $xml->core->description;
diff --git a/include/upgrade-plugin.php b/include/upgrade-plugin.php
index 554df6e..d557e7c 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 '<h2 class="error">';
+    printf (_("Désolé , impossible de se connecter au serveur %s"),
+            NOALYSS_PACKAGE_REPOSITORY);
+    echo '</h2>';
+    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 9373205..3176d32 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 '<h2 class="error">';
+    printf (_("Désolé , impossible de se connecter au serveur %s"),
+            NOALYSS_PACKAGE_REPOSITORY);
+    echo '</h2>';
+    return;
+    
+}
 
 
 $a_template=$xml->xpath('//database_template/dbtemplate');



reply via email to

[Prev in Thread] Current Thread [Next in Thread]