Configure CakePHP in Ubuntu

August 5, 2009 at 7:39 pm | In Ubuntu | Leave a Comment
Tags: ,

Configure CakePHP on Linux/Ubuntu is a bit tricky as you have to on the mod-rewrite and set the AllowOverride property from None to All.
1. mod_rewrite is a part of Apache server that can rewrite requested urls on the fly. To enable mod_rewrite in Ubuntu, you just need to write this command in terminal:

 sudo a2enmod rewrite 

2.Open and edit the default file from this directory /etc/apache2/sites-available/default by using the following command:

sudo gedit  /etc/apache2/sites-available/default

Find the following Directory structure:

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews
AllowOverride None //Change to AllowOverride All
Order allow,deny
allow from all

</Directory>

3.Restart apache using:

  sudo /etc/init.d/apache2 restart  

Your configuratation complete! :)
Now you should now be able to view http://localhost/ with the correct css formatting for the cake default page.
Note: To execute the above command you should have sudo/root permission in Ubuntu

Paypal Integration in simple way

May 5, 2009 at 5:16 pm | In PHP | Leave a Comment
Tags: ,

when you want to transaction through paypal, there are 2(two) situation created

situation 1: Suppose you have a paypal account.You want to sell something and want to make money transaction through paypal. Now there are a critical situation. When someone buy your product through paypal, suppose a software, you want that automatically a license key will send to that user if payment make successful. So, here is the integration process step by step: Put this code in your site:

 <form id=”formpay” action=”https://www.paypal.com/cgi-bin/webscr” method=”POST” >
<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=”yourpaypalemail@email.com”>
<input type=”hidden” name=”item_name” value=”name of the item”>
<input type=”hidden” name=”item_number” value=”1″>
<input type=”hidden” name=”no_shipping” value=”1″>
<input type=”hidden” name=”return” value=”http://yoursite.com/success”>
<input type=”hidden” name=”notify_url” value=”http://yoursite.com/notifyme”>
<input type=”hidden” name=”currency_code” value=”USD”>
<input type=”hidden” name=”amount” value=”4″>
<input type=”image” src=”http://www.paypal.com/en_US/i/btn/x-click-but01.gif” name=”submit” alt=”Make payments with PayPal - it’s fast, free and secure!”>
</form>

This is the html code, that makes a visual paypal button in your site. Look carefully, the action of form remain same as here. If you want a normal buy button, then input name “cmd” its value should be =”_xclick”. input name “business” it’s value should be the email address you registered in paypal. Input name amount contains the price you set as a value. Now the most important input fields are “return” and “notify_url”. “return” field contains that url address, when purchase become successful and you want to show user some message like “congratulation, your purchase is successful”. As soon as purchase makes complete paypal dump some values to your “notify_url”. So, in this field, you should put that url of your site that makes some changes like database update or send any special email.

Now download this free code : http://www.hotscripts.com/Detailed/46734.html After downloading, unzip the zip file. You’ll get two php files. Now copy this file paypal.class.php into your project. Suppose your notify_url field is: http://abdullah.com/notify.php
Now write this code in notify.php

<?php
require_once(’paypal.class.php’);  // include the class file
$p = new paypal_class;             // initiate an instance of the class
if ($p->validate_ipn()) {
// Payment has been recieved and IPN is verified.  This is where you
// update your database to activate or process the order, or setup
// the database with the user’s order details, email an administrator,
// etc.  You can access a slew of information via the ipn_data() array.
// Check the paypal documentation for specifics on what information
// is available in the IPN POST variables.  Basically, all the POST vars
// which paypal sends, which we send back for validation, are now stored
// in the ipn_data() array.
// For this example, we’ll just email ourselves ALL the data.
$subject = ‘Instant Payment Notification - Recieved Payment’;
$to = ‘YOUR EMAIL ADDRESS HERE’;    //  your email
$body =  “An instant payment notification was successfully recieved\n”;
$body .= “from “.$p->ipn_data['payer_email'].” on “.date(’m/d/Y’);
$body .= ” at “.date(’g:i A’).”\n\nDetails:\n”;
foreach ($p->ipn_data as $key => $value) { $body .= “\n$key: $value”; }
mail($to, $subject, $body);
}
?>

So, if $p->validate_ipn() returns true, that means payment verified and you received the payment. And if it returns false, then you’ve to consider that for some reason payment doesn’t make successful.

situation 2: Suppose you want to make a subscription form. Subscripted fee may be charged daily, weekly, monthly or yearly. Suppose you want a yearly subscription form. So, any user who pays you, he have to pay yearly, otherwise his membership will cancel.
Solution: Here is the html code for the form. Look the changes. form action remains same as above. input field cmd is changed. Look the value of it. 5 new input field added here. For subscription form, notify_url be the same and you could use the paypal.class.php and like the previous way, you could check whether payment makes successful or not.

<form id=”fromsub” action=”https://www.paypal.com/cgi-bin/webscr” method=”POST” >
<input type=”hidden” name=”cmd” value=”_xclick-subscriptions”>
<input type=”hidden” name=”business” value=”yourpaypalemail@email.com”>
<input type=”hidden” name=”item_name” value=”name of the item”>
<input type=”hidden” name=”item_number” value=”1″>
<input type=”hidden” name=”no_shipping” value=”1″>
<input type=”hidden” name=”return” value=”http://yoursite.com/success”>
<input type=”hidden” name=”notify_url” value=”http://yoursite.com/notifyme”>
<input type=”hidden” name=”currency_code” value=”USD”>
<input type=”hidden” name=”amount” value=”4″>
<input type=”hidden” name=”a3″ value=”5″>
<input type=”hidden” name=”p3″ value=”1″>
<input type=”hidden” name=”t3″ value=”Y”>
<input type=”hidden” name=”src” value=”1″>
<input type=”hidden” name=”sra” value=”1″>
<input type=”image” src=”https://www.paypal.com/images/x-click-but20.gif” name=”submit” alt=”Make payments with PayPal - it’s fast, free and secure!”>
</form>

HTML Variables for PayPal Subscriptions

Variable Name

Required or Optional

Description

“post” action

Required

Must be set to “https://www.paypal.com/cgi-bin/webscr”

cmd

Required

Must be set to “_xclick-subscriptions”

business

Required

This is your PayPal ID, or email address. This email address must be confirmed and linked to your Verified Business or Premier

account

item_name

Optional

Description of item being sold (maximum 127 characters). If you are collecting aggregate payments, this can include a summary of all items purchased, tracking numbers, or generic terms such as “subscription.” If omitted, customer will see a field in which they have the option of entering an Item Name

return

Optional

An internet URL where the user will be returned after completing the payment. For example, a URL on your site that hosts a “Information on your new subscription” page. If omitted, users will be taken to the PayPal site

rm Optional Return URL behavior. If set to “1” and if a “return” value is
submitted, upon completion of the payment the buyer will be sent
back to the return URL using a GET method, and no transaction
variables will be submitted. If set to “2” and if a “return” value is
submitted, the buyer will be sent back to the return URL using a
POST method, to which all available transaction variables will
also be posted. If omitted or set to “0”, GET methods will be used
for all Subscriptions transactions and Buy Now, Donations, or
PayPal Shopping Cart transactions in which IPN is not enabled.
POST methods with variables will be used for the rest
cancel_retu Optional An internet URL where the user will be returned if payment is
rn cancelled. For example, a URL on your site which hosts a
“Payment Cancelled” page. If if omitted, users will be taken to
the PayPal site
a1 Optional Trial amount 1. This is the price of the first trial period. For a free
trial, use a value of 0
p1 Optional Trial period 1. This is the length of the first trial period. The number is modified by the trial period 1 units (t1, below)
t1 Optional Trial period 1 units. This is the units of trial period 1 (p1, above).
Acceptable values are: D (days), W (weeks), M (months), Y
(years)
a2 Optional Trial amount 2. This is the price of the second trial period
p2 Optional Trial period 2. This is the length of the second trial period. The number is modified by the trial period 1 units (t2, below)
t2 Optional Trial period 2 units. This is the units of trial period 2 (p2, above).
Acceptable values are: D (days), W (weeks), M (months), Y
(years)
a3 Required Regular rate. This is the price of the subscription
p3 Required Regular billing cycle. This is the length of the billing cycle. The number is modified by the regular billing cycle units (t3, below)
t3 Required [required] Regular billing cycle units. This is the units of the
regular billing cycle (p3, above) Acceptable values are: D (days),
W (weeks), M (months), Y (years)
src Optional Recurring payments. If set to “1,” the payment will recur unless
your customer cancels the subscription before the end of the
billing cycle. If omitted, the subscription payment will not recur
at the end of the billing cycle

Class for Backup_Restore of Mysql database

January 26, 2009 at 9:45 am | In Classes | 2 Comments

Today i’m very happy, cause myclass has been approved in phpClasses.

i submit my class in phpClasses last 15 days ago.  approved information get yesterday. you can backup and restore your mysql database very simply way using my class. it produce a .sql file as a backup file, and also you can restore this file using my class.

Continue reading Class for Backup_Restore of Mysql database…

Create a simple script to backup mysql database

January 11, 2009 at 4:22 pm | In mysql | Leave a Comment
Tags: , ,

we can create backup using mysql interface that is phpmyadmin.

But we can create a customize interface to data backup using create simple line of code

<?php
if(isset($_POST['submit']))
{
shell_exec(‘C:\xampp\mysql\bin\mysqldump.exe ‘.$_POST['dbname'].’ –user=root –password= >c:\\’.$_POST['dbname'].’.sql’) ;

}
?>
<body>
<form name=”mysql” method=”post”>
<div>
<table>
<tr>
<td>Database Name</td><td><input type=”text” name=”dbname”></td>
</tr>
<tr><td><input type=”submit”  name=”submit” value=”Backup”></td><td></td>

</tr>
</table>
</div>

</form>
</body>

widget create in a miniute

January 1, 2009 at 10:44 am | In wordpress | Leave a Comment
Tags: ,

in wordpress you can create your widget in a simple manner, the process is so simple

given below the widget plugins name is “widget-test”. you can modified that as your need

<?php
/*
Plugin Name: widget-test
*/
##never forget this function configuration
##never forget add $before_widget,$before_title, $after_title and $after_widget
## example given below
function widget_test($args) {
extract($args);

echo $before_widget.$before_title.”widget-Title”.$after_title;
echo ‘<ul>’.”n”;
echo “text here”;//call any function or print something that will be show in your widget contents

echo ‘</ul>’.”n”;
echo $after_widget;
//}
}

###Widget initialize function
function widget_init() {
register_sidebar_widget(__(‘Widget Title’), ‘widget_test’);
}

add_action(‘plugins_loaded’, ‘widget_init’)
?>

Hi all,

December 1, 2008 at 5:04 pm | In Classes | Leave a Comment

Programming is a passion to me. its true to a lots of programmer in the world, some time we found magic, imagination in the function or events.

i will post some magic & imagination “inshaallah”

In this blog you can share any knowledge, can post tips, tricks that you use or create

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.