1

(11 replies, posted in PunBB 1.2 show off)

Oh it is. You should see the CPANEL for it. I nearly had a heart attack.

Probably going to move a new dedicated server soon enough. smile

Thanks for the comments Matt. big_smile

2

(11 replies, posted in PunBB 1.2 show off)

MattF wrote:

Style looks decent enough. The tabs are screwed in the Moz class browsers too, however.

However, just one slight nitpick. What is so hard about developing a compliant and valid site with regards to Xhtml/html? It's even more ironic when one of your designers professes to be something akin to the bees knees with regards to design, accessibility, usability and so on. Before you point out the fact, I know the site is still being worked upon, but the code should be written correctly from day one, not hacked together and then cleaned up as an after thought.

I will do the validity and the browser integration sometime this month.

Style doesn't look decent enough, I still think there is a lot of work to be done by me to get it nice. I think the borders are a bit too harsh on the eye and the colours are out of depth, so viewing and scrolling down forums is not the nicest thing to do.

The code SHOULD be written correctly from the start, I agree, but I didn't really get my claws on this till a month or so ago. It died for a while, see, so I didn't really bother with such things.

Plus, XHTML validity only really counts of a browser is going to spit the site right back at you because of it, currently none of that is happening and the only problemos are style problems - which IE will always be a fucking dick about.

Give Liq a break, he tried. tongue lol

3

(9 replies, posted in PunBB 1.2 show off)

I noticed, how may I fix this?
hmm

But I am not talking about Vb on this occassion, I am talking about PunBB. hmm

Nope, i use all web browsers for designing sites and in IE it shows up perfectly. hmm
Both values are not the same, as it is overwriting a BASE.CSS css code.

Well it doesnt on my forums. hmm

Well, so far the !important works for me.
As a hack you say? What do you mean by that?

Why would IE ignore it?
!important in CSS just means that that code will overwrite the code in the css file for that specific template.
That is how I made a custom Vbulletin style because of the restrictions of style designing in it.
So I just added in the "extra css board" all the code I wanted, added "!important" after it and it overwrote all the css code before it, so i could do as much as I wanted. It works.

Also, if you use !important in a css style for something then you can overwrite some settings that are default. For example, I have on my css code

h2 {
margin-top: 15px !important;
}

9

(9 replies, posted in PunBB 1.2 show off)

Thoughts anyone? I would appreciate some feedback for the site. smile

10

(9 replies, posted in PunBB 1.2 discussion)

When it's finished I believe.

11

(9 replies, posted in PunBB 1.2 show off)

http://www.3lite-gaming.com/forums.php

I believe the server is lagging because it is not used to this much activity.
We will be upgrading soon enough. But I am 100% sure it works Steven. What browser are you using. And what does it say?

12

(9 replies, posted in PunBB 1.2 show off)

What doesnt work?

http://www.3lite-gaming.com/index.php

Since I added my PunBB style a few months ago, this site has just shot up in popularity.
The site is generally just a nice forum to hand out in. It was meant to be just for graphics designers, but I thought I should change the aspect of that since there are way too many gfx places on the internet.
Now that I have completed the whole design of the website I thought I would "show it off" to everyone here.
There are still a few tweaks here and there I have to do on the style, but generally, it is completely finished.

I have so many mods on it I don't know where to start.
- Subforums
- Rank Pips ( code only for admins and mods - courtesy of Elbekko )
- Reputation
- Polls ( I will have to fix a lot for them, they look incredibly ugly )
- Additions to profile and viewtopic
                                                  - 2142 stats, Xfire, BF2 stats ( courtesy of BF2s and my own code )
- PunPortal 1.0
- Integration of Coppermine Gallery
- Got rid of stickies, added
                                  - Important
                                      - Info
                                      - Interesting
( courtesy of Duffry )
- Online Today
- PMs ( with added code, courtesy of Duk0r )
- IRC Chat
- Arcade

There are more, but I cannot remember them all. tongue

Comments/Suggestions/Critiscm is welcome.
smile

Smartys, could you not put the CSS code on the .tpl file and add !important at the end of each css line?
I think that should work.

15

(6 replies, posted in PunBB 1.2 discussion)

Easy, if you have FTP access go to forums/cache/bans.php and find your ban, delete it and then re-upload. smile

16

(4 replies, posted in PunBB 1.2 troubleshooting)

How do I remove the span from the categories?
hmm

17

(4 replies, posted in PunBB 1.2 troubleshooting)

Right, I would like to know why this is happening -
http://www.ktotheimmy.com/asdadsfsdgfd.png

It is really annoying me, and the only changes I made for the second "4 bar image" to appear was changing the size of the boxes where the topic icons are so I could add topic images instead of boxes.

This is the STYLESHEET

/****************************************************************/
/* 1. IMPORTED STYLESHEETS */
/****************************************************************/

/* Import the basic setup styles */
@import url(imports/base.css);
/* Import the colour scheme */
@import url(imports/Cobalt_cs.css);

/****************************************************************/
/* 2. TEXT SETTINGS */
/****************************************************************/

/* 2.1 This sets the default Font Group */

.pun, .pun INPUT, .pun SELECT, .pun TEXTAREA, .pun OPTGROUP {
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
}

.pun {FONT-SIZE: 11px; LINE-HEIGHT: normal}

/* IEWin Font Size only - to allow IEWin to zoom. Do not remove comments \*/
* HTML .pun {FONT-SIZE: 68.75%}
/* End IE Win Font Size */

/* Set font size for tables because IE requires it */
.pun TABLE, .pun INPUT, .pun SELECT, .pun OPTGROUP, .pun TEXTAREA, DIV.postmsg P.postedit {FONT-SIZE: 1em}

/* 2.2 Set the font-size for preformatted text i.e in code boxes */

.pun PRE {FONT-FAMILY: monaco, "Bitstream Vera Sans Mono", "Courier New", courier, monospace}

/* 2.3 Font size for headers */

.pun H2, .pun H4 {FONT-SIZE: 1em}
.pun H3 {FONT-SIZE: 1.1em}
#brdtitle H1 {FONT-SIZE: 1.4em}

/* 2.4 Larger text for particular items */
DIV.postmsg P {LINE-HEIGHT: 1.4}
DIV.postleft DT {FONT-SIZE: 1.1em}
.pun PRE {FONT-SIZE: 1.2em}

/* 2.5 Bold text */

DIV.postleft DT, DIV.postmsg H4, TD.tcl H3, DIV.forminfo H3, P.postlink, DIV.linkst LI,
DIV.linksb LI, DIV.postlinksb LI, .blockmenu LI, #brdtitle H1, .pun SPAN.warntext, .pun P.warntext {FONT-WEIGHT: bold}

/****************************************************************/
/* 3. LINKS */
/****************************************************************/

.pun A:link, .pun A:visited {
text-decoration: none;
border-bottom: none }
.pun A:hover {
text-decoration: none;
border-bottom: 1px dotted #80D6FF }

/* 3.1 Remove underlining for main menu, post header links, post links and vertical menus */

#brdmenu A:link, #brdmenu A:visited, .blockpost DT A:link, .blockpost DT A:visited, .blockpost H2 A:link,
.blockpost H2 A:visited, .postlink A:link, .postlink A:visited, .postfootright A:link, .postfootright A:visited,
.blockmenu A:link, .blockmenu A:visited {
    TEXT-DECORATION: none
}

/* 3.2 Underline on hover for links in headers and main menu */

#brdmenu A:hover, .blockpost H2 A:hover {TEXT-DECORATION: none}

/****************************************************************/
/* 4. BORDER WIDTH AND STYLE */
/****************************************************************/

/* 4.1 By default borders are 1px solid */

DIV.box, .pun TD, .pun TH, .pun BLOCKQUOTE, DIV.codebox, DIV.forminfo, DIV.blockpost LABEL {
    BORDER-STYLE: solid;
    BORDER-WIDTH: 1px
}

/* 4.2 Special settings for the board header. */

#brdheader DIV.box {BORDER-TOP-WIDTH: 4px}

/* 4.3 Borders for table cells */

.pun TD, .pun TH {
    BORDER-BOTTOM: none;
    BORDER-RIGHT: none
}

.pun .tcl {BORDER-LEFT: none}

/* 4.4 Special setting for fieldsets to preserve IE defaults */

DIV>FIELDSET {
    BORDER-STYLE: solid;
    BORDER-WIDTH: 1px
}

/****************************************************************/
/* 5. VERTICAL AND PAGE SPACING */
/****************************************************************/

/* 5.1 Page margins */

HTML, BODY {MARGIN: 0; PADDING: 0}
#punwrap {width: 1024px; margin: 12px auto}

/* 5.2 Creates vertical space between main board elements (Margins) */

DIV.blocktable, DIV.block, DIV.blockform, DIV.block2col, #postreview {MARGIN-BOTTOM: 12px}
#punindex DIV.blocktable, DIV.blockpost {MARGIN-BOTTOM: 6px}
DIV.block2col DIV.blockform, DIV.block2col DIV.block {MARGIN-BOTTOM: 0px}

/* 5.3 Remove space above breadcrumbs, postlinks and pagelinks with a negative top margin */

DIV.linkst, DIV.linksb {MARGIN-TOP: -12px}
DIV.postlinksb {MARGIN-TOP: -6px}

/* 5.4 Put a 12px gap above the board information box in index because the category tables only
have a 6px space beneath them */

#brdstats {MARGIN-TOP: 12px}

/****************************************************************/
/* 6. SPACING AROUND CONTENT */
/****************************************************************/

/* 6.1 Default padding for main items */

DIV.block DIV.inbox, DIV.blockmenu DIV.inbox {PADDING: 3px 6px}
.pun P, .pun UL, .pun DL, DIV.blockmenu LI, .pun LABEL, #announce DIV.inbox DIV {PADDING: 3px 0}
.pun H2 {PADDING: 4px 6px}

/* 6.2 Special spacing for various elements */

.pun H1 {PADDING: 3px 0px 0px 0}
#brdtitle P {PADDING-TOP: 0px}
DIV.linkst {PADDING: 8px 6px 3px 6px}
DIV.linksb, DIV.postlinksb {PADDING: 3px 6px 8px 6px}
#brdwelcome, #brdfooter DL A, DIV.blockmenu LI, DIV.rbox INPUT  {LINE-HEIGHT: 1.4em}
#viewprofile DT, #viewprofile DD {PADDING: 0 3px; LINE-HEIGHT: 2em}

/* 6.4 Create some horizontal spacing for various elements */

#brdmenu LI, DIV.rbox INPUT, DIV.blockform P INPUT  {MARGIN-RIGHT: 12px}

/****************************************************************/
/* 7. SPACING FOR TABLES */
/****************************************************************/

.pun TH, .pun TD {PADDING: 4px 6px}
.pun TD P {PADDING: 5px 0 0 0}

/****************************************************************/
/* 8. SPACING FOR POSTS */
/****************************************************************/

/* 8.1 Padding around left and right columns in viewtopic */

DIV.postleft DL, DIV.postright {PADDING: 6px}

/* 8.2 Extra spacing for poster contact details and avatar */

DD.usercontacts, DD.postavatar {MARGIN-TOP: 5px}
DD.postavatar {MARGIN-BOTTOM: 5px}

/* 8.3 Extra top spacing for signatures and edited by */

DIV.postsignature, DIV.postmsg P.postedit {PADDING-TOP: 15px}

/* 8.4 Spacing for code and quote boxes */

DIV.postmsg H4 {MARGIN-BOTTOM: 10px}
.pun BLOCKQUOTE, DIV.codebox {MARGIN: 5px 15px 15px 15px; PADDING: 8px}

/* 8.5 Padding for the action links and online indicator in viewtopic */

DIV.postfootleft P, DIV.postfootright UL, DIV.postfootright DIV {PADDING: 10px 6px 5px 6px}

/* 8.6 This is the input on moderators multi-delete view */

DIV.blockpost INPUT, DIV.blockpost LABEL {
    PADDING: 3px;
    DISPLAY: inline
}

P.multidelete {
    PADDING-TOP: 15px;
    PADDING-BOTTOM: 5px
}

/* 8.7 Make sure paragraphs in posts don't get any padding */

DIV.postmsg P {PADDING: 0}

/****************************************************************/
/* 9. SPECIAL SPACING FOR FORMS */
/****************************************************************/

/* 9.1 Padding around fieldsets */

DIV.blockform FORM, DIV.fakeform {PADDING: 20px 20px 15px 20px}
DIV.inform {PADDING-BOTTOM: 12px}

/* 9.2 Padding inside fieldsets */

.pun FIELDSET {PADDING: 0px 12px 0px 12px}
DIV.infldset {PADDING: 9px 0px 12px 0}
.pun LEGEND {PADDING: 0px 6px}

/* 9.3 The information box at the top of the registration form and elsewhere */

DIV.forminfo {
    MARGIN-BOTTOM: 12px;
    PADDING: 9px 10px
}

/* 9.4 BBCode help links in post forms */

UL.bblinks LI {PADDING-RIGHT: 20px}

UL.bblinks {PADDING-BOTTOM: 10px; PADDING-LEFT: 4px}

/* 9.5 Horizontal positioning for the submit button on forms */

DIV.blockform P INPUT {MARGIN-LEFT: 12px}

/****************************************************************/
/* 10. POST STATUS INDICATORS */
/****************************************************************/

/* 10.1 These are the post status indicators which appear at the left of some tables. 
.inew = new posts, .iredirect = redirect forums, .iclosed = closed topics and
.isticky = sticky topics. By default only .inew is different from the default.*/

div.icon {
    float: left;
    display: block;
    width:20px;
    height:20px;
}

DIV.searchposts DIV.icon {MARGIN-LEFT: 0}

/* 10.2 Class .tclcon is a div inside the first column of tables with post indicators. The
margin creates space for the post status indicator */

TD DIV.tclcon {MARGIN-LEFT: 2.3em}


#brdtitle {
    padding:7px 7px 8px;
    font-size:140%;
    line-height:1.2em;
    font-weight:normal;
    color:#fff;
    letter-spacing:.4em;
    text-align: center;
}


.pun H1 {
    padding:5px 5px 7px;
    font-size:140%;
    line-height:1.2em;
    font-weight:normal;
    color:#60A0DC;
    letter-spacing:.4em;
    text-align: center;
}


.blockpost h2 span {

font-size: 11px;

font-weight: normal;

background: 0;

padding-left: 0;

}

h2 span {
background: url('http://www.ktotheimmy.com/theforums/img/h2_icon.gif') 0px 3px no-repeat;
font-size: 12px;
font-weight: bold;
padding-left:12px;
} 

h2 span .conr {background:none;}

And this is the STYLESHEET_cs

/****************************************************************/
/* 1. BACKGROUND AND TEXT COLOURS */
/****************************************************************/

/* 1.1 Default background colour and text colour */

BODY {BACKGROUND-COLOR: #2A2A2A}

.pun {COLOR: #D4D4D4}

DIV.box,  #adminconsole FIELDSET TH, .rowodd, .roweven {BACKGROUND-COLOR: #383838}
#adminconsole TD, #adminconsole TH {BORDER-COLOR: #383838}

/* 1. 2 Darker background colours */

TD.tc2, TD.tc3, TD.tcmod, #brdfooter DIV.box {BACKGROUND-COLOR: #424242}
#adminconsole FIELDSET TD, #viewprofile DD, DIV.forminfo, DIV.blockmenu DIV.box, #adstats DD {BACKGROUND-COLOR: #484848}

.pun BLOCKQUOTE, DIV.codebox {BACKGROUND-COLOR: #353533}

/* 1.3 Main headers and navigation bar background and text colour */

.pun H2 {BACKGROUND-COLOR: #565656; COLOR: #D4D4D4; background-repeat : no-repeat;}

 #brdmenu {
border:1px solid #4D84B8; BACKGROUND-COLOR: #424242; COLOR: #424242; text-align: center; 
}

/* 1.4 Table header rows */

.pun TH, .bgc4 {BACKGROUND-COLOR: #484848}

/* 1.5 Fieldset legend text colour */

.pun LEGEND {COLOR: #60A0DC}

/* 1.6 Highlighted text for various items */

.pun DIV.blockmenu LI.isactive A, #posterror LI STRONG {COLOR: #D4D4D4}

/* 1.7 Dark background for form elements */

.pun TEXTAREA, .pun INPUT, .pun SELECT {BACKGROUND-COLOR: #2A2A2A; COLOR: #D4D4D4}

/****************************************************************/
/* 2. POST BACKGROUNDS AND TEXT */
/****************************************************************/

/* 2.1 This is the setup for posts. */

DIV.blockpost DIV.box, DIV.postright, DIV.postfootright, #postpreview {BACKGROUND-COLOR: #383838}
DIV.postright, DIV.postfootright {BORDER-LEFT-COLOR: #424242}
DIV.postleft, DIV.postfootleft, DIV.blockpost LABEL {BACKGROUND-COLOR: #424242}

/* 2.2 Background for post headers and text colour for post numbers in viewtopic */

DIV.blockpost H2 {BACKGROUND-COLOR: #565656}
DIV.blockpost H2 SPAN.conr {COLOR: #A19E96}

/* 2.3 This is the line above the signature in posts. Colour and background should be the same */

.pun HR {BACKGROUND-COLOR: #606060; COLOR: #606060}

/****************************************************************/
/* 3. BORDER COLOURS */
/****************************************************************/

/* 3.1 All external borders (H1 is the board title) */

DIV.box {BORDER-COLOR: #565656}

/* 3.2 Makes the top border of posts match the colour used for post headers */

DIV.blockpost DIV.box {BORDER-COLOR: #565656 #525252 #525252}

/* 3.3 Table internal borders. By default TH is same as background so border is invisible */

.pun TD {BORDER-COLOR: #565656}
.pun TH {BORDER-COLOR: #484848}

/* 3.4 Creates the inset border for quote boxes, code boxes and form info boxes */

.pun BLOCKQUOTE, DIV.codebox, DIV.forminfo, DIV.blockpost LABEL {BORDER-COLOR: #606060}

/* 3.5 Gecko's default fieldset borders are really nasty so this gives them a colour
without interferring with IE's rather nice default */

.pun DIV>FIELDSET {BORDER-COLOR: #ACA899}

/****************************************************************/
/* 4. LINK COLOURS */
/****************************************************************/

/* 4.1 This is the default for all links */

.pun A:link, .pun A:visited {COLOR: #60A0DC}
.pun A:hover {COLOR: #80D6FF}

/* 4.2 This is the colour for links in header rows and the navigation bar */

.pun H2 A:link, .pun H2 A:visited {COLOR: #D4D4D4}
.pun H2 A:hover {COLOR: #D4D4D4}

/* 4.3 This is for closed topics and "hot" links */

LI.postreport A:link, LI.postreport A:visited, TR.iclosed TD.tcl A:link, TR.iclosed TD.tcl A:visited {COLOR: #888}
LI.postreport A:hover, TR.iclosed TD.tcl A:hover {COLOR: #AAA}
LI.maintenancelink A:link, LI.maintenancelink A:visited {COLOR: #FF4000}
LI.maintenancelink A:hover {COLOR: #FF5010}

/****************************************************************/
/* 5. POST STATUS INDICATORS */
/****************************************************************/

/* These are the post status indicators which appear at the left of some tables. 
.inew = new posts, .iredirect = redirect forums, .iclosed = closed topics and
.isticky = sticky topics. The default is "icon". By default only .inew is different.*/

TR.inew Div.icon { background-image: url(../../img/new-topic.png); background-repeat : no-repeat;}

TR.isticky DIV.icon { background-image: url(../../img/sticky-topic.png); background-repeat : no-repeat; }

TR.isticky DIV.inew { background-image: url(../../img/sticky-topic.png); background-repeat : no-repeat;} 

Div.icon {background-image: url(../../img/nonew-topic.png); background-repeat : no-repeat;}

TR.iredirect DIV.icon { background-image: url(../../img/nonew-topic.png); background-repeat : no-repeat;}

TR.iclosed Div.icon {background-image: url(../../img/nonew-topic.png); background-repeat : no-repeat;}

/****************************************************************/
/* 6. EXTRAS */
/****************************************************************/

#punwrap {
    background: url(../../img//); /*Do NOT edit this unless you want a forum special border*/
}
.pun {
    background: url(../../img//); /*Do NOT edit this unless you want a forum special border*/
}
#brdtitle { 
    background: url(../../img//); /*Here add in your logo, eg img/oxygen/logo.gif*/
}
#brdfooter {
    background: url(../../img//); /*Do NOT edit this unless you want a forum special border*/
}

/*****************************
    post STATUS Offline 
******************************/
.pun DIV.postfootleft p {
padding : 0; 
font-style : normal; 
font-weight : normal; /* text style */
color : #FFFFFF; 
text-indent : 5px; /* text position */
display : block; 
height : 15px; /* icon size */
background-image : url(../../img/); 
background-repeat : no-repeat; 
background-position : 5px 55%; /* icon position */ 
}
/*****************************
    post STATUS Online 
******************************/
.pun DIV.postfootleft p strong {
font-style : normal; 
font-weight : bold; /* text style */
color : #FFFFFF; 
text-indent : 5px; /* text posistion here */
display : block; 
height : 15px;  /* icon size */
background-image : url(../../img/); 
background-repeat : no-repeat; 
background-position : 5px 55%;  /* icon position */
}

#brdmenu li {background:url(../../img/KtotheIMMY2/)}
#brdmenu li .conr {background:none;}

h2 span .conr {background:none;}

I have put Background-repeat : no-repeat; wherever I could, and still it has not changed anything. And I am getting real annoyed. mad
Please help smile

Nope , still has not fixed the problem.
The PROBLEM is INSIDE the PROFILE.php when you enter it on the forums, when you try and access "Personality" for exmaple.
The URL is this
http://www.kntl.co.uk/NEW%20FILES/profi … y&id=2

hmm

But I cannot seem to find this error.

EDIT- found it

TOP PART OF PROFILE

<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB 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.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/


define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/calendar.php';
require PUN_ROOT.'include/image_upload/image_upload.php';

$action = isset($_GET['action']) ? $_GET['action'] : null;
$section = isset($_GET['section']) ? $_GET['section'] : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id < 2)
    message($lang_common['Bad request']);

if ($pun_user['g_read_board'] == '0' && ($action != 'change_pass' || !isset($_GET['key'])))
    message($lang_common['No view']);

// Load the profile.php/register.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';

// Load the profile.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/profile.php';


if ($action == 'change_pass')
{
    if (isset($_GET['key']))
    {
        // If the user is already logged in we shouldn't be here :)
        if (!$pun_user['is_guest'])
        {
            header('Location: index.php');
            exit;
        }

        $key = $_GET['key'];

        $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch new password', __FILE__, __LINE__, $db->error());
        list($new_password_hash, $new_password_key) = $db->fetch_row($result);

        if ($key == '' || $key != $new_password_key)
            message($lang_profile['Pass key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
        else
        {
            $db->query('UPDATE '.$db->prefix.'users SET password=\''.$new_password_hash.'\', activate_string=NULL, activate_key=NULL WHERE id='.$id) or error('Unable to update password', __FILE__, __LINE__, $db->error());

            message($lang_profile['Pass updated'], true);
        }
    }

    // Make sure we are allowed to change this users password
    if ($pun_user['id'] != $id)
    {
        if ($pun_user['g_id'] > PUN_MOD)    // A regular user trying to change another users password?
            message($lang_common['No permission']);
        else if ($pun_user['g_id'] == PUN_MOD)    // A moderator trying to change a users password?
        {
            $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
            if (!$db->num_rows($result))
                message($lang_common['Bad request']);

            if ($pun_config['p_mod_edit_users'] == '0' || $pun_config['p_mod_change_passwords'] == '0' || $db->result($result) < PUN_GUEST)
                message($lang_common['No permission']);
        }
    }

    if (isset($_POST['form_sent']))
    {
        $old_password = isset($_POST['req_old_password']) ? trim($_POST['req_old_password']) : '';
        $new_password1 = trim($_POST['req_new_password1']);
        $new_password2 = trim($_POST['req_new_password2']);

        if ($new_password1 != $new_password2)
            message($lang_prof_reg['Pass not match']);
        if (strlen($new_password1) < 4)
            message($lang_prof_reg['Pass too short']);

        $result = $db->query('SELECT password, save_pass FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch password', __FILE__, __LINE__, $db->error());
        list($db_password_hash, $save_pass) = $db->fetch_row($result);

        $authorized = false;

        if (!empty($db_password_hash))
        {
            $sha1_in_db = (strlen($db_password_hash) == 40) ? true : false;
            $sha1_available = (function_exists('sha1') || function_exists('mhash')) ? true : false;

            $old_password_hash = pun_hash($old_password);    // This could result in either an SHA-1 or an MD5 hash

            if (($sha1_in_db && $sha1_available && $db_password_hash == $old_password_hash) ||
                (!$sha1_in_db && $db_password_hash == md5($old_password)) ||
                $pun_user['g_id'] < PUN_GUEST)
                $authorized = true;
        }

        if (!$authorized)
            message($lang_profile['Wrong pass']);

        $new_password_hash = pun_hash($new_password1);

        $db->query('UPDATE '.$db->prefix.'users SET password=\''.$new_password_hash.'\' WHERE id='.$id) or error('Unable to update password', __FILE__, __LINE__, $db->error());

        if ($pun_user['id'] == $id)
        {
            $expire = ($save_pass == '1') ? time() + 31536000 : 0;
            pun_setcookie($pun_user['id'], $new_password_hash, $expire);
        }

        redirect('http://www.kntl.co.uk/forum/profile.php?section=essentials&id='.$id, $lang_profile['Pass updated redirect']);
    }

    $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
    $required_fields = array('req_old_password' => $lang_profile['Old pass'], 'req_new_password1' => $lang_profile['New pass'], 'req_new_password2' => $lang_profile['Confirm new pass']);
    $focus_element = array('change_pass', (($pun_user['g_id'] > PUN_MOD) ? 'req_old_password' : 'req_new_password1'));
    require PUN_ROOT.'header.php';

?>
<div class="blockform">
    <h2><span><?php echo $lang_profile['Change pass'] ?></span></h2>
    <div class="box">
        <form id="change_pass" method="post" action="profile.php?action=change_pass&id=<?php echo $id ?>" onsubmit="return process_form(this)">
            <div class="inform">
                <input type="hidden" name="form_sent" value="1" />
                <fieldset>
                    <legend><?php echo $lang_profile['Change pass legend'] ?></legend>
                    <div class="infldset">
<?php if ($pun_user['g_id'] > PUN_MOD): ?>                        <label><strong><?php echo $lang_profile['Old pass'] ?></strong><br />
                        <input type="password" name="req_old_password" size="16" maxlength="16" /><br /></label>
<?php endif; ?>                        <label class="conl"><strong><?php echo $lang_profile['New pass'] ?></strong><br />
                        <input type="password" name="req_new_password1" size="16" maxlength="16" /><br /></label>
                        <label class="conl"><strong><?php echo $lang_profile['Confirm new pass'] ?></strong><br />
                        <input type="password" name="req_new_password2" size="16" maxlength="16" /><br /></label>
                        <div class="clearb"></div>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="update" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>
<?php

    require PUN_ROOT.'footer.php';
}


else if ($action == 'change_email')
{
    // Make sure we are allowed to change this users e-mail
    if ($pun_user['id'] != $id)
    {
        if ($pun_user['g_id'] > PUN_MOD)    // A regular user trying to change another users e-mail?
            message($lang_common['No permission']);
        else if ($pun_user['g_id'] == PUN_MOD)    // A moderator trying to change a users e-mail?
        {
            $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
            if (!$db->num_rows($result))
                message($lang_common['Bad request']);

            if ($pun_config['p_mod_edit_users'] == '0' || $db->result($result) < PUN_GUEST)
                message($lang_common['No permission']);
        }
    }

    if (isset($_GET['key']))
    {
        $key = $_GET['key'];

        $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch activation data', __FILE__, __LINE__, $db->error());
        list($new_email, $new_email_key) = $db->fetch_row($result);

        if ($key != $new_email_key)
            message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');
        else
        {
            $db->query('UPDATE '.$db->prefix.'users SET email=activate_string, activate_string=NULL, activate_key=NULL WHERE id='.$id) or error('Unable to update e-mail address', __FILE__, __LINE__, $db->error());

            message($lang_profile['E-mail updated'], true);
        }
    }
    else if (isset($_POST['form_sent']))
    {
        if (pun_hash($_POST['req_password']) !== $pun_user['password'])
            message($lang_profile['Wrong pass']);

        require PUN_ROOT.'include/email.php';

        // Validate the email-address
        $new_email = strtolower(trim($_POST['req_new_email']));
        if (!is_valid_email($new_email))
            message($lang_common['Invalid e-mail']);

        // Check it it's a banned e-mail address
        if (is_banned_email($new_email))
        {
            if ($pun_config['p_allow_banned_email'] == '0')
                message($lang_prof_reg['Banned e-mail']);
            else if ($pun_config['o_mailing_list'] != '')
            {
                $mail_subject = 'Alert - Banned e-mail detected';
                $mail_message = 'User \''.$pun_user['username'].'\' changed to banned e-mail address: '.$new_email."\n\n".'User profile: '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'Forum Mailer'."\n".'(Do not reply to this message)';

                pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
            }
        }

        // Check if someone else already has registered with that e-mail address
        $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE email=\''.$db->escape($new_email).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
        if ($db->num_rows($result))
        {
            if ($pun_config['p_allow_dupe_email'] == '0')
                message($lang_prof_reg['Dupe e-mail']);
            else if ($pun_config['o_mailing_list'] != '')
            {
                while ($cur_dupe = $db->fetch_assoc($result))
                    $dupe_list[] = $cur_dupe['username'];

                $mail_subject = 'Alert - Duplicate e-mail detected';
                $mail_message = 'User \''.$pun_user['username'].'\' changed to an e-mail address that also belongs to: '.implode(', ', $dupe_list)."\n\n".'User profile: '.$pun_config['o_base_url'].'/profile.php?id='.$id."\n\n".'-- '."\n".'Forum Mailer'."\n".'(Do not reply to this message)';

                pun_mail($pun_config['o_mailing_list'], $mail_subject, $mail_message);
            }
        }


        $new_email_key = random_pass(8);

        $db->query('UPDATE '.$db->prefix.'users SET activate_string=\''.$db->escape($new_email).'\', activate_key=\''.$new_email_key.'\' WHERE id='.$id) or error('Unable to update activation data', __FILE__, __LINE__, $db->error());

        // Load the "activate e-mail" template
        $mail_tpl = trim(file_get_contents(PUN_ROOT.'lang/'.$pun_user['language'].'/mail_templates/activate_email.tpl'));

        // The first row contains the subject
        $first_crlf = strpos($mail_tpl, "\n");
        $mail_subject = trim(substr($mail_tpl, 8, $first_crlf-8));
        $mail_message = trim(substr($mail_tpl, $first_crlf));

        $mail_message = str_replace('<username>', $pun_user['username'], $mail_message);
        $mail_message = str_replace('<base_url>', $pun_config['o_base_url'], $mail_message);
        $mail_message = str_replace('<activation_url>', $pun_config['o_base_url'].'/profile.php?action=change_email&id='.$id.'&key='.$new_email_key, $mail_message);
        $mail_message = str_replace('<board_mailer>', $pun_config['o_board_title'].' '.$lang_common['Mailer'], $mail_message);

        pun_mail($new_email, $mail_subject, $mail_message);

        message($lang_profile['Activate e-mail sent'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
    }

    $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
    $required_fields = array('req_new_email' => $lang_profile['New e-mail'], 'req_password' => $lang_common['Password']);
    $focus_element = array('change_email', 'req_new_email');
    require PUN_ROOT.'header.php';

?>
<div class="blockform">
    <h2><span><?php echo $lang_profile['Change e-mail'] ?></span></h2>
    <div class="box">
        <form id="change_email" method="post" action="profile.php?action=change_email&id=<?php echo $id ?>" id="change_email" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_profile['E-mail legend'] ?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <label><strong><?php echo $lang_profile['New e-mail'] ?></strong><br /><input type="text" name="req_new_email" size="50" maxlength="50" /><br /></label>
                        <label><strong><?php echo $lang_common['Password'] ?></strong><br /><input type="password" name="req_password" size="16" maxlength="16" /><br /></label>
                        <p><?php echo $lang_profile['E-mail instructions'] ?></p>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="new_email" value="<?php echo $lang_common['Submit'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>
<?php

    require PUN_ROOT.'footer.php';
}


else if ($action == 'upload_avatar' || $action == 'upload_avatar2')
{
    if ($pun_config['o_avatars'] == '0')
        message($lang_profile['Avatars disabled']);

    if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD)
        message($lang_common['No permission']);

    if (isset($_POST['form_sent']))
    {
        if (!isset($_FILES['req_file']))
            message($lang_profile['No file']);
            
        $uploaded_file = $_FILES['req_file'];

        // Make sure the upload went smooth
        if (isset($uploaded_file['error']))
        {
            switch ($uploaded_file['error'])
            {
                case 1:    // UPLOAD_ERR_INI_SIZE
                case 2:    // UPLOAD_ERR_FORM_SIZE
                    message($lang_profile['Too large ini']);
                    break;

                case 3:    // UPLOAD_ERR_PARTIAL
                    message($lang_profile['Partial upload']);
                    break;

                case 4:    // UPLOAD_ERR_NO_FILE
                    message($lang_profile['No file']);
                    break;

                case 6:    // UPLOAD_ERR_NO_TMP_DIR
                    message($lang_profile['No tmp directory']);
                    break;

                default:
                    // No error occured, but was something actually uploaded?
                    if ($uploaded_file['size'] == 0)
                        message($lang_profile['No file']);
                    break;
            }
        }

        if (is_uploaded_file($uploaded_file['tmp_name']))
        {
            $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
            if (!in_array($uploaded_file['type'], $allowed_types))
                message($lang_profile['Bad type']);

            // Make sure the file isn't too big
            if ($uploaded_file['size'] > $pun_config['o_avatars_size'])
                message($lang_profile['Too large'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].'.');

            // Determine type
            $extensions = null;
            if ($uploaded_file['type'] == 'image/gif')
                $extensions = array('.gif', '.jpg', '.png');
            else if ($uploaded_file['type'] == 'image/jpeg' || $uploaded_file['type'] == 'image/pjpeg')
                $extensions = array('.jpg', '.gif', '.png');
            else
                $extensions = array('.png', '.gif', '.jpg');

            // Move the file to the avatar directory. We do this before checking the width/height to circumvent open_basedir restrictions.
            if (!@move_uploaded_file($uploaded_file['tmp_name'], $pun_config['o_avatars_dir'].'/'.$id.'.tmp'))
                message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.');

            // Now check the width/height
            list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
            if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height'])
            {
                @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
            }
            else if ($type == 1 && $uploaded_file['type'] != 'image/gif')    // Prevent dodgy uploads
            {
                @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp');
                message($lang_profile['Bad type']);
            }            

            // Delete any old avatars and put the new one in place
            @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
            @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[1]);
            @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[2]);
            @rename($pun_config['o_avatars_dir'].'/'.$id.'.tmp', $pun_config['o_avatars_dir'].'/'.$id.$extensions[0]);
            @chmod($pun_config['o_avatars_dir'].'/'.$id.$extensions[0], 0644);
        }
        else
            message($lang_profile['Unknown failure']);

        // Enable use_avatar (seems sane since the user just uploaded an avatar)
        $db->query('UPDATE '.$db->prefix.'users SET use_avatar=1 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());

        redirect('http://www.kntl.co.uk/forum/profile.php?section=personality&id='.$id, $lang_profile['Avatar upload redirect']);
    }

    $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
    $required_fields = array('req_file' => $lang_profile['File']);
    $focus_element = array('upload_avatar', 'req_file');
    require PUN_ROOT.'header.php';

?>
<div class="blockform">
    <h2><span><?php echo $lang_profile['Upload avatar'] ?></span></h2>
    <div class="box">
        <form id="upload_avatar" method="post" enctype="multipart/form-data" action="profile.php?action=upload_avatar2&id=<?php echo $id ?>" onsubmit="return process_form(this)">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_profile['Upload avatar legend'] ?></legend>
                    <div class="infldset">
                        <input type="hidden" name="form_sent" value="1" />
                        <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $pun_config['o_avatars_size'] ?>" />
                        <label><strong><?php echo $lang_profile['File'] ?></strong><br /><input name="req_file" type="file" size="40" /><br /></label>
                        <p><?php echo $lang_profile['Avatar desc'].' '.$pun_config['o_avatars_width'].' x '.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].' '.$lang_common['and'].' '.$pun_config['o_avatars_size'].' '.$lang_profile['bytes'].' ('.ceil($pun_config['o_avatars_size'] / 1024) ?> KB).</p>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="upload" value="<?php echo $lang_profile['Upload'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>
<?php

    require PUN_ROOT.'footer.php';
}


else if ($action == 'delete_avatar')
{
    if ($pun_user['id'] != $id && $pun_user['g_id'] > PUN_MOD)
        message($lang_common['No permission']);

    confirm_referrer('profile.php');

    @unlink($pun_config['o_avatars_dir'].'/'.$id.'.jpg');
    @unlink($pun_config['o_avatars_dir'].'/'.$id.'.png');
    @unlink($pun_config['o_avatars_dir'].'/'.$id.'.gif');

    // Disable use_avatar
    $db->query('UPDATE '.$db->prefix.'users SET use_avatar=0 WHERE id='.$id) or error('Unable to update avatar state', __FILE__, __LINE__, $db->error());

    redirect('profile.php?section=personality&id='.$id, $lang_profile['Avatar deleted redirect']);
}


else if (isset($_POST['update_group_membership']))
{
    if ($pun_user['g_id'] > PUN_ADMIN)
        message($lang_common['No permission']);

    confirm_referrer('profile.php');

    $new_group_id = intval($_POST['group_id']);

    $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group_id.' WHERE id='.$id) or error('Unable to change user group', __FILE__, __LINE__, $db->error());

    // If the user was a moderator or an administrator, we remove him/her from the moderator list in all forums as well
    if ($new_group_id > PUN_MOD)
    {
        $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());

        while ($cur_forum = $db->fetch_assoc($result))
        {
            $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();

            if (in_array($id, $cur_moderators))
            {
                $username = array_search($id, $cur_moderators);
                unset($cur_moderators[$username]);
                $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';

                $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
            }
        }
    }

    redirect('profile.php?section=admin&id='.$id, $lang_profile['Group membership redirect']);
}

else if (isset($_POST['update_forums']))
{
    if ($pun_user['g_id'] > PUN_ADMIN)
        message($lang_common['No permission']);

    confirm_referrer('profile.php');

    // Get the username of the user we are processing
    $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
    $username = $db->result($result);

    $moderator_in = (isset($_POST['moderator_in'])) ? array_keys($_POST['moderator_in']) : array();

    // Loop through all forums
    $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());

    while ($cur_forum = $db->fetch_assoc($result))
    {
        $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();
        // If the user should have moderator access (and he/she doesn't already have it)
        if (in_array($cur_forum['id'], $moderator_in) && !in_array($id, $cur_moderators))
        {
            $cur_moderators[$username] = $id;
            ksort($cur_moderators);

            $db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
        }
        // If the user shouldn't have moderator access (and he/she already has it)
        else if (!in_array($cur_forum['id'], $moderator_in) && in_array($id, $cur_moderators))
        {
            unset($cur_moderators[$username]);
            $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';

            $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
        }
    }

    redirect('profile.php?section=admin&id='.$id, $lang_profile['Update forums redirect']);
}


else if (isset($_POST['ban']))
{
    if ($pun_user['g_id'] > PUN_MOD || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '0'))
        message($lang_common['No permission']);

    redirect('admin_bans.php?add_ban='.$id, $lang_profile['Ban redirect']);
}


else if (isset($_POST['delete_user']) || isset($_POST['delete_user_comply']))
{
    if ($pun_user['g_id'] > PUN_ADMIN)
        message($lang_common['No permission']);

    confirm_referrer('profile.php');

    // Get the username and group of the user we are deleting
    $result = $db->query('SELECT group_id, username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
    list($group_id, $username) = $db->fetch_row($result);

    if ($group_id == PUN_ADMIN)
        message('Administrators cannot be deleted. In order to delete this user, you must first move him/her to a different user group.');

    if (isset($_POST['delete_user_comply']))
    {
        // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well
        if ($group_id < PUN_GUEST)
        {
            $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());

            while ($cur_forum = $db->fetch_assoc($result))
            {
                $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array();

                if (in_array($id, $cur_moderators))
                {
                    unset($cur_moderators[$username]);
                    $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL';

                    $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
                }
            }
        }

        // Delete any subscriptions
        $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE user_id='.$id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());

        // Remove him/her from the online list (if they happen to be logged in)
        $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());

        // Should we delete all posts made by this user?
        if (isset($_POST['delete_posts']))
        {
            require PUN_ROOT.'include/search_idx.php';
            @set_time_limit(0);

            // Find all posts made by this user
            $result = $db->query('SELECT p.id, p.topic_id, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE p.poster_id='.$id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
            if ($db->num_rows($result))
            {
                while ($cur_post = $db->fetch_assoc($result))
                {
                    // Determine whether this post is the "topic post" or not
                    $result2 = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$cur_post['topic_id'].' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

                    if ($db->result($result2) == $cur_post['id'])
                        delete_topic($cur_post['topic_id']);
                    else
                        delete_post($cur_post['id'], $cur_post['topic_id']);

                    update_forum($cur_post['forum_id']);
                }
            }
        }
        else
            // Set all his/her posts to guest
            $db->query('UPDATE '.$db->prefix.'posts SET poster_id=1 WHERE poster_id='.$id) or error('Unable to update posts', __FILE__, __LINE__, $db->error());

        // Delete the user
        $db->query('DELETE FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
        
        require(PUN_ROOT.'include/pms/profile_delete.php');
        
        redirect('index.php', $lang_profile['User delete redirect']);
    }

    $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile'];
    require PUN_ROOT.'header.php';

?>
<div class="blockform">
    <h2><span><?php echo $lang_profile['Confirm delete user'] ?></span></h2>
    <div class="box">
        <form id="confirm_del_user" method="post" action="profile.php?id=<?php echo $id ?>">
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_profile['Confirm delete legend'] ?></legend>
                    <div class="infldset">
                        <p><?php echo $lang_profile['Confirmation info'].' '.pun_htmlspecialchars($username).'.' ?></p>
                        <div class="rbox">
                            <label><input type="checkbox" name="delete_posts" value="1" checked="checked" /><?php echo $lang_profile['Delete posts'] ?><br /></label>
                        </div>
                        <p class="warntext"><strong><?php echo $lang_profile['Delete warning'] ?></strong></p>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="delete_user_comply" value="<?php echo $lang_profile['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
        </form>
    </div>
</div>
<?php

    require PUN_ROOT.'footer.php';
}


else if (isset($_POST['form_sent']))
{
    // Fetch the user group of the user we are editing
    $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        message($lang_common['Bad request']);

    $group_id = $db->result($result);

    if ($pun_user['id'] != $id &&
        ($pun_user['g_id'] > PUN_MOD ||
        ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_edit_users'] == '0') ||
        ($pun_user['g_id'] == PUN_MOD && $group_id < PUN_GUEST)))
        message($lang_common['No permission']);

    if ($pun_user['g_id'] < PUN_GUEST)
        confirm_referrer('profile.php');

    // Extract allowed elements from $_POST['form']
    function extract_elements($allowed_elements)
    {
        $form = array();

        while (list($key, $value) = @each($_POST['form']))
        {
            if (in_array($key, $allowed_elements))
                $form[$key] = $value;
        }

        return $form;
    }

    $username_updated = false;

    // Validate input depending on section
    switch ($section)
    {
        case 'essentials':
        {
            $form = extract_elements(array('timezone', 'language'));

            if ($pun_user['g_id'] < PUN_GUEST)
            {
                $form['admin_note'] = trim($_POST['admin_note']);

                // Are we allowed to change usernames?
                if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_rename_users'] == '1'))
                {
                    $form['username'] = trim($_POST['req_username']);
                    $old_username = trim($_POST['old_username']);

                    if (strlen($form['username']) < 2)
                        message($lang_prof_reg['Username too short']);
                    else if (pun_strlen($form['username']) > 25)    // This usually doesn't happen since the form element only accepts 25 characters
                        message($lang_common['Bad request']);
                    else if (!strcasecmp($form['username'], 'Guest') || !strcasecmp($form['username'], $lang_common['Guest']))
                        message($lang_prof_reg['Username guest']);
                    else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $form['username']))
                        message($lang_prof_reg['Username IP']);
                    else if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[quote=|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $form['username']))
                        message($lang_prof_reg['Username BBCode']);

                    // Check that the username is not already registered
                    $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE username=\''.$db->escape($form['username']).'\' AND id!='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
                    if ($db->num_rows($result))
                        message($lang_profile['Dupe username']);

                    if ($form['username'] != $old_username)
                        $username_updated = true;
                }

                // We only allow administrators to update the post count
                if ($pun_user['g_id'] == PUN_ADMIN)
                    $form['num_posts'] = intval($_POST['num_posts']);
            }

            if ($pun_config['o_regs_verify'] == '0' || $pun_user['g_id'] < PUN_GUEST)
            {
                require PUN_ROOT.'include/email.php';

                // Validate the email-address
                $form['email'] = strtolower(trim($_POST['req_email']));
                if (!is_valid_email($form['email']))
                    message($lang_common['Invalid e-mail']);
            }

            // Make sure we got a valid language string
            if (isset($form['language']))
            {
                $form['language'] = preg_replace('#[\.\\\/]#', '', $form['language']);
                if (!file_exists(PUN_ROOT.'lang/'.$form['language'].'/common.php'))
                        message($lang_common['Bad request']);
            }

            break;
        }

        case 'personal':
        {
            $form = extract_elements(array('realname', 'url', 'location'));

            if ($pun_user['g_id'] == PUN_ADMIN)
                $form['title'] = trim($_POST['title']);
            else if ($pun_user['g_set_title'] == '1')
            {
                $form['title'] = trim($_POST['title']);

                if ($form['title'] != '')
                {
                    // A list of words that the title may not contain
                    // If the language is English, there will be some duplicates, but it's not the end of the world
                    $forbidden = array('Member', 'Moderator', 'Administrator', 'Banned', 'Guest', $lang_common['Member'], $lang_common['Moderator'], $lang_common['Administrator'], $lang_common['Banned'], $lang_common['Guest']);

                    if (in_array($form['title'], $forbidden))
                        message($lang_profile['Forbidden title']);
                }
            }

            // Add http:// if the URL doesn't contain it already
            if ($form['url'] != '' && !stristr($form['url'], 'http://'))
                $form['url'] = 'http://'.$form['url'];

            break;
        }

        case 'messaging':
        {
            $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo'));

            // If the ICQ UIN contains anything other than digits it's invalid
            if ($form['icq'] != '' && preg_match('/[^0-9]/', $form['icq']))
                message($lang_prof_reg['Bad ICQ']);

            break;
        }

        case 'personality':
        {
            $form = extract_elements(array('use_avatar'));

            // Clean up signature from POST
            $form['signature'] = pun_linebreaks(trim($_POST['signature']));

            // Validate signature
            if (pun_strlen($form['signature']) > $pun_config['p_sig_length'])
                message($lang_prof_reg['Sig too long'].' '.$pun_config['p_sig_length'].' '.$lang_prof_reg['characters'].'.');
            else if (substr_count($form['signature'], "\n") > ($pun_config['p_sig_lines']-1))
                message($lang_prof_reg['Sig too many lines'].' '.$pun_config['p_sig_lines'].' '.$lang_prof_reg['lines'].'.');
            else if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && strtoupper($form['signature']) == $form['signature'] && $pun_user['g_id'] > PUN_MOD)
                $form['signature'] = ucwords(strtolower($form['signature']));

            // Validate BBCode syntax
            if ($pun_config['p_sig_bbcode'] == '1' && strpos($form['signature'], '[') !== false && strpos($form['signature'], ']') !== false)
            {
                require PUN_ROOT.'include/parser.php';
                $form['signature'] = preparse_bbcode($form['signature'], $foo, true);
            }

            if (!isset($form['use_avatar']) || $form['use_avatar'] != '1') $form['use_avatar'] = '0';

            break;
        }

        case 'display':
        {
            $form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));
<?php
/***********************************************************************

  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB 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.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

//
// Cookie stuff!
//
function check_cookie(&$pun_user)
{
    global $db, $pun_config, $cookie_name, $cookie_seed;

    $now = time();
    $expire = $now + 31536000;    // The cookie expires after a year

    // We assume it's a guest
    $cookie = array('user_id' => 1, 'password_hash' => 'Guest');

    // If a cookie is set, we get the user_id and password hash from it
    if (isset($_COOKIE[$cookie_name]))
        list($cookie['user_id'], $cookie['password_hash']) = @unserialize($_COOKIE[$cookie_name]);

    if ($cookie['user_id'] > 1)
    {
        // Check if there's a user with the user ID and password hash from the cookie
        $result = $db->query('SELECT u.*, g.*, o.logged, o.idle FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.user_id=u.id WHERE u.id='.intval($cookie['user_id'])) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());
        $pun_user = $db->fetch_assoc($result);

        // If user authorisation failed
        if (!isset($pun_user['id']) || md5($cookie_seed.$pun_user['password']) !== $cookie['password_hash'])
        {
            pun_setcookie(0, random_pass(8), $expire);
            set_default_user();

            return;
        }

        // Set a default language if the user selected language no longer exists
        if (!@file_exists(PUN_ROOT.'lang/'.$pun_user['language']))
            $pun_user['language'] = $pun_config['o_default_lang'];

        // Set a default style if the user selected style no longer exists
        if (!@file_exists(PUN_ROOT.'style/'.$pun_user['style'].'.css'))
            $pun_user['style'] = $pun_config['o_default_style'];

        if (!$pun_user['disp_topics'])
            $pun_user['disp_topics'] = $pun_config['o_disp_topics_default'];
        if (!$pun_user['disp_posts'])
            $pun_user['disp_posts'] = $pun_config['o_disp_posts_default'];

        if ($pun_user['save_pass'] == '0')
            $expire = 0;

        // Define this if you want this visit to affect the online list and the users last visit data
        if (!defined('PUN_QUIET_VISIT'))
        {
            // Update the online list
            if (!$pun_user['logged'])
                $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
            else
            {
                // Special case: We've timed out, but no other user has browsed the forums since we timed out
                if ($pun_user['logged'] < ($now-$pun_config['o_timeout_visit']))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                    $pun_user['last_visit'] = $pun_user['logged'];
                }

                $idle_sql = ($pun_user['idle'] == '1') ? ', idle=0' : '';
                $db->query('UPDATE '.$db->prefix.'online SET logged='.$now.$idle_sql.' WHERE user_id='.$pun_user['id']) or error('Unable to update online list', __FILE__, __LINE__, $db->error());
            }
        }

        $pun_user['is_guest'] = false;
    }
    else
        set_default_user();
}


//
// Fill $pun_user with default values (for guests)
//
function set_default_user()
{
    global $db, $pun_user, $pun_config;

    $remote_addr = get_remote_address();

    // Fetch guest user
    $result = $db->query('SELECT u.*, g.*, o.logged FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON u.group_id=g.g_id LEFT JOIN '.$db->prefix.'online AS o ON o.ident=\''.$remote_addr.'\' WHERE u.id=1') or error('Unable to fetch guest information', __FILE__, __LINE__, $db->error());
    if (!$db->num_rows($result))
        exit('Unable to fetch guest information. The table \''.$db->prefix.'users\' must contain an entry with id = 1 that represents anonymous users.');

    $pun_user = $db->fetch_assoc($result);

    // Update online list
    if (!$pun_user['logged'])
        $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.time().')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
    else
        $db->query('UPDATE '.$db->prefix.'online SET logged='.time().' WHERE ident=\''.$db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error());

    $pun_user['disp_topics'] = $pun_config['o_disp_topics_default'];
    $pun_user['disp_posts'] = $pun_config['o_disp_posts_default'];
    $pun_user['timezone'] = $pun_config['o_server_timezone'];
    $pun_user['language'] = $pun_config['o_default_lang'];
    $pun_user['style'] = $pun_config['o_default_style'];
    $pun_user['is_guest'] = true;
}


//
// Set a cookie, PunBB style!
//
function pun_setcookie($user_id, $password_hash, $expire)
{
    global $cookie_name, $cookie_path, $cookie_domain, $cookie_secure, $cookie_seed;

    // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6)
//    @header('P3P: CP="CUR ADM"');

    setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure);
}


//
// Check whether the connecting user is banned (and delete any expired bans while we're at it)
//
function check_bans()
{
    global $db, $pun_config, $lang_common, $pun_user, $pun_bans;

    // Admins aren't affected
    if ($pun_user['g_id'] == PUN_ADMIN || !$pun_bans)
        return;

    // Add a dot at the end of the IP address to prevent banned address 192.168.0.5 from matching e.g. 192.168.0.50
    $user_ip = get_remote_address().'.';
    $bans_altered = false;

    foreach ($pun_bans as $cur_ban)
    {
        // Has this ban expired?
        if ($cur_ban['expire'] != '' && $cur_ban['expire'] <= time())
        {
            $db->query('DELETE FROM '.$db->prefix.'bans WHERE id='.$cur_ban['id']) or error('Unable to delete expired ban', __FILE__, __LINE__, $db->error());
            $bans_altered = true;
            continue;
        }

        if ($cur_ban['username'] != '' && !strcasecmp($pun_user['username'], $cur_ban['username']))
        {
            $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
            message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
        }

        if ($cur_ban['ip'] != '')
        {
            $cur_ban_ips = explode(' ', $cur_ban['ip']);

            for ($i = 0; $i < count($cur_ban_ips); ++$i)
            {
                $cur_ban_ips[$i] = $cur_ban_ips[$i].'.';

                if (substr($user_ip, 0, strlen($cur_ban_ips[$i])) == $cur_ban_ips[$i])
                {
                    $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
                    message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true);
                }
            }
        }
    }

    // If we removed any expired bans during our run-through, we need to regenerate the bans cache
    if ($bans_altered)
    {
        require_once PUN_ROOT.'include/cache.php';
        generate_bans_cache();
    }
}


//
// Update "Users online"
//
function update_users_online()
{
    global $db, $pun_config, $pun_user;

    $now = time();

    // Fetch all online list entries that are older than "o_timeout_online"
    $result = $db->query('SELECT * FROM '.$db->prefix.'online WHERE logged<'.($now-$pun_config['o_timeout_online'])) or error('Unable to fetch old entries from online list', __FILE__, __LINE__, $db->error());
    while ($cur_user = $db->fetch_assoc($result))
    {
        // If the entry is a guest, delete it
        if ($cur_user['user_id'] == '1')
            $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($cur_user['ident']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
        else
        {
            // If the entry is older than "o_timeout_visit", update last_visit for the user in question, then delete him/her from the online list
            if ($cur_user['logged'] < ($now-$pun_config['o_timeout_visit']))
            {
                $db->query('UPDATE '.$db->prefix.'users SET last_visit='.$cur_user['logged'].' WHERE id='.$cur_user['user_id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
                $db->query('DELETE FROM '.$db->prefix.'online WHERE user_id='.$cur_user['user_id']) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error());
            }
            else if ($cur_user['idle'] == '0')
                $db->query('UPDATE '.$db->prefix.'online SET idle=1 WHERE user_id='.$cur_user['user_id']) or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
        }
    }
}


//
// Generate the "navigator" that appears at the top of every page
//
function generate_navlinks()
{
    global $pun_config, $lang_common, $pun_user;

    // Index and Userlist should always be displayed
    $links[] = '<li id="navindex"><a href="http://www.kntl.co.uk/forum/index.php">'.$lang_common['Index'].'</a>';
    if ($pun_user['g_search'] == '1')
            $links[] = '<li id="navsearch"><a href="http://www.kntl.co.uk/forum/search.php">'.$lang_common['Search'].'</a>';
    $links[] = '<li id="navuserlist"><a href="http://www.kntl.co.uk/forum/userlist.php">'.$lang_common['User list'].'</a>';

    if ($pun_config['o_rules'] == '1')
        $links[] = '<li id="navrules"><a href="http://www.kntl.co.uk/forum/misc.php?action=rules">'.$lang_common['Rules'].'</a>';

    if ($pun_user['is_guest'])
    {

        $links[] = '<li id="navregister"><a href="http://www.kntl.co.uk/forum/register.php">'.$lang_common['Register'].'</a>';
        $links[] = '<li id="navlogin"><a href="http://www.kntl.co.uk/forum/login.php">'.$lang_common['Login'].'</a>';

        $info = $lang_common['Not logged in'];
    }
    else
    {
        if ($pun_user['g_id'] > PUN_MOD)
        {
        
        if ($pun_config['o_rules'] == '1')
        $links[] = '<li id="navrules"><a href="http://www.kntl.co.uk/forum/misc.php?action=rules">'.$lang_common['Rules'].'</a>';
        

            $links[] = '<li id="navprofile"><a href="http://www.kntl.co.uk/forum/profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
            require(PUN_ROOT.'include/pms/functions_navlinks.php');
            $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
        }
        else
        {
            $links[] = '<li id="navprofile"><a href="http://www.kntl.co.uk/forum/profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
            $links[] = '<li id="navadmin"><a href="http://www.kntl.co.uk/forum/admin_index.php">'.$lang_common['Admin'].'</a>';
            require(PUN_ROOT.'include/pms/functions_navlinks.php');
            $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
        }
    }

    // Are there any additional navlinks we should insert into the array before imploding it?
    if ($pun_config['o_additional_navlinks'] != '')
    {
        if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
        {
            // Insert any additional links into the $links array (at the correct index)
            for ($i = 0; $i < count($extra_links[1]); ++$i)
                array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i]));
        }
    }

    return '<ul>'."\n\t\t\t\t".implode($lang_common['Link separator'].'</li>'."\n\t\t\t\t", $links).'</li>'."\n\t\t\t".'</ul>';
}


//
// Display the profile navigation menu
//
function generate_profile_menu($page = '')
{
    global $lang_profile, $pun_config, $pun_user, $id;

?>
<div id="profile" class="block2col">
    <div class="blockmenu">
        <h2><span><?php echo $lang_profile['Profile menu'] ?></span></h2>
        <div class="box">
            <div class="inbox">
                <ul>
                    <li<?php if ($page == 'essentials') echo ' class="isactive"'; ?>><a href="profile.php?section=essentials&id=<?php echo $id ?>"><?php echo $lang_profile['Section essentials'] ?></a></li>
                    <li<?php if ($page == 'personal') echo ' class="isactive"'; ?>><a href="profile.php?section=personal&id=<?php echo $id ?>"><?php echo $lang_profile['Section personal'] ?></a></li>
                    <li<?php if ($page == 'messaging') echo ' class="isactive"'; ?>><a href="profile.php?section=messaging&id=<?php echo $id ?>"><?php echo $lang_profile['Section messaging'] ?></a></li>
                    <li<?php if ($page == 'personality') echo ' class="isactive"'; ?>><a href="profile.php?section=personality&id=<?php echo $id ?>"><?php echo $lang_profile['Section personality'] ?></a></li>
                    <li<?php if ($page == 'display') echo ' class="isactive"'; ?>><a href="profile.php?section=display&id=<?php echo $id ?>"><?php echo $lang_profile['Section display'] ?></a></li>
                    <li<?php if ($page == 'privacy') echo ' class="isactive"'; ?>><a href="profile.php?section=privacy&id=<?php echo $id ?>"><?php echo $lang_profile['Section privacy'] ?></a></li>
<?php if ($pun_user['g_id'] == PUN_ADMIN || ($pun_user['g_id'] == PUN_MOD && $pun_config['p_mod_ban_users'] == '1')): ?>                    <li<?php if ($page == 'admin') echo ' class="isactive"'; ?>><a href="profile.php?section=admin&id=<?php echo $id ?>"><?php echo $lang_profile['Section admin'] ?></a></li>
<?php endif; ?>                </ul>
            </div>
        </div>
    </div>
<?php

}


//
// Update posts, topics, last_post, last_post_id and last_poster for a forum (redirect topics are not included)
//
function update_forum($forum_id)
{
    global $db;

    $result = $db->query('SELECT COUNT(id), SUM(num_replies) FROM '.$db->prefix.'topics WHERE moved_to IS NULL AND forum_id='.$forum_id) or error('Unable to fetch forum topic count', __FILE__, __LINE__, $db->error());
    list($num_topics, $num_posts) = $db->fetch_row($result);

    $num_posts = $num_posts + $num_topics;        // $num_posts is only the sum of all replies (we have to add the topic posts)

    $result = $db->query('SELECT last_post, last_post_id, last_poster FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.' AND moved_to IS NULL ORDER BY last_post DESC LIMIT 1') or error('Unable to fetch last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error());
    if ($db->num_rows($result))        // There are topics in the forum
    {
        list($last_post, $last_post_id, $last_poster) = $db->fetch_row($result);

        $db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$db->escape($last_poster).'\' WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error());
    }
    else    // There are no topics
        $db->query('UPDATE '.$db->prefix.'forums SET num_topics=0, num_posts=0, last_post=NULL, last_post_id=NULL, last_poster=NULL WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error());
}


//
// Delete a topic and all of it's posts
//
function delete_topic($topic_id)
{
    global $db;

    // Delete the topic and any redirect topics
    $db->query('DELETE FROM '.$db->prefix.'topics WHERE id='.$topic_id.' OR moved_to='.$topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $db->error());

    // Create a list of the post ID's in this topic
    $post_ids = '';
    $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
    while ($row = $db->fetch_row($result)) {
        $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
        delete_images($row[0]);
    }

    // Make sure we have a list of post ID's
    if ($post_ids != '')
    {
        strip_search_index($post_ids);

        // Delete posts in topic
        $db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
    }

    // Delete any subscriptions for this topic
    $db->query('DELETE FROM '.$db->prefix.'subscriptions WHERE topic_id='.$topic_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error());
}


//
// Delete a single post
//
function delete_post($post_id, $topic_id)
{
    global $db;

    $result = $db->query('SELECT id, poster, posted FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id.' ORDER BY id DESC LIMIT 2') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    list($last_id, ,) = $db->fetch_row($result);
    list($second_last_id, $second_poster, $second_posted) = $db->fetch_row($result);

    // Delete the post
    $db->query('DELETE FROM '.$db->prefix.'posts WHERE id='.$post_id) or error('Unable to delete post', __FILE__, __LINE__, $db->error());
    delete_images($post_id);

    strip_search_index($post_id);

    // Count number of replies in the topic
    $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error());
    $num_replies = $db->result($result, 0) - 1;

    // If the message we deleted is the most recent in the topic (at the end of the topic)
    if ($last_id == $post_id)
    {
        // If there is a $second_last_id there is more than 1 reply to the topic
        if (!empty($second_last_id))
            $db->query('UPDATE '.$db->prefix.'topics SET last_post='.$second_posted.', last_post_id='.$second_last_id.', last_poster=\''.$db->escape($second_poster).'\', num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
        else
            // We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
            $db->query('UPDATE '.$db->prefix.'topics SET last_post=posted, last_post_id=id, last_poster=poster, num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
    }
    else
        // Otherwise we just decrement the reply counter
        $db->query('UPDATE '.$db->prefix.'topics SET num_replies='.$num_replies.' WHERE id='.$topic_id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
}


//
// Replace censored words in $text
//
function censor_words($text)
{
    global $db;
    static $search_for, $replace_with;

    // If not already built in a previous call, build an array of censor words and their replacement text
    if (!isset($search_for))
    {
        $result = $db->query('SELECT search_for, replace_with FROM '.$db->prefix.'censoring') or error('Unable to fetch censor word list', __FILE__, __LINE__, $db->error());
        $num_words = $db->num_rows($result);

        $search_for = array();
        for ($i = 0; $i < $num_words; ++$i)
        {
            list($search_for[$i], $replace_with[$i]) = $db->fetch_row($result);
            $search_for[$i] = '/\b('.str_replace('\*', '\w*?', preg_quote($search_for[$i], '/')).')\b/i';
        }
    }

    if (!empty($search_for))
        $text = substr(preg_replace($search_for, $replace_with, ' '.$text.' '), 1, -1);

    return $text;
}


//
// Determines the correct title for $user
// $user must contain the elements 'username', 'title', 'posts', 'g_id' and 'g_user_title'
//
function get_title($user)
{
    global $db, $pun_config, $pun_bans, $lang_common;
    static $ban_list, $pun_ranks;

    // If not already built in a previous call, build an array of lowercase banned usernames
    if (empty($ban_list))
    {
        $ban_list = array();

        foreach ($pun_bans as $cur_ban)
            $ban_list[] = strtolower($cur_ban['username']);
    }

    // If not already loaded in a previous call, load the cached ranks
    if ($pun_config['o_ranks'] == '1' && empty($pun_ranks))
    {
        @include PUN_ROOT.'cache/cache_ranks.php';
        if (!defined('PUN_RANKS_LOADED'))
        {
            require_once PUN_ROOT.'include/cache.php';
            generate_ranks_cache();
            require PUN_ROOT.'cache/cache_ranks.php';
        }
    }

    // If the user has a custom title
    if ($user['title'] != '')
        $user_title = pun_htmlspecialchars($user['title']);
    // If the user is banned
    else if (in_array(strtolower($user['username']), $ban_list))
        $user_title = $lang_common['Banned'];
    // If the user group has a default user title
    else if ($user['g_user_title'] != '')
        $user_title = pun_htmlspecialchars($user['g_user_title']);
    // If the user is a guest
    else if ($user['g_id'] == PUN_GUEST)
        $user_title = $lang_common['Guest'];
    else
    {
        // Are there any ranks?
        if ($pun_config['o_ranks'] == '1' && !empty($pun_ranks))
        {
            @reset($pun_ranks);
            while (list(, $cur_rank) = @each($pun_ranks))
            {
                if (intval($user['num_posts']) >= $cur_rank['min_posts'])
                    $user_title = pun_htmlspecialchars($cur_rank['rank']);
            }
        }

        // If the user didn't "reach" any rank (or if ranks are disabled), we assign the default
        if (!isset($user_title))
            $user_title = $lang_common['Member'];
    }

    return $user_title;
}


//
// Generate a string with numbered links (for multipage scripts)
//
function paginate($num_pages, $cur_page, $link_to)
{
    $pages = array();
    $link_to_all = false;

    // If $cur_page == -1, we link to all pages (used in viewforum.php)
    if ($cur_page == -1)
    {
        $cur_page = 1;
        $link_to_all = true;
    }

    if ($num_pages <= 1)
        $pages = array('<strong>1</strong>');
    else
    {
        if ($cur_page > 3)
        {
            $pages[] = '<a href="'.$link_to.'&p=1">1</a>';

            if ($cur_page != 4)
                $pages[] = '…';
        }

        // Don't ask me how the following works. It just does, OK? :-)
        for ($current = $cur_page - 2, $stop = $cur_page + 3; $current < $stop; ++$current)
        {
            if ($current < 1 || $current > $num_pages)
                continue;
            else if ($current != $cur_page || $link_to_all)
                $pages[] = '<a href="'.$link_to.'&p='.$current.'">'.$current.'</a>';
            else
                $pages[] = '<strong>'.$current.'</strong>';
        }

        if ($cur_page <= ($num_pages-3))
        {
            if ($cur_page != ($num_pages-3))
                $pages[] = '…';

            $pages[] = '<a href="'.$link_to.'&p='.$num_pages.'">'.$num_pages.'</a>';
        }
    }

    return implode(' ', $pages);
}


//
// Display a message
//
function message($message, $no_back_link = false)
{
    global $db, $lang_common, $pun_config, $pun_start, $tpl_main;

    if (!defined('PUN_HEADER'))
    {
        global $pun_user;

        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Info'];
        require PUN_ROOT.'header.php';
    }

?>

<div id="msg" class="block">
    <h2><span><?php echo $lang_common['Info'] ?></span></h2>
    <div class="box">
        <div class="inbox">
        <p><?php echo $message ?></p>
<?php if (!$no_back_link): ?>        <p><a href="javascript: history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
<?php endif; ?>        </div>
    </div>
</div>
<?php

    require PUN_ROOT.'footer.php';
}


//
// Format a time string according to $time_format and timezones
//
function format_time($timestamp, $date_only = false)
{
    global $pun_config, $lang_common, $pun_user;

    if ($timestamp == '')
        return $lang_common['Never'];

    $diff = ($pun_user['timezone'] - $pun_config['o_server_timezone']) * 3600;
    $timestamp += $diff;
    $now = time();

    $date = date($pun_config['o_date_format'], $timestamp);
    $today = date($pun_config['o_date_format'], $now+$diff);
    $yesterday = date($pun_config['o_date_format'], $now+$diff-86400);

    if ($date == $today)
        $date = $lang_common['Today'];
    else if ($date == $yesterday)
        $date = $lang_common['Yesterday'];

    if (!$date_only)
        return $date.' '.date($pun_config['o_time_format'], $timestamp);
    else
        return $date;
}


//
// If we are running pre PHP 4.3.0, we add our own implementation of file_get_contents
//
if (!function_exists('file_get_contents'))
{
    function file_get_contents($filename, $use_include_path = 0)
    {
        $data = '';

        if ($fh = fopen($filename, 'rb', $use_include_path))
        {
            $data = fread($fh, filesize($filename));
            fclose($fh);
        }

        return $data;
    }
}


//
// Make sure that HTTP_REFERER matches $pun_config['o_base_url']/$script
//
function confirm_referrer($script)
{
    global $pun_config, $lang_common;

    if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/'.$script, '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''))))
        message($lang_common['Bad referrer']);
}


//
// Generate a random password of length $len
//
function random_pass($len)
{
    $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    $password = '';
    for ($i = 0; $i < $len; ++$i)
        $password .= substr($chars, (mt_rand() % strlen($chars)), 1);

    return $password;
}


//
// Compute a hash of $str
// Uses sha1() if available. If not, SHA1 through mhash() if available. If not, fall back on md5().
//
function pun_hash($str)
{
    if (function_exists('sha1'))    // Only in PHP 4.3.0+
        return sha1($str);
    else if (function_exists('mhash'))    // Only if Mhash library is loaded
        return bin2hex(mhash(MHASH_SHA1, $str));
    else
        return md5($str);
}


//
// Try to determine the correct remote IP-address
//
function get_remote_address()
{
    return $_SERVER['REMOTE_ADDR'];
}


//
// Equivalent to htmlspecialchars(), but allows &#[0-9]+ (for unicode)
//
function pun_htmlspecialchars($str)
{
    $str = preg_replace('/&(?!#[0-9]+;)/s', '&', $str);
    $str = str_replace(array('<', '>', '"'), array('<', '>', '"'), $str);

    return $str;
}


//
// Equivalent to strlen(), but counts &#[0-9]+ as one character (for unicode)
//
function pun_strlen($str)
{
    return strlen(preg_replace('/&#([0-9]+);/', '!', $str));
}


//
// Convert \r\n and \r to \n
//
function pun_linebreaks($str)
{
    return str_replace("\r", "\n", str_replace("\r\n", "\n", $str));
}


//
// A more aggressive version of trim()
//
function pun_trim($str)
{
    global $lang_common;

    if (strpos($lang_common['lang_encoding'], '8859') !== false)
    {
        $fishy_chars = array(chr(0x81), chr(0x8D), chr(0x8F), chr(0x90), chr(0x9D), chr(0xA0));
        return trim(str_replace($fishy_chars, ' ', $str));
    }
    else
        return trim($str);
}


//
// Display a message when board is in maintenance mode
//
function maintenance_message()
{
    global $db, $pun_config, $lang_common, $pun_user;

    // Deal with newlines, tabs and multiple spaces
    $pattern = array("\t", '  ', '  ');
    $replace = array('    ', '  ', '  ');
    $message = str_replace($pattern, $replace, $pun_config['o_maintenance_message']);


    // Load the maintenance template
    $tpl_maint = trim(file_get_contents(PUN_ROOT.'include/template/maintenance.tpl'));


    // START SUBST - <pun_content_direction>
    $tpl_maint = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_maint);
    // END SUBST - <pun_content_direction>


    // START SUBST - <pun_char_encoding>
    $tpl_maint = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_maint);
    // END SUBST - <pun_char_encoding>


    // START SUBST - <pun_head>
    ob_start();

?>
<title><?php echo pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Maintenance'] ?></title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
<?php

    $tpl_temp = trim(ob_get_contents());
    $tpl_maint = str_replace('<pun_head>', $tpl_temp, $tpl_maint);
    ob_end_clean();
    // END SUBST - <pun_head>


    // START SUBST - <pun_maint_heading>
    $tpl_maint = str_replace('<pun_maint_heading>', $lang_common['Maintenance'], $tpl_maint);
    // END SUBST - <pun_maint_heading>


    // START SUBST - <pun_maint_message>
    $tpl_maint = str_replace('<pun_maint_message>', $message, $tpl_maint);
    // END SUBST - <pun_maint_message>


    // End the transaction
    $db->end_transaction();


    // START SUBST - <pun_include "*">
    while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_maint, $cur_include))
    {
        if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1]))
            error('Unable to process user include <pun_include "'.htmlspecialchars($cur_include[1]).'"> from template maintenance.tpl. There is no such file in folder /include/user/');

        ob_start();
        include PUN_ROOT.'include/user/'.$cur_include[1];
        $tpl_temp = ob_get_contents();
        $tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint);
        ob_end_clean();
    }
    // END SUBST - <pun_include "*">


    // Close the db connection (and free up any result data)
    $db->close();

    exit($tpl_maint);
}


//
// Display $message and redirect user to $destination_url
//
function redirect($destination_url, $message)
{
    global $db, $pun_config, $lang_common, $pun_user;

    if ($destination_url == '')
        $destination_url = 'index.php';

    // If the delay is 0 seconds, we might as well skip the redirect all together
    if ($pun_config['o_redirect_delay'] == '0')
        header('Location: '.str_replace('&', '&', $destination_url));


    // Load the redirect template
    $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl'));


    // START SUBST - <pun_content_direction>
    $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir);
    // END SUBST - <pun_content_direction>


    // START SUBST - <pun_char_encoding>
    $tpl_redir = str_replace('<pun_char_encoding>', $lang_common['lang_encoding'], $tpl_redir);
    // END SUBST - <pun_char_encoding>


    // START SUBST - <pun_head>
    ob_start();

?>
<meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay'] ?>;URL=<?php echo str_replace(array('<', '>', '"'), array('<', '>', '"'), $destination_url) ?>" />
<title><?php echo pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Redirecting'] ?></title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
<?php

    $tpl_temp = trim(ob_get_contents());
    $tpl_redir = str_replace('<pun_head>', $tpl_temp, $tpl_redir);
    ob_end_clean();
    // END SUBST - <pun_head>


    // START SUBST - <pun_redir_heading>
    $tpl_redir = str_replace('<pun_redir_heading>', $lang_common['Redirecting'], $tpl_redir);
    // END SUBST - <pun_redir_heading>


    // START SUBST - <pun_redir_text>
    $tpl_temp = $message.'<br /><br />'.'<a href="'.$destination_url.'">'.$lang_common['Click redirect'].'</a>';
    $tpl_redir = str_replace('<pun_redir_text>', $tpl_temp, $tpl_redir);
    // END SUBST - <pun_redir_text>


    // START SUBST - <pun_footer>
    ob_start();

    // End the transaction
    $db->end_transaction();

    // Display executed queries (if enabled)
    if (defined('PUN_SHOW_QUERIES'))
        display_saved_queries();

    $tpl_temp = trim(ob_get_contents());
    $tpl_redir = str_replace('<pun_footer>', $tpl_temp, $tpl_redir);
    ob_end_clean();
    // END SUBST - <pun_footer>


    // START SUBST - <pun_include "*">
    while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_redir, $cur_include))
    {
        if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1]))
            error('Unable to process user include <pun_include "'.htmlspecialchars($cur_include[1]).'"> from template redirect.tpl. There is no such file in folder /include/user/');

        ob_start();
        include PUN_ROOT.'include/user/'.$cur_include[1];
        $tpl_temp = ob_get_contents();
        $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir);
        ob_end_clean();
    }
    // END SUBST - <pun_include "*">


    // Close the db connection (and free up any result data)
    $db->close();

    exit($tpl_redir);
}


//
// Display a simple error message
//
function error($message, $file, $line, $db_error = false)
{
    global $pun_config;

    // Set a default title if the script failed before $pun_config could be populated
    if (empty($pun_config))
        $pun_config['o_board_title'] = 'PunBB';

    // Empty output buffer and stop buffering
    @ob_end_clean();

    // "Restart" output buffering if we are using ob_gzhandler (since the gzip header is already sent)
    if (!empty($pun_config['o_gzip']) && extension_loaded('zlib') && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false || strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== false))
        ob_start('ob_gzhandler');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?> / Error</title>
<style type="text/css">
<!--
BODY {MARGIN: 10% 20% auto 20%; font: 10px Verdana, Arial, Helvetica, sans-serif}
#errorbox {BORDER: 1px solid #B84623}
H2 {MARGIN: 0; COLOR: #FFFFFF; BACKGROUND-COLOR: #B84623; FONT-SIZE: 1.1em; PADDING: 5px 4px}
#errorbox DIV {PADDING: 6px 5px; BACKGROUND-COLOR: #F1F1F1}
-->
</style>
</head>
<body>

<div id="errorbox">
    <h2>An error was encountered</h2>
    <div>
<?php

    if (defined('PUN_DEBUG'))
    {
        echo "\t\t".'<strong>File:</strong> '.$file.'<br />'."\n\t\t".'<strong>Line:</strong> '.$line.'<br /><br />'."\n\t\t".'<strong>PunBB reported</strong>: '.$message."\n";

        if ($db_error)
        {
            echo "\t\t".'<br /><br /><strong>Database reported:</strong> '.pun_htmlspecialchars($db_error['error_msg']).(($db_error['error_no']) ? ' (Errno: '.$db_error['error_no'].')' : '')."\n";

            if ($db_error['error_sql'] != '')
                echo "\t\t".'<br /><br /><strong>Failed query:</strong> '.pun_htmlspecialchars($db_error['error_sql'])."\n";
        }
    }
    else
        echo "\t\t".'Error: <strong>'.$message.'.</strong>'."\n";

?>
    </div>
</div>

</body>
</html>
<?php

    // If a database connection was established (before this error) we close it
    if ($db_error)
        $GLOBALS['db']->close();

    exit;
}

// DEBUG FUNCTIONS BELOW

//
// Display executed queries (if enabled)
//
function display_saved_queries()
{
    global $db, $lang_common;

    // Get the queries so that we can print them out
    $saved_queries = $db->get_saved_queries();

?>

<div id="debug" class="blocktable">
    <h2><span><?php echo $lang_common['Debug table'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <table cellspacing="0">
            <thead>
                <tr>
                    <th class="tcl" scope="col">Time (s)</th>
                    <th class="tcr" scope="col">Query</th>
                </tr>
            </thead>
            <tbody>
<?php

    $query_time_total = 0.0;
    while (list(, $cur_query) = @each($saved_queries))
    {
        $query_time_total += $cur_query[1];

?>
                <tr>
                    <td class="tcl"><?php echo ($cur_query[1] != 0) ? $cur_query[1] : ' ' ?></td>
                    <td class="tcr"><?php echo pun_htmlspecialchars($cur_query[0]) ?></td>
                </tr>
<?php

    }

?>
                <tr>
                    <td class="tcl" colspan="2">Total query time: <?php echo $query_time_total ?> s</td>
                </tr>
            </tbody>
            </table>
        </div>
    </div>
</div>
<?php

}


//
// Unset any variables instantiated as a result of register_globals being enabled
//
function unregister_globals()
{
    // Prevent script.php?GLOBALS[foo]=bar
    if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']))
        exit('I\'ll have a steak sandwich and... a steak sandwich.');
    
    // Variables that shouldn't be unset
    $no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');

    // Remove elements in $GLOBALS that are present in any of the superglobals
    $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
    foreach ($input as $k => $v)
    {
        if (!in_array($k, $no_unset) && isset($GLOBALS[$k]))
            unset($GLOBALS[$k]);
    }
}


//
// Dump contents of variable(s)
//
function dump()
{
    echo '<pre>';

    $num_args = func_num_args();

    for ($i = 0; $i < $num_args; ++$i)
    {
        print_r(func_get_arg($i));
        echo "\n\n";
    }

    echo '</pre>';
    exit;
}

FUNCTIONS.PHP

Edit - it must be this file, no? Because it contains all the PROFILE links.

You mean all the code?
PROFILE.php is kinda large. tongue

You see, that is the problem right there.
I cannot find the messed up links.

Wow this is messed up. sad

OK, but how do I do it by hand?
The file edited was PROFILE.php, I need to change it back to the default link.
How do I do so? hmm

I made the mistake.
What happened was, I was trying to keep the edited files separate to the normal ones, just incase something went wrong.
And when I clicked save in DREAMWEAVER, I saved them in the folder "NEW FILES", and DREAMWEAVER asked me
"UPDATE LINKS?"
And I accidentally clicked yes, so now all the links refer to that folder.
But I have no idea how to revert it, help anyone?

25

(4 replies, posted in PunBB 1.2 show off)

The first one has has lots of mods added to it.
I want to add some more, but I cant think of any.
Any suggestions guys?
The styles are quite basic, but they look nice and clean. They are mixed ideas from every style I have seen.
smile