diff options
-rwxr-xr-x | backend/backend.php | 5 | ||||
-rw-r--r-- | frontend/include/header.php | 3 | ||||
-rw-r--r-- | frontend/pages/invite.php | 39 | ||||
-rw-r--r-- | frontend/pages/register.php | 7 | ||||
-rw-r--r-- | frontend/routing.csv | 2 | ||||
-rwxr-xr-x | setup.php | 2 | ||||
-rw-r--r-- | shared/functions/xhtmlemail.php | 1 | ||||
-rw-r--r-- | todo | 3 |
8 files changed, 55 insertions, 7 deletions
diff --git a/backend/backend.php b/backend/backend.php index 5d5fb6b..3cd0f07 100755 --- a/backend/backend.php +++ b/backend/backend.php @@ -41,7 +41,7 @@ if (is_file($pidfile)) { die("Found already running backend PID=$pid.\n"); } if (posix_geteuid() !== 0) - debug(STDERR, "Not running as root... this is not going to accomplish much."); + debug("Not running as root... this is not going to accomplish much."); if (file_put_contents($pidfile, posix_getpid())) $unlinkpidfile=true; require_once(SHARED.'/include/dbinit.php'); @@ -60,12 +60,15 @@ while (true) { } catch (Exception $e) { log_msg('Caught exception: '.$e->getMessage()); $build->status='finished/failed: '.$e->getMessage(); + $owner=$build->get_owner(); + xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $conf['title'].' build failed', 'Your build has failed. You can find more information at <a href="'.url('logs/'.$build->id).'">'.url('logs/'.$build->id).'</a>'); } $build->finish=time(); log_msg('Finished with build id='.$build->id); if (isset($image)) { log_msg("Completed image at $image"); $build->status='finished/success'; + xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $conf['title'].' build finished', 'Your build has completed successfully. You can find more information and download the completed image at <a href="'.url('logs/'.$build->id).'">'.url('logs/'.$build->id).'</a>'); } $build->write(); unset($build); diff --git a/frontend/include/header.php b/frontend/include/header.php index 0822f68..4a60969 100644 --- a/frontend/include/header.php +++ b/frontend/include/header.php @@ -32,6 +32,9 @@ if (isset($S['head'])) { echo '<li><a href="'.url().'">Home</a></li>'; echo '<li><a href="'.url('create').'">Create an image</a></li>'; echo '<li><a href="'.url('logs').'">Log viewer</a></li>'; +if (isset($S['user']) && $S['user']->hasflag('a')) { + echo '<li><a href="'.url('invite').'">Invite</a></li>'; +} ?> </ul> </div> diff --git a/frontend/pages/invite.php b/frontend/pages/invite.php new file mode 100644 index 0000000..a04a12d --- /dev/null +++ b/frontend/pages/invite.php @@ -0,0 +1,39 @@ +<?php +function init_invite() { + global $S; + if (!isset($S['user'])) { + return 'login'; + } + if (!$S['user']->hasflag('a')) { + return 'denied'; + } +} +function body_invite() { + global $S, $request, $conf; + if (isset($request['emails'])) { + echo '<h3>Inviting Users</h3>'; + $emails=explode("\n", $request['emails']); + foreach ($emails as $email) { + // TODO proper checking that user and registrationtoken don't exist for this email to avoid errors + $email=trim($email); + if (strlen($email) == 0) { + continue; + } + if (!Validate::email($email)) { + echo 'Email address "'.htmlentities($email).'" invalid<br/>'; + continue; + } + $token=sql_registrationtoken::create(); + $token->email=$email; + $token->expire=time()+24*3600; // 24 hour shelf life (we're not checking currently) + $token->owner=$S['user']->id; + $token->write(); + xhtmlemail($email, null, $conf['title'].' invitation', htmlentities($S['user']->name).' has invited you to create an account for '.$conf['title'].'. To create an account, click this link: <a href="'.url('register/'.$token->id).'">'.url('register/'.$token->id).'</a>'); + echo 'Invited '.htmlentities($email).'<br/>'; + } + echo '<a href="'.url('invite').'">Send more invitations</a>'; + } else { + echo '<h3>Invite Users</h3><form action="'.url('invite').'" method="post">Email addresses to send invitations to: (one per line)<br/><textarea name="emails"></textarea><br/><input type="submit" value="Send Invitations" /></form>'; + } +} +?> diff --git a/frontend/pages/register.php b/frontend/pages/register.php index 344ee25..e624ac1 100644 --- a/frontend/pages/register.php +++ b/frontend/pages/register.php @@ -1,12 +1,12 @@ <?php function init_register() { - global $S; + global $S, $request; if (isset($S['user'])) { header('Location: '.url()); return 'welcome'; } if (isset($request['token']) && preg_match('/^[a-zA-Z0-9]{30}$/', $request['token'])) { - $r=$S['pdo']->query('SELECT * FROM `tokens` WHERE `id`=\''.$request['token'].'\''); + $r=$S['pdo']->query('SELECT * FROM `registrationtokens` WHERE `id`=\''.$request['token'].'\''); if ($r->rowCount()) { $S['register.token']=new sql_registrationtoken($r->fetch(PDO::FETCH_ASSOC)); if (isset($request['password'])) { @@ -55,8 +55,7 @@ function body_register() { } elseif (isset($S['register.token'])) { if (isset($S['register.fail'])) echo $S['register.fail']; - else - echo '<h3>Register</h3><form action="'.url('register').'" method="post"><input type="hidden" name="token" value="'.$request['token'].'" />Display name: <input name="name" /><br/>Password: <input type="password" name="password" /><br/><input type="submit" value="Create Account" /></form>'; + echo '<h3>Register</h3><form action="'.url('register').'" method="post"><input type="hidden" name="token" value="'.$request['token'].'" />Display name: <input name="name" /><br/>Password: <input type="password" name="password" /><br/><input type="submit" value="Create Account" /></form>'; } else echo '<h3>Register</h3><form action="'.url('register').'" method="post"> E-mail: <input name="email" /><br/> diff --git a/frontend/routing.csv b/frontend/routing.csv index 74c9fee..bbec7d7 100644 --- a/frontend/routing.csv +++ b/frontend/routing.csv @@ -30,6 +30,8 @@ ^logout/(.+)$ logout go # Account stuff ^register$ register +^register/([a-zA-Z0-9]{30})$ register token +^invite$ invite # Pass through ^(js)/([0-9a-zA-Z-_]+\.(js))$ passthrough dir file ext ^(images)/([0-9a-zA-Z-_]+\.(gif|jpg|jpeg|ico))$ passthrough dir file ext @@ -70,6 +70,6 @@ if ($interactive) { system('stty echo'); } $user->passhash=sha1($pass); -$user->flags='a'; +$user->flags='a'; // Admin $user->write(); ?> diff --git a/shared/functions/xhtmlemail.php b/shared/functions/xhtmlemail.php index f07c99a..2e71388 100644 --- a/shared/functions/xhtmlemail.php +++ b/shared/functions/xhtmlemail.php @@ -14,6 +14,7 @@ function xhtmlemail($to,$from,$subj,$cont,$inheads=null) { } $cont='<?xml version="1.0" encoding="utf-8"?>'."\n".'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n".'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'.$cont.'</html>'."\n"; $heads.='Content-length: '.strlen($cont)."\r\n"; + debug('mail', $heads.$cont); return mail($to,$subj,$cont,$heads); } ?> @@ -1,3 +1,4 @@ +CLI interface to backend? (Or cli interface to frontend...) Find kernels Have backend handle builds that it finds to already be running (break in to steps and store current status) Make frontend package adding a little more user-friendly (ajax or client-side js search) @@ -12,10 +13,10 @@ Either make task status a TEXT or stop putting command name in the status (via t Consider saving env. passed to tasks, path if we ever use it Add metadata back to logviewer Do like wikipedia and put the header in the footer so important parts load first -Add email notifications to backend Add configurable groups of suggested packages to frontend, backend Add a statistics page Add cleanup functions to the frontend and backend Separate variables we got from the URL from the rest, stop using $request, instead keep super globals and strip slashes on them Replace STDOUT, STDERR, echo in backend with variable - either STDOUT, STDERR, or file Go back and figure out what should be log_msg and what should be debug, etc. +Support ~arch installation or remove it from listings |