content
| - ---++ODS Controller for PHP API Login Source Code
The following source code represents the ODS Controller for PHP API Login users.php file:
Virtuoso Web Applications
xpath("/items/item");
$N = 1;
foreach ($items as $S)
{
if ($S <> "0")
$V[$N] = $S;
$N++;
}
return $V;
}
function outFormTitle ($form)
{
if ($form == "login")
print "Login";
if ($form == "user")
print "View Profile";
if ($form == "profile")
print "Edit Profile";
}
function apiURL()
{
$pageURL = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
$pageURL .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"] : $_SERVER['SERVER_NAME'];
return $pageURL.'/ods/api';
}
$_error = "";
$_form = "login";
if (isset ($_POST['form']))
$_form = $_POST['form'];
$_sid = $_POST['sid'];
$_realm = "wa";
if ($_form == "login")
{
if (isset ($_POST['lf_login']) && ($_POST['lf_login'] <> ""))
{
$_url = sprintf ("%s/user.authenticate?user_name=%s&password_hash=%s", apiURL(), $_POST['lf_uid'], sha1($_POST['lf_uid'].$_POST['lf_password']));
$_result = file_get_contents($_url);
if (substr_count($_result, "") <> 0)
{
$_xml = simplexml_load_string($_result);
$_error = $_xml->failed->message;;
} else {
$_sid = $_result;
$_form = "user";
}
}
}
if ($_form == "user")
{
if (isset ($_POST['uf_profile']) && ($_POST['uf_profile'] <> ""))
$_form = "profile";
}
if ($_form == "profile")
{
if (isset ($_POST['pf_update']) && ($_POST['pf_update'] <> ""))
{
$_url = apiURL(). "/user.update.fields".
"?sid=". $_sid.
"&realm=". $_realm.
"&mail=". urlencode ($_POST['pf_mail']).
"&title=". urlencode ($_POST['pf_title']).
"&firstName=". urlencode ($_POST['pf_firstName']).
"&lastName=". urlencode ($_POST['pf_lastName']).
"&fullName=". urlencode ($_POST['pf_fullName']).
"&gender=". urlencode ($_POST['pf_gender']).
"&birthday=". urlencode ($_POST['pf_birthday']).
"&icq=". urlencode ($_POST['pf_icq']).
"&skype=". urlencode ($_POST['pf_skype']).
"&yahoo=". urlencode ($_POST['pf_yahoo']).
"&aim=". urlencode ($_POST['pf_aim']).
"&msn=". urlencode ($_POST['pf_msn']).
"&homeDefaultMapLocation=". urlencode ($_POST['pf_homeDefaultMapLocation']).
"&homeCountry=". urlencode ($_POST['pf_homecountry']).
"&homeState=". urlencode ($_POST['pf_homestate']).
"&homeCity=". urlencode ($_POST['pf_homecity']).
"&homeCode=". urlencode ($_POST['pf_homecode']).
"&homeAddress1=". urlencode ($_POST['pf_homeaddress1']).
"&homeAddress2=". urlencode ($_POST['pf_homeaddress2']).
"&homeTimezone=". urlencode ($_POST['pf_homeTimezone']).
"&homeLatitude=". urlencode ($_POST['pf_homelat']).
"&homeLongitude=". urlencode ($_POST['pf_homelng']).
"&homePhone=". urlencode ($_POST['pf_homePhone']).
"&homeMobile=". urlencode ($_POST['pf_homeMobile']).
"&businessIndustry=". urlencode ($_POST['pf_businessIndustry']).
"&businessOrganization=". urlencode ($_POST['pf_businessOrganization']).
"&businessHomePage=". urlencode ($_POST['pf_businessHomePage']).
"&businessJob=". urlencode ($_POST['pf_businessJob']).
"&businessCountry=". urlencode ($_POST['pf_businesscountry']).
"&businessState=". urlencode ($_POST['pf_businessstate']).
"&businessCity=". urlencode ($_POST['pf_businesscity']).
"&businessCode=". urlencode ($_POST['pf_businesscode']).
"&businessAddress1=". urlencode ($_POST['pf_businessaddress1']).
"&businessAddress2=". urlencode ($_POST['pf_businessaddress2']).
"&businessTimezone=". urlencode ($_POST['pf_businessTimezone']).
"&businessLatitude=". urlencode ($_POST['pf_businesslat']).
"&businessLongitude=". urlencode ($_POST['pf_businesslng']).
"&businessPhone=". urlencode ($_POST['pf_businessPhone']).
"&businessMobile=". urlencode ($_POST['pf_businessMobile']).
"&businessRegNo=". urlencode ($_POST['pf_businessRegNo']).
"&businessCareer=". urlencode ($_POST['pf_businessCareer']).
"&businessEmployees=". urlencode ($_POST['pf_businessEmployees']).
"&businessVendor=". urlencode ($_POST['pf_businessVendor']).
"&businessService=". urlencode ($_POST['pf_businessService']).
"&businessOther=". urlencode ($_POST['pf_businessOther']).
"&businessNetwork=". urlencode ($_POST['pf_businessNetwork']).
"&businessResume=". urlencode ($_POST['pf_businessResume']).
"&securitySecretQuestion=". urlencode ($_POST['pf_securitySecretQuestion']).
"&securitySecretAnswer=". urlencode ($_POST['pf_securitySecretAnswer']).
"&securitySiocLimit=". urlencode ($_POST['pf_securitySiocLimit']);
$_result = file_get_contents($_url);
if (substr_count($_result, "") <> 0)
{
$_xml = simplexml_load_string($_result);
$_error = $_xml->failed->message;;
$_form = "login";
} else {
$_form = "user";
}
}
else if (isset ($_POST['pf_cancel']) && ($_POST['pf_cancel'] <> ""))
{
$_form = "user";
}
}
if (($_form == "user") || ($_form == "profile"))
{
$_url = sprintf ("%s/user.info?sid=%s&realm=%s", apiURL(), $_sid, $_realm);
if ($_form == "profile")
$_url = $_url."&short=1";
$_result = file_get_contents($_url);
$_xml = simplexml_load_string($_result);
if ($_xml->failed->message)
{
$_error = $_xml->failed->message;
$_form = "login";
}
else if ($_form == "profile")
{
$_industries = selectList ('Industry', '');
$_countries = selectList ('Country', '');
}
}
if ($_form == "login")
{
$_sid = "";
$_realm = "";
}
?>
|