<?php
session_start();
$modo_RAD = false; $_rad_ = "/Studio/";
$_desenv_ = $_rad_ . "desenv/usuarios/alessandro/";
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,$esquema,$componentes_no_Prj,$_desenv_,$modo_RAD;foreach( $componentes_no_Prj as $ind_ => $val_){global $$ind_;}include( $_SERVER['DOCUMENT_ROOT'] .$_desenv_ . "core/" .$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 = "core/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 = "core/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 );}return( true );}
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);return(true);}
function readINIfile( $filename, $commentchar = ";" )
{$array1 = array();$array2 = array();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{}}}return( $array2 );}
$projeto = array('projeto_nome' => 'projeto3','projeto_id' => '1','versao' => '0','atualizacao' => '00','revisao' => '10','desenv_id' => 1,'esquema' => 'system','modelo' => 'win98','pageMain' => 'page1');
define('CORE',$_SERVER['DOCUMENT_ROOT'] . $_rad_ . 'core/');
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('_CORE_',$_SERVER['DOCUMENT_ROOT'] . $_desenv_ . 'core/');
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/');
define('LANGUAGE','pt_br');
define( 'NEWLINE', "\n");
define( 'JS_DIR', 'MSIE' );
define( 'JS_START', '<script type="text/javascript">' . "\n" );
define( 'JS_END', '</script>' . "\n" );
$esquema = 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('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'),'gold' => array(),'platina' => array());
$button = array('button1' => array('nome' => 'button1','local' => 'page1','container' => 'false','visual' => 'true'),'button2' => array('nome' => 'button2','local' => 'page1','container' => 'false','visual' => 'true'),'button3' => array('nome' => 'button3','local' => 'page1','container' => 'false','visual' => 'true'),'button4' => array('nome' => 'button4','local' => 'page1','container' => 'false','visual' => 'true'),'button5' => array('nome' => 'button5','local' => 'page1','container' => 'false','visual' => 'true'));
$label = array('label1' => array('nome' => 'label1','local' => 'page1','container' => 'false','visual' => 'true'));
$componentes_no_Prj = array('button' => $button,'label' => $label);
$pages_no_Prj = array('page1' => 'page1');
execPage( $projeto['pageMain'] );
?>
