예제 #1
0
파일: SimpleDB.php 프로젝트: hscale/B-Chat
        $string = implode("", explode("\\", $string));
        return stripslashes(trim($string));
    }
}
//======================================================================
//clear cache
session_start();
$_SESSION = array();
session_destroy();
//create db object
$sdb = new SimpleDB("chat_data");
//clear chat if needed
if (isset($_GET['action']) and $_GET['action'] == "delete") {
    $sdb->clear_db();
}
//return message count if asked for
if (isset($_GET['action']) and $_GET['action'] == "get_msg_count") {
    echo $sdb->get_msg_count();
}
//insert
if (isset($_GET['msg_data'])) {
    if ($_GET['msg_data'] != "") {
        $sdb->insert(array(addslashes($_GET['msg_data'])));
    } else {
        $result = "";
        foreach ($sdb->getRows(1) as $msg) {
            $result = '<div class=\\"msg\\">' . $msg[0] . '</div>' . $result;
        }
        echo $sdb->removeslashes($result);
    }
}