#!/usr/local/bin/php \n"; $outdata2 .= "\n"; $outdata2 .= " \n"; $outdata2 .= " \n"; $outdata2 .= " ".htmlentities($title)."\n"; $outdata2 .= " Zefie PHP Uploader\n"; $outdata2 .= " \n"; $outdata2 .= " ".$vcat."\n"; $outdata2 .= " \n"; if (isset($desc)) { $outdata2 .= " ".htmlentities($desc)."\n"; } if (isset($keywords)) { $outdata2 .= " ".htmlentities($keywords)."\n"; } $outdata2 .= " \n"; $outdata2 .= "\n"; $outdata2 .= "--f93dcbA3\n"; $outdata2 .= "Content-Type: $contype\n"; $outdata2 .= "Content-Transfer-Encoding: binary\n"; $outdata2 .= "\n"; $outdata = "POST ".$yturi." HTTP/1.1\n"; $outdata .= "Host: ".$ythost."\n"; $outdata .= "Authorization: GoogleLogin auth=\"".$token."\"\n"; $outdata .= "GData-Version: 2\n"; $outdata .= "X-GData-Key: key=".$apikey."\n"; $outdata .= "Slug: ".$filename."\n"; $outdata .= "Content-Type: multipart/related; boundary=\"f93dcbA3\"\n"; $outdata .= "Content-Length: ".($filesize+strlen($outdata2)+13)."\n"; $outdata .= "Connection: close\n"; $outdata .= "\n"; $outdata .= $outdata2; $socket = fsockopen($ythost,80,$errno,$errstr,50); if (!$socket) { die("Cannot connect".$errno.$errstr); } else { fwrite($socket,$outdata); $infile = fopen($file,"r"); $sent = 0; while (!feof($infile)) { $buffer = fread($infile,$bufsize); $written = fwrite($socket,$buffer); $sent = ($sent + $written); echo "Sent ".size_hum_read($sent)." of ".size_hum_read($filesize)."...\r"; } echo "\n"; fclose($infile); fwrite($socket,"\n--f93dcbA3--"); $readback = fread($socket,20480); if (preg_match("/400 Bad Request/",$readback) || preg_match("/401 Unauth/",$readback)) { $readsplit = split("\r\n\r\n",$readback); echo "Error Uploading Video: ".$readsplit[1]."\n"; } if (preg_match("/201 Created/",$readback)) { echo "Success!\n\n"; echo "This is a primitive uploader.\n"; echo "Please go to your YouTube Account and update the metadata.\n"; } fclose($socket); $end = time(); $seconds = ($end - $start); $mins = floor ($seconds / 60); $secs = $seconds % 60; if ($secs < 10) { $secs = "0".$secs; } printf ("Total time elapsed: %d:%s\n", $mins, $secs); } function get_mime_type($filename, $mimePath = '/home/mysticmidnight/etc') { $fileext = substr(strrchr($filename, '.'), 1); if (empty($fileext)) return (false); $regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i"; $lines = file("$mimePath/mime.types"); foreach($lines as $line) { if (substr($line, 0, 1) == '#') continue; // skip comments $line = rtrim($line) . " "; if (!preg_match($regex, $line, $matches)) continue; // no match to the extension return ($matches[1]); } return (false); // no match at all } function size_hum_read($size) { $i=0; $iec = array("b", "kb", "mb", "gb", "tb", "pb", "eb", "zb", "yb"); while (($size/1024)>1) { $size=$size/1024; $i++; } return substr($size,0,strpos($size,'.')+4).$iec[$i]; } function prompt_silent($prompt = "Enter Password:") { if (preg_match('/^win/i', PHP_OS)) { $vbscript = sys_get_temp_dir() . 'prompt_password.vbs'; file_put_contents( $vbscript, 'wscript.echo(InputBox("' . addslashes($prompt) . '", "", "password here"))'); $command = "cscript //nologo " . escapeshellarg($vbscript); $password = rtrim(shell_exec($command)); unlink($vbscript); return $password; } else { $command = "/usr/bin/env bash -c 'echo OK'"; if (rtrim(shell_exec($command)) !== 'OK') { trigger_error("Can't invoke bash"); return; } $command = "/usr/bin/env bash -c 'read -s -p \"" . addslashes($prompt) . "\" mypassword && echo \$mypassword'"; $password = rtrim(shell_exec($command)); echo "\n"; return $password; } }