Logo

Xin chào mừng quý khách đến với Mycard.Asia,
xin mời quý khách tiến hành tạo E tại App.Mycard.Asia

TẠO E-CARD NGAY

Hệ thống sẽ tự động chuyển sau 5s

// Kiểm tra quyền truy cập từ session if (isset($_SESSION['access_granted']) && $_SESSION['access_granted'] === true) { $access_granted = true; } // Xử lý form tạo E-Card và các hàm liên quan function handleFileUpload($file_key, $phone, $type, $max_width = null, $max_height = null) { if (isset($_FILES[$file_key]) && $_FILES[$file_key]['error'] == 0) { $file_extension = pathinfo($_FILES[$file_key]['name'], PATHINFO_EXTENSION); // Chuyển extension về chữ thường để tránh lỗi file .JPG hay .PNG viết hoa $file_extension = strtolower($file_extension); $new_file_name = $phone . '_' . $type . '.' . $file_extension; $upload_path = 'data/upload/' . $new_file_name; if (move_uploaded_file($_FILES[$file_key]['tmp_name'], $upload_path)) { // Sửa đổi: Chỉ cần có width HOẶC height là tiến hành resize if ($max_width || $max_height) { resizeImage($upload_path, $max_width, $max_height); } return 'data/upload/' . $new_file_name; } } return null; } function resizeImage($file_path, $max_width, $max_height) { list($width, $height, $type) = getimagesize($file_path); // Khởi tạo kích thước mới bằng kích thước gốc $new_width = $width; $new_height = $height; // Logic tính toán kích thước mới if ($max_height && !$max_width) { // TRƯỜNG HỢP 1: Chỉ cố định Chiều Cao (Yêu cầu của bạn: Height = 200px) $new_height = $max_height; // Tính width theo tỷ lệ của height để không méo ảnh $new_width = round($width * ($max_height / $height)); } elseif ($max_width && !$max_height) { // TRƯỜNG HỢP 2: Chỉ cố định Chiều Rộng $new_width = $max_width; $new_height = round($height * ($max_width / $width)); } elseif ($max_width && $max_height) { // TRƯỜNG HỢP 3: Có cả 2 (Co nhỏ để vừa khung - Logic cũ được tối ưu) $ratio = $width / $height; if ($width / $max_width > $height / $max_height) { $new_width = $max_width; $new_height = round($max_width / $ratio); } else { $new_height = $max_height; $new_width = round($max_height * $ratio); } } // Nếu kích thước mới lớn hơn hoặc bằng kích thước cũ thì không cần resize (tùy chọn, ở đây ta cứ resize để chuẩn hóa) if ($type == IMAGETYPE_JPEG || $type == IMAGETYPE_PNG || $type == IMAGETYPE_GIF) { if ($type == IMAGETYPE_JPEG) $src_image = imagecreatefromjpeg($file_path); elseif ($type == IMAGETYPE_PNG) $src_image = imagecreatefrompng($file_path); else $src_image = imagecreatefromgif($file_path); if (!$src_image) return; // Tránh lỗi nếu không đọc được ảnh $new_image = imagecreatetruecolor($new_width, $new_height); // Xử lý trong suốt cho PNG và GIF (quan trọng cho Logo) if ($type == IMAGETYPE_PNG || $type == IMAGETYPE_GIF) { imagealphablending($new_image, false); imagesavealpha($new_image, true); $transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127); imagefilledrectangle($new_image, 0, 0, $new_width, $new_height, $transparent); } imagecopyresampled($new_image, $src_image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); if ($type == IMAGETYPE_JPEG) imagejpeg($new_image, $file_path, 90); elseif ($type == IMAGETYPE_PNG) imagepng($new_image, $file_path, 9); else imagegif($new_image, $file_path); imagedestroy($new_image); imagedestroy($src_image); } } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['submit_form']) && $access_granted) { $template_content = file_get_contents('template.html'); $phone = $_POST['phone']; // Lưu ý: Cần đảm bảo đường dẫn này đúng với cấu hình server thực tế của bạn $domain_url = 'https://mycard.asia/card/'; // Avatar giữ nguyên kích thước gốc (không truyền tham số size) $avatar_link_relative = handleFileUpload('avatar', $phone, 'avatar'); // Corporate Logo: Chiều rộng Auto (null), Chiều cao 200px $corporate_link_relative = handleFileUpload('corporate_logo', $phone, 'corporate', null, 200); $replacements = [ '$full_name' => $_POST['full_name'], '$phone' => $phone, '$position' => $_POST['position'], '$company' => $_POST['company'], '$e_profile' => $_POST['e_profile'], '$zalo' => $_POST['zalo'], '$tiktok' => $_POST['tiktok'], '$youtube' => $_POST['youtube'], '$website' => $_POST['website'], '$email' => $_POST['email'], '$facebook' => $_POST['facebook'], '$google_maps' => $_POST['google_maps'], '$address' => $_POST['address'], ]; $final_content = str_replace(array_keys($replacements), array_values($replacements), $template_content); if ($avatar_link_relative) { $final_content = str_replace('img/avatar.png', $domain_url . $avatar_link_relative, $final_content); } if ($corporate_link_relative) { $final_content = str_replace('img/corporate.png', $domain_url . $corporate_link_relative, $final_content); } // Đảm bảo thư mục data tồn tại và có quyền ghi if (!is_dir('data')) { mkdir('data', 0755, true); } $new_file_path = 'data/' . $phone . '.html'; file_put_contents($new_file_path, $final_content); $generated_link = $domain_url . $new_file_path; $show_result = true; $_SESSION['access_granted'] = false; // Reset session sau khi tạo thành công } ?> TẠO E-CARD NHANH CHÓNG - TIỆN LỢI - CREAT E-CARD FAST - MyCard.Asia
QR Momo

Xin hãy chuẩn bị 01 hình Avatar, 01 Hình logo và các thông tin cá nhân cần thiết để tiến hành làm E-card

Nhập mã giao dịch vào ô bên dưới để tiến hành phát hành E-card của quý khách.

Hotline support: 0866 1800 45
Một sản phẩm của Vinathis AI & MyCard.Asia