Menu

#8 [Fix] IPB 3.3.4 & MediaWiki 1.9+

v2.2.4
open
nobody
5
2015-03-02
2012-10-18
Geonode
No

I've made a fix for the setup for Ipb, here you go:
[code]<?php

/*
+--------------------------------------------------------
| Package: IpbWiki Core
| Copyright (c) 2006-2011 Peter De Decker
| http://www.ipbwiki.com
+--------------------------------------------------------
*/

if (file_exists ('initdata.php')) {
//Load init data if present
require_once( 'initdata.php' );
} else {
//Set some defaults
define( 'CP_DIRECTORY', 'admin' );
}

if (!defined('WRK_DIR')) {
define ('WRK_DIR', getcwd());
}

if (!defined('KERNEL_PATH')) {
define ('KERNEL_PATH', 'ips_kernel/');
define ('IPS_KERNEL_PATH', 'ips_kernel/');
}

define( 'IPB_THIS_SCRIPT' , 'admin' );
define( 'IPB_LOAD_SQL' , 'admin_queries' );
define( 'IN_IPB', 0 );
define('IPBWIKI', 1);

define('IPBWIKI_LONG_VER', 22004);
define('IPBWIKI_HUMAN_VER', '2.2.4');

class ipbwiki_setup {
// 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 Set Up : $title </title>
<style type='text/css'>
body {
font: x-small sans-serif;
background: #f9f9f9 url(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() {
$this->print_top ('Checking configuration.');

if ( !file_exists ('conf_global.php') ) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file conf_global.php does not exist. Please set up Invision Power Board first before you install IpbWiki.<BR>Click the button below to try again.<p><input type='submit' value='Try Again'></form></td>";
$this->print_footer();
return;
}

// IPB 1.3
if (file_exists ('sources/Admin/admin_pages.php')) {
if ( ! is_writable ('sources/Admin/admin_pages.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file sources/Admin/admin_pages.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
if ( ! is_writable ('admin.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file admin.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
if ( ! is_writable ('index.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file index.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
}

// IPB 2.0
if (file_exists ('sources/admin/admin_pages.php')) {
if ( ! is_writable ('sources/admin/admin_pages.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file sources/admin/admin_pages.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
if ( ! is_writable ('admin.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file admin.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
if ( ! is_writable ('index.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file index.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
if ( ! is_writable('sources/online.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file sources/online.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
}

echo "<td><p><form method='post' action='?act=check_entries'>configuration prerequisites ok, please click the button to Start the installation.<BR><BR><input type='submit' value='Start Install'></form></td>";
$this->print_footer();
}

function do_replace ($in) {
if (strpos($in,base64_decode('aHR0cDovL3d3dy5pcGJ3aWtpLmNvbQ==')) === FALSE) {
$in = str_replace(base64_decode('PCUgQ09QWVJJR0hUICU+'),base64_decode('PCEtLSAtLT4gPGRpdiBjbGFzcz0nY29weXJpZ2h0MicgYWxpZ249J2NlbnRlcic+QnJpZGdlZCBCeSA8QSBIUkVGPWh0dHA6Ly93d3cuaXBid2lraS5jb20gc3R5bGU9J3RleHQtZGVjb3JhdGlvbjpub25lJyB0YXJnZXQ9J19ibGFuayc+SXBiV2lraTogSW50ZWdyYXRpb24gT2YgSW52aXNpb24gUG93ZXIgQm9hcmQgYW5kIE1lZGlhV2lraTwvQT4gJmNvcHk7IDxBIEhSRUY9aHR0cDovL3d3dy5nbG9iYWxzb2Z0LmJlIHN0eWxlPSd0ZXh0LWRlY29yYXRpb246bm9uZScgdGFyZ2V0PSdfYmxhbmsnPkdsb2JhbFNvZnQ8L0E+PC9kaXY+PCUgQ09QWVJJR0hUICU+'),$in);
}
$in = str_replace("'","''",$in);
$in = str_replace("\\","\\\\",$in);
return $in;
}

function do_css ($css) {
if (strlen($css)>0) {
if (strpos($css,'.copyright2') === FALSE) {
$pos = strpos($css,'.copyright');
if ($pos !== FALSE) {
$pos2 = strpos($css,'}',$pos);
$str=substr($css,$pos,$pos2-$pos+1);
$temp = '';
$remember = FALSE;
$result = '.copyright2 { ';
for ($i=1; $i<=strlen($str); $i++) {
if ((substr($str,$i,1) == '{') or (substr($str,$i,1) == ';')) {
if ($remember) {
$result .= $temp . ';';
}
$temp = '';
$remember = FALSE;
} else if (substr($str,$i,1) == ':') {
if ((trim($temp) == 'background') or (trim($temp) == 'font-size') or (trim($temp) == 'color')) {
$remember = true;
$temp .= substr($str,$i,1);
}
} else {
$temp .= substr($str,$i,1);
}
}
$result .= ' }';
$css .= "\r\n" . $result;
}
}
$css = str_replace ("'","''",$css);
}
return $css;
}

function check_entries() {
$ipb13 = 0;
$ipb20 = 0;
$ipb21 = 0;
$ipb22 = 0;
$ipb30 = 0;

// double check!
// check if it is the invision power board directory they passed us on...
if ( file_exists (CP_DIRECTORY . '/api/api_core.php')) {
$ipb30 = 1;
$this->print_top ("Installing...");
} else {
if ( !file_exists ("conf_global.php")) {
$this->print_top ('Configuration Error.');
echo "<td><p><form method='post' action='?act=re-entry'><B>The file conf_global.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;
}

// we have to import the xml on a 2.1 board anyway, assume if the xml exists that it is a 2.1+ board...
if (file_exists ('ipbwiki.xml')) {
if (file_exists ('converge_local/converge.php')) {
$ipb22 = 1;
} else {
$ipb21 = 1;
}
} else {
if (file_exists ('ips_kernel/class_db_mysql.php')) {
$ipb20 = 1;
} else {
$ipb13 = 1;
}
}

if (($ipb20 == 1) or ($ipb13 == 1)) {
// check if we need to modify admin.php
// reset flag & counters...
$settings1_found = false;
$i1 = 0;
$j1 = 0;

$fp = fopen('admin.php', 'r');
while( !feof($fp) ) {
$str = fgets($fp);
// 2.0
if (trim($str) === "'ipbwiki' => array( 'ipbwiki' , 'ipbwiki'), // <-- this line was automatically added by the IPBWiki Installer.") {
$settings1_found = true;
}
// 1.3
if (trim($str) === "'ipbwiki' => 'ipbwiki', // <-- this line was automatically added by the IPBWiki Installer.") {
$settings1_found = true;
}
if (($ipb20 == 1) and (trim($str) === "'emailerror'=> array( 'emailerror' , 'emailerror' ),")) {
// target found, let's add the IPBWIKI Settings...
if (!$settings1_found) {
$arr1[$i1++] = " 'ipbwiki' => array( 'ipbwiki' , 'ipbwiki'), // <-- this line was automatically added by the IPBWiki Installer.\n";
}
}
if (($ipb13 == 1) and (trim($str) === "'csite' => 'ad_dynamiclite',")) {
if (!$settings1_found) {
$arr1[$i1++] = " 'ipbwiki' => 'ipbwiki', // <-- this line was automatically added by the IPBWiki Installer.\n";
}
}
$arr1[$i1++] = $str;
}
fclose($fp);

// check if we need to modify sources/admin/admin_pages.php (we do this check before so that we don't have to bother the user in the middle of the install to chmod a file we're not going to change anyway)
// reset flag & counters...
$settings2_found = false;
$added_to_settings2 = false;
$i2 = 0;
$j2 = 0;

if ($ipb13 == 1) {
$fp = fopen('sources/Admin/admin_pages.php', 'r');
} else {
$fp = fopen('sources/admin/admin_pages.php', 'r');
}
while( !feof($fp) )
{
$str = fgets($fp);
if (trim($str) === "// IpbWiki Administration Plugin") {
$settings2_found = true;
}
if (($settings2_found) and (trim($str) === "2 => array( 'IpbWiki Group Access', 'act=ipbwiki'),")) {
$added_to_settings2 = true;
$arr2[$i2++] = " 2 => array( 'IpbWiki Discussion', 'act=ipbwiki&code=discussion'),\n";
$str = " 3 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
}
if (($settings2_found) and (trim($str) === "3 => array( 'IpbWiki Group Access', 'act=ipbwiki'),")) {
$added_to_settings2 = true;
$arr2[$i2++] = " 3 => array( 'IpbWiki SEO', 'act=ipbwiki&code=seo'),\n";
$str = " 4 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
}
if (($settings2_found) and (trim($str) === "4 => array( 'IpbWiki Group Access', 'act=ipbwiki'),")) {
$added_to_settings2 = true;
$arr2[$i2++] = " 4 => array( 'IpbWiki Namespaces', 'act=ipbwiki&code=namespaces'),\n";
$str = " 5 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
}
if (($settings2_found) and (trim($str) === "5 => array( 'IpbWiki Group Access', 'act=ipbwiki'),")) {
$added_to_settings2 = true;
$arr2[$i2++] = " 5 => array( 'IpbWiki Copyright Removal', 'act=ipbwiki&code=copyrightremoval'),\n";
$str = " 6 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
}
if (($settings2_found) and (trim($str) === "6 => array( 'IpbWiki Group Access', 'act=ipbwiki'),")) {
$added_to_settings2 = true;
$arr2[$i2++] = " 6 => array( 'IpbWiki Skin', 'act=ipbwiki&code=skin'),\n";
$str = " 7 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
}
if (trim($str) === '?>') {
// end of php found, let's add the IPBWIKI Settings...
if (!$settings2_found) {
$arr2[$i2++] = "// The settings below were automatically added by the IpbWiki installer.\n";
$arr2[$i2++] = "// If you make manual changes, please keep track in case you need to\n";
$arr2[$i2++] = "// recreate them later.\n";
$arr2[$i2++] = "\n";
$arr2[$i2++] = "// IpbWiki Administration Plugin\n";
$arr2[$i2++] = "\$PAGES[count(\$PAGES)+1] = array (\n";
$arr2[$i2++] = " 1 => array( 'IpbWiki Configuration', 'act=ipbwiki&code=setup'),\n";
$arr2[$i2++] = " 2 => array( 'IpbWiki Discussion', 'act=ipbwiki&code=discussion'),\n";
$arr2[$i2++] = " 3 => array( 'IpbWiki SEO', 'act=ipbwiki&code=seo'),\n";
$arr2[$i2++] = " 4 => array( 'IpbWiki Namespaces', 'act=ipbwiki&code=namespaces'),\n";
$arr2[$i2++] = " 5 => array( 'IpbWiki Copyright Removal', 'act=ipbwiki&code=copyrightremoval'),\n";
$arr2[$i2++] = " 6 => array( 'IpbWiki Skin', 'act=ipbwiki&code=skin'),\n";
$arr2[$i2++] = " 7 => array( 'IpbWiki Group Access', 'act=ipbwiki'),\n";
$arr2[$i2++] = " );\n";
if ($ipb13 == 1) {
$arr2[$i2++] = "\$CATS[count(\$CATS)+1] = 'IpbWiki';\n";
} else {
$arr2[$i2++] = "\$CATS[count(\$CATS)+1] = array( 'IpbWiki' , '#F9FFA2' );\n";
}
$arr2[$i2++] = "\$DESC[count(\$DESC)+1] = 'Manage your IpbWiki.';\n";
$arr2[$i2++] = "\n";
}
}
$arr2[$i2++] = $str;
}
fclose($fp);

// check if we need to modify index.php
// reset flag & counters...
$settings3_found = false;
$i3 = 0;
$j3 = 0;

$fp = fopen('index.php', 'r');
while( !feof($fp) ) {
$str = fgets($fp);
// 2.0
if (trim($str) === "'ipbwiki_discussion' => array ('ipbwiki_discussion', 'ipbwiki_discussion' ), // <-- this line was automatically added by the IPBWiki Installer.") {
$settings3_found = true;
}
// 1.3
if (trim($str) === "'ipbwiki_discussion' => 'ipbwiki_discussion', // <-- this line was automatically added by the IPBWiki Installer.") {
$settings3_found = true;
}
if (($ipb20 == 1) and (trim($str) === "'findpost' => array( 'findpost' , 'findpost' ),")) {
// target found, let's add the IPBWIKI Settings...
if (!$settings3_found) {
$arr3[$i3++] = " 'ipbwiki_discussion' => array ('ipbwiki_discussion', 'ipbwiki_discussion' ), // <-- this line was automatically added by the IPBWiki Installer.\n";
}
}
if (($ipb13 == 1) and (trim($str) === "'module' => 'modules',")) {
if (!$settings3_found) {
$arr3[$i3++] = " 'ipbwiki_discussion' => 'ipbwiki_discussion', // <-- this line was automatically added by the IPBWiki Installer.\n";
}
}
$arr3[$i3++] = $str;
}
fclose($fp);

// check if we need to modify sources/online.php
// reset flag & counters...
$settings4_found = false;
$i4 = 0;
$j4 = 0;
$cnt = 0;

$fp = fopen('sources/online.php', 'r');
while( !feof($fp) ) {
$str = fgets($fp);
// 2.0
if (trim($str) === "// MOD: IpbWiki") {
$settings4_found = true;
}
if (trim($str) === '$line = " {$ibforums->lang['. "'board_index'". ']}";' ) {
$cnt++;
}
if (($cnt == 2) and (trim($str)==="}")) {
$cnt++;
} else if (($cnt == 3) and (trim($str)==="}")) {
$cnt++;
}
if ($cnt == 4) {
// target found, let's add the IPBWIKI Settings...
$arr4[$i4++] = $str;
$arr4[$i4++] = " // MOD: IpbWiki\r\n";
$arr4[$i4++] = ' if ($sess[' . "'location'] == 'mod:ipbwiki') {\r\n";
$arr4[$i4++] = " \$line = \" <a href='{\$sess['location_1_type']}'>Viewing {\$sess['location_2_type']}</a> \";\r\n";
$str = " }\r\n";
$cnt = 999;
}
$arr4[$i4++] = $str;
}
fclose($fp);

// double check!
// check if we have write access on the sources/online.php file
if (!$settings4_found) {
if ( ! is_writable ('sources/online.php') ) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file sources/online.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
}
// check if we have write access on the forum admin_pages.php file...
if ($ipb13 == 1) {
$admin_pages = 'sources/Admin/admin_pages.php';
} else {
$admin_pages = 'sources/admin/admin_pages.php';
}
if (( ! $settings2_found) or ($added_to_settings2)) {
if ( ! is_writable ($admin_pages)) {
$this->print_top ('Checking file access permissions.');
// let's also check admin.php while we're busy...
if ( ! $settings1_found and ! is_writable ('admin.php')) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The files admin.php and " . $admin_pages . " are not writable, please chmod them to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
} else {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file " . $admin_pages . " is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
}
$this->print_footer();
return;
}
}

// check if we have write access on the forum admin.php file...
if ( ! $settings1_found ) {
if ( ! is_writable ('admin.php')) {
$this->print_top ('Checking file access permissions.');
echo "<td><p><form method='post' action='?act=re-entry'><B>The file admin.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
}

// check if we have write access on the forum admin.php file...
if ( ! $settings3_found ) {
if ( ! is_writable ('index.php')) {
$this->print_top ('Checking file access permissions.');
echo "<td><p><form method='post' action='?act=re-entry'><B>The file index.php is not writable, please chmod it to 777, then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
}

$this->print_top ("Installing...");

$this->add_row ("Appending IpbWiki processing to ..index.php...");
if (! $settings3_found) {
$fp = fopen('index.php', 'w');
while ($j3 <= $i3) {
fwrite ($fp, $arr3[$j3++]);
}
fclose ($fp);
} else {
$this->add_row ('Info: ..index.php was already modified for IpbWiki. Settings not reapplied.');
}

$this->add_row ("Appending IpbWiki processing to ..admin.php...");
if (! $settings1_found) {
$fp = fopen('admin.php', 'w');
while ($j1 <= $i1) {
fwrite ($fp, $arr1[$j1++]);
}
fclose ($fp);
} else {
$this->add_row ('Info: ..admin.php was already modified for IpbWiki. Settings not reapplied.');
}

$this->add_row ("Appending IpbWiki processing to .." . $admin_pages . "...");
if ((! $settings2_found) or ($added_to_settings2)) {
$fp = fopen($admin_pages, 'w');
while ($j2 <= $i2) {
fwrite ($fp, $arr2[$j2++]);
}
fclose ($fp);
} else {
$this->add_row ('Info: ..'. $admin_pages . ' was already modified for IpbWiki. Settings not reapplied.');
}

$this->add_row ("Appending IpbWiki processing to ..sources/online.php...");
if (! $settings4_found) {
$fp = fopen('sources/online.php', 'w');
while ($j4 <= $i4) {
fwrite ($fp, $arr4[$j4++]);
}
fclose ($fp);
} else {
$this->add_row ('Info: ..sources/online.php was already modified for IpbWiki. Settings not reapplied.');
}
} else {
$this->print_top ("Installing...");
}
}
require_once ('conf_global.php');

if ($ipb13 == 1) {
$INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mysql' : $INFO['sql_driver'];
require ( '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();
} else {
if ($ipb30 == 1) {
require ('ipbwiki_db.php');
$DB = new ipbwiki_db();
} else { // IPB 2.x
$INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mysql' : $INFO['sql_driver'];
require ( KERNEL_PATH.'class_db_'.strtolower($INFO['sql_driver']).".php" );
if ($ipb21 == 1 or $ipb20 == 1) {
$DB = new db_driver;
} else { // ipb 2.2 +
$classname = "db_driver_".$INFO['sql_driver'];
$DB = new $classname;
}
$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'] = 'sources/sql/'.strtolower($INFO['sql_driver']).'_queries.php';
$DB->obj['debug'] = 0;
$DB->connect();
}
}
$ibf_prefix = $INFO['sql_tbl_prefix'];

if ($ipb30 == 1) {
$DB->query ("SELECT app_id FROM ".$ibf_prefix."core_applications WHERE app_title = 'IpbWiki'");
if ($row = $DB->fetch_row()) {
$app_id = $row[app_id];
$DB->query ("UPDATE ".$ibf_prefix."core_applications" .
" SET app_version = '" . IPBWIKI_HUMAN_VER . "', app_long_version = " . IPBWIKI_LONG_VER .
" WHERE app_id = " . $app_id );
} else {
$DB->query ("SELECT MAX(app_id) as app_id FROM ".$ibf_prefix."core_applications");
if ($row = $DB->fetch_row()) {
$app_id = $row[app_id] + 1;
$DB->query ("INSERT INTO ".$ibf_prefix."core_applications" .
" (app_id, app_title, app_public_title, app_description, app_author, app_version, app_long_version, app_directory, app_added, app_position, app_protected, app_enabled, app_location) " .
"VALUES " .
" (" . $app_id . ", 'IpbWiki', 'Wiki', 'Integration of Invision Power Board and MediaWiki', 'Peter De Decker', '" . IPBWIKI_HUMAN_VER . "', " . IPBWIKI_LONG_VER . ", 'ipbwiki', 1246304128, 0, 0, 1, 'other') ");
}
}

// admin module
$DB->query ("SELECT sys_module_id FROM ".$ibf_prefix."core_sys_module WHERE sys_module_title = 'IpbWiki' and sys_module_admin = 1");
if ($row = $DB->fetch_row()) {
$module_id = $row[sys_module_id];
$DB->query ("UPDATE ".$ibf_prefix."core_sys_module" .
" SET sys_module_version = '" . IPBWIKI_HUMAN_VER . "'" .
" WHERE sys_module_id = " . $module_id );
} else {
$DB->query ("SELECT MAX(sys_module_id) as sys_module_id FROM ".$ibf_prefix."core_sys_module");
if ($row = $DB->fetch_row()) {
$module_id = $row[sys_module_id] + 1;
$sql = "INSERT INTO ".$ibf_prefix."core_sys_module" .
" (sys_module_id, sys_module_title, sys_module_application, sys_module_key, sys_module_description, sys_module_version, sys_module_protected, sys_module_visible, sys_module_admin) " .
"VALUES " .
" (" . $module_id . ", 'IpbWiki', 'ipbwiki', 'ipbwiki', 'IpbWiki: Integration of Invision Power Board and MediaWiki', '" . IPBWIKI_HUMAN_VER . "', '1', 1, 1) ";
$DB->query ($sql);
}
}

// public module
$DB->query ("SELECT sys_module_id FROM ".$ibf_prefix."core_sys_module WHERE sys_module_title = 'IpbWiki' and sys_module_admin = 0");
if ($row = $DB->fetch_row()) {
$module_id = $row[sys_module_id];
$DB->query ("UPDATE ".$ibf_prefix."core_sys_module" .
" SET sys_module_version = '" . IPBWIKI_HUMAN_VER . "'" .
" WHERE sys_module_id = " . $module_id );
} else {
$DB->query ("SELECT MAX(sys_module_id) as sys_module_id FROM ".$ibf_prefix."core_sys_module");
if ($row = $DB->fetch_row()) {
$module_id = $row[sys_module_id] + 1;
$sql = "INSERT INTO ".$ibf_prefix."core_sys_module" .
" (sys_module_id, sys_module_title, sys_module_application, sys_module_key, sys_module_description, sys_module_version, sys_module_protected, sys_module_visible, sys_module_admin) " .
"VALUES " .
" (" . $module_id . ", 'IpbWiki', 'ipbwiki', 'ipbwiki', 'IpbWiki: Integration of Invision Power Board and MediaWiki', '" . IPBWIKI_HUMAN_VER . "', '1', 1, 0) ";
$DB->query ($sql);
}
}
}

if (($ipb20 == 0) and ($ipb13 == 0) and ($ipb30 == 0)) { // IPB 2.1, 2.2 or 2.3
// Load xml class
require( KERNEL_PATH.'class_xml.php' );

// let's import the xml file...
if (! file_exists ("ipbwiki.xml")) {
echo "<td><p><form method='post' action='?act=re-entry'><B>The file ipbwiki.xml does not exist, please upload the file and then click the button below to try again.<p><input type='submit' value='Try again'></form></td>";
$this->print_footer();
return;
}
// read the file...
$content = implode( '', @file("ipbwiki.xml") );
// Get current components.
$DB->simple_construct( array( 'select' => 'com_id, com_section',
'from' => 'components',
'order' => 'com_id' ) );
$DB->simple_exec();
while ( $row = $DB->fetch_row() ) {
$cur_components[ $row['com_section'] ] = $row['com_id'];
}
$xml = new class_xml();
// Unpack the datafile
$xml->xml_parse_document( $content );
// pArse
$fields = array( 'com_title' , 'com_description', 'com_author' , 'com_url', 'com_version', 'com_menu_data',
'com_enabled' , 'com_safemode' , 'com_section', 'com_filename', 'com_url_title', 'com_url_uri' );
if ( ! is_array( $xml->xml_array['componentexport']['componentgroup']['component'][0] ) ) {
// Ensure [0] is populated
$tmp = $xml->xml_array['componentexport']['componentgroup']['component'];
unset($xml->xml_array['componentexport']['componentgroup']['component']);
$xml->xml_array['componentexport']['componentgroup']['component'][0] = $tmp;
}

foreach( $xml->xml_array['componentexport']['componentgroup']['component'] as $id => $item )
{
$newrow = array();
foreach( $fields as $f ) {
$newrow[$f] = $item[ $f ]['VALUE'];
}
$DB->force_data_type = array( 'com_version' => 'string' );
if ( $cur_components[ $item['com_section']['VALUE'] ] ) { // Update
$DB->do_update( 'components', $newrow, 'com_id='.$cur_components[ $item['com_section']['VALUE'] ] );
} else { // Insert
$newrow['com_date_added'] = time();
$DB->do_insert( 'components', $newrow );
}
}
}

// make a second db connection...
if ($ipb13 == 1) {
$INFO['sql_driver'] = !$INFO['sql_driver'] ? 'mysql' : $INFO['sql_driver'];
//require ( 'sources/Drivers/'.$INFO['sql_driver']).".php" );
$DB2 = new db_driver;
$DB2->obj['sql_database'] = $INFO['sql_database'];
$DB2->obj['sql_user'] = $INFO['sql_user'];
$DB2->obj['sql_pass'] = $INFO['sql_pass'];
$DB2->obj['sql_host'] = $INFO['sql_host'];
$DB2->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
$DB2->connect();
} else {
if ($ipb30 == 1) {
$DB2 = new ipbwiki_db();
} else { // IPB 2.x
if ($ipb21 == 1 or $ipb20 == 1) {
$DB2 = new db_driver;
} else { // ipb 2.2 +
$DB2 = new $classname;
}
$DB2->obj['sql_database'] = $INFO['sql_database'];
$DB2->obj['sql_user'] = $INFO['sql_user'];
$DB2->obj['sql_pass'] = $INFO['sql_pass'];
$DB2->obj['sql_host'] = $INFO['sql_host'];
$DB2->obj['sql_tbl_prefix'] = $INFO['sql_tbl_prefix'];
$DB2->obj['use_shutdown'] = 0;
$DB2->obj['query_cache_file'] = 'sources/sql/'.strtolower($INFO['sql_driver']).'_queries.php';
$DB2->obj['debug'] = 0;
$DB2->connect();
}
}

// add tables to the database...
if (strcasecmp($INFO['sql_driver'],'mssql') == 0) {
//-------------------------------------------------------------------------------------------------------------------------------
// MsSQL
//-------------------------------------------------------------------------------------------------------------------------------
$this->add_row ("Adding tables to (mssql) database...");
$DB->allow_sub_select=1;
$sql="IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '" . $ibf_prefix . "ipbwiki_conf') " .
"CREATE TABLE " . $ibf_prefix . "ipbwiki_conf (" .
" conf_id char(10) NOT NULL, " .
" conf_value text, " .
"PRIMARY KEY (conf_id) " .
");";
$res = $DB->query ($sql);

$DB->allow_sub_select=1;
$sql="IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '" . $ibf_prefix . "ipbwiki_group') " .
"CREATE TABLE " . $ibf_prefix . "ipbwiki_group (" .
" g_id int NOT NULL, " .
" posts int NOT NULL, " .
" ug_group char(16) NOT NULL default '', " .
" PRIMARY KEY (g_id,posts) " .
");";
$res = $DB->query ($sql);

$DB->allow_sub_select=1;
$sql="IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '" . $ibf_prefix . "ipbwiki_group_rights') " .
"CREATE TABLE " . $ibf_prefix . "ipbwiki_group_rights ( " .
" g_id int NOT NULL, " .
// bits for ipbwiki rights...
" ir_read tinyint default 0, " .
" ir_edit tinyint default 0, " .
" ir_minoredit tinyint default 0, " .
" ir_createpage tinyint default 0, " .
" ir_createtalk tinyint default 0, " .
" ir_move tinyint default 0, " .
" ir_delete tinyint default 0, " .
" ir_deletedhistory tinyint default 0, " .
" ir_undelete tinyint default 0, " .
" ir_protect tinyint default 0, " .
" ir_block tinyint default 0, " .
" ir_userrights tinyint default 0, " .
" ir_createaccount tinyint default 0, " .
" ir_upload tinyint default 0, " .
" ir_reupload tinyint default 0, " .
" ir_reuploadshared tinyint default 0, " .
" ir_rollback tinyint default 0, " .
" ir_patrol tinyint default 0, " .
" ir_import tinyint default 0, " .
" ir_importupload tinyint default 0, " .
" ir_editinterface tinyint default 0, " .
" ir_siteadmin tinyint default 0, " .
" ir_bot tinyint default 0, " .
" ir_asksql tinyint default 0, " .
" ir_checkuser tinyint default 0, " .
" ir_makesysop tinyint default 0, " .
" ir_viewrate tinyint default 0, " .
" ir_canrate tinyint default 0, " .
// number of posts required before the right is applied...
" ir_read_posts_req int default 0, " .
" ir_edit_posts_req int default 0, " .
" ir_minoredit_posts_req int default 0, " .
" ir_createpage_posts_req int default 0, " .
" ir_createtalk_posts_req int default 0, " .
" ir_move_posts_req int default 0, " .
" ir_delete_posts_req int default 0, " .
" ir_deletedhistory_posts_req int default 0, " .
" ir_undelete_posts_req int default 0, " .
" ir_protect_posts_req int default 0, " .
" ir_block_posts_req int default 0, " .
" ir_userrights_posts_req int default 0, " .
" ir_createaccount_posts_req int default 0, " .
" ir_upload_posts_req int default 0, " .
" ir_reupload_posts_req int default 0, " .
" ir_reuploadshared_posts_req int default 0, " .
" ir_rollback_posts_req int default 0, " .
" ir_patrol_posts_req int default 0, " .
" ir_import_posts_req int default 0, " .
" ir_importupload_posts_req int default 0, " .
" ir_editinterface_posts_req int default 0, " .
" ir_siteadmin_posts_req int default 0, " .
" ir_bot_posts_req int default 0, " .
" ir_asksql_posts_req int default 0, " .
" ir_checkuser_posts_req int default 0, " .
" ir_makesysop_posts_req int default 0, " .
" ir_viewrate_posts_req int default 0, " .
" ir_canrate_posts_req int default 0, " .
" PRIMARY KEY (g_id) " .
");";
$res = $DB->query ($sql);

$DB->allow_sub_select=1;
$sql="IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '" . $ibf_prefix . "ipbwiki_discussion_topic') " .
"CREATE TABLE " . $ibf_prefix . "ipbwiki_discussion_topic (" .
" id int IDENTITY(1,1) NOT NULL, " .
" topic_id int NULL, " .
" member_id int NOT NULL, " .
" article_title varchar(255), " .
" article_url varchar(255), " .
" article_content text NULL, " .
" namespace int NULL, " .
" PRIMARY KEY (id) " .
"); " .
"CREATE INDEX idx1_".$ibf_prefix."ipbwiki_discussion_topic ON " . $ibf_prefix . "ipbwiki_discussion_topic ( article_title )";
$res = $DB->query ($sql);

$DB->allow_sub_select=1;
$sql="IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '" . $ibf_prefix . "ipbwiki_skin') " .
"CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_skin` (" .
" `skin_id` int NOT NULL, " .
" `skin_type` int NOT NULL, " .
" `custom_skin_name` varchar(100) NOT NULL DEFAULT '', " .
" `logo_picture` varchar(255) NOT NULL DEFAULT '', " .
" prerendered_css text NULL, " .
" topmenul text NULL, " .
" topmenulc text NULL, " .
" topmenur text NULL, " .
" topmenurc text NULL, " .
" leftmenu text NULL, " .
" leftmenuc text NULL, " .
" PRIMARY KEY (skin_id) " .
");";
$res = $DB->query ($sql);

} else { // mysql
//-------------------------------------------------------------------------------------------------------------------------------
// MySQL
//-------------------------------------------------------------------------------------------------------------------------------
$this->add_row ("Adding tables to (mysql) database...");
$sql="CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_conf` (" .
" `conf_id` char(10) NOT NULL, " .
" `conf_value` text, " .
"PRIMARY KEY (conf_id) " .
") ENGINE=InnoDB;";
$res = $DB->query ($sql);

$sql="CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_group` (" .
" g_id int(3) NOT NULL, " .
" posts mediumint(6) NOT NULL, " .
" ug_group char(16) NOT NULL default '', " .
" PRIMARY KEY (g_id,posts) " .
") ENGINE=InnoDB;";
$res = $DB->query ($sql);

$sql="CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_group_rights` ( " .
" g_id int(3) NOT NULL, " .
// bits for ipbwiki rights...
" ir_read tinyint(1) default 0, " .
" ir_edit tinyint(1) default 0, " .
" ir_minoredit tinyint(1) default 0, " .
" ir_createpage tinyint(1) default 0, " .
" ir_createtalk tinyint(1) default 0, " .
" ir_move tinyint(1) default 0, " .
" ir_delete tinyint(1) default 0, " .
" ir_deletedhistory tinyint(1) default 0, " .
" ir_undelete tinyint(1) default 0, " .
" ir_protect tinyint(1) default 0, " .
" ir_block tinyint(1) default 0, " .
" ir_userrights tinyint(1) default 0, " .
" ir_createaccount tinyint(1) default 0, " .
" ir_upload tinyint(1) default 0, " .
" ir_reupload tinyint(1) default 0, " .
" ir_reuploadshared tinyint(1) default 0, " .
" ir_rollback tinyint(1) default 0, " .
" ir_patrol tinyint(1) default 0, " .
" ir_import tinyint(1) default 0, " .
" ir_importupload tinyint(1) default 0, " .
" ir_editinterface tinyint(1) default 0, " .
" ir_siteadmin tinyint(1) default 0, " .
" ir_bot tinyint(1) default 0, " .
" ir_asksql tinyint(1) default 0, " .
" ir_checkuser tinyint(1) default 0, " .
" ir_makesysop tinyint(1) default 0, " .
" ir_viewrate tinyint default 0, " .
" ir_canrate tinyint default 0, " .
// number of posts required before the right is applied...
" ir_read_posts_req mediumint(6) default 0, " .
" ir_edit_posts_req mediumint(6) default 0, " .
" ir_minoredit_posts_req mediumint(6) default 0, " .
" ir_createpage_posts_req mediumint(6) default 0, " .
" ir_createtalk_posts_req mediumint(6) default 0, " .
" ir_move_posts_req mediumint(6) default 0, " .
" ir_delete_posts_req mediumint(6) default 0, " .
" ir_deletedhistory_posts_req mediumint(6) default 0, " .
" ir_undelete_posts_req mediumint(6) default 0, " .
" ir_protect_posts_req mediumint(6) default 0, " .
" ir_block_posts_req mediumint(6) default 0, " .
" ir_userrights_posts_req mediumint(6) default 0, " .
" ir_createaccount_posts_req mediumint(6) default 0, " .
" ir_upload_posts_req mediumint(6) default 0, " .
" ir_reupload_posts_req mediumint(6) default 0, " .
" ir_reuploadshared_posts_req mediumint(6) default 0, " .
" ir_rollback_posts_req mediumint(6) default 0, " .
" ir_patrol_posts_req mediumint(6) default 0, " .
" ir_import_posts_req mediumint(6) default 0, " .
" ir_importupload_posts_req mediumint(6) default 0, " .
" ir_editinterface_posts_req mediumint(6) default 0, " .
" ir_siteadmin_posts_req mediumint(6) default 0, " .
" ir_bot_posts_req mediumint(6) default 0, " .
" ir_asksql_posts_req mediumint(6) default 0, " .
" ir_checkuser_posts_req mediumint(6) default 0, " .
" ir_makesysop_posts_req mediumint(6) default 0, " .
" ir_viewrate_posts_req int default 0, " .
" ir_canrate_posts_req int default 0, " .
" PRIMARY KEY (g_id) " .
") ENGINE=InnoDB;";
$res = $DB->query ($sql);

$sql="CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_discussion_topic` (" .
" `id` int(10) NOT NULL auto_increment, " .
" `topic_id` int(10) NULL, " .
" `member_id` int(10) NOT NULL, " .
" `article_title` varchar(255), " .
" `article_url` varchar(255), " .
" `article_content` text NULL, " .
" `namespace` int NULL, " .
" PRIMARY KEY (id), " .
" KEY discussion_topic (article_title) " .
") ENGINE=InnoDB;";
$res = $DB->query ($sql);

$sql="CREATE TABLE IF NOT EXISTS `" . $ibf_prefix . "ipbwiki_skin` (" .
" `skin_id` int(10) NOT NULL, " .
" `skin_type` int(1) NOT NULL, " .
" `custom_skin_name` varchar(100) NOT NULL DEFAULT '', " .
" `logo_picture` varchar(255) NOT NULL DEFAULT '', " .
" prerendered_css text NULL, " .
" topmenul text NULL, " .
" topmenulc text NULL, " .
" topmenur text NULL, " .
" topmenurc text NULL, " .
" leftmenu text NULL, " .
" leftmenuc text NULL, " .
" PRIMARY KEY (skin_id) " .
") ENGINE=InnoDB;";
$res = $DB->query ($sql);

if (($DB->field_exists( 'article_content', $ibf_prefix.'ipbwiki_discussion_topic') == 0) and ($DB->field_exists( 'article_content', 'ipbwiki_discussion_topic') == 0)) {
$this->add_row ("Upgrading ipbwiki_discussion_topic table...");
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_discussion_topic ADD article_content text NULL";
$res = $DB->query ($sql);
}
if (($DB->field_exists( 'namespace', $ibf_prefix.'ipbwiki_discussion_topic') == 0) and ($DB->field_exists( 'namespace', 'ipbwiki_discussion_topic') == 0)) {
$this->add_row ("Upgrading ipbwiki_discussion_topic table...");
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_discussion_topic ADD namespace int NULL";
$res = $DB->query ($sql);
}

if (($DB->field_exists( 'ir_viewrate', $ibf_prefix.'ipbwiki_group_rights') == 0) and ($DB->field_exists( 'ir_viewrate', 'ipbwiki_group_rights') == 0)) {
$this->add_row ("Upgrading ipbwiki_group_rights table...");
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_viewrate tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_canrate tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_viewrate_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_canrate_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
}

if (($DB->field_exists( 'topmenul', $ibf_prefix.'ipbwiki_skin') == 0) and ($DB->field_exists( 'topmenul', 'ipbwiki_skin') == 0)) {
$this->add_row ("Upgrading ipbwiki_skin table...");
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD topmenul text NULL";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD topmenulc text NULL";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD topmenur text NULL";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD topmenurc text NULL";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD leftmenu text NULL";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_skin ADD leftmenuc text NULL";
$res = $DB->query ($sql);
}

if (($ipb13 == 0) and ($DB->field_exists( 'ir_minoredit', $ibf_prefix.'ipbwiki_group_rights') == 0) and ($DB->field_exists( 'ir_minoredit', 'ipbwiki_group_rights') == 0)) {
$this->add_row ("Upgrading ipbwiki_group_rights table...");
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_minoredit tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_createpage tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_createtalk tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_reupload tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_reuploadshared tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_deletedhistory tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_import tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_importupload tinyint(1) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_minoredit_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_createpage_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_createtalk_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_reupload_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_reuploadshared_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_deletedhistory_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_import_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);
$sql="ALTER TABLE " . $ibf_prefix . "ipbwiki_group_rights ADD ir_importupload_posts_req mediumint(6) default 0";
$res = $DB->query ($sql);

$this->add_row ("Converting ipbwiki_group bitmasks...");
$DB->query ("SELECT * FROM ".$ibf_prefix."ipbwiki_group");
while ($group = $DB->fetch_row()) {
$mask = 0;
if (substr($group['ug_group'], 0, 1) == 1) { $mask += 1; } // read
if (substr($group['ug_group'], 1, 1) == 1) { $mask += 2; } // createaccount
if (substr($group['ug_group'], 2, 1) == 1) { $mask += 4; } // edit
if (substr($group['ug_group'], 3, 1) == 1) { $mask += 64; } // upload
if (substr($group['ug_group'], 4, 1) == 1) { $mask += 512; } // move
if (substr($group['ug_group'], 5, 1) == 1) { $mask += 1024; } // delete
if (substr($group['ug_group'], 6, 1) == 1) { $mask += 4096; } // undelete
if (substr($group['ug_group'], 7, 1) == 1) { $mask += 8192; } // protect
if (substr($group['ug_group'], 8, 1) == 1) { $mask += 16384; } // block
if (substr($group['ug_group'], 9, 1) == 1) { $mask += 32768; } // rollback
if (substr($group['ug_group'], 10, 1) == 1) { $mask += 65536; } // patrol
if (substr($group['ug_group'], 11, 1) == 1) { $mask += 524288; } // editinterface
if (substr($group['ug_group'], 12, 1) == 1) { $mask += 1048576; } // siteadmin
if (substr($group['ug_group'], 13, 1) == 1) { $mask += 2097152; } // bot
if (substr($group['ug_group'], 14, 1) == 1) { $mask += 4194304; } // asksql
if (substr($group['ug_group'], 15, 1) == 1) { $mask += 8388608; } // checkuser
if (substr($group['ug_group'], 16, 1) == 1) { $mask += 16777216; } // userrights (useless right if you use ipbwiki)
if (substr($group['ug_group'], 17, 1) == 1) { $mask += 33554432; } // makesysop (useless right if you use ipbwiki)

$DB2->query ("UPDATE " . $ibf_prefix . "ipbwiki_group SET ug_group='". $mask . "' WHERE g_id=" . $group['g_id'] . " AND posts = " . $group['posts']);
}
}
}

if ($ipb30 == 0) {
$do = 1;
$DB->query ("select * from ".$ibf_prefix."ipbwiki_conf where conf_id='copyrr'" );
if ($row = $DB->fetch_row()) {
if(strlen($row['conf_value']) > 1) {
$do = 0;
}
}
if (($ipb13 == 0) and ($ipb30 == 0) and ($do == 1)) {
$this->add_row("Rebuilding css...");
// image url setting
$DB->query ("select * from ".$ibf_prefix."conf_settings where conf_key='ipb_img_url'" );
if ($row = $DB->fetch_row()) {
$ipb_img_url = ( $row['conf_value'] != '' ) ? $row['conf_value'] : $row['conf_default'] ;
$ipb_img_url = ($ipb_img_url == '{blank}' ) ? '' : $ipb_img_url;
} else {
$ipb_img_url = '';
}

$DB->query ('SELECT set_skin_set_id, set_wrapper,set_cache_wrapper,set_css_method, set_css, set_cache_css, set_image_dir FROM '.$ibf_prefix.'skin_sets');
while ($row = $DB->fetch_row()) {
$row['set_wrapper'] = $this->do_replace($row['set_wrapper']);
$row['set_cache_wrapper'] = $this->do_replace($row['set_cache_wrapper']);
if ($row['set_css_method'] == 0) { // WTF???!!!
$row['set_css'] = $this->do_css($row['set_css']);
} else {
$row['set_css'] = $this->do_css($row['set_cache_css']);
}
$DB2->query ('UPDATE '.$ibf_prefix."skin_sets SET set_css='".$row['set_css']."',set_wrapper='".$row['set_wrapper']."', set_cache_wrapper='".$row['set_cache_wrapper']."' WHERE set_skin_set_id=".$row['set_skin_set_id']);

$css = "/*------------------------------------------------------------------*/\n";
$css .= "/* FILE GENERATED BY INVISION POWER BOARD */\n";
$css .= "/* DO NOT EDIT BY HAND WITHOUT RESYNCHRONISING BACK TO THE DATABASE */\n";
$css .= "/* OR CHANGES TO THIS FILE WILL BE LOST WHEN NEXT EDITED FROM THE */\n";
$css .= "/* ADMIN CONTROL PANEL */\n";
$css .= "/* STYLE DIRECTORY: <#IMG_DIR#> */\n";
$css .= "/* CACHE FILE: Generated: ".gmdate( "D, d M Y H:i:s \G\M\T" )." */\n";
$css .= "/*------------------------------------------------------------------*/\n\n";
$css .= "/*~START CSS~*/\n\n";
$css .= $row['set_css'];

// make sure directories are correct...
$css = str_replace( "url({$row['set_image_dir']}/", "url(style_images/<#IMG_DIR#>/", $css );
$css = str_replace( "url(<#IMG_DIR#>/", "url(style_images/<#IMG_DIR#>/", $css );
$css = preg_replace( "#url\((style_images/)?\d+?/#i", "url(style_images/<#IMG_DIR#>/", $css );
if ( $ipb_img_url ) {
if ( ! preg_match( "#/$#", $ipb_img_url ) )
{
$ipb_img_url .= '/';
}

$css = preg_replace( "#url\(('|\")?style_images/#", "url(\\1{$ipb_img_url}style_images/", $css );
}
$css = str_replace ('<#IMG_DIR#>', $row['set_image_dir'], $css);
$css = str_replace( "\r\n" , "\n", $css );
$css = str_replace( "\r" , "\n", $css );
if ( ! $ipb_img_url ) {
$css = preg_replace( '#([\(|\s*|\'])(style_images/)#', '\\1', $css );
}
$css = str_replace ("\0","",$css);
$css_filename = "style_images/css_".$row['set_skin_set_id'].".css";
if (is_writable($css_filename)) {
if ( $fh = fopen( $css_filename, 'w' ) ) {
fwrite ( $fh, $css );
fclose($fh);
}
}
}
}
}
if (($ipb30 == 1) and ($do == 1)) {
$this->add_row("Rebuilding css...");
// image url setting
$DB->query ("select * from ".$ibf_prefix."core_sys_conf_settings where conf_key='ipb_img_url'" );
if ($row = $DB->fetch_row()) {
$ipb_img_url = ( $row['conf_value'] != '' ) ? $row['conf_value'] : $row['conf_default'] ;
$ipb_img_url = ($ipb_img_url == '{blank}' ) ? '' : $ipb_img_url;
} else {
$ipb_img_url = '';
}
}

if (($ipb20 == 0) and ($ipb13 == 0)) { // IPB 2.1 or higher...
// Enlarge the session table to allow bigger locations...
$this->add_row ("Enlarging session storage...");
$DB->query ("ALTER TABLE ". $ibf_prefix ."sessions MODIFY location_1_type VARCHAR(250)"); // will store wiki - url
$DB->query ("ALTER TABLE ". $ibf_prefix ."sessions MODIFY location_2_type VARCHAR(250)"); // will store wiki - location

// set the wiki link in the board header correctly
if ($ipb30 == 0) {
$DB->query ("SELECT * FROM ".$ibf_prefix."ipbwiki_conf WHERE conf_id='WikiPath'");
if ($res = $DB->fetch_row()) {
$wiki_path = $res['conf_value'];
$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 = mysql_escape_string($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 { // IPB 1.3 or IPB 2.0
if ($DB->field_exists( 'location_1_type', $ibf_prefix.'sessions') == 0) {
$this->add_row ("Enhancing session storage...");
$DB->query ("ALTER TABLE ". $ibf_prefix ."sessions ADD location_1_type VARCHAR(250)"); // will store wiki - url
$DB->query ("ALTER TABLE ". $ibf_prefix ."sessions ADD location_2_type VARCHAR(250)"); // will store wiki - location
}
}

chdir (WRK_DIR);

$this->add_row('');
$this->add_row('');
$this->add_row('<H3>Securing installation...</H3>');
$this->add_row('');
$print='';
ob_start(); // catch the annoying chmod warnings...
if ($ipb20 == 1) {
$print='<tr><td>Please chmod the following files to 644:</td></tr>';
if (!chmod ('admin.php', 0644)) {
$print=$print.'<tr><td> - forums/admin.php</td></tr>';
}
if (!chmod ('/sources/admin/admin_pages.php', 0644)) {
$print=$print.'<tr><td> - forums/sources/admin/admin_pages.php</td></tr>';
}
}
ob_end_clean();
echo $print;

$this->add_row('Please <b>delete</b> the <b>ipbwiki_setup.php</b> file in your forums folder. (If you need to reinstall you can always upload it again later.)');
$this->add_row('');
$this->add_row('');
$this->add_row('After you executed the above actions, click the button below to go to your Forum Admin CP Panel.');
$this->add_row('');
if ($ipb30 == 1) {
$this->add_row('When logged in to your Admin CP Panel, go to My Apps -&gt; IpbWiki and assign ipbwiki permissions to all user groups.');
} else {
$this->add_row('When logged in to your Admin CP Panel, scroll to the bottom and open the group "IpbWiki" and assign ipbwiki permissions to all user groups.');
}

if ($ipb30 == 1) {
echo "<td><p><form method='post' action='" . $INFO['board_url'] . '/' . CP_DIRECTORY . "/index.php'><input type='submit' value='Go to forum Admin CP Panel'></form></td>";
} else {
echo "<td><p><form method='post' action='{$INFO['board_url']}/admin.php'><input type='submit' value='Go to forum Admin CP Panel'></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( "&#032;", " ", $val );
$val = str_replace( "&" , "&amp;" , $val );
$val = str_replace( "<!--" , "&#60;&#33;--" , $val );
$val = str_replace( "-->" , "--&#62;" , $val );
$val = preg_replace( "/<script/i" , "&#60;script" , $val );
$val = str_replace( ">" , "&gt;" , $val );
$val = str_replace( "<" , "&lt;" , $val );
$val = str_replace( "\"" , "&quot;" , $val );
$val = preg_replace( "/\n/" , "<br />" , $val ); // Convert literal newlines
$val = preg_replace( "/\\\$/" , "&#036;" , $val );
$val = preg_replace( "/\r/" , "" , $val ); // Remove literal carriage returns
$val = str_replace( "!" , "&#33;" , $val );
$val = str_replace( "'" , "&#39;" , $val ); // IMPORTANT: It helps to increase sql query safety.
$val = $this->txt_stripslashes ($val);
$val = preg_replace( "/\\\(?!&amp;#|\?#)/", "&#092;", $val );
return $val;
}

function unclean_value ($val) {
$val = str_replace( "&#60;&#33;--" , "<!--" , $val );
$val = str_replace( "--&#62;" , "-->" , $val );
$val = str_replace( "&#60;script" , "<script" , $val );
$val = str_replace( "&gt;" , ">" , $val );
$val = str_replace( "&lt;" , "<" , $val );
$val = str_replace( "&quot;" , "\"" , $val );
$val = str_replace( "<br />" , "\\n" , $val ); // Convert literal newlines
$val = str_replace( "&#036;" , "\$" , $val );
$val = str_replace( "&#33;" , "!" , $val );
$val = str_replace( "&#39;" , "'" , $val ); // IMPORTANT: It helps to increase sql query safety.
$val = str_replace( "&amp;" , "&" , $val );
return $val;
}
}

new ipbwiki_setup();
?>
[/code]

since 3.3.4 removed some columns i removed them also, this should enable you to install it, i will also be doing this for future versions if problems persists.

Discussion


Log in to post a comment.