/**
  * handlePagina	controleer of er inloggegevens zijn gepost, zo ja, log in en redirect naar homepage
  * @throws WebsiteException
  */
 public function handlePagina()
 {
     // standaard wordt dit scherm getoond
     $oResult = $this;
     if (Registry::exists('Bezoeker')) {
         $oGebruiker = Registry::get('Bezoeker');
     } else {
         // gebruiker moet al bestaan, dus fout
         throw new WebsiteException('Gebruiker object bestaat niet');
     }
     if (!$oGebruiker->isIngelogd()) {
         // gebruiker was nog niet ingelogd
         $oValidator = InputValidator::instantiate();
         $oValidator->addValidation('gebruiker', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         $oValidator->addValidation('wachtwoord', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         if ($oValidator->validateAll() == InputValidator::RESULT_OK) {
             // inloggegevens gepost
             if ($oGebruiker->login($oValidator->getValue('gebruiker', InputValidator::SCOPE_POST), $oValidator->getValue('wachtwoord', InputValidator::SCOPE_POST))) {
                 // login gelukt
                 $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
             }
         }
     } else {
         // gebruiker was al eerder ingelogd, ga naar homepage
         $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
     }
     return $oResult;
 }
Example #2
0
 public static function addEntry($type, $action, $uid = FALSE)
 {
     if (\Registry::exists('LOGGER')) {
         $logger = \Registry::get('LOGGER');
     } else {
         $logger = new self();
         \Registry::set('LOGGER', $logger);
     }
     /*
     	eFiction 3 log types:
     	"RG" => _NEWREG
     	"ED" => _ADMINEDIT
     	"DL" => _ADMINDELETE
     	"VS" => _VALIDATESTORY
     	"LP"=> _LOSTPASSWORD
     	"BL" => _BADLOGIN
     	"RE" => "Reviews"
     	"AM" => "Admin Maintenance"
     	"EB" => _EDITBIO
     */
     // Force add entry
     $logger->reset();
     // Submitted data:
     $logger->type = $type;
     $logger->action = $action;
     // Use id of active user, unless specified
     $logger->uid = $uid ? $uid : $_SESSION['userID'];
     $logger->ip = $_SERVER['REMOTE_ADDR'];
     $logger->version = 2;
     // Add entry
     $test = $logger->save();
 }
Example #3
0
 /**
  * Construct DB\SQL
  * @return DB\SQL
  */
 public static function database($db = [])
 {
     if (!Registry::exists('database')) {
         $db = $db ?: Base::instance()->get('database');
         return Registry::set('database', new DB\SQL('mysql:host=' . $db['host'] . ';port=' . $db['port'] . ';dbname=' . $db['name'], $db['user'], $db['password']));
     }
     return Registry::get('database');
 }
Example #4
0
 /**
  *	Return class instance
  *	@return static
  **/
 static function instance()
 {
     if (!Registry::exists($class = get_called_class())) {
         $ref = new Reflectionclass($class);
         $args = func_get_args();
         Registry::set($class, $args ? $ref->newinstanceargs($args) : new $class());
     }
     return Registry::get($class);
 }
Example #5
0
 public static function instance()
 {
     if (\Registry::exists('CONFIG')) {
         $cfg = \Registry::get('CONFIG');
     } else {
         $cfg = new self();
         \Registry::set('CONFIG', $cfg);
     }
     return $cfg;
 }
 /**
  * bouwScherm bouwt het zoekresultaatscherm op
  * @param array $p_aGegevens geassocieerde array met artikelgegevens
  * @return boolean False als er iets mis is gegaan, anders true
  */
 public function bouwScherm()
 {
     if (Registry::exists('Exception')) {
         $oException = Registry::get('Exception');
         $this->m_sTemplate = 'error.tpl';
         $this->m_aData['exception'] = array('message' => $oException->getMessage(), 'trace' => $oException->getTraceAsString());
     } else {
         $this->m_sTemplate = 'error.tpl';
         $this->m_aData['exception'] = array('message' => 'Onbekende fout!', 'trace' => '');
     }
     return true;
 }
Example #7
0
 function setError($error, $error_number = '', $query = '')
 {
     if ($this->error_reporting === true) {
         $this->error = $error;
         $this->error_number = $error_number;
         $this->error_query = $query;
         error_log('[MYSQL] ' . $this->error . ' (' . $this->error_number . '): [QUERY] ' . $this->error_query);
         if (Registry::exists('MessageStack')) {
             Registry::get('MessageStack')->add('debug', $this->getError());
         }
     }
 }
Example #8
0
 public static function instance()
 {
     if (\Registry::exists('ICONSET')) {
         return \Registry::get('ICONSET');
     } else {
         $icon = new self();
         if (empty($icon->_name)) {
             $icon = self::rebuild($icon);
         }
         \Registry::set('ICONSET', $icon);
         return $icon;
     }
 }
 /**
  * handlePagina	controleer of er inloggegevens zijn gepost, zo ja, log in en redirect naar homepage
  * @throws WebsiteException
  */
 public function handlePagina()
 {
     // standaard wordt dit scherm getoond
     $oResult = $this;
     if (Registry::exists('Bezoeker')) {
         $oGebruiker = Registry::get('Bezoeker');
     } else {
         // gebruiker moet al bestaan, dus fout
         throw new WebsiteException('Gebruiker object bestaat niet');
     }
     if ($oGebruiker->isIngelogd()) {
         // Gebruiker wordt uitgelogd
         $oGebruiker->logout();
         $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::WELKOM);
     } else {
         // gebruiker was al eerder uitgelogd / niet ingelogd, ga naar homepage
         $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::WELKOM);
     }
     return $oResult;
 }
Example #10
0
 /**
  * Return the Administration Tool Application modules the administrator has access to
  *
  * @param int $id The ID of the administrator
  * @access public
  * @return array
  */
 public static function getUserLevels($id, $site = null)
 {
     if (empty($site)) {
         $site = OSCOM::getSite();
     }
     $data = array('id' => $id);
     $applications = array();
     foreach (OSCOM::callDB('GetAccessUserLevels', $data, 'Core') as $am) {
         $applications[] = $am['module'];
     }
     if (in_array('*', $applications)) {
         $applications = array();
         $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application');
         $DLapps->setIncludeFiles(false);
         foreach ($DLapps->getFiles() as $file) {
             if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) {
                 // HPDL remove preg_match
                 $applications[] = $file['name'];
             }
         }
     }
     $shortcuts = array();
     foreach (OSCOM::callDB('GetAccessUserShortcuts', $data, 'Core') as $as) {
         $shortcuts[] = $as['module'];
     }
     $levels = array();
     foreach ($applications as $app) {
         $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller';
         if (class_exists($application_class)) {
             if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) {
                 $OSCOM_Application = Registry::get('Application');
             } else {
                 Registry::get('Language')->loadIniFile($app . '.php');
                 $OSCOM_Application = new $application_class(false);
             }
             $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder());
         }
     }
     return $levels;
 }
Example #11
0
 /**
  * constructor
  * Deze constructor controleert of de gebruiker is ingelogd, is dat het geval,
  * dan wordt het ingelogde menu gecreeerd. Als de gebruiker de rechten admin heeft,
  * wordt het adminmenu gecreeerd.
  * @param string $p_sTitel De getoonde titel op het scherm
  * @param array $p_aRechten array bevat alle benodigde rechten om deze pagina op te roepen. Een lege array 
  * @throws InsufficientRightsException
  */
 public function __construct($p_sTitel, $p_aRechten)
 {
     $this->m_sTitel = $p_sTitel;
     $this->m_sHTML = '';
     $this->m_aData = array();
     $this->m_aScripts = array();
     $this->m_oSmarty = null;
     $this->m_sTemplate = '';
     if (is_array($p_aRechten)) {
         $this->m_aBenodigdeRechten = $p_aRechten;
     } else {
         $this->m_aBenodigdeRechten = array(Gebruiker::TOEGANG_GEWEIGERD);
     }
     // genereer het menu aan de hand van de gebruikerrechten
     if (Registry::exists('Bezoeker')) {
         $this->m_oGebruiker = Registry::get('Bezoeker');
         if ($this->m_oGebruiker->isIngelogd()) {
             $oValidator = InputValidator::instantiate();
             $nPagina = intVal($oValidator->getValue('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST));
             if ($nPagina >= MenuGenerator::BEHEER) {
                 $aRechten = $this->m_oGebruiker->__get('Rechten');
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEHEER, $aRechten);
                 if (!$this->checkRechten()) {
                     // genereer een Exception zodat dit scherm nooit per ongeluk getoond kan worden
                     throw new OnvoldoendeRechtenException('Pagina ' . $p_sTitel);
                 }
             } else {
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
             }
         } else {
             $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
         }
     } else {
         $this->m_oGebruiker = null;
     }
 }
Example #12
0
 /**
  * @param $cid
  * @return CortexCollection
  */
 public static function instance($cid)
 {
     if (!\Registry::exists($cid)) {
         trigger_error(sprintf(self::E_UnknownCID, $cid));
     }
     return \Registry::get($cid);
 }
Example #13
0
 /**
  * creates and caches related mapper objects
  * @param string $model
  * @param array $relConf
  * @param string $key
  * @param bool $pushFilter
  * @return Cortex
  */
 protected function getRelInstance($model = null, $relConf = null, $key = '', $pushFilter = false)
 {
     if (!$model && !$relConf) {
         trigger_error(self::E_MISSING_REL_CONF);
     }
     $relConf = $model ? $model::resolveConfiguration() : $relConf;
     $relName = ($model ?: 'Cortex') . '\\' . $relConf['db']->uuid() . '\\' . $relConf['table'] . '\\' . $key;
     if (\Registry::exists($relName)) {
         $rel = \Registry::get($relName);
         $rel->reset();
     } else {
         $rel = $model ? new $model() : new Cortex($relConf['db'], $relConf['table']);
         if (!$rel instanceof Cortex) {
             trigger_error(self::E_WRONG_RELATION_CLASS);
         }
         \Registry::set($relName, $rel);
     }
     // restrict fields of related mapper
     if (!empty($key) && isset($this->relWhitelist[$key])) {
         if (isset($this->relWhitelist[$key][0])) {
             $rel->fields($this->relWhitelist[$key][0], false);
         }
         if (isset($this->relWhitelist[$key][1])) {
             $rel->fields($this->relWhitelist[$key][1], true);
         }
     }
     if ($pushFilter && !empty($key)) {
         if (isset($this->relFilter[$key . '.'])) {
             foreach ($this->relFilter[$key . '.'] as $fkey => $conf) {
                 $rel->filter($fkey, $conf[0], $conf[1]);
             }
         }
         if (isset($this->hasCond[$key . '.'])) {
             foreach ($this->hasCond[$key . '.'] as $fkey => $conf) {
                 $rel->has($fkey, $conf[0], $conf[1]);
             }
         }
     }
     return $rel;
 }
Example #14
0
/**
 * Return an internal URL address.
 *
 * @param string $site The Site to link to. Default: The currently used Site.
 * @param string $application The Site Application to link to. Default: The currently used Site Application.
 * @param string $parameters Parameters to add to the link. Example: key1=value1&key2=value2
 * @param string $connection The type of connection to use for the link. Values: NONSSL, SSL, AUTO. Default: NONSSL.
 * @param bool $add_session_id Add the session ID to the link. Default: True.
 * @param bool $search_engine_safe Use search engine safe URLs. Default: True.
 * @return string The URL address.
 */

    public static function getLink($site = null, $application = null, $parameters = null, $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
      if ( empty($site) ) {
        $site = static::getSite();
      }

      if ( empty($application) && ($site == static::getSite()) ) {
        $application = static::getSiteApplication();
      }

      if ( !in_array($connection, array('NONSSL', 'SSL', 'AUTO')) ) {
        $connection = 'NONSSL';
      }

      if ( !is_bool($add_session_id) ) {
        $add_session_id = true;
      }

      if ( !is_bool($search_engine_safe) ) {
        $search_engine_safe = true;
      }

// Wrapper for RPC links; RPC cannot perform cross domain requests
      $real_site = ($site == 'RPC') ? $application : $site;

      if ( $connection == 'AUTO' ) {
        if ( (static::getRequestType() == 'SSL') && (static::getConfig('enable_ssl', $real_site) == 'true') ) {
          $link = static::getConfig('https_server', $real_site) . static::getConfig('dir_ws_https_server', $real_site);
        } else {
          $link = static::getConfig('http_server', $real_site) . static::getConfig('dir_ws_http_server', $real_site);
        }
      } elseif ( ($connection == 'SSL') && (static::getConfig('enable_ssl', $real_site) == 'true') ) {
        $link = static::getConfig('https_server', $real_site) . static::getConfig('dir_ws_https_server', $real_site);
      } else {
        $link = static::getConfig('http_server', $real_site) . static::getConfig('dir_ws_http_server', $real_site);
      }

      $link .= static::getConfig('bootstrap_file', 'OSCOM') . '?';

      if ( $site != static::getDefaultSite() ) {
        $link .= $site . '&';
      }

      if ( !empty($application) && ($application != static::getDefaultSiteApplication()) ) {
        $link .= $application . '&';
      }

      if ( !empty($parameters) ) {
        $link .= HTML::output($parameters) . '&';
      }

      if ( ($add_session_id === true) && Registry::exists('Session') && Registry::get('Session')->hasStarted() && (SERVICE_SESSION_FORCE_COOKIE_USAGE == '-1') ) {
        if ( strlen(SID) > 0 ) {
          $_sid = SID;
        } elseif ( ((static::getRequestType() == 'NONSSL') && ($connection == 'SSL') && (static::getConfig('enable_ssl', $site) == 'true')) || ((static::getRequestType() == 'SSL') && ($connection != 'SSL')) ) {
          if ( static::getConfig('http_cookie_domain', $site) != static::getConfig('https_cookie_domain', $site) ) {
            $_sid = Registry::get('Session')->getName() . '=' . Registry::get('Session')->getID();
          }
        }
      }

      if ( isset($_sid) ) {
        $link .= HTML::output($_sid);
      }

      while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) {
        $link = substr($link, 0, -1);
      }

      if ( ($search_engine_safe === true) && Registry::exists('osC_Services') && Registry::get('osC_Services')->isStarted('sefu') ) {
        $link = str_replace(array('?', '&', '='), array('/', '/', ','), $link);
      }

      return $link;
    }
Example #15
0
 /**
  * Return an internal URL address.
  *
  * @param string $site The Site to link to. Default: The currently used Site.
  * @param string $application The Site Application to link to. Default: The currently used Site Application.
  * @param string $parameters Parameters to add to the link. Example: key1=value1&key2=value2
  * @param string $connection The type of connection to use for the link. Values: NONSSL, SSL, AUTO. Default: NONSSL.
  * @param bool $add_session_id Add the session ID to the link. Default: True.
  * @param bool $search_engine_safe Use search engine safe URLs. Default: True.
  * @return string The URL address.
  */
 public static function getLink($site = null, $application = null, $parameters = null, $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true)
 {
     if (empty($site)) {
         $site = self::getSite();
     }
     if (empty($application) && $site == self::getSite()) {
         $application = self::getSiteApplication();
     }
     if (!in_array($connection, array('NONSSL', 'SSL', 'AUTO'))) {
         $connection = 'NONSSL';
     }
     if (!is_bool($add_session_id)) {
         $add_session_id = true;
     }
     if (!is_bool($search_engine_safe)) {
         $search_engine_safe = true;
     }
     if ($connection == 'AUTO') {
         if (self::getRequestType() == 'SSL' && ENABLE_SSL === true) {
             $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
         } else {
             $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
         }
     } elseif ($connection == 'SSL' && ENABLE_SSL === true) {
         $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
     } else {
         $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
     }
     $link .= OSCOM_BOOTSTRAP_FILE . '?';
     if ($site != self::getDefaultSite()) {
         $link .= $site . '&';
     }
     if (!empty($application)) {
         $link .= $application . '&';
     }
     if (!empty($parameters)) {
         $link .= $parameters . '&';
     }
     if ($add_session_id === true && Registry::exists('Session') && Registry::get('Session')->hasStarted() && SERVICE_SESSION_FORCE_COOKIE_USAGE == '-1') {
         if (strlen(SID) > 0) {
             $_sid = SID;
         } elseif (self::getRequestType() == 'NONSSL' && $connection == 'SSL' && ENABLE_SSL === true || self::getRequestType() == 'SSL' && $connection != 'SSL') {
             if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
                 $_sid = Registry::get('Session')->getName() . '=' . Registry::get('Session')->getID();
             }
         }
     }
     if (isset($_sid)) {
         $link .= osc_output_string($_sid);
     }
     while (substr($link, -1) == '&' || substr($link, -1) == '?') {
         $link = substr($link, 0, -1);
     }
     if ($search_engine_safe === true && Registry::exists('osC_Services') && Registry::get('osC_Services')->isStarted('sefu')) {
         $link = str_replace(array('?', '&', '='), array('/', '/', ','), $link);
     }
     return $link;
 }
Example #16
0
 protected function exists($key)
 {
     return parent::exists($key) || isset($this->services[$key]);
 }
Example #17
0
 /**
 		Return class instance
 		@return object
 	**/
 static function instance()
 {
     if (!Registry::exists($class = get_called_class())) {
         Registry::set($class, new $class());
     }
     return Registry::get($class);
 }
Example #18
0
 /**
  * tasks for the application once run.
  *
  * @return void
  */
 public static function finish()
 {
     // log script execution time if debugging
     $f3 = \Base::instance();
     $debug = $f3->get('DEBUG');
     if (\Registry::exists('logger')) {
         $logger = \Registry::get('logger');
     }
     if (!empty($logger) && is_object($logger) && $debug || 'production' !== $f3->get('app.env')) {
         // log database transactions if level 3
         $db = \Registry::get('db');
         if (3 <= $debug && method_exists($logger, 'write') && method_exists($db, 'log')) {
             $logger->write($db->log(), $f3->get('log.date'));
         }
         $execution_time = round(microtime(true) - $f3->get('TIME'), 3);
         $params = $f3->get('PARAMS');
         $params = is_array($params) && !empty($params[0]) ? $params[0] : '';
         $logger->write('Script ' . $params . ' executed in ' . $execution_time . ' seconds using ' . round(memory_get_usage() / 1024 / 1024, 2) . '/' . round(memory_get_peak_usage() / 1024 / 1024, 2) . ' MB memory/peak', $f3->get('log.date'));
     }
     // http://php.net/manual/en/function.ob-end-flush.php
     while (ob_get_level()) {
         @ob_end_flush();
         @flush();
     }
 }
Example #19
0
 /**
  * Return the Administration Tool Application modules the administrator has access to
  *
  * @param int $id The ID of the administrator
  * @access public
  * @return array
  */
 public static function getUserLevels($id, $site = null)
 {
     $OSCOM_Database = Registry::get('Database');
     if (empty($site)) {
         $site = OSCOM::getSite();
     }
     $applications = array();
     $Qaccess = $OSCOM_Database->query('select module from :table_administrators_access where administrators_id = :administrators_id');
     $Qaccess->bindInt(':administrators_id', $id);
     $Qaccess->execute();
     while ($Qaccess->next()) {
         $applications[] = $Qaccess->value('module');
     }
     if (in_array('*', $applications)) {
         $applications = array();
         $DLapps = new DirectoryListing(OSCOM::BASE_DIRECTORY . 'Core/Site/' . $site . '/Application');
         $DLapps->setIncludeFiles(false);
         foreach ($DLapps->getFiles() as $file) {
             if (preg_match('/[A-Z]/', substr($file['name'], 0, 1)) && !in_array($file['name'], call_user_func(array('osCommerce\\OM\\Core\\Site\\' . $site . '\\Controller', 'getGuestApplications'))) && file_exists($DLapps->getDirectory() . '/' . $file['name'] . '/Controller.php')) {
                 // HPDL remove preg_match
                 $applications[] = $file['name'];
             }
         }
     }
     $shortcuts = array();
     $Qshortcuts = $OSCOM_Database->query('select module from :table_administrator_shortcuts where administrators_id = :administrators_id');
     $Qshortcuts->bindInt(':administrators_id', $id);
     $Qshortcuts->execute();
     while ($Qshortcuts->next()) {
         $shortcuts[] = $Qshortcuts->value('module');
     }
     $levels = array();
     foreach ($applications as $app) {
         $application_class = 'osCommerce\\OM\\Core\\Site\\' . $site . '\\Application\\' . $app . '\\Controller';
         if (class_exists($application_class)) {
             if (Registry::exists('Application') && $app == OSCOM::getSiteApplication()) {
                 $OSCOM_Application = Registry::get('Application');
             } else {
                 Registry::get('Language')->loadIniFile($app . '.php');
                 $OSCOM_Application = new $application_class(false);
             }
             $levels[$app] = array('module' => $app, 'icon' => $OSCOM_Application->getIcon(), 'title' => $OSCOM_Application->getTitle(), 'group' => $OSCOM_Application->getGroup(), 'linkable' => $OSCOM_Application->canLinkTo(), 'shortcut' => in_array($app, $shortcuts), 'sort_order' => $OSCOM_Application->getSortOrder());
         }
     }
     return $levels;
 }