Exemplo n.º 1
0
        }
        if (DEBUG_SERVER) {
            $firephp->dump('SERVER', $_SERVER);
        }
        if (DEBUG_CONST) {
            $tab_constantes = get_defined_constants(TRUE);
            $firephp->dump('CONSTANTES', $tab_constantes['user']);
        }
    }
}
// ============================================================================
// URL de base du serveur
// ============================================================================
$host = getServerUrl();
define('HOST', $host);
define('URL_BASE', getServerProtocole() . $host . getServerPort($host));
// ============================================================================
// Type de serveur (LOCAL|DEV|PROD)
// ============================================================================
// On ne peut pas savoir avec certitude si un serveur est "local" car aucune méthode ne fonctionne à tous les coups :
// - $_SERVER['HTTP_HOST'] peut ne pas renvoyer localhost sur un serveur local (si configuration de domaines locaux via fichiers hosts / httpd.conf par exemple).
// - gethostbyname($_SERVER['HTTP_HOST']) peut renvoyer "127.0.0.1" sur un serveur non local car un serveur a en général 2 ip (une publique - ou privée s'il est sur un lan - et une locale).
// - $_SERVER['SERVER_ADDR'] peut renvoyer "127.0.0.1" avec nginx + apache sur 127.0.0.1 ...
if (mb_strpos(URL_BASE, 'localhost') || mb_strpos(URL_BASE, '127.0.0.1') || mb_strpos(URL_BASE, '.local')) {
    $serveur_type = 'LOCAL';
} elseif (mb_strpos(URL_BASE, '.sesamath.net:8080') || mb_strpos(URL_BASE, '.sesamath.net:8443')) {
    $serveur_type = 'DEV';
} else {
    $serveur_type = 'PROD';
}
define('SERVEUR_TYPE', $serveur_type);
Exemplo n.º 2
0
    exit;
} else {
    printf("Successfully connected to MySQL Server, database {$database}.\n<br>");
}
if ($handle) {
    // Reset the input file to the beginning and get the Server properties
    fseek($handle, 0);
    while (($line = fgets($handle)) !== false) {
        if (preg_match('/udp\\/ip  /', $line)) {
            $serverPrivIP = getServerPrivIP($line);
            getServerPubIP($line);
            $serverPort = getServerPort($line);
            if ($debug > 2) {
                echo "Server Private IP: " . getServerPrivIP($line) . "\n<br>";
                echo "Server Public IP: " . getServerPubIP($line) . "\n<br>";
                echo "Server Port: " . getServerPort($line) . "\n<br>";
            }
            $serverIdQuery = 'select serverId from hlstats_Servers where address = "' . $serverPrivIP . '" and port = "' . $serverPort . '"';
            $serverIdResults = $link->query($serverIdQuery);
            if ($serverIdResults->num_rows > 0) {
                $row = $serverIdResults->fetch_assoc();
                $serverId = $row["serverId"];
            } else {
                echo "Unable to retreive Server ID from database.<br>";
                exit;
            }
            if ($debug > 2) {
                echo "Server ID: " . $serverId . "<br>";
            }
            break;
        }