コード例 #1
0
ファイル: Indexer.php プロジェクト: bombayworks/currycms
 /**
  * Rebuild search index using a single request.
  *
  * @throws Exception
  */
 public function showRebuildAll()
 {
     if (URL::validate()) {
         // Override and increase max execution time if set
         $timeLimit = ini_get('max_execution_time');
         if ($timeLimit && $timeLimit < 250) {
             @set_time_limit(250);
         }
         Curry_Backend_Indexer::initRebuild();
         Curry_Backend_Indexer::doRebuild();
         $ses = new \Zend\Session\Container(__CLASS__);
         if ($ses->failed) {
             $this->addMessage($ses->failed . ' entries failed indexing.', self::MSG_WARNING);
         }
         $this->addMainMenu();
         $this->addMessage('Search index rebuilt, ' . $ses->success . ' entries updated successfully.', self::MSG_SUCCESS);
     } else {
         throw new Exception('Invalid rebuild link!');
     }
 }
コード例 #2
0
ファイル: URLTest.php プロジェクト: bombayworks/currycms
 public function testSecure()
 {
     $secret = sha1(self::TEST_URL);
     $url = new \Curry\URL(self::TEST_URL);
     $secureUrl = $url->getAbsolute('&', $secret);
     $url = new \Curry\URL($secureUrl);
     $this->assertNotEmpty($url->getVar('hash'));
     $this->assertTrue($url->isValid($secret));
     \Curry\URL::setDefaultSecret(sha1($secret));
     $url = new \Curry\URL(self::TEST_URL);
     $secureUrl = $url->getAbsolute('&', true);
     $url = new \Curry\URL($secureUrl);
     $this->assertNotEmpty($url->getVar('hash'));
     $this->assertTrue($url->isValid());
 }
コード例 #3
0
ファイル: App.php プロジェクト: bombayworks/currycms
 /**
  * Send error notification email.
  *
  * @param Exception $e
  */
 public function sendErrorNotification(Exception $e, Inspector $inspector, Run $run)
 {
     try {
         // Create form to recreate error
         $method = strtoupper($_SERVER['REQUEST_METHOD']);
         $hidden = Html::createHiddenFields($method == 'POST' ? $_POST : $_GET);
         $action = url(URL::getRequestUri())->getAbsolute();
         $form = '<form action="' . $action . '" method="' . $method . '">' . $hidden . '<button type="submit">Execute</button></form>';
         // Compose mail
         $content = '<html><body>' . '<h1>' . get_class($e) . '</h1>' . '<h2>' . htmlspecialchars($e->getMessage()) . '</h2>' . '<p><strong>Method:</strong> ' . $method . '<br/>' . '<strong>URL:</strong> ' . $action . '<br/>' . '<strong>File:</strong> ' . htmlspecialchars($e->getFile()) . '(' . $e->getLine() . ')</p>' . '<h2>Recreate</h2>' . $form . '<h2>Trace</h2>' . '<pre>' . htmlspecialchars($e->getTraceAsString()) . '</pre>' . '<h2>Variables</h2>' . '<h3>$_GET</h3>' . '<pre>' . htmlspecialchars(print_r($_GET, true)) . '</pre>' . '<h3>$_POST</h3>' . '<pre>' . htmlspecialchars(print_r($_POST, true)) . '</pre>' . '<h3>$_SERVER</h3>' . '<pre>' . htmlspecialchars(print_r($_SERVER, true)) . '</pre>' . '</body></html>';
         // Create and send mail
         $mail = new Mail();
         $mail->addTo($this['adminEmail']);
         $mail->setSubject('Error on ' . $this['name']);
         $mail->setBodyHtml($content);
         $mail->send();
         $this->logger->info('Sent error notification');
     } catch (Exception $e) {
         $this->logger->error('Failed to send error notification');
     }
     return Handler::DONE;
 }
コード例 #4
0
ファイル: App.php プロジェクト: bombayworks/currycms
 /**
  * Global helper function for creating URLs.
  *
  * This is a helper function for the Curry\URL-class. The first parameter
  * specifies the URL, if empty the current url will be used.
  *
  * The second parameter is an array of query-string variables to be added
  * to the URL. You can specify key=>value pairs, or if you specify a value 'foo'
  * (ie numerical key) the corresponding $_GET['foo'] value will be used.
  *
  * @param string $url	URL path
  * @param array $vars	Additional query-string variables
  * @return URL
  */
 function url($url = "", array $vars = array())
 {
     $url = new \Curry\URL($url);
     $url->add($vars);
     return $url;
 }
コード例 #5
0
ファイル: Frontend.php プロジェクト: bombayworks/currycms
 /**
  * Handler for reverse-routing.
  *
  * @param string $path
  * @param string|array $query
  */
 public function reverseRoute(&$path, &$query)
 {
     // remove matching base path
     $baseUrl = URL::getDefaultBaseUrl();
     $basePath = $baseUrl['path'];
     $basePathRemoved = false;
     if (StringHelper::startsWith($path, $basePath) && $path !== '/') {
         $path = substr($path, strlen($basePath));
         $basePathRemoved = true;
     }
     //\Curry_Route_ModelRoute::reverse($path, $query);
     // re-add base path if it was removed
     if ($basePathRemoved) {
         $path = $basePath . $path;
     }
 }
コード例 #6
0
ファイル: Database.php プロジェクト: bombayworks/currycms
 /**
  * Restore from file, using _GET request. 
  * 
  * @todo Verify this is working and that it's secure. Can we do this using session variables instead? 
  */
 public function showContinueRestore()
 {
     if (!URL::validate()) {
         throw new Exception('Invalid hash');
     }
     Curry_Backend_DatabaseHelper::restoreFromFile($_GET['file'], $_GET['tables'], $_GET['max_execution_time'], $_GET['line'], $this);
 }