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

  1. <?php
  2. require('Group-Office.php');
  3. $GO_SECURITY->authenticate();
  4. ?>
  5. <html>
  6. <head>
  7. <script language="javascript" type="text/javascript">
  8. <!-- Centring window Javascipt mods By Muffin Research Labs//-->
  9.  
  10. function popup(url,w,h,target)
  11. {
  12.    var centered;
  13.      x = (screen.availWidth - w) / 2;
  14.      y = (screen.availHeight - h) / 2;
  15.    centered =',width=' + w + ',height=' + h + ',left=' + x + ',top=' + y + ',scrollbars=no,resizable=no,status=no';
  16.    popup = window.open(url, target, centered);
  17.            if (!popup.opener) popup.opener = self;
  18.    popup.focus();
  19. }
  20. </script>
  21. <title><?php echo $GO_CONFIG->title; ?>
  22. </title>
  23. <?php
  24. echo '<meta http-equiv="refresh" content="'.$GO_CONFIG->refresh_rate.';url='.$_SERVER['PHP_SELF'].'">';
  25.  
  26. //if user uses the calendar then check for events to remind
  27. if ($calendar_module = $GO_MODULES->get_module('calendar'))
  28. {
  29.     require_once($GO_CONFIG->class_path.'calendar.class.inc');
  30.     $header_cal = new calendar();
  31.  
  32.     $remind_events = $header_cal->get_events_to_remind($GO_SECURITY->user_id);
  33.     if ($remind_events)
  34.     {
  35.         echo '<script language="javascript" type="text/javascript">popup("'.$calendar_module['url'].'reminder.php", "500", "200", "reminder");</script>';
  36.     }
  37.     unset($header_cal);
  38. }
  39.  
  40. $_SESSION['notified_new_mail'] = isset($_SESSION['notified_new_mail']) ? $_SESSION['notified_new_mail'] : 0;
  41. $_SESSION['new_mail'] = 0;
  42. //check for email
  43. if ($email_module = $GO_MODULES->get_module('email'))
  44. {
  45.     require_once($GO_CONFIG->class_path.'email.class.inc');
  46.     require_once($GO_CONFIG->class_path.'imap.class.inc');
  47.     $imap = new imap();
  48.     $email1 = new email();
  49.     $email2 = new email();
  50.  
  51.     $email1->get_accounts($GO_SECURITY->user_id);
  52.  
  53.     while($email1->next_record())
  54.     {
  55.         if ($email1->f('auto_check') == '1')
  56.         {
  57.             $account = $email1->Record;
  58.  
  59.             if ($imap->open($account['host'], $account['type'],$account['port'],$account['username'],$GO_CRYPTO->decrypt($account['password'])))
  60.             {
  61.  
  62.                 if ($account['type'] == 'imap')
  63.                 {
  64.                     $email2->get_folders($email1->f('id'));
  65.                     while($email2->next_record())
  66.                     {
  67.                         $status = $imap->status($email2->f('name'));
  68.                         if ($status->unseen > 0)
  69.                         {
  70.                             $_SESSION['new_mail'] += $status->unseen;
  71.                         }
  72.                     }
  73.                 }else
  74.                 {
  75.                     $status = $imap->status('INBOX');
  76.                     if ($status->unseen > 0)
  77.                     {
  78.                         $_SESSION['new_mail'] += $status->unseen;
  79.                     }
  80.                 }
  81.             }else
  82.             {
  83.                 $email->disable_auto_check($account['id']);
  84.                 echo '<script language="javascript" type="text/javascript">alert("'.$account['host'].' is unreachable. Autocheck disabled.");</script>';
  85.             }
  86.         }
  87.     }
  88.  
  89.     if ($_SESSION['new_mail'] > 0 && $_SESSION['new_mail'] > $_SESSION['notified_new_mail'])
  90.     {
  91.         echo '<script language="javascript" type="text/javascript">popup("'.$email_module['url'].'notify.php", "400", "120", "email_notify");</script>';
  92.     }
  93. }
  94. ?>
  95. </head>
  96. <body>
  97. </body>
  98. </html>