Пример #1
0
function FAS_Call($type, $name, $title, $url, $content)
{
    $context = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $blogstr = $context->getProperty('uri.host') . $context->getProperty('uri.blog');
    $DDosTimeWindowSize = 300;
    $rpc = new XMLRPC();
    $rpc->url = 'http://antispam.textcube.org/RPC/';
    if ($rpc->call('checkSpam', $blogstr, $type, $name, $title, $url, $content, $_SERVER['REMOTE_ADDR']) == false) {
        // call fail
        // Do Local spam check with "Thief-cat algorithm"
        $count = 0;
        if ($type == 2) {
            $storage = "RemoteResponses";
            $pool->reset($storage);
            $pool->setQualifier("url", "eq", $url, true);
            $pool->setQualifier("isfiltered", ">", 0);
            if ($cnt = $pool->getCount("id")) {
                $count += $cnt;
            }
        } else {
            // Comment Case
            $storage = "Comments";
            $pool->reset($storage);
            $pool->setQualifier("comment", "eq", ${$content}, true);
            $pool->setQualifier("name", "eq", $name, true);
            $pool->setQualifier("homepage", "eq", $url, true);
            $pool->setQualifier("isfiltered", ">", 0);
            if ($cnt = $pool->getCount("id")) {
                $count += $cnt;
            }
        }
        // Check IP
        $pool->reset($storage);
        $pool->setQualifier("ip", "eq", $_SERVER['REMOTE_ADDR'], true);
        $pool->setQualifier("written", ">", Timestamp::getUNIXtime() - $DDosTimeWindowSize);
        if ($cnt = $pool->getCount("id")) {
            $count += $cnt;
        }
        if ($count >= 10) {
            return false;
        }
        return true;
    }
    if (!is_null($rpc->fault)) {
        // FAS has some problem
        return true;
    }
    if ($rpc->result['result'] == true) {
        return false;
        // it's spam
    }
    return true;
}
Пример #2
0
function dumbCronScheduler($checkOnly = true)
{
    $context = Model_Context::getInstance();
    $now = Timestamp::getUNIXtime();
    $dumbCronStamps = Setting::getServiceSetting('dumbCronStamps', serialize(array('1m' => 0, '5m' => 0, '30m' => 0, '1h' => 0, '2h' => 0, '6h' => 0, '12h' => 0, '24h' => 0, 'Daily' => 0)), true);
    $dumbCronStamps = unserialize($dumbCronStamps);
    $schedules = array('1m' => 60, '5m' => 60 * 5, '10m' => 60 * 10, '30m' => 60 * 30, '1h' => 60 * 60, '2h' => 60 * 60 * 2, '6h' => 60 * 60 * 6, '12h' => 60 * 60 * 12, '24h' => 60 * 60 * 24, 'Daily' => 60 * 60 * 24, '1w' => 60 * 60 * 24 * 7);
    /* Events: Cron1m, Cron5m, Cron30m, Cron1h, Cron2h, Cron6h, Cron12h */
    $log_file = __TEXTCUBE_CACHE_DIR__ . '/cronlog.txt';
    $log = fopen($log_file, "a");
    foreach ($schedules as $d => $diff) {
        if (!isset($dumbCronStamps[$d])) {
            $dumbCronStamps[$d] = 0;
        }
        if ($now > $diff + $dumbCronStamps[$d]) {
            if ($checkOnly && eventExists("Cron{$d}")) {
                fclose($log);
                return true;
            }
            fireEvent("Cron{$d}", null, $now);
            if ($d == '6h') {
                importlib('model.blog.trash');
                trashVan();
            }
            fwrite($log, date('Y-m-d H:i:s') . ' ' . $context->getProperty('blog.name') . " Cron{$d} executed ({$_SERVER['REQUEST_URI']})\r\n");
            $dumbCronStamps[$d] = $now;
        }
    }
    fclose($log);
    /* Keep just 1000 lines */
    $logcontent = explode("\r\n", file_get_contents($log_file));
    $logcontent = implode("\r\n", array_slice($logcontent, -1000));
    $log = fopen($log_file, "w");
    fwrite($log, $logcontent);
    fclose($log);
    Setting::setServiceSetting('dumbCronStamps', serialize($dumbCronStamps), true);
    return false;
}
Пример #3
0
function publishEntries()
{
    $ctx = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    $blogid = getBlogId();
    $closestReservedTime = Setting::getBlogSettingGlobal('closestReservedPostTime', INT_MAX);
    if ($closestReservedTime < Timestamp::getUNIXtime()) {
        $pool->init("Entries");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("draft", "eq", 0);
        $pool->setQualifier("visibility", "<", 0);
        $pool->setQualifier("published", "<", Timestamp::getUNIXtime());
        $entries = $pool->getAll("id, visibility, category");
        if (count($entries) == 0) {
            return;
        }
        foreach ($entries as $entry) {
            $pool->init("Entries");
            $pool->setQualifier("blogid", "eq", $blogid);
            $pool->setQualifier("draft", "eq", 0);
            $pool->setQualifier("id", "eq", $entry['id']);
            $pool->setAttribute("visibility", 0);
            $result = $pool->update();
            if ($entry['visibility'] == -3) {
                if ($result && setEntryVisibility($entry['id'], 2)) {
                    $updatedEntry = getEntry($blogid, $entry['id']);
                    if (!is_null($updatedEntry)) {
                        fireEvent('UpdatePost', $entry['id'], $updatedEntry);
                        setEntryVisibility($entry['id'], 3);
                    }
                }
            } else {
                if ($result) {
                    setEntryVisibility($entry['id'], abs($entry['visibility']));
                    $updatedEntry = getEntry($blogid, $entry['id']);
                    if (!is_null($updatedEntry)) {
                        fireEvent('UpdatePost', $entry['id'], $updatedEntry);
                    }
                }
            }
        }
        $pool->init("Entries");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("draft", "eq", 0);
        $pool->setQualifier("visibility", "<", 0);
        $pool->setQualifier("published", ">", Timestamp::getUNIXtime());
        $newClosestTime = $pool->getCell("min(published)");
        if (!empty($newClosestTime)) {
            Setting::setBlogSettingGlobal('closestReservedPostTime', $newClosestTime);
        } else {
            Setting::setBlogSettingGlobal('closestReservedPostTime', INT_MAX);
        }
    }
}
Пример #4
0
function api_addAttachment($blogid, $parent, $file)
{
    $pool = DBModel::getInstance();
    $attachment = array();
    $attachment['parent'] = $parent ? $parent : 0;
    $attachment['label'] = Path::getBaseName($file['name']);
    $label = Utils_Unicode::lessenAsEncoding($attachment['label'], 64);
    $attachment['size'] = $file['size'];
    $extension = Path::getExtension($attachment['label']);
    switch (strtolower($extension)) {
        case '.exe':
        case '.php':
        case '.sh':
        case '.com':
        case '.bat':
            $extension = '.xxx';
            break;
    }
    /* Create directory for owner */
    $path = __TEXTCUBE_ATTACH_DIR__ . "/{$blogid}";
    if (!is_dir($path)) {
        mkdir($path);
        if (!is_dir($path)) {
            return false;
        }
        @chmod($path, 0777);
    }
    $pool->reset('Attachments');
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('parent', 'eq', $parent);
    $pool->setQualifier('label', 'eq', $label, true);
    $oldFile = $pool->getCell('name');
    if ($oldFile !== null) {
        $attachment['name'] = $oldFile;
    } else {
        $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        while (Attachment::doesExist($attachment['name'])) {
            $attachment['name'] = rand(1000000000, 9999999999) . $extension;
        }
    }
    $attachment['path'] = "{$path}/{$attachment['name']}";
    deleteAttachment($blogid, -1, $attachment['name']);
    if ($file['content']) {
        $f = fopen($attachment['path'], "w");
        if (!$f) {
            return false;
        }
        $attachment['size'] = fwrite($f, $file['content']);
        fclose($f);
        $file['tmp_name'] = $attachment['path'];
    }
    if ($imageAttributes = @getimagesize($file['tmp_name'])) {
        $attachment['mime'] = $imageAttributes['mime'];
        $attachment['width'] = $imageAttributes[0];
        $attachment['height'] = $imageAttributes[1];
    } else {
        $attachment['mime'] = Utils_Misc::getMIMEType($extension);
        $attachment['width'] = 0;
        $attachment['height'] = 0;
    }
    $attachment['mime'] = Utils_Unicode::lessenAsEncoding($attachment['mime'], 32);
    @chmod($attachment['path'], 0666);
    $pool->reset('Attachments');
    $pool->setAttribute('blogid', $blogid);
    $pool->setAttribute('parent', $attachment['parent']);
    $pool->setAttribute('name', $attachment['name'], true);
    $pool->setAttribute('label', $label, true);
    $pool->setAttribute('mime', $attachment['mime'], true);
    $pool->setAttribute('size', $attachment['size'], true);
    $pool->setAttribute('width', $attachment['width']);
    $pool->setAttribute('height', $attachment['height']);
    $pool->setAttribute('attached', Timestamp::getUNIXtime());
    $pool->setAttribute('downloads', 0);
    $pool->setAttribute('enclosure', 0);
    $result = $pool->insert();
    if (!$result) {
        @unlink($attachment['path']);
        return false;
    }
    return $attachment;
}
Пример #5
0
 static function getHumanReadable($time = null, $from = null)
 {
     if (is_null($from)) {
         $deviation = Timestamp::getUNIXtime() - Timestamp::getUNIXtime($time);
     } else {
         $deviation = Timestamp::getUNIXtime($from) - Timestamp::getUNIXtime($time);
     }
     if ($deviation > 0) {
         // Past.
         if ($deviation < 60) {
             return _f('%1초 전', $deviation);
         } else {
             if ($deviation < 3600) {
                 return _f('%1분 전', intval($deviation / 60));
             } else {
                 if ($deviation < 86400) {
                     return _f('%1시간 전', intval($deviation / 3600));
                 } else {
                     if ($deviation < 604800) {
                         return _f('%1일 전', intval($deviation / 86400));
                     } else {
                         return _f('%1주 전', intval($deviation / 604800));
                     }
                 }
             }
         }
     } else {
         $deviation = abs($deviation);
         if ($deviation < 60) {
             return _f('%1초 후', $deviation);
         } else {
             if ($deviation < 3600) {
                 return _f('%1분 후', intval($deviation / 60));
             } else {
                 if ($deviation < 86400) {
                     return _f('%1시간 후', intval($deviation / 3600));
                 } else {
                     if ($deviation < 604800) {
                         return _f('%1일 후', intval($deviation / 86400));
                     } else {
                         return _f('%1주 후', intval($deviation / 604800));
                     }
                 }
             }
         }
     }
 }
Пример #6
0
function addBlog($blogid, $userid, $identify)
{
    $ctx = Model_Context::getInstance();
    $pool = DBModel::getInstance();
    if (empty($userid)) {
        $userid = 1;
        // If no userid, choose the service administrator.
    } else {
        $pool->reset('Users');
        $pool->setQualirifer('userid', 'eq', $userid);
        if (!$pool->doesExist('userid')) {
            return 3;
        }
        // 3: No user exists with specific userid
    }
    if (!empty($blogid)) {
        // If blogid,
        $pool->reset('BlogSettings');
        $pool->setQualirifer('blogid', 'eq', $blogid);
        if (!$pool->doesExist('blogid')) {
            return 2;
        }
        // 2: No blog exists with specific blogid
        // Thus, blog and user exists. Now combine both.
        $pool->reset('Privileges');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('userid', $userid);
        $pool->setAttribute('acl', 0);
        $pool->setAttribute('created', Timestamp::getUNIXtime());
        $pool->setAttribute('lastlogin', 0);
        $result = $pool->insert();
        return $result;
    } else {
        // If no blogid, create a new blog.
        if (!preg_match('/^[a-zA-Z0-9]+$/', $identify)) {
            return 4;
        }
        // Wrong Blog name
        $identify = POD::escapeString(Utils_Unicode::lessenAsEncoding($identify, 32));
        $blogName = $identify;
        $pool->reset('ReservedWords');
        $pool->setQualifier('word', 'eq', $blogName, true);
        $result = $pool->getCount();
        if ($result && $result > 0) {
            return 60;
            // Reserved blog name.
        }
        $pool->reset('BlogSettings');
        $pool->setQualifier('name', 'eq', 'name', true);
        $pool->setQualifier('value', 'eq', $blogName, true);
        $result = $pool->getCount('value');
        if ($result && $result > 0) {
            return 61;
            // Same blogname is already exists.
        }
        $pool->reset('BlogSettings');
        $blogid = $pool->getCell('max(blogid)') + 1;
        $basicInformation = array('name' => $identify, 'defaultDomain' => 0, 'title' => '', 'description' => '', 'logo' => '', 'logoLabel' => '', 'logoWidth' => 0, 'logoHeight' => 0, 'useFeedViewOnCategory' => 1, 'useSloganOnPost' => 1, 'useSloganOnCategory' => 1, 'useSloganOnTag' => 1, 'entriesOnPage' => 10, 'entriesOnList' => 10, 'entriesOnRSS' => 10, 'commentsOnRSS' => 10, 'publishWholeOnRSS' => 1, 'publishEolinSyncOnRSS' => 1, 'allowWriteOnGuestbook' => 1, 'allowWriteDblCommentOnGuestbook' => 1, 'visibility' => 2, 'language' => $ctx->getProperty('service.language'), 'blogLanguage' => $ctx->getProperty('service.language'), 'timezone' => $ctx->getProperty('service.timezone'));
        $isFalse = false;
        foreach ($basicInformation as $fieldname => $fieldvalue) {
            if (Setting::setBlogSettingDefault($fieldname, $fieldvalue, $blogid) === false) {
                $isFalse = true;
            }
        }
        if ($isFalse == true) {
            $pool->reset('BlogSettings');
            $pool->setQualifier('blogid', 'eq', $blogid);
            $pool->delete();
            return 12;
        }
        $pool->reset('SkinSettings');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('name', 'skin', true);
        $pool->setAttribute('value', $ctx->getProperty('service.skin'), true);
        if (!$pool->insert()) {
            deleteBlog($blogid);
            return 13;
        }
        $pool->reset('FeedSettings');
        $pool->setAttribute('blogid', $blogid);
        if (!$pool->insert()) {
            deleteBlog($blogid);
            return 62;
        }
        $pool->reset('FeedGroups');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('id', 0);
        if (!$pool->insert()) {
            deleteBlog($blogid);
            return 62;
        }
        Setting::setBlogSettingGlobal('defaultEditor', 'modern', $blogid);
        Setting::setBlogSettingGlobal('defaultFormatter', 'ttml', $blogid);
        //Combine user and blog.
        $pool->reset('Privileges');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('userid', $userid);
        $pool->setAttribute('acl', 16);
        $pool->setAttribute('created', Timestamp::getUNIXtime());
        $pool->setAttribute('lastlogin', 0);
        if ($pool->insert()) {
            setDefaultPost($blogid, $userid);
            return true;
        } else {
            return 65;
        }
    }
    //return true; // unreachable code
}
Пример #7
0
/// Copyright (c) 2004-2016, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
require ROOT . '/library/preprocessor.php';
$IV = array('GET' => array('user' => array('email'), 'blogid' => array('id')));
requireStrictRoute();
requirePrivilege('group.creators');
$userid = User::getUserIdByEmail($_GET['user']);
$bid = $_GET['blogid'];
if (empty($userid)) {
    Respond::ResultPage(array(-1, "존재하지 않는 사용자"));
}
$pool = DBModel::getInstance();
$pool->init("Privileges");
$pool->setQualifier("blogid", "eq", $bid);
$pool->setQualifier("userid", "eq", $userid);
$acl = $pool->getCell("acl");
if ($acl === null) {
    // If there is no ACL, add user into the blog.
    $pool->init("Privileges");
    $pool->setAttribute("blogid", $bid);
    $pool->setAttribute("userid", $userid);
    $pool->setAttribute("acl", 0);
    $pool->setAttribute("created", Timestamp::getUNIXtime());
    $pool->setAttribute("lastlogin", 0);
    $pool->insert();
    Respond::ResultPage(0);
} else {
    Respond::ResultPage(array(-2, "이미 참여중인 사용자"));
}
Пример #8
0
function initializeRSSchannel($blogid = null)
{
    global $serviceURL, $defaultURL, $blogURL, $blog;
    if (empty($blogid)) {
        $blogid = getBlogId();
    }
    $channel = array();
    $channel['title'] = RSSMessage($blog['title']);
    $channel['link'] = "{$defaultURL}/";
    $channel['description'] = RSSMessage($blog['description']);
    $channel['language'] = $blog['language'];
    $channel['pubDate'] = Timestamp::getUNIXtime();
    $channel['generator'] = TEXTCUBE_NAME . ' ' . TEXTCUBE_VERSION;
    if (Setting::getBlogSettingGlobal('visibility', 2) == 2 && !empty($blog['logo']) && file_exists(ROOT . "/attach/{$blogid}/{$blog['logo']}")) {
        $logoInfo = getimagesize(ROOT . "/attach/{$blogid}/{$blog['logo']}");
        $channel['url'] = $serviceURL . "/attach/" . $blogid . "/" . $blog['logo'];
        $channel['width'] = $logoInfo[0];
        $channel['height'] = $logoInfo[1];
    }
    return $channel;
}
Пример #9
0
function MT_Cover_getRecentEntries($parameters)
{
    global $database, $blog, $service, $serviceURL, $suri, $configVal, $defaultURL, $skin;
    requireModel("blog.entry");
    requireModel("blog.tag");
    $data = Setting::fetchConfigVal($configVal);
    $data['coverMode'] = !isset($data['coverMode']) ? 1 : $data['coverMode'];
    if (Misc::isMetaBlog() != true) {
        $data['coverMode'] = 1;
    }
    $data['screenshot'] = !isset($data['screenshot']) ? 1 : $data['screenshot'];
    $data['screenshotSize'] = !isset($data['screenshotSize']) ? 90 : $data['screenshotSize'];
    $data['paging'] = !isset($data['paging']) ? '2' : $data['paging'];
    $data['contentLength'] = !isset($data['contentLength']) ? 250 : $data['contentLength'];
    if (isset($parameters['preview'])) {
        // preview mode
        $retval = '표지에 최신 글 목록을 추가합니다.';
        return htmlspecialchars($retval);
    }
    $entryLength = isset($parameters['entryLength']) ? $parameters['entryLength'] : 10;
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail", 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId())) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId());
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId(), 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . getBlogId() . "/coverPostThumbnail/", 0777);
    }
    $page = $data['paging'] == '1' && !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $cache = new PageCache();
    $cache->name = 'MT_Cover_RecentPS';
    if ($cache->load()) {
        //If successful loads
        $cache->contents = unserialize($cache->contents);
        // If coverpage is single mode OR coverpage is coverblog and cache is not expired, return cache contents.
        if (($data['coverMode'] == 1 || $data['coverMode'] == 2) && array_key_exists($page, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 300) {
            return $cache->contents[$page];
        }
    }
    if (Misc::isMetaBlog() == true && doesHaveOwnership() && $service['type'] != 'single') {
        $visibility = 'AND e.visibility > 1 AND (c.visibility > 1 OR e.category = 0)';
    } else {
        $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 1 AND (c.visibility > 1 OR e.category = 0)';
    }
    $multiple = $data['coverMode'] == 2 ? '' : 'e.blogid = ' . getBlogId() . ' AND';
    $privateBlogId = POD::queryColumn("SELECT blogid \n\t\tFROM {$database['prefix']}BlogSettings\n\t\tWHERE name = 'visibility'\n\t\tAND value < 2");
    if (!empty($privateBlogId)) {
        $privateBlogs = ' AND e.blogid NOT IN (' . implode(',', $privateBlogId) . ')';
    } else {
        $privateBlogs = '';
    }
    list($entries, $paging) = Paging::fetch("SELECT e.blogid, e.id, e.userid, e.title, e.content, e.slogan, e.category, e.published, e.contentformatter, c.label\n\t\tFROM {$database['prefix']}Entries e\n\t\tLEFT JOIN {$database['prefix']}Categories c ON e.blogid = c.blogid AND e.category = c.id\n\t\tWHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0 {$privateBlogs}\n\t\tORDER BY published DESC", $page, $entryLength);
    $html = '';
    foreach ((array) $entries as $entry) {
        $tagLabelView = "";
        $blogid = $data['coverMode'] == 2 ? $entry['blogid'] : getBlogId();
        $entryTags = getTags($blogid, $entry['id']);
        $defaultURL = getDefaultURL($blogid);
        if (sizeof($entryTags) > 0) {
            $tags = array();
            foreach ($entryTags as $entryTag) {
                $tags[$entryTag['name']] = "<a href=\"{$defaultURL}/tag/" . (Setting::getBlogSettingGlobal('useSloganOnTag', true) ? URL::encode($entryTag['name'], $service['useEncodedURL']) : $entryTag['id']) . '">' . htmlspecialchars($entryTag['name']) . '</a>';
            }
            $tagLabelView = "<div class=\"post_tags\"><span>TAG : </span>" . implode(",\r\n", array_values($tags)) . "</div>";
        }
        if (empty($entry['category'])) {
            $entry['label'] = _text('분류없음');
            $entry['link'] = "{$defaultURL}/category";
        } else {
            $entry['link'] = "{$defaultURL}/category/" . (Setting::getBlogSettingGlobal('useSloganOnCategory', true) ? URL::encode($entry['label'], $service['useEncodedURL']) : $entry['category']);
        }
        $permalink = "{$defaultURL}/" . (Setting::getBlogSettingGlobal('useSloganOnPost', true) ? "entry/" . URL::encode($entry['slogan'], $service['useEncodedURL']) : $entry['id']);
        $html .= '<div class="coverpost">' . CRLF;
        if ($imageName = MT_Cover_getAttachmentExtract($entry['content'])) {
            if (($tempImageSrc = MT_Cover_getImageResizer($blogid, $imageName, $data['screenshotSize'])) && $data['screenshot'] == 1) {
                $html .= '<div class="img_preview"><a href="' . $permalink . '"><img src="' . $tempImageSrc . '" alt="" /></a></div>' . CRLF;
            }
        }
        $html .= '	<div class="content_box">';
        $html .= '		<h2><a href="' . $permalink . '">' . htmlspecialchars($entry['title']) . '</a></h2>' . CRLF;
        $html .= '		<div class="post_info">' . CRLF;
        $html .= '			<span class="category"><a href="' . htmlspecialchars($entry['link']) . '">' . htmlspecialchars($entry['label']) . '</a></span>' . CRLF;
        $html .= '			<span class="date">' . Timestamp::format5($entry['published']) . '</span>' . CRLF;
        $html .= '			<span class="author"><span class="preposition">by </span>' . User::getName($entry['userid']) . '</span>' . CRLF;
        $html .= '		</div>' . CRLF;
        $html .= '		<div class="post_content">' . htmlspecialchars(Utils_Unicode::lessenAsEm(removeAllTags(stripHTML($entry['content'])), $data['contentLength'])) . '</div>' . CRLF;
        $html .= $tagLabelView;
        $html .= '		<div class="clear"></div>' . CRLF;
        $html .= '	</div>';
        $html .= '</div>' . CRLF;
    }
    if ($data['paging'] == '1') {
        $paging['page'] = $page;
        $paging['total'] = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Entries e WHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0");
        $html .= getPagingView($paging, $skin->paging, $skin->pagingItem) . CRLF;
        $html .= '<script type="text/javascript">' . CRLF;
        $html .= '//<![CDATA[' . CRLF;
        if ($paging['page'] > 1) {
            $html .= 'var prevURL = "' . $paging['url'] . '?page=' . ($paging['page'] - 1) . '"' . CRLF;
        }
        if ($paging['page'] < $paging['total']) {
            $html .= 'var nextURL = "' . $paging['url'] . '?page=' . ($paging['page'] + 1) . '"' . CRLF;
        }
        $html .= '//]]>' . CRLF;
        $html .= '</script>';
    }
    $target = $html;
    $cache->contents[$page] = $target;
    $cache->contents = serialize($cache->contents);
    $cache->dbContents = Timestamp::getUNIXtime();
    $cache->update();
    unset($cache);
    return $target;
}
Пример #10
0
function initializeRSSchannel($blogid = null)
{
    $context = Model_Context::getInstance();
    if (empty($blogid)) {
        $blogid = getBlogId();
    }
    $channel = array();
    $channel['title'] = RSSMessage($context->getProperty('blog.title'));
    $channel['link'] = $context->getProperty('uri.default') . "/";
    $channel['description'] = RSSMessage($context->getProperty('blog.description'));
    $channel['language'] = $context->getProperty('blog.language');
    $channel['pubDate'] = Timestamp::getUNIXtime();
    $channel['generator'] = TEXTCUBE_NAME . ' ' . TEXTCUBE_VERSION;
    if (Setting::getBlogSettingGlobal('visibility', 2) == 2 && $context->getProperty('blog.logo') && file_exists(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/" . $context->getProperty('blog.logo'))) {
        $logoInfo = getimagesize(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/" . $context->getProperty('blog.logo'));
        $channel['url'] = $context->getProperty('uri.service') . "/attach/" . $blogid . "/" . $context->getProperty('blog.logo');
        $channel['width'] = $logoInfo[0];
        $channel['height'] = $logoInfo[1];
    }
    return $channel;
}
Пример #11
0
function trashVan()
{
    global $database;
    requireModel('common.setting');
    if (Timestamp::getUNIXtime() - Setting::getServiceSetting('lastTrashSweep', 0, true) > 86400) {
        //		var_dump(Timestamp::getUNIXtime());
        //		var_dump(Setting::getServiceSetting('lastTrashSweep',0, true));
        POD::execute("DELETE FROM {$database['prefix']}Comments where isfiltered < " . Timestamp::getUNIXtime() . " - 1296000 AND isfiltered > 0");
        POD::execute("DELETE FROM {$database['prefix']}RemoteResponses where isfiltered < " . Timestamp::getUNIXtime() . " - 1296000 AND isfiltered > 0");
        POD::execute("DELETE FROM {$database['prefix']}RefererLogs WHERE referred < " . Timestamp::getUNIXtime() . " - 604800");
        Setting::setServiceSetting('lastTrashSweep', Timestamp::getUNIXtime(), true);
    }
    if (Timestamp::getUNIXtime() - Setting::getServiceSetting('lastNoticeRead', 0, true) > 43200) {
        Setting::removeServiceSetting('TextcubeNotice', true);
        Setting::setServiceSetting('lastNoticeRead', Timestamp::getUNIXtime(), true);
    }
}
Пример #12
0
 function add()
 {
     //		unset($this->id);
     $this->id = $this->getNextLinkId();
     $this->pid = $this->getNextLinkPid();
     if (!isset($this->url)) {
         return $this->_error('url');
     }
     if (!isset($this->title)) {
         return $this->_error('title');
     }
     if (!($query = $this->_buildQuery())) {
         return false;
     }
     if (!isset($this->registered)) {
         $query->setAttribute('written', Timestamp::getUNIXtime());
     }
     if (!$query->insert()) {
         return $this->_error('insert');
     }
     //		$this->id = $query->id;
     return true;
 }
Пример #13
0
 function add()
 {
     global $database;
     if (!isset($this->id)) {
         $this->id = $this->nextId();
     } else {
         $this->id = $this->nextId($this->id);
     }
     if (!isset($this->entry)) {
         return $this->_error('entry');
     }
     if (!isset($this->commenter) && !isset($this->name)) {
         return $this->_error('commenter');
     }
     if (!isset($this->content)) {
         return $this->_error('content');
     }
     if (!isset($this->ip)) {
         $this->ip = $_SERVER['REMOTE_ADDR'];
     }
     if (!isset($this->isfiltered)) {
         $this->isfiltered = 0;
     }
     // legacy
     if (isset($this->commenter)) {
         $this->replier = $this->commenter;
         /*unset($this->commenter);*/
     }
     if (!($query = $this->_buildQuery())) {
         return false;
     }
     if (!$query->hasAttribute('written')) {
         $query->setAttribute('written', Timestamp::getUNIXtime());
     }
     if (!$query->insert()) {
         return $this->_error('insert');
     }
     if (isset($this->parent)) {
         $this->entry = Comment::getEntry($this->parent);
     }
     if (isset($this->entry) && $this->isfiltered == 0) {
         POD::execute("UPDATE {$database['prefix']}Entries SET comments = comments + 1 WHERE blogid = " . getBlogId() . " AND id = {$this->entry}");
     }
     return true;
 }
Пример #14
0
function updateXfn($blogid, $links)
{
    $pool = DBModel::getInstance();
    $ids = array();
    foreach ($links as $k => $v) {
        if (substr($k, 0, 3) == 'xfn') {
            $id = substr($k, 3);
            $xfn = $v;
            $pool->init("Links");
            $pool->setAttribute("xfn", $xfn, true);
            $pool->setAttribute("written", Timestamp::getUNIXtime());
            $pool->setQualifier("blogid", "eq", $blogid);
            $pool->setQualifier("id", "eq", $id);
            $pool->update();
        }
    }
}
 public static function authorize($blogid, $userid)
 {
     if (is_null(self::$mc)) {
         self::initialize();
     }
     $blogid = intval($blogid);
     $userid = intval($userid);
     $session_cookie_path = "/";
     if (!is_null(self::$context->getProperty('service.session_cookie_path'))) {
         $session_cookie_path = self::$context->getProperty('service.session_cookie_path');
     }
     if (!is_numeric($userid)) {
         return false;
     }
     $current = Timestamp::getUNIXtime();
     if (is_null($expires)) {
         $expires = $current + self::$context->getProperty('service.timeout');
     }
     if ($userid != SESSION_OPENID_USERID) {
         /* OpenID session : -1 */
         $_SESSION['userid'] = $userid;
         $id = session_id();
         if (self::isGuestOpenIDSession($id)) {
             //$result = self::$mc->set(self::$context->getProperty('service.domain')."/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,0,self::$context->getProperty('service.timeout'));
             $result = self::$mc->set(self::$context->getProperty('service.domain') . "/authorizedSession/{$id}", $userid, 0, $expires);
             if ($result) {
                 return true;
             }
         }
     }
     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::$context->getProperty('service.domain')."/authorizedSession/{$id}/{$_SERVER['REMOTE_ADDR']}",$userid,0,self::$context->getProperty('service.timeout'));
         $result = self::$mc->set(self::$context->getProperty('service.domain') . "/authorizedSession/{$id}", $userid, 0, self::$context->getProperty('service.timeout'));
         if ($result) {
             @session_id($id);
             setcookie(self::getName(), $id, 0, $session_cookie_path, self::$context->getProperty('service.session_cookie_domain'));
             return true;
         }
     }
     return false;
 }
Пример #16
0
 function authenticate($blogid, $loginid, $password, $blogapi = false)
 {
     global $database;
     $session = array();
     Acl::clearAcl();
     $loginid = POD::escapeString($loginid);
     $blogApiPassword = Setting::getBlogSettingGlobal("blogApiPassword", "");
     if (strlen($password) == 32 && preg_match('/[0-9a-f]{32}/i', $password)) {
         // Raw login. ( with/without auth token)
         $userid = User::getUserIdByEmail($loginid);
         if (!empty($userid) && !is_null($userid)) {
             $query = DBModel::getInstance();
             $query->reset('UserSettings');
             $query->setQualifier('userid', 'equals', intval($userid));
             $query->setQualifier('name', 'equals', 'AuthToken', true);
             $authtoken = $query->getCell('value');
             if (!empty($authtoken) && $authtoken === $password) {
                 // If user requested auth token, use it to confirm.
                 $session['userid'] = $userid;
             } else {
                 // login with md5 hash
                 $secret = 'password = \'' . md5($password) . '\'';
             }
         } else {
             return false;
         }
     } else {
         if ($blogapi && !empty($blogApiPassword)) {
             // BlogAPI login
             $password = POD::escapeString($password);
             $secret = '(password = \'' . md5($password) . '\' OR \'' . $password . '\' = \'' . $blogApiPassword . '\')';
         } else {
             // Normal login
             $secret = 'password = \'' . md5($password) . '\'';
         }
     }
     if (empty($session)) {
         $session = POD::queryRow("SELECT userid, loginid, name FROM {$database['prefix']}Users WHERE loginid = '{$loginid}' AND {$secret}");
     }
     if (empty($session)) {
         /* You should compare return value with '=== false' which checks with variable types*/
         return false;
     }
     $userid = $session['userid'];
     Acl::authorize('textcube', $userid);
     POD::execute("UPDATE {$database['prefix']}Users SET lastlogin = "******" WHERE loginid = '{$loginid}'");
     //		POD::execute("DELETE FROM {$database['prefix']}UserSettings WHERE userid = '$userid' AND name = 'AuthToken' LIMIT 1");
     return $userid;
 }
Пример #17
0
 public static function query($query, $compatiblity = true)
 {
     /// Bypassing compatiblitiy issue : will be replace to NAF2.
     if ($compatibility) {
         $query = str_replace('UNIX_TIMESTAMP()', Timestamp::getUNIXtime(), $query);
         // compatibility issue.
         // CONCAT
         $ppos = -1;
         $length = strlen($query);
         do {
             $pos = strpos($query, '\'', $ppos + 1);
             if ($pos === false) {
                 $pos = strlen($query);
             }
             while (true) {
                 $concat = stripos($query, 'CONCAT', $ppos + 1);
                 if ($concat === false || $concat >= $pos) {
                     break;
                 }
                 $depth = 0;
                 $quote = null;
                 for ($i = $concat + 6; $i < $length; $i++) {
                     if ($quote === null) {
                         if ($query[$i] == '\'' || $query[$i] == '"') {
                             $quote = $query[$i];
                         } elseif ($query[$i] == ',') {
                             $query = substr($query, 0, $i) . ' || ' . substr($query, $i + 1);
                         } elseif ($query[$i] == '(') {
                             $depth++;
                         } elseif ($query[$i] == ')') {
                             if (--$depth == 0) {
                                 break;
                             }
                         }
                     } else {
                         if ($query[$i] == $quote && $query[$i - 1] != '\\') {
                             $quote = null;
                         }
                     }
                 }
                 $query = substr($query, 0, $concat) . substr($query, $concat + 6);
                 $pos = strpos($query, '\'', $ppos + 1);
                 $length = strlen($query);
             }
             $ppos = $pos;
             while ($ppos < $length) {
                 $ppos = strpos($query, '\'', $ppos + 1);
                 if ($query[$ppos - 1] != '\\') {
                     break;
                 }
             }
         } while ($ppos < $length);
     }
     if (function_exists('__tcSqlLogBegin')) {
         __tcSqlLogBegin($query);
         $result = pg_query($query);
         __tcSqlLogEnd($result, 0);
     } else {
         $result = pg_query($query);
     }
     self::$lastQueryType = strtolower(substr($query, 0, 6));
     if (stristr($query, 'update ') || stristr($query, 'insert ') || stristr($query, 'delete ') || stristr($query, 'replace ')) {
         self::clearCache();
     }
     return $result;
 }
Пример #18
0
    setcookie(Session::getName(), $_GET['session'], 0, $context->getProperty('service.session_cookie_path'), $context->getProperty('service.session_cookie_domain'));
    header('Location: ' . $_GET['requestURI']);
    exit;
} else {
    if (!empty($_POST['loginid']) && !empty($_POST['reset'])) {
        if (resetPassword($blogid, $_POST['loginid'])) {
            $message = _text('지정된 이메일로 로그인 정보가 전달되었습니다.');
        } else {
            $message = _text('권한이 없습니다.');
        }
    } else {
        if (!empty($_POST['loginid']) && !empty($_POST['password'])) {
            if (!empty($_POST['autologin'])) {
                $isLogin = login($_POST['loginid'], $_POST['password'], Timestamp::getUNIXtime() + $context->getProperty('service.autologinTimeout'));
            } else {
                $isLogin = login($_POST['loginid'], $_POST['password'], Timestamp::getUNIXtime() + $context->getProperty('service.timeout'));
            }
            if (!$isLogin) {
                $message = _text('아이디 또는 비밀번호가 틀렸습니다.');
                if (!doesHaveMembership() && isLoginId(getBlogId(), $_POST['loginid'])) {
                    $showPasswordReset = true;
                }
            } else {
                if (!doesHaveOwnership()) {
                    $message = _text('서비스의 회원이지만 이 블로그의 구성원이 아닙니다. 주소를 확인해 주시기 바랍니다.');
                }
            }
        }
    }
}
$authResult = fireEvent('LOGIN_try_auth', false);
Пример #19
0
function receiveNotifiedComment($post)
{
    if (empty($post['mode']) || $post['mode'] != 'fb') {
        return 1;
    }
    $context = Model_Context::getInstance();
    CacheControl::flushCommentNotifyRSS();
    $post = fireEvent('ReceiveNotifiedComment', $post);
    if ($post === false) {
        return 7;
    }
    $pool = DBModel::getInstance();
    $blogid = getBlogId();
    $title = Utils_Unicode::lessenAsEncoding($post['s_home_title'], 255);
    $name = Utils_Unicode::lessenAsEncoding($post['s_name'], 255);
    $entryId = $post['s_no'];
    $homepage = Utils_Unicode::lessenAsEncoding($post['url'], 255);
    $entryurl = $post['s_url'];
    $entrytitle = $post['s_post_title'];
    $parent_id = $post['r1_no'];
    $parent_name = Utils_Unicode::lessenAsEncoding($post['r1_name'], 80);
    $parent_parent = $post['r1_rno'];
    $parent_homepage = Utils_Unicode::lessenAsEncoding($post['r1_homepage'], 80);
    $parent_written = $post['r1_regdate'];
    $parent_comment = $post['r1_body'];
    $parent_url = Utils_Unicode::lessenAsEncoding($post['r1_url'], 255);
    $child_id = $post['r2_no'];
    $child_name = Utils_Unicode::lessenAsEncoding($post['r2_name'], 80);
    $child_parent = $post['r2_rno'];
    $child_homepage = Utils_Unicode::lessenAsEncoding($post['r2_homepage'], 80);
    $child_written = $post['r2_regdate'];
    $child_comment = $post['r2_body'];
    $child_url = Utils_Unicode::lessenAsEncoding($post['r2_url'], 255);
    $pool->reset('CommentsNotifiedSiteInfo');
    $pool->setQualifier('url', 'eq', $homepage);
    $siteid = $pool->getCell('id');
    if (empty($siteid)) {
        $insertId = getCommentsNotifiedSiteInfoMaxId() + 1;
        $pool->reset('CommentsNotifiedSiteInfo');
        $pool->setAttribute('id', $insertId);
        $pool->setAttribute('title', $title, true);
        $pool->setAttribute('name', $name, true);
        $pool->setAttribute('url', $homepage, true);
        $pool->setAttribute('modified', Timestamp::getUNIXtime());
        if ($pool->insert()) {
            $siteid = $insertId;
        } else {
            return 2;
        }
    }
    $pool->reset('CommentsNotified');
    $pool->setQualifier('entry', 'eq', $entryId);
    $pool->setQualifier('siteid', 'eq', $siteid);
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('remoteid', 'eq', $parent_id);
    $parentId = $pool->getCell('id');
    if (empty($parentId)) {
        $insertId = getCommentsNotifiedMaxId() + 1;
        $pool->reset('CommentsNotified');
        $pool->setAttribute('blogid', $blogid);
        $pool->setAttribute('replier', NULL);
        $pool->setAttribute('id', $insertId);
        $pool->setAttribute('entry', $entryId);
        $pool->setAttribute('parent', empty($parent_parent) ? NULL : $parent_parent);
        $pool->setAttribute('name', $parent_name, true);
        $pool->setAttribute('password', '', true);
        $pool->setAttribute('homepage', $parent_homepage, true);
        $pool->setAttribute('secret', '', true);
        $pool->setAttribute('comment', $parent_comment, true);
        $pool->setAttribute('ip', '', true);
        $pool->setAttribute('written', $parent_written, true);
        $pool->setAttribute('modified', Timestamp::getUNIXtime());
        $pool->setAttribute('siteid', $siteid);
        $pool->setAttribute('isnew', 1);
        $pool->setAttribute('url', $parent_url, true);
        $pool->setAttribute('remoteid', $parent_id);
        $pool->setAttribute('entrytitle', $entrytitle, true);
        $pool->setAttribute('entryurl', $entryurl, true);
        if (!$pool->insert()) {
            return 3;
        }
        $parentId = $insertId;
    }
    $pool->reset('CommentsNotified');
    $pool->setQualifier('siteid', 'eq', $siteid);
    $pool->setQualifier('remoteid', 'eq', $child_id);
    if ($pool->getCount() > 0) {
        return 4;
    }
    $insertId = getCommentsNotifiedMaxId() + 1;
    $pool->reset('CommentsNotified');
    $pool->setAttribute('blogid', $blogid);
    $pool->setAttribute('replier', NULL);
    $pool->setAttribute('id', $insertId);
    $pool->setAttribute('entry', $entryId);
    $pool->setAttribute('parent', $parentId);
    $pool->setAttribute('name', $child_name, true);
    $pool->setAttribute('password', '', true);
    $pool->setAttribute('homepage', $child_homepage, true);
    $pool->setAttribute('secret', '', true);
    $pool->setAttribute('comment', $child_comment, true);
    $pool->setAttribute('ip', '', true);
    $pool->setAttribute('written', $child_written, true);
    $pool->setAttribute('modified', Timestamp::getUNIXtime());
    $pool->setAttribute('siteid', $siteid);
    $pool->setAttribute('isnew', 1);
    $pool->setAttribute('url', $child_url, true);
    $pool->setAttribute('remoteid', $child_id);
    $pool->setAttribute('entrytitle', $entrytitle, true);
    $pool->setAttribute('entryurl', $entryurl, true);
    if (!$pool->insert()) {
        return 5;
    }
    $pool->reset('CommentsNotified');
    $pool->setAttribute('modified', Timestamp::getUNIXtime());
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('id', 'eq', $parentId);
    if (!$pool->update()) {
        return 6;
    }
    return 0;
}
Пример #20
0
function MT_Cover_getRecentEntries($parameters)
{
    global $skin;
    $context = Model_Context::getInstance();
    $data = $context->getProperty('plugin.config');
    importlib("model.blog.entry");
    importlib("model.blog.tag");
    $data['coverMode'] = !isset($data['coverMode']) ? 1 : $data['coverMode'];
    if (Utils_Misc::isMetaBlog() != true) {
        $data['coverMode'] = 1;
    }
    $data['screenshot'] = !isset($data['screenshot']) ? 1 : $data['screenshot'];
    $data['screenshotSize'] = !isset($data['screenshotSize']) ? 90 : $data['screenshotSize'];
    $data['paging'] = !isset($data['paging']) ? '2' : $data['paging'];
    $data['contentLength'] = !isset($data['contentLength']) ? 250 : $data['contentLength'];
    if (isset($parameters['preview'])) {
        // preview mode
        $retval = '표지에 최신 글 목록을 추가합니다.';
        return htmlspecialchars($retval);
    }
    $entryLength = isset($parameters['entryLength']) ? $parameters['entryLength'] : 10;
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail", 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'))) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'));
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id'), 0777);
    }
    if (!is_dir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/")) {
        @mkdir(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/");
        @chmod(__TEXTCUBE_CACHE_DIR__ . "/thumbnail/" . $context->getProperty('blog.id') . "/coverPostThumbnail/", 0777);
    }
    $page = $data['paging'] == '1' && !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $cache = new PageCache();
    $cache->name = 'MT_Cover_RecentPS';
    if ($cache->load()) {
        //If successful loads
        $cache->contents = unserialize($cache->contents);
        // If coverpage is single mode OR coverpage is coverblog and cache is not expired, return cache contents.
        if (($data['coverMode'] == 1 || $data['coverMode'] == 2) && array_key_exists($page, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 300) {
            return $cache->contents[$page];
        }
    }
    $pool = DBModel::getInstance();
    $pool->reset("BlogSettings");
    $pool->setQualifier("name", "eq", 'visibility', true);
    $pool->setQualifier("value", "<", 2);
    $privateBlogId = $pool->getCell("blogid");
    $pool->reset("Entries");
    $pool->join("Categories", "left", array(array("e.blogid", "eq", "c.blogid"), array("e.category", "eq", "c.id")));
    $pool->setQualifier("e.draft", "eq", 0);
    $pool->setQualifier("e.category", "beq", 0);
    if ($privateBlogId) {
        $pool->setQualifier("e.blogid", "hasnoneof", $privateBlogId);
    }
    if (Utils_Misc::isMetaBlog() == true && doesHaveOwnership() && $context->getProperty('service.type', 'single') != 'single') {
        $pool->setQualifier("e.visibility", ">", 1);
        $pool->setQualifierSet(array("c.visibility", ">", 1), "OR", array("e.category", "eq", 0));
    } else {
        if (!doesHaveOwnership()) {
            $pool->setQualifier("e.visibility", ">", 1);
            $pool->setQualifierSet(array("c.visibility", ">", 1), "OR", array("e.category", "eq", 0));
        }
    }
    if ($data['coverMode'] != 2) {
        $pool->setQualifier("e.blogid", "eq", $context->getProperty("blog.id"));
    }
    list($entries, $paging) = Paging::fetch($pool, $page, $entryLength);
    $html = '';
    foreach ((array) $entries as $entry) {
        $tagLabelView = "";
        $blogid = $data['coverMode'] == 2 ? $entry['blogid'] : $context->getProperty('blog.id');
        $entryTags = getTags($blogid, $entry['id']);
        $defaultURL = getDefaultURL($blogid);
        if (sizeof($entryTags) > 0) {
            $tags = array();
            foreach ($entryTags as $entryTag) {
                $tags[$entryTag['name']] = "<a href=\"{$defaultURL}/tag/" . (Setting::getBlogSettingGlobal('useSloganOnTag', true) ? URL::encode($entryTag['name'], $service['useEncodedURL']) : $entryTag['id']) . '">' . htmlspecialchars($entryTag['name']) . '</a>';
            }
            $tagLabelView = "<div class=\"post_tags\"><span>TAG : </span>" . implode(",\r\n", array_values($tags)) . "</div>";
        }
        if (empty($entry['category'])) {
            $entry['label'] = _text('분류없음');
            $entry['link'] = "{$defaultURL}/category";
        } else {
            $entry['link'] = "{$defaultURL}/category/" . (Setting::getBlogSettingGlobal('useSloganOnCategory', true) ? URL::encode($entry['label'], $service['useEncodedURL']) : $entry['category']);
        }
        $permalink = "{$defaultURL}/" . (Setting::getBlogSettingGlobal('useSloganOnPost', true) ? "entry/" . URL::encode($entry['slogan'], $context->getProperty('service.useEncodedURL', false)) : $entry['id']);
        $html .= '<div class="coverpost">' . CRLF;
        if ($imageName = MT_Cover_getAttachmentExtract($entry['content'])) {
            if (($tempImageSrc = MT_Cover_getImageResizer($blogid, $imageName, $data['screenshotSize'])) && $data['screenshot'] == 1) {
                $html .= '<div class="img_preview"><a href="' . $permalink . '"><img src="' . $tempImageSrc . '" alt="" /></a></div>' . CRLF;
            }
        }
        $html .= '	<div class="content_box">';
        $html .= '		<h2><a href="' . $permalink . '">' . htmlspecialchars($entry['title']) . '</a></h2>' . CRLF;
        $html .= '		<div class="post_info">' . CRLF;
        $html .= '			<span class="category"><a href="' . htmlspecialchars($entry['link']) . '">' . htmlspecialchars($entry['label']) . '</a></span>' . CRLF;
        $html .= '			<span class="date">' . Timestamp::format5($entry['published']) . '</span>' . CRLF;
        $html .= '			<span class="author"><span class="preposition">by </span>' . User::getName($entry['userid']) . '</span>' . CRLF;
        $html .= '		</div>' . CRLF;
        $html .= '		<div class="post_content">' . htmlspecialchars(Utils_Unicode::lessenAsEm(removeAllTags(stripHTML($entry['content'])), $data['contentLength'])) . '</div>' . CRLF;
        $html .= $tagLabelView;
        $html .= '		<div class="clear"></div>' . CRLF;
        $html .= '	</div>';
        $html .= '</div>' . CRLF;
    }
    if ($data['paging'] == '1') {
        $paging['page'] = $page;
        $paging['total'] = POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Entries e WHERE {$multiple} e.draft = 0 {$visibility} AND e.category >= 0");
        $html .= Paging::getPagingView($paging, $skin->paging, $skin->pagingItem) . CRLF;
        $html .= '<script type="text/javascript">' . CRLF;
        $html .= '//<![CDATA[' . CRLF;
        if ($paging['page'] > 1) {
            $html .= 'var prevURL = "' . $paging['url'] . '?page=' . ($paging['page'] - 1) . '"' . CRLF;
        }
        if ($paging['page'] < $paging['total']) {
            $html .= 'var nextURL = "' . $paging['url'] . '?page=' . ($paging['page'] + 1) . '"' . CRLF;
        }
        $html .= '//]]>' . CRLF;
        $html .= '</script>';
    }
    $target = $html;
    $cache->contents[$page] = $target;
    $cache->contents = serialize($cache->contents);
    $cache->dbContents = Timestamp::getUNIXtime();
    $cache->update();
    unset($cache);
    return $target;
}
Пример #21
0
function publishEntries()
{
    global $database;
    $blogid = getBlogId();
    $closestReservedTime = Setting::getBlogSettingGlobal('closestReservedPostTime', INT_MAX);
    if ($closestReservedTime < Timestamp::getUNIXtime()) {
        $entries = POD::queryAll("SELECT id, visibility, category\n\t\t\tFROM {$database['prefix']}Entries \n\t\t\tWHERE blogid = {$blogid} AND draft = 0 AND visibility < 0 AND published < UNIX_TIMESTAMP()");
        if (count($entries) == 0) {
            return;
        }
        foreach ($entries as $entry) {
            $result = POD::query("UPDATE {$database['prefix']}Entries \n\t\t\t\tSET visibility = 0 \n\t\t\t\tWHERE blogid = {$blogid} AND id = {$entry['id']} AND draft = 0");
            if ($entry['visibility'] == -3) {
                if ($result && setEntryVisibility($entry['id'], 2)) {
                    $updatedEntry = getEntry($blogid, $entry['id']);
                    if (!is_null($updatedEntry)) {
                        fireEvent('UpdatePost', $entry['id'], $updatedEntry);
                        setEntryVisibility($entry['id'], 3);
                    }
                }
            } else {
                if ($result) {
                    setEntryVisibility($entry['id'], abs($entry['visibility']));
                    $updatedEntry = getEntry($blogid, $entry['id']);
                    if (!is_null($updatedEntry)) {
                        fireEvent('UpdatePost', $entry['id'], $updatedEntry);
                    }
                }
            }
        }
        $newClosestTime = POD::queryCell("SELECT min(published)\n\t\t\tFROM {$database['prefix']}Entries\n\t\t\tWHERE blogid = {$blogid} AND draft = 0 AND visibility < 0 AND published > UNIX_TIMESTAMP()");
        if (!empty($newClosestTime)) {
            Setting::setBlogSettingGlobal('closestReservedPostTime', $newClosestTime);
        } else {
            Setting::setBlogSettingGlobal('closestReservedPostTime', INT_MAX);
        }
    }
}
Пример #22
0
 function changeACLofUser($blogid, $userid, $ACLtype, $switch)
 {
     // Change user priviledge on the blog.
     $context = Model_Context::getInstance();
     $pool = DBModel::getInstance();
     if (empty($ACLtype) || empty($userid)) {
         return false;
     }
     $pool->reset("Privileges");
     $pool->setQualifier("blogid", "eq", $blogid);
     $pool->setQualifier("userid", "eq", $userid);
     $acl = $pool->getCell("acl");
     if ($acl === null) {
         // If there is no ACL, add user into the blog.
         $name = User::getName($userid);
         $pool->reset("Privileges");
         $pool->setAttribute("blogid", $blogid);
         $pool->setAttribute("userid", $userid);
         $pool->setAttribute("acl", 0);
         $pool->setAttribute("created", Timestamp::getUNIXtime());
         $pool->setAttribute("lastlogin", 0);
         $pool->insert();
         $acl = 0;
     }
     $bitwise = null;
     switch ($ACLtype) {
         case 'admin':
             $bitwise = BITWISE_ADMINISTRATOR;
             break;
         case 'editor':
             $bitwise = BITWISE_EDITOR;
             break;
         default:
             return false;
     }
     if ($switch) {
         $acl |= $bitwise;
     } else {
         $acl &= ~$bitwise;
     }
     $pool->reset("Privileges");
     $pool->setAttribute("acl", $acl);
     $pool->setQualifier("blogid", "eq", $blogid);
     $pool->setQualifier("userid", "eq", $userid);
     return $pool->update();
 }
Пример #23
0
 public static function query($query, $compatibility = true)
 {
     /// Bypassing compatiblitiy issue : will be replace to NAF2.
     if ($compatibility) {
         $query = str_replace('UNIX_TIMESTAMP()', Timestamp::getUNIXtime(), $query);
         // compatibility issue.
         if (stripos($query, "ORDER BY") !== false) {
             $origPagingInst = array('/(ASC|DESC) LIMIT (\\d+) OFFSET 0/si', '/(ASC|DESC) LIMIT (\\d+) OFFSET (\\d+)/si', '/(ASC|DESC) LIMIT 1(^[0-9])/si', '/(ASC|DESC) LIMIT (\\d+)/si', '/RAND\\(\\) LIMIT (\\d+)/si');
             $descPagingInst = array('$1 FOR ORDERBY_NUM() BETWEEN 1 AND $2', '$1 FOR ORDERBY_NUM() BETWEEN ($3+1) AND ($2+$3)', '$1 FOR ORDERBY_NUM() = 1', '$1 FOR ORDERBY_NUM() BETWEEN 1 AND $2', 'RANDOM() FOR ORDERBY_NUM() BETWEEN 1 AND $1');
         } else {
             if (stripos($query, "GROUP BY") !== false) {
                 $origPagingInst = array('/GROUP BY(.*)(ORDER BY)(.*)(ASC|DESC) LIMIT (\\d+) OFFSET 0/si', '/GROUP BY(.*)(ORDER BY)(.*)(ASC|DESC) LIMIT (\\d+) OFFSET ([0-9]+)/si', '/GROUP BY(.*)(ORDER BY)(.*)(ASC|DESC) LIMIT 1(^[0-9])/si', '/GROUP BY(.*)(ORDER BY)(.*)(ASC|DESC) LIMIT (\\d+)/si', '/GROUP BY(.*)(ORDER BY)(.*)RAND\\(\\) LIMIT (\\d+)/si');
                 $descPagingInst = array('GROUP BY $1 HAVING GROUPBY_NUM() = $5 $2 $3 $4', 'GROUP BY $1 HAVING GROUPBY_NUM() BETWEEN ($6+1) AND $5 $2 $3 $4', 'GROUP BY $1 HAVING GROUPBY_NUM() = 1 $2 $3 $4', 'GROUP BY $1 HAVING GROUPBY_NUM() BETWEEN 1 AND $5 $2 $3 $4', 'GROUP BY $1 HAVING GROUPBY_NUM() BETWEEN 1 AND $4 $2 RANDOM() $3');
             } else {
                 $origPagingInst = array('/WHERE(.*)LIMIT (\\d+) OFFSET 0/si', '/WHERE(.*)LIMIT (\\d+) OFFSET ([0-9]+)/si', '/WHERE(.*)LIMIT 1(^[0-9])/si', '/WHERE(.*)LIMIT (\\d+)/si', '/SUM\\((size|value)\\)/si');
                 $descPagingInst = array('WHERE ROWNUM BETWEEN 1 AND $2 AND $1', 'WHERE ROWNUM BETWEEN ($3+1) AND ($2+$3) AND $1', 'WHERE ROWNUM = 1 AND $1', 'WHERE ROWNUM BETWEEN 1 AND $2 AND $1', 'SUM("$1")');
             }
         }
         $query = preg_replace($origPagingInst, $descPagingInst, $query);
         // CONCAT
         $ppos = -1;
         $length = strlen($query);
         do {
             $pos = strpos($query, '\'', $ppos + 1);
             if ($pos === false) {
                 $pos = strlen($query);
             }
             while (true) {
                 $concat = stripos($query, 'CONCAT', $ppos + 1);
                 if ($concat === false || $concat >= $pos) {
                     break;
                 }
                 $depth = 0;
                 $quote = null;
                 for ($i = $concat + 6; $i < $length; $i++) {
                     if ($quote === null) {
                         if ($query[$i] == '\'' || $query[$i] == '"') {
                             $quote = $query[$i];
                         } elseif ($query[$i] == ',') {
                             $query = substr($query, 0, $i) . ' || ' . substr($query, $i + 1);
                         } elseif ($query[$i] == '(') {
                             $depth++;
                         } elseif ($query[$i] == ')') {
                             if (--$depth == 0) {
                                 break;
                             }
                         }
                     } else {
                         if ($query[$i] == $quote && $query[$i - 1] != '\\') {
                             $quote = null;
                         }
                     }
                 }
                 $query = substr($query, 0, $concat) . substr($query, $concat + 6);
                 $pos = strpos($query, '\'', $ppos + 1);
                 $length = strlen($query);
             }
             $ppos = $pos;
             while ($ppos < $length) {
                 $ppos = strpos($query, '\'', $ppos + 1);
                 if ($query[$ppos - 1] != '\\') {
                     break;
                 }
             }
         } while ($ppos < $length);
     }
     if (function_exists('__tcSqlLogBegin')) {
         __tcSqlLogBegin($query);
         $result = cubrid_execute(self::$dbProperties['handle'], $query);
         __tcSqlLogEnd($result, 0);
     } else {
         $result = cubrid_execute(self::$dbProperties['handle'], $query);
     }
     self::$lastQueryType = strtolower(substr($query, 0, 6));
     if (in_array(self::$lastQueryType, array('insert', 'update', 'delete', 'replac'))) {
         self::commit();
         self::clearCache();
     }
     return $result;
 }
Пример #24
0
function trashRemoteResponsesByIP($blogid, $ip)
{
    $pool = DBModel::getInstance();
    $pool->reset("RemoteResponses");
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("ip", "eq", $ip, true);
    $affectedEntries = $pool->getColumn("entry");
    $pool->reset("RemoteResponses");
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("ip", "eq", $ip, true);
    $pool->setAttribute("isfiltered", Timestamp::getUNIXtime());
    if ($pool->update()) {
        CacheControl::flushDBCache('trackback');
        CacheControl::flushDBCache('remoteResponse');
        foreach ($affectedEntries as $entry) {
            updateRemoteResponsesOfEntry($blogid, $entry);
        }
        return true;
    }
    return false;
}
Пример #25
0
function checkStep($step, $check = true)
{
    global $root, $path;
    $error = 0;
    if ($step == 1) {
        if ($check) {
            return true;
        }
    } else {
        if ($step == 2) {
            if ($check) {
                if (!empty($_POST['mode'])) {
                    switch ($_POST['mode']) {
                        case 'install':
                        case 'setup':
                        case 'uninstall':
                            return true;
                    }
                }
            }
            ?>
  <input type="hidden" name="step" value="2" />
  <input id="setupMode" type="hidden" name="mode" value="" />
  <div id="inner">
    <h2><span class="step"><?php 
            echo _f('%1단계', 2);
            ?>
</span> : <?php 
            echo _t('작업 유형을 선택해 주십시오.');
            ?>
</h2>
    <div style="text-align:center">
      <div style="width:100%; padding:40px 0px 40px 0px">
        <div style="margin:20px;"><input type="button" value="<?php 
            echo _t('새로운 텍스트큐브를 설정합니다');
            ?>
" style="width:100%; height:40px; font-size:14px" onclick="next('install');return false;" /></div>
        <div style="margin:20px;"><input type="button" value="<?php 
            echo _t('텍스트큐브를 다시 설정합니다');
            ?>
" style="width:100%; height:40px; font-size:14px" onclick="next('setup');return false;" /></div>
        <div style="margin:20px;"><input type="button" value="<?php 
            echo _t('텍스트큐브 테이블을 삭제합니다');
            ?>
" style="width:100%; height:40px; font-size:14px" onclick="next('uninstall');return false;" /></div>
      </div>
    </div>
  </div>
<?php 
        } else {
            if ($step == 3) {
                if ($check) {
                    switch ($_POST['mode']) {
                        case 'install':
                        case 'setup':
                            if (!empty($_POST['dbServer']) && !empty($_POST['dbName']) && !empty($_POST['dbUser']) && isset($_POST['dbPassword']) && isset($_POST['dbPrefix'])) {
                                $dbTemp = array('server' => $_POST['dbServer'], 'username' => $_POST['dbUser'], 'password' => $_POST['dbPassword'], 'port' => $_POST['dbPort']);
                                if (!empty($_POST['dbName'])) {
                                    $dbTemp['database'] = $_POST['dbName'];
                                }
                                global $dbms;
                                $dbms = $_POST['dbms'];
                                if (!POD::bind($dbTemp)) {
                                    $error = 1;
                                } else {
                                    if (!empty($_POST['dbPrefix']) && !preg_match('/^[a-zA-Z0-9_]+$/', $_POST['dbPrefix'])) {
                                        $error = 3;
                                    } else {
                                        return true;
                                    }
                                }
                            }
                            break;
                        case 'uninstall':
                            if (!empty($_POST['dbServer']) && !empty($_POST['dbName']) && !empty($_POST['dbUser']) && isset($_POST['dbPassword']) && !empty($_POST['dbPort'])) {
                                $dbTemp = array('server' => $_POST['dbServer'], 'username' => $_POST['dbUser'], 'password' => $_POST['dbPassword'], 'port' => $_POST['dbPort']);
                                if (!empty($_POST['dbName'])) {
                                    $dbTemp['database'] = $_POST['dbName'];
                                }
                                global $dbms;
                                $dbms = $_POST['dbms'];
                                if (!POD::bind($dbTemp)) {
                                    $error = 1;
                                } else {
                                    return true;
                                }
                            }
                            break;
                    }
                }
                ?>
  <input type="hidden" name="step" value="3" />
  <input type="hidden" name="mode" value="<?php 
                echo $_POST['mode'];
                ?>
" />
  <script type="text/javascript">
    //<![CDATA[
     function suggestDefaultPort(db) {
		switch(db) {
			case 'MySQLi':
			default:
				port = 3306;
				break;
			case 'Cubrid':
				port = 30000;
				break;
			case 'PostgreSQL':
				port = 5432;
				break;
			default:
				port = '';
				break;
		}
		document.getElementById('dbPort').value = port;
		document.getElementById('dbms'+db).checked = checked;
		return true;
	 }
    //]]>
  </script>
  <div id="inner">
    <h2><span class="step"><?php 
                echo _f('%1단계', 3);
                ?>
</span> : <?php 
                echo _t('작업 정보를 입력해 주십시오.');
                ?>
</h2>
    <div id="userinput">
    <table class="inputs">
	  <tr>
        <th><?php 
                echo _t('데이터베이스 관리 시스템');
                ?>
 :</th>
        <td>
<?php 
                $dbmsSupport = array();
                if (function_exists('mysqli_connect')) {
                    array_push($dbmsSupport, 'MySQLi');
                }
                if (function_exists('pg_connect')) {
                    array_push($dbmsSupport, 'PostgreSQL');
                }
                if (class_exists('SQLite3')) {
                    array_push($dbmsSupport, 'SQLite3');
                }
                if (function_exists('cubrid_connect')) {
                    array_push($dbmsSupport, 'Cubrid');
                }
                foreach ($dbmsSupport as $dbms) {
                    ?>
	      <input type="radio" id="dbms<?php 
                    echo $dbms;
                    ?>
" name="dbms" value="<?php 
                    echo $dbms;
                    ?>
" <?php 
                    echo isset($_POST['dbms']) && $_POST['dbms'] == $dbms || !isset($_POST['dbms']) && $dbms == $dbmsSupport[0] ? 'checked' : '';
                    ?>
 onclick="suggestDefaultPort('<?php 
                    echo $dbms;
                    ?>
');return false;" /> <?php 
                    echo $dbms;
                }
                ?>
         </td>
      </tr>
	  <tr>
        <th><?php 
                echo _t('데이터베이스 서버');
                ?>
 :</th>
        <td>
          <input type="text" name="dbServer" value="<?php 
                echo isset($_POST['dbServer']) ? $_POST['dbServer'] : 'localhost';
                ?>
" class="input<?php 
                echo $check && (empty($_POST['dbServer']) || $error == 1) ? ' input_error' : '';
                ?>
" />
        </td>
      </tr>
      <tr>
        <th><?php 
                echo _t('데이터베이스 포트');
                ?>
 :</th>
        <td>
          <input type="text" id="dbPort" name="dbPort" value="<?php 
                echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '3306';
                ?>
" class="input<?php 
                echo $check && (empty($_POST['dbPort']) || $error == 1) ? ' input_error' : '';
                ?>
" />
        </td>
      </tr>
	  <tr>
        <th><?php 
                echo _t('데이터베이스 이름');
                ?>
 :</th>
        <td>
          <input type="text" name="dbName" value="<?php 
                echo isset($_POST['dbName']) ? $_POST['dbName'] : NULL;
                ?>
" class="input<?php 
                echo $check && (empty($_POST['dbName']) || $error == 2) ? ' input_error' : '';
                ?>
" />
        </td>
      </tr>
      <tr>
        <th><?php 
                echo _t('데이터베이스 사용자명');
                ?>
 :</th>
        <td>
          <input type="text" name="dbUser" value="<?php 
                echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                ?>
" class="input<?php 
                echo $check && (empty($_POST['dbUser']) || $error) ? ' input_error' : '';
                ?>
" />
        </td>
      </tr>
      <tr>
        <th><?php 
                echo _t('데이터베이스 암호');
                ?>
 :</th>
        <td>
          <input type="password" name="dbPassword" value="<?php 
                echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                ?>
" class="input<?php 
                echo $check && $error == 1 ? ' input_error' : '';
                ?>
" />
        </td>
      </tr>
<?php 
                switch ($_POST['mode']) {
                    case 'install':
                    case 'setup':
                        ?>
      <tr>
        <th><?php 
                        echo _t('테이블 식별자');
                        ?>
 :</th>
        <td>
          <input type="text" name="dbPrefix" value="<?php 
                        echo isset($_POST['dbPrefix']) ? $_POST['dbPrefix'] : 'tc_';
                        ?>
" class="input <?php 
                        echo $check && $error == 3 ? ' input_error' : '';
                        ?>
" />
        </td>
      </tr>
<?php 
                        break;
                    case 'uninstall':
                        break;
                }
                ?>
    </table>
    </div>
    <div id="content">
      <ol>
        <li><?php 
                echo _t('데이터베이스가 해당 호스트에 먼저 생성되어 있어야 합니다.');
                ?>
</li>
		<li><?php 
                echo _t('테이블식별자는 텍스트큐브가 사용하는 테이블이름 앞에 붙는 문자열입니다. 데이터 베이스내에 다른 어플리케이션이 사용하는 테이블이 있을 경우 구별하기 위해 사용합니다');
                ?>
 <?php 
                echo _t('테이블식별자를 입력하지 않을 경우 자동으로 tc_ 를 사용합니다.');
                ?>
</li>
      </ol>
    </div>
    <div id="warning"><?php 
                if ($error == 1) {
                    echo _t('데이터베이스 서버에 연결할 수 없습니다. 정보를 다시 입력해 주십시오.');
                } else {
                    if ($error == 2) {
                        echo _t('데이터베이스를 사용할 수가 없습니다. 정보를 다시 입력해 주십시오.');
                    } else {
                        if ($error == 3) {
                            echo _t('테이블 식별자가 올바르지 않습니다. 다시 입력해 주십시오.');
                        } else {
                            if ($error == 6) {
                                echo _t('데이터베이스에 연결할 수 없습니다.');
                            } else {
                                if ($error == 7) {
                                    echo _t('데이터베이스에 접근할 수 없습니다.');
                                } else {
                                    if ($error == 8) {
                                        echo _t('새로운 테이블 식별자가 올바르지 않습니다. 다시 입력해 주십시오.');
                                    } else {
                                        if ($check) {
                                            echo _t('표시된 정보가 부족합니다.');
                                        } else {
                                            echo '&nbsp;';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                ?>
</div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                echo _t('이전');
                ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                echo _t('이전');
                ?>
" /></a>
    <a href="#" onclick="next(); return false;" title="<?php 
                echo _t('다음');
                ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                echo _t('다음');
                ?>
" /></a>
  </div>
  </div>
<?php 
            } else {
                if ($step == 4 || $step == 33) {
                    if ($check) {
                        if ($_POST['mode'] == 'uninstall') {
                            if (empty($_POST['target'])) {
                                checkStep(2, false);
                                return false;
                            } else {
                                checkStep(205, false);
                                return false;
                            }
                        }
                        if (!empty($_POST['checked']) && $_POST['checked'] == 'yes') {
                            return true;
                        }
                    }
                    if ($_POST['mode'] == 'uninstall') {
                        return checkStep(204, false);
                    }
                    ?>
  <input type="hidden" name="step" value="4" />
  <input type="hidden" name="mode" value="<?php 
                    echo $_POST['mode'];
                    ?>
" />
  <input type="hidden" name="dbms" value="<?php 
                    echo isset($_POST['dbms']) ? $_POST['dbms'] : '';
                    ?>
" />
  <input type="hidden" name="dbServer" value="<?php 
                    echo isset($_POST['dbServer']) ? $_POST['dbServer'] : '';
                    ?>
" />
  <input type="hidden" name="dbName" value="<?php 
                    echo isset($_POST['dbName']) ? $_POST['dbName'] : '';
                    ?>
" />
  <input type="hidden" name="dbPort" value="<?php 
                    echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '';
                    ?>
" />
  <input type="hidden" name="dbUser" value="<?php 
                    echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                    ?>
" />
  <input type="hidden" name="dbPassword" value="<?php 
                    echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                    ?>
" />
  <input type="hidden" name="dbPrefix" value="<?php 
                    echo isset($_POST['dbPrefix']) ? $_POST['dbPrefix'] : '';
                    ?>
" />
  <input type="hidden" name="disableRewrite" value="<?php 
                    echo isset($_POST['disableRewrite']) ? $_POST['disableRewrite'] : '';
                    ?>
" />
  <div id="inner">
    <h2><span class="step"><?php 
                    echo _f('%1단계', 4);
                    ?>
</span> : <?php 
                    echo _t('설치 요구 사항을 확인하고 있습니다.');
                    ?>
 </h2>
    <div id="content-box">
    <h3><?php 
                    echo _t('환경');
                    ?>
</h3>
    <ul>
      <li><?php 
                    echo _t('하드웨어');
                    ?>
: <?php 
                    echo @exec('uname -mp');
                    ?>
</li>
      <li><?php 
                    echo _t('운영체제');
                    ?>
: <?php 
                    echo @exec('uname -sir');
                    ?>
</li>
      <li><?php 
                    echo _t('웹서버');
                    ?>
: <?php 
                    echo $_SERVER['SERVER_SOFTWARE'];
                    ?>
 <?php 
                    echo isset($_SERVER['SERVER_SIGNATURE']) ? $_SERVER['SERVER_SIGNATURE'] : '(no signature)';
                    ?>
</li>
      <li><?php 
                    echo _t('PHP 버전');
                    ?>
: <?php 
                    echo phpversion();
                    ?>
</li>
      <li><?php 
                    echo _t('데이터베이스 종류');
                    ?>
: <?php 
                    echo POD::dbms();
                    ?>
</li>
      <li><?php 
                    echo _f('%1 버전', POD::dbms());
                    ?>
: <?php 
                    echo POD::version();
                    ?>
</li>
    </ul>
    <h3>PHP</h3>
    <ul>
<?php 
                    $functions = "\naddslashes\narray_flip\narray_key_exists\narray_pop\narray_push\narray_shift\narray_slice\nbase64_encode\nceil\ncheckdate\nclosedir\ncopy\ncount\ndechex\ndir\nexplode\nfclose\nfeof\nfgets\nfile_exists\nfile_get_contents\nfilesize\nfopen\nfputs\nfread\nfsockopen\nfunction_exists\nfwrite\nget_magic_quotes_gpc\ngetimagesize\ngmdate\ngmmktime\ngmstrftime\nheader\nhtml_entity_decode\nhtmlspecialchars\nimplode\nini_set\nintval\nis_dir\nis_file\nis_null\nis_numeric\nis_writable\nksort\nltrim\nmax\nmd5\nmicrotime\nmin\nmkdir\nmktime\nmove_uploaded_file\nnl2br\nnumber_format\nob_end_clean\nob_get_contents\nob_start\nopendir\nord\nparse_url\npreg_match\npreg_replace\nrand\nrawurlencode\nreaddir\nrmdir\nrtrim\nsession_cache_expire\nsession_destroy\nsession_id\nsession_name\nsession_set_cookie_params\nsession_set_save_handler\nsession_start\nsetcookie\nsizeof\nsprintf\nstr_replace\nstrftime\nstripslashes\nstrlen\nstrncasecmp\nstrncmp\nstrpos\nstrrev\nstrtolower\nstrval\nsubstr\nsubstr_count\nsubstr_replace\ntime\ntrim\nunlink\nurlencode\nxml_get_error_code\nxml_parse\nxml_parser_create\nxml_parser_free\nxml_parser_set_option\nxml_set_character_data_handler\nxml_set_default_handler\nxml_set_element_handler\nxml_set_object\n";
                    $required = array();
                    foreach (explode("\n", str_replace("\r", '', trim($functions))) as $function) {
                        if (!function_exists($function)) {
                            array_push($required, $function);
                        }
                    }
                    if (version_compare(PHP_VERSION, '5.4.0') === -1 && (!isset($service['forceinstall']) || $service['forceinstall'] == false)) {
                        $error = 4;
                        ?>
                <span style="color:red"><?php 
                        echo _f('PHP 버전이 낮습니다. 설치를 위해서는 최소한 %1 이상의 버전이 필요합니다.', '5.4.0');
                        ?>
</span>
<?php 
                    } else {
                        if (count($required) == 0) {
                            ?>
                  <li>OK</li>
<?php 
                        } else {
                            $error = 4;
                            ?>
                <span style="color:red"><?php 
                            echo _t('함수가 설치되어야 합니다.');
                            ?>
</span>
<?php 
                            foreach ($required as $function) {
                                ?>
                  <li style="color:red"><?php 
                                echo $function;
                                ?>
</li>
<?php 
                            }
                        }
                    }
                    ?>
    </ul>
    <h3><?php 
                    echo POD::dbms();
                    ?>
</h3>
    <ul>
<?php 
                    if (POD::charset() == 'utf8') {
                        echo '<li>Character Set: OK</li>';
                    } else {
                        echo '<li style="color:navy">Character Set: ', _t('UTF8 미지원 (경고: 한글 지원이 불완전할 수 있습니다.)'), '</li>';
                    }
                    if (POD::query("CREATE TABLE {$_POST['dbPrefix']}Setup (a INT NOT NULL)")) {
                        POD::query("DROP TABLE {$_POST['dbPrefix']}Setup");
                        echo '<li>', _t('테이블 생성 권한'), ': OK</li>';
                    } else {
                        $error = 6;
                        echo '<li style="color:red">', _t('테이블 생성 권한'), ': ', _t('없음'), '</li>';
                    }
                    ?>
    </ul>
<?php 
                    $tables = array();
                    if ($result = POD::tableList()) {
                        foreach ($result as $table) {
                            if (strncmp($table, $_POST['dbPrefix'], strlen($_POST['dbPrefix']))) {
                                continue;
                            }
                            switch (strtolower(substr($table, strlen($_POST['dbPrefix'])))) {
                                case 'attachments':
                                case 'blogsettings':
                                case 'blogstatistics':
                                case 'categories':
                                case 'comments':
                                case 'commentsnotified':
                                case 'commentsnotifiedqueue':
                                case 'commentsnotifiedsiteinfo':
                                case 'dailystatistics':
                                case 'entries':
                                case 'entriesarchive':
                                case 'feedgrouprelations':
                                case 'feedgroups':
                                case 'feeditems':
                                case 'feedreads':
                                case 'feedsettings':
                                case 'feedstarred':
                                case 'feeds':
                                case 'filters':
                                case 'linkcategories':
                                case 'links':
                                case 'openidusers':
                                case 'pagecachelog':
                                case 'plugins':
                                case 'refererlogs':
                                case 'refererstatistics':
                                case 'reservedwords':
                                case 'servicesetting':
                                case 'sessionvisits':
                                case 'sessions':
                                case 'skinsettings':
                                case 'tagrelations':
                                case 'tags':
                                case 'teamblog':
                                case 'trackbacklogs':
                                case 'trackbacks':
                                case 'usersettings':
                                case 'users':
                                case 'xmlrpcpingsettings':
                                    $tables[count($tables)] = $table;
                                    break;
                            }
                        }
                    }
                    switch ($_POST['mode']) {
                        case 'install':
                            echo '<h3>', _t('새 데이터베이스 테이블'), '</h3>';
                            if (count($tables) == 0) {
                                echo '<ul><li>OK</li></ul>';
                            } else {
                                $error = 7;
                                echo '<ul style="color:red">', _t('테이블이 이미 존재합니다.');
                                foreach ($tables as $table) {
                                    echo '<li>', $table, '</li>';
                                }
                                echo '</ul>';
                            }
                            break;
                        case 'setup':
                            echo '<h3>', _t('데이터베이스 테이블 확인'), '</h3>';
                            if (count($tables) < 40 && count($tables) > 35 || count($tables) == 35 && !in_array('Filters', $tables)) {
                                echo '<ul><li>OK</li></ul>';
                            } else {
                                $error = 7;
                                echo '<ul style="color:red">', _t('테이블이 존재하지 않습니다.');
                                foreach ($tables as $table) {
                                    echo '<li>', $table, '</li>';
                                }
                                echo '</ul>';
                            }
                    }
                    ?>
    <h3><?php 
                    echo _t('파일 시스템 권한');
                    ?>
</h3>
    <ul>
<?php 
                    $commands = array();
                    $filename = $root . '/.htaccess';
                    if (file_exists($filename)) {
                        if (is_writable($filename)) {
                            if (filesize($filename)) {
                                echo '<li style="color:navy">', _f('설정 파일: OK (경고: "%1" 파일을 덮어 쓰게 됩니다.)', $filename), '</li>';
                            } else {
                                echo '<li>', _t('웹 설정 파일'), ': OK</li>';
                            }
                        } else {
                            $error = 8;
                            echo '<li style="color:red">', _t('웹 설정 파일'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0666'), '</li>';
                            array_push($commands, 'chmod 0666 ' . $filename);
                        }
                    } else {
                        if (is_writable($root)) {
                            echo '<li>', _t('웹 설정 파일'), ': OK</li>';
                        } else {
                            $error = 9;
                            echo '<li style="color:red">', _t('웹 설정 파일'), ': ', _f('"%1"에 %2 파일을 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, '.htaccess', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $root);
                        }
                    }
                    $filename = $root . '/config.php';
                    if (file_exists($filename)) {
                        if (is_writable($filename)) {
                            if (filesize($filename)) {
                                echo '<li style="color:navy">', _f('설정 파일: OK (경고: "%1" 파일을 덮어 쓰게 됩니다.)', $filename), '</li>';
                            } else {
                                echo '<li>', _t('설정 파일'), ': OK</li>';
                            }
                        } else {
                            $error = 10;
                            echo '<li style="color:red">', _t('설정 파일'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0666'), '</li>';
                            array_push($commands, 'chmod 0666 ' . $filename);
                        }
                    } else {
                        if (is_writable($root)) {
                            echo '<li>', _t('설정 파일'), ': OK</li>';
                        } else {
                            $error = 11;
                            echo '<li style="color:red">', _t('설정 파일'), ': ', _f('"%1"에 %2 파일을 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, 'config.php', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $root);
                        }
                    }
                    $filename = $root . '/user';
                    if (file_exists($filename)) {
                        if (is_dir($filename) && is_writable($filename)) {
                            echo '<li>', _t('사용자 데이터 디렉토리'), ': OK</li>';
                        } else {
                            $error = 12;
                            echo '<li style="color:red">', _t('사용자 데이터 디렉토리'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $filename);
                        }
                    } else {
                        if (mkdir($filename)) {
                            @chmod($filename, 0777);
                            echo '<li>', _t('사용자 데이터 디렉토리'), ': OK</li>';
                        } else {
                            $error = 13;
                            echo '<li style="color:red">', _t('사용자 데이터 디렉토리'), ': ', _f('"%1"에 %2 디렉토리를 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, 'user', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $root);
                        }
                    }
                    $filename = $root . '/user/attach';
                    if (file_exists($filename)) {
                        if (is_dir($filename) && is_writable($filename)) {
                            echo '<li>', _t('첨부 디렉토리'), ': OK</li>';
                        } else {
                            $error = 12;
                            echo '<li style="color:red">', _t('첨부 디렉토리'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $filename);
                        }
                    } else {
                        if (mkdir($filename)) {
                            @chmod($filename, 0777);
                            echo '<li>', _t('첨부 디렉토리'), ': OK</li>';
                        } else {
                            $error = 13;
                            echo '<li style="color:red">', _t('첨부 디렉토리'), ': ', _f('"%1"에 %2 디렉토리를 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, 'attach', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $root);
                        }
                    }
                    $filename = $root . '/user/cache';
                    if (is_dir($filename)) {
                        if (is_writable($filename)) {
                            echo '<li>', _t('캐시 디렉토리'), ': OK</li>';
                        } else {
                            $error = 12;
                            echo '<li style="color:red">', _t('캐시 디렉토리'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $filename);
                        }
                    } else {
                        if (mkdir($filename)) {
                            @chmod($filename, 0777);
                            echo '<li>', _t('캐시 디렉토리'), ': OK</li>';
                        } else {
                            $error = 13;
                            echo '<li style="color:red">', _t('캐시 디렉토리'), ': ', _f('"%1"에 %2 디렉토리를 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, 'cache', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $root);
                        }
                    }
                    /*        $filename = $root . '/remote';
                            if (is_dir($filename)) {
                                if (is_writable($filename))
                                   echo '<li>', _t('원격 설치 디렉토리'), ': OK</li>';
                                else {
                                    $error = 12;
                                   echo '<li style="color:red">', _t('원격 설치 디렉토리'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0777'), '</li>';
                                }
                            } else if (mkdir($filename)) {
                    			@chmod($filename, 0777);
                               echo '<li>', _t('원격 설치 디렉토리'), ': OK</li>';
                            } else {
                                $error = 13;
                               echo '<li style="color:red">', _t('원격 설치 디렉토리'), ': ', _f('"%1"에 %2 디렉토리를 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', $root, 'cache', '0777'), '</li>';
                            }*/
                    $filename = $root . '/user/skin/blog/customize';
                    if (is_dir($filename)) {
                        if (is_writable($filename)) {
                            echo '<li>', _t('스킨 디렉토리'), ': OK</li>';
                        } else {
                            $error = 14;
                            echo '<li style="color:red">', _t('스킨 디렉토리'), ': ', _f('"%1"에 접근할 수 없습니다. 퍼미션을 %2(으)로 수정해 주십시오.', $filename, '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . $filename);
                        }
                    } else {
                        if (mkdir($filename)) {
                            @chmod($filename, 0777);
                            echo '<li>', _t('스킨 디렉토리'), ': OK</li>';
                        } else {
                            $error = 15;
                            echo '<li style="color:red">', _t('스킨 디렉토리'), ': ', _f('"%1"에 %2 디렉토리를 생성할 수 없습니다. "%1"의 퍼미션을 %3(으)로 수정해 주십시오.', "{$root}/user/skin/blog", 'customize', '0777'), '</li>';
                            array_push($commands, 'chmod 0777 ' . "{$root}/user/skin/blog");
                        }
                    }
                    ?>
    </ul>
<?php 
                    if (!empty($commands)) {
                        echo '<span class="instruction">' . _t("퍼미션 수정은 FTP 프로그램을 사용하시거나 다음의 명령을 터미널에 붙여 넣으시면 됩니다.") . "</span>";
                        echo '<ul class="instruction">';
                        $commands = array_unique($commands);
                        foreach ($commands as $command) {
                            echo "<li>" . $command . "</li>";
                        }
                        echo '</ul>';
                    }
                    if ($step == 33) {
                        $error = 16;
                        if (checkIIS()) {
                            ?>
	<h3><?php 
                            echo _t('IIS Rewrite Module');
                            ?>
</h3>
	<ul style="color:red">
		<li><?php 
                            echo _t('현재 IIS에서의 설치는 실험적으로만 지원하고 있으며 별도의 Rewrite 모듈을 사용해야 합니다.') . ' ' . _t('만약 이 페이지를 보고 계시다면 Apache mod_rewrite와 호환되지 않는 Rewrite 모듈을 사용 중이거나 아예 모듈이 없는 경우입니다.');
                            ?>
</li>
		<li><?php 
                            echo _t('IIS 7.0을 사용하시는 경우 공식 URL Rewrite Module을 사용하려면 <a href="http://www.iis.net/extensions/URLRewrite">이곳에서 다운로드</a>받아 설치하시고, 계속 진행·설치 후 생성되는 <b>.htaccess</b> 파일 내용을 그대로 import해주시면 됩니다.');
                            ?>
</li>
		<li><?php 
                            echo _t('IIS 6.0 이전 버전을 사용하시는 경우 Rewrite 모듈을 설치하려면, 오픈스소 무료 모듈을 제공하고 있는 <a href="http://www.codeplex.com/IIRF" target="_blank">Ionics Isapi Rewrite Filter 홈페이지</a>를 방문하여 설치하신 후, 계속 진행·설치 후 생성되는 <b>.htaccess</b> 파일의 내용을 위 모듈의 설정파일(<b>IsapiRewrite4.ini</b>)에 복사하시기 바랍니다.');
                            ?>
</li>
	</ul>
	<p>
		<input type="radio" name="rewriteIIS" value="IISRewrite" id="rewriteIIS_Option1"><label for="rewriteIIS_Option1"><?php 
                            echo _t('IIS 7.0용 공식 URL Rewrite 모듈을 사용합니다.');
                            ?>
</label><br />
		<input type="radio" name="rewriteIIS" value="ISAPI" id="rewriteIIS_Option2"><label for="rewriteIIS_Option2"><?php 
                            echo _t('IIS 6.0 및 그 이전 버전을 위한 오픈소스 Rewrite 모듈을 사용합니다.');
                            ?>
</label>
	</p>
<?php 
                            $error = 0;
                        } else {
                            ?>
    <h3><?php 
                            echo _t('Apache Rewrite Engine');
                            ?>
</h3>
    <ul style="color:red">
      <li><?php 
                            echo _t('Rewrite를 사용할 수 없습니다.');
                            ?>
<br /><span style="color:black"><?php 
                            echo _t('다음 항목을 확인하십시오.');
                            ?>
</span></li>
      <input type="checkbox" id="disableRewrite" name="disableRewrite" />
	  <label for="disableRewrite"><?php 
                            echo _t('rewrite 모듈을 사용하지 않습니다.') . ' ' . _t('만약 rewrite 모듈 설정을 올바르게 했는데도 모듈 사용 여부의 검사에 문제가 있는 경우 rewrite 모듈을 사용하지 않음을 선택하시고 이 부분을 건너 뛰시기 바랍니다.') . ' ' . _t('지금 설정하지 않아도 설치 이후에 관리 패널의 서비스설정-서버 에서 rewrite 관련 설정을 할 수 있습니다.');
                            ?>
</label>
      <ol style="color:blue">
        <li><?php 
                            echo _t('웹서버 설정에 <b>mod_rewrite</b>의 로딩이 포함되어야 합니다.');
                            ?>
<br />
          <samp><?php 
                            echo _t('예: LoadModule <b>rewrite_module</b> modules/<b>mod_rewrite</b>.so');
                            ?>
</samp>
        </li>
        <li><?php 
                            echo _t('웹서버 설정의 이 디렉토리에 대한 <em>Options</em> 항목에 <b>FollowSymLinks</b>가 포함되거나 <b>All</b>이어야 합니다.');
                            ?>
          <samp><br /><?php 
                            echo _t('예: Options <b>FollowSymLinks</b>');
                            ?>
</samp>
          <samp><br /><?php 
                            echo _t('예: Options <b>All</b>');
                            ?>
</samp>
        </li>
        <li><?php 
                            echo _t('웹서버 설정의 이 디렉토리에 대한 <em>AllowOverride</em> 항목에 <b>FileInfo</b>가 포함되거나 <b>All</b>이어야 합니다.');
                            ?>
          <samp><br /><?php 
                            echo _t('예: AllowOverride <b>FileInfo</b>');
                            ?>
</samp>
          <samp><br /><?php 
                            echo _t('예: AllowOverride <b>All</b>');
                            ?>
</samp>
        </li>
        <li><b><?php 
                            echo _t('위 2와 3의 문제는 아래 내용을 웹서버 설정에 포함시켜 해결할 수 있습니다.');
                            ?>
</b>
          <samp style="color:black"><br />
          &lt;Directory &quot;<?php 
                            echo $root;
                            ?>
&quot;&gt;<br />
          &nbsp;&nbsp;Options FollowSymLinks<br />
          &nbsp;&nbsp;AllowOverride FileInfo<br />
          &lt;/Directory&gt;
          </samp>
        </li>
      </ul>
    </ul>
<?php 
                        }
                    }
                    ?>
  </div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                    echo _t('이전');
                    ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                    echo _t('이전');
                    ?>
" /></a>
    <a href="#" onclick="next(); return false;" title="<?php 
                    echo _t('다음');
                    ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                    echo _t('다음');
                    ?>
" /></a>
  </div>
  </div>
  <input type="hidden" name="checked" value="<?php 
                    echo $error > 0 ? 'no' : 'yes';
                    ?>
" />
<?php 
                } else {
                    if ($step == 5) {
                        if ($check) {
                            if (!empty($_POST['domain']) && !empty($_POST['type'])) {
                                return true;
                            }
                        }
                        // mod_rewrite routine.
                        if (empty($_POST['disableRewrite']) && empty($_POST['rewriteIIS'])) {
                            $filename = $root . '/.htaccess';
                            $fp = fopen($filename, 'w+');
                            if (!$fp) {
                                checkStep($step - 1, false);
                                return false;
                            }
                            fwrite($fp, "RewriteEngine On\nRewriteBase {$path}/\nRewriteRule ^testrewrite\$ setup.php [L]");
                            fclose($fp);
                            @chmod($filename, 0666);
                            if (testMyself('blog' . substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')), $path . '/testrewrite?test=now', $_SERVER['SERVER_PORT'])) {
                                $rewrite = 3;
                            } else {
                                if (testMyself('blog.' . $_SERVER['HTTP_HOST'], $path . '/testrewrite?test=now', $_SERVER['SERVER_PORT'])) {
                                    $rewrite = 2;
                                } else {
                                    if (testMyself($_SERVER['HTTP_HOST'], $path . '/testrewrite?test=now', $_SERVER['SERVER_PORT'])) {
                                        $rewrite = 1;
                                    } else {
                                        $rewrite = 0;
                                        @unlink($filename);
                                        checkStep(33, false);
                                        return false;
                                    }
                                }
                            }
                            @unlink($filename);
                        } else {
                            if (!empty($_POST['rewriteIIS'])) {
                                switch ($_POST['rewriteIIS']) {
                                    case 'ISAPI':
                                        $rewrite = -1;
                                        break;
                                    case 'IISRewrite':
                                    default:
                                        $rewrite = -2;
                                }
                            } else {
                                $rewrite = 0;
                            }
                        }
                        $domain = $rewrite == 3 ? substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1) : $_SERVER['HTTP_HOST'];
                        $blogProtocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
                        $blogDefaultPort = isset($_SERVER['HTTPS']) ? 443 : 80;
                        ?>
  <input type="hidden" name="step" value="<?php 
                        echo $step;
                        ?>
" />
  <input type="hidden" name="mode" value="<?php 
                        echo $_POST['mode'];
                        ?>
" />
  <input type="hidden" name="dbms" value="<?php 
                        echo isset($_POST['dbms']) ? $_POST['dbms'] : '';
                        ?>
" />
  <input type="hidden" name="dbServer" value="<?php 
                        echo isset($_POST['dbServer']) ? $_POST['dbServer'] : '';
                        ?>
" />
  <input type="hidden" name="dbPort" value="<?php 
                        echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '';
                        ?>
" />
  <input type="hidden" name="dbName" value="<?php 
                        echo isset($_POST['dbName']) ? $_POST['dbName'] : '';
                        ?>
" />
  <input type="hidden" name="dbUser" value="<?php 
                        echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                        ?>
" />
  <input type="hidden" name="dbPassword" value="<?php 
                        echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                        ?>
" />
  <input type="hidden" name="dbPrefix" value="<?php 
                        echo isset($_POST['dbPrefix']) ? $_POST['dbPrefix'] : '';
                        ?>
" />
  <input type="hidden" name="checked" value="<?php 
                        echo isset($_POST['checked']) ? $_POST['checked'] : '';
                        ?>
" />
  <input type="hidden" name="domain" value="<?php 
                        echo $domain;
                        ?>
" />
  <input type="hidden" name="disableRewrite" value="<?php 
                        echo isset($_POST['disableRewrite']) ? $_POST['disableRewrite'] : '';
                        ?>
" />
  <input type="hidden" name="rewriteMode" value="<?php 
                        echo $rewrite <= -1 ? $_POST['rewriteIIS'] : 'mod_rewrite';
                        ?>
" />
  <div id="inner">
  <h2><span class="step"><?php 
                        echo _f('%1단계', $step);
                        ?>
</span> : <?php 
                        echo _t('사용 가능한 운영 방법은 다음과 같습니다. 선택하여 주십시오.');
                        ?>
</h2>
  <div id="userinput">
    <table class="inputs">
<?php 
                        if ($rewrite != 0) {
                            ?>
      <tr>
        <th width="120"><strong><?php 
                            echo _t('다중 사용자');
                            ?>
 : </strong></th>
        <td>
<?php 
                            if ($rewrite >= 2) {
                                ?>
        <label for="type1"><input type="radio" id="type1" name="type" value="domain" checked="checked" onclick="show('typeDomain');" />
                      <?php 
                                echo _t('도메인네임(DNS)으로 블로그 식별');
                                ?>
</label>
        <br />
<?php 
                            }
                            ?>
        <label for="type2"><input type="radio" id="type2" name="type" value="path"<?php 
                            echo $rewrite == 1 || $rewrite == -1 ? ' checked="checked"' : '';
                            ?>
 onclick="show('typePath');" />
        <?php 
                            echo _t('하위 경로(Path)로 블로그 식별');
                            ?>
</label></td>
      </tr>
<?php 
                        }
                        ?>
      <tr>
        <th style="padding-top:10px"><strong><?php 
                        echo _t('단일 사용자');
                        ?>
 : </strong></th>
        <td style="padding-top:10px">
          <label for="type3"><input type="radio" id="type3" name="type" value="single" onclick="show('typeSingle');" <?php 
                        echo empty($_POST['disableRewrite']) ? '' : 'checked="checked"';
                        ?>
 /><?php 
                        echo _t('단일 블로그');
                        ?>
</label></td>
      </tr>
      <tr>
        <th style="padding-top:20px"><?php 
                        echo _t('블로그 주소 예시');
                        ?>
</th>
        <td style="padding-top:20px; height:100px">
        <ul id="typeDomain"<?php 
                        echo $rewrite >= 2 ? '' : ' style="display:none"';
                        ?>
>
          <li><?php 
                        echo $blogProtocol;
                        ?>
://<b>blog1</b>.<?php 
                        echo $domain;
                        echo $_SERVER['SERVER_PORT'] == $blogDefaultPort ? '' : ":{$_SERVER['SERVER_PORT']}";
                        echo $path;
                        ?>
/</li>
          <li><?php 
                        echo $blogProtocol;
                        ?>
://<b>blog2</b>.<?php 
                        echo $domain;
                        echo $_SERVER['SERVER_PORT'] == $blogDefaultPort ? '' : ":{$_SERVER['SERVER_PORT']}";
                        echo $path;
                        ?>
/</li>
        </ul>
        <ul id="typePath"<?php 
                        echo $rewrite == 1 ? '' : ' style="display:none"';
                        ?>
>
          <li><?php 
                        echo $blogProtocol;
                        ?>
://<?php 
                        echo $domain;
                        echo $_SERVER['SERVER_PORT'] == $blogDefaultPort ? '' : ":{$_SERVER['SERVER_PORT']}";
                        echo $path;
                        ?>
/<b>blog1</b></li>
          <li><?php 
                        echo $blogProtocol;
                        ?>
://<?php 
                        echo $domain;
                        echo $_SERVER['SERVER_PORT'] == $blogDefaultPort ? '' : ":{$_SERVER['SERVER_PORT']}";
                        echo $path;
                        ?>
/<b>blog2</b></li>
        </ul>
        <ul id="typeSingle" <?php 
                        echo empty($_POST['disableRewrite']) ? 'style="display:none"' : '';
                        ?>
>
          <li><?php 
                        echo $blogProtocol;
                        ?>
://<?php 
                        echo $domain;
                        echo $_SERVER['SERVER_PORT'] == $blogDefaultPort ? '' : ":{$_SERVER['SERVER_PORT']}";
                        echo $path;
                        ?>
/<?php 
                        echo empty($_POST['disableRewrite']) ? '' : 'blog/';
                        ?>
</li>
        </ul>
        </td>
      </tr>
    </table>
  </div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                        echo _t('이전');
                        ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                        echo _t('이전');
                        ?>
" /></a>
    <a href="#" onclick="next(); return false;" title="<?php 
                        echo _t('다음');
                        ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                        echo _t('다음');
                        ?>
" /></a>
  </div>
  </div>
<?php 
                    } else {
                        if ($step == 6) {
                            if ($check) {
                                if (!empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['password2']) && ($_POST['type'] == 'single' || !empty($_POST['blog'])) && isset($_POST['name'])) {
                                    if (!preg_match('/^[^@]+@([-a-zA-Z0-9]+\\.)+[-a-zA-Z0-9]+$/', $_POST['email'])) {
                                        $error = 51;
                                    } else {
                                        if ($_POST['password'] != $_POST['password2']) {
                                            $error = 52;
                                        } else {
                                            if ($_POST['type'] != 'single' && !preg_match('/^[a-zA-Z0-9]+$/', $_POST['blog'])) {
                                                $error = 53;
                                            } else {
                                                if (strlen($_POST['password']) < 6 || strlen($_POST['password2']) < 6) {
                                                    $error = 54;
                                                } else {
                                                    return true;
                                                }
                                            }
                                        }
                                    }
                                }
                            } else {
                                @POD::query('SET CHARACTER SET utf8');
                                if ($result = @POD::query("SELECT loginid, password, name FROM {$_POST['dbPrefix']}Users WHERE userid = 1")) {
                                    @(list($_POST['email'], $_POST['password'], $_POST['name']) = POD::fetch($result, 'row'));
                                    $_POST['password2'] = $_POST['password'];
                                    POD::free($result);
                                }
                                if ($result = @POD::queryCell("SELECT value FROM {$_POST['dbPrefix']}BlogSettings\n\t\t\t\t\t\tWHERE blogid = 1\n\t\t\t\t\t\t\tAND name = 'name'")) {
                                    $_POST['blog'] = $result;
                                }
                            }
                            ?>
  <input type="hidden" name="step" value="<?php 
                            echo $step;
                            ?>
" />
  <input type="hidden" name="mode" value="<?php 
                            echo $_POST['mode'];
                            ?>
" />
  <input type="hidden" name="dbms" value="<?php 
                            echo isset($_POST['dbms']) ? $_POST['dbms'] : '';
                            ?>
" />
  <input type="hidden" name="dbServer" value="<?php 
                            echo isset($_POST['dbServer']) ? $_POST['dbServer'] : '';
                            ?>
" />
  <input type="hidden" name="dbPort" value="<?php 
                            echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '';
                            ?>
" />
  <input type="hidden" name="dbName" value="<?php 
                            echo isset($_POST['dbName']) ? $_POST['dbName'] : '';
                            ?>
" />
  <input type="hidden" name="dbUser" value="<?php 
                            echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                            ?>
" />
  <input type="hidden" name="dbPassword" value="<?php 
                            echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                            ?>
" />
  <input type="hidden" name="dbPrefix" value="<?php 
                            echo isset($_POST['dbPrefix']) ? $_POST['dbPrefix'] : '';
                            ?>
" />
  <input type="hidden" name="checked" value="<?php 
                            echo isset($_POST['checked']) ? $_POST['checked'] : '';
                            ?>
" />
  <input type="hidden" name="domain" value="<?php 
                            echo isset($_POST['domain']) ? $_POST['domain'] : '';
                            ?>
" />
  <input type="hidden" name="disableRewrite" value="<?php 
                            echo isset($_POST['disableRewrite']) ? $_POST['disableRewrite'] : '';
                            ?>
" />
  <input type="hidden" name="rewriteMode" value="<?php 
                            echo isset($_POST['rewriteMode']) ? $_POST['rewriteMode'] : '';
                            ?>
" />
  <input type="hidden" name="type" value="<?php 
                            echo isset($_POST['type']) ? $_POST['type'] : '';
                            ?>
" />
  <div id="inner">
    <h2><span class="step"><?php 
                            echo _f('%1단계', $step);
                            ?>
</span> : <?php 
                            echo _t('관리자 정보 입력');
                            ?>
</h2>
    <div id="userinput">
      <table class="inputs">
        <tr>
          <th style="width:100px"><?php 
                            echo _t('이메일');
                            ?>
 : </th>
          <td>
            <input type="text" id="email" name="email" value="<?php 
                            echo isset($_POST['email']) ? htmlspecialchars($_POST['email']) : '';
                            ?>
" class="input_email"<?php 
                            echo $check && (empty($_POST['email']) || $error == 51) ? ' style="border-color:red"' : '';
                            ?>
 />
          </td>
        </tr>
        <tr>
          <th><?php 
                            echo _t('비밀번호');
                            ?>
 : </th>
          <td>
            <input type="password" name="password" value="<?php 
                            echo isset($_POST['password']) ? htmlspecialchars($_POST['password']) : '';
                            ?>
" class="input_password"<?php 
                            echo $check && empty($_POST['password']) ? ' style="border-color:red"' : '';
                            ?>
 /><br />
			<em class="password"><?php 
                            echo _t('비밀번호는 최소 6자 이상이어야 합니다.');
                            ?>
</em>
          </td>
        </tr>
        <tr>
          <th><?php 
                            echo _t('비밀번호 확인');
                            ?>
 : </th>
          <td>
            <input type="password" name="password2" value="<?php 
                            echo isset($_POST['password2']) ? htmlspecialchars($_POST['password2']) : '';
                            ?>
" class="input_password"<?php 
                            echo $check && empty($_POST['password2']) ? ' style="border-color:red"' : '';
                            ?>
 />
          </td>
        </tr>
        <tr>
          <th><?php 
                            echo _t('블로그 식별자');
                            ?>
 : </th>
          <td>
            <input type="text" name="blog" value="<?php 
                            echo isset($_POST['blog']) ? htmlspecialchars($_POST['blog']) : '';
                            ?>
" class="input_password"<?php 
                            echo $check && (empty($_POST['blog']) || $error == 53) ? ' style="border-color:red"' : '';
                            ?>
 />
          </td>
        </tr>
        <tr>
          <th><?php 
                            echo _t('필명');
                            ?>
 : </th>
          <td>
            <input type="text" name="name" value="<?php 
                            echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
                            ?>
" class="input_password" />
          </td>
        </tr>
      </table>
      <div id="warning"><?php 
                            if ($error == 51) {
                                echo _t('이메일이 올바르지 않습니다.');
                            } else {
                                if ($error == 52) {
                                    echo _t('비밀번호가 일치하지 않습니다.');
                                } else {
                                    if ($error == 53) {
                                        echo _t('블로그 식별자가 올바르지 않습니다.');
                                    } else {
                                        if ($error == 54) {
                                            echo _t('비밀번호는 최소 6자 이상이어야 합니다.');
                                        } else {
                                            if ($check) {
                                                echo _t('표시된 정보가 부족합니다.');
                                            } else {
                                                echo '&nbsp;';
                                            }
                                        }
                                    }
                                }
                            }
                            ?>
</div>
    </div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                            echo _t('이전');
                            ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                            echo _t('이전');
                            ?>
" /></a>
    <a href="#" onclick="next(); return false;" title="<?php 
                            echo _t('다음');
                            ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                            echo _t('다음');
                            ?>
" /></a>
  </div>
  </div>
  <script type="text/javascript">
    //<![CDATA[
      document.getElementById('email').focus();
    //]]>
  </script>
<?php 
                        } else {
                            if ($step == 7) {
                                if ($check) {
                                    return true;
                                }
                                ?>
  <input type="hidden" name="step" value="<?php 
                                echo $step;
                                ?>
" />
  <input type="hidden" name="mode" value="<?php 
                                echo $_POST['mode'];
                                ?>
" />
  <input type="hidden" name="dbms" value="<?php 
                                echo isset($_POST['dbms']) ? $_POST['dbms'] : '';
                                ?>
" />
  <input type="hidden" name="dbServer" value="<?php 
                                echo isset($_POST['dbServer']) ? $_POST['dbServer'] : '';
                                ?>
" />
  <input type="hidden" name="dbPort" value="<?php 
                                echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '';
                                ?>
" />
  <input type="hidden" name="dbName" value="<?php 
                                echo isset($_POST['dbName']) ? $_POST['dbName'] : '';
                                ?>
" />
  <input type="hidden" name="dbUser" value="<?php 
                                echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                                ?>
" />
  <input type="hidden" name="dbPassword" value="<?php 
                                echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                                ?>
" />
  <input type="hidden" name="dbPrefix" value="<?php 
                                echo isset($_POST['dbPrefix']) ? $_POST['dbPrefix'] : '';
                                ?>
" />
  <input type="hidden" name="checked" value="<?php 
                                echo isset($_POST['checked']) ? $_POST['checked'] : '';
                                ?>
" />
  <input type="hidden" name="domain" value="<?php 
                                echo isset($_POST['domain']) ? $_POST['domain'] : '';
                                ?>
" />
  <input type="hidden" name="disableRewrite" value="<?php 
                                echo isset($_POST['disableRewrite']) ? $_POST['disableRewrite'] : false;
                                ?>
" />
  <input type="hidden" name="rewriteMode" value="<?php 
                                echo isset($_POST['rewriteMode']) ? $_POST['rewriteMode'] : '';
                                ?>
" />
  <input type="hidden" name="type" value="<?php 
                                echo isset($_POST['type']) ? $_POST['type'] : '';
                                ?>
" />
  <input type="hidden" name="blog" value="<?php 
                                echo isset($_POST['blog']) ? $_POST['blog'] : '';
                                ?>
" />
  <div id="inner">
    <h2><span class="step"><?php 
                                echo _f('%1단계', $step);
                                ?>
</span> : <?php 
                                echo _t('데이터베이스를 준비하고 있습니다. 잠시만 기다려 주십시오.');
                                ?>
</h2>
    <div id="content-box" style="text-align:center">
	<p></p>
    </div>
  </div><!-- inner -->
  </form>
</div><!-- container -->
<?php 
                                function fail($msg)
                                {
                                    flush();
                                    if ($_POST['mode'] == 'install') {
                                    }
                                    exit;
                                }
                                $loginid = POD::escapeString($_POST['email']);
                                $password = md5($_POST['password']);
                                $name = POD::escapeString($_POST['name']);
                                $blog = POD::escapeString($_POST['blog']);
                                $baseLanguage = POD::escapeString($_POST['Lang']);
                                $baseTimezone = POD::escapeString(substr(_t('default:Asia/Seoul'), 8));
                                if (POD::dbms() == 'MySQLi') {
                                    $charset = 'DEFAULT CHARSET=utf8';
                                    //    	    if (!@POD::query('SET CHARACTER SET utf8'))
                                    //      	    $charset = 'TYPE=MyISAM';
                                    //    @POD::query('SET SESSION collation_connection = \'utf8_general_ci\'');
                                } else {
                                    $charset = '';
                                }
                                if ($_POST['mode'] == 'install') {
                                    $schema = '';
                                    // Compatibility layer load
                                    if (file_exists(ROOT . '/resources/setup/compatibility.' . POD::dbms() . '.sql')) {
                                        $schema = file_get_contents(ROOT . '/resources/setup/compatibility.' . POD::dbms() . '.sql');
                                        $query = explode(';', trim($schema));
                                        foreach ($query as $sub) {
                                            @POD::query($sub);
                                        }
                                        $schema = '';
                                        $query = array();
                                    }
                                    // Loading create schema from sql file. (DBMS specific)
                                    if (POD::dbms() == 'MySQLi') {
                                        $dbSelector = 'MySQL';
                                    } else {
                                        $dbSelector = POD::dbms();
                                    }
                                    $schema .= file_get_contents(ROOT . '/resources/setup/initialize.' . $dbSelector . '.sql');
                                    $schema = str_replace('[##_dbPrefix_##]', $_POST['dbPrefix'], $schema);
                                    $schema = str_replace('[##_charset_##]', $charset, $schema);
                                    $schema .= "\nINSERT INTO {$_POST['dbPrefix']}Users VALUES (1, '{$loginid}', '{$password}', '{$name}', " . Timestamp::getUNIXtime() . ", 0, 0);\nINSERT INTO {$_POST['dbPrefix']}Privileges VALUES (1, 1, 16, " . Timestamp::getUNIXtime() . ", 0);\nINSERT INTO {$_POST['dbPrefix']}ServiceSettings VALUES ('newlineStyle', '1.1');\nINSERT INTO {$_POST['dbPrefix']}ServiceSettings VALUES ('useNewPluginSetting', 1);\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'name', '{$blog}');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'language', '{$baseLanguage}');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'blogLanguage', '{$baseLanguage}');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'timezone', '{$baseTimezone}');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'defaultEditor', 'tinyMCE');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'defaultFormatter', 'ttml');\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'acceptTrackbacks', 1);\nINSERT INTO {$_POST['dbPrefix']}BlogSettings VALUES (1, 'acceptComments', 1);\nINSERT INTO {$_POST['dbPrefix']}Plugins VALUES (1, 'CL_OpenID', null);\nINSERT INTO {$_POST['dbPrefix']}SkinSettings VALUES (1,'skin','periwinkle');\nINSERT INTO {$_POST['dbPrefix']}FeedSettings (blogid) values(1);\nINSERT INTO {$_POST['dbPrefix']}FeedGroups (blogid) values(1);\nINSERT INTO {$_POST['dbPrefix']}Entries (blogid, userid, id, category, visibility, location, title, slogan, contentformatter, contenteditor, starred, acceptcomment, accepttrackback, created, published, modified, content) VALUES (1, 1, 1, 0, 2, '/', '" . POD::escapeString(_t('환영합니다')) . "', 'welcome', 'ttml', 'tinyMCE', 0, 1, 1, " . Timestamp::getUNIXtime() . ", " . Timestamp::getUNIXtime() . "," . Timestamp::getUNIXtime() . ",'" . POD::escapeString(getDefaultPostContent()) . "')";
                                    $query = explode(';', trim($schema));
                                    foreach ($query as $sub) {
                                        if (!empty($sub) && !POD::query($sub, false)) {
                                            $tables = getTables('2.0', $_POST['dbPrefix']);
                                            foreach ($tables as $table) {
                                                if (POD::dbms() == 'Cubrid') {
                                                    @POD::query("DROP " . $table);
                                                } else {
                                                    @POD::query("DROP TABLE " . $table);
                                                }
                                            }
                                            /*		@POD::query(
                                            					"DROP TABLE
                                            						{$_POST['dbPrefix']}Attachments,
                                            						{$_POST['dbPrefix']}BlogSettings,
                                            						{$_POST['dbPrefix']}BlogStatistics,
                                            						{$_POST['dbPrefix']}Categories,
                                            						{$_POST['dbPrefix']}Comments,
                                            						{$_POST['dbPrefix']}CommentsNotified,
                                            						{$_POST['dbPrefix']}CommentsNotifiedQueue,
                                            						{$_POST['dbPrefix']}CommentsNotifiedSiteInfo,
                                            						{$_POST['dbPrefix']}ContentFilters,
                                            						{$_POST['dbPrefix']}DailyStatistics,
                                            						{$_POST['dbPrefix']}Entries,
                                            						{$_POST['dbPrefix']}EntriesArchive,
                                            						{$_POST['dbPrefix']}FeedGroupRelations,
                                            						{$_POST['dbPrefix']}FeedGroups,
                                            						{$_POST['dbPrefix']}FeedItems,
                                            						{$_POST['dbPrefix']}FeedReads,
                                            						{$_POST['dbPrefix']}FeedSettings,
                                            						{$_POST['dbPrefix']}FeedStarred,
                                            						{$_POST['dbPrefix']}Feeds,
                                            						{$_POST['dbPrefix']}Filters,
                                            						{$_POST['dbPrefix']}Links,
                                            						{$_POST['dbPrefix']}LinkCategories,
                                            						{$_POST['dbPrefix']}OpenIDUsers,
                                            						{$_POST['dbPrefix']}PageCacheLog,
                                            						{$_POST['dbPrefix']}Plugins,
                                            						{$_POST['dbPrefix']}Privileges,
                                            						{$_POST['dbPrefix']}RefererLogs,
                                            						{$_POST['dbPrefix']}RefererStatistics,
                                            						{$_POST['dbPrefix']}RemoteResponseLogs,
                                            						{$_POST['dbPrefix']}RemoteResponses,
                                            						{$_POST['dbPrefix']}ReservedWords,
                                            						{$_POST['dbPrefix']}ServiceSettings,
                                            						{$_POST['dbPrefix']}SessionVisits,
                                            						{$_POST['dbPrefix']}Sessions,
                                            						{$_POST['dbPrefix']}SkinSettings,
                                            						{$_POST['dbPrefix']}TagRelations,
                                            						{$_POST['dbPrefix']}Tags,
                                            						{$_POST['dbPrefix']}UserSettings,
                                            						{$_POST['dbPrefix']}Users,
                                            						{$_POST['dbPrefix']}XMLRPCPingSettings"
                                            				);*/
                                            echo '<script type="text/javascript">//<![CDATA[' . CRLF . 'alert("', _t('테이블을 생성하지 못했습니다.'), '")//]]></script>';
                                            $error = 1;
                                            break;
                                        }
                                    }
                                } else {
                                    $ctx = Model_Context::getInstance();
                                    $ctx->setProperty('database.prefix', $_POST['dbPrefix']);
                                    $pool = DBModel::getInstance();
                                    $pool->reset('Users');
                                    $pool->setAttribute('loginid', $loginid, true);
                                    $pool->setAttribute('name', $name, true);
                                    $pool->setQualifier('userid', 'equals', 1);
                                    $pool->update();
                                    $pool->reset('Users');
                                    $pool->setAttribute('password', $password, true);
                                    $pool->setQualifier('userid', 'equals', 1);
                                    $pool->setQualifier('password', 'not', $password2, true);
                                    $pool->update();
                                    $pool->reset('BlogSettings');
                                    $pool->setAttribute('value', $_POST['blog'], true);
                                    $pool->setQualifier('blogid', 'equals', 1);
                                    $pool->setQualifier('name', 'equals', 'name', true);
                                    $pool->update();
                                    $pool->reset('BlogSettings');
                                    $pool->setAttribute('value', $baseLanguage, true);
                                    $pool->setQualifier('blogid', 'equals', 1);
                                    $pool->setQualifier('name', 'equals', 'language', true);
                                    $pool->update();
                                    $pool->reset('BlogSettings');
                                    $pool->setAttribute('value', $baseTimezone, true);
                                    $pool->setQualifier('blogid', 'equals', 1);
                                    $pool->setQualifier('name', 'equals', 'timezone', true);
                                    $pool->update();
                                    $pool->reset('BlogSettings');
                                    $pool->setAttribute('value', Timestamp::getUNIXtime());
                                    $pool->setQualifier('blogid', 'equals', 1);
                                    $pool->setQualifier('name', 'equals', 'created', true);
                                    $pool->update();
                                }
                                if (!$error) {
                                    POD::unbind();
                                    echo '<script type="text/javascript">//<![CDATA[' . CRLF . 'next() //]]></script>';
                                }
                                ?>
</body>
</html>
<?php 
                            } else {
                                if ($step == 8) {
                                    if ($check) {
                                        return true;
                                    }
                                    $useSSL = Utils_Misc::isSecureProtocol() ? 'true' : 'false';
                                    $filename = $root . '/config.php';
                                    $fp = fopen($filename, 'w+');
                                    // For first entry addition
                                    $database = array('server' => $_POST['dbServer'], 'database' => $_POST['dbName'], 'username' => $_POST['dbUser'], 'port' => $_POST['dbPort'], 'password' => $_POST['dbPassword'], 'prefix' => $_POST['dbPrefix']);
                                    if ($fp) {
                                        fwrite($fp, "<?php\nini_set('display_errors', 'off');\n\$database['server'] = '{$_POST['dbServer']}';\n\$database['dbms'] = '{$_POST['dbms']}';\n\$database['database'] = '{$_POST['dbName']}';\n\$database['port'] = '{$_POST['dbPort']}';\n\$database['username'] = '******'dbUser']}';\n\$database['password'] = '******'dbPassword']}';\n\$database['prefix'] = '{$_POST['dbPrefix']}';\n\$service['type'] = '{$_POST['type']}';\n\$service['domain'] = '{$_POST['domain']}';\n\$service['path'] = '{$path}';\n\$service['skin'] = 'periwinkle';\n\$service['favicon_daily_traffic'] = 10; // 10MB\n\$service['useSSL'] = {$useSSL};  // Force SSL protocol (via https)\n//\$serviceURL = 'http://{$_POST['domain']}{$path}' ; // for path of Skin, plugin and etc.\n//\$service['reader'] = true; // Use Textcube reader. You can set it to false if you do not use Textcube reader, and want to decrease DB load.\n//\$service['debugmode'] = true; // uncomment for debugging, e.g. displaying DB Query or Session info\n//\$service['pagecache'] = false; // uncomment if you want to disable page cache feature.\n//\$service['codecache'] = true; // uncomment if you want to enable code cache feature.\n//\$service['debug_session_dump'] = true; // session info debuging.\n//\$service['debug_rewrite_module'] = true; // rewrite handling module debuging.\n//\$service['session_cookie_path'] = \$service['path']; // for avoiding spoiling other textcube's session id sharing root.\n//\$service['allowBlogVisibilitySetting'] = true; // Allow service users to change blog visibility.\n//\$service['externalresources'] = false;  // Loads resources from external storage.\n//\$service['resourcepath'] = 'http://example.com/resource';\t// Specify the full URI of external resource.\n//\$service['autologinTimeout'] = 1209600;\t// Automatic login timeout (sec.)\n//\$service['favicon_daily_traffic'] = 10; // Set favicon traffic limitation. default is 10MB.\n//\$service['skincache'] = true;        // Use skin pre-fetching. Textcube will parse static elements (blog name, title…) only when you change skin. Reduces CPU loads.\n//\$service['cookie_prefix'] = '';        // Service cookie prefix. Default cookie prefix is Textcube_[VERSION_NUMBER].\n//\$database['port'] = 3639;            // Database port number\n//\$database['dbms'] = 'MySQLi';         // DBMS. (MySQL, MySQLi, PostgreSQL, Cubrid.)\n//\$service['memcached'] = true;       // Using memcache to handle session and cache\n//\$memcached['server'] = 'localhost';  // Where memcache server is.\n//\$service['requirelogin'] = false;    // Force log-in process to every blogs. (for private blog service)\n//\$service['jqueryURL'] = '';\t\t// Add URL if you want to use external jquery via CDN. e.g.) Microsoft's CDN: http://ajax.aspnetcdn.com/ajax/jQuery/\n//\$service['lodashURL'] = '';\t\t// Add URL if you want to use external lo-dash via CDN. e.g.) CDNJS' CDN: https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/\n?>");
                                        fclose($fp);
                                        @chmod($filename, 0666);
                                    }
                                    if (!isset($_POST['disableRewrite']) || !$_POST['disableRewrite']) {
                                        $filename = $root . '/.htaccess';
                                        $fp = fopen($filename, 'w+');
                                        switch ($_POST['rewriteMode']) {
                                            case 'ISAPI':
                                                // Users must copy these rules to IsapiRewrite4.ini
                                                $htaccessContent = <<<EOF
RewriteRule ^{$path}/(thumbnail)/([0-9]+/.+)\$ {$path}/cache/\$1/\$2 [L,U]
RewriteRule ^{$path}/attach/([0-9]+/.+)\$ {$path}/user/attach/\$1 [L,U]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^{$path}/user+/+(cache)+/+(.+[^/]).(cache|xml|txt|log)\$ - [NC,F,L,U]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^{$path}/([^?]+[^/])\$ {$path}/\$1/ [L,U]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^\$
RewriteRule ^{$path}/(.*)\$ {$path}/rewrite.php [L,U]
RewriteRule ^{$path}/(.*)\$ {$path}/rewrite.php?%{QUERY_STRING} [L,U]
EOF;
                                                break;
                                            case 'IISRewrite':
                                                // Users must import these rules into URL Rewrite module.
                                                $htaccessContent = <<<EOF
RewriteRule ^{$path}/(thumbnail)/([0-9]+/.+)\$ {$path}/cache/\$1/\$2 [L]
RewriteRule ^{$path}/attach/([0-9]+/.+)\$ {$path}/user/attach/\$1 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^{$path}/user+/+(cache)+/+(.+[^/]).(cache|xml|txt|log)\$ - [NC,F,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^{$path}/([^?]+[^/])\$ {$path}/\$1/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^{$path}/(.*)\$ {$path}/rewrite.php [L,QSA]
EOF;
                                                break;
                                            case 'mod_rewrite':
                                            default:
                                                $htaccessContent = <<<EOF
#<IfModule mod_url.c>
#CheckURL Off
#</IfModule>
#SetEnv PRELOAD_CONFIG 1
RewriteEngine On
RewriteBase {$path}/
RewriteRule ^(thumbnail)/([0-9]+/.+)\$ cache/\$1/\$2 [L]
RewriteRule ^attach/([0-9]+/.+)\$ user/attach/\$1 [L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^user+/+(cache)+/+(.+[^/]).(cache|xml|txt|log)\$ - [NC,F,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])\$ \$1/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\$ rewrite.php [L,QSA]
EOF;
                                        }
                                        if ($fp) {
                                            fwrite($fp, $htaccessContent);
                                            fclose($fp);
                                            @chmod($filename, 0666);
                                        }
                                    }
                                    $blogProtocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
                                    $blogDefaultPort = isset($_SERVER['HTTPS']) ? 443 : 80;
                                    switch ($_POST['type']) {
                                        case 'domain':
                                            $blogURL = "{$blogProtocol}://{$_POST['blog']}.{$_POST['domain']}" . ($_SERVER['SERVER_PORT'] != $blogDefaultPort ? ":{$_SERVER['SERVER_PORT']}" : '') . "{$path}" . (empty($_POST['disableRewrite']) ? '' : '/index.php?');
                                            break;
                                        case 'path':
                                            $blogURL = "{$blogProtocol}://{$_POST['domain']}" . ($_SERVER['SERVER_PORT'] != $blogDefaultPort ? ":{$_SERVER['SERVER_PORT']}" : '') . "{$path}" . (empty($_POST['disableRewrite']) ? '' : '/index.php?') . "/{$_POST['blog']}";
                                            break;
                                        case 'single':
                                            $blogURL = "{$blogProtocol}://{$_POST['domain']}" . ($_SERVER['SERVER_PORT'] != $blogDefaultPort ? ":{$_SERVER['SERVER_PORT']}" : '') . "{$path}" . (empty($_POST['disableRewrite']) ? '' : '/index.php?');
                                            break;
                                    }
                                    ?>
  <div id="inner">
    <h2><span class="step"><?php 
                                    echo _t('설치완료');
                                    ?>
</span> : <?php 
                                    echo _t('텍스트큐브가 성공적으로 설치되었습니다.');
                                    ?>
</h2>
    <div id="content-box">
      <p>
      </p>
      <ul>
        <li><?php 
                                    echo _t('텍스트큐브 주소');
                                    ?>
<br />
          <a href="<?php 
                                    echo $blogURL . '/';
                                    ?>
"><?php 
                                    echo $blogURL . '/';
                                    ?>
</a><br />
          <br />
        </li>
        <li><?php 
                                    echo _t('텍스트큐브 관리 툴 주소');
                                    ?>
<br />
          <a href="<?php 
                                    echo $blogURL . '/';
                                    ?>
owner"><?php 
                                    echo $blogURL . '/';
                                    ?>
owner</a></li>
      </ul>
      <p>
		<?php 
                                    if (checkIIS()) {
                                        echo _t('새로 IIS용 Rewrite 모듈을 설치하셨다면 <b>.htaccess 내용을 모듈 설정에 적용</b>해주십시오.<br />');
                                    }
                                    ?>
		<?php 
                                    echo '<li style="color:red">', _t('보안 관련 안내'), ': ', '<br /><span class="instruction">', _t('보안을 위하여 설치때 필요했던 권한 중 일부를 제거해주세요. FTP 프로그램으로 권한을 수정하시거나 다음의 명령을 터미널에 붙여 넣으시면 됩니다'), '<br />', 'chmod 0755 ' . $root, '</span></li>';
                                    ?>
        <?php 
                                    echo _t('텍스트큐브 관리 툴로 로그인 하신 후 필요사항을 수정해 주십시오.');
                                    ?>
<br />
        <?php 
                                    echo _t('텍스트큐브를 이용해 주셔서 감사합니다.');
                                    ?>
      </p>
    </div>
  </div>
<?php 
                                } else {
                                    if ($step == 204) {
                                        ?>
  <input type="hidden" name="step" value="4" />
  <input type="hidden" name="mode" value="<?php 
                                        echo $_POST['mode'];
                                        ?>
" />
  <input type="hidden" name="dbms" value="<?php 
                                        echo isset($_POST['dbms']) ? $_POST['dbms'] : '';
                                        ?>
" />
  <input type="hidden" name="dbServer" value="<?php 
                                        echo isset($_POST['dbServer']) ? $_POST['dbServer'] : '';
                                        ?>
" />
  <input type="hidden" name="dbPort" value="<?php 
                                        echo isset($_POST['dbPort']) ? $_POST['dbPort'] : '';
                                        ?>
" />
  <input type="hidden" name="dbName" value="<?php 
                                        echo isset($_POST['dbName']) ? $_POST['dbName'] : '';
                                        ?>
" />
  <input type="hidden" name="dbUser" value="<?php 
                                        echo isset($_POST['dbUser']) ? $_POST['dbUser'] : '';
                                        ?>
" />
  <input type="hidden" name="dbPassword" value="<?php 
                                        echo isset($_POST['dbPassword']) ? htmlspecialchars($_POST['dbPassword']) : '';
                                        ?>
" />
  <div id="inner">
    <h2><span class="step"><?php 
                                        echo _f('%1단계', 4);
                                        ?>
</span> : <?php 
                                        echo _t('삭제하고자 하는 테이블을 선택하여 주십시오.');
                                        ?>
</h2>
    <div id="userinput">
    <table id="info">
      <tr>
        <th><?php 
                                        echo _t('식별자');
                                        ?>
</th>
        <th><?php 
                                        echo _t('버전');
                                        ?>
</th>
        <th><?php 
                                        echo _t('테이블');
                                        ?>
</th>
 	    <th></th>
     </tr>
<?php 
                                        $tables = array();
                                        $ckeckedString = 'checked ';
                                        if ($result = POD::tableList()) {
                                            foreach ($result as $table) {
                                                //$table = $table[0];
                                                $entriesMatched = preg_match('/Entries$/', $table);
                                                if ($entriesMatched && checkTables('2.0', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                    ?>
      <tr>
        <th><?php 
                                                    echo $prefix;
                                                    ?>
</th>
        <th>2.0</th>
        <td><?php 
                                                    echo implode(', ', getTables('2.0', $prefix));
                                                    ?>
</td>
	    <th><input type="radio" name="target" value="2.0_<?php 
                                                    echo $prefix;
                                                    ?>
" <?php 
                                                    echo $ckeckedString;
                                                    ?>
/></th>
      </tr>
<?php 
                                                    $ckeckedString = '';
                                                } else {
                                                    if ($entriesMatched && checkTables('1.9', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                        ?>
      <tr>
        <th><?php 
                                                        echo $prefix;
                                                        ?>
</th>
        <th>1.9</th>
        <td><?php 
                                                        echo implode(', ', getTables('1.9', $prefix));
                                                        ?>
</td>
	    <th><input type="radio" name="target" value="1.9_<?php 
                                                        echo $prefix;
                                                        ?>
" <?php 
                                                        echo $ckeckedString;
                                                        ?>
/></th>
      </tr>
<?php 
                                                        $ckeckedString = '';
                                                    } else {
                                                        if ($entriesMatched && checkTables('1.8', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                            ?>
      <tr>
        <th><?php 
                                                            echo $prefix;
                                                            ?>
</th>
        <th>1.8</th>
        <td><?php 
                                                            echo implode(', ', getTables('1.8', $prefix));
                                                            ?>
</td>
	    <th><input type="radio" name="target" value="1.8_<?php 
                                                            echo $prefix;
                                                            ?>
" <?php 
                                                            echo $ckeckedString;
                                                            ?>
/></th>
      </tr>
<?php 
                                                            $ckeckedString = '';
                                                        } else {
                                                            if ($entriesMatched && checkTables('1.7', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                ?>
      <tr>
        <th><?php 
                                                                echo $prefix;
                                                                ?>
</th>
        <th>1.7</th>
        <td><?php 
                                                                echo implode(', ', getTables('1.7', $prefix));
                                                                ?>
</td>
	    <th><input type="radio" name="target" value="1.7_<?php 
                                                                echo $prefix;
                                                                ?>
" <?php 
                                                                echo $ckeckedString;
                                                                ?>
/></th>
      </tr>
<?php 
                                                                $ckeckedString = '';
                                                            } else {
                                                                if ($entriesMatched && checkTables('1.6', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                    ?>
      <tr>
        <th><?php 
                                                                    echo $prefix;
                                                                    ?>
</th>
        <th>1.6</th>
        <td><?php 
                                                                    echo implode(', ', getTables('1.6', $prefix));
                                                                    ?>
</td>
	    <th><input type="radio" name="target" value="1.6_<?php 
                                                                    echo $prefix;
                                                                    ?>
" <?php 
                                                                    echo $ckeckedString;
                                                                    ?>
/></th>
      </tr>
<?php 
                                                                    $ckeckedString = '';
                                                                } else {
                                                                    if ($entriesMatched && checkTables('1.5', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                        ?>
      <tr>
        <th><?php 
                                                                        echo $prefix;
                                                                        ?>
</th>
        <th>1.5</th>
        <td><?php 
                                                                        echo implode(', ', getTables('1.5', $prefix));
                                                                        ?>
</td>
	    <th><input type="radio" name="target" value="1.5_<?php 
                                                                        echo $prefix;
                                                                        ?>
" <?php 
                                                                        echo $ckeckedString;
                                                                        ?>
/></th>
      </tr>
<?php 
                                                                        $ckeckedString = '';
                                                                    } else {
                                                                        if ($entriesMatched && checkTables('1.1', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                            ?>
      <tr>
        <th><?php 
                                                                            echo $prefix;
                                                                            ?>
</th>
        <th>1.1</th>
        <td><?php 
                                                                            echo implode(', ', getTables('1.1', $prefix));
                                                                            ?>
</td>
	    <th><input type="radio" name="target" value="1.1_<?php 
                                                                            echo $prefix;
                                                                            ?>
" <?php 
                                                                            echo $ckeckedString;
                                                                            ?>
/></th>
      </tr>
<?php 
                                                                            $ckeckedString = '';
                                                                        } else {
                                                                            if ($entriesMatched && checkTables('1.0.2', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                                ?>
      <tr>
        <th><?php 
                                                                                echo $prefix;
                                                                                ?>
</th>
        <th>1.0.2</th>
        <td><?php 
                                                                                echo implode(', ', getTables('1.0.2', $prefix));
                                                                                ?>
</td>
	    <th><input type="radio" name="target" value="1.0.2_<?php 
                                                                                echo $prefix;
                                                                                ?>
" <?php 
                                                                                echo $ckeckedString;
                                                                                ?>
/></th>
      </tr>
<?php 
                                                                                $ckeckedString = '';
                                                                            } else {
                                                                                if ($entriesMatched && checkTables('1.0.0', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                                    ?>
      <tr>
        <th><?php 
                                                                                    echo $prefix;
                                                                                    ?>
</th>
        <th>1.0.0</th>
        <td><?php 
                                                                                    echo implode(', ', getTables('1.0.0', $prefix));
                                                                                    ?>
</td>
	    <th><input type="radio" name="target" value="1.0.0_<?php 
                                                                                    echo $prefix;
                                                                                    ?>
" <?php 
                                                                                    echo $ckeckedString;
                                                                                    ?>
/></th>
      </tr>
<?php 
                                                                                    $ckeckedString = '';
                                                                                } else {
                                                                                    if ($entriesMatched && checkTables('1.0.b2', $prefix = substr($table, 0, strlen($table) - 7))) {
                                                                                        ?>
      <tr>
        <th><?php 
                                                                                        echo $prefix;
                                                                                        ?>
</th>
        <th>1.0 Beta 2</th>
        <td><?php 
                                                                                        echo implode(', ', getTables('1.0.b2', $prefix));
                                                                                        ?>
</td>
	    <th><input type="radio" name="target" value="1.0.b2_<?php 
                                                                                        echo $prefix;
                                                                                        ?>
" <?php 
                                                                                        echo $ckeckedString;
                                                                                        ?>
/></th>
      </tr>
<?php 
                                                                                        $ckeckedString = '';
                                                                                    } else {
                                                                                        if (preg_match('/^t3_(.*)_10ofmg$/', $table) && checkTables('0.97', $prefix = substr($table, 3, strlen($table) - 10))) {
                                                                                            ?>
      <tr>
        <th><?php 
                                                                                            echo $prefix;
                                                                                            ?>
</th>
        <th>0.97 (Classic)</th>
        <td><?php 
                                                                                            echo implode(', ', getTables('0.97', $prefix));
                                                                                            ?>
</td>
	    <th><input type="radio" name="target" value="0.97_<?php 
                                                                                            echo $prefix;
                                                                                            ?>
" <?php 
                                                                                            echo $ckeckedString;
                                                                                            ?>
/></th>
      </tr>
<?php 
                                                                                            $ckeckedString = '';
                                                                                        } else {
                                                                                            if (preg_match('/^t3_(.*)_ct1$/', $table) && checkTables('0.96', $prefix = substr($table, 3, strlen($table) - 7))) {
                                                                                                ?>
      <tr>
        <th><?php 
                                                                                                echo $prefix;
                                                                                                ?>
</th>
        <th>0.96x</th>
        <td><?php 
                                                                                                echo implode(', ', getTables('0.96', $prefix));
                                                                                                ?>
</td>
	    <th><input type="radio" name="target" value="0.96_<?php 
                                                                                                echo $prefix;
                                                                                                ?>
" <?php 
                                                                                                echo $ckeckedString;
                                                                                                ?>
/></th>
      </tr>
<?php 
                                                                                                $ckeckedString = '';
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        ?>
    </table>
    </div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                                        echo _t('이전');
                                        ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                                        echo _t('이전');
                                        ?>
" /></a>
    <a href="#" onclick="if (confirm('<?php 
                                        echo _t('삭제하시겠습니까?');
                                        ?>
') && confirm('<?php 
                                        echo _t('정말 삭제하시겠습니까?');
                                        ?>
')) next(); return false;" title="<?php 
                                        echo _t('다음');
                                        ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                                        echo _t('다음');
                                        ?>
" /></a>
  </div>
  </div>
<?php 
                                    } else {
                                        if ($step == 205) {
                                            ?>
  <input type="hidden" name="step" value="1" />
  <div id="inner">
    <h2><span class="step"><?php 
                                            echo _f('%1단계', 5);
                                            ?>
</span> : <?php 
                                            echo _t('선택된 테이블을 삭제하고 있습니다.');
                                            ?>
</h2>
    <div id="userinput">
    <table id="info">
      <tr>
        <th><?php 
                                            echo _t('식별자');
                                            ?>
</th>
        <th><?php 
                                            echo _t('버전');
                                            ?>
</th>
        <th><?php 
                                            echo _t('테이블');
                                            ?>
</th>
     </tr>
<?php 
                                            list($version, $prefix) = explode('_', $_POST['target'], 2);
                                            $result = false;
                                            if (checkTables($version, $prefix)) {
                                                ?>
      <tr>
        <th><?php 
                                                echo $prefix;
                                                ?>
</th>
        <th><?php 
                                                echo $version;
                                                ?>
</th>
        <td><?php 
                                                echo implode(', ', getTables($version, $prefix));
                                                ?>
</td>
      </tr>
<?php 
                                                $result = @POD::query('DROP TABLE ' . implode(', ', getTables($version, $prefix)));
                                            }
                                            ?>
    </table>
	<p><?php 
                                            echo $result ? _t('삭제하였습니다.') : '<span style="color:red">' . _t('삭제하지 못했습니다.') . '</span>';
                                            ?>
</p>
    </div>
  <div id="navigation">
    <a href="#" onclick="window.history.back()" title="<?php 
                                            echo _t('이전');
                                            ?>
"><img src="./resources/style/setup/image/icon_prev.gif" width="74" height="24" alt="<?php 
                                            echo _t('이전');
                                            ?>
" /></a>
    <a href="#" onclick="next(); return false;" title="<?php 
                                            echo _t('다음');
                                            ?>
"><img src="./resources/style/setup/image/icon_next.gif" width="74" height="24" alt="<?php 
                                            echo _t('다음');
                                            ?>
" /></a>
  </div>
  </div>
<?php 
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 public static function authorize($blogid, $userid, $expires = null)
 {
     if (is_null(self::$context)) {
         self::initialize();
     }
     $blogid = intval($blogid);
     $userid = intval($userid);
     if (!Validator::isInteger($expires, 0)) {
         return false;
     }
     $session_cookie_path = "/";
     $t = self::$context->getProperty('service.session_cookie_path');
     if (!empty($t)) {
         $session_cookie_path = self::$context->getProperty('service.session_cookie_path');
     }
     if (!is_numeric($userid)) {
         return false;
     }
     $current = Timestamp::getUNIXtime();
     if (is_null($expires)) {
         $expires = $current + self::$context->getProperty('service.timeout');
     }
     if ($userid != SESSION_OPENID_USERID) {
         /* OpenID session : -1 */
         $_SESSION['userid'] = $userid;
         $id = session_id();
         if (self::isGuestOpenIDSession($id)) {
             $result = self::query('execute', "UPDATE " . self::$context->getProperty('database.prefix') . "Sessions " . "SET userid = {$userid} WHERE id = '{$id}'");
             if ($result) {
                 return true;
             }
         }
     }
     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::query('execute', "INSERT INTO " . self::$context->getProperty('database.prefix') . "Sessions\n\t\t\t\t(id, address, userid, created, updated, expires)\n\t\t\t\tVALUES('{$id}', '{$_SERVER['REMOTE_ADDR']}', {$userid}, {$current}, {$current}, {$expires})");
         if ($result) {
             @session_id($id);
             //$service['domain'] = $service['domain'].':8888';
             setcookie(self::getName(), $id, 0, $session_cookie_path, self::$context->getProperty('service.session_cookie_domain'));
             return true;
         }
     }
     return false;
 }
Пример #27
0
function myPlurk_AddPlurkIcon($target, $mother)
{
    global $blogid, $service, $database, $suri, $blogURL, $pluginURL, $configVal;
    requireComponent('Textcube.Function.misc');
    $data = misc::fetchConfigVal($configVal);
    $attachResponses = isset($data['attachResponses']) && $data['attachResponses'] == 1 ? true : false;
    $plurklang = Setting::getBlogSettingGlobal('blogLanguage', '');
    $plurkIcon = "";
    $responsePlurks = "";
    if ($suri['directive'] != "/rss" && $suri['directive'] != "/m" && $suri['directive'] != "/i/entry" && $suri['directive'] != "/atom" && $suri['directive'] != "/sync" && POD::queryCount("SELECT id FROM {$database['prefix']}PlurkEntries WHERE blogid={$blogid} AND id={$mother}") > 0) {
        $plurk_id = intval(POD::queryCell("SELECT plurkid FROM {$database['prefix']}PlurkEntries WHERE blogid={$blogid} AND id={$mother}"));
        $plurkLink = "http://www.plurk.com/p/" . base_convert($plurk_id, 10, 36);
        if (!empty($plurkLink)) {
            $plurkIcon = '<div id="plurkthis"><img src="' . $pluginURL . '/images/plurkicon.png" border="0" width="16" height="16" alt="Plurk This!" />&nbsp;PLURK: <a href="' . $plurkLink . '" target="_blank">' . $plurkLink . '</a></div><br />';
        }
        if (!$attachResponses) {
            return $plurkIcon . $target;
        }
        $cache = new PageCache();
        $cache->name = 'HC_TCPlurkCache';
        if ($cache->load()) {
            $cache->contents = unserialize($cache->contents);
            if (array_key_exists($mother, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 600) {
                return $plurkIcon . $target . $cache->contents[$mother];
            }
        }
        require_once "libs/plurk_api.php";
        $plurk = new plurk_api();
        $plurkNickname = isset($data['plurknickname']) ? $data['plurknickname'] : "";
        $plurkPassword = isset($data['plurkpassword']) ? $data['plurkpassword'] : "";
        $plurk_api = 'iMCH3JDDda7c4bs0qiOchZcxAx7t8PA7';
        if (!$plurk->login($plurk_api, $plurkNickname, $plurkPassword)) {
            return $plurkIcon . $target;
        }
        $responsePlurks = "";
        $response = $plurk->get_responses($plurk_id);
        if ($response->responses_seen > 0) {
            $qualifiers = array("loves", "likes", "shares", "gives", "hates", "wants", "wishes", "needs", "will", "hopes", "asks", "has", "was", "wonders", "feels", "thinks", "says", "is");
            $qualifiers_locale = array('en' => $qualifiers, 'zh-TW' => array("愛", "喜歡", "推", "給", "討厭", "想要", "希望", "需要", "打算", "希望", "問", "已經", "曾經", "好奇", "覺得", "想", "說", "正在"), 'zh-CN' => array("爱", "喜欢", "推", "给", "讨厌", "想要", "希望", "需要", "打算", "希望", "问", "已经", "曾经", "好奇", "觉得", "想", "说", "正在"));
            $lang = "en";
            switch ($plurklang) {
                case "zh-TW":
                case "zh-CN":
                    $lang = $plurklang;
                    break;
                default:
                    $lang = "en";
            }
            $friends = array();
            $nick2displayname = array('nickname' => array(), 'displayname' => array());
            foreach ($response->friends as $friend) {
                $friends[$friend->uid]['display_name'] = $friend->display_name;
                $friends[$friend->uid]['nick_name'] = $friend->nick_name;
                $friends[$friend->uid]['has_profile_image'] = $friend->has_profile_image == 1 ? true : false;
                $friends[$friend->uid]['avatar'] = $friend->avatar == null ? "" : $friend->avatar;
                if (!in_array($friend->nick_name, $nick2displayname['nickname'])) {
                    array_push($nick2displayname['nickname'], $friend->nick_name);
                    array_push($nick2displayname['displayname'], $friend->display_name);
                }
            }
            ob_start();
            echo "<div class=\"plurkResponse\" id=\"plurkResponse_{$mother}\">\n";
            echo "<h3>" . _f("%1 Responses to this Plurk", $response->responses_seen) . "</h3>\n";
            echo "<div class=\"plurkResponseLists\">\n<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">\n";
            foreach ($response->responses as $commentObj) {
                $comment = (array) $commentObj;
                $userIcon = $friends[$comment['user_id']]['has_profile_image'] ? "http://avatars.plurk.com/{$comment['user_id']}-medium{$friends[$comment['user_id']]['avatar']}.gif" : "";
                $display_name = $friends[$comment['user_id']]['display_name'];
                $nick_name = $friends[$comment['user_id']]['nick_name'];
                $qualifier = in_array($comment['qualifier'], $qualifiers) ? $comment['qualifier'] : "";
                $qualifierKey = array_keys($qualifiers, $comment['qualifier']);
                $qualifier_trans = isset($qualifiers_locale[$lang][$qualifierKey[0]]) ? $qualifiers_locale[$lang][$qualifierKey[0]] : '';
                if (preg_match_all('/<a href="http:\\/\\/www.plurk.com\\/(.*?)" class="ex_link">(.*?)<\\/a>/ms', $comment['content'], $matches)) {
                    $mlen = count($matches[1]);
                    for ($i = $mlen - 1; $i >= 0; $i--) {
                        if (in_array($matches[1][$i], $nick2displayname['nickname'])) {
                            $replydisplayname = $nick2displayname['displayname'][array_search($matches[1][$i], $nick2displayname['nickname'])];
                            $comment['content'] = str_replace('<a href="http://www.plurk.com/' . $matches[1][$i] . '" class="ex_link">' . $matches[2][$i] . '</a>', '<a href="http://www.plurk.com/' . $matches[1][$i] . '" class="ex_link">' . $replydisplayname . '</a>', $comment['content']);
                        }
                    }
                }
                echo "<tr><td class=\"user_icon\"><a href=\"http://www.plurk.com/{$nick_name}\" target=\"_blank\"><img src=\"{$userIcon}\" border=\"0\" width=\"45\" height=\"45\" alt=\"{$display_name}\" title=\"{$display_name}\" onerror=\"this.src='{$pluginURL}/images/nonusericon.gif'\" /></a></td>\n";
                echo "<td class=\"plurkcontent\"><a href=\"http://www.plurk.com/{$nick_name}\" target=\"_blank\">{$display_name}</a>&nbsp;\n";
                echo "<span class=\"qualifier_{$qualifier}\">{$qualifier_trans}</span>&nbsp;<span class=\"plurkcomment\">{$comment['content']}</span></td></tr>\n";
            }
            echo "</table>\n</div>\n<p style=\"text-align:right;line-height:1em;\" class=\"plurkResponseMoreButton\">" . _t('MorePlurk...') . "</p>\n";
            echo "</div>\n\n";
            $responsePlurks = ob_get_contents();
            ob_end_clean();
        } else {
            // no response
        }
        $cache->contents[$mother] = $responsePlurks;
        $cache->contents = serialize($cache->contents);
        $cache->dbContents = Timestamp::getUNIXtime();
        $cache->update();
        unset($cache);
    }
    return $plurkIcon . $target . $responsePlurks;
}
Пример #28
0
 public static function query($query, $compatibility = true)
 {
     //		var_dump($query);
     if ($compatibility) {
         $query = str_replace('UNIX_TIMESTAMP()', Timestamp::getUNIXtime(), $query);
         // compatibility issue.
         $query = str_replace('RAND()', 'RANDOM()', $query);
         // compatibility issue.
         $origPagingInst = array('/CHAR_LENGTH(.*) /si', '/IF\\(([A-Za-z0-9]+),([A-Za-z0-9]+),([A-Za-z0-9]+)\\)/si');
         $descPagingInst = array('LENGTH($1) ', 'CASE WHEN $1 THEN $2 ELSE $3 END');
         $query = preg_replace($origPagingInst, $descPagingInst, $query);
     }
     if (function_exists('__tcSqlLogBegin')) {
         __tcSqlLogBegin($query);
         $result = self::$db->query($query);
         __tcSqlLogEnd($result, 0);
     } else {
         $result = self::$db->query($query);
     }
     self::$lastQueryType = strtolower(substr($query, 0, 6));
     if (stristr($query, 'update ') || stristr($query, 'insert ') || stristr($query, 'delete ') || stristr($query, 'replace ')) {
         self::clearCache();
     }
     return $result;
 }
Пример #29
0
 function authenticate($blogid, $loginid, $password, $blogapi = false)
 {
     $session = array();
     Acl::clearAcl();
     $pool = DBModel::getInstance();
     $blogApiPassword = Setting::getBlogSettingGlobal("blogApiPassword", "");
     $pool->reset("Users");
     if (strlen($password) == 32 && preg_match('/[0-9a-f]{32}/i', $password)) {
         // Traditional md5 Raw login. ( with/without auth token)
         $userid = User::getUserIdByEmail($loginid);
         if (!empty($userid) && !is_null($userid)) {
             $pool->reset('UserSettings');
             $pool->setQualifier('userid', 'equals', intval($userid));
             $pool->setQualifier('name', 'equals', 'AuthToken', true);
             $authtoken = $query->getCell('value');
             $pool->reset("Users");
             if (!empty($authtoken) && $authtoken === $password) {
                 // If user requested auth token, use it to confirm.
                 $session['userid'] = $userid;
             } else {
                 // login with md5 hash
                 $pool->setQualifier("password", "eq", md5($password), true);
             }
         } else {
             return false;
         }
     } else {
         if ($blogapi && !empty($blogApiPassword)) {
             // BlogAPI login
             $pool->setQualifierSet(array("password", "eq", md5($password), true), "OR", array($password, "eq", $blogApiPassword, true));
         } else {
             // Normal login
             $pool->setQualifier("password", "eq", md5($password), true);
         }
     }
     if (empty($session)) {
         $pool->setQualifier("loginid", "eq", $loginid, true);
         $session = $pool->getRow("userid, loginid");
     }
     if (empty($session)) {
         /* You should compare return value with '=== false' which checks with variable types*/
         return false;
     }
     $userid = $session['userid'];
     Acl::authorize('textcube', $userid);
     $pool->reset("Users");
     $pool->setAttribute("lastlogin", Timestamp::getUNIXtime());
     $pool->setQualifier("loginid", "eq", $loginid, true);
     $pool->update();
     //		POD::execute("DELETE FROM {$database['prefix']}UserSettings WHERE userid = '$userid' AND name = 'AuthToken' LIMIT 1");
     return $userid;
 }
Пример #30
0
function updateSubscriptionStatistics($target, $mother)
{
    $blogid = getBlogId();
    $period = Timestamp::getDate();
    if (Filter::isFiltered('ip', $_SERVER['REMOTE_ADDR'])) {
        return;
    }
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    $host = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : '';
    $useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    $pool = DBModel::getInstance();
    $pool->reset("SubscriptionLogs");
    $pool->setAttribute("blogid", $blogid);
    $pool->setAttribute("ip", $ip, true);
    $pool->setAttribute("host", $host, true);
    $pool->setAttribute("useragent", $useragent, true);
    $pool->setAttribute("referred", Timestamp::getUNIXtime());
    $pool->insert();
    $pool->reset("SubscriptionLogs");
    $pool->setQualifier("referred", "<", Timestamp::getUNIXtime() - 604800);
    $pool->delete();
    $pool->reset("SubscriptionStatistics");
    $pool->setAttribute("referred", Timestamp::getUNIXtime());
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("ip", "eq", $ip, true);
    $pool->setQualifier("host", "eq", $host, true);
    $pool->setQualifieri("useragent", "eq", $useragent, true);
    if (!$pool->update('count')) {
        $pool->reset("SubscriptionStatistics");
        $pool->setAttribute("blogid", $blogid);
        $pool->setAttribute("ip", $ip, true);
        $pool->setAttribute("host", $host, true);
        $pool->setAttribute("useragent", $useragent, true);
        $pool->setAttribute("subscribed", Timestamp::getUNIXtime());
        $pool->setAttribute("referred", Timestamp::getUNIXtime());
    }
    return $target;
}