Clomosy | Forum Ana Sayfa
Forum Anasayfa Forum Anasayfa > Genel Programlama > Genel İşlemler
  Aktif Konular Aktif Konular RSS - Bunun nasıl daha hızlı çalışmasını sağlayabiliriz?
  SSS SSS  Forumu Ara   Etkinlikler   Kayıt Ol Kayıt Ol  Giriş Giriş

Clomosy Resmi Forum Sitesidir. Amacımız kullanıcılarımıza, iş ortaklarımıza, danışmanlara, yazılımcılara programlarımız hakkında destek ve bilgi vermektir.

Bunun nasıl daha hızlı çalışmasını sağlayabiliriz?

 Yanıt Yaz Yanıt Yaz
Yazar
Mesaj
  Konu Arama Konu Arama  Topic Seçenekleri Topic Seçenekleri
ibrahimBsr Açılır Kutu İzle
Yeni Üye
Yeni Üye
Simge

Kayıt Tarihi: 23 Haziran 2026
Durum: Aktif Değil
Puanlar: 27
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı ibrahimBsr Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: Bunun nasıl daha hızlı çalışmasını sağlayabiliriz?
    Gönderim Zamanı: 5 Saat 49 Dakika Önce Saat 10:11
//uses Main;

var
  Form1: TCLForm;
  ScaledLayout: TclScaledLayout;
  
  HeaderPnl, LogoLeftPnl, ActionRightPnl, PageTitlePnl, DividerPnl, SearchWrapPnl, SearchPnl, CountPnl, BottomMenuPnl: TclProPanel;
  TitleLbl, SubTitleLbl, PageTitleLbl, CountLbl: TclProLabel;
  SearchEdt: TclProEdit;
  ProfileBtn, ViewToggleBtn, LSummaryBtn, SearchBtn: TclProButton;
  NotifBtn: TclProImage; 
  CatalogBtn, BorrowedBtn, QrBtn, MyListBtn, SettingsBtn: TclProButton;
  
  FiltersPnl: TclProPanel;
  FiltersScrollBox: TclHorzScrollBox;
  FilterAllBtn, FilterRomanBtn, FilterBilimBtn, FilterTarihBtn, FilterFelsefeBtn, FilterCocukBtn, FilterGelisimBtn: TclProButton;
  
  BooksScrollBox, DetailScrollBox: TclVertScrollBox;
  GlobalBookCount: Integer;
  
  GlobalNotifMsg: String; 
  GlobalNotifCount: Integer; 

  GlobalViewMode: String;
  GlobalGridColCount: Integer;
  GlobalGridRowPnl: TclProPanel;

  DetailOverlayPnl, DetailContentPnl, DetailHeaderPnl, DetailFooterPnl: TclProPanel;
  DetailTitleLbl, DetailAuthorLbl, DetailDescLbl: TclProLabel;
  DetailCloseBtn, DetailFavBtn, DetailBorrowBtn: TclProButton;

  AlertOverlayPnl, AlertBoxPnl: TclProPanel;
  AlertMsgLbl: TclProLabel;
  AlertOkBtn: TclProButton;

  GlobalActionTimer, OpenDetailTimer: TclTimer;
  GlobalActionType, GlobalSelectedBookID, GlobalFilterGenre: String;
  GlobalCurrentStock: Integer;
  GlobalBooksList: TclStringList;

void GoToBorrowed; { Clomosy.RunUnit('uOdunc'); }
void GoToQR; { Clomosy.RunUnit('uQR'); }
void GoToListe; { Clomosy.RunUnit('uListe'); }
void GoToSettings; { Clomosy.RunUnit('uAyarlar'); }

void CloseDetail;
{
  DetailOverlayPnl.Visible = False;
  DetailContentPnl.Visible = False;
}

void ToggleViewMode;
var
  clRest: TclRest;
  jsonBody: String;
{
  if (GlobalViewMode == 'list') GlobalViewMode = 'grid';
  else GlobalViewMode = 'list';
  
  if (Clomosy.GlobalVariableString <> '')
  {
    clRest = TclRest.Create;
    clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/settings/'+Clomosy.GlobalVariableString+'/viewMode.json';
    clRest.Method = rmPUT;
    clRest.Accept = 'application/json';
    jsonBody = '"' + GlobalViewMode + '"';
    clRest.AddBody(jsonBody, 'application/json');
    clRest.Execute;
    clRest.Free;
  }
  Clomosy.RunUnit('uKatalog');
}

void SendNotification(AUser: String; AMsg: String);
var
  clRest: TclRest;
  notifID, jsonBody: String;
{
  notifID = FormatDateTime('yymmddhhnnsszzz', Now);
  clRest = TclRest.Create;
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/notifications/' + AUser + '/' + notifID + '.json';
  clRest.Method = rmPUT;
  clRest.Accept = 'application/json';
  jsonBody = '{"msg":"' + AMsg + '"}';
  clRest.AddBody(jsonBody, 'application/json');
  clRest.Execute;
  clRest.Free;
  
  if (AUser == Clomosy.GlobalVariableString)
  {
    GlobalNotifCount = GlobalNotifCount + 1;
    GlobalNotifMsg = GlobalNotifMsg + '- ' + AMsg + #13#10;
    if (NotifBtn <> nil)
    {
      NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D81B60'); 
      NotifBtn.SetclProSettings(NotifBtn.clProSettings);
    }
  }
}

void UpdateModalButtonsStatus(ABookID: String);
var
  clRest: TclRest;
  bData, currentUser, bookStr, stockStr: String;
  pStart, pEnd, totalStock: Integer;
  userAlreadyBorrowed: Boolean;
{
  currentUser = Clomosy.GlobalVariableString;
  
  DetailBorrowBtn.Text = 'Ödünç Al';
  DetailBorrowBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  DetailBorrowBtn.Enabled = True;
  DetailBorrowBtn.SetclProSettings(DetailBorrowBtn.clProSettings);
  
  DetailFavBtn.Text = 'Listeme Ekle';
  DetailFavBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  DetailFavBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  DetailFavBtn.clProSettings.BorderWidth = 0;
  DetailFavBtn.SetclProSettings(DetailFavBtn.clProSettings);
  
  if (currentUser == '') Exit;
  
  clRest = TclRest.Create;
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books/' + ABookID + '.json';
  clRest.Method = rmGET;
  clRest.Execute;
  bookStr = clRest.Response;
  clRest.Free;
  
  totalStock = 0;
  if ((bookStr <> 'null') && (bookStr <> '') && (bookStr <> '{}'))
  {
     pStart = Pos('"stock":"', bookStr);
     if (pStart > 0)
     {
        pStart = pStart + 9;
        pEnd = Pos('"', Copy(bookStr, pStart, Length(bookStr)));
        stockStr = Copy(bookStr, pStart, pEnd - 1);
        if (stockStr <> '') totalStock = StrToIntDef(stockStr, 0);
     }
  }
  GlobalCurrentStock = totalStock;
  
  clRest = TclRest.Create;
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/borrowed/' + ABookID + '.json';
  clRest.Method = rmGET;
  clRest.Execute;
  bData = clRest.Response;
  clRest.Free;
  
  userAlreadyBorrowed = False;
  if ((bData <> 'null') && (bData <> '') && (bData <> '{}'))
  {
     if (Pos('"' + currentUser + '"', bData) > 0) userAlreadyBorrowed = True;
  }
  
  if (userAlreadyBorrowed)
  {
      DetailBorrowBtn.Text = 'Zaten Ödünç Aldınız';
      DetailBorrowBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#4CAF50');
      DetailBorrowBtn.Enabled = False;
      DetailBorrowBtn.SetclProSettings(DetailBorrowBtn.clProSettings);
  }
  else if (totalStock <= 0)
  {
      DetailBorrowBtn.Text = 'Stokta Yok';
      DetailBorrowBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#888888');
      DetailBorrowBtn.Enabled = False;
      DetailBorrowBtn.SetclProSettings(DetailBorrowBtn.clProSettings);
  }
  
  clRest = TclRest.Create;
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/favorites/' + currentUser + '/' + ABookID + '.json';
  clRest.Method = rmGET;
  clRest.Execute;
  bData = clRest.Response;
  clRest.Free;
  if ((bData <> 'null') && (bData <> '') && (bData <> '{}'))
  {
    DetailFavBtn.Text = 'Listemde (Çıkar)';
    DetailFavBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
    DetailFavBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#D81B60');
    DetailFavBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D81B60');
    DetailFavBtn.clProSettings.BorderWidth = 1;
    DetailFavBtn.SetclProSettings(DetailFavBtn.clProSettings);
  }
}

void BorrowBookClick;
var currentUser: String;
{
  if (DetailBorrowBtn.Text <> 'Ödünç Al') Exit;
  currentUser = Clomosy.GlobalVariableString;
  if (currentUser == '') { ShowMessage('Lütfen giriş yapın.'); Exit; }
  
  GlobalActionType = 'BORROW';
  Form1.FormWaiting.Visible = True;
  GlobalActionTimer.Enabled = True;
}

void FavBookClick;
var currentUser: String;
{
  currentUser = Clomosy.GlobalVariableString;
  if (currentUser == '') { ShowMessage('Lütfen giriş yapın.'); Exit; }
  
  if (DetailFavBtn.Text == 'Listeme Ekle') GlobalActionType = 'ADD_FAV';
  else GlobalActionType = 'DEL_FAV';
  
  Form1.FormWaiting.Visible = True;
  GlobalActionTimer.Enabled = True;
}

void OnOpenDetailTimer;
var
  SourceTitleLbl, SourceAuthorLbl, SourceSummaryLbl, SourceUrlLbl, SourceGenreLbl: TclProLabel;
  clRestCache: TclRest;
  jsonBody, bCoverUrl: String;
{
  OpenDetailTimer.Enabled = False;
  
  SourceTitleLbl = TclProLabel(Form1.clFindComponent('Title_' + GlobalSelectedBookID));
  SourceAuthorLbl = TclProLabel(Form1.clFindComponent('Author_' + GlobalSelectedBookID));
  SourceSummaryLbl = TclProLabel(Form1.clFindComponent('Desc_' + GlobalSelectedBookID));
  SourceUrlLbl = TclProLabel(Form1.clFindComponent('CoverUrl_' + GlobalSelectedBookID)); 
  SourceGenreLbl = TclProLabel(Form1.clFindComponent('Genre_' + GlobalSelectedBookID)); 

  if (SourceTitleLbl <> nil) DetailTitleLbl.Text = SourceTitleLbl.Text;
  if (SourceAuthorLbl <> nil) DetailAuthorLbl.Text = SourceAuthorLbl.Text;
  if (SourceSummaryLbl <> nil) DetailDescLbl.Text = SourceSummaryLbl.Text;
  else DetailDescLbl.Text = 'Bu kitap için özet bilgisi bulunamadı.';
  
  bCoverUrl = '';
  if (SourceUrlLbl <> nil) bCoverUrl = SourceUrlLbl.Text;
  
  if ((GlobalSelectedBookID <> '') && (Pos('OL', GlobalSelectedBookID) > 0))
  {
    clRestCache = TclRest.Create;
    clRestCache.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books/'+GlobalSelectedBookID+'.json';
    clRestCache.Method = rmGET;
    clRestCache.Execute;
    
    // Kitap veritabanında yoksa YENİ EKLE
    if ((clRestCache.Response == 'null') || (clRestCache.Response == '') || (clRestCache.Response == '{}'))
    {
       clRestCache.Free; 
       
       clRestCache = TclRest.Create; 
       clRestCache.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books/'+GlobalSelectedBookID+'.json';
       clRestCache.Method = rmPUT;
       clRestCache.Accept = 'application/json';
       
       // BURAYA YENİ KİTAPLAR İÇİN "stock":"0" BİLGİSİ EKLENDİ
       jsonBody = '{"id":"'+GlobalSelectedBookID+'", "title":"'+DetailTitleLbl.Text+'", "author":"'+DetailAuthorLbl.Text+'", "color":"#2E4053", "summary":"OpenLibrary API Kaydı", "cover":"'+bCoverUrl+'", "genre":"'+SourceGenreLbl.Text+'", "stock":"0"}';
       
       clRestCache.AddBody(jsonBody, 'application/json');
       clRestCache.Execute;
       clRestCache.Free;
    }
    else
    {
       clRestCache.Free;
    }
  }
  
  // Modal butonlarını güncelle (Eğer stok 0 ise "Stokta Yok" diyecektir)
  if (GlobalSelectedBookID <> '') UpdateModalButtonsStatus(GlobalSelectedBookID);
  
  DetailOverlayPnl.Visible = True;
  DetailContentPnl.Visible = True;
  DetailContentPnl.BringToFront;
  Form1.FormWaiting.Visible = False;
}

void OpenDetail;
var ClickedPnl: TclProPanel;
{
  ClickedPnl = TclProPanel(Form1.clSender);
  GlobalSelectedBookID = ClickedPnl.clTagStr; 
  DetailContentPnl.clTagStr = GlobalSelectedBookID;
  
  Form1.FormWaiting.Visible = True;
  OpenDetailTimer.Enabled = True;
}

void CreateBookCard(AID: String; ATitle: String; AAuthor: String; ARating: String; AColor: String; ASummary: String; ACoverUrl: String; AGenre: String);
var
  LCardPnl, LCoverPnl, LInfoPnl: TclProPanel;
  LTitleLbl, LAuthorLbl, LRatingLbl, LSummaryLbl, LUrlLbl, LGenreLbl: TclProLabel;
  LCoverImg: TclProImage;
{
  if (GlobalViewMode == 'grid')
  {
    if (GlobalGridColCount == 0)
    {
      GlobalGridRowPnl = Form1.AddNewProPanel(BooksScrollBox, 'GridRow_' + AID);
      GlobalGridRowPnl.Align = alTop; GlobalGridRowPnl.Height = 160; GlobalGridRowPnl.Margins.Left = 10; GlobalGridRowPnl.Margins.Right = 10; GlobalGridRowPnl.Margins.Top = 10;
      GlobalGridRowPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
      GlobalGridRowPnl.SetclProSettings(GlobalGridRowPnl.clProSettings);
    }
    
    LCardPnl = Form1.AddNewProPanel(GlobalGridRowPnl, 'Card_' + AID);
    LCardPnl.Align = alLeft; LCardPnl.Width = 100; LCardPnl.Margins.Left = 5; LCardPnl.Margins.Right = 5;
    LCardPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF'); LCardPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#E2DED5'); LCardPnl.clProSettings.BorderWidth = 1; LCardPnl.clProSettings.RoundHeight = 8; LCardPnl.clProSettings.RoundWidth = 8;
    LCardPnl.SetclProSettings(LCardPnl.clProSettings);
    LCardPnl.clTagStr = AID; Form1.AddNewEvent(LCardPnl, tbeOnClick, 'OpenDetail');
    
    LUrlLbl = Form1.AddNewProLabel(LCardPnl, 'CoverUrl_' + AID, ACoverUrl); LUrlLbl.Visible = False;
    LSummaryLbl = Form1.AddNewProLabel(LCardPnl, 'Desc_' + AID, ASummary); LSummaryLbl.Visible = False;
    LGenreLbl = Form1.AddNewProLabel(LCardPnl, 'Genre_' + AID, AGenre); LGenreLbl.Visible = False;
    LAuthorLbl = Form1.AddNewProLabel(LCardPnl, 'Author_' + AID, AAuthor); LAuthorLbl.Visible = False;

    LCoverPnl = Form1.AddNewProPanel(LCardPnl, 'Cover_' + AID);
    LCoverPnl.Align = alTop; LCoverPnl.Height = 100; LCoverPnl.Margins.Left = 5; LCoverPnl.Margins.Top = 5; LCoverPnl.Margins.Right = 5;
    LCoverPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor(AColor); LCoverPnl.clProSettings.RoundHeight = 5; LCoverPnl.clProSettings.RoundWidth = 5;
    LCoverPnl.SetclProSettings(LCoverPnl.clProSettings);
    LCoverPnl.clTagStr = AID; Form1.AddNewEvent(LCoverPnl, tbeOnClick, 'OpenDetail');
    
    if (ACoverUrl <> '')
    {
      LCoverImg = Form1.AddNewProImage(LCoverPnl, 'CoverImg_' + AID);
      LCoverImg.Align = alClient; LCoverImg.Margins.Left = 2; LCoverImg.Margins.Right = 2; LCoverImg.Margins.Top = 2; LCoverImg.Margins.Bottom = 2;
      LCoverImg.clProSettings.PictureSource = ACoverUrl; LCoverImg.clProSettings.PictureAutoFit = True;
      LCoverImg.SetclProSettings(LCoverImg.clProSettings);
      LCoverImg.clTagStr = AID; Form1.AddNewEvent(LCoverImg, tbeOnClick, 'OpenDetail');
    }
    
    LTitleLbl = Form1.AddNewProLabel(LCardPnl, 'Title_' + AID, ATitle);
    LTitleLbl.Align = alBottom; LTitleLbl.Height = 40; LTitleLbl.Margins.Left = 5; LTitleLbl.Margins.Right = 5; LTitleLbl.Margins.Bottom = 5;
    LTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#002B36'); LTitleLbl.clProSettings.FontSize = 11; LTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold]; LTitleLbl.clProSettings.WordWrap = True;
    LTitleLbl.SetclProSettings(LTitleLbl.clProSettings);
    LTitleLbl.clTagStr = AID; Form1.AddNewEvent(LTitleLbl, tbeOnClick, 'OpenDetail');
    
    GlobalGridColCount = GlobalGridColCount + 1;
    if (GlobalGridColCount >= 3) GlobalGridColCount = 0;
  }
  else
  {
    LCardPnl = Form1.AddNewProPanel(BooksScrollBox, 'Card_' + AID);
    LCardPnl.Align = alTop; LCardPnl.Height = 110; LCardPnl.Margins.Left = 15; LCardPnl.Margins.Right = 15; LCardPnl.Margins.Bottom = 10;
    LCardPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF'); LCardPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#E2DED5'); LCardPnl.clProSettings.BorderWidth = 1;
    LCardPnl.SetclProSettings(LCardPnl.clProSettings);
    
    LUrlLbl = Form1.AddNewProLabel(LCardPnl, 'CoverUrl_' + AID, ACoverUrl); LUrlLbl.Visible = False;
    LSummaryLbl = Form1.AddNewProLabel(LCardPnl, 'Desc_' + AID, ASummary); LSummaryLbl.Visible = False;
    LGenreLbl = Form1.AddNewProLabel(LCardPnl, 'Genre_' + AID, AGenre); LGenreLbl.Visible = False;

    LCoverPnl = Form1.AddNewProPanel(LCardPnl, 'Cover_' + AID);
    LCoverPnl.Align = alLeft; LCoverPnl.Width = 65; LCoverPnl.Margins.Left = 10; LCoverPnl.Margins.Top = 10; LCoverPnl.Margins.Bottom = 10;
    LCoverPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor(AColor);
    LCoverPnl.SetclProSettings(LCoverPnl.clProSettings);
    
    if (ACoverUrl <> '')
    {
      LCoverImg = Form1.AddNewProImage(LCoverPnl, 'CoverImg_' + AID);
      LCoverImg.Align = alClient; LCoverImg.Margins.Left = 2; LCoverImg.Margins.Right = 2; LCoverImg.Margins.Top = 2; LCoverImg.Margins.Bottom = 2;
      LCoverImg.clProSettings.PictureSource = ACoverUrl; LCoverImg.clProSettings.PictureAutoFit = True;
      LCoverImg.SetclProSettings(LCoverImg.clProSettings);
    }
    
    LRatingLbl = Form1.AddNewProLabel(LCardPnl, 'Rating_' + AID, ARating + ' ★' );
    LRatingLbl.Align = alRight; LRatingLbl.Width = 45; LRatingLbl.Margins.Top = 10; LRatingLbl.Margins.Right = 10;
    LRatingLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#B8860B');
    LRatingLbl.SetclProSettings(LRatingLbl.clProSettings);
    
    LSummaryBtn = Form1.AddNewProButton(LCardPnl, 'Summary_' + AID, 'Bilgiler');
    LSummaryBtn.Align = alRight; LSummaryBtn.Width = 60; LSummaryBtn.Margins.Top = 50; LSummaryBtn.Margins.Bottom = 25; LSummaryBtn.Margins.Right = -25;
    LSummaryBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); LSummaryBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
    LSummaryBtn.SetclProSettings(LSummaryBtn.clProSettings);
    LSummaryBtn.clTagStr = AID; Form1.AddNewEvent(LSummaryBtn, tbeOnClick, 'OpenDetail');
    
    LInfoPnl = Form1.AddNewProPanel(LCardPnl, 'Info_' + AID);
    LInfoPnl.Align = alClient; LInfoPnl.Margins.Left = 15;

    LTitleLbl = Form1.AddNewProLabel(LInfoPnl, 'Title_' + AID, ATitle);
    LTitleLbl.Align = alTop; LTitleLbl.Height = 25; LTitleLbl.Margins.Top = 15;
    LTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000'); LTitleLbl.clProSettings.FontSize = 16; LTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
    LTitleLbl.SetclProSettings(LTitleLbl.clProSettings);

    LAuthorLbl = Form1.AddNewProLabel(LInfoPnl, 'Author_' + AID, AAuthor);
    LAuthorLbl.Align = alTop; LAuthorLbl.Height = 20;
    LAuthorLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#666666');
    LAuthorLbl.SetclProSettings(LAuthorLbl.clProSettings);
  }
  GlobalBookCount = GlobalBookCount + 1;
}

void DrawBooks;
var
  i: Integer;
  clQueryItem: TClJSONQuery;
  jsonArrStr, itemID, itemTitle, itemAuthor, itemRating, itemColor, itemSummary, itemCover, itemGenre: String;
{
  if (BooksScrollBox <> nil) BooksScrollBox.Free;
  BooksScrollBox = Form1.AddNewVertScrollBox(ScaledLayout, 'BooksScrollBox_' + FormatDateTime('hhnnsszzz', Now));
  BooksScrollBox.Align = alClient;
  
  GlobalBookCount = 0; GlobalGridColCount = 0;
  if (GlobalBooksList == nil) Exit;

  jsonArrStr = '[';
  for i = 0 to GlobalBooksList.Count - 1
  {
     jsonArrStr = jsonArrStr + GlobalBooksList.Strings;
     if (i < GlobalBooksList.Count - 1) jsonArrStr = jsonArrStr + ',';
  }
  jsonArrStr = jsonArrStr + ']';
  
  if (jsonArrStr <> '[]')
  {
      clQueryItem = Clomosy.ClDataSetFromJSON(jsonArrStr);
      if (clQueryItem <> nil)
      {
         clQueryItem.First;
         while (not clQueryItem.Eof)
         {
            itemGenre = clQueryItem.FieldByName('genre').AsString;
            if ((GlobalFilterGenre == 'Tümü') || (GlobalFilterGenre == '') || (Pos(GlobalFilterGenre, itemGenre) > 0))
            {
               itemID = clQueryItem.FieldByName('id').AsString;
               itemTitle = clQueryItem.FieldByName('title').AsString;
               itemAuthor = clQueryItem.FieldByName('author').AsString;
               itemRating = clQueryItem.FieldByName('rating').AsString;
               itemColor = clQueryItem.FieldByName('color').AsString;
               itemSummary = clQueryItem.FieldByName('summary').AsString;
               itemCover = clQueryItem.FieldByName('cover').AsString;
               CreateBookCard(itemID, itemTitle, itemAuthor, itemRating, itemColor, itemSummary, itemCover, itemGenre);
            }
            clQueryItem.Next;
         }
         clQueryItem.Free;
      }
  }
  CountLbl.Text = IntToStr(GlobalBookCount) + ' kitap';
}

void FilterClick;
var ClickedBtn: TclProButton;
{
  ClickedBtn = TclProButton(Form1.clSender);
  GlobalFilterGenre = ClickedBtn.Text;
  
  FilterAllBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterAllBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterRomanBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterRomanBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterBilimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterBilimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterTarihBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterTarihBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterFelsefeBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterFelsefeBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterCocukBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterCocukBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterGelisimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterGelisimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');

  ClickedBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054');
  ClickedBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  
  FilterAllBtn.SetclProSettings(FilterAllBtn.clProSettings); FilterRomanBtn.SetclProSettings(FilterRomanBtn.clProSettings); FilterBilimBtn.SetclProSettings(FilterBilimBtn.clProSettings);
  FilterTarihBtn.SetclProSettings(FilterTarihBtn.clProSettings); FilterFelsefeBtn.SetclProSettings(FilterFelsefeBtn.clProSettings); FilterCocukBtn.SetclProSettings(FilterCocukBtn.clProSettings); FilterGelisimBtn.SetclProSettings(FilterGelisimBtn.clProSettings);

  DrawBooks;
}

void FetchBooksFromFirebase;
var
  clRestSettings, clRest, clRestBorrowed, clRestReviews, clRestNotif: TclRest;
  clQuery: TClJSONQuery;
  bookID, valStr, ratingStr, currentUser, respStr, retDateStr, bCoverUrl: String;
  bTitle, bAuthor, bColor, bSummary, bGenre: String;
  pStart, pEnd, totalRating, reviewCount, daysLeft: Integer;
  avgRating: Double;
  allBorrowedStr, allReviewsStr, bookBorrowBlock, bookRevBlock: String;
{
  currentUser = Clomosy.GlobalVariableString;
  GlobalNotifMsg = ''; GlobalNotifCount = 0; GlobalGridColCount = 0; 
  
  if (GlobalBooksList <> nil) GlobalBooksList.Free;
  GlobalBooksList = Clomosy.StringListNew;
  
  if (currentUser <> '')
  {
    clRestSettings = TclRest.Create; clRestSettings.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/settings/'+currentUser+'/viewMode.json'; clRestSettings.Method = rmGET; clRestSettings.Execute;
    if (Pos('"grid"', clRestSettings.Response) > 0) GlobalViewMode = 'grid'; else GlobalViewMode = 'list';
    clRestSettings.Free;
    
    if (ViewToggleBtn <> nil)
    {
      if (GlobalViewMode == 'grid') ViewToggleBtn.Text = 'Liste'; else ViewToggleBtn.Text = 'Izgara';
    }
  
    clRestNotif = TclRest.Create; clRestNotif.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/notifications/' + currentUser + '.json'; clRestNotif.Method = rmGET; clRestNotif.Execute;
    respStr = clRestNotif.Response; clRestNotif.Free;
    if ((respStr <> 'null') && (respStr <> '') && (respStr <> '{}'))
    {
      pStart = Pos('"msg":"', respStr);
      while (pStart > 0)
      {
        GlobalNotifCount = GlobalNotifCount + 1; 
        respStr = Copy(respStr, pStart + 7, Length(respStr));
        GlobalNotifMsg = GlobalNotifMsg + '- ' + Copy(respStr, 1, Pos('"', respStr) - 1) + #13#10;
        pStart = Pos('"msg":"', respStr);
      }
    }
  } else GlobalViewMode = 'list';

  clRestBorrowed = TclRest.Create; clRestBorrowed.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/borrowed.json'; clRestBorrowed.Method = rmGET; clRestBorrowed.Execute; allBorrowedStr = clRestBorrowed.Response; clRestBorrowed.Free;
  clRestReviews = TclRest.Create; clRestReviews.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/reviews.json'; clRestReviews.Method = rmGET; clRestReviews.Execute; allReviewsStr = clRestReviews.Response; clRestReviews.Free;

  clRest = TclRest.Create; clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books.json'; clRest.Method = rmGET; clRest.Accept = 'application/json'; clRest.Execute;
  
  if ((clRest.Response <> 'null') && (clRest.Response <> '') && (clRest.Response <> '{}'))
  {
    if ((Pos('":{"', clRest.Response) == 0) && (Pos('": {"', clRest.Response) == 0))
    {
       clRest.Method = rmDELETE; clRest.Execute; ShowMessage('Sistem Uyarısı: Veritabanı sıfırlandı.');
    }
    else
    {
      clQuery = Clomosy.ClDataSetFromJSON(clRest.Response);
      if (clQuery <> nil)
      {
        clQuery.First;
        while (not clQuery.Eof)
        {
          bookID = ''; try bookID = clQuery.FieldByName('id').AsString; except bookID = ''; }
          
          if (bookID <> '')
          {
            bTitle = 'Bilinmeyen Kitap'; try bTitle = clQuery.FieldByName('title').AsString; except bTitle = 'Bilinmeyen Kitap'; }
            bAuthor = 'Bilinmeyen Yazar'; try bAuthor = clQuery.FieldByName('author').AsString; except bAuthor = 'Bilinmeyen Yazar'; }
            bColor = '#2E4053'; try bColor = clQuery.FieldByName('color').AsString; except bColor = '#2E4053'; }
            bSummary = 'Açıklama bulunmuyor.'; try bSummary = clQuery.FieldByName('summary').AsString; except bSummary = 'Açıklama bulunmuyor.'; }
            bCoverUrl = ''; try bCoverUrl = clQuery.FieldByName('cover').AsString; except bCoverUrl = ''; }
            bGenre = 'Roman'; try bGenre = clQuery.FieldByName('genre').AsString; except bGenre = 'Roman'; }

            if ((currentUser <> '') && (allBorrowedStr <> 'null') && (allBorrowedStr <> ''))
            {
               pStart = Pos('"' + bookID + '":', allBorrowedStr);
               if (pStart > 0)
               {
                  bookBorrowBlock = Copy(allBorrowedStr, pStart, 1500);
                  pEnd = Pos('}}', bookBorrowBlock);
                  if (pEnd > 0) bookBorrowBlock = Copy(bookBorrowBlock, 1, pEnd);
                  
                  if (Pos('"' + currentUser + '"', bookBorrowBlock) > 0)
                  {
                     retDateStr = ''; pStart = Pos('"returnDate":"', bookBorrowBlock);
                     if (pStart > 0)
                     {
                        pStart = pStart + 14;
                        pEnd = Pos('"', Copy(bookBorrowBlock, pStart, Length(bookBorrowBlock)));
                        if (pEnd > 0) retDateStr = Copy(bookBorrowBlock, pStart, pEnd - 1);
                     }
                     if (retDateStr <> '')
                     {
                        daysLeft = Trunc(StrToDate(retDateStr)) - Trunc(Now);
                        if (daysLeft < 0) { GlobalNotifCount = GlobalNotifCount + 1; GlobalNotifMsg = GlobalNotifMsg + '- "' + bTitle + '" iadesi ' + IntToStr(Abs(daysLeft)) + ' gün gecikti!' + #13#10; }
                        else if (daysLeft <= 2) { GlobalNotifCount = GlobalNotifCount + 1; GlobalNotifMsg = GlobalNotifMsg + '- "' + bTitle + '" iadesine ' + IntToStr(daysLeft) + ' gün kaldı!' + #13#10; }
                     }
                  }
               }
            }
            
            totalRating = 0; reviewCount = 0;
            if ((allReviewsStr <> 'null') && (allReviewsStr <> ''))
            {
               pStart = Pos('"' + bookID + '":', allReviewsStr);
               if (pStart > 0)
               {
                  bookRevBlock = Copy(allReviewsStr, pStart, 1500);
                  pEnd = Pos('}}', bookRevBlock);
                  if (pEnd > 0) bookRevBlock = Copy(bookRevBlock, 1, pEnd);
                  
                  pStart = Pos('"rating":', bookRevBlock);
                  while (pStart > 0)
                  {
                     pStart = pStart + 9; valStr = Copy(bookRevBlock, pStart, 1); if (valStr == ' ') valStr = Copy(bookRevBlock, pStart + 1, 1);
                     totalRating = totalRating + StrToIntDef(valStr, 0); reviewCount = reviewCount + 1;
                     bookRevBlock = Copy(bookRevBlock, pStart + 1, Length(bookRevBlock)); pStart = Pos('"rating":', bookRevBlock);
                  }
               }
            }
            if (reviewCount > 0) { avgRating = (totalRating * 1.0) / reviewCount; ratingStr = FloatToStr(avgRating); if (Length(ratingStr) > 3) ratingStr = Copy(ratingStr, 1, 3); }
            else ratingStr = '0';
          
            GlobalBooksList.Add('{"id":"'+bookID+'","title":"'+bTitle+'","author":"'+bAuthor+'", "rating":"'+ratingStr+'", "color":"'+bColor+'", "summary":"'+bSummary+'", "cover":"'+bCoverUrl+'", "genre":"'+bGenre+'"}');
          }
          clQuery.Next;
        }
        clQuery.Free; 
      }
    }
  }
  clRest.Free;
  
  if (GlobalNotifCount > 0) { NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D81B60'); NotifBtn.SetclProSettings(NotifBtn.clProSettings); }
  else { NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); NotifBtn.SetclProSettings(NotifBtn.clProSettings); }
  
  DrawBooks;
}

void SearchOpenLibrary;
var
  clRestAPI: TclRest;
  queryStr, jsonResult, docStr, guidStr, valStr, subStr: String;
  pStart, pEnd, docEnd, pSub, i: Integer;
  bKey, bTitle, bAuthor, bCover, bCoverUrl, bGenre: String;
{
  queryStr = SearchEdt.Text;
  if (queryStr == '')
  {
    if (GlobalBooksList <> nil) GlobalBooksList.Free;
    GlobalBooksList = Clomosy.StringListNew;
    FetchBooksFromFirebase;
    Exit;
  }
  
  for i = 1 to Length(queryStr) { if (Copy(queryStr, i, 1) == ' ') queryStr = Copy(queryStr, 1, i-1) + '+' + Copy(queryStr, i+1, Length(queryStr)); }

  if (GlobalBooksList <> nil) GlobalBooksList.Free;
  GlobalBooksList = Clomosy.StringListNew;
  CountLbl.Text = 'API Aranıyor...';
  
  GlobalFilterGenre = 'Tümü'; 
  FilterAllBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054'); FilterAllBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  FilterRomanBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterRomanBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterBilimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterBilimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterTarihBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterTarihBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterFelsefeBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterFelsefeBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterCocukBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterCocukBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterGelisimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterGelisimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterAllBtn.SetclProSettings(FilterAllBtn.clProSettings); FilterRomanBtn.SetclProSettings(FilterRomanBtn.clProSettings); FilterBilimBtn.SetclProSettings(FilterBilimBtn.clProSettings); FilterTarihBtn.SetclProSettings(FilterTarihBtn.clProSettings); FilterFelsefeBtn.SetclProSettings(FilterFelsefeBtn.clProSettings); FilterCocukBtn.SetclProSettings(FilterCocukBtn.clProSettings); FilterGelisimBtn.SetclProSettings(FilterGelisimBtn.clProSettings);

  // API Yükünü hafifletmek için &fields parametresi eklendi
  clRestAPI = TclRest.Create; 
  clRestAPI.BaseURL = 'https://openlibrary.org/search.json?q=' + queryStr + '&limit=15&fields=key,title,author_name,cover_i,subject'; 
  clRestAPI.Method = rmGET; clRestAPI.Accept = 'application/json'; clRestAPI.Execute;
  jsonResult = clRestAPI.Response; clRestAPI.Free;
  
  if ((jsonResult <> '') && (Pos('"docs":', jsonResult) > 0))
  {
     pStart = Pos('"docs":[', jsonResult);
     if (pStart > 0) jsonResult = Copy(jsonResult, pStart + 8, Length(jsonResult));
     
     pStart = Pos('{', jsonResult);
     while (pStart > 0)
     {
        docEnd = Pos('},{', jsonResult);
        if (docEnd == 0) docEnd = Pos('}]', jsonResult);
        if (docEnd == 0) Break;
        
        docStr = Copy(jsonResult, pStart, docEnd - pStart + 1);
        
        bKey = ''; pSub = Pos('"key":"', docStr);
        if (pSub > 0) { pSub = pSub + 7; pEnd = Pos('"', Copy(docStr, pSub, Length(docStr))); bKey = Copy(docStr, pSub, pEnd - 1); if (Length(bKey) > 7) bKey = Copy(bKey, 8, Length(bKey)); }
        
        bTitle = 'Bilinmeyen Kitap'; pSub = Pos('"title":"', docStr);
        if (pSub > 0) { pSub = pSub + 9; pEnd = Pos('"', Copy(docStr, pSub, Length(docStr))); bTitle = Copy(docStr, pSub, pEnd - 1); }
        
        bAuthor = 'Bilinmeyen Yazar'; pSub = Pos('"author_name":["', docStr);
        if (pSub > 0) { pSub = pSub + 16; pEnd = Pos('"', Copy(docStr, pSub, Length(docStr))); bAuthor = Copy(docStr, pSub, pEnd - 1); }
        
        bCoverUrl = ''; pSub = Pos('"cover_i":', docStr);
        if (pSub > 0) {
           pSub = pSub + 10; pEnd = 0; bCover = '';
           while (pSub + pEnd <= Length(docStr))
           {
             valStr = Copy(docStr, pSub + pEnd, 1);
             if ((valStr >= '0') && (valStr <= '9')) { bCover = bCover + valStr; pEnd = pEnd + 1; } else Break;
           }
           if (bCover <> '') bCoverUrl = 'https://covers.openlibrary.org/b/id/' + bCover + '-M.jpg';
        }
        
        // --- TÜRLERİN (GENRE) KUSURSUZ AYRIŞTIRILMASI ---
        bGenre = 'Roman'; 
        pSub = Pos('"subject":[', docStr);
        if (pSub > 0) {
           pSub = pSub + 11; pEnd = Pos(']', Copy(docStr, pSub, Length(docStr))); subStr = AnsiLowerCase(Copy(docStr, pSub, pEnd - 1));
           
           bGenre = '';
           if (Pos('science fiction', subStr) > 0) bGenre = bGenre + 'Bilim Kurgu, ';
           if (Pos('history', subStr) > 0) bGenre = bGenre + 'Tarih, ';
           if (Pos('philosophy', subStr) > 0) bGenre = bGenre + 'Felsefe, ';
           if ((Pos('children', subStr) > 0) || (Pos('juvenile', subStr) > 0)) bGenre = bGenre + 'Çocuk, ';
           if ((Pos('self-help', subStr) > 0) || (Pos('personal growth', subStr) > 0)) bGenre = bGenre + 'Kişisel Gelişim, ';
           if ((Pos('fiction', subStr) > 0) || (Pos('novel', subStr) > 0) || (Pos('magic', subStr) > 0) || (Pos('fantasy', subStr) > 0)) bGenre = bGenre + 'Roman, ';
           
           if (bGenre == '') bGenre = 'Roman'; else bGenre = Copy(bGenre, 1, Length(bGenre) - 2); 
        }
        
        if (bKey <> '') GlobalBooksList.Add('{"id":"'+bKey+'","title":"'+bTitle+'","author":"'+bAuthor+'", "rating":"0", "color":"#2E4053", "summary":"OpenLibrary API Kaydı", "cover":"'+bCoverUrl+'", "genre":"'+bGenre+'"}');
        
        jsonResult = Copy(jsonResult, docEnd + 2, Length(jsonResult));
        pStart = Pos('{', jsonResult);
     }
  }
  else
  {
     ShowMessage('Arama sonucu bulunamadı. Arşiv veritabanınıza geri dönülüyor.');
     SearchEdt.Text = '';
     if (GlobalBooksList <> nil) GlobalBooksList.Free;
     GlobalBooksList = Clomosy.StringListNew;
     FetchBooksFromFirebase;
     Exit;
  }
  
  DrawBooks;
}

void DoSearchBooks;
{
  Form1.FormWaiting.Visible = True;
  GlobalActionType = 'SEARCH';
  GlobalActionTimer.Enabled = True;
}

void OnGlobalActionTimer;
var
  clRest: TclRest;
  bookID, currentUser, jsonBody, returnDate: String;
{
  GlobalActionTimer.Enabled = False;
  bookID = DetailContentPnl.clTagStr; 
  currentUser = Clomosy.GlobalVariableString;
  
  if (GlobalActionType == 'BORROW')
  {
      returnDate = FormatDateTime('dd.mm.yyyy', Now + 14);
      clRest = TclRest.Create;
      clRest.Accept = 'application/json';
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/borrowed/'+bookID+'.json';
      clRest.Method = rmPUT;
      jsonBody = '{"user":"'+currentUser+'", "returnDate":"'+returnDate+'", "id":"'+bookID+'"}';
      clRest.AddBody(jsonBody, 'application/json');
      clRest.Execute;
      clRest.Free;
      
      clRest = TclRest.Create;
      clRest.Accept = 'application/json';
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/borrow_history/'+bookID+'.json';
      clRest.Method = rmPOST; 
      jsonBody = '{"user":"'+currentUser+'", "date":"'+FormatDateTime('dd.mm.yyyy', Now)+'"}';
      clRest.AddBody(jsonBody, 'application/json');
      clRest.Execute;
      clRest.Free;
      
      if (GlobalCurrentStock > 0)
      {
         GlobalCurrentStock = GlobalCurrentStock - 1;
         clRest = TclRest.Create;
         clRest.Accept = 'application/json';
         clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books/'+bookID+'/stock.json';
         clRest.Method = rmPUT;
         clRest.AddBody('"' + IntToStr(GlobalCurrentStock) + '"', 'application/json');
         clRest.Execute;
         clRest.Free;
      }
      
      DetailBorrowBtn.Text = 'Zaten Ödünç Aldınız';
      DetailBorrowBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#4CAF50');
      DetailBorrowBtn.Enabled = False;
      DetailBorrowBtn.SetclProSettings(DetailBorrowBtn.clProSettings);
      
      SendNotification(currentUser, '"' + DetailTitleLbl.Text + '" adlı kitabı ödünç aldınız.');
      ShowMessage(DetailTitleLbl.Text + ' adlı kitabı ödünç aldınız!');
  }
  else if (GlobalActionType == 'ADD_FAV')
  {
      clRest = TclRest.Create;
      clRest.Accept = 'application/json';
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/favorites/'+currentUser+'/'+bookID+'.json';
      clRest.Method = rmPUT;
      jsonBody = '{"added":"true", "addedDate":"' + FormatDateTime('dd.mm.yyyy', Now) + '"}';
      clRest.AddBody(jsonBody, 'application/json');
      clRest.Execute;
      clRest.Free;
      
      clRest = TclRest.Create;
      clRest.Accept = 'application/json';
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/book_favorites/'+bookID+'/'+currentUser+'.json';
      clRest.Method = rmPUT;
      clRest.AddBody('{"user":"'+currentUser+'"}', 'application/json');
      clRest.Execute;
      clRest.Free;
      
      DetailFavBtn.Text = 'Listemde (Çıkar)';
      DetailFavBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
      DetailFavBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#D81B60');
      DetailFavBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D81B60');
      DetailFavBtn.clProSettings.BorderWidth = 1;
      DetailFavBtn.SetclProSettings(DetailFavBtn.clProSettings);
      
      SendNotification(currentUser, '"' + DetailTitleLbl.Text + '" kitabını okuma listenize eklediniz.');
      ShowMessage('Kitap favorilerinize eklendi!');
  }
  else if (GlobalActionType == 'DEL_FAV')
  {
      clRest = TclRest.Create;
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/favorites/'+currentUser+'/'+bookID+'.json';
      clRest.Method = rmDELETE;
      clRest.Execute;
      clRest.Free;
      
      clRest = TclRest.Create;
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/book_favorites/'+bookID+'/'+currentUser+'.json';
      clRest.Method = rmDELETE;
      clRest.Execute;
      clRest.Free;
      
      DetailFavBtn.Text = 'Listeme Ekle';
      DetailFavBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
      DetailFavBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
      DetailFavBtn.clProSettings.BorderWidth = 0;
      DetailFavBtn.SetclProSettings(DetailFavBtn.clProSettings);
      ShowMessage('Kitap favorilerinizden çıkarıldı.');
  }
  else if (GlobalActionType == 'SEARCH')
  {
      SearchOpenLibrary;
  }
  
  Form1.FormWaiting.Visible = False;
}

void CloseCustomAlert;
{
  if (AlertBoxPnl <> nil) { AlertBoxPnl.Free; AlertBoxPnl = nil; }
  if (AlertOverlayPnl <> nil) { AlertOverlayPnl.Free; AlertOverlayPnl = nil; }
}

void ShowCustomAlert(AMessage: String);
{
  AlertOverlayPnl = Form1.AddNewProPanel(Form1, 'AlertOverlayPnl'); 
  AlertOverlayPnl.Align = alClient; AlertOverlayPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#000000'); AlertOverlayPnl.Opacity = 0.6;
  AlertOverlayPnl.SetclProSettings(AlertOverlayPnl.clProSettings); AlertOverlayPnl.BringToFront; 

  AlertBoxPnl = Form1.AddNewProPanel(Form1, 'AlertBoxPnl');
  AlertBoxPnl.Align = alCenter; AlertBoxPnl.Width = 280; AlertBoxPnl.Height = 220; AlertBoxPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); 
  AlertBoxPnl.clProSettings.RoundHeight = 15; AlertBoxPnl.clProSettings.RoundWidth = 15; AlertBoxPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#36212E'); AlertBoxPnl.clProSettings.BorderWidth = 2;
  AlertBoxPnl.SetclProSettings(AlertBoxPnl.clProSettings); AlertBoxPnl.BringToFront; 

  AlertMsgLbl = Form1.AddNewProLabel(AlertBoxPnl, 'AlertMsgLbl', AMessage);
  AlertMsgLbl.Align = alTop; AlertMsgLbl.Height = 120; AlertMsgLbl.Margins.Top = 20; AlertMsgLbl.Margins.Left = 15; AlertMsgLbl.Margins.Right = 15;
  AlertMsgLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#002B36'); AlertMsgLbl.clProSettings.FontSize = 14; AlertMsgLbl.clProSettings.TextSettings.Font.Style = [fsBold]; AlertMsgLbl.clProSettings.WordWrap = True; 
  AlertMsgLbl.SetclProSettings(AlertMsgLbl.clProSettings);

  AlertOkBtn = Form1.AddNewProButton(AlertBoxPnl, 'AlertOkBtn', 'Tamam');
  AlertOkBtn.Align = alBottom; AlertOkBtn.Height = 40; AlertOkBtn.Margins.Bottom = 15; AlertOkBtn.Margins.Left = 60; AlertOkBtn.Margins.Right = 60;
  AlertOkBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054'); AlertOkBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); AlertOkBtn.clProSettings.RoundHeight = 8; AlertOkBtn.clProSettings.RoundWidth = 8;
  AlertOkBtn.SetclProSettings(AlertOkBtn.clProSettings);
  Form1.AddNewEvent(AlertOkBtn, tbeOnClick, 'CloseCustomAlert');
}

void ShowNotifications;
var clRest: TclRest;
{
  if (GlobalNotifCount == 0) ShowCustomAlert('Şu an için yeni bir bildiriminiz bulunmuyor.');
  else
  {
    ShowCustomAlert('BİLDİRİMLERİNİZ:'#13#10 + GlobalNotifMsg);
    if (Clomosy.GlobalVariableString <> '')
    {
      clRest = TclRest.Create; clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/notifications/' + Clomosy.GlobalVariableString + '.json'; clRest.Method = rmDELETE; clRest.Execute; clRest.Free;
    }
    NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); 
    NotifBtn.SetclProSettings(NotifBtn.clProSettings);
    GlobalNotifCount = 0;
  }
}

void LoadUserProfileInitials;
var
  clRest: TclRest;
  resp, adStr, soyadStr, initials: String;
  pStart, pEnd: Integer;
{
  initials = 'U';
  
  if (Clomosy.GlobalVariableString <> '')
  {
     clRest = TclRest.Create;
     clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/' + Clomosy.GlobalVariableString + '.json';
     clRest.Method = rmGET;
     clRest.Execute;
     resp = clRest.Response;
     clRest.Free;
     
     if ((resp <> 'null') && (resp <> '') && (resp <> '{}'))
     {
        adStr = ''; soyadStr = '';
        
        pStart = Pos('"ad":"', resp);
        if (pStart > 0)
        {
           pStart = pStart + 6;
           pEnd = Pos('"', Copy(resp, pStart, Length(resp)));
           adStr = Copy(resp, pStart, pEnd - 1);
        }
        
        pStart = Pos('"soyad":"', resp);
        if (pStart > 0)
        {
           pStart = pStart + 9;
           pEnd = Pos('"', Copy(resp, pStart, Length(resp)));
           soyadStr = Copy(resp, pStart, pEnd - 1);
        }
        
        initials = '';
        if (adStr <> '') initials = initials + Copy(adStr, 1, 1);
        if (soyadStr <> '') initials = initials + Copy(soyadStr, 1, 1);
        
        if (initials == '') initials = Copy(Clomosy.GlobalVariableString, 1, 2);
     }
  }
  
  if (ProfileBtn <> nil)
  {
     ProfileBtn.Text = AnsiUpperCase(initials);
     ProfileBtn.clProSettings.TextSettings.Font.Style = [fsBold];
     ProfileBtn.clProSettings.FontSize = 15;
     ProfileBtn.SetclProSettings(ProfileBtn.clProSettings);
  }
}

void CreateHeader;
{
  HeaderPnl = Form1.AddNewProPanel(ScaledLayout, 'HeaderPnl');
  HeaderPnl.Align = alTop; HeaderPnl.Height = 70; HeaderPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  HeaderPnl.SetclProSettings(HeaderPnl.clProSettings);
  
  LogoLeftPnl = Form1.AddNewProPanel(HeaderPnl, 'LogoLeftPnl');
  LogoLeftPnl.Align = alLeft; LogoLeftPnl.Width = 200; LogoLeftPnl.Margins.Left = 20; LogoLeftPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  LogoLeftPnl.SetclProSettings(LogoLeftPnl.clProSettings);

  TitleLbl = Form1.AddNewProLabel(LogoLeftPnl, 'TitleLbl', 'Arşiv');
  TitleLbl.Align = alTop; TitleLbl.Height = 30; TitleLbl.Margins.Top = 15; TitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#002B36'); TitleLbl.clProSettings.FontSize = 20; TitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  TitleLbl.SetclProSettings(TitleLbl.clProSettings);
  
  SubTitleLbl = Form1.AddNewProLabel(LogoLeftPnl, 'SubTitleLbl', 'KÜTÜPHANESİ');
  SubTitleLbl.Align = alTop; SubTitleLbl.Height = 20; SubTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); SubTitleLbl.clProSettings.FontSize = 10;
  SubTitleLbl.SetclProSettings(SubTitleLbl.clProSettings);

  ActionRightPnl = Form1.AddNewProPanel(HeaderPnl, 'ActionRightPnl');
  ActionRightPnl.Align = alRight; ActionRightPnl.Width = 100; ActionRightPnl.Margins.Right = 20; ActionRightPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  ActionRightPnl.SetclProSettings(ActionRightPnl.clProSettings);

  ProfileBtn = Form1.AddNewProButton(ActionRightPnl, 'ProfileBtn', '');
  ProfileBtn.Align = alRight; ProfileBtn.Width = 40; ProfileBtn.Margins.Top = 15; ProfileBtn.Margins.Bottom = 15; ProfileBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E'); ProfileBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); ProfileBtn.clProSettings.RoundHeight = 5; ProfileBtn.clProSettings.RoundWidth = 5;
  ProfileBtn.SetclProSettings(ProfileBtn.clProSettings);

  NotifBtn = Form1.AddNewProImage(ActionRightPnl, 'NotifBtn'); 
  NotifBtn.Align = alRight; NotifBtn.Width = 40; NotifBtn.Margins.Right = 10; NotifBtn.Margins.Top = 15; NotifBtn.Margins.Bottom = 15; NotifBtn.clProSettings.PictureSource = 'https://w7.pngwing.com/pngs/984/292/png-transparent-alarm-bell-essentials-notification-ui-ui-essentials-icon-thumbnail.png'; NotifBtn.clProSettings.PictureAutoFit = True; NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); NotifBtn.clProSettings.RoundHeight = 8; NotifBtn.clProSettings.RoundWidth = 8;
  NotifBtn.SetclProSettings(NotifBtn.clProSettings);
  Form1.AddNewEvent(NotifBtn, tbeOnClick, 'ShowNotifications');
}

void CreateFiltersUI;
{
  FiltersPnl = Form1.AddNewProPanel(ScaledLayout, 'FiltersPnl');
  FiltersPnl.Align = alTop; FiltersPnl.Height = 55; FiltersPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  FiltersPnl.SetclProSettings(FiltersPnl.clProSettings);

  FiltersScrollBox = Form1.AddNewHorzScrollBox(FiltersPnl, 'FiltersScrollBox');
  FiltersScrollBox.Align = alClient; FiltersScrollBox.Margins.Left = 10; FiltersScrollBox.Margins.Right = 10; FiltersScrollBox.Margins.Bottom = 5;

  FilterAllBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterAllBtn', 'Tümü');
  FilterAllBtn.Align = alLeft; FilterAllBtn.Width = 60; FilterAllBtn.Margins.Right = 5; FilterAllBtn.Margins.Top = 5; FilterAllBtn.Margins.Bottom = 5; FilterAllBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054'); FilterAllBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); FilterAllBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterAllBtn.clProSettings.BorderWidth = 1; FilterAllBtn.clProSettings.RoundHeight = 15; FilterAllBtn.clProSettings.RoundWidth = 15; FilterAllBtn.SetclProSettings(FilterAllBtn.clProSettings); Form1.AddNewEvent(FilterAllBtn, tbeOnClick, 'FilterClick');

  FilterRomanBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterRomanBtn', 'Roman');
  FilterRomanBtn.Align = alLeft; FilterRomanBtn.Width = 70; FilterRomanBtn.Margins.Right = 5; FilterRomanBtn.Margins.Top = 5; FilterRomanBtn.Margins.Bottom = 5; FilterRomanBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterRomanBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterRomanBtn.clProSettings.BorderWidth = 1; FilterRomanBtn.clProSettings.RoundHeight = 15; FilterRomanBtn.clProSettings.RoundWidth = 15; FilterRomanBtn.SetclProSettings(FilterRomanBtn.clProSettings); Form1.AddNewEvent(FilterRomanBtn, tbeOnClick, 'FilterClick');

  FilterBilimBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterBilimBtn', 'Bilim Kurgu');
  FilterBilimBtn.Align = alLeft; FilterBilimBtn.Width = 90; FilterBilimBtn.Margins.Right = 5; FilterBilimBtn.Margins.Top = 5; FilterBilimBtn.Margins.Bottom = 5; FilterBilimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterBilimBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterBilimBtn.clProSettings.BorderWidth = 1; FilterBilimBtn.clProSettings.RoundHeight = 15; FilterBilimBtn.clProSettings.RoundWidth = 15; FilterBilimBtn.SetclProSettings(FilterBilimBtn.clProSettings); Form1.AddNewEvent(FilterBilimBtn, tbeOnClick, 'FilterClick');

  FilterTarihBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterTarihBtn', 'Tarih');
  FilterTarihBtn.Align = alLeft; FilterTarihBtn.Width = 70; FilterTarihBtn.Margins.Right = 5; FilterTarihBtn.Margins.Top = 5; FilterTarihBtn.Margins.Bottom = 5; FilterTarihBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterTarihBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterTarihBtn.clProSettings.BorderWidth = 1; FilterTarihBtn.clProSettings.RoundHeight = 15; FilterTarihBtn.clProSettings.RoundWidth = 15; FilterTarihBtn.SetclProSettings(FilterTarihBtn.clProSettings); Form1.AddNewEvent(FilterTarihBtn, tbeOnClick, 'FilterClick');

  FilterFelsefeBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterFelsefeBtn', 'Felsefe');
  FilterFelsefeBtn.Align = alLeft; FilterFelsefeBtn.Width = 70; FilterFelsefeBtn.Margins.Right = 5; FilterFelsefeBtn.Margins.Top = 5; FilterFelsefeBtn.Margins.Bottom = 5; FilterFelsefeBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterFelsefeBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterFelsefeBtn.clProSettings.BorderWidth = 1; FilterFelsefeBtn.clProSettings.RoundHeight = 15; FilterFelsefeBtn.clProSettings.RoundWidth = 15; FilterFelsefeBtn.SetclProSettings(FilterFelsefeBtn.clProSettings); Form1.AddNewEvent(FilterFelsefeBtn, tbeOnClick, 'FilterClick');

  FilterCocukBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterCocukBtn', 'Çocuk');
  FilterCocukBtn.Align = alLeft; FilterCocukBtn.Width = 70; FilterCocukBtn.Margins.Right = 5; FilterCocukBtn.Margins.Top = 5; FilterCocukBtn.Margins.Bottom = 5; FilterCocukBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterCocukBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterCocukBtn.clProSettings.BorderWidth = 1; FilterCocukBtn.clProSettings.RoundHeight = 15; FilterCocukBtn.clProSettings.RoundWidth = 15; FilterCocukBtn.SetclProSettings(FilterCocukBtn.clProSettings); Form1.AddNewEvent(FilterCocukBtn, tbeOnClick, 'FilterClick');

  FilterGelisimBtn = Form1.AddNewProButton(FiltersScrollBox, 'FilterGelisimBtn', 'Kişisel Gelişim');
  FilterGelisimBtn.Align = alLeft; FilterGelisimBtn.Width = 100; FilterGelisimBtn.Margins.Right = 5; FilterGelisimBtn.Margins.Top = 5; FilterGelisimBtn.Margins.Bottom = 5; FilterGelisimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterGelisimBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#D29054'); FilterGelisimBtn.clProSettings.BorderWidth = 1; FilterGelisimBtn.clProSettings.RoundHeight = 15; FilterGelisimBtn.clProSettings.RoundWidth = 15; FilterGelisimBtn.SetclProSettings(FilterGelisimBtn.clProSettings); Form1.AddNewEvent(FilterGelisimBtn, tbeOnClick, 'FilterClick');
}

void CreateDetailUI;
{
  DetailOverlayPnl = Form1.AddNewProPanel(Form1, 'DetailOverlayPnl');
  DetailOverlayPnl.Align = alClient; DetailOverlayPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#000000'); DetailOverlayPnl.Opacity = 0.6; DetailOverlayPnl.Visible = False; Form1.AddNewEvent(DetailOverlayPnl, tbeOnClick, 'CloseDetail');

  DetailContentPnl = Form1.AddNewProPanel(Form1, 'DetailContentPnl');
  DetailContentPnl.Align = alCenter; DetailContentPnl.Width = 320; DetailContentPnl.Height = 550; DetailContentPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); DetailContentPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#36212E'); DetailContentPnl.clProSettings.BorderWidth = 2; DetailContentPnl.clProSettings.RoundHeight = 10; DetailContentPnl.clProSettings.RoundWidth = 10; DetailContentPnl.SetclProSettings(DetailContentPnl.clProSettings); DetailContentPnl.Visible = False;

  DetailHeaderPnl = Form1.AddNewProPanel(DetailContentPnl, 'DetailHeaderPnl');
  DetailHeaderPnl.Align = alTop; DetailHeaderPnl.Height = 180; DetailHeaderPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#2C3E50'); DetailHeaderPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#36212E'); DetailHeaderPnl.clProSettings.BorderWidth = 2; DetailHeaderPnl.clProSettings.RoundHeight = 10; DetailHeaderPnl.clProSettings.RoundWidth = 10; DetailHeaderPnl.SetclProSettings(DetailHeaderPnl.clProSettings);

  DetailTitleLbl = Form1.AddNewProLabel(DetailContentPnl, 'DetailTitleLbl', '-');
  DetailTitleLbl.Align = alTop; DetailTitleLbl.Height = 35; DetailTitleLbl.Margins.Top = 15; DetailTitleLbl.Margins.Left = 15; DetailTitleLbl.Margins.Right = 15; DetailTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000'); DetailTitleLbl.clProSettings.FontSize = 20; DetailTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold]; DetailTitleLbl.SetclProSettings(DetailTitleLbl.clProSettings);

  DetailAuthorLbl = Form1.AddNewProLabel(DetailContentPnl, 'DetailAuthorLbl', '-');
  DetailAuthorLbl.Align = alTop; DetailAuthorLbl.Height = 25; DetailAuthorLbl.Margins.Left = 15; DetailAuthorLbl.Margins.Right = 15; DetailAuthorLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#666666'); DetailAuthorLbl.clProSettings.FontSize = 14; DetailAuthorLbl.SetclProSettings(DetailAuthorLbl.clProSettings);

  DetailScrollBox = Form1.AddNewVertScrollBox(DetailContentPnl, 'DetailScrollBox');
  DetailScrollBox.Align = alClient; DetailScrollBox.Margins.Top = 15; DetailScrollBox.Margins.Left = 15; DetailScrollBox.Margins.Right = 15; DetailScrollBox.Margins.Bottom = 15;

  DetailDescLbl = Form1.AddNewProLabel(DetailScrollBox, 'DetailDescLbl', '');
  DetailDescLbl.Align = alTop; DetailDescLbl.Margins.Bottom = 20; DetailDescLbl.Width = 340; DetailDescLbl.Height = 100; DetailDescLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#444444'); DetailDescLbl.clProSettings.WordWrap = True; DetailDescLbl.clProSettings.AutoSize = True; DetailDescLbl.SetclProSettings(DetailDescLbl.clProSettings);

  DetailFooterPnl = Form1.AddNewProPanel(DetailContentPnl, 'DetailFooterPnl');
  DetailFooterPnl.Align = alBottom; DetailFooterPnl.Height = 160; 
  
  DetailBorrowBtn = Form1.AddNewProButton(DetailFooterPnl, 'DetailBorrowBtn', 'Ödünç Al');
  DetailBorrowBtn.Align = alTop; DetailBorrowBtn.Height = 40; DetailBorrowBtn.Margins.Left = 20; DetailBorrowBtn.Margins.Right = 20; DetailBorrowBtn.Margins.Top = 10; DetailBorrowBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E'); DetailBorrowBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); DetailBorrowBtn.clProSettings.RoundHeight = 5; DetailBorrowBtn.clProSettings.RoundWidth = 5; DetailBorrowBtn.SetclProSettings(DetailBorrowBtn.clProSettings); Form1.AddNewEvent(DetailBorrowBtn, tbeOnClick, 'BorrowBookClick');
  
  DetailFavBtn = Form1.AddNewProButton(DetailFooterPnl, 'DetailFavBtn', 'Listeme Ekle');
  DetailFavBtn.Align = alTop; DetailFavBtn.Height = 40; DetailFavBtn.Margins.Left = 20; DetailFavBtn.Margins.Right = 20; DetailFavBtn.Margins.Top = 10; DetailFavBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E'); DetailFavBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); DetailFavBtn.clProSettings.RoundHeight = 5; DetailFavBtn.clProSettings.RoundWidth = 5; DetailFavBtn.SetclProSettings(DetailFavBtn.clProSettings); Form1.AddNewEvent(DetailFavBtn, tbeOnClick, 'FavBookClick');
  
  DetailCloseBtn = Form1.AddNewProButton(DetailFooterPnl, 'DetailCloseBtn', 'Kapat');
  DetailCloseBtn.Align = alTop; DetailCloseBtn.Height = 40; DetailCloseBtn.Margins.Left = 20; DetailCloseBtn.Margins.Right = 20; DetailCloseBtn.Margins.Top = 10; DetailCloseBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F9F7F4'); DetailCloseBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#002B36'); DetailCloseBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD'); DetailCloseBtn.clProSettings.BorderWidth = 1; DetailCloseBtn.clProSettings.RoundHeight = 5; DetailCloseBtn.clProSettings.RoundWidth = 5; DetailCloseBtn.SetclProSettings(DetailCloseBtn.clProSettings); Form1.AddNewEvent(DetailCloseBtn, tbeOnClick, 'CloseDetail');
}

void SetupUI;
{
  CreateHeader;
  LoadUserProfileInitials;
  CreateDetailUI;

  PageTitlePnl = Form1.AddNewProPanel(ScaledLayout, 'PageTitlePnl');
  PageTitlePnl.Align = alTop; PageTitlePnl.Height = 50; PageTitlePnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); PageTitlePnl.SetclProSettings(PageTitlePnl.clProSettings);

  PageTitleLbl = Form1.AddNewProLabel(PageTitlePnl, 'PageTitleLbl', 'Katalog');
  PageTitleLbl.Align = alLeft; PageTitleLbl.Margins.Left = 20; PageTitleLbl.Width = 200; PageTitleLbl.clProSettings.FontSize = 22; PageTitleLbl.SetclProSettings(PageTitleLbl.clProSettings);

  ViewToggleBtn = Form1.AddNewProButton(PageTitlePnl, 'ViewToggleBtn', '');
  ViewToggleBtn.Align = alRight; ViewToggleBtn.Width = 60; ViewToggleBtn.Margins.Right = 20; ViewToggleBtn.Margins.Top = 10; ViewToggleBtn.Margins.Bottom = 10; ViewToggleBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF'); ViewToggleBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#F0EBE1') ViewToggleBtn.clProSettings.RoundHeight = 5; ViewToggleBtn.clProSettings.RoundWidth = 5; ViewToggleBtn.clProSettings.FontSize = 10; ViewToggleBtn.SetclProSettings(ViewToggleBtn.clProSettings); Form1.AddNewEvent(ViewToggleBtn, tbeOnClick, 'ToggleViewMode');
  ViewToggleBtn.enabled = false;
  
  SearchWrapPnl = Form1.AddNewProPanel(ScaledLayout, 'SearchWrapPnl');
  SearchWrapPnl.Align = alTop; SearchWrapPnl.Height = 55; SearchWrapPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); SearchWrapPnl.SetclProSettings(SearchWrapPnl.clProSettings);

  SearchPnl = Form1.AddNewProPanel(SearchWrapPnl, 'SearchPnl');
  SearchPnl.Align = alClient; SearchPnl.Margins.Left = 15; SearchPnl.Margins.Right = 15; SearchPnl.Margins.Bottom = 10; SearchPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF'); SearchPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#E2DED5'); SearchPnl.clProSettings.BorderWidth = 1; SearchPnl.clProSettings.RoundHeight = 5; SearchPnl.clProSettings.RoundWidth = 5; SearchPnl.SetclProSettings(SearchPnl.clProSettings);

  SearchEdt = Form1.AddNewProEdit(SearchPnl, 'SearchEdt','API veya Arşivde Ara...');
  SearchEdt.Align = alClient; SearchEdt.Margins.Left = 10; SearchEdt.Margins.Right = 10; SearchEdt.Margins.Top = 5; SearchEdt.Margins.Bottom = 5; SearchEdt.SetclProSettings(SearchEdt.clProSettings);

  SearchBtn = Form1.AddNewProButton(SearchPnl, 'SearchBtn', 'Ara');
  SearchBtn.Align = alRight; SearchBtn.Width = 60; SearchBtn.Margins.Right = 5; SearchBtn.Margins.Top = 5; SearchBtn.Margins.Bottom = 5; SearchBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054'); SearchBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF'); SearchBtn.clProSettings.RoundHeight = 5; SearchBtn.clProSettings.RoundWidth = 5; SearchBtn.SetclProSettings(SearchBtn.clProSettings); Form1.AddNewEvent(SearchBtn, tbeOnClick, 'DoSearchBooks');

  CreateFiltersUI;

  CountPnl = Form1.AddNewProPanel(ScaledLayout, 'CountPnl');
  CountPnl.Align = alTop; CountPnl.Height = 30; CountPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); CountPnl.SetclProSettings(CountPnl.clProSettings);
  
  CountLbl = Form1.AddNewProLabel(CountPnl, 'CountLbl', 'Yükleniyor...');
  CountLbl.Align = alLeft; CountLbl.Margins.Left = 20; CountLbl.Width = 100; CountLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); CountLbl.SetclProSettings(CountLbl.clProSettings);

  DividerPnl = Form1.AddNewProPanel(ScaledLayout, 'DividerPnl');
  DividerPnl.Align = alTop; DividerPnl.Height = 2; DividerPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#E2DED5'); DividerPnl.SetclProSettings(DividerPnl.clProSettings);

  BottomMenuPnl = Form1.AddNewProPanel(ScaledLayout, 'BottomMenuPnl');
  BottomMenuPnl.Align = alBottom; BottomMenuPnl.Height = 60; BottomMenuPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); BottomMenuPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#E2DED5'); BottomMenuPnl.clProSettings.BorderWidth = 1; BottomMenuPnl.SetclProSettings(BottomMenuPnl.clProSettings);

  CatalogBtn = Form1.AddNewProButton(BottomMenuPnl, 'CatalogBtn', 'Katalog');
  CatalogBtn.Align = alLeft; CatalogBtn.Width = 70; CatalogBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#D29054'); CatalogBtn.clProSettings.FontSize = 11; CatalogBtn.SetclProSettings(CatalogBtn.clProSettings);
  
  BorrowedBtn = Form1.AddNewProButton(BottomMenuPnl, 'BorrowedBtn', 'Ödünç');
  BorrowedBtn.Align = alLeft; BorrowedBtn.Width = 70; BorrowedBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); BorrowedBtn.clProSettings.FontSize = 11; BorrowedBtn.SetclProSettings(BorrowedBtn.clProSettings); Form1.AddNewEvent(BorrowedBtn, tbeOnClick, 'GoToBorrowed');

  QrBtn = Form1.AddNewProButton(BottomMenuPnl, 'QrBtn', 'QR Tara');
  QrBtn.Align = alLeft; QrBtn.Width = 70; QrBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); QrBtn.clProSettings.FontSize = 11; QrBtn.SetclProSettings(QrBtn.clProSettings); Form1.AddNewEvent(QrBtn, tbeOnClick, 'GoToQR');

  MyListBtn = Form1.AddNewProButton(BottomMenuPnl, 'MyListBtn', 'Listem');
  MyListBtn.Align = alLeft; MyListBtn.Width = 70; MyListBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); MyListBtn.clProSettings.FontSize = 11; MyListBtn.SetclProSettings(MyListBtn.clProSettings); Form1.AddNewEvent(MyListBtn, tbeOnClick, 'GoToListe');

  SettingsBtn = Form1.AddNewProButton(BottomMenuPnl, 'SettingsBtn', 'Ayarlar');
  SettingsBtn.Align = alLeft; SettingsBtn.Width = 70; SettingsBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888'); SettingsBtn.clProSettings.FontSize = 11; SettingsBtn.SetclProSettings(SettingsBtn.clProSettings); Form1.AddNewEvent(SettingsBtn, tbeOnClick, 'GoToSettings');

  GlobalActionTimer = Form1.AddNewTimer(Form1, 'GlobalActionTimer', 100);
  Form1.AddNewEvent(GlobalActionTimer, tbeOnTimer, 'OnGlobalActionTimer');
  GlobalActionTimer.Enabled = False;
  
  OpenDetailTimer = Form1.AddNewTimer(Form1, 'OpenDetailTimer', 100);
  Form1.AddNewEvent(OpenDetailTimer, tbeOnTimer, 'OnOpenDetailTimer');
  OpenDetailTimer.Enabled = False;
}

{
  Form1 = TCLForm.Create(Self);
  ScaledLayout = Form1.AddNewScaledLayout(Form1, 'ScaledLayout');
  ScaledLayout.Align = alClient;
  ScaledLayout.OriginalHeight = 750;
  ScaledLayout.OriginalWidth = 350;

  SetupUI;
  GlobalFilterGenre = 'Tümü';
  FetchBooksFromFirebase;
  
  Form1.FormWaiting.Visible = False;
  Form1.BtnFormMenu.Visible = False;
  Form1.BtnGoBack.Visible = False;
  Form1.LytTopBar.Visible = False;
  Form1.Run;
}
https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
kayra12 Açılır Kutu İzle
Deneyimli Üye
Deneyimli Üye


Kayıt Tarihi: 23 Aralık 2024
Durum: Aktif
Puanlar: 55
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı kayra12 Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 53 Dakika Önce Saat 13:07
Merhaba ibrahim projen bulut tabanlı olduğu için ve Firebase bağlı olduğu için şunda daha fazla hızlandırma olmuyor bilginizehttps://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
ibrahimBsr Açılır Kutu İzle
Yeni Üye
Yeni Üye
Simge

Kayıt Tarihi: 23 Haziran 2026
Durum: Aktif Değil
Puanlar: 27
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı ibrahimBsr Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 40 Dakika Önce Saat 13:20
var
  MainForm: TCLForm;
  ScaledLayout: TclScaledLayout;

  // --- ASENKRON SİMÜLASYONU İÇİN EKLENENLER ---
  ActionTimer: TClTimer;
  GlobalActionType: String;

  // --- GİRİŞ SAYFASI DEĞİŞKENLERİ ---
  LoginMainPnl, TopPnl, ContentPnl, EmailPnl, PasswordPnl, BottomPnl, RegisterWrapPnl, ForgotPwdPnl: TclProPanel;
  IconImg: TclProImage;
  AppTitleLbl, AppSubTitleLbl, WelcomeLbl, SubWelcomeLbl, EmailTitleLbl, PasswordTitleLbl, RegisterLbl: TclProLabel;
  EmailEdt, PasswordEdt: TclProEdit;
  LoginBtn, RegisterBtn, ForgotPwdBtn: TclProButton;

  // --- KAYIT OL SAYFASI DEĞİŞKENLERİ ---
  RegMainPnl, RegTopPnl, RegTitleWrapPnl, RegBottomPnl: TclProPanel;
  RegScrollBox: TclVertScrollBox;
  
  RegPersonalTitleLbl, RegAccountTitleLbl: TclProLabel;
  RegRow1Pnl, RegAdPnl, RegSoyadPnl, RegTCPnl, RegPhonePnl, RegAddressPnl, RegAgePnl: TclProPanel;
  RegAdLbl, RegSoyadLbl, RegTCLbl, RegPhoneLbl, RegAddressLbl, RegAgeLbl: TclProLabel;
  RegAdEdt, RegSoyadEdt, RegTCEdt, RegPhoneEdt: TclProEdit;
  RegAddressMemo: TclMemo;
  RegAgeCombo: TclComboBox;

  // YÖNETİCİ ALANI İÇİN DEĞİŞKENLER EKLENDİ
  RegEmailPnl, RegPasswordPnl, RegPasswordRepPnl, RegAdminCodePnl: TclProPanel;
  RegEmailLbl, RegPasswordLbl, RegPasswordRepLbl, RegAdminCodeLbl: TclProLabel;
  RegEmailEdt, RegPasswordEdt, RegPasswordRepEdt, RegAdminCodeEdt: TclProEdit;

  RegBackBtn, RegSubmitBtn: TclProButton;
  RegTitleLbl, RegSubTitleLbl: TclProLabel;


// --- Sadece Sayı Girilmesini Sağlayan Fonksiyon ---
void OnNumberOnlyChange;
var
  S, newS, c: String;
  i: Integer;
  Edt: TclProEdit;
{
  Edt = TclProEdit(MainForm.clSender);
  S = Edt.Text;
  newS = '';
  i = 1;
  
  while (i <= Length(S))
  {
    c = Copy(S, i, 1);
    if ((c >= '0') && (c <= '9'))
      newS = newS + c;
    i = i + 1;
  }
  
  if (S <> newS)
  {
    Edt.Text = newS;
  }
}

void ExecuteLogin;
var
  clRest: TclRest;
  EmailKey, responseStr: String;
  isAdmin: Boolean;
{
  EmailKey = EmailEdt.Text;
  
  // FİREBASE KURALI: Klasör isimlerinde nokta olamaz
  while (Pos('.', EmailKey) > 0)
  {
    EmailKey = Copy(EmailKey, 1, Pos('.', EmailKey) - 1) + '_' + Copy(EmailKey, Pos('.', EmailKey) + 1, Length(EmailKey));
  }
  
  isAdmin = False;
  
  // 1. İSTEK: KULLANICILAR (users) TABLOSUNA BAK
  clRest = TclRest.Create;
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'.json';
  clRest.Method = rmGET;
  clRest.Accept = 'application/json';
  clRest.Execute;
  responseStr = clRest.Response;
  clRest.Free; // BAĞLANTIYI TEMİZLE VE KAPAT
  
  // Eğer users tablosunda yoksa, 2. İSTEK: YÖNETİCİLER (admins) TABLOSUNDA ARA
  if ((responseStr == 'null') || (responseStr == ''))
  {
     clRest = TclRest.Create; // YENİ TERTEMİZ BİR BAĞLANTI AÇ
     clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'.json';
     clRest.Method = rmGET;
     clRest.Accept = 'application/json';
     clRest.Execute;
     responseStr = clRest.Response;
     clRest.Free; // BAĞLANTIYI TEMİZLE VE KAPAT
     
     if ((responseStr <> 'null') && (responseStr <> ''))
     {
        isAdmin = True; // Kişi admins tablosunda bulundu!
     }
  }
  
  MainForm.FormWaiting.Visible = False; 
  
  if ((responseStr == 'null') || (responseStr == ''))
  {
    ShowMessage('Kayıtlı e-posta bulunamadı. Lütfen kayıt olun.');
  }
  else
  {
    if (Pos('"sifre":"'+PasswordEdt.Text+'"', responseStr) > 0)
    {
      Clomosy.GlobalVariableString = EmailKey;
      
      // --- SON GİRİŞ TARİHİNİ GÜNCELLE ---
      clRest = TclRest.Create;
      if (isAdmin)
         clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'/son_giris.json';
      else
         clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'/son_giris.json';
         
      clRest.Method = rmPUT;
      clRest.Accept = 'application/json';
      clRest.AddBody('"' + FormatDateTime('dd.mm.yyyy hh:nn:ss', Now) + '"', 'application/json');
      clRest.Execute;
      clRest.Free;
      
      if (isAdmin)
      {
         Clomosy.RunUnit('pGenel'); 
      }
      else
      {
         Clomosy.RunUnit('uKatalog'); 
      }
    }
    else
    {
      ShowMessage('Hatalı şifre girdiniz.');
    }
  }
}

void ExecuteRegister;
var
  clRest: TclRest;
  EmailKey, jsonBody, allUsersResp, allAdminsResp, tcVal, phoneVal, emailVal: String;
  isOk, isAdminReg: Boolean;
{
  tcVal = RegTCEdt.Text;
  phoneVal = RegPhoneEdt.Text;
  emailVal = RegEmailEdt.Text;
  isOk = True;

  EmailKey = emailVal; 
  
  while (Pos('.', EmailKey) > 0)
  {
    EmailKey = Copy(EmailKey, 1, Pos('.', EmailKey) - 1) + '_' + Copy(EmailKey, Pos('.', EmailKey) + 1, Length(EmailKey));
  }
  
  clRest = TclRest.Create;
  clRest.Method = rmGET;
  clRest.Accept = 'application/json';
  clRest.Execute;
  allUsersResp = clRest.Response;
  clRest.Free; 
  
  clRest = TclRest.Create; 
  clRest.Method = rmGET;
  clRest.Accept = 'application/json';
  clRest.Execute;
  allAdminsResp = clRest.Response;
  clRest.Free; 

  if (allUsersResp == 'null') allUsersResp = '';
  if (allAdminsResp == 'null') allAdminsResp = '';
  
  if ((Pos('"' + EmailKey + '":', allUsersResp) > 0) || (Pos('"' + EmailKey + '":', allAdminsResp) > 0))
  {
    ShowMessage('Bu e-posta adresi zaten sistemde kayıtlı!');
    isOk = False;
  }
  else if ((Pos('"tc":"' + tcVal + '"', allUsersResp) > 0) || (Pos('"tc":"' + tcVal + '"', allAdminsResp) > 0))
  {
    ShowMessage('Bu TC Kimlik Numarası sistemde zaten kayıtlı!');
    isOk = False;
  }
  else if ((Pos('"telefon":"' + phoneVal + '"', allUsersResp) > 0) || (Pos('"telefon":"' + phoneVal + '"', allAdminsResp) > 0))
  {
    ShowMessage('Bu telefon numarası sistemde zaten kayıtlı!');
    isOk = False;
  }
  
  if (isOk)
  {
    isAdminReg = False;
    if (RegAdminCodeEdt.Text == '1453') 
    {
       isAdminReg = True;
    }
    
    // --- KAYIT TARİHİ EKLENDİ (kayit_tarihi) ---
    jsonBody = '{"ad":"'+RegAdEdt.Text+'", "soyad":"'+RegSoyadEdt.Text+'", "yas":"'+RegAgeCombo.Text+'", "tc":"'+tcVal+'", "telefon":"'+phoneVal+'", "adres":"'+RegAddressMemo.Text+'", "sifre":"'+RegPasswordEdt.Text+'", "kayit_tarihi":"'+FormatDateTime('dd.mm.yyyy hh:nn:ss', Now)+'"}';
    
    clRest = TclRest.Create;
    
    if (isAdminReg)
       clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'.json';
    else
       clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'.json';
       
    clRest.Method = rmPUT;
    clRest.Accept = 'application/json';
    clRest.AddBody(jsonBody, 'application/json');
    clRest.Execute;
    clRest.Free; 

    MainForm.FormWaiting.Visible = False; 
    RegMainPnl.Visible = False;
    
    if (isAdminReg)
      ShowMessage('SİSTEM YÖNETİCİSİ kaydınız başarıyla oluşturuldu! Lütfen giriş yapınız.');
    else
      ShowMessage('Kayıt işlemi başarıyla eklendi. Lütfen giriş yapınız.');
  }
  else
  {
    MainForm.FormWaiting.Visible = False; 
  }
}

// --- ASENKRON İŞLEM TETİKLEYİCİSİ (TIMER) ---
void OnActionTimerTick;
{
  ActionTimer.Enabled = False; 
  
  if (GlobalActionType == 'Login')
  {
    ExecuteLogin;
  }
  else if (GlobalActionType == 'Register')
  {
    ExecuteRegister;
  }
}


// --- BUTON TIKLAMALARI ---
void CheckLogin;
{
  if ((EmailEdt.Text <> '') && (PasswordEdt.Text <> '')) 
  {
    MainForm.FormWaiting.Visible = True; 
    GlobalActionType = 'Login';
    ActionTimer.Enabled = True; 
  }
  else
  {
    ShowMessage('Lütfen e-posta ve şifrenizi giriniz.'); 
  }
}

void CloseRegister;
var
  tcVal, phoneVal, emailVal: String;
  tcLen, phoneLen: Integer;
{
  tcVal = RegTCEdt.Text;
  phoneVal = RegPhoneEdt.Text;
  emailVal = RegEmailEdt.Text;

  tcLen = Length(tcVal);
  phoneLen = Length(phoneVal);

  if ((RegAdEdt.Text <> '') && (RegSoyadEdt.Text <> '') && (tcVal <> '') && 
      (RegAddressMemo.Text <> '') && (emailVal <> '') && 
      (RegPasswordEdt.Text <> '') && (RegPasswordEdt.Text == RegPasswordRepEdt.Text))
  {
    if (RegAgeCombo.Text == '')
    {
       ShowMessage('Lütfen yaşınızı seçiniz!');
    }
    else if (tcLen <> 11)
    {
       ShowMessage('TC Kimlik Numarası 11 haneli olmalıdır!');
    }
    else if (phoneLen <> 10)
    {
       ShowMessage('Telefon numarası başında 0 olmadan 10 haneli olmalıdır! Örn: 5551234567');
    }
    else if ((Pos('@', emailVal) == 0) || (Pos('.', emailVal) == 0))
    {
       ShowMessage('Lütfen geçerli bir e-posta adresi giriniz!');
    }
    else
    {
      MainForm.FormWaiting.Visible = True; 
      GlobalActionType = 'Register';
      ActionTimer.Enabled = True; 
    }
  }
  else
  {
    ShowMessage('Lütfen tüm alanları eksiksiz doldurun ve şifrelerin eşleştiğinden emin olun.'); 
  }
}

void OpenRegister;
{
  RegMainPnl.Visible = True;
  RegMainPnl.BringToFront;
}

void BackOfMain;
{
  RegMainPnl.Visible = False;
}

void SetupRegisterUI;
var
  ageIndex: Integer;
{
  RegMainPnl = MainForm.AddNewProPanel(ScaledLayout, 'RegMainPnl');
  RegMainPnl.Align = alClient;
  RegMainPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegMainPnl.SetclProSettings(RegMainPnl.clProSettings);
  RegMainPnl.Visible = False; 

  RegTopPnl = MainForm.AddNewProPanel(RegMainPnl, 'RegTopPnl');
  RegTopPnl.Align = alTop;
  RegTopPnl.Height = 150;
  RegTopPnl.Margins.Top = -30;
  RegTopPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  RegTopPnl.clProSettings.RoundHeight = 40;
  RegTopPnl.clProSettings.RoundWidth = 40;
  RegTopPnl.SetclProSettings(RegTopPnl.clProSettings);

  RegBackBtn = MainForm.AddNewProButton(RegTopPnl, 'RegBackBtn', '< Giriş sayfası');
  RegBackBtn.Align = alLeft;
  RegBackBtn.Width = 120;
  RegBackBtn.Margins.Top = 30;
  RegBackBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegBackBtn.clProSettings.TextSettings.Font.Style = [fsBold];
  RegBackBtn.SetclProSettings(RegBackBtn.clProSettings);
  MainForm.AddNewEvent(RegBackBtn, tbeOnClick, 'BackOfMain');

  RegTitleWrapPnl = MainForm.AddNewProPanel(RegTopPnl, 'RegTitleWrapPnl');
  RegTitleWrapPnl.Align = alRight;
  RegTitleWrapPnl.Width = 120;
  RegTitleWrapPnl.Margins.Top = 70;
  RegTitleWrapPnl.Margins.Right = 5;
  RegTitleWrapPnl.clProSettings.RoundHeight = 40;
  RegTitleWrapPnl.clProSettings.RoundWidth = 40;
  RegTitleWrapPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  RegTitleWrapPnl.SetclProSettings(RegTitleWrapPnl.clProSettings);

  RegTitleLbl = MainForm.AddNewProLabel(RegTitleWrapPnl, 'RegTitleLbl', 'Kayıt Ol');
  RegTitleLbl.Align = alTop;
  RegTitleLbl.Height = 25;
  RegTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegTitleLbl.clProSettings.FontSize = 22;
  RegTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  RegTitleLbl.SetclProSettings(RegTitleLbl.clProSettings);

  RegSubTitleLbl = MainForm.AddNewProLabel(RegTitleWrapPnl, 'RegSubTitleLbl', 'YENİ ÜYELİK');
  RegSubTitleLbl.Align = alTop;
  RegSubTitleLbl.Height = 20;
  RegSubTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#B09A9E');
  RegSubTitleLbl.clProSettings.FontSize = 10;
  RegSubTitleLbl.SetclProSettings(RegSubTitleLbl.clProSettings);

  RegScrollBox = MainForm.AddNewVertScrollBox(RegMainPnl, 'RegScrollBox');
  RegScrollBox.Align = alClient;
  RegScrollBox.Margins.Left = 30;
  RegScrollBox.Margins.Right = 30;
  RegScrollBox.Margins.Top = 20;
  RegScrollBox.Margins.Bottom = 20;
  
  RegPersonalTitleLbl = MainForm.AddNewProLabel(RegScrollBox, 'RegPersonalTitleLbl', 'KİŞİSEL BİLGİLER');
  RegPersonalTitleLbl.Align = alTop;
  RegPersonalTitleLbl.Height = 25;
  RegPersonalTitleLbl.Margins.Bottom = 10;
  RegPersonalTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegPersonalTitleLbl.clProSettings.FontSize = 11;
  RegPersonalTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  RegPersonalTitleLbl.SetclProSettings(RegPersonalTitleLbl.clProSettings);

  RegRow1Pnl = MainForm.AddNewProPanel(RegScrollBox, 'RegRow1Pnl');
  RegRow1Pnl.Align = alTop;
  RegRow1Pnl.Height = 80;
  RegRow1Pnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegRow1Pnl.SetclProSettings(RegRow1Pnl.clProSettings);

  RegAdPnl = MainForm.AddNewProPanel(RegRow1Pnl, 'RegAdPnl');
  RegAdPnl.Align = alLeft;
  RegAdPnl.Width = 140; 
  RegAdPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegAdPnl.SetclProSettings(RegAdPnl.clProSettings);

  RegAdLbl = MainForm.AddNewProLabel(RegAdPnl, 'RegAdLbl', 'AD');
  RegAdLbl.Align = alTop;
  RegAdLbl.Height = 20;
  RegAdLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegAdLbl.clProSettings.FontSize = 10;
  RegAdLbl.SetclProSettings(RegAdLbl.clProSettings);

  RegAdEdt = MainForm.AddNewProEdit(RegAdPnl, 'RegAdEdt', '');
  RegAdEdt.Align = alClient;
  RegAdEdt.Margins.Bottom = 15;
  RegAdEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegAdEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegAdEdt.clProSettings.BorderWidth = 1;
  RegAdEdt.SetclProSettings(RegAdEdt.clProSettings);

  RegSoyadPnl = MainForm.AddNewProPanel(RegRow1Pnl, 'RegSoyadPnl');
  RegSoyadPnl.Align = alClient;
  RegSoyadPnl.Margins.Left = 10; 
  RegSoyadPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegSoyadPnl.SetclProSettings(RegSoyadPnl.clProSettings);

  RegSoyadLbl = MainForm.AddNewProLabel(RegSoyadPnl, 'RegSoyadLbl', 'SOYAD');
  RegSoyadLbl.Align = alTop;
  RegSoyadLbl.Height = 20;
  RegSoyadLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegSoyadLbl.clProSettings.FontSize = 10;
  RegSoyadLbl.SetclProSettings(RegSoyadLbl.clProSettings);

  RegSoyadEdt = MainForm.AddNewProEdit(RegSoyadPnl, 'RegSoyadEdt', '');
  RegSoyadEdt.Align = alClient;
  RegSoyadEdt.Margins.Bottom = 15;
  RegSoyadEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegSoyadEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegSoyadEdt.clProSettings.BorderWidth = 1;
  RegSoyadEdt.SetclProSettings(RegSoyadEdt.clProSettings);

  RegAgePnl = MainForm.AddNewProPanel(RegScrollBox, 'RegAgePnl');
  RegAgePnl.Align = alTop;
  RegAgePnl.Height = 80;
  RegAgePnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegAgePnl.SetclProSettings(RegAgePnl.clProSettings);

  RegAgeLbl = MainForm.AddNewProLabel(RegAgePnl, 'RegAgeLbl', 'YAŞ');
  RegAgeLbl.Align = alTop;
  RegAgeLbl.Height = 20;
  RegAgeLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegAgeLbl.clProSettings.FontSize = 10;
  RegAgeLbl.SetclProSettings(RegAgeLbl.clProSettings);

  RegAgeCombo = MainForm.AddNewComboBox(RegAgePnl, 'RegAgeCombo');
  RegAgeCombo.Align = alClient;
  RegAgeCombo.Margins.Bottom = 15;
  
  ageIndex = 10;
  while (ageIndex <= 100)
  {
    RegAgeCombo.AddItem(IntToStr(ageIndex), IntToStr(ageIndex));
    ageIndex = ageIndex + 1;
  }

  RegTCPnl = MainForm.AddNewProPanel(RegScrollBox, 'RegTCPnl');
  RegTCPnl.Align = alTop;
  RegTCPnl.Height = 80;
  RegTCPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegTCPnl.SetclProSettings(RegTCPnl.clProSettings);

  RegTCLbl = MainForm.AddNewProLabel(RegTCPnl, 'RegTCLbl', 'TC KİMLİK NO');
  RegTCLbl.Align = alTop;
  RegTCLbl.Height = 20;
  RegTCLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegTCLbl.clProSettings.FontSize = 10;
  RegTCLbl.SetclProSettings(RegTCLbl.clProSettings);

  RegTCEdt = MainForm.AddNewProEdit(RegTCPnl, 'RegTCEdt', '');
  RegTCEdt.Align = alClient;
  RegTCEdt.Margins.Bottom = 15;
  RegTCEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegTCEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegTCEdt.clProSettings.BorderWidth = 1;
  RegTCEdt.SetclProSettings(RegTCEdt.clProSettings);
  MainForm.AddNewEvent(RegTCEdt, tbeOnChange, 'OnNumberOnlyChange');

  RegPhonePnl = MainForm.AddNewProPanel(RegScrollBox, 'RegPhonePnl');
  RegPhonePnl.Align = alTop;
  RegPhonePnl.Height = 80;
  RegPhonePnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegPhonePnl.SetclProSettings(RegPhonePnl.clProSettings);

  RegPhoneLbl = MainForm.AddNewProLabel(RegPhonePnl, 'RegPhoneLbl', 'TELEFON (Başında 0 olmadan 10 haneli)');
  RegPhoneLbl.Align = alTop;
  RegPhoneLbl.Height = 20;
  RegPhoneLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegPhoneLbl.clProSettings.FontSize = 10;
  RegPhoneLbl.SetclProSettings(RegPhoneLbl.clProSettings);

  RegPhoneEdt = MainForm.AddNewProEdit(RegPhonePnl, 'RegPhoneEdt', '');
  RegPhoneEdt.Align = alClient;
  RegPhoneEdt.Margins.Bottom = 15;
  RegPhoneEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegPhoneEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegPhoneEdt.clProSettings.BorderWidth = 1;
  RegPhoneEdt.SetclProSettings(RegPhoneEdt.clProSettings);
  MainForm.AddNewEvent(RegPhoneEdt, tbeOnChange, 'OnNumberOnlyChange');

  RegAddressPnl = MainForm.AddNewProPanel(RegScrollBox, 'RegAddressPnl');
  RegAddressPnl.Align = alTop;
  RegAddressPnl.Height = 120;
  RegAddressPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegAddressPnl.SetclProSettings(RegAddressPnl.clProSettings);

  RegAddressLbl = MainForm.AddNewProLabel(RegAddressPnl, 'RegAddressLbl', 'ADRES');
  RegAddressLbl.Align = alTop;
  RegAddressLbl.Height = 20;
  RegAddressLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegAddressLbl.clProSettings.FontSize = 10;
  RegAddressLbl.SetclProSettings(RegAddressLbl.clProSettings);

  RegAddressMemo = MainForm.AddNewMemo(RegAddressPnl, 'RegAddressMemo', '');
  RegAddressMemo.Align = alClient;
  RegAddressMemo.Margins.Bottom = 15;

  RegAccountTitleLbl = MainForm.AddNewProLabel(RegScrollBox, 'RegAccountTitleLbl', 'HESAP BİLGİLERİ');
  RegAccountTitleLbl.Align = alTop;
  RegAccountTitleLbl.Height = 25;
  RegAccountTitleLbl.Margins.Top = 15;
  RegAccountTitleLbl.Margins.Bottom = 10;
  RegAccountTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegAccountTitleLbl.clProSettings.FontSize = 11;
  RegAccountTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  RegAccountTitleLbl.SetclProSettings(RegAccountTitleLbl.clProSettings);

  RegEmailPnl = MainForm.AddNewProPanel(RegScrollBox, 'RegEmailPnl');
  RegEmailPnl.Align = alTop;
  RegEmailPnl.Height = 80;
  RegEmailPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegEmailPnl.SetclProSettings(RegEmailPnl.clProSettings);

  RegEmailLbl = MainForm.AddNewProLabel(RegEmailPnl, 'RegEmailLbl', 'E-POSTA');
  RegEmailLbl.Align = alTop;
  RegEmailLbl.Height = 20;
  RegEmailLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegEmailLbl.clProSettings.FontSize = 10;
  RegEmailLbl.SetclProSettings(RegEmailLbl.clProSettings);

  RegEmailEdt = MainForm.AddNewProEdit(RegEmailPnl, 'RegEmailEdt', '');
  RegEmailEdt.Align = alClient;
  RegEmailEdt.Margins.Bottom = 15;
  RegEmailEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegEmailEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegEmailEdt.clProSettings.BorderWidth = 1;
  RegEmailEdt.SetclProSettings(RegEmailEdt.clProSettings);

  RegPasswordPnl = MainForm.AddNewProPanel(RegScrollBox, 'RegPasswordPnl');
  RegPasswordPnl.Align = alTop;
  RegPasswordPnl.Height = 80;
  RegPasswordPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegPasswordPnl.SetclProSettings(RegPasswordPnl.clProSettings);

  RegPasswordLbl = MainForm.AddNewProLabel(RegPasswordPnl, 'RegPasswordLbl', 'ŞİFRE');
  RegPasswordLbl.Align = alTop;
  RegPasswordLbl.Height = 20;
  RegPasswordLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegPasswordLbl.clProSettings.FontSize = 10;
  RegPasswordLbl.SetclProSettings(RegPasswordLbl.clProSettings);

  RegPasswordEdt = MainForm.AddNewProEdit(RegPasswordPnl, 'RegPasswordEdt', '');
  RegPasswordEdt.Align = alClient;
  RegPasswordEdt.Margins.Bottom = 15;
  RegPasswordEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegPasswordEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegPasswordEdt.clProSettings.BorderWidth = 1;
  RegPasswordEdt.SetclProSettings(RegPasswordEdt.clProSettings);

  RegPasswordRepPnl = MainForm.AddNewProPanel(RegScrollBox, 'RegPasswordRepPnl');
  RegPasswordRepPnl.Align = alTop;
  RegPasswordRepPnl.Height = 80;
  RegPasswordRepPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegPasswordRepPnl.SetclProSettings(RegPasswordRepPnl.clProSettings);

  RegPasswordRepLbl = MainForm.AddNewProLabel(RegPasswordRepPnl, 'RegPasswordRepLbl', 'ŞİFRE TEKRAR');
  RegPasswordRepLbl.Align = alTop;
  RegPasswordRepLbl.Height = 20;
  RegPasswordRepLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegPasswordRepLbl.clProSettings.FontSize = 10;
  RegPasswordRepLbl.SetclProSettings(RegPasswordRepLbl.clProSettings);

  RegPasswordRepEdt = MainForm.AddNewProEdit(RegPasswordRepPnl, 'RegPasswordRepEdt', '');
  RegPasswordRepEdt.Align = alClient;
  RegPasswordRepEdt.Margins.Bottom = 15;
  RegPasswordRepEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegPasswordRepEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegPasswordRepEdt.clProSettings.BorderWidth = 1;
  RegPasswordRepEdt.SetclProSettings(RegPasswordRepEdt.clProSettings);

  // YÖNETİCİ DAVET KODU EKRANI EKLENDİ
  RegAdminCodePnl = MainForm.AddNewProPanel(RegScrollBox, 'RegAdminCodePnl');
  RegAdminCodePnl.Align = alTop;
  RegAdminCodePnl.Height = 80;
  RegAdminCodePnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegAdminCodePnl.SetclProSettings(RegAdminCodePnl.clProSettings);

  RegAdminCodeLbl = MainForm.AddNewProLabel(RegAdminCodePnl, 'RegAdminCodeLbl', 'YÖNETİCİ DAVET KODU (Kullanıcı iseniz boş bırakın)');
  RegAdminCodeLbl.Align = alTop;
  RegAdminCodeLbl.Height = 20;
  RegAdminCodeLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#D81B60'); // Dikkat çekmesi için farklı renk
  RegAdminCodeLbl.clProSettings.FontSize = 10;
  RegAdminCodeLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  RegAdminCodeLbl.SetclProSettings(RegAdminCodeLbl.clProSettings);

  RegAdminCodeEdt = MainForm.AddNewProEdit(RegAdminCodePnl, 'RegAdminCodeEdt', '');
  RegAdminCodeEdt.Align = alClient;
  RegAdminCodeEdt.Margins.Bottom = 15;
  RegAdminCodeEdt.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegAdminCodeEdt.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  RegAdminCodeEdt.clProSettings.BorderWidth = 1;
  RegAdminCodeEdt.SetclProSettings(RegAdminCodeEdt.clProSettings);

  RegBottomPnl = MainForm.AddNewProPanel(RegMainPnl, 'RegBottomPnl');
  RegBottomPnl.Align = alBottom;
  RegBottomPnl.Height = 70;
  RegBottomPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  RegBottomPnl.SetclProSettings(RegBottomPnl.clProSettings);

  RegSubmitBtn = MainForm.AddNewProButton(RegBottomPnl, 'RegSubmitBtn', 'Kayıt Tamamla');
  RegSubmitBtn.Align = alClient;
  RegSubmitBtn.Margins.Top = 15;
  RegSubmitBtn.Margins.Bottom = 15;
  RegSubmitBtn.Margins.Left = 15;
  RegSubmitBtn.Margins.Right = 15;
  RegSubmitBtn.clProSettings.RoundHeight = 5;
  RegSubmitBtn.clProSettings.RoundWidth = 5;
  RegSubmitBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  RegSubmitBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  RegSubmitBtn.clProSettings.FontSize = 16;
  RegSubmitBtn.clProSettings.TextSettings.Font.Style = [fsBold];
  RegSubmitBtn.SetclProSettings(RegSubmitBtn.clProSettings);
  
  MainForm.AddNewEvent(RegSubmitBtn, tbeOnClick, 'CloseRegister');
}

void SetupUI;
{
  LoginMainPnl = MainForm.AddNewProPanel(ScaledLayout, 'LoginMainPnl');
  LoginMainPnl.Align = alClient;
  LoginMainPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  LoginMainPnl.SetclProSettings(LoginMainPnl.clProSettings);

  TopPnl = MainForm.AddNewProPanel(LoginMainPnl, 'TopPnl');
  TopPnl.Align = alTop;
  TopPnl.Margins.Top = -50;
  TopPnl.Height = 300;
  TopPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  TopPnl.clProSettings.RoundHeight = 40;
  TopPnl.clProSettings.RoundWidth = 40;
  TopPnl.SetclProSettings(TopPnl.clProSettings);

  IconImg = MainForm.AddNewProImage(TopPnl, 'IconImg');
  IconImg.Align = alTop;
  IconImg.Height = 50;
  IconImg.Margins.Top = 120;
  IconImg.Margins.Bottom = 20;

  AppTitleLbl = MainForm.AddNewProLabel(TopPnl, 'AppTitleLbl', 'Arşiv');
  AppTitleLbl.Align = alTop;
  AppTitleLbl.Height = 40;
  AppTitleLbl.Margins.Top = 10;
  AppTitleLbl.Margins.Left = 135;
  AppTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  AppTitleLbl.clProSettings.FontSize = 32;
  AppTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  AppTitleLbl.SetclProSettings(AppTitleLbl.clProSettings);

  AppSubTitleLbl = MainForm.AddNewProLabel(TopPnl, 'AppSubTitleLbl', 'KÜTÜPHANE SİSTEMİ');
  AppSubTitleLbl.Align = alTop;
  AppSubTitleLbl.Height = 20;
  AppSubTitleLbl.Margins.Top = 5;
  AppSubTitleLbl.Margins.Left = 120;
  AppSubTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#B09A9E');
  AppSubTitleLbl.clProSettings.FontSize = 12;
  AppSubTitleLbl.SetclProSettings(AppSubTitleLbl.clProSettings);

  ContentPnl = MainForm.AddNewProPanel(LoginMainPnl, 'ContentPnl');
  ContentPnl.Align = alClient;
  ContentPnl.Margins.Left = 30;
  ContentPnl.Margins.Right = 30;
  ContentPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  ContentPnl.SetclProSettings(ContentPnl.clProSettings);

  WelcomeLbl = MainForm.AddNewProLabel(ContentPnl, 'WelcomeLbl', 'Hoş geldiniz');
  WelcomeLbl.Align = alTop;
  WelcomeLbl.Height = 35;
  WelcomeLbl.Margins.Top = 30;
  WelcomeLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#222222');
  WelcomeLbl.clProSettings.FontSize = 24;
  WelcomeLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  WelcomeLbl.SetclProSettings(WelcomeLbl.clProSettings);

  SubWelcomeLbl = MainForm.AddNewProLabel(ContentPnl, 'SubWelcomeLbl', 'Devam etmek için giriş yapın');
  SubWelcomeLbl.Align = alTop;
  SubWelcomeLbl.Height = 20;
  SubWelcomeLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  SubWelcomeLbl.clProSettings.FontSize = 12;
  SubWelcomeLbl.SetclProSettings(SubWelcomeLbl.clProSettings);

  EmailTitleLbl = MainForm.AddNewProLabel(ContentPnl, 'EmailTitleLbl', 'E-POSTA');
  EmailTitleLbl.Align = alTop;
  EmailTitleLbl.Height = 20;
  EmailTitleLbl.Margins.Top = 30;
  EmailTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  EmailTitleLbl.clProSettings.FontSize = 10;
  EmailTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  EmailTitleLbl.SetclProSettings(EmailTitleLbl.clProSettings);

  EmailPnl = MainForm.AddNewProPanel(ContentPnl, 'EmailPnl');
  EmailPnl.Align = alTop;
  EmailPnl.Height = 50;
  EmailPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  EmailPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  EmailPnl.clProSettings.BorderWidth = 1;
  EmailPnl.SetclProSettings(EmailPnl.clProSettings);

  EmailEdt = MainForm.AddNewProEdit(EmailPnl, 'EmailEdt', '');
  EmailEdt.Align = alClient;
  EmailEdt.Margins.Top = 15;
  EmailEdt.Margins.Bottom = 15;
  EmailEdt.Margins.Left = 10;
  EmailEdt.Margins.Right = 10;
  EmailEdt.clProSettings.FontSize = 14;
  EmailEdt.SetclProSettings(EmailEdt.clProSettings);

  PasswordTitleLbl = MainForm.AddNewProLabel(ContentPnl, 'PasswordTitleLbl', 'ŞİFRE');
  PasswordTitleLbl.Align = alTop;
  PasswordTitleLbl.Height = 20;
  PasswordTitleLbl.Margins.Top = 20;
  PasswordTitleLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  PasswordTitleLbl.clProSettings.FontSize = 10;
  PasswordTitleLbl.clProSettings.TextSettings.Font.Style = [fsBold];
  PasswordTitleLbl.SetclProSettings(PasswordTitleLbl.clProSettings);

  PasswordPnl = MainForm.AddNewProPanel(ContentPnl, 'PasswordPnl');
  PasswordPnl.Align = alTop;
  PasswordPnl.Height = 50;
  PasswordPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#FFFFFF');
  PasswordPnl.clProSettings.BorderColor = clAlphaColor.clHexToColor('#DDDDDD');
  PasswordPnl.clProSettings.BorderWidth = 1;
  PasswordPnl.SetclProSettings(PasswordPnl.clProSettings);

  PasswordEdt = MainForm.AddNewProEdit(PasswordPnl, 'PasswordEdt', '');
  PasswordEdt.Align = alClient;
  PasswordEdt.Margins.Top = 15;
  PasswordEdt.Margins.Bottom = 15;
  PasswordEdt.Margins.Left = 10;
  PasswordEdt.Margins.Right = 10;
  PasswordEdt.clProSettings.FontSize = 14;
  PasswordEdt.SetclProSettings(PasswordEdt.clProSettings);

  ForgotPwdPnl = MainForm.AddNewProPanel(ContentPnl, 'ForgotPwdPnl');
  ForgotPwdPnl.Align = alTop;
  ForgotPwdPnl.Height = 25;
  ForgotPwdPnl.Margins.Top = 5;
  ForgotPwdPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  ForgotPwdPnl.SetclProSettings(ForgotPwdPnl.clProSettings);

  ForgotPwdBtn = MainForm.AddNewProButton(ForgotPwdPnl, 'ForgotPwdBtn', 'Şifremi unuttum');
  ForgotPwdBtn.Align = alRight; 
  ForgotPwdBtn.Width = 100;
  ForgotPwdBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#B8860B'); 
  ForgotPwdBtn.clProSettings.FontSize = 11;
  ForgotPwdBtn.SetclProSettings(ForgotPwdBtn.clProSettings);

  BottomPnl = MainForm.AddNewProPanel(ContentPnl, 'BottomPnl');
  BottomPnl.Align = alBottom;
  BottomPnl.Height = 120;
  BottomPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1');
  BottomPnl.SetclProSettings(BottomPnl.clProSettings);

  LoginBtn = MainForm.AddNewProButton(BottomPnl, 'LoginBtn', '➔ Giriş Yap');
  LoginBtn.Align = alTop;
  LoginBtn.Height = 55;
  LoginBtn.Margins.Top = 15;
  LoginBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#36212E');
  LoginBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  LoginBtn.clProSettings.FontSize = 16;
  LoginBtn.clProSettings.TextSettings.Font.Style = [fsBold];
  LoginBtn.clProSettings.RoundHeight = 5;
  LoginBtn.clProSettings.RoundWidth = 5;
  LoginBtn.SetclProSettings(LoginBtn.clProSettings);
  
  RegisterWrapPnl = MainForm.AddNewProPanel(BottomPnl, 'RegisterWrapPnl');
  RegisterWrapPnl.Align = alTop;
  RegisterWrapPnl.Height = 30;
  RegisterWrapPnl.Margins.Top = 15;
  RegisterWrapPnl.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); 
  RegisterWrapPnl.SetclProSettings(RegisterWrapPnl.clProSettings);

  RegisterLbl = MainForm.AddNewProLabel(RegisterWrapPnl, 'RegisterLbl', 'Hesabınız yok mu?');
  RegisterLbl.Align = alLeft; 
  RegisterLbl.Width = 110; 
  RegisterLbl.Margins.Left = 60;
  RegisterLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#888888');
  RegisterLbl.clProSettings.FontSize = 12;
  RegisterLbl.SetclProSettings(RegisterLbl.clProSettings);
  
  RegisterBtn = MainForm.AddNewProButton(RegisterWrapPnl, 'RegisterBtn', 'Kayıt ol');
  RegisterBtn.Align = alLeft; 
  RegisterBtn.Width = 50; 
  RegisterBtn.Margins.Bottom = 15;
  RegisterBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#B8860B'); 
  RegisterBtn.clProSettings.FontSize = 14;
  RegisterBtn.SetclProSettings(RegisterBtn.clProSettings);
  
  MainForm.AddNewEvent(LoginBtn, tbeOnClick, 'CheckLogin'); 
  MainForm.AddNewEvent(RegisterBtn, tbeOnClick, 'OpenRegister');

  ActionTimer = MainForm.AddNewTimer(MainForm, 'ActionTimer', 100);
  ActionTimer.Enabled = False;
  MainForm.AddNewEvent(ActionTimer, tbeOnTimer, 'OnActionTimerTick');

  SetupRegisterUI;
}

{
  MainForm = TCLForm.Create(Self); 
  MainForm.SetFormColor('#F0EBE1', '#F0EBE1', clGVertical);

  ScaledLayout = MainForm.AddNewScaledLayout(MainForm, 'ScaledLayout'); 
  ScaledLayout.Align = alClient; 
  ScaledLayout.OriginalHeight = 750; 
  ScaledLayout.OriginalWidth = 350; 

  SetupUI;
  
  MainForm.FormWaiting.Visible = False; 
  MainForm.BtnFormMenu.Visible = False; 
  MainForm.BtnGoBack.Visible = False; 
  MainForm.LytTopBar.Visible = False;
  MainForm.Run; 
}
https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
Emr.Erkmn Açılır Kutu İzle
Moderatör
Moderatör


Kayıt Tarihi: 28 Şubat 2025
Durum: Aktif Değil
Puanlar: 961
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Emr.Erkmn Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 30 Dakika Önce Saat 13:30
Merhaba İbrahim 

Yavaşlıkta tespit ettiklerim 

1Proje de giriş yapılmadığın da gereksiz api istekleri bulunuyor
yani kullanıcı giriş yapmasa bile kütüphanede ki tüm ödünç alınan kitapların listesi sunucudan çekiliyor
2her yükleme de firebase de kullanıcının görüm modu databasen tekrar çekiyor
3api den tarama yaparken gelen json verisi döngü içinde tek tek karakter ayıklıyordu bu durum da cihazda donmayya neden olabilir 
4.firebaseden books.json çekilirken tüm kitapler tek sefer de geliyordu kitap sayısının artması arayüzü dondurabilir 

aşağıda revize edilmiş 2 prosedür bırakıyorum 

void FetchBooksFromFirebase;
var
  clRestSettings, clRest, clRestBorrowed, clRestReviews, clRestNotif: TclRest;
  clQuery: TClJSONQuery;
  bookID, valStr, ratingStr, currentUser, respStr, retDateStr, bCoverUrl: String;
  bTitle, bAuthor, bColor, bSummary, bCover, bGenre: String;
  pStart, pEnd, totalRating, reviewCount, daysLeft: Integer;
  avgRating: Double;
  allBorrowedStr, allReviewsStr, bookBorrowBlock, bookRevBlock: String;
{
  currentUser = Clomosy.GlobalVariableString;
  GlobalNotifMsg = ''; GlobalNotifCount = 0; GlobalGridColCount = 0; 
  
  if (GlobalBooksList <> nil) GlobalBooksList.Free;
  GlobalBooksList = Clomosy.StringListNew;
  
  if (currentUser <> '')
  {
    // İYİLEŞTİRME 1: ViewMode Firebase'den sadece 1 kez çekilir, sonra lokal önbellek kullanılır.
    if (GlobalViewMode == '')
    {
      clRestSettings = TclRest.Create; 
      clRestSettings.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/settings/'+currentUser+'/viewMode.json'; 
      clRestSettings.Method = rmGET; 
      clRestSettings.Execute;
      if (Pos('"grid"', clRestSettings.Response) > 0) GlobalViewMode = 'grid'; else GlobalViewMode = 'list';
      clRestSettings.Free;
    }
    
    if (ViewToggleBtn <> nil)
    {
      if (GlobalViewMode == 'grid') ViewToggleBtn.Text = 'Liste'; else ViewToggleBtn.Text = 'Izgara';
    }
  
    // Bildirimleri çek
    clRestNotif = TclRest.Create; 
    clRestNotif.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/notifications/' + currentUser + '.json'; 
    clRestNotif.Method = rmGET; 
    clRestNotif.Execute;
    respStr = clRestNotif.Response; 
    clRestNotif.Free;
    if ((respStr <> 'null') && (respStr <> '') && (respStr <> '{}'))
    {
      pStart = Pos('"msg":"', respStr);
      while (pStart > 0)
      {
        GlobalNotifCount = GlobalNotifCount + 1; 
        respStr = Copy(respStr, pStart + 7, Length(respStr));
        GlobalNotifMsg = GlobalNotifMsg + '- ' + Copy(respStr, 1, Pos('"', respStr) - 1) + #13#10;
        pStart = Pos('"msg":"', respStr);
      }
    }
  } else GlobalViewMode = 'list';
  // İYİLEŞTİRME 2: Giriş yapmamış misafir kullanıcılar için borrowed.json çağrısı yapılmaz.
  allBorrowedStr = '';
  if (currentUser <> '')
  {
    clRestBorrowed = TclRest.Create; 
    clRestBorrowed.Method = rmGET; 
    clRestBorrowed.Execute; 
    allBorrowedStr = clRestBorrowed.Response; 
    clRestBorrowed.Free;
  }
  clRestReviews = TclRest.Create; 
  clRestReviews.Method = rmGET; 
  clRestReviews.Execute; 
  allReviewsStr = clRestReviews.Response; 
  clRestReviews.Free;
  // İYİLEŞTİRME 3: Firebase'den tek seferde maks 30 kitap istenir (hızlı yükleme için)
  clRest = TclRest.Create; 
  clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/books.json?orderBy="$key"&limitToFirst=30'; 
  clRest.Method = rmGET; 
  clRest.Accept = 'application/json'; 
  clRest.Execute;
  
  if ((clRest.Response <> 'null') && (clRest.Response <> '') && (clRest.Response <> '{}'))
  {
    if ((Pos('":{"', clRest.Response) == 0) && (Pos('": {"', clRest.Response) == 0))
    {
       clRest.Method = rmDELETE; clRest.Execute; ShowMessage('Sistem Uyarısı: Veritabanı sıfırlandı.');
    }
    else
    {
      clQuery = Clomosy.ClDataSetFromJSON(clRest.Response);
      if (clQuery <> nil)
      {
        clQuery.First;
        while (not clQuery.Eof)
        {
          bookID = ''; try bookID = clQuery.FieldByName('id').AsString; except bookID = ''; }
          
          if (bookID <> '')
          {
            bTitle = 'Bilinmeyen Kitap'; try bTitle = clQuery.FieldByName('title').AsString; except bTitle = 'Bilinmeyen Kitap'; }
            bAuthor = 'Bilinmeyen Yazar'; try bAuthor = clQuery.FieldByName('author').AsString; except bAuthor = 'Bilinmeyen Yazar'; }
            bColor = '#2E4053'; try bColor = clQuery.FieldByName('color').AsString; except bColor = '#2E4053'; }
            bSummary = 'Açıklama bulunmuyor.'; try bSummary = clQuery.FieldByName('summary').AsString; except bSummary = 'Açıklama bulunmuyor.'; }
            bCoverUrl = ''; try bCoverUrl = clQuery.FieldByName('cover').AsString; except bCoverUrl = ''; }
            bGenre = 'Roman'; try bGenre = clQuery.FieldByName('genre').AsString; except bGenre = 'Roman'; }
            if ((currentUser <> '') && (allBorrowedStr <> 'null') && (allBorrowedStr <> ''))
            {
               pStart = Pos('"' + bookID + '":', allBorrowedStr);
               if (pStart > 0)
               {
                  bookBorrowBlock = Copy(allBorrowedStr, pStart, 1500);
                  pEnd = Pos('}}', bookBorrowBlock);
                  if (pEnd > 0) bookBorrowBlock = Copy(bookBorrowBlock, 1, pEnd);
                  
                  if (Pos('"' + currentUser + '"', bookBorrowBlock) > 0)
                  {
                     retDateStr = ''; pStart = Pos('"returnDate":"', bookBorrowBlock);
                     if (pStart > 0)
                     {
                        pStart = pStart + 14;
                        pEnd = Pos('"', Copy(bookBorrowBlock, pStart, Length(bookBorrowBlock)));
                        if (pEnd > 0) retDateStr = Copy(bookBorrowBlock, pStart, pEnd - 1);
                     }
                     if (retDateStr <> '')
                     {
                        daysLeft = Trunc(StrToDate(retDateStr)) - Trunc(Now);
                        if (daysLeft < 0) { GlobalNotifCount = GlobalNotifCount + 1; GlobalNotifMsg = GlobalNotifMsg + '- "' + bTitle + '" iadesi ' + IntToStr(Abs(daysLeft)) + ' gün gecikti!' + #13#10; }
                        else if (daysLeft <= 2) { GlobalNotifCount = GlobalNotifCount + 1; GlobalNotifMsg = GlobalNotifMsg + '- "' + bTitle + '" iadesine ' + IntToStr(daysLeft) + ' gün kaldı!' + #13#10; }
                     }
                  }
               }
            }
            
            totalRating = 0; reviewCount = 0;
            if ((allReviewsStr <> 'null') && (allReviewsStr <> ''))
            {
               pStart = Pos('"' + bookID + '":', allReviewsStr);
               if (pStart > 0)
               {
                  bookRevBlock = Copy(allReviewsStr, pStart, 1500);
                  pEnd = Pos('}}', bookRevBlock);
                  if (pEnd > 0) bookRevBlock = Copy(bookRevBlock, 1, pEnd);
                  
                  pStart = Pos('"rating":', bookRevBlock);
                  while (pStart > 0)
                  {
                     pStart = pStart + 9; valStr = Copy(bookRevBlock, pStart, 1); if (valStr == ' ') valStr = Copy(bookRevBlock, pStart + 1, 1);
                     totalRating = totalRating + StrToIntDef(valStr, 0); reviewCount = reviewCount + 1;
                     bookRevBlock = Copy(bookRevBlock, pStart + 1, Length(bookRevBlock)); pStart = Pos('"rating":', bookRevBlock);
                  }
               }
            }
            if (reviewCount > 0) { avgRating = (totalRating * 1.0) / reviewCount; ratingStr = FloatToStr(avgRating); if (Length(ratingStr) > 3) ratingStr = Copy(ratingStr, 1, 3); }
            else ratingStr = '0';
          
            GlobalBooksList.Add('{"id":"'+bookID+'","title":"'+bTitle+'","author":"'+bAuthor+'", "rating":"'+ratingStr+'", "color":"'+bColor+'", "summary":"'+bSummary+'", "cover":"'+bCoverUrl+'", "genre":"'+bGenre+'"}');
          }
          clQuery.Next;
        }
        clQuery.Free; 
      }
    }
  }
  clRest.Free;
  
  if (GlobalNotifCount > 0) { NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D81B60'); NotifBtn.SetclProSettings(NotifBtn.clProSettings); }
  else { NotifBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); NotifBtn.SetclProSettings(NotifBtn.clProSettings); }
  
  DrawBooks;
}


void SearchOpenLibrary;
var
  clRestAPI: TclRest;
  queryStr, jsonResult, docsJsonStr, authorStr, bKey, bTitle, bAuthor, bCover, bCoverUrl, bGenre, subStr: String;
  qry, innerQry: TCLJSONQuery;
  i: Integer;
{
  queryStr = SearchEdt.Text;
  if (queryStr == '')
  {
    if (GlobalBooksList <> nil) GlobalBooksList.Free;
    GlobalBooksList = Clomosy.StringListNew;
    FetchBooksFromFirebase;
    Exit;
  }
  
  for i = 1 to Length(queryStr) { if (Copy(queryStr, i, 1) == ' ') queryStr = Copy(queryStr, 1, i-1) + '+' + Copy(queryStr, i+1, Length(queryStr)); }
  if (GlobalBooksList <> nil) GlobalBooksList.Free;
  GlobalBooksList = Clomosy.StringListNew;
  CountLbl.Text = 'API Aranıyor...';
  
  GlobalFilterGenre = 'Tümü'; 
  FilterAllBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#D29054'); FilterAllBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#FFFFFF');
  FilterRomanBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterRomanBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterBilimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterBilimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterTarihBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterTarihBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterFelsefeBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterFelsefeBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterCocukBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterCocukBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterGelisimBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#F0EBE1'); FilterGelisimBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#000000');
  FilterAllBtn.SetclProSettings(FilterAllBtn.clProSettings); FilterRomanBtn.SetclProSettings(FilterRomanBtn.clProSettings); FilterBilimBtn.SetclProSettings(FilterBilimBtn.clProSettings); FilterTarihBtn.SetclProSettings(FilterTarihBtn.clProSettings); FilterFelsefeBtn.SetclProSettings(FilterFelsefeBtn.clProSettings); FilterCocukBtn.SetclProSettings(FilterCocukBtn.clProSettings); FilterGelisimBtn.SetclProSettings(FilterGelisimBtn.clProSettings);
  clRestAPI = TclRest.Create; 
  clRestAPI.BaseURL = 'https://openlibrary.org/search.json?q=' + queryStr + '&limit=15&fields=key,title,author_name,cover_i,subject'; 
  clRestAPI.Method = rmGET; clRestAPI.Accept = 'application/json'; clRestAPI.Execute;
  jsonResult = clRestAPI.Response; clRestAPI.Free;
  
  // İYİLEŞTİRME 4: Manuel String parçalama (Pos, Copy) yerine hızlı, çift aşamalı DataSet çözümlemesi yapılıyor.
  if (jsonResult <> '')
  {
     qry = Clomosy.ClDataSetFromJSON(jsonResult);
     if (qry <> nil)
     {
        docsJsonStr = qry.FieldByName('docs').AsString;
        qry.Free;
        
        if (docsJsonStr <> '')
        {
           innerQry = Clomosy.ClDataSetFromJSON(docsJsonStr);
           if (innerQry <> nil)
           {
              innerQry.First;
              while (not innerQry.Eof)
              {
                 bKey = innerQry.FieldByName('key').AsString;
                 if (Length(bKey) > 7) bKey = Copy(bKey, 8, Length(bKey));
                 
                 bTitle = innerQry.FieldByName('title').AsString;
                 
                 // Yazar dizisini güvenli ve hızlı çözümle
                 authorStr = innerQry.FieldByName('author_name').AsString;
                 bAuthor = 'Bilinmeyen Yazar';
                 if (authorStr <> '')
                 {
                    if (Copy(authorStr, 1, 2) == '["') {
                       bAuthor = Copy(authorStr, 3, Pos('"', Copy(authorStr, 3, Length(authorStr))) - 1);
                    } else {
                       bAuthor = authorStr;
                    }
                 }
                 
                 bCover = innerQry.FieldByName('cover_i').AsString;
                 bCoverUrl = '';
                 if (bCover <> '') bCoverUrl = 'https://covers.openlibrary.org/b/id/' + bCover + '-M.jpg';
                 
                 // Türleri ayrıştır
                 subStr = AnsiLowerCase(innerQry.FieldByName('subject').AsString);
                 bGenre = 'Roman';
                 if (subStr <> '')
                 {
                    bGenre = '';
                    if (Pos('science fiction', subStr) > 0) bGenre = bGenre + 'Bilim Kurgu, ';
                    if (Pos('history', subStr) > 0) bGenre = bGenre + 'Tarih, ';
                    if (Pos('philosophy', subStr) > 0) bGenre = bGenre + 'Felsefe, ';
                    if ((Pos('children', subStr) > 0) || (Pos('juvenile', subStr) > 0)) bGenre = bGenre + 'Çocuk, ';
                    if ((Pos('self-help', subStr) > 0) || (Pos('personal growth', subStr) > 0)) bGenre = bGenre + 'Kişisel Gelişim, ';
                    if ((Pos('fiction', subStr) > 0) || (Pos('novel', subStr) > 0) || (Pos('magic', subStr) > 0) || (Pos('fantasy', subStr) > 0)) bGenre = bGenre + 'Roman, ';
                    
                    if (bGenre == '') bGenre = 'Roman'; else bGenre = Copy(bGenre, 1, Length(bGenre) - 2);
                 }
                 
                 if (bKey <> '') GlobalBooksList.Add('{"id":"'+bKey+'","title":"'+bTitle+'","author":"'+bAuthor+'", "rating":"0", "color":"#2E4053", "summary":"OpenLibrary API Kaydı", "cover":"'+bCoverUrl+'", "genre":"'+bGenre+'"}');
                 innerQry.Next;
              }
              innerQry.Free;
           }
        }
     }
  }
  else
  {
     ShowMessage('Arama sonucu bulunamadı. Arşiv veritabanınıza geri dönülüyor.');
     SearchEdt.Text = '';
     if (GlobalBooksList <> nil) GlobalBooksList.Free;
     GlobalBooksList = Clomosy.StringListNew;
     FetchBooksFromFirebase;
     Exit;
  }
  
  DrawBooks;
}

https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
Emr.Erkmn Açılır Kutu İzle
Moderatör
Moderatör


Kayıt Tarihi: 28 Şubat 2025
Durum: Aktif Değil
Puanlar: 961
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Emr.Erkmn Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 18 Dakika Önce Saat 13:42
Tekrar Merhaba İBrahim 

Anakodun da yer alan kodlar için

her yeni bir kullanıcı kayıt olurken e-posta,tc gibi alanları daha önce kullanılıp kullanılmadığını kontrol etmek için firebase de kii tüm kullanıcıları ve tüm yöneticileri tamamen cihaza indiriyorsun bu inen veri yığını için de pos araması yapıyorsun bu yaptığın durum hem hız performansını hem de güvenlik açığı oluşturuyor.

db den 100 veya üzeri kullanıcı olduğunda bu sorgu da mb veri indirmeye çalışıyor bu hem hafıza hem de yüksek internet demek
tüm db nin telefona indirilmesi art niyetli kullanıcılar için özel alanların görebilmesi anlamına gelir

void ExecuteLogin;
var
  clRest: TclRest;
  EmailKey, responseStr: String;
  isAdmin: Boolean;
{
  EmailKey = EmailEdt.Text;
  
  // FİREBASE UYUMLULUĞU: E-postadaki noktaları alt çizgiye çevir
  while (Pos('.', EmailKey) > 0)
  {
    EmailKey = Copy(EmailKey, 1, Pos('.', EmailKey) - 1) + '_' + Copy(EmailKey, Pos('.', EmailKey) + 1, Length(EmailKey));
  }
  
  isAdmin = False;
  responseStr = '';
  
  clRest = TclRest.Create;
  try
    clRest.Accept = 'application/json';
    
    // 1. AŞAMA: Sadece bu e-posta adına sahip "Kullanıcı" verisini çek
    clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'.json';
    clRest.Method = rmGET;
    clRest.Execute;
    responseStr = clRest.Response;
    
    // 2. AŞAMA: Eğer kullanıcı bulunamadıysa, "Yönetici" tablosuna tekil istek at
    if ((responseStr == 'null') || (responseStr == ''))
    {
       clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'.json';
       clRest.Execute;
       responseStr = clRest.Response;
       if ((responseStr <> 'null') && (responseStr <> ''))
       {
          isAdmin = True;
       }
    }
  finally
    clRest.Free; // Bağlantıyı güvenle kapat
  }
  
  MainForm.FormWaiting.Visible = False; 
  
  if ((responseStr == 'null') || (responseStr == ''))
  {
    ShowMessage('Kayıtlı e-posta bulunamadı. Lütfen kayıt olun.');
  }
  else
  {
    if (Pos('"sifre":"'+PasswordEdt.Text+'"', responseStr) > 0)
    {
      Clomosy.GlobalVariableString = EmailKey;
      
      // Son giriş tarihini tekil olarak güncelle (Tüm veritabanı etkilenmez)
      clRest = TclRest.Create;
      try
        if (isAdmin)
           clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'/son_giris.json';
        else
           clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'/son_giris.json';
           
        clRest.Method = rmPUT;
        clRest.Accept = 'application/json';
        clRest.AddBody('"' + FormatDateTime('dd.mm.yyyy hh:nn:ss', Now) + '"', 'application/json');
        clRest.Execute;
      finally
        clRest.Free;
      }
      
      if (isAdmin)
         Clomosy.RunUnit('pGenel'); 
      else
         Clomosy.RunUnit('uKatalog'); 
    }
    else
    {
      ShowMessage('Hatalı şifre girdiniz.');
    }
  }
}


void ExecuteRegister;
var
  clRest: TclRest;
  EmailKey, jsonBody, tcVal, phoneVal, emailVal: String;
  isOk, isAdminReg: Boolean;
  emailUserExists, emailAdminExists, tcUserExists, tcAdminExists, phoneUserExists, phoneAdminExists: Boolean;
{
  tcVal = RegTCEdt.Text;
  phoneVal = RegPhoneEdt.Text;
  emailVal = RegEmailEdt.Text;
  isOk = True;
  EmailKey = emailVal; 
  while (Pos('.', EmailKey) > 0)
  {
    EmailKey = Copy(EmailKey, 1, Pos('.', EmailKey) - 1) + '_' + Copy(EmailKey, Pos('.', EmailKey) + 1, Length(EmailKey));
  }
  
  clRest = TclRest.Create;
  try
    clRest.Accept = 'application/json';
    clRest.Method = rmGET;
    
    // Normal kullanıcı e-posta kontrolü
    clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/' + EmailKey + '.json';
    clRest.Execute;
    emailUserExists = (clRest.Response <> 'null') && (clRest.Response <> '');
    
    // Yönetici e-posta kontrolü
    clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/' + EmailKey + '.json';
    clRest.Execute;
    emailAdminExists = (clRest.Response <> 'null') && (clRest.Response <> '');
  finally
    clRest.Free;
  }
  if (emailUserExists || emailAdminExists)
  {
    ShowMessage('Bu e-posta adresi zaten sistemde kayıtlı!');
    isOk = False;
  }
  
  if (isOk)
  {
    clRest = TclRest.Create;
    try
      clRest.Accept = 'application/json';
      clRest.Method = rmGET;
      
      // Kullanıcılar arasında TC sorgula
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users.json?orderBy="tc"&equalTo="' + tcVal + '"';
      clRest.Execute;
      tcUserExists = (clRest.Response <> 'null') && (clRest.Response <> '{}') && (clRest.Response <> '');
      
      // Yöneticiler arasında TC sorgula
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins.json?orderBy="tc"&equalTo="' + tcVal + '"';
      clRest.Execute;
      tcAdminExists = (clRest.Response <> 'null') && (clRest.Response <> '{}') && (clRest.Response <> '');
    finally
      clRest.Free;
    }
    
    if (tcUserExists || tcAdminExists)
    {
      ShowMessage('Bu TC Kimlik Numarası sistemde zaten kayıtlı!');
      isOk = False;
    }
  }
  if (isOk)
  {
    clRest = TclRest.Create;
    try
      clRest.Accept = 'application/json';
      clRest.Method = rmGET;
      
      // Kullanıcılar arasında Telefon sorgula
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users.json?orderBy="telefon"&equalTo="' + phoneVal + '"';
      clRest.Execute;
      phoneUserExists = (clRest.Response <> 'null') && (clRest.Response <> '{}') && (clRest.Response <> '');
      
      // Yöneticiler arasında Telefon sorgula
      clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins.json?orderBy="telefon"&equalTo="' + phoneVal + '"';
      clRest.Execute;
      phoneAdminExists = (clRest.Response <> 'null') && (clRest.Response <> '{}') && (clRest.Response <> '');
    finally
      clRest.Free;
    }
    
    if (phoneUserExists || phoneAdminExists)
    {
      ShowMessage('Bu telefon numarası sistemde zaten kayıtlı!');
      isOk = False;
    }
  }
  
  if (isOk)
  {
    isAdminReg = False;
    if (RegAdminCodeEdt.Text == '1453') 
    {
       isAdminReg = True;
    }
    
    jsonBody = '{"ad":"'+RegAdEdt.Text+'", "soyad":"'+RegSoyadEdt.Text+'", "yas":"'+RegAgeCombo.Text+'", "tc":"'+tcVal+'", "telefon":"'+phoneVal+'", "adres":"'+RegAddressMemo.Text+'", "sifre":"'+RegPasswordEdt.Text+'", "kayit_tarihi":"'+FormatDateTime('dd.mm.yyyy hh:nn:ss', Now)+'"}';
    
    clRest = TclRest.Create;
    try
      if (isAdminReg)
         clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/admins/'+EmailKey+'.json';
      else
         clRest.BaseURL = 'https://deneme-a6346-default-rtdb.firebaseio.com/users/'+EmailKey+'.json';
         
      clRest.Method = rmPUT;
      clRest.Accept = 'application/json';
      clRest.AddBody(jsonBody, 'application/json');
      clRest.Execute;
    finally
      clRest.Free; 
    }
    MainForm.FormWaiting.Visible = False; 
    RegMainPnl.Visible = False;
    
    if (isAdminReg)
      ShowMessage('SİSTEM YÖNETİCİSİ kaydınız başarıyla oluşturuldu! Lütfen giriş yapınız.');
    else
      ShowMessage('Kayıt işlemi başarıyla eklendi. Lütfen giriş yapınız.');
  }
  else
  {
    MainForm.FormWaiting.Visible = False; 
  }
}
https://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
ibrahimBsr Açılır Kutu İzle
Yeni Üye
Yeni Üye
Simge

Kayıt Tarihi: 23 Haziran 2026
Durum: Aktif Değil
Puanlar: 27
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (1) Teşekkürler(1)   Alıntı ibrahimBsr Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 2 Saat 6 Dakika Önce Saat 13:54
Sorunum çözülmüştür uygulama şuan istediğim hızda çalışıyor teşekkür ederimhttps://static.cloudflareinsights.com/beacon.min.js/v4513226cdae34746b4dedf0b4dfa099e1781791509496" integrity="sha512-ZE9pZaUXND66v380QUtch/5sE9tPFh2zg45pR2PB0CVkCtOREv2AJKkSidISWkysEuQ0EH8faUU5du78bx87UQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">
Yukarı Dön
 Yanıt Yaz Yanıt Yaz

Forum Atla Forum İzinleri Açılır Kutu İzle

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.

Bu Sayfa 0,078 Saniyede Yüklendi.