Niezalogowany (Zaloguj się)

Vanilla 1.1.4 jest produktem Lussumo. Więcej informacji: Dokumentacja, Forum.

    • CommentAuthorcrack
    • CommentTime24 Mar 2008
     
    Witam
    Nie wiem czy juz byl o tym wątek ale dodanie pingowania do skryptu mocnelinki to byloby bardzo dobre rozwiązanie, pingowanie po każdym dodaniu wpisu, można by też dodać akcję do crona, dynamiczny sitemap dla gogla to też niezły pomysł.
    Przepraszam jeżeli były o tym wątki
    • CommentAuthorazbest
    • CommentTime18 Jul 2008
     
    CZesc. Zrobilem pinga do ML.
    Musisz utworzyc najpierw kanal RSS. Następnie plik ping. php oraz zmodyfikować .htaccess . Kody poniżej:

    W .htaccess wstawiamy w środek linijkę:
    RewriteRule ^rss.xml$ rss.php [NC,NS]

    tworzymy plik rss.php o nast zawartosci:

    <?php
    //article_id, article_title, article_seo_title, article_description FROM `ml_articles` "
    include("robots_counter.php");


    require_once 'includes/app_top.php';

    header ('Content-Type: text/xml; charset=iso-8859-2');
    $date = $db->get_row('article_date', 'articles', "ORDER BY article_date DESC");
    $xml = '<?xml version="1.0" encoding="iso-8859-2"?>
    <rss version="2.0">
    <channel>
    <title>'.conf('site_name').'</title>
    <description>'.conf('site_description').'</description>
    <link>'.conf('site_address').'</link>
    <copyright>azbeston</copyright>
    <language>pl</language>'
    ;


    // artykuły

    $q = $db->select('*', 'articles', "WHERE article_status='2'ORDER BY article_id DESC LIMIT 0, 10");
    while ($r = $db->fetch($q)) {
    $xml .= '
    <item>
    <title>'.$r['article_title'].'</title>
    <link>'.conf('site_address').'n-'.$r['article_id'].'-'.$r['article_seo_title'].'.html</link>
    <description>'.$r['article_description'].'</description>
    <guid isPermaLink="true">'.conf('site_address').'n-'.$r['article_id'].'-'.$r['article_seo_title'].'.html</guid>

    </item>';
    }

    $xml .= '

    <item>
    <title>Blog o Hotelach</title>
    <link>http://presell.waw.pl</link>
    <description>Zapraszam na Precla o Hotelach</description>
    <guid isPermaLink="true">http://presell.waw.pl</guid>

    </item>
    </channel>
    </rss>';
    echo $xml;
    require_once 'includes/app_bottom.php';
    ?>
    • CommentAuthorazbest
    • CommentTime18 Jul 2008
     
    Teraz tworzymy plik ping.php o zawartości i modyfikujemy

    <?php
    // Tu wtypełniamy w kolejności: tytuł, adres url z http,listapingów

    $blogTitle="Tytuł";
    $blogUrl="http://";
    $pingListFile="pinglist.txt";
    $showDebugInfo=FALSE; // Do you want verbose output?

    // Skończ edycję



    $replacementCount=0;
    $userAgent="pingrpc.php by tayefeh";

    // Read pinglist file. Must contain one fully qualified URL
    // (e.g: http://rpc.technorati.com/rpc/ping) PER LINE (->
    // delimiter is an ASCII-linebreak)
    $fp=fopen($pingListFile,"r");
    while ( ! feof( $fp) )
    {
    $line = trim(fgets( $fp, 4096));
    // get the hostname
    $host=$line; // Make a copy of $line
    $host=preg_replace('/^.*http:\/\//','',$host); // Delete anything before http://
    $host=preg_replace('/\/.*$/','',$host); // Delete anything after behind the hostname

    // get the path
    $path=$line; // Make another copy of $line
    //$path=preg_replace('/^.*http:\/\/[a-zA-Z0-9\-_\.]*\.[a-zA-Z]{1,3}\//','',$path,-1,$replacementCount); // Delete anything before the path
    if(!$replacementCount) $path=''; // if there was no replacement (i.e. no explicit path), act appropiately
    if($host) $myList[$host]=$path;
    }
    echo "<h1>Ping process started</h1>";

    echo "<p>Reading URLs from file $pingListFile: ";
    echo count($myList)." urls read.</p>";

    // Use DOM to create the XML-File
    $xml= new DOMDocument('1.0');
    $xml->formatOutput=true;
    $xml->preserveWhiteSpace=false;
    $xml->substituteEntities=false;

    // Create the xml structure
    $methodCall=$xml->appendChild($xml->createElement('methodCall'));
    $methodName=$methodCall->appendChild($xml->createElement('methodName'));
    $params=$methodCall->appendChild($xml->createElement('params'));
    $param[1]=$params->appendChild($xml->createElement('param'));
    $value[1]=$param[1]->appendChild($xml->createElement('value'));
    $param[2]=$params->appendChild($xml->createElement('param'));
    $value[2]=$param[2]->appendChild($xml->createElement('value'));

    // Set the node values
    $methodName->nodeValue="weblogUpdates.ping";
    $value[1]->nodeValue=$blogTitle;
    $value[2]->nodeValue=$blogUrl;

    $xmlrpcReq = $xml->saveXML(); // Write the document into a string
    $xmlrpcLength = strlen( $xmlrpcReq ); // Get the string length.

    echo "Here's the xml-message I generated (size: $xmlrpcLength bytes):";

    echo "\n<pre>\n";
    echo htmlentities($xmlrpcReq);
    echo "</pre>";

    echo "<dl>";

    // Proceed every link read from file
    foreach ( $myList as $host => $path)
    {
    if($showDebugInfo) echo "<hr/>";

    echo "<dt><strong>Pinging host: $host </strong>";
    $httpReq = "POST /" . $path . " HTTP/1.0\r\n";
    $httpReq .= "User-Agent: " . $userAgent. "\r\n";
    $httpReq .= "Host: " . $host . "\r\n";
    $httpReq .= "Content-Type: text/xml\r\n";
    $httpReq .= "Content-length: $xmlrpcLength\r\n\r\n";
    $httpReq .= "$xmlrpcReq\r\n";
    echo "</dt>";

    if($showDebugInfo)
    {
    echo "<dd><strong>Request:</strong><pre><span style=\"color: #cc9900\">".htmlentities($httpReq)."</span></pre>";
    echo "<strong>Answer</strong>:<span style=\"color: #99cc00\"><pre>";
    }

    // Actually, send ping
    if ( $pinghandle = @fsockopen( $host, 80 ) )
    {
    @fputs( $pinghandle, $httpReq );
    while ( ! feof( $pinghandle ) )
    {
    $pingresponse = @fgets( $pinghandle, 128 );
    if($showDebugInfo) echo htmlentities($pingresponse);
    }
    @fclose( $pinghandle );
    }
    if($showDebugInfo) echo "</span></pre></dd>";
    }
    echo "</dl>";
    echo "<p>FINISHED</p>";

    ?>

    Tworzymy ostatni plik pinglist.txt to lista pingów, czyli serwerów które bedziemy pingować. Dużo jest ich w sieci oto jedna z nich:

    http://blogsearch.google.com/ping/RPC2
    http://rpc.technorati.com/rpc/ping
    http://www.newsisfree.com/xmlrpctest.php
    http://ping.bitacoras.com
    http://ping.blo.gs/
    http://ping.bloggers.jp/rpc/
    http://api.moreover.com/ping
    http://api.my.yahoo.com/RPC2
    http://api.my.yahoo.com/rss/ping
    http://www.bitacoles.net/ping.php
    http://bitacoras.net/ping
    http://blogdb.jp/xmlrpc
    http://www.blogdigger.com/RPC2
    http://www.blogoole.com/ping/
    http://www.blogoon.net/ping/