orthographe
[mtweb] / mw / env / modules / mw_env_webmaster.php
1 <?php
2
3   class mw_env_webmaster extends mw_env{
4
5     function load_webmaster_session(){
6       $data = $this->data();
7       if(!($webmaster_user = $this->get_webmaster_user())) return array();
8       return $data->load_session($webmaster_user);
9     }
10
11     function get_webmaster_user(){
12       if(!file_exists($this->get_webmaster_user_file())) return array();
13       if(!($content = @file_get_contents($this->get_webmaster_user_file()))) return false;
14       $v_content = explode(":", $content);
15       if(count($v_content) != 2) return false;
16       return array(
17         "login" => trim($v_content[0]),
18         "password" => trim($v_content[1])
19       );
20     }
21
22     function set_webmaster_user($login, $password){
23       return @file_put_contents($this->get_webmaster_user_file(), $login.":".$password);
24     }
25
26     function get_webmaster_user_file(){
27       return $this->path("content")."data/.webmaster";
28     }
29
30     function webmaster_login($login, $password){
31       $data = $this->data();
32       if(!($webmaster_user = $this->get_webmaster_user())){
33         return false;
34       }
35       return $data->login($login, $password, $webmaster_user);
36     }
37
38   }