Miscellaneous, Personal, Tips & Trick

This is happen 3 days ago when my friend asking for converting him .htaccess into lighttpd rewrite rules format. After conversion done he wanted to share this script to everyone. If you’re professional Fotographer or just blogger, you may wanted to copyright all your photos/images. Even we know, sometimes people like to share for having fun…. but some people need a copyright to protected his original works before someone copy it. If you’re doing this manually it will take a long time and of course you will bored before this done. In short time we can make a simple watermark to protected our images.

Requirements:

  1. Apache with mod_rewrite / lighttpd (just convert rewrite rules, it should work)
  2. PHP with GD library (check in your phpconfig or asking your webhosting)

Step one.

Prepare one images that you should used as watermark.  This images should be in .PNG format, you can created one using photoshop software to make transparant effect.

Step two.

Make new or open your .htaccess files and write down this code inside it:

RewriteEngine On
RewriteRule ^(.+)\.jpg$ wrapper.php?image=$1\.jpg [L]
RewriteRule ^(.+)\.gif$ wrapper.php?image=$1\.gif [L]
RewriteRule ^(.+)\.png$ wrapper.php?image=$1\.png [L]
RewriteRule ^(.+)\.bmp$ wrapper.php?image=$1\.bmp [L]

For Lighttpd users try to using this conversion, if you meet any problem just following your path and symbol :

url.rewrite-once = (
“^\(.*).jpg” => “/wrapper.php?image=$1.jpg”,
“^\(.*).gif” => “/wrapper.php?image=$1.gif”,
“^\(.*).png” => “/wrapper.php?image=$1.png”,
“^\(.*).bmp” => “/wrapper.php?image=$1.bmp”
)

Step three.

Create wrapper.php files and put code below inside it:

<?php
$watermark = “watermark.png”;
$image = $_GET["image"];

if (empty($image)) die();

if (!file_exists($image)) {
header(“404 Not Found”);
echo “File Not Found.”; die();
}
Read More »

Share |
Miscellaneous, Personal, Tips & Trick

In this article we will learn how to create custom title and meta description for each pages of you website. If you’re using WordPress or script that already have this standard SEO settings, all title and meta can be done setup in easy way. Anyway how if your website using your own design? I mean you designed it from zero! some of us didn’t notice if actually we are using global title and meta that was caused search engine didn’t give good result in return because all categorized as “duplicated“.

ist-false

*sample on false title and meta making my site poor in keyword.

Yup, duplicated but actually it’s not duplicated because it’s our false didn’t give clearly information to crawl robots. I will give example using my own false sites www.nexmutk.com after long long time ago, I didn’t optimized this website because I’m stuck and have no idea on how to optimize it. But after learn and learn now I know that I was doing something wrong because I didn’t give right title and meta for each pages (I used global, poor me).

My website using global header.php so all title and meta are same for each page, Now I understand I must change this to get better result in return to my pages. Let’s try to make it…..

First I created file name config.php then I write inside it (this is sample):

<?php

$titledownload = ‘Download Area – NexusTK Server Emulator – Atlantia MMORPG Development – Nexmutk.com’;

$descriptiondownload = ‘<META NAME=”DESCRIPTION” CONTENT=”Welcome to download area, you can downloading files for nexustk server, atlantia MMORPG development in here”>’;

$keyworddownload = ‘<META NAME=”KEYWORD” CONTENT=”download nexmutk,download nexustk,download nexustk map editor,download nexustk music,download gunbound server,download darkages server,download lunentia server,download ts online server,download ran online server”>’;

?>

Then I write in header.php to include this files for each time header.php called:

<?php

include(‘config.php’);

$currentpage = $_SERVER['REQUEST_URI'];

if($currentpage==”/download.html” || $currentpage==”/download.html” || $currentpage==”" ) {

echo “<title>”.$titledownload.”</title>\n”;

echo “$descriptiondownload\n”;

echo “$keyworddownload\n”;

}

?>

The result is good as I seen in source code, but I’m not sure if this way will make result in search engine better because I need to wait to see if it performs better… Anyway if you’re like to used this simple way you have to repeated each pages to get complex result.. I was thinking to use WordPress if this way fails. he he… enjoy this tips :)

Share |
Computer And Internet, Tips & Trick

Hi all, This article is sample php code on how to pull data from Microsoft Access Database, Anyway this code only works on windows hosting only, when you try in linux hosting you will get message Fatal error: Class ‘COM’ not found.

What is benefit to using this code? Last week I made simple SMS gateway in my personal computer then use Microsoft Access Database as my database. Now I need to show this database out into web page using PHP script. with this code it will be possible.

Just learn this code below it’s very simple, you can pull or entry data into your database.

<?
$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\mydir\\mydir\\mydb.mdb");

// SQL statement to build recordset.
$rs = $conn->Execute("SELECT myfield FROM mytable");
echo "<p>Below is list of values in MYDB.MDB, MYTABLE table, MYFIELD field.</p>";

// Display all the values in the records set
while (!$rs->EOF) {
    $fv = $rs->Fields("myfield");
    echo "Value: ".$fv->value."<br>\n";
    $rs->MoveNext();
}
$rs->Close();
?>

That is, and your’re done :)

Share |
Computer And Internet, Tips & Trick

In this article we will learn how to created online/offline server status, mostly this php code function used in gaming site to show server available or not. In my emulate site I was created sample php snippet code to show server online/offline.

Click here to read sample code in txt format.

All you need is just this sample code:

<?
$ip = “this.ismy.ip.number”;
$port = “portnumber”;

if ($check=@fsockopen($ip,$port,$ERROR_NO,$ERROR_STR,(float)0.5))
{
fclose($check);
echo “MY OWN SERVER<br>”;
echo “<img border=’0′ src=’images/online.jpg’ alt=’ONLINE’>”;
}
else
{
echo “MY OWN SERVER<br>”;
echo “<img border=’0′ src=’images/offline.jpg’ alt=’OFFLINE’>”;
}
?>

Sample result:

ress

Just that! really simple right? he he he.. you can costumize and added anything to make it more beauty. Anyway if you like to play games or bored with life *lol* come to my emulate site www.nexmutk.com and play games together.

Done, Have a good day :D

Share |
Computer And Internet, Miscellaneous, Tips & Trick

Good day everyone, In this article we will learn how to catch information from “HTTP_REFERER” function such as, referer info, keyword info, etc. From some search engine using PHP snippet. This script might usefully when you want to analyze your keyword and referer statistic. Last night I was searching in WP plugin for this script but I didn’t found one really good.

So let’s created it our self, First, You need this PHP class save it as searchkeys.class.php

<?php

class search_keywords
{
var $referer;

var $search_engine;

var $keys;

var $sep;

function search_keywords()
{
$this->referer = ”;
$this->sep = ”;

if ($_SERVER['HTTP_REFERER'] OR $_ENV['HTTP_REFERER'])
{
$this->referer = urldecode(($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : $_ENV['HTTP_REFERER']));
$this->sep = (eregi(‘(\?q=|\?qt=|\?p=)’, $this->referer)) ? ‘\?’ : ‘\&’;
}
}

function get_keys()
{
if (!empty($this->referer))
{
if (eregi(‘www\.google’, $this->referer))
{
// Google
preg_match(“#{$this->sep}q=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘Google’;
}
else if (eregi(‘(yahoo\.com|search\.yahoo)’, $this->referer))
{
// Yahoo
preg_match(“#{$this->sep}p=(.*?)\&#si”, $this->referer, $this->keys);
$this->search_engine = ‘Yahoo’;
}
else if (eregi(’search\.msn’, $this->referer))
{
Read More »

Share |
Computer And Internet, Miscellaneous, Tips & Trick

Hello Everyone, I’m back again ho ho ho :P

This time I will write tutorial on “how to make random ads” using php and text as database. This idea comes from gmail interface my lovely free mail account! pfffftt yea .. yea.. we all know gmail are better than ymail *lol* :P gmail

gmail

Alright leave them fight alone *not our business* before we start to make random ads we have to understand why we should make random ads? if we can fill those ads space with permanent ads. Most of people are bored about ads and ads on all website. Dilemma! in webmaster side we have to earn some revenue to keep continue, in costumer side sometimes they hate if we push to many ads on web page.

So? why not making random ads on your ads space some paid ads and some free ads you can use to help your costumer for what they looking for.  Simple as 1-2-3  now open your superb text editor NOTEPAD and copy this code:

<?php
$fcontents = join (“”, file (“random_ads.txt“));
$s_con = split(“~”,$fcontents);
$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>

Save it as random.php or whatever you like (remember to give .php extension) Now creating random_ads.txt files (for database) and put a sample code on there:

<center>I’m center!</center>
~
<b>I’m bold!!! for freeeeeeeeeeeee</b>
~
I’m adsense ads
~
I’m short news!
~
I’m paid ads!!! hooray!

You can write html code or php code on database file if you’re creative you can put images/flash on it. Now put this both files on same directory on your hosting and embed it using include command into your website page.

Refresh your page to see ads rotated or you can use auto refresh meta

<meta http-equiv=”refresh” content=”180“>

180 value are in milliseconds you can change it to fit your need.

See what you have now :D

Share |