Skip to content
This repository has been archived by the owner on Apr 9, 2021. It is now read-only.

Commit

Permalink
Renamed some variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Quirinus committed Feb 11, 2015
1 parent 19a2a9c commit fb4976b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
28 changes: 14 additions & 14 deletions dl.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,42 +198,42 @@ function zippy_fetch_dl($zippy_page_url, $folder_path, $file_index, $dl_response
}
}

function zippy_batch_dl($gh_zippy_links, $gh_folder_names, $gh_parent_folder = 'GH_DL', $start_folder = 0, $end_folder = 'end', $start_link = 0, $end_link = 'end', $dl_response_time=0, $dl_timeout=0, $sleep_between=2, $dl_fetch_delay=1, $overwrite=0)
function zippy_batch_dl($zippy_links, $folder_names, $parent_folder = 'DL', $start_folder = 0, $end_folder = 'end', $start_link = 0, $end_link = 'end', $dl_response_time=0, $dl_timeout=0, $sleep_between=2, $dl_fetch_delay=1, $overwrite=0)
{
$folder_paths = $gh_folder_names;
array_walk($folder_paths, function(&$value, $key, $gh_parent_folder) {$value = "$gh_parent_folder\\$key.$value";}, $gh_parent_folder);
$folder_paths = $folder_names;
array_walk($folder_paths, function(&$value, $key, $parent_folder) {$value = "$parent_folder\\$key.$value";}, $parent_folder);
create_folders($folder_paths);
$folder_end = $end_folder === 'end' ? count($gh_folder_names) - 1 : $end_folder;
$folder_end = $end_folder === 'end' ? count($folder_names) - 1 : $end_folder;
$datetime = new DateTime();
$datetime = $datetime->format('d-m-Y H:i:s (P \U\T\C)');
file_put_contents("$gh_parent_folder\\log.txt", "Session started: $datetime<br>\r\n", FILE_APPEND);
if (!(file_exists("$gh_parent_folder\\log.php")))
file_put_contents("$parent_folder\\log.txt", "Session started: $datetime<br>\r\n", FILE_APPEND);
if (!(file_exists("$parent_folder\\log.php")))
{
$log_php = "<!DOCTYPE html>\r\n<html>\r\n<head><meta charset='utf-8'><title>GH DL Log</title></head>\r\n<body>\r\n<?php echo file_get_contents(\"log.txt\") ?>\r\n</body>\r\n</html>";
file_put_contents("$gh_parent_folder\\log.php", $log_php);
$log_php = "<!DOCTYPE html>\r\n<html>\r\n<head><meta charset='utf-8'><title>DL Log</title></head>\r\n<body>\r\n<?php echo file_get_contents(\"log.txt\") ?>\r\n</body>\r\n</html>";
file_put_contents("$parent_folder\\log.php", $log_php);
}
for ($i = $start_folder; $i <= $folder_end; $i++)
{
$link_end = $end_link === 'end' ? count($gh_zippy_links[$gh_folder_names[$i]]) - 1 : $end_link;
$link_end = $end_link === 'end' ? count($zippy_links[$folder_names[$i]]) - 1 : $end_link;
for ($j = $start_link; $j <= $link_end; $j++)
{
file_put_contents("$gh_parent_folder\\log.txt", "zippy_fetch_dl({$gh_zippy_links[$gh_folder_names[$i]][$j]}, {$folder_paths[$i]}, $j, $dl_response_time, $dl_timeout, $dl_fetch_delay, ".(string)$overwrite.")<br>\r\n", FILE_APPEND);
$result = zippy_fetch_dl($gh_zippy_links[$gh_folder_names[$i]][$j], $folder_paths[$i], $j, $dl_response_time, $dl_timeout, $dl_fetch_delay, $overwrite);
file_put_contents("$gh_parent_folder\\log.txt", $result, FILE_APPEND);
file_put_contents("$parent_folder\\log.txt", "zippy_fetch_dl({$zippy_links[$folder_names[$i]][$j]}, {$folder_paths[$i]}, $j, $dl_response_time, $dl_timeout, $dl_fetch_delay, ".(string)$overwrite.")<br>\r\n", FILE_APPEND);
$result = zippy_fetch_dl($zippy_links[$folder_names[$i]][$j], $folder_paths[$i], $j, $dl_response_time, $dl_timeout, $dl_fetch_delay, $overwrite);
file_put_contents("$parent_folder\\log.txt", $result, FILE_APPEND);
sleep($sleep_between);
}
}
}

$gh_parent_folder = 'GH_DL';
$parent_folder = 'GH_DL';

$start_folder = 0;
$end_folder = 'end';

$start_link = 0;
$end_link = 'end';

zippy_batch_dl($gh_zippy_links, $gh_folder_names, $gh_parent_folder, $start_folder, $end_folder, $start_link, $end_link);
zippy_batch_dl($zippy_links, $folder_names, $parent_folder, $start_folder, $end_folder, $start_link, $end_link);

//to-do maybe:
//add server to the file name
Expand Down
32 changes: 16 additions & 16 deletions file_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ function fix_bad_path_names($path)
return str_replace($bad, '', $path);
}

$gh_file = file_get_contents('GH_example.html'); //fetching a bunch of links and folders from a random site (only for testing purposes)
$file = file_get_contents('GH_example.html'); //fetching a bunch of links and folders from a random site (only for testing purposes)

preg_match_all('/<span class="mw\-headline">([^\n<]+)<\/span>/i', $gh_file, $gh_folder_names);
$gh_folder_names = array_map('fix_bad_path_names',$gh_folder_names[1]);
preg_match_all('/<span class="mw\-headline">([^\n<]+)<\/span>/i', $file, $folder_names);
$folder_names = array_map('fix_bad_path_names',$folder_names[1]);

$table_delimiter = '<table class="wikitable';
$gh_parts = explode($table_delimiter, $gh_file);
$parts = explode($table_delimiter, $file);
$skip_tables = 4;
$gh_parts = array_slice($gh_parts, $skip_tables);
array_shift($gh_folder_names);
$parts = array_slice($parts, $skip_tables);
array_shift($folder_names);

$pattern = '/href\="http:\/\/www[0-9]*\.zippyshare\.com\/v\/[0-9]*\/file.html"/i';
$gh_parts_count = count($gh_parts);
for ($i=0;$i<$gh_parts_count;$i++)
$parts_count = count($parts);
for ($i=0;$i<$parts_count;$i++)
{
$gh_parts_match_count[$i] = preg_match_all($pattern, $gh_parts[$i], $gh_zippy_links[$i]);
$gh_zippy_links[$i] = array_map('trim_stuff',$gh_zippy_links[$i][0]);
$parts_match_count[$i] = preg_match_all($pattern, $parts[$i], $zippy_links[$i]);
$zippy_links[$i] = array_map('trim_stuff',$zippy_links[$i][0]);
}
$gh_match_count_total = array_sum($gh_parts_match_count);
//$gh_zippy_links_by_folder_index = $gh_zippy_links;
$gh_zippy_links = array_combine($gh_folder_names,$gh_zippy_links);
$gh_match_count_total = array_sum($parts_match_count);
//$zippy_links_by_folder_index = $zippy_links;
$zippy_links = array_combine($folder_names,$zippy_links);

//shows link/folder results
echo "Total zippyshare link count: $gh_match_count_total";
print_r2($gh_folder_names);
print_r2(array_combine($gh_folder_names,$gh_parts_match_count));
print_r2($folder_names);
print_r2(array_combine($folder_names,$parts_match_count));
echo "<hr>GH Zippyshare links:";
print_r2($gh_zippy_links);
print_r2($zippy_links);

?>

0 comments on commit fb4976b

Please sign in to comment.