Location: PHPKode > projects > OSShare > osshare-project-v1.0.1/app/controllers/sitesettings_controller.php
<?php
/*
OsShare v1 , 
Coded By Paimpozhil B. , SaravanaKumar M.S.
*/
class SitesettingsController extends AppController {
	var $layout = 'admin';
	var $name = 'Sitesettings';
	var $helpers = array('Html', 'Form','Javascript','Ajax' );
	var $uses = array('Sitesetting','Slaveserver');

	function index() {
		//$this->Session->setFlash('Settings');
		$this->redirect(array('action'=>'edit','id'=>1), null, true);	
	}

	function clear_cache()
	{
				clearCache();
		$this->Session->setFlash('All Cache Cleared');
				$this->redirect(array('action'=>'index'), null, true);
		
	}
	function add() {
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$this->Sitesetting->create();
			if($this->Sitesetting->save($this->data)) {
				$this->Session->setFlash('The Sitesetting has been saved');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Sitesetting could not be saved. Please, try again.');
			}
		}
		$slaves = $this->Slaveserver->find('list');
		$this->set(compact('slaves'));
		$pics = array("ImageMagick","GD");
		$this->set('pics',$pics);
	}

	function edit($id = null) {
		if(!$id && empty($this->data)) {
			$this->Session->setFlash('Invalid Sitesetting');
			$this->redirect(array('action'=>'index'), null, true);
		}
		if(!empty($this->data)) {
			$this->cleanUpFields();
			$dimensionarr =  explode("x",$this->data["Sitesetting"]["VideoDimensions"]);
			$this->data["Sitesetting"]["VideoHeight"] = $dimensionarr[1];
			$this->data["Sitesetting"]["VideoWidth"] = $dimensionarr[0];
			if($this->data["Sitesetting"]["PictureSoftware"] == "GD")
				$this->data["Sitesetting"]["PictureSoftware"] == "GD";
			else
				$this->data["Sitesetting"]["PictureSoftware"] == "ImageMagick";
			if($this->Sitesetting->save($this->data)) {
				$this->Session->setFlash('The Sitesetting saved');
				clearCache('SiteSettings');
				$this->redirect(array('action'=>'index'), null, true);
			} else {
				$this->Session->setFlash('The Sitesetting could not be saved. Please, try again.');
			}
		}
		if(empty($this->data)) {
			$this->data = $this->Sitesetting->read(null, $id);
		}
		$slaves = $this->Slaveserver->find('list');
		$this->set(compact('slaves'));
		$this->set('selecteddimension',$this->data["Sitesetting"]["VideoWidth"] . 'x' . $this->data["Sitesetting"]["VideoHeight"]);
//		$pics = array(0=>"ImageMagick",1=>"GD");
//		$this->set('pics',$pics);
		$pics["GD"] = "GD";
		$pics["ImageMagick"] = "ImageMagick";
		$this->set('pics',$pics);
		
		//Get dir
		$layoutarray = array(DS => DS);
		if ($handle = opendir(LAYOUTS)) {
   		 while (false !== ($file = readdir($handle))) {
     	   if ($file != "." && $file != ".." && is_dir(LAYOUTS . DS . $file) && $file != ".svn" ) {
         $layoutarray[$file] = $file;
        }
    }
    closedir($handle);
	}
	
		$this->set('skins',$layoutarray);
	}
	function testffmpeg()
	{
	$this->layout='ajax';
	$uploadDir = WWW_ROOT . 'files' . DS;
	$uploadfilepath = $uploadDir . "TestAVI.AVI";
	$videoresolution = $this->ssettings['VideoWidth'] . 'x' . $this->ssettings['VideoHeight'];
	$ffmpegpath = $this->ssettings["FFMPEGPath"];
	$encodecmd = $ffmpegpath . " -i " . 	$uploadfilepath . " " . $this->ssettings['FFmpegArgs'] . " -y " . " -s " . $videoresolution  . " " . $uploadfilepath . ".flv";
	//$ret =  shell_exec($encodecmd);
	$ret = $this->runExternal($encodecmd,$code);
	
//echo( nl2br($ret));

	Configure::write('debug',0);
	$this->set('result',$ret);
	}
}
?>
Return current item: OSShare