Advertisement
Guest User

Untitled

a guest
May 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. if(isset($_POST['add'])) {
  2.     $video_id = $_POST['video_id'];
  3.     $episode_name = $_POST['episode_name'];
  4.     $episode_number = $_POST['episode_number'];
  5.     $season_number = $_POST['season_number'];
  6.     $episode_description = $db->real_escape_string($_POST['episode_description']);
  7.     $video_format = $_POST['video_format'];
  8.     $video_embed_code = $_POST['video_embed_code'];
  9.     $video_file_mp4 = $_POST['video_file_mp4'];
  10.     if($video_format == 1) {
  11.         $source = $video_embed_code;
  12.     } else {
  13.         $source = $video_file_mp4;
  14.     }
  15.     // Thumbnail Photo
  16.     if(isset($_FILES['episode_thumbnail']['name'])) {
  17.         $extension = strtolower(end(explode('.', $_FILES['episode_thumbnail']['name'])));
  18.         if($extension == 'png' || $extension == 'jpg' || $extension == 'jpeg') {
  19.             if(!$_FILES['episode_thumbnail']['error']) {
  20.                 $new_file_name = md5(mt_rand()).$_FILES['episode_thumbnail']['name'];
  21.                 if($_FILES['episode_thumbnail']['size'] > (10024000)) {
  22.                     $valid_file = false;
  23.                     $error = 'Oops! One of the photos you uploaded is too large';
  24.                 } else {
  25.                     $valid_file = true;
  26.                 }
  27.                 if($valid_file) {
  28.                     move_uploaded_file($_FILES['episode_thumbnail']['tmp_name'], '../uploads/episodes/'.$new_file_name);
  29.                     $uploaded = true;
  30.                 }
  31.             }
  32.             else {
  33.                 $error = 'Error occured:  '.$_FILES['episode_thumbnail']['error'];
  34.             }
  35.         }  
  36.     }
  37.     $admin->db->query("UPDATE movies SET is_series='1' WHERE id='".$video_id."'");
  38.     $countseasons = $db->query("SELECT * FROM `seasons` WHERE movie_id='".$video_id."' && season_number='".$season_number."'");
  39.     $row = $countseasons->fetch_row();
  40.     if ($row[1] == $video_id && $row[2] == $season_number) {
  41.         $season_id = $row[0];
  42.     } else {
  43.         $db->query("INSERT INTO seasons (movie_id,season_number) VALUES ('".$video_id."','".$season_number."')");
  44.         $season_id = $db->insert_id;
  45.     }
  46.    
  47.     $db->query("INSERT INTO `episodes`(`season_id`, `movie_id`, `episode_number`, `episode_name`, `episode_description`, `episode_thumbnail`, `episode_source`, `is_embed`) VALUES
  48.     ('".$season_id."','".$video_id."','".$episode_number."','".$episode_name."','".$episode_description."',".$new_file_name."','".$source."','".$is_embed."')");
  49.    
  50.     header('Location: episodes.php?success=1');
  51.     exit;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement