//Debug options:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once('omdb.inc.php');
include_once('ocdparse.inc.php');
$omdb = new OMDB();
$cd_id = @$_GET['cd_id'];
$change = ( @$_GET['change'] == 1 ? true : false );
$cdar = $omdb->GetCD($cd_id);
//Path
if ($change) {
$path = array('CDs' => 'omcds.php', $cdar['cd_name'] => 'omdefs.php?cd_id='.$cd_id, 'Change' => '');
} else {
$path = array('CDs' => 'omcds.php', $cdar['cd_name'] => '');
}
echo $omdb->PrintClickPath($path);
//Actions
if (isset($_POST['ipt_sup'])) {
if (!IS_ADMIN) die('Foei!');
foreach ($_POST['ipt_sup'] as $cas_id => $x) {
foreach($x as $def_id => $y) {
foreach ($y as $sup0 => $action) {
$sup = str_replace("'", "", $sup0);
if ($action == 'add') {
echo "Adding cas_id = $cas_id, def_id = $def_id, sup = $sup
\n";
$omdb->AddDefCasSupport($def_id, $cas_id, $sup);
} else if ($action == 'remv') {
echo "Removing cas_id = $cas_id, def_id = $def_id, sup = $sup
\n";
$omdb->RemvDefCasSupport($def_id, $cas_id, $sup);
} else if ($action != 'inv') {
die('Unknown action -- '.$action);
}
}
}
}
}
if (isset($_POST['ipt_notes'])) {
if (!IS_ADMIN) die('Foei!');
foreach ($_POST['ipt_notes'] as $cas_id => $x) {
foreach($x as $def_id => $y) {
if ($y['old'] != $y['new']) {
echo "Changing note for cas_id = $cas_id, def_id = $def_id
\n";
$omdb->SetDefCasNote($def_id, $cas_id, $y['new']);
}
}
}
}
if (isset($_POST['ipt_url'])) {
if (!IS_ADMIN) die('Foei!');
print_r($_POST['ipt_url']);
foreach( $_POST['ipt_url'] as $cas_id => $x) {
foreach( $x as $tp => $y) {
if ($y['old'] != $y['new']) {
echo "Changing $tp for cas_id = $cas_id
\n";
$omdb->SetCDCasURL($cd_id, $cas_id, $tp, $y['new']);
}
}
}
}
//Print stuff
echo $omdb->PrintDefsWithSupport($cd_id, $change);
echo $omdb->PrintNotes();
echo $omdb->PrintEncDecNote();
if (IS_ADMIN) { ?>
if (!$change) { ?>
}
}
?>