if (file_exists(storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.json')) { $repo = json_decode(file_get_contents(storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.json')); $deployKey = file_get_contents(storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.deploy.key'); $SSHKey = file_get_contents(storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.ssh.key'); if ($deployKey == null) { $deployKey = "no"; } else { $deployKey = storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.deploy.key'; } if ($SSHKey == null) { $SSHKey = "no"; } else { $SSHKey = storage_path() . '/userdata/' . $owner . '_' . $name . '_' . $branch . '.ssh.key'; } } else { return redirect('/')->with('error', 'Non existant repo.'); } if ($request->session()->has('token') || $repo->DeployPass === $pass) { $client = new Github\Client(); $client->authenticate($request->session()->get('token'), null, Github\Client::AUTH_HTTP_TOKEN); $user = $client->currentUser()->show(); if ($user['id'] !== 2953722 && $SSHKey == null || $deployKey == null && $user['id'] !== 2953722) { return redirect('/')->with('error', 'You need an SSH Key and a Deploy Key.'); } $remote = $client->api('repo')->show($owner, $name); ob_start(); require_once __DIR__ . '/deploy.php'; return view('deploy', array('repo' => $repo, 'url' => $remote['private'] ? $remote['ssh_url'] : $remote['clone_url'], 'deployKey' => $deployKey, 'SSHKey' => $SSHKey, 'user' => $user)); } return redirect('/')->with('error', 'Unauthorized.'); });