rewrite.php3 3.25 KB
Newer Older
1
<?php
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
2 3
  $path = '/var/www/local/developers.videolan.org/';
  $dir = $_GET['dir'];
4
  $isindex = false;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
5 6 7

  chdir ($path);

8 9 10
  if ($dir == null)
    $dir = '.';

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
11 12 13 14 15 16
  /* Directory traversal security fix -- Courmisch (20/10/2004) */
  if ((strstr($dir, "..") === FALSE)
   && (strstr($dir, "/.") === FALSE)
   && !preg_match("/[^a-zA-Z0-9\.\/\-]/", $dir))
  {
    $page = $_GET['page'];
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
17
    if (preg_match("/[^a-zA-Z0-9\.\-]/", $page))
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
18
      $page = '403';
19
    else
20 21 22
    {
      if ($page == 'index')
        $isindex = true;
23
      $page = "$dir/$page";
24
    }
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
25 26 27
  }
  else
    $page = '403';
Eric Petit's avatar
Eric Petit committed
28

29 30
  $title = "developers.videolan.org";

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
31
  if( file_exists( "$page.html" ) )
Eric Petit's avatar
Eric Petit committed
32 33 34
  {
    $fd = fopen( "$page.html", "r" );
    $line = fgets( $fd, 1023 );
VideoLAN's avatar
VideoLAN committed
35
    if( eregi( "<.*html", $line ) )
36 37 38
    {
      /* on laisse telles quelles les pages html toutes faites
         (e.g. les docs dveloppeur) */
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
39
      fpassthru ($fd);
40 41
      exit;
    }
42
    else if( ereg( "<?php", $line, $regs ) )
Eric Petit's avatar
Eric Petit committed
43 44 45 46 47 48 49 50 51 52
    {
      $line = fgets( $fd, 1023 );
      eval( $line ); // get $title
    }
  }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
53
  <title><?php echo $title; ?></title>
54
  <link type="text/css" href="/main.css" rel="stylesheet">
Alexis de Lattre's avatar
Alexis de Lattre committed
55
  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
Christophe Mutricy's avatar
Christophe Mutricy committed
56
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
Eric Petit's avatar
Eric Petit committed
57 58 59 60
</head>
<body bgcolor="#ffffff">
<table width="100%" cellspacing=0 cellpadding=10>
<tr><td rowspan=2 width=150 valign=top class=background>
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
61
<?php
62
  include( 'include/menu.inc' );
Eric Petit's avatar
Eric Petit committed
63 64
?>
</td>
Eric Petit's avatar
Eric Petit committed
65
<td height=50 class=background><h1>developers.videolan.org</h1></td></tr>
Eric Petit's avatar
Eric Petit committed
66 67 68
<tr>
<td valign=top>

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
69
<?php
Eric Petit's avatar
Eric Petit committed
70 71 72 73
  if( file_exists( "$page.html" ) )
  {
    include( "$page.html" );
  }
74
  else if( $_GET['changelog'] )
Eric Petit's avatar
Eric Petit committed
75
  {
Antoine Cellerier's avatar
Antoine Cellerier committed
76 77
    echo "<p>Page moved... <a href='http://trac.videolan.org/vlc/browser/trunk/ChangeLog?format=txt'>http://trac.videolan.org/vlc/browser/trunk/ChangeLog?format=txt</a>.</p>";
    /*$changelogfile = file( 'ChangeLog' );
Eric Petit's avatar
Eric Petit committed
78 79 80 81
    while( list( $line_number, $line ) = each( $changelogfile ) )
    {
      $line = htmlspecialchars( $line, ENT_QUOTES );
      echo "$line<br />";
Antoine Cellerier's avatar
Antoine Cellerier committed
82
    }*/
Eric Petit's avatar
Eric Petit committed
83 84
  }
  else
85
  if( $isindex && $dir != "include" && is_dir( $dir ) )
Eric Petit's avatar
Eric Petit committed
86 87
  {
    $listing = array();
88
    $handle = opendir( $dir );
Eric Petit's avatar
Eric Petit committed
89 90 91 92 93 94 95 96 97 98 99 100 101
    while( $file = htmlentities( readdir( $handle ) ) )
    {
      if( $file != "." && $file != "..")
      {
        $listing[]=$file;
      }
    }
    closedir( $handle );
    sort( $listing );
    reset( $listing );

    while( $file = current( $listing ) )
    {
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
102
      echo '<li><code><a href="'.$file.'">'.$file.'</a></code></li>';
Eric Petit's avatar
Eric Petit committed
103 104 105
      next($listing);
    }
  }
106
  else
107
  {
108
    include( '404.html' );
109 110 111 112 113
    if( !strncmp( $dir, "pub", 3 ) )
    {
      echo "<p>Are you looking for <a href='http://downloads.videolan.org/$dir/'>http://downloads.videolan.org/$dir/</a> ?</p>";
    }
  }
Eric Petit's avatar
Eric Petit committed
114 115 116 117 118 119 120 121
?>

<br><br>

</td></tr>

<tr><td colspan=2>
<hr noshade align="left" width="100%">
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
122
<a href="http://validator.w3.org/check/referer"><img align="right"
Eric Petit's avatar
Eric Petit committed
123 124 125 126 127 128 129 130 131 132 133 134
border="0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML
4.01!" height="31" width="88"></a>
<a href="http://jigsaw.w3.org/css-validator/"><img align=right border=0
width=88 height=31 src="http://jigsaw.w3.org/css-validator/images/vcss"
alt="Valid CSS!"></a>
</td></tr>

</table>

</body>
</html>