Location: PHPKode > projects > PHPEcho CMS > modules/admin/modules/forum.php
<?php
/*  +--------------------------------------------
*   |
*   |     Product:       PHPEchoCMS
*   |     Author:        Anas Husseini
*   |     License:       GPL
*   |     Last updated:  16.02.07
*   |     For version:   1.5  
*   |     Desc:          Module for working with Forum module
*   |        
*   +--------------------------------------------
*/

if( !ADMIN_LOAD )
{
    die( "Base not loaded!" );
}

$mlang = $core->getlang("admin_forum");

echo "<br><center><a href='index.php?module=admin&act=forum'>".$mlang['001']."</a> | <a href='index.php?module=admin&act=forum&op=add'>".$mlang['002']."</a></center><br>";

switch ( @$_GET['op'] )
{
    case "add":
        add($mlang);
        break;
    case "edit":
        edit($mlang);
        break;
    case "delete":
        del($mlang);
        break;
    default:
        nlist($mlang);
}

function add($lang)
{
    $mlang = $lang;

    if ( @$_POST['name'] && $_POST['desc'] )
    { 
        $a = query ( "INSERT INTO ".PREFIX."sections VALUES ('', '".addslashes($_POST['name'])."', '".addslashes($_POST['desc'])."','".date("d-m-Y H:i")."')", 1);
        echo $mlang['003'];
    }
    else
    {
       echo "
       <form action='index.php?module=admin&act=forum&op=add' method='post'>
       ".$mlang['004']."<input type='text' name='name' size='50'><br>
       ".$mlang['005']."<input type='text' name='desc' size='50'><br>
       <input type='submit' value='".$mlang['006']."'>
       </form>
       ";
     }
}

function edit($lang)
{      
    $mlang = $lang;

    if ( @$_POST['name'] && $_POST['desc'] )
    {
        query ( "UPDATE `".PREFIX."sections` SET name = '".addslashes($_POST['name'])."', `desc` = '".addslashes($_POST['desc'])."' WHERE id=".addslashes($_GET['id']), 1);
        echo $mlang['007'];
    }

    $section = query ( "SELECT * FROM ".PREFIX."sections WHERE id = '".addslashes(@$_GET['id'])."'", 4);
    if ( $section['id'] )
    {        
        echo "
        <form action='index.php?module=admin&act=forum&op=edit&id=".$_GET['id']."' method='post'>
        ".$mlang['004']."<input type='text' name='name' size='50' value='".$section['name']."'><br>
        ".$mlang['005']."<input type='text' name='desc' size='50' value='".$section['desc']."'><br>
        <input type='submit' value='".$mlang['008']."'>
        </form>
        ";   
    }
}

function del($lang)
{
    $mlang = $lang;

    $section_exist = query ( "SELECT id FROM ".PREFIX."sections WHERE id = '".addslashes($_GET['id'])."'", 4);
    
    if ($section_exist['id'])
    {
        query ( "DELETE FROM ".PREFIX."sections WHERE id = '".$section_exist['id']."'", 1);
        echo $mlang['009'];
    }
}

function nlist($lang)
{
    $mlang = $lang;

    $list = query ("SELECT * FROM ".PREFIX."sections", 1);
    
    echo "<table width='100%'>
    <tr>
        <td width='5%'>    
        <b>#</b>
        </td>
        <td width='65%'>
        <b>".$mlang['010']."</b>
        </td>
        <td width='15%'>
        <b>".$mlang['011']."</b>
        </td>
        <td width='15%'>
        <b>".$mlang['012']."</b>
        </td>
    </tr>
    ";
    
    while ( $sections = mysql_fetch_array ( $list ) )
    {
        echo "
        <tr>
            <td width='5%'>    
            ".$sections['id']."
            </td>
            <td width='65%'>
            ".$sections['name']."
            </td>
            <td width='15%'>
            <a href='index.php?module=admin&act=forum&op=delete&id=".$sections['id']."'>".$mlang['011']."</a>
            </td>
            <td width='15%'>
            <a href='index.php?module=admin&act=forum&op=edit&id=".$sections['id']."'>".$mlang['012']."</a>
            </td>
        </tr>
        ";
    }
    
    echo "</table>";
}
?>
Return current item: PHPEcho CMS