示例#1
0
function fncSave($edt_flg, $navbarMenu, $menuno)
{
    $pi_name = "userbox";
    global $_CONF;
    global $_TABLES;
    global $_USER;
    global $_USERBOX_CONF;
    global $LANG_USERBOX_ADMIN;
    global $_FILES;
    $addition_def = DATABOX_getadditiondef($pi_name);
    $retval = '';
    // clean 'em up
    $id = COM_applyFilter($_POST['id'], true);
    $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
    //@@@@@ username fullname
    $username = COM_applyFilter($_POST['username']);
    $username = addslashes(COM_checkHTML(COM_checkWords($username)));
    $fullname = COM_applyFilter($_POST['fullname']);
    $fullname = addslashes(COM_checkHTML(COM_checkWords($fullname)));
    $page_title = COM_applyFilter($_POST['page_title']);
    $page_title = addslashes(COM_checkHTML(COM_checkWords($page_title)));
    $description = $_POST['description'];
    //COM_applyFilter($_POST['description']);
    $description = addslashes(COM_checkHTML(COM_checkWords($description)));
    $defaulttemplatesdirectory = COM_applyFilter($_POST['defaulttemplatesdirectory']);
    $defaulttemplatesdirectory = addslashes(COM_checkHTML(COM_checkWords($defaulttemplatesdirectory)));
    $draft_flag = COM_applyFilter($_POST['draft_flag'], true);
    //            $hits =0;
    //            $comments=0;
    $comment_expire_flag = COM_applyFilter($_POST['comment_expire_flag'], true);
    if ($comment_expire_flag) {
        $comment_expire_month = COM_applyFilter($_POST['comment_expire_month'], true);
        $comment_expire_day = COM_applyFilter($_POST['comment_expire_day'], true);
        $comment_expire_year = COM_applyFilter($_POST['comment_expire_year'], true);
        $comment_expire_hour = COM_applyFilter($_POST['comment_expire_hour'], true);
        $comment_expire_minute = COM_applyFilter($_POST['comment_expire_minute'], true);
        if ($comment_expire_ampm == 'pm') {
            if ($comment_expire_hour < 12) {
                $comment_expire_hour = $comment_expire_hour + 12;
            }
        }
        if ($comment_expire_ampm == 'am' and $comment_expire_hour == 12) {
            $comment_expire_hour = '00';
        }
    } else {
        $comment_expire_month = 0;
        $comment_expire_day = 0;
        $comment_expire_year = 0;
        $comment_expire_hour = 0;
        $comment_expire_minute = 0;
    }
    $commentcode = COM_applyFilter($_POST['commentcode'], true);
    $trackbackcode = COM_applyFilter($_POST['trackbackcode'], true);
    $cache_time = COM_applyFilter($_POST['cache_time'], true);
    $meta_description = $_POST['meta_description'];
    $meta_description = addslashes(COM_checkHTML(COM_checkWords($meta_description)));
    $meta_keywords = $_POST['meta_keywords'];
    $meta_keywords = addslashes(COM_checkHTML(COM_checkWords($meta_keywords)));
    $language_id = COM_applyFilter($_POST['language_id']);
    $language_id = addslashes(COM_checkHTML(COM_checkWords($language_id)));
    $category = $_POST['category'];
    //@@@@@
    $additionfields = $_POST['afield'];
    $additionfields_old = $_POST['afield'];
    $additionfields_fnm = $_POST['afield_fnm'];
    $additionfields_del = $_POST['afield_del'];
    $additionfields_alt = $_POST['afield_alt'];
    $additionfields_date = array();
    $dummy = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt);
    //
    $owner_id = COM_applyFilter($_POST['owner_id'], true);
    $group_id = COM_applyFilter($_POST['group_id'], true);
    //
    $array['perm_owner'] = $_POST['perm_owner'];
    $array['perm_group'] = $_POST['perm_group'];
    $array['perm_members'] = $_POST['perm_members'];
    $array['perm_anon'] = $_POST['perm_anon'];
    if (is_array($array['perm_owner']) || is_array($array['perm_group']) || is_array($array['perm_members']) || is_array($array['perm_anon'])) {
        list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($array['perm_owner'], $array['perm_group'], $array['perm_members'], $array['perm_anon']);
    } else {
        $perm_owner = COM_applyBasicFilter($array['perm_owner'], true);
        $perm_group = COM_applyBasicFilter($array['perm_group'], true);
        $perm_members = COM_applyBasicFilter($array['perm_members'], true);
        $perm_anon = COM_applyBasicFilter($array['perm_anon'], true);
    }
    //編集日付
    $modified_autoupdate = COM_applyFilter($_POST['modified_autoupdate'], true);
    if ($modified_autoupdate == 1) {
        //$udate = date('Ymd');
        $modified_month = date('m');
        $modified_day = date('d');
        $modified_year = date('Y');
        $modified_hour = date('H');
        $modified_minute = date('i');
    } else {
        $modified_month = COM_applyFilter($_POST['modified_month'], true);
        $modified_day = COM_applyFilter($_POST['modified_day'], true);
        $modified_year = COM_applyFilter($_POST['modified_year'], true);
        $modified_hour = COM_applyFilter($_POST['modified_hour'], true);
        $modified_minute = COM_applyFilter($_POST['modified_minute'], true);
        $modified_ampm = COM_applyFilter($_POST['modified_ampm']);
        if ($modified_ampm == 'pm') {
            if ($modified_hour < 12) {
                $modified_hour = $modified_hour + 12;
            }
        }
        if ($modified_ampm == 'am' and $modified_hour == 12) {
            $modified_hour = '00';
        }
    }
    //公開日
    $released_month = COM_applyFilter($_POST['released_month'], true);
    $released_day = COM_applyFilter($_POST['released_day'], true);
    $released_year = COM_applyFilter($_POST['released_year'], true);
    $released_hour = COM_applyFilter($_POST['released_hour'], true);
    $released_minute = COM_applyFilter($_POST['released_minute'], true);
    if ($released_ampm == 'pm') {
        if ($released_hour < 12) {
            $released_hour = $released_hour + 12;
        }
    }
    if ($released_ampm == 'am' and $released_hour == 12) {
        $released_hour = '00';
    }
    //公開終了日
    $expired_flag = COM_applyFilter($_POST['expired_flag'], true);
    if ($expired_flag) {
        $expired_month = COM_applyFilter($_POST['expired_month'], true);
        $expired_day = COM_applyFilter($_POST['expired_day'], true);
        $expired_year = COM_applyFilter($_POST['expired_year'], true);
        $expired_hour = COM_applyFilter($_POST['expired_hour'], true);
        $expired_minute = COM_applyFilter($_POST['expired_minute'], true);
        if ($expired_ampm == 'pm') {
            if ($expired_hour < 12) {
                $expired_hour = $expired_hour + 12;
            }
        }
        if ($expired_ampm == 'am' and $expired_hour == 12) {
            $expired_hour = '00';
        }
    } else {
        $expired_month = 0;
        $expired_day = 0;
        $expired_year = 0;
        $expired_hour = 0;
        $expired_minute = 0;
    }
    $created = COM_applyFilter($_POST['created_un']);
    $orderno = mb_convert_kana($_POST['orderno'], "a");
    //全角英数字を半角英数字に変換する
    $orderno = COM_applyFilter($orderno, true);
    //$name = mb_convert_kana($name,"AKV");
    //A:半角英数字を全角英数字に変換する
    //K:半角カタカナを全角カタカナに変換する
    //V:濁点つきの文字を1文字に変換する (K、H と共に利用する)
    //$name = str_replace ("'", "’",$name);
    //$code = mb_convert_kana($code,"a");//全角英数字を半角英数字に変換する
    //-----
    $type = 1;
    $uuid = $_USER['uid'];
    // CHECK はじめ
    $err = "";
    //id
    if ($id == 0) {
        //$err.=$LANG_USERBOX_ADMIN['err_uid']."<br {XHTML}>".LB;
    } else {
        if (!is_numeric($id)) {
            $err .= $LANG_USERBOX_ADMIN['err_id'] . "<br {XHTML}>" . LB;
        }
    }
    //文字数制限チェック
    if (mb_strlen($description, 'UTF-8') > $_USERBOX_CONF['maxlength_description']) {
        $err .= $LANG_USERBOX_ADMIN['description'] . $_USERBOX_CONF['maxlength_description'] . $LANG_USERBOX_ADMIN['err_maxlength'] . "<br/>" . LB;
    }
    if (mb_strlen($meta_description, 'UTF-8') > $_USERBOX_CONF['maxlength_meta_description']) {
        $err .= $LANG_USERBOX_ADMIN['meta_description'] . $_USERBOX_CONF['maxlength_meta_description'] . $LANG_USERBOX_ADMIN['err_maxlength'] . "<br/>" . LB;
    }
    if (mb_strlen($meta_keywords, 'UTF-8') > $_USERBOX_CONF['maxlength_meta_keywords']) {
        $err .= $LANG_USERBOX_ADMIN['meta_keywords'] . $_USERBOX_CONF['maxlength_meta_keywords'] . $LANG_USERBOX_ADMIN['err_maxlength'] . "<br/>" . LB;
    }
    //----追加項目チェック
    $err .= DATABOX_checkaddtiondatas($additionfields, $addition_def, $pi_name, $additionfields_fnm, $additionfields_del, $additionfields_alt);
    //編集日付
    $modified = $modified_year . "-" . $modified_month . "-" . $modified_day;
    if (checkdate($modified_month, $modified_day, $modified_year) == false) {
        $err .= $LANG_USERBOX_ADMIN['err_modified'] . "<br {XHTML}>" . LB;
    }
    $modified = COM_convertDate2Timestamp($modified_year . "-" . $modified_month . "-" . $modified_day, $modified_hour . ":" . $modified_minute . "::00");
    //公開日
    $released = $released_year . "-" . $released_month . "-" . $released_day;
    if (checkdate($released_month, $released_day, $released_year) == false) {
        $err .= $LANG_USERBOX_ADMIN['err_released'] . "<br {XHTML}>" . LB;
    }
    $released = COM_convertDate2Timestamp($released_year . "-" . $released_month . "-" . $released_day, $released_hour . ":" . $released_minute . "::00");
    //コメント受付終了日時
    if ($comment_expire_flag) {
        if (checkdate($comment_expire_month, $comment_expire_day, $comment_expire_year) == false) {
            $err .= $LANG_USERBOX_ADMIN['err_comment_expire'] . "<br {XHTML}>" . LB;
        }
        $comment_expire = COM_convertDate2Timestamp($comment_expire_year . "-" . $comment_expire_month . "-" . $comment_expire_day, $comment_expire_hour . ":" . $comment_expire_minute . "::00");
    } else {
        $comment_expire = '0000-00-00 00:00:00';
        //$comment_expire="";
    }
    //公開終了日
    if ($expired_flag) {
        if (checkdate($expired_month, $expired_day, $expired_year) == false) {
            $err .= $LANG_USERBOX_ADMIN['err_expired'] . "<br {XHTML}>" . LB;
        }
        $expired = COM_convertDate2Timestamp($expired_year . "-" . $expired_month . "-" . $expired_day, $expired_hour . ":" . $expired_minute . "::00");
        if ($expired < $released) {
            $err .= $LANG_USERBOX_ADMIN['err_expired'] . "<br {XHTML}>" . LB;
        }
    } else {
        $expired = '0000-00-00 00:00:00';
        //$expired="";
    }
    //errorのあるとき
    if ($err != "") {
        $retval['title'] = $LANG_USERBOX_ADMIN['piname'] . $LANG_USERBOX_ADMIN['edit'];
        $retval['display'] = fncEdit($id, $edt_flg, 3, $err);
        return $retval;
    }
    // CHECK おわり
    if ($id == 0) {
        $w = DB_getItem($_TABLES['USERBOX_base'], "max(id)", "1=1");
        if ($w == "") {
            $w = 0;
        }
        $id = $w + 1;
        $created_month = date('m');
        $created_day = date('d');
        $created_year = date('Y');
        $created_hour = date('H');
        $created_minute = date('i');
        $created = COM_convertDate2Timestamp($created_year . "-" . $created_month . "-" . $created_day, $created_hour . ":" . $created_minute . "::00");
    }
    $hits = 0;
    $comments = 0;
    $fields = "id";
    $values = "{$id}";
    $fields .= ",page_title";
    //
    $values .= ",'{$page_title}'";
    $fields .= ",description";
    //
    $values .= ",'{$description}'";
    $fields .= ",defaulttemplatesdirectory";
    //
    $values .= ",'{$defaulttemplatesdirectory}'";
    //$fields.=",hits";//
    //$values.=",$hits";
    $fields .= ",comments";
    //
    $values .= ",{$comments}";
    $fields .= ",meta_description";
    //
    $values .= ",'{$meta_description}'";
    $fields .= ",meta_keywords";
    //
    $values .= ",'{$meta_keywords}'";
    $fields .= ",commentcode";
    //
    $values .= ",{$commentcode}";
    $fields .= ",trackbackcode";
    //
    $values .= ",{$trackbackcode}";
    $fields .= ",cache_time";
    //
    $values .= ",{$cache_time}";
    $fields .= ",comment_expire";
    //
    if ($comment_expire == '0000-00-00 00:00:00') {
        $values .= ",'{$comment_expire}'";
    } else {
        $values .= ",FROM_UNIXTIME('{$comment_expire}')";
    }
    $fields .= ",language_id";
    //
    $values .= ",'{$language_id}'";
    $fields .= ",owner_id";
    $values .= ",{$owner_id}";
    $fields .= ",group_id";
    $values .= ",{$group_id}";
    $fields .= ",perm_owner";
    $values .= ",{$perm_owner}";
    $fields .= ",perm_group";
    $values .= ",{$perm_group}";
    $fields .= ",perm_members";
    $values .= ",{$perm_members}";
    $fields .= ",perm_anon";
    $values .= ",{$perm_anon}";
    $fields .= ",modified";
    $values .= ",FROM_UNIXTIME('{$modified}')";
    if ($created != "") {
        $fields .= ",created";
        $values .= ",FROM_UNIXTIME('{$created}')";
    }
    $fields .= ",expired";
    if ($expired == '0000-00-00 00:00:00') {
        $values .= ",'{$expired}'";
    } else {
        $values .= ",FROM_UNIXTIME('{$expired}')";
    }
    $fields .= ",released";
    $values .= ",FROM_UNIXTIME('{$released}')";
    $fields .= ",orderno";
    //
    $values .= ",{$orderno}";
    $fields .= ",fieldset_id";
    //
    $values .= ",{$fieldset_id}";
    $fields .= ",uuid";
    $values .= ",{$uuid}";
    $fields .= ",draft_flag";
    $values .= ",{$draft_flag}";
    DB_save($_TABLES['USERBOX_base'], $fields, $values);
    //カテゴリ
    $rt = DATABOX_savecategorydatas($id, $category, $pi_name);
    //追加項目
    DATABOX_uploadaddtiondatas($additionfields, $addition_def, $pi_name, $id, $additionfields_fnm, $additionfields_del, $additionfields_old, $additionfields_alt);
    $rt = DATABOX_saveaddtiondatas($id, $additionfields, $addition_def, $pi_name);
    //user (コアのテーブル)
    //kokoka
    $sql = "UPDATE " . $_TABLES['users'] . " SET ";
    $sql .= " fullname ='" . $fullname . "'";
    $sql .= " WHERE uid=" . $id;
    DB_query($sql);
    $rt = fncsendmail('data', $id);
    $cacheInstance = 'userbox__' . $id . '__';
    CACHE_remove_instance($cacheInstance);
    //exit;// debug 用
    //    if ($edt_flg){
    //        $return_page=$_CONF['site_url'] . "/".THIS_SCRIPT;
    //        $return_page.="?id=".$id;
    //    }else{
    //        $return_page=$_CONF['site_admin_url'] . '/plugins/'.THIS_SCRIPT.'?msg=1';
    //    }
    //    return COM_refresh ($return_page);
    if ($_USERBOX_CONF['aftersave_admin'] === 'no') {
        $retval['title'] = $LANG_USERBOX_ADMIN['piname'] . $LANG_USERBOX_ADMIN['edit'];
        $retval['display'] .= fncEdit($id, $edt_flg, 1, "");
        return $retval;
    } else {
        if ($_USERBOX_CONF['aftersave_admin'] === 'list') {
            $url = $_CONF['site_admin_url'] . "/plugins/{$pi_name}/profile.php";
            $item_url = COM_buildURL($url);
            $target = 'item';
        } else {
            $url = $_CONF['site_url'] . "/userbox/profile.php";
            $url .= "?";
            //コード使用の時
            if ($_USERBOX_CONF['datacode']) {
                $url .= "code=" . $username;
                $url .= "&amp;m=code";
            } else {
                $url .= "id=" . $id;
                $url .= "&amp;m=id";
            }
            $item_url = COM_buildUrl($url);
            $target = $_USERBOX_CONF['aftersave_admin'];
        }
    }
    $return_page = PLG_afterSaveSwitch($target, $item_url, 'userbox', 1);
    echo $return_page;
    exit;
}
示例#2
0
function fncSave($edt_flg, $navbarMenu, $menuno, $template)
{
    $pi_name = "databox";
    global $_CONF;
    global $LANG_DATABOX_ADMIN;
    global $_TABLES;
    global $_USER;
    global $_DATABOX_CONF;
    global $LANG_DATABOX_user_menu;
    $addition_def = DATABOX_getadditiondef();
    $retval = '';
    // clean 'em up
    $id = COM_applyFilter($_POST['id'], true);
    if ($id == 0) {
        $new_flg = true;
    } else {
        $new_flg = false;
    }
    $fieldset_id = COM_applyFilter($_POST['fieldset'], true);
    $code = COM_applyFilter($_POST['code']);
    $code = addslashes(COM_checkHTML(COM_checkWords($code)));
    $title = COM_stripslashes($_POST['title']);
    $title = addslashes(COM_checkHTML(COM_checkWords($title)));
    $page_title = COM_applyFilter($_POST['page_title']);
    $page_title = addslashes(COM_checkHTML(COM_checkWords($page_title)));
    $description = $_POST['description'];
    //COM_applyFilter($_POST['description']);
    $description = addslashes(COM_checkHTML(COM_checkWords($description)));
    $language_id = COM_applyFilter($_POST['language_id']);
    $language_id = addslashes(COM_checkHTML(COM_checkWords($language_id)));
    $category = $_POST['category'];
    //@@@@@
    $additionfields = $_POST['afield'];
    $additionfields_old = $_POST['afield'];
    $additionfields_fnm = $_POST['afield_fnm'];
    $additionfields_del = $_POST['afield_del'];
    $additionfields_alt = $_POST['afield_alt'];
    $additionfields_date = array();
    $additionfields = DATABOX_cleanaddtiondatas($additionfields, $addition_def, $additionfields_fnm, $additionfields_del, $additionfields_date, $additionfields_alt);
    //            $hits =0;
    //            $comments=0;
    $old_mode = COM_applyFilter($_POST['old_mode']);
    $old_mode = addslashes(COM_checkHTML(COM_checkWords($old_mode)));
    //-----
    $type = 1;
    $uuid = $_USER['uid'];
    // CHECK はじめ
    $err = "";
    //id
    if ($id == 0) {
        //$err.=$LANG_DATABOX_ADMIN['err_uid']."<br/>".LB;
    } else {
        if (!is_numeric($id)) {
            $err .= $LANG_DATABOX_ADMIN['err_id'] . "<br/>" . LB;
        }
    }
    //タイトル必須
    if (empty($title)) {
        $err .= $LANG_DATABOX_ADMIN['err_title'] . "<br/>" . LB;
    }
    //文字数制限チェック
    if (mb_strlen($description, 'UTF-8') > $_DATABOX_CONF['maxlength_description']) {
        $err .= $LANG_DATABOX_ADMIN['description'] . $_DATABOX_CONF['maxlength_description'] . $LANG_DATABOX_ADMIN['err_maxlength'] . "<br/>" . LB;
    }
    //----追加項目チェック
    $err .= DATABOX_checkaddtiondatas($additionfields, $addition_def, $pi_name, $additionfields_fnm, $additionfields_del, $additionfields_alt);
    //errorのあるとき
    if ($err != "") {
        $retval['title'] = $LANG_DATABOX_ADMIN['piname'] . $LANG_DATABOX_ADMIN['edit'];
        $retval['display'] = fncEdit($id, $edt_flg, 3, $err, "edit", $fieldset_id, $template, $old_mode);
        return $retval;
    }
    // CHECK おわり
    //-----
    // 新規登録時
    if ($new_flg) {
        $w = DB_getItem($_TABLES['DATABOX_base'], "max(id)", "1=1");
        if ($w == "") {
            $w = 0;
        }
        $id = $w + 1;
    }
    $fields = LB . "id";
    $values = LB . "{$id}";
    if ($new_flg) {
        if ($_DATABOX_CONF['datacode']) {
            $code = "000000" . date(Ymdhis);
        }
        $created = COM_convertDate2Timestamp(date("Y-m-d"), date("H:i::00"));
        $modified = $created;
        $released = $created;
        $commentcode = $_DATABOX_CONF['commentcode'];
        $trackbackcode = $_CONF[trackback_code];
        $comment_expire = '0000-00-00 00:00:00';
        $expired = '0000-00-00 00:00:00';
        //
        $defaulttemplatesdirectory = null;
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        //---
        $meta_description = "";
        $meta_keywords = "";
        $owner_id = $_USER['uid'];
        $group_id = SEC_getFeatureGroup('databox.admin', $_USER['uid']);
        $array = array();
        SEC_setDefaultPermissions($array, $_DATABOX_CONF['default_permissions']);
        $perm_owner = $array['perm_owner'];
        $perm_group = $array['perm_group'];
        $perm_anon = $array['perm_anon'];
        $perm_members = $array['perm_members'];
        $draft_flag = $_DATABOX_CONF['user_draft_default'];
        $cache_time = $_DATABOX_CONF['default_cache_time'];
        //-----
        $fields .= ",defaulttemplatesdirectory";
        //
        $values .= ",'{$defaulttemplatesdirectory}'";
        $fields .= ",draft_flag";
        $values .= ",{$draft_flag}";
        $fields .= ",cache_time";
        $values .= ",{$cache_time}";
        $fields .= ",meta_description";
        //
        $values .= ",'{$meta_description}'";
        $fields .= ",meta_keywords";
        //
        $values .= ",'{$meta_keywords}'";
        $fields .= ",commentcode";
        //
        $values .= ",{$commentcode}";
        $fields .= ",trackbackcode";
        //
        $values .= ",{$trackbackcode}";
        $fields .= ",comment_expire";
        //
        if ($comment_expire == '0000-00-00 00:00:00') {
            $values .= ",'{$comment_expire}'";
        } else {
            $values .= ",FROM_UNIXTIME('{$comment_expire}')";
        }
        $fields .= ",language_id";
        //
        $values .= ",'{$language_id}'";
        $fields .= ",owner_id";
        $values .= ",{$owner_id}";
        $fields .= ",group_id";
        $values .= ",{$group_id}";
        $fields .= ",perm_owner";
        $values .= ",{$perm_owner}";
        $fields .= ",perm_group";
        $values .= ",{$perm_group}";
        $fields .= ",perm_members";
        $values .= ",{$perm_members}";
        $fields .= ",perm_anon";
        $values .= ",{$perm_anon}";
        $fields .= ",modified";
        $values .= ",FROM_UNIXTIME('{$modified}')";
        $fields .= ",created";
        $values .= ",FROM_UNIXTIME('{$created}')";
        $fields .= ",expired";
        if ($expired == '0000-00-00 00:00:00') {
            $values .= ",'{$expired}'";
        } else {
            $values .= ",FROM_UNIXTIME('{$expired}')";
        }
        $fields .= ",released";
        $values .= ",FROM_UNIXTIME('{$released}')";
        $hits = 0;
        $comments = 0;
        $fields .= ",code";
        $values .= ",'{$code}'";
        $fields .= ",title";
        //
        $values .= ",'{$title}'";
        $fields .= ",page_title";
        //
        $values .= ",'{$page_title}'";
        $fields .= ",description";
        //
        $values .= ",'{$description}'";
        //        $fields.=",hits";//
        //        $values.=",$hits";
        $fields .= ",comments";
        //
        $values .= ",{$comments}";
        $fields .= ",fieldset_id";
        //
        $values .= ",{$fieldset_id}";
        $fields .= ",uuid";
        $values .= ",{$uuid}";
        if ($edt_flg) {
            $return_page = $_CONF['site_url'] . "/" . THIS_SCRIPT;
            $return_page .= "?id=" . $id;
        } else {
            $return_page = $_CONF['site_url'] . '/' . THIS_SCRIPT . '?msg=1';
        }
        DB_save($_TABLES['DATABOX_base'], $fields, $values);
    } else {
        $sql = "UPDATE {$_TABLES['DATABOX_base']} set ";
        $sql .= " title = '{$title}'";
        $sql .= " ,page_title = '{$page_title}'";
        $sql .= " ,description = '{$description}'";
        $sql .= " ,language_id = '{$language_id}'";
        $sql .= " ,modified = FROM_UNIXTIME('{$modified}')";
        $sql .= ",uuid='{$uuid}' WHERE id={$id}";
        DB_query($sql);
    }
    //カテゴリ
    //$rt=DATABOX_savedatas("category_id",$_TABLES['DATABOX_category'],$id,$category);
    $rt = DATABOX_savecategorydatas($id, $category);
    //追加項目
    if ($old_mode == "copy") {
        DATABOX_uploadaddtiondatas_cpy($additionfields, $addition_def, $pi_name, $id, $additionfields_fnm, $additionfields_del, $additionfields_old, $additionfields_alt);
    } else {
        DATABOX_uploadaddtiondatas($additionfields, $addition_def, $pi_name, $id, $additionfields_fnm, $additionfields_del, $additionfields_old, $additionfields_alt);
    }
    if ($new_flg) {
        $rt = DATABOX_saveaddtiondatas($id, $additionfields, $addition_def, $pi_name);
    } else {
        $rt = DATABOX_saveaddtiondatas_update($id, $additionfields, $addition_def, $pi_name);
    }
    $rt = fncsendmail('data', $id);
    $cacheInstance = 'databox__' . $id . '__';
    CACHE_remove_instance($cacheInstance);
    //exit;//@@@@@debug 用
    if ($_DATABOX_CONF['aftersave'] === 'no') {
        $retval['title'] = $LANG_DATABOX_ADMIN['piname'] . $LANG_DATABOX_ADMIN['edit'];
        $retval['display'] .= fncEdit($id, $edt_flg, 1, $err, "edit", $fieldset_id, $template);
        return $retval;
    } else {
        if ($_DATABOX_CONF['aftersave'] === 'list' or $_DATABOX_CONF['aftersave'] === 'admin') {
            $url = $_CONF['site_url'] . "/databox/mydata/data.php";
            $item_url = COM_buildURL($url);
            $target = 'item';
        } else {
            $url = $_CONF['site_url'] . "/databox/data.php";
            $url .= "?";
            //コード使用の時
            if ($_DATABOX_CONF['datacode']) {
                $url .= "code=" . $code;
                $url .= "&amp;m=code";
            } else {
                $url .= "id=" . $id;
                $url .= "&amp;m=id";
            }
            $item_url = COM_buildUrl($url);
            $target = $_DATABOX_CONF['aftersave_admin'];
        }
    }
    $return_page = PLG_afterSaveSwitch($target, $item_url, $pi_name, 1);
    echo $return_page;
    exit;
}