Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Fix CSS hover on iPhone/iPad/iPod

Copy this code and paste it any where in your file.
Make sure jQuery included in your page.


Odesk PHP Frontend Developer Test v2 answer

In this test there are 4 questions they are following.


Question no 1:- Fantastic three sequence

Solution :-
<?php
function fantastic3($n) {
$series = array(0,1,1,1);
for($i=3 ; $i<=$n ; $i++){
$a = (isset($series[ (int)$i-3 ]))?$series[ (int)$i-3 ]:0;
$b = (isset($series[ (int)$i-2 ]))?$series[ (int)$i-2 ]:0;
$c = (isset($series[ (int)$i-1 ]))?$series[ (int)$i-1 ]:0;
$d = ($a+$b+$c)-1;
if($d<0){
$d = 0;
}
$series[$i] = $d;
}
echo $series[ (int)$n-1 ];
}
// Do NOT call the fantastic3 function in the code
// you write. The system will call it automatically.
?>

How to write secure code in Php -1

PHP is a very easy language to learn, and many people without any sort of background in programming learn it as a way to add interactivity to their web sites. Unfortunately, that often means PHP programmers, especially those newer to web development, are unaware of the potential security risks their web applications can contain. Here are a few of the more common security problems and how to avoid them.

Rule Number One: Never, Ever, Trust Your Users
It can never be said enough times, you should never, ever, ever trust your users to send you the data you expect. I have heard many people respond to that with something like "Oh, nobody malicious would be interested in my site". Leaving aside that that could not be more wrong, it is not always a malicious user who can exploit a security hole - problems can just as easily arise because of a user unintentionally doing something wrong.

How to write secure code in Php -2

Learn how to improve your security a little further with the second part of this PHP tutorial.
In Writing Secure PHP, I covered a few of the most common security holes in websites. It's time to move on, though, to a few more advanced techniques for securing a website. As techniques for 'breaking into' a site or crashing a site become more advanced, so must the methods used to stop those attacks.


File Systems
Most hosting environments are very similar, and rather predictable. Many web developers are also very predictable. It doesn't take a genius to guess that a site's includes (and most dynamic sites use an includes directory for common files) is an www.website.com/includes/. If the site owner has allowed directory listing on the server, anyone can navigate to that folder and browse files.

How to write secure code in Php -3

The third part of the Writing Secure PHP series, covering weak passwords, clients and more advanced topics.
In How to write secure code in Php-1, 2  and 3 I covered many of the basic mistakes PHP developers make, and how to avoid common security problems. It is time to get a little deeper into security though, and begin to tackle some more advanced issues.
Context
Before I start, it is worth mentioning at this point in this series that much of what is to come is highly dependant on context. If you are running a small personal site and are regularly backing it up, the chances are that there is no real benefit to you spending weeks on advanced security issues. If an attacker can gain nothing (and cause no harm) by compromising your site, and it would only take you ten minutes to restore it, should something go wrong, then it would be a waste to spend too long on security concerns. At the other end of the scale, if you are managing an ecommerce site that processes thousands of credit cards a day, then it is negligent not to spend a lot of time researching and improving your site's security.

How to wright secure code in Php-4


Cross-Site Scripting (XSS)
Cross-site scripting (often abbreviated to XSS) is a form of injection, where an attacker finds a way to have the target site display code they control. In its most basic form, this can be as simple as a site that allows HTML characters in usernames, where someone can specify a username like:
DaveChild<script type="text/javascript" src="http://www.example.com/my_script.js"></script>
Now, whenever someone sees my username on the target site, the script I've added to my username will run. I could potentially use this to grab the person's login information, log their keystrokes - any number of nefarious activities.

How to make a xml file in php

Here is the PHP code you can customize it according to your requirements.

<&#63php
$xml = new SimpleXMLElement('<root/>');

$track = $xml->addChild('track');

$track->addChild('fieldName1','fieldValue');

$track->addChild('fieldName2','fieldValue');

$track->addChild('fieldName3','fieldValue');

$track->addChild('fieldName4','fieldValue');

Header('Content-type: text/xml');

print($xml->asXML());

&#63>
Enjoy Coding ..!!

How to make Paypal Recurring system for any site.


Hello every one today i am going to tell you how to make paypal recurring method for any site you can easily iterated this method to any website.

How to integrate Print Command in any web page

1. Coding Start from here

<html>
<body>
<div id="printTable">
Lorem Ipsum is simply dummy text of the printing and typesetting 
industry. Lorem Ipsum has been the industry's standard dummy text 
ever since the 1500s, when an unknown printer took a galley of .

</div>


Save data from .CSV file to database

1. Save data from .CSV file to database using php

public function savefile()
    {
        die('Remove die to action');
        error_reporting(E_ALL ^ E_NOTICE);   
        if(!defined('DS')) {
            define('DS',DIRECTORY_SEPARATOR);
        }
        mysql_connect('localhost', 'dbuser', 'db_password');
        mysql_select_db('db_name');

Paypal Integration in php

1. Make a new folder in your localhost and Save this file index.php 

<?php
$paypal_username = "arunendra123-facilitator_api1.smartwinzsolutions.com";
$paypal_password = "1394441";
$paypal_signature = "A05YM4frUDrScsYqP299BBa4trgEA3InSTImhusSPEE8pKNdBzC";
include("paypal_pro_signature.inc.php");

$firstName = urlencode("arunbuyer");
$lastName = urlencode("rai");
$creditCardType = urlencode("Visa");
$creditCardNumber = urlencode("4271901174400127");
$expDateMonth = urlencode("03");
$padDateMonth = str_pad($expDateMonth,2,'0',STR_PAD_LEFT);
$expDateYear = urlencode("2019");
$cvv2Number = urlencode("123");
$address1 = urlencode("test");
$address2 = urlencode("test");
$city = urlencode("test");
$state = urlencode("test");
$zip = urlencode("73301");
$amount = urlencode("25.75");
$currencyCode = urlencode("USD");
$paymentAction = urlencode("Sale");
$methodToCall = 'DoDirectPayment';

How To Integrate google translator In any site


1. Copy this Code in section


2. Copy this Code in section
   

Google Translate

Note :- Set dive style according to your choice thanks.

Php script for file download

1. PHP Script for image download you can make any file to to download Paste this script in your file or save it download.php
<?php
$imageurl = filter_input(INPUT_GET, 'imageurl', FILTER_SANITIZE_URL);
// Clean the image URL to get the path and make sure the user is just getting an image.
$url_parsed = parse_url($imageurl);
$file = $_SERVER['DOCUMENT_ROOT'] .'/base-directory'. $url_parsed['path'];
print_r($file);
// Get the extension of the file.
$extension = substr(strrchr($file ,'.'), 1);

// Limit the extensions in this array to those you're allowing the user to download.

$allowed_extensions = array('jpg', 'jpeg', 'png', 'gif');

// Make sure the file requested is in your list of allowed extensions to make sure the user isn't downloading something other than an image.

if (in_array(strtolower($extension), $allowed_extensions)) {

    if (file_exists($file)) {

        header ('Content-type: octet/stream');

        header ('Content-disposition: attachment; filename=' . basename($file) . ';');

        header('Content-Length: ' . filesize($file));

         ob_clean();
        readfile($file);
    }
}
?>
1. HTML Code Paste this code in your html file

    Download  
	
Enjoy......

PHP Interview Question Answer



1) What is PHP.?


PHP is a web language based on scripts that allows developers to dynamically create generated web pages.

2) What does the initials of PHP stand for.?


PHP means PHP: Hypertext Preprocessor.

3) Which programming language does PHP resemble to.?


PHP syntax resembles Perl and C

4) What does PEAR stands for.?


PEAR means “PHP Extension and Application Repository”. it extends PHP and provides a higher level of programming for web developers.

5) What is the actually used PHP version.?


Version 5 is the actually used version of PHP.

6) How do you execute a PHP script from the command line.?


Just use the PHP command line interface (CLI) and specify the file name of the script to be executed as follows:
?

1
php script.php
7) How to run the interactive PHP shell from the command line interface.?