SMF mod ไว้เพิ่ม banner อย่างง่ายๆ

SMF June 8th, 2008

 SMF mod ไว้เพิ่ม banner อย่างง่ายๆ

Mod สำหรับ SMF มำให้เราเพิ่ม HTML code ลง Header/Footer ได้เอง เช่น banner, stats, links, อื่นๆ
ใช้ง่าย ไม่จำเป็นต้องรู้เกี่ยวกับ PHP ลองดาาน์โหลด/ดูข้อมูลเพิ่มเติม ได้ที่ http://custom.simplemachines.org/mods/index.php?mod=351

Tags:

Perl trim function to strip whitespace from a string

Perl June 7th, 2008

#!/usr/bin/perl

# Declare the subroutines
sub trim($);
sub ltrim($);
sub rtrim($);

# Create a test string
my $string = "  \t  Hello world!   ";

# Here is how to output the trimmed text "Hello world!"
print trim($string)."\n";
print ltrim($string)."\n";
print rtrim($string)."\n";

# Perl trim function to remove whitespace from the start and end of the string
sub trim($) {
	my $string = shift;
	$string =~ s/^\s+//;
	$string =~ s/\s+$//;
	return $string;
}

# Left trim function to remove leading whitespace
sub ltrim($) {
	my $string = shift;
	$string =~ s/^\s+//;
	return $string;
}

# Right trim function to remove trailing whitespace
sub rtrim($) {
	my $string = shift;
	$string =~ s/\s+$//;
	return $string;
}

Tags: ,

วิธีส่งเมล์ด้วย PHP mail() ผ่าน SMTP Authentication

PHP June 1st, 2008

ส่งเมล์ด้วย PHP mail() ผ่าน SMTP Authentication

<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo $mail->getMessage();
}
else {
echo "Message successfully sent!";
}
?>

ส่งเมล์ด้วย PHP mail() ผ่าน SMTP Authentication และ SSL

<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://mail.example.com";
$port = "465";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo $mail->getMessage();
}
else {
echo "Message successfully sent!";
}
?>

หมายเหตุ:

- วิธีนี้จำเป็นต้องใช้ PEAR Mail Package (Mail.php) ซึ่งปกติจะมาพร้อมกับ PHP4+ อยู่แล้วครับ เราไม่จำเป็นต้องเขียน script นี้ขึ้นมาเองครับ

- smtp_username / smtp_password คือ อีเมล์ account และรหัสผ่านของเมล์, host หมายถึง ค่า SMTP หรือ Outgoing Mail Server ของอีเมล์ที่เราใช้

Tags: ,

Copyright © 2008 iBiz Network Co., Ltd. Powered by wordpress, Theme by ericulous