Example #1
0
    exit;
}
$display = COM_siteHeader();
$display .= COM_startBlock($LANG_EX00['header']);
$T = new Template($_CONF['path'] . 'plugins/external/templates');
$T->set_file('index', 'index.thtml');
$T->set_block('index', 'Newpage', 'APage');
$recs = DB_query("SELECT * FROM {$_TABLES['external']} \n            ORDER BY title ASC");
$numrecs = DB_numRows($recs);
if ($numrecs < 1) {
    // Can $numrecs ever be -1?  Better safe than sorry
    $T->set_var('notavail', $LANG_EX00['header'] . " " . $LANG_EX00['notavail']);
} else {
    while ($A = DB_fetchArray($recs)) {
        if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0) {
            $T->set_var('exid', $A['exid']);
            if (preg_match("/^(http:\\/\\/)/i", $A['url']) == 1) {
                $T->set_var('page', $A['url']);
            } else {
                $T->set_var('page', $_CONF['site_url'] . '/' . $A['url']);
            }
            $T->set_var('title', $A['title']);
            $T->Parse('APage', 'Newpage', true);
        }
    }
}
$T->parse('output', 'index');
$display .= $T->finish($T->get_var('output'));
$display .= COM_endBlock();
$display .= COM_siteFooter(false);
echo $display;
Example #2
0
$clientDetail = new request();
$clientDetail->openOrganizations($tmpquery);
$comptClientDetail = count($clientDetail->org_id);
$tmpquery = "WHERE org.id = '1'";
$mycompanyDetail = new request();
$mycompanyDetail->openOrganizations($tmpquery);
$comptMycompanyDetailDetail = count($mycompanyDetail->org_id);
$tmpquery = "WHERE invitem.invoice = '{$id}' AND invitem.active = '1' ORDER BY invitem.position ASC";
$listInvoicesItems = new request();
$listInvoicesItems->openInvoicesItems($tmpquery);
$comptListInvoicesItems = count($listInvoicesItems->invitem_id);
$template = new Template();
$template->set_file('invoice', 'tpl_invoice.html');
$template->set_var(array('val_CLIENTNAME' => $clientDetail->org_name[0], 'val_CLIENTADDRESS' => nl2br($clientDetail->org_address1[0]), 'val_COMPANYNAME' => $mycompanyDetail->org_name[0], 'val_COMPANYADDRESS' => nl2br($mycompanyDetail->org_address1[0]), 'str_INVOICE' => $strings["invoice"], 'val_HEADER' => $detailInvoice->inv_header_note[0], 'val_FOOTER' => $detailInvoice->inv_footer_note[0], 'val_TOTALINCTAX' => $detailInvoice->inv_total_inc_tax[0], 'val_TOTALEXTAX' => $detailInvoice->inv_total_ex_tax[0], 'val_TAXRATE' => $detailInvoice->inv_tax_rate[0], 'val_TAXAMOUNT' => $detailInvoice->inv_tax_amount[0], 'str_TOTALINCTAX' => $strings["total_inc_tax"], 'str_TOTALEXTAX' => $strings["total_ex_tax"], 'str_TAXRATE' => $strings["tax_rate"], 'str_TAXAMOUNT' => $strings["tax_amount"], 'str_TITLE' => $strings["title"], 'str_AMOUNTEXTAX' => $strings["amount_ex_tax"]));
$template->set_block('invoice', 'items', 'block');
for ($i = 0; $i < $comptListInvoicesItems; $i++) {
    $template->set_var(array('val_TITLE' => $listInvoicesItems->invitem_title[$i], 'val_AMOUNTEXTAX' => $listInvoicesItems->invitem_amount_ex_tax[$i]));
    $template->Parse('block', 'items', true);
}
$dump_buffer = $template->finish($template->parse('invoice', 'invoice'));
$filename = $strings["invoice"] . $detailInvoice->inv_id[0];
$ext = 'html';
$mime_type = 'text/html';
// Send headers
header('Content-Type: ' . $mime_type);
// lem9: we need "inline" instead of "attachment" for IE 5.5
$content_disp = USR_BROWSER_AGENT == 'IE' ? 'inline' : 'attachment';
header('Content-Disposition:  ' . $content_disp . '; filename="' . $filename . '.' . $ext . '"');
header('Pragma: no-cache');
header('Expires: 0');
echo $dump_buffer;
Example #3
0
function build_toplist($toplist)
{
    global $g_stats, $g_time, $compiler, $C;
    require_once 'dirdb.php';
    require_once 'compiler.php';
    require_once 'template.php';
    require_once 'stats.php';
    if (empty($toplist)) {
        return;
    }
    // Check that source file exists and is readable
    if ($toplist['source'] == TOPLIST_SOURCE_FILE) {
        if (!is_file($toplist['infile']) || !is_readable($toplist['infile'])) {
            return log_toplist_error("Input file '{$toplist['infile']}' does not exist or is not readable");
        }
        $toplist['template'] = file_get_contents($toplist['infile']);
    }
    // Check that the destination file exists and is writeable, or the directory exists and is writeable
    if (!file_exists($toplist['outfile'])) {
        $directory = dirname($toplist['outfile']);
        if (!is_dir($directory) || !is_writeable($directory)) {
            return log_toplist_error("Output directory '{$directory}' does not exist or is not writeable");
        }
    } else {
        if (!is_writeable($toplist['outfile'])) {
            return log_toplist_error("Output file '{$toplist['outfile']}' is not writeable");
        }
    }
    // Compile and check for errors
    if (($compiled = $compiler->Compile($toplist['template'])) === false) {
        return log_toplist_error("Toplist template for '{$toplist['outfile']}' contains errors");
    }
    // Load and cache overall stats
    if (!isset($g_stats)) {
        $_REQUEST['status'] = STATUS_ACTIVE;
        $g_stats = load_overall_stats(DIR_TRADE_STATS, get_trades(), TRUE);
    }
    // Get time
    if (!isset($g_time)) {
        $g_time = time();
    }
    // Prepare categories and groups
    $toplist['categories'] = empty($toplist['categories']) ? null : explode(',', $toplist['categories']);
    $toplist['groups'] = empty($toplist['groups']) ? null : explode(',', $toplist['groups']);
    // Prepare requirements & sources
    $toplist['trade_sources'] = unserialize($toplist['trade_sources']);
    $toplist['req_field'] = unserialize($toplist['req_field']);
    $toplist['req_operator'] = unserialize($toplist['req_operator']);
    $toplist['req_value'] = unserialize($toplist['req_value']);
    // Sort
    $_REQUEST['sort_by'] = $toplist['sort_by'];
    $_REQUEST['trade_sources'] = $toplist['trade_sources'];
    usort($g_stats, 'cmp_overall_stats');
    $t = new Template();
    $rank = 1;
    $trades = array();
    foreach ($g_stats as $so) {
        // Allowed in toplist?
        if (!$so->trade['flag_toplist']) {
            continue;
        }
        // Check categories
        if (!empty($toplist['categories']) && count(array_intersect($toplist['categories'], explode(',', $so->trade['categories']))) == 0) {
            continue;
        }
        // Check groups
        if (!empty($toplist['groups']) && count(array_intersect($toplist['groups'], explode(',', $so->trade['groups']))) == 0) {
            continue;
        }
        // Only trades with thumbnails
        if ($toplist['flag_thumbs_only'] && $so->trade['thumbnails'] < 1) {
            continue;
        }
        // Check requirement
        if (!empty($toplist['req_field']) && !$so->ignore_requirements) {
            for ($i = 0; $i < count($toplist['req_field']); $i++) {
                $req_failed = FALSE;
                switch ($toplist['req_operator'][$i]) {
                    case '>=':
                        $req_failed = !($so->{$toplist['req_field'][$i]} >= $toplist['req_value'][$i]);
                        break;
                    case '<':
                        $req_failed = !($so->{$toplist['req_field'][$i]} < $toplist['req_value'][$i]);
                        break;
                    case '<=':
                        $req_failed = !($so->{$toplist['req_field'][$i]} <= $toplist['req_value'][$i]);
                        break;
                    case '>':
                        $req_failed = !($so->{$toplist['req_field'][$i]} > $toplist['req_value'][$i]);
                        break;
                    default:
                        $req_failed = FALSE;
                        break;
                }
                if ($req_failed) {
                    break;
                }
            }
            if ($req_failed) {
                continue;
            }
        }
        $trade = get_object_vars($so);
        $trade = array_merge($trade, $trade['trade']);
        unset($trade['trade']);
        $trades[$rank] = $trade;
        $rank++;
    }
    $t->AssignByRef('g_trades', $trades);
    $t->AssignByRef('g_config', $C);
    $t->Assign('g_timestamp', $g_time);
    $t->Assign('g_date', date($C['date_format'], $g_time));
    $t->Assign('g_datetime', date($C['date_format'] . ' ' . $C['time_format'], $g_time));
    $output = $t->Parse($compiled);
    file_write($toplist['outfile'], $output);
}