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

Tuesday, July 2, 2013

LoginRadius : Social Login and Share


LoginRadius provides effective single social login api, social sharing plugins and free registration software. It allows visitors to easily connect with your site.

LoginRadius For Social Login :

  • yahoo
  • google
  • facebook
  • linkdin
  • twitter
  • myspace
  • etc...
LoginRadius PHP SDK is a development kit that lets you integrate Social Login such as Facebook, Google, Twitter and over 20 more on a PHP website.
 
It also provide social login as well as social sharing for all programming script and opensource like joomla,wordpress,magento,drupal etc.
 
for demo click here :  Demo
for Login In LoginRadius : Click here
Developer Api : View

Display Fancy Date Format for Wordpress Post

Hello Friends,

 Today we learn how how to convert seconds into a fancy format.that is done by a Simple Php Function to convert Seconds into human readable format like month,day,hour,minutes.This function used in anywhere like wordpress,joomla,magento or simple php script.
 first you have to provide a second in function.

Example code :

$seconds=137267; 
function seconds2human($ss) 

  $s = $ss%60;
  $m = floor(($ss%3600)/60);
  $h = floor(($ss%86400)/3600);
  $d = floor(($ss%2592000)/86400);
  //$M = floor($ss/2592000);
  return "$d days, $h hours, $m minutes, $s seconds";
}

echo seconds2human($seconds);

//output : 1 days, 14 hours, 7 minutes, 47 seconds



Wednesday, June 5, 2013

File Download using Codeigniter Framework

 Download File using Codeigniter Framework is very easy.for download any file or document by Codeigniter use Codeigniter " Download Helper ".


First you have to load this helper in you controller class.i will you how to do this.just see the below code or step.

Load Helper :
$this->load->helper('download');

User Function of Helper : force_download('filename', 'data')

Parameter :
filename = filepath or filename
data=put data into file or apply new filename

Example :
$data = 'Here is some text!';
$name = 'mytext.txt';

force_download($name, $data); 



 

Tuesday, June 4, 2013

File Upload by Codeigniter Framework

Codeigniter File Upload Class provide Many Settings.You can set various preferences, restricting the type and size of the files.
  • Allow Type
  • Max Height
  • Max Width
  • Max Size
  • Validation
  • etc...

Creating the Upload Form

Using a text editor, create a form called upload_form.php. In it, place this code and save it to your applications/views/ folder:

The Success Page

Using a text editor, create a form called upload_success.php. In it, place this code and save it to your applications/views/ folder:

The Controller

Using a text editor, create a controller called upload.php. In it, place this code and save it to your applications/controllers/ folder:

The Upload Folder

You'll need a destination folder for your uploaded images. Create a folder at the root of your CodeIgniter installation called uploads and set its file permissions to 777.

Redirect with Timer in PHP Script

Hello Friends,


Today we learn about how to redirect or refresh or reload page using php function.
Its very easy to do this just one php function and nothing else.I show you how to do this task.Here We use Php Header function for page redirect.



Example :
Syntax : header ('Refresh:time; URL=http://your website url');

Like below........
header('Refresh: 10; URL=http://yoursite.com/page.php');

Tuesday, May 28, 2013

Magento: Get User Details

We will see how we can get details of logged in customer in Magento.
You can use below code snippet in any model, controller or phtml file.

Example code :


  1. // Retrieve Session Object
  2. $session = Mage::getSingleton(‘customer/session’);
  3.  
  4. // Check if user is logged in or not.
  5. if($session->gt;isLoggedIn()) 
  6. {
  7.    $customer = $session->gt;getCustomer();
  8.    
  9.    // Get Customer ID
  10.    echo $customer->gt;getID();
  11.  
  12.    // Get Customer Name
  13.    echo $customer->gt;getName();
  14.    
  15. }

Magento - Get Payment Method name using Order ID

Hello friends,

we will see how how we can get Payment Method name using the Magento Order ID.

Get Payment Method name using Order ID

$order = new Mage_Sales_Model_Order();

 $order_id = ’00000001′;

$order->gt;loadByIncrementId($order_id);

$payment_method = $order->gt;getPayment()->gt;getMethodInstance()->gt;getTitle();

Monday, May 27, 2013

Codecanyon - PHP WebServer with WebSockets Upgrade Script

 Codecanyon

This item is a suite of PHP classes that define a HTTP web server with WebSockets upgrade possibility. It runs in PHP CLI, and you can do everything you want with it thanks to the low-end access of HTTP protocol.


PHP Web Server + WebSockets Upgrade :
  • OOP Based
  • Fully Customizable
  • HTML5 Websockets
  • Low-End Http access
  • Easy to Integrate with another PHP Process

Tuesday, April 23, 2013

Get started with CodeIgniter Framework

A Fully Baked PHP Framework. CodeIgniter is a proven, agile & open PHP web application framework with a small footprint.

How It Works

CodeIgniter uses the MVC or Model View Controller architectural pattern, if your not familiar with MVC it is a logical object orientated development approach. below we look at a simple example of how we use the MVC.

Controllers

A controller is simply a class file that is named in a way that can be associated with a URI. For example if i have a controller with the filename account.php the URI to reach that page would be something like http://your-domain.com/account/ so you no longer need to fiddle with the .htaccess file and mod_rewrite to enable SEO friendly URI’s. The controller is the top level file for each page that allows you to include database requests in the form of ‘Models’ and templates as ‘Views’. below is an example of a controller, This code would be saved in the file blog.php, it’s important to understand the naming convensions because the name of the file is always the name of the class with the first letter capitalised. Within the Blog class we have an index() function which is always loaded when the page is excecuted. For example if we had another function lets say ‘categories’ the code within that function would only be executed if we visited http://your-domain.com/blog/categories/ this is also the way you can pass url parameters into functions but we’ll leave that for another day. We’re loading our ‘View’ in at the bottom and passing the array $data into it. Within the view file which would be called blogview.php if we wanted to echo the heading we’d simply echo $heading the same with the title. With the to do list we would need to setup a for each loop to cycle through the results in that array.
class Blog extends Controller {
 
    function index()
    {
        $data['todo_list'] = array('Clean House','Run Errands');
        $data['title'] = 'My Real Title';
        $data['heading'] = 'My Real Heading';
 
        $this->load->view('blogview', $data);
    }
}

Models

As yet we’re not using a model, this is because our controller isn’t doing anything complex. If we wanted to connect to a database and get a set of results we would use a model which could look like the below. This is all the code we need to pull 10 results from the database which would be returned to the controller in an array. note that you would need to replace ‘tableName’ with your own database table name.

class Blogmodel extends Model {
 
    function Blogmodel()
    {
        // Call the Model constructor
        parent::Model();
    }
 
    function get_last_ten_entries()
    {
        $query = $this->db->get('tableName', 10);
        return $query->result();
    }
 
}
 
To include the model firstly you need to navigate to system/application/config/database.php and add your database connection details. then below you’ll see that i’ve modified the controller that we used earlier so it now connects to the database and gets our data. This will then be sent through to the ‘view’.

Views

Simply put a ‘View’ is our template, it’s where our data gets rendered and is made pretty, you can have as many views as you like and pass whatever data you like into them it’s probably a good idea to have a header, main content area and footer.

For Download Codeigniter : Click here

Monday, April 22, 2013

Get Facebook Profile Image By Php

Hi Friends,

Today We Learn About How Upload or Get Facebook Profile image to local server or anywhere you wish.
here we use facebook graph api and facebook sdk to do this task.so please first you have to download FACEBOOK SDK from here Click .After downloading sdk create one facebook application for doing this task login to your facebook account after login your facebook account it print your all details.in this detail also contain your profile image link. Here the question is how to get image link? but is easy by json and file function.

Just create link or url like " $img="https://graph.facebook.com/$user/picture?redirect=false; ".
$user variable contain your facebook id then all these data add to the file_get_contents($img) function then it decode by json like $jd=json_decode($images); and get image url from json like $url=$jd->data->url; and then apply image upload code.this code is used to upload image wia url.

Example Code :

//Get file name by json
     $img="https://graph.facebook.com/$user/picture?redirect=false";   
    $images=file_get_contents($img);
    $jd=json_decode($images);
    $url=$jd->data->url;

   
//create file name;
$name = basename($url);
list($txt, $ext) = explode(".", $name);
$name = $txt.time();
$name = $name.".".$ext;

 
//file upload
$upload = file_put_contents("uploads/$name",file_get_contents($url));

Thursday, April 18, 2013

Display Breadcrumbs on Website using PHP Script

Hi Friends,
You have a fully dynamic site it’s useful to show the user where they are by breaking down the URL structure so they can navigate backwards through the site.

Breadcrumbs on website using PHP Script

 Breadcrumbs is used to navigate your dynamic website.
its show where you are. 
just put this below code in your files and see your the magic.
 Example code:
$path_parts = pathinfo($_SERVER['REQUEST_URI']);
$filename=explode("?",$path_parts['basename']);
echo " ".$path_parts['dirname'].'/'.$filename[0];

Check Internet Connection is On or Off using Php

Hello Friends,
Today we learn About how to Check Internet Connection is On or Off using Php script is very interesting.Lets see the php magic.

Check Internet is On or Off Using Php

Here we can use fsockopen php function.
in this function contain below parameter.
1)hostname : provide the hostname like :www.google.com
2)port     : add port number like : 80
3)errno    : error number generate by itself.
4)errstr   : display error message when connection fail.
5)timeout  : The connection timeout, in seconds.
example :
if(!$sock= @fsockopen('www.google.com',80,$num,$error,5))
echo "Off line";
else
echo "ok";

Sunday, March 31, 2013

Image Upload from a URL Using Php

By PHP, you need to strip the path from a URL, leaving behind just the filename at the end of the URL. You can do this with a regular expression pattern of course, but I have a much simpler solution. See the example code below.

Get filename from a URL Using Php

 Example : 

 $url = "http://www.iconarchive.com//path/to/file/filename.php";

 $filename = basename($url);

 echo $filename; //filename.php

Thursday, March 14, 2013

Get Remote IP Address By Php Script

Hey Get the Visitor IP Address using Php Script.Just use below code for it.

The Code :

$ip = $_SERVER['REMOTE_ADDR'];
OR
$ip= $REMOTE_ADDR;
Here is sample code:
<?
$ip= $REMOTE_ADDR;
echo "<br> Your IP address : " . $ip;
echo "<br> Your hostname : " . GetHostByName($ip);
?>

Wednesday, March 6, 2013

Run and Install Multiple Xampp Server

Here we Run Multiple Xampp Instance in single computer.one as main and another is a portable xampp server installed in another drive or usb drive.we use two xampp and mysql at a time.

Run Multiple Xampp Server

  • Run Two Xampp at single computer
  • Run Two Mysql Server
  • Use Two Database 

Step For Portable Xampp Configuration(Usb Xampp)

1) G:\xampp\apache\conf\httpd.conf: change code :
ServerName localhost:80 to 
ServerName localhost:8080 
Listen 80 to 
Listen 8080

2) change mysql port 
G:\xampp\mysql\bin\my.ini port = 3306 to port = 3333 
G:\xampp\php\php.ini mysql.default_port = 3306 to mysql.default_port = 3333

3) G:\xampp\apache\conf\httpd.conf: change ssl config:
 LoadModule ssl_module modules/mod_ssl.so to
 #LoadModule ssl_module modules/mod_ssl.so 
LoadModule rewrite_module modules/mod_rewrite.so
 to #LoadModule rewrite_module modules/mod_rewrite.so

4)connect database : localhost to localhost:3333 (mysql port)

 Xample to connect database :

Main Xampp

$my=mysql_connect("localhost","root","rootadmin"); mysql_select_db("test",$my); if($my) { echo "sucessfully connect-main(test)"; }

Portable Xampp

$m=mysql_connect("localhost:3333","root","rootadmin"); mysql_select_db("webauth",$m); if($m) { echo "sucessfully connect portable"; }

Tuesday, March 5, 2013

Codecanyon PHP Search Engine Script

Codecanyon PHP Search Engine Script and Code.Google like search engine or Global search engine by php script.Its very nice and amazing script.this search contain text,video,news,Web, Images Search. Search for .DOC, .XLS, .PDF and many more.

Codecanyon PHP Search Engine Script

 

Wednesday, February 27, 2013

Facebook Graph Api Example Script by Php

All the Facebook Graph Api Example Code using php.This bundle of script contain below facebook script .
  • Facebook  Activity Feed
  • Facebook Add Friends
  • Facebook Comments
  • Facebook Like Button
  • Facebook Like Box
  • Facepile
  • Facebook Recommendation
  • Facebook Status update
  • Live Stream
Download Facebook Script
Facebook Activity Feed
Facebook Add Friends
Facebook Comments
Facebook Like Button
Facebook Like Box
Facepile
Facebook Recommendation
Facebook Status update
Live Stream

Facebook Like Button Using Php Script

Facebook Like button lets users share pages from your site back to their Facebook profile with one click.
Its easy and very simple.But First You have Create Facebook Application because without any application ID this Task is not done.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
display_status_update() and apply its parameter.

function get_like_box($criteria=array()) {
        $url = $criteria['url'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $showfaces = $criteria['showfaces'];
        $stream = $criteria['stream'];
       
        if($url=='') $url = '';
        if($width=='') $width = '292';
        if($height=='') $height = '427';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($show_faces=='') $show_faces = 'true';
        if($stream=='') $stream = 'true';
       
        $content = '<iframe src="http://www.facebook.com/plugins/likebox.php?href='.$url.'&amp;width='.$width.'&amp;colorscheme='.$colorscheme.'&amp;show_faces='.$show_faces.'&amp;stream='.$stream.'&amp;header='.$header.'&amp;height='.$height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }


2) Create Facebook like file :(fb_like.php )

<?php
    include_once('Facebook_plugins_class.php');

    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_button(array('url'=>'https://www.facebook.com/profile.php?id=100001462485647'));
    echo '<div style="padding-bottom:8px;">Available on tutjunction: <a href="https://www.facebook.com/profile.php?id=100001462485647" target="_blank">Facebook WPress Viral tool for WordPress</a></div>';
    echo ''.$display.'<br><br>';
    ?>
</div>
<h3>Facebook Like box</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_box(array('url'=>'https://www.facebook.com/pages/Hellomeed/195450280529871'));
    echo $display;
    ?> 


 

Facebook Activity Feed Using Php

Facebook Activity Feed plugin shows users what their friends are doing on your site through likes and comments.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
get_activity_feed() and apply its parameter.

class Facebook_plugins_class
{
    var $app_id = '115461585200271';
    var $lang = 'en_US'; //en_US, fr_FR, es_LA, ko_KR, ja_JP, de_DE
    var $fb_sdk = '1';
   
    function Facebook_plugins_class($criteria=array()) {
        static $witness;
        if($criteria['app_id']!='') $this->app_id = $criteria['app_id'];
        if($criteria['lang']!='') $this->lang = $criteria['lang'];
        if($criteria['fb_sdk']!='') $this->fb_sdk = $criteria['fb_sdk'];
       
        if($witness=='') {
            if($this->fb_sdk=='1') echo '<div id="fb-root"></div><script src="http://connect.facebook.net/'.$this->lang.'/all.js#appId='.$this->app_id.'&amp;xfbml=1"></script>';
            $witness=1;
        }
    }

function get_activity_feed($criteria=array()) {
        $domain = $criteria['domain'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $recommendations = $criteria['recommendations'];
        $border_color = $criteria['border_color'];
        $font = $criteria['font'];
       
        if($domain=='') $domain = '';
        if($width=='') $width = '300';
        if($height=='') $height = '300';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($recommendations=='') $recommendations = 'false';
        if($border_color=='') $border_color = '';
        if($font=='') $font = ''; //'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
       
        $content = '<iframe src="http://www.facebook.com/plugins/activity.php?site='.$domain.'&amp;width='.$width.'&amp;height='.$height.'&amp;header='.$header.'&amp;colorscheme='.$colorscheme.'&amp;font='.$font.'&amp;border_color='.$border_color.'&amp;recommendations='.$recommendations.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }



2) call this function activity file ( activity.php )

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PhpWeb Blog</title>
</head>
<body>
<h3>Facebook Activity Feed</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_activity_feed(array('domain'=>'themeforest.net', 'width'=>'460'));
    echo $display;
    ?>
</div>
</body>
</html>


 

Facebook Status Update Using Php Script

Facebook Status Update using Facebook Graph Api and Php Script.Its easy and very simple.But First You have Create Facebook Application because without any application ID this Task is not done.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
display_status_update() and apply its parameter.

function display_status_update($criteria=array()) {
        $app_id = $criteria['app_id'];
        $title = $criteria['title'];
        $message = $criteria['message'];
        $name = $criteria['name'];
        $link = $criteria['link'];
        $picture = $criteria['picture'];
        $caption = $criteria['caption'];
        $description = $criteria['description'];
       
        if($app_id=='') $app_id = $this->app_id;
        if($title=='') $title = '';
        if($message=='') $message = '';
        if($name=='') $name = '';
        if($link=='') $link = '';
        if($picture=='') $picture = '';
        if($caption=='') $caption = '';
        if($description=='') $description = '';
        $random = rand(9999,9999999).rand(9999,9999999).rand(9999,9999999);     
        $js ='
        <script>
        function fc_post_fb_update_'.$random.'() {
            FB.ui({
                method: \'feed\',
                message: \''.$message.'\',
                name: \''.$name.'\',
                 link: \''.$link.'\',
                 picture: \''.$picture.'\',
                 caption: \''.$caption.'\',
                 description: \''.$description.'\',
            });
        }
        </script>';
        $content = '<a href="javascript:" onclick="fc_post_fb_update_'.$random.'()">'.$title.'</a>';
        return $content.$js;
    }


1) Create Facebook Status Update file :(fb_update.php ) 
in this file include the above class and call this function.

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php Web tutorials</title>
</head>
<body>
<h3>Facebook status update dialog</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status'));
    echo '1. Standard:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com'));
    echo '2. Update status + share an attached link:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com', 'description'=>'Have a look on the services offered by this company!', 'picture'=>'http://tutjunction.com/wp-content/upload/'));
    echo '3. Update status + share an attached link + description + custom picture attached:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
    echo '<b>Tip:</b><br>Our Facebook status function doesn\'t require your users to authorize your application before they can post to their wall. They can do it right away! Just try it yourself with one of the 3 examples above.';  ?>
</div>
</body>
</html>