upload facility now works in single CIS mode; some simple command-line video moderati...
[living-lab-site.git] / application / controllers / admin_cli.php
1 <?php
2
3 /**
4  * Class Admin_cli controls site administration features
5  *
6  * @category    Controller
7  * @author              Călin-Andrei Burloiu
8  */
9 class Admin_cli extends CI_Controller {
10         
11         public function __construct()
12         {
13                 parent::__construct();
14                 
15                 if (!$this->input->is_cli_request())
16                 {
17                         die("This controller is allowed only from CLI!");
18                 }
19         }
20         
21         public function index()
22         {
23                 echo "P2P-Tube".PHP_EOL;
24         }
25         
26         /**
27          * Removes users that didn't activated their account within
28          * $days_to_expire days inclusively.
29          * 
30          * @param int $days_to_expire 
31          */
32         public function cleanup_unactivated_users($days_to_expire = 2)
33         {
34                 $days_to_expire = intval($days_to_expire);
35                 
36                 $this->load->model('users_model');
37                 
38                 if ($this->users_model->cleanup_unactivated_users($days_to_expire))
39                         echo "Users unactivated within $days_to_expire days were successfully deleted from the database.".PHP_EOL;
40                 else
41                         echo "No users were deleted.".PHP_EOL;
42         }
43         
44         public function print_unactivated_videos()
45         {
46                 $this->load->model('videos_model');
47                 
48                 $videos = $this->videos_model->get_unactivated_videos();
49                 
50                 if ($videos)
51                 {
52                         foreach($videos as $video)
53                         {
54                                 echo $video['video_id']. '  '
55                                                 . site_url("watch/". $video['video_id']
56                                                                 . "/". $video['name']). PHP_EOL;
57                         }
58                 }
59         }
60         
61         public function activate_video($video_id = NULL)
62         {
63                 $this->load->model('videos_model');
64                 $video_id = intval($video_id);
65                 
66                 if ($video_id == 0)
67                 {
68                         echo 'usage: admin_cli activate_video $video_id'.PHP_EOL;
69                         return;
70                 }
71                 
72                 if (!$this->videos_model->activate_video(intval($video_id)))
73                         echo 'error: an error occured while activating the video'.PHP_EOL;
74         }
75 }
76
77 /* End of file admin_cli.php */
78 /* Location: ./application/controllers/admin_cli.php */