コード例 #1
0
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
if (has_post()) {
    if (array_key_exists('image', $_FILES)) {
        $image = $_FILES['image'];
        if (!is_file_type_allowed($image['type'])) {
            header('Location: /admin/index.php');
            die;
        }
        $moved = move_uploaded_file($image['tmp_name'], __DIR__ . '/../img/products/' . $image['name']);
        $image_data = ['product_id' => $_POST['product_id'], 'src' => $image['name'], 'description' => ''];
        save_image($image_data);
    }
    header('Location: /admin/index.php');
    die;
}
if (!array_key_exists('product_id', $_GET)) {
    header('Location: /admin/index.php');
    die;
}
echo render_admin_template('add_image_to_product', ['product_id' => $_GET['product_id'], 'user' => get_current_admin_user()]);
コード例 #2
0
ファイル: index.php プロジェクト: jeffersonchaves/SimpleStore
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
$products = get_products();
echo render_admin_template('catalog', ['products' => $products, 'user' => get_current_admin_user()]);
コード例 #3
0
<?php

require __DIR__ . '/../src/bootstrap_admin.php';
$product = ['id' => 0, 'name' => get_from_post('name', ''), 'price' => get_from_post('price', 0), 'brand' => get_from_post('brand', ''), 'description' => get_from_post('description', ''), 'categories' => get_from_post('categories', '')];
if (has_post()) {
    save_product($product);
    header('Location: /admin/index.php');
    die;
}
echo render_admin_template('product_form', ['title' => 'Add product', 'product' => $product, 'user' => get_current_admin_user()]);
コード例 #4
0
ファイル: login.php プロジェクト: jeffersonchaves/SimpleStore
<?php

require __DIR__ . '/../src/bootstrap.php';
require __DIR__ . '/../src/admin.php';
$login_failed = false;
if (has_post()) {
    if (login($_POST['user'], $_POST['password'])) {
        header('Location: /admin/index.php');
        die;
    }
    $login_failed = true;
}
echo render_admin_template('login', ['login_failed' => $login_failed]);