Ticket #336: configure-detection.patch

File configure-detection.patch, 16.8 kB (added by anonymous, 2 years ago)

the patch

  • .php

    old new  
    9898    define('OK', "ok"); 
    9999    define('WARN', "warn"); 
    100100    define('ERROR', "error"); 
     101    define('UNK_VER', "unk"); 
    101102    define('UPDATE', "update"); 
    102103 
    103104    function print_row($left, $right, $err = OK) { 
     
    111112            case UPDATE: 
    112113                $color = "#DDDD00"; 
    113114                break; 
     115            case UNK_VER: 
     116                $status = "<b>UNKNOW VERSION</b>"; 
     117                $color = "#9999FF"; 
     118                break; 
    114119            case ERROR: 
    115120                $color = "#FE899B"; 
    116121                $status = "<b>FAILED</b>"; 
     
    132137 
    133138    $status = OK; 
    134139 
     140    function check_pear_module($my_path, $my_function = '') { 
     141        $ret = @include_once $my_path; 
     142        // Test the user given function 
     143        if ($res && isset($my_function)) { 
     144            $func_ret = call_user_func($my_function); 
     145            if ($func_ret) { 
     146                $ret = false; 
     147                $msg = $func_ret; 
     148            } 
     149        } 
     150        return $ret; 
     151    } 
     152 
    135153    //smarty compile dirs file permissions. 
    136154    $smarty_base = "../themes"; // this assumes configtest.php is located in webroot/admin/ 
    137155    $result = ""; 
     
    296314    // PEAR::Mail_Mime 
    297315    if ($have_pear) { 
    298316      if (!in_array("mail_mime", $pear_list)) { 
    299         $result = "Not installed.  This PHP extension is required to decode " . 
    300                   "MIME-structured e-mail.  Use <b>pear install Mail_Mime</b> to " . 
    301                   "install this."; 
    302         $status = ERROR; 
     317        $installed = check_pear_module('Mail/mime.php'); 
     318        if (! $installed) { 
     319          $result = "Not installed.  This PHP extension is required to decode " . 
     320                    "MIME-structured e-mail.  Use <b>pear install Mail_Mime</b> to " . 
     321                    "install this."; 
     322          $status = ERROR; 
     323        } else { 
     324          $result = "Installed, but cannot determine version. Please check your " . 
     325                    "system package manager. Versions of Mail_Mime below 1.3.0  " . 
     326                    "are known to be buggy."; 
     327          $status = UNK_VER; 
     328        } 
    303329      } else { 
    304330        $info = $pear_reg->packageInfo("Mail_Mime"); 
    305331        $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    314340        } 
    315341      } 
    316342    } else { 
     343         
    317344        $result = "Requires PEAR"; 
    318345        $status = WARN; 
    319346    } 
     
    329356    // PEAR::DB 
    330357    if ($have_pear) { 
    331358        if (!in_array("db", $pear_list)) { 
     359          $installed = check_pear_module('DB.php'); 
     360          if (! $installed) { 
    332361            $result = "Not installed.  This PHP extension is required in order to provide " . 
    333362                      "database abstraction.  Use <b>pear install DB</b> to install this."; 
    334363            $status = ERROR; 
     364         } else { 
     365           $result = "Installed, but cannot determine version. Please check your " . 
     366                     "system package manager."; 
     367           include_once ("DB.php"); 
     368           $test_dbh = DB::connect($maia_sql_dsn); 
     369           if (DB::isError($test_dbh)) { 
     370               $result .= "Could not connect to database.  Check the \$maia_sql_dsn setting in config.php."; 
     371               $status = ERROR; 
     372           } else { 
     373               $result .= "Database connexion test OK."; 
     374               $status = UNK_VER; 
     375           } 
     376         } 
    335377        } else { 
    336378          $db_info = $pear_reg->packageInfo("DB"); 
    337379          $pathArray = explode( PATH_SEPARATOR, get_include_path() ); 
     
    363405    // PEAR::Pager 
    364406    if ($have_pear) { 
    365407        if (!in_array("pager", $pear_list)) { 
    366             $result = "Not installed.  This PHP extension is required in order to paginate " . 
    367                       "the list of mail items in the quarantines and the ham cache.  Use " . 
    368                       "<b>pear install Pager</b> to install this."; 
    369             $status = ERROR; 
     408            $installed = check_pear_module('Pager/Pager.php'); 
     409            if (! $installed) { 
     410                $result = "Not installed.  This PHP extension is required in order to paginate " . 
     411                          "the list of mail items in the quarantines and the ham cache.  Use " . 
     412                          "<b>pear install Pager</b> to install this."; 
     413                $status = ERROR; 
     414            } else { 
     415                $result = "Installed, but cannot determine version. Please check your " . 
     416                          "system package manager."; 
     417                $status = UNK_VER; 
     418            } 
    370419        } else { 
    371420            $pager_info = $pear_reg->packageInfo("Pager"); 
    372421            $result = is_array($pager_info["version"])?$pager_info["version"]["release"]:$pager_info["version"]; 
     
    379428    print_row("PEAR::Pager", $result, $status); 
    380429 
    381430 
    382           // PEAR::Net_Socket 
     431    // PEAR::Net_Socket 
    383432    if ($have_pear) { 
    384433        if (!in_array("net_socket", $pear_list)) { 
    385             $result = "Not installed.  This PHP extension is required for Net_SMTP to send mail when rescuing email"; 
    386             $status = ERROR; 
     434            $installed = check_pear_module('Net/Socket.php'); 
     435            if (! $installed) { 
     436                $result = "Not installed.  This PHP extension is required for Net_SMTP to send mail when rescuing email"; 
     437                $status = ERROR; 
     438            } else { 
     439                $result = "Installed, but cannot determine version. Please check your " . 
     440                          "system package manager."; 
     441                $status = UNK_VER; 
     442            } 
    387443        } else { 
    388444            $info = $pear_reg->packageInfo("Net_Socket"); 
    389445            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    398454 
    399455    // PEAR::Net_SMTP 
    400456    if ($have_pear) { 
    401       if (!in_array("net_smtp", $pear_list)) { 
    402         $result = "Not installed.  This PHP extension is required to send mail when rescuing email"; 
    403         $status = ERROR; 
    404       } else { 
    405         $info = $pear_reg->packageInfo("Net_SMTP"); 
    406         $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
    407         if (version_compare($result,"1.2.5") < 0) { 
    408           $version = $result; 
    409           $result = "Version $version installed.  Need at least 1.2.5"; 
    410           $status = ERROR; 
     457        if (!in_array("net_smtp", $pear_list)) { 
     458            $installed = check_pear_module('Net/SMTP.php'); 
     459            if (! $installed) { 
     460                $result = "Not installed.  This PHP extension is required to send mail when rescuing email"; 
     461                $status = ERROR; 
     462            } else { 
     463                $result = "Installed, but cannot determine version. Please check your " . 
     464                          "system package manager. Need at least version 1.2.5"; 
     465                $status = UNK_VER; 
     466            } 
    411467        } else { 
    412           $status = OK; 
     468            $info = $pear_reg->packageInfo("Net_SMTP"); 
     469            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     470            if (version_compare($result,"1.2.5") < 0) { 
     471                $version = $result; 
     472                $result = "Version $version installed.  Need at least 1.2.5"; 
     473                $status = ERROR; 
     474            } else { 
     475               $status = OK; 
     476            } 
    413477        } 
    414       } 
    415478    } else { 
    416       $result ="Requires PEAR"; 
    417       $status = WARN; 
     479        $result ="Requires PEAR"; 
     480        $status = WARN; 
    418481    } 
    419482    print_row("PEAR::Net_SMTP", $result, $status); 
    420483 
    421484    // PEAR::Auth_SASL 
    422485    if ($have_pear) { 
    423486        if (!in_array("auth_sasl", $pear_list)) { 
    424             $result = "Not installed.  This module is required by PEAR::Net_SMTP in " . 
    425                       "order to support the DIGEST-MD5 and CRAM-MD5 SMTP authentication methods."; 
    426             $status = ERROR; 
     487            $installed = check_pear_module('Auth/SASL.php'); 
     488            if (! $installed) { 
     489                $result = "Not installed.  This module is required by PEAR::Net_SMTP in " . 
     490                          "order to support the DIGEST-MD5 and CRAM-MD5 SMTP authentication methods."; 
     491                $status = ERROR; 
     492            } else { 
     493                $result = "Installed, but cannot determine version. Please check your " . 
     494                          "system package manager."; 
     495                $status = UNK_VER; 
     496            } 
    427497        } else { 
    428498            $info = $pear_reg->packageInfo("Auth_SASL"); 
    429499            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    438508    // PEAR::Net_IMAP 
    439509    if ($have_pear) { 
    440510        if (!in_array("net_imap", $pear_list)) { 
    441             $result = "Not installed.  This PHP extension is required to authenticate maia against IMAP."; 
    442             $status = WARN; 
     511            $installed = check_pear_module('Net/IMAP.php'); 
     512            if (! $installed) { 
     513                $result = "Not installed.  This PHP extension is required to authenticate maia against IMAP."; 
     514                $status = WARN; 
     515            } else { 
     516                $result = "Installed, but cannot determine version. Please check your " . 
     517                          "system package manager. A bug exists in Net_IMAP 1.0.3 when run under PHP 5, " . 
     518                          " see <a href=\"https://secure.renaissoft.com/maia/ticket/266\">https://secure." . 
     519                          "renaissoft.com/maia/ticket/266</a> for more details.";; 
     520                $status = UNK_VER; 
     521            } 
    443522        } else { 
    444523            $info = $pear_reg->packageInfo("Net_IMAP"); 
    445524            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
    446525          if ($result == "1.0.3" && $php_version >= "5.0.0") { 
    447              $result = "A bug exists in Net_IMAP 1.0.3 when run under PHP 5, see <a href=\"https://secure.renaissoft.com/maia/ticket/266\">https://secure.renaissoft.com/maia/ticket/266</a> for more details."; 
     526             $result = "A bug exists in Net_IMAP 1.0.3 when run under PHP 5, see <a href=\"" . 
     527                       "https://secure.renaissoft.com/maia/ticket/266\">https://secure." . 
     528                       "renaissoft.com/maia/ticket/266</a> for more details."; 
    448529             $status = WARN;       
    449530          } else { 
    450531            $status = OK; 
     
    459540    // PEAR::Net_POP3 
    460541    if ($have_pear) { 
    461542        if (!in_array("net_pop3", $pear_list)) { 
    462             $result = "Not installed.  This PHP extension is required to authenticate maia against POP3."; 
    463             $status = WARN; 
     543            $installed = check_pear_module('Net/POP3.php'); 
     544            if (! $installed) { 
     545                $result = "Not installed.  This PHP extension is required to authenticate maia against POP3."; 
     546                $status = WARN; 
     547            } else { 
     548                $result = "Installed, but cannot determine version. Please check your " . 
     549                          "system package manager."; 
     550                $status = UNK_VER; 
     551            } 
    464552        } else { 
    465553            $info = $pear_reg->packageInfo("Net_POP3"); 
    466554            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    475563    // PEAR::Log 
    476564    if ($have_pear) { 
    477565        if (!in_array("log", $pear_list)) { 
    478             $result = "Not installed, but only required if you want to be able to log user " . 
    479                       "and administrator activity.  Use <b>pear install Log</b> to install " . 
    480                       "this PHP extension."; 
    481             $status = ERROR; 
     566            $installed = check_pear_module('Log.php'); 
     567            if (! $installed) { 
     568                $result = "Not installed, but only required if you want to be able to log user " . 
     569                          "and administrator activity.  Use <b>pear install Log</b> to install " . 
     570                          "this PHP extension."; 
     571                $status = ERROR; 
     572            } else { 
     573                $result = "Installed, but cannot determine version. Please check your " . 
     574                          "system package manager."; 
     575                $status = UNK_VER; 
     576            } 
    482577        } else { 
    483578            $log_info = $pear_reg->packageInfo("Log"); 
    484579            $result = is_array($log_info["version"])?$log_info["version"]["release"]:$log_info["version"]; 
     
    493588    // PEAR::Image_Color 
    494589    if ($have_pear) { 
    495590        if (!in_array("image_color", $pear_list)) { 
    496             $result = "Not installed.  Optional package, required only if you wish " . 
    497                       "to enable the graphical chart features."; 
    498             $status = WARN; 
     591            $installed = check_pear_module('Image/Color.php'); 
     592            if (! $installed) { 
     593                $result = "Not installed.  Optional package, required only if you wish " . 
     594                          "to enable the graphical chart features."; 
     595                $status = WARN; 
     596            } else { 
     597                $result = "Installed, but cannot determine version. Please check your " . 
     598                          "system package manager."; 
     599                $status = UNK_VER; 
     600            } 
    499601        } else { 
    500602            $info = $pear_reg->packageInfo("Image_Color"); 
    501603            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    510612    // PEAR::Image_Canvas 
    511613    if ($have_pear) { 
    512614        if (!in_array("image_canvas", $pear_list)) { 
    513             $result = "Not installed.  Optional package, required only if you wish " . 
    514                       "to enable the graphical chart features."; 
    515             $status = WARN; 
     615            $installed = check_pear_module('Image/Canvas.php'); 
     616            if (! $installed) { 
     617                $result = "Not installed.  Optional package, required only if you wish " . 
     618                          "to enable the graphical chart features."; 
     619                $status = WARN; 
     620            } else { 
     621                $result = "Installed, but cannot determine version. Please check your " . 
     622                          "system package manager."; 
     623                $status = UNK_VER; 
     624            } 
    516625        } else { 
    517626            $info = $pear_reg->packageInfo("Image_Canvas"); 
    518627            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    527636    // PEAR::Image_Graph 
    528637    if ($have_pear) { 
    529638        if (!in_array("image_graph", $pear_list)) { 
    530             $result = "Not installed.  Optional package, required only if you wish " . 
    531                       "to enable the graphical chart features."; 
    532             $status = WARN; 
     639            $installed = check_pear_module('Image/Graph.php'); 
     640            if (! $installed) { 
     641                $result = "Not installed.  Optional package, required only if you wish " . 
     642                          "to enable the graphical chart features."; 
     643                $status = WARN; 
     644            } else { 
     645                $result = "Installed, but cannot determine version. Please check your " . 
     646                          "system package manager."; 
     647                $status = UNK_VER; 
     648            } 
    533649        } else { 
    534650            $info = $pear_reg->packageInfo("Image_Graph"); 
    535651            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    544660    // PEAR::Numbers_Roman 
    545661    if ($have_pear) { 
    546662        if (!in_array("numbers_roman", $pear_list)) { 
    547             $result = "Not installed.  Optional package, required only if you wish " . 
    548                       "to enable the graphical chart features."; 
    549             $status = WARN; 
     663            $installed = check_pear_module('Numbers/Roman.php'); 
     664            if (! $installed) { 
     665                $result = "Not installed.  Optional package, required only if you wish " . 
     666                          "to enable the graphical chart features."; 
     667                $status = WARN; 
     668            } else { 
     669                $result = "Installed, but cannot determine version. Please check your " . 
     670                          "system package manager."; 
     671                $status = UNK_VER; 
     672            } 
    550673        } else { 
    551674            $info = $pear_reg->packageInfo("Numbers_Roman"); 
    552675            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"]; 
     
    561684    // PEAR::Numbers_Words 
    562685    if ($have_pear) { 
    563686        if (!in_array("numbers_words", $pear_list)) { 
    564             $result = "Not installed.  Optional package, required only if you wish " . 
    565                       "to enable the graphical chart features."; 
    566             $status = WARN; 
     687            $installed = check_pear_module('Numbers/Words.php'); 
     688            if (! $installed) { 
     689                $result = "Not installed.  Optional package, required only if you wish " . 
     690                          "to enable the graphical chart features."; 
     691                $status = WARN; 
     692            } else { 
     693                $result = "Installed, but cannot determine version. Please check your " . 
     694                          "system package manager."; 
     695                $status = UNK_VER; 
     696            } 
    567697        } else { 
    568698            $info = $pear_reg->packageInfo("Numbers_Words"); 
    569699            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];