Update mailto support
authorindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 12 Dec 2003 19:18:31 +0000 (19:18 +0000)
committerindiri69 <indiri69@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 12 Dec 2003 19:18:31 +0000 (19:18 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6270 7612ce4b-ef26-0410-bec9-ea0150e637f0

contrib/squirrelmail.mailto.NT2KXP.reg [moved from contrib/squirrelmail.mailto.reg with 100% similarity]
contrib/squirrelmail.mailto.Win9x.reg [new file with mode: 0644]
src/mailto.php

diff --git a/contrib/squirrelmail.mailto.Win9x.reg b/contrib/squirrelmail.mailto.Win9x.reg
new file mode 100644 (file)
index 0000000..f55ed7f
--- /dev/null
@@ -0,0 +1,28 @@
+Here is a windows registry file to set SquirrelMail as a windows email program
+Once this entry is installed, go to Internet Options and select the Programs
+tab.  SquirrelMail should be an option under E-mail:
+
+---- Cut here ----
+REGEDIT4
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail]
+@="SquirrelMail"
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\Protocols]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\Protocols\mailto]
+"URL Protocol"=""
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\Protocols\mailto\shell]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\Protocols\mailto\shell\open]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\Protocols\mailto\shell\open\command]
+@="rundll32.exe url.dll,FileProtocolHandler http://mail.server/squirrelmail/src/mailto.php?emailaddress=%1"
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\shell]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\shell\open]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\SquirrelMail\shell\open\command]
+
index b921e852752d5ab2ec188fc7a2ad8e1bb41838e5..b69855d5d51bc586eec7edc445ef36e7170e1bb4 100644 (file)
@@ -12,7 +12,7 @@
  *  login first)
  *
  * Use the following url to use mailto:
  *  login first)
  *
  * Use the following url to use mailto:
- * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress="%1"
+ * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress=%1
  * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file
  * @package squirrelmail
  */
  * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file
  * @package squirrelmail
  */
@@ -25,52 +25,55 @@ require_once(SM_PATH . 'config/config.php');
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/strings.php');
 
 require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/strings.php');
 
+/* Force users to login each time? */
+$force_login  = true;
+/* Open only the compose window, meaningless if $force_login is true */
+$compose_only = false;
+
 header('Pragma: no-cache');
 header('Pragma: no-cache');
-if(!sqgetGlobalVar('emailaddress', $emailaddress)) {
-    return;
-}
 
 
-$mailto_pos = strpos(strtolower($emailaddress), 'mailto:');
-if($mailto_pos !== false) {
-    $emailaddress = substr($emailaddress, $mailto_pos+7);
-    $_GET['emailaddress'] = $emailaddress;
-}
-if(($pos = strpos($emailaddress, '?')) !== false) {
-    $a = substr($emailaddress, $pos+1);
-    list($emailaddress, $a) = explode('?', $emailaddress, 2);
-    $a = explode('=', $a, 2);
-    $_GET['emailaddress'] = $emailaddress;
-    $_GET[$a[0]] = $a[1];
-}
-$trtable = array('emailaddress' => 'send_to',
-                 'cc'           => 'send_to_cc',
+$trtable = array('cc'           => 'send_to_cc',
                  'bcc'          => 'send_to_bcc',
                  'body'         => 'body',
                  'subject'      => 'subject');
 $url = '';
                  'bcc'          => 'send_to_bcc',
                  'body'         => 'body',
                  'subject'      => 'subject');
 $url = '';
-/* CC, BCC, etc could be any case, so we'll fix them here */
-foreach($_GET as $k=>$g) {
-    if($g != '') {
+
+if(sqgetGlobalVar('emailaddress', $emailaddress)) {
+    $emailaddress = trim($emailaddress);
+    if(stristr($emailaddress, 'mailto:')) {
+        $emailaddress = substr($emailaddress, 7);
+    }
+    if(strpos($emailaddress, '?') !== false) {
+        list($emailaddress, $a) = explode('?', $emailaddress, 2);
+        if(strlen(trim($a)) > 0) {
+            $a = explode('=', $a, 2);
+            $url .= $trtable[strtolower($a[0])] . '=' . urlencode($a[1]) . '&';
+        }
+    }
+    $url = 'send_to=' . urlencode($emailaddress) . '&' . $url;
+
+    /* CC, BCC, etc could be any case, so we'll fix them here */
+    foreach($_GET as $k=>$g) {
         $k = strtolower($k);
         $k = strtolower($k);
-        $k = $trtable[$k];
-        $url .= $k . '=' . urlencode($g) . '&';
+        if(isset($trtable[$k])) {
+            $k = $trtable[$k];
+            $url .= $k . '=' . urlencode($g) . '&';
+        }
     }
     }
+    $url = substr($url, 0, -1);
 }
 }
-$url = substr($url, 0, -1);
-
 sqsession_is_active();
 sqsession_is_active();
-/* Check to see if we're logged in */
-/*
-if (sqsession_is_registered('user_is_logged_in')) {
-    $redirect = 'webmail.php?right_frame=compose.php?';
+
+if($force_login == false && sqsession_is_registered('user_is_logged_in')) {
+    if($compose_only == true) {
+        $redirect = 'compose.php?' . $url;
+    } else {
+        $redirect = 'webmail.php?right_frame=compose.php?' . urlencode($url);
+    }
 } else {
 } else {
-    $redirect = 'login.php?mailto=';
+    $redirect = 'login.php?mailto=' . urlencode($url);
 }
 }
-*/
-$url = urlencode($url);
-/* $redirect .= $url; */
-$redirect = 'login.php?mailto=' . $url;
+
 session_write_close();
 header('Location: ' . get_location() . '/' . $redirect);
 session_write_close();
 header('Location: ' . get_location() . '/' . $redirect);
-
-?>
\ No newline at end of file
+?>