Exemplo n.º 1
0
 private static function exexute_drop_db($database = null)
 {
     if (!self::$absolute_execute && !\Site_Util::check_is_dev_env()) {
         throw new \FuelException('This task is not work at prod env.');
     }
     if (!$database && !($database = \Util_Db::get_database_name())) {
         throw new \FuelException('Drop db error: Database name is not set at configs.');
     }
     self::$database = $database;
     return \DBUtil::shell_exec_drop_database(self::$database);
 }
Exemplo n.º 2
0
function is_dev_env()
{
    return Site_Util::check_is_dev_env();
}
Exemplo n.º 3
0
 public static function check_is_api()
 {
     if (Site_Util::check_is_dev_env() && Input::param('is_api')) {
         return true;
     }
     return Input::is_ajax();
 }
Exemplo n.º 4
0
 private static function execute_clean_file($file_type, $is_tmp = false)
 {
     if (!self::$absolute_execute && !\Site_Util::check_is_dev_env()) {
         throw new \FuelException('This task is not work at prod env.');
     }
     $raw_file_dir_path = \Site_Upload::get_uploaded_path('raw', $file_type, $is_tmp);
     $cache_file_dir_path_key = 'upload.types.' . $file_type;
     if ($is_tmp) {
         $cache_file_dir_path_key .= '.tmp';
     }
     $cache_file_dir_path_key .= '.root_path.cache_dir';
     $cache_file_dir_path = DOCROOT . conf($cache_file_dir_path_key);
     if (!file_exists($raw_file_dir_path) && ($cache_file_dir_path && !file_exists($cache_file_dir_path))) {
         return "File directry '" . $raw_file_dir_path . "' not exists.";
     }
     $file_paths = \Util_file::get_file_recursive($raw_file_dir_path);
     if ($cache_file_dir_path) {
         $file_paths = array_merge($file_paths, \Util_file::get_file_recursive($cache_file_dir_path));
     }
     if (!$file_paths) {
         return sprintf("No files at '%s'", $raw_file_dir_path);
     }
     $i = 0;
     foreach ($file_paths as $file_path) {
         if (self::check_file_exists_record($file_path, $is_tmp)) {
             continue;
         }
         \Util_file::remove($file_path);
         $i++;
     }
     $subject = $file_type;
     if ($is_tmp) {
         $subject .= '_tmp';
     }
     return sprintf('%d %s removed.', $i, $subject);
 }