Ejemplo n.º 1
0
function sendTrackback($blogid, $entryId, $url)
{
    global $defaultURL, $blog;
    requireModel('blog.entry');
    requireModel('blog.keyword');
    $entry = getEntry($blogid, $entryId);
    if (is_null($entry)) {
        return false;
    }
    $link = "{$defaultURL}/{$entryId}";
    $title = htmlspecialchars($entry['title']);
    $entry['content'] = getEntryContentView($blogid, $entryId, $entry['content'], $entry['contentformatter'], getKeywordNames($blogid));
    $excerpt = str_tag_on(UTF8::lessen(removeAllTags(stripHTML($entry['content'])), 255));
    $blogTitle = $blog['title'];
    $isNeedConvert = strpos($url, '/rserver.php?') !== false || strpos($url, 'blog.naver.com/tb') !== false || strpos($url, 'news.naver.com/tb/') !== false || strpos($url, 'blog.empas.com') !== false || strpos($url, 'blog.yahoo.com') !== false || strpos($url, 'www.blogin.com/tb/') !== false || strpos($url, 'cytb.cyworld.nate.com') !== false || strpos($url, 'www.cine21.com/Movies/tb.php') !== false;
    if ($isNeedConvert) {
        $title = UTF8::convert($title, 'EUC-KR');
        $excerpt = UTF8::convert($excerpt, 'EUC-KR');
        $blogTitle = UTF8::convert($blogTitle, 'EUC-KR');
        $content = "url=" . rawurlencode($link) . "&title=" . rawurlencode($title) . "&blog_name=" . rawurlencode($blogTitle) . "&excerpt=" . rawurlencode($excerpt);
        $request = new HTTPRequest('POST', $url);
        $request->contentType = 'application/x-www-form-urlencoded; charset=euc-kr';
        $isSuccess = $request->send($content);
    } else {
        $content = "url=" . rawurlencode($link) . "&title=" . rawurlencode($title) . "&blog_name=" . rawurlencode($blogTitle) . "&excerpt=" . rawurlencode($excerpt);
        $request = new HTTPRequest('POST', $url);
        $request->contentType = 'application/x-www-form-urlencoded; charset=utf-8';
        $isSuccess = $request->send($content);
    }
    if ($isSuccess && checkResponseXML($request->responseText) === 0) {
        //		$url = POD::escapeString(UTF8::lessenAsEncoding($url, 255));
        $trackbacklog = new TrackbackLog();
        $trackbacklog->entry = $entryId;
        $trackbacklog->url = POD::escapeString(UTF8::lessenAsEncoding($url, 255));
        $trackbacklog->add();
        //		POD::query("INSERT INTO {$database['prefix']}TrackbackLogs VALUES ($blogid, '', $entryId, '$url', UNIX_TIMESTAMP())");
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
function tt_xml_parser_into_struct($body)
{
    $h_set = array();
    $r_set = array();
    while ($n1 = strpos($body, "<![CDATA[")) {
        $n2 = strpos($body, "]]>");
        if (!$n2 || $n1 > $n2) {
            break;
        }
        $stamp = get_timestamp2();
        $cval = substr($body, $n1 + 9, $n2 - $n1 - 9);
        $body = str_replace("<![CDATA[" . $cval . "]]>", $stamp, $body);
        $h_set[$stamp] = trim($cval);
    }
    $b_set = explode("<", $body);
    foreach ($b_set as $k => $row) {
        $inp = array();
        $att_set = array();
        $row = trim($row);
        if (!$row) {
            continue;
        }
        if (substr($row, 0, 1) == "/") {
            if (strpos($row, "item")) {
                $inp['tag'] = "ITEM";
                $inp['type'] = "close";
                array_push($r_set, $inp);
            }
            continue;
        }
        if (strpos($row, ">") === false) {
            continue;
        }
        list($tag_inf, $val) = explode(">", $row);
        if ($tag_nid = strpos($tag_inf, " ")) {
            $tag = substr($tag_inf, 0, $tag_nid);
            $tag_inf = substr($tag_inf, $tag_nid);
            while ($tag_n1 = strpos($tag_inf, "=")) {
                $tag_n2 = strpos($tag_inf, "\"", $tag_n1 + 2);
                $att_inf = substr($tag_inf, 1, $tag_n2);
                $tag_inf = substr($tag_inf, $tag_n2 + 1);
                $att_var = trim(strtoupper(substr($att_inf, 0, $tag_n1 - 1)));
                $att_val = trim(str_tag_on(str_replace("\"", "", substr($att_inf, $tag_n1 + 1))));
                $att_set[$att_var] = $att_val;
            }
            $inp['attributes'] = $att_set;
        } else {
            $tag = $tag_inf;
        }
        if (!$tag || $tag == "?XML") {
            continue;
        }
        $tag = strtoupper($tag);
        $inp['tag'] = $tag;
        $val = trim($val);
        if (isset($h_set[$val])) {
            $val = $h_set[$val];
        } else {
            if ($val) {
                $val = str_tag_on($val);
            }
        }
        $inp['value'] = str_replace("document.cookie", "document.&#99;ookie", $val);
        array_push($r_set, $inp);
    }
    return $r_set;
}
Ejemplo n.º 3
0
function sendTrackback($blogid, $entryId, $url)
{
    importlib('model.blog.entry');
    importlib('model.blog.keyword');
    $context = Model_Context::getInstance();
    $entry = getEntry($blogid, $entryId);
    if (is_null($entry)) {
        return false;
    }
    $link = $context->getProperty('uri.default') . "/" . $entryId;
    $title = htmlspecialchars($entry['title']);
    $entry['content'] = getEntryContentView($blogid, $entryId, $entry['content'], $entry['contentformatter'], getKeywordNames($blogid));
    $excerpt = str_tag_on(Utils_Unicode::lessen(removeAllTags(stripHTML($entry['content'])), 255));
    $blogTitle = $context->getProperty('blog.title');
    $isNeedConvert = strpos($url, '/rserver.php?') !== false || strpos($url, 'blog.naver.com/tb') !== false || strpos($url, 'news.naver.com/tb/') !== false || strpos($url, 'blog.empas.com') !== false || strpos($url, 'blog.yahoo.com') !== false || strpos($url, 'www.blogin.com/tb/') !== false || strpos($url, 'cytb.cyworld.nate.com') !== false || strpos($url, 'www.cine21.com/Movies/tb.php') !== false;
    if ($isNeedConvert) {
        $title = Utils_Unicode::convert($title, 'EUC-KR');
        $excerpt = Utils_Unicode::convert($excerpt, 'EUC-KR');
        $blogTitle = Utils_Unicode::convert($blogTitle, 'EUC-KR');
        $content = "url=" . rawurlencode($link) . "&title=" . rawurlencode($title) . "&blog_name=" . rawurlencode($blogTitle) . "&excerpt=" . rawurlencode($excerpt);
        $request = new HTTPRequest('POST', $url);
        $request->contentType = 'application/x-www-form-urlencoded; charset=euc-kr';
        $isSuccess = $request->send($content);
    } else {
        $content = "url=" . rawurlencode($link) . "&title=" . rawurlencode($title) . "&blog_name=" . rawurlencode($blogTitle) . "&excerpt=" . rawurlencode($excerpt);
        $request = new HTTPRequest('POST', $url);
        $request->contentType = 'application/x-www-form-urlencoded; charset=utf-8';
        $isSuccess = $request->send($content);
    }
    if ($isSuccess && checkResponseXML($request->responseText) === 0) {
        $trackbacklog = new TrackbackLog();
        $trackbacklog->entry = $entryId;
        $trackbacklog->url = Utils_Unicode::lessenAsEncoding($url, 255);
        $trackbacklog->add();
        return true;
    }
    return false;
}