Code Duplication    Length = 52-52 lines in 2 locations

class/utility.php 1 location

@@ 288-339 (lines=52) @@
285
         * @param $article
286
         * @return bool
287
         */
288
        public static function planetTrackback($trackback_url, $article)
289
        {
290
            global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
291
292
            $title         = $article->getVar('art_title');
293
            $excerpt       = $article->getVar('art_content');
294
            $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
295
            $title         = xoops_utf8_encode($title);
296
            $excerpt       = xoops_utf8_encode($excerpt);
297
            $blog_name     = xoops_utf8_encode($blog_name);
298
            $charset       = 'utf-8';
299
            $title1        = urlencode($title);
300
            $excerpt1      = urlencode($excerpt);
301
            $name1         = urlencode($blog_name);
302
            $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
303
            $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
304
            $trackback_url = parse_url($trackback_url);
305
306
            $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
307
            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
308
            $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
309
            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
310
            $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
311
            $http_request .= "\r\n\r\n";
312
            $http_request .= $query_string;
313
            if ('' == $trackback_url['port']) {
314
                $trackback_url['port'] = 80;
315
            }
316
            $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
317
            @fwrite($fs, $http_request);
318
            if ($xoopsModuleConfig['do_debug']) {
319
                $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
320
                $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
321
                $fr         .= "CHARSET:$charset\n";
322
                $fr         .= "NAME:$blog_name\n";
323
                $fr         .= 'TITLE:' . $title . "\n";
324
                $fr         .= "EXCERPT:$excerpt\n\n";
325
                while (!@feof($fs)) {
326
                    $fr .= @fgets($fs, 4096);
327
                }
328
                $fr .= "\n\n";
329
330
                if ($fp = fopen($debug_file, 'a')) {
331
                    fwrite($fp, $fr);
332
                    fclose($fp);
333
                } else {
334
                }
335
            }
336
            @fclose($fs);
337
338
            return true;
339
        }
340
341
        /**
342
         * Function to ping servers

include/functions.php 1 location

@@ 281-332 (lines=52) @@
278
     * @param $article
279
     * @return bool
280
     */
281
    function planetTrackback($trackback_url, $article)
282
    {
283
        global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig;
284
285
        $title         = $article->getVar('art_title');
286
        $excerpt       = $article->getVar('art_content');
287
        $blog_name     = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name');
288
        $title         = xoops_utf8_encode($title);
289
        $excerpt       = xoops_utf8_encode($excerpt);
290
        $blog_name     = xoops_utf8_encode($blog_name);
291
        $charset       = 'utf-8';
292
        $title1        = urlencode($title);
293
        $excerpt1      = urlencode($excerpt);
294
        $name1         = urlencode($blog_name);
295
        $url           = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id'));
296
        $query_string  = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset";
297
        $trackback_url = parse_url($trackback_url);
298
299
        $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n";
300
        $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
301
        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n";
302
        $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
303
        $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION;
304
        $http_request .= "\r\n\r\n";
305
        $http_request .= $query_string;
306
        if ('' == $trackback_url['port']) {
307
            $trackback_url['port'] = 80;
308
        }
309
        $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
310
        @fwrite($fs, $http_request);
311
        if ($xoopsModuleConfig['do_debug']) {
312
            $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log';
313
            $fr         = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n";
314
            $fr         .= "CHARSET:$charset\n";
315
            $fr         .= "NAME:$blog_name\n";
316
            $fr         .= 'TITLE:' . $title . "\n";
317
            $fr         .= "EXCERPT:$excerpt\n\n";
318
            while (!@feof($fs)) {
319
                $fr .= @fgets($fs, 4096);
320
            }
321
            $fr .= "\n\n";
322
323
            if ($fp = fopen($debug_file, 'a')) {
324
                fwrite($fp, $fr);
325
                fclose($fp);
326
            } else {
327
            }
328
        }
329
        @fclose($fs);
330
331
        return true;
332
    }
333
334
    /**
335
     * Function to ping servers