diff options
-rw-r--r-- | css/v2/login.css | 75 | ||||
-rw-r--r-- | css/v2/signup.css | 32 | ||||
-rw-r--r-- | frontend/lib/d-files.php | 1 | ||||
-rw-r--r-- | frontend/lib/session.class.php | 26 | ||||
-rw-r--r-- | frontend/login.php | 9 | ||||
-rw-r--r-- | frontend/signup.php | 153 | ||||
-rw-r--r-- | js/v2/login.js | 3 |
7 files changed, 150 insertions, 149 deletions
diff --git a/css/v2/login.css b/css/v2/login.css index 1804f41..201bfa4 100644 --- a/css/v2/login.css +++ b/css/v2/login.css @@ -18,7 +18,6 @@ ul, p { text-decoration: underline; cursor: pointer; } - .deadlink { color: #eae3d7; font-size: 90%; @@ -37,13 +36,12 @@ ul, p { top: 50px; text-align: center; } - #main a { color: #eae3d7; font-size: 90%; } -#signIn { +.box { position: absolute; padding: 3px; right: 5px; @@ -58,80 +56,33 @@ ul, p { filter: alpha(opacity=85); display: none; } - -#signIn table { - margin-left: auto; - margin-right: auto; -} - -#openid_identifier { - background: url(images/openid.png) no-repeat; - background-color: #fff; - background-position: 0 50%; - color: #000; - padding-left: 18px; -} - -#registration { - position: absolute; - padding: 3px; - right: 5px; - top: 5px; - width: 300px; - min-width: 250px; - min-height: 100px; - max-width: 600px; - max-height: 400px; - background-color: black; - opacity: 0.85; - filter: alpha(opacity=85); - display: none; -} -#registration table { - margin-left: auto; - margin-right: auto; -} - -#passwordRecovery { - position: absolute; - padding: 3px; - right: 5px; - top: 5px; - width: 300px; - min-width: 250px; - min-height: 100px; - max-width: 600px; - max-height: 400px; - background-color: black; - opacity: 0.85; - filter: alpha(opacity=85); - display: none; +.box.v { + display: block !important; + padding: 7px; } -#passwordRecovery table { +.box table { margin-left: auto; margin-right: auto; } #about { - position: absolute; padding: 7px; - right: 5px; - top: 5px; - width: 300px; height: 255px; - max-width: 600px; - max-height: 400px; text-align: left; - background-color: black; - opacity: 0.85; - filter: alpha(opacity=85); - display: none; overflow: auto; } #about p { text-align: justify; } +#openid_identifier { + background: url(images/openid.png) no-repeat; + background-color: #fff; + background-position: 0 50%; + color: #000; + padding-left: 18px; +} + #message { position: relative; margin-left: auto; diff --git a/css/v2/signup.css b/css/v2/signup.css deleted file mode 100644 index 68a5111..0000000 --- a/css/v2/signup.css +++ /dev/null @@ -1,32 +0,0 @@ -body { - background-color: black; - color: white; - text-align: center; -} - -.smaller { - font-size: smaller; -} - -.warning { - color: red; - font-weight: bold; -} - -#box { - position: relative; - width: 80%; - max-width: 600px; - top: 50px; - border: 2px solid #339933; - margin-left: auto; - margin-right: auto; -} -#box a { - color: #eae3d7; - font-size: smaller; -} -#box table { - margin-left: auto; - margin-right: auto; -} diff --git a/frontend/lib/d-files.php b/frontend/lib/d-files.php index d3445bd..cc94d04 100644 --- a/frontend/lib/d-files.php +++ b/frontend/lib/d-files.php @@ -43,7 +43,6 @@ $files = array ('bt' => array ('js', array ('js/v2/i18n.js', 'css/v2/niftyCorners.css')), 'css.login' => array ('css', array ('css/v2/login.css')), 'css.notice' => array ('css', array ('css/v2/notice.css')), - 'css.signup' => array ('css', array ('css/v2/signup.css')), 'css.cswindow' => array ('css', array ('css/v2/cswindow.css')), 'dir' => array ('xml', array ('gen/directory.xml')), 'popular' => array ('xml', array ('gen/popular.xml')) diff --git a/frontend/lib/session.class.php b/frontend/lib/session.class.php index 683bf73..7365ed3 100644 --- a/frontend/lib/session.class.php +++ b/frontend/lib/session.class.php @@ -220,7 +220,7 @@ class Session { $db->query ("SELECT id FROM user WHERE email='".$db->escape ($email)."'"); if ($db->next_record ()) { - return _("To enable OpenID support, please visit Menu/User Settings/Manage your OpenIDs."); + return _("To enable OpenID support, please visit Menu/User Settings/Linked Accounts."); } $res = rpNewSendEmail ($email, uniqid (rand(), true), $identity); @@ -239,8 +239,28 @@ class Session break; } } - else - return _("New OpenID accounts without email address are not supported."); + else { + /* + * New account via OpenID. + */ + $db->query ("SELECT id, hash FROM registration WHERE openid_identity='". + $db->escape ($identity)."'"); + if (!$db->next_record ()) { + $hash = sha1 (time().$identity.rand()); + $pass = uniqid (rand(), true); + $db->query ("INSERT INTO registration SET rdate=UTC_TIMESTAMP(), ". + "hash='".$hash."', pass='".$pass."', openid_identity='". + $db->escape ($identity)."'"); + } + else { + $hash = $db->f ('hash'); + } + if (isset ($_SERVER['HTTPS'])) + redirect ($CONF['secureProto'].'://'.$CONF['site']. + '/signup?hash='.$hash); + else + redirect ('http://'.$CONF['site'].'/signup?hash='.$hash); + } } function fb_login (&$fb, $fb_uid, $insideFB=false) diff --git a/frontend/login.php b/frontend/login.php index 095634d..c34ab9a 100644 --- a/frontend/login.php +++ b/frontend/login.php @@ -175,7 +175,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml">'; <body> <div id="main"> -<div id="signIn"> +<div id="signIn" class="box"> <form id="f1" action="<?php echo $CONF['secureProto'].'://'.$CONF['site'].'/login'; ?>" method="post"> <table width="100%" border="0"> <tr id="trCEmail" class="hidden"> @@ -257,7 +257,6 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml">'; <script type="text/javascript"> var addthis_config = { username: 'wojciechpolak', - ui_cobrand: 'Cheetah News', ui_header_color: '#ffffff', ui_header_background: '#000000', data_track_clickback: false, @@ -279,7 +278,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml">'; </table> </form> </div> -<div id="passwordRecovery"> +<div id="passwordRecovery" class="box"> <form id="f2" action="login" method="post"> <table width="100%" border="0"> <tr><td colspan="2"><?php echo _('Password Recovery'); ?></td></tr> @@ -304,7 +303,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml">'; </table> </form> </div> -<div id="registration"> +<div id="registration" class="box"> <form action="<?php echo $CONF['secureProto'].'://'.$CONF['site'].'/login'; ?>" method="post"> <table width="100%" border="0"> <tr><td colspan="2"><?php echo _('Registration Process'); ?></td></tr> @@ -335,7 +334,7 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml">'; </table> </form> </div> -<div id="about"> +<div id="about" class="box"> <p style="font-weight:bold;text-align:left"> <?php printf (_("Bleeding-Edge Personal News Aggregator %s"), 'v2'); ?> </p> diff --git a/frontend/signup.php b/frontend/signup.php index 2df4c51..3522bf5 100644 --- a/frontend/signup.php +++ b/frontend/signup.php @@ -19,11 +19,14 @@ */ require_once 'lib/include.php'; +require_once 'lib/d-sigs.php'; +require_once 'lib/register.php'; start_session ('no'); getvars ('hash'); -postvars ('Confirm,Decline'); +postvars ('Confirm,Decline,cEmail'); +$cEmail = htmlspecialchars (strip_tags ($cEmail)); $layout = ''; $message = ''; @@ -43,45 +46,78 @@ if (!empty ($hash)) $pass = $db->f ('pass'); $openid_identity = $db->f ('openid_identity'); - $db->query ("SELECT email FROM user WHERE email='".$email."'"); - if ($db->next_record ()) { - $message = _('Account already exists.'); + if (strlen ($openid_identity) > 36) + $olabel = substr ($openid_identity, 0, 36).'...'; + else + $olabel = $openid_identity; + + if (empty ($email)) { + if (!empty ($cEmail)) { + $res = rpNewSendEmail ($cEmail, uniqid (rand(), true), $openid_identity); + switch ($res) { + case 0: + $db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'"); + $message = _('A registration confirmation e-mail has been sent to you.'); + break; + case -1: + $message = _('Please specify a valid e-mail address.'); + $layout = 'needEmail'; + break; + case -2: + $message = _('Service temporarily unavailable. Please try again later.'); + $layout = 'needEmail'; + break; + case -3: + $message = _('That account already exists. Please visit Menu/User Settings/Linked Accounts.'); + $layout = 'needEmail'; + break; + } + } + else { + $layout = 'needEmail'; + } } else { - if ($Confirm) { - $db->query ("INSERT INTO user SET email='".$email."', pass='".$pass."'"); - $db->query ("SELECT LAST_INSERT_ID() as last_id FROM user"); - if ($db->next_record ()) { - $last_id = $db->f ('last_id'); + $db->query ("SELECT email FROM user WHERE email='".$email."'"); + if ($db->next_record ()) { + $message = _('Account already exists.'); + } + else { + if ($Confirm) { + $db->query ("INSERT INTO user SET email='".$email."', pass='".$pass."'"); + $db->query ("SELECT LAST_INSERT_ID() as last_id FROM user"); + if ($db->next_record ()) { + $last_id = $db->f ('last_id'); + } + + if (!empty ($openid_identity)) { + $db->query ("INSERT INTO openid SET userid='".$last_id. + "', identity='".$openid_identity."'"); + } + + $db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'"); + + $session->id = $last_id; + $session->email = $email; + $session->pass = $pass; + $session->lang = 'null'; + $session->status['afterlogged'] = 'yes'; + $session->status['iflogged'] = 'yes'; + $_SESSION['session'] = $session; + + redirect ($CONF['secureProto'].'://'.$CONF['site'].'/rd'); } - - if (!empty ($openid_identity)) { - $db->query ("INSERT INTO openid SET userid='".$last_id. - "', identity='".$openid_identity."'"); + else if ($Decline) { + $db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'"); + $message = _('Done, rejected.'); } - - $db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'"); - - $session->id = $last_id; - $session->email = $email; - $session->pass = $pass; - $session->lang = 'null'; - $session->status['afterlogged'] = 'yes'; - $session->status['iflogged'] = 'yes'; - $_SESSION['session'] = $session; - - redirect ($CONF['secureProto'].'://'.$CONF['site'].'/rd'); - } - else if ($Decline) { - $db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'"); - $message = _('Done, rejected.'); + else + $layout = 'confirm'; } - else - $layout = 'confirm'; } } else if (!empty ($hash)) - $message = _('Your confirmation period or invitation has expired.'); + $message = _('Your confirmation period has expired.'); } ?> @@ -91,15 +127,43 @@ if (!empty ($hash)) <title>Cheetah News</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="robots" content="noindex,nofollow" /> -<link rel="stylesheet" href="d?q=css.signup" type="text/css" /> +<link rel="stylesheet" href="<?=dsp('css.login')?>" type="text/css" /> <link rel="icon" href="images/favicon.png" type="image/png" /> </head> <body> +<div id="main"> + <?php -if ($layout == 'confirm') { ?> -<div id="box"> -<h2>Cheetah: <?php echo _('Do you confirm signing up?'); echo '<br />('; echo _('account'); ?> <em><?php echo $email; ?></em>)</h2> +if ($layout == 'needEmail') { ?> +<div class="v box left"> +<h3><?php echo _('Please provide your e-mail address. It is required to continue the sign up process.'); ?></h3> +<p><img src="images/openid.png" width="16" height="16" alt="OpenID" /> + <a href="<?=$openid_identity?>" target="_blank"><?=$olabel?></a> +</p> +<form action="signup" method="post"> + <table width="100%" border="0"> + <tr> + <td align="left"> + <input type="hidden" name="hash" value="<?php echo htmlspecialchars ($hash); ?>" /> + <input type="text" name="cEmail" value="<?php echo $cEmail; ?>" maxlength="255" /> + <input type="submit" name="Confirm" value="<?php echo _('Sign Up'); ?>" /> + </td> + </tr> + <tr style="height:10px"><td></td></tr> + <tr> + <td colspan="2" align="left"> + <a href="http://<?php echo $CONF['site']; ?>/privacy" target="_blank"><?php echo _('Privacy Policy'); ?></a> + <a href="http://<?php echo $CONF['site']; ?>/terms_of_service" target="_blank"><?php echo _('Terms of Service'); ?></a> + </td> + </tr> + </table> +</form> +</div> +<?php } else if ($layout == 'confirm') { ?> +<div class="v box"> +<h2><?php echo _('Do you confirm signing up?'); +echo '<br /><span class="smaller">('; echo _('account'); ?> <em><?php echo $email; ?></em>)</span></h2> <form action="signup" method="post"> <table width="100%" border="0"> <tr> @@ -114,21 +178,18 @@ if ($layout == 'confirm') { ?> <tr style="height:10px"><td></td></tr> <tr> <td colspan="2" align="center"> - <a href="http://<?php echo $CONF['site']; ?>/privacy"><?php echo _('Privacy Policy'); ?></a> - <a href="http://<?php echo $CONF['site']; ?>/terms_of_service"><?php echo _('Terms of Service'); ?></a> + <a href="http://<?php echo $CONF['site']; ?>/privacy" target="_blank"><?php echo _('Privacy Policy'); ?></a> + <a href="http://<?php echo $CONF['site']; ?>/terms_of_service" target="_blank"><?php echo _('Terms of Service'); ?></a> </td> </tr> </table> </form> </div> -<?php } else if ($message) { ?> -<div id="box"> - <h2><?php echo $message; ?></h2> - <table width="100%" border="0"> - <tr><td><a href="http://<?php echo $CONF['site']; ?>/"><?php echo _('Sign in'); ?></a></td></tr> - </table> -</div> -<?php } ?> +<?php } +if ($message) + echo '<div id="message">'.$message.'</div>'; +?> +</div><!-- /main --> </body> </html> diff --git a/js/v2/login.js b/js/v2/login.js index d8bf661..06f6ea0 100644 --- a/js/v2/login.js +++ b/js/v2/login.js @@ -69,6 +69,9 @@ GID ('openid_identifier').value = 'https://www.google.com/accounts/o8/id'; else if (authMech == 'auth-yahoo') GID ('openid_identifier').value = 'http://www.yahoo.com/'; + + if (window.location.protocol == 'http:') + this.action = this.action.replace (/https:/, 'http:'); return true; } return false; |