Location: PHPKode > projects > board-tnk > board-tnk/include/create_delete_forum.inc
<?
// from now all elseif are about forum creation
switch($admin_action) {

case "create_forum":

// naming the new forums
?>
<center>
<form action="<?  print("$SELF"); ?>" method="post">
<input type="hidden" name="admin" value="admin">
<input type="hidden" name="n_forum_create" value="<? print("$n_forum_create"); ?>">
<input type="hidden" name="admin_action" value="create_forum_confirm">
<table border="1" cellspacing="5" cellpadding="5">
<tr class="head">
<td align="center">
<table border="1" cellspacing="5" cellpadding="5">
<?
for ($i=1;$i<=$n_forum_create;$i++){
        ?>
        <tr class="row1">
        <td>
        <b><?  print("$talk[17]"); ?>:</b>
        </td>
        <td>
        <input type="text" name="<? print("forum_create$i"); ?>" maxlength="25"></td>
        </tr>
        <?
}
?>
</table>
<br>
<input type="submit" value="<? print("$talk[55] $n_forum_create $talk[56]"); ?>">
</td>
</tr>
</table>
</form>
</center>
<br><br>

<?
break;
// end namig new forums


case "create_forum_confirm":

// confirmation of forum creation

// Check forum names are given
$checked="1";
for($i=1; $i<= $n_forum_create; $i++ ){
        $ff="forum_create".$i;
        $f=$$ff;
        if($f==""){$checked="0";}
}
if(!$checked){
        print("<center><h2>$talk[61]</h2></center>");
}else{
        ?>
        <center>
        <form action="<?  print("$SELF"); ?>" method="post">
        <input type="hidden" name="admin" value="admin">
        <input type="hidden" name="admin_action" value="create_forum_really">
        <input type="hidden" name="n_forum_create" value="<? print("$n_forum_create"); ?>">
        <table border="1" cellspacing="5" cellpadding="5">
        <tr class="head">
        <td align="center">
        <table border="1" cellspacing="5" cellpadding="5">
        <?
        for($i=1; $i<= $n_forum_create; $i++ ){
                $ff="forum_create".$i;
                $f=$$ff;
                ?>
                <input type="hidden" name="<? print("forum_create$i"); ?>" value="<? print("$f"); ?>">
                <tr class="row1">
                <td align="center">
                <b><? print("$f"); ?></b>
                </td>
                </tr>
                <?
        } // end for
        ?>
        <tr class="row1">
        <td>
        <input type="checkbox" name="confirm" value="yes"><b>&nbsp;<?  print("$talk[55]"); ?>&nbsp;</b>
        </td>
        </table>
        <br>
        <input type="submit" value="<?  print("$talk[62]"); ?>">
        </td>
        </tr>
        </table>
        </form>
        </center>
        <?
} // end if checked

break;
//end forum creation confirmation

case "create_forum_really":

// creation of the forum
if($confirm=="yes"){
        for($i=1; $i<= $n_forum_create; $i++){
                $ff="forum_create".$i;
                $f=$$ff;
                $f=$prefix.$f;
                $f=ereg_replace(" ","_",$f);
                $query="create table ".$f;
                $query=$query." (id int(11) not null auto_increment,";
                $query=$query."name varchar(25),icon int(11),msg text,reply int(11),";
                $query=$query."title varchar(50),date varchar(25), email varchar(50),";
                $query=$query."web varchar(50), primary key(id))";
                $checked=mysql_query($query);
                if(!$checked){
                        print("<center><H2>$talk[63]".mysql_errno().": ".mysql_error()."</H2></center>");
                        $error="1";
                }
        } // end for
        if(!$error){
                ?>
                <center><b><?  print("$talk[64]"); ?></b></center><br>
                <?
                include("include/create_forum.inc");
                }
}else{
        ?>
        <center><b><?  print("$talk[65]"); ?></b></center><br>
        <?
}
break;
// end forum real creation

// delete forum confirmation
case "delete_forum":

?>
<center>
<form action="<?  print("$SELF"); ?>" method="post">
<input type="hidden" name="forum_name" value="<? print("$forum_name");?>">
<input type="hidden" name="admin" value="<? print("$admin");?>">
<input type="hidden" name="admin_action" value="delete_forum_really">
<b><input type="submit" value="<?  print("$talk[58] $forum_name"); ?>"><b>
<input type="checkbox" name="confirm" value="yes"> <b><?  print("$talk[68]"); ?>
</form>
</center>
<br>
<?
break;
//end delete forum confirmation


//really delete forum
case "delete_forum_really":

if($confirm=="yes"){
        $forum=$prefix.$forum_name;
        $forum=ereg_replace(" ","_",$forum);
        $query="drop table ".$forum;
        $checked=mysql_query ($query);
        ?>
        <center><b><?  print("$talk[84]"); ?></b></center><br>
        <?
}else{
        ?>
        <center><b><?  print("$talk[65]"); ?></b></center><br>
        <?
}

// form to create forum
include("include/create_forum.inc");

break;
//end really delete forum


case "":
include("include/create_forum.inc");

break;

} // end switch on admin_action
Return current item: board-tnk