• 11-08-2007, 14:57:35
    #1
    arkadaşlar işte size youtube bot fakat databaseye kaydederken tr karakter hatası alıyorum db ile çok denedim latin 1 yaptım latin 5 yaptım ama yoq olmadı işte kodlar

    ayarlar.php
    <?
    $site_adi = "Video Merkezi";
    $dbadi = "sistem";
    $dbhost = "localhost";
    $dbuser = "root";
    $dbpass = "";
    $baglan = mysql_connect($dbhost,$dbuser,$dbpass);
    ?>



    videoekle.php

    <?
    include("ayarlar.php");
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Youtube Bot By Selim61-www.sistembilgisi.com</title>
    <meta http-equiv="Content-Language" content="tr">
    </head>
    <body>
    <form action=eklee.php method="post"><?
    $sql = 'SELECT * FROM kategori ORDER BY id ASC';
    $query = mysql_query( $sql );
    ?>
    <p>
    <strong>Kategori</strong> :
    <select name="id">
    <?php
    while( $row = mysql_fetch_assoc( $query ) ){ ?>
    <option value="<?php echo $row['id']; ?>" selected><?php echo $row['adi']; ?></option>
    <?php } ?>
    </select>
    </p>
    <p>
    <strong>Anahtar Kelime</strong> :
    <input type="text" name="tag" value="<? echo $_POST['tag'];?>">
    </p>
    <p>
    <strong>Ka? Sayfa</strong> :
    <input type="text" name="page" value="<? echo $_POST['page'];?>" >
    </p>
    <p>
    <input type="submit" value=" Kaydet">
    </p>
    </form>
    </body>
    </html>



    eklee.php

    <?php
    include("ayarlar.php");
    class youTube {
    function get_feed($feed){

    $ch = curl_init();
    $timeout = 0;
    curl_setopt ($ch, CURLOPT_URL, $feed);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $xml = curl_exec($ch);
    curl_close($ch);
    return $xml;
    }
    function yt_results($xml, $howmany){

    preg_match_all("/\<url\>(.+?)\<\/url\>/smi",$xml, $url);
    preg_match_all("/\<description\>(.+?)\<\/description\>/smi",$xml, $description);
    preg_match_all("/\<title\>(.+?)\<\/title\>/smi",$xml, $title);
    preg_match_all("/\<id\>(.+?)\<\/id\>/smi",$xml, $id);
    preg_match_all("/\<length_seconds\>(.+?)\<\/length_seconds\>/smi",$xml, $length_seconds);
    preg_match_all("/\<rating_avg\>(.+?)\<\/rating_avg\>/smi",$xml, $rating_avg);
    preg_match_all("/\<view_count\>(.+?)\<\/view_count\>/smi",$xml, $view_count);
    preg_match_all("/\<video\>(.+?)\<\/video\>/smi",$xml, $video);
    preg_match_all("/\<thumbnail_url\>(.+?)\<\/thumbnail_url\>/smi",$xml, $thumb_nail);

    array_shift($url);
    array_shift($thumb_nail);
    array_shift($description);
    array_shift($title);
    array_shift($id);
    array_shift($length_seconds);
    array_shift($rating_avg);
    array_shift($view_count);
    array_shift($video);

    for($i=0;$i<count($description[0]);$i++){

    $description[0][$i] = preg_replace("/ $description[0][$i] = html_entity_decode($description[0][$i],ENT_QUOTES);
    }
    for($i=0;$i<count($title[0]);$i++){

    $title[0][$i] = preg_replace("/ $title[0][$i] = html_entity_decode($title[0][$i],ENT_QUOTES);
    }

    $total_videos = count($video[0]);


    if($howmany > $total_videos){
    $howmany = $total_videos;
    }

    if(!$howmany || $howmany == 0){
    $howmany = $total_videos;
    }

    global $kid;
    for($i = 0; $i<$howmany; $i++){
    $yenimetin=str_replace($harfler,$harfler2,$title[0][$i]);
    $metin=str_replace($harfler,$harfler2,$description[0][$i]);
    $tarihsaat = date("Y-m-d H:i:s");

    $query="insert into video values('','".$kid."','".$yenimetin."','".$metin."' ,'".$thumb_nail[0][$i]."','http://www.youtube.com/v/".$id[0][$i]."&autoplay=1','1','".$length_seconds[0][$i]."','".$tarihsaat."','0','1','0')";
    mysql_query("$query");
    print "".$yenimetin.";<br>";
    }
    }

    function yt_featured($dev_id, $howmany){

    $feed = "http://www.youtube.com/api2_rest?met...dev_id=$dev_id";

    $xml = $this->get_feed($feed);

    $this->yt_results($xml, $howmany);
    }
    function yt_user($dev_id, $user, $howmany){

    $feed = "http://www.youtube.com/api2_rest?met..._id&user=$user";

    $xml = $this->get_feed($feed);

    $this->yt_results($xml, $howmany);
    }
    function yt_tag($dev_id, $tag, $page){
    $feed = "http://www.youtube.com/api2_rest?met...tag&page=$page";

    $xml = $this->get_feed($feed);

    $this->yt_results($xml, $howmany);

    }
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Video Merkezi</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
    </head>
    <body>
    <?
    $sayfa = $HTTP_POST_VARS["page"];
    $tagi = $HTTP_POST_VARS["tag"];
    $kid = $HTTP_POST_VARS["id"];
    $tag=str_replace($yeni,$eski,$tagi);
    $yt = new youTube;
    print "<p>Videolar: ".$kid."</p>";
    for($page = 0; $page<=$sayfa; $page++){
    $yt->yt_tag("OrQTXfQsgdY", $tag, $page);
    }
    ?>
    </body>
    </html>



    Yazılardaki ? hatasını demiyorum sadece veritabanına kaydettiği videolarda açıklamada karakter hatası var
  • 11-08-2007, 15:22:44
    #2
    Üyeliği durduruldu
    eklee.php
     
     
     <?php
     include("ayarlar.php");
     class youTube {
     function get_feed($feed){
     
     $ch = curl_init();
     $timeout = 0;
     curl_setopt ($ch, CURLOPT_URL, $feed);
     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
     $xml = curl_exec($ch);
     curl_close($ch);
     return $xml;
     }
     function yt_results($xml, $howmany){
     
     preg_match_all("/\<url\>(.+?)\<\/url\>/smi",$xml, $url);
     preg_match_all("/\<description\>(.+?)\<\/descripti  on\>/smi",$xml, $description);
     preg_match_all("/\<title\>(.+?)\<\/title\>/smi",$x  ml, $title);
     preg_match_all("/\<id\>(.+?)\<\/id\>/smi",$xml, $id);
     preg_match_all("/\<length_seconds\>(.+?)\<\/length  _seconds\>/smi",$xml, $length_seconds);
     preg_match_all("/\<rating_avg\>(.+?)\<\/rating_avg  \>/smi",$xml, $rating_avg);
     preg_match_all("/\<view_count\>(.+?)\<\/view_count  \>/smi",$xml, $view_count);
     preg_match_all("/\<video\>(.+?)\<\/video\>/smi",$x  ml, $video);
     preg_match_all("/\<thumbnail_url\>(.+?)\<\/thumbna  il_url\>/smi",$xml, $thumb_nail);
     
     array_shift($url);
     array_shift($thumb_nail);
     array_shift($description);
     array_shift($title);
     array_shift($id);
     array_shift($length_seconds);
     array_shift($rating_avg);
     array_shift($view_count);
     array_shift($video);
     
     for($i=0;$i<count($description[0]);$i++){
     
     $description[0][$i] = preg_replace("/ $description[0][$i] = htmlspecialchars_decode($description[0][$i],ENT_QUOTES);
     }
     for($i=0;$i<count($title[0]);$i++){
     
     $title[0][$i] = preg_replace("/ $title[0][$i] = htmlspecialchars_decode($title[0][$i],ENT_QUOTES);
     }
     
     $total_videos = count($video[0]);
     
     
     if($howmany > $total_videos){
     $howmany = $total_videos;
     }
     
     if(!$howmany || $howmany == 0){
     $howmany = $total_videos;
     }
     
     global $kid;
     for($i = 0; $i<$howmany; $i++){
     $yenimetin=str_replace($harfler,$harfler2,$title[0][$i]);
     $metin=str_replace($harfler,$harfler2,$description[0][$i]);
     $tarihsaat = date("Y-m-d H:i:s");
     
    $query="insert into video values('','".$kid."','".$yenimetin."','".$metin."' ,'".$thumb_nail[0][$i]."','http://www.youtube.com/v/".$id[0][$i]."&autoplay=1','1','".$length_seconds[0][$i]."','".$tarihsaat."','0','1','0')";
     mysql_query("$query");
     print "".$yenimetin.";<br>";
     }
     }
     
     function yt_featured($dev_id, $howmany){
     
     $feed = "http://www.youtube.com/api2_rest?met...dev_id=$dev_id";
     
     $xml = $this->get_feed($feed);
     
     $this->yt_results($xml, $howmany);
     }
     function yt_user($dev_id, $user, $howmany){
     
     $feed = "http://www.youtube.com/api2_rest?met..._id&user=$user";
     
     $xml = $this->get_feed($feed);
     
     $this->yt_results($xml, $howmany);
     }
     function yt_tag($dev_id, $tag, $page){
     $feed = "http://www.youtube.com/api2_rest?met...g&page=$pag  e";
     
     $xml = $this->get_feed($feed);
     
     $this->yt_results($xml, $howmany);
     
     }
     }
     ?>
     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd">
     <html>
     <head>
     <title>Video Merkezi</title>
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
     </head>
     <body>
     <?
     $sayfa = $HTTP_POST_VARS["page"];
     $tagi = $HTTP_POST_VARS["tag"];
     $kid = $HTTP_POST_VARS["id"];
     $tag=str_replace($yeni,$eski,$tagi);
     $yt = new youTube;
     print "<p>Videolar: ".$kid."</p>";
     for($page = 0; $page<=$sayfa; $page++){
     $yt->yt_tag("OrQTXfQsgdY", $tag, $page);
     }
     ?>
     </body>
     </html>
    dene bakalım. Bu arada yoq diye birşey yoktur
  • 11-08-2007, 15:29:44
    #3
    denedim

    önce şurda ufak hatalar vardı
    preg_match_all("/\<video\>(.+?)\<\/video\>/smi",$ xml, $video);
    preg_match_all("/\<thumbnail_url\>(.+?)\<\/thumb nail_url\>/smi",$xml, $thumb_nail);

    onları giderdim

    sonra şöle hata verdi

    Parse error: syntax error, unexpected ';' in /home2/soccertu/public_html/sctr/ara/video/eklee.php on line 43
  • 11-08-2007, 17:55:05
    #4
    Üyeliği durduruldu
    syntax hatası 43. satır'a bak ; unutmuşsun
    Bu arada 37. satırda şöyleymiş
     for($i=0;$i<count($description[0]);$i++){
     
     $description[0][$i] = preg_replace("/ $description[0][$i] = htmlspecialchars_decode($description[0][$i],ENT_QUOTES);
     }
     for($i=0;$i<count($title[0]);$i++){
     
     $title[0][$i] = preg_replace("/ $title[0][$i] = htmlspecialchars_decode($title[0][$i],ENT_QUOTES);
     }
    bunu şununla değiştir
     for($i=0;$i<count($description[0]);$i++){
     
     $description[0][$i] = preg_replace("/". $description[0][$i] = htmlspecialchars_decode($description[0][$i],ENT_QUOTES);
     }
     for($i=0;$i<count($title[0]);$i++){
     
     $title[0][$i] = preg_replace("/". $title[0][$i] = htmlspecialchars_decode($title[0][$i],ENT_QUOTES);
     }
  • 13-08-2007, 09:00:49
    #5
    olmadı kardeş 39 . satırda ; hatası veriyo yani 39 . satır şura

    $title[0][$i] = preg_replace("/". $title[0][$i] = htmlspecialchars_decode($title[0][$i],ENT_QUOTES);
  • 13-08-2007, 10:43:25
    #6
    Üyeliği durduruldu
    $title[0][$i] = preg_replace("/". $title[0][$i] = htmlspecialchars_decode($title[0][$i]),ENT_QUOTES);
  • 13-08-2007, 17:35:19
    #7
    preg_replace fonksiyonunu bildiğim kadarı ile iki paramtre ile çalışmıyodu. eğer php5 e onu eklemişlerse bilmiyorum ama normalde
    preg_replace($giren,$cikan,$degismesigereken);

    şeklinde çalışıyo, yukarı da iki parametre var

    sayfanın başına
    if(!is_function(htmlspecialchars_decode)) {
    function htmlspecialchars_decode ($str) {
    return strtr($str, array_flip(get_html_translation_table(HTML_SPECIAL CHARS)));
    }
    } ekle eğer sunucun php4 se bi sonraki mesajın da diğer hataya yönelik olmasın
    sayfada geçen
    $description[0][$i] = preg_replace("/ $description[0][$i] = htmlspecialchars_decode($description[0][$i],ENT_QUOTES);
    şeklindeki satırları da
    $description[0][$i] = htmlspecialchars_decode($description[0][$i],ENT_QUOTES);
    haline getirirsen çevrim işi tamamlanacaktır
  • 13-08-2007, 18:55:27
    #8
    Seyranli dediklerini yaptım kaydete basına bu sefer ekranda sadece
    Videolar: 1 yazıyo

    önceden kaydederken eklediği videoların başlını falan ekrana yazdırıyodu ama tr karakter hatası vardı db ye kayıtta falan
  • 13-08-2007, 19:46:17
    #9
    Üyeliği durduruldu
    botu bi yerden hatırlıyorum bari dosyaların isimlerini değiştirseydin.Sana yardım etmek isterdim ama şartlar olgunlaşmadı