From b2a7cfb9b152dcad1333b92dde76af3a164af8f6 Mon Sep 17 00:00:00 2001
From: jesse
Date: Fri, 27 May 2011 11:57:02 -0700
Subject: Got image posting finished.
---
.gitignore | 1 +
design/database.sql | 7 +++++
htdocs/new-post.php | 25 +++++++++------
htdocs/postimages.php | 55 ++++++++++++++++++++++++++++++++
htdocs/postings.php | 9 +++++-
htdocs/src/Post.inc.php | 69 +++++++++++++++++++++++++++++++++++------
htdocs/src/PostIterator.inc.php | 2 +-
htdocs/src/config.inc.php | 5 +--
8 files changed, 150 insertions(+), 23 deletions(-)
create mode 100644 htdocs/postimages.php
diff --git a/.gitignore b/.gitignore
index 478fc35..ea6de6c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
**.swp
htdocs/emails.log
tags
+uploads/
diff --git a/design/database.sql b/design/database.sql
index 6bb34da..b79316c 100644
--- a/design/database.sql
+++ b/design/database.sql
@@ -59,6 +59,13 @@ CREATE TABLE post (
UNIQUE KEY(secretid)
);
+CREATE TABLE image (
+ id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
+ post_id INTEGER UNSIGNED NOT NULL,
+
+ PRIMARY KEY(id)
+);
+
CREATE TABLE user (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(60) NOT NULL,
diff --git a/htdocs/new-post.php b/htdocs/new-post.php
index b4dd6ad..7112a8c 100644
--- a/htdocs/new-post.php
+++ b/htdocs/new-post.php
@@ -138,7 +138,8 @@ function finish_post() {
);
$error = '';
- $values = array();
+ $values = array('title' => '', 'description' => '',
+ 'email' => '', 'email2' => '');
foreach ($required as $field => $desc) {
if (!isset($_POST[$field]) or trim($_POST[$field]) == '') {
$error .= "$desc is a required field.
";
@@ -188,9 +189,11 @@ function handle_images() {
function finish_images() {
$post = $_SESSION['newpost'];
- if (isset($_FILES['images']) and is_array($_FILES['images'])) {
- foreach ($_FILES['images'] as $file) {
- $post->addImage($file['tmp_name']);
+ if (isset($_FILES['images'])) {
+ foreach ($_FILES["images"]["error"] as $key => $error) {
+ if ($error == UPLOAD_ERR_OK) {
+ $post->addImage($_FILES['images']['tmp_name'][$key]);
+ }
}
}
@@ -223,21 +226,25 @@ require_once "src/footer.inc.php";
function render_form($error="") {
- global $values;
+
+ $title = isset($_POST['title']) ? $_POST['title'] : '';
+ $description = isset($_POST['description']) ? $_POST['description'] : '';
+ $email = isset($_POST['email']) ? $_POST['email'] : '';
+ $email2 = isset($_POST['email2']) ? $_POST['email2'] : '';
if ($error != '') {
echo "$error
";
}
- echo "";
+ echo "";
echo "";
echo "";
+ . " cols=\"80\">$description
";
- echo "