content
| - ---++ODS Controller for VSP API Login Source Code
The following source code represents the ODS Controller for VSP API Login users.vsp file:
Virtuoso Web Applications
'80')
vHostUrl := vHostUrl || ':' || hpa [1];
}
goto _exit;
}
_default:;
vHostUrl := cfg_item_value (virtuoso_ini_path (), 'URIQA', 'DefaultHost');
if (vHostUrl is null)
{
vHostUrl := sys_stat ('st_host_name');
if (server_http_port () <> '80')
vHostUrl := vHostUrl || ':' || server_http_port ();
}
_exit:;
if (vHostUrl not like 'http://%')
vHostUrl := 'http://' || vHostUrl;
vHostUrl := vHostUrl || '/ods/api';
vRequest := null;
vRespond := null;
declare exit handler for sqlstate '*'
{
dbg_obj_print ('', __SQL_STATE, __SQL_MESSAGE);
vForm := 'login';
goto _end;
};
vError := '';
vForm := get_keyword ('form', params, 'login');
vSid := get_keyword ('sid', params);
vRealm := 'wa';
if (vForm = 'login')
{
if (get_keyword ('lf_login', params, '') <> '')
{
declare vUser, vPassword any;
vUser := get_keyword ('lf_uid', params, '');
vPassword := get_keyword ('lf_password', params, '');
vUrl := sprintf ('%s/user.authenticate?user_name=%s&password_hash=%s', vHostUrl, vUser, ODS.._hex_sha1_digest (vUser || vPassword));
commit work;
vResult := http_client_ext (
vUrl,
http_method=>'GET',
http_headers=>vRequest,
headers=>vRespond
);
if (vRespond[0] like 'HTTP/1._ 4__ %' or vRespond[0] like 'HTTP/1._ 5__ %')
{
vError := vRespond[0];
}
else
{
vSid := vResult;
vForm := 'user';
}
}
}
if (vForm = 'profile')
{
if (get_keyword ('pf_update', params, '') <> '')
{
vUrl := vHostUrl || '/user.update.fields' ||
'?sid=' || vSid ||
'&realm=' || vRealm ||
'&mail=' || sprintf ('%U', get_keyword ('pf_mail', params, '')) ||
'&title=' || sprintf ('%U', get_keyword ('pf_title', params, '')) ||
'&firstName=' || sprintf ('%U', get_keyword ('pf_firstName', params, '')) ||
'&lastName=' || sprintf ('%U', get_keyword ('pf_lastName', params, '')) ||
'&fullName=' || sprintf ('%U', get_keyword ('pf_fullName', params, '')) ||
'&gender=' || sprintf ('%U', get_keyword ('pf_gender', params, '')) ||
'&birthday=' || sprintf ('%U', get_keyword ('pf_birthday', params, '')) ||
'&icq=' || sprintf ('%U', get_keyword ('pf_icq', params, '')) ||
'&skype=' || sprintf ('%U', get_keyword ('pf_skype', params, '')) ||
'&yahoo=' || sprintf ('%U', get_keyword ('pf_yahoo', params, '')) ||
'&aim=' || sprintf ('%U', get_keyword ('pf_aim', params, '')) ||
'&msn=' || sprintf ('%U', get_keyword ('pf_msn', params, '')) ||
'&homeDefaultMapLocation=' || sprintf ('%U', get_keyword ('pf_homeDefaultMapLocation', params, '')) ||
'&homeCountry=' || sprintf ('%U', get_keyword ('pf_homecountry', params, '')) ||
'&homeState=' || sprintf ('%U', get_keyword ('pf_homestate', params, '')) ||
'&homeCity=' || sprintf ('%U', get_keyword ('pf_homecity', params, '')) ||
'&homeCode=' || sprintf ('%U', get_keyword ('pf_homecode', params, '')) ||
'&homeAddress1=' || sprintf ('%U', get_keyword ('pf_homeaddress1', params, '')) ||
'&homeAddress2=' || sprintf ('%U', get_keyword ('pf_homeaddress2', params, '')) ||
'&homeTimezone=' || sprintf ('%U', get_keyword ('pf_homeTimezone', params, '')) ||
'&homeLatitude=' || sprintf ('%U', get_keyword ('pf_homelat', params, '')) ||
'&homeLongitude=' || sprintf ('%U', get_keyword ('pf_homelng', params, '')) ||
'&homePhone=' || sprintf ('%U', get_keyword ('pf_homePhone', params, '')) ||
'&homeMobile=' || sprintf ('%U', get_keyword ('pf_homeMobile', params, '')) ||
'&businessIndustry=' || sprintf ('%U', get_keyword ('pf_businessIndustry', params, '')) ||
'&businessOrganization=' || sprintf ('%U', get_keyword ('pf_businessOrganization', params, '')) ||
'&businessHomePage=' || sprintf ('%U', get_keyword ('pf_businessHomePage', params, '')) ||
'&businessJob=' || sprintf ('%U', get_keyword ('pf_businessJob', params, '')) ||
'&businessCountry=' || sprintf ('%U', get_keyword ('pf_businesscountry', params, '')) ||
'&businessState=' || sprintf ('%U', get_keyword ('pf_businessstate', params, '')) ||
'&businessCity=' || sprintf ('%U', get_keyword ('pf_businesscity', params, '')) ||
'&businessCode=' || sprintf ('%U', get_keyword ('pf_businesscode', params, '')) ||
'&businessAddress1=' || sprintf ('%U', get_keyword ('pf_businessaddress1', params, '')) ||
'&businessAddress2=' || sprintf ('%U', get_keyword ('pf_businessaddress2', params, '')) ||
'&businessTimezone=' || sprintf ('%U', get_keyword ('pf_businessTimezone', params, '')) ||
'&businessLatitude=' || sprintf ('%U', get_keyword ('pf_businesslat', params, '')) ||
'&businessLongitude=' || sprintf ('%U', get_keyword ('pf_businesslng', params, '')) ||
'&businessPhone=' || sprintf ('%U', get_keyword ('pf_businessPhone', params, '')) ||
'&businessMobile=' || sprintf ('%U', get_keyword ('pf_businessMobile', params, '')) ||
'&businessRegNo=' || sprintf ('%U', get_keyword ('pf_businessRegNo', params, '')) ||
'&businessCareer=' || sprintf ('%U', get_keyword ('pf_businessCareer', params, '')) ||
'&businessEmployees=' || sprintf ('%U', get_keyword ('pf_businessEmployees', params, '')) ||
'&businessVendor=' || sprintf ('%U', get_keyword ('pf_businessVendor', params, '')) ||
'&businessService=' || sprintf ('%U', get_keyword ('pf_businessService', params, '')) ||
'&businessOther=' || sprintf ('%U', get_keyword ('pf_businessOther', params, '')) ||
'&businessNetwork=' || sprintf ('%U', get_keyword ('pf_businessNetwork', params, '')) ||
'&businessResume=' || sprintf ('%U', get_keyword ('pf_businessResume', params, '')) ||
'&securitySecretQuestion=' || sprintf ('%U', get_keyword ('pf_securitySecretQuestion', params, '')) ||
'&securitySecretAnswer=' || sprintf ('%U', get_keyword ('pf_securitySecretAnswer', params, '')) ||
'&securitySiocLimit=' || sprintf ('%U', get_keyword ('pf_securitySiocLimit', params, ''));
commit work;
vResult := http_client_ext (
vUrl,
http_method=>'GET',
http_headers=>vRequest,
headers=>vRespond
);
if (vRespond[0] like 'HTTP/1._ 4__ %' or vRespond[0] like 'HTTP/1._ 5__ %')
{
vError := vRespond[0];
vForm := 'login';
}
else
{
vXml := xml_tree_doc (vResult);
if (xpath_eval ('/failed/message', vXml))
{
vError := xpath_eval ('string (/failed/message)', vXml);
vForm := 'login';
} else {
vForm := 'user';
}
}
}
else if (get_keyword ('pf_cancel', params, '') <> '')
{
vForm := 'user';
}
}
if (vForm = 'user')
{
if (get_keyword ('uf_profile', params, '') <> '')
vForm := 'profile';
}
if ((vForm = 'user') or (vForm = 'profile'))
{
vUrl := sprintf ('%s/user.info?sid=%s&realm=%s', vHostUrl, vSid, vRealm);
if (vForm = 'profile')
vUrl := vUrl || '&short=1';
commit work;
vResult := http_client_ext (
vUrl,
http_method=>'GET',
http_headers=>vRequest,
headers=>vRespond
);
if (vRespond[0] like 'HTTP/1._ 4__ %' or vRespond[0] like 'HTTP/1._ 5__ %')
{
vError := vRespond[0];
vForm := 'login';
}
else
{
vXml := xml_tree_doc (vResult);
if (xpath_eval ('/failed/message', vXml))
{
vError := xpath_eval ('string (/failed/message)', vXml);
vForm := 'login';
}
else if (vForm = 'profile')
{
declare tmp, listItems any;
items := vector (vector ('Industry', ''),
vector ('Country', '')
);
vLists := vector ();
foreach (any item in items) do
{
vUrl := sprintf ('%s/lookup.list?key=%s¶m=%s', vHostUrl, item[0], item[1]);
commit work;
vResult := http_client_ext (
vUrl,
http_method=>'GET',
http_headers=>vRequest,
headers=>vRespond
);
if (vRespond[0] like 'HTTP/1._ 4__ %' or vRespond[0] like 'HTTP/1._ 5__ %')
{
vError := vRespond[0];
vForm := 'login';
goto _end;
}
vList := vector ();
tmp := xml_tree_doc (vResult);
listItems := xpath_eval ('/items/item', tmp, 0);
foreach (any listItem in listItems) do
{
vList := vector_concat (vList, vector (cast (listItem as varchar)));
}
vLists := vector_concat (vLists, vector (vList));
}
}
}
}
_end:;
if (vForm = 'login')
{
vSid := '';
vRealm := '';
}
?>
|