PHP Classes
elePHPant
Icontem

File: examples/example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Andrei Orghici  >  WGetAgent  >  examples/example.php  >  Download  
File: examples/example.php
Role: Example script
Content type: text/plain
Description: Class example
Class: WGetAgent
Download files using the wget program
Author: By
Last change: Added $wget_sess->output_name() example call
Date: 7 years ago
Size: 1,274 bytes
 

Contents

Class file image Download
<?
   
// copy finish_download script in /tmp dir and make sure it has execution rights on it (chmod 775)
   
include( "wget.inc.php" );

   
$wget_sess = new wget_agent( "http://www.google.com", "/tmp" );

    if( (
$wget_sess->output_name( "/tmp/newresult.txt" )) === false )
    {
        echo
"ERROR Couldn't set output file";
    }

   
$cls = new someClass();
   
   
$wget_sess->wget_store_function( "someMethod", "cls" );
   
   
$wget_sess->wget_script( "/tmp/finish_download" );

   
$error = $wget_sess->get_error();
    if( !
$error["error_no"] )
    {
        echo
"Starting download...<br>\n";
       
$wget_sess->wget_run();
        echo
"<br>\n".
            
"After download completes check /tmp dir...<br>\n";

       
print_r( $wget_sess->get_error() );
    } else
        echo
$error["error_msg"];



function
bubu( $a1, $a2, $a3 )
{
    echo
"Session: [$a1]<br>\n".
        
"URL: [$a2]<br>\n".
        
"Destination: [$a3]<br>\n";
   
// insert download info into a table maybe...
}

class
someClass
{

 function
someMethod( $a1, $a2, $a3 )
 {
    echo
"Session: [$a1]<br>\n".
        
"URL: [$a2]<br>\n".
        
"Destination: [$a3]<br>\n";
   
// insert download info into a table maybe...
 
}

}
?>