Exemplo n.º 1
0
function print_pages($sitemap, $dir)
{
    $output = "";
    foreach ($dir->page as $page) {
        if ((string) $page !== 'index.html' && (string) $page !== 'index.php') {
            $path = find_path($dir);
            $output .= '<li><a href="/' . $path . $page . '">' . $page . '</a></li>';
        }
    }
    return $output;
}
Exemplo n.º 2
0
    $result = "PostgreSQL support not available";
    $status = WARN;
}
print_row("PostgreSQL Support", $result, $status);
// Database support
if (!($have_mysql || $have_psql)) {
    $result = "No supported databases are available!";
    $status = ERROR;
} else {
    $result = "Database support is ok";
    $status = OK;
}
print_row("Database Support", $result, $status);
// PEAR
$have_pear = false;
if (!($pear_dir = find_path($path_list, "PEAR"))) {
    $result = "Not installed.  The PEAR extension is required by several other " . "PHP extensions that Maia needs.  See <a href=\"http://pear.php.net/\">this page</a> " . "for more information about downloading and installing PEAR.";
    $status = ERROR;
} else {
    // include_once ("PEAR/Remote.php");      // PEAR::Remote
    include_once "PEAR/Config.php";
    // PEAR::Registry
    $have_pear = true;
    $pear = new PEAR_Config();
    $pear_reg = $pear->getRegistry();
    $pear_info = $pear_reg->packageInfo("PEAR");
    $pear_list = $pear_reg->listPackages();
    $pear_version = is_array($pear_info["version"]) ? $pear_info["version"]["release"] : $pear_info["version"];
    $result = $pear_version;
    $status = OK;
}
Exemplo n.º 3
0
function company_path($target)
{
    $magento = magento_path();
    return find_path($target, "{$magento}/app/code/*", "{$magento}/app/code/");
}
Exemplo n.º 4
0
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header("Content-Transfer-Encoding: binary\n");
    if ($file = fopen($path, 'rb')) {
        while (!feof($file) && connection_status() == 0) {
            print fread($file, 1024 * 8);
            flush();
        }
        fclose($file);
    }
    return connection_status() == 0 and !connection_aborted();
}
if (count($files) > 1 || is_dir($files[0])) {
    $d = date("Y-m-d_H-i");
    $ar_file = $tmp_dir . "/" . $d . "_archive.zip";
    $archive = new PclZip($ar_file);
    $path = find_path($files, dirname($files[0]));
    if ($path == '/') {
        $res = $archive->create($files, PCLZIP_OPT_REMOVE_ALL_PATH);
    } else {
        $res = $archive->create($files, PCLZIP_OPT_REMOVE_PATH, $path);
    }
    if (!$res) {
        ?>
	<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
	<body>
	<script type="text/javascript">
    	    parent.fm.showMessage('<?php 
        echo $strErrorCreatingZip;
        ?>
','filemanager-message',0,'warning.gif');
	</script>
Exemplo n.º 5
0
function find_rule($rule)
{
    return find_path('config/rules/' . $rule);
}
Exemplo n.º 6
0
function dispatch_uri($uri)
{
    $path = find_path($uri);
    if (strlen($path) == 0) {
        path_not_found($uri);
    } elseif (!is_dir($path)) {
        send_file($path);
    } elseif ($path[strlen($path) - 1] != '/') {
        redirect("{$uri}/");
    } else {
        list_directory($uri, $path);
    }
}
Exemplo n.º 7
0
<?php

error_reporting(E_ALL);
function __autoload($name)
{
    require_once "classes/{$name}.php";
}
require_once 'functions.php';
// initializing variables
$g['weburl'] = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
$g['webdir'] = dirname($_SERVER['PHP_SELF']);
if (!isset($_GET['dir'])) {
    $_GET['dir'] = '';
}
$g['base_path'] = "presentation/{$_GET['dir']}/";
find_path();
parse_presentation();
print_output();
Exemplo n.º 8
0
<?php

/**
 * @file    index.php
 *
 * PHP version 5.4+
 *
 * @author  Yancharuk Alexander <alex at itvault dot info>
 * @date    2015-07-30 20:47
 * @copyright MIT License
 */
$data = [['Moscow', 'St.Pitersbourg', 3000], ['Moscow', 'Kazan', 3000], ['Moscow', 'Rostov', 6000], ['St.Pitersbourg', 'Kazan', 1000], ['St.Pitersbourg', 'Kemerovo', 3000], ['Perm', 'Kemerovo', 2000], ['Perm', 'Rostov', 3000], ['Kazan', 'Kemerovo', 1000], ['Kazan', 'Rostov', 2000], ['Kemerovo', 'Rostov', 5000]];
list($path, $cost) = find_path($data, 'Kazan', 'Perm');
/**
 * Поиск самого дешёвого пути между двумя локациями
 * Для поиска используется алгоритм Дейкстры
 *
 * @see http://www.sitepoint.com/data-structures-4/
 *
 * @param array  $data   Массив с локациями и ценой проезда между ними [][src, dst, cost]
 * @param string $source Название исходного пункта
 * @param string $target Название конечного пункта
 *
 * @return SplStack
 */
function find_path(array $data, $source, $target)
{
    $graph = build_graph($data);
    // массив лучших цен кратчайшего пути для каждой локации
    $best_cost = [];
    // массив предыдущих локаций для каждой локации
Exemplo n.º 9
0
function move_ai($account)
{
    global $player_data;
    global $map_data;
    if (player_ready($account) == False) {
        irciv_privmsg("player {$account} not ready");
        return;
    }
    unset($player_data[$account]["path"]);
    if (isset($player_data[$account]["active"]) == False) {
        irciv_privmsg("player {$account} has no active unit");
        return;
    }
    $active = $player_data[$account]["active"];
    $start = array();
    $start["x"] = $player_data[$account]["units"][$active]["x"];
    $start["y"] = $player_data[$account]["units"][$active]["y"];
    $paths = array();
    foreach ($player_data as $enemy_account => $enemy_data) {
        if ($enemy_account == $account) {
            continue;
        }
        $path = array();
        $finish = array();
        $finish["x"] = $player_data[$enemy_account]["units"][0]["x"];
        $finish["y"] = $player_data[$enemy_account]["units"][0]["y"];
        if (find_path($path, $start, $finish) == False) {
            $player_data[$account]["status_messages"][] = "no path exists between {$account} and {$enemy_account}";
            status($account);
            continue;
        }
        if (count($path) <= 1) {
            $player_data[$account]["status_messages"][] = "no path exists between {$account} and {$enemy_account}";
            status($account);
            continue;
        }
        $paths[] = $path;
    }
    $min_path_length = $map_data["cols"] * $map_data["rows"];
    $min_path = -1;
    for ($i = 0; $i < count($paths); $i++) {
        if (count($paths[$i]) < $min_path_length) {
            $min_path = $i;
            $min_path_length = count($paths[$i]);
        }
    }
    if ($min_path >= 0) {
        $player_data[$account]["path"] = $paths[$min_path];
        $dir = $paths[$min_path][1]["dir"];
        move_active_unit($account, $dir);
    }
}
Exemplo n.º 10
0
function find_path($files, $path)
{
    if ($path == '/') {
        return '/';
    }
    foreach ($files as $f) {
        if (strpos(dirname($f), $path) === 0) {
            continue;
        }
        return find_path($files, dirname($path));
    }
    return $path;
}