| 7 | | if( !isset($file) ) { die; } |
|---|
| 8 | | |
|---|
| | 8 | $listfile = $_SERVER["DOCUMENT_ROOT"]."/include/mirrors"; |
|---|
| | 9 | $file_id = fopen( $listfile, "r" ); |
|---|
| | 10 | $all = fread ( $file_id, filesize( $listfile ) ); |
|---|
| | 11 | fclose ( $file_id ); |
|---|
| | 12 | $mirrors = explode ( "\n", $all ); |
|---|
| | 13 | |
|---|
| | 14 | if ( isset($mirror) ) |
|---|
| | 15 | { |
|---|
| | 16 | $len = sizeof( $mirrors ); |
|---|
| | 17 | for ( $i = 0; $i < $len; $i++ ) { |
|---|
| | 18 | $url = explode ( "|", $mirrors[$i] ); |
|---|
| | 19 | if( $mirror === $url[0] ) $found = true; |
|---|
| | 20 | } |
|---|
| | 21 | |
|---|
| | 22 | !$found && die; |
|---|
| | 23 | } |
|---|
| | 24 | else |
|---|
| 21 | | $index = rand( 0, sizeof( $mirrors ) - 1 ); |
|---|
| 22 | | if( substr( $mirrors[ $index] , 0, 1 ) == "#" ) continue; |
|---|
| 23 | | $esp = strpos( $mirrors[ $index] , "|" ); |
|---|
| 24 | | $mirror = substr( $mirrors[ $index ], 0, $esp ); |
|---|
| 25 | | } |
|---|
| | 30 | $index = rand( 0, sizeof( $mirrors ) - 1 ); |
|---|
| | 31 | if( substr( $mirrors[ $index] , 0, 1 ) == "#" ) continue; |
|---|
| | 32 | $esp = strpos( $mirrors[ $index] , "|" ); |
|---|
| | 33 | $mirror = substr( $mirrors[ $index ], 0, $esp ); |
|---|
| | 34 | } |
|---|