use empty() to check array's key existence, Fixes #1418

This commit is contained in:
Benjamin Sonntag 2013-02-07 10:42:47 +00:00
parent b6fe519ace
commit 7a34227cbb
2 changed files with 31 additions and 21 deletions

View File

@ -40,16 +40,21 @@ class m_roundcube {
// Search for the domain where the panel is hosted, then search for a webmail in it.
$i=2;
$domain="";
do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
list($host,$dompart)=explode(".",$_SERVER["HTTP_HOST"],$i);
// We search for a 'roundcube' subdomain in that domain
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='roundcube';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
$i++;
} while (strpos($dompart,'.')!==false);
if (!empty($_SERVER["HTTP_HOST"])) {
do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
$expl=explode(".",$_SERVER["HTTP_HOST"],$i);
if (count($expl)>=2) {
list($host,$dompart)=$expl;
// We search for a 'squirrelmail' subdomain in that domain
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='roundcube';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
}
$i++;
} while (strpos($dompart,'.')!==false);
}
// not found: search for a webmail in the admin user account
$db->query("SELECT * FROM sub_domaines s WHERE s.compte=2000 AND s.type='roundcube';");

View File

@ -40,17 +40,22 @@ class m_squirrelmail {
// Search for the domain where the panel is hosted, then search for a webmail in it.
$i=2;
$domain="";
do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
list($host,$dompart)=explode(".",$_SERVER["HTTP_HOST"],$i);
// We search for a 'squirrelmail' subdomain in that domain
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='squirrelmail';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
$i++;
} while (strpos($dompart,'.')!==false);
if (!empty($_SERVER["HTTP_HOST"])) {
do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
$expl=explode(".",$_SERVER["HTTP_HOST"],$i);
if (count($expl)>=2) {
list($host,$dompart)=$expl;
// We search for a 'squirrelmail' subdomain in that domain
$db->query("SELECT * FROM sub_domaines s WHERE s.domaine='".addslashes($dompart)."' AND s.type='squirrelmail';");
if ($db->next_record()) {
$domain=$db->Record;
return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
}
}
$i++;
} while (strpos($dompart,'.')!==false);
}
// not found: search for a webmail in the admin user account
$db->query("SELECT * FROM sub_domaines s WHERE s.compte=2000 AND s.type='squirrelmail';");
if ($db->next_record()) {