Guest User

Untitled

a guest
Jun 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. <?php
  2.  
  3. class Downloads extends Controller
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. }
  9.  
  10. public function index()
  11. {
  12. $data = array(
  13. 'page_title' => 'Downloads',
  14. 'page_header'=> 'Downloads'
  15. );
  16. $this->view->show('downloads', $data);
  17. }
  18.  
  19. public function offload()
  20. {
  21. if( $this->globals->exists('checkSub') )
  22. {
  23. /** Things we need only here **/
  24. $this->zip();
  25. $this->helper('copydir');
  26.  
  27. //List of libraries
  28. $libraries = array(
  29. 'db' => 'Libraries/Database',
  30. 'core' => 'Construction',
  31. 'auth' => 'Libraries/Auth',
  32. 'cache' => 'Libraries/Cache',
  33. 'enc' => 'Libraries/Encrypt',
  34. 'formval' => 'Libraries/Formval',
  35. 'ftp' => 'Libraries/Ftp',
  36. 'global' => 'Libraries/Globals',
  37. 'img' => 'Libraries/Imagemanip',
  38. 'lang' => 'Libraries/Language',
  39. 'sess' => 'Libraries/Session',
  40. 'upl' => 'Libraries/Upload',
  41. 'url' => 'Libraries/Url',
  42. 'view' => 'Libraries/View'
  43. );
  44.  
  45.  
  46. //Get all elements and pop off the submit value
  47. $post = $this->globals->all();
  48. array_pop($post);
  49.  
  50. //See if we can just really quickly offer
  51. //the latest developer package
  52. if( count($post) == count($libraries)
  53. && file_exists(HOME . '/(nrg)Framework.zip') )
  54. {
  55. header('Content-type: application/zip');
  56. header('Content-Disposition: attachment; filename="(nrg)Framework.zip"');
  57. readfile(HOME . '/(nrg)Framework.zip');
  58. return;
  59. }
  60.  
  61. //Create a temporary directory to create download
  62. $dirname = md5( serialize($post) . time() );
  63.  
  64. //Make an initial copy of a blank framework into
  65. //the temp
  66. Copydir::To(HOME . '/blank_frm/', HOME . '/tmp/' . $dirname . '/');
  67.  
  68. //loop through the libraries and see what they'd like
  69. foreach( $post as $library => $val )
  70. {
  71. if( array_key_exists($library, $libraries) )
  72. {
  73. Copydir::To( HOME . '/full_frm/Core/' . $libraries[$library] . '/', HOME . '/tmp/' . $dirname . '/Core/' . $libraries[$library] . '/');
  74. }
  75. }
  76.  
  77. //Okiedokie our download is built...now create a zip from it
  78. $this->zip->copyDir(HOME . '/tmp/' . $dirname . '/', HOME . '/tmp/' . $dirname . '/');
  79. $this->zip->write(HOME . '/tmp/' . '(nrg)Framework-' . $dirname . '.zip');
  80.  
  81.  
  82. header('Content-type: application/zip');
  83. header('Content-Disposition: attachment; filename="(nrg)Framework.zip"');
  84. readfile(HOME . '/tmp/' . '(nrg)Framework-' . $dirname . '.zip');
  85.  
  86. }
  87. }
  88. }
Add Comment
Please, Sign In to add comment