<?php
//if (!defined('PHPLENSAPPLET')) define('PHPLENSAPPLET',1);
if (!defined('PHPLENS_DIR')) define('PHPLENS_DIR','..');
include_once(PHPLENS_DIR."/phplens.inc.php");

define('PHPLENS_BUILDER_RUNNER',true);
session_register('gApplet_name');

$gApplet_name = &$HTTP_SESSION_VARS['gApplet_name'];
if (isset($HTTP_GET_VARS['applet'])) {
	if (!preg_match('/^[a-z0-9_]*$/i',$HTTP_GET_VARS['applet'])) {
		echo "<p>Bad Applet</p>";
		return;
	}
	$gApplet_name = $HTTP_GET_VARS['applet'];
} 
	
if(!empty($gApplet_name)) {
	$appPath = APPLETS_DIR."/objs/$gApplet_name/$gApplet_name.inc.php";
	
	
	if (file_exists($appPath))	{
		if (isset($HTTP_GET_VARS['v'])) {
			switch ($HTTP_GET_VARS['v']) {
			case 'imp':
				$ff = APPLETS_DIR."/objs/$gApplet_name/$gApplet_name.imp.inc.php";
				break;
			case 'inc':
				$ff = $appPath;
				break;
			} 
			
			print "<b>$ff</b><p>";
			highlight_file($ff);
		} else
			include_once($appPath);
	} else echo "<p>Missing <i>$appPath</i>?</p>";
}
?>