您在這裡

获取当前用户的代码是什么?

caigen's 的頭像
caigen 在 2007-03-11 (周日) 19:14 發表

想整合一个地图程序,要求一个用户代码,不知该如何做?

这是那段代码:

<?php
/*
* init
*
* (c) 2007 mapinbox.com
*/

define('M_CHARSET', 'utf-8');

$domain = 'XXXXX.cn'; // 您的域
$authkey = '311111111111110'; // 密钥

// 如果需要跟现有的用户系统整合,请在下方插入获取当前用户的代码
$username = ''; // 用户名

// 以下内容请不要修改
define('M_ROOT', dirname(__FILE__));
define('M_INC_PATH', M_ROOT . '/inc/');
define('M_TPL_PATH', M_ROOT . './templates/');

define('M_URL_MAPINBOX', 'http://www.mapinbox.com');
define('M_URL_JS', M_URL_MAPINBOX . '/misc/loadmap.js');
define('M_URL_UPLOAD', M_URL_MAPINBOX . '/gps/upload.php');
define('M_URL_RPC', M_URL_MAPINBOX . '/service/rpc.php');

if ($domain == '#' . 'DOMAIN#' || $domain == '')
{
$domain = strtolower($_SERVER['SERVER_NAME']);
$domain .= $_SERVER['SERVER_PORT'] != 80 ? ':' . $_SERVER['SERVER_PORT'] : '';
$domain = substr($domain, 0, 4) == 'www.' ? substr($domain, 4) : $domain;
}

if ($authkey == '#' . 'AUTHKEY#')
{
$authkey = '';
}

define('M_DOMAIN', $domain);
define('M_PRIVATE_KEY', $authkey);

$uri = parse_url($_SERVER['REQUEST_URI']);
$map_path = preg_replace('/[\/\\\]{1,}/', '/', $uri['path']);
$map_path = preg_replace('/[^\/]*$/', "", $map_path);
define('M_MAP_PATH', $map_path);

define('M_URL_INDEX', M_MAP_PATH . 'index.php');
define('M_URL_MAP', M_MAP_PATH . 'map.php');
define('M_URL_LITE', M_MAP_PATH . 'lite.php');
define('M_URL_TRACK', M_MAP_PATH . 'track.php');
define('M_USERNAME', $username);
define('M_AUTHSTR', md5(M_PRIVATE_KEY . $username));

$script = "\n";
$script .= "var M_CharSet = '" . M_CHARSET . "';\n";

$script .= "var M_UrlIndex = '" . M_URL_INDEX . "';\n";
$script .= "var M_UrlMap = '" . M_URL_MAP . "';\n";
$script .= "var M_UrlLite = '" . M_URL_LITE . "';\n";
$script .= "var M_UrlGPS = '" . M_URL_TRACK . "';\n";
$script .= "var M_UserName = '" . M_USERNAME . "';\n";
$script .= "var M_AuthStr = '" . M_AUTHSTR . "';\n";
$script .= "\n";
$script .= "\n";

//echo '

' . print_r($_SERVER, true) . '

';
?>