Phpmailer Gmail Ayarları

include ‘phpmailer/class.phpmailer.php’; $this->mail = new PHPMailer(); $this->mail->SMTPAuth = true; $this->mail->Host = ‘smtp.gmail.com’; $this->mail->Port = 465; $this->mail->SMTPSecure = ‘tls’; $this->mail->Username = ‘user@gmail.com’; $this->mail->Password = ‘password’; $this->mail->SetFrom(“noreply@yourdomain.com”, ‘Name’); $this->mail->AddAddress($to,$name); $this->mail->CharSet = ‘UTF-8′; $this->mail->Subject = $subject; $this->mail->MsgHTML($html_message); if($this->mail->Send()) { return json_encode(array(‘status’=>1,’message’=>’Success’)); } else { return json_encode(array(‘status’=>0,’message’=>$this->mail->ErrorInfo)); }

Read More

Phpmailer Ayarları

include ‘phpmailer/class.phpmailer.php’; $this->mail = new PHPMailer(); $this->mail->IsSMTP(); $this->mail->SMTPAuth = true; $this->mail->Host = ‘mail.yourdomain.com’; $this->mail->Port = 587; $this->mail->SMTPSecure = ‘tls’; $this->mail->Username = ‘user@yourdomain.com’; $this->mail->Password = ‘password’; $this->mail->SetFrom(“noreply@yourdomain.com”, ‘Name’); $this->mail->AddAddress($to,$name); $this->mail->CharSet = ‘UTF-8′; $this->mail->Subject = $subject; $this->mail->MsgHTML($html_message); if($this->mail->Send()) { return json_encode(array(‘status’=>1,’message’=>’Success’)); } else { return json_encode(array(‘status’=>0,’message’=>$this->mail->ErrorInfo)); }

Read More

Multidimensional Array Diff

function array_diff_assoc_recursive($array1, $array2){ foreach($array1 as $key => $value){ if(is_array($value)){ if(!isset($array2[$key])){ $difference[$key] = $value; }else if(!is_array($array2[$key])){ $difference[$key] = $value; }else{ $new_diff = array_diff_assoc_recursive($value, $array2[$key]); if($new_diff != FALSE){ $difference[$key] = $new_diff; } } }else if(!isset($array2[$key]) || $array2[$key] != $value){ $difference[$key] = $value; } } return !isset($difference) ? 0 : $difference; }

Read More

TC Kimlik Doğrulama Fonksiyonu

function validateTcNo($tcNo){ if(strlen($tcNo) == 11){ $x = str_split($tcNo); $valid1=((7*($x[0]+$x[2]+$x[4]+$x[6]+$x[8]) – ($x[1]+$x[3]+$x[5]+$x[7]))%10) == $x[9]; $valid2=(($x[0]+$x[1]+$x[2]+$x[3]+$x[4]+$x[5]+$x[6]+$x[7]+$x[8]+$x[9])%10) == $x[10]; return $valid1 && $valid2; }else{ return false; } }

Read More

PDO Database Class

class database { private $dbName = null, $dbHost = null, $dbPass = null, $dbUser = null; private static $instance = null; private function __construct($dbDetails = array()) { // Please note that this is Private Constructor $this->dbName = $dbDetails['db_name']; $this->dbHost = $dbDetails['db_host']; $this->dbUser = $dbDetails['db_user']; $this->dbPass = $dbDetails['db_pass']; // Your Code here to connect to database […]

Read More

Memcache Kullanımı

Öncelikle buradan cache library dosyasını indiriyoruz. Daha sonra php tarafında şu kodları yazıyoruz: require_once (‘cache.php’); $memcache = new Cache(); if (($result = $memcache->get(‘cache_key’)) !== FALSE){ echo $result; }else{ $memcache->set(‘cache_key’, “return_text”, 0, 20); echo “return_text”; }

Read More

Klasör Altındaki Dosyaları Listeleme

1. Yol: $path=”../log/”; if(is_dir($path)){ if($open_path = opendir($path)){ while($file = readdir($open_path)){ echo ‘<a href=”‘ . $path . “” . $file . ‘”>’ . $file . ‘</a><br>’; } closedir($open_path); } } 2. Yol: $path = ‘../log/’; if(is_dir($path)){ $file_list = glob($path . “*.txt”); foreach($file_list as $key => $value){ $filename = str_replace($path, “”, $value); echo $filename; } }

Read More

No-Cache Meta

PHP header(‘Cache-Control: no-cache, no-store, must-revalidate’); // HTTP 1.1. header(‘Pragma: no-cache’); // HTTP 1.0. header(‘Expires: 0′); // Proxies. Java Servlet response.setHeader(“Cache-Control”, “no-cache, no-store, must-revalidate”); // HTTP 1.1. response.setHeader(“Pragma”, “no-cache”); // HTTP 1.0. response.setDateHeader(“Expires”, 0); // Proxies. ASP.NET Response.AppendHeader(“Cache-Control”, “no-cache, no-store, must-revalidate”); // HTTP 1.1. Response.AppendHeader(“Pragma”, “no-cache”); // HTTP 1.0. Response.AppendHeader(“Expires”, “0″); // Proxies. ASP Response.addHeader “Cache-Control”, […]

Read More

Node.js MySql Bağlantısı

Önce mysql eklentisini kurduktan sonra; var mysql = require(‘mysql’); var connection = mysql.createConnection({ host: ‘localhost’, user: ‘root’, password: ”, database: ‘test’, port: 3306 }); connection.connect(); var query = connection.query( ‘SELECT * FROM users’, function(err, result, fields){ if(err) throw err; console.log(‘result: ‘, result); } ); connection.end();

Read More