Test if URL rewriting is working.
コード例 #1
0
ファイル: ElggRewriteTester.php プロジェクト: ibou77/elgg
 /**
  * Run the rewrite test and return a status array
  *
  * @param string $url  URL of rewrite test
  * @param string $path Root directory of Elgg with trailing slash
  *
  * @return array
  */
 public function run($url, $path)
 {
     $this->webserver = \ElggRewriteTester::guessWebServer();
     $this->rewriteTestPassed = $this->runRewriteTest($url);
     if ($this->rewriteTestPassed == FALSE) {
         if ($this->webserver == 'apache' || $this->webserver == 'unknown') {
             if ($this->createHtaccess($url, $path)) {
                 $this->rewriteTestPassed = $this->runRewriteTest($url);
             }
         }
     }
     return $this->returnStatus($url);
 }
コード例 #2
0
ファイル: ElggInstaller.php プロジェクト: nogsus/Elgg
 /**
  * Confirm that the rewrite rules are firing
  *
  * @param array &$report The requirements report array
  *
  * @return void
  */
 protected function checkRewriteRules(&$report)
 {
     global $CONFIG;
     $tester = new ElggRewriteTester();
     $url = elgg_get_site_url() . "rewrite.php";
     $report['rewrite'] = array($tester->run($url, $CONFIG->path));
 }
コード例 #3
0
ファイル: ElggInstaller.php プロジェクト: elgg/elgg
 /**
  * Confirm that the rewrite rules are firing
  *
  * @param array &$report The requirements report array
  *
  * @return void
  */
 protected function checkRewriteRules(&$report)
 {
     $tester = new ElggRewriteTester();
     $url = _elgg_services()->config->getSiteUrl() . "rewrite.php";
     $report['rewrite'] = array($tester->run($url, Directory\Local::root()->getPath()));
 }
コード例 #4
0
ファイル: Application.php プロジェクト: 007arunwilson/Elgg
 /**
  * Elgg upgrade script.
  *
  * This script triggers any necessary upgrades. If the site has been upgraded
  * to the most recent version of the code, no upgrades are run but the caches
  * are flushed.
  *
  * Upgrades use a table {db_prefix}upgrade_lock as a mutex to prevent concurrent upgrades.
  *
  * The URL to forward to after upgrades are complete can be specified by setting $_GET['forward']
  * to a relative URL.
  * 
  * @return void
  */
 public static function upgrade()
 {
     // we want to know if an error occurs
     ini_set('display_errors', 1);
     define('UPGRADING', 'upgrading');
     self::start();
     $site_url = elgg_get_config('url');
     $site_host = parse_url($site_url, PHP_URL_HOST) . '/';
     // turn any full in-site URLs into absolute paths
     $forward_url = get_input('forward', '/admin', false);
     $forward_url = str_replace(array($site_url, $site_host), '/', $forward_url);
     if (strpos($forward_url, '/') !== 0) {
         $forward_url = '/' . $forward_url;
     }
     if (get_input('upgrade') == 'upgrade') {
         $upgrader = new \Elgg\UpgradeService();
         $result = $upgrader->run();
         if ($result['failure'] == true) {
             register_error($result['reason']);
             forward($forward_url);
         }
     } else {
         $rewriteTester = new \ElggRewriteTester();
         $url = elgg_get_site_url() . "__testing_rewrite?__testing_rewrite=1";
         if (!$rewriteTester->runRewriteTest($url)) {
             // see if there is a problem accessing the site at all
             // due to ip restrictions for example
             if (!$rewriteTester->runLocalhostAccessTest()) {
                 // note: translation may not be available until after upgrade
                 $msg = elgg_echo("installation:htaccess:localhost:connectionfailed");
                 if ($msg === "installation:htaccess:localhost:connectionfailed") {
                     $msg = "Elgg cannot connect to itself to test rewrite rules properly. Check " . "that curl is working and there are no IP restrictions preventing " . "localhost connections.";
                 }
                 echo $msg;
                 exit;
             }
             // note: translation may not be available until after upgrade
             $msg = elgg_echo("installation:htaccess:needs_upgrade");
             if ($msg === "installation:htaccess:needs_upgrade") {
                 $msg = "You must update your .htaccess file so that the path is injected " . "into the GET parameter __elgg_uri (you can use install/config/htaccess.dist as a guide).";
             }
             echo $msg;
             exit;
         }
         $vars = array('forward' => $forward_url);
         // reset cache to have latest translations available during upgrade
         elgg_reset_system_cache();
         echo elgg_view_page(elgg_echo('upgrading'), '', 'upgrade', $vars);
         exit;
     }
     forward($forward_url);
 }
コード例 #5
0
ファイル: upgrade.php プロジェクト: ibou77/elgg
if (strpos($forward_url, '/') !== 0) {
    $forward_url = '/' . $forward_url;
}
if (get_input('upgrade') == 'upgrade') {
    $upgrader = new \Elgg\UpgradeService();
    $result = $upgrader->run();
    if ($result['failure'] == true) {
        register_error($result['reason']);
        forward($forward_url);
    }
} else {
    // test the URL rewrite rules
    if (!class_exists('ElggRewriteTester')) {
        require dirname(__FILE__) . '/install/ElggRewriteTester.php';
    }
    $rewriteTester = new \ElggRewriteTester();
    $url = elgg_get_site_url() . "__testing_rewrite?__testing_rewrite=1";
    if (!$rewriteTester->runRewriteTest($url)) {
        // see if there is a problem accessing the site at all
        // due to ip restrictions for example
        if (!$rewriteTester->runLocalhostAccessTest()) {
            // note: translation may not be available until after upgrade
            $msg = elgg_echo("installation:htaccess:localhost:connectionfailed");
            if ($msg === "installation:htaccess:localhost:connectionfailed") {
                $msg = "Elgg cannot connect to itself to test rewrite rules properly. Check " . "that curl is working and there are no IP restrictions preventing " . "localhost connections.";
            }
            echo $msg;
            exit;
        }
        // note: translation may not be available until after upgrade
        $msg = elgg_echo("installation:htaccess:needs_upgrade");
コード例 #6
0
ファイル: ElggInstaller.php プロジェクト: gzachos/elgg_ellak
 /**
  * Confirm that the rewrite rules are firing
  *
  * @param array &$report The requirements report array
  *
  * @return void
  */
 protected function checkRewriteRules(&$report)
 {
     $tester = new ElggRewriteTester();
     $url = _elgg_services()->config->getSiteUrl() . "rewrite.php";
     $report['rewrite'] = array($tester->run($url, $this->CONFIG->path));
 }