Ejemplo n.º 1
0
 /**
  * Set up the transient URL attributes for the article after it has loaded.
  *
  * @since 1.0
  */
 protected function after_load_callback()
 {
     $config = ConfigProvider::getInstance();
     $this->URL = $config->get('app.url') . '/a/' . str_replace(' ', $config->get('cms.url.title.separator'), $this->title->getValue());
     $this->printURL = $config->get('app.url') . '/a/' . str_replace(' ', $config->get('cms.url.title.separator'), $this->title->getValue()) . '/print';
     $this->setupRels();
 }
Ejemplo n.º 2
0
 /**
  * Writes a step in the KPI event to a log file named logs/kpi-'.$this->name->getValue().'.csv, which will be created if it does
  * not exist.
  *
  * @since 1.1
  */
 public function logStep($stepName)
 {
     $config = ConfigProvider::getInstance();
     $this->endTime = microtime(true);
     $this->duration = $this->endTime - $this->startTime;
     $logfile = new LogProviderFile();
     $logfile->setPath($config->get('app.file.store.dir') . 'logs/kpi-' . $this->name->getValue() . '.csv');
     $logfile->setMaxSize($config->get('app.log.file.max.size'));
     $logfile->writeLine(array($this->timeStamp, $this->name->getValue() . ' [' . $stepName . ']', $this->sessionID, $this->startTime, $this->endTime, $this->duration));
 }
Ejemplo n.º 3
0
 /**
  * Renders the HTML and javascript for the string box.
  *
  * @param bool $readOnly set to true to make the text box readonly (defaults to false)
  *
  * @return string
  *
  * @since 1.0
  */
 public function render($readOnly = false)
 {
     $request = new Request(array('method' => 'GET'));
     $html = '<div class="form-group">';
     $html .= '  <label for="' . $this->name . '">' . $this->label . '</label>';
     $html .= '  <input ' . ($this->stringObject->checkIsPassword() ? 'type="password"' : 'type="text"') . ($this->size == 0 ? ' style="width:100%;"' : ' size="' . $this->size . '"') . ' maxlength="' . String::MAX_SIZE . '" name="' . $this->name . '" id="' . $this->name . '" value="' . ($request->getParam($this->name, false) && $this->stringObject->getValue() == '' && !$this->stringObject->checkIsPassword() ? $request->getParam($this->name) : $this->stringObject->getValue()) . '" class="form-control"' . ($readOnly ? ' disabled="disabled"' : '') . '/>';
     if ($this->stringObject->getRule() != '') {
         $html .= '  <input type="hidden" id="' . $this->name . '_msg" value="' . $this->stringObject->getHelper() . '"/>';
         $html .= '  <input type="hidden" id="' . $this->name . '_rule" value="' . $this->stringObject->getRule() . '"/>';
     }
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 4
0
 /**
  * Gets the count of bad requests for the client with this IP and client string in the past
  * configurable period (security.client.temp.blacklist.filter.period).
  *
  * @return int
  *
  * @since 1.0
  *
  * @throws Alpha\Exception\AlphaException
  */
 public function getBadRequestCount()
 {
     $config = ConfigProvider::getInstance();
     // the datetime interval syntax between MySQL and SQLite3 is a little different
     if ($config->get('db.provider.name') == 'Alpha\\Model\\ActiveRecordProviderMySQL') {
         $sqlQuery = 'SELECT COUNT(OID) AS request_count FROM ' . $this->getTableName() . " WHERE IP = '" . $this->IP->getValue() . "' AND client = '" . $this->client->getValue() . "' AND created_ts > NOW()-INTERVAL '" . $config->get('security.client.temp.blacklist.filter.period') . "' MINUTE";
     } else {
         $sqlQuery = 'SELECT COUNT(OID) AS request_count FROM ' . $this->getTableName() . " WHERE IP = '" . $this->IP->getValue() . "' AND client = '" . $this->client->getValue() . "' AND created_ts > datetime('now', '-" . $config->get('security.client.temp.blacklist.filter.period') . " MINUTES')";
     }
     $result = $this->query($sqlQuery);
     if (isset($result[0])) {
         $row = $result[0];
     } else {
         throw new AlphaException('No result set returned when querying the bad request table');
     }
     if (isset($row['request_count'])) {
         return $row['request_count'];
     } else {
         return 0;
     }
 }