Senin, 28 Desember 2009

Email To Image With PHP to reduce Spam

Email To Image

The number of spam emails coming into an email account is usually due to installing an email with a direct plaintext on web page. Well, to help reduce the power of email search engine we will work with the captcha principles, which boot machine or robot can not read into the image. Now we try to display our email in the form of images like services at big website such as Facebook (Email Account Info of Facebook is in form of image).

Email To Image With PHP to reduce Spam can be done with two files. The Engine File to Convert Email To Image i named
emailtoimage.php ;

<?php
header("Content-type: image/png");
// Your email address which will be shown in the image
$email = "$_GET[email]";
$length = (strlen($email)*8);
$im = @ImageCreate ($length, 20)
or die ("Kann keinen neuen GD-Bild-Stream erzeugen");
$background_color = ImageColorAllocate ($im, 255, 255, 255); // White: 255,255,255
$text_color = ImageColorAllocate ($im, 55, 103, 122);
imagestring($im, 3,5,2,$email, $text_color);
imagepng ($im);
?>



and the other one is a Common File to Call the Image.

Email To ImageHow we call the image from the common file ?
Simple, Just Use : Email : <img src=emailtoimage.php?email=$data[email]>

Jumat, 18 Desember 2009

Backup MySQL Database as SQL File with PHP


Backup MySQL Database as SQL File can be done with PHP Programming. It wasn't new thing for the expert. Backup MySQL Database as SQL File can be an alternative programming if something wrong (with server acces Telnet access, or PHPMyadmin). so the better thing we prepare is a backup programming MySQL Database as SQL File with PHP.

A simple way to do this is using a PHP Class to Backup MySQL Database as SQL. But we will got some times to search. Simply use code provide below will help us to do any Backup MySQL Database as SQL File.

The result of the Class is a SQL file with named set in the Class. The SQL File contain all Table as a data definition language (DDL) and data manipulation language (DML).

You need just provide a mysql connection in connection file, example here, i use mysqli_connect

$link=mysqli_connect($server, $username, $password, $database);


<?php
require_once('../include/koneksi.php');
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=
". "kkkk". date('Ymd'). ".sql ");
header("Content-Transfer-Encoding: binary ");


echo "create database if not exists `db_wisuda`;\r\n";
echo "\r\n";
echo "use `db_wisuda`;\r\n";
echo "\r\n";
$m = "SHOW TABLE STATUS FROM db_wisuda";
$n = mysqli_query($link,$m);

while ($datao = mysqli_fetch_array($n))
{
$table=$datao[0];
echo "/*Table structure for table `$table` */\r\n";
echo "\r\n";
echo "DROP TABLE IF EXISTS `$table`;\r\n";
echo "\r\n";
echo "CREATE TABLE `$table` (\r\n";
$sql0="desc $table";
$res0= mysqli_query($link,$sql0);
$jum0=mysqli_num_rows($res0);
$j=0;
$key=0;
while($row0= mysqli_fetch_row($res0)){
$j++;
if($jum0==$j and $key==0)
{
if($row0[2]=='NO')
{
echo "`$row0[0]` $row0[1] NOT NULL);\r\n";
}
else
{
echo "`$row0[0]` $row0[1] default NULL);\r\n";
}
}
else
{
if($row0[2]=='NO')
{
echo "`$row0[0]` $row0[1] NOT NULL,\r\n";
}
else
{
echo "`$row0[0]` $row0[1] default NULL,\r\n";
}
}
if($row0[3]=='PRI')
{
$key=$key+1;
}
}
$sql1= "desc $table";
$res1= mysqli_query($link,$sql1);
$k=0;
while ($row1= mysqli_fetch_row($res1))
{
if($row1[3]=='PRI')
{
$k++;
if($key-1==0)
{
echo "PRIMARY KEY (`$row1[0]`)\r\n";
echo ");\r\n";
}
else if($k>1 and $k<$key)
{
echo "`$row1[0]`,";
}
else if($k==$key)
{
echo "`$row1[0]`)\r\n";
echo ");\r\n";
}
else
{
echo "PRIMARY KEY (`$row1[0]`,";
}
}
}
echo "\r\n";
$sql= "SELECT * FROM $table";
$res= mysqli_query($link,$sql);
while($row= mysqli_fetch_row($res)){
echo "INSERT INTO `$table` VALUES('".implode("','",$row)."');\r\n";
}
}
echo "\r\n";
?>



Selasa, 08 Desember 2009

HTML Tag Base FPDF Text Formatting

Here is the Information About the HTML Tag Base FPDF Text Formatting. Sometimes we want to do formating Text in our FPDF Document Output. So we need simple way to do the Text Formatting.

Example :

Telah Menyelesaikan dengan baik serta memenuhi semua persyaratan pendidikan pada Fakultas Teknik, Program Studi Teknik Elektro. Oleh karena itu kepadanya diberikan gelar akademik : Sarjana Teknik, beserta segala hak dan kewajiban yang melekat pada gelar tersebut.

The Simple Way to do this is HTML Tag Base FPDF Text Formatting. Process or Convert HTML to do The Formating Text, So It can be the output of FPDF PHP Programming.

Here is The Source of Code That we can Follow : http://www.fpdf.de/downloads/addons/41/

and the output will be :

HTML Tag Base, FPDF Text Formatting

Good Browser for FPDF PHP Programming

Google Chrome is a Good Browser for FPDF PHP Programming. Good Browser for FPDF PHP Programming i mean here is easy for Debugging. We Just Need to Reload or Refresh the Browser. Without closing and open new tab to do the debugging.


I Found Moziila Firefox (Up to 3.5 ) isn't a Good Browser for FPDF PHP Programming. Because we need to close and open new tab to do the debugging.

So If You want the Browser for FPDF PHP Programming. You should use Google Chrome (I Use Version 3.0...).