twister-phpbot/habrrssdb.php
2014-02-28 10:39:51 +04:00

31 lines
600 B
PHP

<?php
class HabrRSSDb
{
protected $hDatabase = null;
public function __construct($dbFile)
{
fclose(fopen($dbFile, 'a')); // create file if not exists
$this->hDatabase = fopen($dbFile, 'r+');
}
public function __destruct()
{
fclose($this->hDatabase);
}
public function isPublished($id)
{
fseek($this->hDatabase, $id);
$status = fgetc($this->hDatabase);
return $status === '1';
}
public function setPublished($id)
{
fseek($this->hDatabase, $id);
fwrite($this->hDatabase, '1');
}
}