Thanks for your work. But the PHP Code doesn't work for me. It always says : Warning: strpos() [function.strpos]: Offset not contained in string in /home/admin/domains/mydomain.com/public_html/test.php on line 73 (Apparently megaupload has modified something else)
I tested right after seeing your post & it still works. Syntax is this: $ php -f <php script> <file to upload>
I am not using the script on my shell but on the browser. It always returns this same error (I tired it on two different servers from different hosts and where curl has always worked well)
Yes, I can confirm this also, and it's still working. I think I can edit the first post, couldn't do that before.
Looks like they patched it, here is a new solution in php, shell supported. /usr/bin/megaupload #!/usr/bin/php <?php /* place your cookie string here to obtain one, all you need to do is login to megaupload type the following in address bar javascript:document.write(document.cookie); your string is user=(something); */ $muser = 'MY_COOKIE_STRING'; // remove filename from arguments array_shift($argv); // define the log file to write to define('WRITE_LOG', 'log'); // define seperator define('SEP', '|'); // emulates shell pwd $dir = getcwd().'/'; // loops through all the file, upload and write to log file foreach ($argv as $file) { file_put_contents(WRITE_LOG, $file.SEP.human_size(filesize($file)).SEP.submit_megaupload($file).PHP_EOL, FILE_APPEND); } function submit_megaupload($file, $description = 'My Description') { global $dir, $muser; $postData = array(); $postData['file'] = '@'.$dir.$file; $postData['message'] = $description; $postData['password'] = ""; $postData['trafficurl'] = ""; $postData['toemail'] = ""; $postData['fromemail'] = ""; $postData['multiemail'] = ""; $postData['password'] = ""; $postData['user'] = $muser; $postData['hotlink'] = ""; // I could have broken it up here, but I like to do everything on one line. return between("http://www.megaupload.com/?d=", "'", httpSend(between('flashvars.server = "', '";', httpSend("http://www.megaupload.com/", FALSE, "user={$muser}")).'upload_done.php?UPLOAD_IDENTIFIER='.generateRandomID(32).'&user='.$muser, TRUE, "user={$muser}", FALSE, $postData)); } // generic curl operations function httpSend($url, $isPOST = false, $cookie = false, $isFollow = FALSE, $postData = array(), $timeout = FALSE) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9) Gecko/2008052906 Firefox/3.0"); if (!$cookie) { curl_setopt($ch, CURLOPT_COOKIEFILE, "c.txt"); curl_setopt($ch, CURLOPT_COOKIEJAR, "c.txt"); } else { curl_setopt($ch, CURLOPT_COOKIE, $cookie); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); if ($isFollow) { curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); } if ($isPOST) { curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); } if ($timeout) { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 10); } $data = curl_exec($ch); curl_close($ch); return $data; } $nums = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0); // Converted from disassembled flash http://wwwstatic.megaupload.com/flash/ru.swf function generateRandomID($m) { global $nums; $id = '1'.millitime(); $diff = $m - strlen($id); for ($test = 1; $test <= $diff; ++$test) { $id .= $nums[mt_rand(0, 9)]; } return $id; } // This custom function replaces regex function between($start, $end, $source) { $s = strpos($source, $start) + strlen($start); return substr($source, $s, strpos($source, $end, $s) - $s); } // Php does not have native support for milliseconds function millitime() { return round(microtime(TRUE) * 1000); } // function to get human readable filesize $fs = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); function human_size($size) { global $fs; return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2).$fs[$i]; } ?> PHP: make sure the script is executable # chmod +x /usr/bin/megaupload examples: # megaupload file[1-9].avi -> will upload file1.avi,file2.avi...file9.avi # megaupload file1.avi -> will upload file1.avi # megaupload * -> will upload all files A log will be written to the file defined in script. Notes: try the following in shell # which php # whereis php replace what it says in the first line of the script, if it's different. *Very important If nothing appears you will need to install php (fcgi) or cli mode. Perhaps one of the following commands might help, assuming you have root access. # apt-get install php # apt-get install php-cli # yum install php # yum install php-cli # pacman -Su php
Damn. Sorry to say this after you've spent a while coding, but the bash script still seems to still work by changing that url to http://www.megaupload.com/multiupload/ lol
The Script Broke Yesterday, is their anyone willing to fix. I would really appreciate the help. Honestly if someone fixes this sucker I will give them a reward, invite to a very secret tracker.
I have updated the script, and edited on the first post to reflect the changes since yesterdays changes from megaupload. It's working again using bash, just needed to change the url that xendatious suggested.