Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1371 → Rev 1977

/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/action_preview.php
New file
0,0 → 1,78
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
$previewmessage = $message;
 
if ($attach_count)
{
define('PREVIEW_NO_ATTACHMENT_CLICK',
"javascript:alert('" . $PHORUM["DATA"]["LANG"]["PreviewNoClickAttach"] . "')");
 
// Create the URL and formatted size for attachment files.
foreach ($previewmessage["attachments"] as $nr => $data) {
$previewmessage["attachments"][$nr]["url"] =
phorum_get_url(PHORUM_FILE_URL, "file={$data['file_id']}");
$previewmessage["attachments"][$nr]["size"] =
phorum_filesize($data["size"]);
}
}
 
// Format the message using the default formatting.
include_once("./include/format_functions.php");
$previewmessages = phorum_format_messages(array($previewmessage));
$previewmessage = array_shift($previewmessages);
 
// Recount the number of attachments. Formatting mods might have changed
// the number of attachments we have to display using default formatting.
$attach_count = 0;
if (isset($previewmessage["attachments"])) {
foreach ($previewmessage["attachments"] as $attachment) {
if ($attachment["keep"]) {
$attach_count ++;
}
}
}
 
if ($attach_count)
{
// Disable clicking on attachments in the preview (to prevent the
// browser from jumping to a viewing page, which might break the
// editing flow). This is not done in the previous loop where the
// URL is set, so the formatting code for things like inline
// attachments can be used.
foreach ($previewmessage["attachments"] as $nr => $data) {
$previewmessage["attachments"][$nr]["url"] = PREVIEW_NO_ATTACHMENT_CLICK;
}
} else {
unset($previewmessage["attachments"]);
}
 
// Fill the author name and datestamp for new postings.
if ($mode != "edit" && $PHORUM["DATA"]["LOGGEDIN"]) {
$previewmessage["author"] = $PHORUM["user"]["username"];
$previewmessage["datestamp"] = time();
}
 
// Format datestamp.
$previewmessage["datestamp"] = phorum_date($PHORUM["short_date"], $previewmessage["datestamp"]);
$PHORUM["DATA"]["PREVIEW"] = $previewmessage;
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/request_first.php
New file
0,0 → 1,105
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// Retrieve the message id to work with.
$message_id = 0;
 
if ($mode != "post") {
if (! isset($PHORUM["postingargs"][2])) {
die("Missing message_id parameter in request for mode $mode");
}
$message_id = $PHORUM["postingargs"][2];
}
 
// Create an initial message structure.
$message = array();
foreach ($PHORUM["post_fields"] as $key => $info) {
$message[$key] = $info[pf_INIT];
}
 
// Retrieve the message replied to or the message being edited.
if ($mode != "post")
{
// Check read access on the forum that we're handling.
if (!phorum_check_read_common()) exit;
 
// Retrieve the message from the database. If the message can't be
// retrieved, then return to the message list.
$dbmessage = phorum_db_get_message($message_id);
if (! $dbmessage) {
phorum_redirect_by_url(phorum_get_url(PHORUM_LIST_URL));
exit;
}
}
 
// Set message data for replying to posts.
if ($mode == "reply" || $mode == "quote")
{
// Set thread and parent information.
$message["parent_id"] = $dbmessage["message_id"];
$message["thread"] = $dbmessage["thread"];
 
// Create Re: subject prefix.
if (substr($dbmessage["subject"], 0, 4) != "Re: ") {
$dbmessage["subject"] = "Re: " . $dbmessage["subject"];
}
$message["subject"] = $dbmessage["subject"];
 
// Add a quoted version of the body for quoted reply messages.
if ($mode == "quote")
{
$quoted = phorum_hook("quote", array($dbmessage["author"], $dbmessage["body"]));
 
if (empty($quoted) || is_array($quoted))
{
$quoted = phorum_strip_body($dbmessage["body"]);
$quoted = str_replace("\n", "\n> ", $quoted);
$quoted = wordwrap(trim($quoted), 50, "\n> ", true);
$quoted = "{$dbmessage["author"]} " .
"{$PHORUM["DATA"]["LANG"]["Wrote"]}:\n" .
str_repeat("-", 55) . "\n> $quoted\n\n\n";
}
 
$message["body"] = $quoted;
}
}
 
// Set message data for editing posts.
if ($mode == "edit" || $mode == "moderation") {
// Transfer all database fields to the form fields.
$message = phorum_posting_merge_db2form($message, $dbmessage, ALLFIELDS);
}
 
// For new messages, set some default values for logged in users.
if (($mode == "post" || $mode == "reply" || $mode == "quote") && $PHORUM["DATA"]["LOGGEDIN"])
{
if (isset($PHORUM["user"]["show_signature"]) &&
$PHORUM["user"]["show_signature"]) {
$message["show_signature"] = 1;
}
 
if (isset($PHORUM["user"]["email_notify"]) &&
$PHORUM["user"]["email_notify"]) {
$message["email_notify"] = 1;
}
}
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/request_followup.php
New file
0,0 → 1,59
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// Create an empty message structure.
$message = array();
 
// Inject form field data into the message structure. No checks
// are done on the data over here. Here we just take care of
// putting the data in the right format in the data structure.
foreach ($PHORUM["post_fields"] as $var => $spec)
{
// Format and store the data based on the configuration.
switch ($spec[pf_TYPE])
{
case "boolean":
$message[$var] = isset($_POST[$var]) && $_POST[$var] ? 1 : 0;
break;
 
case "integer":
$message[$var] = isset($_POST[$var]) ? (int) $_POST[$var] : NULL;
break;
 
case "array":
$message[$var] = isset($_POST[$var]) ? unserialize($_POST[$var]) : array();
break;
 
case "string":
$message[$var] = isset($_POST[$var]) ? trim($_POST[$var]) : '';
// Prevent people from impersonating others by using
// multiple spaces in the author name.
if ($var == 'author') {
$message[$var] = preg_replace('/\s+/', ' ', $message[$var]);
}
break;
 
default:
die ("Illegal field type used for field $var: " . $spec[pf_TYPE]);
}
}
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/action_cancel.php
New file
0,0 → 1,34
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// Clean up unlinked attachments from the database.
foreach ($message["attachments"] as $info) {
if (! $info["linked"]) {
phorum_db_file_delete($info["file_id"]);
}
}
 
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["AttachCancel"];
$PHORUM["DATA"]["BACKMSG"] = $PHORUM["DATA"]["LANG"]["BackToList"];
$PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_get_url(PHORUM_LIST_URL);
 
$error_flag = true;
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/action_edit.php
New file
0,0 → 1,168
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// For phorum_update_thread_info().
include_once("./include/thread_info.php");
 
// Create a message which can be used by the database library.
$dbmessage = array(
"message_id" => $message["message_id"],
"thread" => $message["thread"],
"parent_id" => $message["parent_id"],
"forum_id" => $message["forum_id"],
"author" => $message["author"],
"subject" => $message["subject"],
"email" => $message["email"],
"status" => $message["status"],
"closed" => ! $message["allow_reply"],
"body" => $message["body"],
"meta" => $message["meta"],
);
 
// Update sort setting, if allowed. This can only be done
// when editing the thread starter message.
if ( $message["parent_id"]==0 ) {
 
if ($PHORUM["DATA"]["OPTION_ALLOWED"]["sticky"] && $message["special"]=="sticky") {
$dbmessage["sort"] = PHORUM_SORT_STICKY;
} elseif ($PHORUM["DATA"]["OPTION_ALLOWED"]["announcement"] && $message["special"] == "announcement") {
$dbmessage["forum_id"] = $PHORUM["vroot"] ? $PHORUM["vroot"] : 0;
$dbmessage["sort"] = PHORUM_SORT_ANNOUNCEMENT;
} else {
// Not allowed to edit. Keep existing sort value.
switch ($message["special"]) {
case "sticky": $sort = PHORUM_SORT_STICKY; break;
case "announcement": $sort = PHORUM_SORT_ANNOUNCEMENT; break;
default: $sort = PHORUM_SORT_DEFAULT; break;
}
$dbmessage["sort"] = $sort;
}
 
} else {
 
// set some key fields to the same values as the first message in the thread
$dbmessage["forum_id"] = $top_parent["forum_id"];
$dbmessage["sort"] = $top_parent["sort"];
 
}
 
// Update the editing info in the meta data.
$dbmessage["meta"]["show_signature"] = $message["show_signature"];
$dbmessage["meta"]["edit_count"] =
isset($message["meta"]["edit_count"])
? $message["meta"]["edit_count"]+1 : 1;
$dbmessage["meta"]["edit_date"] = time();
$dbmessage["meta"]["edit_username"] = $PHORUM["user"]["username"];
 
// Update attachments in the meta data, link active attachments
// to the message and delete stale attachments.
$dbmessage["meta"]["attachments"] = array();
foreach ($message["attachments"] as $info)
{
if ($info["keep"])
{
$dbmessage["meta"]["attachments"][] = array(
"file_id" => $info["file_id"],
"name" => $info["name"],
"size" => $info["size"],
);
 
phorum_db_file_link(
$info["file_id"],
$message["message_id"],
PHORUM_LINK_MESSAGE
);
} else {
phorum_db_file_delete($info["file_id"]);
}
}
if (!count($dbmessage["meta"]["attachments"])) {
unset($dbmessage["meta"]["attachments"]);
}
 
// Update the data in the database and run pre and post editing hooks.
$dbmessage = phorum_hook("pre_edit", $dbmessage);
phorum_db_update_message($message["message_id"], $dbmessage);
phorum_hook("post_edit", $dbmessage);
 
// Update children to the same sort setting and forum_id.
// The forum_id update is needed for switching between
// announcements and other types of messages.
if (! $message["parent_id"] &&
$origmessage["sort"] != $dbmessage["sort"])
{
$messages = phorum_db_get_messages($message["thread"], 0);
unset($messages["users"]);
foreach($messages as $message_id => $msg){
if($msg["sort"]!=$dbmessage["sort"] ||
$msg["forum_id"] != $dbmessage["forum_id"]) {
$msg["sort"]=$dbmessage["sort"];
$msg["forum_id"]=$dbmessage["forum_id"];
phorum_db_update_message($message_id, $msg);
}
}
 
// The forum stats have to be updated. Announcements aren't
// counted in the thread_count, so if switching to or
// from announcement, the thread_count will change.
phorum_db_update_forum_stats(true);
}
 
// Update all thread messages to the same closed setting.
if (! $message["parent_id"] &&
$origmessage["closed"] != $dbmessage["closed"]) {
if ($dbmessage["closed"]) {
phorum_db_close_thread($message["thread"]);
} else {
phorum_db_reopen_thread($message["thread"]);
}
}
 
// Update thread info.
phorum_update_thread_info($message['thread']);
 
// Update thread subscription or unsubscription.
if ($message["user_id"])
{
if ($message["email_notify"])
{
phorum_user_subscribe(
$message["user_id"], $PHORUM["forum_id"],
$message["thread"], PHORUM_SUBSCRIPTION_MESSAGE
);
} else {
phorum_user_unsubscribe(
$message["user_id"],
$message["thread"],
$message["forum_id"]
);
}
}
 
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["MsgModEdited"];
$PHORUM['DATA']["BACKMSG"] = $PHORUM['DATA']["LANG"]["BackToThread"];
$PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_get_url(
PHORUM_READ_URL,
$message["thread"],
$message["message_id"]
);
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/action_post.php
New file
0,0 → 1,229
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// For phorum_update_thread_info().
include_once("./include/thread_info.php");
 
// For phorum_email_moderators() and phorum_email_notice().
include_once("./include/email_functions.php");
 
// Set some values.
$message["moderator_post"] = $PHORUM["DATA"]["MODERATOR"] ? 1 : 0;
$message["sort"] = PHORUM_SORT_DEFAULT;
$message["closed"] = $message["allow_reply"] ? 0 : 1;
 
// Determine and set the user's IP address.
$user_ip = $_SERVER["REMOTE_ADDR"];
if ($PHORUM["dns_lookup"]) {
$resolved = @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
if (!empty($resolved)) {
$user_ip = $resolved;
}
}
$message["ip"] = $user_ip;
 
// For replies, inherit the closed parameter of our top parent.
// Only for rare race conditions, since you cannot reply to
// closed threads.
if ($mode == "reply") {
$message["closed"] = $top_parent["closed"];
$message["allow_reply"] = ! $top_parent["closed"];
}
 
// Check if allow_reply can be set.
if ($mode == "post" && ! $PHORUM["DATA"]["OPTION_ALLOWED"]["allow_reply"]) {
$message["closed"] = 0;
$message["allow_reply"] = 1;
}
 
// For sticky and announcement theads set the sort parameter
// for replies to the correct value, so threaded views will work.
if ($mode == "reply")
{
if ($top_parent["sort"] == PHORUM_SORT_STICKY) {
$message["sort"] = PHORUM_SORT_STICKY;
} elseif ($top_parent["sort"] == PHORUM_SORT_ANNOUNCEMENT) {
$message["sort"] = PHORUM_SORT_ANNOUNCEMENT;
$message["forum_id"] = $top_parent["forum_id"];
}
}
 
// Do specific actions for new threads with a "special" flag.
if ($mode == "post" && isset($message["special"]))
{
if ($message["special"]=="sticky" && $PHORUM["DATA"]["OPTION_ALLOWED"]["sticky"]) {
$message["sort"] = PHORUM_SORT_STICKY;
} elseif ($message["special"] == "announcement" && $PHORUM["DATA"]["OPTION_ALLOWED"]["announcement"]) {
$message["sort"] = PHORUM_SORT_ANNOUNCEMENT;
$message["forum_id"]= $PHORUM["vroot"] ? $PHORUM["vroot"] : 0;
}
}
 
if ($PHORUM["DATA"]["LOGGEDIN"] && $message["show_signature"]) {
$message["meta"]["show_signature"] = 1;
}
 
// Put messages on hold in case the forum is moderated.
if ($PHORUM["DATA"]["MODERATED"]) {
$message["status"] = PHORUM_STATUS_HOLD;
} else {
$message["status"] = PHORUM_STATUS_APPROVED;
}
 
// Create a unique message id.
$suffix = preg_replace("/[^a-z0-9]/i", "", $PHORUM["name"]);
$message["msgid"] = md5(uniqid(rand())) . ".$suffix";
 
// Run pre post mods.
$message = phorum_hook("pre_post", $message);
 
// Add attachments to meta data.
$message["meta"]["attachments"] = array();
foreach ($message["attachments"] as $info) {
if ($info["keep"]) {
$message["meta"]["attachments"][] = array(
"file_id" => $info["file_id"],
"name" => $info["name"],
"size" => $info["size"],
);
}
}
if (!count($message["meta"]["attachments"])) {
unset($message["meta"]["attachments"]);
}
 
// Keep a copy of the message we have got now.
$message_copy = $message;
 
// Store the message in the database.
$success = phorum_db_post_message($message);
 
if ($success)
{
// Handle linking and deleting of attachments to synchronize
// the message attachments with the working copy list
// of attachments.
foreach ($message_copy["attachments"] as $info) {
if ($info["keep"]) {
phorum_db_file_link(
$info["file_id"],
$message["message_id"],
PHORUM_LINK_MESSAGE
);
} else {
phorum_db_file_delete($info["file_id"]);
}
}
 
// Retrieve the message again to have it in the correct
// format (otherwise it's a bit messed up in the
// post-function). Do merge back data which is not
// stored in the database, but which we might need later on.
$message = phorum_db_get_message($message["message_id"]);
foreach ($message_copy as $key => $val) {
if (! isset($message[$key])) {
$message[$key] = $val;
}
}
 
phorum_update_thread_info($message["thread"]);
 
// Subscribe user to the thread if requested.
if ($message["email_notify"] && $message["user_id"]) {
phorum_user_subscribe(
$message["user_id"], $PHORUM["forum_id"],
$message["thread"], PHORUM_SUBSCRIPTION_MESSAGE
);
}
 
// Mark own message read.
if ($PHORUM["DATA"]["LOGGEDIN"]) {
phorum_db_newflag_add_read(array(0=>array(
"id" => $message["message_id"],
"forum" => $message["forum_id"],
)));
phorum_user_addpost();
}
 
// Actions for messages which are approved.
if ($message["status"] > 0)
{
// Update forum statistics.
phorum_db_update_forum_stats(false, 1, $message["datestamp"]);
 
// Mail subscribed users.
phorum_email_notice($message);
}
 
// Mail moderators.
if ($PHORUM["email_moderators"] == PHORUM_EMAIL_MODERATOR_ON) {
phorum_email_moderators($message);
}
 
// Run after post mods.
$message = phorum_hook("post_post", $message);
 
// Posting is completed. Take the user back to the forum.
if ($PHORUM["redirect_after_post"] == "read")
{
// To the end of the thread.
if (isset($top_parent)) { // not set for top parents themselves.
$readlen = $PHORUM["read_length"];
$pages = ceil(($top_parent["thread_count"]+1) / $readlen);
 
if ($pages > 1) {
$redir_url = phorum_get_url(
PHORUM_READ_URL, $message["thread"],
$message["message_id"], "page=$pages"
);
} else {
$redir_url = phorum_get_url(
PHORUM_READ_URL, $message["thread"],
$message["message_id"]
);
}
 
// wrap redirect because of IE
$redir_url = phorum_get_url(PHORUM_REDIRECT_URL, 'phorum_redirect_to=' . urlencode($redir_url));
 
} else {
 
$redir_url = phorum_get_url( PHORUM_READ_URL, $message["thread"] );
}
 
}
else
{
$redir_url = phorum_get_url(PHORUM_LIST_URL);
}
 
phorum_redirect_by_url($redir_url);
 
return;
}
 
// If we get here, the posting was not successful.
// Restore message and setup the data for displaying an error to the user.
$message = $message_copy;
$PHORUM["DATA"]["ERROR"] = $PHORUM["DATA"]["LANG"]["PostErrorOccured"];
$error_flag = true;
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/action_attachments.php
New file
0,0 → 1,181
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
if ($do_detach)
{
// Find the message to detach.
foreach ($message["attachments"] as $id => $info)
{
if ($info["file_id"] == $do_detach && $info["keep"])
{
// Attachments which are not yet linked to a message
// can be deleted immediately. Linked attachments should
// be kept in the db, in case the users clicks "Cancel".
if (! $info["linked"]) {
phorum_db_file_delete($info["file_id"]);
unset($message["attachments"][$id]);
} else {
$message["attachments"][$id]["keep"] = false;
}
 
// Run the after_detach hook.
list($message,$info) =
phorum_hook("after_detach", array($message,$info));
 
$attach_count--;
 
break;
}
}
}
 
// Attachment(s) uploaded.
elseif ($do_attach && ! empty($_FILES))
{
// The editor template that I use only supports one upload
// at a time. This code supports multiple uploads.
$attached = 0;
foreach ($_FILES as $file)
{
// Not too many attachments?
if ($attach_count >= $PHORUM["max_attachments"]) break;
 
// Check if the tempfile is an uploaded file?
if(! is_uploaded_file($file["tmp_name"])) continue;
 
// Some problems in uploading result in files which are
// zero in size. We asume that people who upload zero byte
// files will almost always have problems uploading.
if ($file["size"] == 0) continue;
 
// check with PHP and MySQL on attachment size
$php_limit = ini_get('upload_max_filesize')*1024;
$max_packetsize = phorum_db_maxpacketsize();
if ($max_packetsize == NULL) {
$db_limit = $php_limit;
} else {
$db_limit = $max_packetsize/1024*.6;
}
if($PHORUM["max_attachment_size"]==0){
$PHORUM["max_attachment_size"] = min($php_limit, $db_limit);
} else {
$PHORUM["max_attachment_size"] = min($PHORUM["max_attachment_size"], $php_limit, $db_limit);
}
 
// Isn't the attachment too large?
if ($PHORUM["max_attachment_size"] > 0 &&
$file["size"] > $PHORUM["max_attachment_size"]*1024) {
$PHORUM["DATA"]["ERROR"] = str_replace(
'%size%',
phorum_filesize($PHORUM["max_attachment_size"] * 1024),
$PHORUM["DATA"]["LANG"]["AttachFileSize"]
);
phorum_filesize($PHORUM["max_attachment_size"] * 1024);
$error_flag = true;
break;
}
 
// Isn't the total attachment size too large?
if ($PHORUM["max_totalattachment_size"] > 0 &&
($file["size"] + $attach_totalsize) > $PHORUM["max_totalattachment_size"]*1024) {
$PHORUM["DATA"]["ERROR"] = str_replace(
'%size%',
phorum_filesize($PHORUM["max_totalattachment_size"] * 1024),
$PHORUM["DATA"]["LANG"]["AttachTotalFileSize"]
);
$error_flag = true;
break;
}
 
// Is the type of file acceptable?
if(! empty($PHORUM["allow_attachment_types"]))
{
$ext=substr($file["name"], strrpos($file["name"], ".")+1);
$allowed_exts=explode(";", $PHORUM["allow_attachment_types"]);
if (! in_array(strtolower($ext), $allowed_exts)) {
$PHORUM["DATA"]["ERROR"] =
$PHORUM["DATA"]["LANG"]["AttachInvalidType"] . " ".
str_replace('%types%', str_replace(";", ", ", $PHORUM["allow_attachment_types"]), $PHORUM["DATA"]["LANG"]["AttachFileTypes"]);
$error_flag = true;
break;
}
}
 
// Read in the file.
$fp = fopen($file["tmp_name"], "r");
if (! $fp) continue;
$file["data"] = base64_encode(fread($fp, $file["size"]));
fclose($fp);
 
// copy the current user_id to the $file array for the hook
$file["user_id"]=$PHORUM["user"]["user_id"];
 
// Run the before_attach hook.
list($message, $file) =
phorum_hook("before_attach", array($message, $file));
 
// Add the file to the database. We add it using message_id
// 0 (zero). Only when the message gets saved definitely,
// the message_id will be updated to link the file to the
// forum message. This is mainly done so we can support
// attachments for new messages, which do not yet have
// a message_id assigned.
$file_id = phorum_db_file_save(
$PHORUM["user"]["user_id"],
$file["name"], $file["size"],
$file["data"], 0, PHORUM_LINK_EDITOR
);
 
// Create new attachment information.
$new_attachment = array(
"file_id" => $file_id,
"name" => $file["name"],
"size" => $file["size"],
"keep" => true,
"linked" => false,
);
 
// Run the after_attach hook.
list($message, $new_attachment) =
phorum_hook("after_attach", array($message, $new_attachment));
 
// Add the attachment to the message.
$message['attachments'][] = $new_attachment;
$attach_totalsize += $new_attachment["size"];
$attach_count++;
$attached++;
}
 
// Show a generic error message if nothing was attached and
// no specific message was set.
if (! $error_flag && ! $attached) {
$PHORUM["DATA"]["ERROR"] =
$PHORUM["DATA"]["LANG"]["AttachmentsMissing"];
$error_flag = true;
}
 
// Show a success message in case an attachment is added.
if (! $error_flag && $attached) {
$PHORUM["DATA"]["OKMSG"] = $PHORUM["DATA"]["LANG"]["AttachmentAdded"];
 
}
}
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/check_permissions.php
New file
0,0 → 1,187
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// Check if the user is allowed to post a new message or a reply.
if( ($mode == "post" && !phorum_user_access_allowed(PHORUM_USER_ALLOW_NEW_TOPIC)) ||
($mode == "reply" && !phorum_user_access_allowed(PHORUM_USER_ALLOW_REPLY)) ) { if ($PHORUM["DATA"]["LOGGEDIN"]) {
// If users are logged in and can't post, they don't have rights to do so.
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["NoPost"];
} else {
// Check if they could post if logged in. If so, let them know to log in.
if( ($mode == "reply" && $PHORUM["reg_perms"] & PHORUM_USER_ALLOW_REPLY) ||
($mode == "post" && $PHORUM["reg_perms"] & PHORUM_USER_ALLOW_NEW_TOPIC) ) {
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["PleaseLoginPost"];
} else {
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["NoPost"];
}
}
$error_flag = true;
return;
 
// Check that they are logged in according to the security settings in
// the admin. If they aren't then either set a message with a login link
// (when running as include) or redirect to the login page.
} elseif($PHORUM["DATA"]["LOGGEDIN"] && !$PHORUM["DATA"]["FULLY_LOGGEDIN"]){
 
if (isset($PHORUM["postingargs"]["as_include"])) {
 
// Generate the URL to return to after logging in.
$args = array(PHORUM_REPLY_URL, $PHORUM["args"][1]);
if (isset($PHORUM["args"][2])) $args[] = $PHORUM["args"][2];
if (isset($PHORUM["args"]["quote"])) $args[] = "quote=1";
$redir = urlencode(call_user_func_array('phorum_get_url', $args));
$url = phorum_get_url(PHORUM_LOGIN_URL, "redir=$redir");
$PHORUM["DATA"]["URL"]["REDIRECT"] = $url;
$PHORUM["DATA"]["BACKMSG"] = $PHORUM["DATA"]["LANG"]["LogIn"];
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["PeriodicLogin"];
$error_flag = true;
return;
 
} else {
 
// Generate the URL to return to after logging in.
$args = array(PHORUM_POSTING_URL);
if (isset($PHORUM["args"][1])) $args[] = $PHORUM["args"][1];
if (isset($PHORUM["args"][2])) $args[] = $PHORUM["args"][2];
if (isset($PHORUM["args"]["quote"])) $args[] = "quote=1";
$redir = urlencode(call_user_func_array('phorum_get_url', $args));
 
phorum_redirect_by_url(phorum_get_url(PHORUM_LOGIN_URL,"redir=$redir"));
exit();
 
}
}
 
// Put read-only user info in the message.
if ($mode == "post" || $mode == "reply")
{
if ($PHORUM["DATA"]["LOGGEDIN"]){
$message["user_id"] = $PHORUM["user"]["user_id"];
$message["author"] = $PHORUM["user"]["username"];
} else {
$message["user_id"] = 0;
}
}
 
// On finishing up, find the original message data in case we're
// editing or replying. Put read-only data in the message to prevent
// data tampering.
if ($finish && ($mode == 'edit' || $mode == 'reply'))
{
$id = $mode == "edit" ? "message_id" : "parent_id";
$origmessage = phorum_db_get_message($message[$id]);
if (! $origmessage) {
phorum_redirect_by_url(phorum_get_url(PHORUM_INDEX_URL));
exit();
}
 
// Copy read-only information for editing messages.
if ($mode == "edit") {
$message = phorum_posting_merge_db2form($message, $origmessage, READONLYFIELDS);
// Copy read-only information for replying to messages.
} else {
$message["parent_id"] = $origmessage["message_id"];
$message["thread"] = $origmessage["thread"];
}
}
 
// We never store the email address in the message in case it
// was posted by a registered user.
if ($message["user_id"]) {
$message["email"] = "";
}
 
// Find the startmessage for the thread.
if ($mode == "reply" || $mode == "edit") {
$top_parent = phorum_db_get_message($message["thread"]);
}
 
// Do permission checks for replying to messages.
if ($mode == "reply")
{
// Find the direct parent for this message.
if ($message["thread"] != $message["parent_id"]) {
$parent = phorum_db_get_message($message["parent_id"]);
} else {
$parent = $top_parent;
}
 
// If this thread is unapproved, then get out.
$unapproved =
empty($top_parent) ||
empty($parent) ||
$top_parent["closed"] ||
$top_parent["status"] != PHORUM_STATUS_APPROVED ||
$parent["status"] != PHORUM_STATUS_APPROVED;
 
if ($unapproved)
{
// In case we run the editor included in the read page,
// we should not redirect to the listpage for moderators.
// Else a moderator can never read an unapproved message.
if (isset($PHORUM["postingargs"]["as_include"])) {
if ($PHORUM["DATA"]["MODERATOR"]) {
$PHORUM["DATA"]["MESSAGE"] = $PHORUM["DATA"]["LANG"]["UnapprovedMessage"];
$error_flag = true;
return;
}
}
 
// In other cases, redirect users that are replying to
// unapproved messages to the message list.
phorum_redirect_by_url(phorum_get_url(PHORUM_LIST_URL));
exit;
}
 
}
 
// Do permission checks for editing messages.
if ($mode == "edit")
{
// Check if the user is allowed to edit this post.
$timelim = $PHORUM["user_edit_timelimit"];
$useredit =
$message["user_id"] == $PHORUM["user"]["user_id"] &&
phorum_user_access_allowed(PHORUM_USER_ALLOW_EDIT) &&
! empty($top_parent) &&
! $top_parent["closed"] &&
(! $timelim || $message["datestamp"] + ($timelim * 60) >= time());
 
// Moderators are allowed to edit message, but not messages from
// announcement threads. Announcements may only be edited by users
// for which the option "announcement" is set as allowed.
$moderatoredit =
$PHORUM["DATA"]["MODERATOR"] &&
$message["forum_id"] == $PHORUM["forum_id"] &&
($message["special"] != "announcement" ||
$PHORUM["DATA"]["OPTION_ALLOWED"]["announcement"]);
 
if (!$useredit && !$moderatoredit) {
$PHORUM["DATA"]["MESSAGE"] =
$PHORUM["DATA"]["LANG"]["EditPostForbidden"];
$error_flag = true;
return;
}
}
 
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/check_banlist.php
New file
0,0 → 1,55
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// For phorum_check_ban_lists().
include_once("./include/profile_functions.php");
 
// Create a list of the bans that we want to check.
$bans = array();
 
// Add checks for registered users.
if ($PHORUM["DATA"]["LOGGEDIN"]) {
$bans[] = array($PHORUM["user"]["username"], PHORUM_BAD_NAMES);
$bans[] = array($PHORUM["user"]["email"], PHORUM_BAD_EMAILS);
$bans[] = array($PHORUM["user"]["user_id"], PHORUM_BAD_USERID);
}
// Add checks for unregistered users.
else {
$bans[] = array($message["author"], PHORUM_BAD_NAMES);
$bans[] = array($message["email"], PHORUM_BAD_EMAILS);
}
 
// Add check for IP-address bans.
$bans[] = array(NULL, PHORUM_BAD_IPS);
 
// Add check for Illegal Content (SPAM) bans.
$bans[] = array($message["subject"], PHORUM_BAD_SPAM_WORDS);
$bans[] = array($message["body"], PHORUM_BAD_SPAM_WORDS);
 
 
// Run the checks.
$msg = phorum_check_bans($bans);
if (!is_null($msg)) {
$PHORUM["DATA"]["MESSAGE"] = $msg;
$error_flag = true;
}
 
?>
/tags/v2.0-narmer/client/phorum/bibliotheque/phorum/include/posting/check_integrity.php
New file
0,0 → 1,67
<?php
 
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
////////////////////////////////////////////////////////////////////////////////
 
if(!defined("PHORUM")) return;
 
// For phorum_valid_email()
include_once("./include/email_functions.php");
 
$error = false;
 
// Post and reply checks for unregistered users.
if (! $PHORUM["DATA"]["LOGGEDIN"] &&
($mode == 'post' || $mode == 'reply'))
{
if (empty($message["author"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrAuthor"];
} elseif ((!defined('PHORUM_ENFORCE_UNREGISTERED_NAMES') || (defined('PHORUM_ENFORCE_UNREGISTERED_NAMES') && PHORUM_ENFORCE_UNREGISTERED_NAMES == true)) && phorum_user_check_username($message["author"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrRegisterdName"];
} elseif (!empty($message["email"]) &&
phorum_user_check_email($message["email"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrRegisterdEmail"];
}
}
 
// A hook entry for checking the data from a module.
if (! $error) {
list($message, $error) =
phorum_hook("check_post", array($message, $error));
}
 
// Data integrity checks for all messages.
if (! $error)
{
if (empty($message["subject"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrSubject"];
} elseif (empty($message["body"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrBody"];
} elseif (!empty($message["email"]) &&
!phorum_valid_email($message["email"])) {
$error = $PHORUM["DATA"]["LANG"]["ErrEmail"];
} elseif (strlen($message["body"]) > 64000) {
$error = $PHORUM["DATA"]["LANG"]["ErrBodyTooLarge"];
}
}
 
if ($error) {
$PHORUM["DATA"]["ERROR"] = $error;
$error_flag = true;
}
 
?>