Java hex2text convert

Here is the code for converting hex into a normal char.

public static String hex2Text(String str){
if(str == null || str.trim().length() == 0)
return "";
str = str.trim();
str = str.toLowerCase(); //ensures all input is lower case
User needs to be warned that their input is invalid
Method must terminate
return ""; //Until proper exception can be written
StringTokenizer tokenizedStr = new StringTokenizer(str);
StringBuffer text = new StringBuffer();
String hexString = tokenizedStr.nextToken();
int bytelen = hexString.length();
if(bytelen > 4){
//User needs to be told input is not valid
return ""; //Until exception can be written.
int decimal = hex2decimal(hexString);
int intValue = 0;
for(int i = 0;i < strlen;++i){
int oneOrZero = decimal % 10;
decimal /= 10;
intValue += Math.pow(2,i) * oneOrZero;
}//end for
char textEquivalent = (char) intValue;
}//end while
return text.toString();

private static int hex2decimal(String hex){
int decimal = 0;
for(int i = hex.length() - 1;i >= 0;--i){
int asciiValue = hex.charAt(i);
if(asciiValue >= '0' && asciiValue <= '9')
asciiValue -= 48;
asciiValue -= 87;
decimal += Math.pow(16,i) * asciiValue;
}//end for
return decimal;
}//end hex2decimal()

Convert HEX2TEXT

Converting hex into a text or normal string.

function hex2text($hexstr) {
$hex = explode('%',$hexstr);
$str = '';
foreach($hex as $hexcode) {
$str .= chr(base_convert($hexcode, 16, 10));
return $str;

PHP insert blob and update blob MySQL

Here is how to insert file BLOB MySQL.

$file_name = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$fp = fopen($tmp_name, 'r');
$file_content = fread($fp, $file_size) or die("Error: cannot read file");
$file_content = mysql_real_escape_string($file_content) or die("Error: cannot read file");
$qu = "INSERT INTO `file`
$re = mysql_query($qu) or die ("Sorry Cant insert db!");
echo $file_name." inserted succesfully to database";
echo "< form method=\"post\" name=\"form1\" enctype=\"multipart/form-data\">";
echo " < input name=\"file\" type=\"file\">";
echo " < input name=\"submit\" type=\"submit\" value=\"Upload\">";
echo "< /form>";

How to Protect from double posting insert MySQL

Submit once even the visitor is refresh the page from browser.
Here is the way to protect.
1. Set a session in the form page

$_SESSION[post_only_once] = 1;
echo "
< form method=\"post\">
Name < input type=\"text\" name=\"name\">
< input type=\"submit\" value=\"submit\" name=\"submit\">
< /form>

2. Check the session before doing INSERT into MySQL.
if($_SESSION[post_only_once] == 1) {
// here doing insert to mysql
unset($_SESSION[post_only_once]); // remove the session after insert

How to connect MySQL from PHP

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
echo 'Connected successfully';

PHP br2nl function


How to detect browser no flash give alternate with gif

Let see, we have one file .swf and one file .gif and we want display the flash file first, and if the browser doesn't support, it will display the .gif version.
Here is the code.


How to pick a complex string from MySQL

We can pick a string from MySQL database with various style.
Example, the value from database is NCABZ-2007
And we want only view ABZ
Here is the CODE.

$data = "NCABZ-2007";
$new_data = substr($data, 2 , 3);

2 = number of data from the left (N=0, C=1, A=2, B=3, etc.)
3 = how much char we want to display

PHP Cut string from MySQL

Shorting or cutting the text string from long char into new max lenght.
Here is the code.

function short_string ($var, $len){    
if (strlen ($var) < $len) {
return $var;
if (preg_match ("/(.{1,$len})\s/", $var, $match)) {
return $match [1] . "..";
} else {
return substr ($var, 0, $len) . "..";

How to use?
short_string ("Very very long text is here blablabla", 14);

The Result is:
Very very long..

Insert and Select doing in MySQL from SQL Injection

Here is the save way from RSS Attack SQL Injection.
Get all variable $_POST or $_GET or $_REQUEST or $_SESSION convert into mysql_real_escape string filter, you do not need one by one for all type variable.
here is code.

$_POST  = array_map('mysql_real_escape_string', $_POST);
$_SESSION = array_map('mysql_real_escape_string', $_SESSION);
$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);

And here is to view back or mysql_unescape_string or mysql_real_unescpae_string or whatever you want to.
function mysql_real_unescape_string($string){
return $string;

Convert TEXT2HEX

Here is a php script snippet to convert string text to hex decimal code.

function text2hex($string) {
$hex = '';
$len =
strlen($string) ;
for ($i = 0; $i < $len; $i++) {
$hex .=
str_pad(dechex(ord($string[$i])), 2, 0, STR_PAD_LEFT);
return $hex;

QuiXplorer - web-based file-management

The best Filemanagement system PHP what i choose is QuiXplorer.
Here is the detail from contributor:

QuiXplorer is a multi-user, web-based file-manager.
It allows you to manage and/or share files over the internet, or an intranet.

The latest version provides the following functionality:

  • Browsing directories; showing names, file sizes,
    file types, modification times and permissions
  • Copying, moving and deleting files
  • Searching for files and directories
  • Uploading and downloading files
  • Editing text files
  • Creating new files and directories
  • Changing file permissions
In multi-user mode:
  • Users are authenticated.
  • Administrators can manage users.
  • Each user has his/her own settings.
QuiXplorer is currently available in English, Dutch, German, French, Spanish and Russian.


TinyMCPUK - TinyMCE with file/image manager

The Best WYSIWYG now for me is TinyMCPUK.
1. Small file size
2. Complete Editor
3. Image Manager and Image Editor

Here is the detail information from the contributor:

TinyMCPUK brings you the powerful TinyMCE plus the MCPUK file manager and ImageManager strictly integrated together.


TinyFCK package contains:

  • a TinyMCE release (absolutely not patched, this is the original TinyMCE)
  • a patched version of Martin Kronstad’s MCPUK/ImageManager integration
  • an example documenting configuration

TinyKCPUK is only available for PHP.



TinyMCPUK 0.1 is updated with TinyMCE


PHP member signup script using mysql

The simple and powerfull User Member System.

Are you creating a signup form for your visitors ? You must have seen many sign up forms through out the Internet. Sites asking you for free signup or paid signup where they keep you waiting until you pay. Through signup webmasters keep a record of the visitors address, profile and other details, so every time the visitor need not fill all the details for every product or service it order through the website.
We will use some basic checking or validation to ensure all required info are filled by the visitor. We will also keep some optional fields in the form. As we will be developing this script with some basic requirements, you can expand it further as per your need. We will try to include all type of form components so you will learn how to handle them in different situation. We will be using MySQL database for storing the data so you must ensure that mysql_connection, database set-up etc are working perfectly..
Source & Download link:

Image Resize PHP use GD and create seperate file thumb

This is simple ready to use.
Image Resize PHP use GD and create seperate file thumb.
And insert into database with id filename, like: 1.jpg or 2.gif, and so on.
Btw, take a look at the comment, it is clear enaugh to understand.


Newsletter free, very simple, easy, ready to use

News letter script with PHP and simple text flat file txt.
Very simple newletter script free that i choose is this link: Newsletter Script

PHP Unlimited sub categories

The best Unlimited sub categories, I choose this one by Shadi Ali (Jan/15/2006).
The coding is simple, easy to understand and ready to use.

This script use: PHP and MySQL database.

Cron job working via cpanel

How to run the php file from cron job via cpanel?
Here it is:
1. login to your cpanel
2. click cron icon
3. click standar
4. enter your email address for reporting if the cron is failed
5. choose the time what you want
6. enter the command, it depends on your server hosting.

the command should be like this:

curl -s -o /dev/null

if curl is disable form your hosting service, you can use another way, with this:

lynx -dump http:// > /dev /null

if curl and lynx is disable form your hosting service, you can use another way, with this:

/usr/bin/wget -O - /home/your_username/public_html/script.php


GET > /dev /null

if curl, lynx and wget is disable form your hosting service, you can use another way, with this:

in the your_script.php file put this at the top the first line before anything:


and use this cron command

php -f /home/your_username/public_html/your_script.php

file your_script.php should chmod 755
and the /home/your_username/ is your path on server.

if you have still problem, like "
No input file specified. ", please try this:


7. save it

if you have error, pls let me know, welcome to leave comment here..

My Editor Wysiwyg ?

I choose for WYSIWYG Editor for web, the best and free is:

Here is some description from the web:

Xinha (pronounced like Xena, the Warrior Princess) is a powerful WYSIWYG HTML editor component that works in Mozilla based browsers as well as in MS Internet Explorer. Its configurabilty and extensibility make it easy to build just the right editor for multiple purposes, from a restricted mini-editor for one database field to a full-fledged website editor. Its liberal licence makes it an ideal candidate for integration into any kind of project.

Xinha is Open Source, and we take this seriously. There is no company that owns the source but a community of professionals who just want Xinha to be the best tool for their work.

AJAX Star Rating Bar

For rating i choose this script, from, here we are the description and the full url.

Unobtrusive AJAX Star Rating Bar

Unobtrusive AJAX Rating Script

What It Is

This is a rating bar script done with PHP and mySQL that allows users to rate things like can be done on Netflix or Amazon, all web 2.0-like with no page refresh. It is a major improvement on the previous version because it is now unobtrusive, meaning that if Javascript is off it will still work (although the page will refresh). You can also set the number of rating units you want to use (i.e. 4 stars, 5 stars, or 10 stars) on a rater to rater basis (see samples below or read the docs). A few other changes were made as well - see the docs for details. Note that this script isn't tied to any specific system (such as WordPress), so you should be able to adapt it to your situation without too much trouble.

Show users IP in a graphic - PHP Script


$img_number = imagecreate(275,25);
$backcolor = imagecolorallocate($img_number,102,102,153);
$textcolor = imagecolorallocate($img_number,255,255,255);

$number = " Your IP is $_SERVER[REMOTE_ADDR]";


header("Content-type: image/jpeg");


Simple CAPTCHA, easy and ready to use.

Screen shot:

Source is on:
just insertt the class, and upload the font, the font you can download from there.

Pagination Version 2 (ready to use PHP MySQL)

Very easy to use simply add the class, and edit setting:

$page = $_REQUEST["page"];
$alamat_pag = ""; // Full adress your PHP script
$adjacents = 3; // do not change if you do not know
$tabel="sample_tabel"; // table database form MySQL
$where=""; // where condition, optional
$order="ORDER BY `date` DESC, `name`"; // order condition, optional
$limit = 10; // set limit per page
include "pagination.php"; // include the class
$no=$start+1; // the number, if you want it to diplay, optional
while($ro = mysql_fetch_array($portfolio)) {
$no." ";

"Total: $total_pages

The code is on:

[AJAX] - File Upload with PHP, Javascript & iFrame

Well, this is my choise for simple uploading system:

take a look...