Ejemplo n.º 1
1
<?php

require_once 'mega.class.php';
$megafile = new MEGA('https://mega.co.nz/#!yl5EFARS!c6T1en1P8N9GuQzsMy5iCh2U9NEmuqTvSd4KkW42UX4');
$megafile->download();
// OR
// $megafile->stream_download(); // to download using streams
Ejemplo n.º 2
0
<?php

require_once 'mega.class.php';
$megafile = new MEGA('https://mega.co.nz/#!yl5EFARS!c6T1en1P8N9GuQzsMy5iCh2U9NEmuqTvSd4KkW42UX4');
//$megafile->download();
// OR
$megafile->stream_download();
// to download using streams
Ejemplo n.º 3
0
 /**
  * Factory method for getting an instance of MEGA client with authentication
  * using a full user account.
  *
  * @param string $email
  * @param string $password
  * @return MEGA
  */
 public static function create_from_login($email, $password)
 {
     $client = new MEGA();
     $client->user_login_session($email, $password);
     return $client;
 }
Ejemplo n.º 4
0
 function mega($url)
 {
     $this->reserved = array();
     $this->CheckMBIP();
     $dlhtml = '';
     if (count($this->jobs) >= $this->max_jobs) {
         $this->error1('manyjob');
     }
     if ($this->countMBIP >= $this->limitMBIP) {
         $this->error1('countMBIP', Tools_get::convertmb($this->limitMBIP * 1024 * 1024), Tools_get::convert_time($this->ttl * 60), Tools_get::convert_time($this->timebw));
     }
     /* check 1 */
     $checkjobs = $this->Checkjobs();
     $heute = $checkjobs[0];
     $lefttime = $checkjobs[1];
     if ($heute >= $this->limitPERIP) {
         $this->error1('limitPERIP', $this->limitPERIP, Tools_get::convert_time($this->ttl_ip * 60), $lefttime);
     }
     /* /check 1 */
     if ($this->lookup_ip($_SERVER['REMOTE_ADDR']) >= $this->max_jobs_per_ip) {
         $this->error1('limitip');
     }
     $url = trim($url);
     if (empty($url)) {
         return;
     }
     $Original = $url;
     $link = '';
     $cookie = '';
     $report = false;
     $megafile = new MEGA(urldecode($url));
     $info = $megafile->file_info();
     $link = 'https://mega.co.nz/';
     $filesize = $info['size'];
     $filename = isset($this->reserved['filename']) ? $this->reserved['filename'] : Tools_get::convert_name($info['attr']['n']);
     $hosting = Tools_get::site_hash($Original);
     if (!isset($filesize)) {
         $this->error2('notsupport', $Original);
     }
     $this->max_size = $this->acc[$site]['max_size'];
     if (!isset($this->max_size)) {
         $this->max_size = $this->max_size_other_host;
     }
     $msize = Tools_get::convertmb($filesize);
     $hash = md5($_SERVER['REMOTE_ADDR'] . $Original);
     if ($hash === false) {
         $this->error1('cantjob');
     }
     if ($filesize > $this->max_size * 1024 * 1024) {
         $this->error2('filebig', $Original, $msize, Tools_get::convertmb($this->max_size * 1024 * 1024));
     }
     if ($this->countMBIP + $filesize / (1024 * 1024) >= $this->limitMBIP) {
         $this->error1('countMBIP', Tools_get::convertmb($this->limitMBIP * 1024 * 1024), Tools_get::convert_time($this->ttl * 60), Tools_get::convert_time($this->timebw));
     }
     /* check 2 */
     $checkjobs = $this->Checkjobs();
     $heute = $checkjobs[0];
     $lefttime = $checkjobs[1];
     if ($heute >= $this->limitPERIP) {
         $this->error1('limitPERIP', $this->limitPERIP, Tools_get::convert_time($this->ttl_ip * 60), $lefttime);
     }
     /* /check 2 */
     $job = array('hash' => "mega_" . substr(md5($hash), 0, 10), 'path' => substr(md5(rand()), 0, 5), 'filename' => urlencode($filename), 'size' => $filesize, 'msize' => $msize, 'mtime' => time(), 'speed' => 0, 'url' => urlencode($Original), 'owner' => $this->owner, 'ip' => $_SERVER['REMOTE_ADDR'], 'type' => 'direct', 'proxy' => 0, 'site' => $site, 'directlink' => array('url' => urlencode($link), 'cookies' => $this->cookie));
     $this->jobs[$hash] = $job;
     $this->save_jobs();
     $tiam = time() . rand(0, 999);
     $gach = explode('/', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']);
     $sv_name = "";
     for ($i = 0; $i < count($gach) - 1; $i++) {
         $sv_name .= $gach[$i] . "/";
     }
     if ($this->acc[$site]['direct']) {
         $linkdown = $link;
     } elseif ($this->longurl) {
         if (function_exists("apache_get_modules") && in_array('mod_rewrite', @apache_get_modules())) {
             $linkdown = 'http://' . $sv_name . $hosting . '/' . $job['hash'] . '/' . urlencode($filename);
         } else {
             $linkdown = 'http://' . $sv_name . 'index.php/' . $hosting . '/' . $job['hash'] . '/' . urlencode($filename);
         }
     } else {
         $linkdown = 'http://' . $sv_name . '?file=' . $job['hash'];
     }
     // Create ads link before to zip it (free account only)
     if (!isset($this->logboostSession) || !$this->logboostSession->isPremium()) {
         if ($this->use_ads && !empty($this->link_ads)) {
             $datalink = $this->curl($this->link_ads . $linkdown, '', '', 0);
             if (preg_match('%(http:\\/\\/.++)%U', $datalink, $adslik)) {
                 $linkdown = trim($adslik[1]);
             }
         }
     }
     // #########Begin short link ############  //    Short link by giaythuytinh176@rapidleech.com
     if (empty($this->zlink) == true && empty($link) == false && empty($this->Googlzip) == false && empty($this->bitly) == true) {
         $datalink = $this->Googlzip($linkdown);
         if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
             $lik = trim($shortlink[1]);
         } else {
             $lik = $linkdown;
         }
     } elseif (empty($this->zlink) == true && empty($link) == false && empty($this->Googlzip) == true && empty($this->bitly) == false) {
         $datalink = $this->bitly($linkdown);
         if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
             $lik = trim($shortlink[1]);
         } else {
             $lik = $linkdown;
         }
     } elseif (empty($this->zlink) == false && empty($link) == false) {
         if (empty($this->Googlzip) == true && empty($this->bitly) == true) {
             if (empty($this->link_zip) == false) {
                 if (empty($this->link_rutgon) == true) {
                     $datalink = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 } elseif (empty($this->link_rutgon) == false) {
                     $apizip = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     $apizip2 = $this->curl($this->link_rutgon . $apizip, '', '', 0);
                     if (preg_match('%(http:\\/\\/.++)%U', $apizip2, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             } elseif (empty($this->link_zip) == true) {
                 if (empty($this->link_rutgon) == true) {
                     $lik = $linkdown;
                 } elseif (empty($this->link_rutgon) == false) {
                     $datalink = $this->curl($this->link_rutgon . $linkdown, '', '', 0);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             }
         } elseif (empty($this->Googlzip) == false && empty($this->bitly) == true) {
             if (empty($this->link_zip) == false) {
                 if (empty($this->link_rutgon) == true) {
                     $apizip = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     $datalink = $this->Googlzip($apizip);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 } elseif (empty($this->link_rutgon) == false) {
                     $apizip = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     $apizip2 = $this->curl($this->link_rutgon . $apizip, '', '', 0);
                     $datalink = $this->Googlzip($apizip2);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             } elseif (empty($this->link_zip) == true) {
                 if (empty($this->link_rutgon) == true) {
                     $datalink = $this->Googlzip($linkdown);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 } elseif (empty($this->link_rutgon) == false) {
                     $apizip = $this->curl($this->link_rutgon . $linkdown, '', '', 0);
                     $datalink = $this->Googlzip($apizip);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             }
         } elseif (empty($this->Googlzip) == true && empty($this->bitly) == false) {
             if (empty($this->link_zip) == false) {
                 if (empty($this->link_rutgon) == true) {
                     $apizip = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     $datalink = $this->bitly($apizip);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 } elseif (empty($this->link_rutgon) == false) {
                     $apizip = $this->curl($this->link_zip . $linkdown, '', '', 0);
                     $apizip2 = $this->curl($this->link_rutgon . $apizip, '', '', 0);
                     $datalink = $this->bitly($apizip2);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             } elseif (empty($this->link_zip) == true) {
                 if (empty($this->link_rutgon) == true) {
                     $datalink = $this->bitly($linkdown);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 } elseif (empty($this->link_rutgon) == false) {
                     $apizip = $this->curl($this->link_rutgon . $linkdown, '', '', 0);
                     $datalink = $this->bitly($apizip);
                     if (preg_match('%(http:\\/\\/.++)%U', $datalink, $shortlink)) {
                         $lik = trim($shortlink[1]);
                     } else {
                         $lik = $linkdown;
                     }
                 }
             }
         }
     } else {
         $lik = $linkdown;
     }
     if ($this->bbcode) {
         echo "<input name='176' type='text' size='100' value='[center][b][URL={$lik}]{$this->title} | [color={$this->colorfn}]{$filename}[/color][color={$this->colorfs}] ({$msize}) [/color][/url][/b][/center]' onClick='this.select()'>";
         echo "<br>";
     }
     $dlhtml = "<b><a title='click here to download' href='{$lik}' style='TEXT-DECORATION: none' target='{$tiam}'> <font color='#00CC00'>" . $filename . "</font> <font color='#FF66FF'>({$msize})</font> ";
     return $dlhtml;
 }