Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Thursday, August 2, 2012

File download with speed limit



Today I have create a script as like rapidshare file download with speed limit.
Script:

Monday, February 27, 2012

Convert xml to cvs by php

I have used php 5.0 to convert xmx to cvs. Here "SimpleXML" reads an entire xml into an object that we can iterate through his properties.To write to the csv output file we will use "fputcsv". "fputcsv" formats a line as csv and writes it to the file.

Code of xml file (as the name "cars.xml") is here:

Create favicon (*.ico) with imagick in php

Here is an example that will take any image format supported by Image Magick (is there one that is not?) and create a 16 pixel favicon image from it. The cropThumbnailImage() method does the work of resizing and cropping in a single swoop while the setFormat() method converts the file to .ico format.

Code is here:

Multiple file upload

Uploading multiple files with PHP requires checking for many possible errors. This script allows the setting of how many upload fields will be displayed in the HTML form and the maximum allowable filesize to upload. The php.ini file also contains an ini option named upload_max_filesize which has a default value of 2M, or two megabytes. This value is taken into consideration also when checking for errors.

The errors are stored in an array called messages and for each file upload a message is generated based on any errors or success of the upload. The form itself was validated with the w3c validator in accordance with the DOCTYPE.

Code with details is:

Calculates the age in php

This simple function calculates the age, in years, of a date supplied in any format supported by the strtotime() funcition, which means, basically, any date you can sanely imagine.

Code of function is:

Twenty Four Hour to Twelve Hour

Recently I have created robotic mailing system for my client. But when it needed to convert a bunch of 24 hour times to 12 hours, the times were in different formats but I needed them in a format that was easily human readable. This function will convert a twenty four hour time to twelve hour time. Feel free to modify it to your own needs.

Code is here:

Convert Unix Timestamp To MySQL Timestamp

PHP date functions such as strtotime() and time() and date() all return a value as a UNIX TIMESTAMP. This is great for date manipulation but becomes a problem when we need a date to INSERT into a MySQL database. The format of a MySQL TIMESTAMP is yyyy-mm-dd hh:mm:ss and to meet this need a simple PHP can be utilized to convert any UNIX TIMESTAMP into a MySQL TIMESTAMP.

Code and use of function is:

Sunday, February 19, 2012

reCaptcha Captcha with PHP and JQuery and CSS

Today I am presenting a code of project for reCaptcha Captcha with PHP and JQuery and CSS. I think all of enjoy it very much.
reCaptcha Captcha with PHP and JQuery and CSS

View Demo: link | Download: Direct

Thursday, February 9, 2012

Image converter class in php

Image converter is so important to a designer and developer. When you want to upload images in host you should convert it in a desired file system. I have create a class in php to convert image to all kind of image from source file system. By this you can create a online image converter. If you create online image converter using this code or develop this please mail me.

It is so easy to call as the code:
[php]

<?php
require("class.imageconverter.php");

$img = new ImageConverter("2000.gif","wbmp");

?>

[/php]
All of code is here:

Wednesday, January 11, 2012

Create or delete subdomain dynamically using php and cPanel

Introduction
Using this code you can create subdomains in the live server using php under cPanel control panel. There are two functions in this code. One is to create subdomains and the other is to delete a subdomain.
A subdomain is nothing but a folder in the root folder or a folder in any other place in your server domain space under the root folder which will be pointed by a url which you give as name.

Create subdomain code in php

Here is the function to create a subdomain in php.

• First parameter is the subdomain name. Like if you want music.sitename.com then you should provide the word music.

• Second parameter is the user name of your web hosting control panel username. This is the login where you manage your sites files, ftp, database, etc.

• Third parameter is the password of your control panel.

• Fourth parameter is the name of your original or root domain. for example if your domain name is example.com then you have to provide this here without the subdomain name.

Friday, January 6, 2012

Convert image to code image by php

[php]
<?php
function image2ascii( $image ){
$ret = '';
$img = ImageCreateFromJpeg($image);
$width = imagesx($img);
$height = imagesy($img);

for($h=0; $h<$height; $h++) // loop for height of image code
{
for($w=0; $w<=$width; $w++) // loop for width of image code
{
$rgb = ImageColorAt($img, $w, $h); // add color in code
$r = ($rgb >> 16 ) & 0xFF;
$g = ($rgb >> 8 ) & 0xFF;
$b = $rgb & 0xFF;
// create a hex value from the rgb
$hex = '#'.str_pad(dechex($r), 2, '0', STR_PAD_LEFT).str_pad(dechex($g), 2, '0', STR_PAD_LEFT).str_pad(dechex($b), 2, '0', STR_PAD_LEFT);

if($w == $width)
{
$ret .= '<br>';
}
else
{
$ret .= '<span style="color:'.$hex.';">*</span>';
}
}
}
return $ret;
}


$image = '123.jpg'; // an image to convert in code
echo image2ascii( $image ); // do the conversion by calling function
?>
[/php]
Click here for Demo

Thursday, December 22, 2011

How to write php

In html file:

[php]

<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo "Welcome to php language";
?>
</body>
</html>

[/php]

In php file:

[php]

<?php
echo "Welcome to php language";
?>

[/php]

All of pages out put will be: Welcome to php language