Friday, July 24, 2009

You can set CakePHP Debug Level

CakePHP Debug Level:

Production Mode:
0: No error messages, errors, or warnings shown. Flash messages redirect.

Development Mode:
1: Errors and warnings shown, model caches refreshed, flash messages halted.
2: As in 1, but also with full debug messages and SQL output.
3: As in 2, but also with full controller dump.

Note:-
In production mode, flash messages redirect after a time interval.
In development mode, you need to click the flash message to continue.

In core.php file u will get this code:-

Configure::write('debug',2);

Thursday, July 23, 2009

Redirect to custom error page,if page is not exists

ErrorDocument 404 /not-found.php

From this .htaccess code you can redirect to custom error page.
if user request for non exists file on site URL.

Saturday, July 18, 2009

Select or Unselect all Checkbox

You can use this free javascript code to Select / Unselect all the checkboxes by selecting a single check box.



checked=false;
function checkedAll (frm1) {
var aa= document.getElementById('frm1');
if (checked == false)
{
checked = true
}
else
{
checked = false
}
for (var i =0; i < aa.elements.length; i++)
{
aa.elements[i].checked = checked;
}
}

OR consider this

tag_name=checkbox array name
checkallName=select all checkbox name

function checkedAll (tag_name,checkallName) {

var checked=false;
checked = document.getElementById(checkallName).checked;

for (var i = 0; i < document.getElementsByName(tag_name).length; i++) {
document.getElementsByName(tag_name)[i].checked = checked;
}

}

Friday, July 10, 2009

php realex payment gateway code

$timestamp = strftime("%Y%m%d%H%M%S");
$topay = '5';
$merchantid = "mytalentplace";//here grant crow`s realex merchent id should come
$secret = "wXcHmZ9yec";


$orderid= $timestamp.'-'.$_SESSION['ord_id'];





$amount =$_POST['amt']*100;

if($_REQUEST['currency']=="doller"){

$curr= "USD";

} elseif($_REQUEST['currency']=="euro"){

$curr= "EUR";

}else {

$curr= "GBP";

}

$tmp = "$timestamp.$merchantid.$orderid.$amount.$curr";
//$tmp = "$timestamp.$merchantid.$orderid";

$md5hash = sha1($tmp);

$tmp = "$md5hash.$secret";

$md5hash = sha1($tmp);

$up="UPDATE `mtp_user_payment` SET order_id='".$lid."' where user_payment_id='".$lid."'";
mysql_query($up);
?>

Opening Cake THTML file with Dreaweaver CS4

Just go to:

C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration

Open file: Extensions.txt

edit line 16 and add THTML

Save and Close the File

Next, Open MMDocumentTypes.xml at C:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\DocumentTypes

Add THTML online 75 : winfileextension=”thtml,php,php3,php4,php5″ macfileextension=”thtml,php,php3,php4,php5″

Save, close and Restart Dreamweaver!


For more Info :- http://keithics.com/blog/article/opening-cake-thtml-file-with-dreaweaver-cs4/118/


Tuesday, July 7, 2009

Website Payments Standard Integration Guide (Paypal)

https://www.paypalobjects.com/WEBSCR-580-20090702-1/en_US/pdf/PP_WebsitePaymentsStandard_IntegrationGuide.pdf

How do I generate a PayPal Identity Token

1. Click the My Account tab.
2. Click Profile at the top of the page.
3. On the right under Selling Preferences click on Website Payment Preferences.
4. Under Auto Return for Website Payments click "on"
5. After Return URL put http://www.example.com
6. Under Payment Data Transfer (Optional) click "on"
7. Scroll to the bottom of the page and click Save.
8. Copy the Identity Token (everything after the word "Token:" in the new window), and paste it into your My talent place PayPal Information.

PayPal Identity Token (PHP Script)

if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); // read the body data $res = ''; $headerdone = false; while (!feof($fp)) { $line = fgets ($fp, 1024); if (strcmp($line, "\r\n") == 0) { // read the header $headerdone = true; } else if ($headerdone) { // header has been read. now read the contents $res .= $line; } }
// parse the data $lines = explode("\n", $res); $keyarray = array(); if (strcmp ($lines[0], "SUCCESS") == 0) { for ($i=1; $iaddPaymentDetails($keyarray['txn_id'], 'Paypal', $keyarray['mc_gross'], $keyarray['option_name1'],$status);
header("location:thanks_payment.php"); } else if (strcmp ($lines[0], "FAIL") == 0) { header("location:error.php"); // log for manual investigation //header("location:thanks_payment.php"); }
}
fclose ($fp);?>

Example of Custom URL rewritting

RewriteEngine on
RewriteRule ^career-options/(.*)-([0-9]+)\.html$ careerdetails.php?carr_id=$2RewriteRule ^career-advice$ careeradvice.phpRewriteRule ^parent-career-help$ parent_profile.phpRewriteRule ^Forum/(.*)-([0-9]+)\.html$ forum_index.php?career_category_id=$2RewriteRule ^career-advice/career-counselling$ careercounselling.phpRewriteRule ^career-advice/interview-training$ interviewsuccess.phpRewriteRule ^career-advice/interview-questions-answers$ interview_questions.phpRewriteRule ^career-options$ career.phpRewriteRule ^community$ community.phpRewriteRule ^career--options/(.*)-([0-9]+)\.html$ careerdetails.php?carr_id=$2&addFirstChoice=1

mytalentplace

One of my favorite recent developed web site.
URL :- http://www.mytalentplace.co.uk/

Wednesday, July 1, 2009

best blog for PHP script or code

This blog is created and maintained by Mr.Jawed Shamshedi (Sr.Eng..) for php developer's.

http://jawedphp.blogspot.com/

PHP date problem

useful URL for PHP date problem

url rewriting

useful url rewriting examples using .htaccess

1)Rewriting product.php?id=12 to product-12.html
It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.
RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1
2) Rewriting product.php?id=12 to product/ipod-nano/12.html
SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.
RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2
3) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
4) Redirecting the domain to a new subfolder of inside public_html.
Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, www.test.com point out to the files inside “new” folder.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{REQUEST_URI} !^/new/
RewriteRule (.*) /new/$1

ebook

lot of books collection here !

Testing Web Based Applications with JMeter

http://www.devarticles.com/c/a/PHP/Regression-Testing-With-JMeter/

Some Important Link to read about OOPs with php

Object Oriented Programming with PHP

http://www.devarticles.com/c/a/PHP/Object-Oriented-Programming-in-PHP/