Kategori : Php ...
-
17
-
11
-
2011
Kategorisi : Apache,Php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^eskidomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.eskidomain.com$
RewriteRule (.*)$ http://www.yenidomain.com/$1 [R=301,L]
-
16
-
11
-
2011
Kategorisi : Php
Php ile unzip:
shell_exec (“unzip -ou ‘ornek.zip’ -d ””);
-
11
-
11
-
2011
Kategorisi : Php
Sadece harfler:
$x = preg_replace(“/\W+/i”,””,$_POST[‘deger’]);
Sadece rakamlar:
$x = ctype_digit(preg_replace(“/\W+/i”,””,$_POST[‘deger’])) ? preg_replace(“/\W+/i”,””,$_POST[‘deger’]): NULL;
Email:
$x = preg_replace(“/[^\wüğışöçÖÇŞİĞÜ\.\:-\s@]/i”,””,$_POST[‘mailAdresi’]);
-
24
-
10
-
2011
Kategorisi : Php
class Mail {
private $smtpServer = 'mail.xxx.com';
private $port = '25';
private $timeout = '45';
private $username = 'xxx@xxx.com';
private $password = 'xxx';
private $newline = "\r\n";
private $localdomain = 'mail.xxx.com';
private $charset = 'utf-8';
private $contentTransferEncoding = false;
// Do not change anything below
private $smtpConnect = false;
private $to = false;
private $subject = false;
private $message = false;
private $headers = false;
private $logArray = array(); // Array response message for debug
private $Error = '';
public function __construct($to, $subject, $message) {
$this->to = &$to;
$this->subject = &$subject;
$this->message = &$message;
// Connect to server
if(!$this->Connect2Server()) {
// Display error message
echo $this->Error.$this->newline.''.$this->newline;
return false;
}
return true;
}
private function Connect2Server() {
// Connect to server
$this->smtpConnect = fsockopen($this->smtpServer,$this->port,$errno,$error,$this->timeout);
$this->logArray['CONNECT_RESPONSE'] = $this->readResponse();
if (!is_resource($this->smtpConnect)) {
return false;
}
$this->logArray['connection'] = "Connection accepted: $smtpResponse";
// Hi, server!
$this->sendCommand("EHLO $this->localdomain");
$this->logArray['EHLO'] = $this->readResponse();
// Let's know each other
$this->sendCommand('AUTH LOGIN');
$this->logArray['AUTH_REQUEST'] = $this->readResponse();
// My name...
$this->sendCommand(base64_encode($this->username));
$this->logArray['REQUEST_USER'] = $this->readResponse();
// My password..
$this->sendCommand(base64_encode($this->password));
$this->logArray['REQUEST_PASSWD'] = $this->readResponse();
// If error in response auth...
if (substr($this->logArray['REQUEST_PASSWD'],0,3)!='235') {
$this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline;
return false;
}
// "From" mail...
$this->sendCommand("MAIL FROM: $this->username");
$this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse();
if (substr($this->logArray['MAIL_FROM_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline;
return false;
}
// "To" address
$this->sendCommand("RCPT TO: $this->to");
$this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse();
if (substr($this->logArray['RCPT_TO_RESPONCE'],0,3)!='250') {
$this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline;
}
// Send data to server
$this->sendCommand('DATA');
$this->logArray['DATA_RESPONSE'] = $this->readResponse();
// Send mail message
if (!$this->sendMail()) return false;
// Good bye server! =)
$this->sendCommand('QUIT');
$this->logArray['QUIT_RESPONSE'] = $this->readResponse();
// Close smtp connect
fclose($this->smtpConnect);
return true;
}
// Function send mail
private function sendMail() {
$this->sendHeaders();
$this->sendCommand($this->message);
$this->sendCommand('.');
$this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse();
if(substr($this->logArray['SEND_DATA_RESPONSE'],0,3)!='250') {
$this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline;
return false;
}
return true;
}
// Function read response
private function readResponse() {
$data="";
while($str = fgets($this->smtpConnect,4096))
{
$data .= $str;
if(substr($str,3,1) == " ") { break; }
}
return $data;
}
// function send command to server
private function sendCommand($string) {
fputs($this->smtpConnect,$string.$this->newline);
return ;
}
// function send headers
private function sendHeaders() {
$this->sendCommand("Date: ".date("D, j M Y G:i:s")." +0700");
$this->sendCommand("From: $this->username <$dom Rezervasyon Formu>");
$this->sendCommand("Reply-To: <$this->username>");
$this->sendCommand("To: <$this->to>");
$this->sendCommand("Subject: $this->subject");
$this->sendCommand("MIME-Version: 1.0");
$this->sendCommand("Content-Type: text/html; charset=$this->charset");
if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: $this->contentTransferEncoding");
$this->sendCommand($this->newline);
return ;
}
public function __destruct() {
if (is_resource($this->smtpConnect)) fclose($this->smtpConnect);
}
}
// Example
// bool new Mail ( string $to , string $subject , string $message)
if (new Mail('rezervasyon@xxx.com',$subject,$icerik)) {
echo 'Mail Gönderildi';
}
else {
echo 'Mail Gönderilemedi';
}
-
05
-
10
-
2011
Kategorisi : Mysql,Php
function clear_sql( $data )
{
$bad = array("'","*","?","select","all","or","SELECT","ALL","OR","concat","-","+","(",")","union",",","group");
$good = array("_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_","_");
$result = str_replace($bad,$good,$data);
$result = trim(addslashes($result));
return $result;
}
print clear_sql($dt);
-
12
-
08
-
2011
Kategorisi : Php
Türkçe karakter Utf8; urlencode ve urldecode fonksiyonlarını kullanmak sorunu çözüyor.
-
21
-
05
-
2011
Kategorisi : Apache,Php
Eğer, .htaccess’ de kullandığımız
AddType application/x-httpd-php .php .htm .html
satırı çalışmıyor ve dosyayı indirip indirmeyeceğimizi soruyorsa;
AddType application/x-httpd-php5 .html .htm
işe yarıyor. Php5 kullanıyorsak durum böyle sonuna 5 ekliyoruz. 😐
-
14
-
04
-
2011
Kategorisi : Php
php -i | grep php.ini
-
07
-
04
-
2011
Kategorisi : Php
Php4 ve Php5 çalıştıran hostinglerde .htaccess dosyamıza:
AddHandler application/x-httpd-php5 .html .htm
kaydını ekliyoruz.
Sadece tek Php versiyonu olan sunucularda ise :
AddType application/x-httpd-php .html .htm
AddType işe yaramazsa;
AddHandler application/x-httpd-php .html .htm
ya da
AddHandler x-httpd-php .html .htm
-
17
-
03
-
2011
Kategorisi : Php
PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y) in filan.php
hatasını düzeltmenin 4 yolu.
1) php.ini dosyasına erişiminiz varsa:
memory_limit = 32M
2) .htaccess dosyasına:
php_value memory_limit 64M
kaydını ekleyerek,
3) php scriptimizin içine:
ini_set('memory_limit', '64M')
kaydını ekleyerek.
4) eğer php ‘yi komut satırından kullanıyorsanız:
% php -d memory_limit=64M -f /yol/script.php