Skip to main content

Posts

PHP, JSON and JavaScript usage

Today i want to introduce you to jSON (JavaScript Object Notation), in short, it is a simple format designed to exchange data between different programming languages. I will show you how to create JavaScript object, convert it to JSON string, and send to PHP script, which will decode jSON string to readable format (for PHP). But that’s not all, PHP script will create it’s own data object encode it to jSON string and send it back. All communication between JavaScript and PHP will be done thru AJAX. If you haven’t heared about jSON yet, then you can visit Wikipedia for more information. The other technology you need to be familiar with before reading this article is AJAX. If you need to, you can read my Introduction to AJAX post. Last note before we start, i am constantly working to make my articles as useful for you as possible, so beginning from this tutorial in each of my programming tutorials, at the end of the article you will find complete source code for download. JSON objects...

Google Checkout Integration for PHP

What is Payment Gateway integration? A payment gateway can be defined as a third party service, which is a combination of hardware and software that provides an interface to the bank credit card processing network. The credit card information is collected and is transferred over the Internet to the credit card processors in the encrypted format for transaction purpose. Some well-known payment gateways are AuthorizeNet, Google Checkout, USAePay, Verisign and Paypal. What is google checkout? Using Google checkout buying from stores across the web becomes simple and also facilitates you to keep track of all the orders. The Google Checkout’s fraud protection policy protects you against all the unauthorized purchases made via Google Checkout. Another advantage is that the Google Checkout does not share the history of the purchasers with other sellers. With Google checkout your email is well protected and is kept confidential. Tracking down...

File Upload by PHP - Ajax

AJAX FILE UPLOAD - Uploading local files with AJAX/Javascript to a server Many people say uploading files with AJAX is impossible! Well, they're wrong :-) Granted this solution only works with FireFox/Mozilla. And the user has to change a setting in "about:config" and accept the advanced access privileges. Anyway, such an AJAX file upload is only suitable for restricted area stuff, such as Content Management Systems, Group-Ware etc., so users can be briefed before actually using it. FireFox/Mozilla settings: Open about:config and check that signed.applets.codebase_principal_support is set to "true" Otherwise Firefox will display something like this Error: uncaught exception: A script from "http://www.captain.at" was denied UniversalXPConnect privileges. Also make sure you check the checkbox "Remember this decision", when FireFox will display this message A script from "http://www.captain.at" is requesting enhanced abilities that ...

Disable session IDs passed via URL

URL based session management does not only have additional security risks compared to cookie based session management, but it can cause also real problems when search engines index your pages. Your visitors may send an URL that contains an active session ID to their friends or they may save the URL that contains a session ID to their bookmarks and access your site with the same session ID always. The same way your visitors can store URL's with sessions ID's, search engines may index them as well, this means new users will access your site with an older session ID. But not only that, most search engines want to provide relevant results for their users, so different pages (URL's) with the same content can be penalized or even banned. We must all admit, SESSID or PHPSESSID added to the end of an URL doesn't look very nice and it's even not easy to remember. For this reason and all the above, you should disable URL based session management on your sites, and keep se...

Find MAC address of user by PHP

That's a small function that basically parses the arp table and returns the mac address of the client. Be sure to understand the basics of arp, since this script will work only on a linear network, without gateways; i.e.: to be sure that i'm get ting the exact mac address , the client should be connected DIRECTLY to the php server; there can be as many switches and hubs you want, but no natting gateways, no routing should be made thanks to Marcus [riptide@digitaltorque.com] for some hacks on this code function return mac address () { // This code is under the GNU Public Licence // Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com // Tested only on linux, please report bugs // WARNING: the commands 'which' and 'arp' should be executable // by the apache user; on most linux boxes the default configuration // should work fine // get the arp executable path $location = `which arp`; $location = rtrim($location); // Execute the arp comm...

PHP Coding Standard

The PHP Coding Standard is with permission based on Todd Hoff's C++ Coding Standard. Rewritten for PHP by Fredrik Kristiansen / DB Medialab, Oslo 2000-2003. Using this Standard . If you want to make a local copy of this standard and use it as your own you are perfectly free to do so. Before you start please verify that you have the most recent document . You can also download a this standard as a word document (maintained by Chris Hubbard ). Introduction Standardization is Important It helps if the standard annoys everyone in some way so everyone feels they are on the same playing field. The proposal here has evolved over many projects, many companies, and literally a total of many weeks spent arguing. It is no particular person's style and is certainly open to local amendments. Good Points When a project tries to adhere to common standards a few good things happen: programmers can go into any code and figure ou...