Пример #1
0
function metaWeblog_newMediaObject()
{
    $context = Model_Context::getInstance();
    $params = func_get_args();
    $result = api_login($params[1], $params[2]);
    if ($result) {
        return $result;
    }
    $file = array('name' => $params[3]['name'], 'content' => $params[3]['bits'], 'size' => count($params[3]['bits']));
    $attachment = api_addAttachment(getBlogId(), 0, $file);
    if (!$attachment) {
        return new XMLRPCFault(1, "Can't create file");
    }
    $attachurl = array('url' => $context->getProperty('uri.host') . $context->getProperty('service.path') . "/attach/" . $blogid . "/" . $attachment['name']);
    return $attachurl;
}
Пример #2
0
 function retrieveCallback($lines, $uid)
 {
     $this->appendUid($uid);
     $mail = $this->pop3->parse($lines);
     if (isset($mail['date_string'])) {
         $slogan = $mail['date_string'];
         $docid = $mail['time_string'];
     } else {
         $slogan = date("Y-m-d");
         $docid = date("H:i:s");
     }
     if (in_array($mail['subject'], array('제목없음'))) {
         $mail['subject'] = '';
     }
     if (!$this->isAllowed($mail)) {
         return false;
     }
     if (false && empty($mail['attachments'])) {
         $this->logMail($mail, "SKIP");
         return false;
     }
     $post = new Post();
     $moblog_begin = "\n<div class=\"moblog-entry\">";
     $moblog_end = "\n</div>\n";
     if ($post->open("slogan = '{$slogan}'")) {
         $post->loadTags();
         $this->log("* 기존 글을 엽니다. (SLOGAN:{$slogan})");
         if (empty($post->tags)) {
             $post->tags = array();
         }
         $tags = $this->extractTags($mail);
         /* mail content will be changed */
         $post->tags = array_merge($post->tags, $tags);
         $post->content .= $moblog_begin . $this->_getDecoratedContent($mail, $docid);
         $post->modified = $mail['date'];
         $post->visibility = $this->visibility;
     } else {
         $this->log("* 새 글을 작성합니다. (SLOGAN:{$slogan})");
         if (isset($mail['date_year'])) {
             $post->title = str_replace(array('%Y', '%M', '%D'), array($mail['date_year'], $mail['date_month'], $mail['date_day']), $this->subject);
         } else {
             $post->title = str_replace(array('%Y', '%M', '%D'), array(date("Y"), date("m"), date("d")), $this->subject);
         }
         $post->userid = $this->userid;
         $post->category = $this->category;
         $post->tags = $this->extractTags($mail);
         /* Go with csv string, Tag class supports both string and array */
         $post->content = $moblog_begin . $this->_getDecoratedContent($mail, $docid);
         $post->contentformatter = getDefaultFormatter();
         $post->contenteditor = getDefaultEditor();
         $post->created = time();
         $post->acceptcomment = true;
         $post->accepttrackback = true;
         $post->visibility = $this->visibility;
         $post->published = time();
         $post->modified = $mail['date'];
         $post->slogan = $slogan;
         if (!$post->add()) {
             $this->logMail($mail, "ERROR");
             $this->log(_t("실패: 글을 추가하지 못하였습니다") . " : " . $post->error);
             return false;
         } else {
             CacheControl::flushCategory($post->category);
         }
     }
     /* 슬로건을 지워야만 문제가 발생하지 않습니다. */
     //unset($post->slogan);
     if (isset($mail['attachments']) && count($mail['attachments'])) {
         importlib("model.blog.api");
         $post->content .= "<div class=\"moblog-attachments\">\n";
         foreach ($mail['attachments'] as $mail_att) {
             $this->log("* " . _t("첨부") . " : {$mail_att['filename']}");
             $att = api_addAttachment(getBlogId(), $post->id, array('name' => $mail_att['filename'], 'content' => $mail_att['decoded_content'], 'size' => $mail_att['length']));
             if (!$att) {
                 $this->logMail($mail, "ERROR");
                 $this->log(_t("실패: 첨부파일을 추가하지 못하였습니다") . " : " . $post->error);
                 return false;
             }
             $alt = htmlentities($mail_att['filename'], ENT_QUOTES, 'utf-8');
             $content = '[##_1C|$FILENAME|width="$WIDTH" height="$HEIGHT" alt="' . $alt . '"|_##]';
             $content = str_replace('$FILENAME', $att['name'], $content);
             $content = str_replace('$WIDTH', $att['width'], $content);
             $content = str_replace('$HEIGHT', $att['height'], $content);
             $post->content .= $content;
         }
         $post->content .= "\n</div>";
     }
     $post->content .= $moblog_end;
     if (!$post->update()) {
         $this->logMail($mail, "ERROR");
         $this->log(_t("실패: 첨부파일을 본문에 연결하지 못하였습니다") . ". : " . $post->error);
         return false;
     }
     $this->logMail($mail, "OK");
     return true;
 }