Loiso - That's not what's wrong...
I have the same problem. It has to do with the way that variables are being called.
I've gotten the page to load with the following code.
What I did was replace "$pun_root" with "PUN_ROOT", and "$language" with "$pun_user['language']".
Past that, I don't know what else to change.
Paste this as the "uploads.php" file. It should work...
<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
$page_title=pun_htmlspecialchars($pun_config['o_board_title']).' » Uploader';
// Load the viewtopic.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/'.'topic.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/'.'uploads.php';
require PUN_ROOT.'header.php';
$result = $db->query('SELECT * FROM '.$db->prefix.'uploads_conf WHERE g_id='.$pun_user['g_id']);
$upl_conf= $db->fetch_assoc($result);
if (!$upl_conf) {
$result = $db->query('SELECT * FROM '.$db->prefix.'uploads_conf WHERE g_id=0');
$upl_conf= $db->fetch_assoc($result);
}
$result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups') or error('Unable to get useergroups', __FILE__, __LINE__, $db->error());
$i=0;
while ($i < $db->num_rows($result)) {
$groups[$i] = $db->fetch_assoc($result);
$result2 = $db->query('SELECT * FROM '.$db->prefix.'uploads_conf WHERE g_id='.$groups[$i]['g_id']) or error('Unable to upload persmissions', __FILE__, __LINE__, $db->error());
$perms[$i]= $db->fetch_assoc($result2);
if (!$perms[$i]) {
$result2 = $db->query('SELECT * FROM '.$db->prefix.'uploads_conf WHERE g_id=0');
$perms[$i]= $db->fetch_assoc($result2);
}
$i++;
}
$allowed = array(".txt",".gif",".jpg",".jpeg",".png");
$pics = array(".gif",".jpg",".jpeg",".png");
?>
<b><a href="./index.php"><?php echo pun_htmlspecialchars($pun_config['o_board_title']); ?></a></a> » <a href="uploads.php"><?php echo $lang_uploads['Uploader']; ?></a><?php //echo ' / '.$lang_uploads['File']; ?></b>
<br><br>
<div class="block">
<h2><span>Uploads</span></h2>
<div class="box">
<div class="inbox">
<?php
if (!$upl_conf['p_view']) {
?>
<div id="announce" class="block">
<h2><span><b>Not allowed</b></span></h2>
<div class="box">
<div class="inbox">
<div><?php echo '<b>You do not have permissons to access upload module. Please, contact Administration.</b>'; ?></div>
</div>
</div>
</div>
<?php
}
elseif (!$_POST) {
$_POST['act']='';
?>
<div class="inform">
<fieldset>
<legend>Upload file</legend>
<div class="infldset">
<form method="POST" action="uploads.php" enctype="multipart/form-data">
<p><b>Uploading Rules:</b><br><br>
- You can use the upload to upload image and text with the following extention. (.txt, .gif, .jpg, .jpeg, .png)<br>
- The file must be under <?php echo round($upl_conf['u_fsize'] / 1024).'KB'; ?> <br>
- Please use a sensible file name or i will remove the file, if anyone abuses this uploader, it will be removed.<br><br>
<input type="file" name="file" size="30"><br><br>
<input type="hidden" name="user_id" value="<?php echo $pun_user['id']; ?>">
<input type="hidden" name="user_name" value="<?php echo $pun_user['username']; ?>">
<input type="submit" name="act" value="Upload"></p>
</form>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>File list</legend>
<div class="infldset">
Files below have been uploaded by users and may be malicous or contain inapropriate content. Click on a file to download. If you find any inapropriate content, please report to Administrator.<br><br>
<table class="punmain" cellspacing="1" cellpadding="4">
<tr class="punhead">
<td class="punhead" style="width: 20%"><?php echo $lang_uploads['File']; ?></td>
<td class="punhead" style="width: 5%"><?php echo $lang_uploads['Size']; ?></td>
<td class="punhead" style="width: 14%"><?php echo $lang_uploads['Posted by']; ?></td>
<?php
if($upl_conf['p_delete'])
echo ' <td class="punhead" style="width: 14%; white-space: nowrap">'.$lang_uploads['Delete'].'</td></tr>';
if($upl_conf['p_globalview']) {
$result = $db->query('SELECT * FROM '.$db->prefix.'uploaded') or error('Error getting file list', __FILE__, __LINE__, $db->error());
} else $result = $db->query('SELECT * FROM '.$db->prefix.'uploaded WHERE id ='.$pun_user['id']) or error('Error getting file list', __FILE__, __LINE__, $db->error());
while($info = $db->fetch_assoc($result)) {
?>
<tr class="puntopic">
<?php
$ext = strtolower(strrchr($info['file'],'.'));
if(in_array($ext,$pics))
echo' <td class="puncon1"><a href="uploaded/'.$info['file'].'">'.$info['file'].'</td>';
else
echo' <td class="puncon1"><a href="./uploaded/'.$info['file'].'">'.$info['file'].'</td>';
?>
<td class="puncon2"><?php echo round(filesize('./uploaded/'.$info['file']) / 1024).'KB'; ?></td>
<td class="puncon1"><?php echo '<a href="profile.php?id='.$info['id'].'">'.$info['user'].'</a>'; ?></td>
<?php
if($upl_conf['p_globaldelete'])
echo ' <td class="puncon1"><form method="POST" action="uploads.php" enctype="multipart/form-data"><input type="hidden" name="delfile" value="'.$info['file'].'"><input type="submit" name="act" value="Delete"></form></td>';
elseif ($upl_conf['p_delete']){
if ($info['id'] == $pun_user['id']) echo '<td class="puncon1"><form method="POST" action="uploads.php" enctype="multipart/form-data"><input type="hidden" name="delfile" value="'.$info['file'].'"><input type="submit" name="act" value="Delete"></form></td>';
else echo ' <td class="puncon1">N/A</td>';
}
?>
</tr>
<?php
}
?>
</table>
</div>
</fieldset>
</div>
</div>
</div>
</div>
<?php }
elseif ($_POST['act']=='Upload') {
if(($upl_conf['p_upload'] <> 1)) error('No permission', __FILE__, __LINE__, $db->error());
$ext = strtolower(strrchr($file_name,'.'));
if($file_name == "")
error('No file selected for upload', __FILE__, __LINE__, $db->error());
else if(file_exists('./uploaded/'.$file_name))
error('File already exists', __FILE__, __LINE__, $db->error());
else if($file_size > $upl_conf['u_fsize'])
error('File was too big', __FILE__, __LINE__, $db->error());
else if(!in_array($ext,$allowed))
error('File is not a valid file type', __FILE__, __LINE__, $db->error());
else {
$result = $db->query('INSERT INTO '.$db->prefix.'uploaded(`file`,`user`,`id`) VALUES(\''.$file_name.'\',\''.$_POST['user_name'].'\',\''.$_POST['user_id'].'\')') or error('Unable to add upload data', __FILE__, __LINE__, $db->error());
@copy($file, './uploaded/'.$file_name) or error('Could not copy file to server', __FILE__, __LINE__, $db->error());
?>
<div class="inform">
<fieldset>
<legend>Uploading...</legend>
<div class="infldset">
<div><?php echo '<b>File has been uploaded to <a href="./uploaded/'.$file_name.'">'.$pun_config['o_base_url'].'/uploaded/'.$file_name.'</a></b>'; ?></div>
</div>
</fieldset>
</div>
<?php
if(in_array($ext,$pics)) echo '<img src="./uploaded/'.$file_name.'"><br><br>';
}
}
elseif($_POST['act']=='Delete') {
if(($upl_conf['p_delete'] <> 1)&&($upl_conf['p_globaldelete'] <> 1)) error('No permission', __FILE__, __LINE__, $db->error());
if(!file_exists('./uploaded/'.$delfile))
error('File doesn\'t exist', __FILE__, __LINE__, $db->error());
else {
unlink('./uploaded/'.$delfile);
$result = $db->query('DELETE FROM '.$db->prefix.'uploaded WHERE file=\''.$delfile.'\'') or error('Unable to delete data', __FILE__, __LINE__, $db->error());
?>
<div class="inform">
<fieldset>
<legend>Deleting...</legend>
<div class="infldset">
<div><?php echo $delfile.' removed from the uploader.'; ?></div>
</div>
</fieldset>
</div>
<?php
}
}
?>
<?php
$footer_style = 'index';
require PUN_ROOT.'footer.php';
The only problems that I get with it is that I get a wierd error:
"Notice: Undefined index: Uploader in /home/adonis/public_html/bb/uploads.php on line 45" which has to do with the way things are being defined (again).
Also, it won't let me upload. It keeps saying that I need to select something to upload, even when I have...