Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • osian/sucs-site
  • kais58/sucs-site
  • imranh/sucs-site
  • foshjedi2004/sucs-site
  • gigosaurus/sucs-site
  • matstn/sucs-site
  • ripp_/sucs-site
  • eggnog/sucs-site
  • sucssite/sucs-site
  • elbows/sucs-site
  • realitykiller/sucs-site
  • crox/sucs-site
  • vectre/sucs-site
  • welshbyte/sucs-site
  • paperclipman/sucs-site
15 results
Show changes
Showing
with 0 additions and 4970 deletions
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
exit;
//
// Return current timestamp (with microseconds) as a float (used in dblayer)
//
if (defined('PUN_SHOW_QUERIES'))
{
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
}
// Load the appropriate DB layer class
switch ($db_type)
{
case 'mysql':
require PUN_ROOT.'include/dblayer/mysql.php';
break;
case 'mysqli':
require PUN_ROOT.'include/dblayer/mysqli.php';
break;
case 'pgsql':
require PUN_ROOT.'include/dblayer/pgsql.php';
break;
case 'sqlite':
require PUN_ROOT.'include/dblayer/sqlite.php';
break;
default:
error('\''.$db_type.'\' is not a valid database type. Please check settings in config.php.', __FILE__, __LINE__);
break;
}
// Create the database adapter object (and open/connect to/select db)
$db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect);
<html>
<head>
<title>.</title>
</head>
<body>
.
</body>
</html>
\ No newline at end of file
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Make sure we have built in support for MySQL
if (!function_exists('mysql_connect'))
exit('This PHP environment doesn\'t have MySQL support built in. MySQL support is required if you want to use a MySQL database to run this forum. Consult the PHP documentation for further assistance.');
class DBLayer
{
var $prefix;
var $link_id;
var $query_result;
var $saved_queries = array();
var $num_queries = 0;
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
$this->prefix = $db_prefix;
if ($p_connect)
$this->link_id = @mysql_pconnect($db_host, $db_username, $db_password);
else
$this->link_id = @mysql_connect($db_host, $db_username, $db_password);
if ($this->link_id)
{
if (@mysql_select_db($db_name, $this->link_id))
return $this->link_id;
else
error('Unable to select database. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
}
else
error('Unable to connect to MySQL server. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
}
function start_transaction()
{
return;
}
function end_transaction()
{
return;
}
function query($sql, $unbuffered = false)
{
if (defined('PUN_SHOW_QUERIES'))
$q_start = get_microtime();
if ($unbuffered)
$this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
else
$this->query_result = @mysql_query($sql, $this->link_id);
if ($this->query_result)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
++$this->num_queries;
return $this->query_result;
}
else
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, 0);
return false;
}
}
function result($query_id = 0, $row = 0)
{
return ($query_id) ? @mysql_result($query_id, $row) : false;
}
function fetch_assoc($query_id = 0)
{
return ($query_id) ? @mysql_fetch_assoc($query_id) : false;
}
function fetch_row($query_id = 0)
{
return ($query_id) ? @mysql_fetch_row($query_id) : false;
}
function num_rows($query_id = 0)
{
return ($query_id) ? @mysql_num_rows($query_id) : false;
}
function affected_rows()
{
return ($this->link_id) ? @mysql_affected_rows($this->link_id) : false;
}
function insert_id()
{
return ($this->link_id) ? @mysql_insert_id($this->link_id) : false;
}
function get_num_queries()
{
return $this->num_queries;
}
function get_saved_queries()
{
return $this->saved_queries;
}
function free_result($query_id = false)
{
return ($query_id) ? @mysql_free_result($query_id) : false;
}
function escape($str)
{
if (is_array($str))
return '';
else if (function_exists('mysql_real_escape_string'))
return mysql_real_escape_string($str, $this->link_id);
else
return mysql_escape_string($str);
}
function error()
{
$result['error_sql'] = @current(@end($this->saved_queries));
$result['error_no'] = @mysql_errno($this->link_id);
$result['error_msg'] = @mysql_error($this->link_id);
return $result;
}
function close()
{
if ($this->link_id)
{
if ($this->query_result)
@mysql_free_result($this->query_result);
return @mysql_close($this->link_id);
}
else
return false;
}
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Make sure we have built in support for MySQL
if (!function_exists('mysqli_connect'))
exit('This PHP environment doesn\'t have Improved MySQL (mysqli) support built in. Improved MySQL support is required if you want to use a MySQL 4.1 (or later) database to run this forum. Consult the PHP documentation for further assistance.');
class DBLayer
{
var $prefix;
var $link_id;
var $query_result;
var $saved_queries = array();
var $num_queries = 0;
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $foo)
{
$this->prefix = $db_prefix;
// Was a custom port supplied with $db_host?
if (strpos($db_host, ':') !== false)
list($db_host, $db_port) = explode(':', $db_host);
if (isset($db_port))
$this->link_id = @mysqli_connect($db_host, $db_username, $db_password, $db_name, $db_port);
else
$this->link_id = @mysqli_connect($db_host, $db_username, $db_password, $db_name);
if (!$this->link_id)
error('Unable to connect to MySQL and select database. MySQL reported: '.mysqli_connect_error(), __FILE__, __LINE__);
}
function start_transaction()
{
return;
}
function end_transaction()
{
return;
}
function query($sql, $unbuffered = false)
{
if (defined('PUN_SHOW_QUERIES'))
$q_start = get_microtime();
$this->query_result = @mysqli_query($this->link_id, $sql);
if ($this->query_result)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
++$this->num_queries;
return $this->query_result;
}
else
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, 0);
return false;
}
}
function result($query_id = 0, $row = 0)
{
if ($query_id)
{
if ($row)
@mysqli_data_seek($query_id, $row);
$cur_row = @mysqli_fetch_row($query_id);
return $cur_row[0];
}
else
return false;
}
function fetch_assoc($query_id = 0)
{
return ($query_id) ? @mysqli_fetch_assoc($query_id) : false;
}
function fetch_row($query_id = 0)
{
return ($query_id) ? @mysqli_fetch_row($query_id) : false;
}
function num_rows($query_id = 0)
{
return ($query_id) ? @mysqli_num_rows($query_id) : false;
}
function affected_rows()
{
return ($this->link_id) ? @mysqli_affected_rows($this->link_id) : false;
}
function insert_id()
{
return ($this->link_id) ? @mysqli_insert_id($this->link_id) : false;
}
function get_num_queries()
{
return $this->num_queries;
}
function get_saved_queries()
{
return $this->saved_queries;
}
function free_result($query_id = false)
{
return ($query_id) ? @mysqli_free_result($query_id) : false;
}
function escape($str)
{
return is_array($str) ? '' : mysqli_real_escape_string($this->link_id, $str);
}
function error()
{
$result['error_sql'] = @current(@end($this->saved_queries));
$result['error_no'] = @mysqli_errno($this->link_id);
$result['error_msg'] = @mysqli_error($this->link_id);
return $result;
}
function close()
{
if ($this->link_id)
{
if ($this->query_result)
@mysqli_free_result($this->query_result);
return @mysqli_close($this->link_id);
}
else
return false;
}
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Make sure we have built in support for PostgreSQL
if (!function_exists('pg_connect'))
pun_exit('This PHP environment doesn\'t have PostgreSQL support built in. PostgreSQL support is required if you want to use a PostgreSQL database to run this forum. Consult the PHP documentation for further assistance.');
class DBLayer
{
var $prefix;
var $link_id;
var $query_result;
var $last_query_text = array();
var $in_transaction = 0;
var $saved_queries = array();
var $num_queries = 0;
var $error_no = false;
var $error_msg = 'Unknown';
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
$this->prefix = $db_prefix;
if ($db_host != '')
{
if (strpos($db_host, ':') !== false)
{
list($db_host, $dbport) = explode(':', $db_host);
$connect_str[] = 'host='.$db_host.' port='.$dbport;
}
else
{
if ($db_host != 'localhost')
$connect_str[] = 'host='.$db_host;
}
}
if ($db_name)
$connect_str[] = 'dbname='.$db_name;
if ($db_username != '')
$connect_str[] = 'user='.$db_username;
if ($db_password != '')
$connect_str[] = 'password='.$db_password;
if ($p_connect)
$this->link_id = @pg_pconnect(implode(' ', $connect_str));
else
$this->link_id = @pg_connect(implode(' ', $connect_str));
if (!$this->link_id)
error('Unable to connect to PostgreSQL server', __FILE__, __LINE__);
else
return $this->link_id;
}
function start_transaction()
{
++$this->in_transaction;
return (@pg_query($this->link_id, 'BEGIN')) ? true : false;
}
function end_transaction()
{
--$this->in_transaction;
if (@pg_query($this->link_id, 'COMMIT'))
return true;
else
{
@pg_query($this->link_id, 'ROLLBACK');
return false;
}
}
function query($sql, $unbuffered = false) // $unbuffered is ignored since there is no pgsql_unbuffered_query()
{
if (strrpos($sql, 'LIMIT') !== false)
$sql = preg_replace('#LIMIT ([0-9]+),([ 0-9]+)#', 'LIMIT \\2 OFFSET \\1', $sql);
if (defined('PUN_SHOW_QUERIES'))
$q_start = get_microtime();
@pg_send_query($this->link_id, $sql);
$this->query_result = @pg_get_result($this->link_id);
if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
++$this->num_queries;
$this->last_query_text[(int)$this->query_result] = $sql;
return $this->query_result;
}
else
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, 0);
$this->error_msg = @pg_result_error($this->query_result);
if ($this->in_transaction)
@pg_query($this->link_id, 'ROLLBACK');
--$this->in_transaction;
return false;
}
}
function result($query_id = 0, $row = 0)
{
return ($query_id) ? @pg_fetch_result($query_id, $row, 0) : false;
}
function fetch_assoc($query_id = 0)
{
return ($query_id) ? @pg_fetch_assoc($query_id) : false;
}
function fetch_row($query_id = 0)
{
return ($query_id) ? @pg_fetch_row($query_id) : false;
}
function num_rows($query_id = 0)
{
return ($query_id) ? @pg_num_rows($query_id) : false;
}
function affected_rows()
{
return ($this->query_result) ? @pg_affected_rows($this->query_result) : false;
}
function insert_id()
{
$query_id = $this->query_result;
if ($query_id && $this->last_query_text[$query_id] != '')
{
if (preg_match('/^INSERT INTO ([a-z0-9\_\-]+)/is', $this->last_query_text[$query_id], $table_name))
{
// Hack (don't ask)
if (substr($table_name[1], -6) == 'groups')
$table_name[1] .= '_g';
$temp_q_id = @pg_query($this->link_id, 'SELECT currval(\''.$table_name[1].'_id_seq\')');
return ($temp_q_id) ? intval(@pg_fetch_result($temp_q_id, 0)) : false;
}
}
return false;
}
function get_num_queries()
{
return $this->num_queries;
}
function get_saved_queries()
{
return $this->saved_queries;
}
function free_result($query_id = false)
{
if (!$query_id)
$query_id = $this->query_result;
return ($query_id) ? @pg_free_result($query_id) : false;
}
function escape($str)
{
return is_array($str) ? '' : pg_escape_string($str);
}
function error()
{
$result['error_sql'] = @current(@end($this->saved_queries));
$result['error_no'] = false;
/*
if (!empty($this->query_result))
{
$result['error_msg'] = trim(@pg_result_error($this->query_result));
if ($result['error_msg'] != '')
return $result;
}
$result['error_msg'] = (!empty($this->link_id)) ? trim(@pg_last_error($this->link_id)) : trim(@pg_last_error());
*/
$result['error_msg'] = $this->error_msg;
return $result;
}
function close()
{
if ($this->link_id)
{
if ($this->in_transaction)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array('COMMIT', 0);
@pg_query($this->link_id, 'COMMIT');
}
if ($this->query_result)
@pg_free_result($this->query_result);
return @pg_close($this->link_id);
}
else
return false;
}
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Make sure we have built in support for SQLite
if (!function_exists('sqlite_open'))
exit('This PHP environment doesn\'t have SQLite support built in. SQLite support is required if you want to use a SQLite database to run this forum. Consult the PHP documentation for further assistance.');
class DBLayer
{
var $prefix;
var $link_id;
var $query_result;
var $in_transaction = 0;
var $saved_queries = array();
var $num_queries = 0;
var $error_no = false;
var $error_msg = 'Unknown';
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
// Prepend $db_name with the path to the forum root directory
$db_name = PUN_ROOT.$db_name;
$this->prefix = $db_prefix;
if (!file_exists($db_name))
{
@touch($db_name);
@chmod($db_name, 0666);
if (!file_exists($db_name))
error('Unable to create new database \''.$db_name.'\'. Permission denied', __FILE__, __LINE__);
}
if (!is_readable($db_name))
error('Unable to open database \''.$db_name.'\' for reading. Permission denied', __FILE__, __LINE__);
if (!is_writable($db_name))
error('Unable to open database \''.$db_name.'\' for writing. Permission denied', __FILE__, __LINE__);
if ($p_connect)
$this->link_id = @sqlite_popen($db_name, 0666, $sqlite_error);
else
$this->link_id = @sqlite_open($db_name, 0666, $sqlite_error);
if (!$this->link_id)
error('Unable to open database \''.$db_name.'\'. SQLite reported: '.$sqlite_error, __FILE__, __LINE__);
else
return $this->link_id;
}
function start_transaction()
{
++$this->in_transaction;
return (@sqlite_query($this->link_id, 'BEGIN')) ? true : false;
}
function end_transaction()
{
--$this->in_transaction;
if (@sqlite_query($this->link_id, 'COMMIT'))
return true;
else
{
@sqlite_query($this->link_id, 'ROLLBACK');
return false;
}
}
function query($sql, $unbuffered = false)
{
if (defined('PUN_SHOW_QUERIES'))
$q_start = get_microtime();
if ($unbuffered)
$this->query_result = @sqlite_unbuffered_query($this->link_id, $sql);
else
$this->query_result = @sqlite_query($this->link_id, $sql);
if ($this->query_result)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
++$this->num_queries;
return $this->query_result;
}
else
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array($sql, 0);
$this->error_no = @sqlite_last_error($this->link_id);
$this->error_msg = @sqlite_error_string($this->error_no);
if ($this->in_transaction)
@sqlite_query($this->link_id, 'ROLLBACK');
--$this->in_transaction;
return false;
}
}
function result($query_id = 0, $row = 0)
{
if ($query_id)
{
if ($row != 0)
@sqlite_seek($query_id, $row);
return @current(@sqlite_current($query_id));
}
else
return false;
}
function fetch_assoc($query_id = 0)
{
if ($query_id)
{
$cur_row = @sqlite_fetch_array($query_id, SQLITE_ASSOC);
if ($cur_row)
{
// Horrible hack to get rid of table names and table aliases from the array keys
while (list($key, $value) = @each($cur_row))
{
$dot_spot = strpos($key, '.');
if ($dot_spot !== false)
{
unset($cur_row[$key]);
$key = substr($key, $dot_spot+1);
$cur_row[$key] = $value;
}
}
}
return $cur_row;
}
else
return false;
}
function fetch_row($query_id = 0)
{
return ($query_id) ? @sqlite_fetch_array($query_id, SQLITE_NUM) : false;
}
function num_rows($query_id = 0)
{
return ($query_id) ? @sqlite_num_rows($query_id) : false;
}
function affected_rows()
{
return ($this->query_result) ? @sqlite_changes($this->query_result) : false;
}
function insert_id()
{
return ($this->link_id) ? @sqlite_last_insert_rowid($this->link_id) : false;
}
function get_num_queries()
{
return $this->num_queries;
}
function get_saved_queries()
{
return $this->saved_queries;
}
function free_result($query_id = false)
{
return true;
}
function escape($str)
{
return is_array($str) ? '' : sqlite_escape_string($str);
}
function error()
{
$result['error_sql'] = @current(@end($this->saved_queries));
$result['error_no'] = $this->error_no;
$result['error_msg'] = $this->error_msg;
return $result;
}
function close()
{
if ($this->link_id)
{
if ($this->in_transaction)
{
if (defined('PUN_SHOW_QUERIES'))
$this->saved_queries[] = array('COMMIT', 0);
@sqlite_query($this->link_id, 'COMMIT');
}
return @sqlite_close($this->link_id);
}
else
return false;
}
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
Partially based on code copyright (C) 2008 FluxBB.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
************************************************************************/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
pun_exit();
//
// Validate an e-mail address
//
function is_valid_email($email)
{
if (strlen($email) > 50)
return false;
return preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email);
}
//
// Check if $email is banned
//
function is_banned_email($email)
{
global $db, $pun_bans;
foreach ($pun_bans as $cur_ban)
{
if ($cur_ban['email'] != '' &&
($email == $cur_ban['email'] ||
(strpos($cur_ban['email'], '@') === false && stristr($email, '@'.$cur_ban['email']))))
return true;
}
return false;
}
//
// Wrapper for PHP's mail()
//
function pun_mail($to, $subject, $message, $from = '')
{
global $pun_config, $lang_common;
// Default sender/return address
if (!$from)
$from = '"'.str_replace('"', '', $pun_config['o_board_title'].' '.$lang_common['Mailer']).'" <'.$pun_config['o_webmaster_email'].'>';
// Do a little spring cleaning
$to = trim(preg_replace('#[\n\r]+#s', '', $to));
$subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
$from = trim(preg_replace('#[\n\r:]+#s', '', $from));
$headers = 'From: '.$from."\r\n".'Date: '.date('r')."\r\n".'MIME-Version: 1.0'."\r\n".'Content-transfer-encoding: 8bit'."\r\n".'Content-type: text/plain; charset='.$lang_common['lang_encoding']."\r\n".'X-Mailer: PunBB Mailer';
// Make sure all linebreaks are CRLF in message (and strip out any NULL bytes)
$message = str_replace(array("\n", "\0"), array("\r\n", ''), pun_linebreaks($message));
if ($pun_config['o_smtp_host'] != '')
smtp_mail($to, $subject, $message, $headers);
else
{
// Change the linebreaks used in the headers according to OS
if (strtoupper(substr(PHP_OS, 0, 3)) == 'MAC')
$headers = str_replace("\r\n", "\r", $headers);
else if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN')
$headers = str_replace("\r\n", "\n", $headers);
mail($to, $subject, $message, $headers);
}
}
//
// This function was originally a part of the phpBB Group forum software phpBB2 (http://www.phpbb.com).
// They deserve all the credit for writing it. I made small modifications for it to suit PunBB and it's coding standards.
//
function server_parse($socket, $expected_response)
{
$server_response = '';
while (substr($server_response, 3, 1) != ' ')
{
if (!($server_response = fgets($socket, 256)))
error('Couldn\'t get mail server response codes. Please contact the forum administrator.', __FILE__, __LINE__);
}
if (!(substr($server_response, 0, 3) == $expected_response))
error('Unable to send e-mail. Please contact the forum administrator with the following error message reported by the SMTP server: "'.$server_response.'"', __FILE__, __LINE__);
}
//
// This function was originally a part of the phpBB Group forum software phpBB2 (http://www.phpbb.com).
// They deserve all the credit for writing it. I made small modifications for it to suit PunBB and it's coding standards.
//
function smtp_mail($to, $subject, $message, $headers = '')
{
global $pun_config;
$recipients = explode(',', $to);
// Sanitize the message
$message = str_replace("\r\n.", "\r\n..", $message);
$message = (substr($message, 0, 1) == '.' ? '.'.$message : $message);
// Are we using port 25 or a custom port?
if (strpos($pun_config['o_smtp_host'], ':') !== false)
list($smtp_host, $smtp_port) = explode(':', $pun_config['o_smtp_host']);
else
{
$smtp_host = $pun_config['o_smtp_host'];
$smtp_port = 25;
}
if (!($socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 15)))
error('Could not connect to smtp host "'.$pun_config['o_smtp_host'].'" ('.$errno.') ('.$errstr.')', __FILE__, __LINE__);
server_parse($socket, '220');
if ($pun_config['o_smtp_user'] != '' && $pun_config['o_smtp_pass'] != '')
{
fwrite($socket, 'EHLO '.$smtp_host."\r\n");
server_parse($socket, '250');
fwrite($socket, 'AUTH LOGIN'."\r\n");
server_parse($socket, '334');
fwrite($socket, base64_encode($pun_config['o_smtp_user'])."\r\n");
server_parse($socket, '334');
fwrite($socket, base64_encode($pun_config['o_smtp_pass'])."\r\n");
server_parse($socket, '235');
}
else
{
fwrite($socket, 'HELO '.$smtp_host."\r\n");
server_parse($socket, '250');
}
fwrite($socket, 'MAIL FROM: <'.$pun_config['o_webmaster_email'].'>'."\r\n");
server_parse($socket, '250');
$to_header = 'To: ';
@reset($recipients);
while (list(, $email) = @each($recipients))
{
fwrite($socket, 'RCPT TO: <'.$email.'>'."\r\n");
server_parse($socket, '250');
$to_header .= '<'.$email.'>, ';
}
fwrite($socket, 'DATA'."\r\n");
server_parse($socket, '354');
fwrite($socket, 'Subject: '.$subject."\r\n".$to_header."\r\n".$headers."\r\n\r\n".$message."\r\n");
fwrite($socket, '.'."\r\n");
server_parse($socket, '250');
fwrite($socket, 'QUIT'."\r\n");
fclose($socket);
return true;
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
//
// SUCS specific functions
//
// because killing off PHP is a little inconsiderate
function pun_exit($spew="")
{
echo $spew;
throw new Exception("pun_exit");
}
function auth_user(&$pun_user)
{
global $db, $pun_config, $session;
if ($session->loggedin) {
$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.username=\''.$session->username.'\'';
$result = $db->query($query) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());
$pun_user = $db->fetch_assoc($result);
$now = time();
if (!isset($pun_user['id'])) {
//Logged in, first-time visitor
$initial_group_id = $pun_config['o_default_user_group'];
$password_hash = pun_hash(random_pass($len));
$email1 = $session->username."@sucs.org";
// default to hide e-mail address, allow form e-mail
$email_setting = "1";
$save_pass = "0";
$timezone = "0";
$language = $pun_config['o_default_lang'];
$db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES (\''.$session->username.'\', '.$initial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error());
// fetch newly-inserted details
$result = $db->query($query) or error('Unable to fetch user information', __FILE__, __LINE__, $db->error());
$pun_user = $db->fetch_assoc($result);
}
// either the data was there all along, or it should be there now, so let's say we're logged in
$pun_user['is_guest'] = false;
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'];
// 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());
}
}
} else {
//Not logged in
set_default_user();
}
}
//
// Cookie stuff!
//
function check_cookie(&$pun_user)
{
global $db, $db_type, $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]) && preg_match('/a:2:{i:0;s:\d+:"(\d+)";i:1;s:\d+:"([0-9a-f]+)";}/', $_COOKIE[$cookie_name], $matches))
list(, $cookie['user_id'], $cookie['password_hash']) = $matches;
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(1, md5(uniqid(rand(), true)), $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'])
{
$pun_user['logged'] = $now;
// With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
break;
default:
$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
break;
}
}
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, $db_type, $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))
pun_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'])
{
$pun_user['logged'] = time();
// With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
break;
default:
$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
break;
}
}
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"');
if (version_compare(PHP_VERSION, '5.2.0', '>='))
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true);
else
setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path.'; HttpOnly', $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="index.php">'.$lang_common['Index'].'</a>';
$links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';
if ($pun_config['o_rules'] == '1')
$links[] = '<li id="navrules"><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a>';
if ($pun_user['is_guest'])
{
if ($pun_user['g_search'] == '1')
$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
// $links[] = '<li id="navregister"><a href="register.php">'.$lang_common['Register'].'</a>';
// $links[] = '<li id="navlogin"><a href="login.php">'.$lang_common['Login'].'</a>';
$info = $lang_common['Not logged in'];
}
else
{
if ($pun_user['g_id'] > PUN_MOD)
{
if ($pun_user['g_search'] == '1')
$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
// $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'&amp;csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$lang_common['Logout'].'</a>';
}
else
{
$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
$links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>';
// $links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'&amp;csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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
//
function update_forum($forum_id)
{
global $db;
$result = $db->query('SELECT COUNT(id), SUM(num_replies) FROM '.$db->prefix.'topics WHERE 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='.$num_topics.', num_posts='.$num_posts.', 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];
// 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());
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.'&amp;p=1">1</a>';
if ($cur_page != 4)
$pages[] = '&hellip;';
}
// 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.'&amp;p='.$current.'">'.$current.'</a>';
else
$pages[] = '<strong>'.$current.'</strong>';
}
if ($cur_page <= ($num_pages-3))
{
if ($cur_page != ($num_pages-3))
$pages[] = '&hellip;';
$pages[] = '<a href="'.$link_to.'&amp;p='.$num_pages.'">'.$num_pages.'</a>';
}
}
return implode('&nbsp;', $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', '&amp;', $str);
$str = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $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('&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
$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_include "*">
while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_maint, $cur_include))
{
if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template maintenance.tpl. There is no such file in folder /include/user/');
ob_start();
include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2];
$tpl_temp = ob_get_contents();
$tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint);
ob_end_clean();
}
// END SUBST - <pun_include "*">
// 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();
// Close the db connection (and free up any result data)
$db->close();
pun_exit($tpl_maint);
}
//
// Display $message and redirect user to $destination_url
//
function redirect($destination_url, $message)
{
global $db, $pun_config, $lang_common, $pun_user;
// Prefix with o_base_url (unless there's already a valid URI)
if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_url, '/') !== 0)
$destination_url = $pun_config['o_base_url'].'/'.$destination_url;
// Do a little spring cleaning
$destination_url = preg_replace('/([\r\n])|(%0[ad])|(;[\s]*data[\s]*:)/i', '', $destination_url);
// 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('&amp;', '&', $destination_url));
// Load the redirect template
$tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl'));
// START SUBST - <pun_include "*">
while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $cur_include))
{
if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]))
error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template redirect.tpl. There is no such file in folder /include/user/');
ob_start();
include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2];
$tpl_temp = ob_get_contents();
$tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir);
ob_end_clean();
}
// END SUBST - <pun_include "*">
// 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('&lt;', '&gt;', '&quot;'), $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>
// Close the db connection (and free up any result data)
$db->close();
pun_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');
?>
<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>
<?php
// If a database connection was established (before this error) we close it
if ($db_error)
$GLOBALS['db']->close();
pun_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] : '&nbsp;' ?></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()
{
$register_globals = @ini_get('register_globals');
if ($register_globals === "" || $register_globals === "0" || strtolower($register_globals) === "off")
return;
// Prevent script.php?GLOBALS[foo]=bar
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']))
pun_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]);
unset($GLOBALS[$k]); // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP <4.4.3 and <5.1.4
}
}
}
//
// 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>';
pun_exit();
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
Partially based on code copyright (C) 2008 FluxBB.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
************************************************************************/
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
pun_exit();
// Here you can add additional smilies if you like (please note that you must escape singlequote and backslash)
$smiley_text = array(':)', '=)', ':|', '=|', ':(', '=(', ':D', '=D', ':o', ':O', ';)', ':/', ':P', ':lol:', ':mad:', ':rolleyes:', ':cool:');
$smiley_img = array('smile.png', 'smile.png', 'neutral.png', 'neutral.png', 'sad.png', 'sad.png', 'big_smile.png', 'big_smile.png', 'yikes.png', 'yikes.png', 'wink.png', 'hmm.png', 'tongue.png', 'lol.png', 'mad.png', 'roll.png', 'cool.png');
// Uncomment the next row if you add smilies that contain any of the characters &"'<>
//$smiley_text = array_map('pun_htmlspecialchars', $smiley_text);
//
// Make sure all BBCodes are lower case and do a little cleanup
//
function preparse_bbcode($text, &$errors, $is_signature = false)
{
// Change all simple BBCodes to lower case
$a = array('[B]', '[I]', '[U]', '[/B]', '[/I]', '[/U]');
$b = array('[b]', '[i]', '[u]', '[/b]', '[/i]', '[/u]');
$text = str_replace($a, $b, $text);
// Do the more complex BBCodes (also strip excessive whitespace and useless quotes)
$a = array( '#\[url=("|\'|)(.*?)\\1\]\s*#i',
'#\[url\]\s*#i',
'#\s*\[/url\]#i',
'#\[email=("|\'|)(.*?)\\1\]\s*#i',
'#\[email\]\s*#i',
'#\s*\[/email\]#i',
'#\[img\]\s*(.*?)\s*\[/img\]#is',
'#\[colou?r=("|\'|)(.*?)\\1\](.*?)\[/colou?r\]#is');
$b = array( '[url=$2]',
'[url]',
'[/url]',
'[email=$2]',
'[email]',
'[/email]',
'[img]$1[/img]',
'[color=$2]$3[/color]');
if (!$is_signature)
{
// For non-signatures, we have to do the quote and code tags as well
$a[] = '#\[quote=(&quot;|"|\'|)(.*?)\\1\]\s*#i';
$a[] = '#\[quote\]\s*#i';
$a[] = '#\s*\[/quote\]\s*#i';
$a[] = '#\[code\][\r\n]*(.*?)\s*\[/code\]\s*#is';
$b[] = '[quote=$1$2$1]';
$b[] = '[quote]';
$b[] = '[/quote]'."\n";
$b[] = '[code]$1[/code]'."\n";
}
// Run this baby!
$text = preg_replace($a, $b, $text);
if (!$is_signature)
{
$overflow = check_tag_order($text, $error);
if ($error)
// A BBCode error was spotted in check_tag_order()
$errors[] = $error;
else if ($overflow)
// The quote depth level was too high, so we strip out the inner most quote(s)
$text = substr($text, 0, $overflow[0]).substr($text, $overflow[1], (strlen($text) - $overflow[0]));
}
else
{
global $lang_prof_reg;
if (preg_match('#\[quote=(&quot;|"|\'|)(.*)\\1\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]#i', $text))
message($lang_prof_reg['Signature quote/code']);
}
return trim($text);
}
//
// Parse text and make sure that [code] and [quote] syntax is correct
//
function check_tag_order($text, &$error)
{
global $lang_common;
// The maximum allowed quote depth
$max_depth = 3;
$cur_index = 0;
$q_depth = 0;
while (true)
{
// Look for regular code and quote tags
$c_start = strpos($text, '[code]');
$c_end = strpos($text, '[/code]');
$q_start = strpos($text, '[quote]');
$q_end = strpos($text, '[/quote]');
// Look for [quote=username] style quote tags
if (preg_match('#\[quote=(&quot;|"|\'|)(.*)\\1\]#sU', $text, $matches))
$q2_start = strpos($text, $matches[0]);
else
$q2_start = 65536;
// Deal with strpos() returning false when the string is not found
// (65536 is one byte longer than the maximum post length)
if ($c_start === false) $c_start = 65536;
if ($c_end === false) $c_end = 65536;
if ($q_start === false) $q_start = 65536;
if ($q_end === false) $q_end = 65536;
// If none of the strings were found
if (min($c_start, $c_end, $q_start, $q_end, $q2_start) == 65536)
break;
// We are interested in the first quote (regardless of the type of quote)
$q3_start = ($q_start < $q2_start) ? $q_start : $q2_start;
// We found a [quote] or a [quote=username]
if ($q3_start < min($q_end, $c_start, $c_end))
{
$step = ($q_start < $q2_start) ? 7 : strlen($matches[0]);
$cur_index += $q3_start + $step;
// Did we reach $max_depth?
if ($q_depth == $max_depth)
$overflow_begin = $cur_index - $step;
++$q_depth;
$text = substr($text, $q3_start + $step);
}
// We found a [/quote]
else if ($q_end < min($q_start, $c_start, $c_end))
{
if ($q_depth == 0)
{
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 1'];
return;
}
$q_depth--;
$cur_index += $q_end+8;
// Did we reach $max_depth?
if ($q_depth == $max_depth)
$overflow_end = $cur_index;
$text = substr($text, $q_end+8);
}
// We found a [code]
else if ($c_start < min($c_end, $q_start, $q_end))
{
// Make sure there's a [/code] and that any new [code] doesn't occur before the end tag
$tmp = strpos($text, '[/code]');
$tmp2 = strpos(substr($text, $c_start+6), '[code]');
if ($tmp2 !== false)
$tmp2 += $c_start+6;
if ($tmp === false || ($tmp2 !== false && $tmp2 < $tmp))
{
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 2'];
return;
}
else
$text = substr($text, $tmp+7);
$cur_index += $tmp+7;
}
// We found a [/code] (this shouldn't happen since we handle both start and end tag in the if clause above)
else if ($c_end < min($c_start, $q_start, $q_end))
{
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 3'];
return;
}
}
// If $q_depth <> 0 something is wrong with the quote syntax
if ($q_depth)
{
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 4'];
return;
}
else if ($q_depth < 0)
{
$error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 5'];
return;
}
// If the quote depth level was higher than $max_depth we return the index for the
// beginning and end of the part we should strip out
if (isset($overflow_begin))
return array($overflow_begin, $overflow_end);
else
return null;
}
//
// Split text into chunks ($inside contains all text inside $start and $end, and $outside contains all text outside)
//
function split_text($text, $start, $end)
{
global $pun_config;
$tokens = explode($start, $text);
$outside[] = $tokens[0];
$num_tokens = count($tokens);
for ($i = 1; $i < $num_tokens; ++$i)
{
$temp = explode($end, $tokens[$i]);
$inside[] = $temp[0];
$outside[] = $temp[1];
}
if ($pun_config['o_indent_num_spaces'] != 8 && $start == '[code]')
{
$spaces = str_repeat(' ', $pun_config['o_indent_num_spaces']);
$inside = str_replace("\t", $spaces, $inside);
}
return array($inside, $outside);
}
//
// Truncate URL if longer than 55 characters (add http:// or ftp:// if missing)
//
function handle_url_tag($url, $link = '')
{
global $pun_user;
$full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
if (strpos($url, 'www.') === 0) // If it starts with www, we add http://
$full_url = 'http://'.$full_url;
else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp://
$full_url = 'ftp://'.$full_url;
else if (!preg_match('#^([a-z0-9]{3,6})://#', $url, $bah)) // Else if it doesn't start with abcdef://, we add http://
$full_url = 'http://'.$full_url;
// Ok, not very pretty :-)
$link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' &hellip; '.substr($url, -10) : $url) : stripslashes($link);
return '<a href="'.$full_url.'">'.$link.'</a>';
}
//
// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag
//
function handle_img_tag($url, $is_signature = false)
{
global $lang_common, $pun_config, $pun_user;
$img_tag = '<a href="'.$url.'">&lt;'.$lang_common['Image link'].'&gt;</a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
else if (!$is_signature && $pun_user['show_img'] != '0')
$img_tag = '<img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
return $img_tag;
}
//
// Convert BBCodes to their HTML equivalent
//
function do_bbcode($text)
{
global $lang_common, $pun_user;
if (strpos($text, 'quote') !== false)
{
$text = str_replace('[quote]', '</p><blockquote><div class="incqbox"><p>', $text);
$text = preg_replace('#\[quote=(&quot;|"|\'|)(.*)\\1\]#seU', '"</p><blockquote><div class=\"incqbox\"><h4>".str_replace(array(\'[\', \'\\"\'), array(\'&#91;\', \'"\'), \'$2\')." ".$lang_common[\'wrote\'].":</h4><p>"', $text);
$text = preg_replace('#\[\/quote\]\s*#', '</p></div></blockquote><p>', $text);
}
$pattern = array('#\[b\](.*?)\[/b\]#s',
'#\[i\](.*?)\[/i\]#s',
'#\[u\](.*?)\[/u\]#s',
'#\[url\]([^\[<]*?)\[/url\]#e',
'#\[url=([^\[<]*?)\](.*?)\[/url\]#e',
'#\[email\]([^\[<]*?)\[/email\]#',
'#\[email=([^\[<]*?)\](.*?)\[/email\]#',
'#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s');
$replace = array('<strong>$1</strong>',
'<em>$1</em>',
'<span class="bbu">$1</span>',
'handle_url_tag(\'$1\')',
'handle_url_tag(\'$1\', \'$2\')',
'<a href="mailto:$1">$1</a>',
'<a href="mailto:$1">$2</a>',
'<span style="color: $1">$2</span>');
// This thing takes a while! :)
$text = preg_replace($pattern, $replace, $text);
return $text;
}
//
// Make hyperlinks clickable
//
function do_clickable($text)
{
global $pun_user;
$text = ' '.$text;
$text = preg_replace('#([\s\(\)])(https?|ftp|news){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2://$3\')', $text);
$text = preg_replace('#([\s\(\)])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^"\s\(\)<\[]*)?)#ie', '\'$1\'.handle_url_tag(\'$2.$3\', \'$2.$3\')', $text);
return substr($text, 1);
}
//
// Convert a series of smilies to images
//
function do_smilies($text)
{
global $smiley_text, $smiley_img;
$text = ' '.$text.' ';
$num_smilies = count($smiley_text);
for ($i = 0; $i < $num_smilies; ++$i)
$text = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="/images/forum/smilies/'.$smiley_img[$i].'" width="15" height="15" alt="'.substr($smiley_img[$i], 0, strrpos($smiley_img[$i], '.')).'" />$2', $text);
return substr($text, 1, -1);
}
//
// Parse message text
//
function parse_message($text, $hide_smilies)
{
global $pun_config, $lang_common, $pun_user;
if ($pun_config['o_censoring'] == '1')
$text = censor_words($text);
// Convert applicable characters to HTML entities
$text = pun_htmlspecialchars($text);
// If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched)
if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false)
{
list($inside, $outside) = split_text($text, '[code]', '[/code]');
$outside = array_map('ltrim', $outside);
$text = implode('<">', $outside);
}
if ($pun_config['o_make_links'] == '1')
$text = do_clickable($text);
if ($pun_config['o_smilies'] == '1' && $pun_user['show_smilies'] == '1' && $hide_smilies == '0')
$text = do_smilies($text);
if ($pun_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
{
$text = do_bbcode($text);
if ($pun_config['p_message_img_tag'] == '1')
{
// $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\.(jpg|jpeg|png|gif)\[/img\]#e', 'handle_img_tag(\'$1$3.$4\')', $text);
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\')', $text);
}
}
// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
$text = str_replace($pattern, $replace, $text);
// If we split up the message before we have to concatenate it together again (code tags)
if (isset($inside))
{
$outside = explode('<">', $text);
$text = '';
$num_tokens = count($outside);
for ($i = 0; $i < $num_tokens; ++$i)
{
$text .= $outside[$i];
if (isset($inside[$i]))
{
$num_lines = ((substr_count($inside[$i], "\n")) + 3) * 1.5;
$height_str = ($num_lines > 35) ? '35em' : $num_lines.'em';
$text .= '</p><div class="codebox"><div class="incqbox"><h4>'.$lang_common['Code'].':</h4><div class="scrollbox" style="height: '.$height_str.'"><pre>'.$inside[$i].'</pre></div></div></div><p>';
}
}
}
// Add paragraph tag around post, but make sure there are no empty paragraphs
$text = str_replace('<p></p>', '', '<p>'.$text.'</p>');
return $text;
}
//
// Parse signature text
//
function parse_signature($text)
{
global $pun_config, $lang_common, $pun_user;
if ($pun_config['o_censoring'] == '1')
$text = censor_words($text);
$text = pun_htmlspecialchars($text);
if ($pun_config['o_make_links'] == '1')
$text = do_clickable($text);
if ($pun_config['o_smilies_sig'] == '1' && $pun_user['show_smilies'] != '0')
$text = do_smilies($text);
if ($pun_config['p_sig_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false)
{
$text = do_bbcode($text);
if ($pun_config['p_sig_img_tag'] == '1')
{
// $text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\.(jpg|jpeg|png|gif)\[/img\]#e', 'handle_img_tag(\'$1$3.$4\', true)', $text);
$text = preg_replace('#\[img\]((ht|f)tps?://)([^\s<"]*?)\[/img\]#e', 'handle_img_tag(\'$1$3\', true)', $text);
}
}
// Deal with newlines, tabs and multiple spaces
$pattern = array("\n", "\t", ' ', ' ');
$replace = array('<br />', '&nbsp; &nbsp; ', '&nbsp; ', ' &nbsp;');
$text = str_replace($pattern, $replace, $text);
return $text;
}
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// The contents of this file are very much inspired by the file functions_search.php
// from the phpBB Group forum software phpBB2 (http://www.phpbb.com).
// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
pun_exit();
//
// "Cleans up" a text string and returns an array of unique words
// This function depends on the current locale setting
//
function split_words($text)
{
global $pun_user;
static $noise_match, $noise_replace, $stopwords;
if (empty($noise_match))
{
$noise_match = array('[quote', '[code', '[url', '[img', '[email', '[color', '[colour', 'quote]', 'code]', 'url]', 'img]', 'email]', 'color]', 'colour]', '^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '+', '[', ']', '{', '}', ':', '\\', '/', '=', '#', ';', '!', '*');
$noise_replace = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ', ' ');
$stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt');
$stopwords = array_map('trim', $stopwords);
}
// Clean up
$patterns[] = '#&[\#a-z0-9]+?;#i';
$patterns[] = '#\b[\w]+:\/\/[a-z0-9\.\-]+(\/[a-z0-9\?\.%_\-\+=&\/~]+)?#';
$patterns[] = '#\[\/?[a-z\*=\+\-]+(\:?[0-9a-z]+)?:[a-z0-9]{10,}(\:[a-z0-9]+)?=?.*?\]#';
$text = preg_replace($patterns, ' ', ' '.strtolower($text).' ');
// Filter out junk
$text = str_replace($noise_match, $noise_replace, $text);
// Strip out extra whitespace between words
$text = trim(preg_replace('#\s+#', ' ', $text));
// Fill an array with all the words
$words = explode(' ', $text);
if (!empty($words))
{
while (list($i, $word) = @each($words))
{
$words[$i] = trim($word, '.');
$num_chars = pun_strlen($word);
if ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords))
unset($words[$i]);
}
}
return array_unique($words);
}
//
// Updates the search index with the contents of $post_id (and $subject)
//
function update_search_index($mode, $post_id, $message, $subject = null)
{
global $db_type, $db;
// Split old and new post/subject to obtain array of 'words'
$words_message = split_words($message);
$words_subject = ($subject) ? split_words($subject) : array();
if ($mode == 'edit')
{
$result = $db->query('SELECT w.id, w.word, m.subject_match FROM '.$db->prefix.'search_words AS w INNER JOIN '.$db->prefix.'search_matches AS m ON w.id=m.word_id WHERE m.post_id='.$post_id, true) or error('Unable to fetch search index words', __FILE__, __LINE__, $db->error());
// Declare here to stop array_keys() and array_diff() from complaining if not set
$cur_words['post'] = array();
$cur_words['subject'] = array();
while ($row = $db->fetch_row($result))
{
$match_in = ($row[2]) ? 'subject' : 'post';
$cur_words[$match_in][$row[1]] = $row[0];
}
$db->free_result($result);
$words['add']['post'] = array_diff($words_message, array_keys($cur_words['post']));
$words['add']['subject'] = array_diff($words_subject, array_keys($cur_words['subject']));
$words['del']['post'] = array_diff(array_keys($cur_words['post']), $words_message);
$words['del']['subject'] = array_diff(array_keys($cur_words['subject']), $words_subject);
}
else
{
$words['add']['post'] = $words_message;
$words['add']['subject'] = $words_subject;
$words['del']['post'] = array();
$words['del']['subject'] = array();
}
unset($words_message);
unset($words_subject);
// Get unique words from the above arrays
$unique_words = array_unique(array_merge($words['add']['post'], $words['add']['subject']));
if (!empty($unique_words))
{
$result = $db->query('SELECT id, word FROM '.$db->prefix.'search_words WHERE word IN('.implode(',', preg_replace('#^(.*)$#', '\'\1\'', $unique_words)).')', true) or error('Unable to fetch search index words', __FILE__, __LINE__, $db->error());
$word_ids = array();
while ($row = $db->fetch_row($result))
$word_ids[$row[1]] = $row[0];
$db->free_result($result);
$new_words = array_diff($unique_words, array_keys($word_ids));
unset($unique_words);
if (!empty($new_words))
{
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$db->query('INSERT INTO '.$db->prefix.'search_words (word) VALUES'.implode(',', preg_replace('#^(.*)$#', '(\'\1\')', $new_words))) or error('Unable to insert search index words', __FILE__, __LINE__, $db->error());
break;
default:
while (list(, $word) = @each($new_words))
$db->query('INSERT INTO '.$db->prefix.'search_words (word) VALUES(\''.$word.'\')') or error('Unable to insert search index words', __FILE__, __LINE__, $db->error());
break;
}
}
unset($new_words);
}
// Delete matches (only if editing a post)
while (list($match_in, $wordlist) = @each($words['del']))
{
$subject_match = ($match_in == 'subject') ? 1 : 0;
if (!empty($wordlist))
{
$sql = '';
while (list(, $word) = @each($wordlist))
$sql .= (($sql != '') ? ',' : '').$cur_words[$match_in][$word];
$db->query('DELETE FROM '.$db->prefix.'search_matches WHERE word_id IN('.$sql.') AND post_id='.$post_id.' AND subject_match='.$subject_match) or error('Unable to delete search index word matches', __FILE__, __LINE__, $db->error());
}
}
// Add new matches
while (list($match_in, $wordlist) = @each($words['add']))
{
$subject_match = ($match_in == 'subject') ? 1 : 0;
if (!empty($wordlist))
$db->query('INSERT INTO '.$db->prefix.'search_matches (post_id, word_id, subject_match) SELECT '.$post_id.', id, '.$subject_match.' FROM '.$db->prefix.'search_words WHERE word IN('.implode(',', preg_replace('#^(.*)$#', '\'\1\'', $wordlist)).')') or error('Unable to insert search index word matches', __FILE__, __LINE__, $db->error());
}
unset($words);
}
//
// Strip search index of indexed words in $post_ids
//
function strip_search_index($post_ids)
{
global $db_type, $db;
switch ($db_type)
{
case 'mysql':
case 'mysqli':
{
$result = $db->query('SELECT word_id FROM '.$db->prefix.'search_matches WHERE post_id IN('.$post_ids.') GROUP BY word_id') or error('Unable to fetch search index word match', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$word_ids = '';
while ($row = $db->fetch_row($result))
$word_ids .= ($word_ids != '') ? ','.$row[0] : $row[0];
$result = $db->query('SELECT word_id FROM '.$db->prefix.'search_matches WHERE word_id IN('.$word_ids.') GROUP BY word_id HAVING COUNT(word_id)=1') or error('Unable to fetch search index word match', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
{
$word_ids = '';
while ($row = $db->fetch_row($result))
$word_ids .= ($word_ids != '') ? ','.$row[0] : $row[0];
$db->query('DELETE FROM '.$db->prefix.'search_words WHERE id IN('.$word_ids.')') or error('Unable to delete search index word', __FILE__, __LINE__, $db->error());
}
}
break;
}
default:
$db->query('DELETE FROM '.$db->prefix.'search_words WHERE id IN(SELECT word_id FROM '.$db->prefix.'search_matches WHERE word_id IN(SELECT word_id FROM '.$db->prefix.'search_matches WHERE post_id IN('.$post_ids.') GROUP BY word_id) GROUP BY word_id HAVING COUNT(word_id)=1)') or error('Unable to delete from search index', __FILE__, __LINE__, $db->error());
break;
}
$db->query('DELETE FROM '.$db->prefix.'search_matches WHERE post_id IN('.$post_ids.')') or error('Unable to delete search index word match', __FILE__, __LINE__, $db->error());
}
<div id="punwrap">
<div id="punadmin" class="pun">
<div id="brdheader" class="block">
<div class="box">
<div id="brdtitle" class="inbox">
<pun_title>
<pun_desc>
</div>
<pun_navlinks>
<pun_status>
</div>
</div>
<pun_announcement>
<pun_main>
<pun_footer>
</div>
</div>
<div id="punwrap">
<div id="helpfile" class="pun">
<pun_main>
</div>
</div>
<html>
<head>
<title>.</title>
</head>
<body>
.
</body>
</html>
\ No newline at end of file
<div id="punwrap">
<div id="pun<pun_page>" class="pun">
<div id="brdheader" class="block">
<div class="box">
<div id="brdtitle" class="inbox">
<pun_title>
<pun_desc>
</div>
<pun_navlinks>
<pun_status>
</div>
</div>
<pun_announcement>
<pun_main>
<pun_footer>
</div>
</div>
<div id="punwrap">
<div id="punmaint" class="pun">
<div class="block">
<h2><pun_maint_heading></h2>
<div class="box">
<div class="inbox">
<p><pun_maint_message></p>
</div>
</div>
</div>
</div>
</div>
<div id="punwrap">
<div id="punredirect" class="pun">
<div class="block">
<h2><pun_redir_heading></h2>
<div class="box">
<div class="inbox">
<p><pun_redir_text></p>
</div>
</div>
</div>
<pun_footer>
</div>
</div>
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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';
if ($pun_user['g_read_board'] == '0')
message($lang_common['No view']);
// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$cur_category = 0;
$cat_count = 0;
while ($cur_forum = $db->fetch_assoc($result))
{
$moderators = '';
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
{
if ($cur_category != 0)
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
++$cat_count;
?>
<div id="idx<?php echo $cat_count ?>" class="blocktable">
<h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2>
<div class="box">
<div class="inbox">
<table cellspacing="0">
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
<?php
$cur_category = $cur_forum['cid'];
}
$item_status = '';
$icon_text = $lang_common['Normal icon'];
$icon_type = 'icon';
// Are there new posts?
if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
{
$item_status = 'inew';
$icon_text = $lang_common['New icon'];
$icon_type = 'icon inew';
}
// Is this a redirect forum?
if ($cur_forum['redirect_url'] != '')
{
$forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
$num_topics = $num_posts = '&nbsp;';
$item_status = 'iredirect';
$icon_text = $lang_common['Redirect icon'];
$icon_type = 'icon';
}
else
{
$forum_field = '<h3><a href="viewforum.php?id='.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
$num_topics = $cur_forum['num_topics'];
$num_posts = $cur_forum['num_posts'];
}
if ($cur_forum['forum_desc'] != '')
$forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_forum['forum_desc'];
// If there is a last_post/last_poster.
if ($cur_forum['last_post'] != '')
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
else
$last_post = '&nbsp;';
if ($cur_forum['moderators'] != '')
{
$mods_array = unserialize($cur_forum['moderators']);
$moderators = array();
while (list($mod_username, $mod_id) = @each($mods_array))
$moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';
$moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
}
?>
<tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
<td class="tcl">
<div class="intd">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
<div class="tclcon">
<?php echo $forum_field."\n".$moderators ?>
</div>
</div>
</td>
<td class="tc2"><?php echo $num_topics ?></td>
<td class="tc3"><?php echo $num_posts ?></td>
<td class="tcr"><?php echo $last_post ?></td>
</tr>
<?php
}
// Did we output any categories and forums?
if ($cur_category > 0)
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
else
echo '<div id="idx0" class="block"><div class="box"><div class="inbox"><p>'.$lang_index['Empty board'].'</p></div></div></div>';
// Collect some statistics from the database
$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);
$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);
$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
?>
<div id="brdstats" class="block">
<h2><span><?php echo $lang_index['Board info'] ?></span></h2>
<div class="box">
<div class="inbox">
<dl class="conr">
<dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
<dd><?php echo $lang_index['No of users'].': <strong>'. $stats['total_users'] ?></strong></dd>
<dd><?php echo $lang_index['No of topics'].': <strong>'.$stats['total_topics'] ?></strong></dd>
<dd><?php echo $lang_index['No of posts'].': <strong>'.$stats['total_posts'] ?></strong></dd>
</dl>
<dl class="conl">
<dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
<dd><?php echo $lang_index['Newest user'] ?>: <a href="profile.php?id=<?php echo $stats['last_user']['id'] ?>"><?php echo pun_htmlspecialchars($stats['last_user']['username']) ?></a></dd>
<?php
if ($pun_config['o_users_online'] == '1')
{
// Fetch users online info and generate strings for output
$num_guests = 0;
$users = array();
$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
while ($pun_user_online = $db->fetch_assoc($result))
{
if ($pun_user_online['user_id'] > 1)
$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
else
++$num_guests;
}
$num_users = count($users);
echo "\t\t\t\t".'<dd>'. $lang_index['Users online'].': <strong>'.$num_users.'</strong></dd>'."\n\t\t\t\t".'<dd>'.$lang_index['Guests online'].': <strong>'.$num_guests.'</strong></dd>'."\n\t\t\t".'</dl>'."\n";
if ($num_users > 0)
echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.$lang_index['Online'].':&nbsp;</strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
else
echo "\t\t\t".'<div class="clearer"></div>'."\n";
}
else
echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";
?>
</div>
</div>
</div>
<?php
$footer_style = 'index';
require PUN_ROOT.'footer.php';
<?php
/***********************************************************************
Copyright (C) 2002-2008 PunBB
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
************************************************************************/
// Let's disable this script, cause we don't want any accidents
pun_exit();
// The PunBB version this script installs
$punbb_version = '1.2.23';
define('PUN_ROOT', './');
if (file_exists(PUN_ROOT.'config.php'))
pun_exit('The file \'config.php\' already exists which would mean that PunBB is already installed. You should go <a href="index.php">here</a> instead.');
// Make sure we are running at least PHP 4.1.0
if (intval(str_replace('.', '', phpversion())) < 410)
pun_exit('You are running PHP version '.PHP_VERSION.'. PunBB requires at least PHP 4.1.0 to run properly. You must upgrade your PHP installation before you can continue.');
// Disable error reporting for uninitialized variables
error_reporting(E_ALL);
// Turn off PHP time limit
@set_time_limit(0);
if (!isset($_POST['form_sent']))
{
// Determine available database extensions
$dual_mysql = false;
$db_extensions = array();
if (function_exists('mysqli_connect'))
$db_extensions[] = array('mysqli', 'MySQL Improved');
if (function_exists('mysql_connect'))
{
$db_extensions[] = array('mysql', 'MySQL Standard');
if (count($db_extensions) > 1)
$dual_mysql = true;
}
if (function_exists('sqlite_open'))
$db_extensions[] = array('sqlite', 'SQLite');
if (function_exists('pg_connect'))
$db_extensions[] = array('pgsql', 'PostgreSQL');
if (empty($db_extensions))
pun_exit('This PHP environment does not have support for any of the databases that PunBB supports. PHP needs to have support for either MySQL, PostgreSQL or SQLite in order for PunBB to be installed.');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PunBB Installation</title>
<link rel="stylesheet" type="text/css" href="style/Oxygen.css" />
<script type="text/javascript">
<!--
function process_form(the_form)
{
var element_names = new Object()
element_names["req_db_type"] = "Database type"
element_names["req_db_host"] = "Database server hostname"
element_names["req_db_name"] = "Database name"
element_names["db_prefix"] = "Table prefix"
element_names["req_username"] = "Administrator username"
element_names["req_password1"] = "Administrator password 1"
element_names["req_password2"] = "Administrator password 2"
element_names["req_email"] = "Administrator's e-mail"
element_names["req_base_url"] = "Base URL"
if (document.all || document.getElementById)
{
for (i = 0; i < the_form.length; ++i)
{
var elem = the_form.elements[i]
if (elem.name && elem.name.substring(0, 4) == "req_")
{
if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
{
alert("\"" + element_names[elem.name] + "\" is a required field in this form.")
elem.focus()
return false
}
}
}
}
return true
}
// -->
</script>
</head>
<body onload="document.getElementById('install').req_db_type.focus()">
<div id="puninstall" style="margin: auto 10% auto 10%">
<div class="pun">
<div class="block">
<h2><span>PunBB Installation</span></h2>
<div class="box">
<div class="inbox">
<p>Welcome to PunBB installation! You are about to install PunBB. In order to install PunBB you must complete the form set out below. If you encounter any difficulties with the installation, please refer to the documentation.</p>
</div>
</div>
</div>
<div class="blockform">
<h2><span>Install PunBB 1.2</span></h2>
<div class="box">
<form id="install" method="post" action="install.php" onsubmit="this.start.disabled=true;if(process_form(this)){return true;}else{this.start.disabled=false;return false;}">
<div><input type="hidden" name="form_sent" value="1" /></div>
<div class="inform">
<div class="forminfo">
<h3>Database setup</h3>
<p>Please enter the requested information in order to setup your database for PunBB. You must know all the information asked for before proceeding with the installation.</p>
</div>
<fieldset>
<legend>Select your database type</legend>
<div class="infldset">
<p>PunBB currently supports MySQL, PostgreSQL and SQLite. If your database of choice is missing from the drop-down menu below, it means this PHP environment does not have support for that particular database. More information regarding support for particular versions of each database can be found in the FAQ.</p>
<?php if ($dual_mysql): ?> <p>PunBB has detected that your PHP environment supports two different ways of communicating with MySQL. The two options are called standard and improved. If you are uncertain which one to use, start by trying improved and if that fails, try standard.</p>
<?php endif; ?> <label><strong>Database type</strong>
<br /><select name="req_db_type">
<?php
foreach ($db_extensions as $db_type)
echo "\t\t\t\t\t\t\t".'<option value="'.$db_type[0].'">'.$db_type[1].'</option>'."\n";
?>
</select>
<br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter your database server hostname</legend>
<div class="infldset">
<p>The address of the database server (example: localhost, db.myhost.com or 192.168.0.15). You can specify a custom port number if your database doesn't run on the default port (example: localhost:3580). For SQLite support, just enter anything or leave it at 'localhost'.</p>
<label><strong>Database server hostname</strong><br /><input type="text" name="req_db_host" value="localhost" size="50" maxlength="100" /><br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter then name of your database</legend>
<div class="infldset">
<p>The name of the database that PunBB will be installed into. The database must exist. For SQLite, this is the relative path to the database file. If the SQLite database file does not exist, PunBB will attempt to create it.</p>
<label for="req_db_name"><strong>Database name</strong><br /><input id="req_db_name" type="text" name="req_db_name" size="30" maxlength="50" /><br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter your database username and password</legend>
<div class="infldset">
<p>Enter the username and password with which you connect to the database. Ignore for SQLite.</p>
<label class="conl">Database username<br /><input type="text" name="db_username" size="30" maxlength="50" /><br /></label>
<label class="conl">Database password<br /><input type="text" name="db_password" size="30" maxlength="50" /><br /></label>
<div class="clearer"></div>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter database table prefix</legend>
<div class="infldset">
<p>If you like you can specify a table prefix. This way you can run multiple copies of PunBB in the same database (example: foo_).</p>
<label>Table prefix<br /><input id="db_prefix" type="text" name="db_prefix" size="20" maxlength="30" /><br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<div class="forminfo">
<h3>Administration setup</h3>
<p>Please enter the requested information in order to setup an administrator for your PunBB installation</p>
</div>
<fieldset>
<legend>Enter Administrators username</legend>
<div class="infldset">
<p>The username of the forum administrator. You can later create more administrators and moderators. Usernames can be between 2 and 25 characters long.</p>
<label><strong>Administrator username</strong><br /><input type="text" name="req_username" size="25" maxlength="25" /><br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter and confirm Administrator password</legend>
<div class="infldset">
<p>Passwords can be between 4 and 16 characters long. Passwords are case sensitive.</p>
<label class="conl"><strong>Password</strong><br /><input id="req_password1" type="text" name="req_password1" size="16" maxlength="16" /><br /></label>
<label class="conl"><strong>Confirm password</strong><br /><input type="text" name="req_password2" size="16" maxlength="16" /><br /></label>
<div class="clearer"></div>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter Administrator's e-mail</legend>
<div class="infldset">
<p>The e-mail address of the forum administrator.</p>
<label for="req_email"><strong>Administrator's e-mail</strong><br /><input id="req_email" type="text" name="req_email" size="50" maxlength="50" /><br /></label>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Enter the Base URL of your PunBB installation</legend>
<div class="infldset">
<p>The URL (without trailing slash) of your PunBB forum (example: http://forum.myhost.com or http://myhost.com/~myuser). This <strong>must</strong> be correct or administrators and moderators will not be able to submit any forms. Please note that the preset value below is just an educated guess by PunBB.</p>
<label><strong>Base URL</strong><br /><input type="text" name="req_base_url" value="http://<?php echo $_SERVER['SERVER_NAME'].str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])) ?>" size="60" maxlength="100" /><br /></label>
</div>
</fieldset>
</div>
<p><input type="submit" name="start" value="Start install" /></p>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
else
{
//
// Strip slashes only if magic_quotes_gpc is on.
//
function unescape($str)
{
return (get_magic_quotes_gpc() == 1) ? stripslashes($str) : $str;
}
//
// 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);
}
//
// A temporary replacement for the full error handler found in functions.php.
// It's here because a function called error() must be callable in the database abstraction layer.
//
function error($message, $file = false, $line = false, $db_error = false)
{
if ($file !== false && $line !== false)
echo '<strong style="color: A00000">An error occured on line '.$line.' in file '.$file.'.</strong><br /><br />';
else
echo '<strong style="color: A00000">An error occured.</strong><br /><br />';
echo '<strong>PunBB reported:</strong> '.htmlspecialchars($message).'<br /><br />';
if ($db_error !== false)
echo '<strong>Database reported:</strong> '.htmlspecialchars($db_error['error_msg']).(($db_error['error_no']) ? ' (Errno: '.$db_error['error_no'].')' : '');
pun_exit();
}
$db_type = $_POST['req_db_type'];
$db_host = trim($_POST['req_db_host']);
$db_name = trim($_POST['req_db_name']);
$db_username = unescape(trim($_POST['db_username']));
$db_password = unescape(trim($_POST['db_password']));
$db_prefix = trim($_POST['db_prefix']);
$username = unescape(trim($_POST['req_username']));
$email = strtolower(trim($_POST['req_email']));
$password1 = unescape(trim($_POST['req_password1']));
$password2 = unescape(trim($_POST['req_password2']));
// Make sure base_url doesn't end with a slash
if (substr($_POST['req_base_url'], -1) == '/')
$base_url = substr($_POST['req_base_url'], 0, -1);
else
$base_url = $_POST['req_base_url'];
// Validate username and passwords
if (strlen($username) < 2)
error('Usernames must be at least 2 characters long. Please go back and correct.');
if (strlen($password1) < 4)
error('Passwords must be at least 4 characters long. Please go back and correct.');
if ($password1 != $password2)
error('Passwords do not match. Please go back and correct.');
if (!strcasecmp($username, 'Guest'))
error('The username guest is reserved. Please go back and correct.');
if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
error('Usernames may not be in the form of an IP address. Please go back and correct.');
if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username))
error('Usernames may not contain any of the text formatting tags (BBCode) that the forum uses. Please go back and correct.');
if (strlen($email) > 50 || !preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email))
error('The administrator e-mail address you entered is invalid. Please go back and correct.');
// Load the appropriate DB layer class
switch ($db_type)
{
case 'mysql':
require PUN_ROOT.'include/dblayer/mysql.php';
break;
case 'mysqli':
require PUN_ROOT.'include/dblayer/mysqli.php';
break;
case 'pgsql':
require PUN_ROOT.'include/dblayer/pgsql.php';
break;
case 'sqlite':
require PUN_ROOT.'include/dblayer/sqlite.php';
break;
default:
error('\''.$db_type.'\' is not a valid database type.');
}
// Create the database object (and connect/select db)
$db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
// Do some DB type specific checks
switch ($db_type)
{
case 'mysql':
case 'mysqli':
break;
case 'pgsql':
// Make sure we are running at least PHP 4.3.0 (needed only for PostgreSQL)
if (version_compare(PHP_VERSION, '4.3.0', '<'))
error('You are running PHP version '.PHP_VERSION.'. PunBB requires at least PHP 4.3.0 to run properly when using PostgreSQL. You must upgrade your PHP installation or use a different database before you can continue.');
break;
case 'sqlite':
if (strtolower($db_prefix) == 'sqlite_')
error('The table prefix \'sqlite_\' is reserved for use by the SQLite engine. Please choose a different prefix.');
break;
}
// Make sure PunBB isn't already installed
$result = $db->query('SELECT 1 FROM '.$db_prefix.'users WHERE id=1');
if ($db->num_rows($result))
error('A table called "'.$db_prefix.'users" is already present in the database "'.$db_name.'". This could mean that PunBB is already installed or that another piece of software is installed and is occupying one or more of the table names PunBB requires. If you want to install multiple copies of PunBB in the same database, you must choose a different table prefix.');
// Create all tables
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."bans (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR(200),
ip VARCHAR(255),
email VARCHAR(50),
message VARCHAR(255),
expire INT(10) UNSIGNED,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$db->start_transaction();
$sql = 'CREATE TABLE '.$db_prefix."bans (
id SERIAL,
username VARCHAR(200),
ip VARCHAR(255),
email VARCHAR(50),
message VARCHAR(255),
expire INT,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$db->start_transaction();
$sql = 'CREATE TABLE '.$db_prefix."bans (
id INTEGER NOT NULL,
username VARCHAR(200),
ip VARCHAR(255),
email VARCHAR(50),
message VARCHAR(255),
expire INTEGER,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'bans. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."categories (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',
disp_position INT(10) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."categories (
id SERIAL,
cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',
disp_position INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."categories (
id INTEGER NOT NULL,
cat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',
disp_position INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'categories. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."censoring (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
search_for VARCHAR(60) NOT NULL DEFAULT '',
replace_with VARCHAR(60) NOT NULL DEFAULT '',
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."censoring (
id SERIAL,
search_for VARCHAR(60) NOT NULL DEFAULT '',
replace_with VARCHAR(60) NOT NULL DEFAULT '',
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."censoring (
id INTEGER NOT NULL,
search_for VARCHAR(60) NOT NULL DEFAULT '',
replace_with VARCHAR(60) NOT NULL DEFAULT '',
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'censoring. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."config (
conf_name VARCHAR(255) NOT NULL DEFAULT '',
conf_value TEXT,
PRIMARY KEY (conf_name)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."config (
conf_name VARCHAR(255) NOT NULL DEFAULT '',
conf_value TEXT,
PRIMARY KEY (conf_name)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."config (
conf_name VARCHAR(255) NOT NULL DEFAULT '',
conf_value TEXT,
PRIMARY KEY (conf_name)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'config. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."forum_perms (
group_id INT(10) NOT NULL DEFAULT 0,
forum_id INT(10) NOT NULL DEFAULT 0,
read_forum TINYINT(1) NOT NULL DEFAULT 1,
post_replies TINYINT(1) NOT NULL DEFAULT 1,
post_topics TINYINT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (group_id, forum_id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."forum_perms (
group_id INT NOT NULL DEFAULT 0,
forum_id INT NOT NULL DEFAULT 0,
read_forum SMALLINT NOT NULL DEFAULT 1,
post_replies SMALLINT NOT NULL DEFAULT 1,
post_topics SMALLINT NOT NULL DEFAULT 1,
PRIMARY KEY (group_id, forum_id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."forum_perms (
group_id INTEGER NOT NULL DEFAULT 0,
forum_id INTEGER NOT NULL DEFAULT 0,
read_forum INTEGER NOT NULL DEFAULT 1,
post_replies INTEGER NOT NULL DEFAULT 1,
post_topics INTEGER NOT NULL DEFAULT 1,
PRIMARY KEY (group_id, forum_id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'forum_perms. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."forums (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum',
forum_desc TEXT,
redirect_url VARCHAR(100),
moderators TEXT,
num_topics MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
num_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
last_post INT(10) UNSIGNED,
last_post_id INT(10) UNSIGNED,
last_poster VARCHAR(200),
sort_by TINYINT(1) NOT NULL DEFAULT 0,
disp_position INT(10) NOT NULL DEFAULT 0,
cat_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."forums (
id SERIAL,
forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum',
forum_desc TEXT,
redirect_url VARCHAR(100),
moderators TEXT,
num_topics INT NOT NULL DEFAULT 0,
num_posts INT NOT NULL DEFAULT 0,
last_post INT,
last_post_id INT,
last_poster VARCHAR(200),
sort_by SMALLINT NOT NULL DEFAULT 0,
disp_position INT NOT NULL DEFAULT 0,
cat_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."forums (
id INTEGER NOT NULL,
forum_name VARCHAR(80) NOT NULL DEFAULT 'New forum',
forum_desc TEXT,
redirect_url VARCHAR(100),
moderators TEXT,
num_topics INTEGER NOT NULL DEFAULT 0,
num_posts INTEGER NOT NULL DEFAULT 0,
last_post INTEGER,
last_post_id INTEGER,
last_poster VARCHAR(200),
sort_by INTEGER NOT NULL DEFAULT 0,
disp_position INTEGER NOT NULL DEFAULT 0,
cat_id INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'forums. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."groups (
g_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
g_title VARCHAR(50) NOT NULL DEFAULT '',
g_user_title VARCHAR(50),
g_read_board TINYINT(1) NOT NULL DEFAULT 1,
g_post_replies TINYINT(1) NOT NULL DEFAULT 1,
g_post_topics TINYINT(1) NOT NULL DEFAULT 1,
g_post_polls TINYINT(1) NOT NULL DEFAULT 1,
g_edit_posts TINYINT(1) NOT NULL DEFAULT 1,
g_delete_posts TINYINT(1) NOT NULL DEFAULT 1,
g_delete_topics TINYINT(1) NOT NULL DEFAULT 1,
g_set_title TINYINT(1) NOT NULL DEFAULT 1,
g_search TINYINT(1) NOT NULL DEFAULT 1,
g_search_users TINYINT(1) NOT NULL DEFAULT 1,
g_edit_subjects_interval SMALLINT(6) NOT NULL DEFAULT 300,
g_post_flood SMALLINT(6) NOT NULL DEFAULT 30,
g_search_flood SMALLINT(6) NOT NULL DEFAULT 30,
PRIMARY KEY (g_id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."groups (
g_id SERIAL,
g_title VARCHAR(50) NOT NULL DEFAULT '',
g_user_title VARCHAR(50),
g_read_board SMALLINT NOT NULL DEFAULT 1,
g_post_replies SMALLINT NOT NULL DEFAULT 1,
g_post_topics SMALLINT NOT NULL DEFAULT 1,
g_post_polls SMALLINT NOT NULL DEFAULT 1,
g_edit_posts SMALLINT NOT NULL DEFAULT 1,
g_delete_posts SMALLINT NOT NULL DEFAULT 1,
g_delete_topics SMALLINT NOT NULL DEFAULT 1,
g_set_title SMALLINT NOT NULL DEFAULT 1,
g_search SMALLINT NOT NULL DEFAULT 1,
g_search_users SMALLINT NOT NULL DEFAULT 1,
g_edit_subjects_interval SMALLINT NOT NULL DEFAULT 300,
g_post_flood SMALLINT NOT NULL DEFAULT 30,
g_search_flood SMALLINT NOT NULL DEFAULT 30,
PRIMARY KEY (g_id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."groups (
g_id INTEGER NOT NULL,
g_title VARCHAR(50) NOT NULL DEFAULT '',
g_user_title VARCHAR(50),
g_read_board INTEGER NOT NULL DEFAULT 1,
g_post_replies INTEGER NOT NULL DEFAULT 1,
g_post_topics INTEGER NOT NULL DEFAULT 1,
g_post_polls INTEGER NOT NULL DEFAULT 1,
g_edit_posts INTEGER NOT NULL DEFAULT 1,
g_delete_posts INTEGER NOT NULL DEFAULT 1,
g_delete_topics INTEGER NOT NULL DEFAULT 1,
g_set_title INTEGER NOT NULL DEFAULT 1,
g_search INTEGER NOT NULL DEFAULT 1,
g_search_users INTEGER NOT NULL DEFAULT 1,
g_edit_subjects_interval INTEGER NOT NULL DEFAULT 300,
g_post_flood INTEGER NOT NULL DEFAULT 30,
g_search_flood INTEGER NOT NULL DEFAULT 30,
PRIMARY KEY (g_id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'groups. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."online (
user_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
ident VARCHAR(200) NOT NULL DEFAULT '',
logged INT(10) UNSIGNED NOT NULL DEFAULT 0,
idle TINYINT(1) NOT NULL DEFAULT 0
) TYPE=HEAP;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."online (
user_id INT NOT NULL DEFAULT 1,
ident VARCHAR(200) NOT NULL DEFAULT '',
logged INT NOT NULL DEFAULT 0,
idle SMALLINT NOT NULL DEFAULT 0
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."online (
user_id INTEGER NOT NULL DEFAULT 1,
ident VARCHAR(200) NOT NULL DEFAULT '',
logged INTEGER NOT NULL DEFAULT 0,
idle INTEGER NOT NULL DEFAULT 0
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'online. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."posts (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
poster VARCHAR(200) NOT NULL DEFAULT '',
poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1,
poster_ip VARCHAR(15),
poster_email VARCHAR(50),
message TEXT,
hide_smilies TINYINT(1) NOT NULL DEFAULT 0,
posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
edited INT(10) UNSIGNED,
edited_by VARCHAR(200),
topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."posts (
id SERIAL,
poster VARCHAR(200) NOT NULL DEFAULT '',
poster_id INT NOT NULL DEFAULT 1,
poster_ip VARCHAR(15),
poster_email VARCHAR(50),
message TEXT,
hide_smilies SMALLINT NOT NULL DEFAULT 0,
posted INT NOT NULL DEFAULT 0,
edited INT,
edited_by VARCHAR(200),
topic_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."posts (
id INTEGER NOT NULL,
poster VARCHAR(200) NOT NULL DEFAULT '',
poster_id INTEGER NOT NULL DEFAULT 1,
poster_ip VARCHAR(15),
poster_email VARCHAR(50),
message TEXT,
hide_smilies INTEGER NOT NULL DEFAULT 0,
posted INTEGER NOT NULL DEFAULT 0,
edited INTEGER,
edited_by VARCHAR(200),
topic_id INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'posts. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."ranks (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
rank VARCHAR(50) NOT NULL DEFAULT '',
min_posts MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."ranks (
id SERIAL,
rank VARCHAR(50) NOT NULL DEFAULT '',
min_posts INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."ranks (
id INTEGER NOT NULL,
rank VARCHAR(50) NOT NULL DEFAULT '',
min_posts INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'titles. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."reports (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0,
created INT(10) UNSIGNED NOT NULL DEFAULT 0,
message TEXT,
zapped INT(10) UNSIGNED,
zapped_by INT(10) UNSIGNED,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."reports (
id SERIAL,
post_id INT NOT NULL DEFAULT 0,
topic_id INT NOT NULL DEFAULT 0,
forum_id INT NOT NULL DEFAULT 0,
reported_by INT NOT NULL DEFAULT 0,
created INT NOT NULL DEFAULT 0,
message TEXT,
zapped INT,
zapped_by INT,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."reports (
id INTEGER NOT NULL,
post_id INTEGER NOT NULL DEFAULT 0,
topic_id INTEGER NOT NULL DEFAULT 0,
forum_id INTEGER NOT NULL DEFAULT 0,
reported_by INTEGER NOT NULL DEFAULT 0,
created INTEGER NOT NULL DEFAULT 0,
message TEXT,
zapped INTEGER,
zapped_by INTEGER,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'reports. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."search_cache (
id INT(10) UNSIGNED NOT NULL DEFAULT 0,
ident VARCHAR(200) NOT NULL DEFAULT '',
search_data TEXT,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."search_cache (
id INT NOT NULL DEFAULT 0,
ident VARCHAR(200) NOT NULL DEFAULT '',
search_data TEXT,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."search_cache (
id INTEGER NOT NULL DEFAULT 0,
ident VARCHAR(200) NOT NULL DEFAULT '',
search_data TEXT,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'search_cache. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."search_matches (
post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
word_id MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
subject_match TINYINT(1) NOT NULL DEFAULT 0
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."search_matches (
post_id INT NOT NULL DEFAULT 0,
word_id INT NOT NULL DEFAULT 0,
subject_match SMALLINT NOT NULL DEFAULT 0
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."search_matches (
post_id INTEGER NOT NULL DEFAULT 0,
word_id INTEGER NOT NULL DEFAULT 0,
subject_match INTEGER NOT NULL DEFAULT 0
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'search_matches. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."search_words (
id MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
word VARCHAR(20) BINARY NOT NULL DEFAULT '',
PRIMARY KEY (word),
KEY ".$db_prefix."search_words_id_idx (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."search_words (
id SERIAL,
word VARCHAR(20) NOT NULL DEFAULT '',
PRIMARY KEY (word)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."search_words (
id INTEGER NOT NULL,
word VARCHAR(20) NOT NULL DEFAULT '',
PRIMARY KEY (id),
UNIQUE (word)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'search_words. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."subscriptions (
user_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
topic_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, topic_id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."subscriptions (
user_id INT NOT NULL DEFAULT 0,
topic_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, topic_id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."subscriptions (
user_id INTEGER NOT NULL DEFAULT 0,
topic_id INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (user_id, topic_id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'subscriptions. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."topics (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
poster VARCHAR(200) NOT NULL DEFAULT '',
subject VARCHAR(255) NOT NULL DEFAULT '',
posted INT(10) UNSIGNED NOT NULL DEFAULT 0,
last_post INT(10) UNSIGNED NOT NULL DEFAULT 0,
last_post_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
last_poster VARCHAR(200),
num_views MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
num_replies MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT 0,
closed TINYINT(1) NOT NULL DEFAULT 0,
sticky TINYINT(1) NOT NULL DEFAULT 0,
moved_to INT(10) UNSIGNED,
forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."topics (
id SERIAL,
poster VARCHAR(200) NOT NULL DEFAULT '',
subject VARCHAR(255) NOT NULL DEFAULT '',
posted INT NOT NULL DEFAULT 0,
last_post INT NOT NULL DEFAULT 0,
last_post_id INT NOT NULL DEFAULT 0,
last_poster VARCHAR(200),
num_views INT NOT NULL DEFAULT 0,
num_replies INT NOT NULL DEFAULT 0,
closed SMALLINT NOT NULL DEFAULT 0,
sticky SMALLINT NOT NULL DEFAULT 0,
moved_to INT,
forum_id INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."topics (
id INTEGER NOT NULL,
poster VARCHAR(200) NOT NULL DEFAULT '',
subject VARCHAR(255) NOT NULL DEFAULT '',
posted INTEGER NOT NULL DEFAULT 0,
last_post INTEGER NOT NULL DEFAULT 0,
last_post_id INTEGER NOT NULL DEFAULT 0,
last_poster VARCHAR(200),
num_views INTEGER NOT NULL DEFAULT 0,
num_replies INTEGER NOT NULL DEFAULT 0,
closed INTEGER NOT NULL DEFAULT 0,
sticky INTEGER NOT NULL DEFAULT 0,
moved_to INTEGER,
forum_id INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'topics. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type)
{
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE '.$db_prefix."users (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
group_id INT(10) UNSIGNED NOT NULL DEFAULT 4,
username VARCHAR(200) NOT NULL DEFAULT '',
password VARCHAR(40) NOT NULL DEFAULT '',
email VARCHAR(50) NOT NULL DEFAULT '',
title VARCHAR(50),
realname VARCHAR(40),
url VARCHAR(100),
jabber VARCHAR(75),
icq VARCHAR(12),
msn VARCHAR(50),
aim VARCHAR(30),
yahoo VARCHAR(30),
location VARCHAR(30),
use_avatar TINYINT(1) NOT NULL DEFAULT 0,
signature TEXT,
disp_topics TINYINT(3) UNSIGNED,
disp_posts TINYINT(3) UNSIGNED,
email_setting TINYINT(1) NOT NULL DEFAULT 1,
save_pass TINYINT(1) NOT NULL DEFAULT 1,
notify_with_post TINYINT(1) NOT NULL DEFAULT 0,
show_smilies TINYINT(1) NOT NULL DEFAULT 1,
show_img TINYINT(1) NOT NULL DEFAULT 1,
show_img_sig TINYINT(1) NOT NULL DEFAULT 1,
show_avatars TINYINT(1) NOT NULL DEFAULT 1,
show_sig TINYINT(1) NOT NULL DEFAULT 1,
timezone FLOAT NOT NULL DEFAULT 0,
language VARCHAR(25) NOT NULL DEFAULT 'English',
style VARCHAR(25) NOT NULL DEFAULT 'Oxygen',
num_posts INT(10) UNSIGNED NOT NULL DEFAULT 0,
last_post INT(10) UNSIGNED,
registered INT(10) UNSIGNED NOT NULL DEFAULT 0,
registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
last_visit INT(10) UNSIGNED NOT NULL DEFAULT 0,
admin_note VARCHAR(30),
activate_string VARCHAR(50),
activate_key VARCHAR(8),
PRIMARY KEY (id)
) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE '.$db_prefix."users (
id SERIAL,
group_id INT NOT NULL DEFAULT 4,
username VARCHAR(200) NOT NULL DEFAULT '',
password VARCHAR(40) NOT NULL DEFAULT '',
email VARCHAR(50) NOT NULL DEFAULT '',
title VARCHAR(50),
realname VARCHAR(40),
url VARCHAR(100),
jabber VARCHAR(75),
icq VARCHAR(12),
msn VARCHAR(50),
aim VARCHAR(30),
yahoo VARCHAR(30),
location VARCHAR(30),
use_avatar SMALLINT NOT NULL DEFAULT 0,
signature TEXT,
disp_topics SMALLINT,
disp_posts SMALLINT,
email_setting SMALLINT NOT NULL DEFAULT 1,
save_pass SMALLINT NOT NULL DEFAULT 1,
notify_with_post SMALLINT NOT NULL DEFAULT 0,
show_smilies SMALLINT NOT NULL DEFAULT 1,
show_img SMALLINT NOT NULL DEFAULT 1,
show_img_sig SMALLINT NOT NULL DEFAULT 1,
show_avatars SMALLINT NOT NULL DEFAULT 1,
show_sig SMALLINT NOT NULL DEFAULT 1,
timezone REAL NOT NULL DEFAULT 0,
language VARCHAR(25) NOT NULL DEFAULT 'English',
style VARCHAR(25) NOT NULL DEFAULT 'Oxygen',
num_posts INT NOT NULL DEFAULT 0,
last_post INT,
registered INT NOT NULL DEFAULT 0,
registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
last_visit INT NOT NULL DEFAULT 0,
admin_note VARCHAR(30),
activate_string VARCHAR(50),
activate_key VARCHAR(8),
PRIMARY KEY (id)
)";
break;
case 'sqlite':
$sql = 'CREATE TABLE '.$db_prefix."users (
id INTEGER NOT NULL,
group_id INTEGER NOT NULL DEFAULT 4,
username VARCHAR(200) NOT NULL DEFAULT '',
password VARCHAR(40) NOT NULL DEFAULT '',
email VARCHAR(50) NOT NULL DEFAULT '',
title VARCHAR(50),
realname VARCHAR(40),
url VARCHAR(100),
jabber VARCHAR(75),
icq VARCHAR(12),
msn VARCHAR(50),
aim VARCHAR(30),
yahoo VARCHAR(30),
location VARCHAR(30),
use_avatar INTEGER NOT NULL DEFAULT 0,
signature TEXT,
disp_topics INTEGER,
disp_posts INTEGER,
email_setting INTEGER NOT NULL DEFAULT 1,
save_pass INTEGER NOT NULL DEFAULT 1,
notify_with_post INTEGER NOT NULL DEFAULT 0,
show_smilies INTEGER NOT NULL DEFAULT 1,
show_img INTEGER NOT NULL DEFAULT 1,
show_img_sig INTEGER NOT NULL DEFAULT 1,
show_avatars INTEGER NOT NULL DEFAULT 1,
show_sig INTEGER NOT NULL DEFAULT 1,
timezone FLOAT NOT NULL DEFAULT 0,
language VARCHAR(25) NOT NULL DEFAULT 'English',
style VARCHAR(25) NOT NULL DEFAULT 'Oxygen',
num_posts INTEGER NOT NULL DEFAULT 0,
last_post INTEGER,
registered INTEGER NOT NULL DEFAULT 0,
registration_ip VARCHAR(15) NOT NULL DEFAULT '0.0.0.0',
last_visit INTEGER NOT NULL DEFAULT 0,
admin_note VARCHAR(30),
activate_string VARCHAR(50),
activate_key VARCHAR(8),
PRIMARY KEY (id)
)";
break;
}
$db->query($sql) or error('Unable to create table '.$db_prefix.'users. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
// Add some indexes
switch ($db_type)
{
case 'mysql':
case 'mysqli':
// We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege
$queries[] = 'ALTER TABLE '.$db_prefix.'online ADD UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx(user_id,ident)';
$queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_multi_idx(poster_id, topic_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'reports ADD INDEX '.$db_prefix.'reports_zapped_idx(zapped)';
$queries[] = 'ALTER TABLE '.$db_prefix.'search_matches ADD INDEX '.$db_prefix.'search_matches_word_id_idx(word_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'search_matches ADD INDEX '.$db_prefix.'search_matches_post_id_idx(post_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'topics ADD INDEX '.$db_prefix.'topics_forum_id_idx(forum_id)';
$queries[] = 'ALTER TABLE '.$db_prefix.'topics ADD INDEX '.$db_prefix.'topics_moved_to_idx(moved_to)';
$queries[] = 'ALTER TABLE '.$db_prefix.'users ADD INDEX '.$db_prefix.'users_registered_idx(registered)';
$queries[] = 'ALTER TABLE '.$db_prefix.'search_cache ADD INDEX '.$db_prefix.'search_cache_ident_idx(ident(8))';
$queries[] = 'ALTER TABLE '.$db_prefix.'users ADD INDEX '.$db_prefix.'users_username_idx(username(8))';
break;
default:
$queries[] = 'CREATE INDEX '.$db_prefix.'online_user_id_idx ON '.$db_prefix.'online(user_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'posts_topic_id_idx ON '.$db_prefix.'posts(topic_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'posts_multi_idx ON '.$db_prefix.'posts(poster_id, topic_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'reports_zapped_idx ON '.$db_prefix.'reports(zapped)';
$queries[] = 'CREATE INDEX '.$db_prefix.'search_matches_word_id_idx ON '.$db_prefix.'search_matches(word_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'search_matches_post_id_idx ON '.$db_prefix.'search_matches(post_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'topics_forum_id_idx ON '.$db_prefix.'topics(forum_id)';
$queries[] = 'CREATE INDEX '.$db_prefix.'topics_moved_to_idx ON '.$db_prefix.'topics(moved_to)';
$queries[] = 'CREATE INDEX '.$db_prefix.'users_registered_idx ON '.$db_prefix.'users(registered)';
$queries[] = 'CREATE INDEX '.$db_prefix.'users_username_idx ON '.$db_prefix.'users(username)';
$queries[] = 'CREATE INDEX '.$db_prefix.'search_cache_ident_idx ON '.$db_prefix.'search_cache(ident)';
$queries[] = 'CREATE INDEX '.$db_prefix.'search_words_id_idx ON '.$db_prefix.'search_words(id)';
break;
}
@reset($queries);
while (list(, $sql) = @each($queries))
$db->query($sql) or error('Unable to create indexes. Please check your configuration and try again.', __FILE__, __LINE__, $db->error());
$now = time();
// Insert the four preset groups
$db->query('INSERT INTO '.$db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Administrators', 'Administrator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $db->error());
$db->query('INSERT INTO '.$db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Moderators', 'Moderator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $db->error());
$db->query('INSERT INTO '.$db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Guest', NULL, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $db->error());
$db->query('INSERT INTO '.$db->prefix."groups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_post_polls, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood) VALUES('Members', NULL, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 300, 60, 30)") or error('Unable to add group', __FILE__, __LINE__, $db->error());
// Insert guest and first admin user
$db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email) VALUES(3, 'Guest', 'Guest', 'Guest')")
or error('Unable to add guest user. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email, num_posts, last_post, registered, registration_ip, last_visit) VALUES(1, '".$db->escape($username)."', '".pun_hash($password1)."', '$email', 1, ".$now.", ".$now.", '127.0.0.1', ".$now.')')
or error('Unable to add administrator user. Please check your configuration and try again.');
// Insert config data
$config = array(
'o_cur_version' => "'$punbb_version'",
'o_board_title' => "'My PunBB forum'",
'o_board_desc' => "'Unfortunately no one can be told what PunBB is - you have to see it for yourself.'",
'o_server_timezone' => "'0'",
'o_time_format' => "'H:i:s'",
'o_date_format' => "'Y-m-d'",
'o_timeout_visit' => "'600'",
'o_timeout_online' => "'300'",
'o_redirect_delay' => "'1'",
'o_show_version' => "'0'",
'o_show_user_info' => "'1'",
'o_show_post_count' => "'1'",
'o_smilies' => "'1'",
'o_smilies_sig' => "'1'",
'o_make_links' => "'1'",
'o_default_lang' => "'English'",
'o_default_style' => "'Oxygen'",
'o_default_user_group' => "'4'",
'o_topic_review' => "'15'",
'o_disp_topics_default' => "'30'",
'o_disp_posts_default' => "'25'",
'o_indent_num_spaces' => "'4'",
'o_quickpost' => "'1'",
'o_users_online' => "'1'",
'o_censoring' => "'0'",
'o_ranks' => "'1'",
'o_show_dot' => "'0'",
'o_quickjump' => "'1'",
'o_gzip' => "'0'",
'o_additional_navlinks' => "''",
'o_report_method' => "'0'",
'o_regs_report' => "'0'",
'o_mailing_list' => "'$email'",
'o_avatars' => "'1'",
'o_avatars_dir' => "'img/avatars'",
'o_avatars_width' => "'60'",
'o_avatars_height' => "'60'",
'o_avatars_size' => "'10240'",
'o_search_all_forums' => "'1'",
'o_base_url' => "'$base_url'",
'o_admin_email' => "'$email'",
'o_webmaster_email' => "'$email'",
'o_subscriptions' => "'1'",
'o_smtp_host' => "NULL",
'o_smtp_user' => "NULL",
'o_smtp_pass' => "NULL",
'o_regs_allow' => "'1'",
'o_regs_verify' => "'0'",
'o_announcement' => "'0'",
'o_announcement_message' => "'Enter your announcement here.'",
'o_rules' => "'0'",
'o_rules_message' => "'Enter your rules here.'",
'o_maintenance' => "'0'",
'o_maintenance_message' => "'The forums are temporarily down for maintenance. Please try again in a few minutes.<br />\\n<br />\\n/Administrator'",
'p_mod_edit_users' => "'1'",
'p_mod_rename_users' => "'0'",
'p_mod_change_passwords' => "'0'",
'p_mod_ban_users' => "'0'",
'p_message_bbcode' => "'1'",
'p_message_img_tag' => "'1'",
'p_message_all_caps' => "'1'",
'p_subject_all_caps' => "'1'",
'p_sig_all_caps' => "'1'",
'p_sig_bbcode' => "'1'",
'p_sig_img_tag' => "'0'",
'p_sig_length' => "'400'",
'p_sig_lines' => "'4'",
'p_allow_banned_email' => "'1'",
'p_allow_dupe_email' => "'0'",
'p_force_guest_email' => "'1'"
);
while (list($conf_name, $conf_value) = @each($config))
{
$db->query('INSERT INTO '.$db_prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
or error('Unable to insert into table '.$db_prefix.'config. Please check your configuration and try again.');
}
// Insert some other default data
$db->query('INSERT INTO '.$db_prefix."categories (cat_name, disp_position) VALUES('Test category', 1)")
or error('Unable to insert into table '.$db_prefix.'categories. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."forums (forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id) VALUES('Test forum', 'This is just a test forum', 1, 1, ".$now.", 1, '".$db->escape($username)."', 1, 1)")
or error('Unable to insert into table '.$db_prefix.'forums. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."topics (poster, subject, posted, last_post, last_post_id, last_poster, forum_id) VALUES('".$db->escape($username)."', 'Test post', ".$now.", ".$now.", 1, '".$db->escape($username)."', 1)")
or error('Unable to insert into table '.$db_prefix.'topics. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES('".$db->escape($username)."', 2, '127.0.0.1', 'If you are looking at this (which I guess you are), the install of PunBB appears to have worked! Now log in and head over to the administration control panel to configure your forum.', ".$now.', 1)')
or error('Unable to insert into table '.$db_prefix.'posts. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('New member', 0)")
or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again.');
$db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('Member', 10)")
or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again.');
if ($db_type == 'pgsql' || $db_type == 'sqlite')
$db->end_transaction();
$alerts = '';
// Check if the cache directory is writable
if (!@is_writable('./cache/'))
$alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The cache directory is currently not writable!</strong></span> In order for PunBB to function properly, the directory named <em>cache</em> must be writable by PHP. Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';
// Check if default avatar directory is writable
if (!@is_writable('./img/avatars/'))
$alerts .= '<p style="font-size: 1.1em"><span style="color: #C03000"><strong>The avatar directory is currently not writable!</strong></span> If you want users to be able to upload their own avatar images you must see to it that the directory named <em>img/avatars</em> is writable by PHP. You can later choose to save avatar images in a different directory (see Admin/Options). Use chmod to set the appropriate directory permissions. If in doubt, chmod to 0777.</p>';
/// Display config.php and give further instructions
$config = '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.$db_name."';\n".'$db_username = \''.$db_username."';\n".'$db_password = \''.$db_password."';\n".'$db_prefix = \''.$db_prefix."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'punbb_cookie';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.substr(sha1(uniqid(rand(), true)), 0, 16)."';\n\ndefine('PUN', 1);";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PunBB Installation</title>
<link rel="stylesheet" type="text/css" href="style/Oxygen.css" />
</head>
<body>
<div id="puninstall" style="margin: auto 10% auto 10%">
<div class="pun">
<div class="blockform">
<h2>Final instructions</h2>
<div class="box">
<div class="fakeform">
<div class="inform">
<div class="forminfo">
<p>To finalize the installation all you need to do is to <strong>copy and paste the text in the text box below into a file called config.php and then upload this file to the root directory of your PunBB installation</strong>. Make sure there are no linebreaks or spaces before &lt;?php. You can later edit config.php if you reconfigure your setup (e.g. change the database password or ).</p>
<?php if ($alerts != ''): ?> <?php echo $alerts."\n" ?>
<?php endif; ?> </div>
<fieldset>
<legend>Copy contents to config.php</legend>
<div class="infldset">
<textarea cols="80" rows="20"><?php echo htmlspecialchars($config) ?></textarea>
</div>
</fieldset>
</div>
<div class="inform">
<div class="forminfo">
<p>Once you have created config.php with the contents above, PunBB is installed!</p>
<p><a href="index.php">Go to forum index</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
<?php
/*
// Determine what locale to use
switch (PHP_OS)
{
case 'WINNT':
case 'WIN32':
$locale = 'english';
break;
case 'FreeBSD':
case 'NetBSD':
case 'OpenBSD':
$locale = 'en_US.US-ASCII';
break;
default:
$locale = 'en_US';
break;
}
// Attempt to set the locale
setlocale(LC_CTYPE, $locale);
*/
// Language definitions for frequently used strings
$lang_common = array(
// Text orientation and encoding
'lang_direction' => 'ltr', // ltr (Left-To-Right) or rtl (Right-To-Left)
'lang_encoding' => 'iso-8859-1',
'lang_multibyte' => false,
// Notices
'Bad request' => 'Bad request. The link you followed is incorrect or outdated.',
'No view' => 'You do not have permission to view these forums.',
'No permission' => 'You do not have permission to access this page.',
'Bad referrer' => 'Bad HTTP_REFERER. You were referred to this page from an unauthorized source. If the problem persists please make sure that \'Base URL\' is correctly set in Admin/Options and that you are visiting the forum by navigating to that URL. More information regarding the referrer check can be found in the PunBB documentation.',
// Topic/forum indicators
'New icon' => 'There are new posts',
'Normal icon' => '<!-- -->',
'Closed icon' => 'This topic is closed',
'Redirect icon' => 'Redirected forum',
// Miscellaneous
'Announcement' => 'Announcement',
'Options' => 'Options',
'Actions' => 'Actions',
'Submit' => 'Submit', // "name" of submit buttons
'Ban message' => 'You are banned from this forum.',
'Ban message 2' => 'The ban expires at the end of',
'Ban message 3' => 'The administrator or moderator that banned you left the following message:',
'Ban message 4' => 'Please direct any inquiries to the forum administrator at',
'Never' => 'Never',
'Today' => 'Today',
'Yesterday' => 'Yesterday',
'Info' => 'Info', // a common table header
'Go back' => 'Go back',
'Maintenance' => 'Maintenance',
'Redirecting' => 'Redirecting',
'Click redirect' => 'Click here if you do not want to wait any longer (or if your browser does not automatically forward you)',
'on' => 'on', // as in "BBCode is on"
'off' => 'off',
'Invalid e-mail' => 'The e-mail address you entered is invalid.',
'required field' => 'is a required field in this form.', // for javascript form validation
'Last post' => 'Last post',
'by' => 'by', // as in last post by someuser
'New posts' => 'New&nbsp;posts', // the link that leads to the first new post (use &nbsp; for spaces)
'New posts info' => 'Go to the first new post in this topic.', // the popup text for new posts links
'Username' => 'Username',
'Password' => 'Password',
'E-mail' => 'E-mail',
'Send e-mail' => 'Send e-mail',
'Moderated by' => 'Moderated by',
'Registered' => 'Registered',
'Subject' => 'Subject',
'Message' => 'Message',
'Topic' => 'Topic',
'Forum' => 'Forum',
'Posts' => 'Posts',
'Replies' => 'Replies',
'Author' => 'Author',
'Pages' => 'Pages',
'BBCode' => 'BBCode', // You probably shouldn't change this
'img tag' => '[img] tag',
'Smilies' => 'Smilies',
'and' => 'and',
'Image link' => 'image', // This is displayed (i.e. <image>) instead of images when "Show images" is disabled in the profile
'wrote' => 'wrote', // For [quote]'s
'Code' => 'Code', // For [code]'s
'Mailer' => 'Mailer', // As in "MyForums Mailer" in the signature of outgoing e-mails
'Important information' => 'Important information',
'Write message legend' => 'Write your message and submit',
// Title
'Title' => 'Title',
'Member' => 'Member', // Default title
'Moderator' => 'Moderator',
'Administrator' => 'Administrator',
'Banned' => 'Banned',
'Guest' => 'Guest',
// Stuff for include/parser.php
'BBCode error' => 'The BBCode syntax in the message is incorrect.',
'BBCode error 1' => 'Missing start tag for [/quote].',
'BBCode error 2' => 'Missing end tag for [code].',
'BBCode error 3' => 'Missing start tag for [/code].',
'BBCode error 4' => 'Missing one or more end tags for [quote].',
'BBCode error 5' => 'Missing one or more start tags for [/quote].',
// Stuff for the navigator (top of every page)
'Index' => 'Index',
'User list' => 'User list',
'Rules' => 'Rules',
'Search' => 'Search',
'Register' => 'Register',
'Login' => 'Login',
'Not logged in' => 'You are not logged in.',
'Profile' => 'Profile',
'Logout' => 'Logout',
'Logged in as' => 'Logged in as',
'Admin' => 'Administration',
'Last visit' => 'Last visit',
'Show new posts' => 'Show new posts since last visit',
'Mark all as read' => 'Mark all topics as read',
'Link separator' => '', // The text that separates links in the navigator
// Stuff for the page footer
'Board footer' => 'Board footer',
'Search links' => 'Search links',
'Show recent posts' => 'Show recent posts',
'Show unanswered posts' => 'Show unanswered posts',
'Show your posts' => 'Show your posts',
'Show subscriptions' => 'Show your subscribed topics',
'Jump to' => 'Jump to',
'Go' => ' Go ', // submit button in forum jump
'Move topic' => 'Move topic',
'Open topic' => 'Open topic',
'Close topic' => 'Close topic',
'Unstick topic' => 'Unstick topic',
'Stick topic' => 'Stick topic',
'Moderate forum' => 'Moderate forum',
'Delete posts' => 'Delete multiple posts',
'Debug table' => 'Debug information',
// For extern.php RSS feed
'RSS Desc Active' => 'The most recently active topics at', // board_title will be appended to this string
'RSS Desc New' => 'The newest topics at', // board_title will be appended to this string
'Posted' => 'Posted' // The date/time a topic was started
);
<?php
// Language definitions used in delete.php
$lang_delete = array(
'Delete post' => 'Delete post',
'Warning' => 'Warning! If this is the first post in the topic, the whole topic will be deleted.',
'Delete' => 'Delete', // The submit button
'Post del redirect' => 'Post deleted. Redirecting &hellip;',
'Topic del redirect' => 'Topic deleted. Redirecting &hellip;'
);