Commit 7a34227c authored by Benjamin Sonntag's avatar Benjamin Sonntag

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

parent b6fe519a
......@@ -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';");
......
......@@ -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()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment