Index: trunk/phase3/maintenance/dev/router.php |
— | — | @@ -1,78 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -# Router for the php cli-server built-in webserver |
5 | | -# http://ca2.php.net/manual/en/features.commandline.webserver.php |
6 | | - |
7 | | -ini_set('display_errors', 1); |
8 | | -error_reporting(E_ALL); |
9 | | - |
10 | | -if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) { |
11 | | - # Known resource, sometimes a script sometimes a file |
12 | | - $file = $_SERVER["SCRIPT_FILENAME"]; |
13 | | -} elseif ( isset( $_SERVER["SCRIPT_NAME"] ) ) { |
14 | | - # Usually unknown, document root relative rather than absolute |
15 | | - # Happens with some cases like /wiki/File:Image.png |
16 | | - if ( is_readable( $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"] ) ) { |
17 | | - # Just in case this actually IS a file, set it here |
18 | | - $file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"]; |
19 | | - } else { |
20 | | - # Otherwise let's pretend that this is supposed to go to index.php |
21 | | - $file = $_SERVER['DOCUMENT_ROOT'] . '/index.php'; |
22 | | - } |
23 | | -} else { |
24 | | - # Meh, we'll just give up |
25 | | - return false; |
26 | | -} |
27 | | - |
28 | | -# And now do handling for that $file |
29 | | - |
30 | | -if ( !is_readable( $file ) ) { |
31 | | - # Let the server throw the error if it doesn't exist |
32 | | - return false; |
33 | | -} |
34 | | -$ext = pathinfo( $file, PATHINFO_EXTENSION ); |
35 | | -if ( $ext == 'php' || $ext == 'php5' ) { |
36 | | - # Execute php files |
37 | | - # We use require and return true here because when you return false |
38 | | - # the php webserver will discard post data and things like login |
39 | | - # will not function in the dev environment. |
40 | | - require( $file ); |
41 | | - return true; |
42 | | -} |
43 | | -$mime = false; |
44 | | -$lines = explode( "\n", file_get_contents( "includes/mime.types" ) ); |
45 | | -foreach ( $lines as $line ) { |
46 | | - $exts = explode( " ", $line ); |
47 | | - $mime = array_shift( $exts ); |
48 | | - if ( in_array( $ext, $exts ) ) { |
49 | | - break; # this is the right value for $mime |
50 | | - } |
51 | | - $mime = false; |
52 | | -} |
53 | | -if ( !$mime ) { |
54 | | - $basename = basename( $file ); |
55 | | - if ( $basename == strtoupper( $basename ) ) { |
56 | | - # IF it's something like README serve it as text |
57 | | - $mime = "text/plain"; |
58 | | - } |
59 | | -} |
60 | | -if ( $mime ) { |
61 | | - # Use custom handling to serve files with a known mime type |
62 | | - # This way we can serve things like .svg files that the built-in |
63 | | - # PHP webserver doesn't understand. |
64 | | - # ;) Nicely enough we just happen to bundle a mime.types file |
65 | | - $f = fopen($file, 'rb'); |
66 | | - if ( preg_match( '^text/', $mime ) ) { |
67 | | - # Text should have a charset=UTF-8 (php's webserver does this too) |
68 | | - header("Content-Type: $mime; charset=UTF-8"); |
69 | | - } else { |
70 | | - header("Content-Type: $mime"); |
71 | | - } |
72 | | - header("Content-Length: " . filesize($file)); |
73 | | - // Stream that out to the browser |
74 | | - fpassthru($f); |
75 | | - return true; |
76 | | -} |
77 | | - |
78 | | -# Let the php server handle things on it's own otherwise |
79 | | -return false; |
Index: trunk/phase3/maintenance/dev/installmw.sh |
— | — | @@ -3,14 +3,7 @@ |
4 | 4 | if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi |
5 | 5 | DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd) |
6 | 6 | |
7 | | -if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ]; then |
8 | | - PHP="$DEV/php/bin/php" |
9 | | -elif [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then |
10 | | - PHP="$HOME/.mwphp/bin/php" |
11 | | -else |
12 | | - echo "Local copy of PHP is not installed" |
13 | | - echo 1 |
14 | | -fi |
| 7 | +. "$DEV/includes/require-php.sh" |
15 | 8 | |
16 | 9 | set -e |
17 | 10 | |
Index: trunk/phase3/maintenance/dev/includes/router.php |
— | — | @@ -0,0 +1,78 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# Router for the php cli-server built-in webserver |
| 5 | +# http://ca2.php.net/manual/en/features.commandline.webserver.php |
| 6 | + |
| 7 | +ini_set('display_errors', 1); |
| 8 | +error_reporting(E_ALL); |
| 9 | + |
| 10 | +if ( isset( $_SERVER["SCRIPT_FILENAME"] ) ) { |
| 11 | + # Known resource, sometimes a script sometimes a file |
| 12 | + $file = $_SERVER["SCRIPT_FILENAME"]; |
| 13 | +} elseif ( isset( $_SERVER["SCRIPT_NAME"] ) ) { |
| 14 | + # Usually unknown, document root relative rather than absolute |
| 15 | + # Happens with some cases like /wiki/File:Image.png |
| 16 | + if ( is_readable( $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"] ) ) { |
| 17 | + # Just in case this actually IS a file, set it here |
| 18 | + $file = $_SERVER['DOCUMENT_ROOT'] . $_SERVER["SCRIPT_NAME"]; |
| 19 | + } else { |
| 20 | + # Otherwise let's pretend that this is supposed to go to index.php |
| 21 | + $file = $_SERVER['DOCUMENT_ROOT'] . '/index.php'; |
| 22 | + } |
| 23 | +} else { |
| 24 | + # Meh, we'll just give up |
| 25 | + return false; |
| 26 | +} |
| 27 | + |
| 28 | +# And now do handling for that $file |
| 29 | + |
| 30 | +if ( !is_readable( $file ) ) { |
| 31 | + # Let the server throw the error if it doesn't exist |
| 32 | + return false; |
| 33 | +} |
| 34 | +$ext = pathinfo( $file, PATHINFO_EXTENSION ); |
| 35 | +if ( $ext == 'php' || $ext == 'php5' ) { |
| 36 | + # Execute php files |
| 37 | + # We use require and return true here because when you return false |
| 38 | + # the php webserver will discard post data and things like login |
| 39 | + # will not function in the dev environment. |
| 40 | + require( $file ); |
| 41 | + return true; |
| 42 | +} |
| 43 | +$mime = false; |
| 44 | +$lines = explode( "\n", file_get_contents( "includes/mime.types" ) ); |
| 45 | +foreach ( $lines as $line ) { |
| 46 | + $exts = explode( " ", $line ); |
| 47 | + $mime = array_shift( $exts ); |
| 48 | + if ( in_array( $ext, $exts ) ) { |
| 49 | + break; # this is the right value for $mime |
| 50 | + } |
| 51 | + $mime = false; |
| 52 | +} |
| 53 | +if ( !$mime ) { |
| 54 | + $basename = basename( $file ); |
| 55 | + if ( $basename == strtoupper( $basename ) ) { |
| 56 | + # IF it's something like README serve it as text |
| 57 | + $mime = "text/plain"; |
| 58 | + } |
| 59 | +} |
| 60 | +if ( $mime ) { |
| 61 | + # Use custom handling to serve files with a known mime type |
| 62 | + # This way we can serve things like .svg files that the built-in |
| 63 | + # PHP webserver doesn't understand. |
| 64 | + # ;) Nicely enough we just happen to bundle a mime.types file |
| 65 | + $f = fopen($file, 'rb'); |
| 66 | + if ( preg_match( '^text/', $mime ) ) { |
| 67 | + # Text should have a charset=UTF-8 (php's webserver does this too) |
| 68 | + header("Content-Type: $mime; charset=UTF-8"); |
| 69 | + } else { |
| 70 | + header("Content-Type: $mime"); |
| 71 | + } |
| 72 | + header("Content-Length: " . filesize($file)); |
| 73 | + // Stream that out to the browser |
| 74 | + fpassthru($f); |
| 75 | + return true; |
| 76 | +} |
| 77 | + |
| 78 | +# Let the php server handle things on it's own otherwise |
| 79 | +return false; |
Property changes on: trunk/phase3/maintenance/dev/includes/router.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 80 | + native |
Index: trunk/phase3/maintenance/dev/start.sh |
— | — | @@ -3,14 +3,7 @@ |
4 | 4 | if [ "x$BASH_SOURCE" == "x" ]; then echo '$BASH_SOURCE not set'; exit 1; fi |
5 | 5 | DEV=$(cd -P "$(dirname "${BASH_SOURCE[0]}" )" && pwd) |
6 | 6 | |
7 | | -if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ]; then |
8 | | - PHP="$DEV/php/bin/php" |
9 | | -elif [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then |
10 | | - PHP="$HOME/.mwphp/bin/php" |
11 | | -else |
12 | | - echo "Local copy of PHP is not installed" |
13 | | - echo 1 |
14 | | -fi |
| 7 | +. "$DEV/includes/require-php.sh" |
15 | 8 | |
16 | 9 | PORT=4881 |
17 | 10 | |
— | — | @@ -18,4 +11,4 @@ |
19 | 12 | echo "" |
20 | 13 | |
21 | 14 | cd "$DEV/../../"; # $IP |
22 | | -"$PHP" -S "localhost:$PORT" "$DEV/router.php" |
| 15 | +"$PHP" -S "localhost:$PORT" "$DEV/includes/router.php" |
Index: trunk/phase3/maintenance/dev/installphp.sh |
— | — | @@ -5,7 +5,9 @@ |
6 | 6 | |
7 | 7 | set -e # DO NOT USE PIPES unless this is rewritten |
8 | 8 | |
9 | | -if [ -d "$DEV/php" -a -x "$DEV/php/bin/php" ] || [ -d "$HOME/.mwphp" -a -x "$HOME/.mwphp/bin/php" ]; then |
| 9 | +. "$DEV/includes/php.sh" |
| 10 | + |
| 11 | +if [ "x$PHP" != "x" -a -x "$PHP" ]; then |
10 | 12 | echo "PHP is already installed" |
11 | 13 | exit 0 |
12 | 14 | fi |
— | — | @@ -16,13 +18,13 @@ |
17 | 19 | cd "$DEV" |
18 | 20 | |
19 | 21 | echo "Preparing to download and install a local copy of PHP 5.4, note that this can take some time to do." |
20 | | -echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mwphp" |
21 | | -echo -n "Install PHP in ~/.mwphp [y/N]: " |
| 22 | +echo "If you wish to avoid re-doing this for uture dev installations of MediaWiki we suggest installing php in ~/.mediawiki/php" |
| 23 | +echo -n "Install PHP in ~/.mediawiki/php [y/N]: " |
22 | 24 | read INSTALLINHOME |
23 | 25 | |
24 | 26 | case "$INSTALLINHOME" in |
25 | 27 | [Yy] | [Yy][Ee][Ss] ) |
26 | | - PREFIX="$HOME/.mwphp" |
| 28 | + PREFIX="$HOME/.mediawiki/php" |
27 | 29 | ;; |
28 | 30 | *) |
29 | 31 | PREFIX="$DEV/php/" |
Index: trunk/phase3/maintenance/dev/README |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | maintenance/dev/ scripts can help quickly setup a local MediaWiki for development purposes. |
3 | 3 | |
4 | | -Wikis setup in this way are NOT meant to be publicly available. They use a development database not acceptible for use in production and place a sqlite database in an unsafe location a real wiki should never place it in. |
| 4 | +Wikis setup in this way are NOT meant to be publicly available. They use a development database not acceptible for use in production. Place a sqlite database in an unsafe location a real wiki should never place it in. And use predictable default logins for the initial administrator user. |
5 | 5 | |
6 | 6 | Running maintenance/dev/install.sh will download and install a local copy of php 5.4, install a sqlite powered instance of MW for development, and then start up a local webserver to view the wiki. |
7 | 7 | |