public function pay($code, $userId) { if (preg_match("/^\\d{" . $this->codeLength . "}\$/", $code)) { $usersTable = new table('user'); $cardmatch = $this->table->load("WHERE activated=0 AND code='{$code}'"); $usermatch = $usersTable->load("WHERE id={$userId}"); c(" WHERE activated=1 AND code='{$code}'"); c($userId); if (count($usermatch) == 1 && count($cardmatch) == 1) { c(42); $card = $cardmatch[0]; $user = $usermatch[0]; $paySum = intval($card['value']); $usersTable->edit(array('id' => $userId, 'cash' => intval($user['cash']) + $paySum)); $this->table->edit(array('id' => $card['id'], 'activated' => 1, 'activationdate' => date("Y-m-d H:i:s"), 'user' => $userId)); return $paySum; } else { l('payment', 'badscratchcard', NULL, $userId, NULL, array()); } return false; } }
private function getCoveredMonths() { $moneyflowTable = new table('moneyflow'); $rows = $moneyflowTable->load('LIMIT 1'); if ($rows && count($rows)) { $coveredMonths = array(); $firstEntry = $rows[0]; $startDate = new DateTime($firstEntry['date']); $currentDate = new DateTime(); $startDate->modify("midnight"); $startDate->setDate($startDate->format('Y'), $startDate->format('m'), 1); $currentDate->modify("midnight"); $currentDate->setDate($currentDate->format('Y'), $currentDate->format('m'), 1); do { $coveredMonths[] = clone $startDate; $startDate->modify('1 month'); } while ($startDate <= $currentDate); return $coveredMonths; } else { return false; } }
} else { if (!$user->isEnabled()) { redirect('disabled.php'); } else { if ($user->isRestricted()) { redirect("/login.php?userisrestricted=true"); } else { $moneyflowTable = new table('moneyflow'); $orderTable = new table('order'); $ordersRows = $orderTable->load("WHERE user="******"WHERE user="******" ORDER BY `id` DESC"); $loadedUsers = array(); foreach ($rows as $key => $row) { $paymentDate = new DateTime($row['date']); $rows[$key]['date'] = $paymentDate->format($timeDateFormat); $rows[$key]['sum'] = formatCash($row['sum']); if ($row['name']) { $rows[$key]['details'] = $row['name']; } else { switch ($row['detailsname']) { case 'scratchcard':
function getAvailableTariffs() { $tariffTable = new table('tariff'); $allTariffs = $tariffTable->load(); $availableTariffs = array(); $userCity = $this->data['city']; for ($i = 0; $i < count($allTariffs); $i++) { $tariff = $allTariffs[$i]; if (in_array($userCity, $tariff['city']) && $tariff['public'] === 1) { $availableTariffs[$tariff['id']] = $tariff; } } return $availableTariffs; }
public function export() { if ($this->connected) { $usersTable = new table('user'); $res = $usersTable->load(" WHERE router=" . $this->id); if ($res) { foreach ($res as $row) { $this->update($row['id']); } 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); }
<?php require_once "../include/core.php"; $routersTable = new table('router'); $rows = $routersTable->load(); foreach ($rows as $row) { controllerRouter($row['id'], 'export', false); }
break; case 'getacl': $masterTable = new table('master'); $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 (!$user->isValid()) { redirect('login.php'); } else { if (!$user->isEnabled()) { redirect('disabled.php'); } else { function markAsRead($id) { } $messageTable = new table('message'); $action = isset($_GET['action']) ? $_GET['action'] : 'notset'; switch ($action) { case 'list': $request = "WHERE (`sender`=" . $user->getId() . " AND `sender_is_admin`=0) OR "; $request .= "(`recipient`=" . $user->getId() . " AND `recipient_is_admin`=0)"; $messages = $messageTable->load($request); foreach ($messages as $key => $message) { if ($message['recipient'] === $user->getId() && $message['recipient_is_admin'] === 0) { $messages[$key]['incoming'] = true; } else { $messages[$key]['incoming'] = false; } } $tpl = array("messages" => $messages); $fenom->display($theme->getTemplateLocation('header.tpl'), $headerData); $fenom->display($theme->getTemplateLocation('messageslist.tpl'), $tpl); $fenom->display($theme->getTemplateLocation('footer.tpl')); break; case 'show': case 'showredirect': $messageId = isset($_GET['id']) ? intval($_GET['id']) : 0;
$speedPostfix = $result[2]; $speedPattern = "%d {$speedPostfix}bit/s"; return sprintf(__($speedPattern), $speedAsNumber); } else { return ''; } } if (isset($_GET['city']) && intval($_GET['city'])) { $selectedCity = intval($_GET['city']); } else { $selectedCity = 0; } $tariffsTable = new table('tariff'); $tariffs = $tariffsTable->load(); $citiesTable = new table('city'); $cities = $citiesTable->load(" ORDER BY `name` ASC"); $tariffsById = array(); $tariffsByCities = array(); $citiesById = array(); // Prepare array for each city foreach ($cities as $city) { $cityId = $city['id']; $tariffsByCities[$cityId] = array(); $citiesById[$cityId] = $city; } foreach ($tariffs as $tariff) { $tariffsById[$tariff['id']] = $tariff; } if ($user->isValid() && $user->getField('city') && configgetvalue('system', 'ucp', NULL, 'showTariffsOnlyFromUsersCity')) { $checkCity = true; } else {