Example #1
0
<?php

require_once "config.php";
require_once "util.php";
session_name("stechat");
session_start();
sc_set_idstr();
$o = array();
if (isset($_GET['room']) && trim($_GET['room']) !== "") {
    if (get_magic_quotes_gpc()) {
        $o['room'] = trim(stripslashes($_GET['room']));
    }
}
if (strlen($o['room']) >= MAX_ROOM_LEN) {
    $o['room'] = NULL;
}
if ($o['room']) {
    $o['next_room'] = sc_generate_next_room_name($o['room']);
    $o['next_room_url'] = '?room=' . urlencode($o['next_room']);
    $o['prev_room'] = sc_generate_prev_room_name($o['room']);
    if ($o['prev_room'] == $o['room']) {
        unset($o['prev_room']);
    } else {
        $o['prev_room_url'] = '?room=' . urlencode($o['prev_room']);
    }
    include "room_view.php";
} else {
    include "index_view.php";
}
Example #2
0
 public function testGenerateRoomName()
 {
     $names = array(array("aaa", "aaa(1)", "aaa(2)", "aaa(3)"), array("aaa(-1)", "aaa(-1)(1)", "aaa(-1)(2)", "aaa(-1)(3)"));
     foreach ($names as $name) {
         $this->assertEquals($name[2], sc_generate_next_room_name($name[0]), $name[0]);
         $this->assertEquals($name[2], sc_generate_next_room_name($name[1]), $name[1]);
         $this->assertEquals($name[3], sc_generate_next_room_name($name[2]));
         $this->assertEquals($name[2], sc_generate_prev_room_name($name[3]));
         $this->assertEquals($name[0], sc_generate_prev_room_name($name[2]));
         $this->assertEquals($name[1], sc_generate_prev_room_name($name[1]), $name[1]);
         $this->assertEquals($name[0], sc_generate_prev_room_name($name[0]));
     }
 }