<?php
set_time_limit(0);
function crearForo($nombre, $foro_padre){
$query_Right_id = "SELECT right_id FROM phpbb_forums where forum_id=$foro_padre";
$Right_id = mysql_query($query_Right_id) or die(mysql_error());
$row_Right_id = mysql_fetch_assoc($Right_id);
$next_leftid = $row_Right_id['right_id'];
$next_rightid = $next_leftid+1;
$consulta = 'UPDATE phpbb_forums SET left_id = left_id + 2 where left_id >= '.$next_leftid .';';
mysql_query($consulta);
$consulta = 'UPDATE phpbb_forums SET right_id = right_id + 2 where right_id >= '.$next_leftid .';';
mysql_query($consulta);
$consulta = "INSERT phpbb_forums (forum_id,forum_type, parent_id, left_id,right_id, forum_parents, forum_name , forum_desc, forum_desc_bitfield, forum_rules) VALUES(null,1, $foro_padre,$next_leftid,$next_rightid,'[BLOB - 0 Bytes]','$nombre','[BLOB - 0 Bytes]','', '[BLOB - 0 Bytes]')".";";
mysql_query($consulta);
$id = mysql_insert_id() ;
$consulta="UPDATE phpbb_forums SET parent_id = 1, forum_type = 1, forum_status = 0, forum_parents = '', forum_link = '', forum_desc = '[BLOB - 0 Bytes]', forum_desc_uid = '', forum_desc_options = 7, forum_desc_bitfield = '', forum_rules = '[BLOB - 0 Bytes]', forum_rules_uid = '', forum_rules_options = 7, forum_rules_bitfield = '', forum_rules_link = '', forum_image = '', forum_style = 0, display_subforum_list = 1, display_on_index = 1, forum_topics_per_page = 0, enable_indexing = 1, enable_icons = 1, enable_prune = 0, prune_days = 0, prune_viewed = 0, prune_freq = 0, forum_flags = 32 WHERE forum_id = $ID";
mysql_query($consulta);
$consulta = "INSERT phpbb_acl_groups(group_id,forum_id,auth_option_id,auth_role_id,auth_setting) SELECT group_id, $id,auth_option_id,auth_role_id,auth_setting FROM phpbb_acl_groups WHERE forum_id = $foro_padre".';';
mysql_query($consulta);
}
$username = "root";
$password = "password";
$hostname = "localhost";
$dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
$selected = mysql_select_db("smf",$dbh);
$query = "SELECT * FROM tabla";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
while ($i < $num) {
crearForo( mysql_result($result,$i,"nombre_foro") , 1);
$i++;
}
?> |