Skip to content

Commit

Permalink
refs #1703 : added - model for deleting trackback/pingbacks with
Browse files Browse the repository at this point in the history
 specific IP.

 -
  • Loading branch information
inureyes committed Dec 9, 2014
1 parent 3450fb1 commit ddbd5bb
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 56 deletions.
2 changes: 1 addition & 1 deletion interface/owner/communication/comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function toggleThisTr(tr, isActive) {
<div id="delete-section-top" class="section">
<span class="label"><?php echo _t('선택한 댓글을');?></span>
<input type="button" class="delete-button input-button" value="<?php echo _t('삭제');?>" onclick="deleteComments();" />
<span class="label"><?php echo _t('선택한 댓글을 삭제할 때 해당 댓글과 동일한 IP에서 발송된 댓글들도 함께 삭제합니다');?></span>
<span class="label"><?php echo (isset($tabsClass['guestbook']) ? _t('선택한 방명록을 삭제할 때 해당 방명록과 동일한 IP에서 발송된 댓글들도 함께 삭제합니다') : _t('선택한 댓글을 삭제할 때 해당 댓글과 동일한 IP에서 발송된 댓글들도 함께 삭제합니다'));?></span>
<input type="checkbox" id="deleteCommentsFromSameIP" class="checkbox" />
</div>

Expand Down
130 changes: 75 additions & 55 deletions library/model/blog.response.remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function getRemoteResponsesWithPagingForOwner($blogid, $category, $site, $ip, $s
if (!is_null($type)) $typeFilter = " AND t.responsetype = '".POD::escapeString($type)."'";
else $typeFilter = '';
$postfix = '';
$sql = "SELECT t.*, c.name AS categoryName
FROM {$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
$sql = "SELECT t.*, c.name AS categoryName
FROM {$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
WHERE t.blogid = $blogid AND t.isfiltered = 0 $typeFilter";
if ($category > 0) {
$categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = $blogid AND parent = $category");
Expand Down Expand Up @@ -50,14 +50,14 @@ function getRemoteResponsesWithPaging($blogid, $entryId, $page, $count, $url = n
$postfix = '';
$authorized = doesHaveOwnership() ? '' : getPrivateCategoryExclusionQuery($blogid);

$sql = "SELECT t.*, c.name AS categoryName
FROM {$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
$sql = "SELECT t.*, c.name AS categoryName
FROM {$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
WHERE t.blogid = $blogid AND t.isfiltered = 0 $authorized $typeFilter";
$sql .= ' ORDER BY t.written DESC';
list($responses, $paging) = Paging::fetch($sql, $page, $count, $url, $prefix, $countItem);
$paging['postfix'] .= $postfix;
$paging['postfix'] .= $postfix;
return array($responses, $paging);
}

Expand All @@ -66,10 +66,10 @@ function getRemoteResponseLogsWithPagingForOwner($blogid, $category, $site, $ip,
if (!is_null($type)) $typeFilter = " AND t.responsetype = '".POD::escapeString($type)."'";
else $typeFilter = '';
$postfix = '&amp;status=sent';
$sql = "SELECT t.*, e.title AS subject, c.name AS categoryName
FROM {$database['prefix']}RemoteResponseLogs t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
$sql = "SELECT t.*, e.title AS subject, c.name AS categoryName
FROM {$database['prefix']}RemoteResponseLogs t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
LEFT JOIN {$database['prefix']}Categories c ON t.blogid = c.blogid AND e.category = c.id
WHERE t.blogid = $blogid $typeFilter";
if ($category > 0) {
$categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = $blogid AND parent = $category");
Expand All @@ -96,11 +96,11 @@ function getRemoteResponses($entry, $type = null) {
if (!is_null($type)) $typeFilter = " AND responsetype = '".POD::escapeString($type)."'";
else $typeFilter = '';
$responses = array();
$result = POD::queryAll("SELECT *
FROM {$database['prefix']}RemoteResponses
WHERE blogid = ".getBlogId()."
AND entry = $entry
AND isfiltered = 0 $typeFilter
$result = POD::queryAll("SELECT *
FROM {$database['prefix']}RemoteResponses
WHERE blogid = ".getBlogId()."
AND entry = $entry
AND isfiltered = 0 $typeFilter
ORDER BY written");
if(!empty($result)) $responses = $result;
// while ($response = POD::fetch($result))
Expand All @@ -120,39 +120,39 @@ function getRemoteResponseList($blogid, $search, $type = null) {
LEFT JOIN {$database['prefix']}Entries e ON t.entry = e.id AND t.blogid = e.blogid AND e.draft = 0
WHERE t.blogid = $blogid
AND t.isfiltered = 0
AND t.entry > 0 $authorized $typeFilter
AND t.entry > 0 $authorized $typeFilter
AND (t.excerpt like '%$search%' OR t.subject like '%$search%')")) {
foreach($result as $response)
foreach($result as $response)
array_push($list['items'], $response);
}
}
return $list;
}

function getRecentRemoteResponses($blogid, $count = false, $guestShip = false, $type = null) {
global $database, $skinSetting;
if (!is_null($type)) $typeFilter = " AND t.responsetype = '".POD::escapeString($type)."'";
else $typeFilter = '';
$sql = (doesHaveOwnership() && !$guestShip) ? "SELECT t.*, e.slogan
FROM
$sql = (doesHaveOwnership() && !$guestShip) ? "SELECT t.*, e.slogan
FROM
{$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id AND e.draft = 0
WHERE
t.blogid = $blogid AND t.isfiltered = 0 $typeFilter
ORDER BY
t.written
DESC LIMIT ".($count != false ? $count : $skinSetting['trackbacksOnRecent']) :
"SELECT t.*, e.slogan
FROM
{$database['prefix']}RemoteResponses t
WHERE
t.blogid = $blogid AND t.isfiltered = 0 $typeFilter
ORDER BY
t.written
DESC LIMIT ".($count != false ? $count : $skinSetting['trackbacksOnRecent']) :
"SELECT t.*, e.slogan
FROM
{$database['prefix']}RemoteResponses t
LEFT JOIN {$database['prefix']}Entries e ON t.blogid = e.blogid AND t.entry = e.id
WHERE
t.blogid = $blogid
AND t.isfiltered = 0
AND e.draft = 0
WHERE
t.blogid = $blogid
AND t.isfiltered = 0
AND e.draft = 0
AND e.visibility >= 2 ".getPrivateCategoryExclusionQuery($blogid)."
$typeFilter
ORDER BY
t.written
ORDER BY
t.written
DESC LIMIT ".($count != false ? $count : $skinSetting['trackbacksOnRecent']);
if ($result = POD::queryAllWithDBCache($sql,'remoteResponse')) {
return $result;
Expand Down Expand Up @@ -192,6 +192,26 @@ function trashRemoteResponse($blogid, $id) {
return false;
}

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);
if ($pool->delete()) {
CacheControl::flushDBCache('trackback');
CacheControl::flushDBCache('remoteResponse');
foreach ($affectedEntries as $entry) {
updateRemoteResponsesOfEntry($blogid, $entry);
}
return true;
}
return false;
}

function revertRemoteResponse($blogid, $id) {
global $database;
requireModel('blog.entry');
Expand Down Expand Up @@ -249,15 +269,15 @@ function getRemoteResponseCount($blogid, $entryId = null) {
global $database;
if (is_null($entryId)) {
$result = POD::queryRow("SELECT SUM(trackbacks) AS t, SUM(pingbacks) AS p
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND draft= 0");
return $result['t'] + $result ['p'];
} else {
$result = POD::queryRow("SELECT trackbacks, pingbacks
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND id = $entryId
$result = POD::queryRow("SELECT trackbacks, pingbacks
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND id = $entryId
AND draft= 0");
return $result['trackbacks'] + $result['pingbacks'];
}
Expand Down Expand Up @@ -304,9 +324,9 @@ function receiveTrackback($blogid, $entry, $title, $url, $excerpt, $site) {
$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;
Expand Down Expand Up @@ -392,7 +412,7 @@ function sendTrackback($blogid, $entryId, $url) {
$request->contentType = 'application/x-www-form-urlencoded; charset=utf-8';
$isSuccess = $request->send($content);
}

if ($isSuccess && (checkResponseXML($request->responseText) === 0)) {
// $url = POD::escapeString(Utils_Unicode::lessenAsEncoding($url, 255));
$trackbacklog = new TrackbackLog;
Expand Down Expand Up @@ -420,22 +440,22 @@ function deleteTrackbackLog($blogid, $id) {
function getTrackbackCount($blogid, $entryId = null) {
global $database;
if (is_null($entryId))
return POD::queryCell("SELECT SUM(trackbacks)
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
return POD::queryCell("SELECT SUM(trackbacks)
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND draft= 0");
return POD::queryCell("SELECT trackbacks
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND id = $entryId
return POD::queryCell("SELECT trackbacks
FROM {$database['prefix']}Entries
WHERE blogid = $blogid
AND id = $entryId
AND draft= 0");
}


function getTrackbackCountPart($trackbackCount, &$skin) {
$noneTrackbackMessage = $skin->noneTrackbackMessage;
$singleTrackbackMessage = $skin->singleTrackbackMessage;

if ($trackbackCount == 0 && !empty($noneTrackbackMessage)) {
dress('article_rep_tb_cnt', 0, $noneTrackbackMessage);
$trackbackView = $noneTrackbackMessage;
Expand All @@ -447,7 +467,7 @@ function getTrackbackCountPart($trackbackCount, &$skin) {
dress('article_rep_tb_cnt', $trackbackCount, $trackbackPart);
$trackbackView = $trackbackPart;
}

return array("tb_count", $trackbackView);
}

Expand Down

0 comments on commit ddbd5bb

Please sign in to comment.