예제 #1
0
파일: Util.php 프로젝트: m3uzz/onionfw
 /**
  * getImage: devolve a imagem solicitada.
  *
  * @param string $psPath        	
  * @param string $psFile        	
  */
 public static function getImage($psFile, $psTamanho = null, $pnId = null, $psTitle = null, $psAlt = null, $psClass = null, $pbReturnPath = false)
 {
     // recupera o diretório da imagem
     $targetDir = System::getBalancedDir($psFile);
     $lsNameImage = preg_replace('/^(.+\\/)?(.+)\\.[^\\.]+$/', '$2', $psFile);
     $ext = preg_replace('/^.+\\.([^\\.]+)$/', '$1', $psFile);
     $source = !empty($psTamanho) ? $targetDir . $lsNameImage . '_' . $psTamanho . '.' . $ext : $targetDir . $lsNameImage . '.' . $ext;
     $class = !empty($psClass) ? 'class="' . $psClass . '"' : '';
     $id = !empty($pnId) ? 'id="' . $pnId . '"' : '';
     $title = !empty($psTitle) ? 'title="' . $psTitle . '"' : '';
     $alt = !empty($psAlt) ? 'alt="' . $psAlt . '"' : '';
     // Log\Debug::debug($source);
     $lsFilePath = realpath(CLIENT_PATH . $source);
     if (file_exists($lsFilePath)) {
         if (!$pbReturnPath) {
             // cria um elemento <img> com o caminho da imagem solicitada
             $img = '<img src="' . $source . '"  ' . $id . ' ' . $title . ' ' . $alt . ' ' . $class . '/>';
         } else {
             $img = $source;
         }
         return $img;
     } else {
         Log\Debug::debug("A imagem solicitada '" . $targetDir . $source . "' não foi encontrada.");
         return null;
     }
 }
예제 #2
0
파일: Layout.php 프로젝트: m3uzz/onionfw
 /**
  * Função pouco utilizada, substituida por get_template()
  * 
  * @param string $psUrl        	
  * @param string $psTemplate        	
  * @return string
  */
 public static function getTemplateExterno($psUrl, $psTemplate)
 {
     $laLk = parse_url($psUrl);
     if ($laLk['scheme'] == "http") {
         return UrlRequest::urlRequest($psUrl . $psTemplate);
     } else {
         return System::localRequest($psTemplate);
     }
 }
예제 #3
0
파일: Config.php 프로젝트: m3uzz/onionfw
 /**
  * 
  * @param array $paConfigs
  */
 public static function cacheConfig($paConfigs)
 {
     $lsCacheConfDir = CLIENT_DIR . DS . 'data' . DS . 'cache' . DS . 'client_config.global.php';
     if ($paConfigs['settings']['cacheConfig'] && !file_exists($lsCacheConfDir)) {
         $lsConfig = File\System::arrayToFile($paConfigs);
         File\System::saveFile($lsCacheConfDir, $lsConfig);
     }
 }
예제 #4
0
 /**
  * Init Onion Application:
  * Test if PHP version is ok;
  * Load the Onion default configs and Client configs to set the application
  * object;
  * Check if the application is available to run or it is in maintenance;
  * Set the modules enable;
  * Construct the Onion application map;
  *
  * @param array $paGeneralConfig        	
  */
 public function init(array $paGeneralConfig = array())
 {
     $this->_generalConfig = $paGeneralConfig;
     $this->testPhpVersion();
     $this->setConfigs();
     // if not a php file, it is an external file and need to be routed
     if (!System::fileRoute($this->_front['meta']['pragma'])) {
         $this->isEnable();
         $this->enableModules();
         /*
          * Session::clearRegister('resource');
          * Session::clearRegister('app');
          * Session::clearRegister('moduleRegistered');
          * //Session::clearRegister('acl'); Register::getModules();
          * Register::getCompostModules();
          * Integration::getIntegrateModules();
          * Register::registreApplication();
          * Register::replaceSectionIntegration();
          * //Log\Debug::display(Session::getRegister('app')); die;
          * Log\Debug::debug(Register::getResourcesList());
          * Log\Debug::debug(Register::getApplicationArray($legacy
          * = true));
          */
         // Log\Debug::display($this->_generalConfig);
         // Log\Debug::display($this->_onionConfig);
         // die();
     }
     return $this;
 }
예제 #5
0
파일: Service.php 프로젝트: m3uzz/onionfw
 public static function serviceRoute()
 {
     if (isset($_SERVER['REQUEST_URI'])) {
         $laParams = null;
         if (isset($_GET)) {
             $laParams['GET'] = $_GET;
         }
         if (isset($_POST)) {
             $laParams['POST'] = $_POST;
         }
         if (isset($_SERVER['Data-type']) && $_SERVER['Data-type'] == 'json' && isset($_SERVER['data'])) {
             $laParams['JSON'] = $_SERVER['data'];
         }
         if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'PUT') {
             $laParams['PUT'] = System::getPutData();
         }
         if (isset($_FILES)) {
             $laParams['FILES'] = $_FILES;
         }
         //Separando o caminho e verificando quantos elementos tem
         $laRequestUri = explode("/", $_SERVER['REQUEST_URI']);
         $lnCount = 0;
         $lsQueryString = "?" . $_SERVER['QUERY_STRING'];
         //Removendo elementos vazios
         foreach ($laRequestUri as $lsValue) {
             if (!empty($lsValue) && $lsValue != $lsQueryString) {
                 $laPath[] = $lsValue;
                 $lnCount++;
             }
         }
         switch ($lnCount) {
             case 0:
             case 1:
                 if (!isset($laPath[0]) || empty($laPath[0])) {
                     $laPath[0] = "index";
                 }
                 $lsService = DS . $laPath[0] . ".php";
                 $lsClass = $laPath[0];
                 $lsMethod = $laPath[0];
                 break;
             case 2:
                 $lsService = DS . $laPath[0] . ".php";
                 $lsClass = $laPath[0];
                 $lsMethod = $laPath[1];
                 break;
             default:
                 $lsService = DS . $laPath[0] . DS . $laPath[1] . ".php";
                 $lsClass = $laPath[0] . "_" . $laPath[1];
                 $lsMethod = $laPath[2];
         }
         $laService['service'] = $lsService;
         $laService['class'] = $lsClass;
         $laService['method'] = $lsMethod;
         Log\Debug::debug($laService);
         Log\Debug::debug($laParams);
         self::run($laService, $laParams);
     } else {
         //Se o service não foi encontrado, retornar 404 not found para o client
         header("HTTP/1.1 404 Service Not Found");
         exit(1);
     }
 }
예제 #6
0
 /**
  *
  * @param string $psField
  * @param mixed $pmValue
  * @return string|unknown
  */
 public function formatFieldToGrid($psField, $pmValue)
 {
     switch ($psField) {
         case 'dtInsert':
         case 'dtUpdate':
             return String::getDateTimeFormat($pmValue);
             break;
         case 'txtServer':
             $paValue = json_decode($pmValue, true);
             $lsUserAgent = isset($paValue['HTTP_USER_AGENT']) ? $paValue['HTTP_USER_AGENT'] : '';
             $lsAccessMsg = isset($paValue['ACCESS_MSG']) ? $paValue['ACCESS_MSG'] : '';
             return "{$lsAccessMsg} | {$lsUserAgent}";
             break;
         case 'time':
             $lsSessionId = session_id();
             //session_id($this->_sSessionId);
             // $lnExpire = session_cache_expire();
             //session_id($lsSessionId);
             return $lnExpire;
             break;
         case 'stSession':
             $this->_sSessionId = $pmValue;
             $lbSessionAlive = false;
             $lsSessionFile = session_save_path() . DS . 'sess_' . $pmValue;
             if (file_exists($lsSessionFile)) {
                 $lsSession = System::localRequest($lsSessionFile);
                 $laSession = $this->unserialize($lsSession);
                 if (is_array($laSession) && isset($laSession['ONION']) && !empty($laSession['ONION'])) {
                     $lbSessionAlive = true;
                 }
             }
             //			    $this->_oSessionManager->regenerateId($this->_sSessionId);
             //			    $lnStatus = $this->_oSessionManager->isValid();
             //			    $loId = $this->_oSessionManager->getStorage();
             //			    Debug::display(date('Y-m-d H:i:s', $loId->getRequestAccessTime()));
             //			    Debug::display($loId->toArray());
             // $this->_oSessionManager->regenerateId($lsSessionId);
             if ($lbSessionAlive) {
                 return '<a href="/log-access/kill-session/?id=' . $pmValue . '"><i class="glyphicon glyphicon-ok-sign text-success" title="' . $pmValue . '"></i></a>';
             } else {
                 return '<i class="glyphicon glyphicon-remove-sign text-danger" title="' . $pmValue . '"></i>';
             }
             break;
         default:
             return $pmValue;
     }
 }