/[gnump3d]/gnump3d/lib/gnump3d/plugins/random.pm
ViewVC logotype

Diff of /gnump3d/lib/gnump3d/plugins/random.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by skx, Sun Oct 12 00:59:57 2003 UTC revision 1.4 by skx, Wed Oct 15 15:38:01 2003 UTC
# Line 68  sub handlePath( ) Line 68  sub handlePath( )
68      my ( $uri ) = (@_);      my ( $uri ) = (@_);
69    
70      #      #
71        # See if we should just return a random directory...
72        #
73        if ( $uri =~ /^\/random\/directory/ )
74        {
75            &handleRandomDirectory( );
76            exit;
77        }
78    
79    
80        #
81      # See if we were called as a result of our form submission or not.      # See if we were called as a result of our form submission or not.
82      #      #
83      if ( $uri =~ /^\/random\/play/ )      if ( $uri =~ /^\/random\/play/ )
# Line 227  sub handlePath( ) Line 237  sub handlePath( )
237          $form   .= "<option value=\"50\">50</option>\n";          $form   .= "<option value=\"50\">50</option>\n";
238          $form   .= "</select>\n";          $form   .= "</select>\n";
239          $form   .= "<input type=\"submit\" name=\"submit\" value=\"Try Again\">\n";          $form   .= "<input type=\"submit\" name=\"submit\" value=\"Try Again\">\n";
240          $form   .= "</form></td></tr></table>\n";          $form   .= "[ <a href=\"/random/directory\">Random Directory</a> ]  </form> </td></tr></table>\n";
241          $output .= $form;          $output .= $form;
242    
243    
# Line 339  sub handlePlaylist( ) Line 349  sub handlePlaylist( )
349      close( $data );      close( $data );
350      exit;      exit;
351  }  }
352    
353    
354    #
355    #  Choose a random line from the cache file, and work out the
356    # directory the given track lives in.
357    #
358    #  Issue a redirect to force the user to view that.
359    #
360    #
361    sub handleRandomDirectory( )
362    {
363    
364        open( FILY, "<$tag_cache" );
365        my @lines = <FILY>;
366        close( FILY );
367    
368        # Pick a random line from the database.
369        my $random = $lines[ rand @lines ];
370        if ( $random =~ /([^\t]+)\t(.*)/ )
371        {
372            $random = $1;
373        }
374    
375        #
376        # We only care about the directory name.
377        #
378        if ( $random =~ /(.*)\/(.*)$/ )
379        {
380            $random = $1;
381        }
382    
383        #
384        #  Strip off the root
385        #
386        if ( $random =~ /$ROOT\/(.*)/ )
387        {
388            $random= $1;
389        }
390    
391        &sendData($data, "HTTP/1.0 300 OK\nLocation: /$random\n\n" );
392    
393        exit;
394    
395    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26