Beispiel #1
0
    $hasImgFile = true;
    if ($_FILES['file']['name'] !== "") {
        $winePicURL = save_file($_FILES['file']['name'], $wine_pic_dir, $_FILES['file']['tmp_name']);
    } else {
        $hasImgFile = false;
        $winePicURL = "";
    }
    // update wine info
    $info_arr = get_wine_basic_info($winePicURL, $uid);
    $wine_id = update_table($conn, $info_arr, $hasImgFile);
    // update wine to online
    $onlineArr = get_online_info($_POST['online_channels'], $_POST['online_links'], $_POST['wine_to_online_ids']);
    update_online($onlineArr, $wine_id, $conn);
    // update wine to offline
    $offlineArr = get_offline_info($_POST['offline_ids'], $_POST['shops'], $_POST['cities'], $_POST['addresses'], $_POST['phones'], $uid);
    update_offline($offlineArr, $wine_id, $conn);
    header("location: manage_wine.php");
}
function update_table($conn, $info_arr, $hasImgFile)
{
    if ($_POST['wine_id'] != "") {
        // update
        if ($hasImgFile == true) {
            $sql = "UPDATE web_wine \n\t\t\t\t\tSET zh_wine_name='{$info_arr['zh_wine_name']}',\n\t\t\t\t\ten_wine_name='{$info_arr['en_wine_name']}',\n\t\t\t\t\tzh_country='{$info_arr['zh_country_name']}',\n\t\t\t\t\tzh_place='{$info_arr['zh_place_name']}',\n\t\t\t\t\ten_place='{$info_arr['en_place_name']}',\n\t\t\t\t\tzh_chateau='{$info_arr['zh_chateau_name']}',\n\t\t\t\t\ten_chateau='{$info_arr['en_chateau_name']}',\n\t\t\t\t\tzh_wine_type='{$info_arr['zh_wine_type_name']}',\n\t\t\t\t\ten_wine_type='{$info_arr['en_wine_type_name']}',\n\t\t\t\t\tzh_grape_type='{$info_arr['zh_grape_name']}',\n\t\t\t\t\ten_grape_type='{$info_arr['en_grape_name']}',\n\t\t\t\t\tvolume = '{$info_arr['volume']}',\n\t\t\t\t\tyear='{$info_arr['wine_year']}',\n\t\t\t\t\tprice='{$info_arr['wine_price']}',\n\t\t\t\t\tseller_id='{$info_arr['seller_id']}',\n\t\t\t\t\timage_name='{$info_arr['image_link']}',\n\t\t\t\t\tcreate_time='{$info_arr['add_time']}'\n\t\t\t\t\tWHERE id='{$_POST['wine_id']}'\n\t\t\t\t\t;";
        } else {
            $sql = "UPDATE web_wine \n\t\t\t\t\tSET zh_wine_name='{$info_arr['zh_wine_name']}',\n\t\t\t\t\ten_wine_name='{$info_arr['en_wine_name']}',\n\t\t\t\t\tzh_country='{$info_arr['zh_country_name']}',\n\t\t\t\t\tzh_place='{$info_arr['zh_place_name']}',\n\t\t\t\t\ten_place='{$info_arr['en_place_name']}',\n\t\t\t\t\tzh_chateau='{$info_arr['zh_chateau_name']}',\n\t\t\t\t\ten_chateau='{$info_arr['en_chateau_name']}',\n\t\t\t\t\tzh_wine_type='{$info_arr['zh_wine_type_name']}',\n\t\t\t\t\ten_wine_type='{$info_arr['en_wine_type_name']}',\n\t\t\t\t\tzh_grape_type='{$info_arr['zh_grape_name']}',\n\t\t\t\t\ten_grape_type='{$info_arr['en_grape_name']}',\n\t\t\t\t\tvolume = '{$info_arr['volume']}',\n\t\t\t\t\tyear='{$info_arr['wine_year']}',\n\t\t\t\t\tprice='{$info_arr['wine_price']}',\n\t\t\t\t\tseller_id='{$info_arr['seller_id']}',\n\t\t\t\t\tcreate_time='{$info_arr['add_time']}'\n\t\t\t\t\tWHERE id='{$_POST['wine_id']}'\n\t\t\t\t\t;";
        }
        if ($conn->query($sql) === TRUE) {
            $wine_id = $conn->insert_id;
            return $_POST['wine_id'];
        }
Beispiel #2
0
<?php

include dirname(__FILE__) . '/../modeles/administration/administration.php';
if (admin_secu($_SESSION['id']) == true) {
    include dirname(__FILE__) . '/../modeles/administration/admin_faq.php';
    if (isset($_POST["radio"])) {
        echo "<h2 style='color:red;text-align:center;'>Vos questions cochées sont maintenant en ligne !</h2>";
        update_offline();
        foreach ($_POST['choix'] as $check) {
            //echo $check;
            $id = $check;
            update_online($id);
        }
    }
    if (isset($_POST["creer"])) {
        creer_faq();
        echo "<h2 style='color:red;text-align:center;'>Nouvelle question ajoutée !</h2>";
    }
    if (isset($_GET['id'])) {
        supp_faq($_GET['id']);
        echo "<h2 style='color:red;text-align:center;'>Question supprimée !</h2>";
    }
    $result = admin_faq();
    //print_r($result);
    $countquest = count($result);
    //print_r($countquest);
    $valide = affiche_faq();
    //print_r($valide);
    $countcheck = count($valide);
    //print_r($countcheck);
    // INCLURE LA VUE CORRESPONDANTE