diff --git a/documents/manual_config.txt b/documents/manual_config.txt index 2a9c2481c..a8e402636 100644 --- a/documents/manual_config.txt +++ b/documents/manual_config.txt @@ -51,4 +51,6 @@ $database['port'] = 3639; // Database port number $database['dbms'] = 'MySQL'; // DBMS. (MySQL, MySQLi, PostgreSQL, Cubrid.) $service['memcached'] = false; // Using memcache to handle session and cache $memcached['server'] = 'localhost'; // Where memcache server is. -?> \ No newline at end of file +// From Textcube 1.8.4 +$service['requirelogin'] = false; // Force log-in process to every blogs. (for private blog service) +?> diff --git a/documents/manual_workflow.txt b/documents/manual_workflow.txt index 14e90357f..05d7bf050 100644 --- a/documents/manual_workflow.txt +++ b/documents/manual_workflow.txt @@ -15,6 +15,8 @@ Dispatching +------+------+ +------+------+ | rewrite.php + | + /framework/Dispatcher.php | + /config.php (Context / URL / configuration loading) | @@ -23,9 +25,11 @@ Dispatching +------+------+ | -------------------------------------- library/preprocessor.php (Preprocessing) ----------------- | - Base components loading + Base components loading ( /framework/boot ) + Environment Normalization (Unification) + Core component loading + + Component / library autoload setting + + Authenticating settings | Validation + Basic POST/GET value validation @@ -44,22 +48,20 @@ Dispatching +------+------+ /library/include.php | + /library/config.php | + /config.php (override) - | + /library/component/~ - | [Loading mandatory models / views] | + /library/model/~ | + /library/view/~ ------------ | Initializing | | If database needed, - +------------------------------+--------------=====----------+ + +------------------------------+-----------------------------+ | | | Initializing database I/O | - | + /library/components/Needlworks.DBMS.XXX.php | + | + /framework/data/DBModel.php | | | | Loading memcache module (if use) | | Creating Session (if requested) | - | + /library/components/Textcube.Data.Session.XXX.php | + | + /framework/legacy/Textcube.Data.Session.XXX.php | +------------------------------+-----------------------------+ | If initialization needed, diff --git a/framework/boot/30-Auth.php b/framework/boot/30-Auth.php index 436197244..9283557ea 100644 --- a/framework/boot/30-Auth.php +++ b/framework/boot/30-Auth.php @@ -260,7 +260,6 @@ function authorize( $domain, $userid ) { $data->setQualifier('userid','equals',intval($userid)); $data->setAttribute('lastLogin',Timestamp::getUNIXtime()); $data->update(); -// POD::execute("UPDATE {$this->context->getProperty('database.prefix')}Privileges SET lastLogin = ".Timestamp::getUNIXtime()." WHERE blogid = $blogid AND userid = $userid"); return; } diff --git a/framework/legacy/Textcube.Core.php b/framework/legacy/Textcube.Core.php index ae97b8c83..7b06504e0 100644 --- a/framework/legacy/Textcube.Core.php +++ b/framework/legacy/Textcube.Core.php @@ -6,8 +6,6 @@ /* This component contains 'User', 'Blog' and 'Transaction' class. NOTE : Classes described below are actually not object. Usually they are static.*/ -requireComponent('Textcube.Control.Auth'); - // for Global Cache global $__gCacheUserNames; $__gCacheUserNames = array(); diff --git a/framework/legacy/Textcube.Data.Post.php b/framework/legacy/Textcube.Data.Post.php index e4faf9342..d3e1b7f8b 100644 --- a/framework/legacy/Textcube.Data.Post.php +++ b/framework/legacy/Textcube.Data.Post.php @@ -497,13 +497,13 @@ function updateRemoteResponses($id = null) { return false; $succeeded = true; foreach ($posts as $id) { - $trackbacks = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}RemoteResponses WHERE blogid = ".$this->blogid." AND entry = $id AND isfiltered = 0 AND type = 'trackback'"); + $trackbacks = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}RemoteResponses WHERE blogid = ".$this->blogid." AND entry = $id AND isfiltered = 0 AND responsetype = 'trackback'"); if (!is_null($trackbacks)) { if (!POD::execute("UPDATE {$database['prefix']}Entries SET trackbacks = $trackbacks WHERE blogid = ".$this->blogid." AND id = $id")) $succeeded = false; } - $pingbacks = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}RemoteResponses WHERE blogid = ".$this->blogid." AND entry = $id AND isFiltered = 0 AND type = 'pingback'"); + $pingbacks = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}RemoteResponses WHERE blogid = ".$this->blogid." AND entry = $id AND isFiltered = 0 AND responsetype = 'pingback'"); if (!is_null($pingbacks)) { if (!POD::execute("UPDATE {$database['prefix']}Entries SET pingbacks = $pingbacks WHERE blogid = ".$this->blogid." AND id = $id")) diff --git a/framework/legacy/Textcube.Data.RemoteResponse.php b/framework/legacy/Textcube.Data.RemoteResponse.php index 9e8bcdf91..fba1e1ffc 100644 --- a/framework/legacy/Textcube.Data.RemoteResponse.php +++ b/framework/legacy/Textcube.Data.RemoteResponse.php @@ -30,7 +30,7 @@ function open($filter = '', $fields = '*', $sort = 'written') { if (!empty($sort)) $sort = 'ORDER BY ' . $sort; $this->close(); - $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}RemoteResponses WHERE blogid = ".getBlogId()." AND type = 'trackback' $filter $sort"); + $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}RemoteResponses WHERE blogid = ".getBlogId()." AND responsetype = 'trackback' $filter $sort"); if ($this->_result) { if ($this->_count = POD::num_rows($this->_result)) return $this->shift(); @@ -114,7 +114,7 @@ function _buildQuery() { $query = DBModel::getInstance(); $query->reset('RemoteResponses'); $query->setQualifier('blogid', getBlogId()); - $query->setQualifier('type', 'trackback'); + $query->setQualifier('responsetype', 'trackback'); if (isset($this->id)) { if (!Validator::number($this->id, 1)) return $this->_error('id'); @@ -196,7 +196,7 @@ function open($filter = '', $fields = '*', $sort = 'written') { if (!empty($sort)) $sort = 'ORDER BY ' . $sort; $this->close(); - $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}RemoteResponses WHERE blogid = ".getBlogId()." AND type = 'pingback' $filter $sort"); + $this->_result = POD::query("SELECT $fields FROM {$database['prefix']}RemoteResponses WHERE blogid = ".getBlogId()." AND responsetype = 'pingback' $filter $sort"); if ($this->_result) { if ($this->_count = POD::num_rows($this->_result)) return $this->shift(); @@ -282,7 +282,7 @@ function _buildQuery() { $query = DBModel::getInstance(); $query->reset('RemoteResponses'); $query->setQualifier('blogid', getBlogId()); - $query->setQualifier('type', 'pingback'); + $query->setQualifier('responsetype', 'pingback'); if (isset($this->id)) { if (!Validator::number($this->id, 1)) return $this->_error('id'); diff --git a/framework/legacy/Textcube.Function.Image.php b/framework/legacy/Textcube.Function.Image.php index de1c17b02..8615ea2e4 100644 --- a/framework/legacy/Textcube.Function.Image.php +++ b/framework/legacy/Textcube.Function.Image.php @@ -2,518 +2,10 @@ /// Copyright (c) 2004-2010, Needlworks / Tatter Network Foundation /// All rights reserved. Licensed under the GPL. /// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) -class Image { - function Image() { - $this->reset(); - } - - function reset() { - $this->extraPadding = 0; - $this->imageFile = NULL; - $this->resultImageDevice = NULL; - } - - function resample($width, $height) { - if (empty($width) && empty($height)) - return false; - if (empty($this->imageFile) || !file_exists($this->imageFile)) - return false; - - // create an image device as image format. - switch ($this->getImageType($this->imageFile)) { - case "gif": - if (imagetypes() & IMG_GIF) { - $originImageDevice = imagecreatefromgif($this->imageFile); - } else { - return false; - } - break; - case "jpg": - if (imagetypes() & IMG_JPG) { - $originImageDevice = imagecreatefromjpeg($this->imageFile); - } else { - return false; - } - break; - case "png": - if ((imagetypes() & IMG_PNG) && function_exists('imagecreatefrompng')) { - $originImageDevice = imagecreatefrompng($this->imageFile); - } else { - return false; - } - break; - case "wbmp": - if (imagetypes() & IMG_WBMP) { - $originImageDevice = imagecreatefromwbmp($this->imageFile); - } else { - return false; - } - break; - case "xpm": - if (imagetypes() & IMG_XPM) { - $originImageDevice = imagecreatefromxpm($this->imageFile); - } else { - return false; - } - break; - default: - return false; - break; - } - // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함. - // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨. - //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); - - if (Path::getExtension($this->imageFile) == ".gif") { - $this->resultImageDevice = imagecreate($width, $height); - } else { - $this->resultImageDevice = imagecreatetruecolor($width, $height); - } - - $bgColorBy16 = $this->hexRGB("FFFFFF"); - $temp = imagecolorallocate($this->resultImageDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); - imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp); - imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice)); - imagedestroy($originImageDevice); - //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); - - return true; - } - - function resizeImageToContent($property, $originSrc, $imageWidth) { - if ( !is_readable($originSrc) ) { - return array($property, false); - } - - list($originWidth, $originHeight, $type, $attr) = getimagesize($originSrc); - $attributes = Misc::getAttributesFromString($property, false); - - // 단위 변환. - $onclickFlag = false; - if (array_key_exists('width', $attributes)) { - if (preg_match('/(.+)(%?)/', $attributes['width'], $matches)) { - if($matches[2] == '%') - $attributes['width'] = round($originWidth * $matches[1] / 100); - else - $attributes['width'] = intval($matches[1]); - - } - } - - if (array_key_exists('height', $attributes)) { - if (preg_match('/(.+)(%?)/', $attributes['height'], $matches)) { - if ($matches[2] == '%') - $attributes['height'] = round($originHeight * $matches[1] / 100); - else - $attributes['height'] = intval($matches[1]); - - } - } - - // 가로, 세로 어느 쪽이든 0이면 이미지는 표시되지 않음. 따라서 계산할 필요 없음. - if ((isset($attributes['width']) && $attributes['width'] <= 0) || (isset($attributes['height']) && $attributes['height'] <= 0)) { - return array($property, false); - } - // 가로만 지정된 이미지의 경우. - if (isset($attributes['width']) && !isset($attributes['height'])) { - // 비어있는 세로를 가로의 크기를 이용하여 계산. - $attributes['height'] = floor($originHeight * $attributes['width'] / $originWidth); - // 세로만 지정된 이미지의 경우. - } else if (!isset($attributes['width']) && isset($attributes['height'])) { - // 비어있는 가로를 세로의 크기를 이용하여 계산. - $attributes['width'] = floor($originWidth * $attributes['height'] / $originHeight); - // 둘 다 지정되지 않은 이미지의 경우. - } else if (!isset($attributes['width']) && !isset($attributes['height'])) { - // 둘 다 비어 있을 경우는 오리지널 사이즈로 대치. - $attributes['width'] = $originWidth; - $attributes['height'] = $originHeight; - } +/// Legacy code for plugins. See /framework/utils/Image.php for working codes. - if ($attributes['width'] > $imageWidth) { - $attributes['height'] = floor($attributes['height'] * $imageWidth / $attributes['width']); - $attributes['width'] = $imageWidth; - } - - if ($attributes['width'] < $originWidth || $attributes['height'] < $originHeight) { - $onclickFlag = true; - } else { - $onclickFlag = false; - } - - $properties = array(); - ksort($attributes); - foreach($attributes as $key => $value) { - array_push($properties, "$key=\"$value\""); - } - - return array(implode(' ', $properties), $onclickFlag); - } - - function impressWaterMark($waterMarkFile, $position="left=10|bottom=10", $gamma=100) { - if ($this->getImageType($waterMarkFile) == "png") - return $this->_impressWaterMarkCore("PNG", $waterMarkFile, $position); - else - return $this->_impressWaterMarkCore("GIF", $waterMarkFile, $position, $gamma); - } - - function _impressWaterMarkCore($type, $waterMarkFile, $position, $gamma=100) { - if (empty($waterMarkFile)) - return false; - if (!file_exists($waterMarkFile)) - return false; - if (empty($this->resultImageDevice)) - return false; - - // validate gamma. - if (!is_int($gamma)) { - $gamma = 100; - } else if ($gamma < 0) { - $gamma = 0; - } else if ($gamma > 100) { - $gamma = 100; - } - - list($waterMarkWidth, $waterMarkHeight, $waterMakrType) = getimagesize($waterMarkFile); - - // position of watermark. - if (preg_match("/^(-?[0-9A-Z]+) (-?[0-9A-Z]+)$/i", $position, $temp)) { - $resultWidth = imagesx($this->resultImageDevice); - $resultHeight = imagesy($this->resultImageDevice); - - switch ($temp[1]) { - case "left": - $xPosition = $this->extraPadding; - break; - case "center": - $xPosition = $resultWidth / 2 - $waterMarkWidth / 2; - break; - case "right": - $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; - break; - default: - // if positive, calculate x value from left. - if (preg_match("/^([1-9][0-9]*)$/", $temp[1], $extra)) { - if ($extra[1] > $resultWidth - $waterMarkWidth) { - $xPosition = $resultWidth - $waterMarkWidth; - } else { - $xPosition = $extra[1]; - } - // if negative, calculate x value from right. - } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[1], $extra)) { - if ($resultWidth - $waterMarkWidth - abs($extra[1]) < 0) { - $xPosition = 0; - } else { - $xPosition = $resultWidth - $waterMarkWidth - abs($extra[1]); - } - // in the case of 0. - } else if ($temp[1] == "0") { - $xPosition = 0; - // the others. calculate x value from left. - } else { - $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; - } - } - - switch ($temp[2]) { - case "top": - $yPosition = $this->extraPadding; - break; - case "middle": - $yPosition = $resultHeight / 2 - $waterMarkHeight / 2; - break; - case "bottom": - $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; - break; - default: - // if positive, calculate y value from top. - if (preg_match("/^([1-9][0-9]*)$/", $temp[2], $extra)) { - if ($extra[1] > $resultHeight - $waterMarkHeight) { - $yPosition = $resultHeight - $waterMarkHeight; - } else { - $yPosition = $extra[1]; - } - // if negative, calculate y value from bottom. - } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[2], $extra)) { - if ($resultHeight - $waterMarkHeight - abs($extra[1]) < 0) { - $yPosition = 0; - } else { - $yPosition = $resultHeight - $waterMarkHeight - abs($extra[1]); - } - // in the case of 0. - } else if ($temp[1] == "0") { - $yPosition = 0; - // the others. calculate y value from bottom. - } else { - $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; - } - } - } else { - $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; - $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; - } - - // create watermark image device. - switch ($waterMakrType) { - case 1: - $waterMarkDevice = imagecreatefromgif($waterMarkFile); - break; - case 2: - $waterMarkDevice = imagecreatefromjpeg($waterMarkFile); - break; - case 3: - $waterMarkDevice = imagecreatefrompng($waterMarkFile); - break; - } - - // PHP >= 4.0.6 - if (strtolower($type) == "png" && function_exists("imagealphablending")) { - imagealphablending($this->resultImageDevice, true); - imagecopy($this->resultImageDevice, $waterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); - } else { - // if not support alpha channel, support GIF transparency. - $tempWaterMarkDevice = imagecreatetruecolor($waterMarkWidth, $waterMarkHeight); - - $bgColorBy16 = $this->hexRGB("FF00FF"); - $temp = imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); - imagecolortransparent($this->resultImageDevice, $temp); - imagefill($tempWaterMarkDevice, 0, 0, $temp); - imagecopy($tempWaterMarkDevice, $waterMarkDevice, 0, 0, 0, 0, $waterMarkWidth, $waterMarkHeight); - - if (function_exists("imagecopymerge")) - imagecopymerge($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight, $gamma); - else - imagecopy($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); - - imagedestroy($tempWaterMarkDevice); - } - - imagedestroy($waterMarkDevice); - return true; - } - - function cropRectByCoordinates($startX, $startY, $finishX, $finishY) { - $width = $finishX - $startX; - $height = $finishY - $startY; - - $targetDevice = imagecreatetruecolor($width, $height); - $bgColorBy16 = $this->hexRGB('FFFFFF'); - imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); - imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $startX, $startY, $width, $height); - $this->resultImageDevice = $targetDevice; - unset($targetDevice); - - return true; - } - - function cropRectBySize($width, $height, $align='center', $valign='middle') { - switch ($align) { - case 'left': - $srcX = 0; - break; - case 'center': - $srcX = floor((imagesx($this->resultImageDevice) - $width) / 2); - break; - case 'right': - $srcX = imagesx($this->resultImageDevice) - $width; - break; - } - - switch ($valign) { - case 'top': - $srcY = 0; - break; - case 'middle': - $srcY = floor((imagesy($this->resultImageDevice) - $height) / 2); - break; - case 'bottom': - $srcY = imagesy($this->resultImageDevice) - $height; - break; - } - - $targetDevice = imagecreatetruecolor($width, $height); - $bgColorBy16 = $this->hexRGB('FFFFFF'); - imagecolorallocate($targetDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); - imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $srcX, $srcY, $width, $height); - $this->resultImageDevice = $targetDevice; - unset($targetDevice); - - return true; - } - - function saveAsFile($fileName) { - return $this->createThumbnailIntoFile($fileName); - } - - function createThumbnailIntoFile($fileName) { - if (empty($this->resultImageDevice)) - return false; - - imageinterlace($this->resultImageDevice); - switch ($this->getImageType($this->imageFile)) { - case "gif": - imagegif($this->resultImageDevice, $fileName); - break; - case "png": - imagepng($this->resultImageDevice, $fileName); - break; - case "wbmp": - imagewbmp($this->resultImageDevice, $fileName); - break; - case "jpg": - default: - imagejpeg($this->resultImageDevice, $fileName, 80); - break; - } - - $this->resultImageDevice = NULL; - - return true; - } - - function saveAsCache() { - return $this->createThumbnailIntoCache(); - } - - function createThumbnailIntoCache() { - header("Content-type: image/jpeg"); - imagejpeg($this->resultImageDevice); - - $originImageDevice = NULL; - $this->resultImageDevice = NULL; - - return true; - } - - function calcOptimizedImageSize($argWidth, $argHeight, $boxWidth=NULL, $boxHeight=NULL, $resizeFlag="reduce") { - if (empty($boxWidth) && empty($boxHeight)) { - return array($argWidth, $argHeight); - } else if (!empty($boxWidth) && empty($boxHeight)) { - if ($argWidth > $boxWidth) { - $newWidth = $boxWidth; - $newHeight = floor($argHeight * $newWidth / $argWidth); - } else { - $newWidth = $argWidth; - $newHeight = $argHeight; - } - } else if (empty($boxWidth) && !empty($boxHeight)) { - if ($argHeight > $boxHeight) { - $newHeight = $boxHeight; - $newWidth = floor($argWidth * $newHeight / $argHeight); - } else { - $newWidth = $argWidth; - $newHeight = $argHeight; - } - } else { - if ($argWidth > $boxWidth) { - $newWidth = $boxWidth; - $newHeight = floor($argHeight * $newWidth / $argWidth); - } else { - $newWidth = $argWidth; - $newHeight = $argHeight; - } - - if ($newHeight > $boxHeight) { - $tempHeight = $newHeight; - $newHeight = $boxHeight; - $newWidth = floor($newWidth * $newHeight / $tempHeight); - } - } - - if ($argWidth * $argHeight > $newWidth * $newHeight) { - if ($resizeFlag == "reduce" || $resizeFlag == "both") { - $imgWidth = $newWidth; - $imgHeight = $newHeight; - } else { - $imgWidth = $argWidth; - $imgHeight = $argHeight; - } - } else if ($argWidth * $argHeight == $newWidth * $newHeight) { - $imgWidth = $argWidth; - $imgHeight = $argHeight; - } else if ($argWidth * $argHeight < $newWidth * $newHeight) { - if ($resizeFlag == "enlarge" || $resizeFlag == "both") { - $imgWidth = $newWidth; - $imgHeight = $newHeight; - } else { - $imgWidth = $argWidth; - $imgHeight = $argHeight; - } - } - - return array($imgWidth, $imgHeight); - } - - function getImageType($filename) { - if (file_exists($filename)) { - if (function_exists("exif_imagetype")) { - $imageType = exif_imagetype($filename); - } else { - $tempInfo = getimagesize($filename); - $imageType = $tempInfo[2]; - } - - switch ($imageType) { - case IMAGETYPE_GIF: - $extension = 'gif'; - break; - case IMAGETYPE_JPEG: - $extension = 'jpg'; - break; - case IMAGETYPE_PNG: - $extension = 'png'; - break; - case IMAGETYPE_SWF: - $extension = 'swf'; - break; - case IMAGETYPE_PSD: - $extension = 'psd'; - break; - case IMAGETYPE_BMP: - $extension = 'bmp'; - break; - case IMAGETYPE_TIFF_II: - case IMAGETYPE_TIFF_MM: - $extension = 'tiff'; - break; - case IMAGETYPE_JPC: - $extension = 'jpc'; - break; - case IMAGETYPE_JP2: - $extension = 'jp2'; - break; - case IMAGETYPE_JPX: - $extension = 'jpx'; - break; - case IMAGETYPE_JB2: - $extension = 'jb2'; - break; - case IMAGETYPE_SWC: - $extension = 'swc'; - break; - case IMAGETYPE_IFF: - $extension = 'aiff'; - break; - case IMAGETYPE_WBMP: - $extension = 'wbmp'; - break; - case IMAGETYPE_XBM: - $extension = 'xbm'; - break; - default: - $extension = false; - } - } else { - $extension = false; - } - - return $extension; - } - - /* "FFFFFF" => array(255, 255, 255) */ - function hexRGB($hexstr) { - $int = hexdec($hexstr); - return array('R' => 0xFF & ($int >> 0x10), 'G' => 0xFF & ($int >> 0x8), 'B' => 0xFF & $int); +if(!class_exists('Image')) { + class Image extends Utils_Image { } } -?> diff --git a/framework/locales/Locales.php b/framework/locales/Locales.php index bccf45693..944baee11 100644 --- a/framework/locales/Locales.php +++ b/framework/locales/Locales.php @@ -146,8 +146,8 @@ function _f($t) { // _t() follows the admin panel locale setting, however _text() follows the skin locale setting. function _text($t) { $locale = Locales::getInstance(); - if(isset($locale->resource['blog']) && isset($locale->resource['blog'][$t])) { - return $locale->resource['blog'][$t]; + if(isset($locale->resource[$locale->domain]) && isset($locale->resource[$locale->domain][$t])) { + return $locale->resource[$locale->domain][$t]; } else return $t; } diff --git a/framework/model/URIHandler.php b/framework/model/URIHandler.php index e0e52b4f6..d8c5e2a51 100644 --- a/framework/model/URIHandler.php +++ b/framework/model/URIHandler.php @@ -31,7 +31,7 @@ private function __URIParser() { $this->context->useNamespace('service'); $url = $this->uri['fullpath']; - $defaultblogid = Setting::getServiceSetting("defaultBlogId",1); + $defaultblogid = Setting::getServiceSetting("defaultBlogId",1,true); $this->suri = array('url' => $url, 'value' => ''); $this->blogid = null; $this->uri['isStrictBlogURL'] = true; @@ -51,18 +51,18 @@ private function __URIParser() { } else { $domain = explode('.', $_SERVER['HTTP_HOST'], 2); if ($domain[1] == $this->context->getProperty('domain')) { - $this->blogid = $this->__getBlogidByName($domain[0]); + $this->blogid = $this->__getBlogIdByName($domain[0]); if ($this->blogid === null) - $this->blogid = $this->__getBlogidBySecondaryDomain($_SERVER['HTTP_HOST']); + $this->blogid = $this->__getBlogIdBySecondaryDomain($_SERVER['HTTP_HOST']); } else { - $this->blogid = $this->__getBlogidBySecondaryDomain($_SERVER['HTTP_HOST']); + $this->blogid = $this->__getBlogIdBySecondaryDomain($_SERVER['HTTP_HOST']); } } } else { // Path-based service if ($url == '/') { $this->blogid = $defaultblogid; } else if (preg_match('@^/+([^/]+)(.*)$@', $url, $matches)) { - $this->blogid = $this->__getBlogidByName(strtok($matches[1],'?')); + $this->blogid = $this->__getBlogIdByName(strtok($matches[1],'?')); if ($this->blogid === null) { $this->blogid = $defaultblogid; $this->uri['isStrictBlogURL']= false; diff --git a/framework/utils/Image.php b/framework/utils/Image.php new file mode 100644 index 000000000..bd76a364c --- /dev/null +++ b/framework/utils/Image.php @@ -0,0 +1,524 @@ +reset(); + } + + public static function getInstance() { + return self::_getInstance(__CLASS__); + } + + function reset() { + $this->extraPadding = 0; + $this->imageFile = NULL; + $this->resultImageDevice = NULL; + } + + function resample($width, $height) { + if (empty($width) && empty($height)) + return false; + if (empty($this->imageFile) || !file_exists($this->imageFile)) + return false; + + // create an image device as image format. + switch ($this->getImageType($this->imageFile)) { + case "gif": + if (imagetypes() & IMG_GIF) { + $originImageDevice = imagecreatefromgif($this->imageFile); + } else { + return false; + } + break; + case "jpg": + if (imagetypes() & IMG_JPG) { + $originImageDevice = imagecreatefromjpeg($this->imageFile); + } else { + return false; + } + break; + case "png": + if ((imagetypes() & IMG_PNG) && function_exists('imagecreatefrompng')) { + $originImageDevice = imagecreatefrompng($this->imageFile); + } else { + return false; + } + break; + case "wbmp": + if (imagetypes() & IMG_WBMP) { + $originImageDevice = imagecreatefromwbmp($this->imageFile); + } else { + return false; + } + break; + case "xpm": + if (imagetypes() & IMG_XPM) { + $originImageDevice = imagecreatefromxpm($this->imageFile); + } else { + return false; + } + break; + default: + return false; + break; + } + // 리샘플링은 최종단계에서 리샘플링만을 하는 기능임. 시스템을 예로 들면 OS의 기능에 해당함. + // 이미지 프로세스는 어플리케이션의 기능으로 볼 수 있고, 따라서 이미지 리샘플링 중에는 이벤트가 끼어들면 안 됨. + //$originImageDevice = fireEvent('BeforeResizeImage', $originImageDevice, $this); + + if (Path::getExtension($this->imageFile) == ".gif") { + $this->resultImageDevice = imagecreate($width, $height); + } else { + $this->resultImageDevice = imagecreatetruecolor($width, $height); + } + + $bgColorBy16 = $this->hexRGB("FFFFFF"); + $temp = imagecolorallocate($this->resultImageDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); + imagefilledrectangle($this->resultImageDevice, 0, 0, $width, $height, $temp); + imagecopyresampled($this->resultImageDevice, $originImageDevice, 0, 0, 0, 0, $width, $height, imagesx($originImageDevice), imagesy($originImageDevice)); + imagedestroy($originImageDevice); + //$this->resultImageDevice = fireEvent('AfterResizeImage', $this->resultImageDevice, $this); + + return true; + } + + function resizeImageToContent($property, $originSrc, $imageWidth) { + if ( !is_readable($originSrc) ) { + return array($property, false); + } + + list($originWidth, $originHeight, $type, $attr) = getimagesize($originSrc); + $attributes = Misc::getAttributesFromString($property, false); + + // 단위 변환. + $onclickFlag = false; + if (array_key_exists('width', $attributes)) { + if (preg_match('/(.+)(%?)/', $attributes['width'], $matches)) { + if($matches[2] == '%') + $attributes['width'] = round($originWidth * $matches[1] / 100); + else + $attributes['width'] = intval($matches[1]); + + } + } + + if (array_key_exists('height', $attributes)) { + if (preg_match('/(.+)(%?)/', $attributes['height'], $matches)) { + if ($matches[2] == '%') + $attributes['height'] = round($originHeight * $matches[1] / 100); + else + $attributes['height'] = intval($matches[1]); + + } + } + + // 가로, 세로 어느 쪽이든 0이면 이미지는 표시되지 않음. 따라서 계산할 필요 없음. + if ((isset($attributes['width']) && $attributes['width'] <= 0) || (isset($attributes['height']) && $attributes['height'] <= 0)) { + return array($property, false); + } + + // 가로만 지정된 이미지의 경우. + if (isset($attributes['width']) && !isset($attributes['height'])) { + // 비어있는 세로를 가로의 크기를 이용하여 계산. + $attributes['height'] = floor($originHeight * $attributes['width'] / $originWidth); + // 세로만 지정된 이미지의 경우. + } else if (!isset($attributes['width']) && isset($attributes['height'])) { + // 비어있는 가로를 세로의 크기를 이용하여 계산. + $attributes['width'] = floor($originWidth * $attributes['height'] / $originHeight); + // 둘 다 지정되지 않은 이미지의 경우. + } else if (!isset($attributes['width']) && !isset($attributes['height'])) { + // 둘 다 비어 있을 경우는 오리지널 사이즈로 대치. + $attributes['width'] = $originWidth; + $attributes['height'] = $originHeight; + } + + if ($attributes['width'] > $imageWidth) { + $attributes['height'] = floor($attributes['height'] * $imageWidth / $attributes['width']); + $attributes['width'] = $imageWidth; + } + + if ($attributes['width'] < $originWidth || $attributes['height'] < $originHeight) { + $onclickFlag = true; + } else { + $onclickFlag = false; + } + + $properties = array(); + ksort($attributes); + foreach($attributes as $key => $value) { + array_push($properties, "$key=\"$value\""); + } + + return array(implode(' ', $properties), $onclickFlag); + } + + function impressWaterMark($waterMarkFile, $position="left=10|bottom=10", $gamma=100) { + if ($this->getImageType($waterMarkFile) == "png") + return $this->_impressWaterMarkCore("PNG", $waterMarkFile, $position); + else + return $this->_impressWaterMarkCore("GIF", $waterMarkFile, $position, $gamma); + } + + function _impressWaterMarkCore($type, $waterMarkFile, $position, $gamma=100) { + if (empty($waterMarkFile)) + return false; + if (!file_exists($waterMarkFile)) + return false; + if (empty($this->resultImageDevice)) + return false; + + // validate gamma. + if (!is_int($gamma)) { + $gamma = 100; + } else if ($gamma < 0) { + $gamma = 0; + } else if ($gamma > 100) { + $gamma = 100; + } + + list($waterMarkWidth, $waterMarkHeight, $waterMakrType) = getimagesize($waterMarkFile); + + // position of watermark. + if (preg_match("/^(-?[0-9A-Z]+) (-?[0-9A-Z]+)$/i", $position, $temp)) { + $resultWidth = imagesx($this->resultImageDevice); + $resultHeight = imagesy($this->resultImageDevice); + + switch ($temp[1]) { + case "left": + $xPosition = $this->extraPadding; + break; + case "center": + $xPosition = $resultWidth / 2 - $waterMarkWidth / 2; + break; + case "right": + $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; + break; + default: + // if positive, calculate x value from left. + if (preg_match("/^([1-9][0-9]*)$/", $temp[1], $extra)) { + if ($extra[1] > $resultWidth - $waterMarkWidth) { + $xPosition = $resultWidth - $waterMarkWidth; + } else { + $xPosition = $extra[1]; + } + // if negative, calculate x value from right. + } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[1], $extra)) { + if ($resultWidth - $waterMarkWidth - abs($extra[1]) < 0) { + $xPosition = 0; + } else { + $xPosition = $resultWidth - $waterMarkWidth - abs($extra[1]); + } + // in the case of 0. + } else if ($temp[1] == "0") { + $xPosition = 0; + // the others. calculate x value from left. + } else { + $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; + } + } + + switch ($temp[2]) { + case "top": + $yPosition = $this->extraPadding; + break; + case "middle": + $yPosition = $resultHeight / 2 - $waterMarkHeight / 2; + break; + case "bottom": + $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; + break; + default: + // if positive, calculate y value from top. + if (preg_match("/^([1-9][0-9]*)$/", $temp[2], $extra)) { + if ($extra[1] > $resultHeight - $waterMarkHeight) { + $yPosition = $resultHeight - $waterMarkHeight; + } else { + $yPosition = $extra[1]; + } + // if negative, calculate y value from bottom. + } else if (preg_match("/^(-?[1-9][0-9]*)$/", $temp[2], $extra)) { + if ($resultHeight - $waterMarkHeight - abs($extra[1]) < 0) { + $yPosition = 0; + } else { + $yPosition = $resultHeight - $waterMarkHeight - abs($extra[1]); + } + // in the case of 0. + } else if ($temp[1] == "0") { + $yPosition = 0; + // the others. calculate y value from bottom. + } else { + $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; + } + } + } else { + $xPosition = $resultWidth - $waterMarkWidth - $this->extraPadding; + $yPosition = $resultHeight - $waterMarkHeight - $this->extraPadding; + } + + // create watermark image device. + switch ($waterMakrType) { + case 1: + $waterMarkDevice = imagecreatefromgif($waterMarkFile); + break; + case 2: + $waterMarkDevice = imagecreatefromjpeg($waterMarkFile); + break; + case 3: + $waterMarkDevice = imagecreatefrompng($waterMarkFile); + break; + } + + // PHP >= 4.0.6 + if (strtolower($type) == "png" && function_exists("imagealphablending")) { + imagealphablending($this->resultImageDevice, true); + imagecopy($this->resultImageDevice, $waterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); + } else { + // if not support alpha channel, support GIF transparency. + $tempWaterMarkDevice = imagecreatetruecolor($waterMarkWidth, $waterMarkHeight); + + $bgColorBy16 = $this->hexRGB("FF00FF"); + $temp = imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); + imagecolortransparent($this->resultImageDevice, $temp); + imagefill($tempWaterMarkDevice, 0, 0, $temp); + imagecopy($tempWaterMarkDevice, $waterMarkDevice, 0, 0, 0, 0, $waterMarkWidth, $waterMarkHeight); + + if (function_exists("imagecopymerge")) + imagecopymerge($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight, $gamma); + else + imagecopy($this->resultImageDevice, $tempWaterMarkDevice, $xPosition, $yPosition, 0, 0, $waterMarkWidth, $waterMarkHeight); + + imagedestroy($tempWaterMarkDevice); + } + + imagedestroy($waterMarkDevice); + return true; + } + + function cropRectByCoordinates($startX, $startY, $finishX, $finishY) { + $width = $finishX - $startX; + $height = $finishY - $startY; + + $targetDevice = imagecreatetruecolor($width, $height); + $bgColorBy16 = $this->hexRGB('FFFFFF'); + imagecolorallocate($tempWaterMarkDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); + imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $startX, $startY, $width, $height); + $this->resultImageDevice = $targetDevice; + unset($targetDevice); + + return true; + } + + function cropRectBySize($width, $height, $align='center', $valign='middle') { + switch ($align) { + case 'left': + $srcX = 0; + break; + case 'center': + $srcX = floor((imagesx($this->resultImageDevice) - $width) / 2); + break; + case 'right': + $srcX = imagesx($this->resultImageDevice) - $width; + break; + } + + switch ($valign) { + case 'top': + $srcY = 0; + break; + case 'middle': + $srcY = floor((imagesy($this->resultImageDevice) - $height) / 2); + break; + case 'bottom': + $srcY = imagesy($this->resultImageDevice) - $height; + break; + } + + $targetDevice = imagecreatetruecolor($width, $height); + $bgColorBy16 = $this->hexRGB('FFFFFF'); + imagecolorallocate($targetDevice, $bgColorBy16['R'], $bgColorBy16['G'], $bgColorBy16['B']); + imagecopy($targetDevice, $this->resultImageDevice, 0, 0, $srcX, $srcY, $width, $height); + $this->resultImageDevice = $targetDevice; + unset($targetDevice); + + return true; + } + + function saveAsFile($fileName) { + return $this->createThumbnailIntoFile($fileName); + } + + function createThumbnailIntoFile($fileName) { + if (empty($this->resultImageDevice)) + return false; + + imageinterlace($this->resultImageDevice); + switch ($this->getImageType($this->imageFile)) { + case "gif": + imagegif($this->resultImageDevice, $fileName); + break; + case "png": + imagepng($this->resultImageDevice, $fileName); + break; + case "wbmp": + imagewbmp($this->resultImageDevice, $fileName); + break; + case "jpg": + default: + imagejpeg($this->resultImageDevice, $fileName, 80); + break; + } + + $this->resultImageDevice = NULL; + + return true; + } + + function saveAsCache() { + return $this->createThumbnailIntoCache(); + } + + function createThumbnailIntoCache() { + header("Content-type: image/jpeg"); + imagejpeg($this->resultImageDevice); + + $originImageDevice = NULL; + $this->resultImageDevice = NULL; + + return true; + } + + function calcOptimizedImageSize($argWidth, $argHeight, $boxWidth=NULL, $boxHeight=NULL, $resizeFlag="reduce") { + if (empty($boxWidth) && empty($boxHeight)) { + return array($argWidth, $argHeight); + } else if (!empty($boxWidth) && empty($boxHeight)) { + if ($argWidth > $boxWidth) { + $newWidth = $boxWidth; + $newHeight = floor($argHeight * $newWidth / $argWidth); + } else { + $newWidth = $argWidth; + $newHeight = $argHeight; + } + } else if (empty($boxWidth) && !empty($boxHeight)) { + if ($argHeight > $boxHeight) { + $newHeight = $boxHeight; + $newWidth = floor($argWidth * $newHeight / $argHeight); + } else { + $newWidth = $argWidth; + $newHeight = $argHeight; + } + } else { + if ($argWidth > $boxWidth) { + $newWidth = $boxWidth; + $newHeight = floor($argHeight * $newWidth / $argWidth); + } else { + $newWidth = $argWidth; + $newHeight = $argHeight; + } + + if ($newHeight > $boxHeight) { + $tempHeight = $newHeight; + $newHeight = $boxHeight; + $newWidth = floor($newWidth * $newHeight / $tempHeight); + } + } + + if ($argWidth * $argHeight > $newWidth * $newHeight) { + if ($resizeFlag == "reduce" || $resizeFlag == "both") { + $imgWidth = $newWidth; + $imgHeight = $newHeight; + } else { + $imgWidth = $argWidth; + $imgHeight = $argHeight; + } + } else if ($argWidth * $argHeight == $newWidth * $newHeight) { + $imgWidth = $argWidth; + $imgHeight = $argHeight; + } else if ($argWidth * $argHeight < $newWidth * $newHeight) { + if ($resizeFlag == "enlarge" || $resizeFlag == "both") { + $imgWidth = $newWidth; + $imgHeight = $newHeight; + } else { + $imgWidth = $argWidth; + $imgHeight = $argHeight; + } + } + + return array($imgWidth, $imgHeight); + } + + function getImageType($filename) { + if (file_exists($filename)) { + if (function_exists("exif_imagetype")) { + $imageType = exif_imagetype($filename); + } else { + $tempInfo = getimagesize($filename); + $imageType = $tempInfo[2]; + } + + switch ($imageType) { + case IMAGETYPE_GIF: + $extension = 'gif'; + break; + case IMAGETYPE_JPEG: + $extension = 'jpg'; + break; + case IMAGETYPE_PNG: + $extension = 'png'; + break; + case IMAGETYPE_SWF: + $extension = 'swf'; + break; + case IMAGETYPE_PSD: + $extension = 'psd'; + break; + case IMAGETYPE_BMP: + $extension = 'bmp'; + break; + case IMAGETYPE_TIFF_II: + case IMAGETYPE_TIFF_MM: + $extension = 'tiff'; + break; + case IMAGETYPE_JPC: + $extension = 'jpc'; + break; + case IMAGETYPE_JP2: + $extension = 'jp2'; + break; + case IMAGETYPE_JPX: + $extension = 'jpx'; + break; + case IMAGETYPE_JB2: + $extension = 'jb2'; + break; + case IMAGETYPE_SWC: + $extension = 'swc'; + break; + case IMAGETYPE_IFF: + $extension = 'aiff'; + break; + case IMAGETYPE_WBMP: + $extension = 'wbmp'; + break; + case IMAGETYPE_XBM: + $extension = 'xbm'; + break; + default: + $extension = false; + } + } else { + $extension = false; + } + + return $extension; + } + + /* "FFFFFF" => array(255, 255, 255) */ + function hexRGB($hexstr) { + $int = hexdec($hexstr); + return array('R' => 0xFF & ($int >> 0x10), 'G' => 0xFF & ($int >> 0x8), 'B' => 0xFF & $int); + } +} +?> diff --git a/interface/blog/checkup.php b/interface/blog/checkup.php index 6fd52fa74..870461c70 100644 --- a/interface/blog/checkup.php +++ b/interface/blog/checkup.php @@ -769,7 +769,16 @@ function clearCache() { else { showCheckupMessage(false); } - } + } + /* From Textcube 1.8.4 */ + if (!POD::queryExistence("DESC {$database['prefix']}RemoteResponseLogs responsetype")) { + $changed = true; + echo '
Omnis mundi creatura quasi liber et pictura nobis est, et speculum
diff --git a/interface/owner/setting/account/invite/index.php b/interface/owner/setting/account/invite/index.php index d0583cd5f..7b82c053b 100644 --- a/interface/owner/setting/account/invite/index.php +++ b/interface/owner/setting/account/invite/index.php @@ -28,6 +28,11 @@ } Respond::ResultPage($blogadd); } -$result = sendInvitationMail(null, User::getUserIdByEmail($_POST['email']),$_POST['name'],$_POST['comment'], $_POST['senderName'], $_POST['senderEmail']); -Respond::ResultPage($result); +if(User::getEmail() == $_POST['email']) { + $result = array('error'=>0,'message'=>_t('이 계정에 새로운 블로그를 추가하였습니다.')); + Respond::ResultPage($result); +} else { + $result = sendInvitationMail(null, User::getUserIdByEmail($_POST['email']),$_POST['name'],$_POST['comment'], $_POST['senderName'], $_POST['senderEmail']); + Respond::ResultPage($result); +} ?> diff --git a/library/function/html.php b/library/function/html.php index 265147999..130609606 100644 --- a/library/function/html.php +++ b/library/function/html.php @@ -123,7 +123,7 @@ function str_tag_off($str) { } function str_tag_truncate($str) { - return strip_tags(preg_replace('/\[##.+##\]/', '', $str)); + return strip_tags(preg_replace('/\[##(.+?)##\]/', '', $str)); } function str_cut($str, $maxlen, $type) { diff --git a/library/function/image.php b/library/function/image.php index 8faf02b7c..2c32550dc 100644 --- a/library/function/image.php +++ b/library/function/image.php @@ -4,13 +4,14 @@ /// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) // img의 width/height에 맞춰 이미지를 리샘플링하는 함수. 썸네일 함수가 아님! 주의. -function resampleImage($imgString, $originSrc, $useAbsolutePath) { - global $database, $serviceURL, $pathURL, $defaultURL; - - if (!extension_loaded('gd') || !file_exists($originSrc)) { +function resampleImage($imgString, $filename, $useAbsolutePath = true) { + $blogid = getBlogId(); + $context = Model_Context::getInstance(); + + if (!extension_loaded('gd') || !file_exists(ROOT . "/attach/{$blogid}/{$filename}")) { return $imgString; } - + if (!is_dir(ROOT."/cache/thumbnail")) { @mkdir(ROOT."/cache/thumbnail"); @chmod(ROOT."/cache/thumbnail", 0777); @@ -21,52 +22,153 @@ function resampleImage($imgString, $originSrc, $useAbsolutePath) { @chmod(ROOT."/cache/thumbnail/".getBlogId(), 0777); } - $originFileName = basename($originSrc); - - // 여기로 넘어오는 값은 이미 getAttachmentBinder() 함수에서 고정값으로 변환된 값이므로 % 값은 고려할 필요 없음. - if (preg_match('/width="([1-9][0-9]*)"/i', $imgString, $temp)) { + $origImageSrc = ($useAbsolutePath ? $context->getProperty('uri.service') : $context->getProperty('uri.path')) . "/attach/{$blogid}/{$filename}"; + $tempWidth = $tempHeight = ''; + if (preg_match('/width="([1-9][0-9]*)"/i', $imgString, $temp)) $tempWidth = $temp[1]; - } else { - $tempWidth = ''; - } - if (preg_match('/height="([1-9][0-9]*)"/i', $imgString, $temp)) { + if (preg_match('/height="([1-9][0-9]*)"/i', $imgString, $temp)) $tempHeight = $temp[1]; - } else { - $tempHeight = ''; - } + + if (!empty($tempWidth) && is_numeric($tempWidth) && !empty($tempHeight) && is_numeric($tempHeight)) + $resizeImage = getImageResizer($filename, array('width' => $tempWidth, 'height' => $tempHeight, 'absolute' => $useAbsolutePath)); + else if (!empty($tempWidth) && !is_numeric($tempWidth) && empty($tempHeight)) + $resizeImage = getImageResizer($filename, array('width' => $tempWidth, 'absolute' => $useAbsolutePath)); + else if (empty($tempWidth) && !empty($tempHeight) && is_numeric($tempHeight)) + $resizeImage = getImageResizer($filename, array('height' => $tempHeight, 'absolute' => $useAbsolutePath)); + else + return $imgString; - $newTempFileName = preg_replace("/\\.([[:alnum:]]+)$/i", ".w{$tempWidth}-h{$tempHeight}.\\1", $originFileName); - $tempSrc = ROOT."/cache/thumbnail/".getBlogId()."/".$newTempFileName; + if ($resizeImage === false) return $imgString; - //$tempURL = "{$pathURL}/thumbnail/".getBlogId()."/".$newTempFileName; -// if ($useAbsolutePath == true) { - // From Textcube 1.6, thumbnail's URLs are also treated as absolute Path. - $tempURL = "{$serviceURL}/thumbnail/".getBlogId()."/".$newTempFileName; -// } - - if (file_exists($tempSrc)) { - $imgString = preg_replace('/src="([^"]+)"/i', 'src="'.$tempURL.'"', $imgString); - $imgString = preg_replace('/width="([^"]+)"/i', 'width="'.$tempWidth.'"', $imgString); - $imgString = preg_replace('/height="([^"]+)"/i', 'height="'.$tempHeight.'"', $imgString); - $imgString = preg_replace('/onclick="open_img\(\'([^\']+)\'\)"/', "onclick=\"open_img('$serviceURL/attach/".getBlogId()."/".$originFileName."')\"", $imgString); - } else { - $AttachedImage = new Image(); - $AttachedImage->imageFile = $originSrc; - - // 리샘플링 시작. - if ($AttachedImage->resample($tempWidth, $tempHeight)) { - // 리샘플링된 파일 저장. - $AttachedImage->createThumbnailIntoFile($tempSrc); - $imgString = preg_replace('/src="([^"]+)"/i', 'src="'.$tempURL.'"', $imgString); - $imgString = preg_replace('/width="([^"]+)"/i', 'width="'.$tempWidth.'"', $imgString); - $imgString = preg_replace('/height="([^"]+)"/i', 'height="'.$tempHeight.'"', $imgString); - $imgString = preg_replace('/onclick="open_img\(\'([^\']+)\'\)"/', "onclick=\"open_img('$serviceURL/attach/".getBlogId()."/".$originFileName."')\"", $imgString); + if (basename($resizeImage[0]) == $filename) return $imgString; + + $resizeImageSrc = $resizeImage[0]; + $resizeImageWidth = $resizeImage[1]; + $resizeImageHeight = $resizeImage[2]; + + $imgString = preg_replace('/src="([^"]+)"/i', 'src="'.$resizeImageSrc.'"', $imgString); + $imgString = preg_replace('/width="([^"]+)"/i', 'width="'.$resizeImageWidth.'"', $imgString); + $imgString = preg_replace('/height="([^"]+)"/i', 'height="'.$resizeImageHeight.'"', $imgString); + $imgString = preg_replace('/onclick="open_img\(\'([^\']+)\'\)"/', "onclick=\"open_img('{$origImageSrc}')\"", $imgString); + + return $imgString; +} + +// 본문으로 부터 포함된 모든 첨부이미지 파일명 추출 +function getAttachmentExtracts($content, $blogid = null){ + if (is_null($blogid)) $blogid = getBlogId(); + + $result = $temp = array(); + if (preg_match_all('/\[##_(1R|1L|1C|2C|3C|iMazing|Gallery)\|[^|]*\.(gif|jpg|jpeg|png|GIF|JPG|JPEG|PNG)\|(.[^\[]*)_##\]/mi', $content, $matches)) { + foreach ($matches[0] as $image) { + $split = explode("|", $image); + if (!in_array($split[1], $temp)) $temp[] = $split[1]; } + } - unset($AttachedImage); + if (preg_match_all('/]+?src=("|\')?([^\'">]*?)("|\')/mi', $content, $matches)) { + foreach ($matches[2] as $image) + if (!in_array(basename($image), $temp)) $temp[] = basename($image); } - return $imgString; + foreach($temp as $filename) { + if (preg_match('/(.+)\.w(\d{1,})\-h(\d{1,})\.(.+)/', $filename, $matches)) + $filename = $matches[1].'.'.$matches[4]; + + if (file_exists(ROOT."/attach/{$blogid}/{$filename}") && !in_array($filename, $result)) + $result[] = $filename; + } + + return $result; +} + +function getImageResizer($filename, $options = null, $blogid = null) { + // version 1.2.2 + // usages : + // $options = array('size'=>100) // resize & crop to square + // $options = array('width'=>100) // resize by width + // $options = array('width'=>100, 'height'=>50) // resize & crop by width and height + // $options = array('force'=>true) // refresh image + // $options = array('absolute'=>true) // use absolute path + + $context = Model_Context::getInstance(); + + if (is_null($blogid)) $blogid = getBlogId(); + $force = isset($options['force']) ? $options['force'] : false; + $absolute = isset($options['absolute']) ? $options['absolute'] : true; + + $originSrc = ROOT."/attach/{$blogid}/{$filename}"; + $originURL = ($absolute ? $context->getProperty('uri.service'):$context->getProperty('uri.path'))."/attach/{$blogid}/{$filename}"; + + if (!file_exists($originSrc)) return false; + + $imageInfo = getimagesize($originSrc); + if ($imageInfo === false || count($imageInfo) < 1) return false; + $originWidth = $imageInfo[0]; + $originHeight = $imageInfo[1]; + + if (!extension_loaded('gd')) return array($originURL, $originWidth, $originHeight); + + if (!is_dir(ROOT."/cache/thumbnail")) { + @mkdir(ROOT."/cache/thumbnail"); + @chmod(ROOT."/cache/thumbnail", 0777); + } + if (!is_dir(ROOT."/cache/thumbnail/" . $blogid)) { + @mkdir(ROOT."/cache/thumbnail/" .$blogid); + @chmod(ROOT."/cache/thumbnail/" . $blogid, 0777); + } + + $objResize = new Utils_Image(); + $objResize->imageFile = $originSrc; + if (isset($options['size']) && is_numeric($options['size'])) { + if ($imageInfo[0] > $imageInfo[1]) + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $options['size']); + else + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $options['size'], null); + $resizeWidth = $resizeHeight = $options['size']; + $resizeFilename = preg_replace("/\\.([[:alnum:]]+)$/i", ".w{$resizeWidth}-h{$resizeHeight}.\\1", $filename); + } else if (isset($options['width']) && is_numeric($options['width']) && isset($options['height']) && is_numeric($options['height'])) { + if ($options['width'] / $options['height'] > intval($imageInfo[0]) / intval($imageInfo[1])) + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $options['width'], NULL); + else + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $options['height']); + $resizeWidth = $tempWidth; + $resizeHeight = $tempHeight; + $resizeFilename = preg_replace("/\\.([[:alnum:]]+)$/i", ".w{$options['width']}-h{$options['height']}.\\1", $filename); + } else { + if (isset($options['width']) && is_numeric($options['width'])) { + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], $options['width'], NULL); + } elseif (isset($options['height']) && is_numeric($options['height'])) { + list($tempWidth, $tempHeight) = $objResize->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $options['height']); + } else { + unset($objResize); + return array($originURL, $originWidth, $originHeight); + } + $resizeWidth = $tempWidth; + $resizeHeight = $tempHeight; + $resizeFilename = preg_replace("/\\.([[:alnum:]]+)$/i", ".w{$resizeWidth}-h{$resizeHeight}.\\1", $filename); + } + $resizeSrc = ROOT . "/cache/thumbnail/{$blogid}/{$resizeFilename}"; + $resizeURL = ($absolute ? $context->getProperty('uri.service'):$context->getProperty('uri.path')) . "/cache/thumbnail/{$blogid}/{$resizeFilename}"; + + if($force) @unlink($resizeSrc); + + if (file_exists($resizeSrc)) { + unset($objResize); + return array($resizeURL, $resizeWidth, $resizeHeight); + } + if ($objResize->resample($tempWidth, $tempHeight)) { + if (isset($options['size']) && is_numeric($options['size'])) + @$objResize->cropRectBySize($options['size'], $options['size']); + if (isset($options['width']) && is_numeric($options['width']) && isset($options['height']) && is_numeric($options['height'])) + @$objResize->cropRectBySize($options['width'], $options['height']); + if ($objResize->saveAsFile($resizeSrc)) { + unset($objResize); + return array($resizeURL, $resizeWidth, $resizeHeight); + } + } + unset($objResize); + return array($originURL, $originWidth, $originHeight); } ?> diff --git a/library/model/blog.blogSetting.php b/library/model/blog.blogSetting.php index 694370a53..42ace2c65 100644 --- a/library/model/blog.blogSetting.php +++ b/library/model/blog.blogSetting.php @@ -46,18 +46,21 @@ function getBlogTags($blogid) { function removeBlogLogo($blogid) { $context = Model_Context::getInstance(); + $skin = new Skin($context->getProperty('skin.skin')); requireModel('blog.attachment'); if(Setting::setBlogSettingGlobal('logo','') === false) return false; else { deleteAttachment($blogid, - 1, $context->getProperty('blog.logo')); $context->setProperty('blog.logo',''); + $skin->purgeCache(); return true; } } function changeBlogLogo($blogid, $file) { $context = Model_Context::getInstance(); + $skin = new Skin($context->getProperty('skin.skin')); requireModel('blog.attachment'); if (($attachment = addAttachment($blogid, - 1, $file)) === false) { return false; @@ -68,6 +71,7 @@ function changeBlogLogo($blogid, $file) { } if(Setting::setBlogSettingGlobal('logo',$attachment['name'])) { deleteAttachment($blogid, - 1, $context->getProperty('blog.logo')); + $skin->purgeCache(); return true; } return false; @@ -157,9 +161,9 @@ function useBlogSlogan($blogid, $useSloganOnPost, $useSloganOnCategory, $useSlog ) { return false; }*/ - setBlogSetting('useSloganOnPost',$useSloganOnPost); - setBlogSetting('useSloganOnCategory',$useSloganOnCategory); - setBlogSetting('useSloganOnTag',$useSloganOnTag); + Setting::setBlogSettingGlobal('useSloganOnPost',$useSloganOnPost); + Setting::setBlogSettingGlobal('useSloganOnCategory',$useSloganOnCategory); + Setting::setBlogSettingGlobal('useSloganOnTag',$useSloganOnTag); $blog['useSloganOnPost'] = $useSloganOnPost; $blog['useSloganOnCategory'] = $useSloganOnCategory; @@ -173,12 +177,12 @@ function useBlogSlogan($blogid, $useSloganOnPost, $useSloganOnCategory, $useSlog } function setEntriesOnRSS($blogid, $entriesOnRSS) { - global $blog; + $context = Model_Context::getInstance(); requireModel('blog.feed'); - if ($entriesOnRSS == $blog['entriesOnRSS']) + if ($entriesOnRSS == $context->getProperty('blog.entriesOnRSS')) return true; if(Setting::setBlogSettingGlobal('entriesOnRSS',$entriesOnRSS) === false) return false; - $blog['entriesOnRSS'] = $entriesOnRSS; + $context->setProperty('blog.entriesOnRSS',$entriesOnRSS); clearFeed(); return true; } @@ -571,12 +575,12 @@ function removeBlog($blogid) { function setSmtpServer( $useCustomSMTP, $smtpHost, $smtpPort ) { if( empty($useCustomSMTP) ) { - setServiceSetting( 'useCustomSMTP', 0 ); + Setting::setServiceSettingGlobal( 'useCustomSMTP', 0 ); return true; } - if( !setServiceSetting( 'useCustomSMTP', 1 ) ) return false; - if( !setServiceSetting( 'smtpHost', $smtpHost ) ) return false; - if( !setServiceSetting( 'smtpPort', $smtpPort ) ) return false; + if( !Setting::setServiceSettingGlobal( 'useCustomSMTP', 1 ) ) return false; + if( !Setting::setServiceSettingGlobal( 'smtpHost', $smtpHost ) ) return false; + if( !Setting::setServiceSettingGlobal( 'smtpPort', $smtpPort ) ) return false; return true; } @@ -584,7 +588,7 @@ function setDefaultBlog( $blogid ) { if(!Acl::check("group.creators")) { return false; } - $result = setServiceSetting("defaultBlogId", $_GET['blogid']); + $result = Setting::setServiceSettingGlobal("defaultBlogId", $_GET['blogid']); return $result; } ?> diff --git a/library/model/blog.service.php b/library/model/blog.service.php index fc032ab85..17e51b7c2 100644 --- a/library/model/blog.service.php +++ b/library/model/blog.service.php @@ -30,7 +30,7 @@ function getSkinSettings($blogid, $forceReload = false) { function getDefaultURL($blogid) { $context = Model_Context::getInstance(); - $blog = Setting::getBlogSettingsGlobal($blogid); + $blog = Setting::getBlogSettingsGlobal($blogid); // Load specific blog's setting switch ($context->getProperty('service.type')) { case 'domain': if (!empty($blog['defaultDomain']) && !empty($blog['secondaryDomain'])) diff --git a/library/preprocessor.php b/library/preprocessor.php index ea88a6e5c..ba8d98f9c 100644 --- a/library/preprocessor.php +++ b/library/preprocessor.php @@ -191,7 +191,6 @@ if(!defined('NO_LOCALE')) { if($context->getProperty('uri.interfaceType') == 'reader') { $languageDomain = 'owner'; } else $languageDomain = $context->getProperty('uri.interfaceType'); - if($languageDomain == 'owner') { $language = $context->getProperty('blog.language') !== null ? $context->getProperty('blog.language') : $context->getProperty('service.language'); } else { @@ -244,11 +243,15 @@ ----------------------------------- Checks privilege setting and block user (or connection). */ - if($context->getProperty('uri.interfaceType') == 'blog' && !defined('__TEXTCUBE_LOGIN__')) { $blogVisibility = Setting::getBlogSettingGlobal('visibility',2); - if($blogVisibility == 0) requireOwnership(); - else if($blogVisibility == 1) requireMembership(); + if($context->getProperty('service.requirelogin',false) == true) { + if($blogVisibility == 0) requireOwnership(); + else requireMembership(); + } else { + if($blogVisibility == 0) requireOwnership(); + else if($blogVisibility == 1) requireMembership(); + } } if(in_array($context->getProperty('uri.interfaceType'), array('owner','reader'))) { diff --git a/library/view/iphoneView.php b/library/view/iphoneView.php index dcbc1f590..dabbbfa75 100644 --- a/library/view/iphoneView.php +++ b/library/view/iphoneView.php @@ -321,10 +321,9 @@ function printIphoneCropProcess($blogid, $filename, $cropSize) { $thumbnailSrc = ROOT . "/cache/thumbnail/{$blogid}/iphoneThumbnail/th_{$filename}"; if (file_exists($originSrc)) { - requireComponent('Textcube.Function.Image'); $imageInfo = getimagesize($originSrc); - $objThumbnail = new Image(); + $objThumbnail = new Utils_Image(); if ($imageInfo[0] > $imageInfo[1]) list($tempWidth, $tempHeight) = $objThumbnail->calcOptimizedImageSize($imageInfo[0], $imageInfo[1], NULL, $cropSize); else diff --git a/library/view/ownerView.php b/library/view/ownerView.php index 98410cbd9..7888506f0 100644 --- a/library/view/ownerView.php +++ b/library/view/ownerView.php @@ -139,7 +139,7 @@ function getEditor() { if($id == $setEditor) { getEditorInfo($id); // explicitly loads plugin code ($pluginURL, $pluginName returned as global) if (isset($editor['initfunc']) && function_exists($editor['initfunc'])) { - echo "\t\t\n".call_user_func($editor['initfunc'], &$editor)."\t\t\n"; + echo "\t\t\n".call_user_func($editor['initfunc'], $editor)."\t\t\n"; $pluginURL = $pluginName = ""; } } diff --git a/library/view/view.php b/library/view/view.php index a6dfaeef1..783a004b5 100644 --- a/library/view/view.php +++ b/library/view/view.php @@ -224,7 +224,7 @@ function getTrackbacksView($entry, $skin, $accepttrackback) { return $trackbacksView; } -function getCommentView($entry, $skin, $inputBlock = true, $page = 1, $count = null) { +function getCommentView($entry, $skin, $inputBlock = true, $page = 1, $count = null, $listBlock = true) { global $contentContainer, $skinSetting, $skin; static $dressCommentBlock = false; $context = Model_Context::getInstance(); @@ -237,12 +237,12 @@ function getCommentView($entry, $skin, $inputBlock = true, $page = 1, $count = n } if(!isset($entry)) $entry['id'] = 0; $blogid = getBlogId(); - $useAjaxBlock = $context->getProperty('blog.useAjaxComment',true); requireModel("common.setting"); requireModel("blog.entry"); requireModel("blog.comment"); requireLibrary('blog.skin'); $authorized = doesHaveOwnership(); + $useAjaxBlock = $context->getProperty('blog.useAjaxComment',true); $useMicroformat = $context->getProperty('blog.useMicroformat',3); $fn = ''; $fn_nickname = ''; @@ -259,140 +259,144 @@ function getCommentView($entry, $skin, $inputBlock = true, $page = 1, $count = n } $commentView = ($isComment ? $skin->comment : $skin->guest); $commentItemsView = ''; - if ($isComment == false) { - global $comments; - if(!isset($comments)) { - list($comments, $paging) = getCommentsWithPagingForGuestbook($blogid, $context->getProperty('suri.page'), $skinSetting['commentsOnGuestbook']); - } - foreach ($comments as $key => $value) { - if ($value['secret'] == 1) { - if (!$authorized) { - if( !doesHaveOpenIDPriv($value) ) { - $comments[$key]['name'] = _text('비밀방문자'); - $comments[$key]['homepage'] = ''; - $comments[$key]['comment'] = _text('관리자만 볼 수 있는 방명록입니다.'); - } else { - $comments[$key]['name'] = _text('비밀방문자') .' '. $comments[$key]['name']; + if ($listBlock === true) { + if ($isComment == false) { + global $comments; + if(!isset($comments)) { + list($comments, $paging) = getCommentsWithPagingForGuestbook($blogid, $context->getProperty('suri.page'), $skinSetting['commentsOnGuestbook']); + } + foreach ($comments as $key => $value) { + if ($value['secret'] == 1) { + if (!$authorized) { + if( !doesHaveOpenIDPriv($value) ) { + $comments[$key]['name'] = _text('비밀방문자'); + $comments[$key]['homepage'] = ''; + $comments[$key]['comment'] = _text('관리자만 볼 수 있는 방명록입니다.'); + } else { + $comments[$key]['name'] = _text('비밀방문자') .' '. $comments[$key]['name']; + } } } } - } - } else { - if($useAjaxBlock) { - list($comments, $paging) = getCommentsWithPagingByEntryId($blogid, $entry['id'], $page, $count,'loadComment','('.$entry['id'].',',',true);return false;'); } else { - $comments = getComments($entry['id']); + if($useAjaxBlock) { + list($comments, $paging) = getCommentsWithPagingByEntryId($blogid, $entry['id'], $page, $count,'loadComment','('.$entry['id'].',',',true,true);return false;'); + } else { + $comments = getComments($entry['id']); + } } - } - if(empty($skin->dressCommentBlock)) { - if( $dressCommentBlock ) { - if($isComment) $skin->commentGuest = $dressCommentBlock; - else $skin->guestGuest = $dressCommentBlock; - } else { - if($isComment) $dressCommentBlock = $skin->commentGuest = addOpenIDPannel( $skin->commentGuest, 'rp' ); - else $dressCommentBlock = $skin->guestGuest = addOpenIDPannel( $skin->guestGuest, 'guest' ); + if(empty($skin->dressCommentBlock)) { + if( $dressCommentBlock ) { + if($isComment) $skin->commentGuest = $dressCommentBlock; + else $skin->guestGuest = $dressCommentBlock; + } else { + if($isComment) $dressCommentBlock = $skin->commentGuest = addOpenIDPannel( $skin->commentGuest, 'rp' ); + else $dressCommentBlock = $skin->guestGuest = addOpenIDPannel( $skin->guestGuest, 'guest' ); + } + $skin->dressCommentBlock = true; } - $skin->dressCommentBlock = true; - } - foreach ($comments as $commentItem) { - $commentItemView = ($isComment ? $skin->commentItem : $skin->guestItem); - $commentSubItemsView = ''; - $subComments = getCommentComments($commentItem['id'],$commentItem); - foreach ($subComments as $commentSubItem) { - $commentSubItemView = ($isComment ? $skin->commentSubItem : $skin->guestSubItem); + /// Dressing comments + foreach ($comments as $commentItem) { + $commentItemView = ($isComment ? $skin->commentItem : $skin->guestItem); + $commentSubItemsView = ''; + $subComments = getCommentComments($commentItem['id'],$commentItem); + foreach ($subComments as $commentSubItem) { + $commentSubItemView = ($isComment ? $skin->commentSubItem : $skin->guestSubItem); + + $commentSubItem['name'] = htmlspecialchars($commentSubItem['name']); + $commentSubItem['comment'] = htmlspecialchars($commentSubItem['comment']); + + $rp_class = $prefix1 . '_general'; + if ($blogid == $commentSubItem['replier']) + $rp_class = $prefix1 . '_admin'; + else if ($commentSubItem['secret'] == 1) { + $rp_class = $prefix1 . '_secret'; + if ($authorized) { + $commentSubItem['comment'] = '' . _text('[비밀댓글]') . ' ' . $commentSubItem['comment']; + } else { + $rp_class .= ' hiddenComment'; + $commentSubItem['name'] = '' . _text('비밀방문자') . ''.(doesHaveOpenIDPriv($commentSubItem)?' '.$commentSubItem['name']:''); + } + } + dress($prefix1 . '_rep_class', $rp_class, $commentSubItemView); + + if (dress($prefix1 . '_rep_id',($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentSubItem['id'], $commentSubItemView) == false) { + $commentSubItemView = "" . $commentSubItemView; + } + if (empty($commentSubItem['homepage']) || + (($commentSubItem['secret'] == 1) && !doesHaveOwnership())) { + dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), "".$commentSubItem['name']."", $commentSubItem), $commentSubItemView); + } else { + dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), '' . $commentSubItem['name'] . '', $commentSubItem), $commentSubItemView); + } + $contentContainer["{$prefix1}_{$commentSubItem['id']}"] = fireEvent(($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent'), nl2br(addLinkSense($commentSubItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentSubItem); + dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentSubItem['id']}"), $commentSubItemView); + dress($prefix1 . '_rep_date', fireEvent(($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate'), Timestamp::format5($commentSubItem['written']), $commentSubItem['written']), $commentSubItemView); + dress($prefix1 . '_rep_link',$context->getProperty('uri.blog')."/".($entry['id'] == 0 ? "guestbook/{$commentItem['id']}#guestbook{$commentSubItem['id']}" : ($context->getProperty('blog.useSloganOnPost') ? "entry/".URL::encode($entry['slogan'],$context->getProperty('service.useEncodedURL')) : $entry['id'])."#comment{$commentSubItem['id']}"), $commentSubItemView); + dress($prefix1 . '_rep_onclick_delete', "deleteComment({$commentSubItem['id']}); return false;", $commentSubItemView); + + $commentSubItemsView .= $commentSubItemView; + } + $commentSubContainer = ($isComment ? $skin->commentSubContainer : $skin->guestSubContainer); + dress(($isComment ? 'rp2_rep' : 'guest_reply_rep'), $commentSubItemsView, $commentSubContainer); + if (count($subComments) > 0) { + dress(($isComment ? 'rp2_container' : 'guest_reply_container'), $commentSubContainer, $commentItemView); + } - $commentSubItem['name'] = htmlspecialchars($commentSubItem['name']); - $commentSubItem['comment'] = htmlspecialchars($commentSubItem['comment']); + $commentItem['name'] = htmlspecialchars($commentItem['name']); + $commentItem['comment'] = htmlspecialchars($commentItem['comment']); $rp_class = $prefix1 . '_general'; - if ($blogid == $commentSubItem['replier']) + if ($blogid == $commentItem['replier']) $rp_class = $prefix1 . '_admin'; - else if ($commentSubItem['secret'] == 1) { + else if ($commentItem['secret'] == 1) { $rp_class = $prefix1 . '_secret'; if ($authorized) { - $commentSubItem['comment'] = '' . _text('[비밀댓글]') . ' ' . $commentSubItem['comment']; + $commentItem['comment'] = '' . _text('[비밀댓글]') . ' ' . $commentItem['comment']; } else { $rp_class .= ' hiddenComment'; - $commentSubItem['name'] = '' . _text('비밀방문자') . ''.(doesHaveOpenIDPriv($commentSubItem)?' '.$commentSubItem['name']:''); + $commentItem['name'] = '' . _text('비밀방문자') . ''.(doesHaveOpenIDPriv($commentItem)?' '.$commentItem['name']:''); } } - dress($prefix1 . '_rep_class', $rp_class, $commentSubItemView); - - if (dress($prefix1 . '_rep_id',($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentSubItem['id'], $commentSubItemView) == false) { - $commentSubItemView = "" . $commentSubItemView; + dress($prefix1 . '_rep_class', $rp_class, $commentItemView); + if (dress($prefix1 . '_rep_id', ($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentItem['id'], $commentItemView) == false) { + $commentItemView = "" . $commentItemView; } - if (empty($commentSubItem['homepage']) || - (($commentSubItem['secret'] == 1) && !doesHaveOwnership())) { - dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), "".$commentSubItem['name']."", $commentSubItem), $commentSubItemView); + if (empty($commentItem['homepage']) || + (($commentItem['secret'] == 1) && !doesHaveOwnership())) { + dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), "".$commentItem['name']."", $commentItem), $commentItemView); } else { - dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), '' . $commentSubItem['name'] . '', $commentSubItem), $commentSubItemView); + dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), '' . $commentItem['name'] . '', $commentItem), $commentItemView); } - $contentContainer["{$prefix1}_{$commentSubItem['id']}"] = fireEvent(($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent'), nl2br(addLinkSense($commentSubItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentSubItem); - dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentSubItem['id']}"), $commentSubItemView); - dress($prefix1 . '_rep_date', fireEvent(($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate'), Timestamp::format5($commentSubItem['written']), $commentSubItem['written']), $commentSubItemView); - dress($prefix1 . '_rep_link',$context->getProperty('uri.blog')."/".($entry['id'] == 0 ? "guestbook/{$commentItem['id']}#guestbook{$commentSubItem['id']}" : ($context->getProperty('blog.useSloganOnPost') ? "entry/".URL::encode($entry['slogan'],$context->getProperty('service.useEncodedURL')) : $entry['id'])."#comment{$commentSubItem['id']}"), $commentSubItemView); - dress($prefix1 . '_rep_onclick_delete', "deleteComment({$commentSubItem['id']}); return false;", $commentSubItemView); - - $commentSubItemsView .= $commentSubItemView; - } - $commentSubContainer = ($isComment ? $skin->commentSubContainer : $skin->guestSubContainer); - dress(($isComment ? 'rp2_rep' : 'guest_reply_rep'), $commentSubItemsView, $commentSubContainer); - if (count($subComments) > 0) { - dress(($isComment ? 'rp2_container' : 'guest_reply_container'), $commentSubContainer, $commentItemView); - } - - $commentItem['name'] = htmlspecialchars($commentItem['name']); - $commentItem['comment'] = htmlspecialchars($commentItem['comment']); - - $rp_class = $prefix1 . '_general'; - if ($blogid == $commentItem['replier']) - $rp_class = $prefix1 . '_admin'; - else if ($commentItem['secret'] == 1) { - $rp_class = $prefix1 . '_secret'; - if ($authorized) { - $commentItem['comment'] = '' . _text('[비밀댓글]') . ' ' . $commentItem['comment']; + $contentContainer["{$prefix1}_{$commentItem['id']}"] = fireEvent(($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent'), nl2br(addLinkSense($commentItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentItem); + dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentItem['id']}"), $commentItemView); + dress($prefix1 . '_rep_date', fireEvent(($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate'), Timestamp::format5($commentItem['written']), $commentItem['written']), $commentItemView); + if ($prefix1 == 'guest' && $authorized != true && $context->getProperty('blog.allowWriteDblCommentOnGuestbook') == 0) { + $doubleCommentPermissionScript = 'alert(\'' . _text('댓글을 사용할 수 없습니다.') . '\'); return false;'; } else { - $rp_class .= ' hiddenComment'; - $commentItem['name'] = '' . _text('비밀방문자') . ''.(doesHaveOpenIDPriv($commentItem)?' '.$commentItem['name']:''); + $doubleCommentPermissionScript = ''; } + dress($prefix1 . '_rep_onclick_reply', $doubleCommentPermissionScript . "commentComment({$commentItem['id']}); return false", $commentItemView); + dress($prefix1 . '_rep_onclick_delete', "deleteComment({$commentItem['id']});return false", $commentItemView); + dress($prefix1 . '_rep_link', + $context->getProperty('uri.blog')."/".($entry['id'] == 0 ? "guestbook/{$commentItem['id']}#guestbook{$commentItem['id']}" : + ($context->getProperty('blog.useSloganOnPost') ? "entry/".URL::encode($entry['slogan'],$context->getProperty('service.useEncodedURL')) : $entry['id'])."?commentId=".$commentItem['id']."#comment{$commentItem['id']}"), $commentItemView); + + $commentItemsView .= $commentItemView; } - dress($prefix1 . '_rep_class', $rp_class, $commentItemView); - if (dress($prefix1 . '_rep_id', ($entry['id'] == 0 ? 'guestbook' : 'comment') . $commentItem['id'], $commentItemView) == false) { - $commentItemView = "" . $commentItemView; - } - if (empty($commentItem['homepage']) || - (($commentItem['secret'] == 1) && !doesHaveOwnership())) { - dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), "".$commentItem['name']."", $commentItem), $commentItemView); - } else { - dress($prefix1 . '_rep_name', fireEvent(($isComment ? 'ViewCommenter' : 'ViewGuestCommenter'), '' . $commentItem['name'] . '', $commentItem), $commentItemView); - } - $contentContainer["{$prefix1}_{$commentItem['id']}"] = fireEvent(($isComment ? 'ViewCommentContent' : 'ViewGuestCommentContent'), nl2br(addLinkSense($commentItem['comment'], ' onclick="return openLinkInNewWindow(this)"')), $commentItem); - dress($prefix1 . '_rep_desc', setTempTag("{$prefix1}_{$commentItem['id']}"), $commentItemView); - dress($prefix1 . '_rep_date', fireEvent(($isComment ? 'ViewCommentDate' : 'ViewGuestCommentDate'), Timestamp::format5($commentItem['written']), $commentItem['written']), $commentItemView); - if ($prefix1 == 'guest' && $authorized != true && $context->getProperty('blog.allowWriteDblCommentOnGuestbook') == 0) { - $doubleCommentPermissionScript = 'alert(\'' . _text('댓글을 사용할 수 없습니다.') . '\'); return false;'; - } else { - $doubleCommentPermissionScript = ''; + /// Merging comments with its paging links. + $commentContainer = ($isComment ? $skin->commentContainer : $skin->guestContainer); + dress(($isComment ? 'rp_rep' : 'guest_rep'), $commentItemsView, $commentContainer); + if (count($comments) > 0) { + if($isComment && $useAjaxBlock) { + $pagingView = Paging::getPagingView($paging, $skin->paging, $skin->pagingItem, false, 'onclick'); + } else $pagingView = ''; + dress($prefix1 . '_container', " |
---|