| <?php |
| |
| |
| |
| |
| |
| |
| |
| |
| class NEWBB_TO_PHPBB |
| { |
| |
| |
| |
| |
| |
| function __construct() |
| { |
| |
| session_start(); |
| |
| |
| if ( isset( $_GET['action'] ) && $_GET['action'] == 'restore' ) |
| { |
| |
| session_unset(); |
| |
| |
| header('Location: index.php'); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| |
| function config_verification( $next_step ) |
| { |
| global $db; |
| global $ldap; |
| global $html; |
| |
| $htmlblock = array(); |
| $error = 0; |
| |
| |
| if ( $ldap->do_bind() ) |
| { |
| array_push($htmlblock, $html->format_message('LDAP Configuration is correct', 'green')); |
| } |
| else |
| { |
| array_push( $htmlblock, $html->format_message('LDAP Configuration is incorrect', 'orange')); |
| $error++; |
| } |
| |
| |
| if ( $db->connect() === true ) |
| { |
| array_push( $htmlblock, $html->format_message('Common DB Configuration is correct', 'green')); |
| |
| |
| if ( $db->check_existance('xoops') === true ) |
| { |
| array_push( $htmlblock, $html->format_message('Xoops configuration is correct', 'green')); |
| } |
| else |
| { |
| array_push( $htmlblock, $html->format_message('Xoops configuration is incorrect', 'orange')); |
| $error++; |
| } |
| |
| |
| if ( $db->check_existance('phpbb') === true ) |
| { |
| array_push( $htmlblock, $html->format_message('phpBB configuration is correct', 'green')); |
| } |
| else |
| { |
| array_push( $htmlblock, $html->format_message('phpBB configuration is incorrect', 'orange')); |
| $error++; |
| } |
| } |
| else |
| { |
| array_push( $htmlblock, $html->format_message('Common DB Configuration is incorrect', 'orange')); |
| $error++; |
| } |
| |
| |
| if ( $error == 0 ) |
| { |
| $next_step++; |
| array_push( $htmlblock, |
| '<p class="action right"> |
| <input type="hidden" name="step" value="'.$next_step.'" /> |
| <input type="submit" name="Next" value="Next" /> |
| </p>'); |
| } |
| else |
| { |
| array_push($htmlblock, '<p class="action left"><img src="img/previous.png" alt="Previous" /><a href="index.php">Check your configuration</a></p>'); |
| } |
| |
| return $html->format_htmlblock($htmlblock); |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function copy_Users() |
| { |
| global $ldap; |
| global $db; |
| |
| $htmlblock = array('<h2>Users</h2>','<ul>'); |
| |
| |
| |
| |
| array_push($htmlblock,'<li>Cleanning up ... </li>'); |
| |
| $sql = sprintf('DELETE FROM %s.%susers WHERE user_id > 52;', |
| $db->db_phpbb_db, |
| $db->db_phpbb_tbl ); |
| $db->query( $sql ); |
| |
| |
| |
| array_push($htmlblock,'<li>Copying ... </li>'); |
| |
| $sql = sprintf("SELECT uname, |
| name, |
| email, |
| pass |
| FROM %s.%susers WHERE uid > 1", |
| $db->db_xoops_db, |
| $db->db_xoops_tbl ); |
| |
| $result = $db->query( $sql ); |
| |
| $counter = 0; |
| |
| while ( $entry = mysql_fetch_array( $result ) ) |
| { |
| |
| if ( $ldap->add_User( $entry ) === true ) |
| { |
| $counter++; |
| } |
| } |
| |
| array_push($htmlblock,'<li>'. $counter .' user(s) copied successfully.</li>','</ul>'); |
| |
| return $htmlblock; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function copy_Forums() |
| { |
| global $db; |
| |
| $htmlblock = array('<h2>Forums</h2>', '<ul>'); |
| |
| |
| |
| array_push( $htmlblock, '<li>Cleanning up ... </li>' ); |
| |
| $sql = sprintf("TRUNCATE %s.%sforums;", |
| $db->db_phpbb_db, |
| $db->db_phpbb_tbl ); |
| |
| $db->query( $sql ); |
| |
| |
| |
| array_push($htmlblock,'<li>Copying ... </li>'); |
| |
| $sql = sprintf("INSERT INTO %s.%sforums (forum_name, |
| forum_desc, |
| forum_topics, |
| forum_topics_real, |
| forum_type, |
| forum_posts) SELECT forum_name, |
| forum_desc, |
| forum_topics, |
| forum_topics, |
| (SELECT 1 AS forum_type), |
| forum_posts FROM %s.%sbb_forums;", |
| $db->db_phpbb_db, $db->db_phpbb_tbl, |
| $db->db_xoops_db, $db->db_xoops_tbl); |
| |
| $db->query( $sql ); |
| |
| |
| |
| $sql = sprintf('SELECT forum_id, left_id, right_id FROM %s.%sforums;', |
| $db->db_phpbb_db, |
| $db->db_phpbb_tbl ); |
| |
| $result = $db->query( $sql ); |
| |
| |
| |
| $left_id = 1; |
| $right_id = 2; |
| $counter = 0; |
| |
| while ( $row = mysql_fetch_array( $result ) ) |
| { |
| $sql = sprintf("UPDATE %s.%sforums SET left_id = %d, right_id = %d WHERE forum_id = %d;", |
| $db->db_phpbb_db, |
| $db->db_phpbb_tbl, |
| $left_id, |
| $right_id, |
| $row['forum_id']); |
| |
| $db->query( $sql ); |
| |
| $left_id = $left_id + 2; |
| $right_id = $left_id + 1; |
| |
| |
| |
| $counter++; |
| } |
| |
| |
| array_push( $htmlblock, '<li>' . $counter . ' forum(s) copied successfully.</li>', '</ul>'); |
| |
| return $htmlblock; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| function copy_Topics() |
| { |
| global $db; |
| |
| $htmlblock = array('<h2>Topics</h2>','<ul>'); |
| |
| |
| |
| array_push( $htmlblock, '<li>Cleanning up ... </li>' ); |
| |
| $sql = sprintf("TRUNCATE %s.%stopics;", |
| $db->db_phpbb_db, |
| $db->db_phpbb_tbl ); |
| |
| $db->query( $sql ); |
| |
| |
| |
| array_push( $htmlblock, '<li>Copying ... </li>' ); |
| |
| $sql = sprintf("INSERT INTO %s.%stopics (forum_id, |
| topic_title, |
| topic_time, |
| topic_last_post_time, |
| topic_views, |
| topic_last_poster_id, |
| topic_poster, |
| topic_replies, |
| topic_replies_real) SELECT forum_id, |
| topic_title, |
| topic_time, |
| topic_time, |
| topic_views, |
| (SELECT 2 AS last_poster_id), |
| (SELECT 2 AS last_poster_id), |
| topic_replies, |
| topic_replies |
| FROM %s.%sbb_topics", |
| $db->db_phpbb_db, $db->db_phpbb_tbl, |
| $db->db_xoops_db, $db->db_xoops_tbl ); |
| |
| $db->query( $sql ); |
| |
| array_push( $htmlblock, '<li>' . mysql_affected_rows() . ' topic(s) copied successfully.</li>', '</ul>' ); |
| |
| return $htmlblock; |
| } |
| |
| |
| |
| |
| function copy_Posts() |
| { |
| global $db; |
| |
| $htmlblock = array('<h2>Posts</h2>','<ul>'); |
| |
| |
| |
| array_push($htmlblock,'<li>Cleanning up ... </li>'); |
| |
| $sql = sprintf("TRUNCATE %s.%sposts;", $db->db_phpbb_db, $db->db_phpbb_tbl); |
| |
| $db->query( $sql ); |
| |
| |
| |
| array_push( $htmlblock, '<li>Copying ... </li>'); |
| |
| $sql = sprintf("INSERT INTO %s.%sposts (topic_id, |
| forum_id, |
| poster_id, |
| post_time, |
| post_subject, |
| post_text) SELECT t1.topic_id, |
| t1.forum_id, |
| (SELECT 2 AS poster_id), |
| t1.post_time, |
| t1.subject, |
| t2.post_text |
| FROM %s.%sbb_posts t1 |
| LEFT JOIN %s.%sbb_posts_text t2 |
| ON t2.post_id = t1.post_id;", |
| $db->db_phpbb_db, $db->db_phpbb_tbl, |
| $db->db_xoops_db, $db->db_xoops_tbl, |
| $db->db_xoops_db, $db->db_xoops_tbl); |
| |
| $db->query( $sql ); |
| |
| array_push( $htmlblock, '<li>' . mysql_affected_rows() .' posts(s) copied successfully.</li>', '</ul>'); |
| |
| return $htmlblock; |
| } |
| |
| |
| |
| |
| function get_randomPass() |
| { |
| |
| $seed = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', |
| 'i', 'j', 'k', 'i', 'l', 'm', 'n', 'o', |
| 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', |
| 'y', 'z'); |
| |
| |
| foreach ( $seed as $value ) |
| { |
| array_push( $seed, strtoupper($value) ); |
| } |
| |
| |
| array_push( $seed, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' ); |
| |
| |
| array_push( $seed, '!', '@', '#', '$', '%', '=', '/','+' ); |
| |
| |
| $userPassword = ''; |
| $passwordLength = 20; |
| for ($i = 0; $i < $passwordLength; $i++) |
| { |
| $userPassword = $userPassword . $seed[array_rand($seed)]; |
| } |
| |
| return $userPassword; |
| } |
| |
| |
| |
| |
| |
| |
| function __destruct() |
| { |
| } |
| } |
| |
| $newbb_to_phpbb = new NEWBB_TO_PHPBB; |
| ?> |