195 lines
4.8 KiB
PHP
195 lines
4.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/* $Id: user_video_upload.php 131 2009-03-22 00:54:31Z john $ */
|
||
|
|
|
||
|
|
$page = "video_group1";
|
||
|
|
include "header.php";
|
||
|
|
|
||
|
|
$task = ( !empty($_POST['task']) ? $_POST['task'] : ( !empty($_GET['task']) ? $_GET['task'] : 'agree' ) );
|
||
|
|
$video_id = ( !empty($_POST['video_id']) ? $_POST['video_id'] : ( !empty($_GET['video_id']) ? $_GET['video_id'] : NULL ) );
|
||
|
|
$video_type = ( !empty($_POST['video_type']) ? $_POST['video_type'] : ( !empty($_GET['video_type']) ? $_GET['video_type'] : 0 ) );
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// User may not upload videos
|
||
|
|
|
||
|
|
|
||
|
|
if ($user->user_info["user_id"]==0) {
|
||
|
|
$page = "error";
|
||
|
|
$smarty->assign('error_header', 11010601);
|
||
|
|
$smarty->assign('error_message', $error_message);
|
||
|
|
$smarty->assign('error_submit', 11010602);
|
||
|
|
include "footer.php";
|
||
|
|
}
|
||
|
|
|
||
|
|
// CREATE VIDEO OBJECT
|
||
|
|
$video = new se_video($user->user_info['user_id'], $video_id);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// SET RESULT AND ERROR VARS
|
||
|
|
$result = FALSE;
|
||
|
|
$is_error = 0;
|
||
|
|
$show_uploader = 1;
|
||
|
|
$file_result = array();
|
||
|
|
$max_uploads = 1;
|
||
|
|
|
||
|
|
|
||
|
|
if( $task == "remove" )
|
||
|
|
{
|
||
|
|
$user->user_intro_delete();
|
||
|
|
$user->user_lastupdate();
|
||
|
|
$user->user_info["introvid"]="";
|
||
|
|
$user->user_info["introapproved"]="0";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if( $task=="upload" && $video->video_exists && !empty($video->video_info['video_uploaded']) )
|
||
|
|
{
|
||
|
|
header("Location: user_video.php");
|
||
|
|
exit();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if( $task=="doupload" )
|
||
|
|
{
|
||
|
|
// mail("leprakhauns@gmail.com", "RRR", $video_id);
|
||
|
|
$isAjax = $_POST['isAjax'];
|
||
|
|
$file_result = Array();
|
||
|
|
|
||
|
|
// WORKAROUND FOR FLASH UPLOADER
|
||
|
|
if($_FILES['file1']['type'] == "application/octet-stream" && $isAjax)
|
||
|
|
{
|
||
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($user->level_info['level_album_mimes'])));
|
||
|
|
$_FILES['file1']['type'] = $file_types[0];
|
||
|
|
}
|
||
|
|
|
||
|
|
for( $f=1; $f<=$max_uploads; $f++ )
|
||
|
|
{
|
||
|
|
$fileid = "file".$f;
|
||
|
|
if( empty($_FILES[$fileid]['name']))
|
||
|
|
continue;
|
||
|
|
|
||
|
|
$file_result[$fileid] = $video->intro_upload("file1");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$file_result[$fileid]['file_name'] = $file_result[$fileid]['name'] = $_FILES[$fileid]['name'];
|
||
|
|
|
||
|
|
if( !$file_result[$fileid]['is_error'] )
|
||
|
|
{
|
||
|
|
$file_result[$fileid]['message'] = 1000086;
|
||
|
|
$result = TRUE;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$file_result[$fileid]['message'] = $file_result[$fileid]['is_error'];
|
||
|
|
}
|
||
|
|
SE_Language::_preload($file_result[$fileid]['message']);
|
||
|
|
}
|
||
|
|
|
||
|
|
// OUTPUT JSON RESULT
|
||
|
|
if( $isAjax )
|
||
|
|
{
|
||
|
|
SE_Language::load();
|
||
|
|
|
||
|
|
if( $result )
|
||
|
|
{
|
||
|
|
$result = "success";
|
||
|
|
$size = sprintf(SE_Language::_get($file_result['file1']['message']), $file_result['file1']['name']);
|
||
|
|
$error = null;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$result = "failure";
|
||
|
|
$error = sprintf(SE_Language::_get($file_result['file1']['message']), $file_result['file1']['name']);
|
||
|
|
$size = null;
|
||
|
|
}
|
||
|
|
if(!headers_sent()) { header('Content-type: application/json'); }
|
||
|
|
echo json_encode(array('result' => $result, 'error' => $error, 'size' => $size));
|
||
|
|
//exit();
|
||
|
|
}
|
||
|
|
|
||
|
|
// SHOW PAGE WITH RESULTS
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$show_uploader = FALSE;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if( !$file_result['file1']['is_error'] )
|
||
|
|
{
|
||
|
|
$task = "uploaded";
|
||
|
|
//header("Location: intro_upload.php");
|
||
|
|
//exit();
|
||
|
|
}
|
||
|
|
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$task = "uploaded";
|
||
|
|
$is_error = $file_result['file1']['is_error'];
|
||
|
|
}
|
||
|
|
$task = "uploaded";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// SET INPUTS
|
||
|
|
$inputs = Array('video_id' => $video->video_info['video_id'], 'task' => 'doupload');
|
||
|
|
|
||
|
|
$smarty->assign('show_uploader', $show_uploader);
|
||
|
|
$smarty->assign('session_id', session_id());
|
||
|
|
$smarty->assign('upload_token', $_SESSION['upload_token']);
|
||
|
|
$smarty->assign('file_result', $file_result);
|
||
|
|
$smarty->assign('inputs', $inputs);
|
||
|
|
$smarty->assign('allowed_exts', str_replace(",", ", ", $user->level_info['level_video_exts']));
|
||
|
|
|
||
|
|
if(SE_DEBUG){
|
||
|
|
}
|
||
|
|
// SET UPLOADER PARAMS
|
||
|
|
$smarty->assign('user_upload_max_files', 1);
|
||
|
|
$smarty->assign('user_upload_max_size', $user->level_info['level_video_maxsize']);
|
||
|
|
|
||
|
|
$smarty->assign('user_upload_allowed_extensions', $user->level_info['level_video_exts']);
|
||
|
|
// DO UPLOAD PAGE STUFF
|
||
|
|
if( $task=="upload" )
|
||
|
|
{
|
||
|
|
// GET MAX FILESIZE ALLOWED
|
||
|
|
|
||
|
|
|
||
|
|
// START NEW SESSION AND SET SESSION VARS FOR UPLOADER
|
||
|
|
// Backwards compatibility with <SE3.10
|
||
|
|
if( !session_id() ) session_start();
|
||
|
|
if( !empty($_COOKIE['user_id']) )
|
||
|
|
{
|
||
|
|
$_SESSION['ul_user_id'] = $_COOKIE['user_id'];
|
||
|
|
$_SESSION['ul_user_email'] = $_COOKIE['user_email'];
|
||
|
|
$_SESSION['ul_user_password'] = $_COOKIE['se_user_pass'];
|
||
|
|
}
|
||
|
|
|
||
|
|
// Keep with 3.10+
|
||
|
|
$_SESSION['upload_token'] = md5(uniqid(rand(), true));
|
||
|
|
$_SESSION['action'] = "user_video_upload.php";
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$smarty->assign('video_id', $video_id);
|
||
|
|
$smarty->assign('user_upload_max_files', 1);
|
||
|
|
// ASSIGN VARIABLES AND SHOW UPLOAD FILES PAGE
|
||
|
|
$smarty->assign('is_error', $is_error);
|
||
|
|
$smarty->assign('error1', $error1);
|
||
|
|
$smarty->assign('task', $task);
|
||
|
|
$smarty->assign('video_last_url', $_POST['video_url']);
|
||
|
|
$smarty->assign_by_ref('video', $video);
|
||
|
|
include "footer.php";
|
||
|
|
?>
|