Example #1
0
 public function output(\Pagemill_Data $data, \Pagemill_Stream $stream)
 {
     $this->pluginTemplate = "/downloads/downloads.plug.html";
     $data = $data->fork();
     $downloads = new Model_Download_File();
     $downloads->where('siteid = ?', Typeframe::CurrentPage()->siteid());
     $data['downloads'] = $downloads;
     parent::output($data, $stream);
 }
Example #2
0
<?php

$query = new Model_Download_File();
$query->where('encodedtitle = ?', pathinfo(Typeframe::CurrentPage()->pathInfo(), PATHINFO_FILENAME));
$query->where('siteid = ?', Typeframe::CurrentPage()->siteid());
$download = $query->getFirst();
if ($download->exists()) {
    $fullname = TYPEF_DIR . '/files/public/downloads/' . $download['filename'];
    $extension = pathinfo($download['filename'], PATHINFO_EXTENSION);
    if (file_exists($fullname) && is_file($fullname)) {
        $download['downloads'] = $download['downloads'] + 1;
        $download->save();
        header('Pragma: public');
        header('Content-Type: application/force-download');
        header('Content-Disposition: attachment; filename="' . $download['encodedtitle'] . '.' . $extension . '"');
        readfile($fullname);
        exit;
    }
}
http_response_code(404);
Typeframe::SetPageTemplate('/404.html');
Example #3
0
<?php

/*
	7 april 2011: created from admin/news/delete.php
*/
// save some typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// if not posting, bounce out of here
if ('POST' != $_SERVER['REQUEST_METHOD']) {
    Typeframe::Redirect('Nothing to do.', $typef_app_dir);
    return;
}
// create download object from given id
$fileid = @$_POST['fileid'];
$download = Model_Download_File::Get($fileid);
// download must exist to proceed
if (!$download->exists()) {
    Typeframe::Redirect('Invalid download id specified.', $typef_app_dir);
    return;
}
// perform the delete
$download->delete();
// done
Typeframe::Redirect('Download has been deleted.', $typef_app_dir);
Example #4
0
File: index.php Project: ssrsfs/blg
<?php

$downloads = new Model_Download_File();
$downloads->where('siteid = ?', Typeframe::CurrentPage()->siteid());
$pm->setVariable('downloads', $downloads);
Example #5
0
File: edit.php Project: ssrsfs/blg
<?php

$download = Model_Download_File::Get($_REQUEST['fileid']);
if (!$download->exists() || $download['siteid'] != Typeframe::CurrentPage()->siteid()) {
    Typeframe::Redirect('Invalid file specified.', Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
include 'options.inc.php';
$pm->setVariable('download', $download);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    include 'update.inc.php';
    if ($download->exists()) {
        Typeframe::Redirect('Download created.', Typeframe::CurrentPage()->applicationUri());
    }
}
Example #6
0
File: add.php Project: ssrsfs/blg
<?php

include 'options.inc.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $download = Model_Download_File::Create();
    $download['siteid'] = Typeframe::CurrentPage()->siteid();
    include 'update.inc.php';
    if ($download->exists()) {
        Typeframe::Redirect('Download created.', Typeframe::CurrentPage()->applicationUri());
    }
}