コード例 #1
0
    }
}
define('FILENAME_IMAGEMANIPULATOR', IMAGE_MANIPULATOR);
// move to xtc_db_queryCached.inc.php
function xtDBquery($query)
{
    if (DB_CACHE == 'true') {
        $result = xtc_db_queryCached($query);
    } else {
        $result = xtc_db_query($query);
    }
    return $result;
}
// security inputfilter for GET/POST/COOKIE
require DIR_FS_CATALOG . DIR_WS_CLASSES . 'inputfilter.php';
$inputfilter = new Inputfilter();
$_GET = $inputfilter->validate($_GET);
$_POST = $inputfilter->validate($_POST);
//$_REQUEST = $inputfilter->validate($_REQUEST);
// initialize the logger class
require DIR_WS_CLASSES . 'logger.php';
// shopping cart class
require DIR_WS_CLASSES . 'shopping_cart.php';
// todo
require DIR_WS_FUNCTIONS . 'general.php';
// define how the session functions will be used
require DIR_WS_FUNCTIONS . 'sessions.php';
// define our general functions used application-wide
require DIR_WS_FUNCTIONS . 'html_output.php';
// set the session name and save path
session_name('MODsid');
コード例 #2
0
ファイル: pbem.plugin.php プロジェクト: habari-extras/pbem
 public static function check_accounts()
 {
     $accounts = array();
     foreach (Users::get() as $user) {
         if (!$user->info->pbem_active) {
             continue;
         }
         $accounts[$user->name] = array('server' => $user->info->pbem_server, 'protocol' => $user->info->pbem_protocol, 'security' => $user->info->pbem_security, 'mailbox' => $user->info->pbem_mailbox, 'username' => $user->info->pbem_username, 'password' => $user->info->pbem_password, 'whitelist' => $user->info->pbem_whitelist, 'class' => $user->info->pbem_class, 'status' => $user->info->pbem_status, 'user' => $user);
     }
     foreach ($accounts as $user => $account) {
         extract($account);
         // build the $server_string used by imap_open()
         $server_string = '{' . $server;
         switch ("{$protocol}+{$security}") {
             case 'imap+none':
                 $server_string .= ':143/imap}';
                 break;
             case 'imap+ssl':
                 $server_string .= ':993/imap/ssl}';
                 break;
             case 'imap+tls':
                 $server_string .= ':143/imap/tls}';
                 break;
             case 'pop3+none':
                 $server_string .= ':110/pop3}';
                 break;
             case 'pop3+ssl':
                 $server_string .= ':995/pop3/ssl}';
                 break;
             case 'pop3+tls':
                 $server_string .= ':110/pop3/tls}';
         }
         $server_string .= $mailbox;
         $mh = imap_open($server_string, $username, $password, OP_SILENT | OP_DEBUG) or Eventlog::log(_t('Unable to connect'));
         // get a better error, one with imap_*
         $n = imap_num_msg($mh);
         $whitelist = explode("\n", $whitelist);
         $messages_skipped = 0;
         for ($i = 1; $i <= $n; $i++) {
             $body = '';
             $attachments = array();
             $media = array();
             $header = imap_header($mh, $i);
             $whitelist_passed = false;
             foreach ($whitelist as $item) {
                 $item = trim(strtolower($item));
                 if ('' == $item) {
                     continue;
                 }
                 // blanks in whitelist
                 if (false != strpos(strtolower($header->fromaddress), $item)) {
                     $whitelist_passed = true;
                     break;
                 }
             }
             if ($whitelist_passed == false) {
                 ++$messages_skipped;
                 // Move onto the next message.
                 continue;
             }
             // get the message structure
             $structure = imap_fetchstructure($mh, $i);
             if (!isset($structure->parts)) {
                 // message is not not multipart
                 $body = imap_body($mh, $i);
                 // fetchbody only works for single part messages.
                 if ($structure->encoding == 4) {
                     $body = quoted_printable_decode($body);
                     // there's room here for more stuff, with strtoupper($structure->subtype...)
                 }
             } else {
                 if (isset($structure->parts) && count($structure->parts)) {
                     for ($j = 0; $j < count($structure->parts); $j++) {
                         $attachments[$j] = array('is_attachment' => false, 'filename' => '', 'subtype' => '', 'name' => '', 'attachment' => '');
                         if ($structure->parts[$j]->ifdparameters) {
                             foreach ($structure->parts[$j]->dparameters as $object) {
                                 if (strtolower($object->attribute) == 'filename') {
                                     $attachments[$j]['is_attachment'] = true;
                                     $attachments[$j]['filename'] = $object->value;
                                     $attachments[$j]['subtype'] = $structure->parts[$j]->subtype;
                                 }
                             }
                         } elseif (strtolower($structure->parts[$j]->subtype) == 'plain') {
                             $body .= imap_fetchbody($mh, $i, $j + 1);
                         }
                         if ($structure->parts[$j]->ifparameters) {
                             foreach ($structure->parts[$j]->parameters as $object) {
                                 if (strtolower($object->attribute) == 'name') {
                                     $attachments[$j]['is_attachment'] = true;
                                     $attachments[$j]['name'] = $object->value;
                                     if (!isset($attachments[$j]['subtype'])) {
                                         // may not be necessary
                                         $attachments[$j]['subtype'] = $structure->parts[$j]->subtype;
                                         // may not be necessary
                                     }
                                     // may not be necessary
                                 }
                             }
                         }
                         if ($attachments[$j]['is_attachment']) {
                             $attachments[$j]['attachment'] = imap_fetchbody($mh, $i, $j + 1);
                             if ($structure->parts[$j]->encoding == 3) {
                                 // 3 = BASE64
                                 $attachments[$j]['attachment'] = base64_decode($attachments[$j]['attachment']);
                                 $path = self::store($attachments[$j]['filename'], $attachments[$j]['attachment']);
                                 if (false !== $path) {
                                     $media[$attachments[$j]['filename']] = $path;
                                 }
                             } elseif ($structure->parts[$j]->encoding == 4) {
                                 // 4 = QUOTED-PRINTABLE
                                 $attachments[$j]['attachment'] = quoted_printable_decode($attachments[$j]['attachment']);
                                 $body .= $attachments[$j]['attachment'];
                             }
                         }
                     }
                 }
             }
             $tags = $user->info->pbem_tags;
             // if the first line of the message starts with 'tags:', read that line into tags.
             if (stripos($body, 'tags:') === 0) {
                 list($additional_tags, $body) = explode("\n", $body, 2);
                 $tags .= ',' . trim(substr($additional_tags, 5));
                 $body = trim($body);
             }
             if (!empty($media)) {
                 $storage = $user->info->pbem_storage;
                 // filter the post body
                 $body = Plugins::filter("pbem_store_{$storage}", $body, $media, $user, $tags);
             }
             $postdata = array('slug' => $header->subject, 'title' => $header->subject, 'tags' => $tags, 'content' => $body, 'user_id' => $user->id, 'pubdate' => HabariDateTime::date_create(), 'status' => Post::status($status), 'content_type' => Post::type('entry'));
             $headerdate = new DateTime($header->date);
             // now in explicit format
             $headerdate = $headerdate->format(_t('Y-m-d H:i:s'));
             EventLog::log(_t('Mail from %1$s (%2$s): "%3$s" (%4$d bytes)', array(Inputfilter::filter($header->from[0]->mailbox . '@' . $header->from[0]->host), $headerdate, Inputfilter::filter($header->subject), $header->Size)));
             $post = Post::create($postdata);
             if ($post) {
                 // done with the message, now delete it. Comment out if you're testing.
                 imap_delete($mh, $i);
             } else {
                 EventLog::log('Failed to create a new post?');
             }
         }
         imap_expunge($mh);
         imap_close($mh);
         if ($messages_skipped > 0) {
             EventLog::log(_t('Skipped %d messages from senders not on the whitelist.', array($messages_skipped)));
         }
     }
 }