File: index.vsp

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (201 lines) | stat: -rw-r--r-- 9,649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?vsp
--   search_ajax.vsp
--
--   $Id$
--
--   AJAX Handler for the google map control
--
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--
--  Copyright (C) 1998-2018 OpenLink Software
--
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
--
  declare sid,realm,server_root,server_dataspace,oldui_url,uname,utype,https varchar;

  utype:=get_keyword('utype',params,'');
  uname:=get_keyword('uname',params,'');

  oldui_url:=sprintf('/ods/uhome.vspx?page=1&ufname=%U&utype=%U', uname, utype);

  declare cookie_arr any;
  cookie_arr := vsp_ua_get_cookie_vec(lines);

  -- if(cookie_arr is not null and get_keyword('interface',cookie_arr,'js')='vspx')
  -- {
  --   http_rewrite ();
  --   http_request_status ('HTTP/1.1 302 Found');
  --   http_header (concat (http_header_get (), 'Location: ',oldui_url,'\r\n'));
  --
  --   return;
  -- }

  sid := get_keyword('sid',params,'');
  realm := get_keyword('realm',params,'wa');

  declare resMeta any;
  resMeta:= string_output ();

  server_root := sprintf('%s%s', http_s (), DB.DBA.WA_GET_HOST ());
  server_dataspace:=server_root||'/dataspace/';

  if (length (uname))
  {
    declare _visibility,_full_name, _country, _state, _city, _oid_url, _oid_server,_country_code,_nick, _cert, _openid_server varchar;
    declare  _lat, _lng real;
    declare uid integer;

    _full_name := coalesce((select coalesce(U.U_FULL_NAME,trim(concat(I.WAUI_FIRST_NAME,' ',I.WAUI_LAST_NAME)),U.U_NAME) as U_FULL_NAME from DB.DBA.WA_USER_INFO I, DB.DBA.SYS_USERS U where I.WAUI_U_ID=U.U_ID and U.U_NAME = uname),uname);

    declare exit handler for not found {
                                         http_rewrite ();
                                         http_request_status ('HTTP/1.1 302 Found');
                                         http_header (concat (http_header_get (), 'Location: ',sprintf('/ods/index.html#msg=%U','The user '||uname||' does not exist.'),'\r\n'));
					 return;
                                       };
    if (not exists (select 1 from SYS_USERS where U_NAME =  uname))
      {
        declare tmp any;
        tmp := (select U_NAME from SYS_USERS join WA_USER_INFO on (U_ID = WAUI_U_ID) where WAUI_NICK = uname);
        if (length (tmp))
          uname := tmp;
      }
    select WAUI_VISIBLE, WAUI_LAT, WAUI_LNG, WAUI_HCOUNTRY, WAUI_HSTATE, WAUI_HCITY, WAUI_OPENID_URL, WAUI_OPENID_SERVER,U_ID,WAUI_NICK, WAUI_CERT
      into _visibility, _lat, _lng, _country, _state, _city, _oid_url, _oid_server,uid, _nick, _cert
      from WA_USER_INFO, DB.DBA.SYS_USERS
     where WAUI_U_ID = U_ID and U_NAME =  uname;

    if (length (_visibility) < 16 or _visibility[16] <> ascii ('1'))
    {
        _country := null;
        _state := null;
        _city := null;
    }

    if (_country is not null and length (_country))
       _country_code := (select WC_CODE from WA_COUNTRY where WC_NAME = _country);
    else
      _country_code:=null;

    https := ODS.ODS_API.getDefaultHttps ();
    if (exists (select 1 from WA_SETTINGS where WS_HTTPS = 1) and https is not null)
      _openid_server := 'https://' || https;
    else
    _openid_server := server_root;
--META openID start
    if (length (_oid_url) and length (_oid_server))
    {
      http('  <link rel="openid.server" title="OpenID Server" href="'|| _oid_server ||'" />\r\n',resMeta);
      http('   <link rel="openid.delegate" title="OpenID URL" href="'|| _oid_url ||'" />\r\n',resMeta);
      http('  <link rel="openid2.provider" title="OpenID v2 Server" href="'|| _oid_server ||'" />\r\n',resMeta);
      http('   <link rel="openid2.local_id" title="OpenID v2 URL" href="'|| _oid_url ||'" />\r\n',resMeta);
    }
    else
    {
      if (_nick <> uname)
        {
        http('   <link rel="openid.delegate" title="OpenID URL" href="'|| server_dataspace||utype||_nick ||'" />\r\n',resMeta);
          http('   <link rel="openid2.local_id" title="OpenID v2 URL" href="'|| server_dataspace||utype||_nick ||'" />\r\n',resMeta);
        }
      http('  <link rel="openid.server" title="OpenID Server" href="'||_openid_server||'/openid" />\r\n',resMeta);
      http('  <link rel="openid2.provider" title="OpenID v2 Server" href="'||_openid_server||'/openid" />\r\n',resMeta);
    }
--META openID end

    http('  <link rel="meta" type="application/rdf+xml" title="SIOC" href="'||server_dataspace||uname||'/sioc.rdf" />\r\n',resMeta);
    http('  <link rel="meta" type="application/rdf+xml" title="FOAF" href="'||server_dataspace||utype||uname||'/foaf.rdf" />\r\n',resMeta);
    http('  <link rel="meta" type="text/rdf+n3" title="FOAF" href="'||server_dataspace||utype||uname||'/foaf.n3" />\r\n',resMeta);
    http('  <link rel="meta" type="application/json" title="FOAF" href="'||server_dataspace||utype||uname||'/foaf.json" />\r\n',resMeta);
    http('  <link rel="http://xmlns.com/foaf/0.1/primaryTopic"  title="About" href="'||server_dataspace||utype||uname||'#this" />\r\n',resMeta);
    http('  <link rev="describedby"  title="About" href="'||server_dataspace||utype||uname||'#this" />\r\n',resMeta);

    http('  <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" />\r\n',resMeta);
    http('  <meta name="dc.language" content="en" scheme="rfc1766" />\r\n',resMeta);
    http('  <meta name="dc.title" content="'||_full_name||'''s ODS home" />\r\n',resMeta);
    http('  <meta name="dc.creator" content="'||_full_name||'" />\r\n',resMeta);
    http('  <meta name="dc.description" content="'||_full_name||'''s Dataspace" />\r\n',resMeta);

    http('  <link rel="schema.geo" href="http://www.w3.org/2003/01/geo/wgs84_pos#" />\r\n',resMeta);
    if (_lat is not null and _lng is not null)
    {
      http('  <meta name="geo.position" content="'||sprintf ('%.06f; %.06f', _lat,_lng)||'" />\r\n',resMeta);
      http('  <meta name="ICBM" content="'||sprintf ('%.06f, %.06f', _lat,_lng)||'" />\r\n',resMeta);
    }

    if (_country is not null)
      http('  <meta name="geo.placename" content="'||sprintf('%s, %s, %s',coalesce(_country,''),coalesce(_state,''),coalesce(_city,''))||'" />\r\n',resMeta);
    if (_country_code is not null)
      http('  <meta name="geo.region" content="'||_country_code||'" scheme="iso-3166-1" />\r\n',resMeta);

    if (utype not in ('person/', 'organization/'))
      utype := '';

    http('  <meta http-equiv="X-XRDS-Location" content="'||server_dataspace||uname||'/yadis.xrds" />\r\n',resMeta);
    http('  <meta http-equiv="X-YADIS-Location" content="'||server_dataspace||uname||'/yadis.xrds" />\r\n',resMeta);

    http('  <link rel="meta" type="application/xml+apml" title="APML 0.6" href="'||server_dataspace||uname||'/apml.xml" />\r\n',resMeta);
    http('  <link rel="alternate" type="application/atom+xml" title="OpenSocial Friends" href="'||server_root||'/feeds/people/'||uname||'/friends" />\r\n',resMeta);

    http('  <meta name="dataspaceid" content="'||sprintf('%d',uid)||'" />\r\n',resMeta);

  }

skip_meta:

  declare html_content, links varchar;
  declare exts any;

  exts :=
  vector (
      	vector ('rdf',  'RDF/XML', 'application/rdf+xml'),
      	vector ('nt',   'N3/Turtle', 'text/n3'),
      	vector ('n3',   'N3/Turtle', 'text/rdf+n3'),
	vector ('json', 'RDF/JSON', 'application/json')
	);

  html_content := (select coalesce(blob_to_string(RES_CONTENT), 'Not found...')
                     from WS.WS.SYS_DAV_RES
                    where RES_FULL_PATH = '/DAV/VAD/wa/index.html');

--  html_content := file_to_string('/dev/virtuoso/binsrc/samples/wa/index.html');

  if (length (uname))
    html_content:=replace (html_content,'#THIS',  server_dataspace||utype||uname || '#this');
  else
    html_content:=replace (html_content,'#THIS', '#this');
  html_content:=replace(html_content,'<!-- #META# -->',string_output_string (resMeta));

  links := 'Link:';
  links := links || sprintf (' <%s%s%s#this>; rel="http://xmlns.com/foaf/0.1/primaryTopic",', server_dataspace, utype, uname);
  links := links || sprintf (' <%s%s%s#this>; rev="describedby",', server_dataspace, utype, uname);
  links := links || sprintf (' <%s/activities/feeds/activities/user/%U>; rel="http://schemas.google.com/g/2010#updates-from"; type="application/atom+xml",', server_root, uname);
  links := links || sprintf (' <%s/sparql?default-graph-uri=%s/dataspace>; title="Public SPARQL Service"; rel="http://ontologi.es/sparql#fingerpoint", ', server_root, server_root);
  foreach (any ss in exts) do
    {
       links := links || sprintf (' <%s%s%s/about.%s>; rel="alternate"; type="%s"; title="Structured Descriptor Document (%s format)",',
       server_dataspace, utype, uname, ss[0], ss[2], ss[1]);
    }
  for select U_E_MAIL from DB.DBA.SYS_USERS where U_NAME = uname do
    {
      links := links || sprintf (' <%s/ods/describe?uri=%U>; rel="webfinger",', server_root, 'acct:' || U_E_MAIL);
    }
  links := rtrim (links, ',\r\n');

  http_rewrite();
  http_header (http_header_get () || links || '\r\nContent-Type: text/html; charset=UTF-8\r\n');
  http (html_content);

?>