Esempio n. 1
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhform/collected.tpl.php');
$form = erLhAbstractModelForm::fetch((int) $Params['user_parameters']['form_id']);
if (is_numeric($Params['user_parameters_unordered']['id']) && $Params['user_parameters_unordered']['action'] == 'delete') {
    // Delete selected canned message
    try {
        if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
            die('Invalid CSRF Token');
            exit;
        }
        $collected = erLhAbstractModelFormCollected::fetch((int) $Params['user_parameters_unordered']['id']);
        $collected->removeThis();
    } catch (Exception $e) {
        // Do nothing
    }
    erLhcoreClassModule::redirect('form/collected', '/' . $form->id);
    exit;
}
$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('form/collected') . '/' . $form->id;
$pages->items_total = erLhAbstractModelFormCollected::getCount(array('filter' => array('form_id' => $form->id)));
$pages->setItemsPerPage(20);
$pages->paginate();
$items = array();
if ($pages->items_total > 0) {
    $items = erLhAbstractModelFormCollected::getList(array('filter' => array('form_id' => $form->id), 'offset' => $pages->low, 'limit' => $pages->items_per_page, 'sort' => 'id DESC'));
}
$tpl->set('items', $items);
$tpl->set('pages', $pages);
$tpl->set('form', $form);
Esempio n. 2
0
<?php

try {
    $file = erLhAbstractModelFormCollected::fetch((int) $Params['user_parameters']['collected_id']);
    $attr_name = $Params['user_parameters']['attr_name'];
    if (isset($file->content_array[$attr_name])) {
        $type = $file->content_array[$attr_name]['value']['type'];
        $array = explode('.', $file->content_array[$attr_name]['value']['name']);
        $ext = end($array);
        header('Content-type: ' . $type);
        header('Content-Disposition: attachment; filename="' . $attr_name . '.' . $ext . '"');
        echo file_get_contents($file->content_array[$attr_name]['filepath'] . $file->content_array[$attr_name]['filename']);
    }
} catch (Exception $e) {
    header('Location: /');
    exit;
}
exit;