Roxen.git
/
server
/
etc
/
modules
/
Roxen.pmod
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/etc/modules/Roxen.pmod:1:
// This is a roxen pike module. Copyright © 1999 - 2004, Roxen IS. //
-
// $Id: Roxen.pmod,v 1.
260
2008/
11
/
26
01
:
52
:
04
mast
Exp $
+
// $Id: Roxen.pmod,v 1.
261
2008/
12/
11
15
:
32
:
28
jonasw
Exp $
#include <roxen.h> #include <config.h> #include <version.h> #include <module.h> #include <stat.h> #define roxen roxenp() #ifdef HTTP_DEBUG # define HTTP_WERR(X) report_debug("HTTP: "+X+"\n");
Roxen.git/server/etc/modules/Roxen.pmod:3918:
return ENCODE_RXML_TEXT(roxen_build, type); case "dist-version": return ENCODE_RXML_TEXT(roxen_dist_version, type); case "product-name": return ENCODE_RXML_TEXT(roxen_product_name, type); case "time": CACHE(c->id,1); return ENCODE_RXML_INT(time(), type); case "server": return ENCODE_RXML_TEXT (c->id->url_base(), type);
-
case "domain":
-
sscanf
(c->id->url_base(), "
%*s
:
//%
[
^:/]
"
,
string
tmp
)
;
-
return ENCODE_RXML_TEXT(tmp, type);
+
case "domain":
{
+
// Handle hosts and adresses including IPv6 format
+
Standards.URI u = Standards.URI
(c->id->url_base()
);
+
string tmp = u && u->host;
+
if (tmp && has_value(tmp
, ":
"))
+
tmp = "
["
+
tmp
+ "]"
;
+
return ENCODE_RXML_TEXT(tmp
|| ""
, type);
+
}
case "locale": NOCACHE(c->id); return ENCODE_RXML_TEXT(roxenp()->locale->get(), type); case "path": return ENCODE_RXML_TEXT(c->id->misc->site_prefix_path, type); case "unique-id": return ENCODE_RXML_TEXT(roxenp()->create_unique_id(), type); case "license-type": { object key = c->id->conf->getvar("license")->get_key();
Roxen.git/server/etc/modules/Roxen.pmod:4477:
//! call @[RequestID.url_base] in it instead, since that function also //! takes into account information sent by the client and the port the //! request came from. (It's often faster too.) { return c->get_url(); } string get_world(array(string) urls) { if(!sizeof(urls)) return 0;
-
string url=urls[0];
+
string url
=
urls[0];
+
mapping(string:Standards.URI) uris = ([ ]);
+
foreach (urls, string u)
+
uris[u] = Standards.URI(u);
+
foreach( ({"http:","https:","ftp:"}), string p) foreach(urls, string u)
-
if(
u[0..sizeof
(p)
-1]==p
) {
-
Standards.URI
ui
=
Standards.URI(u)
;
-
ui->fragment
=
0
;
-
url=
(string)ui
;
+
if
(
has_prefix(
u
,
p)) {
+
uris[u]->fragment
=
0
;
+
url
=
(string) uris[u]
;
+
uris[
url
]
=
uris[u]
;
break; }
-
string protocol, server, path="";
-
int port;
-
if(sscanf(url, "%s://%s:%d/%s", protocol, server, port, path)!=4 &&
-
sscanf(url, "%s://%s:%d", protocol, server, port)!=3 &&
-
sscanf(url, "%s://%s/%s", protocol, server, path)!=3 &&
-
sscanf(url, "%s://%s", protocol, server)!=2 )
-
return 0;
-
+
array hosts=({ gethostname() }), dns; #ifndef NO_DNS catch(dns=Protocols.DNS.client()->gethostbyname(hosts[0])); if(dns && sizeof(dns)) hosts+=dns[2]+dns[1]; #endif /* !NO_DNS */
-
+
Standards.URI uri = uris[url];
+
string server = uri->host;
foreach(hosts, string host)
-
if(glob(server, host))
{
-
server
=host;
-
break
;
+
if
(glob(server, host))
+
uri->host
=
host;
+
return
(string)
uri
;
}
-
if(port) return sprintf("%s://%s:%d/%s", protocol, server, port, path);
-
return sprintf("%s://%s/%s", protocol, server, path);
-
}
-
+
RoxenModule get_owning_module (object|function thing) //! Tries to find out which module the thing belongs to, if any. The //! thing can be e.g. a module object, a Tag object or a simple_tag //! callback. { if (functionp (thing)) thing = function_object (thing); if (objectp (thing)) { if (thing->is_module)