Skip to content

Commit

Permalink
refs #514
Browse files Browse the repository at this point in the history
  * branches/1.8 과 동기화
  • Loading branch information
inureyes committed Oct 12, 2009
1 parent a505c76 commit 7ab8b58
Show file tree
Hide file tree
Showing 117 changed files with 4,161 additions and 261 deletions.
4 changes: 2 additions & 2 deletions framework/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ private function URIinterpreter() {
$interfacePath = 'interface/blog/'.$pathPart.'.php';
break;
case 'rss': case 'atom':
if($uri['fragment'][1] == 'category') {
$pathPart = $uri['fragment'][0].'/category';
if(in_array($uri['fragment'][1],array('category','tag','search'))) {
$pathPart = $uri['fragment'][0].'/'.$uri['fragment'][1];
$interfacePath = 'interface/'.$pathPart.'/index.php';
}
break;
Expand Down
53 changes: 38 additions & 15 deletions framework/legacy/Needlworks.Cache.PageCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function load () {
global $service;
if(isset($service['pagecache']) && $service['pagecache'] == false) return false;
$this->initialize();
$this->contents = $this->dbContents = null;
if(!$this->getFileName()) return false;
if(empty($this->_fileCacheOnly)) $this->getdbContents();
if($this->getFileContents()) {
Expand Down Expand Up @@ -355,17 +356,24 @@ function flushAll($blogid = null) {
$query->delete();
return true;
}

function flushSkin($blogid = null) {
global $gCacheStorage;
if(empty($blogid)) $blogid = getBlogId();
$cache = pageCache::getInstance();
$cache->reset('skinCache');
$cache->purge();
$gCacheStorage->purge();
}
function flushCategory($categoryId = null) {
global $database;

if(empty($categoryId)) $categoryId = '';
else $categoryId = $categoryId.'\\_';
else $categoryId = $categoryId.'-';

$categoryLists = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND (name like 'categoryList\\_".$categoryId."%'
AND (name like 'categoryList-".$categoryId."%'
OR name like 'categoryRSS-".$categoryId."%'
OR name like 'categoryATOM-".$categoryId."%')");
CacheControl::purgeItems($categoryLists);
Expand All @@ -376,28 +384,29 @@ function flushCategory($categoryId = null) {
function flushAuthor($authorId = null) {
global $database;
if(empty($authorId)) $authorId = '';
else $authorId = POD::escapeString($authorId).'\\_';
else $authorId = POD::escapeString($authorId).'-';

$pageLists = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND (name like 'authorList\\_".$authorId."%')");
AND (name like 'authorList-".$authorId."%')");
CacheControl::purgeItems($pageLists);
return true;
}

function flushTag($tagId = null) {
global $database;

if(empty($tagId)) $tagId = '';
else $tagId = $tagId.'\\_';
else $tagId = $tagId.'-';
$cache = pageCache::getInstance();
$tagLists = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND (name like 'tagList\\_".$tagId."%'
OR name like 'keyword\\_".$tagId."%')");
AND (name like 'tagList-".$tagId."%'
OR name like 'keyword-".$tagId."%'
OR name like 'tagATOM-".$tagId."%'
OR name like 'tagRSS-".$tagId."%')");
CacheControl::purgeItems($tagLists);
CacheControl::flushRSS();
$cache->reset();
$cache->name = 'tagPage';
$cache->purge();
Expand All @@ -408,24 +417,38 @@ function flushKeyword($tagId = null) {
global $database;

if(empty($tagId)) $tagId = '';
else $tagId = $tagId.'\\_';
else $tagId = $tagId.'-';
$keywordEntries = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND name like 'keyword\\_".$tagId."%'");
AND name like 'keyword-".$tagId."%'");
CacheControl::purgeItems($keywordEntries);
return true;
}

function flushSearchKeywordRSS($search = null) {
global $database;

if(empty($search)) $search = '';
else $search = escapeSearchString($search);
$searchEntries = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND (name like 'searchATOM-".$search."%'
OR name like 'searchRSS-".$search."%");
CacheControl::purgeItems($searchEntries);
return true;
}

function flushEntry($entryId = null) {
global $database;

if(empty($entryId)) $entryId = '';
else $entryId = $entryId.'\\_';
else $entryId = $entryId.'-';
$Entries = POD::queryColumn("SELECT name
FROM {$database['prefix']}PageCacheLog
WHERE blogid = ".getBlogId()."
AND (name like 'entry\\_".$entryId."%' OR name = 'commentRSS_".$entryId."')");
AND (name like 'entry-".$entryId."%' OR name = 'commentRSS-".$entryId."')");
CacheControl::purgeItems($Entries);
if(!empty($entryId)) {
$entry = POD::queryCell("SELECT userid, category FROM {$database['prefix']}Entries
Expand All @@ -448,11 +471,11 @@ function flushRSS() {
CacheControl::flushCommentRSS();
CacheControl::flushTrackbackRSS();
CacheControl::flushResponseRSS();
CacheControl::flushSearchKeywordRSS();
}

function flushCommentRSS($entryId = null) {
global $database;

if(empty($entryId)) $entryId = '';
$cache = pageCache::getInstance();
$cache->name = 'commentRSS-'.$entryId;
Expand Down
29 changes: 13 additions & 16 deletions framework/legacy/Textcube.Control.Session.Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@

final class Session {
private static $sessionName = null;
private static $mc = null;
private static $domain = null;
private static $mc = null;

private static function initialize() {
global $memcache; /** After PHP 5.0.5, session write performs after object destruction. */
self::$mc = $memcache; /** To Avoid this, just copy memcache handle into Session object. */
$config = Model_Config::getInstance();
self::$domain = $config->service['domain'];
}

public static function open($savePath, $sessionName) {
Expand All @@ -41,26 +38,26 @@ public static function getName() {

public static function read($id) {
if(is_null(self::$mc)) self::initialize();
return self::$mc->get("{self::$domain}/sessions/{$id}/{$_SERVER['REMOTE_ADDR']}");
return self::$mc->get("sessions/{$id}/{$_SERVER['REMOTE_ADDR']}");
}

public static function write($id, $data) {
global $service;
return self::$mc->set("{self::$domain}/sessions/{$id}/{$_SERVER['REMOTE_ADDR']}",$data,$service['timeout']);
return self::$mc->set("sessions/{$id}/{$_SERVER['REMOTE_ADDR']}",$data,$service['timeout']);
}

public static function destroy($id, $setCookie = false) {
self::$mc->delete("{self::$domain}/sessions/{$id}/{$_SERVER['REMOTE_ADDR']}");
self::$mc->delete("{self::$domain}/anonymousSession/{$_SERVER['REMOTE_ADDR']}");
return self::$mc->delete("{self::$domain}/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
self::$mc->delete("sessions/{$id}/{$_SERVER['REMOTE_ADDR']}");
self::$mc->delete("anonymousSession/{$_SERVER['REMOTE_ADDR']}");
return self::$mc->delete("authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
}

public static function gc($maxLifeTime = false) {
return true;
}

private static function getAnonymousSession() {
$anonymousSessionId = self::$mc->get("{self::$domain}/anonymousSession/{$_SERVER['REMOTE_ADDR']}");
$anonymousSessionId = self::$mc->get("anonymousSession/{$_SERVER['REMOTE_ADDR']}");
if(!empty($anonymousSessionId)) return $anonymousSessionId;
else return false;
}
Expand All @@ -71,9 +68,9 @@ private static function newAnonymousSession() {
if (($id = self::getAnonymousSession()) !== false)
return $id;
$id = dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF));
$result = self::$mc->set("{self::$domain}/sessions/{$id}/{$_SERVER['REMOTE_ADDR']}",true,$config->service['timeout']);
$result = self::$mc->set("sessions/{$id}/{$_SERVER['REMOTE_ADDR']}",true,$config->service['timeout']);
if ($result > 0) {
$result = self::$mc->set("{self::$domain}/anonymousSession/{$_SERVER['REMOTE_ADDR']}",$id,$config->service['timeout']);
$result = self::$mc->set("anonymousSession/{$_SERVER['REMOTE_ADDR']}",$id,$config->service['timeout']);
return $id;
}
}
Expand All @@ -98,14 +95,14 @@ public static function setSessionAnonymous($currentId) {
public static function isAuthorized($id) {
if(is_null(self::$mc)) self::initialize();
/* OpenID and Admin sessions are treated as authorized ones*/
$userid = self::$mc->get("{self::$domain}/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
$userid = self::$mc->get("authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
if(!empty($userid)) return true;
else return false;
}

public static function isGuestOpenIDSession($id) {
if(is_null(self::$mc)) self::initialize();
$userid = self::$mc->get("{self::$domain}/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
$userid = self::$mc->get("authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}");
if(!empty($userid) && $userid < 0) return true;
else return false;
}
Expand Down Expand Up @@ -137,7 +134,7 @@ public static function authorize($blogid, $userid) {
$_SESSION['userid'] = $userid;
$id = session_id();
if( self::isGuestOpenIDSession($id) ) {
$result = self::$mc->set("{self::$domain}/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,$config->service['timeout']);
$result = self::$mc->set("authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,$config->service['timeout']);
if ($result) {
return true;
}
Expand All @@ -146,7 +143,7 @@ public static function authorize($blogid, $userid) {
if (self::isAuthorized(session_id())) return true;
for ($i = 0; $i < 3; $i++) {
$id = dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF)) . dechex(rand(0x10000000, 0x7FFFFFFF));
$result = self::$mc->set("{self::$domain}/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,$config->service['timeout']);
$result = self::$mc->set("authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,$config->service['timeout']);

if ($result) {
@session_id($id);
Expand Down
2 changes: 1 addition & 1 deletion framework/legacy/Textcube.Data.Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function add() {
}
$this->id = $query->getCell('id');

$query->reset($database['prefix'] . 'FeedGroupRelations');
$query->reset('FeedGroupRelations');
$query->setQualifier('blogid', 'equals',$blogid);
$query->setQualifier('feed', 'equals',$this->id);
$query->setQualifier('groupid', 'equals',$this->group);
Expand Down
2 changes: 1 addition & 1 deletion framework/legacy/Textcube.Data.SubscriptionStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function _buildQuery() {
if (empty($this->host))
return $this->_error('host');
$query = DBModel::getInstance();
$query->reset($database['prefix'] . 'SubscriptionStatistics');
$query->reset('SubscriptionStatistics');
$query->setQualifier('blogid', 'equals', getBlogId());
if (isset($this->ip)) {
if (!Validator::ip($this->ip))
Expand Down
17 changes: 9 additions & 8 deletions framework/model/URIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,37 @@ private function __URIInterpreter() {

private function __URIParser() {
if(!isset($this->uri)) $this->__URIInterpreter();
$config = Model_Config::getInstance();
$this->context->useNamespace('service');

$url = $this->uri['fullpath'];
$defaultblogid = Setting::getServiceSetting("defaultBlogId",1);
$this->suri = array('url' => $url, 'value' => '');
$this->blogid = null;
$this->uri['isStrictBlogURL'] = true;
$depth = substr_count($config->service['path'], '/');
$depth = substr_count($this->context->getProperty('path'), '/');
if ($depth > 0) {
if (preg_match('@^((/+[^/]+){' . $depth . '})(.*)$@', $url, $matches))
$url = $matches[3];
else
Respond::NotFoundPage();
}
if ($config->service['type'] == 'single') {
if ($this->context->getProperty('type') == 'single') {
$this->blogid = $defaultblogid;
} else {
if ($config->service['type'] == 'domain') {
if ($_SERVER['HTTP_HOST'] == $config->service['domain']) {
if ($this->context->getProperty('type') == 'domain') { // Domain-based service
if ($_SERVER['HTTP_HOST'] == $this->context->getProperty('domain')) {
$this->blogid = $defaultblogid;
} else {
$domain = explode('.', $_SERVER['HTTP_HOST'], 2);
if ($domain[1] == $config->service['domain']) {
if ($domain[1] == $this->context->getProperty('domain')) {
$this->blogid = $this->__getBlogidByName($domain[0]);
if ($this->blogid === null)
$this->blogid = $this->__getBlogidBySecondaryDomain($_SERVER['HTTP_HOST']);
} else {
$this->blogid = $this->__getBlogidBySecondaryDomain($_SERVER['HTTP_HOST']);
}
}
} else {
} else { // Path-based service
if ($url == '/') {
$this->blogid = $defaultblogid;
} else if (preg_match('@^/+([^/]+)(.*)$@', $url, $matches)) {
Expand Down Expand Up @@ -85,7 +86,7 @@ private function __URIParser() {
$depth = substr_count(ROOT, '/');
}
if ($depth > 0) {
if($config->service['fancyURL'] === 0 || $config->service['fancyURL'] === 1) $url = '/'.$this->uri['input']; // Exclude /blog path.
if($this->context->getProperty('fancyURL') === 0 || $this->context->getProperty('fancyURL') === 1) $url = '/'.$this->uri['input']; // Exclude /blog path.
if (preg_match('@^((/+[^/]+){' . $depth . '})/*(.*)$@', $url, $matches)) {
$this->suri['directive'] = $matches[1];
if ($matches[3] !== false) {
Expand Down
2 changes: 1 addition & 1 deletion interface/atom/category/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

require ROOT . '/library/preprocessor.php';
//requireModel("blog.entry");
requireModel("blog.category");

requireStrictBlogURL();
Expand Down
4 changes: 1 addition & 3 deletions interface/atom/comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

require ROOT . '/library/preprocessor.php';
requireModel("blog.feed");
requireModel("blog.entry");

requireStrictBlogURL();
if (false) {
fetchConfigVal();
}
$cache = pageCache::getInstance();
if(!empty($suri['id'])) {
$cache->name = 'commentATOM-'.$suri['id'];
Expand Down
6 changes: 3 additions & 3 deletions interface/atom/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

require ROOT . '/library/preprocessor.php';
requireModel("blog.feed");
requireModel("blog.entry");

requireStrictBlogURL();
if (false) {
fetchConfigVal();
}

publishEntries();
if (!file_exists(ROOT . "/cache/atom/$blogid.xml"))
refreshFeed($blogid,'atom');
Expand Down
1 change: 1 addition & 0 deletions interface/atom/line/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

require ROOT . '/library/preprocessor.php';
requireModel("blog.feed");
Expand Down
2 changes: 2 additions & 0 deletions interface/atom/notifycomment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

if(isset($_GET['loginid'])) $_POST['loginid'] = $_GET['loginid'];
if(isset($_GET['key'])) $_POST['key'] = $_GET['key'];

Expand Down
2 changes: 2 additions & 0 deletions interface/atom/response/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
define('NO_SESSION', true);
define('__TEXTCUBE_LOGIN__',true);
define('__TEXTCUBE_CUSTOM_HEADER__', true);

require ROOT . '/library/preprocessor.php';
requireModel("blog.feed");
Expand Down
Loading

0 comments on commit 7ab8b58

Please sign in to comment.