All pastes #758046 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-01 21:14 UTC
rendered paste body
<?php
/**
*
* @package phpBB3
* @version $Id: index.php,v 1.176 2007/10/05 14:30:06 acydburn Exp $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('');

$sql = "SELECT * FROM phpbb_rating";
$result = $db->sql_query($sql);

while($row = $db->sql_fetchrow($result))
{
	// okay looping through the old ratings, now obtain topic id and copy.
	$sql = "SELECT topic_id FROM " . POSTS_TABLE . " WHERE post_id = '" . $row['post_id'] . "'";
	$new_result = $db->sql_query($sql);
	$new_row = $db->sql_fetchrow($new_result);
	
	// insert
	$sql = "INSERT INTO phpbb_topics_evaluation (topic_id, evaluation, user_id) VALUES ('" . $new_row['topic_id'] . "', '" . $row['option_id'] . "', '" . $row['user_id'] . "');";
	$db->sql_query($sql);
}

?>