SmexyyWeby

Scripting for Fun and Passion

Tag Archives: PHP

Setting Up cURL proxy in XAMPP


cURL is a really nice tool to transfer data to and from a web server. You can use it to access URL and get the contents of web page via a php script.

XAMPP comes with cURL installed but you need to enable it in the php.ini file.

For this go to your XAMPP folder. (I have it installed in C:\xampp\)

  • Go to php folder
  • Open php.ini
  • Search for this line ;extension=php_curl.dll
  • Remove the ; in the beginning (; is used to comment lines)
  • Save the file. (Make sure you do not have apache running at this moment otherwise you can’t save the file. Or best is to open it as an administrator for editing)
  • Restart apache from XAMPP Control Panel.
  • Reopen a cURL script in the browser.

Now sometimes we need to use cURL with a proxy so here is a sample code:

<?php

class cURL{
var $crl;

var $proxy_url;

var $proxy_username_pass;
function cURL($proxy_url="", $proxy_username_pass=""){

$this->proxy_url=$proxy_url;

$this->proxy_username_pass=$proxy_username_pass;

$this->crl = curl_init();

curl_setopt($this->crl, CURLOPT_PROXY, $this->proxy_url);

curl_setopt($this->crl, CURLOPT_PROXYUSERPWD, $this->proxy_username_pass);

}
function get_url_contents($url){

$crl=$this->crl;

$timeout = 5;

curl_setopt ($crl, CURLOPT_URL,$url);

curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);

$ret = curl_exec($crl);

curl_close($crl);

return $ret;

}

}
$proxy_url="http://proxy.com";

$proxy_username_pass="hello:hello";

$cObj=new cURL($proxy_url, $proxy_username_pass);

$webContent= $cObj->get_url_contents("https://smexyyweby.wordpress.com");

echo $webContent;
?>

This will open the page https://smexyyweby.wordpress.com in your browser.Also you have the whole source code of the webpage saved in $webContent so that you can use it accordingly.

Please post any queries or improvements.

Technex ’06 , An Official Report


The news item from Hindustan Times dated Feb. 17 states about the prizes won by BHS High School, Allahabad, at Technex, the annual technical festival of IT-BHU.

(There was another story about MNNIT, Allahabad students winning ‘Best team Prize’ at Technex in Hindustan Times, but the link is lost.)

News Article
BHS students excel at BHU’s ‘Technex’
HT Live CorrespondentAllahabad,
February 17 Read more of this post

An Introduction to Web Development : Installation, PHP, MySQL and your 1st Script.


Well I was thinking about this for a long time … Its been 4 years in my life since I was first introduced to this beautiful world of internet and its been 10 years now that I have felt and am still fascinated by how the world of computers work.

The world of computing has made rapid advancements in the last one decade or so and most of them have been in the field of the ever evolving INTERNET .The internet has evolved like a fast growing Macrocystis pyrifera . Well I used the name because this is the fastest linearly growing organism on this planet.(Search wiki for that .. :P) .But Internet has not grown linearly it has evolved in different domains completely indepent of other stuff but all liking towards the same cloud of TCP/IP and other Protocols.

Web has been a revelation is human beings life. Through it you can find any information on this planet by just a click of your mouse and a KeyPunch on your keyboard.The information available on the internet is huge and people are still adding to it every second (like me … writing this blog entry … :P) in the forms of wikis , tweets , applications , and god knows what not. People are just a click away… life is governed by protocols like HTTP, TCP , FTP …

So you guys might be thinking now what goes behind all this … how are we able to provide all the information over the web how are we able to connect ourselves to the internet.The answer lies in the Web Server . A small program that even you, me and anyone can run on his personal computers and open to ourselves the portal towards sharing our information to the people. Read more of this post

%d bloggers like this: