Compare commits
No commits in common. "de4cbe9ee63762e19dfaace81c91cf4517849c81" and "3bf3b486bff140dd785b3a5df737de8bfdbda9de" have entirely different histories.
de4cbe9ee6
...
3bf3b486bf
4 changed files with 7 additions and 45 deletions
3
Makefile
3
Makefile
|
@ -12,6 +12,3 @@ docker-run: data/
|
|||
FORCE:
|
||||
cp -r src/data ./
|
||||
chmod 777 data
|
||||
|
||||
docker-run-dev: data/ src/
|
||||
docker run -v $(current_dir)src/:/var/www/html/ -v $(current_dir)data/:/var/www/html/data/ -p 8080:80 snuffler/snuffler-web:dev
|
|
@ -102,7 +102,7 @@ class DataBase extends SQLite3 {
|
|||
|
||||
function addPersona($userid, $handle, $name, $about=NULL, $colour=NULL) {
|
||||
$id = hexdec(uniqid());
|
||||
$sql = "INSERT INTO personas (id, userid, handle, name, about, colour) VALUES ('$id', '$userid', '$handle', '$name', '$about', '$colour');";
|
||||
$sql = "INSERT INTO personas (id, userid, handle, name, colour) VALUES ('$id', '$userid', '$handle', '$about', '$colour');";
|
||||
$ret = $this->exec($sql);
|
||||
if(!$ret) {
|
||||
die($this->lastErrorMsg());
|
||||
|
@ -125,9 +125,6 @@ class DataBase extends SQLite3 {
|
|||
return false;
|
||||
}
|
||||
$dbhash = $ret[0];
|
||||
if(!$dbhash) {
|
||||
return false;
|
||||
}
|
||||
return password_verify($password, $dbhash);
|
||||
}
|
||||
|
||||
|
@ -195,19 +192,5 @@ class DataBase extends SQLite3 {
|
|||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
function getPersonas($userid=NULL) {
|
||||
if(!$userid) {
|
||||
$userid = $this->getAuthedUserId();
|
||||
}
|
||||
$sql = "SELECT * FROM personas AS persona WHERE userid='$userid' ORDER BY name;";
|
||||
|
||||
$ret = $this->query($sql);
|
||||
$array = array();
|
||||
while ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
|
||||
array_push($array, $row);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -55,16 +55,12 @@ if(!$database) {
|
|||
} else {
|
||||
?>
|
||||
<a href="logout.php">LOG OUT</a>
|
||||
<form id="postform" method="post" action="post.php">
|
||||
<form id="postform">
|
||||
<textarea id="postformtextarea" name="text" rows="5" placeholder="Whatcha snuffin' about?"></textarea><br />
|
||||
<div id="postformactionrow">
|
||||
<select id="persona" name="persona">
|
||||
<?php
|
||||
$personas = $database->getPersonas();
|
||||
foreach($personas as $persona) {
|
||||
echo "<option value=" . $persona['persona.id'] . ">" . $persona['persona.name'] . "</option>";
|
||||
}
|
||||
?>
|
||||
<select id="user" name="user">
|
||||
<option value=0>SYSTEM</option>
|
||||
<option value=1>User</option>
|
||||
</select>
|
||||
<input type="submit" id="submit" name="submit" value="Snuff!" />
|
||||
</div>
|
||||
|
@ -84,8 +80,8 @@ $posts = array_reverse($database->getPosts());
|
|||
foreach($posts as $post) {
|
||||
echo '<div class="post">';
|
||||
echo '<div class="postinfo">';
|
||||
echo $post["user.name"] . ': <strong>' . $post["persona.name"] . '</strong>';
|
||||
echo '<br><small>@' . $post["user.handle"] . '@' . $post["persona.handle"] . '</small>';
|
||||
echo '<strong>' . $post["user.name"] . '</strong>';
|
||||
echo '<br><small>@' . $post["user.handle"] . '</small>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<p>' . $post["post.text"] . '</p>';
|
||||
|
|
14
src/post.php
14
src/post.php
|
@ -1,14 +0,0 @@
|
|||
<?php
|
||||
if (empty($_POST) || !isset($_POST['submit'])) {
|
||||
die("Post canceled: no post / no submit");
|
||||
}
|
||||
|
||||
require_once('inc/database.php');
|
||||
$db = new DataBase();
|
||||
$userid = $db->getAuthedUserId();
|
||||
$persid = $_POST['persona']; // TODO: CHECK OWNERSHIP! (db schema?)
|
||||
if($userid) {
|
||||
$db->addPost($_POST['text'], $userid, $persid);
|
||||
}
|
||||
header("Location: /");
|
||||
?>
|
Loading…
Reference in a new issue