コード例 #1
0
ファイル: list.php プロジェクト: inscriptionweb/gutuma
 /**
  * Gets the list with the specified id
  * @param int $id The list id
  * @param bool $load_addresses TRUE is list addresses should be loaded (default FALSE) 
  * @return mixed The list or FALSE if an error occured
  */
 public static function get($id, $load_addresses = FALSE)
 {
     $time_start = microtime();
     // Open list file
     $lh = @fopen(realpath(GUTUMA_LISTS_DIR . '/' . $id . '.php'), 'r');
     if ($lh == FALSE) {
         return gu_error(t('Unable to read list file'));
     }
     // Read header from first line
     $header = explode("|", fgetss($lh));
     $list = new gu_list();
     $list->id = $header[0];
     $list->name = $header[1];
     $list->private = (bool) $header[2];
     $list->size = (int) $header[3];
     // Read all address lines
     if ($load_addresses) {
         $addresses = array();
         while (!feof($lh)) {
             $address = trim(fgets($lh));
             if (strlen($address) > 0) {
                 $addresses[] = $address;
             }
         }
         $list->addresses = $addresses;
     }
     fclose($lh);
     gu_debug('gu_list::get(' . $id . ', ' . ($load_addresses ? 'TRUE' : 'FALSE') . ') ' . (microtime() - $time_start) . ' secs');
     return $list;
 }
コード例 #2
0
ファイル: mailer.php プロジェクト: inscriptionweb/gutuma
 /**
  * Sends a message using the Swift mailer
  * @param Swift_Message $message The Swift message object
  * @param Swift_RecipientList $recipients The recipient list
  * @return int The number of messages sent successfully, else FALSE
  */
 private function send(Swift_Message $message, Swift_RecipientList $recipients)
 {
     if (gu_is_demo()) {
         return gu_error(t('Unable to send message in demo mode'));
     }
     try {
         $num_sent = $this->swift->send($message, $recipients, $this->from_address);
     } catch (Swift_ConnectionException $e) {
         gu_debug($e->getMessage());
         return gu_error(t('Unable to send message due to connection error'));
     }
     if (gu_is_debugging()) {
         $log =& Swift_LogContainer::getLog();
         gu_debug('gu_mailer::send(...)<br />' . nl2br(htmlspecialchars($log->dump(true))) . ' => ' . $num_sent);
         $log->clear();
     }
     return $num_sent;
 }
コード例 #3
0
ファイル: newsletter.php プロジェクト: inscriptionweb/gutuma
 /**
  * Cleans up any resources used by this newsletter - i.e. deletes file attachments from temp storage
  * @return bool TRUE if operation was successful, else FALSE
  */
 public function delete()
 {
     gu_debug(t('Deleting newsletter files (%)', array($this->id)));
     $dir = $this->get_dir();
     if (!file_exists($dir)) {
         return TRUE;
     }
     // Delete individual attachments to ensure directory is empty
     foreach ($this->get_attachments() as $attachment) {
         if (!$this->delete_attachment($attachment['name'])) {
             return gu_error(t('Unable to delete message attachment'), ERROR_EXTRA);
         }
     }
     // Delete the newsletter files
     $res1 = @rmdir($dir . '/attachments');
     $res2 = @unlink($dir . '/' . MESSAGE_FILE);
     $res3 = @unlink($dir . '/' . LOCK_FILE);
     $res4 = !file_exists($dir . '/' . RECIPIENTS_FILE) || @unlink($dir . '/' . RECIPIENTS_FILE);
     $res5 = @rmdir($dir);
     if (!($res1 && $res2 && $res3 && $res4 && $res5)) {
         return gu_error(t('Some newsletter files could not be deleted'), ERROR_EXTRA);
     }
     $this->send_progress = NULL;
     return TRUE;
 }