gnoxis.php
<meta charset="utf8" />
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of gnoxis
*
* @author onuragtas
*/
include './fonksiyon.php';
class gnoxis extends fonksiyon {
public $server = "localhost";
public $username = "xxx";
public $password = "yyyy";
public $database_name = "xxx_yyy";
public $site = "http://www.gnoxis.com/f41/bilim-and-teknoloji.html";
function __construct() {
$date = $this->date();
$this->db($this->server, $this->username, $this->password, $this->database_name);
$data = $this->curl($this->site);
preg_match_all('|<a class="title" href="(.*?)" id="thread_title_(.*?)">(.*?)</a>|si', $data, $konu);
for ($a = 0; $a < 11; $a++) {
$url = $konu[1][$a];
echo $title = $konu[3][$a];
$data = $this->curl($url);
preg_match('|<div id="post_message_(.*?)">(.*?)</div>|si', $data, $mesaj);
$mesaj1 = strip_tags($mesaj[2]);
echo "<br />";
// if ($this->kontrol("makale", "baslik='$baslik' AND mesaj='$message'")) {
// } else {
// $ekle = $this->ekle("makale", "baslik, mesaj, tarih, yazan_id, kategori_id, image, onay", "'$title', '$mesaj1', '$date', '1', '13', 'article_images/', '0'");
// if ($ekle) {
// $this->mail("external@linuxmail.org", "external@linuxmail.org", $message, $baslik);
// }
// }
sleep(10);
}
}
}
$gnoxis = new gnoxis();
?>fonksiyon.php<?php
class fonksiyon {
public function db($server, $username, $password, $database_name) {
$database = mysql_connect($server, $username, $password);
mysql_select_db($database_name, $database) or die("Bağlantı hatası.");
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci'");
}
public function curl($site) {
$ch = curl_init($site);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function login($site, $fields_string) {
$ch = curl_init($site);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function download($image, $dir) {
$fp = fopen($dir . basename($image), 'w');
$ch = curl_init($image);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
curl_close($ch);
fclose($fp);
}
public function ekle($table, $column, $values) {
mysql_query("INSERT INTO $table ($column)VALUES($values)");
}
public function kontrol($table, $sart) {
$query = mysql_num_rows(mysql_query("SELECT * FROM $table WHERE $sart"));
if ($query > 0) {
return TRUE;
} else {
return FALSE;
}
}
public function mail($to, $from, $msg, $konu) {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <' . $from . '>' . "\r\n";
mail($to, $konu, $msg, $headers);
}
public function replace($text) {
$text = str_replace("/", "", $text);
return $text;
}
public function date() {
return date("d.m.Y");
}
public function wpPostXMLRPC($title, $body, $rpcurl, $username, $password, $category, $keywords = '', $encoding = 'UTF-8') {
$title = htmlentities($title, ENT_NOQUOTES, $encoding);
$keywords = htmlentities($keywords, ENT_NOQUOTES, $encoding);
curl_setopt($ch, CURLOPT_HTTPHEADER, "charset=UTF-8;");
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
$content = array(
'title' => $title,
'description' => $body,
'mt_allow_comments' => 0, // 1 to allow comments
'mt_allow_pings' => 0, // 1 to allow trackbacks
'post_type' => 'post',
'mt_keywords' => $keywords,
'categories' => array($category)
);
$params = array(0, $username, $password, $content, true);
$request = xmlrpc_encode_request('metaWeblog.newPost', $params, array('encoding'=>'UTF-8','escaping'=>'markup'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
return $results;
}
}
?>veritabanında tablo ve sutunlar hep utf8_turkish_ci... Umarım çözüm bulunur, teşekkürler.
sorunum çözüldü