Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('_VALID') or die('Restricted Access!');
- //Auth::checkAdmin();
- require '../include/function_video.php';
- require_once '../_mods/multiserv/_function.php';
- $video = array();
- $action = (isset($_POST['a'])) ? trim($_POST['a']) : '';
- // ---------------------------------------------------------
- $demo = false;
- if($demo){
- $ip = '';
- $user = '';
- $pass = '';
- $dir = '';
- $dir2 = '';
- $ftp_url = '';
- }
- if($_POST['login'] == "1"){
- $ch = '';
- $sql = "SELECT CHID, name FROM channel ORDER BY name ASC";
- $rs = $conn->execute($sql);
- $channels = $rs->getrows();
- foreach($channels as $chan){
- $ch .= '<option value="'.$chan['CHID'].'">'.$chan['name'].'</option>';
- }
- $us = '';
- $sql = "SELECT UID, username FROM signup ORDER BY username ASC";
- $rs = $conn->execute($sql);
- $users = $rs->getrows();
- foreach($users as $usr){
- $us .= '<option value="'.$usr['UID'].'">'.$usr['username'].'</option>';
- }
- $src_conn = (int)$_POST['src_conn'];
- $smarty->assign('src_conn', $src_conn);
- // Local Server
- if($src_conn == 0){
- $lsrv_dir = $_POST['lsrv_dir'];
- $lsrv_url = $_POST['lsrv_url'];
- $smarty->assign('lsrv_dir', $lsrv_dir);
- $smarty->assign('lsrv_url', $lsrv_url);
- $smarty->assign('murl', $lsrv_url);
- $video = list_local_video($lsrv_dir);
- }
- // SFTP
- if($src_conn == 1){
- if(!function_exists('ssh2_connect')){
- $err = 'No ssh2_connect function found in php!';
- }else{
- $arr= array();
- $arr['host'] = $_POST['rsrv_host'];
- $arr['port'] = $_POST['rsrv_port'];
- $arr['finger'] = $_POST['rsrv_finger'];
- $arr['user'] = $_POST['rsrv_user'];
- $arr['pass'] = $_POST['rsrv_pass'];
- $arr['path'] = $_POST['rsrv_path'];
- $smarty->assign('rsrv_host', $arr['host']);
- $smarty->assign('rsrv_port', $arr['port']);
- $smarty->assign('rsrv_finger', $arr['finger']);
- $smarty->assign('rsrv_user', $arr['user']);
- $smarty->assign('rsrv_pass', $arr['pass']);
- $smarty->assign('rsrv_path', $arr['path']);
- $data = list_local_root($arr);
- if($data['error'] != ''){
- $errors[] = $data['error'];
- }else{
- $video = $data['video'];
- }
- }
- }
- // FTP
- if($src_conn == 2){
- $rr= array();
- $rr['host'] = $_POST['ftp_host'];
- $rr['port'] = $_POST['ftp_port'];
- $rr['user'] = $_POST['ftp_user'];
- $rr['pass'] = $_POST['ftp_pass'];
- $rr['path'] = $_POST['ftp_path'];
- $smarty->assign('ftp_host', $rr['host']);
- $smarty->assign('ftp_port', $rr['port']);
- $smarty->assign('ftp_user', $rr['user']);
- $smarty->assign('ftp_pass', $rr['pass']);
- $smarty->assign('ftp_path', $rr['path']);
- $data = list_server_video($rr);
- if($data['error'] != ''){
- $errors[] = $data['error'];
- }else{
- $video = $data['video'];
- }
- }
- // ------------------------------------------------------------------------------------------------
- $css = <<<CSS
- <style type="text/css">
- input, select {padding:0; margin:0; height:20px;}
- .vx_wrap {z-index:0; width:100%; border-left:1px solid #ccc; border-top:1px solid #ccc; border-right:1px solid #ccc; padding:0; margin:0;}
- .vx_box {width:100%; height:30px; border-bottom:1px solid #ccc; background:#f7f7f7; padding:0; margin:0;}
- .vx_box:hover {background:#E6EBFC;}
- .vx_b1 {float:left; width:22px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; border-right:1px solid #ddd;}
- .vx_b2 {float:left; width:90px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd;}
- .vx_b3 {float:left; width:90px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd;}
- .vx_b4 {float:left; width:150px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd; font-size:0.84em;}
- .vx_b5 {float:left; width:150px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd; font-size:0.84em;}
- .vx_b6 {float:left; width:250px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; font-size:0.84em;}
- select {font-size:0.6em; color:#777; padding:1px; width:90px;}
- option {font-size:0.6em;}
- .sp {margin-top:3px; height:19px; overflow:hidden;}
- .in {position:relative; width:150px; border:1px solid #ccc; outline:none; z-index:999;}
- .smz {width:250px;}
- </style>
- CSS;
- $js = <<<SCRIPT
- <script type="text/javascript">
- function edit(id,id2,n){
- var htm
- var textValue = document.getElementById(id).innerHTML;
- if(n){
- html = '<textarea class="in smz" id="editedValue" onkeyup="javascript:doClick(\'' + id + '\',\'' + id2 + '\',1,event)" onblur="javascript:save(\'' + id + '\',\'' + id2 + '\',1)">' + textValue + '</textarea>';
- }else{
- html = '<input type="text" class="in" id="editedValue" value="' + textValue + '" onkeyup="javascript:doClick(\'' + id + '\',\'' + id2 + '\',0,event)" onblur="javascript:save(\'' + id + '\',\'' + id2 + '\',0)">';
- }
- document.getElementById(id2).innerHTML = html
- document.getElementById('editedValue').focus()
- document.getElementById('editedValue').select()
- }
- function save(id,id2,n){
- var htm
- var editedValue = document.getElementById('editedValue').value
- if(n){
- htm = '<div class="sp" id="' + id + '" onclick="javascript:edit(\'' + id + '\',\'' + id2 + '\',1)">' + editedValue + '</div>'
- }else{
- htm = '<div class="sp" id="' + id + '" onclick="javascript:edit(\'' + id + '\',\'' + id2 + '\',0)">' + editedValue + '</div>'
- }
- document.getElementById(id2).innerHTML = htm
- document.getElementById('post_' + id).value = editedValue
- }
- function doClick(d1,d2,n,e){
- var key;
- if(window.event){
- key = window.event.keyCode;
- }else{
- key = e.which;
- }
- if (key == 13){
- save(d1,d2,n)
- key = 0
- }
- }
- </script>
- SCRIPT;
- // Build Video List here
- // Good Api Version
- $i=0;
- $j = '';
- $ls = '<div class="vx_wrap">';
- $total = count($video);
- for($i=0;$i<$total;$i++){
- $id = $video[$i]['id'];
- $filename = $video[$i]['file'];
- $filedir = $lsrv_dir.'/'.$filename;
- $keyword = 'keywords';
- $description = 'description';
- $j .= '
- <div class="vx_box" id="zdescription_'.$id.'">
- <div class="vx_b1">
- <input type="checkbox" value="'.$id.'" name=keys[] />
- </div>
- <div class="vx_b2">
- <select name="post_channel_'.$id.'">
- '.$ch.'
- </select>
- </div>
- <div class="vx_b3">
- <select name="post_user_'.$id.'">
- '.$us.'
- </select>
- </div>
- <div class="vx_b4" id="xtitle_'.$id.'">
- <div class="sp" id="title_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,0)">'.$filename.'</div>
- </div>
- <div class="vx_b5" id="xkeyword_'.$id.'">
- <div class="sp" id="keyword_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,0)">'.$keyword.'</div>
- </div>
- <div class="vx_b6" id="xdescription_'.$id.'">
- <div class="sp" id="description_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,1)">'.$description.'</div>
- </div>
- <input type="hidden" name="post_file_'.$id.'" id="post_file_'.$id.'" value="'.$filename.'"/>
- <input type="hidden" name="post_title_'.$id.'" id="post_title_'.$id.'" value="'.$filename.'"/>
- <input type="hidden" name="post_keyword_'.$id.'" id="post_keyword_'.$id.'" value="'.$keyword.'"/>
- <input type="hidden" name="post_description_'.$id.'" id="post_description_'.$id.'" value="'.$description.'"/>
- <div style="clear:both;"></div>
- </div>
- ';
- }
- $ls .= $css.$j.'</div>';
- $ls = $ls.'<br/><center><input type="submit" name="submit" value="Submit"/></center>';
- $html = '<form action="'.$baseurl.'/siteadmin/videos.php?m=servadd" method="post">'.$ls.'';
- // ------------------------------------------------------------------------------------------------
- if(!empty($video)){
- $smarty->assign('show', true);
- $smarty->assign('list', $html);
- }
- }
- // ---------------------------------------------------------
- if($_POST['keys'] != ""){
- $keys = $_POST['keys'];
- //print_r($_POST);
- // Type
- $src_conn = (int)$_POST['src_conn'];
- // Local
- if($src_conn == 0){
- $lsrv_dir = $_POST['lsrv_dir'];
- $lsrv_url = $_POST['lsrv_url'];
- }
- if($src_conn == 1){
- $arr = array();
- $arr['host'] = $_POST['rsrv_host'];
- $arr['port'] = $_POST['rsrv_port'];
- $arr['finger'] = $_POST['rsrv_finger'];
- $arr['user'] = $_POST['rsrv_user'];
- $arr['pass'] = $_POST['rsrv_pass'];
- $arr['path'] = $_POST['rsrv_path'];
- }
- if($src_conn == 2){
- $rr = array();
- $rr['host'] = $_POST['ftp_host'];
- $rr['port'] = $_POST['ftp_port'];
- $rr['user'] = $_POST['ftp_user'];
- $rr['pass'] = $_POST['ftp_pass'];
- $rr['path'] = $_POST['ftp_path'];
- }
- while (list ($key,$id) = @each ($keys)){
- $file = $_POST['post_file_'.$id];
- $title = $_POST['post_title_'.$id];
- $keyword = $_POST['post_keyword_'.$id];
- $description = $_POST['post_description_'.$id];
- $channel = $_POST['post_channel_'.$id];
- $uid = $_POST['post_user_'.$id];
- if (!$errors){
- $sql = ""
- ." INSERT INTO video SET"
- ." UID = '" .$uid. "'"
- .", title = '" .mysql_real_escape_string($title). "'"
- .", channel = '" .$channel. "'"
- .", keyword = '" .mysql_real_escape_string($keyword). "'"
- .", space = '0'"
- .", addtime = '" .time(). "'"
- .", adddate = '" .date('Y-m-d'). "'"
- .", vkey = '" .mt_rand(). "'"
- .", type = 'public'"
- .", active = '2'"
- .", ftp_convert = 'convert'"
- .", ftp_src = '".$src."'"
- ."";
- $conn->execute($sql);
- $video_id = mysql_insert_id();
- // File Extension
- $extension = end(explode('.',$file));
- // VDONAME
- $vdoname = $video_id. '.' .$extension;
- // FLVDONAME
- $flvdoname = $video_id. '.flv';
- // VDODIR
- $vdo_path = $config['VDO_DIR'].'/'.$vdoname;
- // GET FILES SECTION ---------------------------------------------------------
- // Local
- if($src_conn == 0){
- $src = ($lsrv_url != '') ? $lsrv_url.'/'.$file : $lsrv_dir.'/'.$file;
- $ftp_moveto = '';
- if(@copy($src,$vdo_path)){
- if($ftp_moveto != ''){
- @copy($src,$ftp_moveto);
- }
- }
- }
- // Root
- if($src_conn == 1){
- $arr['source'] = $_POST['ftp_path'].'/'.$file;
- $arr['dest'] = $vdo_path;
- $ftp_moveto = '';
- $data = get_local_root($arr);
- if($data['error'] != ''){
- $errors[0] = $data['error'];
- }
- }
- if($src_conn == 2){
- $rr['source'] = $file;
- $rr['dest'] = $vdo_path;
- $ftp_moveto = '';
- $data = get_server_video($rr);
- if($data['error'] != ''){
- $errors[0] = $data['error'];
- }
- }
- $space = filesize($vdo_path);
- $duration = get_video_duration($vdo_path, $video_id);
- $vkey = substr(md5($video_id),11,20);
- $sql = ""
- ." UPDATE video SET"
- ." duration = '".mysql_real_escape_string($duration)."'"
- .", vkey = '".$vkey."'"
- .", vdoname = '".mysql_real_escape_string($vdoname)."'"
- .", flvdoname = '".mysql_real_escape_string($flvdoname)."'"
- .", space = '".$space."'"
- ." WHERE VID = '".intval($video_id)."'"
- ." LIMIT 1";
- $conn->execute($sql);
- }
- }
- }
- // -----------------------------------------------------------------
- $smarty->assign('ip', $ip);
- $smarty->assign('dir', $dir);
- $smarty->assign('ftp_url', $ftp_url);
- $smarty->assign('ftp_dr', $dir);
- $smarty->assign('user', $user);
- $smarty->assign('pass', $pass);
- $smarty->assign('remoteServer', $remoteServer);
- $smarty->assign('publicAccess', $publicAccess);
- $smarty->assign('videosFullPath',$videosFullPath);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement