public function PerformAction(&$form)
 {
     $dbg_elem = new DbgElem();
     $dbhandle = $form->a2billing->DBHandle();
     if ($form->FG_DEBUG > 0) {
         array_unshift($form->pre_elems, $dbg_elem);
     }
     $dbg_elem->content .= print_r($_POST, true) . "\n";
     $fil = $_FILES[$form->prefix . 'the_file'];
     if (!isset($fil)) {
         $form->pre_elems[] = new ErrorElem(_("File has not been posted at all!"));
         $form->setAction('ask-import');
         return;
     }
     switch ($fil['error']) {
         case UPLOAD_ERR_OK:
             $dbg_elem->content .= "File uploaded OK.\n";
             break;
         case UPLOAD_ERR_INI_SIZE:
             $form->pre_elems[] = new ErrorElem(str_params(_("File size exceeds %1 limit of the system!"), array(123), 1));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_FORM_SIZE:
             $form->pre_elems[] = new ErrorElem(str_params(_("File size exceeds %1 limit for this action!"), array(123), 1));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_PARTIAL:
             $form->pre_elems[] = new ErrorElem(_("The uploaded file was only partially uploaded."));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_NO_FILE:
             $form->pre_elems[] = new ErrorElem(_("No file was uploaded."));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_NO_TMP_DIR:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Missing a temporary folder. \n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_CANT_WRITE:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Failed to write file to disk.\n";
             $form->setAction('ask-import');
             return;
         default:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Unknown error:" . $fil['error'] . "\n";
             $form->setAction('ask-import');
             return;
     }
     if (isset($this->allowed_mimetypes) && !in_array($fil['type'], $this->allowed_mimetypes)) {
         $form->pre_elems[] = new ErrorElem(str_params(_("Cannot accept file of type %1. Allowed types are: %2."), array($fil['type'], implode(', ', $this->allowed_mimetypes)), 1));
         $dbg_elem->content .= "Cannot accept file type \n";
         $form->setAction('ask-import');
         return;
     }
     //Now, check the given fields
     $this->fields = $this->askImport->mandatory;
     if ($this->askImport->csvmode) {
         $optionals = explode(':', $form->getpost_dirty('search_sources'));
         foreach ($optionals as $opt) {
             if (!empty($opt)) {
                 if (!in_array($opt, $this->askImport->optional)) {
                     $form->pre_elems[] = new ErrorElem(_("Error in submitted form."));
                     $dbg_elem->content .= "You tried to pass {$opt} as a field.\n";
                     $form->setAction('ask-import');
                     return;
                 } else {
                     $this->fields[] = $opt;
                 }
             }
         }
     }
     $tmpdir = DynConf::GetCfg('global', 'upload_tmpdir', '/tmp');
     $tmpname = str_replace('/', '-', basename($fil['name']));
     $tmpname = tempnam($tmpdir, $tmpname);
     if ($tmpname === false) {
         $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
         $dbg_elem->content .= "Cannot make temp file in {$tmpdir} \n";
         $form->setAction('ask-import');
         return;
     }
     if (move_uploaded_file($fil['tmp_name'], $tmpname)) {
         $dbg_elem->content .= "moved  \"" . $fil['tmp_name'] . "\" to \"" . $tmpname . "\"\n";
         $this->movedFile = $tmpname;
     } else {
         $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
         $dbg_elem->content .= "Cannot move uploaded file to temporary. \n";
         $form->setAction('ask-import');
         return;
     }
     // 		$dbg_elem->content .="copying data from  \"".$fil['tmp_name'] ."\" to \"". $tmpname ."\"\n";
     // 		$this->tmpFile = @fopen($fil['tmp_name'],'rb');
     // 		if ($this->tmpFile === false){
     // 			$form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
     // 			$dbg_elem->content .="Cannot open uploaded file. \n";
     // 			$form->setAction('ask-import');
     // 			return;
     // 		}
     //
     // 		$this->copyFile = fopen($tmpname,'w');
     // 		if ($this->copyFile === false){
     // 			$form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
     // 			$dbg_elem->content .="Cannot open copy file. \n";
     // 			$form->setAction('ask-import');
     // 			return;
     // 		}
 }
Example #2
0
    $safe_base = "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    header("Location: {$safe_base}");
    exit;
}
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Form/Class.SqlActionForm.inc.php";
$HD_Form = new SqlActionForm();
$HD_Form->checkRights(1);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$HD_Form->model[] = new TextField(_("First Name"), 'firstname');
$HD_Form->model[] = new TextField(_("Last Name"), 'lastname');
$HD_Form->model[] = new TextField(_("E-mail"), 'email');
$HD_Form->model[] = new TextField(_("Address"), 'address');
$HD_Form->model[] = new TextField(_("City"), 'city');
$HD_Form->model[] = new TextField(_("State"), 'state');
$HD_Form->model[] = new TextField(_("Country"), 'country');
$HD_Form->model[] = new TextField(_("Postal code"), 'zipcode');
// language
// captcha
/* The signup->mail actions are defined here, into this ugly query, so that
   one different signup "mode" could call those SQL functions differently and
   alter this logic */
$HD_Form->QueryString = 'SELECT create_mail( \'' . DynConf::GetCfg(SIGNUP_CFG, 'mail_template', 'signup') . '\',' . 'email, \'' . getenv('LANG') . "', replace(replace(" . "'firstname=' || firstname || '&lastname=' || lastname || '&loginkey=' || loginkey ||" . "'&username='******'&userpass='******' ','%%20'), E'\\n','%%0A') ) AS mailid " . ", email" . " FROM gen_card_signup(" . DynConf::GetCfg(SIGNUP_CFG, 'card_group', '0', true) . ', ' . DynConf::GetCfg(SIGNUP_CFG, 'voip_group', 'NULL') . ', %firstname, %lastname, %email, %address, %city, %state, %country, %zipcode, %lang);';
//'SELECT gen_cards(%#grp, %ser, %#num, %startn, %#ucfg) AS ncards;';
$HD_Form->expectRows = true;
$HD_Form->submitString = _("Sign up!");
$HD_Form->successString = '';
//$HD_Form->contentString = 'Generated:<br>';
$HD_Form->rowString = _("Thank you for signing up.<br>An email has been sent to %email for confirmation!<br>");
require "PP_page.inc.php";
Example #3
0
function login($user, $pass)
{
    global $FG_DEBUG;
    $DBHandle = A2Billing::DBHandle();
    $user = trim($user);
    $pass = trim($pass);
    if (strlen($user) == 0 || strlen($user) >= 50 || strlen($pass) == 0 || strlen($pass) >= 50) {
        return false;
    }
    $nameclause = "";
    if (DynConf::GetCfg(CUSTOMER_CFG, 'username_login', true)) {
        $nameclause = "username = %1";
    }
    if (DynConf::GetCfg(CUSTOMER_CFG, 'useralias_login', false)) {
        if (!empty($nameclause)) {
            $nameclause .= ' OR ';
        }
        $nameclause .= "useralias = %1";
    }
    if (DynConf::GetCfg(CUSTOMER_CFG, 'email_login', false)) {
        if (!empty($nameclause)) {
            $nameclause .= ' OR ';
        }
        $nameclause .= "email = %1";
    }
    if (($cgrp = DynConf::GetCfg(CUSTOMER_CFG, 'cardgroup_only', null)) != null) {
        $group_clause = ' AND grp = %#3';
    }
    $QUERY = str_dbparams($DBHandle, "SELECT id, username, status, currency, grp, language\n\t\t FROM cc_card WHERE ({$nameclause}) AND userpass = %2 {$group_clause} ;", array($user, $pass, $cgrp));
    $res = $DBHandle->Execute($QUERY);
    if (!$res) {
        $errstr = $DBHandle->ErrorMsg();
        if ($FG_DEBUG) {
            echo $errstr . "<br>\n";
        }
        return 4;
    }
    if ($res->EOF) {
        // no such user!
        if ($FG_DEBUG > 1) {
            echo "Query: {$QUERY} <br>";
        }
        return 1;
    }
    $row = $res->fetchRow();
    if ($row['status'] != 1) {
        return 0 - intval($row['status']);
    }
    //     if( ACTIVATEDBYUSER==1 && $row [0][7] != "t" && $row [0][7] != "1" ) {
    // 		return -2;
    // 	}
    return $row;
}
Example #4
0
 function RenderContent()
 {
     echo '<div class="content">' . "\n";
     if (isset($this->contentString)) {
         echo $this->contentString;
     }
     if (isset($this->sip_qryres)) {
         // now, process SIP conf files..
         $cur_srv = null;
         echo _("Generating sip_xx.conf files.<br>");
         $confdir = DynConf::GetCfg('global', 'peer_dir', '/var/tmp');
         $fd = null;
         while ($row = $this->sip_qryres->fetchRow()) {
             if ($cur_srv != $row['srvid']) {
                 $srvhost = str_replace(' ', '_', strtolower($row['srv_host']));
                 $cur_srv = $row['srvid'];
                 echo "<br>\n";
                 // for previous line
                 $filename = "{$confdir}/sip_{$srvhost}.conf";
                 echo "Trying: {$filename}: ";
                 $fd = fopen($filename, "wb");
                 if (!$fd) {
                     echo "<font style='color: red'>" . _("Could not open buddy file") . "</font><br>\n";
                     continue;
                 }
                 if (fwrite($fd, "; Additional peers for host " . $row['srv_host'] . "\n\n") === false) {
                     echo "<font style='color: red'>" . _("Cannot write to file!") . "</font><br>\n";
                     continue;
                     fclose($fd);
                     //abandon writing
                     $fd = null;
                 }
             } elseif (!$fd) {
                 continue;
             }
             if (!isset($row['name'])) {
                 continue;
             }
             fwrite($fd, "\n[" . $row['name'] . "]\n");
             if ($this->FG_DEBUG > 2) {
                 echo "<br>" . htmlspecialchars("[" . $row['name'] . "]") . "<br>\n";
             }
             foreach ($row as $key => $val) {
                 if (in_array($key, array('srvid', 'srv_host', 'name', 'realtime_id'))) {
                     continue;
                 }
                 if (empty($val)) {
                     continue;
                 }
                 fwrite($fd, "{$key}={$val}\n");
                 if ($this->FG_DEBUG > 2) {
                     echo htmlspecialchars("{$key}={$val}") . "<br>\n";
                 }
             }
         }
         echo _("Success!") . "<br>\n";
         if ($this->FG_DEBUG > 2) {
             echo "<br>";
         }
         if ($fd) {
             fclose($fd);
         }
     }
     if (isset($this->afterContentString)) {
         echo $this->afterContentString;
     }
     echo '</div>' . "\n";
 }
<?php

require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Class.HelpElem.inc.php";
/*require_once (DIR_COMMON."Form/Class.RevRef.inc.php");*/
require_once DIR_COMMON . "Form/Class.TimeField.inc.php";
require_once DIR_COMMON . "Form/Class.SqlRefField.inc.php";
require_once DIR_COMMON . "Provi/Class.ProvisionActionForm.inc.php";
$menu_section = 'menu_sipiax';
if (!DynConf::GetCfg(CUSTOMER_CFG, 'menu_sipiax', true)) {
    exit;
}
HelpElem::DoHelp(_("Here you can get example settings you can use in your devices. Select the kind of device (phone) you have and settings will appear."), 'phone.png');
$pr_list = array();
$pr_list[] = array("0", _("Asterisk sip friend"), 'ast-ini', 'sip-peer');
$pr_list[] = array("1", _("Asterisk iax friend"), 'ast-ini', 'iax-peer');
$HD_Form = new ProvisionActionForm();
$HD_Form->checkRights(ACX_ACCESS);
$HD_Form->init($pr_list);
$HD_Form->setArg('cardid', $_SESSION['card_id']);
$PAGE_ELEMS[] =& $HD_Form;
require "PP_page.inc.php";
Example #6
0
<?php

require_once "lib/defines.php";
require_once "lib/module.access.php";
$cfg = DynConf::instance();
?>
<script language="JavaScript">
<!--
var mywin
var prevdiv="dummydiv"
function imgidclick(imgID,divID)
{

	var agt=navigator.userAgent.toLowerCase();
    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	
	
	if (is_ie){			
		if 	(document.all(divID).style.display == "none" )
		{		
			document.all(divID).style.display="";
Example #7
0
 function RenderContent()
 {
     echo '<div class="content">' . "\n";
     if (isset($this->contentString)) {
         echo $this->contentString;
     }
     if (isset($this->qryres)) {
         // now, process SIP conf files..
         $cur_srv = null;
         $cur_nplan = null;
         echo _("Generating extension_xx.ael files.<br>");
         $confdir = DynConf::GetCfg('global', 'peer_dir', '/var/tmp');
         $dialparms = DynConf::GetCfg('peerconf', 'dialparams', '|60|iRl(3600000)');
         $fd = null;
         while ($row = $this->qryres->fetchRow()) {
             if ($cur_srv != $row['srvid']) {
                 $srvhost = str_replace(' ', '_', strtolower($row['srv_host']));
                 $cur_srv = $row['srvid'];
                 echo "<br>\n";
                 // for previous line
                 $filename = "{$confdir}/extensions_{$srvhost}.ael";
                 echo "Trying: {$filename}: ";
                 $fd = fopen($filename, "wb");
                 if (!$fd) {
                     echo "<font style='color: red'>" . _("Could not open buddy file") . "</font><br>\n";
                     continue;
                 }
                 if (fwrite($fd, "// Additional ael extensions for host " . $row['srv_host'] . "\n\n") === false) {
                     echo "<font style='color: red'>" . _("Cannot write to file!") . "</font><br>\n";
                     continue;
                     fclose($fd);
                     //abandon writing
                     $fd = null;
                 }
             } elseif (!$fd) {
                 continue;
             }
             if (!isset($row['useralias'])) {
                 continue;
             }
             if ($cur_nplan != $row['nplan']) {
                 if (!empty($cur_nplan)) {
                     $line = "};\n\n";
                     if ($this->FG_DEBUG > 2) {
                         echo nl2br(htmlspecialchars($line));
                     }
                     fwrite($fd, $line);
                 }
                 $cur_nplan = $row['nplan'];
                 $line = "context dial-nplan-{$cur_nplan} {\n";
                 if (!empty($row['npname'])) {
                     $line .= "\t\t//Dial peers of numplan " . $row['npname'] . "\n";
                 }
                 if ($this->FG_DEBUG > 2) {
                     echo nl2br(htmlspecialchars($line));
                 }
                 fwrite($fd, $line);
             }
             $line = "\t" . $row['useralias'] . " => Dial(";
             if ($row['sipiax'] == 1) {
                 $line .= "SIP";
             } elseif ($row['sipiax'] == 2) {
                 $line .= "IAX2";
             } else {
                 if ($this->FG_DEBUG) {
                     echo "Unknown sipiax " . $row['sipiax'] . "!<br>\n";
                 }
                 continue;
             }
             $line .= "/" . $row['peername'] . $dialparms . ");\n";
             if ($this->FG_DEBUG > 2) {
                 echo nl2br(htmlspecialchars($line));
             }
             fwrite($fd, $line);
         }
         if (!empty($cur_nplan)) {
             $line = "};\n\n";
             if ($this->FG_DEBUG > 2) {
                 echo nl2br(htmlspecialchars($line));
             }
             fwrite($fd, $line);
         }
         echo _("Success!") . "<br>\n";
         if ($this->FG_DEBUG > 2) {
             echo "<br>";
         }
         if ($fd) {
             fclose($fd);
         }
     }
     if (isset($this->afterContentString)) {
         echo $this->afterContentString;
     }
     echo '</div>' . "\n";
 }
Example #8
0
<?php

require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Class.HelpElem.inc.php";
require_once DIR_COMMON . "Form/Class.RevRef.inc.php";
require_once DIR_COMMON . "Form/Class.TimeField.inc.php";
require_once DIR_COMMON . "Form/Class.SqlRefField.inc.php";
require_once DIR_COMMON . "Form/Class.RevRefForm.inc.php";
require_once DIR_COMMON . "Form/Class.TextSearchField.inc.php";
require_once DIR_COMMON . "Form/Class.ClauseField.inc.php";
require_once DIR_COMMON . "Form/Class.SelectionForm.inc.php";
if (!DynConf::GetCfg(CUSTOMER_CFG, 'menu_cdr', true)) {
    exit;
}
$SEL_Form = new SelectionForm();
$SEL_Form->init();
$SEL_Form->model[] = new DateTimeField(_("Period from"), 'date_from');
end($SEL_Form->model)->does_add = false;
end($SEL_Form->model)->def_date = '00:00 last month';
end($SEL_Form->model)->fieldexpr = 'starttime';
$SEL_Form->model[] = new DateTimeField(_("Period to"), 'date_to');
end($SEL_Form->model)->does_add = false;
end($SEL_Form->model)->def_date = 'now';
end($SEL_Form->model)->fieldexpr = 'starttime';
/*$SEL_Form->model[] = new SqlRefFieldN(_("Agent"),'agentid','cc_agent','id','name');
	end($SEL_Form->model)->does_add = false;*/
$SEL_Form->search_exprs['date_from'] = '>=';
$SEL_Form->search_exprs['date_to'] = '<=';
$SEL_Form->model[] = new TextSearchField(_("Destination"), 'destination');
Example #9
0
    require_once 'Class.Logger.php';
    $loog = new Logger();
    $loog->insertLog(0, 1, "TEST", "test entry!", 'aa', 'bb', 'cc');
}
if (false) {
    require_once 'Class.DynConf.php';
    $inst = DynConf::instance();
    $inst->PrefetchGroup('general');
    $inst->dbg_print_cached_config();
    DynConf::instance()->dbg_print_cached_config();
    $val = DynConf::GetCfg('general', 'test', 123);
    print_r($val);
    echo "\n";
    print_r(DynConf::GetCfg('general', 'test2'));
    echo "\n";
    print_r(DynConf::GetCfg('general', 'test'));
    echo "\n";
}
function isnumeric($v)
{
    //return (preg_match('/^\-?[0-9]+$/',$v)>=1);
    return preg_match('/^\\-?[0-9]+([,.][0-9]*)?$/', $v) >= 1;
}
if (false) {
    $examples = array('1', '500', '', 'ab123', '20 1234', '-100', '12-3', '--600', '9823748716249876194652', '1.0', '500,2', '', 'ab,123', '20, 1234', '-100.0', '12.3', '-600.', '98.23748716249876194652');
    foreach ($examples as $ex) {
        echo "Example \"{$ex}\" -> ";
        print_r(isnumeric($ex));
        echo "\n";
    }
}
Example #10
0
require_once "lib/defines.php";
require_once "lib/module.access.php";
// session_name("UISIGNUP");
// session_start();
if (!isset($_SESSION["date_activation"]) || time() - $_SESSION["date_activation"] > 10) {
    $_SESSION["date_activation"] = time();
} else {
    //echo "Act:". time()." - ". $_SESSION["date_activation"] ."\n";
    sleep(7);
    echo gettext("Sorry the activation has been sent already, please wait 1 minute before making any other try !");
    exit;
}
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Form/Class.SqlActionForm.inc.php";
$HD_Form = new SqlActionForm();
$HD_Form->checkRights(1);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$HD_Form->model[] = new TextField(_("User Name"), 'username');
$HD_Form->model[] = new TextField(_("Activation key"), 'loginkey');
/* The signup->mail actions are defined here, into this ugly query, so that
   one different signup "mode" could call those SQL functions differently and
   alter this logic */
$HD_Form->QueryString = 'SELECT create_mail( \'' . DynConf::GetCfg(SIGNUP_CFG, 'mail_act_template', 'signup-activated') . '\',' . 'email, \'' . getenv('LANG') . "', replace(replace(" . "'firstname=' || firstname || '&lastname=' || lastname ||" . "'&username='******'&userpass='******' ','%%20'), E'\\n','%%0A') ) AS mailid, card.* " . " FROM card_signup_activate(" . DynConf::GetCfg(SIGNUP_CFG, 'card_group', '0', true) . ', ' . '%username, %loginkey) AS card;';
//'SELECT gen_cards(%#grp, %ser, %#num, %startn, %#ucfg) AS ncards;';
$HD_Form->expectRows = true;
$HD_Form->submitString = _("Activate!");
$HD_Form->successString = '';
//$HD_Form->contentString = 'Generated:<br>';
$HD_Form->rowString = _("Thank you for signing up.<br>An email has been sent to %email with details about using our services!<br>");
require "PP_page.inc.php";
Example #11
0
<?php

require_once "./lib/defines.php";
require_once "./lib/module.access.php";
require_once DIR_COMMON . "Form.inc.php";
require_once DIR_COMMON . "Form/Class.SqlActionForm.inc.php";
require_once DIR_COMMON . "Class.HelpElem.inc.php";
/*require_once (DIR_COMMON."Form/Class.RevRef.inc.php");*/
require_once DIR_COMMON . "Form/Class.TimeField.inc.php";
require_once DIR_COMMON . "Form/Class.SqlRefField.inc.php";
$menu_section = 'menu_simulator';
if (!DynConf::GetCfg(CUSTOMER_CFG, 'menu_simulator', true)) {
    exit;
}
HelpElem::DoHelp(_("Here you can simulate a phone call and see how much it would cost"), 'vcard.png');
$HD_Form = new SqlTableActionForm();
$HD_Form->checkRights(ACX_ACCESS);
$HD_Form->init();
$PAGE_ELEMS[] =& $HD_Form;
$HD_Form->model[] = new TextField(_("Dial"), 'dialstring', _("The number you wish to dial."));
$HD_Form->QueryString = str_dbparams(A2Billing::DBHandle(), 'SELECT re.*, %%dialstring AS init_dial, cc_sellrate.rateinitial,
	format_currency(sell_calc_fwd(INTERVAL \'5 min\', cc_sellrate.*)/5.0, %3) AS rate5min
	FROM (SELECT * FROM RateEngine3((SELECT tariffgroup FROM cc_card_group WHERE id = %#1), ' . '%%dialstring, (SELECT numplan FROM cc_card_group WHERE id = %#1), now(), 
		(SELECT credit FROM cc_card WHERE id = %#2)) LIMIT 1) AS re, cc_sellrate
		WHERE cc_sellrate.id = re.srid ;', array($_SESSION['card_grp'], $_SESSION['card_id'], $_SESSION['currency']));
$HD_Form->expectRows = true;
$HD_Form->submitString = _("Calculate!");
$HD_Form->successString = '';
$HD_Form->noRowsString = _("No rates/destinations found!");
//$HD_Form->contentString = 'Generated:<br>';
$HD_Form->rmodel[] = new TextField(_('Dial'), 'init_dial');
 public function PerformAction(&$form)
 {
     $dbg_elem = new DbgElem();
     $dbhandle = $form->a2billing->DBHandle();
     if (!isset($this->importEngine)) {
         $this->importEngine = new $this->impEngClass();
         $this->importEngine->Init(array_merge($this->impEngArgs, array('db' => $dbhandle)));
     }
     if ($form->FG_DEBUG > 0) {
         array_unshift($form->pre_elems, $dbg_elem);
     }
     if ($form->FG_DEBUG > 2) {
         $dbg_elem->content .= print_r($_POST, true) . "\n";
     }
     $fil = $_FILES[$form->prefix . 'the_file'];
     if (!isset($fil)) {
         $form->pre_elems[] = new ErrorElem(_("File has not been posted at all!"));
         $form->setAction('ask-import');
         return;
     }
     switch ($fil['error']) {
         case UPLOAD_ERR_OK:
             $dbg_elem->content .= "File uploaded OK.\n";
             break;
         case UPLOAD_ERR_INI_SIZE:
             $form->pre_elems[] = new ErrorElem(str_params(_("File size exceeds %1 limit of the system!"), array(123), 1));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_FORM_SIZE:
             $form->pre_elems[] = new ErrorElem(str_params(_("File size exceeds %1 limit for this action!"), array(123), 1));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_PARTIAL:
             $form->pre_elems[] = new ErrorElem(_("The uploaded file was only partially uploaded."));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_NO_FILE:
             $form->pre_elems[] = new ErrorElem(_("No file was uploaded."));
             $dbg_elem->content .= "Error!\n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_NO_TMP_DIR:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Missing a temporary folder. \n";
             $form->setAction('ask-import');
             return;
         case UPLOAD_ERR_CANT_WRITE:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Failed to write file to disk.\n";
             $form->setAction('ask-import');
             return;
         default:
             $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
             $dbg_elem->content .= "Unknown error:" . $fil['error'] . "\n";
             $form->setAction('ask-import');
             return;
     }
     $allowed_mimetypes = $this->importEngine->getMimeTypes();
     if (!in_array($fil['type'], $allowed_mimetypes)) {
         $form->pre_elems[] = new ErrorElem(str_params(_("Cannot accept file of type %1. Allowed types are: %2."), array($fil['type'], implode(', ', $allowed_mimetypes)), 1));
         $dbg_elem->content .= "Cannot accept file type \n";
         $form->setAction('ask-import');
         return;
     }
     //Now, check the given fields
     $tmpdir = DynConf::GetCfg('global', 'upload_tmpdir', '/tmp');
     $tmpname = str_replace('/', '-', basename($fil['name']));
     $tmpname = tempnam($tmpdir, $tmpname);
     if ($tmpname === false) {
         $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
         $dbg_elem->content .= "Cannot make temp file in {$tmpdir} \n";
         $form->setAction('ask-import');
         return;
     }
     if (move_uploaded_file($fil['tmp_name'], $tmpname)) {
         $dbg_elem->content .= "moved  \"" . $fil['tmp_name'] . "\" to \"" . $tmpname . "\"\n";
         $this->movedFile = $tmpname;
     } else {
         $form->pre_elems[] = new ErrorElem(_("Internal error, could not upload."));
         $dbg_elem->content .= "Cannot move uploaded file to temporary. \n";
         $form->setAction('ask-import');
         return;
     }
 }
Example #13
0
<?php

/* file module.access.php
	
	Module access - an access control module for back office areas


If you're using $_SESSION , make sure you aren't using session_register() too.
From the manual.
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().
*/
require_once DIR_COMMON . "Class.A2Billing.inc.php";
require_once DIR_COMMON . 'Class.DynConf.inc.php';
require_once DIR_COMMON . 'Misc.inc.php';
error_reporting(E_ALL & ~E_NOTICE);
if (!DynConf::GetCfg(CUSTOMER_CFG, 'enable', true)) {
    @syslog(LOG_ERR, "Somebody tried to access Customer UI on " . $_SERVER['PHP_SELF'] . " but you have this disabled.");
    Header("HTTP/1.0 401 Unauthorized");
    exit;
}
define("MODULE_ACCESS_DOMAIN", "CallingCard System");
define("MODULE_ACCESS_DENIED", "./Access_denied.htm");
define("ACX_ACCESS", 1);
header("Expires: Sat, Jan 01 2000 01:01:01 GMT");
session_name("UICSESSION");
session_start();
if (isset($_GET["logout"]) && $_GET["logout"] == "true") {
    session_destroy();
    $cus_rights = 0;
    Header("HTTP/1.0 401 Unauthorized");
    Header("Location: index.php");
Example #14
0
<?php

require_once DIR_COMMON . "Class.A2Billing.inc.php";
require_once DIR_COMMON . 'Class.DynConf.inc.php';
error_reporting(E_ALL & ~E_NOTICE);
if (!DynConf::GetCfg(SIGNUP_CFG, 'enable', false)) {
    @syslog(LOG_ERR, "Somebody tried to access Signup on " . $_SERVER['PHP_SELF'] . " but you don't have this enabled.");
    Header("HTTP/1.0 401 Unauthorized");
    exit;
}
header("Expires: Sat, Jan 01 2000 01:01:01 GMT");
if (!isset($_SESSION)) {
    session_name("UISIGNUP");
    session_start();
}
function has_rights($condition)
{
    return $condition == 1;
}
function session_readonly()
{
    return false;
}
require_once DIR_COMMON . "languageSettings.inc.php";
if (isset($_GET['language'])) {
    if ($FG_DEBUG > 0) {
        echo "<!-- lang explicitly set to " . $_GET['language'] . "-->\n";
    }
    $_SESSION["language"] = $_GET['language'];
} else {
    if (!isset($_SESSION["language"])) {
Example #15
0
if ($argc > 1 && $argv[1] == '--test') {
    AGI::verbose_s("Testing mode!", 0);
    define('DEFAULT_CONFIG', "../a2billing.conf");
    array_shift($argv);
    $argc--;
} else {
    define('DEFAULT_CONFIG', '/etc/a2billing.conf');
}
require_once 'Class.A2Billing.inc.php';
// create the objects
$a2b = A2Billing::instance();
if (!$a2b->load_res_dbsettings('/etc/asterisk/res_pgsql.conf')) {
    @syslog(LOG_ERR, "Cannot fetch settings from res_pgsql.conf");
    exit(2);
}
$dynconf = DynConf::instance();
if ($argc > 1 && is_numeric($argv[1]) && $argv[1] >= 0) {
    $idconfig = $argv[1];
} else {
    $idconfig = 1;
}
try {
    $dynconf->init();
    $dynconf->PrefetchGroup('agiconf' . $idconfig);
} catch (Exception $ex) {
    error_log($ex->getMessage());
    @syslog(LOG_ERR, "Cannot Fetch config!");
    @syslog(LOG_ERR, $ex->getMessage());
    exit;
}
if ($verbose_mode) {