also you have to change the following files:
ipbwiki_interace_setup.php:
[code]<?php
/*
+--------------------------------------------------------
| Package: IpbWiki Interface
| Copyright (c) 2006-2011 Peter De Decker
| http://www.ipbwiki.com
+--------------------------------------------------------
*/
if (!defined(\'WRK_DIR\')) {
define (\'WRK_DIR\', getcwd());
}
if(!function_exists(\'str_ireplace\')) {
function str_ireplace($search,$replace,$subject) {
$search = preg_quote($search, \"/\");
return preg_replace(\"/\".$search.\"/i\", $replace, $subject);
}
}
define( \'IN_IPB\', 0);
class ipbwiki_setup {
// remember our settings...
var $ipb_root_path;
var $ipb_forum_url;
var $forum_charset;
var $wiki_charset;
var $is_ipb;
var $is_vb;
// wiki DB
var $wgDBServer;
var $wgDBname;
var $wgDBuser;
var $wgDBpassword;
var $wgDBprefix;
var $wgServer;
var $wgScriptPath;
var $wgStylePath;
var $wgDefaultSkin;
// charsets...
var $decode_charsets = array( \'iso-8859-1\' => \'ISO-8859-1\',
\'iso8859-1\' => \'ISO-8859-1\',
\'iso-8859-15\' => \'ISO-8859-15\',
\'iso8859-15\' => \'ISO-8859-15\',
\'utf-8\' => \'UTF-8\',
\'cp866\' => \'cp866\',
\'ibm866\' => \'cp866\',
\'cp1251\' => \'windows-1251\',
\'windows-1251\' => \'windows-1251\',
\'win-1251\' => \'windows-1251\',
\'cp1252\' => \'windows-1252\',
\'windows-1252\' => \'windows-1252\',
\'koi8-r\' => \'KOI8-R\',
\'koi8-ru\' => \'KOI8-R\',
\'koi8r\' => \'KOI8-R\',
\'big5\' => \'BIG5\',
\'gb2312\' => \'GB2312\',
\'big5-hkscs\' => \'BIG5-HKSCS\',
\'shift_jis\' => \'Shift_JIS\',
\'sjis\' => \'Shift_JIS\',
\'euc-jp\' => \'EUC-JP\',
\'eucjp\' => \'EUC-JP\',
\'iso-8859-2\' => \'ISO-8859-2\',
\'iso8859-2\' => \'ISO-8859-2\');
// constructor, will take care of the program flow...
function ipbwiki_setup () {
switch (isset($_GET[\'act\']) && ($_GET[\'act\']))
{
case \'check_entries\':
$this->check_entries();
break;
default:
$this->entry();
break;
}
}
function print_top($title=\"\")
{
echo \"<html>
<head><title>IpbWiki Interface Set Up : $title </title>
<style type=\'text/css\'>
body {
font: x-small sans-serif;
background: #f9f9f9 url(skins/monobook/headbg.jpg) 0 0 no-repeat;
color: black;
margin: 0;
padding: 0;
}
table {
font-size: 100%;
background: transparent;
color: black;
}
td {
text-align: left;
}
a {
text-decoration: none;
color: #002bb8;
background: none;
}
a:visited {
color: #5a3696;
}
a:active {
color: #faa700;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body marginheight=\'0\' marginwidth=\'0\' leftmargin=\'30\' topmargin=\'30\' bgcolor=\'#FFFFFF\'><center><table width=\'80%\'>
<H1>IpbWiki Set Up : $title</H1>
<br />
\";
}
function print_footer () {
echo \"</table></center></body></html>\";
}
function add_row ($text) {
echo \"<tr><td>$text</td></tr>\";
}
function entry() {
if ( ! file_exists (\'LocalSettings.php\')) {
$this->print_top (\'Checking file access permissions.\');
$this->add_row (\'the file LocalSettings.php not found in this directory. You have to install MediaWiki before installing the IpbWiki plugin.\');
$this->print_footer();
return;
}
$files = array(\'LocalSettings.php\', \'ipbwiki_config.php\', \'includes/Skin.php\', \'includes/User.php\', \'includes/SkinTemplate.php\', \'includes/EditPage.php\', \'includes/Parser.php\', \'includes/parser/Parser.php\');
$unwriteable = array();
ob_start(); // try to chmod the files so that the files become writable, but catch the annoying messages if we don\'t have rights to chmod...
foreach ($files as $file) {
if (file_exists($file)) {
chmod($file, 0777);
if ( ! is_writable($file)) {
array_push($unwriteable, $file);
}
}
}
ob_end_clean();
if (count($unwriteable) > 0) {
$this->print_top (\'Checking file access permissions.\');
foreach ($unwriteable as $file) {
$this->add_row (\"The file $file is not writable, please chmod it to 777.\");
}
$this->print_footer();
return;
}
if ($this->ipb_root_path != \"\") {
$ipb_root_path = $this->ipb_root_path;
} else {
if ( file_exists (\'ipbwiki_config.php\') ) {
require_once (\'ipbwiki_config.php\');
}
if ($ipb_root_path == \"\") {
$ipb_root_path=$_SERVER[\'DOCUMENT_ROOT\'] . \"/forums/\";
}
}
if ($this->ipb_forum_url != \"\") {
$ipb_forum_url = $this->ipb_forum_url;
}
$this->print_top (\'Configuration.\');
echo \"<td><p><form method=\'post\' action=\'?act=check_entries\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B><H3>Forum Root Directory</H3></B><P>Please specify the complete path to the root of your forum directory (this typically looks something like: /home/public_html/community/forums/)<P><input type=\'input\' name=\'ipb_path\' value=\'$ipb_root_path\' size=\'100\'><p><B><H3>Forum Url</H3></B><P>Please specify the url of your forum (this typically looks something like: http://www.yoursite.com/forums/\)<P><input type=\'input\' name=\'ipb_forum_url\' value=\'$ipb_forum_url\' size=\'100\'><p><B><H3>Character Sets</H3></B><P>Please specify the characters sets you use for your forum and your wiki. (the default charset for the forum is ISO-8859-1 and the default characterset for the wiki is UTF-8, so if you don\'t know what charactersets are, just leave it at those values and it will probably work ;)<p>Wiki Character Set:<p><input type=\'input\' name=\'wiki_charset\' value=\'UTF-8\' size=\'100\'><p>Forum Character Set:<p><input type=\'input\' name=\'forum_charset\' value=\'ISO-8859-1\' size=\'100\'><p><input type=\'submit\' value=\'Start Install\'></form></td>\";
$this->print_footer();
}
function txt_stripslashes($t)
{
if ( get_magic_quotes_gpc() ) {
$t = stripslashes($t);
}
return $t;
}
function clean_value($val) {
$val = str_replace( \" \", \" \", $val );
$val = str_replace( \"&\" , \"&\" , $val );
$val = str_replace( \"<!--\" , \"<!--\" , $val );
$val = str_replace( \"-->\" , \"-->\" , $val );
$val = preg_replace( \"/<script/i\" , \"<script\" , $val );
$val = str_replace( \">\" , \">\" , $val );
$val = str_replace( \"<\" , \"<\" , $val );
$val = str_replace( \"\\\"\" , \""\" , $val );
$val = preg_replace( \"/\\n/\" , \"<br />\" , $val ); // Convert literal newlines
$val = preg_replace( \"/\\\\\\$/\" , \"$\" , $val );
$val = preg_replace( \"/\\r/\" , \"\" , $val ); // Remove literal carriage returns
$val = str_replace( \"!\" , \"!\" , $val );
$val = str_replace( \"\'\" , \"'\" , $val ); // IMPORTANT: It helps to increase sql query safety.
$val = $this->txt_stripslashes ($val);
$val = preg_replace( \"/\\\\\\(?!&#|\\?#)/\", \"\\", $val );
return $val;
}
function check_entries() {
$this->ipb_root_path = $_POST[\'ipb_path\'];
$this->ipb_forum_url = $_POST[\'ipb_forum_url\'];
$this->wiki_charset = $_POST[\'wiki_charset\'];
$this->forum_charset = $_POST[\'forum_charset\'];
if ( !is_dir ($this->ipb_root_path) ) {
$this->print_top (\'Configuration Error.\');
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>The directory \" . $this->ipb_root_path . \" does not exist.<BR>Click the below button to go back to the entry screen where you can correct the path.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
}
// check if it is the invision power board directory they passed us on...
if ( !file_exists ($this->ipb_root_path . \"conf_global.php\")) {
// check if it is the vbulletin directory they passed us on...
if ( !file_exists ($this->ipb_root_path . \"includes/config.php\")) {
// check if simple machine forums...
if ( !file_exists ($this->ipb_root_path . \"Settings.php\")) {
$this->print_top (\'Configuration Error.\');
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>The file \" . $this->ipb_root_path . \"conf_global.php or includes/config.php or Settings.php does not exist.<BR>Click the below button to go back to the entry screen where you can correct the path.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
} else {
$this->is_smf = 1;
$this->is_ipb = 0;
$this->is_vb = 0;
}
} else {
$this->is_ipb = 0;
$this->is_vb = 1;
$this->is_smf = 0;
}
} else {
$this->is_ipb = 1;
$this->is_vb = 0;
$this->is_smf = 0;
}
// check if the charactersets are known charactersets...
if ( !array_key_exists( strtolower($this->wiki_charset), $this->decode_charsets ) ) {
$this->print_top (\'Configuration Error.\');
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>The wiki characterset \" . $this->wiki_charset . \" does not exist or is unsupported.<BR>Click the below button to go back to the entry screen where you can correct the characterset.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
}
if ( !array_key_exists( strtolower($this->forum_charset), $this->decode_charsets ) ) {
$this->print_top (\'Configuration Error.\');
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>The forum characterset \" . $this->forum_charset . \" does not exist or is unsupported.<BR>Click the below button to go back to the entry screen where you can correct the characterset.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
}
$this->print_top (\"Installing...\");
// determine Server
// URL of the Wiki server. It will be automatically built including https mode
$this->wgServer = \'\';
if( isset( $_SERVER[\'SERVER_NAME\'] ) ) {
$wgServerName = $_SERVER[\'SERVER_NAME\'];
} elseif( isset( $_SERVER[\'HOSTNAME\'] ) ) {
$wgServerName = $_SERVER[\'HOSTNAME\'];
} elseif( isset( $_SERVER[\'HTTP_HOST\'] ) ) {
$wgServerName = $_SERVER[\'HTTP_HOST\'];
} elseif( isset( $_SERVER[\'SERVER_ADDR\'] ) ) {
$wgServerName = $_SERVER[\'SERVER_ADDR\'];
} else {
$wgServerName = \'localhost\';
}
# check if server use https:
$wgProto = (isset($_SERVER[\'HTTPS\']) && $_SERVER[\'HTTPS\'] == \'on\') ? \'https\' : \'http\';
$this->wgServer = $wgProto.\'://\' . $wgServerName;
# If the port is a non-standard one, add it to the URL
if( isset( $_SERVER[\'SERVER_PORT\'] )
&& !strpos( $wgServerName, \':\' )
&& ( ( $wgProto == \'http\' && $_SERVER[\'SERVER_PORT\'] != 80 )
|| ( $wgProto == \'https\' && $_SERVER[\'SERVER_PORT\'] != 443 ) ) ) {
$this->wgServer .= \":\" . $_SERVER[\'SERVER_PORT\'];
}
// Invision Power Board?
if ($this->is_ipb == 1) {
// add IpbWiki Plugin...
require_once($this->ipb_root_path . \"conf_global.php\");
}
// reset flag & counters...
$settings_found = false;
$settings_added = false;
$i = 0;
$j = 0;
$this->add_row (\"Appending IpbWiki processing to LocalSettings.php...\");
$fp = fopen(\"LocalSettings.php\", \'r\');
while( !feof($fp) )
{
$str = fgets($fp);
$temppie = preg_replace( \"#wgDBServer\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDBServer=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgDBname\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDBname=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgDBuser\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDBuser=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgDBpassword\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDBpassword=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgDBprefix\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDBprefix=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgStylePath\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgStylePath=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgScriptPath\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgScriptPath=\'\\\\1\'\", $str );
$temppie = preg_replace( \"#wgDefaultSkin\\s*=\\s*\\\"(.*?)\\\";#ie\", \"\\$this->wgDefaultSkin=\'\\\\1\'\", $str );
if (trim($str) === \"# Use IPBWiki Authentication\") {
$settings_found = true;
}
if (trim($str) === \"require_once(\'extensions/ipbwiki/IpbWiki_AuthPlugin.php\');\") {
$str = \"require_once(\'extensions/ipbwiki/ipbwiki_authplugin.php\');\\n\";
}
if (trim($str) === \'?>\') {
// end of php found, let\'s add the IPBWIKI Settings...
if (!$settings_found) {
$settings_added = 1;
$arr[$i++] = \"# The settings below were automatically added by the IpbWiki installer.\\n\";
$arr[$i++] = \"# If you make manual changes, please keep track in case you need to\\n\";
$arr[$i++] = \"# recreate them later.\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \"# Use IPBWiki Authentication\\n\";
$arr[$i++] = \"require_once(\'ipbwiki_interface.php\');\\n\";
$arr[$i++] = \"require_once(\'extensions/ipbwiki/ipbwiki_authplugin.php\');\\n\";
$arr[$i++] = \"\\$wgAuth = new AuthPlugin_ipbwiki(\\$wgGroupPermissions);\\n\";
$arr[$i++] = \"\\$wgWhitelistRead = array (\\\"Special:Userlogin\\\", \\\"Special:Userlogout\\\");\\n\";
$arr[$i++] = \"\\n\";
}
}
$arr[$i++] = $str;
}
if (!$settings_found and !$settings_added) { // MediaWiki 1.10 fix (localsettings isn\'t closed nicely with end php tag)
$arr[$i++] = \"# The settings below were automatically added by the IpbWiki installer.\\n\";
$arr[$i++] = \"# If you make manual changes, please keep track in case you need to\\n\";
$arr[$i++] = \"# recreate them later.\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \"# Use IPBWiki Authentication\\n\";
$arr[$i++] = \"require_once(\'ipbwiki_interface.php\');\\n\";
$arr[$i++] = \"require_once(\'extensions/ipbwiki/ipbwiki_authplugin.php\');\\n\";
$arr[$i++] = \"\\$wgAuth = new AuthPlugin_ipbwiki(\\$wgGroupPermissions);\\n\";
$arr[$i++] = \"\\$wgWhitelistRead = array (\\\"Special:Userlogin\\\", \\\"Special:Userlogout\\\");\\n\";
$arr[$i++] = \"\\n\";
}
fclose($fp);
$this->wgStylePath = str_replace (\'$wgScriptPath\', $this->wgScriptPath, $this->wgStylePath);
if (!$this->wgDefaultSkin or $this->wgDefaultSkin === \'\') {
$this->wgDefaultSkin = \'monobook\';
}
// Invision Power Board?
if ($this->is_ipb == 1) {
$this->ipb30 = 0;
$this->ipb_forum_url = $INFO[\'board_url\'];
// connect to the ipb db
if (file_exists($this->ipb_root_path.\'ipbwiki_db.php\')) {
chdir ($this->ipb_root_path);
define (\'IPBWIKI\',1);
require_once($this->ipb_root_path.\'ipbwiki_db.php\');
$DB = new ipbwiki_db;
chdir(WRK_DIR);
$this->ipb30 = 1;
} else if (file_exists($this->ipb_root_path.\'ips_kernel/\'.\'class_db_\'.strtolower($INFO[\'sql_driver\']).\".php\")) { // IPB 2.x
$INFO[\'sql_driver\'] = !$INFO[\'sql_driver\'] ? \'mysql\' : $INFO[\'sql_driver\'];
require ($this->ipb_root_path.\'ips_kernel/\'.\'class_db_\'.strtolower($INFO[\'sql_driver\']).\".php\" );
if (file_exists($this->ipb_root_path.\'converge_local/converge.php\')) { // IPB 2.2+
$classname = \"db_driver_\".$INFO[\'sql_driver\'];
$DB = new $classname;
} else {
$DB = new db_driver;
}
$DB->obj[\'sql_database\'] = $INFO[\'sql_database\'];
$DB->obj[\'sql_user\'] = $INFO[\'sql_user\'];
$DB->obj[\'sql_pass\'] = $INFO[\'sql_pass\'];
$DB->obj[\'sql_host\'] = $INFO[\'sql_host\'];
$DB->obj[\'sql_tbl_prefix\'] = $INFO[\'sql_tbl_prefix\'];
$DB->obj[\'use_shutdown\'] = 0;
$DB->obj[\'query_cache_file\'] = $this->ipb_root_path.\'sources/sql/\'.strtolower($INFO[\'sql_driver\']).\'_queries.php\';
$DB->obj[\'debug\'] = 0;
$DB->connect();
} else {
$INFO[\'sql_driver\'] = !$INFO[\'sql_driver\'] ? \'mysql\' : $INFO[\'sql_driver\'];
require ( $this->ipb_root_path.\'sources/Drivers/\'.$INFO[\'sql_driver\']).\".php\";
$DB = new db_driver;
$DB->obj[\'sql_database\'] = $INFO[\'sql_database\'];
$DB->obj[\'sql_user\'] = $INFO[\'sql_user\'];
$DB->obj[\'sql_pass\'] = $INFO[\'sql_pass\'];
$DB->obj[\'sql_host\'] = $INFO[\'sql_host\'];
$DB->obj[\'sql_tbl_prefix\'] = $INFO[\'sql_tbl_prefix\'];
$DB->connect();
}
$ibf_prefix = $INFO[\'sql_tbl_prefix\'];
// connect to the wiki database...
if( version_compare( PHP_VERSION, \'4.2.0\', \'ge\' ) ) {
$wikiDB = mysql_connect( $this->wgDBServer, $this->wgDBuser, $this->wgDBpassword, true );
} else {
# On PHP 4.1 the new_link parameter is not available. We cannot
# guarantee that we\'ll actually get a new connection, and this
# may cause some operations to fail possibly.
$wikiDB = mysql_connect( $this->wgDBServer, $this->wgDBuser, $this->wgDBpassword );
}
if ( $wikiDB == false ) {
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>Cannot connect to mysql server \" . $this->wgDBServer . \" with user \".$this->wgDBuser.\"<BR>Check your LocalSettings.php file and then try again.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
} else {
$success = mysql_select_db( $this->wgDBname, $wikiDB );
if ( !$success ) {
echo \"<td><p><form method=\'post\' action=\'?act=re-entry\'><input type="hidden" name="_visit_cookie" value="4e2483ded01750791eae72f157cc9455" /><B>Cannot connect to database \" . $this->wgDBname . \"<BR>Check your LocalSettings.php file and then try again.<p><input type=\'submit\' value=\'Try Again\'></form></td>\";
$this->print_footer();
return;
}
}
// Enlarge the ug_group column to allow bigger member group titles
$this->add_row (\"Enlarge member group storage...\");
$sql = \"ALTER TABLE \". $this->wgDBprefix .\"user_groups MODIFY ug_group VARCHAR(100)\";
$query_id = mysql_query ($sql , $wikiDB) or die(\"Unable to alter user_groups table... - MySQL Error: \" . mysql_error());
// determine the invision power board groups
$cond = \'\';
$DB->query (\"SELECT g_title FROM \".$ibf_prefix.\"groups\");
while ($group = $DB->fetch_row()) {
$cond .= \" AND ug_group <> \'\".$group[\'g_title\'].\"\'\";
}
// clear the user groups in the wiki if they use the old permission system
$query_id = mysql_query (\"DELETE FROM \" . $this->wgDBprefix . \"user_groups WHERE 1=1\".$cond, $wikiDB) or die(\"Unable to delete old usergroups... - MySQL Error: \" . mysql_error());
// let\'s fix the user groups to the new permission system
$query_id = mysql_query (\"SELECT u.user_id, u.user_name FROM \" . $this->wgDBprefix . \"user u LEFT JOIN \" . $this->wgDBprefix . \"user_groups ug ON u.user_id=ug.ug_user WHERE ug_user IS NULL\", $wikiDB) or die(\"Unable to query for the users without user_groups - MySQL Error: \" . mysql_error());
$row = mysql_fetch_array($query_id);
while ($row) {
$user_name = utf8_decode($row [\'user_name\']);
$user_name = $this->clean_value($user_name);
if ($this->ipb30 == 1)
{
$DB->query (\"SELECT member_group_id as mgroup,posts FROM \".$ibf_prefix.\"members WHERE name=\'\".$user_name.\"\'\");
} else {
$DB->query (\"SELECT mgroup,posts FROM \".$ibf_prefix.\"members WHERE name=\'\".$user_name.\"\'\");
}
if ($group = $DB->fetch_row()) {
$DB->query (\"SELECT ig.*,g.g_title FROM \".$ibf_prefix.\"ipbwiki_group ig JOIN \".$ibf_prefix.\"groups g ON g.g_id = ig.g_id WHERE ig.g_id=\".$group[\'mgroup\'].\" AND ig.posts <= \".$group[\'posts\'].\" ORDER BY posts DESC\");
if ($group = $DB->fetch_row()) {
if ($group[\'posts\'] > 0) {
$groupname = $group[\'g_title\'] . \" (\".$group[\'posts\'].\"+ posts)\";
} else {
$groupname = $group[\'g_title\'];
}
mysql_query (\"INSERT INTO \" . $this->wgDBprefix . \"user_groups (ug_user,ug_group) VALUES (\" . $row[\'user_id\'] . \",\'\" . $groupname . \"\')\", $wikiDB) or die(\"Unable to insert user_group - MySQL Error: \" . mysql_error());
}
}
$row = mysql_fetch_array($query_id);
}
// let\'s set up the fix for monobook...
$query_id = mysql_query (\"SELECT * FROM \" . $this->wgDBprefix . \"page WHERE page_title=\'Monobook.css\'\", $wikiDB) or die(\"Unable to query for the page id for monobook.css - MySQL Error: \" . mysql_error());
$row = mysql_fetch_array($query_id);
if ($row) {
$query_id = mysql_query (\"SELECT * FROM \" . $this->wgDBprefix . \"searchindex WHERE si_page=\".$row[\'page_id\'], $wikiDB) or die(\"Unable to query for the searchindex for monobook.css - MySQL Error: \" . mysql_error());
$row2 = mysql_fetch_array($query_id);
if ($row2) {
$query_id = mysql_query (\"UPDATE \".$this->wgDBprefix .\"searchindex SET si_title = \'monobook css\', si_text = \' spoilertop background #e4eaf2 url no-repeat right; border 1px dotted #000; color #000; width 90 ; font-weight bold; font-size 10px; margin 8px auto 0 auto; padding 4px; spoilermain background #fafcfe; border 1px dotted #000; border-top 0; color #465584; width 90 ; padding 4px; margin 0 auto 8px auto; quotetop background #e4eaf2 url no-repeat right; border 1px dotted #000; border-bottom 0; border-left 4px solid #8394b2; color #000; font-weight bold; font-size 10px; margin 8px auto 0 auto; padding 3px; quotemain background #fafcfe; border 1px dotted #000; border-left 4px solid #8394b2; border-top 0; color #465584; padding 4px; margin 0 auto 8px auto; codetop sqltop htmltop background #fddbcc url no-repeat right; color #000; font-weight bold; margin 0 auto 0 auto; padding 3px; width 98 ; codemain sqlmain htmlmain background #fafcfe; border 1px dotted #000; color #465584; font-family courier courier new verdana arial; margin 0 auto 0 auto; padding 2px; width 98 ; textmain font-family courier courier new verdana arial;\' WHERE si_page = \".$row[\'page_id\'], $wikiDB) or die(\"Unable to update the searchindex for monobook.css - MySQL Error: \" . mysql_error());
} else {
$query_id = mysql_query (\"INSERT INTO \".$this->wgDBprefix .\"searchindex (si_page, si_title, si_text) VALUES (\".$row[\'page_id\'].\",\'monobook css\',\' spoilertop background #e4eaf2 url no-repeat right; border 1px dotted #000; color #000; width 90 ; font-weight bold; font-size 10px; margin 8px auto 0 auto; padding 4px; spoilermain background #fafcfe; border 1px dotted #000; border-top 0; color #465584; width 90 ; padding 4px; margin 0 auto 8px auto; quotetop background #e4eaf2 url no-repeat right; border 1px dotted #000; border-bottom 0; border-left 4px solid #8394b2; color #000; font-weight bold; font-size 10px; margin 8px auto 0 auto; padding 3px; quotemain background #fafcfe; border 1px dotted #000; border-left 4px solid #8394b2; border-top 0; color #465584; padding 4px; margin 0 auto 8px auto; codetop sqltop htmltop background #fddbcc url no-repeat right; color #000; font-weight bold; margin 0 auto 0 auto; padding 3px; width 98 ; codemain sqlmain htmlmain background #fafcfe; border 1px dotted #000; color #465584; font-family courier courier new verdana arial; margin 0 auto 0 auto; padding 2px; width 98 ; textmain font-family courier courier new verdana arial; \');\", $wikiDB) or die(\"Unable to query for the searchindex for monobook.css - MySQL Error: \" . mysql_error());
}
// don\'t bother about history, just update the last instance of the page in the text table...
$query_id = mysql_query (\"SELECT * FROM \" . $this->wgDBprefix . \"revision WHERE rev_id=\".$row[\'page_latest\'], $wikiDB) or die(\"Unable to query for the searchindex for monobook.css - MySQL Error: \" . mysql_error());
$row3 = mysql_fetch_array($query_id);
if ($row3) {
$query_id = mysql_query (\"UPDATE \".$this->wgDBprefix .\"text SET old_text=\'.spoilertop{\\n background: #E4EAF2 url(\".$INFO[\'board_url\'].\"/style_images/1/css_img_spoiler.gif) no-repeat right;\\n border: 1px dotted #000;\\n color: #000;\\n width: 90%;\\n font-weight: bold;\\n font-size: 10px;\\n margin: 8px auto 0 auto;\\n padding: 4px;\\n}\\n\\n.spoilermain{\\n background: #FAFCFE;\\n border: 1px dotted #000;\\n border-top: 0;\\n color: #465584;\\n width: 90%;\\n padding: 4px;\\n margin: 0 auto 8px auto;\\n}\\n\\n.quotetop{\\n background: #E4EAF2 url(\".$INFO[\'board_url\'].\"/style_images/1/css_img_quote.gif) no-repeat right;\\n border: 1px dotted #000;\\n border-bottom: 0;\\n border-left: 4px solid #8394B2;\\n color: #000;\\n font-weight: bold;\\n font-size: 10px;\\n margin: 8px auto 0 auto;\\n padding: 3px;\\n}\\n\\n.quotemain{\\n background: #FAFCFE;\\n border: 1px dotted #000;\\n border-left: 4px solid #8394B2;\\n border-top: 0;\\n color: #465584;\\n padding: 4px;\\n margin: 0 auto 8px auto;\\n}\\n\\n.codetop,\\n.sqltop,\\n.htmltop{\\n background: #FDDBCC url(\".$INFO[\'board_url\'].\"/style_images/1/css_img_code.gif) no-repeat right;\\n color: #000;\\n font-weight: bold;\\n margin: 0 auto 0 auto;\\n padding: 3px;\\n width: 98%;\\n}\\n\\n.codemain,\\n.sqlmain,\\n.htmlmain{\\n background: #FAFCFE;\\n border: 1px dotted #000;\\n color: #465584;\\n font-family: Courier, Courier New, Verdana, Arial;\\n margin: 0 auto 0 auto;\\n padding: 2px;\\n width: 98%;\\n}\\n\\n.textmain{\\n font-family: Courier, Courier New, Verdana, Arial;\\n}\' WHERE old_id=\".$row3[\'rev_text_id\'], $wikiDB) or die(\"Unable to set up the text table for monobook.css - MySQL Error: \" . mysql_error());
}
}
// clear the cache...
$query_id = mysql_query (\"DELETE FROM \" . $this->wgDBprefix . \"objectcache\", $wikiDB) or die(\"Unable to clear the object cache - MySQL Error: \" . mysql_error());
}
if (! $settings_found or $settings_added) {
$fp = fopen(\"LocalSettings.php\", \'w\');
while ($j <= $i) {
fwrite ($fp, $arr[$j++]);
}
fclose ($fp);
} else {
$this->add_row (\'Info: LocalSettings.php was already modified for IpbWiki. Settings not reapplied.\');
}
// Add the rating table
$this->add_row (\"Create rating table...\");
$sql = \"CREATE TABLE IF NOT EXISTS \". $this->wgDBprefix .\"rating (
id int(11) unsigned NOT NULL auto_increment,
page_id int(8) NOT NULL default 0,
user_id int(5) NULL,
ip varchar(20) NULL,
rating tinyint(1) NOT NULL default 0,
PRIMARY KEY (id) )
ENGINE=InnoDB;\";
$query_id = mysql_query ($sql , $wikiDB) or die(\"Unable to create rating table... - MySQL Error: \" . mysql_error());
// reset flag & counters...
$settings_found = false;
$fixed_skincode = false;
$abstract_skin = false;
$i = 0;
$j = 0;
$this->add_row (\"Appending IpbWiki processing to includes/Skin.php...\");
$fp = fopen(\"includes/Skin.php\", \'r\');
while( !feof($fp) )
{
$str = fgets($fp);
if (trim($str) === \"// IpbWiki Low Level Skin Interface\") {
$settings_found = true;
}
if (trim($str) === \"abstract class Skin extends ContextSource {\") {
//MW 1.18+
$str = \"abstract class Skin_Orig extends ContextSource {\\n\";
$abstract_skin = true;
}
if (trim($str) === \"class Skin extends Linker {\") {
$str = \"class Skin_Orig extends Linker {\\n\";
}
if (trim($str) === \"function Skin() { parent::Linker(); }\") {
$str = \"function Skin_Orig() { parent::Linker(); }\\n\";
}
if (trim($str) === \'$s .= $wgAuth->get_extra_css_styles();\') {
$fixed_skincode = true;
$str = \" \\$s .= \\$wgAuth->ipbwiki->get_extra_css_styles();\\n\";
}
if (trim($str) === \'?>\') {
$str = \'\'; // MediaWiki 1.11 fix
}
$arr[$i++] = $str;
}
fclose($fp);
// let\'s add the IPBWIKI Settings...
if (!$settings_found) {
$arr[$i++] = \"\\n\";
$arr[$i++] = \"// IpbWiki Low Level Skin Interface\\n\";
$arr[$i++] = \"\\n\";
if ($abstract_skin) {
//MW 1.18+
$arr[$i++] = \" abstract class Skin extends Skin_Orig {\\n\";
} else {
$arr[$i++] = \" class Skin extends Skin_Orig {\\n\";
}
$arr[$i++] = \"\\n\";
$arr[$i++] = \" /** Constructor, call parent constructor */\\n\";
$arr[$i++] = \" function Skin_Orig() {\\n\";
$arr[$i++] = \" parent::Skin(); \\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" function getPoweredBy() {\\n\";
$arr[$i++] = \" global \\$wgScriptPath;\\n\";
$arr[$i++] = \" global \\$wgAuth;\\n\";
$arr[$i++] = \" \\$img = parent::getPoweredBy();\\n\";
$arr[$i++] = \" \\$url = htmlspecialchars( \\\"\\$wgScriptPath/extensions/ipbwiki/linkedby_ipbwiki.png\\\" );\\n\";
$arr[$i++] = \" \\$img2 = \'<a href=\\\"http://www.ipbwiki.com/\\\"><img src=\\\"\'.\\$url.\'\\\" alt=\\\"IpbWiki\\\" /></a>\';\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" if (class_exists (\'ipbwiki\')) {\\n\";
$arr[$i++] = \" \\$show = true;\\n\";
$arr[$i++] = \" \\$copyrr = \\$wgAuth->ipbwiki->ipbwiki->copyrr;\\n\";
$arr[$i++] = \" if ((strlen (\\$copyrr) == 9) and\\n\";
$arr[$i++] = \" (is_numeric (\\$copyrr))) {\\n\";
$arr[$i++] = \" \\$license_part1 = substr (\\$copyrr,0,7);\\n\";
$arr[$i++] = \" \\$license_part2 = substr (\\$copyrr,7,2);\\n\";
$arr[$i++] = \" \\$remainder = strval(intval(\\$license_part1) % 88);\\n\";
$arr[$i++] = \" if (\\$remainder == \\$license_part2) {\\n\";
$arr[$i++] = \" \\$show = false;\\n\";
$arr[$i++] = \" } \\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" if (\\$show) {\\n\";
$arr[$i++] = \" return \\$img2 . \\$img;\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return \\$img;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return \\$img;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } \\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" function reallyDoGetUserStyles() {\\n\";
$arr[$i++] = \" global \\$wgAuth;\\n\";
$arr[$i++] = \" \\$s = parent::reallyDoGetUserStyles();\\n\";
$arr[$i++] = \" \\$s .= \\$wgAuth->ipbwiki->get_extra_css_styles();\\n\";
$arr[$i++] = \" return \\$s;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"?>\"; // nice close
} else {
if (!$fixed_skincode) {
$this->add_row (\'Info: Skin.php was already modified for IpbWiki. Settings not reapplied.\');
} else {
$this->add_row (\'Applied bugfix to Skin.php\');
}
}
// write the skin file...
$fp = fopen(\"includes/Skin.php\", \'w\');
while ($j <= $i) {
fwrite ($fp, $arr[$j++]);
}
fclose ($fp);
// reset flag & counters...
$settings_found = false;
$fix_to_be_applied_for_railroad_sign = true;
$fixed_usercode = false;
$fixed_user_mwbug = false;
$fix_applied_for_railroad_sign = false;
$fix153 = 0;
$i = 0;
$j = 0;
$k = 0;
$this->add_row (\"Appending IpbWiki processing to includes/User.php...\");
$fp = fopen(\"includes/User.php\", \'r\');
while( !feof($fp) )
{
$str = fgets($fp);
if (trim($str) === \"// IpbWiki Low Level User Interface\") {
$settings_found = true;
}
if (trim($str) === \"class User {\") {
$str = \"class User_Orig {\\n\";
}
if ((trim($str) === \"function User() {\") or (trim($str) === \"function User() {\")) {
$str = \" function User_Orig() {\\n\";
}
if (trim($str) === \'if ($name === $wgAuth->ipbwiki->ipbwiki->clean_username($this->mName)) {\') {
$str = \" if (\\$this->mName === \\$wgAuth->ipbwiki->ipbwiki->clean_username(\\$this->mName)) {\\n\";
$fixed_usercode = true;
}
if (substr(trim($str),0,95) === \'$query_id = mysql_query (\"SELECT * FROM \" . $wgDBprefix . \"user WHERE LOWER(user_name) = LOWER(\') {
$str = \" \\$query_id = mysql_query (\\\"SELECT * FROM \\\" . \\$wgDBprefix . \\\"user WHERE LOWER(user_name) = LOWER(\'\\\" . \\$this->mName . \\\"\')\\\", \\$dbr->mConn) or die(\\\"IpbWiki - addToDatabase - MySQL Error: \\\" . mysql_error());\\n\";
}
if (trim($str) === \"// it\'s either this hack or modifying a lot of files... :(\") {
$k = $k + 1;
}
if ((trim($str) === \'global $wgAuth;\') and ($k == 1)) {
$k = $k + 1;
}
if ((trim($str) === \'global $wgDBprefix;\') and ($k == 2)) {
$k = 0;
}
if ((trim($str) !== \'global $wgAuth;\') and ($k == 2)) {
$arr[$i++] = \" global \\$wgDBprefix;\\n\";
$k = 0;
}
if (trim($str) === \'$row = mysql_fetch_array(1);\') {
$str = \" \\$row = mysql_fetch_array(\\$query_id);\\n\";
}
/* fix is deprecated now, was only needed for 1.6.1 till 1.6.3 or sth like that...
if (trim($str) === \'if ( $val != $sessionToken ) {\') {
$str = \" if ( \\$val != \\$sessionToken and \\$wgSessionsInMemcached ) { // IpbWiki Installer: Mediawiki Bugfix\\n\";
$fixed_user_mwbug = true;
} */
if (trim($str) === \'$wgAuth->ipbwiki->ipbwiki->username_replace_special_characters_for_wiki($name);\') {
$fix_to_be_applied_for_railroad_sign = false;
}
if (trim($str) === \'$name = ucfirst($name);\') {
if ($fix_to_be_applied_for_railroad_sign) {
$fix_applied_for_railroad_sign = true;
$arr[$i++] = \" \\$wgAuth->ipbwiki->ipbwiki->username_replace_special_characters_for_wiki(\\$name);\\n\";
$arr[$i++] = \" if (strpos(\\$name, Sanitizer::decodeChar(65283)) <> 0) {\\n\";
$arr[$i++] = \" \\$name = ucfirst(\\$name);\\n\";
$str = \" }\";
}
}
if (trim($str) === \'$query_id = $dbr->select (\\\'user\\\', array (\\\'user_id\\\'));\') {
$str = \" \\$query_id = \\$dbr->select (\'user\', array (\'user_id\'), array (\'user_name\' => \\$this->mName));\\n\";
$fixed_usercode = true;
}
if (substr(trim($str),0,6) === \'self::\') {
$str = str_ireplace(\"self::\", \"User::\", $str);
}
if (trim($str) === \'if (strpos($name, Sanitizer::decodeChar(65283)) <> 0) {\') {
$str = \" if (! strpos(\\$name, Sanitizer::decodeChar(65283))) {\\n\";
}
if (trim($str) === \'$name = ucfirst($name);\') {
$str = \" \\$name = \\$wgAuth->ipbwiki->ucfirst (\\$name);\\n\";
}
if (trim($str) === \'if ($this->mName === User::clean_username($this->mName)) {\') {
$str = \" if (\\$this->mName === \\$this->clean_username(\\$this->mName)) {\\n\";
$fixed_usercode = true;
}
// fixes - IpbWiki 1.5.1
if (trim($str) === \'$name = $wgAuth->ipbwiki->ucfirst ($name);\') {
$str = \" \\$name = \\$wgAuth->ipbwiki->ucfirst (\\$name, \\$wgAuth->ipbwiki->wiki_charset);\\n\";
}
// fixes - IpbWiki 1.5.2
//$str = str_replace(\"static function\", \"function\", $str);
//Deprecate, let\'s try and fix the code rather than working around it
// fixes - IpbWiki 1.5.3
if (trim($str) === \'$u = parent::newFromName ($name, \\\'usable\\\');\') {
$fix153 = 1;
}
if ($fix153 == 1 and substr(trim($str),0,23) === \'if (is_object( $u )) {\') {
$fix153 = 999;
}
if ($fix153 == 1 and trim($str) == \'$u->mName = $name;\') {
$fix153 = 998;
$fixed_usercode = true;
$str = \" if (is_object( \\$u )) { \\$u->mName = \\$name; return \\$u; } else { return null; }\";
}
if ($fix153 == 998 and trim($str) == \'return $u;\') {
$str = \'\';
$fix153 = 999;
}
// fixes - IpbWiki 1.7
if (trim($str) === \'$name = $wgAuth->ipbwiki->ucfirst ($name, $wgAuth->ipbwiki->wiki_charset);\') {
$str = \" \\$name = \\$wgAuth->ipbwiki->ucfirst (\\$name, \\$wgAuth->ipbwiki->ipbwiki->wiki_charset);\\n\";
}
// normal processing
if (trim($str) === \'?>\') {
// Mediawiki 1.11 fix, no longer closes the file nicely...
$str = \'\';
}
$arr[$i++] = $str;
}
fclose($fp);
// let\'s add the IPBWIKI Settings to user.php...
if (!$settings_found) {
$arr[$i++] = \"\\n\";
$arr[$i++] = \"// IpbWiki Low Level User Interface\\n\";
$arr[$i++] = \"class User extends User_Orig {\\n\";
$arr[$i++] = \" // constructor\\n\";
$arr[$i++] = \" function User () {\\n\";
$arr[$i++] = \" global \\$wgVersion;\\n\";
$arr[$i++] = \" // call the parent constructor\\n\";
$arr[$i++] = \" if (version_compare(\\$wgVersion, \'1.17.0\', \'>=\')) {\\n\";
$arr[$i++] = \" return parent::__construct();\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return parent::User_Orig();\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" static function isValidUserName( \\$name ) {\\n\";
$arr[$i++] = \" // ipbwiki core class available...? (woot!)\\n\";
$arr[$i++] = \" if (class_exists (\'ipbwiki\')) {\\n\";
$arr[$i++] = \" return (\\$name === User::clean_username(\\$name));\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return parent::isValidUserName (\\$name);\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" \\n\";
$arr[$i++] = \" static function newFromName( \\$name, \\$validate = \'valid\' ) {\\n\";
$arr[$i++] = \" global \\$wgAuth;\\n\";
$arr[$i++] = \" global \\$wgVersion;\\n\";
$arr[$i++] = \" \\n\";
$arr[$i++] = \" // ipbwiki core class available...? (woot!)\\n\";
$arr[$i++] = \" if (class_exists (\'ipbwiki\')) {\\n\";
$arr[$i++] = \" \\$fname = \'User::newFromName\'; \\n\";
$arr[$i++] = \" \\$wgAuth->ipbwiki->login_name = \\$name; \\n\";
$arr[$i++] = \" \\$name = \\$wgAuth->ipbwiki->ipbwiki->get_display_name (\\$name);\\n\";
$arr[$i++] = \" \\$name = \\$wgAuth->ipbwiki->ipbwiki->unclean_value(\\$name);\\n\";
$arr[$i++] = \" \\$wgAuth->ipbwiki->ipbwiki->username_replace_special_characters_for_wiki(\\$name);\\n\";
$arr[$i++] = \" if (! strpos(\\$name, Sanitizer::decodeChar(65283))) {\\n\";
$arr[$i++] = \" \\$name = \\$wgAuth->ipbwiki->ucfirst (\\$name, \\$wgAuth->ipbwiki->ipbwiki->wiki_charset);\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" \\$wgAuth->ipbwiki->display_name = \\$name; \\n\";
$arr[$i++] = \" if (version_compare(\\$wgVersion, \'1.9.0rc1\', \'>=\')) {\\n\";
$arr[$i++] = \" \\$u = parent::newFromName (\\$name, \'usable\');\\n\";
$arr[$i++] = \" if (is_object( \\$u )) {\\n\";
$arr[$i++] = \" \\$u->mName = \\$name;\\n\";
$arr[$i++] = \" return \\$u;\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return null;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" \\$u = new User();\\n\";
$arr[$i++] = \" \\$u->setName( \\$name );\\n\";
$arr[$i++] = \" \\$dbr =& wfGetDB( DB_SLAVE );\\n\";
$arr[$i++] = \" \\$s = \\$dbr->selectRow( \'user\', array( \'user_id\' ), array( \'user_name\' => \\$name ), \\$fname );\\n\";
$arr[$i++] = \" \\$u->setId (\\$s->user_id);\\n\";
$arr[$i++] = \" return \\$u;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" \\$u = parent::newFromName (\\$name, \\$validate);\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" return \\$u;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" function addToDatabase() {\\n\";
$arr[$i++] = \" // this isn\'t the nicest way to solve the username problem, but there are several direct calls not passing through the user object. \\n\";
$arr[$i++] = \" // it\'s either this hack or modifying a lot of files... :(\\n\";
$arr[$i++] = \" global \\$wgAuth;\\n\";
$arr[$i++] = \" global \\$wgDBprefix;\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" if (class_exists (\'ipbwiki\')) {\\n\";
$arr[$i++] = \" \\$dbr =& wfGetDB( DB_SLAVE );\\n\";
$arr[$i++] = \" if (\\$this->mName === \\$this->clean_username(\\$this->mName)) {\\n\";
$arr[$i++] = \" \\$query_id = \\$dbr->select (\'user\', array (\'user_id\'), array (\'user_name\' => \\$this->mName));\\n\";
$arr[$i++] = \" \\$row = \\$dbr->fetchObject( \\$query_id ) ;\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" if (! \\$row) {\\n\";
$arr[$i++] = \" return parent::addToDatabase();\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" \\$this->mId = \\$row->user_id; \\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" \\$this->mId = 0;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return parent::addToDatabase();\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" \\n\";
$arr[$i++] = \" static function clean_username (\\$val) {\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\">\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\">\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\">\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\"<\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\"<\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\"<\\\" , \\\" \\\" , \\$val );\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\"\'\\\" , \\\" \\\" , \\$val ); // IMPORTANT: It helps to increase sql query safety.\\n\";
$arr[$i++] = \" \\$val = str_replace( \\\"'\\\" , \\\" \\\" , \\$val ); \\n\";
$arr[$i++] = \" return \\$val;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" \\n\";
$arr[$i++] = \" static function isUsableName (\\$name) {\\n\";
$arr[$i++] = \" if (class_exists (\'ipbwiki\')) {\\n\";
$arr[$i++] = \" return User::isValidUserName (\\$name);\\n\";
$arr[$i++] = \" } else {\\n\";
$arr[$i++] = \" return parent::isUsableName (\\$name);\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" } \\n\";
$arr[$i++] = \"}\\n\";
$arr[$i++] = \"?>\"; // nice close of php file...
} else {
if ($fixed_usercode) {
$this->add_row (\'User.php: bugfix applied.\');
} else {
$this->add_row (\'Info: User.php was already modified for IpbWiki. Settings not reapplied.\');
}
}
if ($fixed_user_mwbug) {
$this->add_row (\'User.php: fixed Mediawiki 1.6.x bug.\');
}
if ($fix_applied_for_railroad_sign) {
$this->add_row (\'User.php: applied fix for #.\');
}
// write the user file...
$fp = fopen(\"includes/User.php\", \'w\');
while ($j <= $i) {
fwrite ($fp, $arr[$j++]);
}
fclose ($fp);
// reset flag & counters...
$settings_found = false;
$i = 0;
$j = 0;
$function_found = false;
$fix_applied = false;
$this->add_row (\"Appending IpbWiki processing to includes/SkinTemplate.php...\");
$fp2 = fopen(\"includes/SkinTemplate.php\", \'r\');
while( !feof($fp2) )
{
$str = fgets($fp2);
if (trim($str) === \"// IpbWiki Low Level SkinTemplate Interface\") {
$settings_found = true;
} else if (trim($str) === \"class SkinTemplate extends Skin {\") {
$str = \"class SkinTemplate_Orig extends Skin {\\n\";
} else if (trim($str) === \'function html( $str ) {\') {
$function_found = true;
} else if ($function_found and !$fix_applied and (trim($str) === \"wfRunHooks( \'BeforeDisplayArticle\');\")) {
$this->add_row (\"hook fix already applied\");
$fix_applied = true;
} else if ($function_found and !$fix_applied and (trim($str) === \'echo $this->data[$str];\')) {
$arr[$i++] = \" if (\\$str == \'subtitle\') {\\n\";
$arr[$i++] = \" wfRunHooks( \'BeforeDisplayArticle\');\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" echo \\$this->data[\\$str];\\n\";
$arr[$i++] = \" if (\\$str == \'bodytext\') {\\n\";
$arr[$i++] = \" wfRunHooks( \'AfterDisplayArticle\');\\n\";
$str = \" }\\n\";
} else if (trim($str) === \'?>\') {
$str = \'\'; // MediaWiki 1.11+ fix
}
$arr[$i++] = $str;
}
$arr[$i] = \"\";
fclose($fp2);
// let\'s add the IPBWIKI Settings...
if (!$settings_found) {
$arr[$i++] = \"\\n\";
$arr[$i++] = \"// IpbWiki Low Level SkinTemplate Interface\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" class SkinTemplate extends SkinTemplate_Orig {\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \" function makeTalkUrlDetails( \\$name, \\$urlaction=\'\' ) {\\n\";
$arr[$i++] = \" global \\$wgTitleCache;\\n\";
$arr[$i++] = \" global \\$wgAuth;\\n\";
$arr[$i++] = \" \\$title = Title::newFromText( \\$name );\\n\";
$arr[$i++] = \" if (\\$title) {\\n\";
$arr[$i++] = \" return parent::makeTalkUrlDetails (\\$name, \\$urlaction);\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"}\\n\";
$arr[$i++] = \"?>\"; // nice close...
} else {
$this->add_row (\'Info: SkinTemplate.php was already modified for IpbWiki. Settings not reapplied.\');
}
// write the SkinTemplate file...
$fp2 = fopen(\"includes/SkinTemplate.php\", \'w\');
while ($j < $i) {
fwrite ($fp2, $arr[$j++]);
}
fclose ($fp2);
// reset flag & counters...
$settings_found = false;
$settings_added = false;
$prev_str = \'\';
$i = 0;
$j = 0;
$this->add_row (\"Appending IpbWiki processing to includes/EditPage.php...\");
$fp2 = fopen(\"includes/EditPage.php\", \'r\');
while( !feof($fp2) )
{
$str = fgets($fp2);
if (trim($str) === \"// IpbWiki Low Level EditPage Interface\") {
$settings_found = true;
}
if (trim($str) === \"class EditPage {\") {
$str = \"class EditPage_Orig {\\n\";
}
if (trim($str) === \"private function getContent() {\") {
$str = \" protected function getContent() {\\n\";
}
if (trim($str) === \'function EditPage( $article ) {\') {
$str = \" function EditPage_Orig ( \\$article ) {\\n\";
}
if (trim($str) === \"private function getContent( \\$def_text = \'\' ) {\") {
$str = \" function getContent( \\$def_text = \'\' ) {\\n\";
$settings_added = true;
}
if ((trim($str) === \'$text = parent::getContent();\') and (trim($prev_str) === \'global $wgRequest;\')) {
$settings_added = true;
$arr[$i++] = \" global \\$wgServer;\\n\";
$arr[$i++] = \" global \\$wgArticlePath;\\n\";
}
if ((trim($str) === \'$cat = explode(\";\",$categories);\') and (trim($prev_str) === \"\\$categories = \\$wgRequest->getVal (\'categories\');\")) {
$settings_added = true;
$arr[$i++] = \" \\$namespace = \\$wgRequest->getVal (\'namespace\');\\n\";
$arr[$i++] = \" \\$title = \\$wgRequest->getval(\'title\');\\n\";
$arr[$i++] = \" if (\\$namespace <> \'\') {\\n\";
$arr[$i++] = \" \\$article_url = \\$wgServer . str_replace( \'\\$1\', \\$namespace.\':\'.\\$title.\'&action=edit&categories=\'.\\$categories, \\$wgArticlePath );\\n\";
$arr[$i++] = \" \\$article_url = str_replace (\'/index.php/\',\'/index.php?title=\',\\$article_url);\\n\";
$arr[$i++] = \" @header( \\\"Location: \\\".\\$article_url );\\n\";
$arr[$i++] = \" return;\\n\";
$arr[$i++] = \" }\\n\";
}
if (trim($str) === \'?>\') {
$str = \'\'; // MediaWiki 1.11+ fix
}
$arr[$i++] = $str;
$prev_str = $str;
}
$arr[$i] = \"\";
fclose($fp2);
// let\'s add the IPBWIKI Settings...
if (!$settings_found) {
$arr[$i++] = \"\\n\";
$arr[$i++] = \"// IpbWiki Low Level EditPage Interface\\n\";
$arr[$i++] = \"\\n\";
$arr[$i++] = \"class EditPage extends EditPage_Orig {\\n\";
$arr[$i++] = \" function getContent (\\$def_text = \'\') {\\n\";
$arr[$i++] = \" global \\$wgRequest;\\n\";
$arr[$i++] = \" global \\$wgServer;\\n\";
$arr[$i++] = \" global \\$wgArticlePath;\\n\";
$arr[$i++] = \" \\$text = parent::getContent(\\$def_text);\\n\";
$arr[$i++] = \" \\$categories = \\$wgRequest->getVal (\'categories\'); \\n\";
$arr[$i++] = \" \\$namespace = \\$wgRequest->getVal (\'namespace\');\\n\";
$arr[$i++] = \" \\$title = \\$wgRequest->getval(\'title\');\\n\";
$arr[$i++] = \" if (\\$namespace <> \'\') {\\n\";
$arr[$i++] = \" \\$article_url = \\$wgServer . str_replace( \'\\$1\', \\$namespace.\':\'.\\$title.\'&action=edit&categories=\'.\\$categories, \\$wgArticlePath );\\n\";
$arr[$i++] = \" \\$article_url = str_replace (\'/index.php/\',\'/index.php?title=\',\\$article_url);\\n\";
$arr[$i++] = \" @header( \\\"Location: \\\".\\$article_url );\\n\";
$arr[$i++] = \" return;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" \\$cat = explode(\\\";\\\",\\$categories);\\n\";
$arr[$i++] = \" foreach (\\$cat as \\$c) {\\n\";
$arr[$i++] = \" if (\\$c) {\\n\";
$arr[$i++] = \" \\$text .= \'[[Category:\'.\\$c.\']]\\n\';\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \" return \\$text;\\n\";
$arr[$i++] = \" }\\n\";
$arr[$i++] = \"}\\n\";
$arr[$i++] = \"?>\"; // nice close
} else {
if ($settings_added) {
$this->add_row (\'Applied patch to EditPage.php.\');
} else {
$this->add_row (\'Info: EditPage.php was already modified for IpbWiki. Settings not reapplied.\');
}
}
// write the EditPage file...
if ((!$settings_found) or ($settings_added)) {
$fp2 = fopen(\"includes/EditPage.php\", \'w\');
while ($j < $i) {
fwrite ($fp2, $arr[$j++]);
}
fclose ($fp2);
}
// reset flag & counters...
$settings_found = false;
$settings_added = false;
$prev_str = \'\';
$i = 0;
$j = 0;
$function_found = false;
$profile_out_found = false;
if (file_exists(\'includes/parser/Parser.php\'))
{
$file_name = \'includes/parser/Parser.php\';
}
else
{
$file_name = \'includes/Parser.php\';
}
$this->add_row (\"Appending IpbWiki processing to \".$file_name.\"...\");
$fp2 = fopen($file_name, \'r\');
while( !feof($fp2) )
{
$str = fgets($fp2);
if ((trim($str) === \'function replaceVariables( $text, $args = array(), $argsOnly = false ) {\') or (trim($str) === \'function replaceVariables( $text, $frame = false, $argsOnly = false ) {\' )) {
$function_found = true;
}
if ($function_found and $profile_out_found and (trim($str) === \"wfRunHooks( \'ParserBeforeStrip\', array( &\\$this, &\\$text, &\\$this->mStripState ) );\")) {
$str = \" if ( \\$this->mOutputType == OT_HTML ) { wfRunHooks( \'ParserBeforeStrip\', array( &\\$this, &\\$text, &\\$this->mStripState ) ); }\\r\\n\";
$this->add_row (\'Corrected hook fix.\');
$function_found = false;
$settings_found = true;
}
if ($function_found and (trim($str) === \"wfRunHooks( \'ParserBeforeStrip\', array( &\\$this, &\\$text, &\\$this->mStripState ) );\")) {
$function_found = false;
}
if ($function_found and (trim($str) === \"if ( \\$this->mOutputType == OT_HTML ) { wfRunHooks( \'ParserBeforeStrip\', array( &\\$this, &\\$text, &\\$this->mStripState ) ); }\")) {
$function_found = false;
}
if ($function_found and (trim($str) === \'wfProfileOut( $fname );\') || (trim($str) === \'wfProfileOut( __METHOD__ );\')) {
$profile_out_found = true;
}
if ($function_found and $profile_out_found and (trim($str) === \'return $text;\')) {
// add the extra hook call so templates get bbcode parsing and emoticon replacements...
$arr[$i++] = \" if ( \\$this->mOutputType == OT_HTML ) { wfRunHooks( \'ParserBeforeStrip\', array( &\\$this, &\\$text, &\\$this->mStripState ) ); }\\r\\n\";
$this->add_row (\'Applied hook fix.\');
$function_found = false;
$settings_found = true;
}
$arr[$i++] = $str;
}
// write the Parser.php file...
if (($settings_found) or ($settings_added)) {
$fp2 = fopen($file_name, \'w\');
while ($j <= $i) {
fwrite ($fp2, $arr[$j++]);
}
fclose ($fp2);
} else {
$this->add_row (\'Info: Parser.php was already modified for IpbWiki. Settings not reapplied.\');
}
// write ipbwiki_config.php file
$this->add_row (\"Writing ipbwiki_config.php configuration file...\");
$conf_string =
\"<?php\\n\" .
\"// IPB Wiki configuration settings\\n\" .
\"// http://www.ipbwiki.com\\n\" .
\"\\n\" .
\"/**\\n\" .
\" * The full qualified filesystem path to the folder of your IPB installation.\\n\" .
\" * You must add a trailing slash.\\n\" .
\" *\\n\" .
\" * Example path: /home/public_html/community/forums/\\n\" .
\" *\\n\" .
\" */\\n\" .
\" \\$ipb_root_path = \'\". $this->ipb_root_path . \"\';\\n\" .
\"\\n\" .
\"/**\\n\" .
\" * The url of your forum.\\n\" .
\" * You must add a trailing slash.\\n\" .
\" *\\n\" .
\" * Example path: http://www.yoursite.com/forums/\\n\" .
\" *\\n\" .
\" */\\n\" .
\" \\$ipb_forum_url = \'\". $this->ipb_forum_url . \"\';\\n\" .
\"\\n\" .
\" /* TIP: if you have your wiki and invision power board running on two different \\n\" .
\" * servers, you could try the following: \\n\" .
\" * (Note that I didn\'t test this, but in principle it should work, as long as you\'re able to authenticate to your database server from an external server that is...)\\n\" .
\" *\\n\" .
\" * on your Invision Power Board server:\\n\" .
\" * - download the file conf_global.php (located in the root of your forum directory)\\n\" .
\" * - download the file ips_kernel/class_db_mysql.php \\n\".
\" * (or if you use another database driver for your forum download the appropriate file ie ips_kernel/class_db_<your_db_driver>.php)\\n\" .
\" * - download the file sources/sql/mysql_queries.php \\n\" .
\" * (again if you use another database driver for your forum download the appropriate file) \\n\" .
\" * \\n\" .
\" * on your MediaWiki server:\\n\" .
\" * - create a directory forum\\n\".
\" * - create a directory forum/ips_kernel\\n\".
\" * - create a directory forum/sources/sql\\n\".
\" * - upload conf_global.php to the forum directory \\n\".
\" * - upload class_db_mysql.php to the forum/ips_kernel directory\\n\".
\" * - upload mysql_queries.php to the forum/sources/sql directory\\n\".
\" * - set the above setting (\\$ipb_root_path) to the forum directory you just created.\\n\".
\" * \\n\" .
\" * cross your fingers and run the wiki.\\n\".
\" *\\n\" .
\" */\\n\" .
\"\\n\" .
\"/**\\n\" .
\" * Character sets for forum and wiki\\n\".
\" */\\n\".
\" \\$wiki_charset = \'\". $this->wiki_charset . \"\';\\n\" .
\" \\$forum_charset = \'\". $this->forum_charset . \"\';\\n\" .
\"\\n\" .
\"?>\\n\";
if ( $fhandle = fopen( \'ipbwiki_config.php\', \'w\' ) )
{
fwrite($fhandle, $conf_string, strlen($conf_string) );
fclose($fhandle);
}
else
{
$this->print_top (\'Configuration Error.\');
$this->add_row (\'Fatal error, cannot write configuration file, try to chmod ipbwiki_config.php to 777!\');
$this->print_footer();
return;
}
if ($this->is_ipb == 1) {
// store wiki connection settings in forum db
$DB->query (\"DELETE FROM \".$ibf_prefix.\"ipbwiki_conf WHERE conf_id=\'wikiserver\' or conf_id=\'wikidb\' or conf_id=\'wikiuser\' or conf_id=\'wikipwd\' or conf_id=\'wikipf\' or conf_id=\'wikics\' or conf_id=\'forumcs\'\");
$wiki_server = $this->clean_value ($this->wgDBServer);
$wiki_user = $this->clean_value ($this->wgDBuser);
$wiki_pwd = $this->clean_value ($this->wgDBpassword);
$wiki_db = $this->clean_value ($this->wgDBname);
$wiki_prefix = $this->clean_value ($this->wgDBprefix);
$wiki_charset = $this->clean_value ($this->wiki_charset);
$forum_charset = $this->clean_value ($this->forum_charset);
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikiserver\',\'\".$wiki_server.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikiuser\',\'\".$wiki_user.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikipwd\',\'\".$wiki_pwd.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikidb\',\'\".$wiki_db.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikipf\',\'\".$wiki_prefix.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'wikics\',\'\".$wiki_charset.\"\')\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'forumcs\',\'\".$forum_charset.\"\')\");
// storing wiki path in invision power board configuration.
$this->add_row(\'store wiki path in invision power board database.\');
$DB->query (\"DELETE FROM \".$ibf_prefix.\"ipbwiki_conf WHERE conf_id=\'WikiPath\'\");
$wiki_path = $this->clean_value ($this->wgServer . $this->wgScriptPath);
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'WikiPath\',\'\".$wiki_path.\"\')\");
if ($this->ipb30 == 0)
{
if (file_exists ($this->ipb_root_path . \'converge_local/converge.php\')) {
// set the wiki link in the board header correctly
$DB->query (\"UPDATE \".$ibf_prefix.\"components SET com_url_uri = \'\".$wiki_path.\"\' WHERE com_title=\'IpbWiki\'\");
// update the components cache
$components = array();
$DB->query ( \'select com_id,com_enabled,com_section,com_filename,com_url_uri,com_url_title,com_position from \'.$ibf_prefix.\'components where com_enabled=1 order by com_position ASC\');
while ( $r = $DB->fetch_row() )
{
$components[] = $r;
}
$value = serialize($components);
$value = str_replace (\"\'\",\"\'\'\",$value);
$DB->query (\'DELETE FROM \'.$ibf_prefix.\"cache_store WHERE cs_key=\'components\'\");
$DB->query (\'INSERT INTO \'.$ibf_prefix.\"cache_store (cs_key,cs_value,cs_extra,cs_array) VALUES (\'components\',\'\".$value.\"\',\'\',\'1\')\");
}
/* } else { */
}
$external_link = $this->clean_value ($this->wgServer . $this->wgStylePath . \'/\'. $this->wgDefaultSkin . \'/external.png\');
$DB->query (\"DELETE FROM \".$ibf_prefix.\"ipbwiki_conf WHERE conf_id=\'LinkImg\'\");
$DB->query (\"INSERT INTO \".$ibf_prefix.\"ipbwiki_conf (conf_id,conf_value) VALUES (\'LinkImg\',\'\".$external_link.\"\')\");
// IPB 2.1?
/* todo custom bbcode check */
/* if (($DB->field_exists( \'bbcode_id\', $ibf_prefix.\'custom_bbcode\') == 1) or ($DB->field_exists( \'bbcode_id\', \'custom_bbcode\') == 1)) {
// clear bbcode cache
$DB->query (\"DELETE FROM \".$ibf_prefix.\"cache_store WHERE cs_key=\'bbcode\'\");
// clear wiki tag
$DB->query (\"DELETE FROM \".$ibf_prefix.\"custom_bbcode WHERE bbcode_tag=\'wiki\'\");
$DB->query (\"SELECT MAX(bbcode_id) + 1 as bbcode_id FROM \" . $ibf_prefix . \"custom_bbcode\");
$row = $DB->fetch_row();
if (strtolower($INFO[\'sql_driver\']) === \'mssql\') {
$DB->query (\"SET IDENTITY_INSERT \". $ibf_prefix . \"custom_bbcode ON\");
}
$DB->query (\"INSERT INTO \". $ibf_prefix . \"custom_bbcode (bbcode_id,bbcode_title,bbcode_desc,bbcode_tag,bbcode_replace,bbcode_useoption, bbcode_example) VALUES (\" . $row[\'bbcode_id\'] . \", \'Wiki tag\', \'This tag links to the wiki.\', \'wiki\', \'<a href=\\\"\". $wiki_path . \"/index.php?title={content}\\\" style=\\\"background: url(\". $external_link . \") center right no-repeat; padding-right: 13px; border-bottom: 1px dotted #3366BB; color: #3366BB; cursor:pointer; text-decoration:none;\\\" class=\\\"wiki\\\">{content}</a>\', 0, \'[wiki]Main Page[/wiki]\')\");
if (strtolower($INFO[\'sql_driver\']) === \'mssql\') {
$DB->query (\"SET IDENTITY_INSERT \". $ibf_prefix . \"custom_bbcode OFF\");
}
} */
}
$this->add_row(\'\');
$this->add_row(\'\');
$this->add_row(\'<H3>Securing installation...</H3>\');
$this->add_row(\'\');
$this->add_row(\'Please chmod the following files to 644:\');
$print=\'\';
ob_start(); // catch the annoying chmod warnings...
if (!chmod (\"LocalSettings.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/LocalSettings.php</td></tr>\';
}
if (!chmod (\"ipbwiki_config.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/ipbwiki_config.php</td></tr>\';
}
if (!chmod (\"includes/Skin.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/includes/skin.php</td></tr>\';
}
if (!chmod (\"includes/User.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/includes/user.php</td></tr>\';
}
if (!chmod (\"includes/SkinTemplate.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/includes/skintemplate.php</td></tr>\';
}
if (!chmod (\"includes/EditPage.php\", 0644)) {
$print=$print.\'<tr><td> - wiki/includes/EditPage.php</td></tr>\';
}
if (!chmod ($file_name, 0644)) {
$print=$print.\'<tr><td> - wiki/\'.$file_name.\'</td></tr>\';
}
ob_end_clean();
echo $print;
$this->add_row(\'Please <b>delete</b> the <b>ipbwiki_interface_setup.php</b> file in your wiki folder. (If you need to reinstall you can always upload it again later.)\');
$this->add_row(\'\');
$this->add_row(\'\');
$this->print_footer();
}
}
new ipbwiki_setup();
?>
[/code]
ipbwiki20.php:
[code]<?php
/*
+--------------------------------------------------------
| Package: IpbWiki Core
| Module: IpbWiki 2.0 Abstraction Layer
| Copyright (c) 2006-2011 Peter De Decker
| http://www.ipbwiki.com
+--------------------------------------------------------
*/
// this file shouldn\'t be called directly!
if( ! defined( \"IPBWIKI\" ) ) {
print \"<h1>Incorrect access</h1>You cannot access this file directly.\";
exit();
}
// Kernel Path, used to call the database abstraction layers...
if (!defined(\'KERNEL_PATH\')) {
define (\'KERNEL_PATH\', \'ips_kernel/\');
}
require_once (\'ipbwiki_commons_ipb.php\');
class ipbwiki20 extends ipbwiki_commons_ipb {
// Invision Power Board Variables
var $converge;
var $sql_driver;
var $sql_user;
var $sql_pass;
// Class Constructor
// initialisations, set up the db connection, etc...
function ipbwiki20() {
// read the database settings
require (\'conf_global.php\');
$this->connect_to_database($INFO);
// call the parent constructor
parent::ipbwiki_commons_ipb();
// variables for the post parser
// retrieve default skin set...
$sql = $this->retrieve_default_skin_sql();
$this->DB->query ($sql);
if ($row = $this->DB->fetch_row()) {
$this->img_url = $this->get_img_url($INFO,$row[\'set_image_dir\']);
$this->css_skin_filename = $INFO[\'board_url\'].\'/style_images/css_\'.$row[\'set_skin_set_id\'].\'.css\';
$this->skin_id = $row[\'set_skin_set_id\'];
$this->ipbwiki_monobook_skin_extra_css = \'\';
$this->ipbwiki_monobook_skin_extra_css = $row[\'prerendered_css\'];
$this->topmenu_left = $this->unclean_value($row[\'topmenulc\']);
$this->topmenu_right = $this->unclean_value($row[\'topmenurc\']);
$this->leftmenu = $this->unclean_value($row[\'leftmenuc\']);
if ($this->enable_skin_integration) {
switch ($row[\'skin_type\']) {
case \'1\': // IpbWiki MediaWiki Style
$this->default_skin_name = \'ipbwiki_skin_monobook\';
break;
case \'2\': // IpbWiki MediaWiki Style Colored
$this->default_skin_name = \'ipbwiki_skin_monobook\';
$this->skin_colored = \'_colored\';
break;
case \'3\': // IpbWiki Ipb Style
$this->default_skin_name = \'ipbwiki_skin\';
break;
case \'4\': // Custom Skin
$this->default_skin_name = $row[\'custom_skin_name\'];
break;
default: $this->default_skin_name = \'\';
}
$this->skin_logo = $this->get_logo($row[\'logo_picture\']);
} else {
$this->default_skin_name = \'\';
}
if (($this->topmenu_left == \'\') || ($this->topmenu_left === \"<div class=\'ipb-top-left-link\'></div>\")) {
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"ipbwiki_conf c WHERE conf_id =\'topmenulc\'\");
$row = $this->DB->fetch_row();
$this->topmenu_left = $this->unclean_value($row[\'conf_value\']);
}
if (($this->topmenu_right == \'\') || ($this->topmenu_right === \"<div class=\'ipb-top-right-link\'></div>\")) {
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"ipbwiki_conf c WHERE conf_id =\'topmenurc\'\");
$row = $this->DB->fetch_row();
$this->topmenu_right = $this->unclean_value($row[\'conf_value\']);
}
if (($this->leftmenu === \'\') || ($this->leftmenu === \'<ul><li></li></ul>\')) {
$this->leftmenu = \'\';
}
if (($this->ipbwiki_monobook_skin_extra_css) == \'\') { // in case we haven\'t prerendered it...
$this->skin_retrieve_extra_css();
}
}
// read some settings from the database...
// cookies!
$this->retrieve_cookies();
// default language
$this->retrieve_default_language();
// variables for the post parser...
$this->retrieve_post_parser_variables();
// converge...
$this->set_up_converge();
// finally some info from conf_global.php
$this->sql_user = $INFO[\'sql_user\'];
$this->sql_pass = $INFO[\'sql_pass\'];
}
function get_img_url($INFO,$image_dir)
{
return $INFO[\'board_url\'].\'/style_images/\'.$image_dir;
}
function get_logo($logo_picture)
{
return ($logo_picture == \'\' ? $this->img_url . \'/logo4.gif\' : $logo_picture);
}
function connect_to_database($INFO)
{
// instead of reinventing the wheel, let\'s make use of the database-abstraction layer present in the Invision Power Board Classes...
$INFO[\'sql_driver\'] = !$INFO[\'sql_driver\'] ? \'mysql\' : $INFO[\'sql_driver\'];
require ( KERNEL_PATH.\'class_db_\'.strtolower($INFO[\'sql_driver\']).\".php\" );
if (file_exists(\'converge_local/converge.php\')) { // IPB 2.2+
$classname = \"db_driver_\".$INFO[\'sql_driver\'];
$this->DB = new $classname;
} else {
$this->DB = new db_driver;
}
$this->DB->obj[\'sql_database\'] = $INFO[\'sql_database\'];
$this->DB->obj[\'sql_user\'] = $INFO[\'sql_user\'];
$this->DB->obj[\'sql_pass\'] = $INFO[\'sql_pass\'];
$this->DB->obj[\'sql_host\'] = $INFO[\'sql_host\'];
$this->DB->obj[\'sql_tbl_prefix\'] = $INFO[\'sql_tbl_prefix\'];
$this->DB->obj[\'use_shutdown\'] = 0;
$this->DB->obj[\'query_cache_file\'] = $this->ipb_root_path.\'sources/sql/\'.strtolower($INFO[\'sql_driver\']).\'_queries.php\';
$this->DB->obj[\'debug\'] = 0;
$this->DB->connect();
// store the sql driver...
$this->sql_driver = strtolower ($INFO[\'sql_driver\']);
}
function retrieve_default_skin_sql()
{
$sql = \'SELECT ss.set_image_dir, ss.set_skin_set_id, iws.skin_type, iws.custom_skin_name, iws.logo_picture, iws.prerendered_css, iws.topmenulc, iws.topmenurc, iws.leftmenuc
FROM \'.$this->ibf_prefix.\'skin_sets ss
LEFT JOIN \'.$this->ibf_prefix.\'ipbwiki_skin iws
ON ss.set_skin_set_id = iws.skin_id
WHERE set_default = 1\';
return $sql;
}
function retrieve_cookies()
{
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'cookie_domain\'\");
$row = $this->DB->fetch_row();
$this->cookie_domain = $row[\'conf_value\'];
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'cookie_id\'\");
$row = $this->DB->fetch_row();
$this->cookie_id = $row[\'conf_value\'];
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'cookie_path\'\");
$row = $this->DB->fetch_row();
$this->cookie_path = $row[\'conf_value\'];
$this->cookie_path == \"\" ? \"/\" : $this->cookie_path;
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'match_browser\'\");
$row = $this->DB->fetch_row();
$this->match_browser = $row[\'conf_value\'];
}
function retrieve_default_language()
{
// brrr... the default ipb query is a bit cumbersome, rewrite...!!!
$this->DB->query (\"select \".$this->ibf_prefix.\"languages.ldir, count(\".$this->ibf_prefix.\"members.id) as mcount from \".$this->ibf_prefix.
\"languages left join \".$this->ibf_prefix.\"members on(\".$this->ibf_prefix.\"members.language=\".$this->ibf_prefix.\"languages.ldir) where (\".
$this->ibf_prefix.\"members.language is not null or \".$this->ibf_prefix.\"members.language = \'en\') group by \".
$this->ibf_prefix.\"languages.ldir,\".$this->ibf_prefix.\"languages.lname order by \".$this->ibf_prefix.\"languages.lname\");
$row = $this->DB->fetch_row();
if (! $this->default_language = $row[\'ldir\']) {
$this->default_language = \'en\';
}
}
function retrieve_post_parser_variables()
{
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'allow_dynamic_img\'\");
$row = $this->DB->fetch_row();
$this->allow_dynamic_img = $row[\'conf_value\'];
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'allow_flash\'\");
$row = $this->DB->fetch_row();
$this->allow_flash = $row[\'conf_value\'];
$this->DB->query (\"SELECT conf_value,conf_default FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'max_w_flash\'\");
$row = $this->DB->fetch_row();
$this->max_w_flash = ($row[\'conf_value\'] == \"\"? $row[\'conf_default\'] : $row[\'conf_value\']);
$this->DB->query (\"SELECT conf_value,conf_default FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'max_h_flash\'\");
$row = $this->DB->fetch_row();
$this->max_h_flash = ($row[\'conf_value\'] == \"\"? $row[\'conf_default\'] : $row[\'conf_value\']);
$this->DB->query (\"SELECT conf_value FROM \" . $this->ibf_prefix . \"conf_settings c WHERE conf_key =\'img_ext\'\");
$row = $this->DB->fetch_row();
$this->img_ext = $row[\'conf_value\'];
$this->emoticons_url = $INFO[\'board_url\'].\'/style_emoticons/default\';
}
function set_up_converge()
{
require_once(KERNEL_PATH.\'/class_converge.php\');
$this->converge = new class_converge( $this->DB );
}
// ------------------------------------------------------------------------------
// following functions override the placeholder functions with actual
// implementations
// ------------------------------------------------------------------------------
// retrieve_member_record
// expects a member record returned with at least the following fields:
// - name
// - email
// - converge_pass_hash
function retrieve_member_record ($member_name) {
$this->apply_forum_charset ($member_name);
return $this->retrieve_member_record_for_authentication_from_name($member_name);
}
function retrieve_member_record_for_authentication ($member_id) {
$this->DB->query (\"SELECT m.id, m.name, m.mgroup, g.g_access_cp, m.posts, m.email, m.member_login_key, mc.converge_pass_hash, mc.converge_pass_salt FROM \" . $this->ibf_prefix . \"members m JOIN \" . $this->ibf_prefix . \"members_converge mc ON m.email = mc.converge_email JOIN \" . $this->ibf_prefix . \"groups g ON g.g_id=m.mgroup WHERE m.id=\'\" . $member_id . \"\'\");
return $this->DB->fetch_row();
}
function retrieve_member_record_for_authentication_from_name ($member_name) {
// ipbwiki orig $this->DB->query (\"SELECT m.id, m.name, m.mgroup, g.g_access_cp, m.posts, m.email, m.member_login_key, mc.converge_pass_hash, mc.converge_pass_salt FROM \" . $this->ibf_prefix . \"members m JOIN \" . $this->ibf_prefix . \"members_converge mc ON m.email = mc.converge_email JOIN \" . $this->ibf_prefix . \"groups g ON g.g_id=m.mgroup WHERE LOWER(m.name)=LOWER(\'\" . $member_name . \"\')\");
$this->DB->query (\"SELECT m.id, m.name, m.mgroup, g.g_access_cp, m.posts, m.email, m.member_login_key, mc.converge_pass_hash, mc.converge_pass_salt FROM \" . $this->ibf_prefix . \"members m JOIN \" . $this->ibf_prefix . \"members_converge mc ON m.email = mc.converge_email JOIN \" . $this->ibf_prefix . \"groups g ON g.g_id=m.mgroup WHERE m.name=\'\" . $member_name . \"\'\");
return $this->DB->fetch_row();
}
function validate_password ($member, $password) {
return ( $member[\'converge_pass_hash\'] == md5 ( md5($member[\'converge_pass_salt\']) . md5($password)) );
}
function retrieve_emoticons () {
// only process the default emoticon set, when we ever get to implementing the skins, then change this!
if (strcasecmp($this->sql_driver,\'mssql\') == 0) {
$this->DB->query (\"SELECT typed,image,emo_set FROM \".$this->ibf_prefix.\"emoticons WHERE emo_set=\'default\' ORDER BY LEN(typed) DESC\");
} else {
$this->DB->query (\"SELECT typed,image,emo_set FROM \".$this->ibf_prefix.\"emoticons WHERE emo_set=\'default\' ORDER BY LENGTH(typed) DESC\");
}
}
function update_email_linked_tables ($member, $email) {
$this->DB->query(\"UPDATE \".$this->ibf_prefix.\"members_converge SET converge_email=\'\".$email.\"\' WHERE converge_email=\'\".$member[\'email\'].\"\'\");
}
function get_session_id ($member_id, $pass_hash) {
// We\'re not requiring to have the same ip-address as we must allow people who are on a non-static ip-address to log in on a next occasion.
$this->DB->query (\"SELECT s.id FROM \".$this->ibf_prefix.\"members m JOIN \".$this->ibf_prefix.\"sessions s ON s.member_id=m.id WHERE m.member_login_key=\'\".$pass_hash.\"\' AND m.id=\".$member_id /*.\" AND s.ip_address=\'\".$this->ip_address.\"\'\"*/ );
$row = $this->DB->fetch_row();
return $row[\'id\'];
}
// ------------------------------------------------------------------------------
// following functions are the core of IpbWiki, here we have interaction with
// Invision Power Board!
// ------------------------------------------------------------------------------
// canAddUser
// checks if the username-password combo is allowable...
function canAddUser ($username, $password) {
$ok = parent::canAddUser ($username, $password);
if ($ok == TRUE) {
// Non Registerable name?
$username = $this->clean_value($username);
// ipbwiki orig $this->DB->query (\"SELECT * FROM \".$this->ibf_prefix.\"banfilters WHERE ban_type=\'name\' AND LOWER(ban_content)=LOWER(\'\". $username . \"\')\");
$this->DB->query (\"SELECT * FROM \".$this->ibf_prefix.\"banfilters WHERE ban_type=\'name\' AND ban_content=\'\". $username . \"\'\");
if ($this->DB->get_num_rows()) {
print_r (\'username already taken, please choose another name...\');
return FALSE;
}
}
return $ok;
}
function check_if_email_address_exists_sql ($email)
{
return \"SELECT * FROM \". $this->ibf_prefix . \"members_converge WHERE converge_email = \'\" . $email . \"\'\";
}
function generate_fake_email ()
{
$this->DB->query (\"SELECT MAX(converge_id) as max_id FROM \". $this->ibf_prefix . \"members_converge\");
$row = $this->DB->fetch_row();
$id = $row[\'max_id\'];
$id++;
$email = $id . \'@fake_ipbwiki_email.com\';
return $email;
}
function generate_auto_login_key()
{
return $this->converge->generate_auto_log_in_key();
}
function generate_password_salt($len=60)
{
return $this->converge->generate_password_salt($len);
}
function generate_compiled_passhash($converge_pass_salt,$password)
{
return $this->converge->generate_compiled_passhash( $converge_pass_salt, md5($password) );
}
function create_user_insert_into_db ($username,$password,$email)
{
$member = array(
\'name\' => $username,
\'member_login_key\' => $this->generate_auto_login_key(),
\'email\' => $email,
\'mgroup\' => $this->member_group,
\'posts\' => 0,
\'joined\' => time(),
\'ip_address\' => $this->ip_address,
\'time_offset\' => 0,
\'view_sigs\' => 1,
\'email_pm\' => 1,
\'view_img\' => 1,
\'view_avs\' => 1,
\'restrict_post\' => 0,
\'view_pop\' => 1,
\'msg_total\' => 0,
\'new_msg\' => 0,
\'coppa_user\' => 0,
\'language\' => $this->default_language,
\'dst_in_use\' => 0,
\'allow_admin_mails\'=> 1,
\'hide_email\' => 0,
\'subs_pkg_chosen\' => 0
);
$converge_pass_salt = $this->generate_password_salt(5);
$converge_pass_hash = $this->generate_compiled_passhash( $converge_pass_salt, $password );
$converge = array( \'converge_email\' => $email,
\'converge_joined\' => time(),
\'converge_pass_hash\' => $converge_pass_hash,
\'converge_pass_salt\' => str_replace( \'\\\\\', \"\\\\\\\\\", $converge_pass_salt )
);
// Insert: CONVERGE
$this->DB->do_insert( \'members_converge\', $converge );
// Get converges auto_increment user_id
$member_id = $this->DB->get_insert_id();
$member[\'id\'] = $member_id;
// Insert: MEMBER
$this->DB->do_insert( \'members\', $member );
// Insert: MEMBER EXTRA
$this->DB->do_insert( \'member_extra\', array( \'id\' => $member_id, \'vdirs\' => \'in:Inbox|sent:Sent Items\' ) );
}
// create_user
// creates a new user in the IPB database
function create_user ($username, $password, $email) {
// store unclean values, so that we can reuse the regular authentication
$orig_username = $username;
$orig_password = $password;
// Clean Username
$this->username_replace_special_characters_for_forum($username);
$username = $this->txt_stripslashes($username);
$username = preg_replace(\"/&#([0-9]+);/\", \'-\', $username);
$username = $this->clean_value($username);
$this->apply_forum_charset ($username);
$username = $this->ucfirst($username, $this->forum_charset);
// Clean Password
$password = $this->txt_stripslashes($password);
$password = preg_replace(\"/&#([0-9]+);/\", \'-\', $password);
$password = $this->clean_value($password);
$this->apply_forum_charset ($password);
// Clean email
$this->apply_forum_charset ($email);
$email = $this->clean_email($email);
if ($email == \"\") {
$email = $this->generate_fake_email();
}
$sql = $this->check_if_email_address_exists_sql($email);
$this->DB->query ($sql); // check if the email address is already used...
if ($this->DB->get_num_rows()) {
print_r (\'email address already connected to another email address, wiki user not synchronized to forum database.\');
return FALSE;
}
$this->create_user_insert_into_db($username,$password,$email);
// let\'s immediately log in this user as well on the forum!
return $this->authenticate_user ($orig_username, $orig_password);
}
function get_display_name_sql ($name)
{
$this->DB->query (\"SELECT m.id, m.name, m.members_display_name as display_name FROM \" . $this->ibf_prefix . \"members m WHERE m.name=\'\" . $name . \"\'\");
$member = $this->DB->fetch_row();
return $member;
}
function get_display_name ($name) {
$save_name = $name;
$this->username_replace_special_characters_for_forum($name);
$name = $this->txt_stripslashes($name);
$name = preg_replace(\"/&#([0-9]+);/\", \'-\', $name);
$name = $this->clean_value($name);
$this->apply_forum_charset ($name);
$name = $this->ucfirst($name, $this->forum_charset);
$member = $this->get_display_name_sql ($name);
if ($member) {
$name = $member[\'name\'];
$this->apply_wiki_charset ($name);
return $name;
} else {
return $save_name;
}
}
// retrieve_md5_password
// retrieves important member info in an array...
// not used anymore???
function retrieve_md5_password ($username) {
$this->DB->query (\"SELECT m.id, m.name, m.mgroup, m.posts, m.email, mc.converge_pass_hash as md5_password FROM \" . $this->ibf_prefix . \"members m JOIN \" . $this->ibf_prefix . \"members_converge mc ON m.email = mc.converge_email WHERE m.name=\'\" . $username . \"\'\");
$member = $this->DB->fetch_row();
return $member;
}
function setPassword_get_user_sql ($username)
{
return \"SELECT m.id, m.name, m.mgroup, m.member_login_key, mc.converge_pass_hash, mc.converge_pass_salt FROM \" . $this->ibf_prefix . \"members m JOIN \" . $this->ibf_prefix . \"members_converge mc ON m.email = mc.converge_email WHERE m.name=\'\" . $username . \"\'\";
}
function update_hash_and_key ($converge_pass_hash,$converge_pass_salt,$member_login_key,$member_id)
{
$this->DB->query(\"UPDATE \".$this->ibf_prefix.\"members_converge SET converge_pass_hash=\'\".$converge_pass_hash.\"\',converge_pass_salt=\'\".$converge_pass_salt.\"\' WHERE converge_id=\'\".$member_id.\"\'\");
$this->DB->query(\"UPDATE \".$this->ibf_prefix.\"members SET member_login_key=\'\".$member_login_key.\"\' WHERE id=\'\".$member_id.\"\'\");
}
// setPassword
// updates the password for the specified username
function setPassword ($username, $password) {
// clean the user name
$this->username_replace_special_characters_for_forum($username);
$username = $this->txt_stripslashes($username);
$username = preg_replace(\"/&#([0-9]+);/\", \'-\', $username);
$username = $this->clean_value($username);
$this->apply_forum_charset ($username);
$username = $this->ucfirst($username, $this->forum_charset);
// does the user exist?
$sql = $this->setPassword_get_user_sql ($username);
$this->DB->query ($sql);
if ($member = $this->DB->fetch_row()) {
// do some sanity checks on the new password...
if (empty($password) OR strlen($password) < 3 OR strlen($password) > 32) {
return FALSE;
}
// ...and clean the password...
$password = $this->txt_stripslashes($password);
$password = preg_replace(\"/&#([0-9]+);/\", \'-\', $password);
$password = $this->clean_value($password);
$this->apply_forum_charset ($password);
$member_login_key = $this->generate_auto_login_key();
$converge_pass_salt = $this->generate_password_salt(5);
$converge_pass_hash = $this->generate_compiled_passhash( $converge_pass_salt, $password );
$this->update_hash_and_key ($converge_pass_hash,$converge_pass_salt,$member_login_key,$member[\'id\']);
return true;
} else { // member not found in forum database...
// return true as password is also set for non existing users in MW1.9+...
return true;
}
}
function retrieve_secondary_ipbwikigroup_for_member ($username) {
// clean the user name
$this->username_replace_special_characters_for_forum($username);
$username = $this->txt_stripslashes($username);
$username = preg_replace(\"/&#([0-9]+);/\", \'-\', $username);
$username = $this->clean_value($username);
$this->apply_forum_charset ($username);
$username = $this->ucfirst($username, $this->forum_charset);
// ipbwiki orig $this->DB->query (\"SELECT m.mgroup_others, m.posts FROM \" . $this->ibf_prefix . \"members m WHERE LOWER(m.name) = LOWER(\'\" . $username . \"\')\");
$this->DB->query (\"SELECT m.mgroup_others, m.posts FROM \" . $this->ibf_prefix . \"members m WHERE m.name = \'\" . $username . \"\'\");
$member = $this->DB->fetch_row();
$groups = explode (\',\',$member[\'mgroup_others\']);
$sec_group = array();
foreach ($groups as $value) {
if ($value) {
$this->DB->query (\"SELECT g.g_title, ig.posts as ig_posts FROM \" . $this->ibf_prefix . \"groups g JOIN \".$this->ibf_prefix.\"ipbwiki_group ig ON ig.g_id = g.g_id AND $member[posts] >= ig.posts WHERE g.g_id = $value ORDER BY ig.posts DESC\");
if ($group = $this->DB->fetch_row()) {
$this->apply_wiki_charset ($group[\'g_title\']);
if ($group[\'ig_posts\'] > 0) {
$sec_group[] = $group[\'g_title\'].\" (\".$group[\'ig_posts\'].\"+ \".$this->ipbwiki_lang[\'posts\'].\")\";
} else {
$sec_group[] = $group[\'g_title\'];
}
}
}
}
return $sec_group;
}
function get_permission_join_member_sql ($cookie)
{
return \'SELECT g_perm_id FROM \'.$this->ibf_prefix.\'groups g JOIN \'.$this->ibf_prefix.\'members m ON m.mgroup = g.g_id WHERE m.id = \'.$cookie[\'member_id\'];
}
function get_permission_join () {
// determine permission masks of the user group, if the ParseCache is disabled fetch the permissions of the guest group
$cookie = $this->retrieve_forum_session();
if (($this->parsercache === \'0\') and ($cookie[\'member_id\'] > 0)) {
$sql = $this->get_permission_join_member_sql ($cookie);
} else {
$sql = \'SELECT g_perm_id FROM \'.$this->ibf_prefix.\'groups WHERE g_id = \'.$this->guest_group;
}
$this->DB->query ($sql);
$permission = $this->DB->fetch_row();
// retrieve the permission masks we have in an array...
$permission = explode (\',\',$permission[\'g_perm_id\']);
// retrieve the forums we have access to...
$sql = \'SELECT id, permission_array FROM \'.$this->ibf_prefix.\'forums\';
if ($forum_id > 0) {
$sql .= \" WHERE id = \" . $forum_id;
}
$this->DB->query ($sql);
$extra_sql = \'\';
$first = true;
while ($row = $this->DB->fetch_row()) {
$ok = false;
$perms = unserialize(stripslashes($row[\'permission_array\']));
$read_perms = $perms[\'read_perms\'];
foreach ($permission as $value) {
if ($read_perms == \'*\' OR $read_perms == \'\') { $ok = true; break; }
if (strstr($read_perms, $value) !== false ) { $ok = true; break; }
}
if ($ok) {
if ($first) {
$extra_sql .= $row[\'id\'];
$first = false;
} else {
$extra_sql .= \',\' . $row[\'id\'];
}
}
}
if ($first == true) { // no matches found?
$extra_sql = \' AND 1 = 2 \';
} else {
$extra_sql = \' AND t.forum_id IN (\'.$extra_sql.\')\';
}
return $extra_sql;
}
// topic - post interaction
// get_topic_list
// gets a topic list from the forum
function get_topic_list ($forum_id, $topics) {
$extra_sql = $this->get_permission_join();
$sql = \"SELECT t.tid, t.state, t.icon_id, t.title, t.description, t.posts, t.starter_id, sm.members_display_name AS sm_name, t.views, t.last_post, t.last_poster_id, lm.members_display_name AS lm_name, t.forum_id, f.name as forumdesc
FROM \".$this->ibf_prefix.\"topics t
LEFT JOIN \".$this->ibf_prefix.\"members sm ON sm.id = t.starter_id
LEFT JOIN \".$this->ibf_prefix.\"members lm ON lm.id = t.last_poster_id
JOIN \".$this->ibf_prefix.\"forums f ON f.id = t.forum_id\" . $extra_sql . \"
WHERE t.approved = 1 \";
if ($forum_id > 0) {
$sql .= \" AND t.forum_id = \" . $forum_id;
if ($topics !== \'\') {
$sql .= \' AND t.tid IN (\'. $topics . \')\';
}
} else if ($topics !== \'\') {
$sql .= \' AND t.tid IN (\'. $topics . \')\';
}
$sql .= \" ORDER BY last_post DESC\";
$this->DB->query ($sql);
}
// ------------------------------------------------------------------------------------------
// retrieve post info...
// ------------------------------------------------------------------------------------------
function get_post_sql ($extra_sql, $post_id)
{
$sql = \'SELECT p.pid, p.author_id, p.author_name, p.post_date, p.icon_id, p.post, p.topic_id, t.forum_id, m.title, m.mgroup, m.posts, m.joined, m.id, g.g_title, me.avatar_location, me.avatar_type
FROM \'.$this->ibf_prefix.\'posts p
JOIN \'.$this->ibf_prefix.\'topics t
ON t.tid = p.topic_id
AND t.approved = 1 \'.$extra_sql.\'
LEFT JOIN \'.$this->ibf_prefix.\'members m
ON m.id = p.author_id
LEFT JOIN \'.$this->ibf_prefix.\'member_extra me
ON m.id = me.id
LEFT JOIN \'.$this->ibf_prefix.\'groups g
ON g.g_id = m.mgroup
WHERE queued = 0
AND p.pid = \' . $post_id;
return $sql;
}
function get_post ($post_id, $check_permission) {
if ($check_permission == 1) {
$extra_sql = $this->get_permission_join();
} else {
$extra_sql = \'\';
}
$sql = $this->get_post_sql ($extra_sql, $post_id);
$this->DB->query ($sql);
}
function get_post_icon ($icon) {
if ($icon > 0) {
return \"<img src=\'\".$this->img_url.\"/icon\".$icon.\".gif\' border=\'0\' style=\'padding-bottom:2px\'>\";
} else {
return \"<img src=\'\".$this->img_url.\"/to_post_off.gif\' border=\'0\' style=\'padding-bottom:2px\'>\";
}
}
}
?>
[/code]
that shou'd make the setup work