Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <?php
  2. use Bernard\Driver\PredisDriver;
  3. use Predis\Client;
  4. use Bernard\Message\PlainMessage;
  5. use Bernard\Producer;
  6. use Bernard\QueueFactory\PersistentFactory;
  7. use Bernard\Serializer;
  8. class Controller_Start extends Controller_Base_Public
  9. {
  10.  
  11. /**
  12. *
  13. */
  14. public function action_index()
  15. {
  16.  
  17.  
  18. if(Input::method() == 'POST')
  19. {
  20.  
  21. $name = trim(Input::post('folder_name'));
  22. $links = Input::post('links', array());
  23. $allow_links = Input::post('allow_links', 'on');
  24. $allow_dlc = Input::post('allow_dlc', 0);
  25. $allow_cnl = Input::post('allow_cnl', 0);
  26. $captcha = Input::post('captcha', '0');
  27. $password = trim(Input::post('folder_password', ''));
  28.  
  29. $folder = new Folder();
  30. $folder->set_attribute('name', $name);
  31. $folder->set_attribute('allow_links', $allow_links);
  32. $folder->set_attribute('allow_dlc', $allow_dlc);
  33. $folder->set_attribute('allow_cnl', $allow_cnl);
  34. $folder->set_attribute('captcha', (in_array($captcha, array('1', '0')) ? $captcha : 1));
  35. $folder->set_attribute('password', $password);
  36. $folder->set_attribute('deleted', 0);
  37. $folder->set_attribute('user_id', $this->user['uid']);
  38.  
  39. foreach($links as $package)
  40. {
  41.  
  42. $mirror = explode("\n", $package);
  43. $folder->set_mirror($mirror);
  44.  
  45. }
  46.  
  47. if($folder->is_valid())
  48. {
  49.  
  50. if($folder->persist())
  51. {
  52.  
  53. Response::redirect('show/'.$folder->secure_id);
  54.  
  55. }
  56. else
  57. {
  58. Session::set_flash('input.old', Input::post());
  59. \Messages::error('Sorry, an error occurred.');
  60. \Messages::redirect(Uri::current());
  61. }
  62.  
  63. }
  64. else
  65. {
  66.  
  67. Session::set_flash('input.old', Input::post());
  68. \Messages::error('Sorry, some errors occurred.<br />'.implode('<br />', $folder->get_errors()));
  69. \Messages::redirect(Uri::current());
  70.  
  71. }
  72.  
  73.  
  74. }
  75.  
  76. $user = Model_User::query()->where('id', '=', $this->user['uid'])->get_one();
  77. if(!$user)
  78. {
  79. $user = (object) array(
  80. 'default_show_links' => 1,
  81. 'default_show_dlc' => 1,
  82. 'default_show_cnl' => 1,
  83. 'default_folder_password' => '',
  84. 'default_show_captcha' => 1
  85. );
  86. }
  87.  
  88. $data['user'] = $user;
  89.  
  90. return Response::forge(View::forge('home.html.twig', isset($data) ? $data : array(), false));
  91.  
  92. }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement