phpSyntaxCheck() public static method

public static phpSyntaxCheck ( $phpCode )
Exemplo n.º 1
0
 public static function ia_block_view($params, Smarty_Internal_Template &$smarty)
 {
     $block = $params['block'];
     switch ($block['type']) {
         case 'menu':
             if ($block['contents']) {
                 $smarty->assign('menu', $block);
                 $result = $smarty->fetch($block['tpl']);
             }
             break;
         case 'smarty':
             $smarty->assign('block', $block);
             if ($block['external']) {
                 $filename = explode(':', $block['filename']);
                 $template = iaCore::instance()->get('tmpl');
                 switch (count($filename)) {
                     case 1:
                         $templateFile = sprintf("%stemplates/%s/%s", IA_HOME, $template, $filename[0]);
                         $templateFile = file_exists($templateFile) ? $templateFile : sprintf('%s/templates/common/%s', IA_HOME, $filename[0]);
                         break;
                     case 2:
                         $templateFile = sprintf('%stemplates/%s/packages/%s/%s', IA_HOME, $template, $filename[0], $filename[1]);
                         $templateFile = file_exists($templateFile) ? $templateFile : sprintf('%spackages/%s/templates/common/%s', IA_HOME, $filename[0], $filename[1]);
                         break;
                     default:
                         $templateFile = sprintf("%stemplates/%s/plugins/%s/%s", IA_HOME, $template, $filename[1], $filename[2]);
                         $templateFile = file_exists($templateFile) ? $templateFile : sprintf('%splugins/%s/templates/front/%s', IA_HOME, $filename[1], $filename[2]);
                 }
                 $source = @file_get_contents($templateFile);
                 if (false === $source) {
                     trigger_error('Unable to locate the block template: <b>' . $block['filename'] . '</b>');
                 }
             } else {
                 $source = $block['contents'];
             }
             $result = $smarty->fetch('eval:' . $source);
             break;
         case 'php':
             if (!$block['external']) {
                 if (iaSystem::phpSyntaxCheck($block['contents'])) {
                     $iaCore = iaCore::instance();
                     // predefine this variable to be used in the code below
                     $result = eval($block['contents']);
                 } else {
                     iaDebug::debug(array('name' => $block['name'], 'code' => '<textarea style="width:80%;height:100px;">' . $block['contents'] . '</textarea>'), '<b style="color:red;">PHP syntax error in the block "' . $block['name'] . '"</b>', 'error');
                 }
             } else {
                 $result = (include_once $block['filename']);
             }
             break;
         case 'html':
             $result = $block['contents'];
             break;
         case 'plain':
             $result = htmlspecialchars($block['contents']);
     }
     return empty($result) ? '' : $result;
 }
Exemplo n.º 2
0
 public function startHook($name, array $params = array())
 {
     if (empty($name)) {
         return false;
     }
     iaDebug::debug('php', $name, 'hooks');
     if (!isset($this->_hooks[$name])) {
         return false;
     }
     iaSystem::renderTime('hook', $name);
     if (count($this->_hooks[$name]) > 0) {
         $variablesList = array_keys($params);
         extract($params, EXTR_REFS | EXTR_SKIP);
         $iaCore =& $this;
         $iaView =& $this->iaView;
         $iaDb =& $this->iaDb;
         foreach ($this->_hooks[$name] as $extras => $hook) {
             if ('php' == $hook['type'] && (empty($hook['pages']) || in_array($iaView->name(), $hook['pages']))) {
                 if ($hook['filename']) {
                     if (!file_exists(IA_HOME . $hook['filename'])) {
                         $message = sprintf('Can\'t start hook "%s". File does not exist: %s', $name, $hook['filename']);
                         iaDebug::debug($message, null, 'error');
                     } else {
                         include IA_HOME . $hook['filename'];
                     }
                 } else {
                     iaSystem::renderTime('START TIME ' . $name . ' ' . $extras);
                     if (iaSystem::phpSyntaxCheck($hook['code'])) {
                         eval($hook['code']);
                     } else {
                         iaDebug::debug(array('name' => $name, 'code' => '<textarea style="width:80%;height:100px;">' . $hook['code'] . '</textarea>'), '<b style="color:red;">Syntax error in hook "' . $name . '" of "' . $extras . '"</b>', 'error');
                     }
                     iaSystem::renderTime('END TIME ' . $name . ' ' . $extras);
                 }
             }
         }
         compact($variablesList);
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 protected function _runPhpCode($code)
 {
     if (iaSystem::phpSyntaxCheck($code)) {
         $iaCore =& $this->iaCore;
         $iaDb =& $this->iaDb;
         eval($code);
     }
 }
Exemplo n.º 4
0
 public static function ia_block_view($params, Smarty_Internal_Template &$smarty)
 {
     $block = $params['block'];
     switch ($block['type']) {
         case 'menu':
             if ($block['contents']) {
                 $smarty->assign('menu', $block);
                 $result = $smarty->fetch($block['tpl']);
             }
             break;
         case 'smarty':
             $smarty->assign('block', $block);
             $result = $smarty->fetch($block['external'] ? $block['filename'] : 'eval:' . $block['contents']);
             break;
         case 'php':
             if (!$block['external']) {
                 if (iaSystem::phpSyntaxCheck($block['contents'])) {
                     $iaCore = iaCore::instance();
                     // predefine this variable to be used in the code below
                     $result = eval($block['contents']);
                 } else {
                     iaDebug::debug(array('name' => $block['name'], 'code' => '<textarea style="width:80%;height:100px;">' . $block['contents'] . '</textarea>'), '<b style="color:red;">PHP syntax error in the block "' . $block['name'] . '"</b>', 'error');
                 }
             } else {
                 $result = (include_once $block['filename']);
             }
             break;
         case 'html':
             $result = $block['contents'];
             break;
         case 'plain':
             $result = htmlspecialchars($block['contents']);
     }
     return empty($result) ? '' : $result;
 }