/** * Alterna entre los entornos disonibles * * @param string $next_environment Entorno a utilizar, si no se indica se * se utilizara el siguiente disponible */ public static function doSwitch($next_environment = null) { $environment = self::info(); if (empty($environment['available'])) { return false; } if ($next_environment === null) { $index = array_search($environment['current'], $environment['available']) + 1; if ($index >= count($environment['available'])) { $index = 0; } } else { $index = array_search($next_environment, $environment['available']); if (false === $index) { return false; } } $environment['current'] = $environment['available'][$index]; $info = json_encode($environment, JSON_PRETTY_PRINT); $path = Globals::get('base_path') . '/config/environment.json'; if (false === @file_put_contents($path, $info)) { return false; } return $environment['current']; }
public static function checkModeAdmin() { if (session_id() == '') { @session_start("suite"); } $_SERVER['HTTP_SOURCE'] = isset($_SERVER['HTTP_SOURCE']) ? $_SERVER['HTTP_SOURCE'] : ""; if ($_SERVER['HTTP_SOURCE'] != "suite") { $manager = null; // controla o acesso ao manager, verificando a autenticação /*if(count(Globals::get('app/options/master/manager')) > 0 ){ $manager = Globals::get('app/options/master/manager'); }*/ if (count(Globals::get('settings/manager')) > 0) { $manager = Globals::get('settings/manager'); } //$manager = isset(Globals::get('app/options/master/manager/access/username'))?'1':null;//isset(Globals::get('app/options/master/manager'))?Globals::get('app/options/master/manager'):null; if ($manager != null) { $manager_access = count($manager->access) > 0 ? $manager->access : null; if ($manager_access != null && strpos(Globals::get('http/controllers/destination'), '!/manager/access') === false) { if (!isset($_SESSION["suite"])) { return false; } $sessionSuite = $_SESSION["suite"]; $sessionSuiteObj = json_decode($sessionSuite); if (!isset($sessionSuiteObj->manager->access)) { //$querys = "&querybefore=". Globals::get()->http->destination; header("location: " . Globals::get('path/manager/link') . "/manager/access"); return false; } } } //return false; } return true; }
public function saveAction() { require Globals::get('current/path/action/path') . "../ModelAssistent.php"; $modelAssistent = new ModelAssistent(); $data = $_POST['data']; $dataObj = json_decode($data); $option = ""; foreach ($dataObj as $key => $value) { foreach ($value as $key2 => $value2) { if ($option != "") { $option .= ","; } $option .= '"' . $key2 . '" : ' . json_encode($value2) . ''; } } $options = "{" . $option . "}"; $filename = Globals::get('path/domain/path') . 'options.json'; $result = file_put_contents($filename, $options); if ($result) { $status = "success"; } $optionsObj = json_decode($options); $modelAssistent->makeStruct($optionsObj); echo json_encode(array('status' => $status)); return array('continue' => false); }
public function logoutAction() { //$path = Globals::get('path/manager/link').'manager/access/out'; //$html = file_get_contents($path); Session::out(); header("location:" . Globals::get('path/manager/link')); return array('continue' => false, 'parameters' => array('title' => 'Suite Manager', 'subtitle' => 'Manager Tool', 'content' => ''), 'view' => array(array('html' => '$html'))); }
/** * verifica estrutura da aplicação esta correta * @return [type] [description] */ public function checkFirstAccess() { $pathApp = Globals::get('path/app/appbase/path'); $dirArray = Functions::scanOnlyDir($pathApp); if (count($dirArray) < 1) { return true; } else { return false; } }
public function AboutAction() { $link = '<a class="link" target="_blank" href="http://' . Globals::get('suite/site') . '">' . Globals::get('suite/site') . '</a>'; $html = '<dl>'; $html .= '<dt>Version</dt><dd>' . Globals::get('suite/version') . '</dd>'; $html .= '<dt>Author</dt><dd>' . Globals::get('suite/author') . '</dd>'; $html .= '<dt>Site</dt><dd>' . $link . '</dd>'; $html .= '</dl>'; return array('continue' => true, 'parameters' => array('title' => 'About Suite', 'subtitle' => 'Framework for developed web', 'content' => $html)); }
private function __construct() { $this->set_routing_table(); $a_get_request = Globals::get('_GET'); $m_route = array(); if (isset($a_get_request['viewfile']) && !is_null($a_get_request['viewfile'])) { $m_route = explode('/', $a_get_request['viewfile']); } else { $m_route[0] = 'start'; } $a_route = $this->get_route($m_route[0]); if ($a_route !== false) { if ($a_route['type'] === 'class') { try { $o_reflect_class = new ReflectionClass($m_route[0] . '\\' . $a_route['file']); if ($o_reflect_class->hasMethod($m_route[1])) { if ($m_route[0] === 'ajax') { $o_reflect_class->newInstance($m_route[1]); exit(1); } else { $o_reflect_method = $o_reflect_class->getMethod($m_route[1]); if ($o_reflect_method->isStatic()) { $o_reflect_method->invoke(null); } else { $o_reflect_method->invoke($o_reflect_class->newInstance()); } } } } catch (ReflectionException $e) { try { $o_reflect_class = new ReflectionClass($m_route[0] . '\\' . $a_route['file']); if ($o_reflect_class->hasMethod($a_route['default_method'])) { $o_reflect_method = $o_reflect_class->getMethod($a_route['default_method']); if ($o_reflect_method->isStatic()) { $o_reflect_method->invoke(null); } else { $o_reflect_method->invoke($o_reflect_class->newInstance()); } } } catch (ReflectionException $e) { echo $e->getMessage(); } } } } /* $size = sizeof($m_view_file)-1; self::$s_current_request_file = $m_view_file[$size]; unset($m_view_file[$size]); $m_view_file = implode('/',$m_view_file); self::$s_current_request_path = $m_view_file; */ }
public function welcomeAction() { //$html = Globals::get()->http->destination; $content = "<br>You can access the manager page to administer your application"; $content .= "<br><br><strong style='min-width:100px;display:inline-table'>Username:</strong> admin"; $content .= "<br><strong style='min-width:100px;display:inline-table'>Password:</strong> admin"; $content .= '<a href="' . Globals::get('path/manager/link') . '">Go to Manager</a>'; $content .= '<br>Use the assistant to create the application structure. '; $content .= '<a href="' . Globals::get('path/manager/link') . '/manager/assistant">Go to Assistant</a>'; $content .= '<br>for help and instructions to develop, visit the link below.'; $content .= '<a href="' . Globals::get('path/manager/link') . '/manager/help">Go to Help</a>'; return array('continue' => true, 'parameters' => array('title' => 'Wellcome', 'subtitle' => 'You can now develop your application.', 'content' => $content)); }
public static function append($id, $msg) { // blockieren Semphore::p(); $counter = Globals::get('counter', 0); $counter++; Globals::put('counter', $counter); $textToAdd = $counter . ";" . $id . ";" . time() . ";" . $msg . PHP_EOL; $myfile = fopen(self::FILE, "a") or die("Unable to open file!"); fwrite($myfile, $textToAdd); fclose($myfile); // freigeben Semphore::v(); }
/** * @return bool */ private static function getCache() { if (!Globals::get('MongularCache')) { return FALSE; } try { $cache = new self(); if ($cache->connect()) { return $cache; } return FALSE; } catch (\Exception $e) { return FALSE; } }
public static function getRoute() { $route = $_SERVER['REQUEST_METHOD'] !== 'GET' ? strtolower($_SERVER['REQUEST_METHOD']) . ':' : ''; $url = explode('/', Globals::get('r')); Globals::set('url', $url); foreach ($url as $i => $session) { if (is_numeric($session)) { $route .= "-num"; } else { $route .= $i ? '-' : ''; $route .= is_numeric($session) ? 'num' : $session; } } Globals::set('route', $route); }
public function makeStruct($options) { $app = $options->app; //$pathApp = Globals::get('path/app/path'); $pathApp = Globals::get('path/app/appbase/path') . $app . '/'; if (!file_exists($pathApp)) { mkdir($pathApp); if (!is_writable($pathApp)) { if (!chmod($pathApp, 0777)) { echo "Não é possivel alterar a permissão do arquivo ({$filename})"; exit; } } chmod($pathApp, 0777); $pathModel = Globals::get('path/manager/modules/path') . 'manager/assistant/_assets/model/default.tar.gz'; $this->extract($pathModel, $pathApp); } }
/** * This method initialize the current language and the current step * */ private function init() { //get the current post-request and check if the language was given by POST $s_post = \Globals::get('_POST'); if (!is_null($s_post['game_language'])) { \Session::get_session()->set_value('language', $s_post['game_language']); } //Initialize the I18N-Class for templates-usage \I18N::init(); //if we have no language-value in the session, set the default install-language to ENGLISH if (is_null(\Session::get_session()->get_value('language'))) { \I18N::set_language('en_EN'); } else { \I18N::set_language(\Session::get_session()->get_value('language')); } \Replacer::set_language(\I18N::get_language()); //set the current step by POST $this->i_step = $s_post['install_step']; }
public function listAction() { /*echo '<pre>'; print_r(Globals::get('path/app/plugins')); echo '</pre>';*/ // $html = ' '; /*Globals::set('parameters')->inner('title','List of plugins'); Globals::set('parameters')->inner('subtitle',' '); Globals::set('parameters')->inner('content',$html); */ $repositoryList = Globals::get('path/app/plugins/repository'); $repository = ""; foreach ($repositoryList as $key => $value) { $repository .= '<option value="' . $value . '">' . $key . '</option>'; } //Globals::set('parameters')->inner('repository',$repository); //$repository = ''; return array('continue' => true, 'parameters' => array('title' => 'List of Plugins', 'subtitle' => '', 'repository' => $repository, 'content' => $html), 'view' => array(array('html' => ''))); }
public function __construct() { if (isset($_GET['url'])) { $url = explode('/', Globals::get('url')); $url = array_filter($url); $this->_module = strtolower(array_shift($url)); $this->_controller = strtolower(array_shift($url)); $this->_action = strtolower(array_shift($url)); $this->_args = $url; } if (!isset($this->_module) || $this->_module == 'index.php') { $this->_module = 'home'; } if (!isset($this->_controller) || empty($this->_controller)) { $this->_controller = 'index'; } if ($this->_action == '') { $this->_action = 'show'; } if (!isset($this->_argumentos)) { $this->_argumentos = array(); } }
public static function add($ip) { $allIPs = Globals::get('ips', ''); $allIPs = $allIPs . ";" . $ip; Globals::put('ips', $allIPs); }
public static function getRouteName() { $route = strtolower($_SERVER['REQUEST_METHOD']) . ':'; $url = explode('/', Globals::get('r')); foreach ($url as $i => $session) { if (is_numeric($session)) { $route .= "-num"; } else { $route .= $i ? '-' : ''; $route .= is_numeric($session) ? 'num' : $session; } } return $route; }
public function getHtml($valueAction) { $html_view = null; $html_view_meta = null; $html_view_metaind = null; $html_view_header = null; $html_view_main = null; $html_view_footer = null; $resultView = isset($valueAction['view']) ? $valueAction['view'] : null; $resultContinue = isset($valueAction['continue']) ? $valueAction['continue'] : null; $resultParameters = isset($valueAction['parameters']) ? $valueAction['parameters'] : null; // define parametros da action if ($resultParameters != null) { Globals::set('current')->action = array('parameters' => $resultParameters); } $controller_link = Globals::get('http/domain/url') . Globals::get('http/controllers/destination') . '/'; Globals::set('current')->controller = array('link' => $controller_link); if (is_array($resultView)) { // inclui na página conteúdo baseado no view do return foreach ($resultView as $key2 => $value2) { foreach ($value2 as $key3 => $value3) { if ($key3 === 'html') { $html_view_main .= $value3; } elseif ($key3 === 'meta') { if (key($value3) == 'path') { $html_view_meta .= Functions::requireToVar($value3[key($value3)]); } else { if (key($value3) == 'html') { $html_view_meta .= $value3[key($value3)]; } } } elseif ($key3 === 'header') { if (key($value3) == 'path') { $html_view_header .= Functions::requireToVar($value3[key($value3)]); } else { if (key($value3) == 'html') { $html_view_header .= $value3[key($value3)]; } } } elseif ($key3 === 'main') { if (key($value3) == 'path') { $html_view_main .= Functions::requireToVar($value3[key($value3)]); } else { if (key($value3) == 'html') { $html_view_main .= $value3[key($value3)]; } } } elseif ($key3 === 'footer') { if (key($value3) == 'path') { $html_view_footer .= Functions::requireToVar($value3[key($value3)]); } else { if (key($value3) == 'html') { $html_view_footer .= $value3[key($value3)]; } } } else { if (file_exists($value3)) { $html_view_main .= Functions::requireToVar($value3); } } } } } return array('continue' => $resultContinue, 'view' => array('meta' => $html_view_meta, 'header' => $html_view_header, 'main' => $html_view_main, 'footer' => $html_view_footer)); }
<div class='contentBack' > <div class='content' > <section> <header class="headerBody"> <h1><?php echo Globals::get('current/action/parameters/title'); ?> </h1> <h2><?php echo Globals::get('current/action/parameters/subtitle'); ?> </h2> </header> <article class="mainContent"><?php echo Globals::get('current/action/parameters/content'); ?> </article> <footer><?php echo Globals::get('current/action/parameters/footer'); ?> </footer> </section> </div> </div>
/** * Executa o action do controller * @param [type] $control [description] */ public function LoadAction($control) { $http = Globals::get()->http; $controlName = get_class($control); $actionName = explode("_", $controlName); $actionName = $actionName[0]; $actionName = strtolower($actionName); $actionName = $actionName . 'Action'; $destination = $http->controllers->destination; $lastAction = $http->controllers->lastaction; $lastAction = Functions::ajustControlName($lastAction); $action = $lastAction . 'Action'; $parameters = array('destination' => $destination); $error = true; $nextpar = false; // executa a busca por actions existentes reversamente // verifica se existe um metodo com o nome da action e executa o metodo $controllers = $http->controllers->list; $controllers = array_reverse($controllers); foreach ($controllers as $key => $value) { $valueAction = $value . 'Action'; //if($nextpar == true){ //echo $valueAction; //} if (method_exists($control, $valueAction)) { $parameters['next'] = substr($destination, strpos($destination, $value) + strlen($value) + 1); $result = $control->{$valueAction}($parameters); // verifica se nextpar foi definido no retorno do metodo da Action, // se foi definido impede a exibição da página de erro e sinaliza // que os proximos controllers da url são parametros if (isset($result['nextpar']) && $result['nextpar'] == true) { $error = true; break; } else { break; } } else { $error = false; } } if ($error == false) { return $error; } else { return $result; } }
public static function get() { return Globals::get('neighbor', ''); }
<!DOCTYPE html> <html> <head> <?php echo Globals::get('app/view/meta'); ?> </head> <body> <div class="wrapper"> <header> <?php echo Globals::get('app/view/header'); ?> </header> <main> <?php echo Globals::get('app/view/main'); ?> </main> <footer> <?php echo Globals::get('app/view/footer'); ?> </footer> </div> </body> </html>
public static function isServer() { return strcmp(Globals::get(ROLE, ""), SERVER) == 0; }
<script src="<?php echo Globals::get('path/module/current/meta/url'); ?> js/Box.js"></script> <script src="<?php echo Globals::get('path/module/current/meta/url'); ?> js/Events.js"></script> <script src="<?php echo Globals::get('path/module/current/meta/url'); ?> js/default.js"></script>
case 'get:posts-search-var': return new PostsController('search', $var); case 'get:gamers': return new GamersController('all'); case 'post:users-facebook': return new UsersController('singinByFacebook'); case 'post:users-token': return new UsersController('readByToken'); case 'post:ms-newlesson': return new MesalvaController('newLesson'); case 'post:ms-readlesson': return new MesalvaController('readLesson'); default: return null; } } $url_last = count(Globals::get('url')); $try = bothRoutes(REST::getRouteName()); while (is_null($try) && $url_last > 0) { $url = Globals::get('url'); $var = $url[--$url_last]; $url[$url_last] = 'var'; $route = strtolower($_SERVER['REQUEST_METHOD']) . ':'; $route .= implode('-', $url); $try = bothRoutes($route, $var); if (!is_null($try)) { exit; } } REST::return404(['route' => Globals::get('route'), 'inputs' => REST::getInputs()]);
public function getAction() { //echo $http['destination'].'<br>'; $data = null; $preUrl = Globals::get('path/app/link'); $lastactions = isset($http['lastcontrol']) ? $http['lastcontrol'] : null; $lastactionsArray = explode('/', $lastactions); $status = ''; $downloaded = true; $pluginDep = $this->getDependence(); if (is_array($pluginDep)) { if ($lastactions != null) { foreach ($pluginDep as $key => $value) { if ($lastactions != null && $lastactions == $value['control']) { $repositoriestarget = isset($value['repositoriestarget']) ? $value['repositoriestarget'] : null; $status = 'found'; $data[] = $value; } } } else { foreach ($pluginDep as $key => $value) { $status = 'found'; $data[] = $value; } } } echo json_encode(array('status' => $status, 'data' => $data)); return array('continue' => false); }
public function versionAction() { Globals::set('manager')->inner('parameters', array('title' => 'About Suite', 'subtitle' => 'Version', 'content' => Globals::get()->suite->version)); return array('continue' => true, 'view' => array(array('main' => array('path' => __DIR__ . '/Index_view.php')))); }
<div class='contentBack' > <div class='content' > <div class='row'> <div class='column left'> <div class="headerBody"> <h1><?php echo Globals::get('current/action/parameters/title'); ?> </h1> </div> <div class="mainContent"> <h2><?php echo Globals::get('current/action/parameters/subtitle'); ?> </h2> <div><?php echo Globals::get('current/action/parameters/content'); ?> </div> </div> </div> </div> </div> </div>
public function checkPrefixUrl(ISettings $settings, IPath $path) { //$settings = $this->settings; $getSettings = Globals::get('settings'); //$settings->getSettings(); $getPath = $path->getPath(); $getResponse = Globals::get('http'); //$this->getResponse(); $controllersRequest = Globals::get('http/controllers'); //$this->getControllers(); $controllers = $getResponse->controllers->list; /*echo '<pre>'; print_r($getPath); echo '</pre>';*/ if ($controllers[0] == '_plugins' || substr($controllers[0], 0, 1) == "!") { return; } $prefixUrl = $getSettings->prefix; if ($prefixUrl != '' && strpos($getResponse->query, $prefixUrl) != true) { //header("Location: ".$getPath->app->url.$prefixUrl); header("Location: " . $getPath->app->link); } }
<?php // observa a checagem de dependencia Events::Observer('plugin[founddependence]', function ($key, $value) { header('location:' . Globals::get('path/manager/link') . 'plugins/dependence/check/' . $value['action']); }); // observa a ocorrencia do erro de aplicação não encontrada Events::Observer('error[app_not_found]', function ($key, $value) { $path = Globals::get('path/manager/link') . "/manager/assistant"; $suitepar = json_encode(array('type' => 'app_not_found')); $result = Functions::getFileBySuite($path, array("header" => "Suite_par: {$suitepar} \r\n")); echo $result; exit; }); // first access on suite Events::Observer('info[welcome]', function ($key, $value) { $path = Globals::get('path/manager/link') . "/screens/welcome"; $suitepar = json_encode(array('type' => 'welcome')); $result = Functions::getFileBySuite($path, array("header" => "Suite_par: {$suitepar} \r\n")); echo $result; exit; });