<?php function createThumbnail($fileSrc,$thumbDest,$thumb_width,$thumb_height){ $ext=strtolower(substr($fileSrc,strrpos($fileSrc,"."))); if($ext==".png"){ @$base_img = ImageCreateFromPNG($fileSrc); }else if(($ext==".jpeg") || ($ext == ".jpg")){ @$base_img = ImageCreateFromJPEG($fileSrc); }else if(($ext == ".gif")){ @$base_img = imagecreatefromgif($fileSrc); } if(!$base_img) return false; $img_width = imagesx($base_img); $img_height = imagesy($base_img); if($thumb_width <= $thumb_height){ $size_percent = intval($thumb_height / ($img_height / 100)); $new_width = intval($size_percent * ($img_width/100)); $new_height = $thumb_height; $difference_width = intval(($new_width - $thumb_width)/2); $difference_height = 0; }else{ $size_percent = intval($thumb_width / ($img_width / 100)); $new_height = intval($size_percent * ($img_height/100)); $new_width = $thumb_width; $difference_width = 0; $difference_height = intval(($new_height - $thumb_height)/2); } $thumb_img = ImageCreateTrueColor($new_width, $new_height); ImageCopyResampled($thumb_img,$base_img,0,0,0,0,$new_width,$new_height,$img_width,$img_height); $thumb_images = ImageCreateTrueColor($thumb_width, $thumb_height); ImageCopyMerge($thumb_images,$thumb_img,0,0,$difference_width,$difference_height,$thumb_width,$thumb_height,100); if($ext == ".png"){ ImagePNG($thumb_images, $thumbDest); }else if(($ext == ".jpeg") || ($ext == ".jpg")){ ImageJPEG($thumb_images, $thumbDest,82); }else if($ext == ".gif"){ ImageGIF($thumb_images, $thumbDest); } @ImageDestroy($base_img); @ImageDestroy($thumb_images); @ImageDestroy($thumb_img); return true; } ?>
Etiket arşivi: Php Function
OpenX flash player version detect bug
Find the following function in www/admin/lib-swf.inc.php (relative to your OpenX base install directory):
<?php function phpAds_SWFVersion($buffer) { if (substr($buffer, 0, 3) == swf_tag_identify || substr($buffer, 0, 3) == swf_tag_compressed) return ord(substr($buffer, 3, 1)); else return false; } ?>
And change that to:
<?php function phpAds_SWFVersion($buffer) { if (substr($buffer, 0, 3) == swf_tag_identify || substr($buffer, 0, 3) == swf_tag_compressed) { $rv = ord(substr($buffer, 3, 1)); if ($rv > 10 && $rv < 13) $rv = 10; elseif ($rv >= 13) $rv = 11; return $rv; } else return false; } ?>
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'); ?>
Php Curl ile Proxy örneği
<?php function chs(){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.mehmetmutlu.com.tr/ip.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); //http://hidemyass.com/proxy-list/ curl_setopt($ch, CURLOPT_PROXYPORT, '8080'); curl_setopt($ch, CURLOPT_USERAGENT, "bots"); curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP'); curl_setopt($ch, CURLOPT_PROXY,'12.174.27.73'); curl_setopt($ch, CURLOPT_PROXYUSERPWD,''); $output = curl_exec($ch); curl_close($ch); return $output; } print_r(chs()); ?>