Gmail SMTP E-Mail Gönderme

$user = 'xxxx@gmail.com';
$pass = '1234';
kısmını değiştirerek kullanabilirsiniz...

 <?php header('Content-Type: text/html; charset=utf-8');
$smtp = fsockopen("smtp.gmail.com", 587, $errno, $errstr, 15);

function get($smtp){
 $send = '';
 $sr = fgets($smtp,1024);
 while( $sr ){
 $send .= $sr;
 if( $sr[3] != '-' ){ break; }
 $sr = fgets($smtp,1024);
 }
 return $send;
}
function put($cmd,$smtp){
 fputs($smtp,$cmd."\r\n",1024);
}

function smtp_mail($to, $subject, $message, $headers = '',$smtp)
{
 $recipients = explode(',', $to);
 $user = 'xxxx@gmail.com';
 $pass = '1234';
 echo '<pre>';
 get($smtp);
 
 put("EHLO ".$_SERVER['HTTP_HOST'],$smtp);
 echo get($smtp); // 250
 put("STARTTLS",$smtp);
 echo get($smtp); // 220
 
 if(false == stream_socket_enable_crypto($smtp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)){
 die("unable to start tls encryption");
 }
 put('AUTH LOGIN',$smtp);
 echo get($smtp); // 334
 put(base64_encode($user),$smtp);
 echo get($smtp); // 334
 put(base64_encode($pass),$smtp);
 echo get($smtp); // 235
 put('MAIL FROM: <'.$user.'>',$smtp);
 echo get($smtp); // 250
 foreach ($recipients as $email)
 {
 put('RCPT TO: <'.$email.'>',$smtp);
 echo get($smtp); // 250
 }
 put('DATA',$smtp);
 echo get($smtp); // 354
 fwrite($smtp, 'Subject: '.$subject."\r\n".'To: <'.implode('>, <', $recipients).'>'."\r\n".$headers."\r\n\r\n".$message."\r\n");
 fwrite($smtp, '.'."\r\n");
 echo get($smtp); // 250
 put("EHLO ".$_SERVER['HTTP_HOST'],$smtp);
 echo get($smtp); // 250
 put("QUIT",$smtp);
 echo get($smtp);
 echo "</pre>"; 
 fclose($smtp); 
 return true;
} 
function send_test_email($smtp) { 
 if(smtp_mail('ulusanyazilim@gmail.com', 'Konu', 'Mesaj','',$smtp)) {
  echo "Gönderim Başarılı.";
 }else{
  echo "Bir Hata Oluştu.";
 } 
} 
send_test_email($smtp); 
?>

 

Menüye Tıklayarak Anlık Sayfa Çağırma

<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 <title></title>
 <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
 <style type="text/css">
 body{min-width:600px;}
 div{float:left;margin:1vh;padding:1vw;border:1vh solid #ccc;}
 .AdminMenu{width:15vw;}
 .Icerik{width:70vw;}
 </style>
</head>
<body>
<span id="Kapsa">
 <div class="AdminMenu">
 <a href="#" data="sayfa1.php" class="adminlink">Sayfa 1</a>
 <a href="#" data="sayfa2.php" class="adminlink">Sayfa 2</a>
<script>
$( ".adminlink" ).click(function() {
 var link = $( this ).attr( "data" );
 $.ajax({url: link,success: function(data) { $('.Icerik').html(data);}});
});

</script>
 </div>
 <div class="Icerik">
 ben bir varsayılan içeriğim<br>
 tıklanan linkteki html içerikler benimle değişir.
linklerdeki data="" kısmına yazdığınız adresler çağırır.
 </div>
</span>
</body>
</html>

 

Bunu mu demek istediniz?

Google’ın bunu mu demek istediniz uygulamasını kendi projelerinizde kullanabilirsiniz.

<?php 
$app_lang="tr";
$url="http://www.google.com/search?q=".urldecode($_GET['q'])."&ie=UTF-8&oe=UTF-8&hl=".$app_lang;

$icerik = @file_get_contents($url);
$aranan1 =('@spell=1(.*?)><br>@si');
preg_match_all($aranan1, $icerik, $ara1);
$aranan1 =('@">(.*?)</a@si');
$varmi =preg_match_all($aranan1, @$ara1[1][0], $ara2);
if($varmi == true){$didyoumean = @strip_tags($ara2[1][0]);}
else {$didyou = $_GET['q'];}
////////////////////////////////////////////////////
?>
 <form action="" method="post">
 <table>
 <tr>
 <td><label id="slabel">Detaylı Arama &</label></td>
 <td class="search"><input id="sinput" type="text" name="q" placeholder="Aranacak kelime yazın..."/><input id="ssubmit" type="submit" value="ARA"/></td>
 </tr>
 </table>
 </form>
<?php if(isset($didyoumean)){?>
 Bunu mu demek istediniz? <a href="<?php echo "?q=".$didyoumean;?>"><?php echo $didyoumean;?>
 <?php }else{ ?>
 Aranan kelime : <a style="font-weight:bold;color:#000;" href="<?php echo "?q=".$didyou;?>"><?php echo $didyou;?>
 <?php } 
 ?>

 

Önemli Ortak Kullanılabilecek Komutlar

<?php
ob_start();//html boşluklarını sıkıştırma
session_start();//oturum başlatma
header('Content-Type: text/html; charset=utf-8');//karakter seti seçimi
header("Cache-Control: no-cache, must-revalidate"); //önbellek almamak için
error_reporting (E_ERROR | E_WARNING | E_PARSE);//hataları göstermek için
set_time_limit(0);//zaman aşımı önlemek için
extract($_POST,EXTR_SKIP); //$_POST["id"] yi $id'ye çevirir
extract($_GET,EXTR_SKIP); //$_GET["id"] yi $id'ye çevirir
extract($_COOKIE,EXTR_SKIP);//$_COOKIE["id"] yi $id'ye çevirir

/*
sayfa içeriği
*/


ob_end_flush();
?>

 

Tüm Resimleri Boyutlandırma

<?php	
$anadizin="C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\";
$dizin='attachment';
$en = 135;
$boy = 135;
$basla=microtime(); 
function seoimg($file,$en,$boy){
header('Content-Type: '.getimagesize($file)[mime]);
//if(getimagesize($file)[mime] == "image/gif"){header('Content-Type: image/gif');}
$oran = getimagesize($file)[0]/getimagesize($file)[1];
if ($en/$boy > $oran) {$en = $boy*$oran;} 
else{$boy = $en/$oran;}
$resim=imagecreatetruecolor($en, $boy);
imagecopyresampled($resim, imagecreatefromjpeg($file), 0, 0, 0, 0, $en, $boy, getimagesize($file)[0], getimagesize($file)[1]);
if(getimagesize($file)[mime] == "image/jpeg"){imagejpeg($resim, $file, 100);}
if(getimagesize($file)[mime] == "image/png"){imagepng($resim, $file, 100);}
if(getimagesize($file)[mime] == "image/gif"){imagegif($resim, $file, 100);}
return true;
}
$liste= realpath($dizin);
$i=0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($liste)) as $dosya)
{
				
				$dosya=str_replace($dizin,"../",$dosya);
        $dosya=str_replace("\","/",$dosya);
				@seoimg($dosya,$en,$boy);
				@header('Content-Type: text/html; charset=utf-8');
				$i++;
				echo " ".$i.". satır tamamlandı [".$dosya."]<br>";
}

echo $i. " satır etkilendi<br>";
$son=microtime(); 
echo abs($basla-$son)." saniyede yüklendi"; 
?>
<?php
/* NOT EASYPHP üzerinde test edilmiştir.
ÇIKTISI
1. satır tamamlandı [attachment/2012/01/5/axgjd.gif]
2. satır tamamlandı [attachment/2013/05/12/abkly.png]
3. satır tamamlandı [attachment/2014/08/24/wthop.jpeg]
.
.
22484 satır etkilendi
0.731462 saniyede yüklendi
*/
/* AYARLAR  Örn: "C:Program FilesEasyPHP-DevServer-14.1VC9datalocalwebimages" için
$anadizin="C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\";
$dizin='images';
$en = 135;
$boy = 135;
*/
/* Test Sonuçları
Eski Boyut: 793MB
Yeni Boyut: 198MB
21.732 Dosya 375 Klasör
*/
/* Şuanki bulunduğunuz dizini bu şekilde bulabilirsiniz
echo realpath("");
*/
?>

Konu İsmini Başlığa Yazdırmak

Bildiğiniz üzere php’de değişkeni kendisinden sonra echo ile yazdırabiliyoruz.Genelde konular body kısmında olduğu için head daki <title> tagına jquery ile ulaşıp değiştirebiliriz.

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
	<div class="sayfam">
	<?php
	$baslik  ="Merhaba Dünya";
	?>
		<div id="baslik">
		<?php echo $baslik; ?>
		<script type="text/javascript">$(document).attr('title', '<?php echo $baslik; ?>');</script>
		</div>
	</div>
</body>
</html>

Resim Boyutlandırma (Seo Resim Optimize)

Kırpma işlemi değil, aynı oranda küçültme işlemi yapar.

Dikkat: Eski resim dosyanızı yeni boyutları ile değiştirir.

test.jpg üzerinde 250px x 250px örnek kullanılmıştır.

Not: Resim dosyalarınızın türüne göre image/jpeg ve imagecreatefromjpeg fonksiyonunu değiştirmeniz gerekebilir. Örnekte jpg ve jpeg uzantılı dosyalar için anlatım yapılmıştır.

Mime Tipleri ( image/gif image/jpeg image/png image/bmp

Fonksiyonlar ( imagecreatefrombmp,  imagecreatefromgif, imagecreatefromjpeg, imagecreatefrompng)

<?php header('Content-Type: image/jpeg');
$file = 'test.jpg';
$en = 250;
$boy = 250;
$oran = getimagesize($file)[0]/getimagesize($file)[1];
if ($en/$boy > $oran) {$en = $boy*$oran;} 
else{$boy = $en/$oran;}
$resim=imagecreatetruecolor($en, $boy);
imagecopyresampled($resim, imagecreatefromjpeg($file), 0, 0, 0, 0, $en, $boy, getimagesize($file)[0], getimagesize($file)[1]);
imagejpeg($resim, $file, 100);
?>
<?php
//KONTROL
header('Content-Type: text/html');
echo '<img src="test.jpg">';
?>

 

Array Chunk ile Döngüdeki Tabloyu Sütunlara Ayırmak

21 tane verimiz olduğunu var sayarsak ($veri) ve bunu tabloda 3 sütuna bölmek istersek ($ayir) kodlar bu şekilde olacaktır.

<?php 
$veri=21;
for($x=0;$x<$veri;$x++){
 $ornekveri[] = "Lorem impsum ".$x;
};
$ayiralim=3;
echo '<table border="1">';
foreach (array_chunk($ornekveri, $kaca_ayiralim) as $dizi) {
 echo "<tr>";
 foreach ($dizi as $deger) { 
  echo "<td>".$deger."</td>";  
 } 
 echo "</tr>";
}
echo '</table>';
?>