Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MINOR Removed unused rewritetest.php

  • Loading branch information...
commit 448a729a2918a8c2d678ee6299f0450c2fce67a0 1 parent 3450bad
Sean Harvey authored April 14, 2012

Showing 1 changed file with 0 additions and 166 deletions. Show diff stats Hide diff stats

  1. 166  rewritetest.php
166  rewritetest.php
... ...
@@ -1,166 +0,0 @@
1  
-<?php
2  
-
3  
-createHtaccess();
4  
-
5  
-$baseURL = dirname($_SERVER['SCRIPT_NAME']);
6  
-if($baseURL == "/") {
7  
-	$baseURL = "";
8  
-}
9  
-
10  
-if(isset($_REQUEST['force'])) {
11  
-	echo "Forced continue, attempting to redirect to <a href=\"home/successfullyinstalled?flush=1\">home/successfullyinstalled</a>.
12  
-		<script>setTimeout(function() { window.location.href = 'home/successfullyinstalled?flush=1'; }, 1000);</script>";
13  
-} else {	
14  
-	$modRewriteWorking  = performModRewriteTest();
15  
-	
16  
-	if(!$modRewriteWorking) {
17  
-		createHtaccessAlternative();
18  
-		$modRewriteWorking  = performModRewriteTest();
19  
-	}
20  
-	
21  
-	if($modRewriteWorking) {
22  
-		echo "mod_rewrite is working! I will now try and direct you to
23  
-					<a href=\"home/successfullyinstalled?flush=1\">home/successfullyinstalled</a> to confirm that the installation was successful.
24  
-					<script>setTimeout(function() { window.location.href = 'home/successfullyinstalled?flush=1'; }, 1000);</script>
25  
-		";
26  
-	} else {
27  
-		restoreHtaccess();
28  
-		
29  
-		echo "mod_rewrite doesn't appear to be working. Make sure:" .
30  
-				"<ul>" .
31  
-				"<li>mod_rewrite is enabled in your httpd.conf</li>" .
32  
-				"<li>AllowOverride is enabled for the current path.</li>" .
33  
-				"</ul>" .
34  
-				"Please check these options, then refresh this page." .
35  
-				"If you believe that your configuration is correct, <a href=\"rewritetest.php?force=1\">click here to proceed anyway.</a>";
36  
-	}
37  
-}
38  
-
39  
-function performModRewriteTest() {
40  
-	$baseURL = dirname($_SERVER['SCRIPT_NAME']);
41  
-	if($baseURL == "/") {
42  
-		$baseURL = "";
43  
-	}
44  
-
45  
-	// Check if mod_rewrite works properly
46  
-	$location = 'http://' . (isset($_SERVER['PHP_AUTH_USER']) ? "$_SERVER[PHP_AUTH_USER]:$_SERVER[PHP_AUTH_PW]@" : '') . $_SERVER['HTTP_HOST'] . $baseURL . '/InstallerTest/testrewrite';
47  
-	$testrewriting = file_get_contents($location);
48  
-
49  
-	if($testrewriting == 'OK') {
50  
-		return true;
51  
-	}
52  
-	
53  
-	// Workaround for 'URL file-access is disabled in the server configuration' using curl
54  
-	if(function_exists('curl_init')) {
55  
-		$ch = curl_init($location);
56  
-		$fp = @fopen(dirname(tempnam('adfadsfdas','')) . '/rewritetest', "w");
57  
-		
58  
-		if($fp) {
59  
-			curl_setopt($ch, CURLOPT_FILE, $fp);
60  
-			curl_setopt($ch, CURLOPT_HEADER, 0);
61  
-			curl_exec($ch);
62  
-			curl_close($ch);
63  
-			fclose($fp);
64  
-			$testrewriting = file_get_contents(dirname(tempnam('adfadsfdas','')) . '/rewritetest');
65  
-			unlink(dirname(tempnam('adfadsfdas','')) . '/rewritetest');
66  
-			if($testrewriting == 'OK') {
67  
-				return true;
68  
-			}
69  
-		}
70  
-	}
71  
-	
72  
-	return false;
73  
-}
74  
-
75  
-function createHtaccess() {
76  
-	$start = "### SILVERSTRIPE START ###\n";
77  
-	$end= "\n### SILVERSTRIPE END ###";
78  
-	$base = dirname($_SERVER['SCRIPT_NAME']);
79  
-	
80  
-	$rewrite = <<<TEXT
81  
-RewriteEngine On
82  
-RewriteBase $base
83  
-
84  
-RewriteCond %{REQUEST_URI} ^(.*)$
85  
-RewriteCond %{REQUEST_FILENAME} !-f
86  
-RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
87  
-TEXT
88  
-	;
89  
-	
90  
-	if(file_exists('.htaccess')) {
91  
-		$htaccess = file_get_contents('.htaccess');
92  
-	
93  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') === false && strpos($htaccess, '### SILVERSTRIPE END ###') === false) {
94  
-			$htaccess .= "\n### SILVERSTRIPE START ###\n### SILVERSTRIPE END ###\n";
95  
-		}
96  
-	
97  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') !== false && strpos($htaccess, '### SILVERSTRIPE END ###') !== false) {
98  
-			$start = substr($htaccess, 0, strpos($htaccess, '### SILVERSTRIPE START ###')) . "### SILVERSTRIPE START ###\n";
99  
-			$end = "\n" . substr($htaccess, strpos($htaccess, '### SILVERSTRIPE END ###'));
100  
-		}
101  
-	}
102  
-		
103  
-	createFile('.htaccess', $start . $rewrite . $end);
104  
-}
105  
-
106  
-function createHtaccessAlternative() {
107  
-	$start = "### SILVERSTRIPE START ###\n";
108  
-	$end= "\n### SILVERSTRIPE END ###";
109  
-	$base = dirname($_SERVER['SCRIPT_NAME']);
110  
-	
111  
-	$rewrite = <<<TEXT
112  
-RewriteEngine On
113  
-RewriteBase $base
114  
-
115  
-RewriteCond %{REQUEST_URI} ^(.*)$
116  
-RewriteCond %{REQUEST_FILENAME} !-f
117  
-RewriteRule .* $_SERVER[DOCUMENT_ROOT]/framework/main.php?url=%1&%{QUERY_STRING} [L]
118  
-TEXT
119  
-	;
120  
-	
121  
-	if(file_exists('.htaccess')) {
122  
-		$htaccess = file_get_contents('.htaccess');
123  
-		
124  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') === false && strpos($htaccess, '### SILVERSTRIPE END ###') === false) {
125  
-			$htaccess .= "\n### SILVERSTRIPE START ###\n### SILVERSTRIPE END ###\n";
126  
-		}
127  
-	
128  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') !== false && strpos($htaccess, '### SILVERSTRIPE END ###') !== false) {
129  
-			$start = substr($htaccess, 0, strpos($htaccess, '### SILVERSTRIPE START ###')) . "### SILVERSTRIPE START ###\n";
130  
-			$end = "\n" . substr($htaccess, strpos($htaccess, '### SILVERSTRIPE END ###'));
131  
-		}
132  
-	}
133  
-		
134  
-	createFile('.htaccess', $start . $rewrite . $end);
135  
-}
136  
-	
137  
-function restoreHtaccess() {
138  
-	$start = "### SILVERSTRIPE START ###\n";
139  
-	$end= "\n### SILVERSTRIPE END ###";
140  
-	
141  
-	if(file_exists('.htaccess')) {
142  
-		$htaccess = file_get_contents('.htaccess');
143  
-		
144  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') === false && strpos($htaccess, '### SILVERSTRIPE END ###') === false) {
145  
-			$htaccess .= "\n### SILVERSTRIPE START ###\n### SILVERSTRIPE END ###\n";
146  
-		}
147  
-	
148  
-		if(strpos($htaccess, '### SILVERSTRIPE START ###') !== false && strpos($htaccess, '### SILVERSTRIPE END ###') !== false) {
149  
-			$start = substr($htaccess, 0, strpos($htaccess, '### SILVERSTRIPE START ###')) . "### SILVERSTRIPE START ###\n";
150  
-			$end = "\n" . substr($htaccess, strpos($htaccess, '### SILVERSTRIPE END ###'));
151  
-		}
152  
-	}
153  
-	
154  
-	createFile('.htaccess', $start . $end);
155  
-}
156  
-
157  
-function getBaseDir() {
158  
-	return dirname($_SERVER['SCRIPT_FILENAME']) . '/';
159  
-}
160  
-
161  
-function createFile($filename, $content) {
162  
-	$base = getBaseDir();
163  
-	if(($fh = fopen($base . $filename, 'w')) && fwrite($fh, $content) && fclose($fh))
164  
-		return true;
165  
-}
166  
-?>

0 notes on commit 448a729

Please sign in to comment.
Something went wrong with that request. Please try again.