|
|
|
PHP |
mail ile ekli dosya göndermek | | function mail_dosya( $gidenmailadresi, $mailbaslik, $mailhtml, $gönderilenmailadresi, $eklenendosya, $replayadresi="" ) {
// handles mime type for better receiving
$ext = strrchr( $eklenendosya , '.');
$ftype = "";
if ($ext == ".doc") $ftype = "application/msword";
if ($ext == ".jpg") $ftype = "image/jpeg";
if ($ext == ".gif") $ftype = "image/gif";
if ($ext == ".zip") $ftype = "application/zip";
if ($ext == ".pdf") $ftype = "application/pdf";
if ($ftype=="") $ftype = "application/octet-stream";
$file = fopen($eklenendosya, "rb");
$data = fread($file, filesize( $eklenendosya ) );
fclose($file);
$content = chunk_split(base64_encode($data));
$uid = md5(uniqid(time()));
$h = "From: $gönderilenmailadresi\r\n";
if ($replayadresi) $h .= "Reply-To: ".$replayadresi."\r\n";
$h .= "MIME-Version: 1.0\r\n";
$h .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$h .= "This is a multi-part message in MIME format.\r\n";
$h .= "--".$uid."\r\n";
$h .= "Content-type:text/html; charset=iso-8859-1\r\n";
$h .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$h .= $mailhtml."\r\n\r\n";
$h .= "--".$uid."\r\n";
$h .= "Content-Type: ".$ftype."; name=\"".basename($eklenendosya)."\"\r\n";
$h .= "Content-Transfer-Encoding: base64\r\n";
$h .= "Content-Disposition: attachment; filename=\"".basename($eklenendosya)."\"\r\n\r\n";
$h .= $content."\r\n\r\n";
$h .= "--".$uid."--";
// mail gönder
return mail( $gidenmailadresi, $mailbaslik, strip_tags($mailhtml), str_replace("\r\n","\n",$h) ) ;
}
|
Böyyük Patron Tarafından 13-03-2010 Tarihinde Gönderilmiştir.
Bu Konuyu Yazdır
Kaynak : |
|
|
PHP |
web sayfalarından meta tagları favicon resimleri almak | | function getLinksInfo($url) {
$web_page = file_get_contents($url);
$data['keywords']="";
$data['description']="";
$data['title']="";
$data['favicon']="";
$data['images']=array();
preg_match_all('#<title([^>]*)?>(.*)</title>#Uis', $web_page, $title_array);
$data['title'] = $title_array[2][0];
preg_match_all('#<meta([^>]*)(.*)>#Uis', $web_page, $meta_array);
for($i=0;$i<count($meta_array[0]);$i++) {
if (strtolower(attr($meta_array[0][$i],"name"))=='description') $data['description'] = attr($meta_array[0][$i],"content");
if (strtolower(attr($meta_array[0][$i],"name"))=='keywords') $data['keywords'] = attr($meta_array[0][$i],"content");
}
preg_match_all('#<link([^>]*)(.*)>#Uis', $web_page, $link_array);
for($i=0;$i<count($link_array[0]);$i++) {
if (strtolower(attr($link_array[0][$i],"rel"))=='shortcut icon') $data['favicon'] = makeabsolute($url,attr($link_array[0][$i],"href"));
}
preg_match_all('#<img([^>]*)(.*)/?>#Uis', $web_page, $imgs_array);
$imgs = array();
for($i=0;$i<count($imgs_array[0]);$i++) {
if ($src = attr($imgs_array[0][$i],"src")) {
$src = makeabsolute($url,$src);
if (getRemoteFileSize($src)>15000) array_push($imgs,$src);
}
if (count($imgs)>5) break;
}
$data['images']=$imgs;
return $data;
}
print_r(getLinksInfo("http://www.dizzin.com"));
dönen sonuç dizidir(array).
$gelen=getLinksInfo("http://www.dizzin.com");
echo $gelen['keywords'];
gibide değişkene alabilirsiniz
|
Böyyük Patron Tarafından 13-03-2010 Tarihinde Gönderilmiştir.
Bu Konuyu Yazdır
Kaynak : |
|
|
PHP |
web sayfasını curl ile text olarak almak | | function webpage2txt($url) {
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_PORT, 80); //Set the port number
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$document = curl_exec($ch);
$search = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<![\s\S]*?-[ \t\n\r]*>@', // Strip multi-line comments including CDATA
'/\s{2,}/',
);
$text = preg_replace($search, "\n", html_entity_decode($document));
$pat[0] = "/^\s+/";
$pat[2] = "/\s+\$/";
$rep[0] = "";
$rep[2] = " ";
$text = preg_replace($pat, $rep, trim($text));
return $text;
}
echo webpage2txt("http://www.otelreferans.com");
|
Böyyük Patron Tarafından 13-03-2010 Tarihinde Gönderilmiştir.
Bu Konuyu Yazdır
Kaynak : |
|
|
PHP |
curl ile facebook a login olmak | | function fb_login($login_email, $login_pass){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1');
curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)");
curl_exec($ch);
$err = 0;
$err = curl_errno($ch);
curl_close($ch);
if ($err != 0){
echo 'error='.$err."\n";
return(false);
} else {
return(true);
}
} |
Böyyük Patron Tarafından 13-03-2010 Tarihinde Gönderilmiştir.
Bu Konuyu Yazdır
Kaynak : |
|
|
PHP |
array_map fonksiyonu ile büyük kolaylıklar | | Herhangi bir fonksiyonu toplu halde uygulayabilmenize yarar. Dizi olarak çıktı verir.
array_map("fonksiyon adi","fonksiyon uygulanacagi veri");
<?php
# Filtre Fonksiyonumuz
function filtrele($girdi){
$girdi = htmlspecialchars(mysql_real_escape_string($girdi)); # zararlı kodları temizledik.
return $girdi;
}
$_POST = array_map("filtrele",$_POST);
?> |
Böyyük Patron Tarafından 11-03-2010 Tarihinde Gönderilmiştir.
Bu Konuyu Yazdır
Kaynak : |
|
|
|