Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
m_squirrelmail Class Reference

This class handle squirrelmail's webmail hook the main panel page to add a link to the webmail. More...

Public Member Functions

 hook_admin_webmail ()
 Hook called by the homepage or the /webmail link to redirect the user to a known webmail url. More...
 
 hook_mail_delete_for_real ($mail_id, $fullmail)
 Hook called when an email is REALLY deleted (by the cron, not just in the panel) More...
 

Detailed Description

This class handle squirrelmail's webmail hook the main panel page to add a link to the webmail.

Definition at line 30 of file m_squirrelmail.php.

Member Function Documentation

m_squirrelmail::hook_admin_webmail ( )

Hook called by the homepage or the /webmail link to redirect the user to a known webmail url.

the variable 'webmail_redirect' tells which webmail has the priority.

Returns
string the URL of the webmail

Definition at line 38 of file m_squirrelmail.php.

References $db, $domain, $host, and $i.

38  {
39  global $db;
40  // Search for the domain where the panel is hosted, then search for a webmail in it.
41  $i=2;
42  if (!empty($_SERVER["HTTP_HOST"])) {
43  do { // for each domain part (search panel.alternc.org then alternc.org then org, if the current panel is at www.panel.alternc.org)
44  $expl=explode(".",$_SERVER["HTTP_HOST"],$i);
45  if (count($expl)>=2) {
46  list($host,$dompart)=$expl;
47  // We search for a 'squirrelmail' subdomain in that domain
48  $db->query("SELECT * FROM sub_domaines s WHERE s.domaine= ? AND s.type='squirrelmail';",array($dompart));
49  if ($db->next_record()) {
50  $domain=$db->Record;
51  return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
52  }
53  }
54  $i++;
55  } while (strpos($dompart,'.')!==false);
56  }
57 
58  // not found: search for a webmail in the admin user account
59  $db->query("SELECT * FROM sub_domaines s WHERE s.compte=2000 AND s.type='squirrelmail';");
60  if ($db->next_record()) {
61  $domain=$db->Record;
62  return "http://".$domain["sub"].(($domain["sub"])?".":"").$domain["domaine"];
63  }
64 
65  }
$host
Definition: config.php:86
global $db
Definition: bootstrap.php:22
$domain
Definition: dom_import.php:40
m_squirrelmail::hook_mail_delete_for_real (   $mail_id,
  $fullmail 
)

Hook called when an email is REALLY deleted (by the cron, not just in the panel)

Parameters
mail_idinteger the ID of the mail in the AlternC database
fullmailstring the deleted mail himself in the form of john@.nosp@m.doma.nosp@m.in.tl.nosp@m.d
Returns
boolean|null

Definition at line 74 of file m_squirrelmail.php.

References $t.

74  {
75  $fullmail2 = str_replace('@','_',$fullmail); // fullname with _ instead of @ (compatibility)
76  $todel = array (
77  "$fullmail.abook",
78  "$fullmail.pref",
79  "$fullmail2.abook",
80  "$fullmail2.pref");
81 
82  foreach ( $todel as $t ) {
83  if (file_exists("/var/lib/squirrelmail/data/$t") ) {
84  @unlink("/var/lib/squirrelmail/data/$t");
85  }
86  }
87  } // hook_mail_delete_for_real
$t
Definition: dom_editdns.php:58

The documentation for this class was generated from the following file: