Initial commit
[2ch-be.git] / dev-test / include / follower.class.php
blobb49650228edc3b56c953fd08c08c5afff6e19eda
1 <?php
2 Class Follower{
3 public $array;
4 public $filename;
5 private $Message;
7 public function __construct($message){
8 $this->Message = new Message;
11 public function setFollowLines($file){
12 $handle = fopen($file, "r");
13 while (($line = fgets($handle)) !== false) {
14 $line = trim($line);
15 $this->array[$line] = $line;
19 public function getFollowLines($value){
20 if(isset($value)){
21 return $this->array[$value];
22 }else{
23 return $this->array;
27 public function addLines($value, $firsttime = FALSE){
28 if($firsttime){
29 file_put_contents($this->filename, $value.PHP_EOL);
30 }else{
31 file_put_contents($this->filename, $value.PHP_EOL,FILE_APPEND);
35 public function removeID($array, $value){
36 unset($array[$value]);
37 $array = implode(PHP_EOL, $array);
38 $array = (empty($array)) ? trim($array) : $array.PHP_EOL ;
39 // $array .= PHP_EOL;
40 file_put_contents($this->filename, $array);
41 return $array;
44 public function checkFollow($userID){
45 if($userID=="NG"){
46 return "NG";
47 }else{
48 $npath = $this->Message->GetPath(FDB_PATH, "FDB");
50 if(!$npath){
51 return "NG";
52 }else{
53 $this->filename = $npath."/follow.txt";
55 if(file_exists($this->filename)){
56 static::setFollowLines($this->filename);
57 $value = static::getFollowLines($userID);
58 return ($value!=NULL) ? TRUE : FALSE;
59 }else{
60 //create a file please.
61 //then return false.
62 $fh = fopen($this->filename, 'w');