• 25-05-2021, 15:17:23
    #1
    Bir rss feed oluşturucu için bir kod derledim fakat verileri çekemiyorum db bağlantısını yaptığım halde içerikler gelmiyor doğru tablodan doğru verileri çekiyorum ama yok veriler gelmiyor kafayı yemek üzereyim .. Üstadlar bi bakabilirse çok sevinirim...
    <?php
    header('Content-type: text/xml'); ?>
    <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <?php
    
    $servername = "localhost";
    $username = "--";
    $password = "--";
    $dbname = "--";
    
    $site = $_SERVER["HTTP_HOST"];
    $tarih=date("Y-m-d");
    
    
    function seo($url){
    $url = trim($url);
    $url = strtolower($url);
    $find = array('<b>', '</b>');
    $url = str_replace ($find, '', $url);
    $url = preg_replace('/<(\/{0,1})img(.*?)(\/{0,1})\>/', 'image', $url);
    $find = array(' ', '&quot;', '&amp;', '&', '\r\n', '\n', '/', '\\', '+', '<', '>');
    $url = str_replace ($find, '-', $url);
    $find = array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê');
    $url = str_replace ($find, 'e', $url);
    $find = array('í', 'ı', 'ì', 'î', 'ï', 'I', 'İ', 'Í', 'Ì', 'Î', 'Ï');
    $url = str_replace ($find, 'i', $url);
    $find = array('ó', 'ö', 'Ö', 'ò', 'ô', 'Ó', 'Ò', 'Ô');
    $url = str_replace ($find, 'o', $url);
    $find = array('á', 'ä', 'â', 'à', 'â', 'Ä', 'Â', 'Á', 'À', 'Â');
    $url = str_replace ($find, 'a', $url);
    $find = array('ú', 'ü', 'Ü', 'ù', 'û', 'Ú', 'Ù', 'Û');
    $url = str_replace ($find, 'u', $url);
    $find = array('ç', 'Ç');
    $url = str_replace ($find, 'c', $url);
    $find = array('ş', 'Ş');
    $url = str_replace ($find, 's', $url);
    $find = array('ğ', 'Ğ');
    $url = str_replace ($find, 'g', $url);
    $find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
    $repl = array('', '-', '');
    $url = preg_replace ($find, $repl, $url);
    $url = str_replace ('--', '-', $url);
    return $url;
    }
    
    
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    mysqli_set_charset($conn,'utf8');
    
    
    ?>
    <channel>
    <title>Site Başlığı</title>
    <description>Site Açıklama</description>
    <link><?php echo URL ?></link>
    <language>tr</language>
    <?php
    $rssSql = query('SELECT * FROM news ORDER BY id DESC LIMIT 20');
    while($icerik = row($rssSql)) { ?>
    <item>
    <title><?php echo $icerik['page_title'] ?></title>
    <image>
    <url><?php echo URL.'/img/'.$icerik['foto'] ?></url>
    </image>
    <link><?php echo URL,$icerik['news_name'] ?></link>
    <pubDate><?php echo formatZaman($icerik['$tarih']) ?></pubDate>
    <description><?php echo $icerik['page_description'] ?></description>
    <language>tr</language>
    <guid isPermaLink="true"><?php echo URL,$icerik['news_name'] ?></guid>
    </item>
    <?php
    }
    ?>
    <?php
    $conn->close();
    ?>
    </channel>
    </rss>
  • 25-05-2021, 17:05:44
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
     while ($icerik = mysql_fetch_array($rssSql)) { ... }
  • 25-05-2021, 18:08:29
    #3
    $rssSql = conn->query('SELECT * FROM news ORDER BY id DESC LIMIT 20');
    while($icerik = $rssSql->fetch_assoc()) { ?>
  • 25-05-2021, 19:25:57
    #4
    Bu sayfa çalışmıyor
    şu anda bu isteği işleme alamıyor.
    [COLOR=var(--error-code-color)]HTTP ERROR 500

    Arkadaşlar bitane rss buldum editledim türkçe karakter sorunu var örneğin ç leri c ı ları i yapmam gerekiyor burada belirlenmeyen karakterleri "-" yap demiş bunu

    public function clean($string) {
      $string = strtolower( preg_replace('@[\W_]+@', '-', $string) );
      $string = rtrim($string,'-');
      $string = strtolower($string);
      return $string;
      }


    function replace_tr($text) {
      $text = trim($text);
      $search = array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ');
      $replace = array('c','c','g','g','i','i','o','o','s','s','u','u','-');
      $new_text = str_replace($search,$replace,$text);
      return $new_text;

    yapıyorum yemiyor. Yada bana makul bir ücret karşılığı şu sorunları halledebilecek olan biri varsa çok sevinirim. Özel yazılım sitemap xml i kendim hallettim feed yaptım yarım yamalak tarih 1970 i gösteriyor. Resim yolu yok yaptığım rss
    kriptoparapiyasa.com/rss.php
  • 25-05-2021, 19:32:04
    #5
    <?php
    require_once ('ayar.php'); //Veritabanı bağlantımızı yaptık.
    
    $cek = $baglanti->get_row("SELECT * FROM ayarlar");
    $url = _base;
    header('Content-Type: text/xml; charset=utf-8', true); //set document header content type to be XML
    $xml = new DOMDocument("1.0", "UTF-8"); // Create new DOM document.
     
    //create "RSS" element
    $rss = $xml->createElement("rss"); 
    $rss_node = $xml->appendChild($rss); //add RSS element to XML node
    $rss_node->setAttribute("version","2.0"); //set RSS version
     
    //set attributes
    $rss_node->setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/"); //xmlns:dc (info http://j.mp/1mHIl8e )
    $rss_node->setAttribute("xmlns:content","http://purl.org/rss/1.0/modules/content/"); //xmlns:content (info http://j.mp/1og3n2W)
    $rss_node->setAttribute("xmlns:atom","http://www.w3.org/2005/Atom");//xmlns:atom (http://j.mp/1tErCYX )
     
    //Create RFC822 Date format to comply with RFC822
    $date_f = date("D, d M Y H:i:s T", time());
    $build_date = gmdate(DATE_RFC2822, strtotime($date_f));
     
    //create "channel" element under "RSS" element
    $channel = $xml->createElement("channel");  
    $channel_node = $rss_node->appendChild($channel);
     
    //a feed should contain an atom:link element (info http://j.mp/1nuzqeC)
    $channel_atom_link = $xml->createElement("atom:link");  
    $channel_atom_link->setAttribute("href","$url"); //url of the feed
    $channel_atom_link->setAttribute("rel","self");
    $channel_atom_link->setAttribute("type","application/rss+xml");
    $channel_node->appendChild($channel_atom_link); 
     
    //add general elements under "channel" node
    $channel_node->appendChild($xml->createElement("title", "$cek->title | $cek->telefon")); //title
    $channel_node->appendChild($xml->createElement("description", "$cek->keyw"));  //description
    $channel_node->appendChild($xml->createElement("link", "$url")); //website link 
    $channel_node->appendChild($xml->createElement("language", "tr-TR"));  //language
    $channel_node->appendChild($xml->createElement("lastBuildDate", $build_date));  //last build date
    $channel_node->appendChild($xml->createElement("generator", "$cek->title | $cek->telefon")); //generator
     
     
    $cek = $baglanti->get_results(" SELECT * FROM urunler ORDER BY id DESC ");
     
    if($cek){ //we have records 
        foreach($cek as $row) //loop through each row
        {
          $item_node = $channel_node->appendChild($xml->createElement("item")); //create a new node called "item"
          $title_node = $item_node->appendChild($xml->createElement("title", $row->urunadi)); //Add Title under "item"
          $link_node = $item_node->appendChild($xml->createElement("link", $url.strtolower($row->urunseo)."/")); //add link node under "item"
          
          //Unique identifier for the item (GUID)
          $guid_link = $xml->createElement("guid", $url.strtolower($row->urunseo)."/".md5($row->id));  
          $guid_link->setAttribute("isPermaLink","false");
          $guid_node = $item_node->appendChild($guid_link); 
         
          //create "description" node under "item"
          $description_node = $item_node->appendChild($xml->createElement("description"));  
          
          //fill description node with CDATA content
          $description_contents = $xml->createCDATASection(htmlentities($row->urunozellik));  
          $description_node->appendChild($description_contents); 
        
          //Published date
          $date_rfc = gmdate(DATE_RFC2822, strtotime($row->published));
          $pub_date = $xml->createElement("pubDate", turkce_tarih($row->tarih));  
          $pub_date_node = $item_node->appendChild($pub_date); 
     
        }
    }
    echo $xml->saveXML();
    ?>
    Kendi kullanmış olduğum RSS kodlarım. Bende internetten bulup kendime göre düzenledim. Sizde bunu kendinize göre düzenleyebilirsiniz.

    Kodların çalıştığını görmek isterseniz buraya tıklamanız yeterli.
  • 25-05-2021, 19:46:04
    #6
    tuzlatuning adlı üyeden alıntı: mesajı görüntüle
    <?php
    require_once ('ayar.php'); //Veritabanı bağlantımızı yaptık.
    
    $cek = $baglanti->get_row("SELECT * FROM ayarlar");
    $url = _base;
    header('Content-Type: text/xml; charset=utf-8', true); //set document header content type to be XML
    $xml = new DOMDocument("1.0", "UTF-8"); // Create new DOM document.
     
    //create "RSS" element
    $rss = $xml->createElement("rss");
    $rss_node = $xml->appendChild($rss); //add RSS element to XML node
    $rss_node->setAttribute("version","2.0"); //set RSS version
     
    //set attributes
    $rss_node->setAttribute("xmlns:dc","http://purl.org/dc/elements/1.1/"); //xmlns:dc (info http://j.mp/1mHIl8e )
    $rss_node->setAttribute("xmlns:content","http://purl.org/rss/1.0/modules/content/"); //xmlns:content (info http://j.mp/1og3n2W)
    $rss_node->setAttribute("xmlns:atom","http://www.w3.org/2005/Atom");//xmlns:atom (http://j.mp/1tErCYX )
     
    //Create RFC822 Date format to comply with RFC822
    $date_f = date("D, d M Y H:i:s T", time());
    $build_date = gmdate(DATE_RFC2822, strtotime($date_f));
     
    //create "channel" element under "RSS" element
    $channel = $xml->createElement("channel");  
    $channel_node = $rss_node->appendChild($channel);
     
    //a feed should contain an atom:link element (info http://j.mp/1nuzqeC)
    $channel_atom_link = $xml->createElement("atom:link");  
    $channel_atom_link->setAttribute("href","$url"); //url of the feed
    $channel_atom_link->setAttribute("rel","self");
    $channel_atom_link->setAttribute("type","application/rss+xml");
    $channel_node->appendChild($channel_atom_link);
     
    //add general elements under "channel" node
    $channel_node->appendChild($xml->createElement("title", "$cek->title | $cek->telefon")); //title
    $channel_node->appendChild($xml->createElement("description", "$cek->keyw"));  //description
    $channel_node->appendChild($xml->createElement("link", "$url")); //website link
    $channel_node->appendChild($xml->createElement("language", "tr-TR"));  //language
    $channel_node->appendChild($xml->createElement("lastBuildDate", $build_date));  //last build date
    $channel_node->appendChild($xml->createElement("generator", "$cek->title | $cek->telefon")); //generator
     
     
    $cek = $baglanti->get_results(" SELECT * FROM urunler ORDER BY id DESC ");
     
    if($cek){ //we have records
        foreach($cek as $row) //loop through each row
        {
          $item_node = $channel_node->appendChild($xml->createElement("item")); //create a new node called "item"
          $title_node = $item_node->appendChild($xml->createElement("title", $row->urunadi)); //Add Title under "item"
          $link_node = $item_node->appendChild($xml->createElement("link", $url.strtolower($row->urunseo)."/")); //add link node under "item"
          
          //Unique identifier for the item (GUID)
          $guid_link = $xml->createElement("guid", $url.strtolower($row->urunseo)."/".md5($row->id));  
          $guid_link->setAttribute("isPermaLink","false");
          $guid_node = $item_node->appendChild($guid_link);
        
          //create "description" node under "item"
          $description_node = $item_node->appendChild($xml->createElement("description"));  
          
          //fill description node with CDATA content
          $description_contents = $xml->createCDATASection(htmlentities($row->urunozellik));  
          $description_node->appendChild($description_contents);
        
          //Published date
          $date_rfc = gmdate(DATE_RFC2822, strtotime($row->published));
          $pub_date = $xml->createElement("pubDate", turkce_tarih($row->tarih));  
          $pub_date_node = $item_node->appendChild($pub_date);
     
        }
    }
    echo $xml->saveXML();
    ?>
    Kendi kullanmış olduğum RSS kodlarım. Bende internetten bulup kendime göre düzenledim. Sizde bunu kendinize göre düzenleyebilirsiniz.

    Kodların çalıştığını görmek isterseniz buraya tıklamanız yeterli.
    Hocam çok çok teşekür ederim ama ne yazık ki bende çalışmadı "Bu sayfa çalışmıyor http error 500" hatası verdi sunucu yapılandırılmaları, php versiyon, mysql versiyon gibi birçok faktör var sanırım uyum sağlamadı. Ama verdiğiniz kodlardan birkaç kısım ile tarih vb gibi ayarlar yapılabilinir sanırım tekrardan çok teşekür ederim hocam...
  • 25-05-2021, 19:51:14
    #7
    dudbox adlı üyeden alıntı: mesajı görüntüle
    Hocam çok çok teşekür ederim ama ne yazık ki bende çalışmadı "Bu sayfa çalışmıyor http error 500" hatası verdi sunucu yapılandırılmaları, php versiyon, mysql versiyon gibi birçok faktör var sanırım uyum sağlamadı. Ama verdiğiniz kodlardan birkaç kısım ile tarih vb gibi ayarlar yapılabilinir sanırım tekrardan çok teşekür ederim hocam...
    Rica ederim hocam. Yalnız ben PDO kullanmamıştım. O konuda da uyarayım.
  • 25-05-2021, 19:57:52
    #8
    tuzlatuning adlı üyeden alıntı: mesajı görüntüle
    Rica ederim hocam. Yalnız ben PDO kullanmamıştım. O konuda da uyarayım.
    Evet hocam fark ettim anlamadıgım olay PDO'yu benim host neden çalıştırmadı ? cpanelden php settings ten falan PDO yumu açmamız gerekiyor ?
  • 25-05-2021, 20:00:39
    #9
    dudbox adlı üyeden alıntı: mesajı görüntüle
    Evet hocam fark ettim anlamadıgım olay PDO'yu benim host neden çalıştırmadı ? cpanelden php settings ten falan PDO yumu açmamız gerekiyor ?
    İsterseniz kodları localhost üzerinde deneyin. Sonra cPanel üzerinden PHP sürümünü 7.3 ve ya 7.4 sürümüne çekip öyle deneyin.
    Bütün bu işlemleri yapmadan önce mutlaka yedek almayı unutmayın.