upload_opt_list['embed_code_div'] = array( 'title' => 'Embed Code', 'load_func' => 'load_embed_form', ); if(!function_exists('validate_embed_code')) { /** * Function used create duration from input * @param DURATION */ function validate_duration($time) { global $LANG; if(empty($time)) return true; $time = explode(':',$time); if(count($time)>0) { $sec = 0; $total = count($time); if($total==3) { $hrs = $time[0]*60*60; $mins = $time[1]*60; $secs = $time[2]; }elseif($total==2) { $hrs = 0; $mins = $time[0]*60; $secs = $time[1]; }else{ $hrs = 0; $mins = 0; $secs = $time[0]; } $sec = $hrs+$mins+$secs; if(!empty($sec)) return $sec; else e(lang('invalid_duration')); }else{ if(is_numeric($time)) return $time; else e(lang('invalid_duration')); } } /** * Function used to validate embed code */ function validate_embed_code($val) { if(empty($val) || $val=='none') { return 'none'; }else{ //Striping Slasshes as they are not required $val = stripslashes($val); //Removing spaces and non required code $val = preg_replace(array("/\r+/","/\n+/","/\t+/"),"",$val); //Removing Links $val = preg_replace('/(.*)<\/a>/','',$val); //Removing JS Codes $val = preg_replace('/]*?>.*?<\/script>/si','',$val); //Removing Iframes $val = preg_replace('/<\/iframe>/','',$val); //Removing Img Tags $val = preg_replace('//','',$val); if(!stristr($val,''; echo 'Please enter embed code
'; echo ''; echo '

'; echo 'Please Enter video duration
'; echo '
'; echo '

'; echo 'Please select video thumb
'; echo ''; echo ''; echo '
'; echo ''; } $embed_field_array['embed_code'] = array ( 'title' =>'Embed Code', 'name' =>'embed_code', 'db_field' =>'embed_code', 'required' =>'no', 'validate_function'=>'validate_embed_code', 'use_func_val' => true, 'clean_func' => array('htmlspecialchars'), 'type' => 'textarea', ); $embed_field_array['duration'] = array ( 'title' =>'Video duration', 'name' =>'duration', 'db_field' =>'duration', 'required' =>'no', 'validate_function'=>'validate_duration', 'use_func_val' => true, 'display_admin' => 'no_display', ); $embed_field_array['thumb_file_field'] = array ( 'title' => 'Thumb File', 'type' => 'fileField', 'name' => 'thumb_file', 'required' => 'no', 'validate_function' => 'upload_thumb', 'display_admin' => 'no_display', ); function upload_thumb($array) { global $file_name,$LANG; //Get File Name $file = $array['name']; $ext = getExt($file); $image = new ResizeImage(); if(!empty($file) && file_exists($array['tmp_name'])) { if($image->ValidateImage($array['tmp_name'],$ext)){ $file = BASEDIR.'/files/thumbs/'.$_POST['file_name'].'.'.$ext; if(!file_exists($file)) { move_uploaded_file($array['tmp_name'],$file); $image->CreateThumb($file,$file,THUMB_WIDTH,$ext,THUMB_HEIGHT,false); } }else{ e(lang('vdo_thumb_up_err')); } }else{ return true; } } /** * Function used to check embed video * if video is embeded , it will check its code * if everthing goes ok , it will change its status to successfull * @param VID */ function embed_video_check($vid) { global $myquery,$db; $vdetails = $myquery->get_video_details($vid); if(!empty($vdetails['embed_code']) && $vdetails['embed_code'] !=' ' && $vdetails['embed_code'] !='none') { $db->Execute("UPDATE video SET status='Successful' WHERE videoid='$vid'"); } } /** * Function used to play embed code * @param Video details */ function play_embed_video($data) { global $swfobj; $vdetails = $data['vdetails']; $file = get_video_file($vdetails,false,false); if(!$file || $file=='no_video.flv') { if(!empty($vdetails['embed_code']) && $vdetails['embed_code']!='none') { $embed_code = $vdetails['embed_code']; //Replacing Height And Width $h_w_p = array("{Width}","{Height}"); $h_w_r = array($data['width'],$data['height']); $embed_code = str_replace($h_w_p,$h_w_r,$embed_code); $swfobj->EmbedCode(unhtmlentities($embed_code),$data['player_div']); return $swfobj->code; } }else{ return false; } } register_after_video_upload_action('embed_video_check'); register_custom_upload_field($embed_field_array); $Cbucket->add_header(PLUG_DIR.'/embed_video_mod/header.html'); register_actions_play_video('play_embed_video'); } ?>