コード例 #1
0
ファイル: gen_doc.php プロジェクト: colindj/ssdb-docs
function parse_dir($input_dir, $output_dir, $base_url = '.')
{
    if (!file_exists($output_dir)) {
        mkdir($output_dir);
    }
    $template = "{$input_dir}/template.php";
    if (!file_exists($template)) {
        $template = null;
    }
    $files = scandir($input_dir);
    foreach ($files as $file) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $fullpath = "{$input_dir}/{$file}";
        if (is_dir($fullpath)) {
            $new_output_dir = $output_dir . '/' . $file;
            parse_dir($fullpath, $new_output_dir, "{$base_url}/..");
        } else {
            $ps = explode('.', $file);
            $ext = $ps[count($ps) - 1];
            if ($ext == 'md') {
                gen_doc($fullpath, $output_dir, $template, $base_url);
            } else {
                if (!in_array($ext, array('php'))) {
                    copy($fullpath, "{$output_dir}/{$file}");
                }
            }
        }
    }
}
コード例 #2
0
function parse_dir($dir, $url)
{
    global $ignore, $filetypes, $replace, $chfreq, $prio;
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        // Check if this file needs to be ignored, if so, skip it.
        if (in_array(utf8_encode($file), $ignore) || strpos($file, 'LCK') || strpos($file, 'angela') || strpos($file, 'vti') || strpos($file, '_mm') || strpos($file, 'bak') || strpos($file, 'gif') || strpos($file, 'jpg') || strpos($file, 'png') || strpos($file, 'js')) {
            continue;
        }
        if (is_dir($file)) {
            if (defined('RECURSIVE') && RECURSIVE) {
                parse_dir($file, $url . $file . '/');
            }
        }
        // Check whether the file has on of the extensions allowed for this XML sitemap
        $fileinfo = pathinfo($dir . $file);
        if (in_array($fileinfo['extension'], $filetypes)) {
            // Create a W3C valid date for use in the XML sitemap based on the file modification time
            /*
            * if (filemtime( $dir .'/'. $file )==FALSE) {
            				$mod = date( 'c', filectime( $dir . $file ) );
            			} else {
            				$mod = date( 'c', filemtime( $dir . $file ) );
            			}
            			
            			above dynamic mod time is giving warning 
            filemtime(): stat failed for imagesaddnewimage.cfm in <b>D:\home\semiprecious.com\wwwroot\xmlsitemap.php</b> on line <b>47</b><br />
              so hardcoding to 31 Oct 2014
            */
            $mod = '2014-10-31T18:00:00-06:00';
            // Replace the file with it's replacement from the settings, if needed.
            if (in_array($file, $replace)) {
                $file = $replace[$file];
            }
            // Start creating the output
            ?>

    <url>
        <loc><?php 
            echo $url . rawurlencode($file);
            ?>
</loc>
        <lastmod><?php 
            echo $mod;
            ?>
</lastmod>
        <changefreq><?php 
            echo $chfreq;
            ?>
</changefreq>
        <priority><?php 
            echo $prio;
            ?>
</priority>
    </url><?php 
        }
    }
    closedir($handle);
}
コード例 #3
0
ファイル: xml-sitemap.php プロジェクト: arjint2004/12516
function parse_dir($dir, $url)
{
    global $ignore, $filetypes, $replace, $chfreq, $prio;
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        // Check if this file needs to be ignored, if so, skip it.
        if (in_array(utf8_encode($file), $ignore)) {
            continue;
        }
        if (is_dir($file)) {
            if (defined('RECURSIVE') && RECURSIVE) {
                parse_dir($file, $url . $file . '/');
            }
        }
        // Check whether the file has on of the extensions allowed for this XML sitemap
        $fileinfo = pathinfo($dir . $file);
        if (in_array($fileinfo['extension'], $filetypes)) {
            echo $dir . $file;
            echo filectime($dir . $file);
            die;
            // Create a W3C valid date for use in the XML sitemap based on the file modification time
            if (filemtime($dir . '/' . $file) == FALSE) {
                $mod = date('c', filectime($dir . $file));
            } else {
                $mod = date('c', filemtime($dir . $file));
            }
            // Replace the file with it's replacement from the settings, if needed.
            if (in_array($file, $replace)) {
                $file = $replace[$file];
            }
            // Start creating the output
            ?>

    <url>
        <loc><?php 
            echo $url . rawurlencode($file);
            ?>
</loc>
        <lastmod><?php 
            echo $mod;
            ?>
</lastmod>
        <changefreq><?php 
            echo $chfreq;
            ?>
</changefreq>
        <priority><?php 
            echo $prio;
            ?>
</priority>
    </url><?php 
        }
    }
    closedir($handle);
}
コード例 #4
0
ファイル: crawl.php プロジェクト: unetics/Crawler
  * If this is a seed URL, set clicks to zero, 
  * otherwise, increment our internal click counter one beyond the parent's clicks
  */
 if (!isset($url_data['clicks'])) {
     $clicks = 0;
 } else {
     $clicks = $url_data['clicks'] + 1;
 }
 /**
  * Curl the page, returning data as an array
  */
 $page_data = curl_page($url_data['url']);
 /**
  * Calculate the directory of the current page, used to parse relative URLs
  */
 $dir = parse_dir($url_data['url']);
 /**
  * Parse the title of the current page
  */
 $title = parse_title($page_data['html']);
 /**
  * Parse the HTML for links, store in an array
  */
 $links = parse_links($page_data['html']);
 /**
  * Loop through the array of links
  */
 foreach ($links as $key => &$link) {
     /**
      * Uniformly clean the link so we don't have duplicates (absolute, no anchors, add www., etc.)
      */
コード例 #5
0
 function get_nav($path)
 {
     return parse_dir($path);
 }
コード例 #6
0
ファイル: Parser.php プロジェクト: tommiu/phpjoern_mirror
/**
 * Parses and generates ASTs for all PHP files buried within a
 * directory.
 *
 * @param $path        Path to the directory
 * @param $csvexporter A CSV exporter instance to use for exporting
 *                     the ASTs of all parsed files.
 * @param $top         Boolean indicating whether this call
 *                     corresponds to the top-level call of the
 *                     function. We wouldn't need this if I didn't
 *                     insist on the root directory of a project
 *                     getting node index 0. But, I do insist.
 *
 * @return If the directory corresponding to the function call finds
 *         itself interesting, it stores a directory node for itself
 *         and this function returns the index of that
 *         node. Otherwise, returns -1. A directory finds itself
 *         interesting if it contains PHP files, or if one of its
 *         child directories finds itself interesting. -- As a special
 *         case, the root directory of a project (corresponding to the
 *         top-level call) always finds itself interesting and always
 *         stores a directory node for itself.
 */
function parse_dir($path, $csvexporter, $top = true) : int
{
    // save any interesting directory/file indices in the current folder
    $found = [];
    // if the current folder finds itself interesting, we will create a
    // directory node for it and return its index
    $dirnode = $top ? $csvexporter->store_dirnode(basename($path)) : -1;
    $dhandle = opendir($path);
    // iterate over everything in the current folder
    while (false !== ($filename = readdir($dhandle))) {
        $finfo = new SplFileInfo(build_path($path, $filename));
        if ($finfo->isFile() && $finfo->isReadable() && strtolower($finfo->getExtension()) === 'php') {
            $found[] = parse_file($finfo->getPathname(), $csvexporter);
        } else {
            if ($finfo->isDir() && $finfo->isReadable() && $filename !== '.' && $filename !== '..') {
                if (-1 !== ($childdir = parse_dir($finfo->getPathname(), $csvexporter, false))) {
                    $found[] = $childdir;
                }
            }
        }
    }
    // if the current folder finds itself interesting...
    if (!empty($found)) {
        if (!$top) {
            $dirnode = $csvexporter->store_dirnode(basename($path));
        }
        foreach ($found as $i => $nodeindex) {
            $csvexporter->store_rel($dirnode, $nodeindex, "DIRECTORY_OF");
        }
    }
    closedir($dhandle);
    return $dirnode;
}
コード例 #7
0
ファイル: index.php プロジェクト: ijcoe6ru/php_tor_controller
function update_status_function()
{
    /**
     * data will be empty if something fails on the server side.
     *
     * The first 8 lines are the following status of tor:
     * 	version
     * 	network-liveness
     * 	status/bootstrap-phase
     * 	status/circuit-established
     * 	status/enough-dir-info
     * 	status/good-server-descriptor
     * 	status/accepted-server-descriptor
     * 	status/reachability-succeeded
     * The next line is a number num in decimal meaning the lines for stream
     * status.
     * The next num lines are stream status, with " " at the end of each line.
     * The next line is a number num in decimal meaning the number of lines for
     * OR connection status.
     * The next num lines are OR connection status, with " " at the end of each
     * line.
     * The next line is a number num in decimal meaning the lines for circuit
     * status.
     * The next num lines are circuit status. Each entry is
     * 	id
     * 	status
     * 	build flag
     * 	time created
     * 	path
     * Seperators are " ".
     * The next line is a number num in decimal meaning the entries for OR
     * status.
     * The next num lines are OR status. Each entry is
     * 	nickname
     * 	identity
     * 	digest
     * 	publication
     * 	ip
     * 	ORPort
     * 	DIRPort
     * 	IPv6 addresses, each ending with ';'
     * 	flags
     * 	version
     * 	bandwidth
     * 	portlist
     * Seperators are "\t".
     * Each of the next lines is a timestamp in miliseconds in decimal followed
     * by a line of response for one of the following asynchronous events
     * without "650" at the beginning of the line.
     * 	bw
     * 	info
     * 	notice
     * 	warn
     * 	err
     * Line breaks are "\n".
     */
    global $tor_version_string, $tc, $event_names_string, $now;
    $output_lines = array();
    header('Content-type: text/plain');
    $output_lines[] = $tor_version_string;
    $getinfo_values = parse_getinfo_array(array('network-liveness', 'status/bootstrap-phase', 'status/circuit-established', 'status/enough-dir-info', 'status/good-server-descriptor', 'status/accepted-server-descriptor', 'status/reachability-succeeded', 'stream-status', 'orconn-status', 'circuit-status'));
    // for network-liveness, status/bootstrap-phase, status/circuit-established,
    // status/enough-dir-info, status/good-server-descriptior,
    // status/accepted-server-descriptor, and status/reachability-succeeded
    for ($index = 0; $index < 7; $index++) {
        $output_lines[] = $getinfo_values[$index]->lines[0];
    }
    // for stream-status
    $output_lines[] = $getinfo_values[7]->num;
    foreach ($getinfo_values[7]->lines as $line) {
        $output_lines[] = "{$line} ";
    }
    // for orconn-status
    $output_lines[] = $getinfo_values[8]->num;
    foreach ($getinfo_values[8]->lines as $line) {
        $a = explode(' ', $line);
        for ($b = 0; $b < 2; $b++) {
            if (!isset($a[$b])) {
                $a[$b] = '';
            }
        }
        $output_lines[] = "{$a['1']} {$a['0']} ";
    }
    // for circuit-status
    $output_lines[] = $getinfo_values[9]->num;
    foreach ($getinfo_values[9]->lines as $line) {
        $output_lines[] = output_circuit_status($line);
    }
    // for ns/all
    $num = 0;
    $output_lines_ns = array();
    if (compare_version(array(0, 1, 2, 3))) {
        $getinfo_values = parse_getinfo('ns/all');
        if ($getinfo_values->num) {
            foreach ($getinfo_values->lines as $line) {
                if ($result = parse_dir($line)) {
                    $output_lines_ns[] = $result;
                    $num++;
                }
            }
            $output_lines_ns[] = output_parse_dir();
            $num++;
        }
    } else {
        $getinfo_values = parse_getinfo('network-status');
        if ($getinfo_values->num) {
            foreach ($getinfo_values->lines as $line) {
                if ($result = parse_dir_v1($line)) {
                    $output_lines_ns[] = $result;
                    $num++;
                }
            }
            $output_lines_ns[] = output_parse_dir();
            $num++;
        }
    }
    $output_lines[] = $num;
    foreach ($output_lines_ns as $line) {
        $output_lines[] = $line;
    }
    // for asynchronous events
    exec_command_no_response("setevents {$event_names_string}");
    stream_set_blocking($tc, 0);
    $now = (int) (microtime(1) * 1000000);
    // to wait for asynchronous
    $time_check = $now + update_status_initial_wait;
    $event_cache = array();
    while ($now < $time_check) {
        foreach (get_events() as $event) {
            $event_cache[] = $event;
        }
    }
    session_restart_configure();
    session_start();
    $serial = $_SESSION['php_tor_controller_last_event_capture'] + 1 & 0xffff;
    $_SESSION['php_tor_controller_last_event_capture'] = $serial;
    $_SESSION['php_tor_controller_last_event_capture_time'] = $now;
    $_SESSION['php_tor_controller_last_event_capture_events'] = $event_cache;
    session_write_close();
    $event_cache = array();
    while (1) {
        $time_check += update_status_check_interval;
        while ($now < $time_check) {
            foreach (get_events() as $event) {
                $event_cache[] = $event;
            }
        }
        // to check for another instance of this script capturing asynchronous
        // events
        session_start();
        if ($_SESSION['php_tor_controller_last_event_capture'] != $serial) {
            stream_set_blocking($tc, 1);
            close_tc();
            $last_capture_time = $_SESSION['php_tor_controller_last_event_capture_time'];
            $last_capture_events = $_SESSION['php_tor_controller_last_event_capture_events'];
            session_write_close();
            // all the output
            foreach ($output_lines as $line) {
                echo $line, "\n";
            }
            /*
             * If $_SESSION['php_tor_controller_last_event_capture_events'] is
             * empty or it matches no part of $event_cache, all events that are
             * received earlier than
             * $_SESSION['php_tor_controller_last_event_capture_time'] will be
             * sent. Otherwise, all events received earlier than the part that
             * match and the part that match are sent.
             */
            $num = count($last_capture_events);
            if ($num) {
                $a = 0;
                $last_pos = count($event_cache) - 1;
                $latest = $last_capture_events[$num - 1]->time + event_received_time_difference;
                while ($last_pos > $a) {
                    $c = $a + $last_pos >> 1;
                    if ($event_cache[$c]->time > $latest) {
                        $last_pos = $c - 1;
                    } else {
                        $a = $c + 1;
                    }
                }
                for ($last_pos++; $last_pos >= $num; $last_pos--) {
                    $start_pos = $last_pos - $num;
                    $a = $num;
                    while (1) {
                        $eventa = $last_capture_events[--$a];
                        $eventb = $event_cache[$a + $start_pos];
                        if ($eventa->time - event_received_time_difference > $eventb->time) {
                            goto events_no_match;
                        }
                        if ($eventa->line !== $eventb->line || $eventa->time + event_received_time_difference < $eventb->time) {
                            break;
                        }
                        if (!$a) {
                            for ($a = 0; $a < $last_pos; $a++) {
                                output_event($event_cache[$a]);
                            }
                            exit;
                        }
                    }
                }
            } else {
                events_no_match:
            }
            for ($a = 0; isset($event_cache[$a]) && $event_cache[$a]->time < $last_capture_time; $a++) {
                output_event($event_cache[$a]);
            }
            exit;
        }
        session_write_close();
    }
}
コード例 #8
0
ファイル: index.php プロジェクト: BGCX261/zpanel-svn-to-git
?>
        </tr>
	<tr>
		<td class="fieldname">Path:</td>
		<td><select name="path"><option value="/" <?php 
if ($action == 'Edit') {
    if ($thisdom['path'] == '/') {
        echo 'SELECTED ';
    }
}
?>
>[root]</option><?php 
if ($action == 'Edit') {
    parse_dir($user['homedir'], $thisdom['path']);
} else {
    parse_dir($user['homedir']);
}
?>
</select></td>
	</tr>
	<tr>
		<td><input type="submit" id="Add" value="<?php 
echo $button;
?>
"></td>
		<td><div id="add_domain_status"></div></td>
	<tr>
</table>
</form>
<br />
<h1>Current Subdomains</h1>
コード例 #9
0
function parse_dir($dir)
{
    // add a trailing slash if it doesn't exist:
    if (substr($dir, -1) != '/') {
        $dir .= '/';
    }
    $files = array();
    if ($dh = @opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (!preg_match('/^\\./s', $file)) {
                if (is_dir($dir . $file)) {
                    $newdir = $dir . $file . '/';
                    chdir($newdir);
                    $files = array_merge($files, parse_dir($newdir));
                } else {
                    $files[] = $dir . $file;
                }
            }
        }
        chdir($dir);
    }
    return $files;
}
コード例 #10
0
ファイル: snap.php プロジェクト: JackieXie168/sdcc
    }
    green_bar("Supported Windows - x86_64 Binaries", "Windows64");
    for ($i = 0; $i < $windows64_num; $i++) {
        display_files($descdir, $lsDir, $cldir, $rtdir, $windows64_dir[$i]);
    }
    green_bar("Supported Mac OS X Binaries", "MacOSX");
    for ($i = 0; $i < $macosx_num; $i++) {
        display_files($descdir, $lsDir, $cldir, $rtdir, $macosx_dir[$i]);
    }
    green_bar("Documentation", "Docs");
    for ($i = 0; $i < $docs_num; $i++) {
        display_files($descdir, $lsDir, $cldir, false, $docs_dir[$i]);
    }
    for ($i = 0; $i < $other_docs_num; $i++) {
        display_files($descdir, $lsDir, false, false, $other_docs_dir[$i]);
    }
    green_bar("Source Code", "Source");
    for ($i = 0; $i < $source_num; $i++) {
        display_files($descdir, $lsDir, $cldir, false, $source_dir[$i]);
    }
    if ($other_num > 0) {
        green_bar("Other Files", "Other");
    }
    for ($i = 0; $i < $other_num; $i++) {
        display_files($descdir, $lsDir, $cldir, $rtdir, $other_dir[$i]);
    }
}
//end-function declaration
require 'snap_header.php';
parse_dir('snapshots.desc', 'tree.txt', 'changelog_heads', 'regression_test_results');
require 'snap_footer.php';