• 25-05-2021, 20:02:04
    #10
    tuzlatuning adlı üyeden alıntı: mesajı görüntüle
    İ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.
    Öyle bi deneyim hocam birde çok teşekür ederim
  • 25-05-2021, 20:06:20
    #11
    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 size zahmet kullandıgınız php sürümü ayarları nedir ? "PDO" ların hangilerini açmamız gerekiyor ? ve diğer seçenekler sizdekinin bir ekran görüntüsünü rica edebilirmiyim ?

  • 25-05-2021, 20:11:18
    #12
    dudbox adlı üyeden alıntı: mesajı görüntüle
    Hocam size zahmet kullandıgınız php sürümü ayarları nedir ? "PDO" ların hangilerini açmamız gerekiyor ? ve diğer seçenekler sizdekinin bir ekran görüntüsünü rica edebilirmiyim ?



    Ben kontrolü bu şekilde sağlıyorum hocam. Dediğiniz kısım bende hata veriyor. Muhtemelen bende de sizde ki gibi gözükecektir.
  • 25-05-2021, 21:24:28
    #13
    @tuzlatuning; Anladım hocam... Arkadaşlar işin içinden çıkamıyorum herşeyi halettim başlıklar gelmiyo başlık yerine tarih geldi başlık tagını değiştirip tarih tagı girdim nerde hata yapıyorum arkadaşlar ufak bir şey var çözemiyorum bi yardım eli uzatıverseniz ..

    <?php
    header("Content-Type: application/xml; charset=UTF-8" , true);
    header('Pragma: public');
    header('Cache-control: private');
    header('Expires: -1');
    date_default_timezone_set('UTC');
    define('slash','/yazi/');
    $url = 'https://'.$_SERVER['HTTP_HOST'];
    
    $rss = new rss;
    $rssTitle = 'Latest Updates';
    $rssDescription = 'Get Latest Updates Of This Site';
    $rss->head($rssTitle,$rssDescription,$url);
    $date1 = $_REQUEST['date'];
    echo date('D, d M Y H:i:s T', strtotime($date1));
    $query = "SELECT * FROM news ORDER BY id";
    if ($result = mysqli_query($rss->conn(), $query)) {
    while ($row = mysqli_fetch_assoc($result)) {
    $link = $url.slash.rss::clean($row['news_name']);
    $baslik = ($row['news_name']);
    $date= date("D, d M Y H:i:s T", $row['date']);
    
    
    
    
    if (preg_match('/^.{1,500}\b/s', $row['news_description'], $match))
    {
    $description=$match[0].'...';
    }
    rss::feed(htmlspecialchars($row['date']),$link,htmlspecialchars($description),$date,);
    }
    mysqli_free_result($result);
    }
    
    $rss->foot();
    $rss->close();
    
    
    class rss
    {
    public $conn;
    public function __construct()
    {
    if(!$this->conn())
    {
    die('Failed to connect with MySQL');
    self::close();
    }
    }
    public function conn()
    {
    $host = "localhost";
    $user = "---";
    $pass = "---";
    $name = "----";
    $conn = mysqli_connect($host,$user,$pass,$name);
    
    if (mysqli_connect_errno())
    {
    die("Failed to connect with MySQL: ".mysqli_connect_error());
    }
    else
    {
    return $this->conn = $conn;
    }
    }
    public function head($description,$siteurl)
    {
    echo '<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">';
    echo '<channel>';
    echo '<title>'.$rssTitle.'</title>';
    echo '<link>'.$siteurl.'</link>';
    echo '<description>'.$description.'</description>';
    echo '<language>en-us</language>';
    echo '<atom:link href="'.$siteurl.'/rss.xml" rel="self" type="application/rss+xml"/>';
    
    }
    public function feed($news_name,$url,$description,$date)
    {
    echo '
    <item>
    <lastBuildDate>'.$news_name.'</lastBuildDate>
    <link>'.$url.'</link>
    <description>'.$description.'</description>
    <title>'.$baslik.'</title>
    </item>
    ';
    }
    public function foot()
    {
    echo '</channel>';
    echo '</rss>';
    }
    public function clean($string) {
    $string = strtolower( preg_replace('@[\W_]+@', '-', $string) );
    $string = rtrim($string,'-');
    $string = strtolower($string);
    return $string;
    }
    
    public function close()
    {
    mysqli_close(self::conn());
    }
    }
    
    ?>

    Ekran çıktısı : https://www.kriptoparapiyasa.com/rss.php