• 27-05-2010, 14:46:32
    #1
    Php ye yeni başladım sayılır.Amacım işe yarar öğeleri parça parça öğrenmek.En basit olan komutlara zaten aşinayım.Döngüsel olarak 4 kere alıp kaldığım java dersine benzediği ve onda da biraz işe yarasın diye başladım denebilir

    Neyse soruma gelirsek. file_get_contents ile veri çekiyorum. Adres otomatik olarak sürekli değiştiği için her seferinde yeni kategoriyi çekip içine giriyorum ve ilk sıradaki konuya girip içeriğini alıyorum. Fakat yapamadığım konu içerisine girince içerikle gelen resimleri resize yapamıyorum.Tüm resimlerin genişliğini 500px yapmak istiyorum.

    denediklerim ;

    $mac4[0] = preg_replace('!width=".*?"!s', '500', $mac3[0]);

    $mac4[0] = replace_content_inside_delimiters('width="','"', '500', $mac3[0]);


    (araya koyunca değişken isimlerini değiştirdim , $subject = $mac4[0] ; yaptım , unutmadım yani )

    Ama çalıştıramadım . Ya hiçbirşey değişmedi yada hata aldım.Sizce nasıl yapabilirim bunu.


    konu.php
    <?php 
    $site   = file_get_contents("http://www.voleybol.org.tr/sistem/");
    $mac  = explode('<td width=100% 
    
    background=images/baslik_sablon.gif>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
    
    sp;&nbsp;&nbsp;<font family=Arial color=white><strong><a href="',$site);
    $mac  = explode('" /><font color=#FFFFFF>Güncel Haberler</a></td>',$mac[1]);
    
    $URL0="http://www.voleybol.org.tr$mac[0]"; 
    
    // Güncel haberlere gidildi
    
    $site3   = file_get_contents("$URL0");
    $mac2  = explode('<td valign=top valign=top align=left><a href="',$site3);
    $mac2  = explode('" alt="',$mac2[1]);
    $URL2="http://www.voleybol.org.tr$mac2[0]"; 
    
    //Ilk konu urlsi bastırıldı
    
    $site4   = file_get_contents("$URL2");
    $mac3  = explode('/></center><br />',$site4);
    $mac3  = explode('Okunma Sayısı',$mac3[1]);
    
    $search = array('/sistem/', '3343r34r1dd4d');
    $replace = array('http://www.voleybol.org.tr/sistem/', 'd23d34d43r344f34');
    $subject = $mac3[0] ;
    
    echo  '<table width="50%">' ; 
    echo str_replace($search, $replace, $subject);
    echo  '</table>' ;
    
    // ilk konu içerği bastırıldı.
    
    ?>
  • 27-05-2010, 16:18:09
    #2
    Üyeliği durduruldu
    http://www.white-hat-web-design.co.u...e-resizing.php
    class ı indirelim önce

    daha sonra resimlere uygulayalım.
    //height width ayarları için
    
    <?php
       include('SimpleImage.php');
       $image = new SimpleImage();
       $image->load('picture.jpg');
       $image->resize(250,400);
       $image->save('picture2.jpg');
    ?>
    
    //sadece width ayarı için
    <?php
       include('SimpleImage.php');
       $image = new SimpleImage();
       $image->load('picture.jpg');
       $image->resizeToWidth(250);
       $image->save('picture2.jpg');
    ?>
  • 27-05-2010, 17:44:22
    #3
    <?php 
    $site   = file_get_contents("http://www.voleybol.org.tr/sistem/");
    $mac  = explode('<td width=100% 
    
    background=images/baslik_sablon.gif>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
    
    sp;&nbsp;&nbsp;<font family=Arial color=white><strong><a href="',$site);
    $mac  = explode('" /><font color=#FFFFFF>Güncel Haberler</a></td>',$mac[1]);
    
    $URL0="http://www.voleybol.org.tr$mac[0]"; 
    
    // Güncel haberlere gidildi
    
    $site3   = file_get_contents("$URL0");
    $mac2  = explode('<td valign=top valign=top align=left><a href="',$site3);
    $mac2  = explode('" alt="',$mac2[1]);
    $URL2="http://www.voleybol.org.tr$mac2[0]"; 
    
    //Ilk konu urlsi bastırıldı
    
    $site4   = file_get_contents("$URL2");
    $mac3  = explode('/></center><br />',$site4);
    $mac3  = explode('Okunma Sayısı',$mac3[1]);
    
    $search = array('/sistem/', '3343r34r1dd4d');
    $replace = array('http://www.voleybol.org.tr/sistem/', 'd23d34d43r344f34');
    $subject = $mac3[0] ;
    
    $site6   = file_get_contents("$URL2");
    $mac5  = explode('<td valign=top><center><img src="',$site6);
    $mac5  = explode('" ="100%" alt=',$mac5[1]);
    $URL5="http://www.voleybol.org.tr/sistem/$mac5[0]"; 
    
    
    
    @setlocale(LC_ALL, 'turkish'); 
    $resim = strftime("%d-%B-%Y-%H-%M-%S");
    
    include('SimpleImage.php');
    $image = new SimpleImage();
    $image->load("$URL5");
    $image->resize(250,400);
    $image->save("$resim.jpg"); 
    
    echo "<img src='$resim.jpg'  />";
    
    
    
    echo  '<table width="50%">' ; 
    echo str_replace($search, $replace, $subject);
    echo  '</table>' ;
    
    // ilk konu içerği bastırıldı.
    
    ?>

    Teşekkür ederim güzel çalıştı , her çalıştığında resmi o anki tarih ve saate göre kaydediyor.Curl ve database ekleim mi tek konuluk bot oldu gibi Ama ilk önce content karşılaştırması yapıp aynı konuyu tekrar bastırmamak var.
  • 27-05-2010, 19:22:29
    #4
    Son hali böyle oldu.



    <?php 
    $site   = file_get_contents("http://www.voleybol.org.tr/sistem/");
    $mac  = explode('<td width=100% 
    
    background=images/baslik_sablon.gif>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
    <font family=Arial color=white><strong><a href="',$site);
    $mac  = explode('" /><font color=#FFFFFF>Güncel Haberler</a></td>',$mac[1]);
    
    $URL0="http://www.voleybol.org.tr$mac[0]"; 
    
    // Güncel haberlere gidildi
    
    $site3   = file_get_contents("$URL0");
    $mac2  = explode('<td valign=top valign=top align=left><a href="',$site3);
    $mac2  = explode('" alt="',$mac2[1]);
    $URL2="http://www.voleybol.org.tr$mac2[0]"; 
    
    //Ilk konu urlsi bastırıldı
    
    $site4   = file_get_contents("$URL2");
    $mac3  = explode('</strong></center><br /><p>&nbsp;</p>',$site4);
    $mac3  = explode('Okunma Sayısı',$mac3[1]);
    
    
    
    $search = array('/sistem/', '<div><span style="font-size: 14pt">', '</span></div>', '<div>&nbsp;</div>','<br /><br /><font size=2px>');
    $replace = array('http://www.voleybol.org.tr/sistem/', ' ', ' ', ' ', ' ');
    $subject = $mac3[0] ;
    
    
    
    
    //baslik baslangiç
    $baslikadres  = file_get_contents("$URL2");
    $baslik1  = explode('</center><br /><center><strong><font size=2px>',$baslikadres);
    $baslik1  = explode('</strong></center><br />',$baslik1[1]);
    
    //baslik bitiş
    
    
    //resim baslangic
    
    $site6   = file_get_contents("$URL2");
    $mac5  = explode('<td valign=top><center><img src="',$site6);
    $mac5  = explode('" ="100%" alt=',$mac5[1]);
    $URL5="http://www.voleybol.org.tr/sistem/$mac5[0]"; 
    
    
    
    @setlocale(LC_ALL, 'english'); 
    $resim = strftime("%d-%B-%Y-%H-%M-%S");
    
    include('SimpleImage.php');
    $image = new SimpleImage();
    $image->load("$URL5");
    $image->resize(400,400);
    $image->save("$resim.jpg"); 
    
    //resim bitis
    
    
    // ilk konu içerği bastırıldı.
    
    ?>
    
    
    
    
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    
    <meta equiv="content-type" content="text/html;charset="windows-1254">
    <meta equiv="content-type" content="text/html;charset="iso-8859-9">
    <meta name="description" content="Site" />
    <meta name="keywords" content="Site" />
    <title><?php echo $resim; ?></title>
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    
    <div id="body1">
    <table >
    <tr><center><h2><?php  echo $baslik1[0] ; ?></h2></center></br></tr>
    <tr><center><img src='<?php echo $resim; ?>.jpg'   /></center></tr>
    <tr><p>&nbsp;&nbsp;&nbsp;<?php echo str_replace($search, $replace, $subject); ?></p></tr>
    </div>
    
    </table>
    </body>
    </html>
    Herhangi bir projesinde örnek olarak kullanıcak arkadaşlar SimpleImage.php dosyasını bu dosyanın yanında bulundurmayı unutmasınlar.

    Düzeltme1 : tarih olayını ingilizce yaptım.Türkçe olunca resim bulunamıyorum sitede.