Exemple #1
0
function printIphoneArchives($blogid)
{
    global $database;
    $archives = array();
    $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid);
    $skinSetting = Setting::getSkinSettings($blogid);
    $result = POD::queryAllWithDBCache("SELECT EXTRACT(year_month FROM FROM_UNIXTIME(e.published)) period, COUNT(*) count \n\t\tFROM {$database['prefix']}Entries e\n\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\tGROUP BY period \n\t\tORDER BY period \n\t\tDESC ");
    if ($result) {
        foreach ($result as $archive) {
            array_push($archives, $archive);
        }
    }
    return $archives;
}
Exemple #2
0
function getSkinSettings($blogid, $forceReload = false)
{
    return Setting::getSkinSettings($blogid, $forceReload);
}
Exemple #3
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;
}
 function setSkinSetting($name, $value, $blogid = null)
 {
     global $__gCacheSkinSettings;
     global $__gCacheBlogSettings;
     global $gCacheStorage;
     if (is_null($blogid)) {
         $blogid = getBlogId();
     }
     if (!is_numeric($blogid)) {
         return null;
     }
     if (!array_key_exists($blogid, $__gCacheSkinSettings)) {
         // force loading
         Setting::getSkinSettings($blogid, false);
     }
     if ($__gCacheBlogSettings[$blogid] === false) {
         return null;
     }
     $gCacheStorage->purge();
     if (array_key_exists($name, $__gCacheSkinSettings[$blogid])) {
         // overwrite value
         $__gCacheSkinSettings[$blogid][$name] = $value;
         $query = DBModel::getInstance();
         $query->reset('SkinSettings');
         $query->setQualifier('blogid', 'equals', $blogid);
         $query->setQualifier('name', 'equals', $name, true);
         $query->setAttribute('blogid', $blogid);
         $query->setAttribute('name', $name, true);
         $query->setAttribute('value', $value, true);
         return $query->replace();
     }
     // insert new value
     $__gCacheSkinSettings[$blogid][$name] = $value;
     $query = DBModel::getInstance();
     $query->reset('SkinSettings');
     $query->setAttribute('blogid', $blogid);
     $query->setAttribute('name', $name, true);
     $query->setAttribute('value', $value, true);
     return $query->insert();
 }
Exemple #5
0
function getCalendar($blogid, $period)
{
    global $database;
    $skinSetting = Setting::getSkinSettings($blogid);
    $pool = DBModel::getInstance();
    $pool->init("Entries");
    $pool->setAlias("Entries", "e");
    $pool->setQualifier("e.blogid", "eq", $blogid);
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", ">=", 0);
    if (!doesHaveOwnership()) {
        $pool->setQualifier("e.visibility", ">", 0);
        $pool = getPrivateCategoryExclusionQualifier($pool, $blogid);
    }
    $calendar = array('days' => array());
    if ($period === true || !checkPeriod($period)) {
        $period = Timestamp::getYearMonth();
    }
    $calendar['period'] = $period;
    $calendar['year'] = substr($period, 0, 4);
    $calendar['month'] = substr($period, 4, 2);
    switch (POD::dbms()) {
        case 'Cubrid':
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYY')", "eq", $calendar['year'], true);
            $pool->setQualifier("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'MM')", "eq", $calendar['month'], true);
            $result = $pool->getAll("TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'DD')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'SQLite3':
            $pool->setQualifier("strftime('%Y',e.published,'unixepoch')", "eq", $calendar['year'], true);
            $pool->setQualifier("strftime('%m',e.published,'unixepoch')", "eq", $calendar['month'], true);
            $result = $pool->getAll("strftime('%d',e.published,'unixepoch')", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
        case 'MySQL':
        case 'MySQLi':
        case 'PostgreSQL':
        default:
            $pool->setQualifier("YEAR(FROM_UNIXTIME(e.published))", "eq", $calendar['year'], true);
            $pool->setQualifier("MONTH(FROM_UNIXTIME(e.published))", "eq", $calendar['month'], true);
            $result = $pool->getAll("DAYOFMONTH(FROM_UNIXTIME(e.published))", array('filter' => 'distinct', 'usedbcache' => true, 'cacheprefix' => 'entry'));
            break;
    }
    if ($result) {
        foreach ($result as $dayArray) {
            list($day) = $dayArray;
            array_push($calendar['days'], $day);
        }
    }
    $calendar['days'] = array_flip($calendar['days']);
    return $calendar;
}
Exemple #6
0
function getCategoriesSkin()
{
    $ctx = Model_Context::getInstance();
    $setting = Setting::getSkinSettings(getBlogId());
    $skin = array('name' => "{$setting['skin']}", 'url' => $ctx->getProperty('service.path') . "/skin/tree/{$setting['tree']}", 'labelLength' => $setting['labelLengthOnTree'], 'showValue' => $setting['showValueOnTree'], 'itemColor' => "{$setting['colorOnTree']}", 'itemBgColor' => "{$setting['bgColorOnTree']}", 'activeItemColor' => "{$setting['activeColorOnTree']}", 'activeItemBgColor' => "{$setting['activeBgColorOnTree']}");
    return $skin;
}
Exemple #7
0
 private function __URIvariableParser()
 {
     global $suri, $blog, $blogid, $skinSetting, $gCacheStorage;
     // To support legacy for global variables.
     $blogid = $this->blogid;
     $gCacheStorage = globalCacheStorage::getInstance();
     // Initialize global cache
     $suri = $this->suri;
     $blog = Setting::getBlogSettingsGlobal($this->blogid);
     $blog['id'] = $this->blogid;
     $skinSetting = Setting::getSkinSettings($this->blogid);
     if (!is_null($this->context->getProperty('service.serviceURL'))) {
         $this->uri['service'] = $this->context->getProperty('service.serviceURL');
     }
     if (!isset($this->uri['service'])) {
         $this->uri['service'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $this->context->getProperty('service.domain') . (!is_null($this->context->getProperty('service.port')) ? ':' . $this->context->getProperty('service.port') : '') . $this->context->getProperty('service.path');
     }
     $this->context->useNamespace('service');
     switch ($this->context->getProperty('service.type')) {
         case 'domain':
             $this->uri['path'] = $this->context->getProperty('path');
             $blog['primaryBlogURL'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $blog['name'] . '.' . $this->context->getProperty('domain') . (!is_null($this->context->getProperty('port')) ? ':' . $this->context->getProperty('port') : '') . $this->uri['path'];
             if (!empty($blog['secondaryDomain'])) {
                 $blog['secondaryBlogURL'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $blog['secondaryDomain'] . (!is_null($this->context->getProperty('port')) ? ':' . $this->context->getProperty('port') : '') . $this->uri['path'];
             } else {
                 $blog['secondaryBlogURL'] = null;
             }
             if ($blog['defaultDomain']) {
                 $this->uri['default'] = $blog['secondaryBlogURL'];
                 if ($_SERVER['HTTP_HOST'] == $blog['secondaryDomain']) {
                     $this->uri['base'] = $this->context->getProperty('path');
                 } else {
                     $this->uri['base'] = $this->uri['default'];
                 }
             } else {
                 $this->uri['default'] = $blog['primaryBlogURL'];
                 if ($_SERVER['HTTP_HOST'] == $blog['name'] . '.' . $this->context->getProperty('domain')) {
                     $this->uri['base'] = $this->context->getProperty('path');
                 } else {
                     $this->uri['base'] = $this->uri['default'];
                 }
             }
             break;
         case 'path':
             $this->uri['path'] = $this->context->getProperty('path') . '/' . $blog['name'];
             $blog['primaryBlogURL'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $this->context->getProperty('domain') . (!is_null($this->context->getProperty('port')) ? ':' . $this->context->getProperty('port') : '') . $this->uri['path'];
             $blog['secondaryBlogURL'] = null;
             $this->uri['default'] = $blog['primaryBlogURL'];
             if ($_SERVER['HTTP_HOST'] == $this->context->getProperty('domain')) {
                 $this->uri['base'] = $this->context->getProperty('path') . '/' . $blog['name'];
             } else {
                 $this->uri['base'] = $this->uri['default'];
             }
             break;
         case 'single':
         default:
             $this->uri['path'] = $this->context->getProperty('path');
             $blog['primaryBlogURL'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $this->context->getProperty('domain') . (!is_null($this->context->getProperty('port')) ? ':' . $this->context->getProperty('port') : '') . $this->uri['path'];
             $blog['secondaryBlogURL'] = null;
             $this->uri['default'] = $blog['primaryBlogURL'] . $this->__getFancyURLpostfix();
             if ($_SERVER['HTTP_HOST'] == $this->context->getProperty('domain')) {
                 $this->uri['base'] = $this->context->getProperty('path');
             } else {
                 $this->uri['base'] = $this->uri['default'];
             }
             break;
     }
     $this->uri['host'] = ($this->context->getProperty('service.useSSL', false) ? 'https://' : '//') . $_SERVER['HTTP_HOST'] . (!is_null($this->context->getProperty('port')) ? ':' . $this->context->getProperty('port') : '');
     $this->uri['blog'] = $this->uri['path'] . $this->__getFancyURLpostfix();
     $this->uri['folder'] = rtrim($this->uri['blog'] . $suri['directive'], '/');
     $this->uri['permalink'] = rtrim($this->uri['default'] . rtrim($this->suri['directive'], '/') . (empty($this->suri['id']) ? '/' . $this->suri['value'] : '/' . $this->suri['id']), '/');
     $this->uri['basicblog'] = $this->uri['blog'];
     if (defined('__TEXTCUBE_MOBILE__')) {
         $this->uri['blog'] .= '/m';
         $_SESSION['mode'] = 'mobile';
     } else {
         if (defined('__TEXTCUBE_IPHONE__')) {
             $this->uri['blog'] .= '/i';
             $_SESSION['mode'] = 'mobile';
         }
     }
     $this->blog = $blog;
     $this->skin = $skinSetting;
     $this->updateContext();
 }
Exemple #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;
}
Exemple #9
0
function getArchives($blogid, $option = 'yearmonth')
{
    global $database;
    $archives = array();
    $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid);
    $skinSetting = Setting::getSkinSettings($blogid);
    $archivesOnPage = $skinSetting['archivesOnPage'];
    switch (POD::dbms()) {
        case 'PostgreSQL':
            if ($option == 'year') {
                $format = 'year';
            } else {
                if ($option == 'month') {
                    $format = 'month';
                } else {
                    $format = 'year, month';
                }
            }
            $sql = "SELECT EXTRACT(YEAR FROM FROM_UNIXTIME(e.published)) AS year, EXTRACT(MONTH FROM FROM_UNIXTIME(e.published)) AS month, COUNT(*) AS count \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY {$format} \n\t\t\t\tORDER BY {$format}\n\t\t\t\tDESC LIMIT {$archivesOnPage}";
            $result = POD::queryAllWithDBCache($sql, 'entry');
            if ($result) {
                foreach ($result as $archive) {
                    switch ($option) {
                        case 'year':
                            $archive['period'] = $archive['year'];
                            break;
                        case 'month':
                            $archive['period'] = sprintf("%02d", $archive['month']);
                            break;
                        case 'yearmonth':
                        default:
                            $archive['period'] = $archive['year'] . sprintf("%02d", $archive['month']);
                            break;
                    }
                    array_push($archives, $archive);
                }
            }
            break;
        case 'SQLite3':
            if ($option == 'year') {
                $format = '%Y';
            } else {
                if ($option == 'month') {
                    $format = '%m';
                } else {
                    $format = '%Y%m';
                }
            }
            $sql = "SELECT strftime('" . $format . "',e.published,'unixepoch') AS period, COUNT(*) AS count \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY period \n\t\t\t\tORDER BY period \n\t\t\t\tDESC LIMIT {$archivesOnPage}";
            $result = POD::queryAllWithDBCache($sql, 'entry');
            if ($result) {
                foreach ($result as $archive) {
                    array_push($archives, $archive);
                }
            }
            break;
        case 'Cubrid':
            if ($option == 'year') {
                $format = 'YYYY';
            } else {
                if ($option == 'month') {
                    $format = 'MM';
                } else {
                    $format = 'YYYYMM';
                }
            }
            $sql = "SELECT TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, '{$format}') period, \n\t\t\t\tCOUNT(*) \"count\"\n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY TO_CHAR(to_timestamp('09:00:00 AM 01/01/1970')+e.published, 'YYYYMM') \n\t\t\t\tORDER BY period\n\t\t\t\tDESC FOR ORDERBY_NUM() BETWEEN 1 AND {$archivesOnPage}";
            $result = POD::queryAllWithDBCache($sql, 'entry');
            if ($result) {
                foreach ($result as $archive) {
                    array_push($archives, $archive);
                }
            }
            break;
        case 'MySQL':
        case 'MySQLi':
        default:
            if ($option == 'year') {
                $format = 'year';
            } else {
                if ($option == 'month') {
                    $format = 'month';
                } else {
                    $format = 'year_month';
                }
            }
            $sql = "SELECT EXTRACT({$format} FROM FROM_UNIXTIME(e.published)) period, COUNT(*) count \n\t\t\t\tFROM {$database['prefix']}Entries e\n\t\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} AND e.category >= 0 \n\t\t\t\tGROUP BY period \n\t\t\t\tORDER BY period \n\t\t\t\tDESC LIMIT {$archivesOnPage}";
            $result = POD::queryAllWithDBCache($sql, 'entry');
            if ($result) {
                foreach ($result as $archive) {
                    array_push($archives, $archive);
                }
            }
            break;
    }
    return $archives;
}