Exemplo n.º 1
0
function receiveTrackback($blogid, $entry, $title, $url, $excerpt, $site)
{
    global $database, $blog, $defaultURL;
    if (empty($url)) {
        return 5;
    }
    $post = new Post();
    if (!$post->doesAcceptTrackback($entry)) {
        return 3;
    }
    $filtered = 0;
    if (!Filter::isAllowed($url)) {
        if (Filter::isFiltered('ip', $_SERVER['REMOTE_ADDR']) || Filter::isFiltered('url', $url)) {
            $filtered = 1;
        } else {
            if (Filter::isFiltered('content', $excerpt)) {
                $filtered = 1;
            } else {
                if (!fireEvent('AddingTrackback', true, array('entry' => $entry, 'url' => $url, 'site' => $site, 'title' => $title, 'excerpt' => $excerpt))) {
                    $filtered = 1;
                }
            }
        }
    }
    $title = correctTTForXmlText($title);
    $excerpt = correctTTForXmlText($excerpt);
    $url = UTF8::lessenAsEncoding($url);
    $site = UTF8::lessenAsEncoding($site);
    $title = UTF8::lessenAsEncoding($title);
    $excerpt = UTF8::lessenAsEncoding($excerpt);
    $trackback = new Trackback();
    $trackback->entry = $entry;
    $trackback->url = $url;
    $trackback->site = $site;
    $trackback->title = $title;
    $trackback->excerpt = $excerpt;
    if ($filtered > 0) {
        $trackback->isfiltered = true;
    }
    if ($trackback->add()) {
        if ($filtered == 0) {
            CacheControl::flushDBCache('trackback');
        }
        return $filtered == 0 ? 0 : 3;
    } else {
        return 4;
    }
    return 0;
}
 function flushEntry($entryId = null)
 {
     global $database;
     if (empty($entryId)) {
         $entryId = '';
     } else {
         $entryId = $entryId . '\\_';
     }
     $cache = pageCache::getInstance();
     $Entries = POD::queryColumn("SELECT name\n\t\t\tFROM {$database['prefix']}PageCacheLog\n\t\t\tWHERE blogid = " . getBlogId() . "\n\t\t\tAND (name like 'entry\\_" . $entryId . "%' OR name = 'commentRSS_" . $entryId . "')");
     CacheControl::purgeItems($Entries);
     if (!empty($entryId)) {
         $entry = POD::queryCell("SELECT userid, category FROM {$database['prefix']}Entries\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND id = {$entryId}");
         if (!empty($entry)) {
             CacheControl::flushAuthor($entry['userid']);
             CacheControl::flushCategory($entry['category']);
             CacheControl::flushDBCache();
         }
     } else {
         CacheControl::flushAuthor();
         CacheControl::flushCategory();
         CacheControl::flushDBCache();
     }
     unset($cache);
     return true;
 }
Exemplo n.º 3
0
function trashCommentInOwner($blogid, $id)
{
    global $database;
    if (!is_numeric($id)) {
        return false;
    }
    $entryId = POD::queryCell("SELECT entry FROM {$database['prefix']}Comments WHERE blogid = {$blogid} AND id = {$id}");
    //	$result = POD::queryCount("UPDATE {$database['prefix']}Comments SET isfiltered = UNIX_TIMESTAMP() WHERE blogid = $blogid AND id = $id");
    //	if ($result && $result == 1) {
    if (POD::query("UPDATE {$database['prefix']}Comments SET isfiltered = UNIX_TIMESTAMP() WHERE blogid = {$blogid} AND id = {$id}")) {
        if (POD::query("UPDATE {$database['prefix']}Comments SET isfiltered = UNIX_TIMESTAMP() WHERE blogid = {$blogid} AND parent = {$id}")) {
            CacheControl::flushCommentRSS($entryId);
            CacheControl::flushDBCache('comment');
            updateCommentsOfEntry($blogid, $entryId);
            return true;
        }
    }
    return false;
}
Exemplo 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;
    }
}
Exemplo n.º 5
0
function trashCommentInOwner($blogid, $id)
{
    if (!is_numeric($id)) {
        return false;
    }
    $pool = DBModel::getInstance();
    $pool->reset('Comments');
    $pool->setQualifier('blogid', 'eq', $blogid);
    $pool->setQualifier('id', 'eq', $id);
    $entryId = $pool->getCell('entry');
    $pool->setAttribute('isfiltered', Timestamp::getUNIXtime());
    if ($pool->update()) {
        $pool->unsetQualifier('id');
        $pool->setQualifier('parent', 'eq', $id);
        if ($pool->update()) {
            CacheControl::flushCommentRSS($entryId);
            CacheControl::flushDBCache('comment');
            filterTrashComments($blogid, $id);
            updateCommentsOfEntry($blogid, $entryId);
            return true;
        }
    }
    return false;
}
Exemplo n.º 6
0
 function flushEntry($entryId = null)
 {
     global $database;
     if (empty($entryId)) {
         $entryId = '';
     } else {
         $entryId = intval($entryId);
     }
     $Entries = POD::queryColumn("SELECT name\n\t\t\tFROM {$database['prefix']}PageCacheLog\n\t\t\tWHERE blogid = " . getBlogId() . "\n\t\t\tAND (name like 'entry-" . $entryId . "-%' OR name like '%RSS-" . $entryId . "' OR name like '%ATOM-" . $entryId . "')");
     if (!empty($Entries)) {
         CacheControl::purgeItems($Entries);
     }
     if (!empty($entryId)) {
         $entry = POD::queryRow("SELECT userid, category, published FROM {$database['prefix']}Entries\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND id = {$entryId}");
         if (!empty($entry)) {
             $entry['period'] = Timestamp::getYearMonth($entry['published']);
             CacheControl::flushAuthor($entry['userid']);
             CacheControl::flushCategory($entry['category']);
             CacheControl::flushArchive($entry['period']);
             CacheControl::flushDBCache('entry');
         }
     } else {
         CacheControl::flushAuthor();
         CacheControl::flushCategory();
         CacheControl::flushDBCache('entry');
     }
     return true;
 }
Exemplo n.º 7
0
function protectEntry($id, $password)
{
    $pool->init("Entries");
    $pool->setQualifier("blogid", "eq", getBlogId());
    $pool->setQualifier("id", "eq", $id);
    $pool->setQualifier("visibility", "eq", 1);
    $pool->setAttribute("password", $password, true);
    $pool->setAttribute("modified", Timestamp::getUNIXtime());
    $result = $pool->update();
    if ($result) {
        CacheControl::flushEntry($id);
        CacheControl::flushDBCache('entry');
        CacheControl::flushDBCache('comment');
        CacheControl::flushDBCache('trackback');
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 8
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;
 }
Exemplo n.º 9
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;
    }
}