function &plugin($name) { if (pluginExists($name)) { return $this->plugins[$name]; } else { return _null(); } }
public function getStatistics() { global $sessionId; $data = array("total" => 0, "bymonth" => array()); $masterTable = new table('master'); $master = $masterTable->loadById($sessionId); $permittedCities = $master['city']; $permittedStreets = $master['street']; $permittedGroups = $master['usergroup']; foreach ($this->getCoveredMonths() as $month) { $monthAsText = $month->format('Y-m'); $cacheFilename = 'paymentstats-' . $monthAsText; if (pluginExists('grouprestrict') && $permittedGroups) { $cacheFilename .= '-group(' . join($permittedGroups, '_') . ')'; } $cacheFilename .= '.txt'; $cache = new StatisticsCache($cacheFilename); $cache->month = $month; $monthData = json_decode($cache->get(), true); $data['total'] += $monthData['total']; $data['bymonth'][$monthAsText] = $monthData; } return $data; }
jBlog.initPageParams({ current:'<?php echo $this->getArchiveType(); ?> ', respondId:'<?php $this->respondId(); ?> ', title:'<?php $this->archiveTitle(array('category' => _t('分类:%s'), 'search' => _t('搜索:%s'), 'tag' => _t('标签:%s'), 'author' => _t('%s 发布的文章')), '', ' - '); $this->options->title(); ?> ', }); <?php if (pluginExists('TeComment')) { ?> TeCmt.init(); <?php } ?> <?php echo getAntiSpam($this); ?> </script> <?php if ($this->options->siteStat) { $this->options->siteStat(); } }
if ($user->isEnabled()) { if (configgetvalue('system', 'ucp', NULL, 'showMoneyflow')) { $menu['moneyflow.php'] = array(__('Moneyflow'), 0); } if (pluginExists('scratchcard')) { $menu['paywithcard.php'] = array(__('Fund by card'), 0); } } } if (configgetvalue('system', 'ucp', NULL, 'showTariffs')) { $menu['tariffs.php'] = array(__('Tariffs'), 0); } if (configgetvalue('system', 'ucp', NULL, 'showDocuments')) { $menu['documents.php'] = array(__('Documents'), 0); } if ($user->isValid() && pluginExists('message')) { if ($user->isEnabled()) { $messageText = __('Messages'); $messageTable = new table('message'); $request = "WHERE `recipient`=" . $user->getId() . " AND `recipient_is_admin`=0 AND `is_new`=1"; $newMessages = $messageTable->load($request); $newMessagesCount = count($newMessages); if ($newMessagesCount) { $messageText .= ' <span id="messages-count">' . $newMessagesCount . '</span>'; } $menu['message.php'] = array($messageText, 0); } } $menu['contacts.php'] = array(__('Contacts'), 0); $scriptName = substr($_SERVER['SCRIPT_NAME'], 1); if (isset($menu[$scriptName])) {
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(); } }
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); }
function getLocalImageThumbnail($url, $size) { $options = Typecho_Widget::widget('Widget_Options'); $siteUrl = $options->siteUrl; if (is_null($size) || !pluginExists('Jianshu')) { return Typecho_Common::url($url, $siteUrl); } $index = $options->index; $imageApi = Typecho_Common::url('/action/tools', $index); $s = $size[0] . 'x' . $size[1]; return $imageApi . "?do=image&url={$url}&s={$s}"; }
} ?> <?php if ($this->is('archive')) { ?> <li class="active"> <a href="javascript:jBlog.goTop();"><?php _e($this->getArchiveTitle()); ?> </a> </li> <?php } ?> <?php if (pluginExists('Jianshu')) { ?> <li><a href="javascript:jBlog.ajaxGetExplore();" title="<?php _e('随机显示一篇文章'); ?> "><?php _e('探索'); ?> </a></li> <?php } ?> <li class="page-search"> <form id="search" method="post" action="./" role="search"> <label for="s" class="sr-only"><?php _e('搜索关键字');
<div class="main-inner"> <article class="post" itemscope itemtype="http://schema.org/BlogPosting"> <div class="post-header"> <h2 class="post-title"><?php $this->title(); ?> </h2> </div> <div class="post-content markdown-body" itemprop="articleBody"> <?php $this->content(); ?> <ul class="tag-list flinks"> <?php if (pluginExists('Links')) { ?> <?php Links_Plugin::output(null, 0, ''); ?> <?php } ?> </ul> </div> </article> <?php $this->need('comments.php'); ?> </div><!-- end #main-->
if (strlen($filterQuery)) { $filterQuery .= " AND "; } $filterQuery .= " ("; for ($i = 0; $i < count($permittedGroups); $i++) { $filterQuery .= "`usergroup`=" . $permittedGroups[$i]; if ($i !== count($permittedGroups) - 1) { $filterQuery .= " OR "; } } $filterQuery .= ")"; } } } else { if ($target === 'order') { if (pluginExists('grouprestrict')) { if (count($permittedGroups)) { if (strlen($filterQuery)) { $filterQuery .= " AND "; } $filterQuery .= " `user` IN ( SELECT `id` FROM `" . DB_TABLE_PREFIX . "user` WHERE `usergroup` IN (" . join($permittedGroups, ",") . "))"; } } } } if (strlen($filterQuery)) { $filterQuery = "WHERE " . $filterQuery; } $table->load4AJAX($filterQuery); if ($filter === '*') { $response->length = count($response->data);
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(); } } }
} } } 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'));