Exemple #1
0
 function del_child($parent = null)
 {
     if (!empty($parent)) {
         for ($x = 0; $x < count($_SESSION['modelmenu']); $x++) {
             $elmenu = $_SESSION['modelmenu'][$x];
             if ($elmenu[0] == $parent) {
                 unset($_SESSION['modelmenu'][$x]);
             }
             if ($elmenu[3] == $parent) {
                 unset($_SESSION['modelmenu'][$x]);
                 del_child($elmenu[0]);
             }
         }
     }
 }
Exemple #2
0
function del_child($id)
{
    global $pro_class_table;
    global $product_table;
    global $pic_no_pic;
    global $pro_pic_table;
    global $pro_size_table;
    global $pro_color_table;
    global $pro_stock_table;
    global $pro_size_relate_table;
    global $pro_color_relate_table;
    global $pro_download_table;
    $unit2 = new product();
    $unit2->table = $product_table;
    $sql = "select id,pic,pic2 from `{$pro_class_table}` where upid='{$id}'";
    $res = mysql_query($sql);
    if (mysql_num_rows($res) > 0) {
        while ($row = mysql_fetch_array($res)) {
            if ($row['pic'] != $pic_no_pic) {
                @unlink($row['pic']);
            }
            //移除圖片
            if ($row['pic2'] != $pic_no_pic) {
                @unlink($row['pic2']);
            }
            //移除圖片
            del_child($row['id']);
        }
    }
    $sql = "DELETE from `{$pro_class_table}` where id='{$id}'";
    mysql_query($sql);
    $sql = "select id from `{$product_table}` where upid='{$id}'";
    $res = mysql_query($sql);
    while ($row = mysql_fetch_array($res)) {
        $unit2->id = $row['id'];
        $unit2->get_db_var();
        $unit2->del();
        //刪除產品
        remove_home_num($unit2->id);
        //維持首頁勾選數量
        if ($unit2->pic != $pic_no_pic) {
            @unlink($unit2->pic);
        }
        //移除圖片
        //CLEAN RELATED DATA UP BEGIN-----------------------------------------------------------------------
        //刪除其它圖片資料
        $sql2 = "select * from `{$pro_pic_table}` where `upid`='" . $unit2->id . "'";
        $res2 = mysql_query($sql2);
        while ($row2 = mysql_fetch_array($res2)) {
            @unlink($row2['pic']);
            @unlink($row2['s_pic']);
        }
        $sql = "DELETE from `{$pro_pic_table}` where `upid`='" . $unit2->id . "'";
        mysql_query($sql);
        //刪除檔案資料
        $sql2 = "select * from `{$pro_download_table}` where `upid`='" . $unit2->id . "'";
        $res2 = mysql_query($sql2);
        while ($row2 = mysql_fetch_array($res2)) {
            @unlink($row2['file']);
        }
        $sql = "DELETE from `{$pro_download_table}` where `upid`='" . $unit2->id . "'";
        mysql_query($sql);
        //刪除庫存資料
        $sql2 = "SELECT id from `{$pro_color_relate_table}` where `upid`='" . $unit2->id . "'";
        $res2 = mysql_query($sql2);
        while ($row2 = mysql_fetch_array($res2)) {
            $sql2 = "DELETE from `{$pro_stock_table}` where `upid`='" . $row2['id'] . "'";
            mysql_query($sql2);
        }
        //刪除顏色資料
        $sql = "DELETE from `{$pro_color_relate_table}` where `upid`='" . $unit2->id . "'";
        mysql_query($sql);
        //刪除大小資料
        $sql = "DELETE from `{$pro_size_relate_table}` where `upid`='" . $unit2->id . "'";
        mysql_query($sql);
        //END ---------------------------------------------------------------------------------------
    }
}
Exemple #3
0
<?php

error_reporting(E_ERROR | E_PARSE);
include '../../helper/db_connect.php';
connect_database();
$id = $_GET['id'];
$parent_id = $_GET['p_id'];
$childs = get_person_detial($parent_id);
$child = mysql_fetch_assoc($childs);
print_r($child);
if ($child['MOTHER_ID'] == $id) {
    $type = "MOTHER_ID";
} else {
    if ($child['PARENT_ID'] == $id) {
        $type = "PARENT_ID";
    }
}
del_child($parent_id, $type);
echo "<script type='text/javascript'>";
echo "window.history.back();";
echo "</script>";
    $img->set_width($pic_width);
    //決定縮圖大小,大圖大小
    $img->set_savepath("../images/" . date("Y-m-d"));
    //設定儲存路徑
    $pic2 = $img->save();
} else {
    $pic2 = $_POST['pic2'];
}
if ($check == 'upd') {
    $unit->table = $pro_class_table;
    $unit->get_vars();
    $unit->pic = $pic;
    $unit->pic2 = $pic2;
    $buff = array();
    $unit->get_history($unit->upid, $buff);
    $unit->upd();
    $tool->show(get_msg("upd_success"), $_SERVER['HTTP_REFERER']);
    exit;
}
if (isset($_POST['del'])) {
    $id = $_POST['id'];
    for ($i = 0; $i < count($id); $i++) {
        del_child($id[$i]);
    }
    if (count($id) > 0) {
        $tool->show(get_msg("del_success"), $_SERVER['HTTP_REFERER']);
    } else {
        $tool->error(get_msg("del_fail"));
    }
    exit;
}