Exemple #1
0
        $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);
    }
}
Exemple #2
0
 public function insert($val)
 {
     if ($this->fileWrite == false) {
         //if not saving changes to file
         if (file_put_contents($this->walPath, '2;' . $val . PHP_EOL, FILE_APPEND) === false) {
             return false;
         } else {
             if (++$this->opNumber > $this->maxOps) {
                 return $this->saveLoggedData($this->dbFileVer);
             }
         }
     }
     return parent::insert($val);
 }