OldAppsOldApps.com

Go Back   OldApps.com Community Forum > OldApps.com > Programs - Articles/ Tips/ Tweaks

Programs - Articles/ Tips/ Tweaks Need to downgrade to an earlier version?
Need particular information about a software?
Good articles and tips for older versions.

Comment
 
LinkBack Article Tools Search this Article
Small PHP Codes | Snippets
Published by _Vishal_
3 Weeks Ago
Default Small PHP Codes | Snippets

function to get real ip.

PHP Code:
function getRealIpAddr()
{
    if (!empty(
$_SERVER['HTTP_CLIENT_IP']))
    {
        
$ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR']))
    
//to check ip is pass from proxy
    
{
        
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
        
$ip=$_SERVER['REMOTE_ADDR'];
    }
    return 
$ip;

Article Tools
  #1 (permalink)  
By _Vishal_ on 3 Weeks Ago
Default Re: Small PHP Codes | Snippets

image watermark with php


PHP Code:
<?php  
 
$main_img         
"image.jpg"// main big photo / picture
$watermark_img    "watermark.gif"// use GIF or PNG, JPEG has no tranparency support
$padding         3// distance to border in pixels for watermark image
$opacity        100;    // image opacity for transparent watermark
 
$watermark     imagecreatefromgif($watermark_img); // create watermark
$image         imagecreatefromjpeg($main_img); // create main graphic
 
if(!$image || !$watermark) die("Error: main image or watermark could not be loaded!");
 
 
$watermark_size     getimagesize($watermark_img);
$watermark_width     $watermark_size[0];  
$watermark_height     $watermark_size[1];  
 
$image_size     getimagesize($main_img);  
$dest_x         $image_size[0] - $watermark_width $padding;  
$dest_y         $image_size[1] - $watermark_height $padding;
 
 
// copy watermark on main image
imagecopymerge($image$watermark$dest_x$dest_y00$watermark_width$watermark_height$opacity);
 
 
// print image to screen
header("content-type: image/jpeg");   
imagejpeg($image);  
imagedestroy($image);  
imagedestroy($watermark);
?>
Reply With Quote
  #2 (permalink)  
By _Vishal_ on 3 Weeks Ago
Default Re: Small PHP Codes | Snippets

Unzip file using PHP

PHP Code:
<?php
 
// create object
$zip = new ZipArchive() ;
 
// open archive
if ($zip->open(&#8217;archive.zip’) !== TRUE) {
die (&#8217;Could not open archive’);
}
 
// extract contents to destination directory
$zip->extractTo(&#8217;/ tmp/extracted/ ‘);
 
// close archive
// print success message
$zip->close();
echo &
#8216;Archive extracted to directory’;
 
?>
Reply With Quote
Comment

Article Tools Search this Article
Search this Article:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Article Article Starter Category Comments Last Post
Limewire Version History admin Changelog (Version History) 4 05-03-2009 08:53 AM


All times are GMT -7. The time now is 02:57 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© OldApps.com