Пример #1
0
/**
* 
* @command check_class_and_namespace
*/
function pestle_cli($argv)
{
    $path = inputOrIndex('Which folder?', '/path/to/magento/app/code/Pulsestorm', $argv, 0);
    $files = glob_recursive($path . '/*');
    foreach ($files as $file) {
        $file = realpath($file);
        if (strpos($file, '.php') === false) {
            output("NOT .php: Skipping {$file}");
            continue;
        }
        $contents = file_get_contents($file);
        $namespace = parseNamespace($contents);
        if (!$namespace) {
            output("No Namspace: Skipping {$file}");
            continue;
        }
        $class = parseClass($contents);
        if (!$class) {
            output("No Class: Skipping {$class}");
            continue;
        }
        $full_class = $namespace . '\\' . $class;
        $path = str_replace('\\', '/', $full_class) . '.php';
        if (strpos($file, $path) === false) {
            output("ERROR: Path `{$path}` not in");
            output($file);
        } else {
            output('.');
        }
    }
}
Пример #2
0
 function glob_recursive($directory, &$directories = array())
 {
     foreach (glob($directory, GLOB_ONLYDIR | GLOB_NOSORT) as $folder) {
         $directories[] = $folder;
         glob_recursive("{$folder}/*", $directories);
     }
 }
Пример #3
0
Файл: css.php Проект: buuum/app
 function glob_recursive($pattern, $flags = 0)
 {
     $files = glob($pattern, $flags);
     foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
         $files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags));
     }
     return $files;
 }
Пример #4
0
function glob_recursive($pattern, $flags = 0)
{
    //http://www.php.net/manual/en/function.glob.php#106595
    $files = glob($pattern, $flags);
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        $files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags));
    }
    return $files;
}
Пример #5
0
function getMenuXmlFiles()
{
    $base = getBaseMagentoDir();
    // $results = `find $base/vendor -name menu.xml`;
    // $results = explode("\n", $results);
    $results = glob_recursive("{$base}/vendor/menu.xml");
    $results = array_filter($results);
    return $results;
}
Пример #6
0
function getAllControllerFiles($base)
{
    $files = glob($base . '/*');
    $controllers = array_filter($files, function ($item) {
        return is_dir($item . '/Controller/');
    });
    $controllers = array_map(function ($item) {
        return glob_recursive($item . '/Controller/*.php');
    }, $files);
    return $controllers;
}
Пример #7
0
function getFiles($folder, $extension_string)
{
    if (file_exists($folder) && !is_dir($folder)) {
        return [$folder];
    }
    $extensions = array_filter(explode(',', $extension_string));
    $files = [];
    foreach ($extensions as $extension) {
        $files = array_merge($files, glob_recursive($folder . '/*.' . $extension));
    }
    return $files;
}
 public function theme_manifest()
 {
     $this->line("");
     $this->comment("Theme Manifest");
     $theme_folder = get_theme_root() . "/" . get_stylesheet();
     $asset_folder = "/public";
     $uri_path = $theme_folder . $asset_folder;
     $files_array = glob_recursive($uri_path . "/*.*", GLOB_ERR);
     $files_array = array_map(array($this, 'root_to_relative_url'), $files_array);
     foreach ($files_array as $file) {
         $this->line($file);
     }
 }
Пример #9
0
function glob_recursive($pattern, $flags = 0, $prefix_remove = false, $prefix_add = "")
{
    //http://www.php.net/manual/en/function.glob.php#106595
    $files = glob($pattern, $flags);
    $prefix_remove_len = $prefix_remove ? strlen($prefix_remove) : 0;
    foreach ($files as $k => $file) {
        $files[$k] = $prefix_add . substr($file, $prefix_remove_len);
    }
    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
        $files = array_merge($files, glob_recursive($dir . '/' . basename($pattern), $flags, $prefix_remove, $prefix_add));
    }
    return $files;
}
Пример #10
0
 function get_theme_files($extension = 'php', $directory = '/')
 {
     $theme_dir = CMS_ROOT . 'themes/' . $this->settings->theme . '/';
     $pattern = $theme_dir . trim($directory, '/') . '/*.' . $extension;
     $file_array = array();
     $files = glob_recursive($pattern, GLOB_BRACE);
     foreach ($files as $file) {
         $relative_path = str_replace(dirname($pattern) . '/', '', $file);
         $theme_path = str_replace($theme_dir, '', $file);
         $file_array[$relative_path] = array('hash' => url_base64_encode($theme_path), 'theme_path' => $theme_path, 'relative_path' => $relative_path, 'title' => ucwords(str_replace(array('_', '-'), ' ', basename($file, '.' . $extension))));
     }
     return $file_array;
 }
Пример #11
0
function getUsedAclRuleIdsFromControllerFiles($dir)
{
    $files = glob_recursive($dir . '/*/Controller/*.php');
    $code = array_map(function ($file) {
        $function = getFunctionFromCode(file_get_contents($file), '_isAllowed');
        if (strpos($function, '_isAllowed')) {
            return getAclRulesFromIsAllowedFunction($function);
        }
        return false;
    }, $files);
    $code = array_filter($code);
    return $code;
}
Пример #12
0
 function testLintErrors() {
     $exit = 0;
     $root = get_osticket_root_path();
     foreach (glob_recursive("$root/*.js") as $s) {
         ob_start();
         system("jsl -process $s", $exit);
         $line = ob_get_contents();
         ob_end_clean();
         if ($exit == 3)
             $this->fail($s, 0, $line);
         else
             $this->pass();
     }
 }
Пример #13
0
 function glob_recursive($pattern, $flags = 0)
 {
     $files = glob($pattern, $flags);
     $dirs = glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT);
     if (is_array($files) && !empty($dirs)) {
         foreach ($dirs as $dir) {
             $_files = glob_recursive($dir . '/' . basename($pattern), $flags);
             if (is_array($_files)) {
                 $files = array_merge($files, $_files);
             }
         }
     }
     return $files;
 }
Пример #14
0
function glob_recursive($pattern, $int_flags = 0)
{
    $files = glob($pattern, $int_flags);
    if (!$files) {
        $files = array();
    }
    foreach ($files as $k => $filename) {
        if (is_dir($filename)) {
            unset($files[$k]);
            $subfiles = glob_recursive($filename . '/*', $int_flags);
            $files = array_merge($files, $subfiles);
        }
    }
    return $files;
}
Пример #15
0
 function get_tpl_contents($theme = 'default')
 {
     require DATA_PATH . 'themes/' . $theme . '/info.php';
     $pfiles = array();
     if (isset($info['parent_theme'])) {
         $pfiles = glob_recursive(DATA_PATH . 'themes/' . $info['parent_theme'] . '/*.tpl');
     }
     $cfiles = glob_recursive(DATA_PATH . 'themes/' . $theme . '/*.tpl');
     $files = array_merge($pfiles, $cfiles);
     $tcontent = "";
     foreach ($files as $file) {
         $tcontent .= file_get_contents($file);
     }
     return $tcontent;
 }
Пример #16
0
 static function getAllScripts($excludes=true, $root=false) {
     $root = $root ?: get_osticket_root_path();
     $scripts = array();
     foreach (glob_recursive("$root/*.php") as $s) {
         $found = false;
         if ($excludes) {
             foreach (self::$third_party_paths as $p) {
                 if (strpos($s, $p) !== false) {
                     $found = true;
                     break;
                 }
             }
         }
         if (!$found)
             $scripts[] = $s;
     }
     return $scripts;
 }
Пример #17
0
 public function test_creates_documentation_folder_and_copies_assets()
 {
     $outputDir = __DIR__ . '/output';
     $documentarian = new Documentarian();
     $documentarian->create($outputDir);
     // Test for folders
     $this->assertTrue(is_dir($outputDir . '/source'));
     $this->assertTrue(is_dir($outputDir . '/source/includes'));
     $this->assertTrue(is_dir($outputDir . '/source/assets'));
     $this->assertTrue(is_dir($outputDir . '/css'));
     $this->assertTrue(is_dir($outputDir . '/js'));
     // Test that stubbed files exist
     $this->assertFileExists($outputDir . '/source/index.md');
     $this->assertFileExists($outputDir . '/source/.gitignore');
     $this->assertFileExists($outputDir . '/source/includes/_errors.md');
     $this->assertFileExists($outputDir . '/source/package.json');
     $this->assertFileExists($outputDir . '/source/gulpfile.js');
     $this->assertFileExists($outputDir . '/source/config.php');
     $this->assertFileExists($outputDir . '/js/all.js');
     $this->assertFileExists($outputDir . '/css/style.css');
     // Test that resources were copied
     $jsFiles = glob_recursive(__DIR__ . '/../resources/js/*');
     foreach ($jsFiles as $jsFile) {
         $file = str_replace(__DIR__ . '/../resources/', $outputDir . '/source/assets/', $jsFile);
         if (!is_dir($jsFile)) {
             $this->assertFileExists($file);
         }
     }
     $cssFiles = glob_recursive(__DIR__ . '/../resources/stylus/*');
     foreach ($cssFiles as $cssFile) {
         $file = str_replace(__DIR__ . '/../resources/', $outputDir . '/source/assets/', $cssFile);
         if (!is_dir($cssFile)) {
             $this->assertFileExists($file);
         }
     }
     $imageFiles = glob_recursive(__DIR__ . '/../resources/images/*');
     foreach ($imageFiles as $imageFile) {
         $file = str_replace(__DIR__ . '/../resources/', $outputDir . '/source/assets/', $imageFile);
         if (!is_dir($imageFile)) {
             $this->assertFileExists($file);
         }
     }
 }
function glob_recursive($Pattern, $Flags = 0, $Strip_Underscore = false)
{
    $Return = array();
    // Search in the Current Directory
    foreach (glob($Pattern, $Flags) as $File) {
        if (!$Strip_Underscore || strpos($File, '/_') === false) {
            $Return[] = realpath($File);
        }
    }
    // FOREACHDIRECTORY
    // Search in ALL sub-directories.
    foreach (glob(dirname($Pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $Directory) {
        // This is a recursive function.
        // Usually, THIS IS VERY BAD.
        // For searching recursively however,
        // it does make some sense.
        if (!$Strip_Underscore || strpos($Directory, '/_') === false) {
            $Return = array_merge($Return, glob_recursive($Directory . '/' . basename($Pattern), $Flags, $Strip_Underscore));
        }
    }
    // FOREACHDIRECTORY
    return $Return;
}
Пример #19
0
 /**
  * Get resources files
  */
 public function getResourcesFiles($type = 'site')
 {
     $files = array_merge(glob_recursive(Theme::model()->getSourceWwwDir($type) . '/*.css'), glob_recursive(Theme::model()->getSourceWwwDir($type) . '/*.js'));
     return $files;
 }
Пример #20
0
<?php

function isJson($filename)
{
    $string = file_get_contents($filename);
    json_decode($string);
    return json_last_error() == JSON_ERROR_NONE;
}
require_once __DIR__ . '/function.glob_recursive.php';
$json_files = glob_recursive(__DIR__ . '/../*.json');
$result['invalid_files'] = array();
$result['valid_files'] = array();
foreach ($json_files as $filename) {
    // Validate
    if (isJson($filename)) {
        $result['valid_files'][] = $filename;
    } else {
        $result['invalid_files'][] = $filename;
    }
}
var_dump($result);
if (!empty($result['invalid_files'])) {
    // That's an error
    exit(1);
}
Пример #21
0
            print("$test: $message @ $script:$line\n");
        }
        return count($fails);
    }
}
if (function_exists('pcntl_signal')) {
    declare(ticks=1);
    function show_fails_on_ctrlc() {
        while (@ob_end_flush());
        print("\n");
        exit(show_fails());
    }
    pcntl_signal(SIGINT, 'show_fails_on_ctrlc');
}

foreach (glob_recursive(dirname(__file__)."/tests/test.*.php") as $t) {
    if (strpos($t,"class.") !== false)
        continue;
    $class = (include $t);
    if (!is_string($class))
        continue;
    if($selected_test && ($class != $selected_test))
    	continue;
    $test = new $class();
    echo "Running: " . $test->name . "\n";
    $test->run();
    $fails = array_merge($fails, $test->fails);
    echo " ok\n";
}
show_fails();
Пример #22
0
 /**
  * Возвращает ассоциативный массив исходных файлов [fullpath => namespace]
  * @param  string $path Путь до класса/классов
  * @return array
  */
 protected function getSourceClasses($path)
 {
     $filepath = trim(str_replace('\\', '/', $path), '/');
     $fullpath = $this->sourcePath . '/' . $filepath;
     $result = [];
     if (substr($fullpath, -4, 4) === '.php' && file_exists($fullpath)) {
         $result[$filepath] = substr($path, 0, -4);
     } else {
         if (!is_dir($fullpath) && file_exists($fullpath . '.php')) {
             $result[$filepath . '.php'] = $path;
         } else {
             if (is_dir($fullpath)) {
                 $preflen = strlen($this->sourcePath);
                 $files = glob_recursive($fullpath . '/*.php', GLOB_NOSORT);
                 foreach ($files as $filepath) {
                     if (strpos($filepath, 'Example') !== false) {
                         continue;
                     }
                     $fp = substr($filepath, $preflen + 1);
                     $ns = '\\' . str_replace('/', '\\', substr($fp, 0, -4));
                     $result[$fp] = $ns;
                 }
             }
         }
     }
     return $result;
 }
function _pugpig_directory_get_files($directory)
{
    if (substr($directory, -1) != '/') {
        $directory = $directory . '/';
    }
    $match = $directory . "*.*";
    $f = glob_recursive($match, GLOB_ERR);
    // print_r(implode($f, "<br />")); exit();
    return $f;
}
Пример #24
0
if (isset($_GET['files_backup'])) {
    set_time_limit(600);
    $GLOBALS['cache']->clear();
    // Clear cache to remove unimpoartant data to save space and possible errors
    include_once $pclzip_path;
    $destination_filepath = 'backup/files_' . CC_VERSION . '_' . date("dMy-His") . '.zip';
    $archive = new PclZip($destination_filepath);
    $skip_folders = 'backup|cache|images/cache';
    if (isset($_POST['skip_images']) && $_POST['skip_images'] == '1') {
        $skip_folders .= '|images/source';
    }
    if (isset($_POST['skip_downloads']) && $_POST['skip_downloads'] == '1') {
        $skip_folders .= '|files';
    }
    $backup_list = array();
    $files = glob_recursive('*');
    foreach ($files as $file) {
        $file_match = preg_replace('#^./#', '', $file);
        if ($file == 'images' || preg_match('#^(' . $skip_folders . ')#', $file_match)) {
            continue;
        }
        $backup_list[] = $file;
    }
    $v_list = $archive->create($backup_list);
    if ($v_list == 0) {
        @unlink($destination_filepath);
        $GLOBALS['main']->setACPWarning("Error: " . $archive->errorInfo(true));
    } else {
        $GLOBALS['main']->setACPNotify($lang['maintain']['files_backup_complete']);
    }
    httpredir('?_g=maintenance&node=index#backup');
Пример #25
0
}
$command = 'mv RELEASE-0.1.0 RELEASE-' . $package_release;
$output = script_run_command($command);
$command = 'mv API-0.1.0 API-' . $package_release;
$output = script_run_command($command);
$command = 'rm package_compatible.xml';
$output = script_run_command($command);
$command = 'rm stub.php';
$output = script_run_command($command);
$command = 'rm -Rf tests/ www/ example/ docs/ data/';
$output = script_run_command($command);
$file_replacements = array();
$file_replacements['{PACKAGE_NAME}'] = $package_name;
$file_replacements['{PACKAGE_RELEASE}'] = $package_release;
$file_replacements['{PACKAGE_REQUIRE_DEPENDENCIES}'] = null;
$composers = glob_recursive('composer.json');
if ($composers) {
    $composer_file = $composers[0];
}
if (isset($composer_file)) {
    $content = file_get_contents($composer_file);
    $composer = json_decode($content, true);
    $package_info = array();
    foreach ($composer['require'] as $dep => $version) {
        $vendor = $name = $dep;
        if (strpos($dep, '/')) {
            list($vendor, $name) = explode('/', $dep, 2);
        }
        if ($vendor == 'zendframework') {
            $name = ucwords(str_replace('-', ' ', $name));
            $package_info['required'] = str_replace(' ', '_', $name);
Пример #26
0
    while (strcmp($ap[$i], $bp[$i]) === 0) {
        $i++;
    }
    return strcmp($ap[$i], $bp[$i]);
});
//$files = glob_recursive(__DIR__ . '/../src/*.js');
//foreach ($files as $i => $file) {
//    $files[$i] = trim(substr(realpath($file), strlen(realpath(__DIR__ . '/../src'))), DIRECTORY_SEPARATOR);
//    $files[$i] = str_replace('\\', '/', $files[$i]);
//}
//echo implode(PHP_EOL, $files);
//
//$files = glob_recursive(__DIR__ . '/../src/*.css');
//foreach ($files as $i => $file) {
//    $files[$i] = trim(substr(realpath($file), strlen(realpath(__DIR__ . '/../src'))), DIRECTORY_SEPARATOR);
//    $files[$i] = str_replace('\\', '/', $files[$i]);
//}
//echo implode(PHP_EOL, $files);
//
//$files = glob_recursive(__DIR__ . '/../src/*.png');
//foreach ($files as $i => $file) {
//    $files[$i] = trim(substr(realpath($file), strlen(realpath(__DIR__ . '/../src'))), DIRECTORY_SEPARATOR);
//    $files[$i] = str_replace('\\', '/', $files[$i]);
//}
//echo implode(PHP_EOL, $files);
$files = glob_recursive(__DIR__ . '/../src/*.html');
foreach ($files as $i => $file) {
    $files[$i] = trim(substr(realpath($file), strlen(realpath(__DIR__ . '/../src'))), DIRECTORY_SEPARATOR);
    $files[$i] = str_replace('\\', '/', $files[$i]);
}
echo implode(PHP_EOL, $files);
Пример #27
0
    function __getAllJsPhrases($root=ROOT_DIR) {
        $strings = array();
        $root = rtrim($root, '/') . '/';
        $funcs = array('__'=>array('forms'=>1));
        foreach (glob_recursive($root . "*.js") as $s) {
            $script = file_get_contents($s);
            $s = str_replace($root, '', $s);
            $this->stderr->write($s."\n");
            $calls = array();
            preg_match_all('/(?:function\s+)?__\(\s*[^\'"]*(([\'"])(?:(?<!\\\\)\2|.)+\2)\s*[^)]*\)/',
                $script, $calls, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
            foreach ($calls as $c) {
                if (!($call = $this->__find_strings(token_get_all('<?php '.$c[0][0]), $funcs, 0)))
                    continue;
                $call = $call[0];

                list($lhs) = str_split($script, $c[1][1]);
                $call['line'] = strlen($lhs) - strlen(str_replace("\n", "", $lhs)) + 1;

                self::__addString($strings, $call, $s);
            }
        }
        return $strings;
    }
Пример #28
0
 /**
  * Deletes all thumbs from one media
  *
  * @param $media
  */
 public function delete_thumbs($media)
 {
     self::$ci->load->helper('file');
     $thumb_folder = Settings::get('thumb_folder') ? Settings::get('thumb_folder') : '.thumbs';
     $thumb_path_segment = str_replace(Settings::get('files_path') . '/', '', $media['base_path']);
     $thumb_base_path = DOCPATH . Settings::get('files_path') . '/' . $thumb_folder . '/';
     $thumb_file_path = $thumb_base_path . $thumb_path_segment . $media['file_name'];
     $thumbs = glob_recursive($thumb_file_path);
     foreach ($thumbs as $thumb) {
         @unlink($thumb);
     }
 }
Пример #29
0
<?php

require_once __DIR__ . '/functions.php';
$result = [];
$scan = function ($path) use(&$result) {
    // echo 'Scanning: ' . $path . PHP_EOL;
    foreach (glob_recursive($path) as $file) {
        // echo 'Found: ' . $file . PHP_EOL;
        $contents = file_get_contents($file);
        $matches = null;
        preg_match_all('/^function (.+?)\\(/m', $contents, $matches);
        foreach ($matches[1] as $function) {
            $result[] = "if (typeof Raptor.{$function} === 'undefined' && typeof {$function} !== 'undefined') Raptor.{$function} = {$function};";
        }
    }
};
$scan(__DIR__ . '/../src/tools/*.js');
$scan(__DIR__ . '/../src/adapters/*.js');
$scan(__DIR__ . '/../src/components/*.js');
$scan(__DIR__ . '/../src/tools/*.js');
$scan(__DIR__ . '/../../raptor-common/*.js');
$result = array_unique($result);
natsort($result);
$result = implode(PHP_EOL, $result);
echo "// <expose>\n{$result}\nwindow.Raptor = Raptor;\n// </expose>\n";
Пример #30
0
<?php

require_once __DIR__ . '/functions.php';
if (!isset($_SERVER['argv'][1]) || !is_dir($_SERVER['argv'][1])) {
    echo 'Usage: php scripts\\list-files.php <directory>';
    exit;
}
$directory = $_SERVER['argv'][1];
$files = glob_recursive($directory . '/*.*');
foreach ($files as $i => $file) {
    $files[$i] = realpath($file);
}
usort($files, function ($a, $b) {
    if (dirname($a) != dirname($b)) {
        return strcmp(dirname($a), dirname($b));
    }
    $ae = substr($a, strpos($a, '.') + 1);
    $be = substr($b, strpos($b, '.') + 1);
    if ($ae === $be) {
        return strcmp($a, $b);
    }
    return strcmp($ae, $be);
});
$root = realpath(__DIR__ . '/..') . '/';
$last_path = null;
foreach ($files as $i => $file) {
    if ($last_path === null) {
        $last_path = dirname($file);
    } elseif ($last_path !== dirname($file) && !preg_match('/[\\/\\\\]templates[\\/\\\\]/', $file)) {
        echo PHP_EOL;
        $last_path = dirname($file);