HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/freecams1.com/public_html/admin/scraper_cron.php
<?php
    ini_set('user_agent', 'Mozilla/7.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/6.0.0.0');
    require('db.php');

    @mkdir($content_path);
    chmod($content_path, 0777);
	

    $result = dbQuery("SELECT * FROM `scraper_import` ORDER BY `record_num` DESC", false);
	dbQuery("UPDATE `status` SET `scraper_running` = 1, scraper_done = 0, scraper_total = '".(int)count($result)."'");
    foreach ($result as $row) {
        if (count(dbQuery("SELECT * FROM `scraper_import` WHERE `url` = '$row[url]'", false)) > 0 && count(dbQuery("SELECT * FROM `scraper_import_log` WHERE `url` = '$row[url]'", false)) < 1) {
            $json = json_decode(shell_exec("/usr/local/bin/youtube-dl --dump-json " . escapeshellarg($row['url'])), true);
			if($json['tags']) { $json['keywords'] = implode(",",$json['tags']); } 
			
            $video = array(
                'title' => $json['title'] ? $json['title'] : 'Not Available',
                'description' => $json['title'],
                'keywords' => $json['keywords'],
                'url' => $json['url'],
                'filename' => uniqid('', true) . '.' . ($json['ext'] ? $json['ext'] : 'mp4'),
            );
			
			//overwrite with API data if available.
			if($row['data']) { 
				$data = json_decode($row['data'],true); 
				if(is_array($data)) { 
					$video['keywords'] = $data['tags']; 
					$video['title'] = $data['title']; 
					$video['source_thumb_url'] = $data['thumb'];
				}
			}
			

            if ($video['url'] != "" && stripos($video['url'], 'mp4') === false && stripos($json['_filename'], '.mp4') === false) {
                $video['filename'] = uniqid('', true) . '.flv';
            }

            $output = "$content_path/$video[filename]";
			
			$urlEscaped = mysqli_real_escape_string($dblink, $row['url']);
			$outputEscaped = mysqli_real_escape_string($dblink, $output);
			dbQuery("UPDATE status SET scraper_processing = '$urlEscaped', scraper_processing_output = '$outputEscaped'");
			
			
            //if ($video['url'] != "") {
             //   echo shell_exec("$wget_path \"$video[url]\" -U=\"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1)\" -O \"$output\"");
            //} else {
				echo "/usr/local/bin/youtube-dl " . escapeshellarg($row['url']) . " -o $output\n";
                echo shell_exec("/usr/local/bin/youtube-dl " . escapeshellarg($row['url']) . " -o $output");
         //   }
			
            chmod($output, 0777);

            if (file_exists($output) && filesize($output) > 0) {
                dbReconnect();
				$video['title'] = stripslashes($video['title']);
                $video = mysqli_real_escape_array($video);
                echo $sql = "INSERT INTO content(`title`, `filename`, `orig_filename`, `description`, `keywords`, `scheduled_date`, `date_added`, `submitter`, `approved`, `hotlinked`, `paysite`, `source_thumb_url`, `orig_csv_url`) VALUES('$video[title]', '$video[filename]', '$video[filename]', '$video[description]', '$video[keywords]', NOW(), NOW(), '$row[user]', 0, '$hotlinked', '$row[paysite]', '$video[source_thumb_url]', '$row[url]')";
                dbQuery($sql);
                $content_id = mysqli_insert_id($dblink);

                if ($video['keywords'] != "") {
                    $parray = explode(',', $video['keywords']);
                    foreach ($parray as $p) {
                        $p = trim($p);
                        $rresult = dbQuery("SELECT `record_num` FROM `niches` WHERE `name` LIKE '$p'", false);
                        if (count($rresult) > 0) {
                            $rrow = $rresult[0];
                            dbQuery("INSERT INTO `content_niches` (`niche`, `content`) VALUES ('$rrow[record_num]', '$content_id')");
                            unset($rrow, $rresult);
                        }
                    }
                }
				dbQuery("UPDATE status SET scraper_done = scraper_done+1");
                dbQuery("INSERT INTO `scraper_import_log` SET `url` = '$row[url]'");
                dbQuery("DELETE FROM `scraper_import` WHERE `record_num` = '$row[record_num]'");
            } else {
                unlink($filepath);
            }
        } else {
            dbQuery("DELETE FROM `scraper_import` WHERE `url` = '$row[url]'");
        }
    }

    dbReconnect();
    dbQuery("UPDATE `status` SET `scraper_running` = 0, scraper_pid = 0");
    echo 'Done';
?>