Example #1
0
 public function get_font()
 {
     if (!($captcha_fonts = AWS_APP::cache()->get('captcha_fonts'))) {
         $captcha_fonts = fetch_file_lists(AWS_PATH . 'core/fonts/');
         AWS_APP::cache()->set('captcha_fonts', $captcha_fonts, get_setting('cache_level_normal'));
     }
     return array_random($captcha_fonts);
 }
Example #2
0
 public function client_list_image_clean($mp_menu)
 {
     if (!is_dir(ROOT_PATH . 'weixin/list_image/')) {
         return false;
     }
     foreach ($mp_menu as $key => $val) {
         if ($val['sub_button']) {
             foreach ($val['sub_button'] as $sub_key => $sub_val) {
                 $attach_list[] = $sub_val['attch_key'] . '.jpg';
             }
         }
         $attach_list[] = $val['attch_key'] . '.jpg';
     }
     $files_list = fetch_file_lists(ROOT_PATH . 'weixin/list_image/', 'jpg');
     foreach ($files_list as $search_file) {
         if (!in_array(str_replace('square_', '', base_name($search_file)))) {
             unlink($search_file);
         }
     }
 }
Example #3
0
/**
 * 递归读取文件夹的文件列表
 *
 * 读取的目录路径可以是相对路径, 也可以是绝对路径, $file_type 为指定读取的文件后缀, 不设置则读取文件夹内所有的文件
 *
 * @param  string
 * @param  string
 * @return array
 */
function fetch_file_lists($dir, $file_type = null)
{
    if ($file_type) {
        if (substr($file_type, 0, 1) == '.') {
            $file_type = substr($file_type, 1);
        }
    }
    $base_dir = realpath($dir);
    $dir_handle = opendir($base_dir);
    $files_list = array();
    while (($file = readdir($dir_handle)) !== false) {
        if (substr($file, 0, 1) != '.' and !is_dir($base_dir . '/' . $file)) {
            if ($file_type and H::get_file_ext($file, false) == $file_type or !$file_type) {
                $files_list[] = $base_dir . '/' . $file;
            }
        } else {
            if (substr($file, 0, 1) != '.' and is_dir($base_dir . '/' . $file)) {
                if ($sub_dir_lists = fetch_file_lists($base_dir . '/' . $file, $file_type)) {
                    $files_list = array_merge($files_list, $sub_dir_lists);
                }
            }
        }
    }
    return $files_list;
}
Example #4
0
 public function js_action()
 {
     $files_list = fetch_file_lists(ROOT_PATH . 'static/js/', 'js');
     foreach ($files_list as $search_file) {
         $data = file_get_contents($search_file);
         preg_match_all("#" . preg_quote('_t(\'') . "(.*)" . preg_quote('\')') . "#isU", $data, $matchs);
         foreach ($matchs[1] as $key => $val) {
             $string = $val;
             if (strstr($string, "', ")) {
                 $string = explode("', ", $string);
                 $string = $string[0];
             }
             if (strstr($string, "'), ")) {
                 $string = explode("'), ", $string);
                 $string = $string[0];
             }
             if (strstr($string, "') .")) {
                 $string = explode("') .", $string);
                 $string = $string[0];
             }
             if (strstr($string, "') ")) {
                 $string = explode("') ", $string);
                 $string = $string[0];
             }
             if (!$this->model('system')->fetch_row('lang', "string = '" . $this->model('system')->quote($string) . "' AND type = 'js'")) {
                 $this->model('system')->insert('lang', array('string' => $string, 'type' => 'js'));
             }
         }
     }
 }