Ejemplo n.º 1
0
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$login_info = $freeside->login_info();
extract($login_info);
$error = $_GET['error'];
if ($error) {
    $username = $_GET['username'];
    $email = $_GET['email'];
    $domain = $_GET['domain'];
}
$title = 'Login';
include 'elements/header.php';
include 'elements/error.php';
?>

<FORM ACTION="process_login.php" METHOD=POST>
<INPUT TYPE="hidden" NAME="session" VALUE="login">

<TABLE BGCOLOR="#c0c0c0" BORDER=0 CELLSPACING=2 CELLPADDING=0>

<?php 
if ($single_domain) {
    ?>

  <TR>
    <TH ALIGN="right">Username </TH>
    <TD>
      <INPUT TYPE="text" NAME="username" VALUE="<?php 
    echo htmlspecialchars($username);
Ejemplo n.º 2
0
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$session_id = $_GET['session_id'];
$renew_info = $freeside->renew_info(array('session_id' => $session_id));
$error = $renew_info['error'];
if ($error) {
    header('Location:login.php?error=' . urlencode($error));
    die;
}
#in the simple case, just deal with the first package
$bill_date = $renew_info['dates'][0]['bill_date'];
$bill_date_pretty = $renew_info['dates'][0]['bill_date_pretty'];
$renew_date = $renew_info['dates'][0]['renew_date'];
$renew_date_pretty = $renew_info['dates'][0]['renew_date_pretty'];
$amount = $renew_info['dates'][0]['amount'];
$payment_info = $freeside->payment_info(array('session_id' => $session_id));
extract($payment_info);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <TITLE>Renew Early</TITLE>
  </HEAD>
  <BODY>
    <H1>Renew Early</H1>

    <FONT SIZE="+1" COLOR="#ff0000"><?php 
echo htmlspecialchars($_GET['error']);
?>
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->agent_login(array('username' => strtolower($_POST['username']), 'password' => strtolower($_POST['password'])));
error_log("[login] received response from freeside: {$response}");
$error = $response['error'];
if (!$error) {
    // sucessful login
    $session_id = $response['session_id'];
    error_log("[login] agent logged into freeside with session_id={$session_id}");
    // store session id in your session store, to be used for other calls
} else {
    // unsucessful login
    error_log("[login] error logging agent into freeside: {$error}");
    // display error message to user
}
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->order_pkg(array('session_id' => $_POST['session_id'], 'pkgpart' => 15, 'id' => $_POST['id'], 'name' => $_POST['name']));
$error = $response['error'];
if (!$error) {
    // sucessful order
    $pkgnum = $response['pkgnum'];
    $svcnum = $response['svcnum'];
    error_log("[order_pkg] package ordered pkgnum={$pkgnum}, svcnum={$svcnum}");
    // store svcnum, to be used for the customer_status call
} else {
    // unsucessful order
    error_log("[order_pkg] error ordering package: {$error}");
    // display error message to user
}
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$domain = 'example.com';
$response = $freeside->login(array('username' => strtolower($_POST['username']), 'domain' => $domain, 'password' => strtolower($_POST['password'])));
error_log("[login] received response from freeside: {$response}");
$error = $response['error'];
if (!$error) {
    // sucessful login
    $session_id = $response['session_id'];
    error_log("[login] logged into freeside with session_id={$session_id}");
    // store session id in your session store, to be used for other calls
} else {
    // unsucessful login
    error_log("[login] error logging into freeside: {$error}");
    // display error message to user
}
Ejemplo n.º 6
0
 /**
  * Authenticate user and register user information into a session
  */
 function Auth()
 {
     global $ARI_ADMIN_USERNAME;
     global $ARI_ADMIN_PASSWORD;
     global $ARI_ADMIN_EXTENSIONS;
     global $ARI_CRYPT_PASSWORD;
     global $ASTERISK_VOICEMAIL_CONF;
     global $ASTERISK_VOICEMAIL_CONTEXT;
     global $ASTERISK_VOICEMAIL_PATH;
     global $ASTERISK_PROTOCOLS;
     global $CALLMONITOR_ADMIN_EXTENSIONS;
     global $ARI_NO_LOGIN;
     global $ARI_DEFAULT_ADMIN_PAGE;
     global $ARI_DEFAULT_USER_PAGE;
     $crypt = new Crypt();
     // init variables
     $extension = '';
     $displayname = '';
     $vm_password = '';
     $category = '';
     $context = '';
     $voicemail_enabled = '';
     $voicemail_email_address = '';
     $voicemail_pager_address = '';
     $voicemail_email_enable = '';
     $admin = '';
     $admin_callmonitor = '';
     $default_page = '';
     $username = '';
     $password = '';
     // get the ari authentication cookie
     $data = '';
     $chksum = '';
     if (isset($_COOKIE['ari_auth'])) {
         $buf = unserialize($_COOKIE['ari_auth']);
         list($data, $chksum) = $buf;
     }
     if (md5($data) == $chksum) {
         $data = unserialize($crypt->decrypt($data, $ARI_CRYPT_PASSWORD));
         $username = $data['username'];
         $password = $data['password'];
     }
     if (isset($_POST['username']) && isset($_POST['password'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
     }
     // init email options array
     $voicemail_email = array();
     // when login, make a new session
     if ($username && !$ARI_NO_LOGIN) {
         $auth = false;
         // check admin
         if (!$auth) {
             if ($username == $ARI_ADMIN_USERNAME && $password == $ARI_ADMIN_PASSWORD) {
                 // authenticated
                 $auth = true;
                 $extension = 'admin';
                 $name = 'Administrator';
                 $admin = 1;
                 $admin_callmonitor = 1;
                 $default_page = $ARI_DEFAULT_ADMIN_PAGE;
             }
         }
         // check voicemail login
         if (!$auth) {
             if (is_readable($ASTERISK_VOICEMAIL_CONF)) {
                 $lines = file($ASTERISK_VOICEMAIL_CONF);
                 // look for include files and tack their lines to end of array
                 foreach ($lines as $key => $line) {
                     if (preg_match("/include/i", $line)) {
                         $include_filename = '';
                         $parts = split(' ', $line);
                         if (isset($parts[1])) {
                             $include_filename = trim($parts[1]);
                         }
                         if ($include_filename) {
                             $path_parts = pathinfo($ASTERISK_VOICEMAIL_CONF);
                             $include_path = fixPathSlash($path_parts['dirname']) . $include_filename;
                             foreach (glob($include_path) as $include_file) {
                                 $include_lines = file($include_file);
                                 $lines = array_merge($include_lines, $lines);
                             }
                         }
                     }
                 }
                 // process
                 foreach ($lines as $key => $line) {
                     // check for current context and process
                     if (preg_match("/\\[.*\\]/i", $line)) {
                         $currentContext = trim(preg_replace('/\\[|\\]/', '', $line));
                     }
                     if ($ASTERISK_VOICEMAIL_CONTEXT && $currentContext != $ASTERISK_VOICEMAIL_CONTEXT) {
                         continue;
                     }
                     // check for user and process
                     unset($value);
                     $parts = split('=>', $line);
                     if (isset($parts[0])) {
                         $var = $parts[0];
                     }
                     if (isset($parts[1])) {
                         $value = $parts[1];
                     }
                     $var = trim($var);
                     if ($var == $username && $value) {
                         $buf = split(',', $value);
                         if ($buf[0] == $password) {
                             // authenticated
                             $auth = true;
                             $extension = $username;
                             $displayname = $buf[1];
                             $vm_password = $buf[0];
                             $default_page = $ARI_DEFAULT_USER_PAGE;
                             $context = $currentContext;
                             $voicemail_enabled = 1;
                             $voicemail_email_address = $buf[2];
                             $voicemail_pager_address = $buf[3];
                             if ($voicemail_email_address || $voicemail_pager_address) {
                                 $voicemail_email_enable = 1;
                             }
                             $options = split('\\|', $buf[4]);
                             foreach ($options as $option) {
                                 $opt_buf = split('=', $option);
                                 $voicemail_email[$opt_buf[0]] = trim($opt_buf[1]);
                             }
                             $admin = 0;
                             if ($ARI_ADMIN_EXTENSIONS) {
                                 $extensions = split(',', $ARI_ADMIN_EXTENSIONS);
                                 foreach ($extensions as $key => $value) {
                                     if ($extension == $value) {
                                         $admin = 1;
                                         break 2;
                                     }
                                 }
                             }
                             $admin_callmonitor = 0;
                             if ($CALLMONITOR_ADMIN_EXTENSIONS) {
                                 $extensions = split(',', $CALLMONITOR_ADMIN_EXTENSIONS);
                                 foreach ($extensions as $key => $value) {
                                     if ($value == 'all' || $extension == $value) {
                                         $admin_callmonitor = 1;
                                         break 2;
                                     }
                                 }
                             }
                         } else {
                             $_SESSION['ari_error'] = "Incorrect Password";
                             return;
                         }
                     }
                 }
             } else {
                 $_SESSION['ari_error'] = "File not readable: " . $ASTERISK_VOICEMAIL_CONF;
                 return;
             }
         }
         // check sip login
         if (!$auth) {
             foreach ($ASTERISK_PROTOCOLS as $protocol => $value) {
                 $config_files = split(';', $value['config_files']);
                 foreach ($config_files as $config_file) {
                     if (is_readable($config_file)) {
                         $lines = file($config_file);
                         foreach ($lines as $key => $line) {
                             unset($value);
                             $parts = split('=', $line);
                             if (isset($parts[0])) {
                                 $var = trim($parts[0]);
                             }
                             if (isset($parts[1])) {
                                 $value = trim($parts[1]);
                             }
                             if ($var == "username") {
                                 $protocol_username = $value;
                             }
                             if ($var == "secret") {
                                 $protocol_password = $value;
                                 if ($protocol_username == $username && $protocol_password == $password) {
                                     // authenticated
                                     $auth = true;
                                     $extension = $username;
                                     $displayname = $username;
                                     $default_page = $ARI_DEFAULT_ADMIN_PAGE;
                                     $admin = 0;
                                     if ($ARI_ADMIN_EXTENSIONS) {
                                         $extensions = split(',', $ARI_ADMIN_EXTENSIONS);
                                         foreach ($extensions as $key => $value) {
                                             if ($extension == $value) {
                                                 $admin = 1;
                                                 break 2;
                                             }
                                         }
                                     }
                                     $admin_callmonitor = 0;
                                     if ($CALLMONITOR_ADMIN_EXTENSIONS) {
                                         $extensions = split(',', $CALLMONITOR_ADMIN_EXTENSIONS);
                                         foreach ($extensions as $key => $value) {
                                             if ($value == 'all' || $extension == $value) {
                                                 $admin_callmonitor = 1;
                                                 break 2;
                                             }
                                         }
                                     }
                                 } else {
                                     if ($protocol_username == $username && $protocol_password != $password) {
                                         $_SESSION['ari_error'] = _("Incorrect Password");
                                         return;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // let user know bad login
         if (!$auth) {
             $_SESSION['ari_error'] = _("Incorrect Username or Password");
         }
         // freeside login
         $freeside = new FreesideSelfService();
         $domain = 'svc_phone';
         $response = $freeside->login(array('username' => strtolower($username), 'domain' => $domain, 'password' => strtolower($password)));
         error_log("[login] received response from freeside: {$response}");
         $error = $response['error'];
         if (!$error && $response['session_id']) {
             // sucessful freeside login
             error_log("[login] logged into freeside with session_id={$session_id}");
             // store session id in your session store, to be used for other calls
             //$fs_session_id = $response['session_id'];
             $_SESSION['freeside_session_id'] = $response['session_id'];
             $customer_info = $freeside->customer_info(array('session_id' => $_SESSION['freeside_session_id']));
             //XXX error checking here too
             $displayname = $customer_info['name'];
         } else {
             // unsucessful login
             error_log("[login] error logging into freeside: {$error}");
             $auth = false;
             $extension = '';
             // display error message to user
             $_SESSION['ari_error'] = _("Incorrect Username or Password");
         }
         // if authenticated and user wants to be remembered, set cookie
         $remember = '';
         if (isset($_POST['remember'])) {
             $remember = $_POST['remember'];
         }
         if ($auth && $remember) {
             $data = array('username' => $username, 'password' => $password);
             $data = $crypt->encrypt(serialize($data), $ARI_CRYPT_PASSWORD);
             $chksum = md5($data);
             $buf = serialize(array($data, $chksum));
             setcookie('ari_auth', $buf, time() + 365 * 24 * 60 * 60, '/');
         }
         // set category
         if (!$category) {
             $category = "general";
         }
         // set context
         if (!$context) {
             $context = "default";
         }
         // no login user
         if ($ARI_NO_LOGIN) {
             $extension = 'admin';
             $name = 'Administrator';
             $admin_callmonitor = 1;
             $default_page = $ARI_DEFAULT_ADMIN_PAGE;
         }
         // get outboundCID if it exists
         $outboundCID = $this->getOutboundCID($extension);
         // set
         if ($extension) {
             $_SESSION['ari_user']['extension'] = $extension;
             $_SESSION['ari_user']['outboundCID'] = $outboundCID;
             $_SESSION['ari_user']['displayname'] = $displayname;
             $_SESSION['ari_user']['voicemail_password'] = $vm_password;
             $_SESSION['ari_user']['category'] = $category;
             $_SESSION['ari_user']['context'] = $context;
             $_SESSION['ari_user']['voicemail_enabled'] = $voicemail_enabled;
             $_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address;
             $_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address;
             $_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable;
             foreach ($voicemail_email as $key => $value) {
                 $_SESSION['ari_user']['voicemail_email'][$key] = $value;
             }
             $_SESSION['ari_user']['admin'] = $admin;
             $_SESSION['ari_user']['admin_callmonitor'] = $admin_callmonitor;
             $_SESSION['ari_user']['default_page'] = $default_page;
             // force the session data saved
             session_write_close();
         }
     }
 }
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->new_agent(array('agent' => $_POST['agent'], 'username' => strtolower($_POST['username']), '_password' => strtolower($_POST['password'])));
error_log("[new_agent] received response from freeside: {$response}");
$error = $response['error'];
if (!$error) {
    // sucessful signup
    $session_id = $response['session_id'];
    error_log("[new_agent] signup up agent");
} else {
    // unsucessful signup
    error_log("[new_agent] signup error: {$error}");
    // display error message to user
}
Ejemplo n.º 8
0
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->switch_cust(array('session_id' => $_COOKIE['session_id'], 'custnum' => $_POST['custnum']));
#error_log("[switch_cust] received response from freeside: $response");
$error = $response['error'];
if ($error) {
    //this isn't well handled... but the only possible error is a session timeout?
    header('Location:index.php?username='******'&domain=' . urlencode($domain) . '&email=' . urlencode($email) . '&error=' . urlencode($error));
    die;
}
// sucessful customer selection
header("Location:main.php");
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$session_id = $_POST['session_id'];
$response = $freeside->new_customer(array('session_id' => $session_id, 'first' => $_POST['first'], 'last' => $_POST['last'], 'address1' => $_POST['address1'], 'address2' => $_POST['address2'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'zip' => $_POST['zip'], 'country' => 'US', 'daytime' => $_POST['daytime'], 'fax' => $_POST['fax'], 'payby' => 'BILL', 'invoicing_list' => $_POST['email'], 'pkgpart' => 2, 'username' => strtolower($_POST['username']), '_password' => strtolower($_POST['password'])));
error_log("[new_customer] received response from freeside: {$response}");
$error = $response['error'];
if (!$error) {
    // sucessful signup
    $custnum = $response['custnum'];
    error_log("[new_customer] signup up with custnum {$custnum}");
} else {
    // unsucessful signup
    error_log("[new_customer] signup error:: {$error}");
    // display error message to user
}
Ejemplo n.º 10
0
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->logout(array('session_id' => $_COOKIE['session_id']));
setcookie('session_id', '', time() - 3600);
$error = $response['error'];
if ($error) {
    error_log("Logout error: {$error}; ignoring");
}
header('Location:index.php?error=' . urlencode(_('You have been logged out.') . '  ' . _('Thank you for using the system.')));
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$response = $freeside->process_payment_order_renew(array('session_id' => $_POST['session_id'], 'payby' => 'CARD', 'amount' => $_POST['amount'], 'payinfo' => $_POST['payinfo'], 'paycvv' => $_POST['paycvv'], 'month' => $_POST['month'], 'year' => $_POST['year'], 'payname' => $_POST['payname'], 'address1' => $_POST['address1'], 'address2' => $_POST['address2'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'zip' => $_POST['zip'], 'save' => $_POST['save'], 'auto' => $_POST['auto'], 'paybatch' => $_POST['paybatch']));
error_log("[process_payment_order_renew] received response from freeside: {$response}");
$error = $response['error'];
if ($error) {
    error_log("[process_payment_order_renew] response error: {$error}");
    header('Location:order_renew.php' . '?session_id=' . urlencode($_POST['session_id']) . '?error=' . urlencode($error) . '&payby=CARD' . '&amount=' . urlencode($_POST['amount']) . '&payinfo=' . urlencode($_POST['payinfo']) . '&paycvv=' . urlencode($_POST['paycvv']) . '&month=' . urlencode($_POST['month']) . '&year=' . urlencode($_POST['year']) . '&payname=' . urlencode($_POST['payname']) . '&address1=' . urlencode($_POST['address1']) . '&address2=' . urlencode($_POST['address2']) . '&city=' . urlencode($_POST['city']) . '&state=' . urlencode($_POST['state']) . '&zip=' . urlencode($_POST['zip']) . '&save=' . urlencode($_POST['save']) . '&auto=' . urlencode($_POST['auto']) . '&paybatch=' . urlencode($_POST['paybatch']));
    die;
}
// sucessful renewal.
$session_id = $response['session_id'];
// now what?
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <TITLE>Renew Early</TITLE>
  </HEAD>
  <BODY>
    <H1>Renew Early</H1>

    Renewal processed sucessfully.

  </BODY>
</HTML>
Ejemplo n.º 12
0
<?php

require 'freeside.class.php';
$freeside = new FreesideSelfService();
$session_id = $_GET['session_id'];
$response = $freeside->customer_info(array('session_id' => $session_id));
$error = $response['error'];
if ($error) {
    header('Location:login.php?error=' . urlencode($error));
    die;
}
extract($response);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <TITLE>My Account</TITLE>
  </HEAD>
  <BODY>
    <H1>My Account</H1>

      Hello, <?php 
echo htmlspecialchars($name);
?>
<BR><BR>

      <?php 
echo $small_custview;
?>

      <BR>