public function callHooks($event, $obj, $args = '') { $result = false; if ($this->rootdataaccess) { $query = $this->rootdataaccess->execute('SELECT * FROM hooks WHERE functionapplication=' . $this->rootdataaccess->formatText($this->application) . ' AND function=' . $this->rootdataaccess->formatText($this->function) . ' AND event=' . $this->rootdataaccess->formatText($event)); if ($query) { $result = Hook::RESULT_OK; $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); while (!$query->eof) { $data = $query->getFields(); if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->hooks[$this->application . '::' . $this->function . '::' . $event][] = $data['hookhandler'] . ' - ' . $data['hookmethod']; } require_once 'shared/hooks/' . $data['hookhandler']; // let the 'class::function' syntax be accepted in dispatch maps if (is_string($data['hookmethod']) && strpos($data['hookmethod'], '::')) { $data['hookmethod'] = explode('::', $data['hookmethod']); } // verify that function to be invoked is in fact callable if (!is_callable($data['hookmethod'])) { continue; } $func_result = call_user_func($data['hookmethod'], $obj, $args); if ($func_result == Hook::RESULT_ABORT) { $result = Hook::RESULT_ABORT; } $query->moveNext(); } } } return $result; }
/** * Launches a panel in the domain desktop. * * If the panel name is one "main" then * no real panel is launched, a domain desktop layout file is included. * * Domain desktop layout files are stored in the folder * core/classes/innomatic/desktop/layout/domain. * * @param string $resource Panel name. */ public function executeDomain($resource) { // Check if this is the default page and if the user is allowed to access the dashboard if (substr($resource, -1, 1) == '/') { $perm = new \Innomatic\Desktop\Auth\DesktopPanelAuthorizator($this->container->getCurrentDomain()->getDataAccess(), $this->container->getCurrentUser()->getGroup()); $node_id = $perm->getNodeIdFromFileName('dashboard'); if ($perm->check($node_id, \Innomatic\Desktop\Auth\DesktopPanelAuthorizator::NODETYPE_PAGE) != \Innomatic\Desktop\Auth\DesktopPanelAuthorizator::NODE_NOTENABLED) { $resource = $resource . 'dashboard'; } } if (substr($resource, -1, 1) != '/') { // Must exit if the user called a page for which he isn't enabled // if (!isset($perm)) { $perm = new \Innomatic\Desktop\Auth\DesktopPanelAuthorizator($this->container->getCurrentDomain()->getDataAccess(), $this->container->getCurrentUser()->getGroup()); } $desktopPanel = basename($resource); if ($this->container->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->desktopApplication = $desktopPanel; $dump->sessionId = $this->session->getId(); } switch ($desktopPanel) { case 'index': break; default: $node_id = $perm->getNodeIdFromFileName($desktopPanel); if ($node_id) { if ($perm->check($node_id, \Innomatic\Desktop\Auth\DesktopPanelAuthorizator::NODETYPE_PAGE) == \Innomatic\Desktop\Auth\DesktopPanelAuthorizator::NODE_NOTENABLED) { $adloc = new \Innomatic\Locale\LocaleCatalog('innomatic::authentication', $this->container->getCurrentUser()->getLanguage()); $this->container->abort($adloc->getStr('nopageauth')); } } else { $adloc = new \Innomatic\Locale\LocaleCatalog('innomatic::authentication', $this->container->getCurrentUser()->getLanguage()); $this->container->abort($adloc->getStr('nopageauth')); } } if (is_dir($resource . '-panel')) { $panelHome = $resource . '-panel/'; $panelName = basename($resource); $controllerClassName = ucfirst($panelName) . 'PanelController'; // Checks if view file and definition exist if (!(include_once $panelHome . $controllerClassName . '.php')) { throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_CONTROLLER_FILE); } if (!class_exists($controllerClassName, true)) { throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_CONTROLLER_CLASS); } $controller = new $controllerClassName(\Innomatic\Core\InnomaticContainer::MODE_DOMAIN, $panelName); $this->container->setPanelController($controller); } else { switch ($desktopPanel) { case 'menu': include 'innomatic/desktop/layout/domain/' . $desktopPanel . '.php'; break; default: include $resource . '.php'; } } } else { if (strlen($this->session->get('INNOMATIC_AUTH_USER'))) { \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getProcessor()->getResponse()->addHeader('P3P', 'CP="CUR ADM OUR NOR STA NID"'); include 'innomatic/desktop/layout/domain/index.php'; } } }
public function execute($query) { $result = false; if ($this->opened) { $pieces = $this->splitSQL($query); for ($i = 0; $i < count($pieces); $i++) { if ($this->innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->dataAccess['queries'][] = $pieces[$i]; $debugCounter = $this->innomatic->getDbLoadTimer()->AdvanceCounter(); $this->innomatic->getDbLoadTimer()->Start($debugCounter . ': ' . $pieces[$i]); $resid = $this->doExecute($pieces[$i]); $this->innomatic->getDbLoadTimer()->Stop($debugCounter . ': ' . $pieces[$i]); if ($this->debug == true) { $this->log = new \Innomatic\Logging\Logger($this->dasn->getOption('logfile')); $this->log->logEvent('innomatic.dataaccess.execute', 'Executed query ' . $pieces[$i], \Innomatic\Logging\Logger::DEBUG); } } else { $resid = $this->doExecute($pieces[$i]); } if ($resid === false) { $this->lastError = 'Unable to execute query ' . $pieces[$i]; $this->log = new \Innomatic\Logging\Logger($this->dasn->getOption('logfile')); $this->log->logEvent('innomatic.dataaccess.execute', $this->lastError, \Innomatic\Logging\Logger::ERROR); $result = false; } elseif ($i == count($pieces) - 1 and $resid !== true) { $rsname = '\\Innomatic\\Dataaccess\\Drivers\\' . ucfirst(strtolower($this->driver)) . '\\' . ucfirst(strtolower($this->driver)) . 'DataAccessResult'; $result = new $rsname($resid); $this->lastError = ''; } else { $result = true; $this->lastError = ''; } } } else { $this->lastError = 'Database not connected'; $this->log = new \Innomatic\Logging\Logger($this->dasn->getOption('logfile')); $this->log->logEvent('innomatic.dataaccess.execute', $this->lastError, \Innomatic\Logging\Logger::ERROR); } return $result; }
public function shutdown($exit = true) { if ($this->state != \Innomatic\Core\InnomaticContainer::STATE_SETUP) { if (is_object($this->rootDb)) { $hook = new \Innomatic\Process\Hook($this->rootDb, 'innomatic', 'instance'); $null = ''; switch ($hook->callHooks('shutdown', $null, '')) { case \Innomatic\Process\Hook::RESULT_ABORT: $this->abort('Shutdown aborted'); break; } } } switch ($this->state) { case \Innomatic\Core\InnomaticContainer::STATE_DEBUG: if (is_object($this->loadTimer) and RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean() == true) { $this->loadTimer->Mark('end'); $log = $this->getLogger(); $log->logEvent('innomatic', 'Profiler total time: ' . $this->loadTimer->getTotalTime(), \Innomatic\Logging\Logger::DEBUG); $fh = @fopen($this->home . 'core/temp/pids/' . $this->pid, 'w'); if ($fh) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->snapshot(); @fwrite($fh, serialize($dump)); @fclose($fh); } } break; } if (!RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean()) { if (is_object($this->loadTimer)) { $this->loadTimer->Mark('end'); $log = $this->getLogger(); $log->logEvent('innomatic', 'Profiler total time: ' . $this->loadTimer->getTotalTime(), \Innomatic\Logging\Logger::DEBUG); } $fh = @fopen($this->home . 'core/temp/pids/' . $this->pid . '_coredump', 'w'); if ($fh) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->snapshot(); @fwrite($fh, serialize($dump)); @fclose($fh); } } if (!RootContainer::instance('\\Innomatic\\Core\\RootContainer')->isClean() or $this->state != \Innomatic\Core\InnomaticContainer::STATE_DEBUG and file_exists($this->home . 'core/temp/pids/' . $this->pid)) { @unlink($this->home . 'core/temp/pids/' . $this->pid); } if ($exit) { exit; } }
public function logEvent($contest, $eventstring, $type = \Innomatic\Logging\Logger::GENERIC) { $result = false; if (strlen($this->mLogFile) > 0) { $timestamp = time(); $date = getdate($timestamp); $log_event = false; switch ($type) { case \Innomatic\Logging\Logger::NOTICE: $evtype = 'NOTICE'; $log_event = true; break; case \Innomatic\Logging\Logger::WARNING: $evtype = 'WARNING'; $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); switch ($innomatic->getState()) { case \Innomatic\Core\InnomaticContainer::STATE_DEBUG: case \Innomatic\Core\InnomaticContainer::STATE_SETUP: $log_event = true; } break; case \Innomatic\Logging\Logger::ERROR: $evtype = 'ERROR'; $log_event = true; break; case \Innomatic\Logging\Logger::FAILURE: $evtype = 'FAILURE'; $log_event = true; break; case \Innomatic\Logging\Logger::GENERIC: $evtype = 'GENERIC'; $log_event = true; break; case \Innomatic\Logging\Logger::DEBUG: $evtype = 'DEBUG'; $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) { $log_event = true; } break; default: $evtype = 'UNDEFINED'; $log_event = true; break; } $logstr = ''; if ($log_event) { $logstr = sprintf("%04s/%02s/%02s - %02s:%02s:%02s - %s - %s : %s", $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], $date['seconds'], $evtype, $contest, $eventstring); //$logstr = "$date[mday]/$date[mon]/$date[year] - $date[hours]:$date[minutes]:$date[seconds] - ".$evtype." - ".$contest." : ".$eventstring; @error_log($logstr . "\n", 3, $this->mLogFile); $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) { $dump = \Innomatic\Debug\InnomaticDump::instance('\\Innomatic\\Debug\\InnomaticDump'); $dump->logs[$this->mLogFile][] = $logstr; } } $result = $logstr; if ($evtype == \Innomatic\Logging\Logger::FAILURE) { \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->abort($logstring); } } return $result; }