コード例 #1
0
 function stripImagesFromMessage($message_id)
 {
     $db = JFactory::getDBO();
     $qry = "SELECT * FROM #__fss_ticket_messages WHERE id = " . $db->escape($message_id);
     $db->setQuery($qry);
     $message = $db->loadObject();
     $body = $message->body;
     $count = 0;
     while (strpos($body, "[img]data:") !== false) {
         $start = strpos($body, "[img]data:");
         $end = strpos($body, "[/img]", $start);
         if ($end < 1) {
             break;
         }
         $count++;
         $content = substr($body, $start + 5, $end - $start - 5);
         list($type, $rest) = explode(";", $content, 2);
         list($encoding, $data) = explode(",", $rest, 2);
         $image_data = base64_decode($data);
         list($junk, $extension) = explode("/", $type, 2);
         $filename = "message-{$message_id}-inline-image-{$count}." . $extension;
         $destpath = JPATH_SITE . DS . FSS_Settings::get('attach_location') . DS . 'support' . DS;
         $destname = FSS_File_Helper::makeAttachFilename("support", $filename, date("Y-m-d", strtotime($message->posted)), $this, $message->user_id);
         if (file_put_contents($destpath . $destname, $image_data)) {
             $size = filesize($destpath . $destname);
             $qry = "INSERT INTO #__fss_ticket_attach (ticket_ticket_id, filename, diskfile, size, user_id, added, message_id, inline) VALUES ('";
             $qry .= FSSJ3Helper::getEscaped($db, $this->id) . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $filename) . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $destname) . "',";
             $qry .= "'" . $size . "',";
             $qry .= "'" . FSSJ3Helper::getEscaped($db, $message->user_id) . "',";
             $qry .= "'" . $message->posted . "', " . $message->id . ", 1)";
             $db->setQuery($qry);
             $db->Query();
             $attach_id = $db->insertid();
         }
         $key = FSS_Helper::base64url_encode(FSS_Helper::encrypt($attach_id, FSS_Helper::getEncKey("file")));
         $replace = "[img]" . JURI::base() . "index.php?option=com_fss&view=image&fileid={$attach_id}&key={$key}" . "[/img]";
         $body = substr($body, 0, $start) . $replace . substr($body, $end + 6);
     }
     if ($count > 0) {
         $qry = "UPDATE #__fss_ticket_messages SET body = \"" . $db->escape($body) . "\" WHERE id = " . $db->escape($message_id);
         $db->setQuery($qry);
         $db->Query();
     }
 }
コード例 #2
0
ファイル: helper.php プロジェクト: vstorm83/propertease
 static function AutoLoginCreate($userid)
 {
     $o = mt_rand(10000, 99999) . "|" . time() . "|" . $userid . "|1";
     $enc = self::encrypt($o, self::getEncKey());
     return FSS_Helper::base64url_encode($enc);
 }
コード例 #3
0
ファイル: emailcheck.php プロジェクト: vstorm83/propertease
 function processInlineImages($message_id, $body = null)
 {
     // scan body for [cid:image001.png@01D04526.5927F8D0] and replace with any images attached to that message
     $db = JFactory::getDBO();
     if ($body == "") {
         $qry = "SELECT * FROM #__fss_ticket_messages WHERE id = " . $db->escape($message_id);
         $db->setQuery($qry);
         $message = $db->loadObject();
         $body = $message->body;
     }
     $qry = "SELECT * FROM #__fss_ticket_attach WHERE message_id = " . $db->escape($message_id);
     $db->setQuery($qry);
     $attach = $db->loadObjectList();
     if (preg_match_all("/\\[cid\\:(.*)\\@.*\\]/", $body, $matches)) {
         $changed = false;
         foreach ($matches[0] as $offset => $match) {
             $image = $matches[1][$offset];
             foreach ($attach as $att) {
                 if ($att->filename == $image) {
                     $attach_id = $att->id;
                     $key = FSS_Helper::base64url_encode(FSS_Helper::encrypt($attach_id, FSS_Helper::getEncKey("file")));
                     $replace = "[img]" . JURI::base() . "index.php?option=com_fss&view=image&fileid={$attach_id}&key={$key}" . "[/img]";
                     $body = str_replace($match, $replace, $body);
                     $changed = true;
                 }
             }
         }
         if ($changed) {
             $qry = "UPDATE #__fss_ticket_messages SET body = '" . $db->escape($body) . "' WHERE id = " . $db->escape($message_id);
             $db->setQuery($qry);
             $db->Query();
         }
     }
     return $body;
 }