Only show new players from the last 45 days
[e-DoKo.git] / include / welcome.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Arun Persaud <arun@nubati.net>
3  *
4  *   This file is part of e-DoKo.
5  *
6  *   e-DoKo is free software: you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, either version 3 of the License, or
9  *   (at your option) any later version.
10  *
11  *   e-DoKo is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 /* make sure that we are not called from outside the scripts,
22  * use a variable defined in config.php to check this
23  */
24 if(!isset($HOST))
25   exit;
26
27 /* this outputs the default home page with some extra statistics on it */
28
29 $pre[0]=0;$game[0]=0;$done[0]=0;
30
31 $r=DB_query("SELECT COUNT(*) FROM Game where status='pre'");
32 if($r)  $pre  = DB_fetch_array($r);
33
34 $r=DB_query("SELECT COUNT(*) FROM Game where status='play'");
35 if($r)  $game  = DB_fetch_array($r);
36
37 $r=DB_query("SELECT COUNT(*) FROM Game where status='gameover'");
38 if($r)  $done  = DB_fetch_array($r);
39
40
41 $r=DB_query("SELECT AVG(datediff(mod_date,create_date)) FROM Game where status='gameover' ");
42 if($r)
43   $avgage= DB_fetch_array($r);
44  else
45    $avgage[0]=0;
46
47 $pre    = $pre[0];
48 $game   = $game[0];
49 $done   = $done[0];
50 $avgage = $avgage[0];
51
52 echo "\n\n<div class=\"login\">\n";
53
54 ?>
55   <div class="jumbotron">
56   <h1>E-DoKo</h1>
57   <p>Play Doppelkopf online</p>
58   <p> For more information please visit our <a href="<?php echo "$WIKI"; ?>">wiki</a> or just log in. </p>
59   </div>
60
61
62   <ul class="loginregister nav nav-tabs">
63   <li class="active"><a href="#login" data-toggle="tab"> Login </a></li>
64   <li><a href="#register" data-toggle="tab"> Register</a> </li>
65   </ul>
66
67   <div class="tab-content">
68   <div class="tab-pane active" id="login">
69   <form class="loginregister form-inline" action="index.php?action=login" method="post">
70   <fieldset>
71       <input type="email"    id="email"    name="email"    size="20" maxlength="30" placeholder="email" autofocus />
72       <input type="password" id="password" name="password" size="20" maxlength="30" placeholder="password"/>
73 <?php
74   if($OPENIDPATH)
75     {?>
76     <br /> or use openid <br />
77     <input type="text" id="openid_url" name="openid_url" size="20" maxlength="50" placeholder="http://username.openid.net"/>
78          <span class="help-bloc">See <a href="http://openid.net">openid.net</a> for more information</span>.
79     <hr />
80     <input type="submit" class="submitbutton" name="login"  value="login" />
81     <input type="submit" class="button"       name="forgot" value="Forgot your password?" />
82 <?php }?>
83   </fieldset>
84   </form>
85    </div>
86
87   <div class="tab-pane" id="register">
88
89 <?php
90      /* check for openid information */
91      $openid_url = '';
92      $name       = '';
93      $email      = '';
94      if(myisset('openid_url'))
95        $openid_url = $_REQUEST['openid_url'];
96      if(myisset('openidname'))
97        $name       = $_REQUEST['openidname'];
98      if(myisset('openidemail'))
99        $email      = $_REQUEST['openidemail'];
100
101      echo '  <form class="loginregister form-horizontal doregister" action="index.php?action=register" method="post">'; echo "\n";
102      echo '  <fieldset>'; echo "\n";
103      echo '     <div class="form-group">'; echo "\n";
104      echo '     <label for="Rfullname">Full name:</label>'; echo "\n";
105      echo "     <input type=\"text\" id=\"Rfullname\" name=\"Rfullname\" size=\"20\" maxlength=\"30\" value=\"$name\" /> <br />\n";
106      echo "     </div>\n";
107      echo '     <div class="form-group">'; echo "\n";
108      echo '     <label for="Remail">Email:</label>'; echo "\n";
109      echo "     <input type=\"email\" id=\"Remail\" name=\"Remail\" size=\"20\" maxlength=\"30\" value=\"$email\" />  <br />\n";
110      echo "     </div>\n";
111      echo '     <div class="form-group">'; echo "\n";
112      if($openid_url=='')
113        {
114          echo '     <label for="Rpassword">Password:</label>'; echo "\n";
115          echo '     <input type="password" id="Rpassword" name="Rpassword" size="20" maxlength="30" />'; echo "<br />\n";
116        }
117      else
118        {
119          echo '    <label for="Ropenid">OpenId:</label>'; echo "\n";
120          echo '    <input type="text" id="Ropenid" name="Ropenid" size="20" maxlength="50" value="'.htmlentities($openid_url).'" /> <br />'; echo "\n";
121        }
122      echo "     </div>\n";
123      echo '     <div class="form-group">'; echo "\n";
124      echo '     <label for="Rtimezone">Timezone:</label>'; echo "\n";
125      output_select_timezone("Rtimezone");
126      echo "     </div>\n";
127
128      /* random number to select robotproof question */
129      $rand_number = mt_rand(0,3); /* to get numbers between 0 and 4  */
130      $Robotproof = "Robotproof".$rand_number;
131 ?>
132     <p>Please answer this anti-spam question:</p>
133     <div class="form-group">
134     <label for="Robotproof">  <?php echo output_robotproof($rand_number); ?></label>
135 <?php
136          echo "    <input type=\"text\" id=\"Robotproof\" name=\"$Robotproof\" size=\"20\" maxlength=\"30\" /> <br />\n";
137 ?>
138     </div>
139     <input type="submit" class="submitbutton" value="register" />
140
141 <?php
142        if($openid_url=='')
143          echo "  <p><strong> IMPORTANT: passwords are going over the net as clear text, so pick an easy password. ".
144            "No need to pick anything complicated here ;)</strong></p>\n";
145
146      echo "  <p><strong>N.B. Your email address will be visible to players you play games with.</strong></p>\n";
147 ?>
148   </fieldset>
149   </form>
150    </div>
151    </div>
152
153 <?php
154   echo "<hr />";
155 echo "<div class=\"welcomestats\">\n";
156 echo "<h4>Some statistics:</h4>\n";
157
158 if($pre == 0)
159   echo "<p> At the moment there are no games that are being started ";
160  else if($pre==1)
161    echo "<p> At the moment there is one game that is being started ";
162  else
163    echo "<p> At the moment there are $pre games that are being started ";
164
165 echo "and ";
166
167 if($game==0)
168   echo "zero games that are ongoing. ";
169  else if($game==1)
170    echo "one game that is ongoing. ";
171  else
172    echo "$game games that are ongoing. ";
173
174 echo "<br />\n";
175
176 if($done==0)
177   echo "No game has been completed on this server. </p>";
178  else if($done==1)
179    echo "One game has been completed on this server. </p>";
180  else
181    echo "$done games have been completed on this server. Average time of a game: $avgage days</p>\n";
182 ?>
183 </div>
184 </div>