PHP Classes

File: compare_hash.php

Recommend this page to a friend!
  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: 7 years ago
Size: 905 bytes


Class file image Download
require_once 'class.hashcheck.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

if (!empty(
$output_file)) {
file_put_contents($output_file, $msgbuffer);