function convert_smart_quotes($text){ /*HABER METİNİN İÇİNDE OFFİCE WORLD TİPİ VİRGÜL TEK TIRNAK FİLAN DÜZENTİYOR*/ $text = str_replace(chr(130), ',', $text); $text = str_replace(chr(132), '"', $text); $text = str_replace(chr(133), '...',$text); $text = str_replace(chr(145), "'", $text); $text = str_replace(chr(146), "'", $text); $text = str_replace(chr(147), '"', $text); $text = str_replace(chr(148), '"', $text); $text = mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8'); $text = str_replace('Ğ', 'Ğ', $text); $text = str_replace('ğ', 'ğ', $text); $text = str_replace('Ö', 'Ö', $text); $text = str_replace('ö', 'ö', $text); $text = str_replace('Ç', 'Ç', $text); $text = str_replace('ç', 'ç', $text); $text = str_replace('Ş', 'Ş', $text); $text = str_replace('ş', 'ş', $text); $text = str_replace('İ', 'İ', $text); $text = str_replace('ı', 'ı', $text); $text = str_replace('Ü', 'Ü', $text); $text = str_replace('ü', 'ü', $text); $text = str_replace('"', '"', $text); return $text; }
Kategori arşivi: Php
filter_var
<?php // for filters that accept options, use this format $options = array( 'options' => array( 'default' => 3, // value to return if the filter fails // other options here 'min_range' => 0 ), 'flags' => FILTER_FLAG_ALLOW_OCTAL, ); $var = filter_var('0755', FILTER_VALIDATE_INT, $options); // for filter that only accept flags, you can pass them directly $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // for filter that only accept flags, you can also pass as an array $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, array('flags' => FILTER_NULL_ON_FAILURE)); // callback filter function foo($value) { $ret = new stdClass; $ret->value = filter_var($value, FILTER_VALIDATE_BOOLEAN, array('flags' => FILTER_NULL_ON_FAILURE)); return $ret; } $var = filter_var('yes', FILTER_CALLBACK, array('options' => 'foo')); ?>
http_build_query
<?php $data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor'); echo http_build_query($data) . "\n"; echo http_build_query($data, 'myvar_'); ?>
<?php $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo http_build_query($data); // foo=bar&baz=boom&cow=milk&php=hypertext+processor echo http_build_query($data, '', '&'); // foo=bar&baz=boom&cow=milk&php=hypertext+processor ?>0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
Plesk Api domain bilgilerini çekmek
<?php function get($host, $login, $password, $packet){ $curl = curl_init(); curl_setopt($curl,CURLOPT_URL, "https://{$host}:8443/enterprise/control/agent.php"); curl_setopt($curl,CURLOPT_RETURNTRANSFER,true); curl_setopt($curl,CURLOPT_POST,true); curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false); curl_setopt($curl,CURLOPT_HTTPHEADER,array("HTTP_AUTH_LOGIN: {$login}","HTTP_AUTH_PASSWD: {$password}","HTTP_PRETTY_PRINT: TRUE","Content-Type: text/xml")); curl_setopt($curl,CURLOPT_POSTFIELDS,$packet); $result = curl_exec($curl); $xml = new SimpleXMLElement($result); if (curl_errno($curl)){ $errmsg = curl_error($curl); $errcode = curl_errno($curl); curl_close($curl); throw new ApiRequestException($errmsg, $errcode); } curl_close($curl); return $xml; } function domain_get($host, $login, $password,$domain){ $packet = '<packet version="1.6.0.0"><domain><get><filter><domain-name>'.$domain.'</domain-name></filter><dataset><hosting/><limits/><stat/></dataset></get></domain></packet>'; return $this->get($host, $login, $password,$packet); } print_r(domain_get('12.12.12.12','admin','123456','test.com')); ?>
Php Curl ile vb – Vbulletin forum sitelerine giriş yapma örneği
Merhabalar bir arkadaşımın isteği üzerine vbulletin forum sitelerine giriş yapmak (curl vp login) örnekği yaptım. makale olarak paylaşmaya karar verdim,
<?php function login($username,$password){ $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,false); curl_setopt($ch, CURLOPT_COOKIEFILE, 'D:/wamp/nurcipekci2/cerez.txt'); //çerez yolumuz curl_setopt($ch, CURLOPT_COOKIEJAR, 'D:/wamp/nurcipekci2/cerez.txt'); //çerez yolumuz curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_COOKIESESSION,true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bakterim.net/index.php'); curl_setopt($ch, CURLOPT_URL, 'http://www.bakterim.net/login.php?do=login'); //login yapıyoruz curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "vb_login_username=$username&vb_login_password&s=&securitytoken=guest&do=login&vb_login_md5password=".md5($password)."&vb_login_md5password_utf=".md5($password)); $exec = curl_exec($ch); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bakterim.net/login.php?do=login'); curl_setopt($ch, CURLOPT_URL, 'http://www.bakterim.net/clientscript/vbulletin_global.js?v=373'); //js load güvenliği $exec = curl_exec($ch); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bakterim.net/login.php?do=login'); curl_setopt($ch, CURLOPT_URL, 'http://www.bakterim.net/index.php'); //anasayfaya geri dönüyoruz $exec = curl_exec($ch); curl_setopt($ch, CURLOPT_REFERER, 'http://www.bakterim.net/index.php'); curl_setopt($ch, CURLOPT_URL, 'http://www.bakterim.net/ask-sevgi/'); //gitmek istediğimiz örnek kategori $exec = curl_exec($ch); return $exec; } echo login('hrulk','123456'); ?>