aboutsummaryrefslogtreecommitdiff
path: root/frontend/signup.php
blob: 2df4c510bd9c43482aafb47f9454f223de10f893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php

/*
   Cheetah News signup.php
   Copyright (C) 2005, 2006, 2008, 2010 Wojciech Polak.

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 3 of the License, or (at your
   option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

require_once 'lib/include.php';

start_session ('no');

getvars ('hash');
postvars ('Confirm,Decline');

$layout = '';
$message = '';

if (!empty ($hash))
{
  $db = new Database ();

  /* delete unused, expired entries */
  $db->query ("DELETE LOW_PRIORITY FROM registration WHERE rdate < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 DAY)");

  $db->query ("SELECT email, pass, openid_identity ".
	      "FROM registration WHERE hash='".$db->escape ($hash)."'");
  if ($db->next_record ())
  {
    $email = $db->f ('email');
    $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.');
    }
    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');
      }
      else if ($Decline) {
	$db->query ("DELETE FROM registration WHERE hash='".$db->escape ($hash)."'");
	$message = _('Done, rejected.');
      }
      else
	$layout = 'confirm';
    }
  }
  else if (!empty ($hash))
    $message = _('Your confirmation period or invitation has expired.');
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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="icon" href="images/favicon.png" type="image/png" />
</head>
<body>

<?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>
<form action="signup" method="post">
  <table width="100%" border="0">
    <tr>
      <td align="center" style="width:50%">
	<input type="hidden" name="hash" value="<?php echo htmlspecialchars ($hash); ?>" />
	<input type="submit" name="Confirm" value="<?php echo _('Yes, I confirm'); ?>" />
      </td>
      <td align="center" style="width:50%">
	<input type="submit" name="Decline" value="<?php echo _('No, I decline'); ?>" />
      </td>
    </tr>
    <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>&nbsp;&nbsp;
	<a href="http://<?php echo $CONF['site']; ?>/terms_of_service"><?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 } ?>

</body>
</html>

Return to:

Send suggestions and report system problems to the System administrator.