From c2776f84d2bbba47dade91fb7a24786715002e15 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 19 May 2013 15:02:05 -0700 Subject: [PATCH] Preparations for e107.org login. --- e107_admin/theme.php | 6 +++ e107_handlers/e_marketplace.php | 90 +++++++++++++++++++++++++++++++++ e107_handlers/theme_handler.php | 16 +++++- 3 files changed, 110 insertions(+), 2 deletions(-) diff --git a/e107_admin/theme.php b/e107_admin/theme.php index b43e28f63..275870f08 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -73,6 +73,12 @@ if(e_AJAX_REQUEST) { switch ($_GET['action']) { + case 'login': + $mp = $themec->getMarketplace(); + echo $mp->renderLoginForm(); + exit; + break; + case 'download': $string = base64_decode($_GET['src']); parse_str($string, $p); diff --git a/e107_handlers/e_marketplace.php b/e107_handlers/e_marketplace.php index 1dc7c2aac..12fd721d2 100644 --- a/e107_handlers/e_marketplace.php +++ b/e107_handlers/e_marketplace.php @@ -38,6 +38,10 @@ class e_marketplace */ public function generateAuthKey($username, $password) { + if(trim($username) == '' || trim($password) == '') + { + return false; + } $this->setAuthKey($this->makeAuthKey($username, $password, true)); return $this; } @@ -65,6 +69,92 @@ class e_marketplace if($plain && !empty($password)) $password = md5($password); return sha1($username.$password.$now); } + + + + /** + * Have the admin enter their e107.org login details in order to create the authorization key. + */ + public function renderLoginForm() + { + + $text = ' +
+
+ + +
+
+
+
+
+ Login +
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
'; + + //TODO Use Form handler for INPUT tags. + //XXX TBD OR do we just redirect to the signup page on the website, in an iframe? + + $text .= ' +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+ '; + + return $text; + } /** * Retrieve currently used adapter diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 4ba20b272..0ef6e7cf9 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -1032,11 +1032,23 @@ class themeHandler $id = $frm->name2id($theme['name']); $LAN_DOWNLOAD = ($theme['price'] > 0) ? "Buy/Download" : "Download"; - $downloadUrl = e_SELF.'?action=download&src='.base64_encode($d);//$url.'&action=download'; + if($this->mp->hasAuthKey()) + { + $action = 'download'; + $caption = "Downloading ".$theme['name']." ".$theme['version']; + } + else + { + $action = 'login'; + $caption = "Please login to your e107.org account to proceed.."; + } + + + $downloadUrl = e_SELF.'?action='.$action.'&src='.base64_encode($d);//$url.'&action=download'; $infoUrl = $url.'&action=info'; //$main_icon = " "; - $main_icon = " "; + $main_icon = " "; $info_icon = "".trim(E_32_CAT_ABOUT).""; if($theme['livedemo'])