예제 #1
0
require_once "overall.php";
$params = $_POST + $_GET;
try {
    $apikey = @$params['apikey'];
    $allowedKeys = preg_split('/\\s+/s', trim(getSetting("apikeys", "")));
    if (!$apikey || !in_array($apikey, $allowedKeys)) {
        throw new Exception('Invalid "apikey" parameter');
    }
    $itemIds = trim(@$params['item_ids']);
    if (!$itemIds) {
        throw new Exception('Parameter "item_ids" must be specified and not empty');
    }
    $dataNames = trim(@$params['data_names']);
    $dataNames = $dataNames ? explode(TAGS_SEP, $dataNames) : array();
    $onlyPeriods = trim(@$params['periods']);
    $onlyPeriods = $onlyPeriods ? explode(TAGS_SEP, $onlyPeriods) : array();
    list($to, $back) = parseToBackPeriod($params);
    $result = array();
    foreach (getPeriods() as $period => $periodName) {
        if ($onlyPeriods && !in_array($period, $onlyPeriods)) {
            continue;
        }
        $result[$period] = generateTableData($to, $back, $period, $itemIds, $dataNames);
    }
    //	print_r($result);
    header("Content-Type: application/json");
    echo json_encode($result);
} catch (Exception $e) {
    header("Content-Type: text/plain");
    echo $e->getMessage();
}
예제 #2
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
function generateRow($index, $container_type)
{
    return XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell(JHtmlGrid::id($index, $container_type->id)), XmlTagHelper::formatTableCell(JText::_($container_type->container_name)), XmlTagHelper::formatTableCell($container_type->liters)));
}
function generateTableData($container_types)
{
    $tableData = array();
    foreach ($container_types as $index => $container_type) {
        $tableData[] = generateRow($index, $container_type);
    }
    return $tableData;
}
$xmlTag = new XmlTag();
if (isset($this->container_types)) {
    $tableContent = generateTableData($this->container_types);
    $xmlTag->FORM(array('action' => 'index.php?option=com_reomi&view=container_types', 'id' => 'adminForm', 'method' => 'post', 'name' => 'adminForm'), $xmlTag()->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JHtmlGrid::checkall())->TH(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_TABLE_HEADER_CONTAINER'))->TH(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_TABLE_HEADER_LITERS'))))->TBODY($xmlTag()->__fromArray($tableContent)))->INPUT(array('type' => 'hidden', 'name' => 'task', 'value' => ''))->INPUT(array('type' => 'hidden', 'name' => 'boxchecked', 'value' => '0'))->_(JHtmlForm::token()));
} else {
    $xmlTag->P(JText::_('COM_ROEMI_ADMIN_VIEW_CONTAINER_TYPES_EMPTY_TABLE_MSG'));
}
echo $xmlTag;
예제 #3
0
            } else {
                $_POST['item']['sql'] = "SELECT COUNT(*)\nFROM some_table\nWHERE created BETWEEN \$FROM AND \$TO\n";
            }
        }
    }
}
$SELECT_DSNS = array();
foreach ($DB->select("SELECT id, name FROM dsn ORDER BY name") as $row) {
    $SELECT_DSNS[$row['id']] = $row['name'];
}
$SELECT_ITEMS = array();
$seenArchived = 0;
foreach ($DB->select("SELECT id, name, archived FROM item ORDER BY archived, name") as $row) {
    if (!$seenArchived && $row['archived']) {
        $SELECT_ITEMS[0] = "";
    }
    $SELECT_ITEMS[$row['id']] = $row['name'];
}
$SELECT_PERIODS = getPeriods();
if (!$tables && $id) {
    $to = $DB->selectCell("SELECT MAX(created) FROM data WHERE item_id=?", $id);
    if (!$to) {
        $to = time();
    }
    foreach ($SELECT_PERIODS as $period => $periodName) {
        $data = generateTableData($to, $PREVIEW_TABLES_COLS, $period, $id);
        $tables[$periodName] = generateHtmlTableFromData($data, true);
    }
}
$title = $id ? 'Edit item <a href="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '">' . htmlspecialchars($_POST['item']['name']) . '</a>' . '&nbsp;<a href="item.php?clone=' . htmlspecialchars($id) . '" title="Clone this item"><img src="static/clone.gif" width="10" height="10" border="0" /></a>' : "Add a new item";
template("item", array("titleHtml" => $title, "title" => strip_tags($title), "tables" => $tables, "canAjaxTestSql" => canAjaxTestSql()));
예제 #4
0
}
$onlyReName = null;
if (isset($_SERVER['argv'][2])) {
    $onlyReName = $_SERVER['argv'][2];
}
$to = trunkTime($to);
// mail is always sent for WHOLE periods
$emails = trim(getSetting('emails'));
if ($period == 'month' && trim($emailsMonth = getSetting('emails_month'))) {
    $emails .= ($emails ? ", " : "") . $emailsMonth;
}
if (!$emails) {
    die("Please specify E-mails to send stats at Settings page!\n");
}
// Generate the table data.
$data = generateTableData($to, $back, $period, null, null, $onlyReName);
// Remove archived rows.
foreach ($data['groups'] as $gName => $gRows) {
    foreach ($gRows as $rName => $rInfo) {
        if ($rInfo['archived']) {
            unset($data['groups'][$gName][$rName]);
        }
    }
    if (!$data['groups'][$gName]) {
        unset($data['groups'][$gName]);
    }
}
// Generate HTML.
$html = generateHtmlTableFromData($data);
$firstCaption = current($data['captions']);
$SELECT_PERIODS = getPeriods();
예제 #5
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted access');
function generateRow($city)
{
    return XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell($city->name), XmlTagHelper::formatTableCell($city->service)));
}
function generateTableData($cities)
{
    $tableData = array();
    foreach ($cities as $city) {
        $tableData[] = generateRow($city);
    }
    return $tableData;
}
$xmlTag = new XmlTag();
$xmlTag->H1(JText::_('COM_REOMI_VIEW_CITIES_PAGE_TITLE'))->P(JText::_('COM_REOMI_VIEW_CITIES_PAGE_DESC'))->BR();
if (isset($this->cities)) {
    $tableContent = generateTableData($this->cities);
    $xmlTag->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JText::_('COM_ROEMI_VIEW_CITIES_TABLE_HEADER_CITY'))->TH(JText::_('COM_ROEMI_VIEW_CITIES_TABLE_HEADER_SERVICE'))))->TBODY($xmlTag()->__fromArray($tableContent)));
} else {
    $xmlTag->P(JText::_('COM_ROEMI_VIEW_CITIES_EMPTY_TABLE_MSG'));
}
echo $xmlTag;
예제 #6
0
<?php

define("USE_GZIP", 1);
require_once "overall.php";
$url = preg_replace('/\\?.*/s', '', $_SERVER['REQUEST_URI']);
setSetting("index_url", ($_SERVER['SERVER_PORT'] == 443 ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $url);
list($to, $back, $period) = parseToBackPeriod($_GET);
$data = generateTableData($to, getSetting("cols", 30) + 1, $period, @$_GET['tag'], null, @$_GET['re']);
$html = generateHtmlTableFromData($data);
$SELECT_PERIODS = getPeriods();
$name = getSetting("instance");
template("index", array("title" => ($name ? $name . ": " : "") . $SELECT_PERIODS[$period] . " statistics for " . date("Y-m-d", trunkTime($to) - 1), "to" => $to, "htmlTable" => $html));
예제 #7
0
<?php

// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
function generateRow($index, $fee)
{
    setlocale(LC_MONETARY, 'fr_FR.utf8');
    $desc = $fee->description;
    if ($desc == null) {
        $desc = "";
    }
    return XmlTagHelper::formatTableRow(array(XmlTagHelper::formatTableCell(JHtmlGrid::id($index, $fee->id)), XmlTagHelper::formatTableCell(JText::_($fee->name)), XmlTagHelper::formatTableCell(JText::_($desc)), XmlTagHelper::formatTableCell(money_format('%n', $fee->fee))));
}
function generateTableData($fees)
{
    $tableData = array();
    foreach ($fees as $index => $fee) {
        $tableData[] = generateRow($index, $fee);
    }
    return $tableData;
}
$xmlTag = new XmlTag();
if (isset($this->bulk_fees)) {
    $tableContent = generateTableData($this->bulk_fees);
    $xmlTag->FORM(array('action' => 'index.php?option=com_reomi&view=bulk_fees', 'id' => 'adminForm', 'method' => 'post', 'name' => 'adminForm'), $xmlTag()->TABLE(array('class' => 'table table-striped table-hover'), $xmlTag()->THEAD($xmlTag()->TR($xmlTag()->TH(JHtmlGrid::checkall())->TH(JText::_('COM_ROEMI_ADMIN_VIEW_BULK_FEES_TABLE_HEADER_USER'))->TH(JText::_('COM_ROEMI_ADMIN_VIEW_BULK_FEES_TABLE_HEADER_DESC'))->TH(JText::_('COM_ROEMI_ADMIN_VIEW_BULK_FEES_TABLE_HEADER_FEE'))))->TBODY($xmlTag()->__fromArray($tableContent)))->INPUT(array('type' => 'hidden', 'name' => 'task', 'value' => ''))->INPUT(array('type' => 'hidden', 'name' => 'boxchecked', 'value' => '0'))->_(JHtmlForm::token()));
} else {
    $xmlTag->P(JText::_('COM_ROEMI_ADMIN_VIEW_BULK_FEES_EMPTY_TABLE_MSG'));
}
echo $xmlTag;