Changeset 4165 for trunk/rms-web

Show
Ignore:
Timestamp:
07/16/05 00:50:48 (3 years ago)
Author:
emostar
Message:

Patch by JG <jg AT cms.ac> for the RMS Web Interface. Fixes some problems with parsing of strings and security issues.

Location:
trunk/rms-web
Files:
1 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/rms-web/check_session.php

    r4149 r4165  
    11<? 
     2session_start(); 
    23/* clear any post/get input of identification */ 
    34$username = ""; 
     
    1011//session_save_path( "/home/allusers/myself/htdocs/tmp" ); 
    1112session_set_cookie_params(60*60*5); // five hours 
    12 session_start(); 
     13 
    1314if ( isset( $_SESSION["username"] ) ) 
    1415{ 
  • trunk/rms-web/index.php

    r4149 r4165  
    11<?php 
    2  
     2include "check_session.php"; 
    33include "config.php"; 
    4 include "check_session.php"; 
    54include "rms.php"; 
    65 
     
    6059    } 
    6160     
    62     header('Location: main.php'); 
     61    echo "<script>document.location.href='main.php'</script>"; 
    6362  } 
    6463   
  • trunk/rms-web/list.php

    r4149 r4165  
    11<?php 
    2  
     2include "check_session.php"; 
    33include "config.php"; 
    4 include "check_session.php"; 
    54include "rms.php"; 
    65 
  • trunk/rms-web/logout.php

    r4149 r4165  
    11<?php 
    2  
    32include "check_session.php"; 
    43session_destroy(); 
    5  
    64header("Location: index.php"); 
    7  
    85?> 
  • trunk/rms-web/lougout.php

    r4149 r4165  
    11<?php 
    2  
    32include "check_session.php"; 
    43session_destroy(); 
    54header("location:index.php"); 
    6  
    75?> 
  • trunk/rms-web/message.php

    r4149 r4165  
    1   
    21<?php 
    3  
     2include "check_session.php"; 
    43include "config.php"; 
    5 include "check_session.php"; 
    64include "rms.php"; 
     5include "kses.php"; 
    76 
    87function rmsHandleCommand($cmd, $id = "", $pp = "") 
     
    7776  $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 
    7877  $packet = socket_read($sock, 1024, PHP_BINARY_READ); 
    79   $msg = substr($packet, 0, strpos($packet, '223')); 
    8078   
    81   $msg = str_replace("\r\n", "<BR>", $msg); 
     79  $msg = str_replace("\r\n", "<BR>", $packet); 
    8280  $msg = str_replace("\n", "<BR>", $msg); 
     81   
     82  preg_match("/^(.*)<BR>223 Message Complete<BR>$/", $msg, $matches); 
     83  $msg = $matches[1]; 
     84 
     85  // kses input filtering 
     86  $allowed = array('b' => array(), 
     87                   'i' => array(), 
     88                   'a' => array('href' => 1, 'title' => 1), 
     89                   'p' => array('align' => 1), 
     90                   'br' => array()); 
     91 
     92  if (get_magic_quotes_gpc()) 
     93    $msg = stripslashes($msg); 
     94  $msg = kses($msg, $allowed); 
     95  // -- 
    8396   
    8497  $location = "message.php?command=MSG&id=" . $id . "&pp=" . $pp; 
     
    142155   
    143156  $packet = socket_read($sock, 1024, PHP_NORMAL_READ); 
    144   if (!strstr($packet, "302")) 
     157  if (!preg_match("/^302\s{1}.*/", $packet)) 
    145158  { 
    146159    echo "<BR><B>Invalid response (" . $packet . ")</B><BR>\n"; 
  • trunk/rms-web/rms.php

    r4149 r4165  
    3434  $packet = socket_read($sock, 512, PHP_NORMAL_READ); 
    3535   
    36   if (!strstr($packet, "300")) 
     36  if (!preg_match("/^300\s{1}.*/", $packet)) 
    3737  { 
    3838     echo "Invalid response"; 
     
    4848  $packet = socket_read($sock, 512, PHP_NORMAL_READ); 
    4949   
    50   if (!strstr($packet, "301")) 
     50  if (!preg_match("/^301\s{1}.*/", $packet)) 
    5151  { 
    5252    echo "Invalid response"; 
     
    6161  $packet = socket_read($sock, 512, PHP_NORMAL_READ); 
    6262     
    63   if (!strstr($packet, "200")) 
     63  if (!preg_match("/^200\s{1}.*/", $packet)) 
    6464  { 
    6565    $errmsg = $packet; 
     
    8787  $packet = socket_read($sock, 512, PHP_NORMAL_READ); 
    8888   
    89   if (strstr($packet, "202")) 
     89  if (preg_match("/^202\s{1}.*/", $packet)) 
    9090  { 
    9191    //TODO Handle all the protocols seperately 
     
    134134  $packet = socket_read($sock, 512, PHP_NORMAL_READ); 
    135135   
    136   while (!strstr($packet, "206")) 
    137   { 
    138     if (strstr($packet, "204")) 
     136  while (!preg_match("/^206$/", $packet)) 
     137  { 
     138    if (preg_match("/^204\s{1}.*/", $packet)) 
    139139    { 
    140140      $id = " "; 
  • trunk/rms-web/server.php

    r4149 r4165  
    11<?php 
    2  
     2include "check_session.php"; 
    33include "rms.php"; 
    44include "config.php"; 
    5 include "check_session.php"; 
    65 
    76$cmd = $_POST["cmd"]; 
  • trunk/rms-web/settings.php

    r4149 r4165  
    1010    $fc = file("config.php"); 
    1111    $f = fopen("config.php", "w"); 
     12    if (!$f) 
     13    { 
     14        echo "config.php not writable"; 
     15        exit(); 
     16    } 
    1217     
    1318    foreach($fc as $line)