merhaba.
rastgele çekmede bir sorun var.
5er 5er çekiyor.
yani rastgele üye adı çekiyor fakat çektiği üye adı arka arkaya 5 mesaj yazıyor, sonra rastgele başka bir üye adı ile 5 mesaj ardı ardına yazıyor. ve döngü devam ediyor.
bakılacak sayfa muhtemelen budur ;
konu çekme sayfası
<?
include("ayarlar.php");
$kullanici=kullanici_bilgi_al();
if(! isset($_GET[mevcut_sayfa])) $mevcut_sayfa=1; else $mevcut_sayfa=$_GET[mevcut_sayfa];
if($mevcut_sayfa>$_GET[baslik_max_sayfa]): ?>
<script>
document.location.href='konu_indir.php?<? echo "veritabani=ok&ilk_mesaj=$_GET[ilk_mesaj]&baslik_max_sayfa=$_GET[baslik_max_sayfa]&resim=$_GET[resim]&tag=$_GET[tag]&eklenecek_kategori=$_GET[eklenecek_kategori]&dis_resim=$_GET[dis_resim]&forum_anasayfa=".urlencode($kullanici[2]).""; ?>';
</script>
<? die("bitti.");
endif;
if($mevcut_sayfa==1): cookie_dosya_temizle(); giris_yap();
else:
echo "Ýndiriliyor. Lütfen bekleyin...<P>"; flush(); ob_flush();
endif;
if($_GET[veritabani]=="ok" && !isset($_GET[konu_adres])):
if(! $sonuc=mysql_fetch_assoc(mysql_query("SELECT * FROM vbulletin_bot WHERE parent = '0' AND is_crawled NOT LIKE '%1%' AND link LIKE '%".urldecode($_GET[forum_anasayfa])."%' ORDER BY `id` DESC LIMIT 1"))) die("<B>indirme iþlemi tamamen bitti!!!</B>");
$_GET[konu_adres]=$sonuc[link];
echo $_GET[konu_adres]."<P>";
$icerik=sayfa_indir($_GET[konu_adres]);
else:
$icerik=sayfa_indir($_GET[konu_adres]);
endif;
$kategori_sayfa=kategori_adres_duzelt($_GET[konu_adres]);
//echo $kategori_sayfa."<br>";
//echo htmlentities($icerik);
if(! isset($_GET[eklenen_id])):
$sorgu=mysql_query("INSERT INTO `vbulletin_bot` (`link`, `is_crawled`, `parent`, `eklenecek_kategori`) VALUES ('$_GET[konu_adres]', '1', '0', '$_GET[eklenecek_kategori]')");
$eklenen_id=mysql_insert_id();
else:
$sorgu=mysql_query("INSERT INTO `vbulletin_bot` (`link`, `is_crawled`, `parent`, `eklenecek_kategori`) VALUES ('$_GET[konu_adres]', '1', '$_GET[eklenen_id]', '$_GET[eklenecek_kategori]')");
$eklenen_id=$_GET[eklenen_id];
endif;
// Konu baþlýðýný bir kereliðine al
$satir=explode('id="td_post_', $icerik);
$x=$satir[1]; //bölünmüþ strong içeriyor.
$x=explode('<strong>', $x);
$x=$x[1];
$x=explode('</strong>', $x);
$baslik=strip_tags(trim($x[0]));
//------------------------------------
// Mesaj içeriklerini al hepsini
$attach_array=array();
if(eregi('<!-- message -->', $icerik)):
$sil=array('</div>');
$duz=array('');
$mesaj_icerik=array();
$satir=explode('<!-- message -->', $icerik);
for($i=1; $i<(sizeof($satir)+1); $i++):
//Attach alýmý
if($_GET[resim]=="ON" && preg_match_all('<a.*href.*attachment.php.*a>', $satir[$i], $matches, PREG_SET_ORDER)):
echo "attachment buldu.";
foreach($matches[0] as $key => $value){
//echo $value;
$dosya_attach=explode('href="', $value);
$dosya_attach=explode('"', $dosya_attach[1]);
if(eregi("http", $dosya_attach[0]))
$dosya_attach=$dosya_attach[0];
else
$dosya_attach=$kullanici[2].$dosya_attach[0];
echo $dosya_attach;
if($chuck=file_get_contents($dosya_attach)):
//echo $dosya_attach."<br>";
$dosya_ismi=random_dosyaismi();
$dosya=fopen($dosya_ismi, "w"); fputs($dosya, $chuck); fclose($dosya);
$h=explode("</a>", $value);
$h=explode(">", $h[0]);
$h=$h[1];
$h=explode(".", $h);
$extension=$h[(sizeof($h)-1)];
//echo $mime_type;
//echo $dosya_ismi."<br>";
$byte_size=strlen($chuck);
if(eregi("image", $mime_type)):
list($width, $height)=getimagesize($dosya_ismi);
$new_height=@round((($height*72) / $width)); //200 yerine standart ratio
$chuck2=file_get_contents($bot_adres."show_image.php?filename=".urlencode($dosya_ismi)."&width=72&height=$new_height");
$byte_size2=strlen($chuck2);
endif;
//$extension=explode("/", $mime_type); $extension=$extension[(sizeof($extension)-1)];
$yeni_dosya_ismi=str_replace(".", "", $dosya_ismi)."".$extension;
$file_hash=hash_file('md5', $dosya_ismi);
$attrs=array('0' => $yeni_dosya_ismi, '1' => addslashes($chuck), '2' => $byte_size, '3' => addslashes($chuck2), '4' => $bytesize2, '5' => $extension, '6' => $file_hash);
$dfd=sizeof($mesaj_icerik);
$attach_array["$dfd"]=$attrs;
unlink($dosya_ismi);
endif;
}
endif;
//Attach alýmý son.
$x=explode('<!-- / message -->', $satir[$i]);
$mi=$x[0];
$x=explode('<div id="post_message_', $mi);
$mi=$x[1];
$post_sil="";
$v=0; while($mi[$v]!=='>'):
$post_sil.=$mi[$v];
$v++;
if($v>400) break;
endwhile;
if(strlen($mi)<2) continue;
array_push($sil, $post_sil.">"); array_push($duz, '');
$mi=trim(str_replace($sil, $duz, $mi));
array_push($mesaj_icerik, $mi);
endfor;
else:
$sil=array('</div>');
$duz=array('');
$mesaj_icerik=array();
$satir=explode('id="post_message_', $icerik);
for($i=1; $i<(sizeof($satir)+1); $i++):
//if(! ($i % 2)) continue;
//Attach alýmý
if($_GET[resim]=="ON" && preg_match_all('<a.*href.*attachment.php.*a>', $satir[$i], $matches, PREG_SET_ORDER)):
echo "attachment buldu.";
foreach($matches[0] as $key => $value){
//echo $value;
$dosya_attach=explode('href="', $value);
$dosya_attach=explode('"', $dosya_attach[1]);
if(eregi("http", $dosya_attach[0]))
$dosya_attach=$dosya_attach[0];
else
$dosya_attach=$kullanici[2].$dosya_attach[0];
echo $dosya_attach;
if($chuck=file_get_contents($dosya_attach)):
//echo $dosya_attach."<br>";
$dosya_ismi=random_dosyaismi();
$dosya=fopen($dosya_ismi, "w"); fputs($dosya, $chuck); fclose($dosya);
$h=explode("</a>", $value);
$h=explode(">", $h[0]);
$h=$h[1];
$h=explode(".", $h);
$extension=$h[(sizeof($h)-1)];
//echo $mime_type;
//echo $dosya_ismi."<br>";
$byte_size=strlen($chuck);
if(eregi("image", $mime_type)):
list($width, $height)=getimagesize($dosya_ismi);
$new_height=@round((($height*72) / $width)); //200 yerine standart ratio
$chuck2=file_get_contents($bot_adres."show_image.php?filename=".urlencode($dosya_ismi)."&width=72&height=$new_height");
$byte_size2=strlen($chuck2);
endif;
//$extension=explode("/", $mime_type); $extension=$extension[(sizeof($extension)-1)];
$yeni_dosya_ismi=str_replace(".", "", $dosya_ismi)."".$extension;
$file_hash=hash_file('md5', $dosya_ismi);
$attrs=array('0' => $yeni_dosya_ismi, '1' => addslashes($chuck), '2' => $byte_size, '3' => addslashes($chuck2), '4' => $bytesize2, '5' => $extension, '6' => $file_hash);
$dfd=sizeof($mesaj_icerik);
$attach_array["$dfd"]=$attrs;
unlink($dosya_ismi);
endif;
}
endif;
//Attach alýmý son.
$x=explode('</td>', $satir[$i]);
$mi=$x[0];
$post_sil="";
$v=0; while($mi[$v]!=='>'):
$post_sil.=$mi[$v];
$v++;
if($v>400) break;
endwhile;
if(strlen($mi)<2) continue;
array_push($sil, $post_sil.">"); array_push($duz, '');
$mi=trim(str_replace($sil, $duz, $mi));
array_push($mesaj_icerik, $mi);
endfor;
endif;
//--------------------------------------------
// Mesajlarý veritabanýna gir
$i=0;
$bsl=yazi_duzelt($baslik);
foreach($mesaj_icerik as $mesaj){
if($i>0 && $_GET[ilk_mesaj]=="ON") break;
if($_GET[dis_resim]!=="ON")
$mesaj=html_entity_decode(strip_tags(yazi_duzelt($mesaj), '<a><b><i><img><br><div>')); else
$mesaj=html_entity_decode(strip_tags(yazi_duzelt($mesaj), '<a><b><i><br><div>'));
if($i>0 OR isset($_GET[thread_id])) $baslik="Cvp: ".$bsl;
$mesaj_sayi = @mysql_query("select posts,userid from user where username = '".$forum_member."'") or die("Kullanýcý mesaj sayýsý alýnamadý!");
$mesaj_sayisi = @mysql_result($mesaj_sayi, 0, "posts") or $mesaj_sayisi = 0;
$u_id = @mysql_result($mesaj_sayi, 0, "userid") or die("Userid Alýnamadý. Kullanýcý adý yanlýþ!");
$forum_mesaj = @mysql_query("select threadcount,replycount from forum where forumid = '".$_GET[eklenecek_kategori]."'") or die("Forum mesaj sayýsý alýnamadý! Belirtilen id de bir forum yok!");
$forum_mesaj_sayisi = @mysql_result($forum_mesaj, 0, "threadcount") or $forum_mesaj_sayisi = 0;
$forum_msj_sayisi = @mysql_result($forum_mesaj, 0, "replycount") or $forum_msj_sayisi = 0;
$thread_id = @mysql_query("select * from thread order by threadid desc limit 0,1") or die("Forum son baþlýðý alýnamadý");
$thread_idm = @mysql_result($thread_id, 0, "threadid") or $thread_idm = 0;
if($i<1 && ! isset($_GET[thread_id])):
$thread_idm++; $forum_mesaj_sayisi++;
endif;
$mesaj_arttir = mysql_query("UPDATE user SET posts = '".($mesaj_sayisi+1)."' where username = '".$forum_member."'") or die("Mesaj sayisi arttirilamadi");
$forum_mesaj_arttir = mysql_query("UPDATE forum SET lastpost = '".time()."', lastposter = '".$forum_member."', lastthread = '".mysql_escape_string($baslik)."', lastthreadid = '".$thread_idm."', threadcount = '".$forum_mesaj_sayisi."', replycount = '".($forum_msj_sayisi+1)."' where forumid = '".$_GET[eklenecek_kategori]."'") or die("Forum mesaji arttirilamadi");
if($i==0 && ! isset($_GET[thread_id])):
$thread = mysql_query("INSERT INTO thread (threadid, title, firstpostid, lastpostid, lastpost, forumid, pollid, open, replycount, hiddencount, deletedcount, postusername, postuserid, lastposter, dateline, views, iconid, notes, visible, sticky, votenum, votetotal, attach, similar) VALUES ('".$thread_idm."', '".mysql_escape_string($baslik)."', 1, 1, ".time().", '".$_GET[eklenecek_kategori]."', 0, 1, 0, 0, 0, '".$forum_member."', 1, '".$forum_member."', ".time().", 0, 0, '', 1, 0, 0, 0, 0, '')") or die("Baslik Eklenemedi");
mysql_query("UPDATE `vbulletin_bot` SET `eklenecek_kategori`");
endif;
$post = mysql_query("INSERT INTO post (postid, threadid, parentid, username, userid, title, dateline, pagetext, allowsmilie, showsignature, ipaddress, iconid, visible, attach, infraction, reportthreadid) VALUES ('', '".$thread_idm."', 0, '".$forum_member."', '".$u_id."', '".mysql_escape_string($baslik)."', '".time()."', '".mysql_escape_string(strip_tags($mesaj, '<a><b><i><br><div>'))."', 1, 0, '127.0.0.1', 0, 1, 0, 0, 0)") or die("Mesaj eklenemedi");
$post_id=mysql_insert_id();
// Dýþarýdan resim al ---------------------------------------------------
if($_GET[dis_resim]=="ON"):
if(preg_match_all('<img.*src=".*\/>', $mesaj, $matches, PREG_SET_ORDER)):
//echo "resim vaaaaaaaaarrrrr";
foreach($matches[0] as $key => $value){
$y=explode("<img", $value);
if(sizeof($y)>1):
foreach($y as $value){
$x=explode('src="', $value);
$resim="";
$bs=$x[1];
//echo $bs;
$v=0; while($bs[$v]!=='"'):
$resim.=$bs[$v];
$v++;
if($v>400) break;
endwhile;
if(eregi("http://", $resim) && !eregi($kullanici[2], $resim)):
if($chuck=@file_get_contents($resim)):
$d=explode("/", $resim);
if(eregi("attachment.php", $resim)) $dosya_ismi="1111.jpg"; else $dosya_ismi=$d[(sizeof($d)-1)];
$dosya=fopen($dosya_ismi, "w");
fputs($dosya, $chuck);
fclose($dosya);
$byte_size=strlen($chuck);
list($width, $height)=getimagesize($dosya_ismi);
$new_height=@round((($height*72) / $width)); //200 yerine standart ratio
$chuck2=file_get_contents($bot_adres."show_image.php?filename=".urlencode($dosya_ismi)."&width=72&height=$new_height");
$byte_size2=strlen($chuck2);
$extension=explode(".", $dosya_ismi); $extension=$extension[(sizeof($extension)-1)];
$file_hash=hash_file('md5', $dosya_ismi);
mysql_query("INSERT INTO `attachment` (`userid`, `dateline`, `thumbnail_dateline`, `filename`, `filedata`, `visible`, `filesize`, `postid`, `thumbnail`, `thumbnail_filesize`, `extension`, `filehash`) VALUES ('$u_id', '".time()."', '".time()."', '$dosya_ismi', '".addslashes($chuck)."', '1', '$byte_size', '$post_id', '".addslashes($chuck2)."', '$byte_size2', '$extension', '$file_hash')");
mysql_query("UPDATE `post` SET `attach` = '1' WHERE `postid` = '$post_id'");
mysql_query("UPDATE `thread` SET `attach` = '1' WHERE `threadid` = '$thread_idm'");
unlink($dosya_ismi);
endif;
echo "$resim <BR>";
endif;
}
else:
$x=explode('src="', $value);
$resim="";
$bs=$x[1];
//echo $bs;
$v=0; while($bs[$v]!=='"'):
$resim.=$bs[$v];
$v++;
if($v>400) break;
endwhile;
if(eregi("http://", $resim) && !eregi($kullanici[2], $resim)):
if($chuck=@file_get_contents($resim)):
$d=explode("/", $resim);
if(eregi("attachment.php", $resim)) $dosya_ismi="1111.jpg"; else $dosya_ismi=$d[(sizeof($d)-1)];
$dosya=fopen($dosya_ismi, "w");
fputs($dosya, $chuck);
fclose($dosya);
$byte_size=strlen($chuck);
list($width, $height)=getimagesize($dosya_ismi);
$new_height=@round((($height*72) / $width)); //200 yerine standart ratio
$chuck2=file_get_contents($bot_adres."show_image.php?filename=".urlencode($dosya_ismi)."&width=72&height=$new_height");
$byte_size2=strlen($chuck2);
$extension=explode(".", $dosya_ismi); $extension=$extension[(sizeof($extension)-1)];
$file_hash=hash_file('md5', $dosya_ismi);
mysql_query("INSERT INTO `attachment` (`userid`, `dateline`, `thumbnail_dateline`, `filename`, `filedata`, `visible`, `filesize`, `postid`, `thumbnail`, `thumbnail_filesize`, `extension`, `filehash`) VALUES ('$u_id', '".time()."', '".time()."', '$dosya_ismi', '".addslashes($chuck)."', '1', '$byte_size', '$post_id', '".addslashes($chuck2)."', '$byte_size2', '$extension', '$file_hash')");
mysql_query("UPDATE `post` SET `attach` = '1' WHERE `postid` = '$post_id'");
mysql_query("UPDATE `thread` SET `attach` = '1' WHERE `threadid` = '$thread_idm'");
unlink($dosya_ismi);
endif;
echo "$resim <BR>";
endif;
endif;
}
endif;
endif;
// Dýþarýdan resim al son ---------------------------------------------------
if($_GET[tag]=="ON"):
$x=explode('id="tag_list_cell">', $icerik);
$x=explode('</td>', $x[1]);
$tags=strip_tags($x[0]);
echo $tags;
mysql_query("UPDATE `thread` SET `taglist` = '$tags' WHERE `threadid` = '$thread_idm'");
$tags=explode(", ", $tags);
foreach($tags as $tag){
mysql_query("INSERT INTO `tag` (`tagtext`, `dateline`) VALUES ('$tag', '".time()."')");
$ins_id=mysql_insert_id();
mysql_query("INSERT INTO `tagthread` (`tagid`, `threadid`, `userid`, `dateline`) VALUES ('".$ins_id."', '$thread_idm', '$u_id', '".time()."')");
}
endif;
if($_GET[resim]=="ON" && strlen($attach_array[$i][0])>2): //attachmentlar
mysql_query("INSERT INTO `attachment` (`userid`, `dateline`, `thumbnail_dateline`, `filename`, `filedata`, `visible`, `filesize`, `postid`, `thumbnail`, `thumbnail_filesize`, `extension`, `filehash`) VALUES ('$u_id', '".time()."', '".time()."', '".$attach_array[$i]['0']."', '".$attach_array[$i]['1']."', '1', '".$attach_array[$i]['2']."', '$post_id', '".$attach_array[$i]['3']."', '".$attach_array[$i]['4']."', '".$attach_array[$i]['5']."', '".$attach_array[$i]['6']."')");
mysql_query("UPDATE `post` SET `attach` = '1' WHERE `postid` = '$post_id'");
mysql_query("UPDATE `thread` SET `attach` = '1' WHERE `threadid` = '$thread_idm'");
endif;
$i++;
}
$thread_sayisi=mysql_num_rows(mysql_query("SELECT `threadid` FROM `thread`"));
$reply_count=mysql_num_rows(mysql_query("SELECT `postid` FROM `post` WHERE `threadid` = '$thread_idm'"))-1;
$user_mesaj_sayisi=mysql_num_rows(mysql_query("SELECT `postid` FROM `post` WHERE `username` = '$forum_member'"));
//$forum_reply_count=mysql_num_rows(mysql_query("SELECT `postid` FROM `post` WHERE `threadid` = '$_GET[thread_id]'"));
mysql_query("UPDATE user SET posts = '".$user_mesaj_sayisi."' where username = '".$forum_member."'");
mysql_query("UPDATE `thread` SET `replycount` = '$reply_count', `lastpost` = '".time()."' WHERE `threadid` = '$thread_idm'");
mysql_query("UPDATE `vbulletin_bot` SET `thread_id` = '$thread_idm', `is_crawled` = '1' WHERE `link` = '".html_entity_decode(urldecode($_GET[konu_adres]))."'");
//echo "UPDATE `vbulletin_bot` SET `thread_id` = '$thread_idm', `is_crawled` = '1' WHERE `link` = '".html_entity_decode(urldecode($_GET[konu_adres]))."'";
//mysql_query("UPDATE `forum`");
//--------------------------------------------
// Sonraki Sayfayý bul
$satir=explode("\n", $icerik);
for($i=0; $i<(sizeof($satir)+1); $i++):
if(preg_match_all('/<a.*class="smallfont".*>><\/a>/', $satir[$i], $matches, PREG_SET_ORDER)):
foreach($matches[0] as $key => $value){
$y=explode('href="', $value);
$bs=$y[(sizeof($y)-1)];
$sonraki="";
$v=0; while($bs[$v]!=='"'):
$sonraki.=$bs[$v];
$v++;
if($v>400) break;
endwhile;
if(eregi("http://", $sonraki)): ;
elseif(eregi("\/", $sonraki)):
if($sonraki[0]=="/") $sonraki[0]="";
$sonraki=trim($sonraki);
$sonraki=$kullanici[2].$sonraki;
endif;
if(! eregi("http://", $sonraki)):
if($sonraki[0]=="/") $sonraki[0]="";
$sonraki=trim($sonraki);
$sonraki=$kategori_sayfa.$sonraki;
endif;
//echo $sonraki;
}
endif;
endfor;
//---------------------------------------------
//foreach($sil as $value) echo $value;
mysql_query("DELETE FROM `vbulletin_bot` WHERE `link` NOT LIKE '%http:%'");
if($_GET[ilk_mesaj]=="ON"):
?>
<script>
document.location.href='konu_indir.php?<? echo "veritabani=ok&ilk_mesaj=$_GET[ilk_mesaj]&baslik_max_sayfa=$_GET[baslik_max_sayfa]&resim=$_GET[resim]&tag=$_GET[tag]&eklenecek_kategori=$_GET[eklenecek_kategori]&dis_resim=$_GET[dis_resim]&forum_anasayfa=".urlencode($kullanici[2]).""; ?>';
</script>
<?
die();
endif;
if(strlen($sonraki)<3 && $_GET[veritabani]=="ok"): ?>
<script>
document.location.href='konu_indir.php?<? echo "veritabani=ok&ilk_mesaj=$_GET[ilk_mesaj]&baslik_max_sayfa=$_GET[baslik_max_sayfa]&resim=$_GET[resim]&tag=$_GET[tag]&eklenecek_kategori=$_GET[eklenecek_kategori]&dis_resim=$_GET[dis_resim]&forum_anasayfa=".urlencode($kullanici[2]).""; ?>';
</script>
<? die("bitti.");
elseif(strlen($sonraki)<3 && $_GET[veritabani]!=="ok"):
die("bitti");
endif;
$parameters="forum_anasayfa=".urlencode($kullanici[2])."&konu_adres=".html_entity_decode(urlencode($sonraki))."&max_sayfa=$_GET[max_sayfa]&baslik_max_sayfa=$_GET[baslik_max_sayfa]&resim=$_GET[resim]&tag=$_GET[tag]&ilk_mesaj=$_GET[ilk_mesaj]&eklenecek_kategori=$_GET[eklenecek_kategori]&dis_resim=$_GET[dis_resim]&thread_id=$thread_idm&eklenen_id=$eklenen_id&mevcut_sayfa=".($mevcut_sayfa+1);
if($_GET[veritabani]=="ok") $parameters.="&veritabani=ok"
//echo $parameters;
?>
<script>
document.location.href='konu_indir.php?<? echo $parameters; ?>';
</script>