Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Downloads extends Controller
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function index()
- {
- $data = array(
- 'page_title' => 'Downloads',
- 'page_header'=> 'Downloads'
- );
- $this->view->show('downloads', $data);
- }
- public function offload()
- {
- if( $this->globals->exists('checkSub') )
- {
- /** Things we need only here **/
- $this->zip();
- $this->helper('copydir');
- //List of libraries
- $libraries = array(
- 'db' => 'Libraries/Database',
- 'core' => 'Construction',
- 'auth' => 'Libraries/Auth',
- 'cache' => 'Libraries/Cache',
- 'enc' => 'Libraries/Encrypt',
- 'formval' => 'Libraries/Formval',
- 'ftp' => 'Libraries/Ftp',
- 'global' => 'Libraries/Globals',
- 'img' => 'Libraries/Imagemanip',
- 'lang' => 'Libraries/Language',
- 'sess' => 'Libraries/Session',
- 'upl' => 'Libraries/Upload',
- 'url' => 'Libraries/Url',
- 'view' => 'Libraries/View'
- );
- //Get all elements and pop off the submit value
- $post = $this->globals->all();
- array_pop($post);
- //See if we can just really quickly offer
- //the latest developer package
- if( count($post) == count($libraries)
- && file_exists(HOME . '/(nrg)Framework.zip') )
- {
- header('Content-type: application/zip');
- header('Content-Disposition: attachment; filename="(nrg)Framework.zip"');
- readfile(HOME . '/(nrg)Framework.zip');
- return;
- }
- //Create a temporary directory to create download
- $dirname = md5( serialize($post) . time() );
- //Make an initial copy of a blank framework into
- //the temp
- Copydir::To(HOME . '/blank_frm/', HOME . '/tmp/' . $dirname . '/');
- //loop through the libraries and see what they'd like
- foreach( $post as $library => $val )
- {
- if( array_key_exists($library, $libraries) )
- {
- Copydir::To( HOME . '/full_frm/Core/' . $libraries[$library] . '/', HOME . '/tmp/' . $dirname . '/Core/' . $libraries[$library] . '/');
- }
- }
- //Okiedokie our download is built...now create a zip from it
- $this->zip->copyDir(HOME . '/tmp/' . $dirname . '/', HOME . '/tmp/' . $dirname . '/');
- $this->zip->write(HOME . '/tmp/' . '(nrg)Framework-' . $dirname . '.zip');
- header('Content-type: application/zip');
- header('Content-Disposition: attachment; filename="(nrg)Framework.zip"');
- readfile(HOME . '/tmp/' . '(nrg)Framework-' . $dirname . '.zip');
- }
- }
- }
Add Comment
Please, Sign In to add comment