Water Therapy

What is Water Therapy?

Early morning, after you get up from bed, (without even brushing your teeth) drink 1.50 liters of water i.e. 5 to 6 glasses. You may wash your face thereafter. This is called water therapy.
Here it is very essential to note that nothing else, neither drinks nor solid food of any sort should be taken within 1 hour before and after drinking these 1.5 liters of water. It is also to be strictly observed that no alcoholic drinks shall be taken the previous night.

File Upload using jQuery, Ajax, WordPress

HTML Page:
The first step is to prepare your HTML. Put it wherever the code for your admin page is. You want to have a text input for the image URL, and a button that will launch the uploader dialog.
<tr valign="top">
<th scope="row">Upload Image</th>
<td><label for="upload_image">
<input id="upload_image" type="text" size="36" name="upload_image" value="" />
<input id="upload_image_button" type="button" value="Upload Image" />
<br />Enter an URL or upload an image for the banner.
</label></td>
</tr>

File Upload Using Ajax

Using Basic PHP and JQuery:

There are three main components to our task.
  • The multiple attribute on the file input element.
  • The FileReader object from the new File API.
  • The FormData object from XMLHttpRequest2.
We use the multiple attribute to allow the user to select multiple files for upload (multiple file upload will work normally even if FormData isn’t available). As you’ll see, FileReader allows us to show the user thumbnails of the files they’re uploading (we’ll be expecting images).

How to Set Up PayPal Integration with PHP & MySQL

There are 3 main parts to the PayPal IPN system.
  1. A webpage that initiates a request to PayPal to make a payment.
  2. A PHP page on your webserver that PayPal calls to notify you that payment has been made.
  3. A webpage that confirms the above payment and continues on to the next phase of your web application, such as a ‘Thank You’ page.

Step 1 – Setup PayPal Account

Sign up for a PayPal account if you don’t already have one. Select an appropriate account type, either Personal or Business.
Once you have a registered PayPal account your account must be setup correctly to use IPN.
Select ‘edit profile’ from your PayPal account and check the following settings.
  • Under ‘Selling Preferences’ &gt;&gt; ‘Instant Payment Notification Preferences’
    • Set the IPN value to ‘On’
    • Set the IPN URL to the PHP page containing the IPN code shown in steps 3 &amp; 4 of this tutorial. (http://www.example.com/payment.php)
  • Under ‘Selling Preferences’ &gt;&gt; ‘payment receiving preferences’
    • Block payments from users who pay with echeck. (This is because these will not be instant payments)
  • Under ‘account information’ &gt;&gt; ‘email’
    • Note down your primary email address. This email will be visible to users so make it a professional one. User’s may feel apprehensive about sending money to an e-mail address with the domain ‘hotmail.com’ or ‘Yahoo.com’ etc…

Email Availability Check(Code Igniter)

This script will show you how can we check live availability of username or email using Ajax in Codeigniter. Using this tutorial you can also understand how can we send a jQuery Ajax request to server living in CodeIgniter.

In your view where you have created form include jQuery library and put the below code there(We assumed that jquery is already included!). In header section:

$(document).ready(function() {
/// make loader hidden in start
$('#Loading').hide();
$('#email').blur(function(){
var a = $("#email").val();
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
// check if email is valid
if(filter.test(a)){
// show loader
$('#Loading').show();
$.post("<?php echo base_url()?>controller_name/check_email_availablity", {
email: $('#email').val()
}, function(response){
//#emailInfo is a span which will show you message
$('#Loading').hide();
setTimeout("finishAjax('Loading', '"+escape(response)+"')", 400);
});
return false;
}
});

PHP coding standards

Indenting and Line Length

Use an indent of 4 spaces, with no tabs. This helps to avoid problems with diffs, patches, SVN history and annotations.
It is recommended to keep lines at approximately 75-85 characters long for better code readability.

Control Structures

These include if, for, while, switch, etc. Here is an example if statement, since it is the most complicated of them:
<?php
if ((condition1) || (condition2)) {
     action1;
} elseif ((condition3) && (condition4)) {
     action2;
} else {
     defaultaction;
}
?>
Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.

Cross Scripting(XSS)

What Is Cross Site Scripting?
 Injecting Scripts Into Otherwise Benign and Trusted Browser Rendered Content Cross-site scripting attacks are attacks that target the end user instead of your actual site. Vulnerable web applications that don’t check or validate properly incoming data let arbitrary code to run on a client computer (such as Javascript). The end result can be anything from stealing cookie data or redirecting to a different site, to embedding a browser exploit on a page. Anything that can be done with Javascript (a lot!).
XSS attacks have the following characteristics:
 Exploit the trust a user has for a particular site. Users don't necessarily have a high level of trust for any web site, but the browser does. For example, when the browser sends cookies in a request, it is trusting the web site. Users may also have different browsing habits or even different levels of security defined in their browser depending on which site they are visiting. Generally involve web sites that display external data. Applications at a heightened risk include forums, web mail clients, and anything that displays syndicated content (such as RSS feeds). Inject content of the attacker's choosing. When external data is not properly filtered, you might display content of the attacker's choosing. This is just as dangerous as letting the attacker edit your source on the server. How can this happen? If you display content that comes from any external source without properly filtering it, you are vulnerable to XSS.