diff options
Diffstat (limited to 'fs_selfservice/fri/includes')
-rw-r--r-- | fs_selfservice/fri/includes/ajax.php | 132 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/asi.php | 156 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/bootstrap.php | 315 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/common.php | 434 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/crypt.php | 81 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/database.php | 72 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/display.php | 222 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/freeside.class.php | 38 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/lang.php | 112 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/login.php | 515 | ||||
-rw-r--r-- | fs_selfservice/fri/includes/main.conf.php | 331 |
11 files changed, 0 insertions, 2408 deletions
diff --git a/fs_selfservice/fri/includes/ajax.php b/fs_selfservice/fri/includes/ajax.php deleted file mode 100644 index fc7961b..0000000 --- a/fs_selfservice/fri/includes/ajax.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -/* - * AJAX page update script - */ -function ajaxRefreshScript($args) { - - global $AJAX_PAGE_REFRESH_TIME; - - $url_args = "?ajax_refresh=1&"; - foreach($args as $key => $value) { - $url_args .= $key . "=" . $value . "&"; - } - $url_args = substr($url_args, 0,strlen($url_args)-1); - - $ret = " - <script type='text/javascript' language='javascript'> - - var http_request = false; - - function makeRequest(url, parameters) { - - http_request = false; - - if (window.XMLHttpRequest) { // Mozilla, Safari,... - http_request = new XMLHttpRequest(); - if (http_request.overrideMimeType) { - http_request.overrideMimeType('text/xml'); - } - } - else if (window.ActiveXObject) { // IE - try { - http_request = new ActiveXObject('Msxml2.XMLHTTP'); - } - catch (e) { - try { - http_request = new ActiveXObject('Microsoft.XMLHTTP'); - } - catch (e) {} - } - } - if (!http_request) { - return false; - } - http_request.onreadystatechange = alertContents; - http_request.open('GET', url + parameters, true); - http_request.send(null); - } - - function alertContents() { - - if (!http_request) { - return; - } - - if (http_request.readyState == 4) { - if (http_request.status == 200) { - - var result = http_request.responseXML; - if (!result.documentElement && http_request.responseStream) { - result.load(http_request.responseStream); - } - - var response = http_request.responseXML.documentElement; - - var nav_menu = ''; - if (response.getElementsByTagName('nav_menu')[0]) { - nav_menu = response.getElementsByTagName('nav_menu')[0].firstChild.data; - } - var nav_submenu = ''; - if (response.getElementsByTagName('nav_submenu')[0]) { - nav_submenu = response.getElementsByTagName('nav_submenu')[0].firstChild.data; - } - var content = ''; - if (response.getElementsByTagName('content')[0]) { - content = response.getElementsByTagName('content')[0].firstChild.data; - } - - if (nav_menu) { - document.getElementById('nav_menu').innerHTML = ''; - document.getElementById('nav_menu').innerHTML = nav_menu; - } - if (nav_submenu) { - document.getElementById('nav_submenu').innerHTML = ''; - document.getElementById('nav_submenu').innerHTML = nav_submenu; - } - if (content) { - document.getElementById('content').innerHTML = ''; - document.getElementById('content').innerHTML = content; - } - } - } - } - - function updatePage() { - makeRequest('" . $_SESSION['ARI_ROOT'] . "', '" . $url_args . "'); - } - - // refresh time in 'minutes:seconds' (0 to inifinity) : (0 to 59) - var refresh_time='" . $AJAX_PAGE_REFRESH_TIME . "'; - - if (document.images){ - var limit=refresh_time.split(\":\"); - limit=limit[0]*60+limit[1]*1; - var current = limit; - } - - function beginRefresh(){ - - if (!document.images) { - return; - } - if (current==1) { - updatePage(); - current = limit; - } - else { - current-=1; - } - - setTimeout(\"beginRefresh()\",1000); - } - - window.onload=beginRefresh; - - </script>"; - - return $ret; -} - - -?>
\ No newline at end of file diff --git a/fs_selfservice/fri/includes/asi.php b/fs_selfservice/fri/includes/asi.php deleted file mode 100644 index 62f221e..0000000 --- a/fs_selfservice/fri/includes/asi.php +++ /dev/null @@ -1,156 +0,0 @@ -<?php - -/** - * @file - * Asterisk manager interface for access to asterisk api (astdb) - */ - -/** - * Asterisk Manager Interface - */ -class AsteriskManagerInterface { - - var $socket; - - /** - * constructor - */ - function AsteriskManagerInterface() { - } - - /* - * Reloads Asterisk Configuration - * - * @param $username - * asterisk manager interface username - * @param $password - * asterisk manager interface password - */ - function connect($host,$username,$password) { - - // connect - $fp = fsockopen($host, 5038, $errno, $errstr, 10); - if (!$fp) { - return FALSE; - } - else { - $buffer=''; - if(version_compare(phpversion(), '4.3', '>=')) { - stream_set_timeout($fp, 5); - } - else { - socket_set_timeout($fp, 5); - } - $buffer = fgets($fp); - if (!preg_match('/Asterisk Call Manager/i', $buffer)) { - $_SESSION['ari_error'] = _("Asterisk Call Manager not responding") . "<br />\n"; - return FALSE; - } - else { - $out="Action: Login\r\nUsername: ".$username."\r\nSecret: ".$password."\r\n\r\n"; - fwrite($fp,$out); - $buffer=fgets($fp); - if ($buffer!="Response: Success\r\n") { - $_SESSION['ari_error'] = _("Asterisk authentication failed:") . "<br />" . $buffer . "<br />\n"; - return FALSE; - } - else { - $buffers=fgets($fp); // get rid of Message: Authentication accepted - - // connected - $this->socket = $fp; - } - } - } - return TRUE; - } - - /* - * Reloads Asterisk Configuration - */ - function disconnect() { - - if ($this->socket) { - fclose($this->socket); - } - } - - /* - * Reloads Asterisk Configuration - * - * @param $command - * Command to be sent to the asterisk manager interface - * @return $ret - * response from asterisk manager interface - */ - function command($command) { - - $response = ''; - - fwrite($this->socket,$command); - - $count = 0; - while (($buffer = fgets($this->socket)) && (!preg_match('/Response: Follows/i', $buffer))) { - - if ($count>100) { - $_SESSION['ari_error'] = _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; - return FALSE; - } - $count++; - } - - $count = 0; - while (($buffer = fgets($this->socket)) && (!preg_match('/END COMMAND/i', $buffer))) { - - if (preg_match('/Value/',$buffer)) { - $parts = split(' ',trim($buffer)); - $response = $parts[1]; - } - - if ($count>100) { - $_SESSION['ari_error'] = _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; - return; - } - $count++; - } - - return $response; - } - - function command2($command) { - - $response = ''; - - fwrite($this->socket,$command); - - $count = 0; - while (($buffer = fgets($this->socket)) && (!preg_match('/Response: Follows/i', $buffer))) { - - if ($count>100) { - $_SESSION['ari_error'] = _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; - return FALSE; - } - $count++; - } - - $count = 0; - while (($buffer = fgets($this->socket)) && (!preg_match('/END COMMAND/i', $buffer))) { - - if (preg_match('/Value:/',$buffer)) { - $parts = split('Value:',trim($buffer)); - $response = $parts[1]; - } - if ($count>100) { - $_SESSION['ari_error'] = _("Asterisk command not understood") . "<br />" . $buffer . "<br />\n"; - return; - } - $count++; - } - - return $response; - } - -} - - -?>
\ No newline at end of file diff --git a/fs_selfservice/fri/includes/bootstrap.php b/fs_selfservice/fri/includes/bootstrap.php deleted file mode 100644 index a01a2f5..0000000 --- a/fs_selfservice/fri/includes/bootstrap.php +++ /dev/null @@ -1,315 +0,0 @@ -<?php - -/** - * @file - * Functions that need to be loaded on every request. - */ - -/** - * Sets doc root - */ -function setARIRoot() { - - $found = 0; - if (isset($_SERVER['PHP_SELF'])) { - if ($_SERVER['PHP_SELF']!='') { - $_SESSION['ARI_ROOT'] = $_SERVER['PHP_SELF']; - } - } - - if (!$found) { - $_SESSION['ARI_ROOT'] = "index.php"; - } -} - -/** - * Return a arguments. - * - * @param $args - * The name of the array being acted upon. - * @param $name - * The name of the variable to return. - * @return - * The value of the variable. - */ -function getArgument($args, $name) { - - return isset($args[$name]) ? $args[$name] : ''; -} - -/* - * Gets top level directory names - * - * @param $path - * directory to search - * @param $filter - * string to use as a filter to match files to return - * @return $directories - * directories found - */ -function getDirectories($path,$filter) { - - $directories = array(); - - if (is_dir($path)) { - - $dh = opendir($path); - while (false!== ($item = readdir($dh))) { - if($item!="." && $item!="..") { - - $path = fixPathSlash($path); - $directory = $path; - $directory = appendPath($directory,$item); - - if (is_dir($directory)) { - - $found = 0; - if ($filter) { - if (strpos($directory,$filter)) { - $found = 1; - } - } else { - $found = 1; - } - if ($found) { - $directories[count($directories) + 1] = $directory; - } - } - } - } - } - - return $directories; -} - -/* - * Gets file names recursively 6 folders deep - * - * @param $path - * directory to search - * @param $filter - * string to use as a filter to match files to return - * @param $recursive_max - * max number of sub folders to search - * @param $recursive_count - * current sub folder count - * @return $files - * files found - */ -function getFiles($path,$filter,$recursive_max,$recursive_count) { - - $files = array(); - - if (@is_dir($path) && @is_readable($path)) { - $dh = opendir($path); - while (false!== ($item = readdir($dh))) { - if($item[0]!=".") { - - $path = fixPathSlash($path); - $msg_path = appendPath($path,$item); - - $fileCount++; - if ($fileCount>3000) { - $_SESSION['ari_error'] - .= _("To many files in $msg_path Not all files processed") . "<br>"; - return; - } - - if ($recursive_count<$recursive_max && is_dir($msg_path)) { - - $dirCount++; - if ($dirCount>10) { - $_SESSION['ari_error'] - .= sprintf(_("To many directories in %s Not all files processed"),$msg_path) . "<br>"; - return; - } - - $count = $recursive_count + 1; - $path_files = getFiles($msg_path,$filter,$recursive_max,$count); - $files = array_merge($files,$path_files); - } - else { - $found = 0; - if ($filter) { - if (strpos($msg_path,$filter)) { - $found = 1; - } - } else { - $found = 1; - } - if ($found) { - $files[count($files) + 1] = $msg_path; - } - } - } - } - } - - return $files; -} - -/* Utilities */ - -/** - * Fixes the path for a trailing slash - * - * @param $path - * path to append - * @return $ret - * path to returned - */ -function fixPathSlash($path) { - - $ret = $path; - - $slash = ''; - if (!preg_match('/\/$/',$path)) { - $slash = '/'; - } - $ret .= $slash; - - return $ret; -} - -/** - * Appends folder to end of path - * - * @param $path - * path to append - * @param $folder - * folder to append to path - * @return $ret - * path to returned - */ -function appendPath($path,$folder) { - - $ret = $path; - - $m = ''; - if (!preg_match('/\/$/',$path)) { - $m = '/'; - } - $ret .= $m . $folder; - - return $ret; -} - -/** - * Get Date format - * - * @param $timestamp - * timestamp to be converted - */ -function getDateFormat($timestamp) { - return date('Y-m-d', $timestamp); -} - -/** - * Get time format - * - * @param $timestamp - * timestamp to be converted - */ -function getTimeFormat($timestamp) { - return date('G:i:s', $timestamp); -} - -/* */ - -/** - * Checks ARI dependencies - */ -function checkDependencies() { - - // check for PHP - if (!version_compare(phpversion(), '4.3', '>=')) { - echo _("ARI requires a version of PHP 4.3 or later"); - exit(); - } - - // check for PEAR - $include_path = ini_get('include_path'); - $buf = split(':|,',$include_path); - - $found = 0; - foreach ($buf as $path) { - $path = fixPathSlash($path); - $pear_check_path = $path . "DB.php"; - if (is_file($pear_check_path)) { - $found = 1; - break; - } - } - - if (!$found) { - echo _("PHP PEAR must be installed. Visit http://pear.php.net for help with installation."); - exit(); - } -} - -/** - * Starts the session - */ -function startARISession() { - - if (!isset($_SESSION['ari_user']) ) { - - // start a new session for the user - ini_set('session.name', 'ARI'); // prevent session name clashes - ini_set('session.gc_maxlifetime', '3900'); // make the session timeout a long time - set_time_limit(360); - session_start(); - } -} - -/** - * Bootstrap - * - * Loads critical variables needed for every page request - * - */ -function bootstrap() { - - // set error reporting - error_reporting (E_ALL & ~ E_NOTICE); -} - -/** - * Set HTTP headers in preparation for a page response. - * - * TODO: Figure out caching - */ -function ariPageHeader() { - - bootstrap(); -} - -/** - * Perform end-of-request tasks. - * - * This function sets the page cache if appropriate, and allows modules to - * react to the closing of the page by calling hook_exit(). - */ -function ariPageFooter() { - -} - -/** - * Includes and run functions - */ - -include_once("./includes/lang.php"); -$language = new Language(); -$language->set(); - -checkDependencies(); -startARISession(); -setARIRoot(); - -include_once("./includes/main.conf.php"); -include_once("./version.php"); -include_once("./includes/crypt.php"); -include_once("./includes/login.php"); - - -?> diff --git a/fs_selfservice/fri/includes/common.php b/fs_selfservice/fri/includes/common.php deleted file mode 100644 index 87f2026..0000000 --- a/fs_selfservice/fri/includes/common.php +++ /dev/null @@ -1,434 +0,0 @@ -<?php - -/** - * @file - * common functions - core handler - */ - -/* - * Checks if user is set and sets - */ -function checkErrorMessage() { - - if ($_SESSION['ari_error']) { - $ret .= "<div class='error'> - " . $_SESSION['ari_error'] . " - </div> - <br>"; - unset($_SESSION['ari_error']); - } - - return $ret; -} - -/* - * Checks modules directory, and configuration, and loaded modules - */ -function loadModules() { - - global $ARI_ADMIN_MODULES; - global $ARI_DISABLED_MODULES; - - global $loaded_modules; - - $modules_path = "./modules"; - if (is_dir($modules_path)) { - - $filter = ".module"; - $recursive_max = 1; - $recursive_count = 0; - $files = getFiles($modules_path,$filter,$recursive_max,$recursive_count); - - foreach($files as $key => $path) { - - // build module object - include_once($path); - $path_parts = pathinfo($path); - list($name,$ext) = split("\.",$path_parts['basename']); - - // check for module and get rank - if (class_exists($name)) { - - $module = new $name(); - - // check if admin module - $found = 0; - if ($ARI_ADMIN_MODULES) { - $admin_modules = split(',',$ARI_ADMIN_MODULES); - foreach ($admin_modules as $key => $value) { - if ($name==$value) { - $found = 1; - break; - } - } - } - - // check if disabled module - $disabled = 0; - if ($ARI_DISABLED_MODULES) { - $disabled_modules = split(',',$ARI_DISABLED_MODULES); - foreach ($disabled_modules as $key => $value) { - if ($name==$value) { - $disabled = 1; - break; - } - } - } - - // if not admin module or admin user add to module name to array - if (!$disabled && (!$found || $_SESSION['ari_user']['admin'])) { - $loaded_modules[$name] = $module; - } - } - } - } - else { - $_SESSION['ari_error'] = _("$path not a directory or not readable"); - } -} - -/** - * Builds database connections - */ -function databaseLogon() { - - global $STANDALONE; - - global $ASTERISKMGR_DBHOST; - - global $AMP_FUNCTIONS_FILES; - global $AMPORTAL_CONF_FILE; - - global $LEGACY_AMP_DBENGINE; - global $LEGACY_AMP_DBFILE; - global $LEGACY_AMP_DBHOST; - global $LEGACY_AMP_DBNAME; - - global $ASTERISKCDR_DBENGINE; - global $ASTERISKCDR_DBFILE; - global $ASTERISKCDR_DBHOST; - global $ASTERISKCDR_DBNAME; - - global $ARI_DISABLED_MODULES; - - global $loaded_modules; - - // This variable is a global in the FreePBX function.inc.php but needs to be - // declared here or the is not seen when parse_amprotaconf() is eventually called - // ?php bug? - // - global $amp_conf_defaults; - - // get user - if ($STANDALONE['use']) { - - $mgrhost = $ASTERISKMGR_DBHOST; - $mgruser = $STANDALONE['asterisk_mgruser']; - $mgrpass = $STANDALONE['asterisk_mgrpass']; - - $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; - $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; - $asteriskcdr_dbuser = $STANDALONE['asteriskcdr_dbuser']; - $asteriskcdr_dbpass = $STANDALONE['asteriskcdr_dbpass']; - $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; - $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; - } - else { - - $include = 0; - $files = split(';',$AMP_FUNCTIONS_FILES); - foreach ($files as $file) { - if (is_file($file)) { - include_once($file); - $include = 1; - } - } - - if ($include) { - $amp_conf = parse_amportal_conf($AMPORTAL_CONF_FILE); - - $mgrhost = $ASTERISKMGR_DBHOST; - $mgruser = $amp_conf['AMPMGRUSER']; - $mgrpass = $amp_conf['AMPMGRPASS']; - - $amp_dbengine = isset($amp_conf["AMPDBENGINE"]) ? $amp_conf["AMPDBENGINE"] : $LEGACY_AMP_DBENGINE; - $amp_dbfile = isset($amp_conf["AMPDBFILE"]) ? $amp_conf["AMPDBFILE"] : $LEGACY_AMP_DBFILE; - $amp_dbuser = $amp_conf["AMPDBUSER"]; - $amp_dbpass = $amp_conf["AMPDBPASS"]; - $amp_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $LEGACY_AMP_DBHOST; - $amp_dbname = isset($amp_conf["AMPDBNAME"]) ? $amp_conf["AMPDBNAME"] : $LEGACY_AMP_DBNAME; - - $asteriskcdr_dbengine = $ASTERISKCDR_DBENGINE; - $asteriskcdr_dbfile = $ASTERISKCDR_DBFILE; - $asteriskcdr_dbuser = $amp_conf["AMPDBUSER"]; - $asteriskcdr_dbpass = $amp_conf["AMPDBPASS"]; - $asteriskcdr_dbhost = $ASTERISKCDR_DBHOST; - $asteriskcdr_dbhost = isset($amp_conf["AMPDBHOST"]) ? $amp_conf["AMPDBHOST"] : $ASTERISKCDR_DBHOST; - $asteriskcdr_dbname = $ASTERISKCDR_DBNAME; - - unset($amp_conf); - } - } - - // asterisk manager interface (berkeley database I think) - global $asterisk_manager_interface; - $asterisk_manager_interface = new AsteriskManagerInterface(); - - $success = $asterisk_manager_interface->Connect($mgrhost,$mgruser,$mgrpass); - if (!$success) { - $_SESSION['ari_error'] = - _("ARI does not appear to have access to the Asterisk Manager.") . " ($errno)<br>" . - _("Check the ARI 'main.conf.php' configuration file to set the Asterisk Manager Account.") . "<br>" . - _("Check /etc/asterisk/manager.conf for a proper Asterisk Manager Account") . "<br>" . - _("make sure [general] enabled = yes and a 'permit=' line for localhost or the webserver."); - return FALSE; - } - - // pear interface databases - $db = new Database(); - - // AMP asterisk database - if (!$STANDALONE['use']) { - $_SESSION['dbh_asterisk'] = $db->logon($amp_dbengine, - $amp_dbfile, - $amp_dbuser, - $amp_dbpass, - $amp_dbhost, - $amp_dbname); - if (!isset($_SESSION['dbh_asterisk'])) { - $_SESSION['ari_error'] .= _("Cannot connect to the $amp_dbname database") . "<br>" . - _("Check AMP installation, asterisk, and ARI main.conf"); - return FALSE; - } - } - - // cdr database - if (in_array('callmonitor',array_keys($loaded_modules))) { - $_SESSION['dbh_cdr'] = $db->logon($asteriskcdr_dbengine, - $asteriskcdr_dbfile, - $asteriskcdr_dbuser, - $asteriskcdr_dbpass, - $asteriskcdr_dbhost, - $asteriskcdr_dbname); - if (!isset($_SESSION['dbh_cdr'])) { - $_SESSION['ari_error'] .= sprintf(_("Cannot connect to the $asteriskcdr_dbname database"),$asteriskcdr_dbname) . "<br>" . - _("Check AMP installation, asterisk, and ARI main.conf"); - return FALSE; - } - } - - return TRUE; -} - -/** - * Logout if needed for any databases - */ -function databaseLogoff() { - - global $asterisk_manager_interface; - - $asterisk_manager_interface->Disconnect(); -} - -/* - * Checks if user is set and sets - */ -function loginBlock() { - - $login = new Login(); - - if (isset($_REQUEST['logout'])) { - $login->Unauth(); - } - - if (!isset($_SESSION['ari_user'])) { - $login->Auth(); - - } - - if (!isset($_SESSION['ari_user'])) { - - // login form - $ret .= $login->GetForm(); - - return $ret; - } -} - -/* - * Main handler for website - */ -function handleBlock() { - - global $ARI_NO_LOGIN; - - global $loaded_modules; - - // check errors here and in login block - $content .= checkErrorMessage(); - - // check logout - if ($_SESSION['ari_user'] && !$ARI_NO_LOGIN) { - $logout = 1; - } - - // if nothing set goto user default page - if (!isset($_REQUEST['m'])) { - $_REQUEST['m'] = $_SESSION['ari_user']['default_page']; - } - // if not function specified then use display page function - if (!isset($_REQUEST['f'])) { - $_REQUEST['f'] = 'display'; - } - - $m = $_REQUEST['m']; // module - $f = $_REQUEST['f']; // function - $a = $_REQUEST['a']; // action - - // set arguments - $args = array(); - foreach($_REQUEST as $key => $value) { - $args[$key] = $value; - } - - // set rank - $ranked_modules = array(); - foreach ($loaded_modules as $module) { - - $module_methods = get_class_methods($module); // note that PHP4 returns all lowercase - while (list($index, $value) = each($module_methods)) { - $module_methods[strtolower($index)] = strtolower($value); - } - reset($module_methods); - - $rank = 99999; - $rank_function = "rank"; - if (in_array(strtolower($rank_function), $module_methods)) { - $rank = $module->$rank_function(); - } - - $ranked_modules[$rank] = $module; - } - ksort($ranked_modules); - - // process modules - foreach ($ranked_modules as $module) { - - // process module - $name = get_class($module); // note PHP4 returns all lowercase - $module_methods = get_class_methods($module); // note PHP4 returns all lowercase - while (list($index, $value) = each($module_methods)) { - $module_methods[strtolower($index)] = strtolower($value); - } - reset($module_methods); - - // init module - $module->init(); - - // add nav menu items - $nav_menu_function = "navMenu"; - if (in_array(strtolower($nav_menu_function), $module_methods)) { - $nav_menu .= $module->$nav_menu_function($args); - } - - if (strtolower($m)==strtolower($name)) { - - // build sub menu - $subnav_menu_function = "navSubMenu"; - if (in_array(strtolower($subnav_menu_function), $module_methods)) { - $subnav_menu .= $module->$subnav_menu_function($args); - } - - // execute function (usually to build content) - if (in_array(strtolower($f), $module_methods)) { - $content .= $module->$f($args); - } - } - } - - // add logout link - if ($logout != '') { - $nav_menu .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?logout=1'>" . _("Logout") . "</a></small></small></p>"; - } - - // error message if no content - if (!$content) { - $content .= _("Page Not Found."); - } - - return array($nav_menu,$subnav_menu,$content); -} - -/* - * Main handler for website - */ -function handler() { - - global $ARI_VERSION; - - // version - $ari_version = $ARI_VERSION; - - // check error - $error = $_SESSION['ari_error']; - - // load modules - loadModules(); - - // login to database - $success = databaseLogon(); - if ($success) { - - // check if login is needed - $content = loginBlock(); - if (!isset($content)) { - list($nav_menu,$subnav_menu,$content) = handleBlock(); - } - } - else { - - $display = new Display(); - - $content .= $display->displayHeaderText("ARI"); - $content .= $display->displayLine(); - $content .= checkErrorMessage(); - } - - // log off any databases needed - databaseLogoff(); - - // check for ajax request and refresh or if not build the page - if (isset($_REQUEST['ajax_refresh']) ) { - - echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?> - <response> - <nav_menu><![CDATA[" . $nav_menu . "]]></nav_menu> - <subnav_menu><![CDATA[" . $subnav_menu . "]]></subnav_menu> - <content><![CDATA[" . $content . "]]></content> - </response>"; - } - else { - - // build the page - include_once("./theme/page.tpl.php"); - } -} - -/** - * Includes and run functions - */ - -// create asterisk manager interface singleton -$asterisk_manager_interface = ''; - -// array to keep track of loaded modules -$loaded_modules = array(); - -include_once("./includes/asi.php"); -include_once("./includes/database.php"); -include_once("./includes/display.php"); -include_once("./includes/ajax.php"); - -include_once("./includes/freeside.class.php"); - -?> diff --git a/fs_selfservice/fri/includes/crypt.php b/fs_selfservice/fri/includes/crypt.php deleted file mode 100644 index 301d8a8..0000000 --- a/fs_selfservice/fri/includes/crypt.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php - -/* - * Allows encrypt and decrypt - */ -class Crypt { - - /** - * Gets a random value for encryption - * - From php.net docs - * - * @param $iv_len - * length of random variable - */ - function getRndIV($iv_len) { - - $iv = ''; - while ($iv_len-- > 0) { - $iv .= chr(mt_rand() & 0xff); - } - return $iv; - } - - /** - * Encrypts string - * - From php.net docs - * - * @param $str - * string to encrypt - * @param $salt - * password to use for encryption - * @param $iv_len - * length of random number - */ - function encrypt($str, $salt, $iv_len = 16) { - - $str .= "\x13"; - $n = strlen($str); - if ($n % 16) $str .= str_repeat("\0", 16 - ($n % 16)); - $i = 0; - $enc_text = $this->getRndIV($iv_len); - $iv = substr($salt ^ $enc_text, 0, 512); - while ($i < $n) { - $block = substr($str, $i, 16) ^ pack('H*', md5($iv)); - $enc_text .= $block; - $iv = substr($block . $iv, 0, 512) ^ $salt; - $i += 16; - } - return urlencode(base64_encode($enc_text)); - } - - /** - * Decrypts string - * - From php.net docs - * - * @param $enc - * encrypted string to decrypt - * @param $salt - * password to use for encryption - * @param $iv_len - * length of random number - */ - function decrypt($enc, $salt, $iv_len = 16) { - - $enc = urldecode(base64_decode($enc)); - $n = strlen($enc); - $i = $iv_len; - $str = ''; - $iv = substr($salt ^ substr($enc, 0, $iv_len), 0, 512); - while ($i < $n) { - $block = substr($enc, $i, 16); - $str .= $block ^ pack('H*', md5($iv)); - $iv = substr($block . $iv, 0, 512) ^ $salt; - $i += 16; - } - return preg_replace('/\\x13\\x00*$/', '', $str); - } -} - - -?> diff --git a/fs_selfservice/fri/includes/database.php b/fs_selfservice/fri/includes/database.php deleted file mode 100644 index ff3d199..0000000 --- a/fs_selfservice/fri/includes/database.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -/** - * @file - * Functions for the database - */ - -/* - * Database Class - */ -class Database { - - /* - * Constructor - */ - function Database() { - - // PEAR must be installed - require_once('DB.php'); - } - - /* - * Logs into database and returns database handle - * - - * @param $engine - * database engine - * @param $dbfile - * database file - * @param $username - * username for database - * @param $password - * password for database - * @param $host - * database host - * @param $name - * database name - * @return $dbh - * variable to hold the returned database handle - */ - function logon($engine,$dbfile,$username,$password,$host,$name) { - - // connect string - if ($dbfile) { - // datasource mostly to support sqlite: dbengine://dbfile?mode=xxxx - $dsn = $engine . '://' . $dbfile . '?mode=0666'; - } - else { - // datasource in in this style: dbengine://username:password@host/database - $datasource = $engine . '://' . $username . ':' . $password . '@' . $host . '/' . $name; - } - - // options - $options = array( - 'debug' => 2, - 'portability' => DB_PORTABILITY_LOWERCASE|DB_PORTABILITY_RTRIM|DB_PORTABILITY_DELETE_COUNT|DB_PORTABILITY_NUMROWS|DB_PORTABILITY_ERRORS|DB_PORTABILITY_NULL_TO_EMPTY, - ); - - // attempt connection - $dbh = DB::connect($datasource,$options); - - // if connection failed show error - if(DB::isError($dbh)) { - $_SESSION['ari_error'] .= $dbh->getMessage() . "<br><br>"; - return; - } - return $dbh; - } -} - - -?>
\ No newline at end of file diff --git a/fs_selfservice/fri/includes/display.php b/fs_selfservice/fri/includes/display.php deleted file mode 100644 index 41d8dc5..0000000 --- a/fs_selfservice/fri/includes/display.php +++ /dev/null @@ -1,222 +0,0 @@ -<?php - -/** - * @file - * Functions common to display - */ - -/** - * Display - */ -class Display { - - /** - * display constructor - */ - function Display() { - } - - /** - * display text header - * - * @param $text - * Header text to display - */ - function displayHeaderText($text) { - - $ret = "<h2>" . $text . "</h2> - <br>"; - - return $ret; - } - - /** - * displays header line - */ - function displayLine() { - - $ret = " - <div id='line'> - <div class='spacer'></div> - <div class='spacer'></div> - </div> - <br>"; - - return $ret; - } -} - -/** - * DisplaySearch - */ -class DisplaySearch extends Display { - - /** - * Constructor - */ - function DisplaySearch() { - } - - /** - * displays search controls - * - * @param $align - * where to align the control - * @param $q - * search query - * @param $focus - * whether to focus control on this block - */ - function displaySearchBlock($align,$m,$q,$url_opts,$focus) { - - // align - if ($align=='center') { - $alignText = "class='bar_center'"; - } - else { - $alignText = "class='bar_left'"; - } - - // url options - foreach ($url_opts as $key => $value) { - $option_text .= "<input type=hidden name=" . $key . " value=" . $value . ">"; - } - - // build - $ret .= "<div " . $alignText . "> - <form class='bar' action='" . $_SESSION['ARI_ROOT'] . "' method='GET' name='search'> - <input type=hidden name=m value=" . $m . "> - <input type=text name=q size=40 value='" . $q . "' maxlength=256> - " . $option_text . " - <input type=hidden name=start value=0> - <input type=submit name=btnS value='" . _("Search") . "'> - </form> - </div>"; - - if ($focus=="true") { // search block loaded twice usually so only allow javascript to be loaded on the top block - $ret .= "<script type='text/javascript'> - <!-- - if (document.search) { - document.search.q.focus(); - } - // --> - </script>"; - } - - return $ret; - } - - /** - * displays info bar - * - * @param $controls - * controls for the page on the bar - * @param $q - * search query - * @param $start - * start number of current page - * @param $span - * number of items on current page - * @param $total - * total number of records found by current search - */ - function displayInfoBarBlock($controls,$q,$start,$span,$total) { - - if ($total<$span) { - $span = $total; - } - $start_count = ($total>0)?$start+1:$start; - $span_count = ($start+$span>$total)?$total:$start+$span; - - if ($controls) { - $left_text = $controls; - } - elseif ($q != NULL) { - $left_text = "<small><small>" . _("Searched for") . " <u>" . $q . "</u></small></small>"; - } - - if ($span<$total) { - $right_text = "<small><small>" . sprintf(_("Results %d - %d of %d"),$start_count,$span_count,$total) . "</small></small>"; - } else { - $right_text = "<small><small>" . sprintf(_("Results %d"),$total) . "</small></small>"; - } - - $ret .= " - <table id='navbar' width='100%'> - <tr> - <td> - " . $left_text . " - </td> - <td align='right'> - " . $right_text ." - </td> - </tr> - </table>"; - - return $ret; - } - - /** - * displays navigation bar - * - * @param $q - * search query - * @param $start - * start number of current page - * @param $span - * number of items on current page - * @param $total - * total number of records found by current search - */ - function displayNavigationBlock($m,$q,$url_opts,$start,$span,$total) { - - $start = $start=='' ? 0 : $start ; - $span = $span=='' ? 15 : $span ; - - $total_pages = ceil($total/$span); - $start_page = floor($start/$span); - - // if more than ten pages start at this page minus ten otherwise start at zero - $begin = ($start_page>10)?($start_page-10):0; - // if more than ten pages then stop at this page plus ten otherwise stop at last page - $end = ($start_page>8)?($start_page+10):10; - - // url - $unicode_q = urlencode($q); // encode search string - - foreach ($url_opts as $key => $value) { - $option_text .= "&" . $key . "=" . $value; - } - - $url = $_SESSION['ARI_ROOT'] . "?m=" . $m . "&q=" . $unicode_q . $option_text; - - // build - if ($start_page!=0) { - $start_page_text = "<a href='" . $url . "&start=0'><small>" . _("First") . "</a> </small> - <a href=" . $url . "&start=" . ($start-$span) . "><small><</a> </small>"; - } - - for($next_page=$begin;($next_page<$total_pages)&&($next_page<$end);$next_page++) { - if ($next_page == $start_page) { - $middle_page_text .= "<small>" . ($next_page+1) . " </small>"; - } else { - $middle_page_text .= "<a href='" . $url . "&start=" . ($next_page*$span) . "'><small>" . ($next_page+1) . "</a> </small>"; - } - } - if ( ($start_page != $total_pages-1) && ($total != 0) ) { - $end_page_text = "<a href='" . $url . "&start=" . ($start+$span) . "'><small>></a> </small> - <a href='" . $url . "&start=" . ($total_pages-1)*$span . "'><small>" . _("Last") . "</a> </small>"; - } - - $ret .= "<div class='bar_center'> - " . $start_page_text . " - " . $middle_page_text . " - " . $end_page_text . " - </div>"; - - return $ret; - } -} - - -?>
\ No newline at end of file diff --git a/fs_selfservice/fri/includes/freeside.class.php b/fs_selfservice/fri/includes/freeside.class.php deleted file mode 100644 index a441398..0000000 --- a/fs_selfservice/fri/includes/freeside.class.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -class FreesideSelfService { - - //Change this to match the location of your selfservice xmlrpc.cgi or daemon - //var $URL = 'https://www.example.com/selfservice/xmlrpc.cgi'; - var $URL = 'http://localhost/selfservice/xmlrpc.cgi'; - - function FreesideSelfService() { - $this; - } - - public function __call($name, $arguments) { - - error_log("[FreesideSelfService] $name called, sending to ". $this->URL); - - $request = xmlrpc_encode_request("FS.SelfService.XMLRPC.$name", $arguments); - $context = stream_context_create( array( 'http' => array( - 'method' => "POST", - 'header' => "Content-Type: text/xml", - 'content' => $request - ))); - $file = file_get_contents($this->URL, false, $context); - if (!$file) { - trigger_error("[FreesideSelfService] XML-RPC communication error: file_get_contents did not return"); - } else { - $response = xmlrpc_decode($file); - if (xmlrpc_is_fault($response)) { - trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])"); - } else { - //error_log("[FreesideSelfService] $response"); - return $response; - } - } - } - -} - -?> diff --git a/fs_selfservice/fri/includes/lang.php b/fs_selfservice/fri/includes/lang.php deleted file mode 100644 index b27b8e3..0000000 --- a/fs_selfservice/fri/includes/lang.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php - -/** - * @file - * i18n language functions - */ - -/** - * Class for login - */ -class Language { - - var $error; - - /** - * Sets i18n locale language - * - * sets the language for i18n php gettext module - * (gettext has to be enabled in the php.ini) - * - */ - function set() { - - if (extension_loaded('gettext')) { - - // try and find the default locale - $default_lang = preg_replace('/-/','_',$_SERVER['HTTP_ACCEPT_LANGUAGE']); - - $locale = 'en_US'; - $locale_dir = "./locale"; - $directories = getdirectories($locale_dir,""); - foreach($directories as $directory) { - $buf = substr($directory,strlen($locale_dir)+1,strlen($directory) - strlen($locale_dir)); - if (preg_match("/" . $buf . "/i",$default_lang)) { - $locale = $buf; - break; - } - } - - // set locale - $language = isset($_COOKIE['ari_lang']) ? $_COOKIE['ari_lang'] : $locale; - putenv("LANG=$language"); - putenv("LANGUAGE=$language"); - setlocale(LC_MESSAGES,$language); - bindtextdomain('ari','./locale'); - bind_textdomain_codeset('ari', 'UTF-8'); - textdomain('ari'); - - } else { - function _($str) { - return $str; - } - } - } - - /** - * Sets the i18n language in a cookie - * - * @param $lang_code - * length of random number - */ - function setCookie($lang_code) { - - if (extension_loaded('gettext')) { - setcookie("ari_lang", $lang_code, time()+365*24*60*60); - } - } - - /** - * Sets the i18n language in a cookie - * - * @param $lang_code - * length of random number - */ - function getForm() { - - // lang setting options - if (extension_loaded('gettext')) { - - $langOptions = " - <script> - function setCookie(name,value) { - var t = new Date(); - var e = new Date(); - e.setTime(t.getTime() + 365*24*60*60); - document.cookie = name+\"=\"+escape(value) + \";expires=\"+e.toGMTString(); - } - </script> - <form class='lang' name='lang' action=" . $_SESSION['ARI_ROOT'] . " method='POST'> - <select class='lang_code' name='lang_code' onChange=\"setCookie('ari_lang',document.lang.lang_code.value); window.location.reload();\"> - <option value='en_US' " . ($_COOKIE['ari_lang']=='en_US' ? 'selected' : '') . ">English</option> - <option value='es_ES' " . ($_COOKIE['ari_lang']=='es_ES' ? 'selected' : '') . ">Español</option> - <option value='fr_FR' " . ($_COOKIE['ari_lang']=='fr_FR' ? 'selected' : '') . ">French</option> - <option value='de_DE' " . ($_COOKIE['ari_lang']=='de_DE' ? 'selected' : '') . ">German</option> - <option value='el_GR' " . ($_COOKIE['ari_lang']=='el_GR' ? 'selected' : '') . ">Greek</option> - <option value='he_IL' " . ($_COOKIE['ari_lang']=='he_IL' ? 'selected' : '') . ">Hebrew</option> - <option value='hu_HU' " . ($_COOKIE['ari_lang']=='hu_HU' ? 'selected' : '') . ">Hungarian</option> - <option value='it_IT' " . ($_COOKIE['ari_lang']=='it_IT' ? 'selected' : '') . ">Italian</option> - <option value='pt_BR' " . ($_COOKIE['ari_lang']=='pt_BR' ? 'selected' : '') . ">Portuguese</option> - <option value='sv_SE' " . ($_COOKIE['ari_lang']=='sv_SE' ? 'selected' : '') . ">Swedish</option> - </select> - </form>"; - } - - return $langOptions; - } - - -} - - -?>
\ No newline at end of file diff --git a/fs_selfservice/fri/includes/login.php b/fs_selfservice/fri/includes/login.php deleted file mode 100644 index 41bb7a6..0000000 --- a/fs_selfservice/fri/includes/login.php +++ /dev/null @@ -1,515 +0,0 @@ -<?php - -/** - * @file - * login functions - */ - -/** - * Class for login - */ -class Login { - - var $error; - - /** - * 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(); - } - } - } - - /* - * Gets user outbound caller id - * - * @param $exten - * Extension to get information about - * @return $ret - * outbound caller id - */ - function getOutboundCID($extension) { - - global $asterisk_manager_interface; - - $ret = ''; - $response = $asterisk_manager_interface->Command2("Action: Command\r\nCommand: database get AMPUSER $extension/outboundcid\r\n\r\n"); - if ($response) { - - $posLeft = strpos( $response, "<")+strlen("<"); - $posRight = strpos( $response, ">", $posLeft); - $ret = substr( $response,$posLeft,$posRight-$posLeft); - } - return $ret; - } - - /** - * logout - */ - function Unauth() { - unset($_COOKIE["ari_auth"]); - setcookie('ari_auth',"",time(),'/'); - unset($_SESSION['ari_user']); - } - - /** - * Provide a login form for user - * - * @param $request - * Variable to hold data entered into form - */ - function GetForm() { - - global $ARI_NO_LOGIN; - - if ($ARI_NO_LOGIN) { - $ret = ''; - return; - } - - if (isset($_GET['login'])) { - $login = $_GET['login']; - } - - // if user name and password were given, but there was a problem report the error - if ($this->error!='') { - $ret = $this->error; - } - - $language = new Language(); - $display = new Display(NULL); - - // new header - $ret .= $display->DisplayHeaderText(_("Login")); - $ret .= $display->DisplayLine(); - $ret .= checkErrorMessage(); - - $ret .= " - <table id='login'> - <form id='login' name='login' action=" . $_SESSION['ARI_ROOT'] . " method='POST'> - <tr> - <td class='right'> - <small><small>" . _("Login") . ": </small></small> - </td> - <td> - <input type='text' name='username' value='" . $login . "' maxlength=20 tabindex=1> - </td> - </tr> - <tr> - <td class='right'> - <small><small>" . _("Password") . ": </small></small> - </td> - <td colspan=1> - <input type='password' name='password' maxlength=20 tabindex=2> - </td> - </tr> - <tr> - <td></td> - <td> - <input type='submit' name='btnSubmit' value='" . _("Submit") . "' tabindex=3></small></small></p> - </td> - </tr> - <tr> - <td class='right'> - <input type='checkbox' name='remember'> - </td> - <td class='left'> - <p class='small'>" . _("Remember Password") . "</p> - </td> - </tr> - </form> - <tr> - <td></td> - <td> - " . $language->getForm() . " - </td> - </tr> - <tr><td> </td></tr> - </table> - <table id='login_text'> - <tr> - <td>" . - _("Use your <b>Voicemail Mailbox and Password</b>") . "<br>" . - _("This is the same password used for the phone") . "<br>" . - "<br>" . - _("For password maintenance or assistance, contact your Phone System Administrator.") . "<br>" . " - </td> - </tr> - </table>"; - - $ret .= " - <script type='text/javascript'> - <!-- - if (document.login) { - document.login.username.focus(); - } - // --> - </script>"; - - return $ret; - } - - -} - - -?> diff --git a/fs_selfservice/fri/includes/main.conf.php b/fs_selfservice/fri/includes/main.conf.php deleted file mode 100644 index cedf60c..0000000 --- a/fs_selfservice/fri/includes/main.conf.php +++ /dev/null @@ -1,331 +0,0 @@ -<?php - -/** - * @file - * site-specific configuration file. - */ - -############################### -# AMP or standalone settings -############################### -# -# From AMP. Used for logon to database. -# -$AMP_FUNCTIONS_FILES = "../admin/functions.php;../admin/functions.inc.php"; -$AMPORTAL_CONF_FILE = "/etc/amportal.conf"; - -# -# Host for Asterisk Manager Interface -# -$ASTERISKMGR_DBHOST = "localhost"; - -# -# Database options for older legacy AMP installations (pre-FreePBX) -# - $LEGACY_AMP_DBFILE only needs to be set if using a database like sqlite -# -$LEGACY_AMP_DBHOST = "localhost"; -$LEGACY_AMP_DBENGINE = "mysql"; -$LEGACY_AMP_DBFILE = ""; -$LEGACY_AMP_DBNAME = "asterisk"; - -# -# Database cdr settings -# - Only need to update these settings if standalone or an older AMP version (pre-FreePBX) is used -# - $ASTERISKCDR_DBFILE only needs to be set if using a database like sqlite -# Options: supported database types (others are supported, but not listed) -# 'mysql' - MySQL -# 'pgsql' - PostgreSQL -# 'oci8' - Oracle -# 'odbc' - ODBC -# -$ASTERISKCDR_DBHOST = "localhost"; -$ASTERISKCDR_DBENGINE = "mysql"; -$ASTERISKCDR_DBFILE = ""; -$ASTERISKCDR_DBNAME = "asteriskcdrdb"; -$ASTERISKCDR_DBTABLE = "cdr"; - -# -# Standalone, for use without AMP -# set use = true; -# set asterisk_mgruser to Asterisk Call Manager username -# set asterisk_mgrpass to Asterisk Call Manager password -# -$STANDALONE['use'] = false; -$STANDALONE['asterisk_mgruser'] = ""; -$STANDALONE['asterisk_mgrpass'] = ""; -$STANDALONE['asteriskcdr_dbuser'] = ""; -$STANDALONE['asteriskcdr_dbpass'] = ""; - -############################### -# authentication settings -############################### -# -# For using the Call Monitor only -# option: 0 - use Authentication, Voicemail, and Call Monitor -# 1 - use only the Call Monitor -# -$ARI_NO_LOGIN = 0; - -# -# Admin only account -# -$ARI_ADMIN_USERNAME = "admin"; -$ARI_ADMIN_PASSWORD ="ari_password"; -# -# Admin extensions -# option: Comma delimited list of extensions -# -$ARI_ADMIN_EXTENSIONS = ""; - -# -# Authentication password to unlock cookie password -# This must be all continuous and only letters and numbers -# -$ARI_CRYPT_PASSWORD = "z1Mc6KRxA7Nw90dGjY5qLXhtrPgJOfeCaUmHvQT3yW8nDsI2VkEpiS4blFoBuZ"; - -############################### -# modules settings -############################### -# -# modules with admin only status (they will not be displayed for regular users) -# option: Comma delimited list of module names (ie voicemail,callmonitor,help,settings) -# -$ARI_ADMIN_MODULES = ""; - -# -# disable modules (you can also just delete them from /recordings/modules without problems) -# option: Comma delimited list of module names (ie voicemail,callmonitor,help,settings) -# -$ARI_DISABLED_MODULES = ""; - -# -# sets the default admin page -# option: Comma delimited list of module names (ie voicemail,callmonitor,help,settings) -# -$ARI_DEFAULT_ADMIN_PAGE = "callmonitor"; - -# -# sets the default user page -# option: Comma delimited list of module names (ie voicemail,callmonitor,help,settings) -# -#$ARI_DEFAULT_USER_PAGE = "voicemail"; -$ARI_DEFAULT_USER_PAGE = "dashboard"; - -# -# enables ajax page refresh -# option: 0 - disable ajax page refresh -# 1 - enable ajax page refresh -# -$AJAX_PAGE_REFRESH_ENABLE = 1; - -# -# sets the default user page -# option: refresh time in 'minutes:seconds' (0 to inifinity) : (0 to 59) -# -$AJAX_PAGE_REFRESH_TIME ="01:00"; -############################### -# voicemail settings -############################### -# -# voicemail config. -# -$ASTERISK_VOICEMAIL_CONF = "/etc/asterisk/voicemail.conf"; - -# -# To set to a specific context. -# If using default or more than one context then leave blank -# -$ASTERISK_VOICEMAIL_CONTEXT = ""; - -# -# Location of asterisk voicemail recordings on server -# Use semi-colon for multiple paths -# -$ASTERISK_VOICEMAIL_PATH = "/var/spool/asterisk/voicemail"; - -# -# valid mailbox folders -# -$ASTERISK_VOICEMAIL_FOLDERS = array(); -$ASTERISK_VOICEMAIL_FOLDERS[0]['folder'] = "INBOX"; -$ASTERISK_VOICEMAIL_FOLDERS[0]['name'] = _("INBOX"); -$ASTERISK_VOICEMAIL_FOLDERS[1]['folder'] = "Family"; -$ASTERISK_VOICEMAIL_FOLDERS[1]['name'] = _("Family"); -$ASTERISK_VOICEMAIL_FOLDERS[2]['folder'] = "Friends"; -$ASTERISK_VOICEMAIL_FOLDERS[2]['name'] = _("Friends"); -$ASTERISK_VOICEMAIL_FOLDERS[3]['folder'] = "Old"; -$ASTERISK_VOICEMAIL_FOLDERS[3]['name'] = _("Old"); -$ASTERISK_VOICEMAIL_FOLDERS[4]['folder'] = "Work"; -$ASTERISK_VOICEMAIL_FOLDERS[4]['name'] = _("Work"); - -############################### -# call monitor settings -############################### -# -# Location of asterisk call monitor recordings on server -# -$ASTERISK_CALLMONITOR_PATH = "/var/spool/asterisk/monitor"; - -# -# Extensions with access to all call monitor recordings -# option: Comma delimited list of extensions or "all" -# -$CALLMONITOR_ADMIN_EXTENSIONS =""; -# -# Allow call monitor users to delete monitored calls -# option: 0 - do not show controls -# 1 - show controls -# -$CALLMONITOR_ALLOW_DELETE = 1; - -# -# Allow for aggressive matching of recording files to database records -# will match recordings that are marked several seconds off -# option: 0 - do not aggressively match -# 1 - aggressively match -# -$CALLMONITOR_AGGRESSIVE_MATCHING = 1; - -# -# Limits log/recording file matching to exact matching -# will not try to look through all the recordings and make a best match -# even if there is not uniqueid -# requires that the MYSQL_UNIQUEID flag be compiled in asterisk-addons -# (in the asterisk-addon Makefile add the following "CFLAGS+=-DMYSQL_LOGUNIQUEID") -# -# * use if there are or will be more than 2500 recording files -# -# option: 0 - do not exact match -# 1 - only exact match -# -$CALLMONITOR_ONLY_EXACT_MATCHING = 0; - -############################### -# conference page settings -############################### -# -# Meetme extension prefix -# for this module to function, the user has to have -# a meetme conference room {prefix}{extension} -# -$CONFERENCE_WEBMEETME_PREFIX = ""; - -# -# url to web meetme conference room -# example: "http://example.mycompany.com/webmeetme" -# -$CONFERENCE_WEBMEETME_URL = ""; - -############################### -# help page settings -############################### -# -# help feature codes -# list of handset options and their function -# -$ARI_HELP_FEATURE_CODES = array(); -//$ARI_HELP_FEATURE_CODES['*411'] = _("Directory"); -//$ARI_HELP_FEATURE_CODES['*43'] = _("Echo Test"); -//$ARI_HELP_FEATURE_CODES['*60'] = _("Time"); -//$ARI_HELP_FEATURE_CODES['*61'] = _("Weather"); -//$ARI_HELP_FEATURE_CODES['*62'] = _("Schedule wakeup call"); -//$ARI_HELP_FEATURE_CODES['*65'] = _("festival test (your extension is XXX)"); -//$ARI_HELP_FEATURE_CODES['*77'] = _("IVR Recording"); -//$ARI_HELP_FEATURE_CODES['*99'] = _("Playback IVR Recording"); -//$ARI_HELP_FEATURE_CODES['666'] = _("Test Fax"); -//$ARI_HELP_FEATURE_CODES['7777'] = _("Simulate incoming call"); - -$ARI_HELP_FEATURE_CODES['*72'] = _("Call Forward All Activate"); -$ARI_HELP_FEATURE_CODES['*73'] = _("Call Forward All Deactivate"); -$ARI_HELP_FEATURE_CODES['*74'] = _("Call Forward All Prompting Deactivate"); -$ARI_HELP_FEATURE_CODES['*90'] = _("Call Forward Busy Activate"); -$ARI_HELP_FEATURE_CODES['*91'] = _("Call Forward Busy Deactivate"); -$ARI_HELP_FEATURE_CODES['*92'] = _("Call Forward Busy Prompting Deactivate"); -$ARI_HELP_FEATURE_CODES['*52'] = _("Call Forward No Answer/Unavailable Activate"); -$ARI_HELP_FEATURE_CODES['*53'] = _("Call Forward No Answer/Unavailable Deactivate"); -$ARI_HELP_FEATURE_CODES['*70'] = _("Call Waiting - Activate"); -$ARI_HELP_FEATURE_CODES['*71'] = _("Call Waiting - Deactivate"); -$ARI_HELP_FEATURE_CODES['*78'] = _("Do-Not-Disturb Activate"); -$ARI_HELP_FEATURE_CODES['*79'] = _("Do-Not-Disturb Deactivate"); -$ARI_HELP_FEATURE_CODES['*97'] = _("My Voicemail"); -$ARI_HELP_FEATURE_CODES['*98'] = _("Dial Voicemail"); - -############################### -# settings page settings -############################### -# -# protocol config. -# config_file options: semi-colon delimited list of extensions -# -$ASTERISK_PROTOCOLS = array(); -$ASTERISK_PROTOCOLS['iax']['table'] = "iax"; -$ASTERISK_PROTOCOLS['iax']['config_files'] = "/etc/asterisk/iax.conf;/etc/asterisk/iax_additional.conf"; -$ASTERISK_PROTOCOLS['sip']['table'] = "sip"; -$ASTERISK_PROTOCOLS['sip']['config_files'] = "/etc/asterisk/sip.conf;/etc/asterisk/sip_additional.conf"; -$ASTERISK_PROTOCOLS['zap']['table'] = "zap"; -$ASTERISK_PROTOCOLS['zap']['config_files'] = "/etc/asterisk/zapata.conf;/etc/asterisk/zapata_additional.conf"; - -# Settings for Follow-Me Select Boxes in seconds -# - -$SETTINGS_PRERING_LOW = 4; -$SETTINGS_PRERING_HIGH = 30; -$SETTINGS_LISTRING_LOW = 6; -$SETTINGS_LISTRING_HIGH = 60; - -$SETTINGS_FOLLOW_ME_LIST_MAX = 5; -$SETTINGS_ALLOW_VMX_SETTINGS = true; -# -# For setting -# option: 0 - do not show controls -# 1 - show controls -# -$SETTINGS_ALLOW_CALLFORWARD_SETTINGS = 1; -$SETTINGS_ALLOW_VOICEMAIL_SETTINGS = 1; -$SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET = 1; - -# -# password length -# setting: number of characters required for changing voicemail password -# -$SETTINGS_VOICEMAIL_PASSWORD_LENGTH = 3; - -# -# password exact length -# option: 0 - do not require exact length when setting the password -# 1 - require exact length when setting the password -# -$SETTINGS_VOICEMAIL_PASSWORD_EXACT = 0; - -# -# voicemail email option descriptions -# -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS = array(); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['attach'] = _("Email voicemail as attachment"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['saycid'] = _("Say caller id in recording emailed"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['envelope'] = _("Say envelop (date/time) in recording emailed"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['delete'] = _("Delete voicemail when emailed"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['nextaftercmd'] = _("Play next message after deleting current message"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['review'] = _("Ask caller to review their voicemail before sending"); -$SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS['maxmessage'] = _("Maximum time in seconds a voicemail will record"); - -# -# Default -# option: ".wav" - wav format -# ".gsm" - gsm format -# -$ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT = ".wav"; - -# -# For setting -# option: 0 - do not show controls -# 1 - show controls -# -$SETTINGS_ALLOW_CALL_RECORDING_SET = 1; - - -$SETTINGS_ALLOW_PHONE_SETTINGS = 1; - - - -?> |