Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // dafont.com sucker
- $maxpages = 1;
- $url = "http://www.dafont.com/alpha.php?lettre=a&page=" . $maxpages . "&fpp=100";
- $array = file_get_contents( $url );
- getTextBetweenTags( 'a' , $array , 1 );
- $lettres = str_split('abcdefghijklmnopqrstuvwxyz#');
- $oldletter = 'a';
- $pagenum = 1;
- $counter = 1;
- echo "\n\n";
- foreach ( $lettres as $num => $letter ) {
- if ( $letter != $oldletter ) {
- // GET PAGES FOR EACH LETTER
- getTextBetweenTags( 'a' , "http://www.dafont.com/alpha.php?lettre=" . urlencode( $letter ) . "&page=1&fpp=100" , 1 );
- $pagenum = 1;
- }
- while ( $pagenum <= $maxpages ) {
- echo "Letter: " . $letter . ' page: ' . $pagenum . "\n";
- $url = "http://www.dafont.com/alpha.php?lettre=" . urlencode($letter) . "&page=" . $pagenum . "&fpp=100";
- $array = file_get_contents( $url );
- $output[] = getTextBetweenTags( 'a' , $array , 0 , $letter );
- $oldletter = $letter;
- $pagenum ++;
- }
- }
- function getTextBetweenTags( $tag, $html, $strict = 0 , $letter = "" ) {
- global $maxpages, $counter;
- $dom = new domDocument;
- @$dom->loadHTML($html);
- $content = $dom->getElementsByTagname( $tag );
- $out = array();
- foreach ($content as $item) {
- $valueID = $item->getAttribute('class');
- if ( substr( $item->getAttribute('href') , 0 , 10) == 'mtheme.php' && $strict == 0 ) {
- $masterTheme = $item->childNodes->item(0)->nodeValue;
- $subTheme = "";
- }
- if ( substr( $item->getAttribute('href') , 0 , 10) == 'theme.php?' && $strict == 0 ) {
- $subTheme = $item->childNodes->item(0)->nodeValue;
- }
- if ( $valueID == 'dl' && $strict == 0 ) {
- $out[] = array( "class"=>$item->getAttribute('class') , "href"=>$item->getAttribute('href'));
- $dir = realpath(null) . "/dafonts/fonts_" . $letter . "/";
- if ( $masterTheme == "" ) $masterTheme = "Misc";
- if ( $subTheme == "" ) $subTheme = "Misc";
- $structure = realpath(null) . "/dafonts/" . $masterTheme . "/" . $subTheme . "/";
- @mkdir( $structure , 0777 , true );
- @mkdir( $dir , 0777, true );
- $file = $item->getAttribute('href');
- list($junk , $filename ) = explode( "f=" , $file );
- get_file1( $file , $dir , $filename . '.zip' , $file );
- echo "\tCreating SymLink: " . $structure . $filename . ".zip for Source: " . $dir . $filename . '.zip' . "\n";
- @symlink( $dir . $filename . '.zip' , $structure . $filename . ".zip" );
- $counter = $counter + 1;
- $masterTheme = "";
- } else {
- if ( substr( $item->getAttribute('href') , 0 , 10) == 'alpha.php?' ) {
- $pageurl = $item->getAttribute('href');
- list( $crap , $page ) = explode( 'page=', $pageurl );
- list( $page , $crap ) = explode( '&', $page );
- if ( $strict == 1 && $page > $maxpages ) $maxpages = $page;
- }
- }
- }
- return $out;
- }
- function get_file1($file, $local_path, $newfilename , $referer) {
- global $counter;
- $err_msg = '';
- echo $counter . ":\tAttempting download for $file\n";
- $out = fopen($local_path.$newfilename,"wb");
- if ($out == FALSE){
- print "File not opened \n";
- exit;
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_FILE, $out);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_URL, $file);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Referer: ' . $referer ));
- curl_exec($ch);
- if ( curl_error( $ch ) ) echo " Error is : " . curl_error( $ch ) . "\n";
- curl_close($ch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement