Soft Rejection: Redux Framework issue

I got soft rejection several times for this issue, the opendir()

if (is_dir($sample_patterns_path)) :

            if ($sample_patterns_dir = opendir($sample_patterns_path)) :
                $sample_patterns = array();

                while (( $sample_patterns_file = readdir($sample_patterns_dir) ) !== false) {

                    if (stristr($sample_patterns_file, '.png') !== false || stristr($sample_patterns_file, '.jpg') !== false) {
                        $name = explode('.', $sample_patterns_file);
                        $name = str_replace('.' . end($name), '', $sample_patterns_file);
                        $sample_patterns[]  = array('alt' => $name, 'img' => $sample_patterns_url . $sample_patterns_file);
                    }
                }
            endif;
        endif;

How can i solve that? I’m fed up with this. But its on theme options page in redux framework.

Message from review team:

opendir() is not needed with WordPress themes for the following reasons: - Not particularly safe. - Some hosting companies will disable it by default.

Please help anyone!

Thanks,
E.K.

Delete Those block of codes.