Esempio n. 1
0
function CT_Start_Default($target)
{
    importlib("model.blog.attachment");
    $context = Model_Context::getInstance();
    $blogURL = $context->getProperty('uri.blog');
    $blogid = $context->getProperty('blog.id');
    $target .= '<ul>';
    $target .= '<li><a href="' . $blogURL . '/owner/entry/post">' . _t('새 글을 씁니다') . '</a></li>' . CRLF;
    $latestEntryId = Setting::getBlogSettingGlobal('LatestEditedEntry_user' . getUserId(), 0);
    if ($latestEntryId !== 0) {
        $latestEntry = CT_Start_Default_getEntry($blogid, $latestEntryId);
        if ($latestEntry != false) {
            $target .= '<li><a href="' . $blogURL . '/owner/entry/edit/' . $latestEntry['id'] . '">' . _f('최근글(%1) 수정', htmlspecialchars(Utils_Unicode::lessenAsEm($latestEntry['title'], 10))) . '</a></li>';
        }
    }
    if (Acl::check('group.administrators')) {
        $target .= '<li><a href="' . $blogURL . '/owner/skin">' . _t('스킨을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/sidebar">' . _t('사이드바 구성을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/setting">' . _t('블로그에 표시되는 값들을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/entry/category">' . _t('카테고리를 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/plugin">' . _t('플러그인을 켜거나 끕니다') . '</a></li>' . CRLF;
    }
    if ($context->getProperty('service.reader', false) != false) {
        $target .= '<li><a href="' . $blogURL . '/owner/network/reader">' . _t('RSS 리더를 봅니다') . '</a></li>' . CRLF;
    }
    $target .= '</ul>';
    return $target;
}
 function open($xml, $encoding = null)
 {
     if (!empty($encoding) && strtolower($encoding) != 'utf-8' && !Utils_Unicode::validate($xml)) {
         if (preg_match('/^<\\?xml[^<]*\\s+encoding=["\']?([\\w-]+)["\']?/', $xml, $matches)) {
             $encoding = $matches[1];
             $xml = preg_replace('/^(<\\?xml[^<]*\\s+encoding=)["\']?[\\w-]+["\']?/', '$1"utf-8"', $xml, 1);
         }
         if (strcasecmp($encoding, 'utf-8')) {
             $xml = Utils_Unicode::bring($xml, $encoding);
             if (is_null($xml)) {
                 $this->error = XML_ERROR_UNKNOWN_ENCODING;
                 return false;
             }
         }
     } else {
         if (substr($xml, 0, 3) == "") {
             $xml = substr($xml, 3);
         }
     }
     $p = xml_parser_create();
     xml_set_object($p, $this);
     xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
     xml_set_element_handler($p, 'o', 'c');
     xml_set_character_data_handler($p, 'd');
     xml_set_default_handler($p, 'x');
     $this->tree = array('children' => array());
     $this->_cursor =& $this->tree;
     $this->_cdata = false;
     xml_parse($p, $xml);
     unset($this->_cursor);
     unset($this->_cdata);
     $this->error = xml_get_error_code($p);
     xml_parser_free($p);
     return $this->error == XML_ERROR_NONE;
 }
Esempio n. 3
0
function CT_Start_Default($target)
{
    requireModel("blog.attachment");
    requireComponent("Eolin.PHP.Core");
    requireComponent("Textcube.Function.misc");
    global $blogid, $blogURL, $database, $service;
    $target .= '<ul>';
    $target .= '<li><a href="' . $blogURL . '/owner/entry/post">' . _t('새 글을 씁니다') . '</a></li>' . CRLF;
    $latestEntryId = Setting::getBlogSettingGlobal('LatestEditedEntry_user' . getUserId(), 0);
    if ($latestEntryId !== 0) {
        $latestEntry = CT_Start_Default_getEntry($blogid, $latestEntryId);
        if ($latestEntry != false) {
            $target .= '<li><a href="' . $blogURL . '/owner/entry/edit/' . $latestEntry['id'] . '">' . _f('최근글(%1) 수정', htmlspecialchars(Utils_Unicode::lessenAsEm($latestEntry['title'], 10))) . '</a></li>';
        }
    }
    if (Acl::check('group.administrators')) {
        $target .= '<li><a href="' . $blogURL . '/owner/skin">' . _t('스킨을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/sidebar">' . _t('사이드바 구성을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/skin/setting">' . _t('블로그에 표시되는 값들을 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/entry/category">' . _t('카테고리를 변경합니다') . '</a></li>' . CRLF;
        $target .= '<li><a href="' . $blogURL . '/owner/plugin">' . _t('플러그인을 켜거나 끕니다') . '</a></li>' . CRLF;
    }
    if ($service['reader'] != false) {
        $target .= '<li><a href="' . $blogURL . '/owner/network/reader">' . _t('RSS 리더를 봅니다') . '</a></li>' . CRLF;
    }
    $target .= '</ul>';
    return $target;
}
Esempio n. 4
0
function FM_Textile_summary($blogid, $id, $content, $keywords = array(), $useAbsolutePath = true)
{
    $context = Model_Context::getInstance();
    $view = FM_Textile_format($blogid, $id, $content, $keywords, $useAbsolutePath, true);
    if (!$context->getProperty("blog.publishWholeOnRSS")) {
        $view = Utils_Unicode::lessen(removeAllTags(stripHTML($view)), 255);
    }
    return $view;
}
Esempio n. 5
0
function FM_TTML_summary($blogid, $id, $content, $keywords = array(), $useAbsolutePath = true)
{
    global $blog;
    $view = FM_TTML_format($blogid, $id, $content, $keywords, $useAbsolutePath, true);
    if (!$blog['publishWholeOnRSS']) {
        $view = Utils_Unicode::lessen(removeAllTags(stripHTML($view)), 255);
    }
    return $view;
}
 function _buildQuery()
 {
     $query = DBModel::getInstance();
     $query->reset('ServiceSettings');
     $query->setQualifier('name', 'equals', Utils_Unicode::lessenAsEncoding($this->name, 32), false);
     if (isset($this->value)) {
         $query->setAttribute('value', Utils_Unicode::lessenAsEncoding($this->value, 255), true);
     }
     return $query;
 }
Esempio n. 7
0
function _getRecentEntriesView($entries, $template)
{
    $context = Model_Context::getInstance();
    ob_start();
    foreach ($entries as $entry) {
        $view = $template;
        Utils_Misc::dress('rctps_rep_link', $context->getProperty('uri.blog') . "/" . $entry['id'], $view);
        Utils_Misc::dress('rctps_rep_edit_link', $context->getProperty('uri.blog') . "/owner/entry/edit/" . $entry['id'], $view);
        Utils_Misc::dress('rctps_rep_title', htmlspecialchars(Utils_Unicode::lessenAsEm($entry['title'], 30)), $view);
        Utils_Misc::dress('rctps_rep_rp_cnt', "<span id=\"commentCountOnRecentEntries{$entry['id']}\">" . ($entry['comments'] > 0 ? "({$entry['comments']})" : '') . '</span>', $view);
        print $view;
    }
    $view = ob_get_contents();
    ob_end_clean();
    return $view;
}
Esempio n. 8
0
function RecentRP_getRecentCommentsView($comments, $template)
{
    global $contentContainer;
    $context = Model_Context::getInstance();
    ob_start();
    foreach ($comments as $comment) {
        $view = "{$template}";
        Utils_Misc::dress('rctrp_rep_link', $context->getProperty('uri.blog') . "/{$comment['entry']}#comment{$comment['id']}", $view);
        $contentContainer["recent_comment_{$comment['id']}"] = htmlspecialchars(Utils_Unicode::lessenAsEm(strip_tags($comment['comment']), 30));
        Utils_Misc::dress('rctrp_rep_desc', setTempTag("recent_comment_{$comment['id']}"), $view);
        Utils_Misc::dress('rctrp_rep_desc', htmlspecialchars(Utils_Unicode::lessenAsEm(strip_tags($comment['comment']), 30)), $view);
        Utils_Misc::dress('rctrp_rep_time', fireEvent('ViewRecentCommentDate', Timestamp::format3($comment['written'])), $view);
        Utils_Misc::dress('rctrp_rep_name', htmlspecialchars(Utils_Unicode::lessenAsEm(strip_tags($comment['name']), 10)) . $comment['secret'] . $comment['replier'], $view);
        print $view;
    }
    $view = ob_get_contents();
    ob_end_clean();
    return $view;
}
Esempio n. 9
0
/**
 * @brief Syndicating routine.
 * @see Tag, User, DBModel, Model_Context
 */
function SyndicateToEolin($entryId, $entry, $mode)
{
    $context = Model_Context::getInstance();
    $blogid = $context->getProperty('blog.id');
    $rpc = new XMLRPC();
    $rpc->url = 'http://ping.eolin.com/';
    $summary = array('blogURL' => $context->getProperty('uri.default'), 'syncURL' => $context->getProperty('uri.default') . "/plugin/abstractToEolin?entryId={$entryId}");
    if ($mode == 'create') {
        $summary['blogTitle'] = $context->getProperty('blog.title');
        $summary['language'] = $context->getProperty('blog.language');
        $summary['permalink'] = $context->getProperty('uri.default') . "/" . ($context->getProperty('blog.useSloganOnPost') ? "entry/{$entry['slogan']}" : $entry['id']);
        $summary['title'] = Utils_Unicode::lessenAsByte($entry['title'], 255);
        $summary['content'] = Utils_Unicode::lessenAsByte(stripHTML(getEntryContentView($blogid, $entry['id'], $entry['content'], $entry['contentformatter'])), 1023, '');
        $summary['author'] = User::authorName($entry['userid'], $entryId);
        $summary['tags'] = Tag::getTagsWithEntryId($blogid, $entry);
        $summary['location'] = $entry['location'];
        $summary['written'] = Timestamp::getRFC1123($entry['published']);
    }
    return $rpc->call("sync.{$mode}", $summary);
}
 function _buildQuery()
 {
     $query = DBModel::getInstance();
     $query->reset('RemoteResponses');
     $query->setQualifier('blogid', getBlogId());
     $query->setQualifier('responsetype', 'pingback');
     if (isset($this->id)) {
         if (!Validator::number($this->id, 1)) {
             return $this->_error('id');
         }
         $query->setQualifier('id', $this->id);
     }
     if (isset($this->entry)) {
         if (!Validator::number($this->entry, 1)) {
             return $this->_error('entry');
         }
         $query->setQualifier('entry', $this->entry);
     }
     if (isset($this->url)) {
         $this->url = Utils_Unicode::lessenAsEncoding(trim($this->url), 255);
         if (empty($this->url)) {
             return $this->_error('url');
         }
         $query->setQualifier('url', $this->url, true);
     }
     if (isset($this->ip)) {
         if (!Validator::ip($this->ip)) {
             return $this->_error('ip');
         }
         $query->setAttribute('ip', $this->ip, true);
     }
     if (isset($this->received)) {
         if (!Validator::timestamp($this->received)) {
             return $this->_error('received');
         }
         $query->setAttribute('written', $this->received);
     }
     if (isset($this->isFiltered)) {
         if ($this->isFiltered) {
             $query->setAttribute('isFiltered', 'UNIX_TIMESTAMP()');
         } else {
             $query->setAttribute('isFiltered', Validator::getBit($this->isFiltered));
         }
     }
     return $query;
 }
 function _buildQuery()
 {
     global $database;
     $this->host = Utils_Unicode::lessenAsEncoding(trim($this->host), 64);
     if (empty($this->host)) {
         return $this->_error('host');
     }
     $query = DBModel::getInstance();
     $query->reset('RefererStatistics');
     $query->setQualifier('blogid', 'equals', getBlogId());
     $query->setQualifier('host', 'equals', $this->host, true);
     if (isset($this->count)) {
         if (!Validator::number($this->count, 1)) {
             return $this->_error('count');
         }
         $query->setAttribute('count', $this->count);
     }
     return $query;
 }
Esempio n. 12
0
 function add()
 {
     global $database;
     $this->id = null;
     $this->link = Utils_Unicode::lessenAsEncoding(trim($this->link), 255);
     if (empty($this->link)) {
         return false;
     }
     if (isset($this->group)) {
         if (is_numeric($this->group) && $this->group > 0) {
             FeedGroup::getName($this->group);
         }
     }
     if (!is_numeric($this->feed)) {
         return false;
     }
     if (!is_numeric($this->published)) {
         return false;
     }
     $query = DBModel::getInstance();
     $query->reset('FeedItems');
     $query->setQualifier('feed', 'equals', $this->feed);
     $query->setQualifier('permalink', 'equals', $this->link, true);
     $this->id = $query->getCell('id');
     if (is_null($this->id)) {
         $query->setAttribute('id', $this->_getMaxId() + 1);
         $query->setAttribute('title', Utils_Unicode::lessenAsEncoding($this->title, 255), true);
         $query->setAttribute('description', $this->description, true);
         $query->setAttribute('tags', Utils_Unicode::lessenAsEncoding($this->tags, 255), true);
         $query->setAttribute('enclosure', Utils_Unicode::lessenAsEncoding($this->enclosure, 255), true);
         $query->setAttribute('author', Utils_Unicode::lessenAsEncoding($this->author, 255), true);
         $query->setAttribute('written', $this->published);
         $this->id = $query->insert();
         //echo mysql_error(), '<br />';
         if ($this->id === false) {
             return false;
         }
     }
     return true;
 }
 function _buildQuery()
 {
     $query = DBModel::getInstance();
     $query->reset('Users');
     $query->setQualifier('userid', getUserId());
     if (isset($this->userid)) {
         if (!Validator::number($this->userid, 1)) {
             return $this->_error('userid');
         }
         $query->setQualifier('userid', $this->userid);
     }
     if (isset($this->loginid)) {
         $this->loginid = Utils_Unicode::lessenAsEncoding(trim($this->loginid), 64);
         if (empty($this->loginid)) {
             return $this->_error('loginid');
         }
         $query->setAttribute('loginid', $this->loginid, true);
     }
     if (isset($this->password)) {
         $this->password = trim($this->password);
         if (empty($this->password)) {
             return $this->_error('password');
         }
         $query->setAttribute('password', $this->password, true);
     }
     if (isset($this->name)) {
         $this->name = Utils_Unicode::lessenAsEncoding(trim($this->name), 32);
         if (empty($this->name)) {
             return $this->_error('name');
         }
         $query->setAttribute('name', $this->name, true);
     }
     if (isset($this->created)) {
         if (!Validator::number($this->created, 0)) {
             return $this->_error('created');
         }
         $query->setAttribute('created', $this->created);
     }
     if (isset($this->lastLogin)) {
         if (!Validator::number($this->lastLogin, 1)) {
             return $this->_error('lastLogin');
         }
         $query->setAttribute('lastLogin', $this->lastLogin);
     }
     if (isset($this->host)) {
         if (!Validator::number($this->host, 0)) {
             return $this->_error('host');
         }
         $query->setAttribute('host', $this->host);
     }
     return $query;
 }
Esempio n. 14
0
function saveFeedItem($feedId, $item)
{
    global $database;
    $item = fireEvent('SaveFeedItem', $item);
    $item['permalink'] = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct($item['permalink'])));
    $item['author'] = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct($item['author'])));
    $item['title'] = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct($item['title'])));
    $item['description'] = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct($item['description']), 65535));
    $tagString = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct(implode(', ', $item['tags']))));
    $enclosureString = POD::escapeString(Utils_Unicode::lessenAsEncoding(Utils_Unicode::correct(implode('|', $item['enclosures']))));
    if ($item['written'] > gmmktime() + 86400) {
        return false;
    }
    $deadLine = 0;
    $feedlife = POD::queryCell("SELECT feedlife FROM {$database['prefix']}FeedSettings");
    if ($feedlife > 0) {
        $deadLine = gmmktime() - $feedlife * 86400;
    }
    if ($id = POD::queryCell("SELECT id FROM {$database['prefix']}FeedItems WHERE permalink='{$item['permalink']}'") && $item['written'] != 0) {
        $result = POD::query("UPDATE {$database['prefix']}FeedItems SET author = '{$item['author']}', title = '{$item['title']}', description = '{$item['description']}', tags = '{$tagString}', enclosure = '{$enclosureString}', written = {$item['written']} WHERE id = {$id}");
        /*
        TODO : 읽은글이 읽지않은 글로 표시되는 문제 원인이 찾아질때 까지 막아둠
        if (POD::num_rows($result) > 0)
            POD::query("DELETE FROM {$database['prefix']}FeedReads WHERE item = $id");
        */
    } else {
        if ($id != null) {
            return false;
        } else {
            if ($item['written'] == 0) {
                $item['written'] = gmmktime();
            }
            if ($item['written'] > $deadLine) {
                $id = POD::queryCell("SELECT max(id) FROM {$database['prefix']}FeedItems");
                if (!$id) {
                    $id = 0;
                }
                $id++;
                POD::query("INSERT INTO {$database['prefix']}FeedItems VALUES({$id}, {$feedId}, '{$item['author']}', '{$item['permalink']}', '{$item['title']}', '{$item['description']}', '{$tagString}', '{$enclosureString}', {$item['written']})");
            }
        }
    }
    return true;
}
Esempio n. 15
0
function getLinkListView($links)
{
    $context = Model_Context::getInstance();
    if (rtrim($context->getProperty('suri.url'), '/') == $context->getProperty('uri.path')) {
        $home = true;
    } else {
        $home = false;
    }
    $categoryName = null;
    $buffer = '<ul>' . CRLF;
    $showXfn = Setting::getBlogSettingGlobal('useMicroformat', 3) > 1;
    foreach ($links as $link) {
        if (!doesHaveOwnership() && $link['visibility'] == 0 || !doesHaveMembership() && $link['visibility'] < 2) {
            continue;
        }
        if ($categoryName != $link['categoryName']) {
            if (!empty($categoryName)) {
                $buffer .= '</ul>' . CRLF . '</li>' . CRLF;
            }
            $categoryName = $link['categoryName'];
            $buffer .= '<li><span class="link_ct">' . htmlspecialchars($link['categoryName']) . '</span>' . CRLF . '<ul>' . CRLF;
        }
        if ($showXfn && $home && $link['xfn']) {
            addXfnAttrs(htmlspecialchars($link['url']), htmlspecialchars($link['xfn']), $link['url']);
        }
        $buffer .= '<li><a href="' . htmlspecialchars($link['url']) . '">' . fireEvent('ViewLink', htmlspecialchars(Utils_Unicode::lessenAsEm($link['name'], $context->getProperty('skin.linkLength')))) . '</a></li>' . CRLF;
    }
    if (!empty($categoryName)) {
        $buffer .= '</ul>' . CRLF . '</li>' . CRLF;
    }
    $buffer .= '</ul>' . CRLF;
    return $buffer;
}
Esempio n. 16
0
function api_update_attaches_with_replace($entryId)
{
    $pool = DBModel::getInstance();
    $pool->reset('Attachments');
    $pool->setQualifier('blogid', 'eq', getBlogId());
    $pool->setQualifier('parent', 'eq', 0);
    $newFiles = $pool->getAll('name,label');
    if ($newFiles) {
        foreach ($newFiles as $newfile) {
            $newfile['label'] = Utils_Unicode::lessenAsEncoding($newfile['label'], 64);
            $pool->reset('Attachments');
            $pool->setQualifier('blogid', 'eq', getBlogId());
            $pool->setQualifier('parent', 'eq', $entryId);
            $pool->setQualifier('label', 'eq', $newfile['label'], true);
            $oldFile = $pool->getCell('name');
            if (!is_null($oldFile)) {
                deleteAttachment(getBlogId(), $entryId, $oldFile);
            }
        }
    }
    api_update_attaches($entryId);
}
Esempio n. 17
0
                trashCommentInOwner($blogid, $comment['id']);
            }
        }
    }
    POD::free($result);
}
if ($result = POD::query("SELECT id, url, site, subject, excerpt FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}")) {
    while ($trackback = POD::fetch($result)) {
        setProgress($item++ / $items * 100, _t('걸린 글 데이터를 교정하고 있습니다.'));
        $correction = '';
        if (!Utils_Unicode::validate($trackback['url'])) {
            $correction .= ' url = \'' . POD::escapeString(Utils_Unicode::correct($trackback['url'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['site'])) {
            $correction .= ' site = \'' . POD::escapeString(Utils_Unicode::correct($trackback['site'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['subject'])) {
            $correction .= ' subject = \'' . POD::escapeString(Utils_Unicode::correct($trackback['subject'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['excerpt'])) {
            $correction .= ' excerpt = \'' . POD::escapeString(Utils_Unicode::correct($trackback['excerpt'], '?')) . '\'';
        }
        if (strlen($correction) > 0) {
            POD::query("UPDATE {$database['prefix']}RemoteResponses SET {$correction} WHERE blogid = {$blogid} AND id = {$trackback['id']}");
            $corrected++;
        }
    }
    POD::free($result);
}
setProgress(100, _t('완료되었습니다.') . "({$corrected})");
finish();
Esempio n. 18
0
 function modifyTagsWithEntryId($blogid, $entry, $taglist)
 {
     global $database;
     if (empty($taglist)) {
         $taglist = array();
     }
     $tmptaglist = array_filter($taglist, 'Tag_removeEmptyTagHelper');
     $taglist = array();
     foreach ($tmptaglist as $tag) {
         $tag = POD::escapeString(trim($tag));
         array_push($taglist, $tag);
     }
     // step 1. Get deleted Tag
     $tmpoldtaglist = POD::queryColumn("SELECT name FROM {$database['prefix']}Tags\n\t\t\tLEFT JOIN {$database['prefix']}TagRelations ON tag = id \n\t\t\tWHERE blogid = {$blogid} AND entry = {$entry}");
     if ($tmpoldtaglist === null) {
         $tmpoldtaglist = array();
     }
     $oldtaglist = array();
     foreach ($tmpoldtaglist as $tag) {
         $tag = POD::escapeString(Utils_Unicode::lessenAsEncoding(trim($tag), 255));
         array_push($oldtaglist, $tag);
     }
     $deletedTagList = array_diff($oldtaglist, $taglist);
     $insertedTagList = array_diff($taglist, $oldtaglist);
     // step 2. Insert Tag
     if (count($insertedTagList) > 0) {
         foreach ($insertedTagList as $tg) {
             if (!Tag::doesExist($tg)) {
                 @POD::execute("INSERT INTO {$database['prefix']}Tags (id, name) VALUES (" . (Tag::_getMaxId() + 1) . ",'" . $tg . "')");
             }
         }
         //			$tagliststr = '(\'' . implode('\') , (\'', $insertedTagList) . '\')';
         //			POD::execute("INSERT IGNORE INTO {$database['prefix']}Tags (name) VALUES $tagliststr ");
         // step 3. Insert Relation
         $tagliststr = '\'' . implode('\' , \'', $insertedTagList) . '\'';
         /*
         POD::execute("INSERT INTO {$database['prefix']}TagRelations
             (SELECT $blogid, t.id, $entry FROM {$database['prefix']}Tags as t
                 WHERE
                 name in ( $tagliststr ) AND
                 t.id NOT IN
                     ( SELECT tag FROM {$database['prefix']}TagRelations WHERE
                         (tag = t.id) AND (entry = $entry) AND (blogid = $blogid)
                     )
                 )");
         */
         // For MySQL 3, Simple Query Version
         $tagIDs = POD::queryColumn("SELECT id FROM {$database['prefix']}Tags WHERE name in ( {$tagliststr} )");
         $tagrelations = array();
         foreach ($tagIDs as $tagid) {
             array_push($tagrelations, " ({$blogid}, {$tagid}, {$entry}) ");
         }
         foreach ($tagrelations as $tr) {
             @POD::execute("INSERT INTO {$database['prefix']}TagRelations VALUES {$tr}");
         }
         //$tagRelationStr = implode(', ', $tagrelations);
         //POD::execute("INSERT IGNORE INTO {$database['prefix']}TagRelations VALUES $tagRelationStr");
     }
     // step 4. Delete Tag
     if (count($deletedTagList) > 0) {
         // small step, get tag id list
         $tagliststr = '\'' . implode('\' , \'', $deletedTagList) . '\'';
         $t1list = POD::queryColumn("SELECT id FROM {$database['prefix']}Tags WHERE name in ( {$tagliststr} )");
         if (is_null($t1list)) {
             return;
         }
         // What?
         // Flushing pageCache
         foreach ($t1list as $tagids) {
             CacheControl::flushTag($tagids);
         }
         // Make string
         $t1liststr = implode(', ', $t1list);
         $taglist = POD::queryColumn("SELECT tag FROM {$database['prefix']}TagRelations\n\t\t\t\t\t\tWHERE blogid = {$blogid} AND entry = {$entry} AND tag in ( {$t1liststr} )");
         if (is_null($taglist)) {
             return;
         }
         // What?
         // now delete tag
         $tagliststr = implode(', ', $taglist);
         // step 5. Delete Relation
         POD::execute("DELETE FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid} AND entry = {$entry} AND tag in ( {$tagliststr} )");
         // step 6. Delete Tag
         $nottargets = POD::queryColumn("SELECT DISTINCT tag FROM {$database['prefix']}TagRelations WHERE tag in ( {$tagliststr} )");
         if (count($nottargets) > 0) {
             $nottargetstr = implode(', ', $nottargets);
             POD::execute("DELETE FROM {$database['prefix']}Tags WHERE id IN ( {$tagliststr} ) AND id NOT IN ( {$nottargetstr} )");
         } else {
             POD::execute("DELETE FROM {$database['prefix']}Tags WHERE id IN ( {$tagliststr} )");
         }
     }
 }
Esempio n. 19
0
 function saveSlogan($slogan = null)
 {
     global $database;
     $this->init();
     if (!Validator::number($this->id, 1)) {
         return $this->_error('id');
     }
     if (!Validator::number($this->userid, 1)) {
         return $this->_error('userid');
     }
     if (isset($slogan)) {
         $this->slogan = $slogan;
     }
     $query = new DBModel();
     $query->reset('Entries');
     $query->setQualifier('blogid', $this->blogid);
     if (isset($this->userid)) {
         $query->setQualifier('userid', $this->userid);
     }
     $query->setQualifier('id', $this->id);
     if (!$query->doesExist()) {
         return $this->_error('id');
     }
     if (isset($this->slogan) && $this->validateSlogan($this->slogan)) {
         $slogan0 = $this->slogan;
     } else {
         $slogan0 = $this->slogan = $this->makeSlogan($this->title);
     }
     $slogan0 = Utils_Unicode::lessenAsEncoding($slogan0, 255);
     for ($i = 1; $i < 1000; $i++) {
         //			$checkSlogan = POD::escapeString($this->slogan);
         $checkSlogan = $this->slogan;
         $query->setAttribute('slogan', $checkSlogan, true);
         if (!POD::queryExistence("SELECT id FROM {$database['prefix']}Entries " . "WHERE blogid = " . $this->blogid . " AND id <> {$this->id} AND slogan ='{$checkSlogan}'")) {
             if (!$query->update()) {
                 return $this->_error('update');
             }
             return true;
         }
         $this->slogan = Utils_Unicode::lessenAsEncoding($slogan0, 245) . '-' . $i;
     }
     // if try saveSlogan again, slogan string has more $i
     return $this->_error('limit');
 }
Esempio n. 20
0
        ?>
/owner/<?php 
        echo $editmode;
        ?>
/edit/<?php 
        echo $entryModifyLink;
        ?>
'<?php 
        echo $entry['draft'] ? "+(confirm('" . _t('임시 저장본을 보시겠습니까?') . "') ? '?draft' : '')" : '';
        ?>
; document.getElementById('list-form').submit(); return false;"><?php 
        echo htmlspecialchars($entry['title']);
        ?>
</a>
												<span class="description"><?php 
        echo $contentLength > 0 ? Utils_Unicode::lessenAsEm(removeAllTags(strip_tags($entry['content'])), $contentLength) : '';
        ?>
</span>
											</td>
											<td class="category">
<?php 
        if ($entry['category'] == 0) {
            ?>
<a id="category_<?php 
            echo $entry['id'];
            ?>
" class="uncategorized" href="<?php 
            echo $context->getProperty('uri.blog');
            ?>
/owner/entry?category=-10"><?php 
            echo _t('분류 없음');
 function setServiceSetting($name, $value, $global = null)
 {
     global $__serviceSetting;
     if (is_null($global)) {
         $name = 'plugin_' . $name;
     }
     $name = Utils_Unicode::lessenAsEncoding($name, 32);
     $query = DBModel::getInstance();
     $query->reset('ServiceSettings');
     $query->setQualifier('name', 'equals', $name, true);
     $query->setAttribute('name', $name, true);
     $query->setAttribute('value', $value, true);
     if (!empty($__serviceSetting)) {
         $__serviceSetting[$name] = $value;
     }
     return $query->replace();
 }
Esempio n. 22
0
function sendInvitationMail($blogid, $userid, $name, $comment, $senderName, $senderEmail)
{
    $ctx = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    if (empty($blogid)) {
        $pool->reset('BlogSettings');
        $blogid = $pool->getCell('max(blogid)');
        // If no blogid, get the latest created blogid.
    }
    $email = User::getEmail($userid);
    $pool->reset('Users');
    $pool->setQualifier('userid', 'eq', $userid);
    $password = getCell('password');
    $authtoken = getAuthToken($userid);
    $blogName = getBlogName($blogid);
    if (empty($email)) {
        return 1;
    }
    if (!preg_match('/^[^@]+@([-a-zA-Z0-9]+\\.)+[-a-zA-Z0-9]+$/', $email)) {
        return 2;
    }
    if (empty($name)) {
        $name = User::getName($userid);
    }
    if (strcmp($email, Utils_Unicode::lessenAsEncoding($email, 64)) != 0) {
        return 11;
    }
    //$loginid = POD::escapeString(Utils_Unicode::lessenAsEncoding($email, 64));
    $name = POD::escapeString(Utils_Unicode::lessenAsEncoding($name, 32));
    //$headers = 'From: ' . encodeMail($senderName) . '<' . $senderEmail . ">\n" . 'X-Mailer: ' . TEXTCUBE_NAME . "\n" . "MIME-Version: 1.0\nContent-Type: text/html; charset=utf-8\n";
    if (empty($name)) {
        $subject = _textf('귀하를 %1님이 초대합니다', $senderName);
    } else {
        $subject = _textf('%1님을 %2님이 초대합니다', $name, $senderName);
    }
    $message = file_get_contents(ROOT . "/resources/style/letter/letter.html");
    $message = str_replace('[##_title_##]', _text('초대장'), $message);
    $message = str_replace('[##_content_##]', $comment, $message);
    $message = str_replace('[##_images_##]', $ctx->getProperty('uri.service') . "/resources/style/letter", $message);
    $message = str_replace('[##_link_##]', getInvitationLink(getBlogURL($blogName), $email, $password, $authtoken), $message);
    $message = str_replace('[##_go_blog_##]', getBlogURL($blogName), $message);
    $message = str_replace('[##_link_title_##]', _text('블로그 바로가기'), $message);
    if (empty($name)) {
        $message = str_replace('[##_to_##]', '', $message);
    } else {
        $message = str_replace('[##_to_##]', _text('받는 사람') . ': ' . $name, $message);
    }
    $message = str_replace('[##_sender_##]', _text('보내는 사람') . ': ' . $senderName, $message);
    $ret = sendEmail($senderName, $senderEmail, $name, $email, $subject, $message);
    if ($ret !== true) {
        return array(14, $ret[1]);
    }
    return true;
}
Esempio n. 23
0
 static function add($email, $name)
 {
     global $database, $service, $user, $blog;
     if (empty($email)) {
         return 1;
     }
     if (!preg_match('/^[^@]+@([-a-zA-Z0-9]+\\.)+[-a-zA-Z0-9]+$/', $email)) {
         return 2;
     }
     if (strcmp($email, Utils_Unicode::lessenAsEncoding($email, 64)) != 0) {
         return 11;
     }
     $loginid = POD::escapeString(Utils_Unicode::lessenAsEncoding($email, 64));
     $name = POD::escapeString(Utils_Unicode::lessenAsEncoding($name, 32));
     $password = User::__generatePassword();
     $authtoken = md5(User::__generatePassword());
     if (POD::queryExistence("SELECT * FROM {$database['prefix']}Users WHERE loginid = '{$loginid}'")) {
         return 9;
         // User already exists.
     }
     if (POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Users WHERE name = '{$name}'")) {
         $name = $name . '.' . time();
     }
     $result = POD::query("INSERT INTO {$database['prefix']}Users (userid, loginid, password, name, created, lastlogin, host) VALUES (" . (User::__getMaxUserId() + 1) . ", '{$loginid}', '" . md5($password) . "', '{$name}', UNIX_TIMESTAMP(), 0, " . getUserId() . ")");
     if (empty($result)) {
         return 11;
     }
     $result = POD::query("INSERT INTO {$database['prefix']}UserSettings (userid, name, value) VALUES ('" . User::getUserIdByEmail($loginid) . "', 'AuthToken', '{$authtoken}')");
     if (empty($result)) {
         return 11;
     }
     return true;
 }
Esempio n. 24
0
function treatPluginTable($plugin, $name, $fields, $keys, $version)
{
    $context = Model_Context::getInstance();
    $query = DBModel::getInstance();
    if (doesExistTable($context->getProperty('database.prefix') . $name)) {
        $keyname = 'Database_' . $name;
        $value = $plugin;
        $result = Setting::getServiceSetting($keyname, null, true);
        if (is_null($result)) {
            $keyname = Utils_Unicode::lessenAsEncoding($keyname, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            $query->reset('ServiceSettings');
            $query->setAttribute('name', $keyname, true);
            $query->setAttribute('value', $value, true);
            $query->insert();
        } else {
            $keyname = Utils_Unicode::lessenAsEncoding($keyname, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            $values = explode('/', $result, 2);
            if (strcmp($plugin, $values[0]) != 0) {
                // diff plugin
                return false;
                // nothing can be done
            } else {
                if (strcmp($version, $values[1]) != 0) {
                    $query->reset('ServiceSettings');
                    $query->setQualifier('name', 'equals', $keyname, true);
                    $query->setAttribute('value', $value, true);
                    $query->update();
                    $eventName = 'UpdateDB_' . $name;
                    fireEvent($eventName, $values[1]);
                }
            }
        }
        return true;
    } else {
        $query->init($name);
        $query->structure = array("blogid" => array("type" => 'integer', "isNull" => false, "default" => 0, "index" => true));
        $isaiExists = false;
        foreach ($fields as $field) {
            $branch = array();
            $ai = '';
            if (strtolower($field['attribute']) == 'int' || strtolower($field['attribute']) == 'mediumint') {
                if ($field['autoincrement'] == 1 && !$isaiExists) {
                    $branch['autoincrement'] = true;
                    //$branch['index'] = true;
                    $isaiExists = true;
                    if (!in_array($field['name'], $keys)) {
                        $branch['index'] = true;
                    }
                }
            }
            $branch['type'] = strtolower($field['attribute']);
            if ($field['isnull'] == 0) {
                $branch['isNull'] = false;
            } else {
                $branch['isNull'] = true;
            }
            if (!is_null($field['default'])) {
                $branch['default'] = $field['default'];
            }
            if ($field['length'] >= 0) {
                $branch['length'] = $field['length'];
            }
            $query->structure[$field['name']] = $branch;
        }
        array_unshift($keys, 'blogid');
        $query->option['primary'] = $keys;
        if ($query->create()) {
            $keyname = Utils_Unicode::lessenAsEncoding('Database_' . $name, 32);
            $value = Utils_Unicode::lessenAsEncoding($plugin . '/' . $version, 255);
            Setting::setServiceSetting($keyname, $value, true);
            return true;
        } else {
            return false;
        }
    }
    return true;
}
 function _buildQuery()
 {
     global $database;
     $query = DBModel::getInstance();
     $query->reset('Comments');
     $query->setQualifier('blogid', 'equals', getBlogId());
     $query->setQualifier('entry', 'equals', 0);
     if (isset($this->id)) {
         if (!Validator::number($this->id, 1)) {
             return $this->_error('id');
         }
         $query->setQualifier('id', 'equals', $this->id);
     }
     if (isset($this->parent)) {
         if (!Validator::number($this->parent, 1)) {
             return $this->_error('parent');
         }
     }
     $query->setAttribute('parent', $this->parent);
     if (isset($this->commenter)) {
         if (!Validator::number($this->commenter, 1)) {
             return $this->_error('commenter');
         }
         if (!($this->name = User::getName($this->commenter))) {
             return $this->_error('commenter');
         }
         $query->setAttribute('replier', $this->commenter);
     }
     if (isset($this->name)) {
         $this->name = Utils_Unicode::lessenAsEncoding(trim($this->name), 80);
         if (empty($this->name)) {
             return $this->_error('name');
         }
         $query->setAttribute('name', $this->name, true);
     }
     if (isset($this->openid)) {
         $this->openid = Utils_Unicode::lessenAsEncoding(trim($this->openid), 128);
         if (empty($this->openid)) {
             return $this->_error('openid');
         }
         $query->setAttribute('openid', $this->openid, true);
     }
     if (isset($this->homepage)) {
         $this->homepage = Utils_Unicode::lessenAsEncoding(trim($this->homepage), 80);
         if (empty($this->homepage)) {
             return $this->_error('homepage');
         }
         $query->setAttribute('homepage', $this->homepage, true);
     }
     if (isset($this->ip)) {
         if (!Validator::ip($this->ip)) {
             return $this->_error('ip');
         }
         $query->setAttribute('ip', $this->ip, true);
     }
     if (isset($this->secret)) {
         $query->setAttribute('secret', Validator::getBit($this->secret));
     }
     if (isset($this->content)) {
         $this->content = trim($this->content);
         if (empty($this->content)) {
             return $this->_error('content');
         }
         $query->setAttribute('comment', $this->content, true);
     }
     if (isset($this->written)) {
         if (!Validator::timestamp($this->written)) {
             return $this->_error('written');
         }
         $query->setAttribute('written', $this->written);
     }
     if (isset($this->isfiltered)) {
         $query->setAttribute('isfiltered', Validator::getBit($this->isfiltered));
     }
     if (isset($this->password)) {
         $this->password = Utils_Unicode::lessenAsEncoding($this->password, 32);
         $query->setAttribute('password', $this->password, true);
         $this->password = null;
     }
     return $query;
 }
 function add()
 {
     if ($this->id != 0) {
         $this->id = null;
     }
     if (isset($this->parent) && !is_numeric($this->parent)) {
         return $this->_error('parent');
     }
     $this->name = Utils_Unicode::lessenAsEncoding(trim($this->name), 127);
     if (empty($this->name)) {
         return $this->_error('name');
     }
     $query = DBModel::getInstance();
     $query->reset('Categories');
     $query->setQualifier('blogid', 'equals', getBlogId());
     if (isset($this->parent)) {
         if (is_null($parentLabel = Category::getLabel($this->parent))) {
             return $this->_error('parent');
         }
         $query->setQualifier('parent', 'equals', $this->parent);
         $query->setAttribute('label', Utils_Unicode::lessenAsEncoding($parentLabel . '/' . $this->name, 255), true);
     } else {
         $query->setQualifier('parent', null);
         $query->setAttribute('label', $this->name, true);
     }
     $query->setQualifier('name', 'equals', $this->name, true);
     if (isset($this->priority)) {
         if (!is_numeric($this->priority)) {
             return $this->_error('priority');
         }
         $query->setAttribute('priority', $this->priority);
     }
     if ($query->doesExist()) {
         $this->id = $query->getCell('id');
         if ($query->update()) {
             return true;
         } else {
             return $this->_error('update');
         }
     }
     if (!isset($this->id)) {
         $this->id = $this->getNextCategoryId();
         $query->setQualifier('id', 'equals', $this->id);
     }
     if (!$query->insert()) {
         return $this->_error('insert');
     }
     return true;
 }
Esempio n. 27
0
function pretty_dress($view)
{
    global $blogid, $blog, $database, $service, $stats, $skinSetting;
    $context = Model_Context::getInstance();
    /* local static */
    global $pd_category, $pd_categoryXhtml, $pd_archive, $pd_calendar, $pd_tags, $pd_notices, $pd_recentEntry;
    global $pd_recentComment, $pd_recentTrackback, $pd_link, $pd_authorList;
    if (isset($_REQUEST['safe'])) {
        // safe mode
        return '<div class="coverpage-element-safebox">&hellip;</div>';
    }
    if (isset($_REQUEST['tag'])) {
        // safe mode
        return '<div class="coverpage-element-safebox"><p>' . nl2br(htmlspecialchars($view, ENT_QUOTES)) . '</p></div>';
    }
    $writer = User::getBlogOwnerName($blogid);
    $pageTitle = _t('페이지 제목');
    dress('page_title', htmlspecialchars($pageTitle), $view);
    dress('blogger', htmlspecialchars($writer), $view);
    dress('title', htmlspecialchars($context->getProperty('blog.title')), $view);
    dress('desc', htmlspecialchars($context->getProperty('blog.description')), $view);
    if ($context->getProperty('blog.logo') != null) {
        dress('image', $context->getProperty('service.path') . "/attach/{$blogid}/" . $context->getProperty('blog.logo'), $view);
    } else {
        dress('image', $context->getProperty('service.path') . "/resources/image/spacer.gif", $view);
    }
    dress('blog_link', $context->getProperty('uri.blog') . "/", $view);
    dress('keylog_link', $context->getProperty('uri.blog') . "/keylog", $view);
    dress('localog_link', $context->getProperty('uri.blog') . "/location", $view);
    dress('taglog_link', $context->getProperty('uri.blog') . "/tag", $view);
    dress('guestbook_link', $context->getProperty('uri.blog') . "/guestbook", $view);
    list($view, $searchView) = Skin::cutSkinTag($view, 'search');
    dress('search_name', 'search', $searchView);
    dress('search_text', isset($search) ? htmlspecialchars($search) : '', $searchView);
    dress('search_onclick_submit', 'searchBlog()', $searchView);
    dress('search', '<form id="TTSearchForm" action="' . parseURL($context->getProperty('uri.blog') . '/search/') . '" method="get" onsubmit="return searchBlog()">' . $searchView . '</form>', $view);
    dress('category', $pd_category, $view);
    dress('category_list', $pd_categoryXhtml, $view);
    dress('count_total', $stats['total'], $view);
    dress('count_today', $stats['today'], $view);
    dress('count_yesterday', $stats['yesterday'], $view);
    list($view, $archiveView) = Skin::cutSkinTag($view, 'archive_rep');
    dress('archive_rep', getArchivesView($pd_archive, $archiveView), $view);
    dress('calendar', $pd_calendar, $view);
    list($view, $randomView) = Skin::cutSkinTag($view, 'random_tags');
    dress('random_tags', getRandomTagsView($pd_tags, $randomView), $view);
    list($view, $recentNoticeItem) = Skin::cutSkinTag($view, 'rct_notice_rep');
    list($view, $noticeView) = Skin::cutSkinTag($view, 'rct_notice');
    $notices = $pd_notices;
    if (sizeof($notices) == 0) {
        $notices = array(array('title' => _t('공지 제목'), 'id' => -1));
    }
    if (sizeof($notices) > 0) {
        $itemsView = '';
        foreach ($notices as $notice) {
            $itemView = $recentNoticeItem;
            dress('notice_rep_title', htmlspecialchars(fireEvent('ViewNoticeTitle', Utils_Unicode::lessenAsEm($notice['title'], $skinSetting['recentNoticeLength']), $notice['id'])), $itemView);
            dress('notice_rep_link', "{$context->getProperty}('uri.blog')/notice/{$notice['id']}", $itemView);
            $itemsView .= $itemView;
        }
        dress('rct_notice_rep', $itemsView, $noticeView);
        dress('rct_notice', $noticeView, $view);
    }
    list($view, $authorList) = Skin::cutSkinTag($view, 'author_rep');
    dress('author_rep', getAuthorListView($pd_authorList, $authorList), $view);
    list($view, $recentEntry) = Skin::cutSkinTag($view, 'rctps_rep');
    dress('rctps_rep', getRecentEntriesView($pd_recentEntry, null, $recentEntry), $view);
    list($view, $recentComments) = Skin::cutSkinTag($view, 'rctrp_rep');
    dress('rctrp_rep', getRecentCommentsView($pd_recentComment, null, $recentComments), $view);
    list($view, $recentTrackback) = Skin::cutSkinTag($view, 'rcttb_rep');
    dress('rcttb_rep', getRecentTrackbacksView($pd_recentTrackback, null, $recentTrackback), $view);
    list($view, $s_link_rep) = Skin::cutSkinTag($view, 'link_rep');
    dress('link_rep', getLinksView($pd_link, $s_link_rep), $view);
    dress('rss_url', "{$context->getProperty}('uri.blog')/rss", $view);
    dress('owner_url', "{$context->getProperty}('uri.blog')/owner", $view);
    dress('textcube_name', TEXTCUBE_NAME, $view);
    dress('textcube_version', TEXTCUBE_VERSION, $view);
    $tagSearches = array('@<a @i', '@</a *>@i', '@ id *= *".*"@isU', '@ onkey(down|up|press) *="@i', '@ on(click|load|unload) *="@i', '@<input +@i', '@<script.*</script *>@siU', '@<form @siU', '@</form>@siU');
    $tagReplaces = array('<span ', '</span>', '', ' onnothing="', ' onnothing="', '<input disabled="disabled" ', '', '<div ', '</div>');
    $view = preg_replace($tagSearches, $tagReplaces, $view);
    return correctCoverpageImage($view);
}
Esempio n. 28
0
 private function validate()
 {
     if (is_null($this->id)) {
         $this->id = $this->getNextId();
     }
     $this->category = Utils_Unicode::lessenAsByte($this->category, 11);
     $this->content = Utils_Unicode::lessenAsByte($this->content, 512);
     if (empty($this->author)) {
         $this->author = User::getName();
     }
     $this->author = Utils_Unicode::lessenAsByte($this->author, 32);
     if (!Validator::isInteger($this->blogid, 1)) {
         return $this->error('blogid');
     }
     if (!Validator::timestamp($this->created)) {
         return $this->error('created');
     }
     return true;
 }
Esempio n. 29
0
function FM_default_summary($blogid, $id, $content, $keywords = array(), $useAbsolutePath = false)
{
    $context = Model_Context::getInstance();
    if (!$context->getProperty('blog.publishWholeOnRSS')) {
        $content = Utils_Unicode::lessen(removeAllTags(stripHTML($content)), 255);
    }
    return $content;
}
 function _buildQuery()
 {
     global $database;
     $query = DBModel::getInstance();
     $query->reset('LinkCategories');
     $query->setQualifier('blogid', 'equals', getBlogId());
     if (isset($this->id)) {
         if (!Validator::number($this->id, 1)) {
             return $this->_error('id');
         }
         $query->setQualifier('id', 'equals', $this->id);
     }
     if (isset($this->pid)) {
         if (!Validator::number($this->pid, 1)) {
             return $this->_error('pid');
         }
         $query->setQualifier('pid', 'equals', $this->pid);
     }
     if (isset($this->priority)) {
         if (intval($this->priority) < 0) {
             return $this->_error('category');
         }
         $query->setQualifier('priority', 'equals', $this->priority);
     }
     if (isset($this->name)) {
         $this->url = Utils_Unicode::lessenAsEncoding(trim($this->name), 255);
         if (empty($this->name)) {
             return $this->_error('name');
         }
         $query->setQualifier('name', 'equals', $this->name, true);
     }
     if (isset($this->visibility)) {
         if (intval($this->visibility) < 0) {
             return $this->_error('visibility');
         }
         $query->setQualifier('visibility', 'equals', $this->visibility);
     }
     return $query;
 }