Location: PHPKode > projects > PhpChangeLog > phpchangelog-0.6/admin/admin.php
<?php

/**
 * phpChangeLog admin main index
 *
 * This is the main admin script
 */


# For debugging, do full error_reporting
error_reporting(2500);

# Define our own file & path
$thisfile = $_SERVER['PHP_SELF'];

# start a session (or resume an existing one)
session_start();

if(empty($_SESSION['user'])) {
    echo "<meta http-equiv=\"Refresh\" content=\"0; URL=./\">";
    die();
}

$selected_db = $_SESSION['database'];

# set root directory for this script
$rootdoc = "..";

# include the configuration file
require ("$rootdoc/conf/config.inc.php");
require ("$rootdoc/mysql/mysql_process.inc.php");
require ("$rootdoc/functions/functions.inc.php");
require ("$rootdoc/html/html_header.inc.php");

if (isset($_POST['adddb_create'])) {
    addslashes($_POST['db']);
    create_new_db($_POST['db']);
}

if (isset($_GET['dropdb'])) {
    drop_db($_GET['dropdb']);
}

    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
    echo " <tr>\n";
    echo "  <td width=\"150\">\n";
    echo "   <img src=\"$rootdoc/img/phpChangeLog-logo-small.gif\" border=\"0\" />\n";
    echo "  </td>\n";
    echo "  <td align=\"right\">\n";
    echo "    User logged in   :" .$_SESSION['user'];
    echo "    <a href=\"index.php?logout=TRUE\">[logout]</a>\n";
    echo "  </td>\n";
    echo " </tr>\n";
    echo "</table>\n";

    echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
    echo " <tr>\n";
    echo "  <td width=\"150\" valign=\"top\">\n";
    echo "  <b>Databases</b><br />\n";

    $sql = mysql_query("SELECT * FROM db");
    
    while ($record = mysql_fetch_object($sql)) {
        echo "<a href=\"$thisfile?dropdb=$record->id\"";
	echo " onclick=\"return confirm('Remove database $record->db?')\">\n";
        echo " <img src=\"$rootdir/img/remove.gif\" border=\"0\" alt=\"remove $record->db\" /></a> $record->db\n";
        echo "<br />\n";
    }

    echo "<br />";
    echo "<a href=\"$thisfile?render=adddb\">[create db]</a>\n";
    echo "  </td>\n";
    echo "  <td valign=\"top\">\n";

    ### CONTENT

    # If we want to create databases, show a login screen
    if (isset($_GET['render']) && $_GET['render'] == "adddb") { 
        $sql_get_db = mysql_query("SELECT * FROM $proj_db ORDER BY project");
	    
	echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n"; 
	echo " <tr>\n";
	echo "  <form method=\"POST\" action=\"$thisfile\">\n";
	echo "  <td><b>Database</b></td>\n";
	echo " </tr>\n";
	echo " <tr>\n";
	echo "  <td valign=\"top\" align=\"left\" width=\"140\">\n";
        echo "   <input type=\"hidden\" name=\"adddb_create\" value=\"TRUE\">\n";
        echo "   <input type=\"text\" name=\"db\" \><br /><br />\n";
        echo "   <input type=\"submit\" value=\"add\" \>\n";

    }
    
    echo "  </td> \n";
    echo " </tr>\n";
    echo "</table>\n";



?>

</body>
</html>
Return current item: PhpChangeLog