Go Back   Gaming Gutter > Non-Gaming > Programming > Source Code


Source Code - Have a source code/project files you want to post? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post The best browser
11-13-2008 06:35 PM
Last post by azn fingers
Today 08:54 PM
59 Replies, 353 Views
Go to first new post Selling Tons of Legit...
07-17-2008 06:47 PM
by Crim
Last post by ebilbish
Today 08:51 PM
432 Replies, 4,744 Views
Go to first new post What's your weather?
11-08-2008 04:43 PM
by reirei
Last post by azn fingers
Today 08:51 PM
58 Replies, 355 Views
Go to first new post Instruments, anyone?
10-23-2008 11:50 AM
Last post by azn fingers
Today 08:49 PM
131 Replies, 728 Views
Go to first new post Heather wants to kill a...
Today 06:49 PM
Last post by Unregenerate Passion
Today 08:48 PM
19 Replies, 72 Views
Reply
 
LinkBack Thread Tools Display Modes

 [PHP] HTTP Wrapper.
Old 12-20-2006, 08:33 AM   #1 (permalink)
Underground

Male gommle is offline
 
gommle's Avatar
 
Join Date: Sep 2006
Location: The o great land of Nooooooreeeway
Age: 20
Posts: 658
GPoints: 38
iTrader: 0 / 0%
gommle Is Recognizable
Rep Power: 7
[PHP] HTTP Wrapper.

Here ya go. Commented for easy use.

PHP Code:
<?
/*
   ___                          _      
  / _ \___  _ __ ___  _ __ ___ | | ___ 
 / /_\/ _ \| '_ ` _ \| '_ ` _ \| |/ _ \
/ /_\\ (_) | | | | | | | | | | | |  __/
\____/\___/|_| |_| |_|_| |_| |_|_|\___|

Original filename:     > curl.function.php
E-Mail:                > gommle@gmail.com
MSN:                > datafrik2003@hotmail.com
*/


//--------------------------------------------\\
#####          ~ cURL function ~           #####
#----------------------------------------------#
// Function to send requests using Curl
// Builtin cookie handling for *nix systems.
// For Wintendo you need to edit the path in 
// CURLOPT_COOKIEJAR and CURLOPT_COOKIEFILE

## Usage ##
# Return all recieved data to $html.
//    $html = curl(    'http://freakforum.nu/login.php',
//                    'user=lolol&pass=lolol',
//                    'http://freakforum.nu/',
//                    '12.34.56.78:8080' );
# Only the first param is needed to fetch a page. 'http://digg.com/'
# GET data should be included in the first param. 'http://lol.com/?page=rofl'
# The second is POST data, in the same format as GET. 'user=me&pass=you'
# Referer: The page you "came from". 'http://neopets.com/lab2.phtml'
# Proxy: If your server gets banned from some online game '123.123.123.123:1337'


function curl($url$data=''$referer=''$proxy='')
{
    
// Make config available
    
global $config;
    
    
// Initiate Curl
    
$ch curl_init();
    
    
// Set URL to fetch
    
curl_setopt($chCURLOPT_URL$url);
    
    
// Set User Agent to remote browser
    
curl_setopt($chCURLOPT_USERAGENT$_SERVER[HTTP_USER_AGENT]);
    
    
// Follow location headers
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
    
// Set referer
    
if($referer) { curl_setopt($chCURLOPT_REFERER$referer); }
    
    
// Don't return data immediately
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
    
// Get cookies from this file
    
curl_setopt($chCURLOPT_COOKIEJAR'/tmp/'.$_SERVER[HTTP_REMOTE_ADDR].'cookie.txt');
    
    
// Load cookies from this file
    
curl_setopt($chCURLOPT_COOKIEFILE'/tmp/'.$_SERVER[HTTP_REMOTE_ADDR].'cookie.txt');
    
    
// Use a proxy if set
    
if($proxy) {
        
// Enable proxies
        
curl_setopt($chCURLOPT_HTTPPROXYTUNNEL1);
        
        
// Set timeout for proxy, so php doesn't timeout.
        
curl_setopt($chCURLOPT_TIMEOUT5);
        
        
// Use this proxy
        
curl_setopt($chCURLOPT_PROXY$proxy);
    }
    
    
// Set POST options if data is specified
    
if($data) {
        
// Use method POST
        
curl_setopt($chCURLOPT_POST1);
        
        
// POST this data
        
curl_setopt($chCURLOPT_POSTFIELDS$data);
    }
    
$data curl_exec($ch);
    return(
$data);
}
###################################################
?>
__________________

  Reply With Quote

 Re: [PHP] HTTP Wrapper.
Old 12-20-2006, 08:35 AM   #2 (permalink)
Ryan
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
Rep Power:
Re: [PHP] HTTP Wrapper.

Good job +rep x]
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 08:58 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.17734599 seconds (100.00% PHP - 0% MySQL) with 19 queries