function linux_users() { /* For all groups.. */ foreach (Group::all() as $group) { if (!$group->server->created) { continue; } /* Find the user of the assistant */ if ($group->assistant_id != null) { $su = ServerUser::where('user_id', $group->assistant_id)->where('server_id', $group->server->id)->first(); /* Not created, create! */ if (!$su && $group->assistant_id) { $su = new ServerUser(); $su->user_id = $group->assistant_id; $su->server_id = $group->server->id; $su->created = 0; $su->save(); } } /* All students */ foreach ($group->students as $student) { /* Check if not already created */ $su = ServerUser::where('user_id', $student->user_id)->where('server_id', $group->server->id)->first(); /* Not created, create! */ if (!$su) { $su = new ServerUser(); $su->user_id = $student->user_id; $su->server_id = $group->server->id; $su->created = 0; $su->save(); } } } }
echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">Extern IP-adres</span>'; echo '<span class="col-sm-4">' . env('WEBDB_IP') . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">Intern IP-adres</span>'; echo '<span class="col-sm-4">' . $server->ip_address . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">SSH poort</span>'; echo '<span class="col-sm-4">' . $server->ssh_port . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">State</span>'; echo '<span class="col-sm-4">' . $server->state; if ($server->state == 'Off') { echo ' (' . link_to('staff/server-on/' . $server->id, 'Aanzetten') . ')'; } echo '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">Up Time</span>'; echo '<span class="col-sm-4">' . $server->uptime . '</span></div>'; echo '</div>'; $su = \App\Models\ServerUser::where('server_id', $server->id)->where('created', 1)->where('user_id', Auth::id())->first(); if ($su) { echo '<h2>Inloggegevens</h2>'; echo '<p>Met onderstaande gegevens kun je inloggen op SSH, MySQL en MailCatcher.</p>'; echo '<div class="container">'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">Gebruikersnaam</span>'; echo '<span class="col-sm-4">' . $su->username . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">Wachtwoord</span>'; echo '<span class="col-sm-4">' . $su->password . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">SSH-commando</span>'; echo '<span class="col-sm-4">ssh -p ' . $server->ssh_port . ' ' . $su->username . '@' . $server->hostname . '.' . env('WEBDB_URL') . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">phpMyAdmin</span>'; echo '<span class="col-sm-4">' . link_to('https://' . $server->hostname . '.' . env('WEBDB_URL') . '/phpmyadmin') . '</span></div>'; echo '<div class="row"><span class="col-sm-2" style="text-align:left;font-weight: bold;">MailCatcher</span>'; echo '<span class="col-sm-4">' . link_to('https://' . $server->hostname . '-mail.' . env('WEBDB_URL')) . '</span></div>'; echo '</div>';