Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.96 KB | None | 0 0
  1. <?php
  2. defined('_VALID') or die('Restricted Access!');
  3. //Auth::checkAdmin();
  4. require '../include/function_video.php';
  5. require_once '../_mods/multiserv/_function.php';
  6.  
  7. $video  = array();
  8. $action    = (isset($_POST['a'])) ? trim($_POST['a']) : '';
  9.  
  10. // ---------------------------------------------------------
  11.  
  12. $demo = false;
  13. if($demo){
  14.     $ip = '';
  15.     $user = '';
  16.     $pass = '';
  17.     $dir = '';
  18.     $dir2 = '';
  19.     $ftp_url = '';
  20. }
  21.  
  22.  
  23. if($_POST['login'] == "1"){
  24.  
  25.     $ch         = '';
  26.     $sql        = "SELECT CHID, name FROM channel ORDER BY name ASC";
  27.     $rs         = $conn->execute($sql);
  28.     $channels   = $rs->getrows();
  29.     foreach($channels as $chan){
  30.         $ch .= '<option value="'.$chan['CHID'].'">'.$chan['name'].'</option>';
  31.     }
  32.  
  33.     $us         = '';
  34.     $sql        = "SELECT UID, username FROM signup ORDER BY username ASC";
  35.     $rs         = $conn->execute($sql);
  36.     $users      = $rs->getrows();
  37.     foreach($users as $usr){
  38.         $us .= '<option value="'.$usr['UID'].'">'.$usr['username'].'</option>';
  39.     }  
  40.  
  41.     $src_conn = (int)$_POST['src_conn'];
  42.     $smarty->assign('src_conn', $src_conn);
  43.    
  44.    
  45.     // Local Server
  46.     if($src_conn == 0){
  47.         $lsrv_dir = $_POST['lsrv_dir'];
  48.         $lsrv_url = $_POST['lsrv_url'];
  49.         $smarty->assign('lsrv_dir', $lsrv_dir);
  50.         $smarty->assign('lsrv_url', $lsrv_url);
  51.         $smarty->assign('murl', $lsrv_url);
  52.         $video = list_local_video($lsrv_dir);
  53.     }
  54.    
  55.    
  56.     // SFTP
  57.     if($src_conn == 1){
  58.         if(!function_exists('ssh2_connect')){
  59.             $err = 'No ssh2_connect function found in php!';
  60.         }else{
  61.             $arr= array();
  62.             $arr['host'] = $_POST['rsrv_host'];
  63.             $arr['port'] = $_POST['rsrv_port'];
  64.             $arr['finger'] = $_POST['rsrv_finger'];
  65.             $arr['user'] = $_POST['rsrv_user'];
  66.             $arr['pass'] = $_POST['rsrv_pass'];
  67.             $arr['path'] = $_POST['rsrv_path'];    
  68.             $smarty->assign('rsrv_host', $arr['host']);
  69.             $smarty->assign('rsrv_port', $arr['port']);
  70.             $smarty->assign('rsrv_finger', $arr['finger']);
  71.             $smarty->assign('rsrv_user', $arr['user']);
  72.             $smarty->assign('rsrv_pass', $arr['pass']);
  73.             $smarty->assign('rsrv_path', $arr['path']);
  74.             $data = list_local_root($arr);
  75.             if($data['error'] != ''){
  76.                 $errors[] = $data['error'];
  77.             }else{
  78.                 $video = $data['video'];
  79.             }
  80.         }
  81.     }
  82.    
  83.     // FTP
  84.     if($src_conn == 2){
  85.         $rr= array();
  86.         $rr['host'] = $_POST['ftp_host'];  
  87.         $rr['port'] = $_POST['ftp_port'];  
  88.         $rr['user'] = $_POST['ftp_user'];  
  89.         $rr['pass'] = $_POST['ftp_pass'];  
  90.         $rr['path'] = $_POST['ftp_path'];  
  91.         $smarty->assign('ftp_host', $rr['host']);
  92.         $smarty->assign('ftp_port', $rr['port']);
  93.         $smarty->assign('ftp_user', $rr['user']);
  94.         $smarty->assign('ftp_pass', $rr['pass']);
  95.         $smarty->assign('ftp_path', $rr['path']);
  96.         $data = list_server_video($rr);
  97.         if($data['error'] != ''){
  98.             $errors[] = $data['error'];
  99.         }else{
  100.             $video = $data['video'];
  101.         }
  102.     }
  103.    
  104.     // ------------------------------------------------------------------------------------------------
  105.  
  106.  
  107.     $css = <<<CSS
  108.         <style type="text/css">
  109.         input, select {padding:0; margin:0; height:20px;}
  110.         .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;}
  111.         .vx_box {width:100%; height:30px; border-bottom:1px solid #ccc; background:#f7f7f7; padding:0; margin:0;}
  112.         .vx_box:hover {background:#E6EBFC;}
  113.         .vx_b1 {float:left; width:22px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; border-right:1px solid #ddd;}
  114.         .vx_b2 {float:left; width:90px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd;}
  115.         .vx_b3 {float:left; width:90px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; border-right:1px solid #ddd;}
  116.         .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;}
  117.         .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;}
  118.         .vx_b6 {float:left; width:250px; height:25px; padding-left:5px; padding-top:5px; padding-right:5px; color:#777; font-size:0.84em;}
  119.         select {font-size:0.6em; color:#777; padding:1px; width:90px;}
  120.         option {font-size:0.6em;}
  121.         .sp {margin-top:3px; height:19px; overflow:hidden;}
  122.         .in {position:relative; width:150px; border:1px solid #ccc; outline:none; z-index:999;}
  123.         .smz {width:250px;}
  124.         </style>
  125. CSS;
  126.  
  127.     $js = <<<SCRIPT
  128.         <script type="text/javascript">
  129.             function edit(id,id2,n){
  130.                 var htm
  131.                 var textValue = document.getElementById(id).innerHTML;
  132.                 if(n){
  133.                     html = '<textarea class="in smz" id="editedValue" onkeyup="javascript:doClick(\'' + id + '\',\'' + id2 + '\',1,event)" onblur="javascript:save(\'' + id + '\',\'' + id2 + '\',1)">' + textValue + '</textarea>';
  134.                 }else{
  135.                     html = '<input type="text" class="in" id="editedValue" value="' + textValue + '" onkeyup="javascript:doClick(\'' + id + '\',\'' + id2 + '\',0,event)" onblur="javascript:save(\'' + id + '\',\'' + id2 + '\',0)">';
  136.                 }
  137.            
  138.                 document.getElementById(id2).innerHTML = html
  139.                 document.getElementById('editedValue').focus()
  140.                 document.getElementById('editedValue').select()
  141.             }
  142.             function save(id,id2,n){   
  143.                 var htm
  144.                 var editedValue = document.getElementById('editedValue').value
  145.            
  146.                 if(n){
  147.                     htm = '<div class="sp" id="' + id + '" onclick="javascript:edit(\'' + id + '\',\'' + id2 + '\',1)">' + editedValue + '</div>'
  148.                 }else{
  149.                     htm = '<div class="sp" id="' + id + '" onclick="javascript:edit(\'' + id + '\',\'' + id2 + '\',0)">' + editedValue + '</div>'
  150.                 }  
  151.                        
  152.            
  153.                 document.getElementById(id2).innerHTML = htm
  154.                 document.getElementById('post_' + id).value = editedValue
  155.             }  
  156.             function doClick(d1,d2,n,e){
  157.                 var key;
  158.                 if(window.event){
  159.                       key = window.event.keyCode;
  160.                 }else{
  161.                       key = e.which;
  162.                 }
  163.                 if (key == 13){
  164.                     save(d1,d2,n)
  165.                     key = 0
  166.                 }
  167.            }
  168.        
  169.         </script>
  170. SCRIPT;
  171.  
  172.  
  173.     // Build Video List here
  174.     // Good Api Version
  175.     $i=0;
  176.     $j = '';
  177.     $ls = '<div class="vx_wrap">';
  178.     $total = count($video);
  179.     for($i=0;$i<$total;$i++){
  180.  
  181.         $id = $video[$i]['id'];
  182.         $filename = $video[$i]['file'];
  183.         $filedir = $lsrv_dir.'/'.$filename;
  184.    
  185.         $keyword = 'keywords';
  186.         $description = 'description';
  187.    
  188.         $j .= '
  189.         <div class="vx_box" id="zdescription_'.$id.'">
  190.             <div class="vx_b1">
  191.                 <input type="checkbox" value="'.$id.'" name=keys[] />
  192.             </div>
  193.             <div class="vx_b2">
  194.                 <select name="post_channel_'.$id.'">
  195.                 '.$ch.'
  196.                 </select>      
  197.             </div>
  198.             <div class="vx_b3">
  199.                 <select name="post_user_'.$id.'">
  200.                 '.$us.'
  201.                 </select>      
  202.             </div>     
  203.             <div class="vx_b4" id="xtitle_'.$id.'">
  204.                 <div class="sp" id="title_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,0)">'.$filename.'</div>
  205.             </div>
  206.             <div class="vx_b5" id="xkeyword_'.$id.'">
  207.                 <div class="sp" id="keyword_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,0)">'.$keyword.'</div>
  208.             </div>     
  209.             <div class="vx_b6" id="xdescription_'.$id.'">
  210.                 <div class="sp" id="description_'.$id.'" onclick="javascript:edit(this.id,\'x\' + this.id,1)">'.$description.'</div>
  211.             </div>
  212.  
  213.             <input type="hidden" name="post_file_'.$id.'" id="post_file_'.$id.'" value="'.$filename.'"/>   
  214.             <input type="hidden" name="post_title_'.$id.'" id="post_title_'.$id.'"  value="'.$filename.'"/>
  215.             <input type="hidden" name="post_keyword_'.$id.'" id="post_keyword_'.$id.'"  value="'.$keyword.'"/> 
  216.             <input type="hidden" name="post_description_'.$id.'" id="post_description_'.$id.'"  value="'.$description.'"/> 
  217.        
  218.             <div style="clear:both;"></div>
  219.         </div>
  220.         ';
  221.  
  222.    
  223.  
  224.     }
  225.  
  226.  
  227.     $ls .= $css.$j.'</div>';
  228.     $ls = $ls.'<br/><center><input type="submit" name="submit" value="Submit"/></center>';
  229.     $html = '<form action="'.$baseurl.'/siteadmin/videos.php?m=servadd" method="post">'.$ls.'';
  230.  
  231.  
  232.    
  233.    
  234.     // ------------------------------------------------------------------------------------------------
  235.  
  236.     if(!empty($video)){
  237.         $smarty->assign('show', true);
  238.         $smarty->assign('list', $html);
  239.     }
  240.    
  241. }
  242.  
  243. // ---------------------------------------------------------
  244.  
  245. if($_POST['keys'] != ""){
  246.     $keys = $_POST['keys'];
  247.     //print_r($_POST);
  248.     // Type
  249.     $src_conn = (int)$_POST['src_conn'];
  250.    
  251.     // Local
  252.     if($src_conn == 0){
  253.         $lsrv_dir = $_POST['lsrv_dir'];
  254.         $lsrv_url = $_POST['lsrv_url'];
  255.     }
  256.    
  257.     if($src_conn == 1){
  258.         $arr = array();
  259.         $arr['host'] = $_POST['rsrv_host'];
  260.         $arr['port'] = $_POST['rsrv_port'];
  261.         $arr['finger'] = $_POST['rsrv_finger'];
  262.         $arr['user'] = $_POST['rsrv_user'];
  263.         $arr['pass'] = $_POST['rsrv_pass'];
  264.         $arr['path'] = $_POST['rsrv_path'];
  265.     }  
  266.  
  267.     if($src_conn == 2){
  268.         $rr = array();
  269.         $rr['host'] = $_POST['ftp_host'];  
  270.         $rr['port'] = $_POST['ftp_port'];  
  271.         $rr['user'] = $_POST['ftp_user'];  
  272.         $rr['pass'] = $_POST['ftp_pass'];  
  273.         $rr['path'] = $_POST['ftp_path'];  
  274.     }  
  275.  
  276.    
  277.     while (list ($key,$id) = @each ($keys)){
  278.         $file = $_POST['post_file_'.$id];
  279.         $title = $_POST['post_title_'.$id];
  280.         $keyword = $_POST['post_keyword_'.$id];
  281.         $description = $_POST['post_description_'.$id];
  282.         $channel = $_POST['post_channel_'.$id];
  283.         $uid = $_POST['post_user_'.$id];
  284.              
  285.         if (!$errors){
  286.             $sql = ""
  287.                 ." INSERT INTO video SET"
  288.                 ." UID = '" .$uid. "'"
  289.                 .", title = '" .mysql_real_escape_string($title). "'"
  290.                 .", channel = '" .$channel. "'"
  291.                 .", keyword = '" .mysql_real_escape_string($keyword). "'"
  292.                 .", space = '0'"
  293.                 .", addtime = '" .time(). "'"
  294.                 .", adddate = '" .date('Y-m-d'). "'"
  295.                 .", vkey = '" .mt_rand(). "'"
  296.                 .", type = 'public'"
  297.                 .", active = '2'"
  298.                 .", ftp_convert = 'convert'"
  299.                 .", ftp_src = '".$src."'"
  300.             ."";
  301.             $conn->execute($sql);
  302.             $video_id = mysql_insert_id();
  303.            
  304.             // File Extension
  305.             $extension = end(explode('.',$file));
  306.             // VDONAME
  307.             $vdoname = $video_id. '.' .$extension;
  308.             // FLVDONAME
  309.             $flvdoname = $video_id. '.flv';
  310.             // VDODIR
  311.             $vdo_path = $config['VDO_DIR'].'/'.$vdoname;
  312.            
  313.             // GET FILES SECTION ---------------------------------------------------------
  314.            
  315.             // Local
  316.             if($src_conn == 0){
  317.                 $src = ($lsrv_url != '') ? $lsrv_url.'/'.$file : $lsrv_dir.'/'.$file;
  318.                 $ftp_moveto = '';
  319.                 if(@copy($src,$vdo_path)){
  320.                     if($ftp_moveto != ''){
  321.                         @copy($src,$ftp_moveto);
  322.                     }
  323.                 }          
  324.             }
  325.        
  326.             // Root
  327.             if($src_conn == 1){
  328.                 $arr['source'] = $_POST['ftp_path'].'/'.$file;
  329.                 $arr['dest'] = $vdo_path;
  330.                 $ftp_moveto = '';
  331.                
  332.                 $data = get_local_root($arr);
  333.                 if($data['error'] != ''){
  334.                     $errors[0] = $data['error'];
  335.                 }
  336.             }              
  337.  
  338.  
  339.             if($src_conn == 2){
  340.                 $rr['source'] = $file;
  341.                 $rr['dest'] = $vdo_path;
  342.                 $ftp_moveto = '';
  343.                
  344.                 $data = get_server_video($rr);
  345.                 if($data['error'] != ''){
  346.                     $errors[0] = $data['error'];
  347.                 }
  348.             }  
  349.            
  350.            
  351.             $space = filesize($vdo_path);
  352.             $duration = get_video_duration($vdo_path, $video_id);
  353.             $vkey = substr(md5($video_id),11,20);
  354.             $sql = ""
  355.                 ."  UPDATE video SET"
  356.                 ."  duration = '".mysql_real_escape_string($duration)."'"
  357.                 .", vkey = '".$vkey."'"
  358.                 .", vdoname = '".mysql_real_escape_string($vdoname)."'"
  359.                 .", flvdoname = '".mysql_real_escape_string($flvdoname)."'"
  360.                 .", space = '".$space."'"
  361.                 ."  WHERE VID = '".intval($video_id)."'"
  362.                 ."  LIMIT 1";
  363.             $conn->execute($sql);      
  364.  
  365.         }  
  366.        
  367.     }
  368. }
  369.  
  370.  
  371.  
  372.  
  373. // -----------------------------------------------------------------
  374.  
  375. $smarty->assign('ip', $ip);
  376. $smarty->assign('dir', $dir);
  377. $smarty->assign('ftp_url', $ftp_url);
  378. $smarty->assign('ftp_dr', $dir);
  379. $smarty->assign('user', $user);
  380. $smarty->assign('pass', $pass);
  381.  
  382. $smarty->assign('remoteServer', $remoteServer);
  383. $smarty->assign('publicAccess', $publicAccess);
  384. $smarty->assign('videosFullPath',$videosFullPath);
  385.  
  386.  
  387. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement