[ create a new paste ] login | about

Link: http://codepad.org/qnD4wRVE    [ raw code | fork ]

BluePanther - PHP, pasted on Sep 12:
<?php
/*
 * Gallery controller page - galleryadmin.php
 * This page is the controller for gallery management
 * This page should be used as the admin 'homepage'
 *
 * Non-database solution
 *
 * @author Aaron Maclean
*/

// Hardcoded password for authorised people to C-U-D
$password = 'ChangeMe!';

function create($input){
    global $password;
    if($input != FALSE){
        // Form was submitted
    }
    else {
        // display form
    }
}

function manage($input){
    global $password;
    if($input != FALSE){
        // Something was updated/deleted
    }
    else {
        if(isset($_GET['sub'])){
            // determine what they want to do, retrieve id
            $id = $_GET['id'];
            switch($_GET['sub']){
                case 'update':
                    // Populated update form + password
                    break;
                case 'delete':
                    // Are you sure? + password
                    break;
                default:
                    echo 'Unknown subtask.';
                    break;
            }
        }
        else{
            // display form
        }
    }
}

// galleryadmin.php?task=
if(isset($_GET['task'])){
    switch($_GET['task']){
        case 'create':
            echo ( (!empty($_POST)) ? create($_POST) : create(FALSE) );
            break;
        case 'manage':
            echo ( (!empty($_POST)) ? manage($_POST) : manage(FALSE) );
            break;
        default:
            echo 'Task not recognised.';
            break;
    }
}
?>


Output:
No errors or program output.


Create a new paste based on this one


Comments: