예제 #1
0
}
if (isset($_SESSION['image_filename']) == false) {
    show_error_redirect_back("Error uploading image!  A session variable is missing set, so either there was a session timeout or you tried to reload the page.  Please try again.");
}
$image_filename = $_SESSION['image_filename'];
$_SESSION['image_filename'] = null;
if (isset($_POST['category_id']) == false || is_numeric($_POST['category_id']) == false) {
    show_error_redirect_back("Error -- category wasn't found");
}
$title = mysql_escape_string(htmlentities(trim($_POST['title'])));
$caption = mysql_escape_string(nl2br(htmlentities(trim($_POST['caption']))));
$category = get_category_by_category_id($_POST['category_id'], $db_read);
if (validate_title($title) == false) {
    show_error_redirect_back("Invalid title.  Titles have to be 0-{$max_length_title} characters.");
}
if (validate_comment($caption) == false) {
    show_error_redirect_back("Invalid caption.  Captions have to be 0-{$max_length_comment} characters.");
}
# Make sure he's uploading to his own category
$result = try_mysql_query("SELECT * FROM categories WHERE user_id='" . $me['user_id'] . "' AND category_id='" . $category['category_id'] . "'", $db_read);
if (mysql_num_rows($result) == 0) {
    show_error_redirect_back("Invalid category.");
}
mysql_free_result($result);
# Insert the new picture
try_mysql_query("INSERT INTO pictures (category_id, title, filename, caption, date_added) VALUES ('" . $category['category_id'] . "', '{$title}', '{$image_filename}', '{$caption}', NOW())", $db_write);
$picture_id = mysql_insert_id($db_write);
# Update the las modified category (used for the default selection in the category combo)
try_mysql_query("UPDATE users SET last_category='" . $category['category_id'] . "' WHERE user_id='" . $me['user_id'] . "'", $db_write);
# Update the last modified time for the private user/category
try_mysql_query("UPDATE users SET last_updated=NOW() WHERE user_id='" . $me['user_id'] . "'", $db_write);
예제 #2
0
<?php

// meta tags for head section
$article_meta_title = !empty($article['seo_title']) ? $article['seo_title'] : $article['title'] . ' - ' . $config['site']['title'];
$config['site']['meta_title'] = $article_meta_title;
$config['site']['meta']['description'] = !empty($article['seo_desc']) ? $article['seo_desc'] : $article['summary'];
$config['site']['meta']['keywords'] = !empty($article['seo_keywords']) ? $article['seo_keywords'] : $config['meta']['keywords'];
$config['site']['meta']['author'] = $article['author_name'];
// hide or disable comments?
$hide_comments = $config['comments']['site_hide'] + $article['comments_hide'];
$disable_comments = $config['comments']['site_disable'] + $article['comments_disable'];
if (empty($disable_comments)) {
    $post_errors = isset($_POST['submit_comment']) ? validate_comment($config['comments']['form_protection'], $article) : '';
}
// output article
echo show_article($article, $config);
// output article comments
/*
	$config['comments']['site_hide']
	$config['comments']['site_disable']
	$config['comments']['form_protection']
	$config['comments']['moderate']
	$config['comments']['allow_html']
	
	$article['comments_disable']
	$article['comments_hide']
*/
if (empty($hide_comments)) {
    echo show_article_comments($article['comments']);
}
// output comment form
예제 #3
0
# post_comment.php
# Post a comment on an image.
#
header('Pragma: no-cache');
require 'shared.php';
# Make a connection to the database
$db_read = get_db_read();
$db_write = get_db_write();
if (!$me) {
    show_error_redirect_back("Please log in first");
}
if (isset($_POST['picture_id']) == false) {
    show_error_redirect_back("Couldn't find picture id");
}
if (isset($_POST['comment']) == false) {
    show_error_redirect_back("Couldn't find comment");
}
$comment = mysql_escape_string(nl2br(htmlentities(trim($_POST['comment']))));
$picture_id = $_POST['picture_id'];
if (validate_comment($comment) == false) {
    show_error_redirect_back("Invalid comment.  Comments have to be 0-{$max_length_comment} characters.");
}
if (is_numeric($picture_id) == false) {
    show_error_redirect_back("Invalid category.");
}
try_mysql_query("INSERT INTO comments (user_id, picture_id, text, date_added) VALUES ('" . $me['user_id'] . "', '{$picture_id}', '{$comment}', NOW())", $db_write);
$user = get_user_from_picture_id($picture_id, $db_read);
if ($user['notify_comments'] == '1') {
    smtp_send(array($user['email']), "OSPAP - New Comment", "New Comment Notification", "A new comment has been posted for one of your pictures!  It was posted by " . $me['username'] . " and can be viewed here:\n" . get_full_path_to("show_picture.php?picture_id={$picture_id}") . "\n\nNote: this is an automatic email, please don't reply.");
}
show_message_redirect("Comment added", "show_picture.php?picture_id={$picture_id}#comments");