master
rubenwardy 2014-04-21 17:52:21 +00:00
parent 7a41dbbbdf
commit f2b078a2ed
4 changed files with 28 additions and 20 deletions

View File

@ -6,6 +6,14 @@ require "common/common.php";
auth(AUTH_ADMIN);
if ($_GET['id']=="user"){
if (strlen($_POST['username']) > 25)
msgscrn("Username too long","Unable to create that user because the username was too long.");
if (strlen($_POST['first']) > 30)
msgscrn("Firstname too long","Unable to create that user because the first name was too long.");
if (strlen($_POST['sur']) > 30)
msgscrn("Surname too long","Unable to create that user because the surname was too long.");
$user = new User(null);
$user->username = $_POST['username'];
$user->firstname = $_POST['first'];

View File

@ -1,6 +1,6 @@
<?php
// The root url
$root_url = "http://spell.rubenwardy.kd.io/";
$root_url = "http://rubenwardy.kd.io/spelling/";
function burl($page){
global $root_url;
@ -53,7 +53,7 @@ function auth($level){
if ($current_user->rank >= AUTH_PUPIL){
msgscrn("Access Denied","You do not have the authority to do this.<br>Try logging in with ".getAuthLabel($level)." privileges.<p><a class=\"button\" href=\"".burl("logout.php")."\">Log Out</a></p>","","");
}
header("location: /login.php?id=$level");
header("location: ".burl("login.php?id=$level"));
die("");
}
}

View File

@ -26,19 +26,19 @@ if ($_GET['mode']=="prop" && isset($_POST['title']) && $_POST['title']!=""){
$_POST['def']!=""
){
// Add a new word
$w = new Word(null);
$w->testID = $test->id;
$w->word = $_POST['word'];
$w->def = $_POST['def'];
$w->save();
$newword = new Word(null);
$newword->testID = $test->id;
$newword->word = $_POST['word'];
$newword->def = $_POST['def'];
$newword->save();
// Split near word field into elements
$nws = explode(',', $_POST['nearword']);
foreach ($nws as $nw){
$nearword_word = trim($nw);
$nearwords = explode(',', $_POST['nearword']);
foreach ($nearwords as $near){
$nearword_word = trim($near);
if ($nearword_word){
$nearword = new Nearword(null);
$nearword->wordID = $w->id;
$nearword->wordID = $newword->id;
$nearword->word = $nearword_word;
$nearword->save();
}
@ -177,15 +177,15 @@ Nearwords: <input type="text" size="60" name="nearword" /><br>
<tr><th>Answer</th><th>Definition</th><th>Near words</th><th></th></tr>
<?php
// Output table row
function orow($word,$def,$near,$wid){
function orow($word,$def,$near,$wordid){
global $test;
echo "<tr><td style=\"width: 10%;\">$word</td><td style=\"width: 40%;\">$def</td><td style=\"width: 30%;\">$near</td><td><a style=\"width: 20%;\" href=\"edit.php?id={$test->id}&mode=ew&word=$wid\" class=\"button\">Edit</a> <a href=\"edit.php?id={$test->id}&mode=dw&word=$wid\" class=\"button\">Delete</a></td></tr>\n";
echo "<tr><td style=\"width: 10%;\">$word</td><td style=\"width: 40%;\">$def</td><td style=\"width: 30%;\">$near</td><td><a style=\"width: 20%;\" href=\"edit.php?id={$test->id}&mode=ew&word=$wordid\" class=\"button\">Edit</a> <a href=\"edit.php?id={$test->id}&mode=dw&word=$wordid\" class=\"button\">Delete</a></td></tr>\n";
}
$words = $test->words();
foreach ($words as $w){
$nw = "";
$list = $w->nearwords();
foreach ($list as $n){
$nearwords = $w->nearwords();
foreach ($nearwords as $n){
// Add near word to list
$nw .= (($nw=="")?"":", ")."{$n->word}";
}

View File

@ -37,11 +37,11 @@ if ($_POST['submitted']=="true"){
$count += 2;
}else{
// Enter as wrong
$ww = new WrongWord(null);
$ww->wordID = $w->id;
$ww->scoreID = $scores->id;
$ww->word = $guess;
$ww->save();
$wrongword = new WrongWord(null);
$wrongword->wordID = $w->id;
$wrongword->scoreID = $scores->id;
$wrongword->word = $guess;
$wrongword->save();
// Pupil got the word wrong, check for nearwords
$near = $w->nearwords();