コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $media_convert = MediaConvert::where('state', '!=', 'done')->get();
     foreach ($media_convert as $convert) {
         $response = $this->getConvertInfo($convert->file_id, '-' . $convert->preset);
         $info_decode_all = json_decode($response, true);
         if ($info_decode_all["data"] == 100) {
             $file = MediaLike::where('id', '=', $convert->file_id)->first();
             if ($convert->preset == "400") {
                 $re = $this->getConvertProcess($convert->media_id . '/' . $file->path . '-400.mp4');
             } elseif ($convert->preset == "700") {
                 $re = $this->getConvertProcess($convert->media_id . '/' . $file->path . '-700.mp4');
             }
             $convert->state = "done";
             $file->type = "conv";
             if ($convert->preset == "400") {
                 $file->preset_four = true;
             } elseif ($convert->preset == "700") {
                 $file->preset_seven = true;
             }
             $file->save();
         } elseif ($info_decode_all["data"] < 1) {
             $convert->state = "process";
         }
         $convert->percent = $info_decode_all["data"];
         $convert->save();
     }
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $media_id = $this->option('media');
     $media_files = MediaLike::where('media_id', '=', $media_id)->get();
     $download_folder = '/home/mfs/Downloads/transmission/completed/' . $media_id;
     foreach ($media_files as $file) {
         //$new_file = new MediaAdd;
         //$new_file->path = $download_folder;
         //$new_file->media_id = $media_id;
         //$new_file->name = str_replace("#", "", $bs . $file[0]);
         //$new_file->size = $file[3];
         $filepath = $download_folder . '/' . $this->mb_escapeshellarg($file->path);
         $new_name = str_replace("#", "", $filepath);
         if ($filepath != $new_name) {
             $old_folder = $download_folder . '/' . $file->path;
             $new_folder = $download_folder . '/' . str_replace("#", "", $file->path);
             shell_exec("mv {$old_folder} {$new_folder}");
             shell_exec("mv {$filepath} {$new_name}");
             $filepath = $new_name;
         }
         if ($this->getFast($filepath)) {
             $out_meta = shell_exec("qtfaststart {$filepath} 2>&1");
             sleep(5);
         }
         $fi_size = shell_exec("stat -c '%s' {$filepath} 2>&1");
         $file->size_or = (int) $fi_size;
         if (file_exists($download_folder . '/' . str_replace("#", "", $file->path))) {
             if ((int) $fi_size > 15032385536) {
                 $file->cksum = '-';
             } else {
                 $cksum = shell_exec("python3.2 /var/www/data/crc32sum.py {$filepath} 2>&1");
                 $file->cksum = $cksum;
             }
             $file->save();
         }
     }
     //$transmission = new Vohof\Transmission($config);
     //$remove = $transmission->remove($hash);
 }
コード例 #3
0
ファイル: routes.php プロジェクト: naveengamage/okaydrive
         } else {
             $new_file->path = str_replace("#", "", $file[0]);
         }
         $new_file->name = $path_parts["basename"];
         $new_file->type = $this->getExt($new_file->path);
         $new_file->in = 0;
         $new_file->size = $file[3];
         $new_file->media_id = $update->id;
         //$like->user_id = Auth::user()->id;
         $new_file->save();
         $ignore_first_folder = false;
     } else {
         if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
             $full_path = $this->fullpath($dirs, $i - 1);
             //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
             $new_file = new MediaLike();
             if ($tor[34] != 0) {
                 $new_file->path = basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]);
             } else {
                 $new_file->path = $file[0];
             }
             $new_file->type = $this->getExt($new_file->path);
             $new_file->name = $path_parts["basename"];
             $new_file->in = $paths[$full_path]["id"];
             $new_file->size = $file[3];
             $new_file->media_id = $update->id;
             //$like->user_id = Auth::user()->id;
             $new_file->save();
         }
     }
 }
コード例 #4
0
					<a href="/torrent/{{$user_media->uni_id}}d={{$folder->folder_id}}&b={{$current}}"><p>{{ $folder->name }}</p></a>
				</li>
@endforeach
				
		    </ul>
		</div>
			<?php 
if (!$media->downloading() && $media->max_file_id != 0) {
    $thumb_views = array();
    $frames = 13;
    for ($k = 1; $k < $frames; $k++) {
        $thumb_set["thumb"] = 'snaps/thumbs/' . $media->id . '/' . $media->max_file_id . '/' . $k . '.jpg';
        $thumb_set["big"] = 'snaps/big/' . $media->id . '/' . $media->max_file_id . '/' . $k . '.jpg';
        $thumb_views[] = $thumb_set;
    }
    $files_vid = MediaLike::where('media_id', '=', $media->id)->where('type', '=', 'vid')->where('type', '=', 'vid-conv')->get();
    foreach ($files_vid as $file_vid) {
        $thumb_set["thumb"] = 'snaps/thumbs/' . $media->id . '/' . $file_vid->id . '/1.jpg';
        $thumb_set["big"] = 'snaps/big/' . $media->id . '/' . $file_vid->id . '/1.jpg';
        $thumb_views[] = $thumb_set;
    }
}
?>
		<div id="bottom">
			@if($media->downloading())
			<div id="con" style="background: #f5f5f5;overflow: hidden;height:150px;">
					<div style="text-align:center; margin:0 auto; ">
						<div class="stat-bt" style="display:inline-block;margin-top:5px;vertical-align: middle;">
								<input type="text" value="0" data-width="135" data-height="135" class="knob">		
						</div>
						<div  style="display:inline-block;vertical-align: middle;margin-left:10px;"> 
コード例 #5
0
ファイル: CheckAll.php プロジェクト: naveengamage/okaydrive
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $time_start = microtime(true);
     $media = Media::where('state', '!=', 'done')->where('state', '!=', 'failed')->where('state', '!=', 'max_pause')->where('state', '!=', 'process')->where('state', '!=', 'fail_free')->where('state', '!=', 'delete')->get();
     foreach ($media as $update) {
         try {
             if ($update->state === "put_pause") {
                 echo "start";
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=start&hash=' . $update->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $torrent_start = json_decode($response, true);
                 $update->state = "put_start";
                 $update->save();
             }
             $now = new DateTime();
             $now_stamp = $now->format('Y-m-d H:i:s');
             $diff = strtotime($now_stamp) - strtotime($update->featured_at);
             $diff_in_minss = $diff / 60;
             if ($diff_in_minss > 60 && $update->cat == 1 && $update->featured_at != "0000-00-00 00:00:00") {
                 $media_users = UserMedia::where('media_id', '=', $update->id)->get();
                 $del = true;
                 foreach ($media_users as $media_user) {
                     $user = User::where('id', '=', $media_user->user_id)->first();
                     if ($user->category_id == 1) {
                     } else {
                         $del = false;
                         $update->cat = $user->category_id;
                         $update->save();
                     }
                 }
                 if ($del) {
                     $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                     $input_xml = '<methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>d.set_custom5</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value><value><string>1</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.delete_tied</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.erase</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value></data></array></value></param></params></methodCall>';
                     $ch = curl_init($url);
                     $username = '******';
                     $password = '******';
                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                     curl_setopt($ch, CURLOPT_POST, 1);
                     curl_setopt($ch, CURLOPT_POSTFIELDS, $input_xml);
                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                     curl_setopt($ch, CURLOPT_HEADER, 0);
                     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                     curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                     //timeout in seconds
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                     $response = curl_exec($ch);
                     $report = new UserFlag();
                     $report->type = 'check';
                     $report->media_id = $update->id;
                     $report->res = 'took more than an hour' . $response;
                     $report->save();
                     $update->state = 'fail_free';
                     $update->save();
                     $user_report = UserFlag::where('media_id', '=', $update->id)->where('type', '=', 'error')->first();
                     if (!isset($user_report->id)) {
                         $report = new UserFlag();
                         $report->type = 'error';
                         $report->media_id = $update->id;
                         $report->res = $response;
                         $report->save();
                     }
                 }
             } else {
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=list-get&hash=' . $update->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                 //timeout in seconds
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $tor = json_decode($response, true);
                 if (count($tor != 0) && $tor != false) {
                     echo $tor[0];
                     echo "files begin";
                     if ($update->files()->count() == 0 && $update->file_try < 3 && $update->state == "downloading" || $update->files()->count() == 0 && $update->file_try == 3 && $update->state == "downloading" && $this->percent($tor[9], $tor[6]) > 0) {
                         echo "files";
                         if ($tor[3] != 0) {
                             if (strpos($update->title, '.meta') !== false) {
                                 echo "in";
                             } else {
                                 if (!empty($tor[26])) {
                                     $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                                     $myvars = 'mode=fls&hash=' . $tor[0];
                                     $ch = curl_init($url);
                                     $username = '******';
                                     $password = '******';
                                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                     curl_setopt($ch, CURLOPT_POST, 1);
                                     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                     curl_setopt($ch, CURLOPT_HEADER, 0);
                                     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
                                     curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                                     //timeout in seconds
                                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                     $response = curl_exec($ch);
                                     $torrent_files = json_decode($response, true);
                                     $files = $torrent_files;
                                     if (!empty($files)) {
                                         $ignore_first_folder = true;
                                         $id = 1;
                                         $paths = array();
                                         foreach ($files as $file) {
                                             if ($file[0] != $tor[0] . '.meta' && isset($file[0]) && !empty($file[0])) {
                                                 if ($tor[34] != 0) {
                                                     $fd = parse_url(basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]));
                                                 } else {
                                                     $fd = parse_url(str_replace("#", "", $file[0]));
                                                 }
                                                 if (isset($fd['path'])) {
                                                     $path_parts = pathinfo($fd['path']);
                                                 } else {
                                                     $path_parts = pathinfo($file["name"]);
                                                 }
                                                 $dirs = explode("/", $path_parts['dirname']);
                                                 for ($i = 0; $i <= count($dirs); $i++) {
                                                     if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                                         $full_path = $this->fullpath($dirs, $i);
                                                         if (array_key_exists($full_path, $paths)) {
                                                         } else {
                                                             $paths[$full_path]["id"] = $id;
                                                             $paths[$full_path]["name"] = $dirs[$i];
                                                             $prev_path = $this->fullpath($dirs, $i - 1);
                                                             if (!isset($paths[$prev_path]["id"])) {
                                                                 $pv_p = 0;
                                                             } else {
                                                                 $pv_p = $paths[$prev_path]["id"];
                                                             }
                                                             $new_folder = new MediaFlag();
                                                             $new_folder->name = $dirs[$i];
                                                             $new_folder->folder_id = $id;
                                                             $new_folder->in = $pv_p;
                                                             $new_folder->media_id = $update->id;
                                                             $new_folder->save();
                                                             $id++;
                                                         }
                                                     } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                                         //echo $path_parts["basename"].' 0';
                                                         $new_file = new MediaLike();
                                                         if ($tor[34] != 0) {
                                                             $new_file->path = basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]);
                                                         } else {
                                                             $new_file->path = str_replace("#", "", $file[0]);
                                                         }
                                                         $new_file->name = $path_parts["basename"];
                                                         $new_file->type = $this->getExt($new_file->path);
                                                         $new_file->in = 0;
                                                         $new_file->size = $file[3];
                                                         $new_file->media_id = $update->id;
                                                         //$like->user_id = Auth::user()->id;
                                                         $new_file->save();
                                                         $ignore_first_folder = false;
                                                     } else {
                                                         if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                                             $full_path = $this->fullpath($dirs, $i - 1);
                                                             //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                                             $new_file = new MediaLike();
                                                             if ($tor[34] != 0) {
                                                                 $new_file->path = basename(str_replace("#", "", $tor[26])) . '/' . str_replace("#", "", $file[0]);
                                                             } else {
                                                                 $new_file->path = $file[0];
                                                             }
                                                             $new_file->type = $this->getExt($new_file->path);
                                                             $new_file->name = $path_parts["basename"];
                                                             $new_file->in = $paths[$full_path]["id"];
                                                             $new_file->size = $file[3];
                                                             $new_file->media_id = $update->id;
                                                             //$like->user_id = Auth::user()->id;
                                                             $new_file->save();
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         $update["ignore_first"] = $ignore_first_folder;
                                         $update->save();
                                     }
                                     $update->file_try = $update->file_try + 1;
                                     $update->save();
                                 }
                             }
                         }
                     }
                     $info = $tor;
                     echo "max check begin";
                     $max_pause = false;
                     if (strpos($update->title, '.meta') !== false) {
                         echo "in";
                     } else {
                         if ($tor[5] != $update->hash . '.meta' && $info[29] != 0 && $info[6] != null && $info[6] != 0 && !empty($info[6]) && $update->max_check == 0) {
                             $max_pause = true;
                             $media_users = UserMedia::where('media_id', '=', $update->id)->get();
                             echo $info[6] . 'size';
                             foreach ($media_users as $media_user) {
                                 $user = User::where('id', '=', $media_user->user_id)->first();
                                 $user_cat = Category::where('id', '=', $user->category_id)->first();
                                 if ($info[6] > $user_cat->max_add) {
                                     $media_user->max_error = true;
                                     $media_user->save();
                                 } else {
                                     $max_pause = false;
                                 }
                             }
                             if ($max_pause) {
                                 $update->state = "max_pause";
                                 $update->save();
                                 $info["status"] = 7;
                                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                                 $input_xml = '<methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>d.set_custom5</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value><value><string>1</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.delete_tied</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.erase</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value></data></array></value></param></params></methodCall>';
                                 $ch = curl_init($url);
                                 $username = '******';
                                 $password = '******';
                                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                 curl_setopt($ch, CURLOPT_POST, 1);
                                 curl_setopt($ch, CURLOPT_POSTFIELDS, $input_xml);
                                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                 curl_setopt($ch, CURLOPT_HEADER, 0);
                                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                                 //timeout in seconds
                                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                 $response = curl_exec($ch);
                                 $report = new UserFlag();
                                 $report->type = 'check';
                                 $report->media_id = $update->id;
                                 $report->res = 'max pause' . $response;
                                 $report->save();
                             }
                             $update->max_check = 1;
                             $update->save();
                         }
                     }
                     echo "max check end";
                     if ($max_pause) {
                     } else {
                         $state = 'stop';
                         if ($info[1] != 0) {
                             $state = "downloading";
                             if ($info[4] == 0 || $info[29] == 0) {
                                 $state = "paused";
                             }
                         } elseif ($info[24] != 0) {
                             $state = "hashing";
                         } elseif ($info[2] != 0) {
                             $state = "checking";
                         }
                         if ($info[9] >= $info[6]) {
                             $state = "done";
                         }
                         if ($update->title != $info[5]) {
                             if ($info[5] == '') {
                                 $info[5] = 'no name field';
                             }
                             $update->title = $info[5];
                         }
                         if ($update->state == "put_start" && $state == 'stop') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                             $update->state = "downloading";
                             $update->status = 4;
                             $update->save();
                         } elseif ($update->state == "downloading" && $state == 'stop') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                         } elseif ($update->state == "downloading" && $state == 'paused') {
                             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                             $myvars = 'mode=start&hash=' . $tor[0];
                             $ch = curl_init($url);
                             $username = '******';
                             $password = '******';
                             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                             curl_setopt($ch, CURLOPT_POST, 1);
                             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                             curl_setopt($ch, CURLOPT_HEADER, 0);
                             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                             $response = curl_exec($ch);
                             $torrent_start = json_decode($response, true);
                         }
                         if ($info[29] == 0 && $info[1] == 1 && $info[2] == 1) {
                             $state = 'hashing';
                         }
                         switch ($state) {
                             case "hashing":
                                 $update->state = "hashing";
                                 $update->save();
                                 break;
                             case "checking":
                                 $update->state = "check";
                                 $update->status = 2;
                                 $update->save();
                                 break;
                             case "paused":
                             case "downloading":
                                 $update->state = "downloading";
                                 $update->status = 4;
                                 $update->save();
                                 break;
                             case "done":
                                 if ($tor[5] == $update->hash . '.meta' || $update->title == $update->hash . '.meta') {
                                     $report = new UserFlag();
                                     $report->media_id = $update->id;
                                     $report->save();
                                 } else {
                                     $loc = '/home/mfs/Downloads/transmission/completed/' . $update->id;
                                     $url = 'http://s01.okaydrive.com/rt/plugins/datadir/action.php';
                                     $myvars = 'move_fastresume=0&move_datafiles=1&move_addpath=1&hash=' . $tor[0] . '&datadir=' . $loc;
                                     $ch = curl_init($url);
                                     $username = '******';
                                     $password = '******';
                                     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                                     curl_setopt($ch, CURLOPT_POST, 1);
                                     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                                     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                                     curl_setopt($ch, CURLOPT_HEADER, 0);
                                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                                     $response = curl_exec($ch);
                                     $torrent_move = json_decode($response, true);
                                     $process = shell_exec('nohup php /opt/nginx/html/artisan sys:process --hash=' . $update->hash . ' > /dev/null 2>&1 & echo $!');
                                     $update->state = "process";
                                     $update->status = 5;
                                     $update->save();
                                     break;
                                 }
                         }
                         if ($update->state == "put_start" || $update->state == "put_pause" || strpos($update->title, '.meta') !== false || $update->featured_at != "0000-00-00 00:00:00") {
                             echo "in";
                         } else {
                             if ($update->state == "downloading") {
                                 $now = new DateTime();
                                 $now_stamp = $now->format('Y-m-d H:i:s');
                                 $update->featured_at = $now_stamp;
                                 $update->save();
                             }
                         }
                         if ($update->state == "hashing") {
                             $update->perc = $this->percent($info[25], $info[8]);
                         } else {
                             $update->perc = $this->percent($info[9], $info[6]);
                         }
                         $update->upsd = $info[13];
                         if ($info[13] == 0) {
                             $update->eta = $info[6] - $info[9];
                         } else {
                             $update->eta = ($info[6] - $info[9]) / $info[13];
                         }
                         $update->peersc = $info[18];
                         $update->peersa = $info[19];
                         $update->size = $info[6];
                         if ($update->title != $info[5]) {
                             if ($info[5] == '') {
                                 $info[5] = 'no name field';
                             }
                             $update->title = $info[5];
                         }
                         $update->save();
                     }
                     echo uniqid();
                 }
             }
         } catch (Exception $e) {
             echo 'Message: ' . $e->getMessage();
             $report = new UserFlag();
             $report->type = 'check-all-error';
             $report->media_id = $update->id;
             $report->res = $e->getMessage();
             $report->save();
         }
     }
     echo "end";
 }
コード例 #6
0
ファイル: UserController.php プロジェクト: nvq247/Kxexnxh
 public function profile_likes($username)
 {
     $user = User::where('username', '=', $username)->first();
     $medias = MediaLike::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
     $is_user_profile = false;
     if (!Auth::guest() && Auth::user()->id == $user->id) {
         $is_user_profile = true;
     }
     $user_points = DB::table('points')->where('user_id', '=', $user->id)->sum('points');
     $data = array('user' => $user, 'media' => $medias, 'likes' => true, 'settings' => Setting::first(), 'is_user_profile' => $is_user_profile, 'user_points' => $user_points);
     return View::make('Theme::user', $data);
 }
コード例 #7
0
ファイル: MediaController.php プロジェクト: nvq247/Kxexnxh
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $media = Media::find($id);
     if ($media->user_id == Auth::user()->id || Auth::user()->admin == 1) {
         $media_flags = MediaFlag::where('media_id', '=', $id)->get();
         foreach ($media_flags as $media_flag) {
             $media_flag->delete();
         }
         $media_likes = MediaLike::where('media_id', '=', $id)->get();
         foreach ($media_likes as $media_like) {
             $media_like->delete();
         }
         $comments = Comment::where('media_id', '=', $id)->get();
         foreach ($comments as $comment) {
             $comment_votes = CommentVote::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_votes as $comment_vote) {
                 $comment_vote->delete();
             }
             $comment_flags = CommentFlag::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_flags as $comment_flag) {
                 $comment_flag->delete();
             }
             $comment->delete();
         }
         // if the media type is a gif we need to remove the animation file too.
         if (strpos($media->pic_url, '.gif') > 0) {
             if (file_exists(Config::get('site.uploads_dir') . 'images/' . str_replace(".gif", "-animation.gif", $media->pic_url))) {
                 unlink(Config::get('site.uploads_dir') . 'images/' . str_replace(".gif", "-animation.gif", $media->pic_url));
             }
         }
         // remove the image
         if (file_exists(Config::get('site.uploads_dir') . 'images/' . $media->pic_url)) {
             unlink(Config::get('site.uploads_dir') . 'images/' . $media->pic_url);
         }
         $media->delete();
     }
     return Redirect::to('admin?section=media')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
 }
コード例 #8
0
ファイル: UserController.php プロジェクト: giangcoffee/ninja
 public function profile_likes($username)
 {
     $user = User::where('username', '=', $username)->first();
     $medias = MediaLike::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
     $data = array('user' => $user, 'media' => $medias, 'likes' => true);
     return View::make('user.index', $data);
 }
コード例 #9
0
$user_url = '#_';
$username = Lang::get('lang.anonymous');
$user_avatar = Config::get('site.uploads_dir') . 'avatars/default.jpg';
?>
	  		@endif

				<a href="{{ $user_url }}"><img src="{{ $user_avatar }}" class="img-circle user-avatar-medium" /></a><h2 class="item-title"><a href="{{ URL::to('media') . '/' . $item->slug; }}" alt="{{ $item->title }}">{{{ stripslashes($item->title) }}}</a></h2>
				<div class="item-details">
					<p class="details">{{ Lang::get('lang.submitted_by') }}: <a href="{{ $user_url }}">{{ $username}}</a> {{ Lang::get('lang.submitted_on') }} {{ date("F j, Y", strtotime($item->created_at)) }}</p>
					<p class="home-like-count"><i class="fa {{ $settings->like_icon }}"></i> <span>{{ count($item->media_likes) }}</span></p>
					<p class="home-comment-count"><i class="fa fa-comments"></i> {{ count($item->comments) }}</p>
					<p class="home-view-count"><i class="fa fa-eye"></i> @if(isset($view_increment) && $view_increment == true ){{ $item->views + 1 }}@else{{ $item->views }}@endif </p>
				</div>
				@if(!Auth::guest())
					<?php 
$liked = MediaLike::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $item->id)->first();
?>
 
				@endif
				<div class="home-media-like @if(isset($liked->id)) active @endif" data-authenticated="@if(Auth::guest()){{ 'false' }}@else{{ 'true' }}@endif" data-id="{{ $item->id }}"><i class="fa {{ $settings->like_icon }}"></i></div>
			
		</div>

		<div class="clear"></div>

		@if($item->nsfw != 0 && Auth::guest())

			<div class="nsfw-container">
				<h1>NSFW!</h1>
				<p>This content has been marked as Not Safe For Work, login to view this content</p>
				<div class="nsfw-login-signup">
コード例 #10
0
ファイル: Process.php プロジェクト: naveengamage/okaydrive
    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        include_once "/opt/nginx/html/laravel/vendor/SmartImage.class.php";
        try {
            $hash = $this->option('hash');
            $media = Media::where('hash', '=', $hash)->first();
            if ($media->files()->count() == 0) {
                echo "files";
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=info&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_info = json_decode($response, true);
                $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                $myvars = 'mode=fls&hash=' . $hash;
                $ch = curl_init($url);
                $username = '******';
                $password = '******';
                curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                $torrent_files = json_decode($response, true);
                $files = $torrent_files;
                if (!empty($files)) {
                    echo "not empty";
                    echo count($files);
                    $ignore_first_folder = true;
                    $id = 1;
                    $paths = array();
                    foreach ($files as $file) {
                        if ($torrent_info[3] != 0) {
                            $fd = parse_url(basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]));
                        } else {
                            $fd = parse_url(str_replace("#", "", $file[0]));
                        }
                        $path_parts = pathinfo($fd['path']);
                        $dirs = explode("/", $path_parts['dirname']);
                        for ($i = 0; $i <= count($dirs); $i++) {
                            if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                $full_path = $this->fullpath($dirs, $i);
                                if (array_key_exists($full_path, $paths)) {
                                } else {
                                    $paths[$full_path]["id"] = $id;
                                    $paths[$full_path]["name"] = $dirs[$i];
                                    $prev_path = $this->fullpath($dirs, $i - 1);
                                    if (!isset($paths[$prev_path]["id"])) {
                                        $pv_p = 0;
                                    } else {
                                        $pv_p = $paths[$prev_path]["id"];
                                    }
                                    $new_folder = new MediaFlag();
                                    $new_folder->name = $dirs[$i];
                                    $new_folder->folder_id = $id;
                                    $new_folder->in = $pv_p;
                                    $new_folder->media_id = $media->id;
                                    $new_folder->save();
                                    $id++;
                                }
                            } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                //echo $path_parts["basename"].' 0';
                                $new_file = new MediaLike();
                                if ($torrent_info[3] != 0) {
                                    $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                } else {
                                    $new_file->path = str_replace("#", "", $file[0]);
                                }
                                $new_file->name = $path_parts["basename"];
                                $new_file->type = $this->getExt($new_file->path);
                                $new_file->in = 0;
                                $new_file->size = $file[3];
                                $new_file->media_id = $media->id;
                                //$like->user_id = Auth::user()->id;
                                $new_file->save();
                                $ignore_first_folder = false;
                            } else {
                                if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                    $full_path = $this->fullpath($dirs, $i - 1);
                                    //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                    $new_file = new MediaLike();
                                    if ($torrent_info[3] != 0) {
                                        $new_file->path = basename(str_replace("#", "", $torrent_info[2])) . '/' . str_replace("#", "", $file[0]);
                                    } else {
                                        $new_file->path = str_replace("#", "", $file[0]);
                                    }
                                    $new_file->type = $this->getExt($new_file->path);
                                    $new_file->name = $path_parts["basename"];
                                    $new_file->in = $paths[$full_path]["id"];
                                    $new_file->size = $file[3];
                                    $new_file->media_id = $media->id;
                                    //$like->user_id = Auth::user()->id;
                                    $new_file->save();
                                }
                            }
                        }
                    }
                    $media["ignore_first"] = $ignore_first_folder;
                    $media->save();
                }
            }
            $files_local = $media->getFiles();
            if (!empty($files_local)) {
                echo "pro";
                $media_id = $media->id;
                shell_exec('nohup php /opt/nginx/html/artisan check:files --media=' . $media_id . ' > /dev/null 2>&1 & echo $!');
                $max_file_id = null;
                $max_file_size = 0;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->size > $max_file_size) {
                            $max_file_size = $file->size;
                            $max_file_id = $file->id;
                        }
                    }
                }
                $media->max_file_id = $max_file_id;
                $media->save();
                $fast = false;
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        if ($file->type == "vid") {
                            $fast = $this->getFast($file->path);
                        }
                        if ($file->id == $max_file_id) {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 13);
                        } else {
                            $info = $this->makeThumbs($media->id, $file->id, $media->id . '/' . $file->path, $fast, 1);
                        }
                        if (!empty($info) && $info != null) {
                            $info_decode_all = json_decode($info, true);
                            $info_decode = $info_decode_all["data"];
                            $new_fileinfo = new FileInfo();
                            $new_fileinfo->file_id = $file->id;
                            $new_fileinfo->media_id = $media->id;
                            $new_fileinfo->video_duration = $info_decode["video_duration"];
                            $new_fileinfo->video_codec_name = $info_decode["video_codec_name"];
                            $new_fileinfo->video_width = $info_decode["video_width"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_height = $info_decode["video_height"];
                            $new_fileinfo->video_ratio = $info_decode["video_ratio"];
                            $new_fileinfo->video_fps = $info_decode["video_fps"];
                            $new_fileinfo->audio_codec_name = $info_decode["audio_codec_name"];
                            $new_fileinfo->audio_bit_rate = $info_decode["audio_bit_rate"];
                            $new_fileinfo->save();
                        }
                    } elseif ($file->type == "img") {
                        //$this->setimages($file->name ,$media->id . '/'. $file->path);
                        $file_path_thumb = '/opt/nginx/html/public/cache/thumbs/' . $file->id . '.jpg';
                        $full_path = '/home/mfs/Downloads/transmission/completed/' . $media->id . '/' . $file->path;
                        if (file_exists($file_path_thumb)) {
                            unlink($file_path_thumb);
                        }
                        try {
                            $img = new SmartImage($full_path);
                            $img->resize(130, 130, true);
                            $img->saveImage($file_path_thumb, 85);
                        } catch (Exception $e) {
                            $full_path = '/home/mfs/Downloads/transmission/image.png';
                            $img = new SmartImage($full_path);
                            $img->saveImage($file_path_thumb, 85);
                        }
                        //file_put_contents($file_path_thumb, $file_img_tmp);
                    }
                }
                sleep(10);
                $save_base_thumbs = "/opt/nginx/html/public/snaps/thumbs/";
                $save_base_big = "/opt/nginx/html/public/snaps/big/";
                foreach ($files_local as $file) {
                    if ($file->type == "vid" || $file->type == "vid-conv") {
                        $snap_big_path = $save_base_big . $media->id;
                        if (!file_exists($snap_big_path)) {
                            mkdir($snap_big_path, 0775, true);
                        }
                        $snap_big_path_full = $snap_big_path . '/' . $file->id;
                        if (!file_exists($snap_big_path_full)) {
                            mkdir($snap_big_path_full, 0775, true);
                        }
                        $snap_thumb_path = $save_base_thumbs . $media->id;
                        if (!file_exists($snap_thumb_path)) {
                            mkdir($snap_thumb_path, 0775, true);
                        }
                        $snap_thumb_path_full = $snap_thumb_path . '/' . $file->id;
                        if (!file_exists($snap_thumb_path_full)) {
                            mkdir($snap_thumb_path_full, 0775, true);
                        }
                        if ($media->max_file_id != $file->id) {
                            $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/1.jpg';
                            $snap_big_path_full_file = $snap_big_path_full . '/1.jpg';
                            $snap_thumb_path_full_file = $snap_thumb_path_full . '/1.jpg';
                            if (file_exists($snap_big_path_full_file)) {
                            } else {
                                try {
                                    $file_img = file_get_contents($file_get);
                                    file_put_contents($snap_big_path_full_file, $file_img);
                                    $img = new SmartImage($snap_big_path_full_file);
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                } catch (Exception $e) {
                                    $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                    $img->resize(130, 130, true);
                                    $img->saveImage($snap_thumb_path_full_file, 85);
                                }
                            }
                        } elseif ($media->max_file_id == $file->id) {
                            $frames = 13;
                            for ($k = 1; $k < $frames; $k++) {
                                $snap_big_path_full_file = $snap_big_path_full . '/' . $k . '.jpg';
                                $snap_thumb_path_full_file = $snap_thumb_path_full . '/' . $k . '.jpg';
                                $file_get = '/opt/nginx/html/laravel/public/snaps/' . $media->id . '/' . $file->id . '/' . $k . '.jpg';
                                if (file_exists($snap_big_path_full_file)) {
                                } else {
                                    try {
                                        $file_img = file_get_contents($file_get);
                                        file_put_contents($snap_big_path_full_file, $file_img);
                                        $img = new SmartImage($snap_big_path_full_file);
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    } catch (Exception $e) {
                                        $img = new SmartImage('/opt/nginx/html/app/commands/1.png');
                                        $img->resize(130, 130, true);
                                        $img->saveImage($snap_thumb_path_full_file, 85);
                                    }
                                }
                            }
                        }
                    }
                }
                while (MediaLike::where('media_id', '=', $media->id)->where('cksum', '=', '')->count() != 0) {
                    sleep(1);
                }
                $media["state"] = 'done';
                $media->save();
                $media_users = $media->usersMedia();
                foreach ($media_users as $media_user) {
                    try {
                        $user_this = User::where('id', '=', $media_user->user_id)->first();
                        if (isset($user_this->email) && $user_this->ea) {
                            require_once '/opt/nginx/html/vendor/php-aws-ses-master/src/ses.php';
                            $ses = new SimpleEmailService('AKIAJNUKDR6WQV2PJLEA', 'Q0p4SCDdHK5QddvUICYj/xMfoAbcxa7buuRYTJyY');
                            $m = new SimpleEmailServiceMessage();
                            $m->addTo($user_this->email);
                            $m->setFrom('DATAS Support <*****@*****.**>');
                            $m->setSubject('Your files are ready to download.');
                            $html = '<table class="yiv7962433916container" align="center" cellspacing="0" border="0" cellpadding="0" width="580" bgcolor="#FFFFFF" style="width:580px;background-color:#FFF;border-top:1px solid #DDD;border-bottom:1px solid #DDD;" id="yui_3_13_0_1_1397466773730_2821">
												<tbody id="yui_3_13_0_1_1397466773730_2820"><tr id="yui_3_13_0_1_1397466773730_2819">
													<td class="yiv7962433916title" style="padding-top:34px;padding-left:39px;padding-right:39px;text-align:left;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;" id="yui_3_13_0_1_1397466773730_2818">
														<h2 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:30px;color:#262626;font-weight:normal;margin-top:0;margin-bottom:13px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;letter-spacing:0;" id="yui_3_13_0_1_1397466773730_2817">Your file is ready!</h2>
														<h3 style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;font-size:16px;color:#3e434a;font-weight:normal;margin-top:0;margin-bottom:19px;margin-right:0;margin-left:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;line-height:25px;" id="yui_3_13_0_1_1397466773730_2824">The file <b>' . $media->title . '</b> has been downloaded and ready to Play, Download, Convert or Stream.</h3>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2831">
													<td class="yiv7962433916cta" align="left" style="background-color:#F1FAFE;font-size:14px;color:#1f1f1f;border-top-width:1px;border-top-style:solid;border-top-color:#DAE3EA;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#DAE3EA;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:20px;padding-bottom:20px;padding-right:39px;padding-left:39px;text-align:left;" id="yui_3_13_0_1_1397466773730_2830">
														<table cellspacing="0" border="0" cellpadding="0" width="500" align="left">
															<tbody><tr>
																<td width="24"></td>
																<td class="yiv7962433916link" align="left" style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;padding-left:9px;font-size:14px;"><strong><a rel="nofollow" style="color:#2b6cb5;font-family:Arial;font-size:12px;" target="_blank" href="https://okaydrive.com/torrent/' . $media_user->uni_id . '">Click here to go to your file</a></strong></td>
															</tr>
														</tbody></table>
													</td>
												</tr>
												<tr id="yui_3_13_0_1_1397466773730_2827">
													<td class="yiv7962433916footer" style="color:#797c80;font-size:12px;border-left-width:1px;border-left-style:solid;border-left-color:#DDD;border-right-width:1px;border-right-style:solid;border-right-color:#DDD;padding-top:23px;padding-left:39px;padding-right:13px;padding-bottom:23px;text-align:left;" id="yui_3_13_0_1_1397466773730_2826">
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2832">
															You can login with <a rel="nofollow" style="font-weight:bold;text-decoration:none;color:inherit;cursor:default;">' . $user_this->username . '</a> at <a rel="nofollow" target="_blank" href="https://okaydrive.com" id="yui_3_13_0_1_1397466773730_2833">https://okaydrive.com</a>
														</p>
														<p style="font-family:Helvetica Neue, Arial, Helvetica, sans-serif;margin-top:0;margin-bottom:0;margin-right:0;margin-left:0;padding-top:0;padding-bottom:13px;padding-right:0;padding-left:0;line-height:20px;" id="yui_3_13_0_1_1397466773730_2825">Want some help with using our site? Simply reply to this email or email us - support@okaydrive.com. Email alerts are enabled by default, you may disable email alerts in your account settings.</p>
													</td>
												</tr>
												<tr>
											</tr></tbody></table>';
                            $m->setMessageFromString('', $html);
                            $ses->sendEmail($m);
                        }
                    } catch (Exception $e) {
                    }
                }
            }
        } catch (Exception $e) {
            file_put_contents('/home/mfs/l.log', $e);
        }
    }
コード例 #11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $media = Media::find($id);
     if ($media->user_id == Auth::user()->id || Auth::user()->admin == 1) {
         $media_flags = MediaFlag::where('media_id', '=', $id)->get();
         foreach ($media_flags as $media_flag) {
             $media_flag->delete();
         }
         $media_likes = MediaLike::where('media_id', '=', $id)->get();
         foreach ($media_likes as $media_like) {
             $media_like->delete();
         }
         $comments = Comment::where('media_id', '=', $id)->get();
         foreach ($comments as $comment) {
             $comment_votes = CommentVote::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_votes as $comment_vote) {
                 $comment_vote->delete();
             }
             $comment_flags = CommentFlag::where('comment_id', '=', $comment->id)->get();
             foreach ($comment_flags as $comment_flag) {
                 $comment_flag->delete();
             }
             $comment->delete();
         }
         $arrayPicUrl = explode("/", $media->pic_url);
         // if the media type is a gif we need to remove the animation file too.
         if (strpos($media->pic_url, '.gif') > 0) {
             \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo(str_replace(".gif", "-animation.gif", $media->pic_url), PATHINFO_FILENAME));
         }
         // remove the image
         \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo($media->pic_url, PATHINFO_FILENAME));
         $media->delete();
     }
     return Redirect::to('admin?section=media')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
 }
コード例 #12
0
ファイル: Media.php プロジェクト: naveengamage/okaydrive
 public function getFiles()
 {
     return MediaLike::where('media_id', '=', $this->id)->get();
 }
コード例 #13
0
ファイル: ProcessIt.php プロジェクト: naveengamage/okaydrive
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $config = array('host' => 'http://77.247.178.109:9018', 'endpoint' => '/datasrpc/rpc', 'username' => 'datasrpc', 'password' => 'Q8EAxtApHzNmz6UKHBQX');
     $hash = $this->option('hash');
     $media = Media::where('hash', '=', $hash)->first();
     $transmission = new Vohof\Transmission($config);
     $getFiles = $transmission->get($media->hash, array('files'));
     $files = $getFiles["arguments"]["torrents"][0]["files"];
     if (!empty($files)) {
         $media->files()->delete();
         $media->folders()->delete();
         $ignore_first_folder = true;
         $id = 1;
         $paths = array();
         foreach ($files as $file) {
             $fd = parse_url($file["name"]);
             $path_parts = pathinfo($fd['path']);
             $dirs = explode("/", $path_parts['dirname']);
             for ($i = 0; $i <= count($dirs); $i++) {
                 if (isset($dirs[$i]) && $dirs[$i] != '.') {
                     $full_path = $this->fullpath($dirs, $i);
                     if (array_key_exists($full_path, $paths)) {
                     } else {
                         $paths[$full_path]["id"] = $id;
                         $paths[$full_path]["name"] = $dirs[$i];
                         $prev_path = $this->fullpath($dirs, $i - 1);
                         if (!isset($paths[$prev_path]["id"])) {
                             $pv_p = 0;
                         } else {
                             $pv_p = $paths[$prev_path]["id"];
                         }
                         $new_folder = new MediaFlag();
                         $new_folder->name = $dirs[$i];
                         $new_folder->folder_id = $id;
                         $new_folder->in = $pv_p;
                         $new_folder->media_id = $media->id;
                         $new_folder->save();
                         $id++;
                     }
                 } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                     //echo $path_parts["basename"].' 0';
                     $new_file = new MediaLike();
                     $new_file->path = $file["name"];
                     $new_file->name = $path_parts["basename"];
                     $new_file->type = $this->getExt($new_file->path);
                     $new_file->in = 0;
                     $new_file->size = $file["length"];
                     $new_file->media_id = $media->id;
                     //$like->user_id = Auth::user()->id;
                     $new_file->save();
                     $ignore_first_folder = false;
                 } else {
                     if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                         $full_path = $this->fullpath($dirs, $i - 1);
                         //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                         $new_file = new MediaLike();
                         $new_file->path = $file["name"];
                         $new_file->name = $path_parts["basename"];
                         $new_file->type = $this->getExt($new_file->path);
                         $new_file->in = $paths[$full_path]["id"];
                         $new_file->size = $file["length"];
                         $new_file->media_id = $media->id;
                         //$like->user_id = Auth::user()->id;
                         $new_file->save();
                     }
                 }
             }
         }
         $media["ignore_first"] = $ignore_first_folder;
         $media->save();
     }
     $files_local = $media->files();
     if (!empty($files_local)) {
         $max_file_id = null;
         $max_file_size = 0;
         foreach ($files_local as $file) {
             if ($file->type == "vid" || $file->type == "vid-conv") {
                 if ($file->size > $max_file_size) {
                     $max_file_size = $file->size;
                     $max_file_id = $file->id;
                 }
             }
         }
         $media->max_file_id = $max_file_id;
         $media->save();
         foreach ($files_local as $file) {
             if ($file->type == "vid" || $file->type == "vid-conv") {
                 if ($file->id == $max_file_id) {
                     echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 1);
                 } else {
                     echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 13);
                 }
             }
         }
     }
 }
コード例 #14
0
 public function uploadFile()
 {
     $requestsPerHour = 60;
     $key = sprintf('api:%s', Request::getClientIp());
     $get_data = DB::table('limit')->where('ip', $key)->first();
     if (isset($get_data->ip)) {
         $count = $get_data->count;
         $count++;
         DB::table('limit')->where('ip', $key)->update(array('count' => $count));
     } else {
         DB::table('limit')->insert(array('user_id' => Auth::user()->id, 'ip' => $key, 'count' => 0));
     }
     $count = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->where('cat', '=', '1')->count();
     //if($count >= 2 && Auth::user()->category_id == 1){
     //	$response = Response::json(array('result'=>false, 'location' => false,'error'=>'Free accounts are only allowed 2 torrents per account.' ));
     //	$response->header('Content-Type', 'application/json');
     //	return $response;
     //}
     $user_media = UserMedia::where('user_id', '=', Auth::user()->id)->where('is_deleted', '=', '0')->get();
     if (count($user_media) != 0) {
         $uma = array();
         foreach ($user_media as $um) {
             array_push($uma, $um->media_id);
         }
         $media_count = Media::whereIn('id', $uma)->where('state', '!=', 'done')->where('state', '!=', 'max_pause')->where('state', '!=', 'failed')->where('state', '!=', 'process')->where('state', '!=', 'stop')->count();
         if ($media_count >= 1 && Auth::user()->category_id == 1) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Free accounts are only allowed 1 active torrent per account.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
         if ($media_count >= 10) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Your account is only allowed 10 active torrents.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     if (Auth::user()->category_id == 1) {
         $status = true;
         $useage = Auth::user()->used_bytes;
         if ($useage > Auth::user()->avl_bytes) {
             $status = false;
         }
         if (Auth::user()->avl_bytes - $useage < 104857600) {
             $status = false;
         }
         date_default_timezone_set('Pacific/Auckland');
         $ip_date = date("Y-m-d");
         $ip_bytes = DataIp::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('date', '=', $ip_date)->sum('bytes');
         if (1073741824 - $ip_bytes < 104857600) {
             $status = false;
         }
         if (!$status) {
             $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Low bandwidth left on your account. Upgrade your account to premium.'));
             $response->header('Content-Type', 'application/json');
             return $response;
         }
     }
     require '/opt/nginx/html/vendor/upload.php';
     $upload_directory = '/opt/nginx/html/public/cache/tmp';
     $allowed_extensions = array('torrent');
     $max_size = 1048576;
     $uploader = new FileUpload('file');
     $ext = $uploader->getExtension();
     if (empty($ext)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Invalid file type.'));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $filename = uniqid(uniqid(), true) . '.' . $ext;
     $uploader->newFileName = $filename;
     $uploader->sizeLimit = $max_size;
     $result = $uploader->handleUpload($upload_directory, $allowed_extensions);
     $errors = $uploader->getErrorMsg();
     if (!empty($errors)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => $uploader->getErrorMsg()));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     $file = $uploader->getSavedFile();
     $url = 'http://s01.okaydrive.com/rt/php/addtorrent2.php';
     $myvars = 'torrents_start_stopped=1&url=https://okaydrive.com/cache/tmp/' . $filename;
     $ch = curl_init($url);
     $username = '******';
     $password = '******';
     curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $response = curl_exec($ch);
     $json = json_decode($response, true);
     $uni_id = '';
     if ($json["result"] == "success") {
         $hash = $json["hash"];
         $mediaexist = Media::where('hash', '=', $hash)->first();
         if (isset($mediaexist->id)) {
             if ($mediaexist->state == 'done' || $mediaexist->state == 'failed') {
                 $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
                 $myvars = 'mode=remove&hash=' . $mediaexist->hash;
                 $ch = curl_init($url);
                 $username = '******';
                 $password = '******';
                 curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
                 curl_setopt($ch, CURLOPT_POST, 1);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
                 curl_setopt($ch, CURLOPT_TIMEOUT, 4);
                 //timeout in seconds
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $response = curl_exec($ch);
                 $removed = json_decode($response, true);
             }
             $userHasMedia = UserMedia::where('user_id', '=', Auth::user()->id)->where('media_id', '=', $mediaexist->id)->first();
             if (!isset($userHasMedia->id)) {
                 if ($mediaexist->size > Auth::user()->category()->max_add) {
                     $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Max torrent size allowed for Free accounts reached.'));
                     $response->header('Content-Type', 'application/json');
                     return $response;
                 }
                 if ($mediaexist->state == 'max_pause') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'fail_free' && $mediaexist->user_id != Auth::user()->user_id) {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'delete') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 $newMedia = new UserMedia();
                 $newMedia->user_id = Auth::user()->id;
                 $newMedia->cat = Auth::user()->category_id;
                 $newMedia->media_id = $mediaexist->id;
                 $newMedia->uni_id = uniqid(rand(), true);
                 $newMedia->save();
                 $uni_id = $newMedia->uni_id;
                 $res = 'cache';
             } else {
                 if ($mediaexist->state == 'max_pause') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'fail_free' && $mediaexist->user_id != Auth::user()->user_id) {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($mediaexist->state == 'delete') {
                     $mediaexist->state = 'put_pause';
                     $mediaexist->save();
                 }
                 if ($userHasMedia->is_deleted) {
                     $userHasMedia->is_deleted = false;
                     $userHasMedia->save();
                 }
                 $uni_id = $userHasMedia->uni_id;
                 $res = 'has';
             }
         } else {
             sleep(4);
             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
             $myvars = 'mode=info&hash=' . $hash;
             $ch = curl_init($url);
             $username = '******';
             $password = '******';
             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             $torrent_info = json_decode($response, true);
             if (empty($torrent_info[0]) || !isset($torrent_info[0])) {
                 $torrent_info[0] = $hash;
             }
             $inputTorrent["hash"] = $hash;
             $inputTorrent["title"] = $torrent_info[0];
             $inputTorrent["state"] = 'put_pause';
             $inputTorrent["user_id"] = Auth::user()->id;
             $inputTorrent["source"] = 'https://okaydrive.com/cache/tmp/' . $filename;
             $inputTorrent["cat"] = Auth::user()->category_id;
             $new_media = $this->media->create($inputTorrent);
             $newMedia = new UserMedia();
             $newMedia->user_id = Auth::user()->id;
             $newMedia->cat = Auth::user()->category_id;
             $newMedia->media_id = $new_media->id;
             $newMedia->uni_id = uniqid(rand(), true);
             $newMedia->save();
             $uni_id = $newMedia->uni_id;
             sleep(1);
             $url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
             $myvars = 'mode=fls&hash=' . $hash;
             $ch = curl_init($url);
             $username = '******';
             $password = '******';
             curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $response = curl_exec($ch);
             $torrent_files = json_decode($response, true);
             $files = $torrent_files;
             $totalSize = $torrent_info[1];
             if (!empty($totalSize)) {
                 if ($totalSize > Auth::user()->category()->max_add) {
                     $newMedia->delete();
                     $new_media->delete();
                     $response = Response::json(array('result' => false, 'location' => false, 'error' => 'Max torrent size allowed for Free accounts reached.'));
                     $response->header('Content-Type', 'application/json');
                     return $response;
                 } else {
                     $new_media["size"] = $totalSize;
                 }
             }
             if (!empty($files) && !empty($torrent_info[2])) {
                 $ignore_first_folder = true;
                 $id = 1;
                 $paths = array();
                 foreach ($files as $file) {
                     if ($file[0] != $hash . '.meta') {
                         if ($torrent_info[3] != 0) {
                             $fd = parse_url(basename($torrent_info[2]) . '/' . $file[0]);
                         } else {
                             $fd = parse_url($file[0]);
                         }
                         $path_parts = pathinfo($fd['path']);
                         $dirs = explode("/", $path_parts['dirname']);
                         for ($i = 0; $i <= count($dirs); $i++) {
                             if (isset($dirs[$i]) && $dirs[$i] != '.') {
                                 $full_path = $this->fullpath($dirs, $i);
                                 if (array_key_exists($full_path, $paths)) {
                                 } else {
                                     $paths[$full_path]["id"] = $id;
                                     $paths[$full_path]["name"] = $dirs[$i];
                                     $prev_path = $this->fullpath($dirs, $i - 1);
                                     if (!isset($paths[$prev_path]["id"])) {
                                         $pv_p = 0;
                                     } else {
                                         $pv_p = $paths[$prev_path]["id"];
                                     }
                                     $new_folder = new MediaFlag();
                                     $new_folder->name = $dirs[$i];
                                     $new_folder->folder_id = $id;
                                     $new_folder->in = $pv_p;
                                     $new_folder->media_id = $new_media->id;
                                     $new_folder->save();
                                     $id++;
                                 }
                             } elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
                                 //echo $path_parts["basename"].' 0';
                                 $new_file = new MediaLike();
                                 if ($torrent_info[3] != 0) {
                                     $new_file->path = basename($torrent_info[2]) . '/' . $file[0];
                                 } else {
                                     $new_file->path = $file[0];
                                 }
                                 $new_file->type = $this->getExt($new_file->path);
                                 $new_file->name = $path_parts["basename"];
                                 $new_file->in = 0;
                                 $new_file->size = $file[3];
                                 $new_file->media_id = $new_media->id;
                                 //$like->user_id = Auth::user()->id;
                                 $new_file->save();
                                 $ignore_first_folder = false;
                             } else {
                                 if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
                                     $full_path = $this->fullpath($dirs, $i - 1);
                                     //echo $path_parts["basename"].' '.$paths[$full_path]["id"];
                                     $new_file = new MediaLike();
                                     if ($torrent_info[3] != 0) {
                                         $new_file->path = basename($torrent_info[2]) . '/' . $file[0];
                                     } else {
                                         $new_file->path = $file[0];
                                     }
                                     $new_file->type = $this->getExt($new_file->path);
                                     $new_file->name = $path_parts["basename"];
                                     $new_file->in = $paths[$full_path]["id"];
                                     $new_file->size = $file[3];
                                     $new_file->media_id = $new_media->id;
                                     //$like->user_id = Auth::user()->id;
                                     $new_file->save();
                                 }
                             }
                         }
                     }
                 }
                 $new_media["ignore_first"] = $ignore_first_folder;
             }
             $new_media->save();
             $res = 'added';
         }
     } else {
         $error = "Could not add the torrent, please check your input.";
     }
     //$new_media = $this->media->create($input);
     if (isset($error)) {
         $response = Response::json(array('result' => false, 'location' => false, 'error' => $error));
         $response->header('Content-Type', 'application/json');
         return $response;
     } else {
         $response = Response::json(array('result' => true, 'location' => '/torrent/' . $uni_id, 'torrent' => $res));
         $response->header('Content-Type', 'application/json');
         return $response;
     }
 }