<?php
/**
 * This file is to upload the videos
 *
 * This file is having VideoUpload class to upload the videos
 *
 * PHP version 5.0
 *
 * @category	Anova
 * @package		VideoUpload
 * @author 		shankar_76ag08
 * @copyright 	Copyright (c) 2010 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @version		SVN: $Id:
 * @since 		2008-12-19
 *
 **/
require_once('../common/configs/config.inc.php');
$CFG['lang']['include_files'][] = 'languages/%s/'.$CFG['admin']['index']['anova_module'].'/videoUpload.php';
$CFG['site']['is_module_page'] = $CFG['admin']['index']['anova_module'];
//compulsory
$CFG['mods']['is_include_only']['html_header'] = false;
$CFG['html']['is_use_header'] = false;
//$CFG['auth']['is_authenticate'] = 'members';
$CFG['is']['ajax_page'] = true;
require_once($CFG['site']['project_path'].'common/application_top.inc.php');

set_time_limit(0);
class VideoUpload extends FormHandler
	{
		/**
		 * VideoUpload::chkIsValidCaptureFile()
		 *
		 * @return
		 */
		public function chkIsValidCaptureFile()
			{
				$file_name = $this->CFG['admin']['video']['red5_flv_path'].$this->fields_arr['rid'].'.flv';
				if(1 or is_file($file_name))
					return true;
				return false;
			}

		/**
		 * VideoUpload::resetFieldsArray()
		 *
		 * @return
		 */
		public function resetFieldsArray()
			{
				$this->setFormField('rid', '');
			}
	}
//<<<<<-------------- Class VideoUpload begins ---------------//
//-------------------- Code begins -------------->>>>>//
$VideoUpload = new VideoUpload();

if(!isAjax())
	Redirect2URL(getAnovaUrl('questions', '?view=ask', 'ask/'));

$VideoUpload->setPageBlockNames(array('video_upload_form_capture'));

//default form fields and values...
$VideoUpload->resetFieldsArray();

$VideoUpload->setAllPageBlocksHide();
$VideoUpload->setPageBlockShow('video_upload_form_capture');
$VideoUpload->sanitizeFormInputs($_REQUEST);

if($VideoUpload->isFormGETed($_GET, 'upload'))
	{
		if($VideoUpload->chkIsValidCaptureFile())
			{
				$VideoUpload->setAllPageBlocksHide();
				$VideoUpload->setCommonSuccessMsg($LANG['success_uploaded']);
				$VideoUpload->setPageBlockShow('block_msg_form_success');
			}
		else
			{
				$VideoUpload->setCommonSuccessMsg($LANG['error_uploaded']);
				$VideoUpload->setPageBlockShow('block_msg_form_error');
			}
	}
//<<<<<-------------------- Code ends----------------------//
//-------------------- Page block templates begins -------------------->>>>>//

if ($VideoUpload->isShowPageBlock('video_upload_form_capture'))
	{
		$settingspath = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/quickCaptureConfigXmlCode.php?file_name='.$VideoUpload->getFormField('rid');
		$skinpath = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/files/flash/video_capture/skins/skin.xml';
		$VideoUpload->quick_recorder_path = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/files/flash/video_capture/QuickRecorder.swf?filename='.$VideoUpload->getFormField('rid').'&settingspath='.$settingspath.'&themePath='.$skinpath;
	}

//--------------------Page block templates begins-------------------->>>>>//
//include the header file
$VideoUpload->includeAjaxHeader();
//include the content of the page
setTemplateFolder('members/', $CFG['admin']['index']['anova_module']);
$smartyObj->display('videoUpload.tpl');
//include the footer of the page
//<<<<<<--------------------Page block templates Ends--------------------//
$VideoUpload->includeAjaxFooter();
?>