Exemplo n.º 1
0
function phorum_extract_language_strings_recurse($path)
{
    global $extract_strings;
    $dh = opendir($path);
    while ($f = readdir($dh)) {
        $file = "{$path}/{$f}";
        $ext = null;
        if (preg_match('/\\.(\\w+)$/', $f, $m)) {
            $ext = $m[1];
        }
        // Skip what we do not want to index.
        if ($f == "." || $f == "..") {
            continue;
        }
        // this and parent dir
        if ($f == ".svn") {
            continue;
        }
        // SVN data directories
        if ($f == "lang") {
            continue;
        }
        // language files
        if ($f == "mods") {
            continue;
        }
        // mods
        if ($f == "docs") {
            continue;
        }
        // documentation
        if (preg_match('/\\.(php|tpl)$/', $file)) {
            $fp = fopen($file, "r");
            if (!$fp) {
                trigger_error("Can't read file '{$file}'", E_USER_ERROR);
            }
            while ($line = fgets($fp, 1024)) {
                $strings = array();
                if (preg_match_all('/LANG->([\\w_-]+)/', $line, $m, PREG_SET_ORDER)) {
                    $strings = array_merge($strings, $m);
                }
                if (preg_match_all('/(?:\\$PHORUM|\\$GLOBALS\\[["\']PHORUM["\']\\])\\[["\']DATA["\']\\]\\[["\']LANG["\']\\]\\[["\']([^"\']+)["\']\\]/', $line, $m, PREG_SET_ORDER)) {
                    $strings = array_merge($strings, $m);
                }
                foreach ($strings as $string) {
                    if (!isset($extract_strings[$string[1]])) {
                        $extract_strings[$string[1]] = array('files' => array());
                    }
                    $extract_strings[$string[1]]['files'][$file]++;
                    $extract_strings[$string[1]]['source'][$string[0]]++;
                }
            }
            fclose($fp);
        }
        if (is_dir($file)) {
            phorum_extract_language_strings_recurse($file);
        }
    }
    closedir($dh);
}
Exemplo n.º 2
0
function phorum_extract_language_strings_recurse($path)
{
    global $extract_strings;

    $dh = opendir($path);
    while (($f = readdir($dh))) 
    {
        $file = "$path/$f";
        
        $ext = null;
        if (preg_match('/\.(\w+)$/', $f, $m)) $ext = $m[1];

        // Skip what we do not want to index.
        if ($f == "." || $f == "..") continue; // this and parent dir
        if ($f == ".svn") continue;            // SVN data directories
        if ($f == "lang") continue;            // language files
        if ($f == "mods") continue;            // mods
        if ($f == "docs") continue;            // documentation 
        if ($f == "cache") continue;           // the cache directory
        

        if (preg_match('/\.(php|tpl)$/', $file)) {
            $fp = fopen($file, "r");
            if (! $fp) die("Can't read file '$file'");
            while (($line = fgets($fp, 1024))) {
                $strings = array();
                if (preg_match_all('/LANG->([\w_-]+)/', $line, $m, PREG_SET_ORDER)) {
                    $strings = array_merge($strings, $m);
                }
                if (preg_match_all('/\$PHORUM\[["\']DATA["\']\]\[["\']LANG["\']\]\[["\']([^"\']+)["\']\]/', $line, $m, PREG_SET_ORDER)) {              
                    $strings = array_merge($strings, $m);
                }
                foreach ($strings as $string) {
                    if (! isset($extract_strings[$string])) {
                        $extract_strings[$string] = array('files'=>array());
                    }
                    $extract_strings[$string[1]]['files'][$file]++;
                    $extract_strings[$string[1]]['source'][$string[0]]++;

                }
            }
            fclose($fp);
        }
        
        if (is_dir($file)) {
            phorum_extract_language_strings_recurse($file);
        }
    }
    closedir($dh);
}