Esempio n. 1
0
 function removeAll($removeAttachments = true)
 {
     global $database;
     $blogid = getBlogId();
     POD::query("UPDATE {$database['prefix']}BlogStatistics SET visits = 0 WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}DailyStatistics WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Categories WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Attachments WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Comments WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Links WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Filters WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RefererLogs WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RefererStatistics WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Plugins WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedStarred WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedReads WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedGroupRelations WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedGroups WHERE blogid = {$blogid}");
     if (file_exists(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml")) {
         unlink(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml");
     }
     if ($removeAttachments) {
         Path::removeFiles(Path::combine(ROOT, 'attach', $blogid));
     }
 }
 function removeAll($removeAttachments = true)
 {
     global $database;
     $blogid = getBlogId();
     $tags = POD::queryColumn("SELECT DISTINCT tag FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid}");
     POD::query("UPDATE {$database['prefix']}BlogStatistics SET visits = 0 WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}DailyStatistics WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Categories WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Attachments WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Comments WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}CommentsNotified WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Entries WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}LinkCategories WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Links WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RefererLogs WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}RefererStatistics WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}Plugins WHERE blogid = {$blogid}");
     //POD::query("DELETE FROM {$database['prefix']}UserSettings WHERE user = $blogid");
     POD::query("DELETE FROM {$database['prefix']}Filters WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedStarred WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedReads WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedGroupRelations WHERE blogid = {$blogid}");
     POD::query("DELETE FROM {$database['prefix']}FeedGroups WHERE blogid = {$blogid} AND id <> 0");
     if (count($tags) > 0) {
         $tagliststr = implode(', ', $tags);
         $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} ) ");
         }
     }
     if (file_exists(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml")) {
         unlink(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml");
     }
     if ($removeAttachments) {
         Path::removeFiles(Path::combine(ROOT, 'attach', $blogid));
         POD::query("UPDATE {$database['prefix']}BlogSettings SET logo = '' WHERE blogid = {$blogid}");
     }
 }
Esempio n. 3
0
function removeBlog($blogid)
{
    $pool = DBModel::getInstance();
    $ctx = Model_Context::getInstance();
    if (Setting::getServiceSetting("defaultBlogId", 1, true) == $blogid) {
        return false;
    }
    $targets = array('Attachments', 'BlogSettings', 'BlogStatistics', 'Categories', 'Comments', 'CommentsNotified', 'CommentsNotifiedQueue', 'DailyStatistics', 'Entries', 'EntriesArchive', 'FeedGroups', 'FeedReads', 'FeedStarred', 'FeedSettings', 'Filters', 'Links', 'LinkCategories', 'PageCacheLog', 'Plugins', 'RefererLogs', 'RefererStatistics', 'RemoteResponses', 'RemoteResponseLogs', 'SkinSettings', 'TagRelations', 'Privileges', 'XMLRPCPingSettings');
    //Clear Tables
    foreach ($targets as $t) {
        $pool->reset($t);
        $pool->setQualifier('blogid', 'eq', $blogid);
        $pool->delete();
    }
    //Delete Tags
    $tags = POD::queryColumn("SELECT DISTINCT tag FROM " . $ctx->getProperty('database.prefix') . "TagRelations WHERE blogid = {$blogid}");
    if (count($tags) > 0) {
        $tagliststr = implode(', ', $tags);
        // Tag id used at deleted blog.
        $nottargets = POD::queryColumn("SELECT DISTINCT tag FROM " . $ctx->getProperty('database.prefix') . "TagRelations WHERE tag in ( {$tagliststr} )");
        // Tag id used at other blogs.
        if (count($nottargets) > 0) {
            $nottargetstr = implode(', ', $nottargets);
            POD::execute("DELETE FROM " . $ctx->getProperty('database.prefix') . "Tags WHERE id IN ( {$tagliststr} ) AND id NOT IN ( {$nottargetstr} )");
        } else {
            POD::execute("DELETE FROM " . $ctx->getProperty('database.prefix') . "Tags WHERE id IN ( {$tagliststr} ) ");
        }
    }
    //Delete Feeds
    $feeds = POD::queryColumn("SELECT DISTINCT feeds FROM " . $ctx->getProperty('database.prefix') . "FeedGroupRelations WHERE blogid = {$blogid}");
    if (count($feeds) > 0) {
        foreach ($feeds as $feedId) {
            deleteFeed($blogid, $feedId);
        }
    }
    //Clear Plugin Database
    // TODO : encapsulate with 'value'
    $query = "SELECT name, value FROM " . $ctx->getProperty('database.prefix') . "ServiceSettings WHERE name like 'Database\\_%'";
    $plugintablesraw = POD::queryAll($query);
    foreach ($plugintablesraw as $table) {
        $dbname = $ctx->getProperty('database.prefix') . substr($table['name'], 9);
        POD::execute("DELETE FROM " . $ctx->getProperty('database.prefix') . "{$dbname} WHERE blogid = {$blogid}");
    }
    //Clear RSS Cache
    if (file_exists(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml")) {
        unlink(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml");
    }
    //Delete Attachments
    Path::removeFiles(Path::combine(ROOT, 'attach', $blogid));
    return true;
}
Esempio n. 4
0
function selectSkin($blogid, $skinName)
{
    $context = Model_Context::getInstance();
    importlib('blogskin');
    $blogid = getBlogId();
    if (empty($skinName)) {
        return _t('실패했습니다.');
    }
    if (strncmp($skinName, 'customize/', 10) == 0) {
        if (strcmp($skinName, "customize/{$blogid}") != 0) {
            return _t('실패 했습니다');
        }
    } else {
        $skinName = Path::getBaseName($skinName);
        if ($skinName === '.' || $skinName === '..') {
            return _t('실패 했습니다');
        }
    }
    if (file_exists(getSkinPath($skinName) . "/index.xml")) {
        $xml = file_get_contents(getSkinPath($skinName) . "/index.xml");
        $xmls = new XMLStruct();
        if (!$xmls->open($xml, $context->getProperty('service.encoding'))) {
            return _t('실패했습니다.');
        }
        $assignments = array('skin' => $skinName);
        $value = $xmls->getValue('/skin/default/recentEntries');
        if (!empty($value) || is_numeric($value)) {
            $assignments['entriesOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/recentComments');
        if (!empty($value) || is_numeric($value)) {
            $assignments['commentsOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/itemsOnGuestbook');
        if (!empty($value) || is_numeric($value)) {
            $assignments['commentsOnGuestbook'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tagsInCloud');
        if (!empty($value) || is_numeric($value)) {
            $assignments['tagsOnTagbox'] = $value;
        }
        $value = $xmls->getValue('/skin/default/sortInCloud');
        if (!empty($value) || is_numeric($value)) {
            $assignments['tagboxAlign'] = $value;
        }
        $value = $xmls->getValue('/skin/default/recentTrackbacks');
        if (!empty($value) || is_numeric($value)) {
            $assignments['trackbacksOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/expandComment');
        if (isset($value)) {
            $assignments['expandComment'] = $value ? '1' : '0';
        }
        $value = $xmls->getValue('/skin/default/expandTrackback');
        if (isset($value)) {
            $assignments['expandTrackback'] = $value ? '1' : '0';
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentNotice');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentNoticeLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentPage');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentPageLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentEntry');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentEntryLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentComment');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentCommentLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentTrackback');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentTrackbackLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfLink');
        if (!empty($value) || is_numeric($value)) {
            $assignments['linkLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/contentWidth');
        if (!empty($value) || is_numeric($value)) {
            $assignments['contentWidth'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnCategory');
        if (isset($value)) {
            $assignments['showListOnCategory'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnArchive');
        if (isset($value)) {
            $assignments['showListOnArchive'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnTag');
        if (isset($value)) {
            $assignments['showListOnTag'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnSearch');
        if (isset($value)) {
            $assignments['showListOnSearch'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnAuthor');
        if (isset($value)) {
            $assignments['showListOnAuthor'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/color');
        if (isset($value)) {
            $assignments['colorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/bgColor');
        if (isset($value)) {
            $assignments['bgcolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/activeColor');
        if (isset($value)) {
            $assignments['activecolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/activeBgColor');
        if (isset($value)) {
            $assignments['activebgcolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/labelLength');
        if (!empty($value) || is_numeric($value)) {
            $assignments['labelLengthOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/showValue');
        if (isset($value)) {
            $assignments['showValueOnTree'] = $value ? '1' : '0';
        }
        foreach ($assignments as $name => $value) {
            Setting::setSkinSetting($name, $value, $blogid);
        }
        if ($xmls->doesExist('/skin/support')) {
            foreach ($xmls->selectNodes('/skin/support') as $support) {
                if (!empty($support['.attributes']['mobile']) && $support['.attributes']['mobile'] == "yes") {
                    /// Main skin supports mobile, too.
                    Setting::setBlogSetting('useiPhoneUI', 0, true);
                } else {
                    Setting::setBlogSetting('useiPhoneUI', 1, true);
                }
            }
        } else {
            Setting::setBlogSetting('useiPhoneUI', 1, true);
        }
        // none/single/multiple
        $value = $xmls->getValue('/skin/default/commentMessage/none');
        if (is_null($value)) {
            Setting::setBlogSetting('noneCommentMessage', NULL, true);
        } else {
            Setting::setBlogSetting('noneCommentMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/commentMessage/single');
        if (is_null($value)) {
            Setting::setBlogSetting('singleCommentMessage', NULL, true);
        } else {
            Setting::setBlogSetting('singleCommentMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/trackbackMessage/none');
        if (is_null($value)) {
            Setting::setBlogSetting('noneTrackbackMessage', NULL, true);
        } else {
            Setting::setBlogSetting('noneTrackbackMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/trackbackMessage/single');
        if (is_null($value)) {
            Setting::setBlogSetting('singleTrackbackMessage', NULL, true);
        } else {
            Setting::setBlogSetting('singleTrackbackMessage', $value, true);
        }
    } else {
        Setting::setBlogSetting('noneCommentMessage', NULL, true);
        Setting::setBlogSetting('singleCommentMessage', NULL, true);
        Setting::setBlogSetting('noneTrackbackMessage', NULL, true);
        Setting::setBlogSetting('singleTrackbackMessage', NULL, true);
        Setting::setSkinSetting('skin', $skinName, $blogid);
    }
    Setting::removeBlogSetting("sidebarOrder", true);
    CacheControl::flushAll();
    CacheControl::flushSkin();
    Path::removeFiles(getSkinPath('customize/' . getBlogId()) . "/");
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}
Esempio n. 5
0
function removeBlog($blogid)
{
    $pool = DBModel::getInstance();
    $context = Model_Context::getInstance();
    if (Setting::getServiceSetting("defaultBlogId", 1, true) == $blogid) {
        return false;
    }
    $targets = array('Attachments', 'BlogSettings', 'BlogStatistics', 'Categories', 'Comments', 'CommentsNotified', 'CommentsNotifiedQueue', 'DailyStatistics', 'Entries', 'EntriesArchive', 'FeedGroups', 'FeedReads', 'FeedStarred', 'FeedSettings', 'Filters', 'Links', 'LinkCategories', 'PageCacheLog', 'Plugins', 'RefererLogs', 'RefererStatistics', 'RemoteResponses', 'RemoteResponseLogs', 'SkinSettings', 'TagRelations', 'Privileges', 'XMLRPCPingSettings');
    //Clear Tables
    foreach ($targets as $t) {
        $pool->reset($t);
        $pool->setQualifier('blogid', 'eq', $blogid);
        $pool->delete();
    }
    //Delete Tags
    $pool->reset("TagRelations");
    $pool->setQualifier("blogid", "eq", $blogid);
    $tags = $pool->getColumn("tag", "DISTINCT");
    if (count($tags) > 0) {
        $pool->reset("TagRelations");
        // Tag id used at deleted blog.
        $pool->setQualifier("tag", "hasoneof", $tags);
        $nottargets = $pool->getColumn("tag", "DISTINCT");
        // Tag id used at other blogs.
        if (count($nottargets) > 0) {
            $pool->reset("Tags");
            $pool->setQualifier("id", "hasoneof", $tags);
            $pool->setQualifier("id", "hasnoneof", $nottargets);
            $pool->delete();
        } else {
            $pool->reset("Tags");
            $pool->setQualifier("id", "hasoneof", $tags);
            $pool->delete();
        }
    }
    //Delete Feeds
    $pool->reset("FeedGroupRelations");
    $pool->setQualifier("blogid", "eq", $blogid);
    $feeds = $pool->getColumn("feeds", "DISTINCT");
    if (count($feeds) > 0) {
        foreach ($feeds as $feedId) {
            deleteFeed($blogid, $feedId);
        }
    }
    //Clear Plugin Database
    // TODO : encapsulate with 'value'
    $pool->reset("ServiceSettings");
    $pool->setQualifier("name", "like", "Database_");
    $plugintablesraw = $pool->getAll();
    foreach ($plugintablesraw as $table) {
        $pool->reset(substr($table['name'], 9));
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->delete();
    }
    //Clear RSS Cache
    if (file_exists(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml")) {
        unlink(__TEXTCUBE_CACHE_DIR__ . "/rss/{$blogid}.xml");
    }
    //Delete Attachments
    Path::removeFiles(Path::combine(ROOT, 'attach', $blogid));
    return true;
}
Esempio n. 6
0
function removeBlog($blogid)
{
    global $database;
    if (getServiceSetting("defaultBlogId", 1) == $blogid) {
        return false;
    }
    $tags = POD::queryColumn("SELECT DISTINCT tag FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid}");
    $feeds = POD::queryColumn("SELECT DISTINCT feeds FROM {$database['prefix']}FeedGroupRelations WHERE blogid = {$blogid}");
    //Clear Tables
    POD::execute("DELETE FROM {$database['prefix']}Attachments WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}BlogSettings WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}BlogStatistics WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Categories WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Comments WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}CommentsNotified WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}CommentsNotifiedQueue WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}DailyStatistics WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Entries WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}EntriesArchive WHERE blogid = {$blogid}");
    //	POD::execute("DELETE FROM {$database['prefix']}FeedGroupRelations WHERE blogid = $blogid");
    POD::execute("DELETE FROM {$database['prefix']}FeedGroups WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}FeedReads WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}FeedStarred WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}FeedSettings WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Filters WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Links WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}LinkCategories WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}PageCacheLog WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Plugins WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}RefererLogs WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}RefererStatistics WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}SkinSettings WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}TagRelations WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}Privileges WHERE blogid = {$blogid}");
    POD::execute("DELETE FROM {$database['prefix']}XMLRPCPingSettings WHERE blogid = {$blogid}");
    //Delete Tags
    if (count($tags) > 0) {
        $tagliststr = implode(', ', $tags);
        // Tag id used at deleted blog.
        $nottargets = POD::queryColumn("SELECT DISTINCT tag FROM {$database['prefix']}TagRelations WHERE tag in ( {$tagliststr} )");
        // Tag id used at other blogs.
        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} ) ");
        }
    }
    //Delete Feeds
    if (count($feeds) > 0) {
        foreach ($feeds as $feedId) {
            deleteFeed($blogid, $feedId);
        }
    }
    //Clear Plugin Database
    // TODO : encapsulate with 'value'
    $query = "SELECT name, value FROM {$database['prefix']}ServiceSettings WHERE name like 'Database\\_%'";
    $plugintablesraw = POD::queryAll($query);
    foreach ($plugintablesraw as $table) {
        $dbname = $database['prefix'] . substr($table['name'], 9);
        POD::execute("DELETE FROM {$database['prefix']}{$dbname} WHERE blogid = {$blogid}");
    }
    //Clear RSS Cache
    if (file_exists(ROOT . "/cache/rss/{$blogid}.xml")) {
        unlink(ROOT . "/cache/rss/{$blogid}.xml");
    }
    //Delete Attachments
    Path::removeFiles(Path::combine(ROOT, 'attach', $blogid));
    return true;
}
Esempio n. 7
0
function selectSkin($blogid, $skinName)
{
    global $database, $service;
    requireComponent('Needlworks.Cache.PageCache');
    requireLibrary('blog.skin');
    $blogid = getBlogId();
    if (empty($skinName)) {
        return _t('실패했습니다.');
    }
    if (strncmp($skinName, 'customize/', 10) == 0) {
        if (strcmp($skinName, "customize/{$blogid}") != 0) {
            return _t('실패 했습니다');
        }
    } else {
        $skinName = Path::getBaseName($skinName);
        if ($skinName === '.' || $skinName === '..') {
            return _t('실패 했습니다');
        }
    }
    if (file_exists(ROOT . "/skin/blog/{$skinName}/index.xml")) {
        $xml = file_get_contents(ROOT . "/skin/blog/{$skinName}/index.xml");
        $xmls = new XMLStruct();
        if (!$xmls->open($xml, $service['encoding'])) {
            return _t('실패했습니다.');
        }
        $assignments = array('skin' => $skinName);
        $value = $xmls->getValue('/skin/default/recentEntries');
        if (!empty($value) || is_numeric($value)) {
            $assignments['entriesOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/recentComments');
        if (!empty($value) || is_numeric($value)) {
            $assignments['commentsOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/itemsOnGuestbook');
        if (!empty($value) || is_numeric($value)) {
            $assignments['commentsOnGuestbook'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tagsInCloud');
        if (!empty($value) || is_numeric($value)) {
            $assignments['tagsOnTagbox'] = $value;
        }
        $value = $xmls->getValue('/skin/default/sortInCloud');
        if (!empty($value) || is_numeric($value)) {
            $assignments['tagboxAlign'] = $value;
        }
        $value = $xmls->getValue('/skin/default/recentTrackbacks');
        if (!empty($value) || is_numeric($value)) {
            $assignments['trackbacksOnRecent'] = $value;
        }
        $value = $xmls->getValue('/skin/default/expandComment');
        if (isset($value)) {
            $assignments['expandComment'] = $value ? '1' : '0';
        }
        $value = $xmls->getValue('/skin/default/expandTrackback');
        if (isset($value)) {
            $assignments['expandTrackback'] = $value ? '1' : '0';
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentNotice');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentNoticeLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentEntry');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentEntryLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentComment');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentCommentLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfRecentTrackback');
        if (!empty($value) || is_numeric($value)) {
            $assignments['recentTrackbackLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/lengthOfLink');
        if (!empty($value) || is_numeric($value)) {
            $assignments['linkLength'] = $value;
        }
        $value = $xmls->getValue('/skin/default/contentWidth');
        if (!empty($value) || is_numeric($value)) {
            $assignments['contentWidth'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnCategory');
        if (isset($value)) {
            $assignments['showListOnCategory'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnArchive');
        if (isset($value)) {
            $assignments['showListOnArchive'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnTag');
        if (isset($value)) {
            $assignments['showListOnTag'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnSearch');
        if (isset($value)) {
            $assignments['showListOnSearch'] = $value;
        }
        $value = $xmls->getValue('/skin/default/showListOnAuthor');
        if (isset($value)) {
            $assignments['showListOnAuthor'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/color');
        if (isset($value)) {
            $assignments['colorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/bgColor');
        if (isset($value)) {
            $assignments['bgcolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/activeColor');
        if (isset($value)) {
            $assignments['activecolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/activeBgColor');
        if (isset($value)) {
            $assignments['activebgcolorOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/labelLength');
        if (!empty($value) || is_numeric($value)) {
            $assignments['labelLengthOnTree'] = $value;
        }
        $value = $xmls->getValue('/skin/default/tree/showValue');
        if (isset($value)) {
            $assignments['showValueOnTree'] = $value ? '1' : '0';
        }
        foreach ($assignments as $name => $value) {
            Setting::setSkinSetting($name, $value, $blogid);
        }
        // none/single/multiple
        $value = $xmls->getValue('/skin/default/commentMessage/none');
        if (is_null($value)) {
            Setting::setBlogSetting('noneCommentMessage', NULL, true);
        } else {
            Setting::setBlogSetting('noneCommentMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/commentMessage/single');
        if (is_null($value)) {
            Setting::setBlogSetting('singleCommentMessage', NULL, true);
        } else {
            Setting::setBlogSetting('singleCommentMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/trackbackMessage/none');
        if (is_null($value)) {
            Setting::setBlogSetting('noneTrackbackMessage', NULL, true);
        } else {
            Setting::setBlogSetting('noneTrackbackMessage', $value, true);
        }
        $value = $xmls->getValue('/skin/default/trackbackMessage/single');
        if (is_null($value)) {
            Setting::setBlogSetting('singleTrackbackMessage', NULL, true);
        } else {
            Setting::setBlogSetting('singleTrackbackMessage', $value, true);
        }
    } else {
        Setting::setBlogSetting('noneCommentMessage', NULL, true);
        Setting::setBlogSetting('singleCommentMessage', NULL, true);
        Setting::setBlogSetting('noneTrackbackMessage', NULL, true);
        Setting::setBlogSetting('singleTrackbackMessage', NULL, true);
        Setting::setSkinSetting('skin', $skinName, $blogid);
    }
    Setting::removeBlogSetting("sidebarOrder", true);
    CacheControl::flushAll();
    CacheControl::flushSkin();
    Path::removeFiles(ROOT . "/skin/blog/customize/" . getBlogId() . "/");
    Setting::getSkinSettings($blogid, true);
    // refresh skin cache
    return true;
}