From d30af6c9816b549787a930ddda9478c7af2332a9 Mon Sep 17 00:00:00 2001 From: dmorley Date: Sun, 1 Feb 2015 18:18:40 -0800 Subject: [PATCH] start of an edit feature for podmins --- db/edit.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ db/gettoken.php | 44 ++++++++++++++++++++++++++++++++++++ db/tables.sql | 3 +++ index.php | 4 +++- 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 db/edit.php create mode 100644 db/gettoken.php diff --git a/db/edit.php b/db/edit.php new file mode 100644 index 0000000..e38084e --- /dev/null +++ b/db/edit.php @@ -0,0 +1,60 @@ + $_GET['token']) { +echo "token not a match";die; +} +if ($row["tokenexpire"] < date("Y-m-d H:i:s", time())) { +echo "token expired";die; +} + + +echo "Authorized to edit " . $domain . " until " .$row["tokenexpire"] . "
"; +echo "Stats URL
"; +echo "Email
"; + +echo "Weight This lets you weight your pod lower on the list if you have too much trafic coming in
"; +echo "save button goes here


"; + +echo "delete button with big warning its forever
"; +} +if ($sfsdthis == 1) { +$expire = date("Y-m-d H:i:s", time() + 7000); + $sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'"; + $result = pg_query_params($dbh, $sql, array($uuid,$expire)); + if (!$result) { + die("Error in SQL query: " . pg_last_error()); + } + $to = $_POST["email"]; + $subject = "Temporary edit key for poduptime "; + $message = "Link: https://podupti.me/db/edit.php?domain=" . $_POST["domain"] . "&token=" . $uuid . " Expires: " . $expire . "\n\n"; + $headers = "From: support@diasp.org\r\n"; + @mail( $to, $subject, $message, $headers ); + + echo "Link sent to your email"; + pg_free_result($result); + pg_close($dbh); +} +?> diff --git a/db/gettoken.php b/db/gettoken.php new file mode 100644 index 0000000..0156e4a --- /dev/null +++ b/db/gettoken.php @@ -0,0 +1,44 @@ + $_POST['email']) { +echo "email not a match";die; +} + } + +$uuid = md5(uniqid($domain, true)); +$expire = date("Y-m-d H:i:s", time() + 700); + $sql = "UPDATE pods SET token=$1, tokenexpire=$2 WHERE domain = '$domain'"; + $result = pg_query_params($dbh, $sql, array($uuid,$expire)); + if (!$result) { + die("Error in SQL query: " . pg_last_error()); + } + $to = $_POST["email"]; + $subject = "Temporary edit key for podupti.me"; + $message = "Link: https://podupti.me/db/edit.php?domain=" . $_POST["domain"] . "&token=" . $uuid . " Expires: " . $expire . "\n\n"; + $headers = "From: support@diasp.org\r\n"; + @mail( $to, $subject, $message, $headers ); + + echo "Link sent to your email"; + pg_free_result($result); + pg_close($dbh); + +?> diff --git a/db/tables.sql b/db/tables.sql index 240b3f6..a93eda2 100644 --- a/db/tables.sql +++ b/db/tables.sql @@ -39,7 +39,10 @@ CREATE TABLE pods ( service_twitter booleen, service_tumblr booleen, service_wordpress booleen, + token text, + tokenexpire timestamp, comment_counts int, + weight int DEFAULT 10, dateUpdated timestamp DEFAULT current_timestamp, dateLaststats timestamp DEFAULT current_timestamp, dateCreated timestamp DEFAULT current_timestamp diff --git a/index.php b/index.php index 192a87e..c1e2241 100644 --- a/index.php +++ b/index.php @@ -85,7 +85,7 @@ if ($detect->isMobile()) {echo '' ?>
- Pod Host? Click here to add your listing.
+ Pod Host? Click here to add/edit your listing.
Data last refreshed at: Pacific Time
@@ -104,6 +104,8 @@ if ($detect->isMobile()) {echo '' Your Email:
+ Need to edit somehing?
+
Pod Domainname:Registered Email:

Is your pod missing? If the server can not get a diaspora session its on the hidden list Show. This is mostly because of selfsigned or openca certs, if you need a free ssl cert get one from startssl.com.
-- GitLab