All pastes #934602 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-08 23:06 UTC
rendered paste body
<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright © 2002 - 2006 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
require_once "../maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";
include LOCALE.LOCALESET."forum/post.php";
require_once INCLUDES."forum_functions_include.php";

if (!FUSION_QUERY || !isset($forum_id) || !isNum($forum_id)) fallback("index.php");
// Parameters
//MULTI UPLOAD FILES
$wd = 5;
// posts on a site
echo "<script>
function AddRowsToTable() { 
 var tbl = document.getElementById('dateiupload'); 
 var lastRow = tbl.rows.length; 
 var iteration = lastRow;    
 if (iteration < $wd) {    
   var row = tbl.insertRow(lastRow); 
  
   var cellRight = row.insertCell(0); 
   var el = document.createElement('input'); 
   el.setAttribute('type', 'file'); 
   el.setAttribute('name', 'attach[]'); 
   el.setAttribute('class', 'textbox'); 
   
   cellRight.setAttribute('id',iteration) 
   cellRight.appendChild(el); 
   var aa = document.createElement(\"a\"); 
   aa.setAttribute('href', '#'); 
   var clickName = new Function(\"DeleteRow(this)\"); 
   aa.onclick = clickName; 
   aa.innerHTML = \"&nbsp;(Entfernen/Remove) \"; 
   cellRight.appendChild(aa); 
 } else { 
   alert('No more than $wd; Files ...'); 
 } 
} 
function DeleteRow(x) 
{ 
     while (x.tagName.toLowerCase() !='tr') 
     { 
          if(x.parentElement) 
             x=x.parentElement; 
        else if(x.parentNode) 
             x=x.parentNode; 
        else 
             return; 
     } 
     var rowNum=x.rowIndex; 
     while (x.tagName.toLowerCase() !='table') 
     { 
          if(x.parentElement) 
             x=x.parentElement; 
        else if(x.parentNode) 
             x=x.parentNode; 
        else 
             return; 
     } 
     x.deleteRow(rowNum);  
} 
</script>";

$result = dbquery(
	"SELECT f.*, f2.forum_name AS forum_cat_name
	FROM ".$db_prefix."forums f
	LEFT OUTER JOIN ".$db_prefix."forums f2 ON f.forum_cat=f2.forum_id
	WHERE f.forum_id='".$forum_id."'"
);

if (dbrows($result)>0) {	$fdata = dbarray($result);} else {	fallback("index.php");
}
$can_view = forum_accesscontrol($userdata['user_id'],$fdata['forum_access'],$fdata['forum_id'], "auth_read");
if (!$can_view) fallback("index.php");
// rechte ermitteln
$can_post = $can_view && forum_accesscontrol($userdata['user_id'],$fdata['forum_posting'],$fdata['forum_id'], "auth_post") ? true : false;
$can_reply = $can_view && forum_accesscontrol($userdata['user_id'],$fdata['forum_reply'],$fdata['forum_id'], "auth_reply") ? true : false;
$can_edit = ($can_post || $can_reply) && $fdata['forum_edit']==1 ? true : false;
$can_delete = ($can_post || $can_reply) && $fdata['forum_delete']==1 ? true : false;
$can_download = $can_view && forum_accesscontrol($userdata['user_id'],$fdata['forum_download'],$fdata['forum_id'], "auth_download") ? true : false;
$can_mod = view_forum_mods($fdata['forum_id'],true) ? true : false;
$can_attach = ($can_post || $can_reply) && forum_accesscontrol($userdata['user_id'],$fdata['forum_attach'],$fdata['forum_id'], "auth_attach") ? true : false;
define ("iMOD", iMEMBER && $can_mod ? true : false);
$caption = $fdata['forum_cat_name']." | ".$fdata['forum_name'];

if ($action == "newthread" && ($can_post || iMOD || iSUPERADMIN)) {include "postnewthread.php";} elseif ($action == "reply" && ($can_reply || iMOD|| iSUPERADMIN)) {
	if (!isset($thread_id) || !isNum($thread_id)) fallback("index.php");
	$result = dbquery("SELECT * FROM ".$db_prefix."threads WHERE thread_id='".$thread_id."' AND forum_id='".$fdata['forum_id']."'");
	if (dbrows($result)) { $tdata = dbarray($result); } else { fallback("index.php"); }
	
	if (!$tdata['thread_locked'] && ($can_reply || iMOD || iSUPERADMIN)) { include "postreply.php"; } else { fallback("index.php"); }
} elseif ($action == "edit" || $action == "delete") {
	if (!isset($thread_id) || !isNum($thread_id) || !isset($post_id) || !isNum($post_id)) { fallback("index.php"); exit; }

	$result = dbquery("SELECT * FROM ".$db_prefix."threads WHERE thread_id='".$thread_id."' AND forum_id='".$fdata['forum_id']."'");
	if (dbrows($result)) { $tdata = dbarray($result); } else { fallback("index.php"); }

	$result = dbquery("SELECT p.*, u.user_level FROM ".$db_prefix."posts p, ".$db_prefix."users u WHERE p.post_id='".$post_id."' AND p.thread_id='".$tdata['thread_id']."' AND p.forum_id='".$fdata['forum_id']."' AND p.post_author = u.user_id");
	
	if (dbrows($result)) { $pdata = dbarray($result); } else { fallback("index.php"); }
	if ($userdata['user_id'] != $pdata['post_author'] && !iMOD && !iSUPERADMIN) fallback("index.php");
	$can_delete = ( iMOD || iSUPERADMIN ) ? 1 : $fdata['forum_delete'];

	if($action == "delete" && $can_delete)
	{
		if($pdata['user_level'] == '103')
		{
			$can_really_delete = iSUPERADMIN ? 1 : 0;
		}
		elseif($pdata['user_level'] == '102')
		{
			$can_really_delete = iADMIN ? 1 : 0;
		}
		else
		{
			$can_really_delete = 1;
		}

		if($can_really_delete)
		{
		$result = dbquery("DELETE FROM ".$db_prefix."posts WHERE post_id='$post_id' AND thread_id='$thread_id'");
		$result = dbquery("SELECT * FROM ".$db_prefix."forum_attachments WHERE post_id='$post_id'");
		if (dbrows($result) != 0) {
			$attach = dbarray($result);
			unlink(FORUM."attachments/".$attach['attach_name']);
			$result2 = dbquery("DELETE FROM ".$db_prefix."forum_attachments WHERE post_id='$post_id'");
		}
		$posts = dbcount("(post_id)", "posts", "thread_id='$thread_id'");
		if ($posts == 0) {
			$result = dbquery("DELETE FROM ".$db_prefix."threads WHERE thread_id='$thread_id' AND forum_id='$forum_id'");
			$result = dbquery("DELETE FROM ".$db_prefix."thread_notify WHERE thread_id='$thread_id'");
		}
		// update forum_lastpost and forum_lastuser if post_datestamp matches
		fu_f_update_forum($forum_id);
        fu_f_update_thread($thread_id);		
	
		opentable($locale['407']);
		echo "<center><br>\n".$locale['445']."<br><br>\n";
		if ($posts > 0) {
			
if (!empty($pdata2) && isset($pdata2['post_id'])) {$post_id="&pid=".$pdata2['post_id']."#post_".$pdata2['post_id'];}			
else {$post_id="";}
		// automatische Weiterleitung		
		echo"<script language='javascript'>
		<!--
		var site = 'viewthread.php?forum_id=".$forum_id."&thread_id=".$thread_id.$post_id."';
		function redirect() {
		window.location = site ;
		}
		setTimeout('redirect()', 3000);
		// -->
		</script>";
		echo"<div align='center'>
		<center>
		<table border='0' cellpadding='4' cellspacing='1'>
			<tr>
			<td width='100%' align='center'>
			<font class='tbl'>Een moment ".$userdata['user_name'].", Je word doorgestuurd ...</font>
			</td>
			</tr>
		</table>
		</center>
		</div><br>";	
		echo "<a href='viewthread.php?forum_id=$forum_id&thread_id=$thread_id'>".$locale['447']."</a> | <a href='index.php'>".$locale['449']."</a><br><br>\n</center>\n";
		} else {
		// automatische Weiterleitung		
		echo"<script language='javascript'>
		<!--
		var site = 'viewthread.php?forum_id=$forum_id';
		function redirect() {
		window.location = site ;
		}
		setTimeout('redirect()', 3000);
		// -->
		</script>";
		echo"<div align='center'>
		<center>
		<table border='0' cellpadding='4' cellspacing='1'>
			<tr>
			<td width='100%' align='center'>
			<font class='tbl'>Een moment ".$userdata['user_name'].", Je word doorgestuurd ...</font>
			</td>
			</tr>
		</table>
		</center>
		</div><br>";		
		echo "<a href='viewforum.php?forum_id=$forum_id'>".$locale['448']."</a> | <a href='index.php'>".$locale['449']."</a><br><br>\n</center>\n";
		}
		closetable();
		}
	}
	if($action == "edit")
	{
		if (!$fdata['forum_edit'] && !iMOD && !iSUPERADMIN) fallback("index.php");
		if (!$tdata['thread_locked']) {
			if($pdata['user_level'] == '103')
			{
				if(iSUPERADMIN) { include "postedit.php"; } else { fallback("index.php"); }
			}
			elseif($pdata['user_level'] == '102')
			{
				if(iADMIN) { include "postedit.php"; } else { fallback("index.php"); }
			}
			else
			{
				include "postedit.php";
			}
		} else {
			if (iMOD || iSUPERADMIN)
			{
				if($pdata['user_level'] == '103')
				{
					if(iSUPERADMIN) { include "postedit.php"; } else { fallback("index.php"); }
				}
				elseif($pdata['user_level'] == '102')
				{
					if(iADMIN) {include "postedit.php"; } else { fallback("index.php"); }
				}
				else
				{
					include "postedit.php";
				}
			}
		}
	}
} else {
	header("Location: index.php");
}

//require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";

// File is correctly working (tested by silvermoon) \\
?>