Tareq Alam

i have promises to keep and miles to go before i sleep – Robert Frost

Some Test Credit Card Numbers October 24, 2008

I think This will help the developers who are trying to integrate various payment gateway. here is some test credit card names and numbers:

370000000000002 American Express Test Card
6011000000000012 Discover Test Card
5424000000000015 MasterCard Test Card
4007000000027 Visa Test Card
4012888818888 second Visa Test Card
3088000000000017 JCB
38000000000006 Diners Club/ Carte Blanche

Hope this helps

Thanks

 

PHP: Change Image Opacity June 20, 2008

Filed under: PHP — tareqalam @ 1:03 pm
Tags: , , ,

Here is a script which will change the image opacity…

Try this code and have fun..
$imageName = 'path/to/your/image/file'
$im_src = create_image_from_type($imageName);
$size = getimagesize($imageName);
$im_dst = create_image_from_type($imageName);
$white = imagecolorallocate($im_dst, 255, 255, 255);
imagecolortransparent($im_dst, $white);
imagefilledrectangle($im_dst, 0, 0, $size[0], $size[1], $white);
$opacityVal = 50;// put the opacity value here
imagecopymerge($im_dst, $im_src, 0, 0, 0, 0,$size[0], $size[1], $opacityVal);
save_image($im_dst, $imageName, 100);
imagedestroy($im_dst);
imagedestroy($im_src);

function save_image($image_dest,$image_src,$image_quality)
{
$image_type = getimagesize($image_src);
if($image_type['mime']=='image/png')
{
imagepng($image_dest,$image_src);
}
else
{
imagejpeg($image_dest,$image_src,$image_quality);
}
return true;
}

function create_image_from_type($image_path)
{
$image_type = getimagesize($image_path);
if($image_type['mime']=='image/png')
{
$im = imagecreatefrompng($image_path);
}
else
{
$im = imagecreatefromjpeg($image_path);
}
return $im;
}

 

File upload with ajax April 23, 2008

Filed under: AJAX, PHP — tareqalam @ 8:46 am
Tags: , , ,

I have suffered finding a code to easily upload file using ajax. Then I have found a Plugin which uses Jquery and PHP to upload file. I should not take the credit to make it. here is the link from where i got the code
http://www.phpletter.com/Our-Projects/AjaxFileUpload/
This is free and very easy to use. And the code is really helpful. U can customize it in your own way.

Please thank him for this code. I am really greatful to the person who made this and gave that to us totally free.

 

CakePHP April 21, 2008

Filed under: PHP, PHP Frameworks — tareqalam @ 8:21 am
Tags: , ,

CakePHP is a nice PHP framework. Its as delicious as it’s name.
Installation is too easy. Just follow the steps..

  • download cake php from here http://www.cakephp.org/
  • just unpack it to your host and point the url and do as the introductory page say

Now I want to discuss how i have intigrated Smarty in CakePHP

I know there are few drawbacks of smarty but its helpful for the people who are already master in smarty.

Intigrating Smarty with cakePHP will be like blessing for them. Because they dont need to learn the template engine of cakephp then :) . Hope you guyz find this helpful

Steps

1. Download a version of SmartyView from here:
http://cakeforge.org/snippet/detail.php?type=snippet&id=6

  1. Save SmartyView as /(app)/views/smarty.php

2. Download Smarty

http://smarty.php.net/download.php
Extract tarball so Smarty.class.php sits at /vendor/smarty/Smarty.class.php

3. Create “smarty/compile” and “smarty/cache” within your tmp dir

(/(app)/tmp/ by default) and make them writable by the apache user

4. Include in your controller

(in app_controller.php to do it app-wide) var $view = 'Smarty'; and (to enable the SmartyHtml/SmartyJavascript helpers) var $helpers = array('SmartyHtml','SmartyJavascript'); to use Smarty templates and helpers.

You now have SmartyView installed!

Notes:

  1. /views/smarty_templates is parsed for smarty plugins : http://smarty.incutio.com/?page=SmartyPlugins
  2. SmartyView will fall back to .thtml templates for views.
  3. By default Smarty views must reside in ’smarty’ subdirectories — see addendum for information regarding removing this requirement.
 

Mojavi Framework April 21, 2008

Filed under: PHP, PHP Frameworks — tareqalam @ 8:00 am
Tags: , ,

I have worked with Mojave framework for more than 1 year while i was in ECBBBD. This is a true MVC(Model View Controller) Framework.

With this framework its easy to develop any kind of site and web application. Smarty is intigrated with this framework.

The original project site can be found at http://www.mojavi.org

This site’s development is currently stopped. But you can have a brief idea there.

If you’re looking for the Mojavi 2.0 API Documentation it can now be found at http://www.tannerburson.com/docs/mojavi/api please update your bookmarks accordingly.

I have worked on many projects using this framework. Though its not that much famous framework, its simple and easy.