예제 #1
0
파일: Article.php 프로젝트: alphadevx/alpha
 /**
  * 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();
 }
예제 #2
0
파일: KPI.php 프로젝트: alphadevx/alpha
 /**
  * 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));
 }
예제 #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;
 }
예제 #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;
     }
 }
예제 #5
0
 /**
  * Method to render the reset password HTML form.
  *
  * @return string
  *
  * @since 1.0
  */
 public function displayResetForm()
 {
     $config = ConfigProvider::getInstance();
     $html = '<div class="bordered padded">';
     $html .= '<h1>Password reset</h1>';
     $html .= '<p>If you have forgotten your password, you can use this form to have a new password automatically generated and sent to your e-mail address.</p>';
     $html .= '<form action="' . FrontController::generateSecureURL('act=Alpha\\Controller\\LoginController&reset=true') . '" method="POST" id="resetForm" accept-charset="UTF-8">';
     $request = new Request(array('method' => 'GET'));
     $email = new String($request->getParam('email', ''));
     $email->setRule(Validator::REQUIRED_EMAIL);
     $email->setSize(70);
     $email->setHelper('Please provide a valid e-mail address!');
     $stringBox = new StringBox($email, $this->BO->getDataLabel('email'), 'email', 'resetForm', '50');
     $html .= $stringBox->render();
     $html .= '<div class="form-group lower spread">';
     $temp = new Button('submit', 'Reset Password', 'resetBut');
     $html .= $temp->render();
     $temp = new Button("document.location.replace('" . $config->get('app.url') . "')", 'Cancel', 'cancelBut');
     $html .= $temp->render();
     $html .= '</div>';
     $html .= $this->renderSecurityFields();
     $html .= '</form>';
     $html .= '</div>';
     return $html;
 }
예제 #6
0
파일: Person.php 프로젝트: alphadevx/alpha
 /**
  * Setter for displayName.
  *
  * @param string $displayName
  *
  * @since 1.0
  */
 public function setDisplayName($displayName)
 {
     $this->displayName->setValue($displayName);
 }