From: "Liam McLoughlin" <hexxeh@hexxeh.net>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoaster:webui commit in: /, web/
Date: Fri, 5 Aug 2011 23:37:11 +0000 (UTC) [thread overview]
Message-ID: <ee02363d07131379c1e2537cffa20c453f596cad.hexxeh@gentoo> (raw)
Message-ID: <20110805233711.e5EF1iA7K9xW_3ZIRB4YiRcYVVeKgX6LTQShDOkyTFA@z> (raw)
commit: ee02363d07131379c1e2537cffa20c453f596cad
Author: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
AuthorDate: Fri Aug 5 23:37:00 2011 +0000
Commit: Liam McLoughlin <hexxeh <AT> hexxeh <DOT> net>
CommitDate: Fri Aug 5 23:37:00 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoaster.git;a=commit;h=ee02363d
Add email notification support
---
config.php | 12 +++++++++++-
daemon.php | 28 ++++++++++++++++++++++++++++
web/index.php | 12 ++++++++++++
web/process.php | 7 ++++---
4 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/config.php b/config.php
index 760c1e2..c1807fa 100644
--- a/config.php
+++ b/config.php
@@ -3,6 +3,9 @@
// Gentoaster build daemon settings
// Licensed under GPL v3, see COPYING file
+ // Set the publically viewable URL for this Gentoaster instance
+ define("GENTOASTER_URL", "http://192.168.2.169");
+
// Set the path that completed images should be stored at
define("CONFIGURATIONS_PATH", "/var/www/gentoaster/images");
@@ -26,4 +29,11 @@
define("MYSQL_HOSTNAME", "localhost");
define("MYSQL_USERNAME", "gentoaster");
define("MYSQL_PASSWORD", "");
- define("MYSQL_DATABASE", "gentoaster");
\ No newline at end of file
+ define("MYSQL_DATABASE", "gentoaster");
+
+ // Set the SMTP details that should be used for notifications
+ define("SMTP_ENABLED", false);
+ define("SMTP_HOST", "");
+ define("SMTP_USERNAME", "");
+ define("SMTP_PASSWORD", "");
+ define("SMTP_EMAIL", "");
\ No newline at end of file
diff --git a/daemon.php b/daemon.php
index 65d7d2b..4041317 100644
--- a/daemon.php
+++ b/daemon.php
@@ -4,6 +4,7 @@
// Licensed under GPL v3, see COPYING file
require_once "config.php";
+ require_once "Mail.php";
$worker = new GearmanWorker();
$worker->addServer();
@@ -36,6 +37,33 @@
$stmt->bind_param("sds", $result, $returncode, $handle);
$stmt->execute();
$stmt->close();
+
+ $query = "SELECT id, email FROM builds WHERE handle = ?";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("s", $handle);
+ $stmt->execute();
+ $stmt->bind_result($buildID, $email);
+ $stmt->fetch();
+
+ if($email != null) {
+ $headers = array('From' => SMTP_EMAIL,
+ 'To' => $email,
+ 'Subject' => "Your Gentoaster build has completed");
+
+ $smtp = Mail::factory('smtp',
+ array ('host' => SMTP_HOST,
+ 'auth' => true,
+ 'username' => SMTP_USERNAME,
+ 'password' => SMTP_PASSWORD));
+
+ $body = "Your Gentoaster build has finished.\n\n"
+ ."You can view the results at ".GENTOASTER_URL
+ ."/status.php?uuid=".$buildID;
+
+ $mail = $smtp->send($email, $headers, $body);
+ }
+
+ $stmt->close();
$db->close();
return serialize(array($returncode, $result));
diff --git a/web/index.php b/web/index.php
index dcaae6b..f46af2b 100644
--- a/web/index.php
+++ b/web/index.php
@@ -1,5 +1,6 @@
<?php
require_once "config.php";
+ require_once GENTOASTER_PATH."/config.php";
if (RECAPTCHA_ENABLED) {
require_once "recaptcha.php";
@@ -116,6 +117,17 @@
of your own personalised Gentoo virtual machine
image.</p>
</div>
+ <?php if(SMTP_ENABLED) { ?>
+ <div id="notifications" class="step">
+ <h1>Notifications</h1>
+ Want us to email you when your image has finished toasting?
+ Pop your email in here. If you don't want an email, simply
+ leave this field blank.<br /><br />
+ <label for="notifications_email">E-Mail</label>
+ <br />
+ <input type="text" name="email" id="notifications_email">
+ </div>
+ <?php } ?>
<?php
if (RECAPTCHA_ENABLED) {
?>
diff --git a/web/process.php b/web/process.php
index c590bee..de8ea90 100644
--- a/web/process.php
+++ b/web/process.php
@@ -62,6 +62,7 @@
$features = filter_input(INPUT_POST, "features", FILTER_CALLBACK, $sfi);
$keywords = filter_input(INPUT_POST, "keywords", FILTER_CALLBACK, $sfi);
$outputFormat = filter_input(INPUT_POST, "format", FILTER_CALLBACK, $sfi);
+ $email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
$iniString = "[vmconfig]
@@ -97,10 +98,10 @@ OUTPUT_FORMAT=$outputFormat";
die("Could not connect to database ".mysqli_connect_error());
}
- $query = "INSERT INTO builds (id, handle, ipaddress) ".
- "VALUES(?, ?, ?)";
+ $query = "INSERT INTO builds (id, handle, ipaddress, email) ".
+ "VALUES(?, ?, ?, ?)";
$stmt = $db->prepare($query);
- $stmt->bind_param("sss", $buildID, $handle, $ipaddress);
+ $stmt->bind_param("ssss", $buildID, $handle, $ipaddress, $email);
$stmt->execute();
$stmt->close();
$db->close();
next reply other threads:[~2011-08-05 23:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-12 23:18 Liam McLoughlin [this message]
2011-08-05 23:37 ` [gentoo-commits] proj/gentoaster:webui commit in: /, web/ Liam McLoughlin
-- strict thread matches above, loose matches on Subject: below --
2011-08-15 1:20 [gentoo-commits] proj/gentoaster:master " Liam McLoughlin
2011-08-15 1:17 Liam McLoughlin
2011-08-12 23:18 Liam McLoughlin
2011-08-12 23:17 Liam McLoughlin
2011-08-12 23:17 Liam McLoughlin
2011-07-24 2:43 [gentoo-commits] proj/gentoaster:webui " Liam McLoughlin
2011-08-12 23:17 ` [gentoo-commits] proj/gentoaster:master " Liam McLoughlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee02363d07131379c1e2537cffa20c453f596cad.hexxeh@gentoo \
--to=hexxeh@hexxeh.net \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox