. */ function ListBlocks() { global $db; $result = $db->Query("SELECT * FROM bayonet_blocks"); $blocks = $db->Fetch(); echo ""; foreach($blocks as $block) { echo ""; } echo "
Existing Blocks
{$block['weight']} : {$block['dir_name']}EditDelete
"; } function NewBlock() { global $db; if(isset($_POST['processed'])) { //Secure our data to prevent injection attacks. $weight = addslashes($_POST['weight']); $dir_name = addslashes($_POST['dir_name']); $position = addslashes($_POST['position']); $active = addslashes($_POST['active']); if(empty($weight) || empty($dir_name) || empty($position)) { echo "You must fill everything out before proceeding."; return; } //Update the database with the new data. $db->Query("INSERT INTO bayonet_blocks SET weight = '$weight', dir_name = '$dir_name', position = '$position', active = '$active'"); //die, because we have completed what we wanted to do. echo "New block, '$dir_name', at position '$weight' added.\n"; return; } ?>
Weight
Position
Directory Name
Active
'Yes',0 => 'No'); foreach($options as $option => $value) { $selected = NULL; if($active == $option) { $selected = "selected"; } echo "\n"; } } function EditBlock($block_id) { global $db; if(isset($_POST['processed'])) { //Secure our data to prevent injection attacks. $weight = addslashes($_POST['weight']); $dir_name = addslashes($_POST['dir_name']); $position = addslashes($_POST['position']); $active = addslashes($_POST['active']); if(empty($weight) || empty($dir_name) || empty($position)) { echo "You must fill everything out before proceeding."; return; } //Update the database with the new data. $db->Query("UPDATE bayonet_blocks SET weight = '$weight', dir_name = '$dir_name', position = '$position', active = '$active' WHERE block_id = '$block_id'"); //$isActive = $active ? "IS" : "IS NOT"; echo "Block, '$dir_name', at position '$weight' has been edited.\n"; //die, because we have completed what we wanted to do. return; } //Grab the page from the database according to the $page_id passed to the function. // {{{ XXX: FIXME -- Re-write this /* $result = $db->Query("SELECT weight,dir_name,position,active FROM bayonet_blocks WHERE block_id = '$block_id'"); while(($row = $db->Fetch($result))!=false) { //We only want one row, so we don't have to $block[]... No foreach necessary. $block = $row; } */ // }}} ?>
Weight
Position
Directory Name
Active
Query("SELECT dir_name FROM bayonet_blocks WHERE block_id = '$block_id'"); $block = $db->Fetch($result); if(isset($_POST['proceed'])) { echo "Block '{$block['dir_name']}', was deleted."; $db->Query("DELETE FROM bayonet_blocks WHERE block_id = '$block_id' LIMIT 1"); return; } if(isset($_POST['cancel'])) { echo "User cancelled deletion of page: '{$block['dir_name']}'"; return; } ?>
Are you SURE you want to delete the block titled: ''?