public  function ifIs($paramStr, $valid = NULL)
  {
    /* hole wert */
    $value    = $this->m_cParam->extractValue($paramStr);

    /* validiere den Wert */
    if (isset($valid) == true) {
      try {
        CSecure::validData($value, $valid);

        /* kein fehler, es ist okay */
        return true;
      }
      /* fehler beim validiren, false */
      catch (CError $error) {
        return false;
      }
    }

    /* wenn nicht validiert, gebe wert zurück */
    return $value;
  }
  private function updateActiveEvent()
  {
    foreach ($this->m_eventParam as $event => &$param) {
      try {
        $value    = $this->m_cParam->extractValue($param["value"]);

        /* soll es mit valid geprüft werden? */
        if (array_key_exists("valid", $param) == true) {
          CSecure::validData($value, $param["valid"]);
          $this->m_activeEvent[$event]  = true;
        }
        /*-
         * sonst, event ist aktive wenn wert nicht empty() */
        else {
          if (empty($value) == false) {
            $this->m_activeEvent[$event]  = true;
          } 
        }
      }
      catch(CError $error) {
        /* mache nichts, warscheindlich sind daten noch nicht abrufbar 
         * Zeige nur den ERROR_PARAM_INVALID, da dort wohl ein fehler ist,
         * und nie erfolgreich sein wird */
        if ($error->m_errCode == ERROR_PARAM_INVALID) {
          throw $error;
        }
      }
    }
  }
  public  function loadSession()
  {
    $cooName    = &$this->m_confXml["cookname"]["xmlValue"];

    /*-
     * exists a Coookie with session? None, create a new session */
    if (array_key_exists($cooName, $_COOKIE) == false) {

      /* get new session id */
      $this->createNewSessionId();

      /* set default user id with SysKey */
      $this->setSessionValue("userid", 
        $this->m_confXml["defaultuserid"]["xmlValue"],
        $this->m_sysKey);

      /* set cookie */
      if (setcookie($cooName,
          $this->m_sessId,
          $this->m_confXml["sessionvalid"]["xmlValue"] * 60 * 60 + time(),
          $this->m_confXml["path"]["xmlValue"],
          $this->m_confXml["domain"]["xmlValue"],
          $this->m_confXml["secureonly"]["xmlValue"],
          true) == false) {
        throw new CError(ERROR_SET_COOKIE);
      }
    }
    /*-
     * init current session */
    else {
      $exp  = $this->m_confXml["sessionvalid"]["xmlValue"] * 60 * 60;

      /* secure test of valid sessid */
      try {
        CSecure::validData($_COOKIE[$cooName], "word");
      }
      catch (CError $error) {
        throw new CError(ERROR_INVALID_SESSION, array($_SERVER["REMOTE_ADDR"]));
      }

      /* set default values */
      $this->m_sessId    = $_COOKIE[$cooName];
      $this->m_sessFile .= $this->m_sessId;

      /* if server session expire, invalid cookie! */
      if (filectime($this->m_sessFile) + $exp <= time()) {
        unlink($this->m_sessFile);
        throw new CError(ERROR_INVALID_SESSION, array($_SERVER["REMOTE_ADDR"]));
      }

      /* load data */
      $this->loadSessionData();
    }
  }
示例#4
0
  private function addNodeToGlob(&$getArr)
  {
    $getName  = &$getArr["xmlValue"];
    $getValue = &$_GET[$getName];

    if (isset($getValue) == false) {
      return;
    }

    /*-
     * Valid / Filter / Guard -> check -> add */
    try {
      /*-
       * check Valid */
      if (array_key_exists("valid", $getArr["xmlAttribute"]) == true) {
        $setValid = &$getArr["xmlAttribute"]["valid"];
        CSecure::validData($getValue, $setValid);
      }

      /*-
       * filter value */
      if (array_key_exists("filter", $getArr["xmlAttribute"]) == true) {
        $filter    = &$getArr["xmlAttribute"]["filter"];

        CSecure::filterData($getValue, $filter);
      }
      
      /*-
       * Guard */
      if (strtolower($getArr["xmlAttribute"]["guard"]) != "off") {
        CSecure::guard($getValue);
      }

      /*-
       * If you use a key for protect the value */
      $key    = $this->getKey($getArr["xmlAttribute"]);

      /**
       * add to Glob */
      $this->m_cGlob->setGet($getName, $getValue, $key);

    }
    catch (CError $error) {
      if ($this->confXml["usestrict"]["xmlValue"] == true) {
        throw new CError(ERROR_GET_VALID, array($getName, 
                          $error->getMessage()));
      }
    }
  }