コード例 #1
0
ファイル: file_uploader.php プロジェクト: Coding110/cbvideo
}
//Check file size
$file_size = @filesize($_FILES['Filedata']["tmp_name"]);
if (!$file_size || $file_size > $max_file_size_in_bytes) {
    upload_error("File exceeds the maximum allowed size");
    exit(0);
}
//Checking file type
$types_array = preg_replace('/,/', ' ', $types);
$types_array = explode(' ', $types_array);
$file_ext = strtolower(getExt($_FILES['Filedata']['name']));
if (!in_array($file_ext, $types_array)) {
    upload_error("Invalid file extension");
    exit(0);
}
move_uploaded_file($tempFile, $targetFile);
$Upload->add_conversion_queue($targetFileName, $file_directory);
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN')) {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName}");
} else {
    exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName} &> /dev/null &");
}
$status_array['success'] = 'yes';
$status_array['file_name'] = $file_name;
echo json_encode($status_array);
//function used to display error
function upload_error($error)
{
    echo json_encode(array("error" => $error));
}
コード例 #2
0
ファイル: file_uploader.php プロジェクト: reactvideos/Website
     }
     logData('moving physical file to TEMP_DIR', 'checkpoints');
     move_uploaded_file($tempFile, $targetFile);
     $Upload->add_conversion_queue($targetFileName);
     $quick_conv = config('quick_conv');
     $use_crons = config('use_crons');
     if ($quick_conv == 'yes' || $use_crons == 'no') {
         //exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
         if (stristr(PHP_OS, 'WIN')) {
             //echo php_path()." -q ".BASEDIR."/actions/video_convert_test.php $targetFileName";
             exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName}");
         } elseif (stristr(PHP_OS, 'darwin')) {
             exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName} </dev/null >/dev/null &");
         } else {
             // for ubuntu or linux
             exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$targetFileName} {$file_name} {$file_directory} > /dev/null &");
         }
     }
     echo json_encode(array("success" => "yes", "file_name" => $file_name, 'phpos' => PHP_OS));
     break;
 case "update_video":
     $Upload->validate_video_upload_form();
     $_POST['videoid'] = trim($_POST['videoid']);
     if (empty($eh->error_list)) {
         $cbvid->update_video();
     }
     if (error()) {
         echo json_encode(array('error' => error('single')));
     } else {
         echo json_encode(array('msg' => msg('single')));
     }
コード例 #3
0
ファイル: video.class.php プロジェクト: yukisky/clipbucket
 /**
  * Function used to perform several actions with a video
  */
 function action($case, $vid)
 {
     global $db, $eh;
     $vid = mysql_clean($vid);
     $video = $this->get_video_details($vid);
     if (!$video) {
         return false;
     }
     //Lets just check weathter video exists or not
     switch ($case) {
         //Activating a video
         case 'activate':
         case 'av':
         case 'a':
             $db->update(tbl("video"), array('active'), array('yes'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_act_msg"), 'm');
             if (SEND_VID_APPROVE_EMAIL == 'yes') {
                 //Sending Email
                 global $cbemail, $userquery;
                 $tpl = $cbemail->get_template('video_activation_email');
                 $user_fields = $userquery->get_user_field($video['userid'], "username,email");
                 $more_var = array('{username}' => $user_fields['username'], '{video_link}' => videoLink($video));
                 if (!is_array($var)) {
                     $var = array();
                 }
                 $var = array_merge($more_var, $var);
                 $subj = $cbemail->replace($tpl['email_template_subject'], $var);
                 $msg = nl2br($cbemail->replace($tpl['email_template'], $var));
                 //Now Finally Sending Email
                 cbmail(array('to' => $user_fields['email'], 'from' => WEBSITE_EMAIL, 'subject' => $subj, 'content' => $msg));
             }
             if (($video['broadcast'] == 'public' || $video['broadcast'] == "logged") && $video['subscription_email'] == 'pending') {
                 //Sending Subscription email in background
                 if (stristr(PHP_OS, 'WIN')) {
                     exec(php_path() . " -q " . BASEDIR . "/actions/send_subscription_email.php {$vid} ");
                 } else {
                     exec(php_path() . " -q " . BASEDIR . "/actions/send_subscription_email.php {$vid} &> /dev/null &");
                 }
             }
             break;
             //Deactivating a video
         //Deactivating a video
         case "deactivate":
         case "dav":
         case "d":
             $db->update(tbl("video"), array('active'), array('no'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_act_msg1"), 'm');
             break;
             //Featuring Video
         //Featuring Video
         case "feature":
         case "featured":
         case "f":
             $db->update(tbl("video"), array('featured', 'featured_date'), array('yes', now()), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_vdo_fr_msg"), 'm');
             break;
             //Unfeatured video
         //Unfeatured video
         case "unfeature":
         case "unfeatured":
         case "uf":
             $db->update(tbl("video"), array('featured'), array('no'), " videoid='{$vid}' OR videokey = '{$vid}' ");
             e(lang("class_fr_msg1"), 'm');
             break;
     }
 }
コード例 #4
0
ファイル: experiments.php プロジェクト: reactvideos/Website
 switch ($mode) {
     default:
         echo json_encode(array("err" => "Well hellow :/"));
         break;
     case "getPreDetails":
         $err = array();
         $msg = array();
         if (!function_exists("exec")) {
             $err[] = "<br>C'mon man! there shuld be some 'exec' functions :(";
             $err[] = "<div class=\"expErr\">Exec function does not exist</div>";
             theEnd();
         } else {
             $msg[] = "<div class=\"expOK\">Exec function exists</div>";
         }
         //testing php compatiblity
         $phpTest = shell_output(php_path() . " -q " . ADMINBASEDIR . '/lab_resources/echo.php');
         if (!$phpTest) {
             $err[] = "<br>OMG! Your host is so chipless that it doesn't even allow you to use PHP CLI , very bad!";
             $err[] = "<div class=\"expErr\">PHP CLI is not enabled</div>";
             theEnd();
         } else {
             $msg[] = "<div class=\"expOK\">PHP CLI is enabled</div>";
         }
         //now get ffmpeg details
         $ffmpegDetails = shell_output($Cbucket->configs['ffmpegpath'] . " -version ");
         if (preg_match("/ffmpeg/i", $ffmpegDetails)) {
             //$msg[] = "<br>".nl2br($ffmpegDetails);
             $msg[] = "<div class=\"expOK\">FFMPEG Exists</div>";
         } else {
             $err[] = '<br>How can human work without brain? same situation is with video conversion, no ffmpeg, no conversion.';
             $err[] = "<div class=\"expErr\">FFMPEG does not exist</div>";
コード例 #5
0
ファイル: functions.php プロジェクト: yukisky/clipbucket
/**
 * Functon used to get binary paths
 */
function get_binaries($path)
{
    if (is_array($path)) {
        $type = $path['type'];
        $path = $path['path'];
    }
    if ($type == '' || $type == 'user') {
        $path = strtolower($path);
        switch ($path) {
            case "php":
                return php_path();
                break;
            case "mp4box":
                return config("mp4boxpath");
                break;
            case "flvtool2":
                return config("flvtool2path");
                break;
            case "ffmpeg":
                return config("ffmpegpath");
                break;
        }
    } else {
        $path = strtolower($path);
        switch ($path) {
            case "php":
                $return_path = shell_output("which php");
                if ($return_path) {
                    return $return_path;
                } else {
                    return "Unable to find PHP path";
                }
                break;
            case "mp4box":
                $return_path = shell_output("which MP4Box");
                if ($return_path) {
                    return $return_path;
                } else {
                    return "Unable to find mp4box path";
                }
                break;
            case "flvtool2":
                $return_path = shell_output("which flvtool2");
                if ($return_path) {
                    return $return_path;
                } else {
                    return "Unable to find flvtool2 path";
                }
                break;
            case "ffmpeg":
                $return_path = shell_output("which ffmpeg");
                if ($return_path) {
                    return $return_path;
                } else {
                    return "Unable to find ffmpeg path";
                }
                break;
        }
    }
}
コード例 #6
0
ファイル: mass_uploader.php プロジェクト: reactvideos/Website
            e("\"" . $file_arr['title'] . "\" Has been uploaded successfully", "m");
        }
        if ($vid) {
            $dosleep = 0;
            //Moving file to temp dir and Inserting in conversion queue..
            $file_name = $cbmass->move_to_temp($file_arr, $file_key);
            $results = $Upload->add_conversion_queue($file_name);
            $str = "/" . date("Y") . "/" . date("m") . "/" . date("d") . "/";
            $str1 = date("Y") . "/" . date("m") . "/" . date("d");
            mkdir(BASEDIR . '/files/videos' . $str);
            $tbl = tbl("video");
            $fields['file_directory'] = $str1;
            $fname = explode('.', $file_name);
            $cond = 'file_name=' . '\'' . $fname[0] . '\'';
            $result = db_update($tbl, $fields, $cond);
            $result = exec(php_path() . " -q " . BASEDIR . "/actions/video_convert.php {$file_name} {$dosleep} &> /dev/null &");
            if (file_exists(CON_DIR . '/' . $file_name)) {
                unlink(CON_DIR . '/' . $file_name);
                foreach ($vtitle as &$title) {
                    $resul1 = glob(BASEDIR . '/files/videos/' . $title . ".*");
                    unlink($resul1[0]);
                }
            }
        }
    }
}
if (count($error_lists) > 0) {
    foreach ($error_lists as $e) {
        e($e);
    }
}
コード例 #7
0
ファイル: video_convert.php プロジェクト: yukisky/clipbucket
                        }
                        /**
                         * @todo : Add Filters for this params 
                         */
                        $twoPass = false;
                        if ($vid_profile['2pass'] == 'yes') {
                            $twoPass = true;
                        }
                        $params = array('format' => $vid_profile['format'], 'output_file' => $output_file, 'preset' => $vid_profile['preset'], 'height' => $vid_profile['height'], 'width' => $vid_profile['width'], 'resize' => $vid_profile['resize'], 'bitrate' => $vid_profile['video_bitrate'], 'aspect_ratio' => $vid_profile['aspect_ratio'], 'arate' => $vid_profile['audio_rate'], 'fps' => $vid_profile['video_rate'], 'abitrate' => $vid_profile['audio_bitrate'], '2pass' => $twoPass);
                        $converter->convert($params);
                        $output_details = $converter->getInfo($output_file);
                        $time_finished = time();
                        $log = $converter->log();
                        $fields = array('log' => json_encode($log), 'status' => 's', 'output_results' => json_encode($output_details), 'date_completed' => $time_finished);
                        $cbupload->update_video_file($fid, $fields);
                        unset($converter);
                        break;
                    }
                }
                $file_name = $queue['queue_name'];
                if ($file_name) {
                    exec(php_path() . " -q " . BASEDIR . "/actions/verify_videos.php {$file_name} &> /dev/null &");
                }
                if (!$convert) {
                    $cbupload->update_queue_status($queue, 's', 'File removed from queue');
                }
            }
            break;
        }
    }
}
コード例 #8
0
ファイル: video_convert.php プロジェクト: Coding110/cbvideo
    $ffmpeg = new FFMpeg($configs, $log);
    $ffmpeg->ffmpeg($orig_file);
    $ffmpeg->file_name = $tmp_file;
    //$ffmpeg->logs = $log;
    $ffmpeg->ClipBucket();
    //logData(json_encode("in end video convert"));
    //$ffmpeg->convertVideo($orig_file);
    //exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php $orig_file");
    //exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php &> /dev/null &");
    if (stristr(PHP_OS, 'WIN')) {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep}");
    } elseif (stristr(PHP_OS, 'darwin')) {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep} </dev/null >/dev/null &");
    } else {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep} &> /dev/null &");
        logData(json_encode(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep} &> /dev/null &"));
    }
    if (!isset($_GET['test'])) {
        unlink($orig_file);
    }
}
exit;
$str = "/" . date("Y") . "/" . date("m") . "/" . date("d") . "/";
$orig_file1 = BASEDIR . '/files/videos' . $str . $tmp_file . '-sd.' . $ext;
if ($orig_file1) {
    $status = "Successful";
    if (PHP_OS == "Linux") {
        $ffMpegPath = FFMPEG_BINARY;
        file_put_contents('test.txt', $ffMpegPath . " -i " . $orig_file1 . " -acodec copy -vcodec copy -y -f null /dev/null 2>&1");
        $out = shell_exec($ffMpegPath . " -i " . $orig_file1 . " -acodec copy -vcodec copy -y -f null /dev/null 2>&1");
        sleep(1);
コード例 #9
0
ファイル: video_convert.php プロジェクト: reactvideos/Website
    $ffmpeg->ffmpeg($orig_file);
    $ffmpeg->cb_combo_res = config('cb_combo_res');
    $ffmpeg->res_configurations = array('gen_240' => config('gen_240'), 'gen_360' => config('gen_360'), 'gen_480' => config('gen_480'), 'gen_720' => config('gen_720'), 'gen_1080' => config('gen_1080'));
    logData($ffmpeg->res_configurations, 'checkpoints');
    $ffmpeg->file_name = $tmp_file;
    $ffmpeg->filetune_directory = $file_directory;
    $ffmpeg->raw_path = VIDEOS_DIR . '/' . $file_directory . $_filename;
    //$ffmpeg->logs = $log;
    logData('Going to call ClipBucket Function', 'checkpoints');
    $ffmpeg->ClipBucket();
    if (stristr(PHP_OS, 'WIN')) {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep}");
    } elseif (stristr(PHP_OS, 'darwin')) {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep} </dev/null >/dev/null &");
    } else {
        exec(php_path() . " -q " . BASEDIR . "/actions/verify_converted_videos.php {$orig_file} {$dosleep} &> /dev/null &");
    }
    if (!isset($_GET['test'])) {
        unlink($orig_file);
    }
}
exit;
$str = "/" . date("Y") . "/" . date("m") . "/" . date("d") . "/";
$orig_file1 = BASEDIR . '/files/videos' . $str . $tmp_file . '-sd.' . $ext;
if ($orig_file1) {
    $status = "Successful";
    if (PHP_OS == "Linux") {
        $ffMpegPath = FFMPEG_BINARY;
        file_put_contents('test.txt', $ffMpegPath . " -i " . $orig_file1 . " -acodec copy -vcodec copy -y -f null /dev/null 2>&1");
        $out = shell_exec($ffMpegPath . " -i " . $orig_file1 . " -acodec copy -vcodec copy -y -f null /dev/null 2>&1");
        sleep(1);
コード例 #10
0
ファイル: verify_videos.php プロジェクト: yukisky/clipbucket
     if ($files) {
         foreach ($files as $file) {
             if ($file['status'] == 'f' && $file['is_original'] == 'no') {
                 $video_status = 'Failed';
                 $failed_reason = 'Video failed in conversion';
                 update_video_status($video['file_name'], $video_status, $failed_reason);
             }
         }
     }
 }
 if ($video_status == 'Successful') {
     if ($video['subscription_email'] == 'pending') {
         //Send emails...even queue then in subscription so we can
         //Send them later..
         //For now..we will use our old method..
         exec(php_path() . " -q " . BASEDIR . "/actions/send_subscription_email.php {$videoid} &> /dev/null &");
     }
     //Just incase...video duration is not updated...
     if ($video['duration'] < 1) {
         if ($files) {
             foreach ($files as $file) {
                 if ($file['status'] == 's' && $file['is_original'] == 'no') {
                     $video_status = 'Successful';
                     update_video_status($video['file_name'], $video_status);
                     $output_results = json_decode($file['output_results'], true);
                     $duration = $output_results['duration'];
                     //Update video details..
                     update_video_data($videoid, 'duration', $duration);
                     if ($duration) {
                         break;
                     }