Пример #1
0
 public function update($id, $requestData)
 {
     $settings = Settings::first();
     $companyname = $settings->company;
     $user = User::findorFail($id);
     $password = bcrypt($requestData->password);
     $role = $requestData->roles;
     $department = $requestData->departments;
     if ($requestData->hasFile('image_path')) {
         $settings = Settings::findOrFail(1);
         $companyname = $settings->company;
         $file = $requestData->file('image_path');
         $destinationPath = public_path() . '\\images\\' . $companyname;
         $filename = str_random(8) . '_' . $file->getClientOriginalName();
         $file->move($destinationPath, $filename);
         if ($requestData->password == "") {
             $input = array_replace($requestData->except('password'), ['image_path' => "{$filename}"]);
         } else {
             $input = array_replace($requestData->all(), ['image_path' => "{$filename}", 'password' => "{$password}"]);
         }
     } else {
         if ($requestData->password == "") {
             $input = array_replace($requestData->except('password'));
         } else {
             $input = array_replace($requestData->all(), ['password' => "{$password}"]);
         }
     }
     $user->fill($input)->save();
     $user->roles()->sync([$role]);
     $user->department()->sync([$department]);
     Session::flash('flash_message', 'User successfully updated!');
     return $user;
 }
Пример #2
0
 function all()
 {
     if (!($settings = Settings::first())) {
         $settings = new Settings();
         $settings->save();
     }
     $whereis_node = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis node')));
     $whereis_nodejs = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis nodejs')));
     $whoami = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whoami')));
     $home = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('echo $HOME')));
     $pw = @posix_getpwuid(@posix_getuid());
     $detectedHome = is_array($pw) && isset($pw['dir']) ? trim(preg_replace('/\\s\\s+/', ' ', $pw['dir'])) : '';
     $defaultNodeJsPath = false;
     if (empty($settings->nodejs_path)) {
         if (!empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_nodejs);
             if (isset($parts[0]) && $parts[0] == 'nodejs:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
         if (!$defaultNodeJsPath && !empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_node);
             if (isset($parts[0]) && $parts[0] == 'node:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
     }
     return view('settings', ['settings' => $settings, 'whereis_node' => $whereis_node, 'whereis_nodejs' => $whereis_nodejs, 'whoami' => $whoami, 'home' => $home, 'detectedHome' => $detectedHome, 'defaultNodeJsPath' => $defaultNodeJsPath]);
 }
Пример #3
0
 public function start($id)
 {
     if (!($workflow = Workflow::find((int) $id))) {
         return redirect('workflows')->with('status_error', "Workflow not found.");
     }
     if (empty($workflow->path)) {
         return redirect('workflows')->with('status_error', "Workflow not found.");
     }
     if (!empty($workflow->pid)) {
         return redirect('workflows')->with('status_error', "Workflow already started.");
     }
     if ($anotherStarted = Workflow::where('id', '!=', $id)->where('pid', '!=', '')->first()) {
         return redirect('workflows')->with('status_error', "Another workflow is already running. Please stop any other workflow first.");
     }
     if (!($settings = Settings::first())) {
         return redirect('workflows')->with('status_error', "Please fill in all the required settings.");
     }
     if (empty($settings->home_path)) {
         return redirect('workflows')->with('status_error', "Please fill in your home path.");
     }
     if (empty($settings->c9_path)) {
         return redirect('workflows')->with('status_error', "Please specify Cloud9 IDE path in settings.");
     }
     $command = "/usr/bin/nohup {$settings->nodejs_path} {$settings->c9_path} -w {$workflow->path} {$workflow->args} {$settings->default_args} > /dev/null & echo \$!";
     putenv("HOME={$settings->home_path}");
     $return = shell_exec($command);
     $pid = (int) $return;
     if (!$pid) {
         return redirect('workflows')->with('status_error', "Error while starting the server ({$return}).");
     }
     $workflow->pid = $pid;
     $workflow->save();
     return redirect('workflows')->with('status_success', "Workflow started. PID #{$pid}");
 }
Пример #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $settings = Settings::first();
     return $settings->portfolio_section;
     return var_dump($settings);
 }