Example #1
0
                break;
        }
    }
}
if (!empty($_POST)) {
    $authToken = isset($_POST['authenticity_token']) ? $_POST['authenticity_token'] : '';
    $cost = isset($_POST['cost']) ? $_POST['cost'] : 3;
    $category = isset($_POST['category']) ? $_POST['category'] : 0;
    $cost = helper::clearInt($cost);
    $category = helper::clearInt($category);
    if ($authToken === helper::getAuthenticityToken() && !APP_DEMO) {
        if (isset($_FILES['uploaded_file']['name'])) {
            $uploaded_file = $_FILES['uploaded_file']['tmp_name'];
            $uploaded_file_name = basename($_FILES['uploaded_file']['name']);
            $uploaded_file_ext = pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);
            $gift_next_id = $gift->db_getMaxId();
            $gift_next_id++;
            if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], GIFTS_PATH . $gift_next_id . "." . $uploaded_file_ext)) {
                $gift->db_add($cost, $category, APP_URL . "/" . GIFTS_PATH . $gift_next_id . "." . $uploaded_file_ext);
            }
        }
    }
    header("Location: /admin/gifts.php");
}
helper::newAuthenticityToken();
$css_files = array("admin.css");
$page_title = "Gifts";
include_once $_SERVER['DOCUMENT_ROOT'] . "/common/header.inc.php";
?>

<body class="bg_gray">