Пример #1
0
/**
 * Scans directory and add all files with specified extensions as MOSS base file for comparation.
 * @param string $cd_path directory where the base directory is located.
 * @param string $directory directory name or file name.
 * @param array<string> $extensions lower case extension names without dot.
 */
function moss_add_all_base_files($cd_path, $directory, $extensions = array())
{
    $ci =& get_instance();
    $ci->load->library('mosslib');
    if (file_exists($cd_path . $directory) && is_array($extensions) && count($extensions)) {
        if (is_file($cd_path . $directory)) {
            $path_info = pathinfo($cd_path . $directory);
            if (in_array(strtolower($path_info['extension']), $extensions)) {
                $current_path = getcwd();
                chdir($cd_path);
                $ci->mosslib->addBaseFile($directory);
                chdir($current_path);
            }
        } else {
            $dirs = scandir($cd_path . $directory);
            foreach ($dirs as $dir) {
                if ($dir != '.' && $dir != '..') {
                    $dir_path = rtrim($directory, '/\\') . DIRECTORY_SEPARATOR . $dir;
                    moss_add_all_base_files($cd_path, $dir_path . (is_dir($dir_path) ? DIRECTORY_SEPARATOR : ''), $extensions);
                }
            }
        }
    }
}
Пример #2
0
 public function execute()
 {
     set_time_limit(0);
     $path = $this->input->post('path');
     $config = $this->input->post('config');
     if ($this->is_moss_user_id_set()) {
         $this->load->library('mosslib');
         $this->load->helper('moss');
         $this->mosslib->setLanguage($config['l']);
         $this->mosslib->setIngoreLimit((int) $config['m']);
         $this->mosslib->setResultLimit((int) $config['n']);
         $this->load->config('moss');
         $moss_lang_file_extensions = $this->config->item('moss_langs_file_extensions');
         $extensions = $moss_lang_file_extensions[$config['l']];
         moss_add_all_files(rtrim($path, '/\\') . '/', 'source/', $extensions);
         moss_add_all_base_files(rtrim($path, '/\\') . '/', 'base/', $extensions);
         $current_path = getcwd();
         chdir($path);
         $results = $this->mosslib->send();
         chdir($current_path);
         echo '<a href="' . $results . '" class="button" target="_blank">' . $this->lang->line('admin_moss_execute_results_button_text') . '</a>';
     } else {
         echo '<p>' . $this->lang->line('admin_moss_general_error_user_id_not_set') . '</p>';
     }
     if (mb_substr($path, 0, mb_strlen(self::MOSS_WORKING_DIRECTORY)) == self::MOSS_WORKING_DIRECTORY && mb_strlen(self::MOSS_WORKING_DIRECTORY) < mb_strlen($path)) {
         @unlink_recursive($path, TRUE);
     }
 }