4 * Class Admin_cli controls site administration features
7 * @author Călin-Andrei Burloiu
9 class Admin_cli extends CI_Controller {
11 public function __construct()
13 parent::__construct();
15 if (!$this->input->is_cli_request())
17 die("This controller is allowed only from CLI!");
21 public function index()
23 echo "P2P-Tube".PHP_EOL;
27 * Removes users that didn't activated their account within
28 * $days_to_expire days inclusively.
30 * @param int $days_to_expire
32 public function cleanup_unactivated_users($days_to_expire = 2)
34 $days_to_expire = intval($days_to_expire);
36 $this->load->model('users_model');
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;
41 echo "No users were deleted.".PHP_EOL;
44 public function print_unactivated_videos()
46 $this->load->model('videos_model');
48 $videos = $this->videos_model->get_unactivated_videos();
52 foreach($videos as $video)
54 echo $video['video_id']. ' '
55 . site_url("watch/". $video['video_id']
56 . "/". $video['name']). PHP_EOL;
61 public function activate_video($video_id = NULL)
63 $this->load->model('videos_model');
64 $video_id = intval($video_id);
68 echo 'usage: admin_cli activate_video $video_id'.PHP_EOL;
72 if (!$this->videos_model->activate_video(intval($video_id)))
73 echo 'error: an error occured while activating the video'.PHP_EOL;
77 /* End of file admin_cli.php */
78 /* Location: ./application/controllers/admin_cli.php */