-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
186 lines (158 loc) · 7.21 KB
/
index.php
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
define("SITEHTML", getcwd()."/");
require_once(SITEHTML."/cfg.php");
$login = isset($_POST['userid']);
if($login) {
require_once(SITEHTML."/class/validate.class.php");
$err[0] = false; //wrong username or password
$err[1] = false; //validation is set to 0
$userid = $db->real_escape_string(trim($_POST['userid']));
//Check for duplicate login ID
$qry = "SELECT id, phash, validated FROM users WHERE username='$userid' OR mail='$userid'";
$res = $db->query($qry);
if($res && $res->num_rows == 1) {
$userinfo = $res->fetch_object();
require_once(SITEHTML."class/passwordhash.class.php");
$phpass = new PasswordHash(8, FALSE);
$passed = $phpass->CheckPassword($_POST['pass'], $userinfo->phash);
unset($phpass); //remove object
if($passed) {
if($userinfo->validated) {
session_regenerate_id();
$_SESSION['USER_ID'] = $userinfo->id;
session_write_close();
header("location: ".SITEISO);
exit();
} else {
unset($userinfo);
$err[1] = true;
}
} else {
unset($userinfo);
$err[0] = true;
}
} else {
unset($userinfo);
$err[0] = true;
}
}
/*------------------------------------*/
/* Meta tags (individual) */
//Regular
$info["title"]="";
$info["description"]="Description";
$info["keywords"]="Key,words";
//Robots
$info["robots"]=array("index"=>false,"follow"=>false,"archive"=>false);
/*------------------------------------*/
//Require the html head
require(SITEHTML."comp/html-head.php");
?>
<div class='main'>
<?php
if($user) {
echo '<div id="left-menu" class="lftcol"><ul>';
$qry = sprintf("SELECT iso FROM lingual_rights WHERE user_id = '%d';", $user->id);
$res = $db->query($qry);
if($res && $res->num_rows) {
echo '<li><a href="'.SITEISO.'translate/en/'.$res->fetch_object()->iso.'/1/" title="'.$lingual->get_text(2373).'" class="translate">'.$lingual->get_text(2418).'</a></li>';
}
$qry = sprintf("SELECT superuser FROM users WHERE id = '%d';", $user->id);
$res = $db->query($qry);
if($res && $res->num_rows && $res->fetch_object()->superuser) {
echo '<li><a href="'.SITEISO.'users/" title="Overview of users" class="translate">Overview of users</a></li>';
}
echo '<li class="lower"><a class="logout" href="'.SITEISO.'logout.php">'.$lingual->get_text(2419).'</a></li>';
echo '</ul></div>';
echo '<div class="midcol"><div class="content">';
require_once(SITEHTML."class/project.class.php");
$project = new Project($db, LANG_ISO, $user->id);
if(isset($_POST['cmd']) && $_POST['cmd'] = "rm_prj") {
$project->del_project(substr($_POST['actid'], 1), $_POST['actname']);
}
$curpro = $project->get_projects();
echo '<h1>'.$lingual->get_text(2415).'</h1>';
echo '<p>'.$lingual->get_text(2416).'</p><br />';
for($i = 0; $i < count($curpro); $i++) {
echo '<div class="projectcon"><a href="'.SITEISO.'project/'.$curpro[$i]["id"].'/" title="'.$curpro[$i]["name"].'" class="projectbar">'.$curpro[$i]["name"].'</a><a href="#'.$curpro[$i]["id"].'" title="Delete the project '.$curpro[$i]["name"].'" class="deleteproject deleteicon"> </a></div>';
}
echo '<div><a href="'.SITEISO.'new-project/" title="'.$lingual->get_text(2417).'" class="projectbar">'. $lingual->get_text(2417).'</a></div>';
echo '<div class="delsure hide" id="delsure">';
echo '<a href="#" class="close"> </a>';
echo '<h3>Are you ABSOLUTELY sure?</h3>';
echo '<p>This will <strong>DELETE</strong> the project and any data it may contain. This action CANNOT be undone.</p><br />';
echo '<p>Please type in the name of the project to confirm the action.</p>';
echo '<form method="post"><input type="text" name="prjname" id="prjname" />';
echo '<input type="hidden" name="actname" id="actname" value="" />';
echo '<input type="hidden" name="actid" id="actid" value="" />';
echo '<input type="hidden" name="cmd" value="rm_prj" />';
echo '<a href="#" class="btn btngray" id="sbmt">Delete this project</a>';
echo '</form>';
echo '<script type="text/javascript">'."\n".'$(document).ready(function() {';
echo '$(".deleteproject").click(function() {
$("#actname").attr("value", $(this).parent().children(".projectbar").eq(0).html());
$("#actid").attr("value", $(this).attr("href"));
$(".delsure").toggleClass("hide");
return false;
});';
echo '$("#prjname").keyup(function() {
if($("#actname").attr("value") == $(this).val()) {
$("#sbmt").attr("class", "btn btnred");
} else {
$("#sbmt").attr("class", "btn btngray");
}
return false;
});';
echo '$("#sbmt").click(function() {
if ($("#sbmt").attr("class") == "btn btnred") {
$(this).parent().submit();
} else {
return false;
}
});';
echo '});'."\n".'</script>';
echo '</div>';
echo '<br /><p>'.$lingual->get_text(2372).'</p>';
echo '</div>';
echo '</div>';
} else {
echo '<div class="bigcol1"><div class="content">';
echo '<h1>Getting Started!</h1>';
echo '<p>Learn about surprise project<br /><br />
<ol>
<li>Watch the 5 Minutes video presentation of surprise</li>
<li>Sign up for an account</li>
<li>Login and start your awesome process</li>
</ol>
</p>';
echo '<hr style="margin-top:30px; display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0;" />';
echo '<h1>Video presentation</h1>';
echo '<p>Learn about the theAwesomeName <br /><br />
<div style="text-align:center;">
<img src="./tmp/video.png" alt="video" />
</div>
</p>';
echo '</div></div>';
echo '<div id="login" class="rgtcol3">';
echo '<form method="post" action="'.SITEISO.'" class="loginform">';
echo '<fieldset>';
echo '<legend>'.$lingual->get_text(2408).'</legend>';
if($login && $err[0]) echo '<span style="margin-left:5%; color:red;">'.$lingual->get_text(2402).'</span>';
else if($login && $err[1]) echo '<span style="margin-left:5%; color:red;">Please confirm your email before you loging in</span>';
echo '<ul>'.'<li>'.'<label for="userid">'.$lingual->get_text(2403).'</label><input type="text" id="userid" name="userid" value="'.($login ? $_POST["userid"] : '').'" />';
/* if(isset($errmsg["userid"])) echo "<p>".$errmsg["userid"]."</p>"; */
echo '</li><li>';
echo '<label for="pass">'.$lingual->get_text(2404).'</label>';
echo '<input type="password" id="pass" name="pass" value="'.($login ? $_POST["pass"] : '').'" />';
/* if(isset($errmsg["pass"])) echo "<p>".$errmsg["pass"]."</p>"; */
echo '</li></ul>';
echo '<input type="submit" name="Submit" value="'.$lingual->get_text(2407).'" />';
/* echo '<p class="signup">Forgot your <a href="'.SITEISO.'forgotpass.php">password</a> ?</p>'; */
echo '<p class="signup">'.$lingual->get_text(2405).' <a href="'.SITEISO.'signup.php">'.$lingual->get_text(2406).'</a></p>';
echo '</fieldset>';
echo '</form>';
echo '</div></div>';
}
//Require the html foot
require(SITEHTML."comp/html-foot.php");
?>