Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
evsmash/files / libs / Http / Attachments.php
Size: Mime:
<?php

namespace Evsmash\Files\Http;

use Evsmash\Core\Http\Base;

use Evsmash\Core\Helpers\View;
use Evsmash\Core\Simpy\Element;
use Evsmash\Core\System\Exception;

use Evsmash\Files\Attachment;

class Attachments extends Base {

	// download
	public function download() {

		// config
		if(!cfg('evsmash-files-attachments-download')) {
			Exception::notexists('attachments', 'download');
		}

		// get
		$element = Element::check(new Attachment);

		// downloads
		$element->downloads = $element->downloads + 1;
		$element->save();

		// view
		View::file($element->file, $element->name);

	}

	// show
	public function show() {

		// config
		if(!cfg('evsmash-files-attachments-show')) {
			Exception::notexists('attachments', 'show');
		}

		// get
		$element = Element::check(new Attachment);

		// downloads
		$element->downloads = $element->downloads + 1;
		$element->save();

		// view
		View::file($element->file, $element->name, false);

	}

}