AvocadoAmber/AvocadoEdition_Light/adm/editor_font_update.php

62 lines
2.1 KiB
PHP
Raw Normal View History

2024-09-22 10:46:52 +09:00
<?php
2024-09-22 13:51:59 +09:00
include_once './_common.php';
2024-09-22 10:46:52 +09:00
if ($is_admin != 'super') {
2024-09-22 13:51:59 +09:00
alert('최고관리자만 접근 가능합니다.');
2024-09-22 10:46:52 +09:00
}
2024-09-22 13:51:59 +09:00
$w = isset($_POST['w']) ? $_POST['w'] : (isset($_GET['w']) ? $_GET['w'] : '');
if ($w == 'd') {
$font_id = isset($_POST['font_id']) ? intval($_POST['font_id']) : isset($_GET['font_id']) ? intval($_GET['font_id']) : 0;
if (!$font_id) {
alert('올바른 요청이 아닙니다.');
}
}
if ($w == '') {
$font_css = isset($_POST['font_css']) ? stripslashes(trim($_POST['font_css'])) : '';
$font_name = isset($_POST['font_name']) ? clean_xss_tags(trim($_POST['font_name'])) : '';
if (empty($font_css) || empty($font_name)) {
alert('@font-face CSS와 폰트 이름은 필수 입력 항목입니다.');
}
preg_match("/font-family:\s*['\"](.*?)['\"]/i", $font_css, $family_matches);
preg_match("/src:\s*(.*?);/i", $font_css, $src_matches);
preg_match("/font-weight:\s*(.*?);/i", $font_css, $weight_matches);
preg_match("/font-style:\s*(.*?);/i", $font_css, $style_matches);
$font_family = isset($family_matches[1]) ? clean_xss_tags(trim($family_matches[1])) : '';
$font_url = isset($src_matches[1]) ? addslashes(trim($src_matches[1])) : '';
$font_weight = isset($weight_matches[1]) ? clean_xss_tags(trim($weight_matches[1])) : 'normal';
$font_style = isset($style_matches[1]) ? clean_xss_tags(trim($style_matches[1])) : 'normal';
if (empty($font_family) || empty($font_url)) {
alert('CSS에서 font-family와 src를 추출할 수 없습니다.');
}
$sql = "INSERT INTO {$g5['font_table']} SET font_name = '{$font_name}',
font_family = '{$font_family}',
font_url = '{$font_url}',
font_weight = '{$font_weight}',
font_style = '{$font_style}'";
sql_query($sql);
$sql_error = sql_error_info();
$msg = '폰트가 추가되었습니다.';
} else if ($w == 'd') {
$sql = " DELETE FROM {$g5['font_table']} WHERE font_id = '{$font_id}' ";
sql_query($sql);
$msg = '폰트가 삭제되었습니다.';
}
if ($msg) {
alert($msg);
}
goto_url('./editor_font.php');