Login   Register  
PHP Classes
elePHPant
Icontem

File: compare_hash.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Charalampos Pournaris  >  Torrent Pieces Hash Verification  >  compare_hash.php  >  Download  
File: compare_hash.php
Role: Application script
Content type: text/plain
Description: Main script file
Class: Torrent Pieces Hash Verification
Compare downloaded data with torrent data
Author: By
Last change: include fix
Date: 2009-01-12 15:44
Size: 905 bytes
 

Contents

Class file image Download
<?php
require_once 'class.hashcheck.php';
require_once 
'utils.php';

// Check for correct argument count
if ($argc 3) {
    
printConsole "Usage: {$argv[0]} <torrent_file> <path> [output_file]"true );
}

$output_file '';
$msgbuffer '';

if (!
file_exists($argv[2])) {
    
printConsole("Torrent data path specified '{$argv[2]}' does not exist. Please choose another one"true);
}

if (!empty(
$argv[3])) {
    if (
file_exists($argv[3])) {
        
printConsole("Filename '{$argv[3]}' exists. Please remove it or use another filename"true);
    } else {
        
$output_file $argv[3];
    }
}

// Create the hash check object. $argv[1] = torrent file metadata path, $argv[2] = torrent data target path
$hash_check = new HashCheck($argv[1], $argv[2]);

// Check hashes and report results
$hash_check->doCheck();

if (!empty(
$output_file)) {
    
file_put_contents($output_file$msgbuffer);
}
?>