3 require('freeside.class.php');
4 $freeside = new FreesideSelfService();
6 $ip = $_SERVER['REMOTE_ADDR'];
8 if ($_POST['domain'] == "ip_mac") {
9 $mac_addr = $freeside->get_mac_address( array('ip' => $ip, ) );
10 $_POST['username'] = $mac_addr['mac_address'];
13 $response = $freeside->login( array(
14 'email' => strtolower($_POST['email']),
15 'username' => strtolower($_POST['username']),
16 'domain' => strtolower($_POST['domain']),
17 'password' => $_POST['password'],
20 #error_log("[login] received response from freeside: $response");
22 $error = $response['error'];
26 header('Location:index.php?username='. urlencode($_POST['username']).
27 '&domain='. urlencode($_POST['domain']).
28 '&email='. urlencode($_POST['email']).
29 '&error='. urlencode($error)
37 $session_id = $response['session_id'];
39 error_log("[login] logged into freeside with session_id=$session_id, setting cookie");
41 // now what? for now, always redirect to the main page (or the select a
42 // customer diversion).
43 // eventually, other options?
45 setcookie('session_id', $session_id);
47 if ( $response['custnum'] || $response['svcnum'] ) {
49 header("Location:main.php");
52 } elseif ( $response['customers'] ) {
53 //var_dump($response['customers']);
56 <? $title ='Select customer'; include('elements/header.php'); ?>
57 <? include('elements/error.php'); ?>
59 <FORM NAME="SelectCustomerForm" ACTION="process_select_cust.php" METHOD=POST>
60 <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
62 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
65 <TH ALIGN="right">Customer </TH>
67 <SELECT NAME="custnum" ID="custnum" onChange="custnum_changed()">
68 <OPTION VALUE="">Select a customer
69 <? foreach ( $response['customers'] AS $custnum => $customer ) { ?>
70 <OPTION VALUE="<? echo $custnum ?>"><? echo htmlspecialchars( $customer ) ?>
77 <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" ID="submit" VALUE="Select customer" DISABLED></TD>
83 <SCRIPT TYPE="text/javascript">
85 function custnum_changed () {
86 var form = document.SelectCustomerForm;
87 if ( form.custnum.selectedIndex > 0 ) {
88 form.submit.disabled = false;
90 form.submit.disabled = true;
96 <? include('elements/footer.php'); ?>
102 // die 'login successful, but unrecognized info (no custnum, svcnum or customers)';