function drawMachines() { $cli = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]); $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct"); $msg = new XML_RPC_Message('listMachines', array($req)); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $machines = $resp->value(); $i = $machines->arraysize(); while ($i--) { $m = XML_RPC_decode($machines->arraymem($i)); echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'>\n <ul class='menu' >\n <li >\n <p onclick='javascript:toggleSpan(\"span{$m}\");' >{$m}<br/><span id='span{$m}'>{$m}\n <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n <input type='submit' value='Save'><br style='clear:both'>\n <a href='setup_machine.php?machine={$m}'><em class='butt'>Setup</em></a>\n <a href='start_manager.php?machine={$m}'><input type='button' value='StartManager'></a><br>\n\n <input id='sName{$m}' type='text' value='SUT_NAME' style='clear:both; float:left; width:25%;'/>\n <input id='sValue{$m}' type='text' value='Value'/><br>"; $params = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string'), "sut_machine" => new XML_RPC_Value($m, 'string')), "struct"); $msg = new XML_RPC_Message('getConfig', array($params)); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $cfgTable = $resp->value(); $j = $cfgTable->arraysize(); while ($j--) { $cfgEntry = $cfgTable->arraymem($j); $cfgEntry->structreset(); $symbol = XML_RPC_decode($cfgEntry->structmem("symbol")); $value = XML_RPC_decode($cfgEntry->structmem("val")); echo "<b>{$symbol}</b>"; echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n"; } echo " </span></p>\n </li> </ul> </form>"; } }
function setMachineConfig($cli) { /* Serialize Machine name */ $versions = array(); $m = $_GET['SUT_MACHINE']; $xuname = new XML_RPC_Value($_SESSION['username'], 'string'); $xmachine = new XML_RPC_Value($m, 'string'); /*--------------------------------------------*/ /* Serialize the content of config +++++++++++*/ foreach ($_POST as $k => $v) { if (preg_match("/SUT_/", $k)) { $cfgLines[] = new XML_RPC_Value("{$k} = '" . stripslashes($v) . "'\n", 'string'); } } $xcfgLines = new XML_RPC_Value($cfgLines, 'array'); /*--------------------------------------------*/ /* Serialize Method parameter ++++++++++++++++*/ $request = new XML_RPC_Value(array("sut_username" => $xuname, "sut_machine" => $xmachine, "cfg_lines" => $xcfgLines), "struct"); $params = array($request); $msg = new XML_RPC_Message('setConfig', $params); /*--------------------------------------------*/ $resp = $cli->send($msg); if (hasErrors($resp)) { return; } }
function drawMachines() { $cli = new XML_RPC_Client('/RPCSERVER', 'localhost', 5000); $msg = new XML_RPC_Message('listMachines'); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $machines = $resp->value(); $i = $machines->arraysize(); #$i = 1; while ($i--) { $m = XML_RPC_decode($machines->arraymem($i)); echo "<form name='{$m}' action='set_config.php?SUT_MACHINE={$m}' method='post'> <ul id='menu'>\n <li ><p>{$m}\n <span id='span{$m}'>\n <a href='javascript:;' onclick='addEvent(\"span{$m}\", \"sName{$m}\", \"sValue{$m}\");'><em class='butt'>Add</em></a>\n <input type='submit' value='Save'>\n\n <input id='sName{$m}' type='text' value='SUT_NAME' style='text-align:right; clear:both; float:left; width:12em;'/>\n <input id='sValue{$m}' type='text' value='Value'/>\n\n\n "; $params = array(new XML_RPC_Value($m, 'string')); $msg = new XML_RPC_Message('getConfig', $params); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $cfgTable = $resp->value(); $j = $cfgTable->arraysize(); while ($j--) { $cfgEntry = $cfgTable->arraymem($j); $cfgEntry->structreset(); $symbol = XML_RPC_decode($cfgEntry->structmem("symbol")); $value = XML_RPC_decode($cfgEntry->structmem("val")); echo "<b>{$symbol}</b>"; echo "<input type='text' name='{$symbol}' value='{$value}' /><br>\n"; } echo "\n\n </span></p>\n </li>\n </ul>\n\n</form>"; } }
function listOSes() { echo "ON Machine:<br>"; $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct"); $msg = new XML_RPC_Message('listMachines', array($req)); $resp = $this->xmlrpc->send($msg); if (hasErrors($resp)) { return false; } $i = $resp->value()->arraysize(); echo "<select name='sut_os[]' multiple size='5'>"; while ($i--) { echo "<option>" . XML_RPC_decode($resp->value()->arraymem($i)) . "</option>"; } echo "</select>"; }
function runTests($cli) { /* Serialize the SUT Versions ++++++++++++++++*/ //print "\nVersions:\n"; $versions = array(); for ($i = 0; $i < count($_GET['sut_versions']); ++$i) { $versions[] = new XML_RPC_Value($_GET['sut_versions'][$i], 'string'); } $xversions = new XML_RPC_Value($versions, "array"); //print "\nBuild:\n ".$_GET['sut_build']."\n"; /*--------------------------------------------*/ /* Serialize the OSes +++++++++++++++++++++++*/ //print "\nOS:\n"; $oses = array(); for ($i = 0; $i < count($_GET['sut_os']); ++$i) { $oses[] = new XML_RPC_Value($_GET['sut_os'][$i], 'string'); } $xoses = new XML_RPC_Value($oses, 'array'); /*--------------------------------------------*/ /* Serialize the TEST categories +++++++++++++*/ //print "\nTests:\n"; $tests = array(); for ($i = 0; $i < count($_GET['sut_tests']); ++$i) { $tests[] = new XML_RPC_Value($_GET['sut_tests'][$i], 'string'); } $xtests = new XML_RPC_Value($tests, "array"); /*--------------------------------------------*/ /* Serialize the userTEST categories +++++++++++++*/ for ($i = 0; $i < count($_GET['sut_usertests']); ++$i) { $tests[] = new XML_RPC_Value($_GET['sut_usertests'][$i], 'string'); } $xtests = new XML_RPC_Value($tests, "array"); /*--------------------------------------------*/ $refresh = "n"; if ($_REQUEST['refresh']) { $refresh = "y"; } /* Serialize Method parameter ++++++++++++++++*/ $request = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION["username"], "string"), "sut_tests" => $xtests, "sut_versions" => $xversions, "sut_os" => $xoses, "sut_build" => new XML_RPC_Value($_GET['sut_build'], 'string'), "sut_refresh" => new XML_RPC_Value($refresh, 'string')), "struct"); $params = array($request); $msg = new XML_RPC_Message('runTests', $params); /*--------------------------------------------*/ $resp = $cli->send($msg); if (hasErrors($resp)) { return; } }
function listTests($cli) { echo "Tests:<br>"; $msg = new XML_RPC_Message('listTests'); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } $val = $resp->value(); $i = $val->arraysize(); echo "<select name='sut_tests[]' multiple size='5'>"; while ($i--) { echo "<option>" . XML_RPC_decode($val->arraymem($i)) . "</option>"; } echo "</select>"; #$data = XML_RPC_decode($val); }
function addMachine($cli) { /* Serialize _POST */ $xuser = new XML_RPC_Value($_SESSION['username'], 'string'); $xmname = new XML_RPC_Value($_POST['SUT_MNAME'], 'string'); $xos = new XML_RPC_Value($_POST['SUT_OS'], 'string'); $xosver = new XML_RPC_Value($_POST['SUT_OSVER'], 'string'); $xmip = new XML_RPC_Value($_POST['SUT_MIP'], 'string'); /* Serialize Method parameter */ $request = new XML_RPC_Value(array("sut_username" => $xuser, "sut_mname" => $xmname, "sut_os" => $xos, "sut_osver" => $xosver, "sut_mip" => $xmip), "struct"); $params = array($request); $msg = new XML_RPC_Message('addMachine', $params); $resp = $cli->send($msg); if (hasErrors($resp)) { return; } }
function parseConfig($basename, $server) { $xmlfile = '/etc/voip/voipconfig.xml'; $xlsfile = dirname(__FILE__) . DIRECTORY_SEPARATOR . $basename; if (!file_exists($xmlfile)) { VOIPXMLConfiguredElement::error("Can't find {$xmlfile}."); } $config = new VOIPConfig(new SimpleXMLElement(file_get_contents($xmlfile))); $config->findRefs(); if (createExcel()) { $objPHPExcel = phpexcel_createPHPExcelObject(); $objPHPExcel->getProperties()->setCreator("freePbxConfig - MEVOIP - {$basename}")->setLastModifiedBy("freePbxConfig - MEVOIP - {$basename}")->setTitle("freePbxConfig - MEVOIP - {$basename}")->setSubject("freePbxConfig - MEVOIP - {$basename}")->setDescription("freePbxConfig - MEVOIP - {$basename}")->setKeywords("freePbxConfig - MEVOIP - {$basename}")->setCategory("freePbxConfig - MEVOIP - {$basename}"); $s = $objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->getActiveSheet()->setTitle('VOIP PABX'); $objPHPExcel->getDefaultStyle()->getFont()->setName('Tahoma'); $objPHPExcel->getDefaultStyle()->getFont()->setSize(8); $config->writeExcel($objPHPExcel); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save($xlsfile . '.xls'); } if (true) { $serdata = array(); $serdata['adLogin'] = $config->getUserArrayByField($config->users, 'adLogin'); $serdata['ext'] = $config->getUserArrayByField($config->users, 'extension'); $serdata['area'] = $config->getUserArrayByField($config->users, 'area', false); $serdata['queues'] = $config->getUserArrayByField($config->queues, 'extension'); $serdata['groups'] = $config->getUserArrayByField($config->ringGroups, 'extension'); $serdata['confs'] = $config->getUserArrayByField($config->confs, 'extension'); $provision = dirname(__FILE__) . DIRECTORY_SEPARATOR . $basename . DIRECTORY_SEPARATOR . $basename . '.dat'; file_put_contents($provision, serialize($serdata)); VOIPXMLConfiguredElement::info("Wrote provisioning info to {$provision}."); } $argv = @$_SERVER['argv']; if (@$argv[1] == "run") { if (!hasErrors()) { VOIPXMLConfiguredElement::info("Previous errors not detected, applying configuration."); $config->applyConfigToFreePBX($server); } else { VOIPXMLConfiguredElement::error("Previous errors detected. STOPPING."); } } else { $config->generateOutboundRulesFile('outbound_rules.conf'); } //print_r($config); }
} ?> <div class="wrap"> <h2>Auto More Tag by <a href="http://travisweston.com/">Travis Weston</a></h2> <?php $options = get_option('tw_auto_more_tag'); if (isset($_GET['settings-updated']) && isset($options['auto_update']) && $options['auto_update'] == true) { $this->updateAll(); } ?> <?php if (hasErrors($options['messages']) || hasNotices($options['messages']) || hasWarnings($options['messages'])) { ?> <div id="auto_more_tags" class="error settings-error"> <?php if (hasErrors($options['messages'])) { ?> <h3>ERRORS:</h3> <?php foreach ($options['messages']['errors'] as $error) { ?> <p style="padding-left: 25px;"><?php echo $error; ?> </p> <?php } $options['messages']['errors'] = array(); } if (hasNotices($options['messages'])) { ?>
function checkRemembered($cookie) { list($username, $cookie) = @unserialize($cookie); if (!$username or !$cookie) { return; } $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($username, 'string'), "sut_cookie" => new XML_RPC_Value($cookie, 'string')), 'struct'); $msg = new XML_RPC_Message('checkRemembered', array($req)); $rsp = $this->xmlrpc->send($msg); if (hasErrors($rsp)) { return; } $this->setSession($rsp, true); }
require_once 'base_lib.php'; session_start(); session_defaults(); # collect information from the post $username = $_POST['username']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $xmlrpc = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]); $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($username, 'string'), "sut_name" => new XML_RPC_Value($name, 'string'), "sut_email" => new XML_RPC_Value($email, 'string'), "sut_password" => new XML_RPC_Value($password, 'string')), "struct"); $msg = new XML_RPC_Message('registerUser', array($req)); $rsp = $xmlrpc->send($msg); ?> <!-- Begin Site --> <html> <head> <LINK href="mystyle.css" rel="stylesheet" type="text/css"> <LINK REL="SHORTCUT ICON" href="seraph.ico"> <title>Register new user</title> </head> <body class='bheader' > <?php drawMenu(); if (hasErrors($rsp) || !XML_RPC_decode($rsp->value())) { echo "I'm sorry but the username you specified has already been taken. Please pick another one."; return 0; } //echo "Returned:".XML_RPC_decode($rsp->value())."<br>"; echo "You have successfully Registered";
<?php require_once 'XML/RPC.php'; require_once 'base_lib.php'; session_start(); $c = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]); $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string')), "struct"); $msg = new XML_RPC_Message('clearRunnedJobs', array($req)); $rsp = $c->send($msg); if (hasErrors($rsp)) { return false; } header('location:index.php');
function netregistry_DeleteNameserver($params) { $username = $params['Username']; $password = $params['Password']; $proxyHost = $params['ProxyHost']; $proxyPort = $params['ProxyPort']; $tld = $params['tld']; $sld = $params['sld']; $nameserver = $params['nameserver']; $values = array(); try { $client = getSOAPClient($username, $password, $proxyHost, $proxyPort); $result = $client->deleteHost(array("domain" => "" . $sld . "." . $tld, "hostName" => $nameserver)); if (hasErrors($result)) { logError(getErrorString($result)); $values['error'] = getErrorString($result); } } catch (SoapFault $fault) { logError($fault); $values->error .= $fault; } return $values; }
function listJobs($job_type) { $xmlrpc = new XML_RPC_Client('/RPCSERVER', $_SESSION["host"], $_SESSION["port"]); echo "<button onClick=\"window.location='clear_logs.php'\" style='margin-left:15px'>Clear Logs</button><br/>"; echo "List of Jobs:(click to open errorlog)<br>"; echo "<div class='job_running'>"; echo "<span class='id'>Id</span>"; echo "<span >Job State</span>"; echo "<span class='name'>Machine</span>"; echo "<span >Start date</span>"; echo "<span >Start time</span>"; echo "Progress"; echo "</div>"; /*-------------------------------------------*/ $state = "job_running"; $req = new XML_RPC_Value(array("sut_username" => new XML_RPC_Value($_SESSION['username'], 'string'), "job_type" => new XML_RPC_Value($job_type, 'int')), "struct"); $msg = new XML_RPC_Message('listJobs', array($req)); $resp = $xmlrpc->send($msg); if (hasErrors($resp)) { return false; } $i = $resp->value()->arraysize(); while ($i--) { $log = $resp->value()->arraymem($i); $date = XML_RPC_decode($log->structmem("job_date")); $time = XML_RPC_decode($log->structmem("job_time")); $name = XML_RPC_decode($log->structmem("job_name")); $ctest = XML_RPC_decode($log->structmem("job_ctest")); $tests = XML_RPC_decode($log->structmem("job_tests")); if ($tests == 0) { $tests = 1; } $pct = 4 + 100 * (int) $ctest / ((int) $tests * 6); echo "<a style='text-decoration:none' href='view.php?log={$name}'>"; echo "<div class='{$state}'>"; echo "<span class='id'>1000</span>"; echo "<span>{$state}</span>"; echo "<span class='name'>{$name}</span>"; echo "<span>{$date}</span>"; echo "<span>{$time}</span>"; echo "<span class='bar' style='margin:0.5em; height: 15px; width: {$pct}%;'> </span>"; echo "{$ctest} of {$tests}"; echo "</div>"; echo "</a>"; } /*---------------------------------------------*/ /* while($i++<3) { echo "<div class='job_running_ok'>"; echo "<a href='http://google.com'>"; echo "<span>1000</span>"; echo "<span><b >Running</b></span>"; echo "<span>".XML_RPC_decode($resp->value()->arraymem($i)) ."</span>"; echo "</a>"; echo "</div>"; } while($i++<6) { echo "<div class='job_pending'>"; echo "<a href='http://google.com'>"; echo "<span>1000</span>"; echo "<span><b >Pending</b></span>"; echo "<span>".XML_RPC_decode($resp->value()->arraymem($i)) ."</span>"; echo "</a>"; echo "</div>"; }*/ }
<?php } else { ?> <tr> <td> </td> </tr> <?php } ?> </table> <br /> </td> <td id="body"> <?php if (hasErrors()) { ?> <div id="errorBox"> The following errors occured: <ul> <?php $errors = getErrors(); $warnings = getWarnings(); $allErrors = array_merge($errors, $warnings); foreach ($allErrors as $error) { ?> <li><?php echo $error->getMessage(); ?> </li> <?php
public function applyConfigToFreePBX($server) { $mysql = new mysqli("{$server}", "freepbxConfig", "ast123", "asterisk"); if (mysqli_connect_errno()) { $this->error("Connect to mysql failed: " . mysqli_connect_error()); exit; } $astman = new AGI_AsteriskManager(); if (!($res = $astman->connect($server . ":" . "5038", 'freepbxConfig', 'ast123', 'off'))) { $this->error("Erro conectando astman!"); exit; } $this->config = $this; $this->mysql = $mysql; $this->astman = $astman; $this->getVoiceMailCurrentInfo(); $this->info("Configuring basic settings..."); $this->config->queryExec("REPLACE INTO admin (variable, value) VALUES ('email', '*****@*****.**')"); $this->config->queryExec("REPLACE INTO admin (variable, value) VALUES ('need_reload', 'true')"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('nat', 'yes', 39, 0)"); if ($this->externalIpType == "dynamic") { $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('nat_mode', 'externhost', 10, 0)"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('externhost_val', '{$this->externalIp}', 40, 0)"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('externrefresh', '120', 41, 0)"); } else { $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('nat_mode', 'externip', 10, 0)"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('externip_val', '{$this->externalIp}', 40, 0)"); } $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('localnet_0', '{$this->localNet}', 42, 0)"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('netmask_0', '{$this->localNetMask}', 0, 0)"); $this->config->queryExec("REPLACE INTO sipsettings (keyword, data, seq, type) VALUES ('sip_language', 'pt_BR', 0, 0)"); $this->config->queryExec("REPLACE INTO iaxsettings (keyword, data, seq, type) VALUES ('iax_language', 'pt_BR', 0, 0)"); $this->info("Clearing/deleting old settings from most FreePBX tables..."); $this->config->queryExec("DELETE from devices"); $this->config->queryExec("DELETE from users"); $this->config->queryExec("DELETE from fax_users"); $this->config->queryExec("DELETE from fax_incoming"); $this->config->queryExec("DELETE from queues_config"); $this->config->queryExec("DELETE from queues_details"); $this->config->queryExec("DELETE from ringgroups"); $this->config->queryExec("DELETE from incoming"); $this->config->queryExec("DELETE FROM cidlookup_incoming"); $this->config->queryExec("DELETE from outbound_routes"); $this->config->queryExec("DELETE from outbound_route_patterns"); $this->config->queryExec("DELETE from outbound_route_sequence"); $this->config->queryExec("DELETE from outbound_route_trunks"); $this->config->queryExec("DELETE from meetme"); $this->config->queryExec("DELETE from trunks"); $this->config->queryExec("DELETE from trunk_dialpatterns"); $this->config->queryExec("DELETE from sip"); // For users and trunks? $this->config->queryExec("DELETE from iax"); // For users and trunks? $this->config->queryExec("DELETE from zapchandids"); $this->applyConfigToFreePBXArray($this->users, 'users'); $this->applyConfigToFreePBXArray($this->queues, 'queues'); $this->applyConfigToFreePBXArray($this->ringGroups, 'ringgroups'); $this->applyConfigToFreePBXArray($this->confs, 'conferences'); $this->applyConfigToFreePBXArray($this->trunks, 'trunks'); $this->applyConfigToFreePBXArray($this->outRoutes, 'outbound routes'); $this->applyConfigToFreePBXArray($this->inRoutes, 'inbound routes'); $this->applyConfigToFreePBXArray($this->channelMaps, 'channel maps'); $this->applyConfigToFreePBXArray($this->sounds, 'sounds'); $this->config->queryExec("DELETE from ivr where ivr_id > 1"); $this->config->queryExec("DELETE from ivr_dests"); $this->config->queryExec("DELETE from recordings where id > 1"); $this->config->queryExec("DELETE from announcement"); $this->config->queryExec("DELETE from miscapps"); $this->config->queryExec("DELETE from featurecodes where modulename = 'miscapps'"); $this->applyConfigToFreePBXArray($this->recordings, 'recordings'); $this->applyConfigToFreePBXArray($this->uras, 'uras'); $this->applyConfigToFreePBXArray($this->announces, 'announces'); $this->applyConfigToFreePBXArray($this->miscapps, 'miscapps'); $this->doVoiceMailConfig(); $this->generateOutboundRulesFile(); if (!hasErrors()) { $this->warn("Reloading FreePBX Config (orange bar) automatically..."); $command = "/var/lib/asterisk/bin/module_admin reload"; $result = trim(`{$command}`); if ($result == "Successfully reloaded") { $this->info("FreePBX successfully reloaded! :-) ", false); $this->sayOK(); echo "\n"; } else { $this->error("Error reloading FreePBX: {$result}"); } } }