<?php
session_start();
$modo_RAD = false; $_rad_ = "/Studio/" ;
$_desenv_ = $_rad_ . "desenv/usuarios/othuki/";
function getPatch()
{$uri = $_SERVER["REQUEST_URI"];$len = strlen($uri) -1;while($uri[$len] != "/")$len --;return substr($uri, 0, $len + 1);}
function execPage( $nPage )
{global $projeto,$estilo,$componentes_no_Prj,$_desenv_,$modo_RAD;foreach( $componentes_no_Prj as $ind_ => $val_){global $$ind_;}include( $_SERVER['DOCUMENT_ROOT'] .$_desenv_ . "bin/" .$nPage . '.main.php' );}
function getTemplates( $comp_no_Prj, $local )
{$arr = array();foreach($comp_no_Prj as $_ind_ => $_val_){foreach($_val_ as $_n_ => $_l_){if ($_l_['local'] == $local )$arr[] = $_l_['nome'];}}return($arr);}
function getGlobal( $comp_no_Prj, $local )
{$arr = array();foreach($comp_no_Prj as $_ind_ => $_val_){foreach($_val_ as $_n_ => $_l_){if ($_l_['local'] == $local )$arr[] = $_l_['nome'];}}return($arr);}
function getRegistro( $prj )
{global $_rad_, $_desenv_;$nFile = $prj . ".main.prj";$nDest = $prj . ".main.inc.php";$texto = "";$nComp = "";$nObj = "";$nl = "\n";$array = array();if ( file_exists($nFile) ){$linhas = file($nFile);}else{$linhas = array();}asort($linhas);reset($linhas);$texto = "<?php " . NEWLINE;$flag = false;foreach( $linhas as $i_ => $linha_ ){$linha_ = trim($linha_);if ( !empty( $linha_ ) ){$flag = true;$arrLinhas = explode( ";", trim($linha_) );array_pop($arrLinhas);foreach( $arrLinhas as $ii_ => $linha ){$arr = explode( ":", $linha );if( $nComp != $arr[0] ){if ( $nObj != "" ){$texto .= " )".$nl;}if( $nComp != "" )$texto .= " ); ".$nl;$nComp = $arr[0];$nObj = "";$array[] = $arr[0];$texto .= " $".$arr[0]." = array( ".$nl;}if( $nObj != $arr[1] ){if ( $nObj != "" ){$texto .= " ),".$nl;}$nObj = $arr[1];$texto .= " '".$arr[1]."' => array( " . $nl;}$texto .= " 'nome' => '" . $arr[2] . "'," . $nl;$texto .= " 'local' => '" . $arr[3] . "'," . $nl;$texto .= " 'container' => '" . $arr[4] . "'," . $nl;$texto .= " 'visual' => '" . trim($arr[5]) . "' " . $nl;}}}$l = count( $array );$x = 0;if ( $flag ){$texto .= " )" . $nl;$texto .= " );" . $nl;}$texto .= " " . $nl;$texto .= " \$componentes_no_Prj = array( " . $nl;foreach($array as $ii_ => $cpo ){$x ++;$sp = ( $x < $l ) ? "," : "";$texto .= " '".$cpo."' => $".$cpo . $sp . $nl;}$texto .= " ); " . $nl;$texto .= " " . $nl;$texto .= "?> " . $nl;$fp = @fopen( $nDest, 'wb' );fwrite( $fp, $texto );fclose( $fp );return( $prj . ".main.inc.php" );}
function getPaletas()
{$nDir = "bin/paletas/";$arrPaleta = array();if ( file_exists($nDir) && is_dir($nDir) ){if ($handle = opendir($nDir)){while (false !== ($file = readdir($handle))){if ( is_dir($nDir.$file) ){if ($file != "." &&$file != ".." &&$file != "bkp"){$arrPaleta[] = "$file";}}}closedir($handle);}}return( $arrPaleta );}
function getObjetos($nPaleta)
{$nDir = "bin/paletas/" . $nPaleta;$arrObj = array();if ( file_exists($nDir) ){if ($handle = opendir($nDir)){while (false !== ($file = readdir($handle))){if ($file != "." &&$file != ".." &&$file != "bkp"){$ix = strpos( $file, ".");$arrObj[] = substr($file,0, $ix);}}closedir($handle);}}return( array_unique($arrObj) );}
function getFile( $nDir, $pre = "" )
{$arrFile = array();if ( file_exists($nDir) && is_dir($nDir) ){if ($handle = opendir($nDir)){while (false !== ($file = readdir($handle))){if ( !is_dir($nDir.$file) ){if ($pre == "" ){$arrFile[] = "$file";}else{$l = strlen($pre);if( $pre == substr($file, 0, $l) &&!strpos( $file, "RAD" ))$arrFile[] = "$file";}}}closedir($handle);}}return( $arrFile );}
function getDir( $nDir )
{$arrFile = array();if ( file_exists($nDir) && is_dir($nDir) ){if ($handle = opendir($nDir)){while (false !== ($file = readdir($handle))){if ( is_dir($nDir . $file) &&$file != '.' && $file != '..'){$arrFile[] = "$file";}}closedir($handle);}}return( $arrFile );}
function writeTO( $texto_, $alvo_ = "HTML" )
{if ( $alvo_ == "HTML"){echo( $texto_ . NEWLINE );}else{fwrite( $alvo_, $texto_ . NEWLINE );}}
function readINIfile ( $filename, $commentchar = ';' )
{if( file_exists( $filename ) ){$array1 = @file( $filename );$section = '';foreach ( $array1 as $filedata ){$dataline = trim($filedata);$firstchar = substr($dataline, 0, 1);if ( $firstchar != $commentchar && $dataline != '' ){if ($firstchar == '[' && substr($dataline, -1, 1) == ']'){$section = strtolower( substr( $dataline, 1, -1 ) );}else{$delimiter = strpos($dataline, '=');if ($delimiter > 0){$key = strtolower( trim( substr($dataline, 0, $delimiter) ) );$value = trim( substr( $dataline, $delimiter + 1) );if ( substr($value, 1, 1) == '"' &&substr($value, -1, 1) == '"'){$value = substr($value, 1, -1);}$array2[$section][$key] = stripcslashes($value);}else{$array2[$section][strtolower(trim($dataline))] = '';}}}else{}}}else{$array2 = array();}return $array2;}
function writeINIfile ($filename, $array1, $commentchar, $commenttext)
{$handle = @fopen($filename, 'wb');if ( $commenttext != '' ){$comtext = $commentchar.str_replace($commentchar, "\r\n".$commentchar,str_replace("\r", $commentchar,str_replace("\n", $commentchar,str_replace("\n\r", $commentchar,str_replace("\r\n", $commentchar, $commenttext)))));if ( substr($comtext, -1, 1) == $commentchar &&substr($comtext, -1, 1) != $commentchar){$comtext = substr( $comtext, 0, -1 );}@fwrite ( $handle, $comtext."\r\n" );}foreach ($array1 as $sections => $items){if (isset($section)){@fwrite ($handle, "\r\n");}$section = ucfirst(preg_replace('/[\0-\37]|\177/', "-", $sections));@fwrite ( $handle, "[".$section."]\r\n" );foreach ($items as $keys => $values){$key = preg_replace('/[\0-\37]|=|\177/', "-", $keys);if ( substr($key, 0, 1) == $commentchar){$key = '-'.substr($key, 1);}$value = addcslashes($values,'');@fwrite( $handle, ' ' . $key . ' = ' . $value . "\r\n" );}}fclose($handle);}
$projeto = array('projeto_nome' => 'novo','projeto_id' => '1','versao' => '0','atualizacao' => '00','revisao' => '10','desenv_id' => 1,'estilo' => 'system','pageMain' => 'page1');
define('BIN' ,$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'bin/');
define('USES',$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'uses/');
define('CSS' ,$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'css/');
define('INC' ,$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'include/');
define('CFG' ,$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'config/');
define('IMG' ,$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'imagens/');
define('LANGUAGE','pt_br');
define( 'NEWLINE', "\n");
define('_BIN_' ,$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'bin/');
define('_USES_',$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'uses/');
define('_CSS_' ,$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'css/');
define('_INC_' ,$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'include/');
define('_CFG_' ,$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'config/');
define('_IMG_' ,$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'imagens/');
$estilo = array('system' => array('ActiveBorder' =>'ActiveBorder','ActiveCaption' =>'ActiveCaption','AppWorkSpace' =>'AppWorkSpace','BackGround' =>'BackGround','ButtonFace' =>'ButtonFace','ButtonHighlight' =>'ButtonHighlight','ButtonShadow' =>'ButtonShadow','ButtonText' =>'ButtonText','CaptionText' =>'CaptionText','GrayText' =>'GrayText','Highlight' =>'Highlight','HighlightText' =>'HighlightText','InactiveBorder' =>'InactiveBorder','InactiveCaption' =>'InactiveCaption','InfoBackground' =>'InfoBackground','InfoText' =>'InfoText','Menu' =>'Menu','MenuText' =>'MenuText','Scrollbar' =>'Scrollbar','ThreeDDarkShadow' =>'ThreeDDarkShadow','ThreeDFace' =>'ThreeDFace','ThreeDHighlight' =>'ThreeDHighlight','ThreeDLightShadow' =>'ThreeDLightShadow','ThreeShadow' =>'ThreeShadow','Window' =>'Window','WindowText' =>'WindowText','FontFamily' =>'verdana, tahoma, "Courier New", times','FontSize' =>'10'),'win98' => array(),'gold' => array(),'platina' => array());
$label = array('label1' => array('nome' => 'label1','local' => 'page1','container' => 'false','visual' => 'true'));
$componentes_no_Prj = array('label' => $label);
$pages_no_Prj = array('page1' => 'page1');
execPage( $projeto['pageMain'] );
?>
