Changeset 4577

Show
Ignore:
Timestamp:
06/08/08 00:00:41 (3 months ago)
Author:
thresh
Message:

mirror.php allows to open every $mirror supplied in $_GET, if $file is set.
Attempt to fix it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • www.videolan.org/mirror.php

    r3975 r4577  
    44   $file = $_GET["file"]; 
    55 
     6   if( !isset($file) ) { die; } 
    67 
    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 
    925   # Pick up a random mirror   
    10    if( !isset( $mirror ) ) 
    1126   { 
    12         $listfile = $_SERVER["DOCUMENT_ROOT"]."/include/mirrors"; 
    13         $file_id = fopen( $listfile , "r" ); 
    14         $all = fread( $file_id, filesize( $listfile ) ); 
    15         fclose( $file_id ); 
    16         $mirrors = explode( "\n", $all ); 
    17         array_pop( $mirrors ); 
    18  
    19         while( !isset( $mirror ) ) 
     27       array_pop( $mirrors ); 
     28       while( !isset( $mirror ) ) 
    2029        { 
    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       
    2635   } 
    2736?>