Jump to content
xisto Community
Sign in to follow this  
ipunto21

Php Tutorials Plz

Recommended Posts

Can any1 tell me where i can download a freee php tutorial... like a pdf or html... is good in some cases have a good php tutorial for dinamic pages Scripting... :P

Share this post


Link to post
Share on other sites

The best way to learn php is by a book.So you can download a good php book at your local bookstore :P But seriously if you search for ?php tutorial? you will eventely find a good one you can download print or what ever you want whit it.

Share this post


Link to post
Share on other sites

The best way to learn php is by a book.
So you can download a good php book at your local bookstore  :)

But seriously if you search for php tutorial you will eventely find a good one you can download print or what ever you want whit it.

Lol, i am having great difficulty finding a good one :) lol, if anyone finds one then please post it here!

Share this post


Link to post
Share on other sites

Google.com is the best way to find your scripts I reckon.Google.com - the heart of internet search engines -

Share this post


Link to post
Share on other sites

<span style='font-family:Impact'><span style='color:red'>i think u shuld look at php.net and on the left side there's a link named tuturial</span></span>


Thanks for the link. pretty useful. I also found this one pretty useful as it has how tos for common tasks like user authentication, user tracking, PHP/MySQL integration, etc:

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

I am also looking for a good one, but im wanting to learn sockets for a collage project

I just did this HTTP Wrapper. It uses cURL to make HTTP requests, which can be very handy to emulate human browsing behavior.

 

Also, some of you might find this very handy and it could help you understand something about PHP from the examples I'm going to to give.

 

Heres the Wrapper, you need to save this as HTTPWrapper.class.php in Notepad or any PHP editor you have.

 

<?php//Created by GaiaZone//Also known as Riddledefine("USERAGENT", "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2");class HTTPWrapper {  var $responseHeaders;  var $responseBody;  var $lastURL;  var $lastErrorNum;  var $lastError;  var $ch;  var $ts;  var $totalTime; //Username and Password are for Sessions Login, if you're not going to Login anywhere, put anything there.   function HTTPWrapper($username, $password)  {    $this->ch = curl_init();    $headers   = array();    $headers[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";    $headers[] = "Accept-Language: en-us,en;q=0.5";    $headers[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";    $headers[] = "Keep-Alive: 300";    $headers[] = "Connection: keep-alive";    curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);    curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);    curl_setopt($this->ch, CURLOPT_HEADER,         1);    curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);    curl_setopt($this->ch, CURLOPT_COOKIEFILE,     COOKIE_PATH . $username . '.cookie');    curl_setopt($this->ch, CURLOPT_COOKIEJAR,      COOKIE_PATH . $username . '.cookie');    curl_setopt($this->ch, CURLOPT_ENCODING,       "gzip, deflate");    curl_setopt($this->ch, CURLOPT_USERAGENT,      USERAGENT);    curl_setopt($this->ch, CURLOPT_HTTPHEADER,     $headers);    $this->username = trim($username);    $this->password = $password;    $this->ts        = 0;    $this->totalTime = 0;  }  /**   * The HTTP Proxy to use for the request   * Use the format ip:port or hostname:port   *   * Example:   * <code>   * <?php   *   * // proxy using hostname   * $Wrapper->SetProxy('proxyhost.tld:3128');   *   * // proxy using I.P. address   * $Wrapper->SetProxy('111.111.111.111:8080');   *   * ?>   * </code>   *   * @param string $proxy  The proxy server to use   */  function SetProxy($proxy)  {    curl_setopt($this->ch, CURLOPT_PROXY, $proxy);  }  /**   * Remove the proxy set by a previous call to SetProxy   *   */  function ClearProxy()  {    curl_setopt($this->ch, CURLOPT_PROXY, '');  }  /**   * Set the User Agent to send in all requests   *   * @param string $userAgent  The new user agent to use   */  function SetUserAgent($userAgent)  {    curl_setopt($this->ch, CURLOPT_USERAGENT, $userAgent);  }  function HttpGet($url, $referer = '')  {    $this->lastURL = $url;    curl_setopt($this->ch, CURLOPT_HTTPGET, 1);    curl_setopt($this->ch, CURLOPT_URL, $url);    curl_setopt($this->ch, CURLOPT_REFERER, $referer);    return $this->_request();  }  function HttpPost($url, $postdata, $referer = '')  {    $this->lastURL = $url;    curl_setopt($this->ch, CURLOPT_POST, 1);    curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postdata);    curl_setopt($this->ch, CURLOPT_URL, $url);    curl_setopt($this->ch, CURLOPT_REFERER, $referer);    return $this->_request();  }  function StartTimer()  {    $this->ts = $this->microtime_float();  }  /**   * Stop the timer and get the time elapsed   *   * @return float   */  function StopTimer()  {    $st = $this->microtime_float();    if ($this->ts == 0) return $this->totalTime = 0;    return $this->totalTime = round($this->ts - $st, 2);  }  /**   * Get the time taken from the timer   *   * @return float   */  function GetTotalTime()  {    return $this->totalTime;  }  /**   * Perform the request   *   * @access private   * @return bool   */  function _request()  {    $this->responseBody    = '';    $this->responseHeaders = '';    $data = curl_exec( $this->ch );    if ($data === false) {      $this->lastErrorNum = curl_errno($this->ch);      $this->lastError    = curl_error($this->ch);      return false;    } else {      $this->lastErrorNum = 0;      $this->lastError    = '';      list($this->responseHeaders, $this->responseBody) = explode("\r\n\r\n", $data, 2);      return true;    }  }  /**   * Get a timestamp w/ microseconds   * Courtesy of php.net   *   * @access private   * @return float   */  function microtime_float()  {    list($usec, $sec) = explode(" ", microtime());    return ((float)$usec + (float)$sec);  } } //Class end ?>
You will find this very handy because you won't need to rewrite all that mumbojumbo every time you want to use sockets.

 

How to use:

 

In your PHP page (the one you're going to write down the script) you will have to include the HTTPWrapper.class.php file.

<?phpinclude 'HTTPWrapper.class.php';?>
After you include the class file, you can use all the functions in it without having to write them again.

 

I'd like to explain how to use it now by making a sample script that will visit Google and search for the word "Cheese".

 

First of all we start our PHP script in the Body of the webpage and we tell PHP that we are naming the variable $Wrapper as a new HTTPWrapper like this:

<?php$user='Google'; //If you don't need a username like in this example, just put anything.$pass='anything'; //same with the pass.$Wrapper = new HTTPWrapper($user, $pass);?>
Now we have our HTTPWrapper ready to use.

 

The first thing we want to do is "Get" to the Google Page.

<?php$user='Google'; //If you don't need a username like in this example, just put anything.$pass='anything'; //same with the pass.$Wrapper = new HTTPWrapper($user, $pass); $Wrapper->HttpGet('google.com;;  echo $Wrapper->responseBody;?>
The code above will visit Google and print the html code into your page, allowing you to view the result of the Wrapper. This is very handy for debugging.

Now you know how to use one of the vars.

 

Once we are there, we want to search the word "Cheese". To make this easier, you should Packet Sniff your communication with the site, that way you know if you're POSTING or GETTING to the Website and the order of the Post data or the normal url.

 

After verifying the search url, I came up with this:

<?php$user='Google'; //If you don't need a username like in this example, just put anything.$pass='anything'; //same with the pass.$SearchWord='Cheese'; //What you're searching for.$Wrapper = new HTTPWrapper($user, $pass); $Wrapper->HttpGet('google.com;; $Wrapper->HttpGet('www.google.com/q=&%2339; . $SearchWord);  echo $Wrapper->responseBody;?>
The example above should now go to Google and search for "Cheese", then print the whole page's HTML into your .PHP page, letting you view your result.

 

You can impovise plenty with this Wrapper, you just need to spend some time searching for other commands you can combine with this such as preg_match_all and plenty others.

 

You can print data tables to your web page with information organized in different ways. PHP is truly a great language to learn.

 

I hope this Wrapper is used for good. =]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.