home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / email / index.php < prev    next >
PHP Script  |  2004-03-08  |  7KB  |  177 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. require($GO_CONFIG->class_path."imap.class.inc");
  15. require($GO_CONFIG->class_path."email.class.inc");
  16. require($GO_LANGUAGE->get_language_file('email'));
  17. $mail = new imap();
  18. $email = new email();
  19.  
  20. $GO_SECURITY->authenticate();
  21. $GO_MODULES->authenticate('email');
  22.  
  23.  
  24. $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : 0;
  25. $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
  26. $uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : 0;
  27. $max_rows = isset($_REQUEST['max_rows']) ? $_REQUEST['max_rows'] : $_SESSION['GO_SESSION']['max_rows_list'];
  28. $first_row = (isset($_REQUEST['first_row'])) ? $_REQUEST['first_row'] : 0;
  29. $table_tabindex = isset($_REQUEST['table_tabindex']) ? $_REQUEST['table_tabindex'] : null;
  30. $mailbox = isset($_REQUEST['mailbox'])?  $_REQUEST['mailbox'] : 'INBOX';
  31.  
  32. $link_back = $GO_MODULES->url.'index.php?account_id='.$account_id.'&mailbox='.$mailbox.'&first_row='.$first_row;
  33.  
  34. //remember sorting passed by inbox in cookie
  35. if (isset($_REQUEST['newsort']))
  36. {
  37.     SetCookie("mail_sort",$_REQUEST['newsort'],time()+3600*24*365,"/","",0);
  38.     $_COOKIE['mail_sort'] = $_REQUEST['newsort'];
  39. }
  40. if (isset($_REQUEST['newreverse']))
  41. {
  42.     SetCookie("mail_reverse",$_REQUEST['newreverse'],time()+3600*24*365,"/","",0);
  43.     $_COOKIE['mail_reverse'] = $_REQUEST['newreverse'];
  44. }
  45.  
  46. if (!$account = $email->get_account($account_id))
  47. {
  48.     $account = $email->get_account(0);
  49. }
  50.  
  51. if ($account && $account["user_id"] != $GO_SECURITY->user_id)
  52. {
  53.     header('Location: '.$GO_CONFIG->host.'error_docs/403.php');
  54.     exit();
  55. }
  56.  
  57.  
  58. $disable_accounts = ($GO_CONFIG->get_setting('em_disable_accounts') == 'true') ? true : false;
  59.  
  60. $page_title = $lang_modules['email'];
  61. require($GO_THEME->theme_path."header.inc");
  62. ?>
  63. <table border="0" cellspacing="0" cellpadding="0">
  64. <tr>
  65.     <td width="5"></td>
  66.     <td><h1>
  67.     <?php
  68.     if ($account)
  69.     {
  70.         if ($mailbox == $account['mbroot'])
  71.         {
  72.             echo $ml_inbox;
  73.         }else
  74.         {
  75.             echo substr(str_replace($account['mbroot'], '', $mailbox), 1);
  76.         }
  77.         echo ' - '.$account['email'];
  78.     }else
  79.     {
  80.         echo $ml_welcome;
  81.     }
  82.     ?>
  83.     </h1>
  84.     </td>
  85. </tr>
  86. </table>
  87. <table border="0" cellspacing="0" cellpadding="0">
  88. <tr>
  89.     <td class="ModuleIcons">
  90.     <a href="javascript:popup('send.php','<?php echo $GO_CONFIG->composer_width; ?>','<?php echo $GO_CONFIG->composer_height; ?>')"><img src="<?php echo $GO_THEME->images['compose']; ?>" border="0" height="32" width="32" /><br /><?php echo $ml_compose; ?></a></td>
  91.     <?php
  92.     if (!$disable_accounts)
  93.     {
  94.         echo '<td class="ModuleIcons">';
  95.         echo '<a href="accounts.php?return_to='.urlencode($link_back).'"><img src="'.$GO_THEME->images['accounts'].'" border="0" height="32" width="32" /><br />'.$ml_accounts.'</a></td>';
  96.     }else
  97.     {
  98.         if ($account)
  99.         {
  100.             echo '<td class="ModuleIcons">';
  101.             echo '<a href="account.php?account_id='.$account['id'].'&return_to='.urlencode($link_back).'"><img src="'.$GO_THEME->images['accounts'].'" border="0" height="32" width="32" /><br />'.$ml_edit_account.'</a></td>';
  102.         }
  103.     }
  104.     if ($account['type'] == "imap" && $account)
  105.     {
  106.         echo '<td class="ModuleIcons">';
  107.         echo '<a href="folders.php?account_id='.$account['id'].'&return_to='.urlencode($link_back).'"><img src="'.$GO_THEME->images['folders'].'" border="0" height="32" width="32" /><br />'.$ml_folders.'</a></td>';
  108.         echo '<td class="ModuleIcons">';
  109.         echo '<a href="filters.php?account_id='.$account['id'].'&return_to='.urlencode($link_back).'"><img src="'.$GO_THEME->images['filters'].'" border="0" height="32" width="32" /><br />'.$ml_filters.'</a></td>';
  110.         if ($task == '')
  111.         {
  112.             echo '<td class="ModuleIcons">';
  113.             echo '<a href="javascript:mark_as_read()"><img src="'.$GO_THEME->images['markread'].'" border="0" height="32" width="32" /><br />'.$ml_markread.'</a></td>';
  114.             echo '<td class="ModuleIcons">';
  115.             echo '<a href="javascript:mark_as_unread()"><img src="'.$GO_THEME->images['markunread'].'" border="0" height="32" width="32" /><br />'.$ml_markunread.'</a></td>';
  116.         }
  117.  
  118.     }
  119.     if ($account)
  120.     {
  121.         echo '<td class="ModuleIcons">';
  122.         echo '<a href="'.$_SERVER['PHP_SELF'].'?account_id='.$account['id'].'&mailbox=INBOX"><img src="'.$GO_THEME->images['em_refresh'].'" border="0" height="32" width="32" /><br />'.$ml_refresh.'</a></td>';
  123.         echo '<td class="ModuleIcons">';
  124.         echo '<a href="javascript:confirm_delete()"><img src="'.$GO_THEME->images['delete_big'].'" border="0" height="32" width="32" /><br />'.$ml_delete.'</a></td>';
  125.         echo '<td class="ModuleIcons">';
  126.         echo '<a href="javascript:confirm_empty_mailbox()"><img src="'.$GO_THEME->images['empty_folder'].'" border="0" height="32" width="32" /><br />'.$ml_empty_mailbox.'</a></td>';
  127.     }
  128.     if ($GO_MODULES->write_permissions)
  129.     {
  130.         echo '<td class="ModuleIcons">';
  131.         echo '<a href="configuration.php?return_to='.urlencode($link_back).'"><img src="'.$GO_THEME->images['em_settings_admin'].'" border="0" height="32" width="32" /><br />'.$menu_configuration.'</a></td>';
  132.     }
  133.  
  134.     ?>
  135. </tr>
  136. </table>
  137. <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="email_client">
  138. <input type="hidden" name="empty_mailbox" />
  139. <input type="hidden" name="link_back" value="<?php echo $link_back; ?>" />
  140. <input type="hidden" name="account_id" value="<?php echo $account['id']; ?>" />
  141. <?php
  142.  
  143. if ($account)
  144. {
  145.     if ($mail->open($account['host'], $account['type'], $account['port'], $account['username'], $GO_CRYPTO->decrypt($account['password']), $mailbox))
  146.     {
  147.         //block email to spam folder
  148.         if (isset($_REQUEST['spam_uid']) && $_REQUEST['spam_uid'] >0)
  149.         {
  150.             $spam_folder = $account['spam'];
  151.             if ($_REQUEST['spam_address'] != '' && $spam_folder != '')
  152.             {
  153.                 $email->add_filter($_SESSION['email_id'], "sender", $_REQUEST['spam_address'], $spam_folder);
  154.                 $messages[] = $_REQUEST['spam_uid'];
  155.                 $mail->move($spam_folder, $messages);
  156.             }
  157.         }
  158.     }else
  159.     {
  160.  
  161.         echo '<table border="0" cellpadding="10" width="100%"><tr><td>';
  162.         echo '<p class="Error">'.$ml_connect_failed.' \''.$account['host'].'\' '.$ml_at_port.': '.$account['port'].'</p>';
  163.         echo '<p class="Error">'.imap_last_error().'</p>';
  164.         require($GO_THEME->theme_path.'footer.inc');
  165.         exit();
  166.     }
  167.  
  168.     require("navigation.inc");
  169. }else
  170. {
  171.     echo '<br /><p class="normal"><b>'.$ml_no_accounts.'</b></p><br /><p class="normal">'.$ml_text.'</p>';
  172. }
  173. echo '</form>';
  174. $mail->close();
  175. require($GO_THEME->theme_path."footer.inc");
  176. ?>
  177.