3 require('freeside.class.php');
4 $freeside = new FreesideSelfService();
6 $ip = $_SERVER['REMOTE_ADDR'];
8 $mac = $freeside->get_mac_address( array('ip' => $ip, ) );
10 $response = $freeside->login( array(
11 'username' => $mac['mac_address'],
15 $error = $response['error'];
19 $title ='Login'; include('elements/header.php');
20 include('elements/error.php');
23 // header('Location:index.php?username='. urlencode($mac).
24 // '&domain='. urlencode($domain).
25 // '&email='. urlencode($email).
26 // '&error='. urlencode($error)
33 $session_id = $response['session_id'];
35 error_log("[login] logged into freeside with session_id=$session_id, setting cookie");
37 // now what? for now, always redirect to the main page (or the select a
38 // customer diversion).
39 // eventually, other options?
41 setcookie('session_id', $session_id);
43 if ( $response['custnum'] || $response['svcnum'] ) {
45 header("Location:main.php");
49 } elseif ( $response['customers'] ) {
50 //var_dump($response['customers']);
53 <? $title ='Select customer'; include('elements/header.php'); ?>
54 <? include('elements/error.php'); ?>
56 <FORM NAME="SelectCustomerForm" ACTION="process_select_cust.php" METHOD=POST>
57 <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
59 <TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>
62 <TH ALIGN="right">Customer </TH>
64 <SELECT NAME="custnum" ID="custnum" onChange="custnum_changed()">
65 <OPTION VALUE="">Select a customer
66 <? foreach ( $response['customers'] AS $custnum => $customer ) { ?>
67 <OPTION VALUE="<? echo $custnum ?>"><? echo htmlspecialchars( $customer ) ?>
74 <TD COLSPAN=2 ALIGN="center"><INPUT TYPE="submit" ID="submit" VALUE="Select customer" DISABLED></TD>
80 <SCRIPT TYPE="text/javascript">
82 function custnum_changed () {
83 var form = document.SelectCustomerForm;
84 if ( form.custnum.selectedIndex > 0 ) {
85 form.submit.disabled = false;
87 form.submit.disabled = true;
97 // die 'login successful, but unrecognized info (no custnum, svcnum or customers)';
99 } // multiple customers found
101 } //successfull login
105 <? include('elements/footer.php'); ?>