<?php
/**
* phpChangeLog MySQL processor
*
* This script does all the MySQL DELETE and INSERT queries
*/
# Connect to the database
$conn_handler = mysql_connect("$sql_server", "$sql_username", "$sql_password");
mysql_select_db("$sql_database", $conn_handler) or die ("cannot select db");
# If the user chooses to delete a maintainer, delete it.
if (isset($_GET['remove_maintainer'])) {
$remove_maintainer = $_GET['remove_maintainer'];
addslashes($remove_maintainer);
$table = $_SESSION['database'] ."_maintainers";
mysql_query("DELETE FROM $table WHERE id = '$remove_maintainer'")||die("BLA");
}
# If the user chooses to delete a project, delete it + changelog input
if (isset($_GET['remove_project'])) {
$remove_project = $_GET['remove_project'];
addslashes($remove_project);
$table = $_SESSION['database'] ."_projects";
mysql_query("DELETE FROM $table WHERE id = '$remove_project'")||die("BLA");
$table = $_SESSION['database'] ."_changelog";
mysql_query("DELETE FROM $table WHERE project_id = '$remove_project'")||die("BLA");
}
# If the user wants to add a project, or maintainer, start some functions
if (isset($_POST['add_type'])) {
if (isset($_POST['project'])) {
add_type_db("project", "projects", $_POST['project']);
}
if (isset($_POST['maintainer'])) {
add_type_db("maintainer", "maintainers", $_POST['maintainer'], $_POST['password']);
}
}
# If the user wants to submit a changelog entry, process it
if (isset($_POST['addchlog'])) {
$table = $_SESSION['database'] ."_maintainers";
$sql_get_mntnrid = mysql_query("SELECT * FROM $table WHERE maintainer = '$maintainer' ORDER BY maintainer");
$mntnrid = mysql_fetch_object($sql_get_mntnrid);
$projid = $_POST['projid'];
$comment = $_POST['comment'];
$date = date("YmdHi");
addslashes($projid);
addslashes($comment);
$table = $_SESSION['database'] ."_changelog";
mysql_query("INSERT INTO $table (project_id, maintainer_id, date, comment)
VALUES ('$projid', '$mntnrid->id', '$date', '$comment');");
$render="getchlog";
$id=$projid;
}
# If the user wants to change a maintainer password
if (isset($_POST['edit_maintainer_do'])) {
if (strlen($_POST['password']) == 0) {
$return = "You didn't enter a password\n";
} else {
mysql_query("UPDATE $_SESSION[database]_maintainers SET password = MD5('$_POST[password]')") or die ("Cannot update maintainer" . mysql_error());
$return = "Maintainer updated.\n";
}
}
?>