Example #1
0
$options = getopt("", array("db-prefix:"));
if (isset($options['db-prefix'])) {
    define('DB_TABLE_PREFIX', $options['db-prefix']);
    echo "DB prefix: " . $options['db-prefix'];
}
require_once realpath(__DIR__ . "/../include/core.php");
$currentDay = intval(date('j'));
// Create withdrawal date
$withdrawalDay = configgetvalue('system', 'cash', NULL, 'withdrawalDay');
$withdrawalDate = new DateTime('first day of this month midnight');
$withdrawalDate->modify(intval($withdrawalDay) - 1 . ' days');
// Create notifications start date
$notificationsOffset = configgetvalue('system', 'cash', NULL, 'notificationsOffset');
$notificationsStartDate = clone $withdrawalDate;
$notificationsStartDate->modify(-$notificationsOffset . ' days');
// Crete notifications end date
$notificationsDuration = configgetvalue('system', 'cash', NULL, 'notificationsDuration');
$notificationsEndDate = clone $notificationsStartDate;
$notificationsEndDate->modify($notificationsDuration . ' days');
// Show notifications
if (configgetvalue('system', 'cash', NULL, 'showNotifications') && intval($notificationsStartDate->format('j')) === $currentDay) {
    echo "Show notifications...";
    payment(1);
} else {
    if (intval($notificationsEndDate->format('j')) === $currentDay) {
        echo "Hide notifications...";
        payment(2);
    }
}
echo "Withdrawal...";
payment(0);
Example #2
0
 if ($withdrawalDay) {
     $startDate->modify("+{$withdrawalDay} day");
     $endDate->modify("+{$withdrawalDay} day");
 }
 if ($currentDate < $startDate) {
     $startDate->modify("-1 month");
     $endDate->modify("-1 month");
 }
 $currency = configgetvalue('system', 'main', NULL, 'currency');
 $tariffPrice = smoneyf($user->calculateTariffPrice());
 $formattedTariffPrice = sprintf(_ngettext("%s {$currency}", "%s {$currency}", $tariffPrice), $tariffPrice);
 $fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
 if (isset($_POST['code'])) {
     $paySum = $sc->pay($_POST['code'], $user->getId());
     if ($paySum) {
         $currency = configgetvalue('system', 'main', NULL, 'currency');
         $formattedFundSum = sprintf(ngettext("%s {$currency}", "%s {$currency}", $paySum), $paySum);
         $tpl = array("formattedFundSum" => $formattedFundSum);
         $fenom->display($theme->getTemplateLocation('goodcard.tpl'), $tpl);
     } else {
         $fenom->display($theme->getTemplateLocation('badcard.tpl'));
     }
 } else {
     $currentTariff = getCurrentTariff($user->getId());
     $selectedTariff = $user->getSelectedTariff();
     if (!$currentTariff && $selectedTariff) {
         $fenom->display($theme->getTemplateLocation('notification.tpl'), array("className" => "tip", "errorText" => sprintf(__('After updating service "%s" from %s to %s will be automatically paid for %s.'), $selectedTariff['name'], $currentDate->format($dateFormat), $endDate->format($dateFormat), sprintf(_ngettext("%s {$currency}", "%s {$currency}", $tariffPrice), $tariffPrice))));
     }
     $fenom->display($theme->getTemplateLocation('paywithcard.tpl'));
 }
 $fenom->display($theme->getTemplateLocation('footer.tpl'));
Example #3
0
 public function update($userid)
 {
     if ($this->connected) {
         $resource = $this->checkConnection();
         $majorVersion = intval($resource['version'][0]);
         $usersTable = new table('user');
         $usersRes = $usersTable->load(" WHERE id={$userid}");
         if (!$usersRes) {
             return;
         }
         foreach ($usersRes as $devuserrow) {
             $syncData = array("/ip/firewall/address-list" => array(), "/queue/simple" => array(), "/ppp/secret" => array());
             $userId = '' . $devuserrow['id'];
             $useraddr = json_decode($devuserrow['iplist'], true);
             //	Address list section
             $currentTariff = getCurrentTariff($devuserrow['id'], $usersTable);
             if ($currentTariff) {
                 $currentTariff = $currentTariff['detailsid'];
             }
             if (empty($useraddr) || $useraddr == NULL) {
                 return true;
             }
             $ipList = array();
             foreach ($useraddr as $ip => $mac) {
                 $ipList[] = $ip;
             }
             if (userIsDisabled($userid, $usersTable)) {
                 $addrlist = 'disabled';
             } else {
                 $addrlist = $currentTariff ? 'allow' : 'deny';
             }
             if (count($ipList) === 2) {
                 $syncData["/ip/firewall/address-list"][$userId][] = array("list" => $addrlist, "address" => $ipList[1]);
             }
             //	Queque section
             if ($currentTariff) {
                 $tariffTable = new table('tariff');
                 $utariffres = $tariffTable->load("WHERE id={$currentTariff}");
                 $utariffrow = $utariffres[0];
                 if ($utariffrow) {
                     // Select right target addresses index
                     if ($majorVersion === 5) {
                         $addressIndex = 'target-addresses';
                     } else {
                         $addressIndex = 'target';
                     }
                     // Normal / day
                     if (pluginExists('night') && ($utariffrow['nightupspeed'] || $utariffrow['nightdownspeed'])) {
                         $dayTime = $this->calculateMikrotikTime(configgetvalue('system', 'tariff', NULL, 'nightHourEnd'));
                         $dayTime .= '-1d';
                         //$dayTime .= '-'.$this->calculateMikrotikTime ( configgetvalue('system', 'tariff', NULL, 'nightHourStart') );
                         $dayTime .= ',sun,mon,tue,wed,thu,fri,sat';
                     } else {
                         $dayTime = '0s-1d,sun,mon,tue,wed,thu,fri,sat';
                     }
                     // Burst
                     if (pluginExists('burst') && ($utariffrow['downburstlimit'] && $utariffrow['upburstlimit'] && $utariffrow['downburstthreshold'] && $utariffrow['upburstthreshold'] && $utariffrow['downbursttime'] && $utariffrow['upbursttime'])) {
                         $burstLimit = $utariffrow['upburstlimit'] . '/' . $utariffrow['downburstlimit'];
                         $burstThreshold = $utariffrow['upburstthreshold'] . '/' . $utariffrow['downburstthreshold'];
                         $burstTime = $utariffrow['upbursttime'] . '/' . $utariffrow['downbursttime'];
                     } else {
                         $burstLimit = "0/0";
                         $burstThreshold = "0/0";
                         $burstTime = "0s/0s";
                     }
                     $useraddr = json_decode($devuserrow['iplist'], true);
                     $responce = $this->API->comm('/queue/simple/print', array('?name' => $userid));
                     $ipList = array();
                     foreach ($useraddr as $ip => $mac) {
                         $ipList[] = $ip . "/32";
                     }
                     if (count($ipList) === 2) {
                         $syncData["/queue/simple"][$userId][] = array("limit-at" => $utariffrow['upspeed'] . "/" . $utariffrow['downspeed'], "max-limit" => $utariffrow['upspeed'] . "/" . $utariffrow['downspeed'], $addressIndex => $ipList[1], "name" => $userId, "time" => $dayTime, "burst-limit" => $burstLimit, "burst-threshold" => $burstThreshold, "burst-time" => $burstTime);
                     }
                     // Night
                     $responce = $this->API->comm('/queue/simple/print', array('?name' => "{$userid}-night"));
                     if (pluginExists('night') && ($utariffrow['nightupspeed'] || $utariffrow['nightdownspeed'])) {
                         $useraddr = json_decode($devuserrow['iplist'], true);
                         $ipList = array();
                         foreach ($useraddr as $ip => $mac) {
                             $ipList[] = $ip . "/32";
                         }
                         //$time  = $this->calculateMikrotikTime ( configgetvalue('system', 'tariff', NULL, 'nightHourStart') );
                         $time = '0s';
                         $time .= '-' . $this->calculateMikrotikTime(configgetvalue('system', 'tariff', NULL, 'nightHourEnd'));
                         $time .= ',sun,mon,tue,wed,thu,fri,sat';
                         if (count($ipList) == 2) {
                             $syncData["/queue/simple"][$userId][] = array("limit-at" => $utariffrow['nightupspeed'] . "/" . $utariffrow['nightdownspeed'], "max-limit" => $utariffrow['nightupspeed'] . "/" . $utariffrow['nightdownspeed'], $addressIndex => $ipList[1], "name" => $userId . '-night', "time" => $time, "burst-limit" => $burstLimit, "burst-threshold" => $burstThreshold, "burst-time" => $burstTime);
                         }
                     } else {
                         if (count($responce)) {
                             $this->API->comm("/queue/simple/remove", array(".id" => $responce[0]['.id']));
                         }
                     }
                 }
             }
             //	PPP section
             //
             $useraddr = json_decode($devuserrow['iplist'], true);
             $response = $this->API->comm('/ppp/secret/print', array('?comment' => $userid));
             $ipList = array();
             $disableSecretsForDisabledUsers = configgetvalue('router', 'ppp', $this->id, 'disablePPPSecretsOfBlockedUsers');
             $disabledState = $devuserrow['disabled'] == '1' && $disableSecretsForDisabledUsers ? 'yes' : 'no';
             foreach ($useraddr as $ip => $mac) {
                 $ipList[] = $ip;
             }
             if (count($ipList) === 2) {
                 $syncData["/ppp/secret"][$userId][] = array("service" => "any", "profile" => "default", "local-address" => $ipList[0], "remote-address" => $ipList[1], "disabled" => $disabledState, "name" => $devuserrow['login'], "password" => $devuserrow['password']);
             }
         }
         $this->sync($syncData);
         return $this->checkConnection();
     }
 }
Example #4
0
 function getFormattedCashToPay()
 {
     $currency = configgetvalue('system', 'main', NULL, 'currency');
     $cashToPay = $this->getCashToPay();
     return sprintf(_ngettext("%s {$currency}", "%s {$currency}", $cashToPay), $cashToPay);
 }
Example #5
0
            redirect("/login.php?userisrestricted=true");
        } else {
            $page = 'info';
            $selectedTariff = $user->getSelectedTariff();
            $currentTariff = $user->getCurrentTariff();
            $currentOrder = getCurrentTariff($user->getId());
            if ($currentOrder) {
                if ($user->getField('credit') || $currentOrder['temp'] == 1) {
                    $state = __('Is on loan');
                } else {
                    $state = __('Enabled');
                }
            } else {
                $state = __('Disabled');
            }
            $discount = $user->getDiscount();
            $permittedActions = array();
            if (configgetvalue('system', 'ucp', NULL, 'permitTariffChange') && configgetvalue('subscriber', 'main', $user->getId(), 'permitTariffChange')) {
                $permittedActions['changetariff'] = true;
            }
            if (configgetvalue('system', 'ucp', NULL, 'permitPasswordChange') && configgetvalue('subscriber', 'main', $user->getId(), 'permitPasswordChange') && $user->getField('login')) {
                $permittedActions['changepassword'] = true;
            }
            $tariffIsChanging = $currentOrder && intval($currentOrder['detailsid']) !== intval($user->getField('tariff'));
            $tpl = array("username" => $userName, "state" => $state, "permittedActions" => $permittedActions, "currentOrder" => $currentOrder, "currentTariff" => $currentTariff, "selectedTariff" => $selectedTariff, "tariffIsChanging" => $tariffIsChanging, "user" => $user);
            $fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
            $fenom->display($theme->getTemplateLocation('info.tpl'), $tpl);
            $fenom->display($theme->getTemplateLocation('footer.tpl'));
        }
    }
}
Example #6
0
             } else {
                 $url = "";
             }
             redirect($url);
         } else {
             //l('auth', 'badlogin', NULL, NULL, NULL, array('ip'=>$_SERVER['REMOTE_ADDR'], 'login' => $login, 'password' => $password));
             redirect("/login.php?wrongloginpassword=true");
             die;
         }
     } else {
         if (isset($_POST["byip"]) && $_POST["byip"] == 'true') {
             $ipUser = new User($ipRequest);
             if ($ipUser->isValid()) {
                 $_SESSION['id'] = $ipUser->getId();
             }
             if (configgetvalue('system', 'ucp', NULL, 'restrictUsersLoggedByIP')) {
                 $user->isRestricted = true;
                 $_SESSION['is_restricted'] = true;
             }
             if (isset($_SESSION['url'])) {
                 $url = $_SESSION['url'];
             } else {
                 $url = "";
             }
             redirect($url);
         }
     }
     break;
 case 'logout':
     $_SESSION['id'] = 0;
     unset($_SESSION['is_restricted']);
Example #7
0
<?php

include_once '../include/ucp.php';
$mainPageText = configgetvalue('system', 'ucp', NULL, 'mainPageText');
$mainPageText = preg_replace('%\\n%', '<br>', $mainPageText);
$tpl = array("mainPageText" => $mainPageText);
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
$fenom->display($theme->getTemplateLocation('index.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));
Example #8
0
 public function getData()
 {
     global $mysqlTimeDateFormat, $sessionId;
     $data = array("total" => 0, "scratchcard" => 0, "adminpay" => array("total" => 0, "byadmin" => array()));
     $masterTable = new table('master');
     $master = $masterTable->loadById($sessionId);
     $permittedCities = $master['city'];
     $permittedStreets = $master['street'];
     $permittedGroups = $master['usergroup'];
     $admins = $masterTable->load();
     for ($i = 0; $i < count($admins); $i++) {
         $data['adminpay']['byadmin'][$admins[$i]['id']] = 0;
     }
     $currentTime = new DateTime();
     $moneyflowTable = new table('moneyflow');
     $startDate = clone $this->month;
     $endDate = clone $this->month;
     $endDate->modify('1 month');
     $endDate->modify('-1 second');
     $offsetDays = configgetvalue('system', 'statistics', null, 'paymentsOffset');
     $startDate->modify($offsetDays . ' day');
     $endDate->modify($offsetDays . ' day');
     $condition = "WHERE `date`>='" . $startDate->format($mysqlTimeDateFormat) . "' AND `date`<='" . $endDate->format($mysqlTimeDateFormat) . "' AND (`detailsname`='adminpay' OR `detailsname`='scratchcard') AND `sum`>0";
     if (pluginExists('grouprestrict') && $permittedGroups) {
         $condition .= " AND ( `user` IN (SELECT `id` FROM `user` WHERE `usergroup` IN (" . join($permittedGroups, ",") . ") ) )";
     }
     $rows = $moneyflowTable->load($condition);
     foreach ($rows as $row) {
         $sum = $row['sum'];
         $data['total'] += $sum;
         if ($row['detailsname'] === 'adminpay') {
             $data['adminpay']['total'] += $sum;
             if (!isset($data['adminpay']['byadmin'][$row['detailsid']])) {
                 $data['adminpay']['byadmin'][$row['detailsid']] = 0;
             }
             $data['adminpay']['byadmin'][$row['detailsid']] += $sum;
         } else {
             $data['scratchcard'] += $sum;
         }
     }
     $lastRow = end($rows);
     configsetvalue('var', 'cache', null, 'int', $this->fileName, $lastRow['id']);
     return json_encode($data);
 }
Example #9
0
<?php

include_once '../include/ucp.php';
$companyContacts = configgetvalue('system', 'ucp', NULL, 'contactsPageText');
$companyContacts = preg_replace('%\\n%', '<br>', $companyContacts);
$tpl = array("contactsText" => $companyContacts);
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
$fenom->display($theme->getTemplateLocation('contacts.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));
Example #10
0
    <link rel="stylesheet" type="text/css" href="<?php 
    echo $usertheme;
    ?>
/style-desktop.css" />
<?php 
} else {
    ?>
    <link rel="stylesheet" type="text/css" href="<?php 
    echo $usertheme;
    ?>
/style.css" />
<?php 
}
?>
    <link rel="gettext" type="application/x-po" href="loadplugin.php?target=locale&name=<?php 
echo configgetvalue('system', 'main', NULL, 'acpLocale');
?>
&type=po" />
    <script>
      var pluginsLoaders=[];
      var debug=<?php 
if (defined('DEBUG')) {
    echo 'true';
} else {
    echo 'false';
}
?>
;
      var userId=<?php 
if (isset($sessionId) && $sessionId) {
    echo $sessionId;
Example #11
0
     $master = $masterTable->loadById($sessionId);
     $userGroupId = $master['group'];
     $groupTable = new table('group');
     $group = $groupTable->loadById($userGroupId);
     $userAcl = json_decode($group['acl'], true);
     $response = $userAcl;
     break;
 case 'getstatimage':
     if (checkPermission($sessionId, array('statistics'))) {
         $routerId = $_GET['router'];
         $path = str_replace(' ', '%20', $_GET['path']);
         $routerTable = new table('router');
         $res = $routerTable->load("WHERE id={$routerId}");
         if ($row = $res[0]) {
             $address = $row['ip'];
             $port = configgetvalue('router', 'main', $routerId, 'statPort');
             $url = "http://{$address}:{$port}/{$path}.gif";
             header("Content-Type:image/gif");
             $img = file_get_contents($url);
             header("Content-Length:" . strlen($img));
             echo $img;
         }
     }
     return;
     break;
 case 'configedit':
     //function configedit($response, $type, $path, $ownerid, $name, $value)
     $type = $_GET['type'];
     if (checkPermission($sessionId, array('preference', $type)) || $type === 'user') {
         switch ($type) {
             case 'system':
Example #12
0
<?php

include_once '../include/ucp.php';
$documents = configgetvalue('system', 'ucp', NULL, 'documents');
for ($i = 0; $i < count($documents); $i++) {
    if (!isset($documents[$i]['fileName']) || !isset($documents[$i]['name'])) {
        array_splice($documents, $i, 1);
    } else {
        $documents[$i]['ext'] = pathinfo('../ucp/upload/' . $documents[$i]['fileName'], PATHINFO_EXTENSION);
        if (isset($documents[$i]['forceDownload']) && $documents[$i]['forceDownload']) {
            $documents[$i]['linkText'] = __("Download");
        } else {
            $documents[$i]['linkText'] = __("View");
        }
    }
}
$tpl = array("documents" => $documents);
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
$fenom->display($theme->getTemplateLocation('documents.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));
Example #13
0
 public function update($userid)
 {
     if ($this->connected) {
         $resource = $this->checkConnection();
         $majorVersion = intval($resource['version'][0]);
         $usersTable = new table('user');
         $usersRes = $usersTable->load(" WHERE id={$userid}");
         if (!$usersRes) {
             return;
         }
         $syncData = array("/ip/firewall/address-list" => array(), "/ip/firewall/filter" => array(), "/ip/firewall/mangle" => array(), "/ip/arp" => array(), "/queue/simple" => array(), "/ip/dhcp-server/lease" => array());
         foreach ($usersRes as $devuserrow) {
             $userId = '' . $devuserrow['id'];
             foreach ($syncData as $key => $value) {
                 $syncData[$key][$userId] = array();
             }
             $useraddr = json_decode($devuserrow['iplist'], true);
             //	Address list section
             foreach ($useraddr as $ip => $mac) {
                 if (strlen($mac)) {
                     $mac = strtoupper($mac);
                     $useraddr[$ip] = preg_replace('/..(?!$)/', '$0:', strtoupper($mac));
                 }
             }
             $currentTariff = getCurrentTariff($devuserrow['id'], $usersTable);
             if ($currentTariff) {
                 $currentTariff = $currentTariff['detailsid'];
             }
             if (empty($useraddr) || $useraddr == NULL) {
                 return true;
             }
             if (userIsDisabled($devuserrow['id'], $usersTable)) {
                 $addrlist = 'disabled';
             } else {
                 $addrlist = $currentTariff ? 'allow' : 'deny';
             }
             foreach ($useraddr as $key => $value) {
                 $syncData["/ip/firewall/address-list"][$userId][] = array("list" => $addrlist, "address" => $key);
             }
             //	MAC-filter	section
             $macFilterType = configgetvalue('router', 'main', $this->id, 'filterType');
             switch ($macFilterType) {
                 case 1:
                     $inInterface = configgetvalue('router', 'main', $this->id, 'inInterface');
                     foreach ($useraddr as $ip => $mac) {
                         if (strlen($mac)) {
                             $syncData["/ip/arp"][$userId][] = array("mac-address" => $mac, "address" => $ip, "interface" => $inInterface);
                         }
                     }
                     break;
                 case 2:
                     foreach ($useraddr as $ip => $mac) {
                         if (strlen($mac)) {
                             $syncData["/ip/firewall/filter"][$userId][] = array("list" => $addrlist, "address" => $key, "action" => "drop", "chain" => "forward", "src-mac-address" => "!" . $mac, "src-address" => $ip);
                         }
                     }
                     break;
                 case 3:
                     foreach ($useraddr as $ip => $mac) {
                         if (strlen($mac)) {
                             $syncData["/ip/firewall/mangle"][$userId][] = array("action" => "mark-connection", "new-connection-mark" => "badmac", "chain" => "prerouting", "src-mac-address" => "!" . $mac, "src-address" => $ip);
                         }
                     }
                     break;
             }
             //	Queque section
             //
             if ($currentTariff) {
                 $tariffTable = new table('tariff');
                 $utariffres = $tariffTable->load("WHERE id={$currentTariff}");
                 $utariffrow = $utariffres[0];
                 if ($utariffrow) {
                     // Normal / day
                     if (pluginExists('night') && ($utariffrow['nightupspeed'] || $utariffrow['nightdownspeed'])) {
                         $dayTime = $this->calculateMikrotikTime(configgetvalue('system', 'tariff', NULL, 'nightHourEnd'));
                         $dayTime .= '-1d';
                         //$dayTime .= '-'.$this->calculateMikrotikTime ( configgetvalue('system', 'tariff', NULL, 'nightHourStart') );
                         $dayTime .= ',sun,mon,tue,wed,thu,fri,sat';
                     } else {
                         $dayTime = '0s-1d,sun,mon,tue,wed,thu,fri,sat';
                     }
                     // Burst
                     if (pluginExists('burst') && $utariffrow['downburstlimit'] && $utariffrow['upburstlimit'] && $utariffrow['downburstthreshold'] && $utariffrow['upburstthreshold'] && $utariffrow['downbursttime'] && $utariffrow['upbursttime']) {
                         $burstLimit = $utariffrow['upburstlimit'] . '/' . $utariffrow['downburstlimit'];
                         $burstThreshold = $utariffrow['upburstthreshold'] . '/' . $utariffrow['downburstthreshold'];
                         $burstTime = $utariffrow['upbursttime'] . '/' . $utariffrow['downbursttime'];
                     } else {
                         $burstLimit = "0/0";
                         $burstThreshold = "0/0";
                         $burstTime = "0s/0s";
                     }
                     // Speed
                     $speed = $utariffrow['upspeed'] . "/" . $utariffrow['downspeed'];
                     $useraddr = json_decode($devuserrow['iplist'], true);
                     $responce = $this->API->comm('/queue/simple/print', array('?name' => $userid));
                     //$addresslist=explode(',', $responce[0]['target-addresses']);
                     $ipList = array();
                     foreach ($useraddr as $ip => $mac) {
                         $ipList[] = $ip . "/32";
                     }
                     // Select right target addresses index
                     if ($majorVersion === 5) {
                         $addressIndex = 'target-addresses';
                     } else {
                         $addressIndex = 'target';
                     }
                     $dbadrr = implode(',', $ipList);
                     if (count($useraddr)) {
                         $syncData["/queue/simple"][$userId][] = array("limit-at" => $utariffrow['upspeed'] . "/" . $utariffrow['downspeed'], "max-limit" => $utariffrow['upspeed'] . "/" . $utariffrow['downspeed'], $addressIndex => $dbadrr, "name" => $userId, "time" => $dayTime, "burst-limit" => $burstLimit, "burst-threshold" => $burstThreshold, "burst-time" => $burstTime);
                     }
                     // Night
                     $responce = $this->API->comm('/queue/simple/print', array('?name' => "{$userid}-night"));
                     if (pluginExists('night') && ($utariffrow['nightupspeed'] || $utariffrow['nightdownspeed'])) {
                         $nightSpeed = $utariffrow['nightupspeed'] . "/" . $utariffrow['nightdownspeed'];
                         $useraddr = json_decode($devuserrow['iplist'], true);
                         $ipList = array();
                         foreach ($useraddr as $ip => $mac) {
                             $ipList[] = $ip . "/32";
                         }
                         $dbadrr = implode(',', $ipList);
                         //$time  = $this->calculateMikrotikTime ( configgetvalue('system', 'tariff', NULL, 'nightHourStart') );
                         $time = '0s';
                         $time .= '-' . $this->calculateMikrotikTime(configgetvalue('system', 'tariff', NULL, 'nightHourEnd'));
                         $time .= ',sun,mon,tue,wed,thu,fri,sat';
                         if (count($useraddr)) {
                             $syncData["/queue/simple"][$userId][] = array("limit-at" => $nightSpeed, "max-limit" => $nightSpeed, $addressIndex => $dbadrr, "name" => $userId . '-night', "time" => $time, "burst-limit" => $burstLimit, "burst-threshold" => $burstThreshold, "burst-time" => $burstTime);
                         }
                     }
                 }
             }
             //	DHCP section
             $useraddr = json_decode($devuserrow['iplist'], true);
             foreach ($useraddr as $key => $value) {
                 if ($useraddr[$key]) {
                     $useraddr[$key] = preg_replace('/..(?!$)/', '$0:', strtoupper($value));
                 }
             }
             foreach ($useraddr as $ip => $mac) {
                 if (strlen($mac)) {
                     $syncData["/ip/dhcp-server/lease"][$userId][] = array("address" => $ip, "mac-address" => $mac);
                 }
             }
             $this->sync($syncData);
             return $this->checkConnection();
         }
     }
 }
Example #14
0
        }
    }
} else {
    foreach ($tariffs as $tariff) {
        if ($tariff['public'] == '1') {
            $tariffCities = $tariff['city'];
            $tariffCopy = $tariff;
            foreach ($speedRows as $row) {
                $tariffCopy[$row] = formatSpeed($tariffCopy[$row]);
            }
            $tariffCopy['price'] = formatCash($tariffCopy['price']);
            $tariffsByCities[0][] = $tariffCopy;
        }
    }
}
function sortByPrice($a, $b)
{
    global $tariffsById;
    return $tariffsById[$b['id']]['price'] < $tariffsById[$a['id']]['price'];
    //return $b['price'] < $a['price'];
}
foreach ($tariffsByCities as $city => $tariffsByCity) {
    uasort($tariffsByCities[$city], substr("sortByPrice(", 0, -1));
}
$tpl = array("nameText" => __('Name'), "downloadSpeedText" => __('Download speed'), "uploadSpeedText" => __('Upload speed'), "nightDownloadSpeedText" => __('Night download speed'), "nightUploadSpeedText" => __('Night upload speed'), "priceText" => __("Price"), "citiesById" => $citiesById, "tariffsByCities" => $tariffsByCities);
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
if (pluginExists('night')) {
    $fenom->display($theme->getTemplateLocation('notification.tpl'), array("className" => "tip", "errorText" => sprintf(__("Night rates are valid from %s to %s"), configgetvalue('system', 'tariff', NULL, 'nightHourStart'), configgetvalue('system', 'tariff', NULL, 'nightHourEnd'))));
}
$fenom->display($theme->getTemplateLocation('tariffs.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));
Example #15
0
<?php

include_once '../include/ucp.php';
$page = 'login';
if (configgetvalue('system', 'ucp', NULL, 'IPautoLogin')) {
    $ipUser = new User($ipRequest);
    $ipIsFound = $ipUser->isValid();
} else {
    $ipIsFound = false;
}
$tpl = array("ipIsFound" => $ipIsFound, "userIsRestricted" => isset($_GET['userisrestricted']) && $_GET['userisrestricted'] === 'true');
$fenom->display($theme->getTemplateLocation('header.tpl'), $headerData);
if (isset($_GET['wrongloginpassword'])) {
    $fenom->display($theme->getTemplateLocation('notification.tpl'), array("className" => "error", "errorText" => __("Wrong login or password. Please try again…")));
} else {
    if (isset($_GET['userisrestricted'])) {
        $fenom->display($theme->getTemplateLocation('notification.tpl'), array("className" => "error", "errorText" => __("You are logged in in automatic mode. Please enter your login and password to unlock all opportunities.")));
    }
}
$fenom->display($theme->getTemplateLocation('login.tpl'), $tpl);
$fenom->display($theme->getTemplateLocation('footer.tpl'));