Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
feat: SketchUp klasik arayuzu, kisayollar, VCB olcu kutusu ve YakNet 3B bilesen havuzu
This commit is contained in:
+274
-2
@@ -398,8 +398,8 @@ $userId = $currentUser ? (int)$currentUser['id'] : 0;
|
||||
$userEmail = $currentUser ? (string)($currentUser['email'] ?? '') : '';
|
||||
$userName = $currentUser ? (string)($currentUser['name'] ?? '') : '';
|
||||
|
||||
// 3. Kişisel Bulut Depolama İşlemleri (list, save, sync_all, delete) YakNet Kullanıcısı Gerektirir
|
||||
if (in_array($action, ['list', 'save', 'sync_all', 'delete'], true)) {
|
||||
// 3. Kişisel Bulut Depolama İşlemleri (list, save, sync_all, delete, bileşen yayınlama/silme, tercih kaydetme) YakNet Kullanıcısı Gerektirir
|
||||
if (in_array($action, ['list', 'save', 'sync_all', 'delete', 'component_publish', 'component_delete', 'prefs_save'], true)) {
|
||||
if (!$currentUser || $userId <= 0) {
|
||||
snapcad_json_response([
|
||||
'ok' => false,
|
||||
@@ -1297,4 +1297,276 @@ if ($action === 'classroom_reset_pin') {
|
||||
]);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// 8. ORTAK 3B BİLEŞEN KÜTÜPHANESİ (Mini 3D Warehouse) & KULLANICI TERCİHLERİ
|
||||
// =========================================================================
|
||||
|
||||
// 8a. BİLEŞENLERİ LİSTELE (Genel topluluk bileşenleri + kullanıcının kendi bileşenleri)
|
||||
if ($action === 'component_list') {
|
||||
snapcad_enforce_rate_limit($pdo, 'component_list', 120, 60);
|
||||
$category = trim((string)($_GET['category'] ?? $jsonBody['category'] ?? ''));
|
||||
$query = trim((string)($_GET['q'] ?? $jsonBody['q'] ?? ''));
|
||||
|
||||
try {
|
||||
$where = ['(is_public = 1' . ($userId > 0 ? ' OR user_id = :uid' : '') . ')'];
|
||||
$params = [];
|
||||
if ($userId > 0) {
|
||||
$params[':uid'] = $userId;
|
||||
}
|
||||
if ($category !== '' && $category !== 'Tümü') {
|
||||
$where[] = 'category = :cat';
|
||||
$params[':cat'] = substr($category, 0, 120);
|
||||
}
|
||||
if ($query !== '') {
|
||||
$where[] = '(title LIKE :q OR description LIKE :q OR author_name LIKE :q)';
|
||||
$params[':q'] = '%' . substr($query, 0, 80) . '%';
|
||||
}
|
||||
|
||||
$sql = 'SELECT component_uid, user_id, author_name, title, category, description, shapes_count, is_public, downloads_count, updated_at '
|
||||
. 'FROM snapcad_shared_components WHERE ' . implode(' AND ', $where)
|
||||
. ' ORDER BY downloads_count DESC, updated_at DESC LIMIT 60';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
$components = [];
|
||||
foreach ($rows as $row) {
|
||||
$components[] = [
|
||||
'component_uid' => $row['component_uid'],
|
||||
'author_name' => $row['author_name'],
|
||||
'title' => $row['title'],
|
||||
'category' => $row['category'],
|
||||
'description' => $row['description'] ?? '',
|
||||
'shapes_count' => (int)$row['shapes_count'],
|
||||
'is_public' => (bool)$row['is_public'],
|
||||
'downloads_count' => (int)$row['downloads_count'],
|
||||
'is_owner' => $userId > 0 && (int)$row['user_id'] === $userId,
|
||||
'updated_at' => $row['updated_at'],
|
||||
];
|
||||
}
|
||||
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'schema_ready' => true,
|
||||
'count' => count($components),
|
||||
'components' => $components,
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'schema_ready' => false,
|
||||
'count' => 0,
|
||||
'components' => [],
|
||||
]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// 8b. TEKİL BİLEŞENİ İNDİR / SAHNEYE EKLE
|
||||
if ($action === 'component_get') {
|
||||
snapcad_enforce_rate_limit($pdo, 'component_get', 120, 60);
|
||||
$compUid = trim((string)($_GET['component_uid'] ?? $jsonBody['component_uid'] ?? ''));
|
||||
if ($compUid === '' || strlen($compUid) > 64) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen kimliği geçersiz.'], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT component_uid, user_id, author_name, title, category, description, shapes_json, shapes_count, is_public, downloads_count, updated_at
|
||||
FROM snapcad_shared_components
|
||||
WHERE component_uid = :cid
|
||||
LIMIT 1
|
||||
");
|
||||
$stmt->execute([':cid' => $compUid]);
|
||||
$row = $stmt->fetch();
|
||||
if (!$row) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen bulunamadı.'], 404);
|
||||
}
|
||||
if (!(bool)$row['is_public'] && (int)$row['user_id'] !== $userId) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bu özel bileşene erişim izniniz yok.'], 403);
|
||||
}
|
||||
|
||||
$upd = $pdo->prepare("UPDATE snapcad_shared_components SET downloads_count = downloads_count + 1 WHERE component_uid = :cid");
|
||||
$upd->execute([':cid' => $compUid]);
|
||||
|
||||
$shapes = json_decode((string)$row['shapes_json'], true);
|
||||
if (!is_array($shapes)) {
|
||||
$shapes = [];
|
||||
}
|
||||
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'component' => [
|
||||
'component_uid' => $row['component_uid'],
|
||||
'author_name' => $row['author_name'],
|
||||
'title' => $row['title'],
|
||||
'category' => $row['category'],
|
||||
'description' => $row['description'] ?? '',
|
||||
'shapes_count' => (int)$row['shapes_count'],
|
||||
'is_public' => (bool)$row['is_public'],
|
||||
'downloads_count' => (int)$row['downloads_count'] + 1,
|
||||
'updated_at' => $row['updated_at'],
|
||||
'shapes' => $shapes,
|
||||
],
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen veritabanı henüz hazırlanmadı (migrate.php gerekli).'], 503);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// 8c. SEÇİLİ NESNELERİ YAKNET 3B BİLEŞEN HAVUZUNA YAYINLA
|
||||
if ($action === 'component_publish') {
|
||||
snapcad_enforce_rate_limit($pdo, 'component_publish', 30, 3600);
|
||||
$title = substr(trim((string)($jsonBody['title'] ?? '')), 0, 255);
|
||||
$category = substr(trim((string)($jsonBody['category'] ?? 'Genel 3B Bileşen')), 0, 120) ?: 'Genel 3B Bileşen';
|
||||
$description = substr(trim((string)($jsonBody['description'] ?? '')), 0, 1000);
|
||||
$isPublic = array_key_exists('is_public', $jsonBody) ? (!empty($jsonBody['is_public']) ? 1 : 0) : 1;
|
||||
$shapes = $jsonBody['shapes'] ?? null;
|
||||
|
||||
if ($title === '' || !is_array($shapes) || count($shapes) === 0) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen adı ve en az 1 geometri gereklidir.'], 400);
|
||||
}
|
||||
|
||||
$shapesJson = json_encode($shapes, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($shapesJson === false || strlen($shapesJson) > 1048576) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen geometrisi 1 MB sınırını aşıyor.'], 413);
|
||||
}
|
||||
|
||||
$requestedUid = substr(trim((string)($jsonBody['component_uid'] ?? '')), 0, 64);
|
||||
$compUid = $requestedUid !== '' ? $requestedUid : ('cmp_' . bin2hex(random_bytes(8)));
|
||||
$authorName = substr($userName ?: 'YakNet Kullanıcısı', 0, 255);
|
||||
|
||||
try {
|
||||
if ($requestedUid !== '') {
|
||||
$chk = $pdo->prepare("SELECT user_id FROM snapcad_shared_components WHERE component_uid = :cid LIMIT 1");
|
||||
$chk->execute([':cid' => $requestedUid]);
|
||||
$owner = $chk->fetch();
|
||||
if ($owner && (int)$owner['user_id'] !== $userId) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Başka bir kullanıcıya ait bileşeni güncelleyemezsiniz.'], 403);
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO snapcad_shared_components
|
||||
(component_uid, user_id, author_name, title, category, description, shapes_json, shapes_count, is_public)
|
||||
VALUES
|
||||
(:cid, :uid, :author, :title, :cat, :descr, :sjson, :scnt, :pub)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
author_name = VALUES(author_name),
|
||||
title = VALUES(title),
|
||||
category = VALUES(category),
|
||||
description = VALUES(description),
|
||||
shapes_json = VALUES(shapes_json),
|
||||
shapes_count = VALUES(shapes_count),
|
||||
is_public = VALUES(is_public),
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
");
|
||||
$stmt->execute([
|
||||
':cid' => $compUid,
|
||||
':uid' => $userId,
|
||||
':author' => $authorName,
|
||||
':title' => $title,
|
||||
':cat' => $category,
|
||||
':descr' => $description,
|
||||
':sjson' => $shapesJson,
|
||||
':scnt' => count($shapes),
|
||||
':pub' => $isPublic,
|
||||
]);
|
||||
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'component_uid' => $compUid,
|
||||
'message' => 'Bileşen YakNet 3B Bileşen Havuzuna kaydedildi.',
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bileşen tablosu için veritabanı migrasyonu gerekli.'], 503);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// 8d. KULLANICININ PAYLAŞTIĞI BİLEŞENİ SİL
|
||||
if ($action === 'component_delete') {
|
||||
snapcad_enforce_rate_limit($pdo, 'component_delete', 60, 60);
|
||||
$compUid = trim((string)($jsonBody['component_uid'] ?? $_POST['component_uid'] ?? ''));
|
||||
if ($compUid === '' || strlen($compUid) > 64) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Silinecek bileşen belirtilmedi.'], 400);
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("DELETE FROM snapcad_shared_components WHERE component_uid = :cid AND user_id = :uid LIMIT 1");
|
||||
$stmt->execute([':cid' => $compUid, ':uid' => $userId]);
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'deleted' => $stmt->rowCount() > 0,
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response(['ok' => true, 'deleted' => false]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// 8e. KULLANICI ARAYÜZ & KISAYOL TERCİHLERİNİ GETİR
|
||||
if ($action === 'prefs_get') {
|
||||
if (!$currentUser || $userId <= 0) {
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'authenticated' => false,
|
||||
'prefs' => null,
|
||||
]);
|
||||
}
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT prefs_json, updated_at FROM snapcad_user_prefs WHERE user_id = :uid LIMIT 1");
|
||||
$stmt->execute([':uid' => $userId]);
|
||||
$row = $stmt->fetch();
|
||||
$prefs = $row ? json_decode((string)$row['prefs_json'], true) : null;
|
||||
snapcad_json_response([
|
||||
'ok' => true,
|
||||
'authenticated' => true,
|
||||
'prefs' => is_array($prefs) ? $prefs : null,
|
||||
'updated_at' => $row['updated_at'] ?? null,
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response(['ok' => true, 'authenticated' => true, 'prefs' => null, 'schema_ready' => false]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
// 8f. KULLANICI ARAYÜZ & KISAYOL TERCİHLERİNİ KAYDET
|
||||
if ($action === 'prefs_save') {
|
||||
snapcad_enforce_rate_limit($pdo, 'prefs_save', 60, 60);
|
||||
$prefs = $jsonBody['prefs'] ?? null;
|
||||
if (!is_array($prefs)) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Geçersiz tercih verisi.'], 400);
|
||||
}
|
||||
$prefsJson = json_encode($prefs, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
if ($prefsJson === false || strlen($prefsJson) > 32768) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Tercih verisi 32 KB sınırını aşıyor.'], 413);
|
||||
}
|
||||
try {
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO snapcad_user_prefs (user_id, prefs_json)
|
||||
VALUES (:uid, :pjson)
|
||||
ON DUPLICATE KEY UPDATE prefs_json = VALUES(prefs_json), updated_at = CURRENT_TIMESTAMP
|
||||
");
|
||||
$stmt->execute([':uid' => $userId, ':pjson' => $prefsJson]);
|
||||
snapcad_json_response(['ok' => true, 'saved_at' => date('c')]);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() === '42S02' || str_contains($e->getMessage(), '1146')) {
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Tercihler tablosu henüz oluşturulmadı.'], 503);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
snapcad_json_response(['ok' => false, 'error' => 'Bilinmeyen işlem: ' . $action], 400);
|
||||
Reference in New Issue
Block a user