function flushItemsByPlugin($pluginName)
 {
     global $databases;
     $xmls = new XMLStruct();
     $manifest = @file_get_contents(ROOT . "/plugins/{$pluginName}/index.xml");
     if ($manifest && $xmls->open($manifest)) {
         if ($xmls->doesExist('/plugin/binding/listener')) {
             //event listener가 있는 경우
             foreach ($xmls->selectNodes('/plugin/binding/listener') as $listener) {
                 if (!empty($listener['.attributes']['event']) && !empty($listener['.value'])) {
                     // Event가 있는 경우
                     if (strpos(strtolower($listener['.attributes']['event']), 'view') !== false) {
                         CacheControl::flushCategory();
                     }
                 }
             }
             unset($listener);
         }
         if ($xmls->doesExist('/plugin/binding/tag')) {
             foreach ($xmls->selectNodes('/plugin/binding/tag') as $tag) {
                 if (!empty($tag['.attributes']['name']) && !empty($tag['.attributes']['handler'])) {
                     CacheControl::flushCategory();
                     CacheControl::flushTag();
                 }
             }
             unset($tag);
         }
         //			if ($xmls->doesExist('/plugin/binding/sidebar')) {
         //			TODO:	사이드바 캐시때 처리하도록 하지요.
         //			}
         if ($xmls->doesExist('/plugin/binding/formatter[lang()]')) {
             CacheControl::flushCategory();
         }
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
function useBlogSlogan($blogid, $useSloganOnPost, $useSloganOnCategory, $useSloganOnTag)
{
    $ctx = Model_Context::getInstance();
    $useSloganOnPost = $useSloganOnPost ? 1 : 0;
    $useSloganOnCategory = $useSloganOnCategory ? 1 : 0;
    $useSloganOnTag = $useSloganOnTag ? 1 : 0;
    if ($useSloganOnPost == $ctx->getProperty('blog.useSloganOnPost') && $useSloganOnCategory == $ctx->getProperty('blog.useSloganOnCategory') && $useSloganOnTag == $ctx->getProperty('blog.useSloganOnTag')) {
        return true;
    }
    /*	if(Setting::setBlogSettingGlobal('useSloganOnPost',$useSlogan) === false
    	|| Setting::setBlogSettingGlobal('useSloganOnCategory',$useSlogan) === false
    	|| Setting::setBlogSettingGlobal('useSloganOnTag',$useSlogan) === false
    		) {
    		return false;
    	}*/
    Setting::setBlogSettingGlobal('useSloganOnPost', $useSloganOnPost);
    Setting::setBlogSettingGlobal('useSloganOnCategory', $useSloganOnCategory);
    Setting::setBlogSettingGlobal('useSloganOnTag', $useSloganOnTag);
    $ctx->setProperty('blog.useSloganOnPost', $useSloganOnPost);
    $ctx->setProperty('blog.useSloganOnCategory', $useSloganOnCategory);
    $ctx->setProperty('blog.useSloganOnTag', $useSloganOnTag);
    requireModel('blog.feed');
    CacheControl::flushCategory();
    CacheControl::flushEntry();
    CacheControl::flushTag();
    fireEvent('ToggleBlogSlogan', null, $useSloganOnPost);
    clearFeed();
    return true;
}
Exemplo n.º 4
0
function setSkinSetting($blogid, $setting)
{
    global $skinSetting;
    // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE
    importlib('blogskin');
    $blogid = getBlogId();
    if (strncmp($context->getProperty('skin.skin'), 'customize/', 10) == 0) {
        if (strcmp($context->getProperty('skin.skin'), "customize/{$blogid}") != 0) {
            return false;
        }
    } else {
        $skinSetting['skin'] = Path::getBaseName($context->getProperty('skin.skin'));
        // Legacy global support. TODO: DELETE THIS LINE AFTER CHECK EVERY REFERENCES IN WHOLE SOURCE
        $context->setProperty('skin.skin', $skinSetting['skin']);
        if ($context->getProperty('skin.skin') === '.' || $context->getProperty('skin.skin') === '..') {
            return _t('실패 했습니다');
        }
    }
    $skinpath = getSkinPath($context->getProperty('skin.skin'));
    if (!is_dir($skinpath)) {
        return _t('실패 했습니다');
    }
    foreach ($setting as $key => $value) {
        Setting::setSkinSetting($key, $value, $blogid);
    }
    Setting::setSkinSetting('skin', $context->getProperty('skin.skin'), $blogid);
    Setting::setBlogSetting('useMicroformat', $setting['useMicroformat'], true);
    Setting::setBlogSetting('useAjaxComment', $setting['useAjaxComment'], true);
    Setting::setBlogSetting('useFOAF', $setting['useFOAF'] == 1 ? 1 : 0, true);
    Setting::setBlogSetting('entriesOnPage', $setting['entriesOnPage'], true);
    Setting::setBlogSetting('entriesOnList', $setting['entriesOnList'], true);
    CacheControl::flushCategory();
    CacheControl::flushTag();
    CacheControl::flushSkin();
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}
Exemplo n.º 5
0
function setCategoryVisibility($blogid, $id, $visibility)
{
    requireModel('blog.feed');
    if ($id == 0) {
        return false;
    }
    $parentVisibility = getParentCategoryVisibility($blogid, $id);
    if ($parentVisibility !== false && $parentVisibility < 2) {
        return false;
    }
    // return without changing if parent category is set to hidden.
    $pool = DBModel::getInstance();
    $pool->reset('Categories');
    $pool->setAttribute('visibility', $visibility);
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('id', 'eq', $id);
    $result = $pool->update();
    if ($result && $visibility == 1) {
        $result = setChildCategoryVisibility($blogid, $id, $visibility);
    }
    if ($result) {
        clearFeed();
    }
    updateEntriesOfCategory($blogid);
    CacheControl::flushCategory($id);
    return $result ? $visibility : false;
}
Exemplo n.º 6
0
function setCategoryVisibility($blogid, $id, $visibility)
{
    global $database;
    requireModel('blog.feed');
    if ($id == 0) {
        return false;
    }
    $parentVisibility = getParentCategoryVisibility($blogid, $id);
    if ($parentVisibility !== false && $parentVisibility < 2) {
        return false;
    }
    // return without changing if parent category is set to hidden.
    $result = POD::query("UPDATE {$database['prefix']}Categories\n\t\tSET visibility = {$visibility}\n\t\tWHERE blogid = {$blogid}\n\t\t\tAND id = {$id}");
    if ($result && $visibility == 1) {
        $result = setChildCategoryVisibility($blogid, $id, $visibility);
    }
    if ($result) {
        clearFeed();
    }
    updateEntriesOfCategory($blogid);
    CacheControl::flushCategory($id);
    return $result ? $visibility : false;
}
Exemplo n.º 7
0
function useBlogSlogan($blogid, $useSloganOnPost, $useSloganOnCategory, $useSloganOnTag)
{
    global $blog;
    requireModel('blog.feed');
    $useSloganOnPost = $useSloganOnPost ? 1 : 0;
    $useSloganOnCategory = $useSloganOnCategory ? 1 : 0;
    $useSloganOnTag = $useSloganOnTag ? 1 : 0;
    if ($useSloganOnPost == $blog['useSloganOnPost'] && $useSloganOnCategory == $blog['useSloganOnCategory'] && $useSloganOnTag == $blog['useSloganOnTag']) {
        return true;
    }
    /*	if(Setting::setBlogSettingGlobal('useSloganOnPost',$useSlogan) === false
    	|| Setting::setBlogSettingGlobal('useSloganOnCategory',$useSlogan) === false
    	|| Setting::setBlogSettingGlobal('useSloganOnTag',$useSlogan) === false
    		) {
    		return false;
    	}*/
    Setting::setBlogSettingGlobal('useSloganOnPost', $useSloganOnPost);
    Setting::setBlogSettingGlobal('useSloganOnCategory', $useSloganOnCategory);
    Setting::setBlogSettingGlobal('useSloganOnTag', $useSloganOnTag);
    $blog['useSloganOnPost'] = $useSloganOnPost;
    $blog['useSloganOnCategory'] = $useSloganOnCategory;
    $blog['useSloganOnTag'] = $useSloganOnTag;
    CacheControl::flushCategory();
    CacheControl::flushEntry();
    CacheControl::flushTag();
    fireEvent('ToggleBlogSlogan', null, $blog['useSloganOnPost']);
    clearFeed();
    return true;
}
Exemplo n.º 8
0
function setSkinSetting($blogid, $setting)
{
    global $database;
    global $skinSetting;
    requireLibrary('blog.skin');
    $blogid = getBlogId();
    if (strncmp($skinSetting['skin'], 'customize/', 10) == 0) {
        if (strcmp($skinSetting['skin'], "customize/{$blogid}") != 0) {
            return false;
        }
    } else {
        $skinSetting['skin'] = Path::getBaseName($skinSetting['skin']);
        if ($skinSetting['skin'] === '.' || $skinSetting['skin'] === '..') {
            return _t('실패 했습니다');
        }
    }
    $skinpath = ROOT . '/skin/blog/' . $skinSetting['skin'];
    if (!is_dir($skinpath)) {
        return _t('실패 했습니다');
    }
    foreach ($setting as $key => $value) {
        Setting::setSkinSetting($key, $value, $blogid);
    }
    Setting::setSkinSetting('skin', $skinSetting['skin'], $blogid);
    Setting::setBlogSetting('useMicroformat', $setting['useMicroformat'], true);
    Setting::setBlogSetting('useAjaxComment', $setting['useAjaxComment'], true);
    Setting::setBlogSetting('useFOAF', $setting['useFOAF'] == 1 ? 1 : 0, true);
    Setting::setBlogSetting('entriesOnPage', $setting['entriesOnPage'], true);
    Setting::setBlogSetting('entriesOnList', $setting['entriesOnList'], true);
    CacheControl::flushCategory();
    CacheControl::flushTag();
    CacheControl::flushSkin();
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}