twister-phpbot/habrrssdb.php

31 lines
600 B
PHP
Raw Normal View History

2014-02-28 06:39:51 +00:00
<?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');
}
}