Esempio n. 1
0
function CountAndShow($target, $mother)
{
    global $database, $service, $suri, $blogid;
    $now_timestamp = time();
    $output = '';
    if ($suri['directive'] != "/rss" && $suri['directive'] != "/m" && $suri['directive'] != "/i/entry" && $suri['directive'] != "/atom" && $suri['directive'] != "/sync") {
        if (SaveReadToCookie($blogid, $mother)) {
            if (!POD::queryCount("UPDATE {$database['prefix']}EntryReadCount SET readcounts = readcounts + 1, lastaccess = {$now_timestamp} WHERE blogid={$blogid} AND id={$mother}")) {
                POD::query("INSERT INTO {$database['prefix']}EntryReadCount (blogid, id, readcounts, lastaccess) VALUES ({$blogid}, {$mother}, 1, {$now_timestamp})");
            }
        }
        $readcount = POD::queryCell("SELECT readcounts FROM {$database['prefix']}EntryReadCount WHERE blogid={$blogid} AND id={$mother}");
        $output .= "<span class=\"c_cnt\">views: {$readcount} times </span><br />";
    }
    return $output . $target;
}
Esempio n. 2
0
 function doesExist($tag)
 {
     global $database;
     return POD::queryCount("SELECT id FROM {$database['prefix']}Tags WHERE name = '" . $tag . "' LIMIT 1");
 }
Esempio n. 3
0
function deleteRemoteResponseLog($blogid, $id)
{
    global $database;
    $result = POD::queryCount("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = {$blogid} AND id = {$id}");
    return $result == 1 ? true : false;
}
Esempio n. 4
0
function protectEntry($id, $password)
{
    global $database;
    $password = POD::escapeString($password);
    $result = POD::queryCount("UPDATE {$database['prefix']}Entries SET password = '******', modified = UNIX_TIMESTAMP() WHERE blogid = " . getBlogId() . " AND id = {$id} AND visibility = 1");
    if ($result > 0) {
        CacheControl::flushEntry($id);
        CacheControl::flushDBCache('entry');
        CacheControl::flushDBCache('comment');
        CacheControl::flushDBCache('trackback');
        return true;
    } else {
        return false;
    }
}
Esempio n. 5
0
function deleteFeedGroup($blogid, $id)
{
    global $database;
    if ($id == 0) {
        return -1;
    }
    POD::query("UPDATE {$database['prefix']}FeedGroupRelations SET groupid = 0 WHERE blogid = {$blogid} AND groupid = {$id}");
    $result = POD::queryCount("DELETE FROM {$database['prefix']}FeedGroups WHERE id = {$id}");
    if ($result != 1) {
        return 1;
    }
    return 0;
}
 static function updateVisitorStatistics($blogid)
 {
     global $database, $blogURL;
     if (!fireEvent('UpdatingVisitorStatistics', true)) {
         return;
     }
     if (doesHaveOwnership()) {
         return;
     }
     $id = session_id();
     if (POD::queryCount("SELECT blogid FROM {$database['prefix']}SessionVisits WHERE id = '{$id}' AND address = '{$_SERVER['REMOTE_ADDR']}' AND blogid = {$blogid}") > 0) {
         return;
     }
     if (POD::queryCount("INSERT INTO {$database['prefix']}SessionVisits values('{$id}', '{$_SERVER['REMOTE_ADDR']}', {$blogid})") > 0) {
         if (POD::queryCount("UPDATE {$database['prefix']}BlogStatistics SET visits = visits + 1 WHERE blogid = {$blogid}") < 1) {
             POD::execute("INSERT into {$database['prefix']}BlogStatistics values({$blogid}, 1)");
         }
         $period = Timestamp::getDate();
         if (POD::queryCount("UPDATE {$database['prefix']}DailyStatistics SET visits = visits + 1 WHERE blogid = {$blogid} AND datemark = {$period}") < 1) {
             POD::execute("INSERT INTO {$database['prefix']}DailyStatistics VALUES ({$blogid}, {$period}, 1)");
         }
         if (!empty($_SERVER['HTTP_REFERER'])) {
             $referer = parse_url($_SERVER['HTTP_REFERER']);
             if (!empty($referer['host']) && ($referer['host'] != $_SERVER['HTTP_HOST'] || strncmp($referer['path'], $blogURL, strlen($blogURL)) != 0)) {
                 if (Filter::isFiltered('ip', $_SERVER['REMOTE_ADDR']) || Filter::isFiltered('url', $_SERVER['HTTP_REFERER'])) {
                     return;
                 }
                 if (!fireEvent('AddingRefererLog', true, array('host' => $referer['host'], 'url' => $_SERVER['HTTP_REFERER']))) {
                     return;
                 }
                 $host = POD::escapeString(Utils_Unicode::lessenAsEncoding($referer['host'], 64));
                 $url = POD::escapeString(Utils_Unicode::lessenAsEncoding($_SERVER['HTTP_REFERER'], 255));
                 POD::query("INSERT INTO {$database['prefix']}RefererLogs values({$blogid}, '{$host}', '{$url}', UNIX_TIMESTAMP())");
                 //					POD::query("DELETE FROM {$database['prefix']}RefererLogs WHERE referred < UNIX_TIMESTAMP() - 604800");	// Moved to trashVan
                 if (!POD::queryCount("UPDATE {$database['prefix']}RefererStatistics SET count = count + 1 WHERE blogid = {$blogid} AND host = '{$host}' LIMIT 1")) {
                     POD::execute("INSERT into {$database['prefix']}RefererStatistics values({$blogid}, '{$host}', 1)");
                 }
             }
         }
     }
 }
Esempio n. 7
0
 function remove($id = null)
 {
     // attachment & category is own your risk!
     global $database, $gCacheStorage;
     $this->init();
     if (!empty($id)) {
         $this->id = $id;
     }
     // step 0. Get Information
     if (!isset($this->id) || !Validator::number($this->id, 1)) {
         return $this->_error('id');
     }
     if (!($query = $this->_buildQuery())) {
         return false;
     }
     if (!($entry = $query->getRow('category, visibility'))) {
         return $this->_error('id');
     }
     // step 1. Check Syndication
     if ($entry['visibility'] == 3) {
         requireComponent('Eolin.API.Syndication');
         Syndication::leave($this->getLink());
     }
     CacheControl::flushEntry($this->id);
     CacheControl::flushDBCache('entry');
     CacheControl::flushDBCache('comment');
     CacheControl::flushDBCache('trackback');
     $gCacheStorage->purge();
     // step 2. Delete Entry
     $sql = "DELETE FROM " . $database['prefix'] . "Entries WHERE blogid = " . $this->blogid . " AND id = " . $this->id;
     if (POD::queryCount($sql)) {
         // step 3. Delete Comment
         POD::execute("DELETE FROM {$database['prefix']}Comments WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 4. Delete Trackback
         POD::execute("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 5. Delete Trackback Logs
         POD::execute("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = " . $this->blogid . " AND entry = " . $this->id);
         // step 6. update Category
         if (isset($entry['category'])) {
             $target = ($parentCategory = Category::getParent($entry['category'])) ? '(id = ' . $entry['category'] . ' OR id = ' . $parentCategory . ')' : 'id = ' . $entry['category'];
             if (isset($entry['visibility']) && $entry['visibility'] != 1) {
                 POD::query("UPDATE {$database['prefix']}Categories SET entries = entries - 1, entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target);
             } else {
                 POD::query("UPDATE {$database['prefix']}Categories SET entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target);
             }
         }
         // step 7. Delete Attachment
         $attachNames = POD::queryColumn("SELECT name FROM {$database['prefix']}Attachments\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND parent = " . $this->id);
         if (POD::execute("DELETE FROM {$database['prefix']}Attachments WHERE blogid = " . getBlogId() . " AND parent = " . $this->id)) {
             foreach ($attachNames as $attachName) {
                 if (file_exists(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}")) {
                     @unlink(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}");
                 }
             }
         }
         // step 8. Delete Tags
         $this->deleteTags();
         // step 9. Clear RSS
         requireComponent('Textcube.Control.RSS');
         RSS::refresh();
         return true;
     }
     return false;
 }
Esempio n. 8
0
 public function delete($count = null, $option = null)
 {
     if (empty($this->table)) {
         return false;
     }
     if (!is_null($count)) {
         $this->setLimit($count);
     }
     $this->_query = 'DELETE FROM ' . $this->table . $this->_makeWhereClause();
     if ($option == 'count') {
         return POD::queryCount($this->_query);
     }
     if (POD::query($this->_query)) {
         return true;
     }
     return false;
 }
 private static function DBQuery($mode = 'query', $sql)
 {
     switch ($mode) {
         case 'cell':
             return POD::queryCell($sql);
         case 'row':
             return POD::queryRow($sql);
         case 'execute':
             return POD::execute($sql);
         case 'count':
             return POD::queryCount($sql);
         case 'all':
             return POD::queryAll($sql);
         case 'query':
         default:
             return POD::query($sql);
     }
     return null;
 }
Esempio n. 10
0
function addBlog($blogid, $userid, $identify)
{
    global $database, $service;
    if (empty($userid)) {
        $userid = 1;
        // If no userid, choose the service administrator.
    } else {
        if (!POD::queryExistence("SELECT userid\n\t\t\tFROM {$database['prefix']}Users\n\t\t\tWHERE userid = " . $userid)) {
            return 3;
        }
        // 3: No user exists with specific userid
    }
    if (!empty($blogid)) {
        // If blogid,
        if (!POD::queryExistence("SELECT blogid\n\t\t\tFROM {$database['prefix']}BlogSettings\n\t\t\tWHERE blogid = " . $blogid)) {
            return 2;
            // 2: No blog exists with specific blogid
        }
        // Thus, blog and user exists. Now combine both.
        $result = POD::query("INSERT INTO {$database['prefix']}Privileges\n\t\t\t(blogid,userid,acl,created,lastlogin) \n\t\t\tVALUES({$blogid}, {$userid}, 0, UNIX_TIMESTAMP(), 0)");
        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(UTF8::lessenAsEncoding($identify, 32));
        $blogName = $identify;
        $result = POD::queryCount("SELECT * \n\t\t\tFROM {$database['prefix']}ReservedWords\n\t\t\tWHERE word = '{$blogName}'");
        if ($result && $result > 0) {
            return 60;
            // Reserved blog name.
        }
        $result = POD::queryCount("SELECT value \n\t\t\tFROM {$database['prefix']}BlogSettings \n\t\t\tWHERE name = 'name' AND value = '{$blogName}'");
        if ($result && $result > 0) {
            return 61;
            // Same blogname is already exists.
        }
        $blogid = POD::queryCell("SELECT max(blogid)\n\t\t\tFROM {$database['prefix']}BlogSettings") + 1;
        $baseTimezone = POD::escapeString($service['timezone']);
        $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' => $service['language'], 'blogLanguage' => $service['language'], 'timezone' => $baseTimezone);
        $isFalse = false;
        foreach ($basicInformation as $fieldname => $fieldvalue) {
            if (setBlogSettingDefault($fieldname, $fieldvalue, $blogid) === false) {
                $isFalse = true;
            }
        }
        if ($isFalse == true) {
            POD::query("DELETE FROM {$database['prefix']}BlogSettings WHERE blogid = {$blogid}");
            return 12;
        }
        if (!POD::query("INSERT INTO {$database['prefix']}SkinSettings (blogid) VALUES ({$blogid})")) {
            deleteBlog($blogid);
            return 13;
        }
        if (!POD::query("INSERT INTO {$database['prefix']}FeedSettings \n\t\t\t(blogid) VALUES ({$blogid})")) {
            deleteBlog($blogid);
            return 62;
        }
        if (!POD::query("INSERT INTO {$database['prefix']}FeedGroups \n\t\t\t(blogid, id) \n\t\t\tVALUES ({$blogid}, 0)")) {
            deleteBlog($blogid);
            return 62;
        }
        setBlogSetting('defaultEditor', 'modern', $blogid);
        setBlogSetting('defaultFormatter', 'ttml', $blogid);
        //Combine user and blog.
        if (POD::query("INSERT INTO {$database['prefix']}Privileges \n\t\t\t(blogid,userid,acl,created,lastlogin) \n\t\t\tVALUES({$blogid}, {$userid}, 16, UNIX_TIMESTAMP(), 0)")) {
            setDefaultPost($blogid, $userid);
            return true;
        } else {
            return 65;
        }
    }
    //return true; // unreachable code
}
Esempio n. 11
0
 public function delete($count = null, $option = null)
 {
     if (empty($this->table)) {
         return false;
     }
     $this->_called = true;
     if (!is_null($count)) {
         $this->setLimit($count);
     }
     $this->_query = 'DELETE FROM ' . $this->_getTableName() . $this->_makeWhereClause();
     if ($option == 'count') {
         $result = POD::queryCount($this->_query);
         $this->_manage_pool_stack();
         return $result;
     }
     $result = POD::query($this->_query);
     if ($result) {
         $this->_manage_pool_stack();
         return true;
     }
     return false;
 }
Esempio n. 12
0
function updateSubscriptionStatistics($target, $mother)
{
    global $database, $blogURL;
    $blogid = getBlogId();
    $period = Timestamp::getDate();
    requireComponent('Textcube.Data.Filter');
    if (Filter::isFiltered('ip', $_SERVER['REMOTE_ADDR'])) {
        return;
    }
    $ip = POD::escapeString($_SERVER['REMOTE_ADDR']);
    $host = POD::escapeString(isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : '');
    $useragent = POD::escapeString(isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
    POD::query("INSERT INTO {$database['prefix']}SubscriptionLogs values({$blogid}, '{$ip}', '{$host}', '{$useragent}', UNIX_TIMESTAMP())");
    POD::query("DELETE FROM {$database['prefix']}SubscriptionLogs WHERE referred < UNIX_TIMESTAMP() - 604800");
    if (!POD::queryCount("UPDATE {$database['prefix']}SubscriptionStatistics SET referred = UNIX_TIMESTAMP() WHERE blogid = {$blogid} AND ip = '{$ip}' AND host = '{$host}' AND useragent = '{$useragent}'")) {
        POD::query("INSERT INTO {$database['prefix']}SubscriptionStatistics VALUES ({$blogid}, '{$ip}', '{$host}', '{$useragent}', UNIX_TIMESTAMP(),UNIX_TIMESTAMP())");
    }
    return $target;
}
Esempio n. 13
0
function clearPluginTable($name)
{
    global $database;
    $name = POD::escapeString($name);
    $count = POD::queryCount("DELETE FROM {$database['prefix']}{$name} WHERE blogid = " . getBlogId());
    return $count == 1;
}
Esempio n. 14
0
function isLoginId($blogid, $loginid)
{
    global $database;
    $loginid = POD::escapeString($loginid);
    // 팀블로그 :: 팀원 확인
    $result = POD::queryCount("SELECT u.userid \n\t\t\tFROM {$database['prefix']}Users u, \n\t\t\t\t{$database['prefix']}Privileges t \n\t\t\tWHERE t.blogid = {$blogid} \n\t\t\t\tAND u.loginid = '{$loginid}' \n\t\t\t\tAND t.userid = u.userid");
    // End TeamBlog
    if ($result && $result === 1) {
        return true;
    }
    return false;
}
Esempio n. 15
0
if ($service['type'] != "single") {
    ?>
				<th><?php 
    echo _t('바로 가기');
    ?>
</th>
<?php 
}
?>
				</tr>
			</thead>
			<tbody>
<?php 
$row = 25;
$bloglist = POD::queryColumn("SELECT blogid,name FROM `{$database['prefix']}BlogSettings` WHERE name = 'name' ORDER BY blogid ASC LIMIT " . ($page - 1) * $row . " ,{$row}");
$blogcount = POD::queryCount("SELECT blogid FROM `{$database['prefix']}BlogSettings` WHERE name = 'name'");
$pages = (int) (($blogcount - 0.5) / $row) + 1;
if ($pages < $page) {
    printRespond(array('error' => -2, 'result' => $pages));
}
if ($bloglist) {
    $tempString = "";
    foreach ($bloglist as $itemBlogId) {
        $result = POD::queryAll("SELECT * FROM `{$database['prefix']}BlogSettings` WHERE blogid = {$itemBlogId}");
        foreach ($result as $row) {
            $bsetting[$row['name']] = $row['value'];
        }
        $bsetting['owner'] = POD::queryCell("SELECT userid FROM `{$database['prefix']}Privileges` WHERE acl & " . BITWISE_OWNER . " != 0 AND blogid = " . $itemBlogId);
        ?>
				<tr id="table-blog-list_<?php 
        echo $itemBlogId;
Esempio n. 16
0
</th>
						<th><?php 
echo _t('최근 로그인');
?>
</th>
						<th><?php 
echo _t('임시 암호');
?>
</th>
					</tr>
				</thead>
				<tbody>
<?php 
$row = 25;
$userlist = POD::queryAll("SELECT * FROM `{$database['prefix']}Users` WHERE 1 ORDER BY userid LIMIT " . ($page - 1) * $row . ", " . $row);
$usercount = POD::queryCount("SELECT userid FROM `{$database['prefix']}Users` WHERE 1");
$pages = (int) (($usercount - 0.5) / $row) + 1;
if ($userlist) {
    $tempString = "";
    foreach ($userlist as $row) {
        ?>
					<tr id="table-user-list_<?php 
        echo $row['userid'];
        ?>
">
						<td><?php 
        echo $row['userid'];
        ?>
</td>
						<td><a href="<?php 
        echo $context->getProperty('uri.blog');
Esempio n. 17
0
        $correction = '';
        if (!Utils_Unicode::validate($comment['name'])) {
            $correction .= ' name = \'' . POD::escapeString(Utils_Unicode::correct($comment['name'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($comment['homepage'])) {
            $correction .= ' homepage = \'' . POD::escapeString(Utils_Unicode::correct($comment['homepage'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($comment['comment'])) {
            $correction .= ' comment = \'' . POD::escapeString(Utils_Unicode::correct($comment['comment'], '?')) . '\'';
        }
        if (strlen($correction) > 0) {
            POD::query("UPDATE {$database['prefix']}Comments SET {$correction} WHERE blogid = {$blogid} AND id = {$comment['id']}");
            $corrected++;
        }
        if (!is_null($comment['parent']) && $comment['isfiltered'] == 0) {
            $r2 = POD::queryCount("SELECT id FROM {$database['prefix']}Comments WHERE blogid = {$blogid} AND id = {$comment['parent']} AND isfiltered = 0");
            if ($r2 <= 0) {
                trashCommentInOwner($blogid, $comment['id']);
            }
        }
    }
    POD::free($result);
}
if ($result = POD::query("SELECT id, url, site, subject, excerpt FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}")) {
    while ($trackback = POD::fetch($result)) {
        setProgress($item++ / $items * 100, _t('걸린 글 데이터를 교정하고 있습니다.'));
        $correction = '';
        if (!Utils_Unicode::validate($trackback['url'])) {
            $correction .= ' url = \'' . POD::escapeString(Utils_Unicode::correct($trackback['url'], '?')) . '\'';
        }
        if (!Utils_Unicode::validate($trackback['site'])) {
Esempio n. 18
0
function deleteCommentNotifiedInOwner($blogid, $id)
{
    global $database;
    if (!is_numeric($id)) {
        return false;
    }
    fireEvent('DeleteCommentNotified', $id);
    $entryId = POD::queryCell("SELECT entry FROM {$database['prefix']}CommentsNotified WHERE blogid = {$blogid} AND id = {$id}");
    if (POD::queryCount("DELETE FROM {$database['prefix']}CommentsNotified WHERE blogid = {$blogid} AND id = {$id}") == 1) {
        if (POD::query("DELETE FROM {$database['prefix']}CommentsNotified WHERE blogid = {$blogid} AND parent = {$id}")) {
            updateCommentsOfEntry($blogid, $entryId);
            CacheControl::flushCommentNotifyRSS();
            return true;
        }
    }
    return false;
}
Esempio n. 19
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;
}
Esempio n. 20
0
function protectEntry($id, $password)
{
    $ctx = Model_Context::getInstance();
    $password = POD::escapeString($password);
    $result = POD::queryCount("UPDATE " . $ctx->getProperty('database.prefix') . "Entries SET password = '******', modified = UNIX_TIMESTAMP() WHERE blogid = " . getBlogId() . " AND id = {$id} AND visibility = 1");
    if ($result > 0) {
        CacheControl::flushEntry($id);
        CacheControl::flushDBCache('entry');
        CacheControl::flushDBCache('comment');
        CacheControl::flushDBCache('trackback');
        return true;
    } else {
        return false;
    }
}