示例#1
0
function includedFiles($filename)
{
    if (!file_exists($filename)) {
        return array();
    }
    $file = file_get_contents($filename);
    if (!$file) {
        return array();
    }
    $file = strip_comments($file);
    $includes = array();
    if (preg_match_all('/^\\s*#(include|import)\\s+"([^"]+)"/m', $file, $matches)) {
        foreach ($matches[2] as $match) {
            if ($match[0] == "/" || $match[0] == "~") {
                $include = $match;
            } else {
                $include = dirname($filename) . "/" . $match;
            }
            $include = normalize_path($include);
            if (!$include) {
                continue;
            }
            array_push($includes, $include);
        }
    }
    return $includes;
}
示例#2
0
文件: gFSS.php 项目: easy-designs/v2
function get_gFSS($f)
{
    # get the active css file
    $css_file = urldecode($_REQUEST['f']);
    # read the content into a variable & close the file
    $content = read_file_to_var($css_file);
    # standardize the coding style
    $content = standardize_code($content);
    # strip any comments
    $content = strip_comments($content);
    # get the array of gFSS-related CSS data
    $gFSS_arr = get_gFSS_array($content);
    # output the final array as XML
    output_gFSS_XML($gFSS_arr);
}
function ParsePHPFile($file, $prepend_out = '')
{
    $contents = file_get_contents($file);
    $contents = strip_comments($contents);
    if (preg_match_all("/<\\?(php)?(.*?)(\\?>|\$\$)/s", $contents, $matchs)) {
        foreach ($matchs[2] as $match) {
            $match = strip_comments($match);
            $results = lookForPaths($match);
            if ($results) {
                for ($i = 0; $i < count($results[0]); $i++) {
                    $file_param = get_file_path($results[1][$i], $results[2][$i]);
                    if (is_absolute_file($file_param)) {
                        echo $prepend_out . "{$file} : " . trim($results[0][$i]) . PHP_EOL;
                    }
                }
            }
        }
    }
}
示例#4
0
    $file = $_GET['file'];
    $require_comments = $file[0] == '.';
    $file = '../' . $file;
    $filepath = realpath($file);
    $basepath = realpath('../../');
    if (strpos($basepath, $filepath) === 0) {
        #trying to get the source outside restler examples
        die('not allowed');
    }
    if (!file_exists($file)) {
        die('file not found');
    }
    $text = file_get_contents($file);
    $file = pathinfo($file, PATHINFO_FILENAME) . '.php';
    if (!$require_comments) {
        $text = strip_comments($text);
    }
    die($file . '<pre id="php">' . htmlspecialchars($text) . "</pre>");
} else {
    die('no file specified');
}
function strip_comments($fileStr)
{
    $newStr = '';
    $commentTokens = array(T_COMMENT);
    //if (defined('T_DOC_COMMENT'))
    //$commentTokens[] = T_DOC_COMMENT; // PHP 5
    $tokens = token_get_all($fileStr);
    $result = array();
    foreach ($tokens as $token) {
        if (is_array($token)) {
示例#5
0
function is_plausible_decl($text, &$title)
{
    // Don't go too far into inline functions
    if (preg_match('/^\\s*static inline (.*?)\\{/s', $text, $matches)) {
        $text = $matches[1];
    }
    // Sanity check; if there are blank lines in there, we probably
    // got too much, unless this is a struct
    if (!preg_match('/^struct/', $text) && strpos($text, "\n\n") !== false) {
        return '';
    }
    $text = trim($text);
    // Look for what is probably the function name
    $stripped = strip_comments($text);
    if (preg_match(',^typedef\\s+\\S+\\s+\\(\\*(ph_[a-zA-Z0-9_]+)\\),', $stripped, $matches)) {
        $title = $matches[1];
    } else {
        if (preg_match(',^(struct\\s+\\S+),', $stripped, $matches)) {
            $title = $matches[1];
        } else {
            if (preg_match(',((ph|PH)_[a-zA-Z0-9_]+)\\(,', $stripped, $matches)) {
                $title = $matches[1];
            } else {
                if (preg_match(',(struct\\s+\\S+),', $stripped, $matches)) {
                    $title = $matches[1];
                }
            }
        }
    }
    return $text;
}
示例#6
0
function get_text($title, $section, $return = False, $return_lines_array = False)
{
    if ($title == "") {
        wiki_privmsg($return, "wiki: get_text=invalid title");
        return False;
    }
    $index = -1;
    $title = str_replace(" ", "_", $title);
    if ($section != "") {
        $uri = "/w/api.php?action=parse&format=php&page=" . urlencode($title) . "&prop=sections";
        $response = wget(WIKI_HOST, $uri, 80, WIKI_USER_AGENT);
        $data = unserialize(strip_headers($response));
        if (isset($data["parse"]["sections"]) == False) {
            wiki_privmsg($return, "wiki: get_text=error getting sections for page \"" . $title . "\"");
            return False;
        }
        $sections = $data["parse"]["sections"];
        for ($i = 0; $i < count($sections); $i++) {
            $line = $sections[$i]["line"];
            if (strtolower($section) == strtolower($line)) {
                $index = $sections[$i]["index"];
                break;
            }
        }
    }
    $uri = "/w/api.php?action=parse&format=php&page=" . urlencode($title) . "&prop=text";
    if ($index > 0) {
        $uri = $uri . "&section={$index}";
    }
    /*$url="http://".WIKI_HOST.$uri;
      $url=get_redirected_url($url);
      if (get_host_and_uri($url,&$host,&$uri,&$port)==False)
      {
        wiki_privmsg($return,"wiki: get_text=url parse failed");
        return False;
      }*/
    $response = wget(WIKI_HOST, $uri, 80, WIKI_USER_AGENT);
    $data = unserialize(strip_headers($response));
    if (isset($data["parse"]["text"]["*"]) == True) {
        $text = $data["parse"]["text"]["*"];
        if ($section != "") {
            $id = str_replace(" ", "_", $section);
            $id = str_replace("~", ".7E", $id);
            $id = str_replace("(", ".28", $id);
            $id = str_replace(")", ".29", $id);
            $head = "<span class=\"mw-headline\" id=\"{$id}\">{$section}</span>";
            if (strpos($text, $head) === False) {
                wiki_privmsg($return, "wiki: get_text=section span not found");
                return False;
            }
        }
    } else {
        wiki_privmsg($return, "wiki: get_text=section not found");
        return False;
    }
    strip_comments($text);
    strip_all_tag($text, "h2");
    strip_all_tag($text, "h3");
    $text = strip_tags($text);
    $text = trim($text, " \t\n\r\v\"");
    $br = random_string(30);
    $text = str_replace("\n", $br, $text);
    $text = replace_ctrl_chars($text, " ");
    $text = html_decode($text);
    $text = clean_text($text);
    $url = "http://wiki.soylentnews.org/wiki/" . urlencode($title);
    if ($section != "") {
        $url = $url . "#{$id}";
    }
    if ($return_lines_array == False) {
        $text = str_replace($br, " ", $text);
        $text = clean_text($text);
        if (strlen($text) > 400) {
            $text = trim(substr($text, 0, 400)) . "...";
        }
        bot_ignore_next();
        wiki_privmsg($return, $text);
        wiki_privmsg($return, $url);
        $result = $text;
    } else {
        $result = explode($br, $text);
        for ($i = 0; $i < count($result); $i++) {
            $result[$i] = trim($result[$i]);
            if (strlen($result[$i]) > 300) {
                $result[$i] = trim(substr($result[$i], 0, 300)) . "...";
            }
        }
        delete_empty_elements($result);
        $result[] = $url;
    }
    return $result;
}
示例#7
0
function cWebGLIncludeFile($file)
{
    global $basepath;
    if (!file_exists($basepath . '/' . $file)) {
        return "throw new Error('Could not load file \\'{$file}\\'');";
    }
    ob_start();
    include $basepath . '/' . $file;
    $output = ob_get_clean();
    $output = strip_comments($output);
    $output = preg_replace('#\\n\\n+#', "\n", $output);
    $output = preg_replace_callback('#include\\(\'([^\']+)\'\\);#', 'cWebGLIncludeCallback', $output);
    $output = "//file: {$file}\n{$output}";
    //$output = processCnvGLDefines($output);
    return $output;
}
function validate_email($email)
{
    $no_ws_ctl = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]";
    $alpha = "[\\x41-\\x5a\\x61-\\x7a]";
    $digit = "[\\x30-\\x39]";
    $cr = "\\x0d";
    $lf = "\\x0a";
    $crlf = "(?:{$cr}{$lf})";
    $obs_char = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]";
    $obs_text = "(?:{$lf}*{$cr}*(?:{$obs_char}{$lf}*{$cr}*)*)";
    $text = "(?:[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|{$obs_text})";
    $text = "(?:{$lf}*{$cr}*{$obs_char}{$lf}*{$cr}*)";
    $obs_qp = "(?:\\x5c[\\x00-\\x7f])";
    $quoted_pair = "(?:\\x5c{$text}|{$obs_qp})";
    $wsp = "[\\x20\\x09]";
    $obs_fws = "(?:{$wsp}+(?:{$crlf}{$wsp}+)*)";
    $fws = "(?:(?:(?:{$wsp}*{$crlf})?{$wsp}+)|{$obs_fws})";
    $ctext = "(?:{$no_ws_ctl}|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])";
    $ccontent = "(?:{$ctext}|{$quoted_pair})";
    $comment = "(?:\\x28(?:{$fws}?{$ccontent})*{$fws}?\\x29)";
    $cfws = "(?:(?:{$fws}?{$comment})*(?:{$fws}?{$comment}|{$fws}))";
    $outer_ccontent_dull = "(?:{$fws}?{$ctext}|{$quoted_pair})";
    $outer_ccontent_nest = "(?:{$fws}?{$comment})";
    $outer_comment = "(?:\\x28{$outer_ccontent_dull}*(?:{$outer_ccontent_nest}{$outer_ccontent_dull}*)+{$fws}?\\x29)";
    $atext = "(?:{$alpha}|{$digit}|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])";
    $atext_domain = "(?:{$alpha}|{$digit}|[\\x2b\\x2d\\x5f])";
    $atom = "(?:{$cfws}?(?:{$atext})+{$cfws}?)";
    $atom_domain = "(?:{$cfws}?(?:{$atext_domain})+{$cfws}?)";
    $qtext = "(?:{$no_ws_ctl}|[\\x21\\x23-\\x5b\\x5d-\\x7e])";
    $qcontent = "(?:{$qtext}|{$quoted_pair})";
    $quoted_string = "(?:{$cfws}?\\x22(?:{$fws}?{$qcontent})*{$fws}?\\x22{$cfws}?)";
    $quoted_string = "(?:{$cfws}?\\x22(?:{$fws}?{$qcontent})+{$fws}?\\x22{$cfws}?)";
    $word = "(?:{$atom}|{$quoted_string})";
    $obs_local_part = "(?:{$word}(?:\\x2e{$word})*)";
    $obs_domain = "(?:{$atom_domain}(?:\\x2e{$atom_domain})*)";
    $dot_atom_text = "(?:{$atext}+(?:\\x2e{$atext}+)*)";
    $dot_atom_text_domain = "(?:{$atext_domain}+(?:\\x2e{$atext_domain}+)*)";
    $dot_atom = "(?:{$cfws}?{$dot_atom_text}{$cfws}?)";
    $dot_atom_domain = "(?:{$cfws}?{$dot_atom_text_domain}{$cfws}?)";
    $dtext = "(?:{$no_ws_ctl}|[\\x21-\\x5a\\x5e-\\x7e])";
    $dcontent = "(?:{$dtext}|{$quoted_pair})";
    $domain_literal = "(?:{$cfws}?\\x5b(?:{$fws}?{$dcontent})*{$fws}?\\x5d{$cfws}?)";
    $local_part = "(({$dot_atom})|({$quoted_string})|({$obs_local_part}))";
    $domain = "(({$dot_atom_domain})|({$domain_literal})|({$obs_domain}))";
    $addr_spec = "{$local_part}\\x40{$domain}";
    if (strlen($email) > 256) {
        return FALSE;
    }
    $email = strip_comments($outer_comment, $email, "(x)");
    if (!preg_match("!^{$addr_spec}\$!", $email, $m)) {
        return FALSE;
    }
    $bits = array('local' => isset($m[1]) ? $m[1] : '', 'local-atom' => isset($m[2]) ? $m[2] : '', 'local-quoted' => isset($m[3]) ? $m[3] : '', 'local-obs' => isset($m[4]) ? $m[4] : '', 'domain' => isset($m[5]) ? $m[5] : '', 'domain-atom' => isset($m[6]) ? $m[6] : '', 'domain-literal' => isset($m[7]) ? $m[7] : '', 'domain-obs' => isset($m[8]) ? $m[8] : '');
    $bits['local'] = strip_comments($comment, $bits['local']);
    $bits['domain'] = strip_comments($comment, $bits['domain']);
    if (strlen($bits['local']) > 64) {
        return FALSE;
    }
    if (strlen($bits['domain']) > 255) {
        return FALSE;
    }
    if (strlen($bits['domain-literal'])) {
        $Snum = "(\\d{1,3})";
        $IPv4_address_literal = "{$Snum}\\.{$Snum}\\.{$Snum}\\.{$Snum}";
        $IPv6_hex = "(?:[0-9a-fA-F]{1,4})";
        $IPv6_full = "IPv6\\:{$IPv6_hex}(:?\\:{$IPv6_hex}){7}";
        $IPv6_comp_part = "(?:{$IPv6_hex}(?:\\:{$IPv6_hex}){0,5})?";
        $IPv6_comp = "IPv6\\:({$IPv6_comp_part}\\:\\:{$IPv6_comp_part})";
        $IPv6v4_full = "IPv6\\:{$IPv6_hex}(?:\\:{$IPv6_hex}){5}\\:{$IPv4_address_literal}";
        $IPv6v4_comp_part = "{$IPv6_hex}(?:\\:{$IPv6_hex}){0,3}";
        $IPv6v4_comp = "IPv6\\:((?:{$IPv6v4_comp_part})?\\:\\:(?:{$IPv6v4_comp_part}\\:)?){$IPv4_address_literal}";
        if (preg_match("!^\\[{$IPv4_address_literal}\\]\$!", $bits['domain'], $m)) {
            if (intval($m[1]) > 255) {
                return FALSE;
            }
            if (intval($m[2]) > 255) {
                return FALSE;
            }
            if (intval($m[3]) > 255) {
                return FALSE;
            }
            if (intval($m[4]) > 255) {
                return FALSE;
            }
        } else {
            while (1) {
                if (preg_match("!^\\[{$IPv6_full}\\]\$!", $bits['domain'])) {
                    break;
                }
                if (preg_match("!^\\[{$IPv6_comp}\\]\$!", $bits['domain'], $m)) {
                    list($a, $b) = explode('::', $m[1]);
                    $folded = strlen($a) && strlen($b) ? "{$a}:{$b}" : "{$a}{$b}";
                    $groups = explode(':', $folded);
                    if (count($groups) > 6) {
                        return FALSE;
                    }
                    break;
                }
                if (preg_match("!^\\[{$IPv6v4_full}\\]\$!", $bits['domain'], $m)) {
                    if (intval($m[1]) > 255) {
                        return FALSE;
                    }
                    if (intval($m[2]) > 255) {
                        return FALSE;
                    }
                    if (intval($m[3]) > 255) {
                        return FALSE;
                    }
                    if (intval($m[4]) > 255) {
                        return FALSE;
                    }
                    break;
                }
                if (preg_match("!^\\[{$IPv6v4_comp}\\]\$!", $bits['domain'], $m)) {
                    list($a, $b) = explode('::', $m[1]);
                    $b = substr($b, 0, -1);
                    # remove the trailing colon before the IPv4 address
                    $folded = strlen($a) && strlen($b) ? "{$a}:{$b}" : "{$a}{$b}";
                    $groups = explode(':', $folded);
                    if (count($groups) > 4) {
                        return FALSE;
                    }
                    break;
                }
                return FALSE;
            }
        }
    } else {
        $labels = explode('.', $bits['domain']);
        if (count($labels) == 1) {
            return FALSE;
        }
        foreach ($labels as $label) {
            if (strlen($label) > 63) {
                return FALSE;
            }
            if (substr($label, 0, 1) == '-') {
                return FALSE;
            }
            if (substr($label, -1) == '-') {
                return FALSE;
            }
        }
        if (preg_match('!^[0-9]+$!', array_pop($labels))) {
            return FALSE;
        }
    }
    return TRUE;
}
示例#9
0
function strip_comments(&$html)
{
    $i = strpos($html, "<!--");
    $end = "-->";
    $j = strpos($html, $end);
    if ($i === False or $j === False) {
        return False;
    }
    $html = substr($html, 0, $i) . substr($html, $j + strlen($end));
    strip_comments($html);
    return True;
}
function validate_email($email){


    $no_ws_ctl    = "[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]";
    $alpha        = "[\\x41-\\x5a\\x61-\\x7a]";
    $digit        = "[\\x30-\\x39]";
    $cr        = "\\x0d";
    $lf        = "\\x0a";
    $crlf        = "(?:$cr$lf)";


    $obs_char    = "[\\x00-\\x09\\x0b\\x0c\\x0e-\\x7f]";
    $obs_text    = "(?:$lf*$cr*(?:$obs_char$lf*$cr*)*)";
    $text        = "(?:[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]|$obs_text)";


    $text        = "(?:$lf*$cr*$obs_char$lf*$cr*)";
    $obs_qp        = "(?:\\x5c[\\x00-\\x7f])";
    $quoted_pair    = "(?:\\x5c$text|$obs_qp)";


    $wsp        = "[\\x20\\x09]";
    $obs_fws    = "(?:$wsp+(?:$crlf$wsp+)*)";
    $fws        = "(?:(?:(?:$wsp*$crlf)?$wsp+)|$obs_fws)";
    $ctext        = "(?:$no_ws_ctl|[\\x21-\\x27\\x2A-\\x5b\\x5d-\\x7e])";
    $ccontent    = "(?:$ctext|$quoted_pair)";
    $comment    = "(?:\\x28(?:$fws?$ccontent)*$fws?\\x29)";
    $cfws        = "(?:(?:$fws?$comment)*(?:$fws?$comment|$fws))";


    $outer_ccontent_dull    = "(?:$fws?$ctext|$quoted_pair)";
    $outer_ccontent_nest    = "(?:$fws?$comment)";
    $outer_comment        = "(?:\\x28$outer_ccontent_dull*(?:$outer_ccontent_nest$outer_ccontent_dull*)+$fws?\\x29)";



    $atext        = "(?:$alpha|$digit|[\\x21\\x23-\\x27\\x2a\\x2b\\x2d\\x2f\\x3d\\x3f\\x5e\\x5f\\x60\\x7b-\\x7e])";
    $atext_domain     = "(?:$alpha|$digit|[\\x2b\\x2d\\x5f])";

    $atom        = "(?:$cfws?(?:$atext)+$cfws?)";
    $atom_domain       = "(?:$cfws?(?:$atext_domain)+$cfws?)";


    $qtext        = "(?:$no_ws_ctl|[\\x21\\x23-\\x5b\\x5d-\\x7e])";
    $qcontent    = "(?:$qtext|$quoted_pair)";
    $quoted_string    = "(?:$cfws?\\x22(?:$fws?$qcontent)*$fws?\\x22$cfws?)";


    $quoted_string    = "(?:$cfws?\\x22(?:$fws?$qcontent)+$fws?\\x22$cfws?)";
    $word        = "(?:$atom|$quoted_string)";


    $obs_local_part    = "(?:$word(?:\\x2e$word)*)";


    $obs_domain    = "(?:$atom_domain(?:\\x2e$atom_domain)*)";

    $dot_atom_text     = "(?:$atext+(?:\\x2e$atext+)*)";
    $dot_atom_text_domain    = "(?:$atext_domain+(?:\\x2e$atext_domain+)*)";


    $dot_atom    	   = "(?:$cfws?$dot_atom_text$cfws?)";
    $dot_atom_domain   = "(?:$cfws?$dot_atom_text_domain$cfws?)";


    $dtext        = "(?:$no_ws_ctl|[\\x21-\\x5a\\x5e-\\x7e])";
    $dcontent    = "(?:$dtext|$quoted_pair)";
    $domain_literal    = "(?:$cfws?\\x5b(?:$fws?$dcontent)*$fws?\\x5d$cfws?)";


    $local_part    = "(($dot_atom)|($quoted_string)|($obs_local_part))";
    $domain        = "(($dot_atom_domain)|($domain_literal)|($obs_domain))";
    $addr_spec    = "$local_part\\x40$domain";


    if (strlen($email) > 256) return FALSE;


    $email = strip_comments($outer_comment, $email, "(x)");



    if (!preg_match("!^$addr_spec$!", $email, $m)){

        return FALSE;
    }

    $bits = array(
            'local'            => isset($m[1]) ? $m[1] : '',
            'local-atom'        => isset($m[2]) ? $m[2] : '',
            'local-quoted'        => isset($m[3]) ? $m[3] : '',
            'local-obs'        => isset($m[4]) ? $m[4] : '',
            'domain'        => isset($m[5]) ? $m[5] : '',
            'domain-atom'        => isset($m[6]) ? $m[6] : '',
            'domain-literal'    => isset($m[7]) ? $m[7] : '',
            'domain-obs'        => isset($m[8]) ? $m[8] : '',
    );



    $bits['local']    = strip_comments($comment, $bits['local']);
    $bits['domain']    = strip_comments($comment, $bits['domain']);




    if (strlen($bits['local']) > 64) return FALSE;
    if (strlen($bits['domain']) > 255) return FALSE;



    if (strlen($bits['domain-literal'])){

        $Snum            = "(\d{1,3})";
        $IPv4_address_literal    = "$Snum\.$Snum\.$Snum\.$Snum";

        $IPv6_hex        = "(?:[0-9a-fA-F]{1,4})";

        $IPv6_full        = "IPv6\:$IPv6_hex(:?\:$IPv6_hex){7}";

        $IPv6_comp_part        = "(?:$IPv6_hex(?:\:$IPv6_hex){0,5})?";
        $IPv6_comp        = "IPv6\:($IPv6_comp_part\:\:$IPv6_comp_part)";

        $IPv6v4_full        = "IPv6\:$IPv6_hex(?:\:$IPv6_hex){5}\:$IPv4_address_literal";

        $IPv6v4_comp_part    = "$IPv6_hex(?:\:$IPv6_hex){0,3}";
        $IPv6v4_comp        = "IPv6\:((?:$IPv6v4_comp_part)?\:\:(?:$IPv6v4_comp_part\:)?)$IPv4_address_literal";



        if (preg_match("!^\[$IPv4_address_literal\]$!", $bits['domain'], $m)){

            if (intval($m[1]) > 255) return FALSE;
            if (intval($m[2]) > 255) return FALSE;
            if (intval($m[3]) > 255) return FALSE;
            if (intval($m[4]) > 255) return FALSE;

        }else{


            while (1){

                if (preg_match("!^\[$IPv6_full\]$!", $bits['domain'])){
                    break;
                }

                if (preg_match("!^\[$IPv6_comp\]$!", $bits['domain'], $m)){
                    list($a, $b) = explode('::', $m[1]);
                    $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
                    $groups = explode(':', $folded);
                    if (count($groups) > 6) return FALSE;
                    break;
                }

                if (preg_match("!^\[$IPv6v4_full\]$!", $bits['domain'], $m)){

                    if (intval($m[1]) > 255) return FALSE;
                    if (intval($m[2]) > 255) return FALSE;
                    if (intval($m[3]) > 255) return FALSE;
                    if (intval($m[4]) > 255) return FALSE;
                    break;
                }

                if (preg_match("!^\[$IPv6v4_comp\]$!", $bits['domain'], $m)){
                    list($a, $b) = explode('::', $m[1]);
                    $b = substr($b, 0, -1); # remove the trailing colon before the IPv4 address
                    $folded = (strlen($a) && strlen($b)) ? "$a:$b" : "$a$b";
                    $groups = explode(':', $folded);
                    if (count($groups) > 4) return FALSE;
                    break;
                }

                return FALSE;
            }
        }
    }else{


        $labels = explode('.', $bits['domain']);


        if (count($labels) == 1) return FALSE;


        foreach ($labels as $label){

            if (strlen($label) > 63) return FALSE;
            if (substr($label, 0, 1) == '-') return FALSE;
            if (substr($label, -1) == '-') return FALSE;
        }

        if (preg_match('!^[0-9]+$!', array_pop($labels))) return FALSE;
    }


    return TRUE;
}
示例#11
0
文件: build.php 项目: Nurudeen/prado
/**
 * The framework directory
 */
define('FRAMEWORK_DIR', realpath(dirname(__FILE__) . '/../../framework'));
/**
 * The merged file name
 */
define('OUTPUT_FILE', 'pradolite.php');
if (FRAMEWORK_DIR === false || !is_file(FRAMEWORK_DIR . '/prado.php')) {
    die('Unable to determine the installation directory of Prado Framework.');
}
$lastupdate = date('Y/m/d H:i:s');
$comments = "\n/**\n * File Name: pradolite.php\n * Last Update: {$lastupdate}\n * Generated By: buildscripts/phpbuilder/build.php\n *\n * This file is used in lieu of prado.php to boost PRADO application performance.\n * It is generated by expanding prado.php with included files.\n * Comments and trace statements are stripped off.\n *\n * Do not modify this file manually.\n */\n";
$content = unfold_file(FRAMEWORK_DIR . '/prado.php');
$content = "<?php\n" . preg_replace('/^(\\?>|<\\?php)/mu', '', $content) . "\n?>";
$content = strip_comments($content);
$content = preg_replace('/^\\s*Prado::trace.*\\s*;\\s*$/mu', '', $content);
$content = strip_empty_lines($content);
$content = substr_replace($content, $comments, 5, 0);
file_put_contents(FRAMEWORK_DIR . '/' . OUTPUT_FILE, $content);
echo "Done.\n";
exit;
function strip_comments($source)
{
    $tokens = token_get_all($source);
    /* T_ML_COMMENT does not exist in PHP 5.
     * The following three lines define it in order to
     * preserve backwards compatibility.
     *
     * The next two lines define the PHP 5-only T_DOC_COMMENT,
     * which we will mask as T_ML_COMMENT for PHP 4.
示例#12
0
$strip_comments = NULL;
if (array_key_exists('strip_comments', $_GET)) {
    $strip_comments = $_GET['strip_comments'];
}
if (is_null($rspec_id)) {
    relative_redirect('home.php');
}
/* $rspec is the database record */
$rspec = fetchRSpec($rspec_id);
if (is_null($rspec)) {
    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
    exit;
}
$owner_id = $rspec['owner_id'];
$visibility = $rspec['visibility'];
if ($visibility != 'public' && $owner_id != $user->account_id) {
    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
    exit;
}
// Set headers for xml
header("Cache-Control: public");
header("Content-Type: text/xml");
$result = $rspec['rspec'];
if ($strip_comments) {
    $result = strip_comments($result);
}
print $result;
function strip_comments($rspec)
{
    return preg_replace('/<!--(.*)-->/Uis', '', $rspec);
}
示例#13
0
 // don't look within ignored folders
 $should_ignore = false;
 foreach ($json['templates_ignore'] as $should_ignore_dir) {
     if (strpos(str_replace("\\", "/", $f), $should_ignore_dir) !== false) {
         $should_ignore = true;
     }
 }
 if ($should_ignore) {
     if ($debug) {
         echo "Ignoring ignored template folder '{$f}'\n";
     }
     continue;
 }
 $input = file_get_contents($f);
 $input = str_replace("\r\n", "\n", $input);
 $input = strip_comments($input);
 // find instances of t() and ht()
 foreach ($json['translation_functions'] as $translation_function) {
     $matches = false;
     if (preg_match_all("#[ \t\n=\\-(]" . $translation_function . "\\((|['\"][^\"]+[\"'],[ \t\n])\"([^\"]+)\"(|,[ \t\n].+?)\\)#ims", $input, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             // remove whitespace that will never display
             $match[2] = strip_i18n_key($match[2]);
             $found[$match[2]] = $match[2];
         }
     }
     if (preg_match_all("#[ \t\n=\\-(]" . $translation_function . "\\((|['\"][^\"]+[\"'],[ \t\n])'([^']+)'(|,[ \t\n].+?)\\)#ims", $input, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             // remove whitespace that will never display
             $match[2] = strip_i18n_key($match[2]);
             $found[$match[2]] = $match[2];