Exemple #1
0
<?
$po = WGParseFile($APPL['file']['path']);
if (!$po['F']) return;
$st=@file_get_contents($po['f']);
$st=json_decode($st,true);
if (!is_array($st)) FatalError("Invalid stream info file");

$t=str_replace(array(".youtube\n","\n"),'',$APPL['file']['filename']."\n");
if (isset($st['t'])) $t=$st['t'];

Window($t,"/bin/mime/ico/youtube.png",580,360);
?><div style="width: 561px; height: 316px; margin: auto; padding-top: 4px;">
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php 
echo htmlspecialchars($st['v'], ENT_QUOTES);
?>
" frameborder="0" allowfullscreen></iframe>
</div>
<?
endWin();
?>
Exemple #2
0
function execApp($ex,$action=AJ_SHELL) {
	global $CMD;
	global $OUTJSON;
	global $APPL;
	global $DBH;
	global $JSON;
	global $WEBGUI;	
	global $WGData;
	
	if (!is_array($ex)) $ex = WGParseFile($ex);
	if ($ex===false) FatalError("Invalid file");
	if (!$ex['D']) FatalError("E5 Invalid application");
	
	$lang=$_SESSION['WGLang'] ? $_SESSION['WGLang'] : '_D_';
		
	$rvar = array(
		'FILE'	=> $ex['w'],
		'PATH'	=> pathinfo($ex['w'],PATHINFO_DIRNAME),
		'URL'	=> @$JSON['url'])
		;
	
	if ($ex['D']) $rvar['APPPATH']=rtrim($ex['w'],'/').'/'; else $rvar['APPPATH']=rtrim($rvar['PATH'],'/').'/';
	
	$mf = json_decode( @file_get_contents($ex['f'].'/manifest.json') , true);
	if (!is_array($mf)) FatalError("Invalid Manifest");
	
	$x = $ex['f'].'/lang';
	if (file_exists($x) and is_dir($x)) {
		list($y)=explode('-',$lang,2);
		foreach(array($lang,$y,'_D_') as $kf) {
			$y = $x . '/'. $kf.'.json';
			
			if (file_exists($y)) {
				$x = @file_get_contents($y);
				$x = json_decode($x,true);
				if (!is_array($x)) FatalError("Can't load lang `$kf`");
				$rvar=array_merge($rvar,$x);
				$x=null;
				break;
				}
			}
		}
	
	$WEBGUI['rvar']=$rvar;
	
	$x = $ex['f'].'/'.$mf['ico'];
	if (file_exists($x)) $x=$ex['w'].'/'.$mf['ico']; else $x=null;
	
	//--form

	endWin();
	
	Window(
		$mf['title'], 
		$x, 
		$mf['w'] ? $mf['w'] : 320 ,
		$mf['h'] ? $mf['h'] : 240 )
		;
	
	if (@$mf['autoResize']) WGAutoResizeWin();
	
	if (isset($mf['winType'])) {
		if (is_numeric($mf['winType'])) $WEBGUI['win']['winType']=$mf['winType']; else {
			if ($mf['winType']=='nosize') $WEBGUI['win']['winType'] = WIN_NOSIZE;
			if ($mf['winType']=='dialog') $WEBGUI['win']['winType'] = WIN_DIALOG;
			if ($mf['winType']=='normal') $WEBGUI['win']['winType'] = WIN_NORMAL;
			if ($mf['winType']=='popup') $WEBGUI['win']['winType'] = WIN_POPUP;
			}
		}
		
	if (isset($mf['pox'])) {
			if (!is_numeric($mf['pox'])) {
				if ($mf['pox']=='center') 
					$mf['pox']=POX_CENTER; 
					else if ($mf['pox']=='rev') 
					$mf['pox']=POX_RB;
					else $mf['pox']=POX_NORMAL;
				}
			setWindowPox(
			$mf['pox'],
			isset($mf['x']) ? $mf['x'] : false,
			isset($mf['y']) ? $mf['y'] : false)
			;
		}
	
	if ($action == AJ_SHELL or $action == AJ_DIALOG) {
		$hdc=WGSNew($ex['w'], isset($mf['name']) ? $mf['name'] : false);
		$APPL['hdc']=$hdc;
		$APPL['asNew']=true;
		$APPL['url']=$ex['w']; 
		} else $hdc=$APPL['hdc'];
		
	setWindowContext($hdc,$mf['name'] ? $mf['name'] : false,$ex['w']);
		
	$WEBGUI['win']['data'] = WGSLoad($hdc,$ex['w'],isset($mf['name']) ? $mf['name'] : false);

	if (is_array($rvar) and ($action==AJ_SHELL or $action==AJ_DIALOG)) {
		if (isset($rvar['win']) and is_array($rvar['win'])) $WEBGUI['win']['winLang'] = $rvar['win'];
		if (file_exists($ex['f'].'/style.css')) WGWinCss($ex['w'].'/style.css',$rvar);
		if (isset($rvar['_title'])) $WEBGUI['win']['title'] = $rvar['_title'];
		}
			
	$f = $ex['f'].'/event.php';
	if (file_exists($f)) {
		WGRequirePHP($f,$rvar);
		
		$fn=false;
		
		if ($action==AJ_POST) {
			$fn='form_'.@$JSON['frm'].'_post';
			if (!function_exists($fn)) $fn='form_'.$APPL['act'].'_post'; 
			$WEBGUI['win']['data'][$APPL['act']]=$JSON['par'];
			}
			
		if ($action==AJ_WINAJAX) $fn='ajax_'.$APPL['api'];
		if ($action==AJ_EVENT) $fn='event_'.$APPL['api'];
		if (($action==AJ_SHELL || $action==AJ_DIALOG) && $APPL['act']!='') $fn='load_'.$APPL['act'];
		if (($action==AJ_SHELL || $action==AJ_DIALOG) && $APPL['act']=='') $fn='winMain';
		
		if ($fn and function_exists($fn)) {
			if (isset($WEBGUI['form']) and isset($JSON['frm']) and $JSON['frm']!='') {
				if (!isset($WEBGUI['form'][ $JSON['frm'] ])) FatalError("Unknown form `".$JSON['frm']."`");
				$formData=$JSON['par'];
				$err = WGFormCheck($WEBGUI['form'][ $JSON['frm'] ], $formData);
				if ($err) {
					foreach($WEBGUI['form'][ $JSON['frm']]['obj'] as $t0) {
						if ($t0['n']==$err) {
							FatalError( isset($t0['par']['err']) ? $t0['par']['err'] : "Invalid value for `".$t0['c']."`");
							}
						}
					FatalError("Invalid value for `$err`");
					}
				WGDestroyCaptcha($WEBGUI['form'][ $JSON['frm'] ]);
				} else {
					$formData=@$JSON['par']; 
				}
			$pr=$fn(@$JSON['par'],$formData);
			
			if ($action==AJ_POST and $pr) $OUTJSON['postReply']=$pr;
			if ($action==AJ_WINAJAX and $pr) $OUTJSON['ajaxReturn'] = $pr;
			}
				
		}
	
	$formFile=$ex['f'].'/form.conf';
	if (file_exists($formFile)) {
		$X = @file_get_contents($formFile);
		if ($X===false) FatalError("Can't read form.conf");
		$X = WGReplacer($X,$rvar);
		$WEBGUI['form'] = WGFormParser($X,$action);
		$X=null;
		$formFile=true;
		} else $formFile=false;
		
	if ($action == AJ_SHELL || $action == AJ_DIALOG) {
		
		$f = $ex['f'].'/app.js';
		if (file_exists($f)) winJS( @file_get_contents($f) );
	
		$f = $ex['f'].'/data.json';
		if (file_exists($f)) {
			$WEBGUI['win']['data'] = json_decode(@file_get_contents($f),true);
			if (!is_array($WEBGUI['win']['data'])) FatalError("Invalid `data.json` structure/syntax");
			}
			
		$f = $ex['f'].'/layout.php';
		if (file_exists($f)) WGRequirePHP($f,$rvar);
		
		if (isset($WEBGUI['form'])) {
			foreach($WEBGUI['form'] as $X) WGFormActivity($X);
			$X=null;
			}
			
		$f = $ex['f'].'/app.ejs';
		if (file_exists($f)) {
			$f = @file_get_contents($f);
			if ($f===false) FatalError("Can't load EJS");
			$f = WGReplacer($f,$rvar);
			$f=explode("\n",$f);
			WGParseEJSTag($f);
			} else {
			$f = $ex['f'].'/event.json';	
			if (file_exists($f)) {
				$js=@file_get_contents($f);
				$js=json_decode($js,true);
				if (!is_array($js)) FatalError("Can't load application.\nBad JSON sctructure in event.json");
				$WEBGUI['win']['event']=$js;
				$js=null;
				}
			}
		
		if (function_exists('layout_create')) layout_create();
		}	
		
	endWin();
	}
Exemple #3
0
		$APPL['isAPI'] = 'bin/system';
		}
	
	if ($APPL['isAPI']) {
		if (!$APPL['api'] or $APPL['api']=='') FatalError("API name requested");
		if (!preg_match('/^[a-zA-Z0-9\_\-]{1,40}$/',$APPL['api'])) FatalError("Invalid API name");
		$f = $APPL['isAPI'].'/'. $APPL['api']. '.php';
		$f = WGParseFile($f);
		if (!$f) FatalError("Invalid API name");
		if (!$f['F']) FatalError("API file not found `".$f['f']."`");
		$APPL['bin'] = $f;
		WGRequirePHP($f['f']);
		}
		
	if ($APPL['executor']) {
		$f = WGParseFile($APPL['executor'],true);
		if (!$f) FatalError("Invalid executor file name");
		if (!$f['F'] and !$f['D']) FatalError("Executor not found `".print_r($APPL['executor'],true)."`");
		$APPL['bin'] = $f;
		if ($f['F']) { 
			if ($f['extension']=='php') {
				WGRequirePHP($f['f']);
				} else if ($f['extension']=='json') {
					$js=@file_get_contents($f);
					$js=json_decode($f,true);
					if (!is_array($js)) FatalError("Invalid executor json `".$APPL['executor']."`");
					Window($f['filename']);
					$WEBGUI['win']=array_merge($WEBGUI['win'],$js);
					$js=null;
					unset($js['hdc']);
					endWin();