RgIQJU)EmTZE'iEqFzA>)TQ3H#TLqIjNT&ChX\nTK\00005JH\0FE@'љFphS5F\"oѮe%aoS E) DUQFmѣMѲe(tn U1ܣ~>\$ǂ(hǑGy`\0 G35Sp(PG\$# N\nV\$]ԜP=\"RӨ?Lzt1L\$\0G~,KN=GMNS)O]:ԊS}81RGe@C\0OPSN1T!P@SSG`\n:Pj7R @3\n DӠL \0Q5CPSMPv4?h hTD0֏>&ITxO?@UR8@%ԖKNKRyEE# @%LQQ?N5\0R\0ԁTFԔRS!oTEC(ĵ\0?3iSS@UQeM K\n4PCeS\0NCPO!\"RTSNU5OU>UiIPU#UnKPUYT*CU/\0+):ReA\$\0xWD3`U5IHUY:P e\0MJiQ>@TC{u?^v\0WR]U}C1-5+U?\rW5JU-SXL \\t?sMbՃV܁tT>MU+ Ec9Nm\rRǃC8SX'RXjCI#G|!QGhtQ )gչTVoUTZN*T\\*S-pSVqM(Q=\\-UUUVCZ\nuV\$?M@UWJ\r\rU\\'UW]WW8N'#h=oCF(:9YuV-U9]C:U\\\nqW(TT?5P\$ R3⺟C}`>\0E]#R #R)W:`#G)4R;ViD%8)Ǔ^Q#h HX \$Nx#i xԒXR'9`m\\\nEQ`bu@NdT#YYGV]j5#?Lxt/##酽OPQ6^ M\\R5tӚp*XV\"WD oRALm\rdGN 6p\$P废E5Tx\n+C[V8UDu}ػF\$.Q-;4ȀNX\n.Xb͐\0b)#NG4KZS^״M8d\"C>dHe\nY8. ҏFDW1cZ6QKH@*\0^\\QF4U3Y|=ӤEۤ?-47YPmhYw_\rVeױMُe(0F\r!PUIu7QCю?0gu\rqधY-Q=g\0\0M#US5Zt֟ae^\$>ArV_\r;tHWZ@HhzD\0S2J HIO'ǁeg6[R /KM\n>HZ!iTX6iC !ӛg G }Q64>w!ڙC}VB>UQڑj8cUT'<>HC]V7jj3v`023x@Uk\n:Si5#Y-wM?cMQGQуb`\0@ҧ\0M)ZrKX֟WllTMD\r4QsS40sQ́mYhdC`{VgE\nXkՁ',4^6#<4NXnM):OM_6d[\"KUn?lx\0&\0R56T~>ո?Jn Z/i6glͦUF}.JLCTbM4cLTjSD}JtZ:Ld:Ezʤ>V\$2>[p6R9uW.?1RHuR?58ԮDupcZ?r Eaf}5wYϒWwT[Sp7'_aEk\"[/i#\$;mfأWOF\r%\$ju-t#<!\n:KEA]\nUQKE#X5[>`/D֭VEp)I%qnx):le[e\\eV[j7 -+GWEwtWkE~uQ/m#ԐW`yuǣDA'ױ\rՙOD )ZM^u-|v8]ghLW\06X=YdQ7ϓ9r <֏DB`c9`D=wxI%,ᄬj[њO ``|. AO @@ 0h2\\ЀM{e9^>@7\0˂W\$,Ś@w^fm,\0yD,ם^X.ֆ72f;6\n^zCקmzn^&LFF,[eaXy9h!:z9cQ9b !Gw_Wg9S+tptɃ\nm+_ \\k5]4_h9 N]%|7֜];|X9|G[\0}UMCI:qOVԃa\0\rR6π\0@HP+rSWp7I~p/H^E-%̻&.+Jђ;:!N ~/W!BL+\$q=+`/Ƅe\\xpElpSJSݢ6_(ůb\\O&\\59\09nD{\$Kv2 d]vC?tf|W:p&Ln賞{;GR9T.yI8\rl Tn3T.93ZsG: 0z.]ģQ?gT%xՌ.n<-8B˳,BrgQɎ`2:{gsgZ <w{bU9 `5`4\0BxMp8qnah@ؼ-(>S|038h\0CzLQ@\n?`A>2,N&xl8sah1|BɇDxB#VV`Wa'@ X_?\n _. Pr2bUarI~S\0ׅ\"2>b;vPh{[7a`\0˲jo~v|fv4[\${P\rvBKGbpO5ݠ2\0jلL)mVejBB.'R{CV'` %ǀ\$O\0`4 N>;4/π*\\5!`X*%N3SAMƔ,1\\caϧ @˃B/0`v2`hDJO\$@p!9!\n17pB,>8F4fπ:733T8=+~n\\e
6ONn!;@tw^FL;,^a\ra\"ڮ':vJe4א;_d\r4\r:S2[cXʦPl\$ޣiwd#Bb`:~ <\02RP\rJ8Dt@E\0\r͜67Y\"\r3.+z3;_ʟvLwJ94IJa,A;s?N\nR!ݐOms_-zۭwzܭ7zMo\0aݹ48PfY?ieBS1\0jDTeKUYS?66R c6Ry[c5]B͔R_eA)&[凕XYRW6VYaeUfYewUbwEʆ;z^W9קݖ\0<ޘe9Sda _-L8DžQTH[!Aa\ry0iJ}z:\r)S@h@YmCEgcyφ&F)}biOi:dAnc=L9Oh{ 8hY.\rև1QU CheO+2oNzp(]hZ|OczD;T\0j\08#>Ύ=bZ8Fj;T酡w)N`ÅB{z\rc|dTGi/!i0'`Z:CH(8`V\0ꧩWǪzgG-[ iN\rqno ƥfEJapb}6=o,tY+EC\rPx4=@.F[zqX6:FG#\$@&abhE:`S11g12uhY_:Bߡdc*\0ƗFYF:n=ۨH*ZMhk/냡zٹ]h@1\0ZK^+,vfs>O|s\0֜5XѯFnAr]|Ii4 C h@عcߥ6smOgXV26g?~YѰscl \\R\0cA+1\n(^368cz:=z( ;裨sF@`;,>yT&dLן%-CHL8\rbMj]4Ym9ZBP}<X̥+g^M + B_FdXlw~\r⽋\":qA1X3ΓEh4ZZ&1~!Nfo\nMeXI΄G@V*X;Y5{V\nTz\rF3}mp1[>tew@Vz#2 i{9p̝gh+[elUAٶӼi1!omm*K}!Ƴ{mef`mCz=n:}g TmLu1F}=8ZOmFFMfOO/ޓVoqjn!+ZI.9!nG\\3a~O+::K@\n@Hph\\BdmfvCP\" .nW&nHY+\rzi>MfqۤQc[H+o*1'#āEwD_X)>s-~\rT=- ym{hjM)^'@V+i;FD[b!B :MPۭoCvAE?CIiY#pP\$kJq.07xlsC|bo2X>M\rl&:2~cQod-URoYnM;n#\0PfPo(Cv<[o۸fѿ;ẖ[Y.oUppU.B!'\0@DY`o<>pķq,Y1Q߸/qg\0+\0D? k:\$ץ6~I=@!vzO+9iag?0Gnq]{Ҹ,FO <_>f+, &·yǩO:U¯L\núI:2-;_Ģ|%崿!f\$Xr\"Kni\$8#gt-r@L圏@S#3268sh٠ƑI1Sn20-42As(4˶\0#rK'ͷG'7&\n>xJGO8,08\0W9I?:3n\r-w:;3ȉ!;ꃘZRM+>0/=R'148m%ȥ}χ9;=nQ=hhLGkW\r %4ҜsΖJ3s4@U%\$N;?4N2|Z3h\035^xi2d\r|Mʣbh|#v` \0ꐮ\$\r2h#?I\n+o-?6`ṽ.\$KY%J?cRN#K:KEL>:@jPn_t&slm'ЩɸӜ;6ۗHU5#Q7UWYU bNW_;TC[<ږ>WCU6X#`MI:tӵ u#`fu\$tX`f<;bgh97S58#^-\0չR*'(qZ壣XQFUvW GWTW~ڭ^WJ=_ؗbmbV\\l/MTmTOXu=_ITvvua\rL_qR/]]msu=H=ug o\\UՅgM XVU%h53U\\=QMvgmuehbMGCeO5ԁO5Yi=e GTURvOa*ivWXJ5NUdk5hPmu[\0_[Y-r(CrMeJ!h?QrX3 x#x<{u5~-uYyQ\r-\0uգuuٿpUڅ)P\rU7mӂz=1+mI,>X7].* ^N./\") s|ӟl}!5npjh}mEzHaO0d=A|w߳uvGx#bcSo-tOm`C^M@hn\$k``HD^PE[]rRm=.ه>Ayi \" o-,.\nq+fXd*߽K' %a9pKLM!,zX#VuH%!63JryՁq_u W|@3b17|~wﱳA7 9cS&{%VxkZOwUr?N |C#Űկ /9ftEwCa^\0O9GjczA͎:an0bJ{o!3!'K}\\3W5xL;2ζna;Xӛ]ox{5ޙjXvӚqEE{р4{ \n>aﯷL'{\n>JߌӗY\rOʽt-O49F;GIF1oOa{w0Ư;loJTb\rw2J=D#n:yS^,.?(I\$Ư3s4MaCRG̑I߰n^\\{n\\7ٟic1hoo?j[WX{qaϤ.&N3]HY[&8?3݆#Be6@[G\r+}_7|N4~(z~%?[1S]xkKxO^ArZ+*WkwD(R:\0'm!O\nu.[ P!}m 1pu,TL 0}&P٥\n=D=\rA/o@2t6DK\0q7lB(;[kr\r;#lŔ\r<}zb+O[WrX`Z ţPm'FnSp-\0005`dPǾ;n\05fPEJw .?;Nޥ,;Ʀ-[7ei-dَ<[~6k:&.7]\0/59 @eT:煘3dsݝ5䏜5f\0PHB8JLS\0vI\07Dma3e?B\$.Ef@nbGbq3|PaˈϯX7Tg>.p5AHŵ3S,@#&w3m[Iѥ^̤J1?gTၽ#S=__ Vq/C۾݀|D g>܄ 6\r7}qŤJGB^\\g&%[2Ixì6\03]3{@RUMv<1szuP5F:i|`qV| \nk}'|gd!8 <,P7m||IA]BB F0X D`WqmOL .(pҁ\"!\0AV7kM\$N0\\\"f\0uq,5A6p\nΐjY7[pK4;l5n@\\fl MP3CHbЌcEpP4eooe{\r-2.֥P50uG}\0<\r!~\n7Fd>a%c6ԞM|dO_?JC0>Ё&7kM4`%flΘB~wxZGP20=*p@BeȔ|2\r?q8Њ(yr0>>E?w|r]%Av@+XAgsCAXmNҝ4\0\r8JJǸDҚ:= S4F; \\&P!6%\$ixi4c0B;62=1̈PCmdpc+5\$/rCR`MQ6(\\2A\\lGl\0BqPrBт_6Ll!BQIGXRbs]BHr`X\$p8 nbR,±L\"E%\0aYBsD,!ϛpN9RbG4MtjUy\0%\$.iL!xғ(.)6T(Ia%K]mt&G7ITMB\rza])va%41Tj(!\\\\W\\t\$0%\0aK\$TF(YC@HHnDdWphZ'ZC,/\$JFBuܬQ:ΥA:-a#=jblUg;{RUEWnUaVNjuG*yֹ%@*Yx_z])v\"RLVIv=`'U) S\r~R\ni)5SD49~b;)3,9M3HsJkTÜ(uJ][\$ufob\n.,Yܵ9j1'!1\$Jgڤ՟ĆU0ZuahcH,YtKb55/dYAU҅[W>_V\r*j-T zYdcmҹ:[Ut-{l i+a).[_:5hW§m%JI[Th>;X̺dSdV;\rƱ!NK&AJu4Bdg.Vpmb)V!U\0G丨`\\q7QbVL:ՂZ.N*ԏU]ZlzR D1I£r:\0<1~;#JbMy+۔/\"ϛj<3#̌:P.}eD\"qyJGsopX\rd\rxJ%ƼO:%yy,%{3\"-:FIك*@ԟyT\\UY~3Df,s8HV't9v(:B9\\Z(&E8W\$X\0\n9WBb66j9 ʈ?,| ag1\nPs\0@%#K\r\0ŧ\00?š,\0hh\08\0l\0-ZjbŬ\0p\0-f`ql0\0i-\\ps7e\"-ZlbE,\0]P Eb\0/,Z\r\0000[f-@\rӯEڋ/Z8~\"ڋ.^Qwϋ\0/t_ȼE\00d]bŤ|\0\\ؼE\0af0tZnJ\0l\00L^Qj@J^q#F(1/[1I.^8\0[q[Ñl\" \00,d\rc{cE\0o0]\0\rc%ۋ8wZ-\\{G/\\bp@1\0a1s!Ũ//]8~c\"ۋ2cΑm\"9q/\\^fQ~c_-\$i\"\0003fXqx#\09Z.i@F3tZH \rcKb\0j/Dj1IhavƩOZ4Zт#YE\0i.hHsX/F<.jb\0mV/d\\bE3T^(шcKFR]Xq6]hc6Eċ66hn\0005sn/dn`\r\"F-D`ՑN2Ybx#\\닇V3x1xFx\06bq!8|^ub-rq:%0pp#\06fǢŬd0qH\$@q-^B4\"\081/lnxϑG3:0tjh~@Ƽ3vHbG(e4gغq21-nX\"F4i\n<{㑍ƉJ;]1#0J;4^DǮ4i(H#Ex/n1/ǡj6,l1t/\0005%0]xGG5!0rq2ޑNFPo\"4_1d%e 3s8G5 6[HcHjY;[辑b! y@\\q#WHN;cQ:-%.kXƑG͌1DfߑcWFl!0c Eܐ;lq\"F7\\\\Oq.T|\"?Ef9TyYѩSG1A\$f9R\n\"x>BHߤ\0:\$e1F?=3Tu)\nqb~Y4^QjcK1\"8|6c\"B\"b4%G\0e\"/t1r1e!v2y<Ǡ8\\oђ#tѐ\rz@}Hby 1\\deGZ3~r)1ȿBl~H:dF-?k8qc(F͋K5|myc1<*@j1ž>IZQj2\$0hQVFT \$Al~qڣȱ\$>\\p\rq\$/u%!Jq \$tEGN-Tq)\"Hʌ=X2-H8\\nRW\$H\"C\\_\0d\$f\".Du 'QzE&0toqjƿR@du##LLk*q\$*Gđi@TilE5r\\dI\"/Z0j\$Tz5Ld3o.Tq!1{9ZQbFwJ94n{(-82hu;\$-DkrsH#Y7\"/E \$j^-]7[\"N\$W/]\$+1Ga/&IDn@\$!\$-k!Q)(N/\$tOKzPtX[\0Gw(*K\$v1c'G̞Ixd\nA8\\rXaIiNI%\$_6fQ#I5#Fغ#E⒕\"3\$IcHvR|QcE:RehEΏfK`8r.#Es0LRF!\nC\$`\$H?nPe!@F'/%N,hrF\$3tҀ!1µa-'U%w*#>@̬eJ;Pw/+5E\rjnd^[cΰuz\\ؐ1mi\"xp;P)#ؒ!A; 4a{`aV{KU8㨟0''o2yc̸9]K@җ^lBOr,du8?%gBYn+%ce\0ऱYr@f(]ּ\nbiznSS2GdBPj@(ȥ!-ve*c\04J炒,U dej'TH]ԊG!)u֯үZB5̓W0\nRW\\Q j^r%l3,Yyf3&Q:ϵ2mR)T(KR0ʔ@YY:e3\r%T%XST.J\\0hąD!:uU\"Ło+7\"f'R\0J2S2#nm I劜\"X[ր} Jc9p0Q(U\0xDEW.L=ti'Gl%\08VBU1ye\0KT4mV2)\r]I/\rFXߨaG¹*>ERZ-)I\$:a\0Fybagw(_@v}iʳS^25DԳ UROJH\\isfKNqiSgO\nF~|*@gR_Q<9sܬ3i+ؗ.Cw|y6aOY9ɖ\nԽ-([_}S]cS=YU-><\n\\ZY췢wEJ%sLdy+\rCߡ'Al,y3͗` _*P ThKDV~5 0+,-?]3֍K`^I42(]w.r]\nYƨB }ЋR g}:HJWP\"V\\ >ܬ݆=:\n0\\+SfUU,WCֈOn΅.e9|RI'[/2QBn:I\ng9\r,R6Q\$X+>`\n)/_8Qi=v?5v\0 \nLGDmw\\FѢdꟵ}s\"Yv|J*9h@XEU*(oQ]\$B,KTvAptCɃ\nC,/<ڙEW-VP=W*%K-Q`9 (59Ӏm)X@2T@\nSbdEδa+DX|U F 2%5\njmW+xKV3#CTek&,ljbd7)ӓ\"\n+PbI@3ܵjUEs)Df뒃PZ3AΌ\nwTh𗲪ۘ4Z+J[6J\0֗\\,K3.]a_\0RJ Ɨ`^ԶClRIK\n\$nŏKj\n~/mn].`ij#Kf:`\0錀67K▨zc\0/K/dFE\0aLdZ`JSʙ24@/(L0`ĩ_L]4ZhЩSDM4:cSRME4iSGEMj4zdթSFKL%4e%\$lKM21ڔiMV.ڔiLz/ۣӄM,`_imSgMƜjg59.9j_S.9_S.7r)%[2m8uTS3M:]3qnӱKN1|^kt\"HgKj-;zciӚ\r<_-iӸ\"֞U.iRڑkOF=:\\\$ZөMLE5xӻ_\"֜=<\0tS9OҞ1~iO>~q)F=6:~JP:=T)ƫPJ8@w*O5]>tT\n!\"6Y )H/P3 /P~ Ӯ!\"Cj eNJ*%41QCZQjTBQ.\rE)\0004\$2SM+gSD5MRHwU\"K8RڌU*-U*n¾TIR,tZYIUF51W)vk_KƫpJ5ZjůR4r\n^jICK}Uʓ_ԛO=NR*F-R%Wc\\aV>EYjdëUάWX5*ՋUyZ1kը7VR\\H5h*UUƧM[kvո3V}[(5WzոiBO1TV;[pRGu;T@0>\0/IW`]\08P]1m*ǍyUzmW|ݓ[֯]JшUZ*5\\jZ`Z5~EW4Z5hQ^cXZS1oVU&T5}cU^Xdm*kUuSfG=[jsտXKc\niRHi#uWtXcĹUrڢUZՇNEX4udEeV^KnV8sX¥f/hJ-J]ӂzON\")]b +z.cS.iF QNQV*O[XnxP koN}gڜϦVTZjhYjkD*!h&Xzi+GV\"Z:Ҥ+NoGZjji]ʞkO_֬ԐmjIt#[j\rnnZ_,gĚ:9[L2W=T0f\0PU6\ns%7isY?u3nb5X|G~l&kMyS)]ܭrٸ?}u'n0W-ιbǪk?vQ7}p\nٮZ*9)5ޕZW-ZB:㫊W\0WZfpGpٮ:FpUSN/\\%s9S{ 8Zasۓ+N^9M{P5 QJy;zYV 3:DI+19M;V\rQ{ծ+FCLĹNԈ\\)\$iN'\0P]X^s1f&\"'`/fPEi\0kv\0fhS0&¦lͼ#fu5 i%:Fd9G< {}s[7\0Ξ3ft:+.Ȕp>ձ@!Pas6q,1bǬŋZK-ar`?RxX鑡V#Ĥz; DH16D`Y`RP>-!\$~π`>h01&\0hIwlZ\$\\\r8~,\no_B2Da1ǩ=v*Y\n\n![mj0,muW@ FX=(b@Wr!LHk\rE\nW\r'FH\$m=ۥ{LY&_\0#䔀[9\0\"@8iK0lp\ng'qbFycl@9(#JUݲ{io.{ͳ4V́VnFxz Qޞ\$kSa~ʨ0s@%y@5HNͦ@x# ܫ /\\?$_POST["signature"],"version"=>$_POST["version"])));exit;}global$b,$g,$m,$ec,$mc,$wc,$n,$kd,$qd,$ba,$Rd,$x,$ca,$me,$qf,$bg,$Hh,$vd,$oi,$ui,$U,$Ii,$ia;if(!$_SERVER["REQUEST_URI"])$_SERVER["REQUEST_URI"]=$_SERVER["ORIG_PATH_INFO"];if(!strpos($_SERVER["REQUEST_URI"],'?')&&$_SERVER["QUERY_STRING"]!="")$_SERVER["REQUEST_URI"].="?$_SERVER[QUERY_STRING]";if($_SERVER["HTTP_X_FORWARDED_PREFIX"])$_SERVER["REQUEST_URI"]=$_SERVER["HTTP_X_FORWARDED_PREFIX"].$_SERVER["REQUEST_URI"];$ba=($_SERVER["HTTPS"]&&strcasecmp($_SERVER["HTTPS"],"off"))||ini_bool("session.cookie_secure");@ini_set("session.use_trans_sid",false);if(!defined("SID")){session_cache_limiter("");session_name("adminer_sid");$Of=array(0,preg_replace('~\?.*~','',$_SERVER["REQUEST_URI"]),"",$ba);if(version_compare(PHP_VERSION,'5.2.0')>=0)$Of[]=true;call_user_func_array('session_set_cookie_params',$Of);session_start();}remove_slashes(array(&$_GET,&$_POST,&$_COOKIE),$Vc);if(get_magic_quotes_runtime())set_magic_quotes_runtime(false);@set_time_limit(0);@ini_set("zend.ze1_compatibility_mode",false);@ini_set("precision",15);function
get_lang(){return'en';}function
lang($ti,$hf=null){if(is_array($ti)){$eg=($hf==1?0:1);$ti=$ti[$eg];}$ti=str_replace("%d","%s",$ti);$hf=format_number($hf);return
sprintf($ti,$hf);}if(extension_loaded('pdo')){class
Min_PDO
extends
PDO{var$_result,$server_info,$affected_rows,$errno,$error;function
__construct(){global$b;$eg=array_search("SQL",$b->operators);if($eg!==false)unset($b->operators[$eg]);}function
dsn($jc,$V,$E,$yf=array()){try{parent::__construct($jc,$V,$E,$yf);}catch(Exception$Ac){auth_error(h($Ac->getMessage()));}$this->setAttribute(13,array('Min_PDOStatement'));$this->server_info=@$this->getAttribute(4);}function
query($F,$Ci=false){$G=parent::query($F);$this->error="";if(!$G){list(,$this->errno,$this->error)=$this->errorInfo();if(!$this->error)$this->error='Unknown error.';return
false;}$this->store_result($G);return$G;}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result($G=null){if(!$G){$G=$this->_result;if(!$G)return
false;}if($G->columnCount()){$G->num_rows=$G->rowCount();return$G;}$this->affected_rows=$G->rowCount();return
true;}function
next_result(){if(!$this->_result)return
false;$this->_result->_offset=0;return@$this->_result->nextRowset();}function
result($F,$o=0){$G=$this->query($F);if(!$G)return
false;$I=$G->fetch();return$I[$o];}}class
Min_PDOStatement
extends
PDOStatement{var$_offset=0,$num_rows;function
fetch_assoc(){return$this->fetch(2);}function
fetch_row(){return$this->fetch(3);}function
fetch_field(){$I=(object)$this->getColumnMeta($this->_offset++);$I->orgtable=$I->table;$I->orgname=$I->name;$I->charsetnr=(in_array("blob",(array)$I->flags)?63:0);return$I;}}}$ec=array();class
Min_SQL{var$_conn;function
__construct($g){$this->_conn=$g;}function
select($Q,$K,$Z,$nd,$_f=array(),$z=1,$D=0,$mg=false){global$b,$x;$Yd=(count($nd)selectQueryBuild($K,$Z,$nd,$_f,$z,$D);if(!$F)$F="SELECT".limit(($_GET["page"]!="last"&&$z!=""&&$nd&&$Yd&&$x=="sql"?"SQL_CALC_FOUND_ROWS ":"").implode(", ",$K)."\nFROM ".table($Q),($Z?"\nWHERE ".implode(" AND ",$Z):"").($nd&&$Yd?"\nGROUP BY ".implode(", ",$nd):"").($_f?"\nORDER BY ".implode(", ",$_f):""),($z!=""?+$z:null),($D?$z*$D:0),"\n");$Dh=microtime(true);$H=$this->_conn->query($F);if($mg)echo$b->selectQuery($F,$Dh,!$H);return$H;}function
delete($Q,$wg,$z=0){$F="FROM ".table($Q);return
queries("DELETE".($z?limit1($Q,$F,$wg):" $F$wg"));}function
update($Q,$N,$wg,$z=0,$L="\n"){$Vi=array();foreach($N
as$y=>$X)$Vi[]="$y = $X";$F=table($Q)." SET$L".implode(",$L",$Vi);return
queries("UPDATE".($z?limit1($Q,$F,$wg,$L):" $F$wg"));}function
insert($Q,$N){return
queries("INSERT INTO ".table($Q).($N?" (".implode(", ",array_keys($N)).")\nVALUES (".implode(", ",$N).")":" DEFAULT VALUES"));}function
insertUpdate($Q,$J,$kg){return
false;}function
begin(){return
queries("BEGIN");}function
commit(){return
queries("COMMIT");}function
rollback(){return
queries("ROLLBACK");}function
slowQuery($F,$fi){}function
convertSearch($u,$X,$o){return$u;}function
value($X,$o){return(method_exists($this->_conn,'value')?$this->_conn->value($X,$o):(is_resource($X)?stream_get_contents($X):$X));}function
quoteBinary($Yg){return
q($Yg);}function
warnings(){return'';}function
tableHelp($B){}}$ec["sqlite"]="SQLite 3";$ec["sqlite2"]="SQLite 2";if(isset($_GET["sqlite"])||isset($_GET["sqlite2"])){$hg=array((isset($_GET["sqlite"])?"SQLite3":"SQLite"),"PDO_SQLite");define("DRIVER",(isset($_GET["sqlite"])?"sqlite":"sqlite2"));if(class_exists(isset($_GET["sqlite"])?"SQLite3":"SQLiteDatabase")){if(isset($_GET["sqlite"])){class
Min_SQLite{var$extension="SQLite3",$server_info,$affected_rows,$errno,$error,$_link;function
__construct($Uc){$this->_link=new
SQLite3($Uc);$Yi=$this->_link->version();$this->server_info=$Yi["versionString"];}function
query($F){$G=@$this->_link->query($F);$this->error="";if(!$G){$this->errno=$this->_link->lastErrorCode();$this->error=$this->_link->lastErrorMsg();return
false;}elseif($G->numColumns())return
new
Min_Result($G);$this->affected_rows=$this->_link->changes();return
true;}function
quote($P){return(is_utf8($P)?"'".$this->_link->escapeString($P)."'":"x'".reset(unpack('H*',$P))."'");}function
store_result(){return$this->_result;}function
result($F,$o=0){$G=$this->query($F);if(!is_object($G))return
false;$I=$G->_result->fetchArray();return$I[$o];}}class
Min_Result{var$_result,$_offset=0,$num_rows;function
__construct($G){$this->_result=$G;}function
fetch_assoc(){return$this->_result->fetchArray(SQLITE3_ASSOC);}function
fetch_row(){return$this->_result->fetchArray(SQLITE3_NUM);}function
fetch_field(){$e=$this->_offset++;$T=$this->_result->columnType($e);return(object)array("name"=>$this->_result->columnName($e),"type"=>$T,"charsetnr"=>($T==SQLITE3_BLOB?63:0),);}function
__desctruct(){return$this->_result->finalize();}}}else{class
Min_SQLite{var$extension="SQLite",$server_info,$affected_rows,$error,$_link;function
__construct($Uc){$this->server_info=sqlite_libversion();$this->_link=new
SQLiteDatabase($Uc);}function
query($F,$Ci=false){$Re=($Ci?"unbufferedQuery":"query");$G=@$this->_link->$Re($F,SQLITE_BOTH,$n);$this->error="";if(!$G){$this->error=$n;return
false;}elseif($G===true){$this->affected_rows=$this->changes();return
true;}return
new
Min_Result($G);}function
quote($P){return"'".sqlite_escape_string($P)."'";}function
store_result(){return$this->_result;}function
result($F,$o=0){$G=$this->query($F);if(!is_object($G))return
false;$I=$G->_result->fetch();return$I[$o];}}class
Min_Result{var$_result,$_offset=0,$num_rows;function
__construct($G){$this->_result=$G;if(method_exists($G,'numRows'))$this->num_rows=$G->numRows();}function
fetch_assoc(){$I=$this->_result->fetch(SQLITE_ASSOC);if(!$I)return
false;$H=array();foreach($I
as$y=>$X)$H[($y[0]=='"'?idf_unescape($y):$y)]=$X;return$H;}function
fetch_row(){return$this->_result->fetch(SQLITE_NUM);}function
fetch_field(){$B=$this->_result->fieldName($this->_offset++);$ag='(\[.*]|"(?:[^"]|"")*"|(.+))';if(preg_match("~^($ag\\.)?$ag\$~",$B,$A)){$Q=($A[3]!=""?$A[3]:idf_unescape($A[2]));$B=($A[5]!=""?$A[5]:idf_unescape($A[4]));}return(object)array("name"=>$B,"orgname"=>$B,"orgtable"=>$Q,);}}}}elseif(extension_loaded("pdo_sqlite")){class
Min_SQLite
extends
Min_PDO{var$extension="PDO_SQLite";function
__construct($Uc){$this->dsn(DRIVER.":$Uc","","");}}}if(class_exists("Min_SQLite")){class
Min_DB
extends
Min_SQLite{function
__construct(){parent::__construct(":memory:");$this->query("PRAGMA foreign_keys = 1");}function
select_db($Uc){if(is_readable($Uc)&&$this->query("ATTACH ".$this->quote(preg_match("~(^[/\\\\]|:)~",$Uc)?$Uc:dirname($_SERVER["SCRIPT_FILENAME"])."/$Uc")." AS a")){parent::__construct($Uc);$this->query("PRAGMA foreign_keys = 1");return
true;}return
false;}function
multi_query($F){return$this->_result=$this->query($F);}function
next_result(){return
false;}}}class
Min_Driver
extends
Min_SQL{function
insertUpdate($Q,$J,$kg){$Vi=array();foreach($J
as$N)$Vi[]="(".implode(", ",$N).")";return
queries("REPLACE INTO ".table($Q)." (".implode(", ",array_keys(reset($J))).") VALUES\n".implode(",\n",$Vi));}function
tableHelp($B){if($B=="sqlite_sequence")return"fileformat2.html#seqtab";if($B=="sqlite_master")return"fileformat2.html#$B";}}function
idf_escape($u){return'"'.str_replace('"','""',$u).'"';}function
table($u){return
idf_escape($u);}function
connect(){global$b;list(,,$E)=$b->credentials();if($E!="")return'Database does not support password.';return
new
Min_DB;}function
get_databases(){return
array();}function
limit($F,$Z,$z,$C=0,$L=" "){return" $F$Z".($z!==null?$L."LIMIT $z".($C?" OFFSET $C":""):"");}function
limit1($Q,$F,$Z,$L="\n"){global$g;return(preg_match('~^INTO~',$F)||$g->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')")?limit($F,$Z,1,0,$L):" $F WHERE rowid = (SELECT rowid FROM ".table($Q).$Z.$L."LIMIT 1)");}function
db_collation($l,$pb){global$g;return$g->result("PRAGMA encoding");}function
engines(){return
array();}function
logged_user(){return
get_current_user();}function
tables_list(){return
get_key_vals("SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view') ORDER BY (name = 'sqlite_sequence'), name");}function
count_tables($k){return
array();}function
table_status($B=""){global$g;$H=array();foreach(get_rows("SELECT name AS Name, type AS Engine, 'rowid' AS Oid, '' AS Auto_increment FROM sqlite_master WHERE type IN ('table', 'view') ".($B!=""?"AND name = ".q($B):"ORDER BY name"))as$I){$I["Rows"]=$g->result("SELECT COUNT(*) FROM ".idf_escape($I["Name"]));$H[$I["Name"]]=$I;}foreach(get_rows("SELECT * FROM sqlite_sequence",null,"")as$I)$H[$I["name"]]["Auto_increment"]=$I["seq"];return($B!=""?$H[$B]:$H);}function
is_view($R){return$R["Engine"]=="view";}function
fk_support($R){global$g;return!$g->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");}function
fields($Q){global$g;$H=array();$kg="";foreach(get_rows("PRAGMA table_info(".table($Q).")")as$I){$B=$I["name"];$T=strtolower($I["type"]);$Tb=$I["dflt_value"];$H[$B]=array("field"=>$B,"type"=>(preg_match('~int~i',$T)?"integer":(preg_match('~char|clob|text~i',$T)?"text":(preg_match('~blob~i',$T)?"blob":(preg_match('~real|floa|doub~i',$T)?"real":"numeric")))),"full_type"=>$T,"default"=>(preg_match("~'(.*)'~",$Tb,$A)?str_replace("''","'",$A[1]):($Tb=="NULL"?null:$Tb)),"null"=>!$I["notnull"],"privileges"=>array("select"=>1,"insert"=>1,"update"=>1),"primary"=>$I["pk"],);if($I["pk"]){if($kg!="")$H[$kg]["auto_increment"]=false;elseif(preg_match('~^integer$~i',$T))$H[$B]["auto_increment"]=true;$kg=$B;}}$zh=$g->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ".q($Q));preg_match_all('~(("[^"]*+")+|[a-z0-9_]+)\s+text\s+COLLATE\s+(\'[^\']+\'|\S+)~i',$zh,$De,PREG_SET_ORDER);foreach($De
as$A){$B=str_replace('""','"',preg_replace('~^"|"$~','',$A[1]));if($H[$B])$H[$B]["collation"]=trim($A[3],"'");}return$H;}function
indexes($Q,$h=null){global$g;if(!is_object($h))$h=$g;$H=array();$zh=$h->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ".q($Q));if(preg_match('~\bPRIMARY\s+KEY\s*\((([^)"]+|"[^"]*"|`[^`]*`)++)~i',$zh,$A)){$H[""]=array("type"=>"PRIMARY","columns"=>array(),"lengths"=>array(),"descs"=>array());preg_match_all('~((("[^"]*+")+|(?:`[^`]*+`)+)|(\S+))(\s+(ASC|DESC))?(,\s*|$)~i',$A[1],$De,PREG_SET_ORDER);foreach($De
as$A){$H[""]["columns"][]=idf_unescape($A[2]).$A[4];$H[""]["descs"][]=(preg_match('~DESC~i',$A[5])?'1':null);}}if(!$H){foreach(fields($Q)as$B=>$o){if($o["primary"])$H[""]=array("type"=>"PRIMARY","columns"=>array($B),"lengths"=>array(),"descs"=>array(null));}}$Bh=get_key_vals("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = ".q($Q),$h);foreach(get_rows("PRAGMA index_list(".table($Q).")",$h)as$I){$B=$I["name"];$v=array("type"=>($I["unique"]?"UNIQUE":"INDEX"));$v["lengths"]=array();$v["descs"]=array();foreach(get_rows("PRAGMA index_info(".idf_escape($B).")",$h)as$Xg){$v["columns"][]=$Xg["name"];$v["descs"][]=null;}if(preg_match('~^CREATE( UNIQUE)? INDEX '.preg_quote(idf_escape($B).' ON '.idf_escape($Q),'~').' \((.*)\)$~i',$Bh[$B],$Hg)){preg_match_all('/("[^"]*+")+( DESC)?/',$Hg[2],$De);foreach($De[2]as$y=>$X){if($X)$v["descs"][$y]='1';}}if(!$H[""]||$v["type"]!="UNIQUE"||$v["columns"]!=$H[""]["columns"]||$v["descs"]!=$H[""]["descs"]||!preg_match("~^sqlite_~",$B))$H[$B]=$v;}return$H;}function
foreign_keys($Q){$H=array();foreach(get_rows("PRAGMA foreign_key_list(".table($Q).")")as$I){$q=&$H[$I["id"]];if(!$q)$q=$I;$q["source"][]=$I["from"];$q["target"][]=$I["to"];}return$H;}function
view($B){global$g;return
array("select"=>preg_replace('~^(?:[^`"[]+|`[^`]*`|"[^"]*")* AS\s+~iU','',$g->result("SELECT sql FROM sqlite_master WHERE name = ".q($B))));}function
collations(){return(isset($_GET["create"])?get_vals("PRAGMA collation_list",1):array());}function
information_schema($l){return
false;}function
error(){global$g;return
h($g->error);}function
check_sqlite_name($B){global$g;$Kc="db|sdb|sqlite";if(!preg_match("~^[^\\0]*\\.($Kc)\$~",$B)){$g->error=sprintf('Please use one of the extensions %s.',str_replace("|",", ",$Kc));return
false;}return
true;}function
create_database($l,$d){global$g;if(file_exists($l)){$g->error='File exists.';return
false;}if(!check_sqlite_name($l))return
false;try{$_=new
Min_SQLite($l);}catch(Exception$Ac){$g->error=$Ac->getMessage();return
false;}$_->query('PRAGMA encoding = "UTF-8"');$_->query('CREATE TABLE adminer (i)');$_->query('DROP TABLE adminer');return
true;}function
drop_databases($k){global$g;$g->__construct(":memory:");foreach($k
as$l){if(!@unlink($l)){$g->error='File exists.';return
false;}}return
true;}function
rename_database($B,$d){global$g;if(!check_sqlite_name($B))return
false;$g->__construct(":memory:");$g->error='File exists.';return@rename(DB,$B);}function
auto_increment(){return" PRIMARY KEY".(DRIVER=="sqlite"?" AUTOINCREMENT":"");}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){global$g;$Oi=($Q==""||$cd);foreach($p
as$o){if($o[0]!=""||!$o[1]||$o[2]){$Oi=true;break;}}$c=array();$If=array();foreach($p
as$o){if($o[1]){$c[]=($Oi?$o[1]:"ADD ".implode($o[1]));if($o[0]!="")$If[$o[0]]=$o[1][0];}}if(!$Oi){foreach($c
as$X){if(!queries("ALTER TABLE ".table($Q)." $X"))return
false;}if($Q!=$B&&!queries("ALTER TABLE ".table($Q)." RENAME TO ".table($B)))return
false;}elseif(!recreate_table($Q,$B,$c,$If,$cd,$Ma))return
false;if($Ma){queries("BEGIN");queries("UPDATE sqlite_sequence SET seq = $Ma WHERE name = ".q($B));if(!$g->affected_rows)queries("INSERT INTO sqlite_sequence (name, seq) VALUES (".q($B).", $Ma)");queries("COMMIT");}return
true;}function
recreate_table($Q,$B,$p,$If,$cd,$Ma,$w=array()){global$g;if($Q!=""){if(!$p){foreach(fields($Q)as$y=>$o){if($w)$o["auto_increment"]=0;$p[]=process_field($o,$o);$If[$y]=idf_escape($y);}}$lg=false;foreach($p
as$o){if($o[6])$lg=true;}$hc=array();foreach($w
as$y=>$X){if($X[2]=="DROP"){$hc[$X[1]]=true;unset($w[$y]);}}foreach(indexes($Q)as$ge=>$v){$f=array();foreach($v["columns"]as$y=>$e){if(!$If[$e])continue
2;$f[]=$If[$e].($v["descs"][$y]?" DESC":"");}if(!$hc[$ge]){if($v["type"]!="PRIMARY"||!$lg)$w[]=array($v["type"],$ge,$f);}}foreach($w
as$y=>$X){if($X[0]=="PRIMARY"){unset($w[$y]);$cd[]=" PRIMARY KEY (".implode(", ",$X[2]).")";}}foreach(foreign_keys($Q)as$ge=>$q){foreach($q["source"]as$y=>$e){if(!$If[$e])continue
2;$q["source"][$y]=idf_unescape($If[$e]);}if(!isset($cd[" $ge"]))$cd[]=" ".format_foreign_key($q);}queries("BEGIN");}foreach($p
as$y=>$o)$p[$y]=" ".implode($o);$p=array_merge($p,array_filter($cd));$Zh=($Q==$B?"adminer_$B":$B);if(!queries("CREATE TABLE ".table($Zh)." (\n".implode(",\n",$p)."\n)"))return
false;if($Q!=""){if($If&&!queries("INSERT INTO ".table($Zh)." (".implode(", ",$If).") SELECT ".implode(", ",array_map('idf_escape',array_keys($If)))." FROM ".table($Q)))return
false;$_i=array();foreach(triggers($Q)as$yi=>$gi){$xi=trigger($yi);$_i[]="CREATE TRIGGER ".idf_escape($yi)." ".implode(" ",$gi)." ON ".table($B)."\n$xi[Statement]";}$Ma=$Ma?0:$g->result("SELECT seq FROM sqlite_sequence WHERE name = ".q($Q));if(!queries("DROP TABLE ".table($Q))||($Q==$B&&!queries("ALTER TABLE ".table($Zh)." RENAME TO ".table($B)))||!alter_indexes($B,$w))return
false;if($Ma)queries("UPDATE sqlite_sequence SET seq = $Ma WHERE name = ".q($B));foreach($_i
as$xi){if(!queries($xi))return
false;}queries("COMMIT");}return
true;}function
index_sql($Q,$T,$B,$f){return"CREATE $T ".($T!="INDEX"?"INDEX ":"").idf_escape($B!=""?$B:uniqid($Q."_"))." ON ".table($Q)." $f";}function
alter_indexes($Q,$c){foreach($c
as$kg){if($kg[0]=="PRIMARY")return
recreate_table($Q,$Q,array(),array(),array(),0,$c);}foreach(array_reverse($c)as$X){if(!queries($X[2]=="DROP"?"DROP INDEX ".idf_escape($X[1]):index_sql($Q,$X[0],$X[1],"(".implode(", ",$X[2]).")")))return
false;}return
true;}function
truncate_tables($S){return
apply_queries("DELETE FROM",$S);}function
drop_views($aj){return
apply_queries("DROP VIEW",$aj);}function
drop_tables($S){return
apply_queries("DROP TABLE",$S);}function
move_tables($S,$aj,$Xh){return
false;}function
trigger($B){global$g;if($B=="")return
array("Statement"=>"BEGIN\n\t;\nEND");$u='(?:[^`"\s]+|`[^`]*`|"[^"]*")+';$zi=trigger_options();preg_match("~^CREATE\\s+TRIGGER\\s*$u\\s*(".implode("|",$zi["Timing"]).")\\s+([a-z]+)(?:\\s+OF\\s+($u))?\\s+ON\\s*$u\\s*(?:FOR\\s+EACH\\s+ROW\\s)?(.*)~is",$g->result("SELECT sql FROM sqlite_master WHERE type = 'trigger' AND name = ".q($B)),$A);$jf=$A[3];return
array("Timing"=>strtoupper($A[1]),"Event"=>strtoupper($A[2]).($jf?" OF":""),"Of"=>($jf[0]=='`'||$jf[0]=='"'?idf_unescape($jf):$jf),"Trigger"=>$B,"Statement"=>$A[4],);}function
triggers($Q){$H=array();$zi=trigger_options();foreach(get_rows("SELECT * FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ".q($Q))as$I){preg_match('~^CREATE\s+TRIGGER\s*(?:[^`"\s]+|`[^`]*`|"[^"]*")+\s*('.implode("|",$zi["Timing"]).')\s*(.*?)\s+ON\b~i',$I["sql"],$A);$H[$I["name"]]=array($A[1],$A[2]);}return$H;}function
trigger_options(){return
array("Timing"=>array("BEFORE","AFTER","INSTEAD OF"),"Event"=>array("INSERT","UPDATE","UPDATE OF","DELETE"),"Type"=>array("FOR EACH ROW"),);}function
begin(){return
queries("BEGIN");}function
last_id(){global$g;return$g->result("SELECT LAST_INSERT_ROWID()");}function
explain($g,$F){return$g->query("EXPLAIN QUERY PLAN $F");}function
found_rows($R,$Z){}function
types(){return
array();}function
schemas(){return
array();}function
get_schema(){return"";}function
set_schema($bh){return
true;}function
create_sql($Q,$Ma,$Ih){global$g;$H=$g->result("SELECT sql FROM sqlite_master WHERE type IN ('table', 'view') AND name = ".q($Q));foreach(indexes($Q)as$B=>$v){if($B=='')continue;$H.=";\n\n".index_sql($Q,$v['type'],$B,"(".implode(", ",array_map('idf_escape',$v['columns'])).")");}return$H;}function
truncate_sql($Q){return"DELETE FROM ".table($Q);}function
use_sql($j){}function
trigger_sql($Q){return
implode(get_vals("SELECT sql || ';;\n' FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ".q($Q)));}function
show_variables(){global$g;$H=array();foreach(array("auto_vacuum","cache_size","count_changes","default_cache_size","empty_result_callbacks","encoding","foreign_keys","full_column_names","fullfsync","journal_mode","journal_size_limit","legacy_file_format","locking_mode","page_size","max_page_count","read_uncommitted","recursive_triggers","reverse_unordered_selects","secure_delete","short_column_names","synchronous","temp_store","temp_store_directory","schema_version","integrity_check","quick_check")as$y)$H[$y]=$g->result("PRAGMA $y");return$H;}function
show_status(){$H=array();foreach(get_vals("PRAGMA compile_options")as$xf){list($y,$X)=explode("=",$xf,2);$H[$y]=$X;}return$H;}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
support($Pc){return
preg_match('~^(columns|database|drop_col|dump|indexes|descidx|move_col|sql|status|table|trigger|variables|view|view_trigger)$~',$Pc);}$x="sqlite";$U=array("integer"=>0,"real"=>0,"numeric"=>0,"text"=>0,"blob"=>0);$Hh=array_keys($U);$Ii=array();$vf=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","IN","IS NULL","NOT LIKE","NOT IN","IS NOT NULL","SQL");$kd=array("hex","length","lower","round","unixepoch","upper");$qd=array("avg","count","count distinct","group_concat","max","min","sum");$mc=array(array(),array("integer|real|numeric"=>"+/-","text"=>"||",));}$ec["pgsql"]="PostgreSQL";if(isset($_GET["pgsql"])){$hg=array("PgSQL","PDO_PgSQL");define("DRIVER","pgsql");if(extension_loaded("pgsql")){class
Min_DB{var$extension="PgSQL",$_link,$_result,$_string,$_database=true,$server_info,$affected_rows,$error,$timeout;function
_error($xc,$n){if(ini_bool("html_errors"))$n=html_entity_decode(strip_tags($n));$n=preg_replace('~^[^:]*: ~','',$n);$this->error=$n;}function
connect($M,$V,$E){global$b;$l=$b->database();set_error_handler(array($this,'_error'));$this->_string="host='".str_replace(":","' port='",addcslashes($M,"'\\"))."' user='".addcslashes($V,"'\\")."' password='".addcslashes($E,"'\\")."'";$this->_link=@pg_connect("$this->_string dbname='".($l!=""?addcslashes($l,"'\\"):"postgres")."'",PGSQL_CONNECT_FORCE_NEW);if(!$this->_link&&$l!=""){$this->_database=false;$this->_link=@pg_connect("$this->_string dbname='postgres'",PGSQL_CONNECT_FORCE_NEW);}restore_error_handler();if($this->_link){$Yi=pg_version($this->_link);$this->server_info=$Yi["server"];pg_set_client_encoding($this->_link,"UTF8");}return(bool)$this->_link;}function
quote($P){return"'".pg_escape_string($this->_link,$P)."'";}function
value($X,$o){return($o["type"]=="bytea"?pg_unescape_bytea($X):$X);}function
quoteBinary($P){return"'".pg_escape_bytea($this->_link,$P)."'";}function
select_db($j){global$b;if($j==$b->database())return$this->_database;$H=@pg_connect("$this->_string dbname='".addcslashes($j,"'\\")."'",PGSQL_CONNECT_FORCE_NEW);if($H)$this->_link=$H;return$H;}function
close(){$this->_link=@pg_connect("$this->_string dbname='postgres'");}function
query($F,$Ci=false){$G=@pg_query($this->_link,$F);$this->error="";if(!$G){$this->error=pg_last_error($this->_link);$H=false;}elseif(!pg_num_fields($G)){$this->affected_rows=pg_affected_rows($G);$H=true;}else$H=new
Min_Result($G);if($this->timeout){$this->timeout=0;$this->query("RESET statement_timeout");}return$H;}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
result($F,$o=0){$G=$this->query($F);if(!$G||!$G->num_rows)return
false;return
pg_fetch_result($G->_result,0,$o);}function
warnings(){return
h(pg_last_notice($this->_link));}}class
Min_Result{var$_result,$_offset=0,$num_rows;function
__construct($G){$this->_result=$G;$this->num_rows=pg_num_rows($G);}function
fetch_assoc(){return
pg_fetch_assoc($this->_result);}function
fetch_row(){return
pg_fetch_row($this->_result);}function
fetch_field(){$e=$this->_offset++;$H=new
stdClass;if(function_exists('pg_field_table'))$H->orgtable=pg_field_table($this->_result,$e);$H->name=pg_field_name($this->_result,$e);$H->orgname=$H->name;$H->type=pg_field_type($this->_result,$e);$H->charsetnr=($H->type=="bytea"?63:0);return$H;}function
__destruct(){pg_free_result($this->_result);}}}elseif(extension_loaded("pdo_pgsql")){class
Min_DB
extends
Min_PDO{var$extension="PDO_PgSQL",$timeout;function
connect($M,$V,$E){global$b;$l=$b->database();$P="pgsql:host='".str_replace(":","' port='",addcslashes($M,"'\\"))."' options='-c client_encoding=utf8'";$this->dsn("$P dbname='".($l!=""?addcslashes($l,"'\\"):"postgres")."'",$V,$E);return
true;}function
select_db($j){global$b;return($b->database()==$j);}function
quoteBinary($Yg){return
q($Yg);}function
query($F,$Ci=false){$H=parent::query($F,$Ci);if($this->timeout){$this->timeout=0;parent::query("RESET statement_timeout");}return$H;}function
warnings(){return'';}function
close(){}}}class
Min_Driver
extends
Min_SQL{function
insertUpdate($Q,$J,$kg){global$g;foreach($J
as$N){$Ji=array();$Z=array();foreach($N
as$y=>$X){$Ji[]="$y = $X";if(isset($kg[idf_unescape($y)]))$Z[]="$y = $X";}if(!(($Z&&queries("UPDATE ".table($Q)." SET ".implode(", ",$Ji)." WHERE ".implode(" AND ",$Z))&&$g->affected_rows)||queries("INSERT INTO ".table($Q)." (".implode(", ",array_keys($N)).") VALUES (".implode(", ",$N).")")))return
false;}return
true;}function
slowQuery($F,$fi){$this->_conn->query("SET statement_timeout = ".(1000*$fi));$this->_conn->timeout=1000*$fi;return$F;}function
convertSearch($u,$X,$o){return(preg_match('~char|text'.(!preg_match('~LIKE~',$X["op"])?'|date|time(stamp)?|boolean|uuid|'.number_type():'').'~',$o["type"])?$u:"CAST($u AS text)");}function
quoteBinary($Yg){return$this->_conn->quoteBinary($Yg);}function
warnings(){return$this->_conn->warnings();}function
tableHelp($B){$we=array("information_schema"=>"infoschema","pg_catalog"=>"catalog",);$_=$we[$_GET["ns"]];if($_)return"$_-".str_replace("_","-",$B).".html";}}function
idf_escape($u){return'"'.str_replace('"','""',$u).'"';}function
table($u){return
idf_escape($u);}function
connect(){global$b,$U,$Hh;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2])){if(min_version(9,0,$g)){$g->query("SET application_name = 'Adminer'");if(min_version(9.2,0,$g)){$Hh['Strings'][]="json";$U["json"]=4294967295;if(min_version(9.4,0,$g)){$Hh['Strings'][]="jsonb";$U["jsonb"]=4294967295;}}}return$g;}return$g->error;}function
get_databases(){return
get_vals("SELECT datname FROM pg_database WHERE has_database_privilege(datname, 'CONNECT') ORDER BY datname");}function
limit($F,$Z,$z,$C=0,$L=" "){return" $F$Z".($z!==null?$L."LIMIT $z".($C?" OFFSET $C":""):"");}function
limit1($Q,$F,$Z,$L="\n"){return(preg_match('~^INTO~',$F)?limit($F,$Z,1,0,$L):" $F".(is_view(table_status1($Q))?$Z:" WHERE ctid = (SELECT ctid FROM ".table($Q).$Z.$L."LIMIT 1)"));}function
db_collation($l,$pb){global$g;return$g->result("SHOW LC_COLLATE");}function
engines(){return
array();}function
logged_user(){global$g;return$g->result("SELECT user");}function
tables_list(){$F="SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = current_schema()";if(support('materializedview'))$F.="
UNION ALL
SELECT matviewname, 'MATERIALIZED VIEW'
FROM pg_matviews
WHERE schemaname = current_schema()";$F.="
ORDER BY 1";return
get_key_vals($F);}function
count_tables($k){return
array();}function
table_status($B=""){$H=array();foreach(get_rows("SELECT c.relname AS \"Name\", CASE c.relkind WHEN 'r' THEN 'table' WHEN 'm' THEN 'materialized view' ELSE 'view' END AS \"Engine\", pg_relation_size(c.oid) AS \"Data_length\", pg_total_relation_size(c.oid) - pg_relation_size(c.oid) AS \"Index_length\", obj_description(c.oid, 'pg_class') AS \"Comment\", ".(min_version(12)?"''":"CASE WHEN c.relhasoids THEN 'oid' ELSE '' END")." AS \"Oid\", c.reltuples as \"Rows\", n.nspname
FROM pg_class c
JOIN pg_namespace n ON(n.nspname = current_schema() AND n.oid = c.relnamespace)
WHERE relkind IN ('r', 'm', 'v', 'f')
".($B!=""?"AND relname = ".q($B):"ORDER BY relname"))as$I)$H[$I["Name"]]=$I;return($B!=""?$H[$B]:$H);}function
is_view($R){return
in_array($R["Engine"],array("view","materialized view"));}function
fk_support($R){return
true;}function
fields($Q){$H=array();$Ca=array('timestamp without time zone'=>'timestamp','timestamp with time zone'=>'timestamptz',);$Dd=min_version(10)?"(a.attidentity = 'd')::int":'0';foreach(get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, pg_get_expr(d.adbin, d.adrelid) AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment, $Dd AS identity
FROM pg_class c
JOIN pg_namespace n ON c.relnamespace = n.oid
JOIN pg_attribute a ON c.oid = a.attrelid
LEFT JOIN pg_attrdef d ON c.oid = d.adrelid AND a.attnum = d.adnum
WHERE c.relname = ".q($Q)."
AND n.nspname = current_schema()
AND NOT a.attisdropped
AND a.attnum > 0
ORDER BY a.attnum")as$I){preg_match('~([^([]+)(\((.*)\))?([a-z ]+)?((\[[0-9]*])*)$~',$I["full_type"],$A);list(,$T,$te,$I["length"],$wa,$Fa)=$A;$I["length"].=$Fa;$eb=$T.$wa;if(isset($Ca[$eb])){$I["type"]=$Ca[$eb];$I["full_type"]=$I["type"].$te.$Fa;}else{$I["type"]=$T;$I["full_type"]=$I["type"].$te.$wa.$Fa;}if($I['identity'])$I['default']='GENERATED BY DEFAULT AS IDENTITY';$I["null"]=!$I["attnotnull"];$I["auto_increment"]=$I['identity']||preg_match('~^nextval\(~i',$I["default"]);$I["privileges"]=array("insert"=>1,"select"=>1,"update"=>1);if(preg_match('~(.+)::[^)]+(.*)~',$I["default"],$A))$I["default"]=($A[1]=="NULL"?null:(($A[1][0]=="'"?idf_unescape($A[1]):$A[1]).$A[2]));$H[$I["field"]]=$I;}return$H;}function
indexes($Q,$h=null){global$g;if(!is_object($h))$h=$g;$H=array();$Qh=$h->result("SELECT oid FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema()) AND relname = ".q($Q));$f=get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $Qh AND attnum > 0",$h);foreach(get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption , (indpred IS NOT NULL)::int as indispartial FROM pg_index i, pg_class ci WHERE i.indrelid = $Qh AND ci.oid = i.indexrelid",$h)as$I){$Ig=$I["relname"];$H[$Ig]["type"]=($I["indispartial"]?"INDEX":($I["indisprimary"]?"PRIMARY":($I["indisunique"]?"UNIQUE":"INDEX")));$H[$Ig]["columns"]=array();foreach(explode(" ",$I["indkey"])as$Nd)$H[$Ig]["columns"][]=$f[$Nd];$H[$Ig]["descs"]=array();foreach(explode(" ",$I["indoption"])as$Od)$H[$Ig]["descs"][]=($Od&1?'1':null);$H[$Ig]["lengths"]=array();}return$H;}function
foreign_keys($Q){global$qf;$H=array();foreach(get_rows("SELECT conname, condeferrable::int AS deferrable, pg_get_constraintdef(oid) AS definition
FROM pg_constraint
WHERE conrelid = (SELECT pc.oid FROM pg_class AS pc INNER JOIN pg_namespace AS pn ON (pn.oid = pc.relnamespace) WHERE pc.relname = ".q($Q)." AND pn.nspname = current_schema())
AND contype = 'f'::char
ORDER BY conkey, conname")as$I){if(preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA',$I['definition'],$A)){$I['source']=array_map('trim',explode(',',$A[1]));if(preg_match('~^(("([^"]|"")+"|[^"]+)\.)?"?("([^"]|"")+"|[^"]+)$~',$A[2],$Ce)){$I['ns']=str_replace('""','"',preg_replace('~^"(.+)"$~','\1',$Ce[2]));$I['table']=str_replace('""','"',preg_replace('~^"(.+)"$~','\1',$Ce[4]));}$I['target']=array_map('trim',explode(',',$A[3]));$I['on_delete']=(preg_match("~ON DELETE ($qf)~",$A[4],$Ce)?$Ce[1]:'NO ACTION');$I['on_update']=(preg_match("~ON UPDATE ($qf)~",$A[4],$Ce)?$Ce[1]:'NO ACTION');$H[$I['conname']]=$I;}}return$H;}function
view($B){global$g;return
array("select"=>trim($g->result("SELECT pg_get_viewdef(".$g->result("SELECT oid FROM pg_class WHERE relname = ".q($B)).")")));}function
collations(){return
array();}function
information_schema($l){return($l=="information_schema");}function
error(){global$g;$H=h($g->error);if(preg_match('~^(.*\n)?([^\n]*)\n( *)\^(\n.*)?$~s',$H,$A))$H=$A[1].preg_replace('~((?:[^&]|&[^;]*;){'.strlen($A[3]).'})(.*)~','\1\2',$A[2]).$A[4];return
nl_br($H);}function
create_database($l,$d){return
queries("CREATE DATABASE ".idf_escape($l).($d?" ENCODING ".idf_escape($d):""));}function
drop_databases($k){global$g;$g->close();return
apply_queries("DROP DATABASE",$k,'idf_escape');}function
rename_database($B,$d){return
queries("ALTER DATABASE ".idf_escape(DB)." RENAME TO ".idf_escape($B));}function
auto_increment(){return"";}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){$c=array();$vg=array();if($Q!=""&&$Q!=$B)$vg[]="ALTER TABLE ".table($Q)." RENAME TO ".table($B);foreach($p
as$o){$e=idf_escape($o[0]);$X=$o[1];if(!$X)$c[]="DROP $e";else{$Ui=$X[5];unset($X[5]);if(isset($X[6])&&$o[0]=="")$X[1]=($X[1]=="bigint"?" big":" ")."serial";if($o[0]=="")$c[]=($Q!=""?"ADD ":" ").implode($X);else{if($e!=$X[0])$vg[]="ALTER TABLE ".table($B)." RENAME $e TO $X[0]";$c[]="ALTER $e TYPE$X[1]";if(!$X[6]){$c[]="ALTER $e ".($X[3]?"SET$X[3]":"DROP DEFAULT");$c[]="ALTER $e ".($X[2]==" NULL"?"DROP NOT":"SET").$X[2];}}if($o[0]!=""||$Ui!="")$vg[]="COMMENT ON COLUMN ".table($B).".$X[0] IS ".($Ui!=""?substr($Ui,9):"''");}}$c=array_merge($c,$cd);if($Q=="")array_unshift($vg,"CREATE TABLE ".table($B)." (\n".implode(",\n",$c)."\n)");elseif($c)array_unshift($vg,"ALTER TABLE ".table($Q)."\n".implode(",\n",$c));if($Q!=""||$ub!="")$vg[]="COMMENT ON TABLE ".table($B)." IS ".q($ub);if($Ma!=""){}foreach($vg
as$F){if(!queries($F))return
false;}return
true;}function
alter_indexes($Q,$c){$i=array();$fc=array();$vg=array();foreach($c
as$X){if($X[0]!="INDEX")$i[]=($X[2]=="DROP"?"\nDROP CONSTRAINT ".idf_escape($X[1]):"\nADD".($X[1]!=""?" CONSTRAINT ".idf_escape($X[1]):"")." $X[0] ".($X[0]=="PRIMARY"?"KEY ":"")."(".implode(", ",$X[2]).")");elseif($X[2]=="DROP")$fc[]=idf_escape($X[1]);else$vg[]="CREATE INDEX ".idf_escape($X[1]!=""?$X[1]:uniqid($Q."_"))." ON ".table($Q)." (".implode(", ",$X[2]).")";}if($i)array_unshift($vg,"ALTER TABLE ".table($Q).implode(",",$i));if($fc)array_unshift($vg,"DROP INDEX ".implode(", ",$fc));foreach($vg
as$F){if(!queries($F))return
false;}return
true;}function
truncate_tables($S){return
queries("TRUNCATE ".implode(", ",array_map('table',$S)));return
true;}function
drop_views($aj){return
drop_tables($aj);}function
drop_tables($S){foreach($S
as$Q){$O=table_status($Q);if(!queries("DROP ".strtoupper($O["Engine"])." ".table($Q)))return
false;}return
true;}function
move_tables($S,$aj,$Xh){foreach(array_merge($S,$aj)as$Q){$O=table_status($Q);if(!queries("ALTER ".strtoupper($O["Engine"])." ".table($Q)." SET SCHEMA ".idf_escape($Xh)))return
false;}return
true;}function
trigger($B,$Q=null){if($B=="")return
array("Statement"=>"EXECUTE PROCEDURE ()");if($Q===null)$Q=$_GET['trigger'];$J=get_rows('SELECT t.trigger_name AS "Trigger", t.action_timing AS "Timing", (SELECT STRING_AGG(event_manipulation, \' OR \') FROM information_schema.triggers WHERE event_object_table = t.event_object_table AND trigger_name = t.trigger_name ) AS "Events", t.event_manipulation AS "Event", \'FOR EACH \' || t.action_orientation AS "Type", t.action_statement AS "Statement" FROM information_schema.triggers t WHERE t.event_object_table = '.q($Q).' AND t.trigger_name = '.q($B));return
reset($J);}function
triggers($Q){$H=array();foreach(get_rows("SELECT * FROM information_schema.triggers WHERE event_object_table = ".q($Q))as$I)$H[$I["trigger_name"]]=array($I["action_timing"],$I["event_manipulation"]);return$H;}function
trigger_options(){return
array("Timing"=>array("BEFORE","AFTER"),"Event"=>array("INSERT","UPDATE","DELETE"),"Type"=>array("FOR EACH ROW","FOR EACH STATEMENT"),);}function
routine($B,$T){$J=get_rows('SELECT routine_definition AS definition, LOWER(external_language) AS language, *
FROM information_schema.routines
WHERE routine_schema = current_schema() AND specific_name = '.q($B));$H=$J[0];$H["returns"]=array("type"=>$H["type_udt_name"]);$H["fields"]=get_rows('SELECT parameter_name AS field, data_type AS type, character_maximum_length AS length, parameter_mode AS inout
FROM information_schema.parameters
WHERE specific_schema = current_schema() AND specific_name = '.q($B).'
ORDER BY ordinal_position');return$H;}function
routines(){return
get_rows('SELECT specific_name AS "SPECIFIC_NAME", routine_type AS "ROUTINE_TYPE", routine_name AS "ROUTINE_NAME", type_udt_name AS "DTD_IDENTIFIER"
FROM information_schema.routines
WHERE routine_schema = current_schema()
ORDER BY SPECIFIC_NAME');}function
routine_languages(){return
get_vals("SELECT LOWER(lanname) FROM pg_catalog.pg_language");}function
routine_id($B,$I){$H=array();foreach($I["fields"]as$o)$H[]=$o["type"];return
idf_escape($B)."(".implode(", ",$H).")";}function
last_id(){return
0;}function
explain($g,$F){return$g->query("EXPLAIN $F");}function
found_rows($R,$Z){global$g;if(preg_match("~ rows=([0-9]+)~",$g->result("EXPLAIN SELECT * FROM ".idf_escape($R["Name"]).($Z?" WHERE ".implode(" AND ",$Z):"")),$Hg))return$Hg[1];return
false;}function
types(){return
get_vals("SELECT typname
FROM pg_type
WHERE typnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema())
AND typtype IN ('b','d','e')
AND typelem = 0");}function
schemas(){return
get_vals("SELECT nspname FROM pg_namespace ORDER BY nspname");}function
get_schema(){global$g;return$g->result("SELECT current_schema()");}function
set_schema($ah,$h=null){global$g,$U,$Hh;if(!$h)$h=$g;$H=$h->query("SET search_path TO ".idf_escape($ah));foreach(types()as$T){if(!isset($U[$T])){$U[$T]=0;$Hh['User types'][]=$T;}}return$H;}function
create_sql($Q,$Ma,$Ih){global$g;$H='';$Qg=array();$kh=array();$O=table_status($Q);$p=fields($Q);$w=indexes($Q);ksort($w);$Zc=foreign_keys($Q);ksort($Zc);if(!$O||empty($p))return
false;$H="CREATE TABLE ".idf_escape($O['nspname']).".".idf_escape($O['Name'])." (\n ";foreach($p
as$Rc=>$o){$Rf=idf_escape($o['field']).' '.$o['full_type'].default_value($o).($o['attnotnull']?" NOT NULL":"");$Qg[]=$Rf;if(preg_match('~nextval\(\'([^\']+)\'\)~',$o['default'],$De)){$jh=$De[1];$yh=reset(get_rows(min_version(10)?"SELECT *, cache_size AS cache_value FROM pg_sequences WHERE schemaname = current_schema() AND sequencename = ".q($jh):"SELECT * FROM $jh"));$kh[]=($Ih=="DROP+CREATE"?"DROP SEQUENCE IF EXISTS $jh;\n":"")."CREATE SEQUENCE $jh INCREMENT $yh[increment_by] MINVALUE $yh[min_value] MAXVALUE $yh[max_value] START ".($Ma?$yh['last_value']:1)." CACHE $yh[cache_value];";}}if(!empty($kh))$H=implode("\n\n",$kh)."\n\n$H";foreach($w
as$Id=>$v){switch($v['type']){case'UNIQUE':$Qg[]="CONSTRAINT ".idf_escape($Id)." UNIQUE (".implode(', ',array_map('idf_escape',$v['columns'])).")";break;case'PRIMARY':$Qg[]="CONSTRAINT ".idf_escape($Id)." PRIMARY KEY (".implode(', ',array_map('idf_escape',$v['columns'])).")";break;}}foreach($Zc
as$Yc=>$Xc)$Qg[]="CONSTRAINT ".idf_escape($Yc)." $Xc[definition] ".($Xc['deferrable']?'DEFERRABLE':'NOT DEFERRABLE');$H.=implode(",\n ",$Qg)."\n) WITH (oids = ".($O['Oid']?'true':'false').");";foreach($w
as$Id=>$v){if($v['type']=='INDEX'){$f=array();foreach($v['columns']as$y=>$X)$f[]=idf_escape($X).($v['descs'][$y]?" DESC":"");$H.="\n\nCREATE INDEX ".idf_escape($Id)." ON ".idf_escape($O['nspname']).".".idf_escape($O['Name'])." USING btree (".implode(', ',$f).");";}}if($O['Comment'])$H.="\n\nCOMMENT ON TABLE ".idf_escape($O['nspname']).".".idf_escape($O['Name'])." IS ".q($O['Comment']).";";foreach($p
as$Rc=>$o){if($o['comment'])$H.="\n\nCOMMENT ON COLUMN ".idf_escape($O['nspname']).".".idf_escape($O['Name']).".".idf_escape($Rc)." IS ".q($o['comment']).";";}return
rtrim($H,';');}function
truncate_sql($Q){return"TRUNCATE ".table($Q);}function
trigger_sql($Q){$O=table_status($Q);$H="";foreach(triggers($Q)as$wi=>$vi){$xi=trigger($wi,$O['Name']);$H.="\nCREATE TRIGGER ".idf_escape($xi['Trigger'])." $xi[Timing] $xi[Events] ON ".idf_escape($O["nspname"]).".".idf_escape($O['Name'])." $xi[Type] $xi[Statement];;\n";}return$H;}function
use_sql($j){return"\connect ".idf_escape($j);}function
show_variables(){return
get_key_vals("SHOW ALL");}function
process_list(){return
get_rows("SELECT * FROM pg_stat_activity ORDER BY ".(min_version(9.2)?"pid":"procpid"));}function
show_status(){}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
support($Pc){return
preg_match('~^(database|table|columns|sql|indexes|descidx|comment|view|'.(min_version(9.3)?'materializedview|':'').'scheme|routine|processlist|sequence|trigger|type|variables|drop_col|kill|dump)$~',$Pc);}function
kill_process($X){return
queries("SELECT pg_terminate_backend(".number($X).")");}function
connection_id(){return"SELECT pg_backend_pid()";}function
max_connections(){global$g;return$g->result("SHOW max_connections");}$x="pgsql";$U=array();$Hh=array();foreach(array('Numbers'=>array("smallint"=>5,"integer"=>10,"bigint"=>19,"boolean"=>1,"numeric"=>0,"real"=>7,"double precision"=>16,"money"=>20),'Date and time'=>array("date"=>13,"time"=>17,"timestamp"=>20,"timestamptz"=>21,"interval"=>0),'Strings'=>array("character"=>0,"character varying"=>0,"text"=>0,"tsquery"=>0,"tsvector"=>0,"uuid"=>0,"xml"=>0),'Binary'=>array("bit"=>0,"bit varying"=>0,"bytea"=>0),'Network'=>array("cidr"=>43,"inet"=>43,"macaddr"=>17,"txid_snapshot"=>0),'Geometry'=>array("box"=>0,"circle"=>0,"line"=>0,"lseg"=>0,"path"=>0,"point"=>0,"polygon"=>0),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}$Ii=array();$vf=array("=","<",">","<=",">=","!=","~","!~","LIKE","LIKE %%","ILIKE","ILIKE %%","IN","IS NULL","NOT LIKE","NOT IN","IS NOT NULL");$kd=array("char_length","lower","round","to_hex","to_timestamp","upper");$qd=array("avg","count","count distinct","max","min","sum");$mc=array(array("char"=>"md5","date|time"=>"now",),array(number_type()=>"+/-","date|time"=>"+ interval/- interval","char|text"=>"||",));}$ec["oracle"]="Oracle (beta)";if(isset($_GET["oracle"])){$hg=array("OCI8","PDO_OCI");define("DRIVER","oracle");if(extension_loaded("oci8")){class
Min_DB{var$extension="oci8",$_link,$_result,$server_info,$affected_rows,$errno,$error;function
_error($xc,$n){if(ini_bool("html_errors"))$n=html_entity_decode(strip_tags($n));$n=preg_replace('~^[^:]*: ~','',$n);$this->error=$n;}function
connect($M,$V,$E){$this->_link=@oci_new_connect($V,$E,$M,"AL32UTF8");if($this->_link){$this->server_info=oci_server_version($this->_link);return
true;}$n=oci_error();$this->error=$n["message"];return
false;}function
quote($P){return"'".str_replace("'","''",$P)."'";}function
select_db($j){return
true;}function
query($F,$Ci=false){$G=oci_parse($this->_link,$F);$this->error="";if(!$G){$n=oci_error($this->_link);$this->errno=$n["code"];$this->error=$n["message"];return
false;}set_error_handler(array($this,'_error'));$H=@oci_execute($G);restore_error_handler();if($H){if(oci_num_fields($G))return
new
Min_Result($G);$this->affected_rows=oci_num_rows($G);}return$H;}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
result($F,$o=1){$G=$this->query($F);if(!is_object($G)||!oci_fetch($G->_result))return
false;return
oci_result($G->_result,$o);}}class
Min_Result{var$_result,$_offset=1,$num_rows;function
__construct($G){$this->_result=$G;}function
_convert($I){foreach((array)$I
as$y=>$X){if(is_a($X,'OCI-Lob'))$I[$y]=$X->load();}return$I;}function
fetch_assoc(){return$this->_convert(oci_fetch_assoc($this->_result));}function
fetch_row(){return$this->_convert(oci_fetch_row($this->_result));}function
fetch_field(){$e=$this->_offset++;$H=new
stdClass;$H->name=oci_field_name($this->_result,$e);$H->orgname=$H->name;$H->type=oci_field_type($this->_result,$e);$H->charsetnr=(preg_match("~raw|blob|bfile~",$H->type)?63:0);return$H;}function
__destruct(){oci_free_statement($this->_result);}}}elseif(extension_loaded("pdo_oci")){class
Min_DB
extends
Min_PDO{var$extension="PDO_OCI";function
connect($M,$V,$E){$this->dsn("oci:dbname=//$M;charset=AL32UTF8",$V,$E);return
true;}function
select_db($j){return
true;}}}class
Min_Driver
extends
Min_SQL{function
begin(){return
true;}}function
idf_escape($u){return'"'.str_replace('"','""',$u).'"';}function
table($u){return
idf_escape($u);}function
connect(){global$b;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2]))return$g;return$g->error;}function
get_databases(){return
get_vals("SELECT tablespace_name FROM user_tablespaces");}function
limit($F,$Z,$z,$C=0,$L=" "){return($C?" * FROM (SELECT t.*, rownum AS rnum FROM (SELECT $F$Z) t WHERE rownum <= ".($z+$C).") WHERE rnum > $C":($z!==null?" * FROM (SELECT $F$Z) WHERE rownum <= ".($z+$C):" $F$Z"));}function
limit1($Q,$F,$Z,$L="\n"){return" $F$Z";}function
db_collation($l,$pb){global$g;return$g->result("SELECT value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET'");}function
engines(){return
array();}function
logged_user(){global$g;return$g->result("SELECT USER FROM DUAL");}function
tables_list(){return
get_key_vals("SELECT table_name, 'table' FROM all_tables WHERE tablespace_name = ".q(DB)."
UNION SELECT view_name, 'view' FROM user_views
ORDER BY 1");}function
count_tables($k){return
array();}function
table_status($B=""){$H=array();$ch=q($B);foreach(get_rows('SELECT table_name "Name", \'table\' "Engine", avg_row_len * num_rows "Data_length", num_rows "Rows" FROM all_tables WHERE tablespace_name = '.q(DB).($B!=""?" AND table_name = $ch":"")."
UNION SELECT view_name, 'view', 0, 0 FROM user_views".($B!=""?" WHERE view_name = $ch":"")."
ORDER BY 1")as$I){if($B!="")return$I;$H[$I["Name"]]=$I;}return$H;}function
is_view($R){return$R["Engine"]=="view";}function
fk_support($R){return
true;}function
fields($Q){$H=array();foreach(get_rows("SELECT * FROM all_tab_columns WHERE table_name = ".q($Q)." ORDER BY column_id")as$I){$T=$I["DATA_TYPE"];$te="$I[DATA_PRECISION],$I[DATA_SCALE]";if($te==",")$te=$I["DATA_LENGTH"];$H[$I["COLUMN_NAME"]]=array("field"=>$I["COLUMN_NAME"],"full_type"=>$T.($te?"($te)":""),"type"=>strtolower($T),"length"=>$te,"default"=>$I["DATA_DEFAULT"],"null"=>($I["NULLABLE"]=="Y"),"privileges"=>array("insert"=>1,"select"=>1,"update"=>1),);}return$H;}function
indexes($Q,$h=null){$H=array();foreach(get_rows("SELECT uic.*, uc.constraint_type
FROM user_ind_columns uic
LEFT JOIN user_constraints uc ON uic.index_name = uc.constraint_name AND uic.table_name = uc.table_name
WHERE uic.table_name = ".q($Q)."
ORDER BY uc.constraint_type, uic.column_position",$h)as$I){$Id=$I["INDEX_NAME"];$H[$Id]["type"]=($I["CONSTRAINT_TYPE"]=="P"?"PRIMARY":($I["CONSTRAINT_TYPE"]=="U"?"UNIQUE":"INDEX"));$H[$Id]["columns"][]=$I["COLUMN_NAME"];$H[$Id]["lengths"][]=($I["CHAR_LENGTH"]&&$I["CHAR_LENGTH"]!=$I["COLUMN_LENGTH"]?$I["CHAR_LENGTH"]:null);$H[$Id]["descs"][]=($I["DESCEND"]?'1':null);}return$H;}function
view($B){$J=get_rows('SELECT text "select" FROM user_views WHERE view_name = '.q($B));return
reset($J);}function
collations(){return
array();}function
information_schema($l){return
false;}function
error(){global$g;return
h($g->error);}function
explain($g,$F){$g->query("EXPLAIN PLAN FOR $F");return$g->query("SELECT * FROM plan_table");}function
found_rows($R,$Z){}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){$c=$fc=array();foreach($p
as$o){$X=$o[1];if($X&&$o[0]!=""&&idf_escape($o[0])!=$X[0])queries("ALTER TABLE ".table($Q)." RENAME COLUMN ".idf_escape($o[0])." TO $X[0]");if($X)$c[]=($Q!=""?($o[0]!=""?"MODIFY (":"ADD ("):" ").implode($X).($Q!=""?")":"");else$fc[]=idf_escape($o[0]);}if($Q=="")return
queries("CREATE TABLE ".table($B)." (\n".implode(",\n",$c)."\n)");return(!$c||queries("ALTER TABLE ".table($Q)."\n".implode("\n",$c)))&&(!$fc||queries("ALTER TABLE ".table($Q)." DROP (".implode(", ",$fc).")"))&&($Q==$B||queries("ALTER TABLE ".table($Q)." RENAME TO ".table($B)));}function
foreign_keys($Q){$H=array();$F="SELECT c_list.CONSTRAINT_NAME as NAME,
c_src.COLUMN_NAME as SRC_COLUMN,
c_dest.OWNER as DEST_DB,
c_dest.TABLE_NAME as DEST_TABLE,
c_dest.COLUMN_NAME as DEST_COLUMN,
c_list.DELETE_RULE as ON_DELETE
FROM ALL_CONSTRAINTS c_list, ALL_CONS_COLUMNS c_src, ALL_CONS_COLUMNS c_dest
WHERE c_list.CONSTRAINT_NAME = c_src.CONSTRAINT_NAME
AND c_list.R_CONSTRAINT_NAME = c_dest.CONSTRAINT_NAME
AND c_list.CONSTRAINT_TYPE = 'R'
AND c_src.TABLE_NAME = ".q($Q);foreach(get_rows($F)as$I)$H[$I['NAME']]=array("db"=>$I['DEST_DB'],"table"=>$I['DEST_TABLE'],"source"=>array($I['SRC_COLUMN']),"target"=>array($I['DEST_COLUMN']),"on_delete"=>$I['ON_DELETE'],"on_update"=>null,);return$H;}function
truncate_tables($S){return
apply_queries("TRUNCATE TABLE",$S);}function
drop_views($aj){return
apply_queries("DROP VIEW",$aj);}function
drop_tables($S){return
apply_queries("DROP TABLE",$S);}function
last_id(){return
0;}function
schemas(){return
get_vals("SELECT DISTINCT owner FROM dba_segments WHERE owner IN (SELECT username FROM dba_users WHERE default_tablespace NOT IN ('SYSTEM','SYSAUX'))");}function
get_schema(){global$g;return$g->result("SELECT sys_context('USERENV', 'SESSION_USER') FROM dual");}function
set_schema($bh,$h=null){global$g;if(!$h)$h=$g;return$h->query("ALTER SESSION SET CURRENT_SCHEMA = ".idf_escape($bh));}function
show_variables(){return
get_key_vals('SELECT name, display_value FROM v$parameter');}function
process_list(){return
get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
FROM v$session sess LEFT OUTER JOIN v$sql sql
ON sql.sql_id = sess.sql_id
WHERE sess.type = \'USER\'
ORDER BY PROCESS
');}function
show_status(){$J=get_rows('SELECT * FROM v$instance');return
reset($J);}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
support($Pc){return
preg_match('~^(columns|database|drop_col|indexes|descidx|processlist|scheme|sql|status|table|variables|view|view_trigger)$~',$Pc);}$x="oracle";$U=array();$Hh=array();foreach(array('Numbers'=>array("number"=>38,"binary_float"=>12,"binary_double"=>21),'Date and time'=>array("date"=>10,"timestamp"=>29,"interval year"=>12,"interval day"=>28),'Strings'=>array("char"=>2000,"varchar2"=>4000,"nchar"=>2000,"nvarchar2"=>4000,"clob"=>4294967295,"nclob"=>4294967295),'Binary'=>array("raw"=>2000,"long raw"=>2147483648,"blob"=>4294967295,"bfile"=>4294967296),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}$Ii=array();$vf=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","IN","IS NULL","NOT LIKE","NOT REGEXP","NOT IN","IS NOT NULL","SQL");$kd=array("length","lower","round","upper");$qd=array("avg","count","count distinct","max","min","sum");$mc=array(array("date"=>"current_date","timestamp"=>"current_timestamp",),array("number|float|double"=>"+/-","date|timestamp"=>"+ interval/- interval","char|clob"=>"||",));}$ec["mssql"]="MS SQL (beta)";if(isset($_GET["mssql"])){$hg=array("SQLSRV","MSSQL","PDO_DBLIB");define("DRIVER","mssql");if(extension_loaded("sqlsrv")){class
Min_DB{var$extension="sqlsrv",$_link,$_result,$server_info,$affected_rows,$errno,$error;function
_get_error(){$this->error="";foreach(sqlsrv_errors()as$n){$this->errno=$n["code"];$this->error.="$n[message]\n";}$this->error=rtrim($this->error);}function
connect($M,$V,$E){global$b;$l=$b->database();$yb=array("UID"=>$V,"PWD"=>$E,"CharacterSet"=>"UTF-8");if($l!="")$yb["Database"]=$l;$this->_link=@sqlsrv_connect(preg_replace('~:~',',',$M),$yb);if($this->_link){$Pd=sqlsrv_server_info($this->_link);$this->server_info=$Pd['SQLServerVersion'];}else$this->_get_error();return(bool)$this->_link;}function
quote($P){return"'".str_replace("'","''",$P)."'";}function
select_db($j){return$this->query("USE ".idf_escape($j));}function
query($F,$Ci=false){$G=sqlsrv_query($this->_link,$F);$this->error="";if(!$G){$this->_get_error();return
false;}return$this->store_result($G);}function
multi_query($F){$this->_result=sqlsrv_query($this->_link,$F);$this->error="";if(!$this->_result){$this->_get_error();return
false;}return
true;}function
store_result($G=null){if(!$G)$G=$this->_result;if(!$G)return
false;if(sqlsrv_field_metadata($G))return
new
Min_Result($G);$this->affected_rows=sqlsrv_rows_affected($G);return
true;}function
next_result(){return$this->_result?sqlsrv_next_result($this->_result):null;}function
result($F,$o=0){$G=$this->query($F);if(!is_object($G))return
false;$I=$G->fetch_row();return$I[$o];}}class
Min_Result{var$_result,$_offset=0,$_fields,$num_rows;function
__construct($G){$this->_result=$G;}function
_convert($I){foreach((array)$I
as$y=>$X){if(is_a($X,'DateTime'))$I[$y]=$X->format("Y-m-d H:i:s");}return$I;}function
fetch_assoc(){return$this->_convert(sqlsrv_fetch_array($this->_result,SQLSRV_FETCH_ASSOC));}function
fetch_row(){return$this->_convert(sqlsrv_fetch_array($this->_result,SQLSRV_FETCH_NUMERIC));}function
fetch_field(){if(!$this->_fields)$this->_fields=sqlsrv_field_metadata($this->_result);$o=$this->_fields[$this->_offset++];$H=new
stdClass;$H->name=$o["Name"];$H->orgname=$o["Name"];$H->type=($o["Type"]==1?254:0);return$H;}function
seek($C){for($s=0;$s<$C;$s++)sqlsrv_fetch($this->_result);}function
__destruct(){sqlsrv_free_stmt($this->_result);}}}elseif(extension_loaded("mssql")){class
Min_DB{var$extension="MSSQL",$_link,$_result,$server_info,$affected_rows,$error;function
connect($M,$V,$E){$this->_link=@mssql_connect($M,$V,$E);if($this->_link){$G=$this->query("SELECT SERVERPROPERTY('ProductLevel'), SERVERPROPERTY('Edition')");if($G){$I=$G->fetch_row();$this->server_info=$this->result("sp_server_info 2",2)." [$I[0]] $I[1]";}}else$this->error=mssql_get_last_message();return(bool)$this->_link;}function
quote($P){return"'".str_replace("'","''",$P)."'";}function
select_db($j){return
mssql_select_db($j);}function
query($F,$Ci=false){$G=@mssql_query($F,$this->_link);$this->error="";if(!$G){$this->error=mssql_get_last_message();return
false;}if($G===true){$this->affected_rows=mssql_rows_affected($this->_link);return
true;}return
new
Min_Result($G);}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
mssql_next_result($this->_result->_result);}function
result($F,$o=0){$G=$this->query($F);if(!is_object($G))return
false;return
mssql_result($G->_result,0,$o);}}class
Min_Result{var$_result,$_offset=0,$_fields,$num_rows;function
__construct($G){$this->_result=$G;$this->num_rows=mssql_num_rows($G);}function
fetch_assoc(){return
mssql_fetch_assoc($this->_result);}function
fetch_row(){return
mssql_fetch_row($this->_result);}function
num_rows(){return
mssql_num_rows($this->_result);}function
fetch_field(){$H=mssql_fetch_field($this->_result);$H->orgtable=$H->table;$H->orgname=$H->name;return$H;}function
seek($C){mssql_data_seek($this->_result,$C);}function
__destruct(){mssql_free_result($this->_result);}}}elseif(extension_loaded("pdo_dblib")){class
Min_DB
extends
Min_PDO{var$extension="PDO_DBLIB";function
connect($M,$V,$E){$this->dsn("dblib:charset=utf8;host=".str_replace(":",";unix_socket=",preg_replace('~:(\d)~',';port=\1',$M)),$V,$E);return
true;}function
select_db($j){return$this->query("USE ".idf_escape($j));}}}class
Min_Driver
extends
Min_SQL{function
insertUpdate($Q,$J,$kg){foreach($J
as$N){$Ji=array();$Z=array();foreach($N
as$y=>$X){$Ji[]="$y = $X";if(isset($kg[idf_unescape($y)]))$Z[]="$y = $X";}if(!queries("MERGE ".table($Q)." USING (VALUES(".implode(", ",$N).")) AS source (c".implode(", c",range(1,count($N))).") ON ".implode(" AND ",$Z)." WHEN MATCHED THEN UPDATE SET ".implode(", ",$Ji)." WHEN NOT MATCHED THEN INSERT (".implode(", ",array_keys($N)).") VALUES (".implode(", ",$N).");"))return
false;}return
true;}function
begin(){return
queries("BEGIN TRANSACTION");}}function
idf_escape($u){return"[".str_replace("]","]]",$u)."]";}function
table($u){return($_GET["ns"]!=""?idf_escape($_GET["ns"]).".":"").idf_escape($u);}function
connect(){global$b;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2]))return$g;return$g->error;}function
get_databases(){return
get_vals("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')");}function
limit($F,$Z,$z,$C=0,$L=" "){return($z!==null?" TOP (".($z+$C).")":"")." $F$Z";}function
limit1($Q,$F,$Z,$L="\n"){return
limit($F,$Z,1,0,$L);}function
db_collation($l,$pb){global$g;return$g->result("SELECT collation_name FROM sys.databases WHERE name = ".q($l));}function
engines(){return
array();}function
logged_user(){global$g;return$g->result("SELECT SUSER_NAME()");}function
tables_list(){return
get_key_vals("SELECT name, type_desc FROM sys.all_objects WHERE schema_id = SCHEMA_ID(".q(get_schema()).") AND type IN ('S', 'U', 'V') ORDER BY name");}function
count_tables($k){global$g;$H=array();foreach($k
as$l){$g->select_db($l);$H[$l]=$g->result("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES");}return$H;}function
table_status($B=""){$H=array();foreach(get_rows("SELECT ao.name AS Name, ao.type_desc AS Engine, (SELECT value FROM fn_listextendedproperty(default, 'SCHEMA', schema_name(schema_id), 'TABLE', ao.name, null, null)) AS Comment FROM sys.all_objects AS ao WHERE schema_id = SCHEMA_ID(".q(get_schema()).") AND type IN ('S', 'U', 'V') ".($B!=""?"AND name = ".q($B):"ORDER BY name"))as$I){if($B!="")return$I;$H[$I["Name"]]=$I;}return$H;}function
is_view($R){return$R["Engine"]=="VIEW";}function
fk_support($R){return
true;}function
fields($Q){$vb=get_key_vals("SELECT objname, cast(value as varchar) FROM fn_listextendedproperty('MS_DESCRIPTION', 'schema', ".q(get_schema()).", 'table', ".q($Q).", 'column', NULL)");$H=array();foreach(get_rows("SELECT c.max_length, c.precision, c.scale, c.name, c.is_nullable, c.is_identity, c.collation_name, t.name type, CAST(d.definition as text) [default]
FROM sys.all_columns c
JOIN sys.all_objects o ON c.object_id = o.object_id
JOIN sys.types t ON c.user_type_id = t.user_type_id
LEFT JOIN sys.default_constraints d ON c.default_object_id = d.parent_column_id
WHERE o.schema_id = SCHEMA_ID(".q(get_schema()).") AND o.type IN ('S', 'U', 'V') AND o.name = ".q($Q))as$I){$T=$I["type"];$te=(preg_match("~char|binary~",$T)?$I["max_length"]:($T=="decimal"?"$I[precision],$I[scale]":""));$H[$I["name"]]=array("field"=>$I["name"],"full_type"=>$T.($te?"($te)":""),"type"=>$T,"length"=>$te,"default"=>$I["default"],"null"=>$I["is_nullable"],"auto_increment"=>$I["is_identity"],"collation"=>$I["collation_name"],"privileges"=>array("insert"=>1,"select"=>1,"update"=>1),"primary"=>$I["is_identity"],"comment"=>$vb[$I["name"]],);}return$H;}function
indexes($Q,$h=null){$H=array();foreach(get_rows("SELECT i.name, key_ordinal, is_unique, is_primary_key, c.name AS column_name, is_descending_key
FROM sys.indexes i
INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
WHERE OBJECT_NAME(i.object_id) = ".q($Q),$h)as$I){$B=$I["name"];$H[$B]["type"]=($I["is_primary_key"]?"PRIMARY":($I["is_unique"]?"UNIQUE":"INDEX"));$H[$B]["lengths"]=array();$H[$B]["columns"][$I["key_ordinal"]]=$I["column_name"];$H[$B]["descs"][$I["key_ordinal"]]=($I["is_descending_key"]?'1':null);}return$H;}function
view($B){global$g;return
array("select"=>preg_replace('~^(?:[^[]|\[[^]]*])*\s+AS\s+~isU','',$g->result("SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = ".q($B))));}function
collations(){$H=array();foreach(get_vals("SELECT name FROM fn_helpcollations()")as$d)$H[preg_replace('~_.*~','',$d)][]=$d;return$H;}function
information_schema($l){return
false;}function
error(){global$g;return
nl_br(h(preg_replace('~^(\[[^]]*])+~m','',$g->error)));}function
create_database($l,$d){return
queries("CREATE DATABASE ".idf_escape($l).(preg_match('~^[a-z0-9_]+$~i',$d)?" COLLATE $d":""));}function
drop_databases($k){return
queries("DROP DATABASE ".implode(", ",array_map('idf_escape',$k)));}function
rename_database($B,$d){if(preg_match('~^[a-z0-9_]+$~i',$d))queries("ALTER DATABASE ".idf_escape(DB)." COLLATE $d");queries("ALTER DATABASE ".idf_escape(DB)." MODIFY NAME = ".idf_escape($B));return
true;}function
auto_increment(){return" IDENTITY".($_POST["Auto_increment"]!=""?"(".number($_POST["Auto_increment"]).",1)":"")." PRIMARY KEY";}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){$c=array();$vb=array();foreach($p
as$o){$e=idf_escape($o[0]);$X=$o[1];if(!$X)$c["DROP"][]=" COLUMN $e";else{$X[1]=preg_replace("~( COLLATE )'(\\w+)'~",'\1\2',$X[1]);$vb[$o[0]]=$X[5];unset($X[5]);if($o[0]=="")$c["ADD"][]="\n ".implode("",$X).($Q==""?substr($cd[$X[0]],16+strlen($X[0])):"");else{unset($X[6]);if($e!=$X[0])queries("EXEC sp_rename ".q(table($Q).".$e").", ".q(idf_unescape($X[0])).", 'COLUMN'");$c["ALTER COLUMN ".implode("",$X)][]="";}}}if($Q=="")return
queries("CREATE TABLE ".table($B)." (".implode(",",(array)$c["ADD"])."\n)");if($Q!=$B)queries("EXEC sp_rename ".q(table($Q)).", ".q($B));if($cd)$c[""]=$cd;foreach($c
as$y=>$X){if(!queries("ALTER TABLE ".idf_escape($B)." $y".implode(",",$X)))return
false;}foreach($vb
as$y=>$X){$ub=substr($X,9);queries("EXEC sp_dropextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = ".q(get_schema()).", @level1type = N'Table', @level1name = ".q($B).", @level2type = N'Column', @level2name = ".q($y));queries("EXEC sp_addextendedproperty @name = N'MS_Description', @value = ".$ub.", @level0type = N'Schema', @level0name = ".q(get_schema()).", @level1type = N'Table', @level1name = ".q($B).", @level2type = N'Column', @level2name = ".q($y));}return
true;}function
alter_indexes($Q,$c){$v=array();$fc=array();foreach($c
as$X){if($X[2]=="DROP"){if($X[0]=="PRIMARY")$fc[]=idf_escape($X[1]);else$v[]=idf_escape($X[1])." ON ".table($Q);}elseif(!queries(($X[0]!="PRIMARY"?"CREATE $X[0] ".($X[0]!="INDEX"?"INDEX ":"").idf_escape($X[1]!=""?$X[1]:uniqid($Q."_"))." ON ".table($Q):"ALTER TABLE ".table($Q)." ADD PRIMARY KEY")." (".implode(", ",$X[2]).")"))return
false;}return(!$v||queries("DROP INDEX ".implode(", ",$v)))&&(!$fc||queries("ALTER TABLE ".table($Q)." DROP ".implode(", ",$fc)));}function
last_id(){global$g;return$g->result("SELECT SCOPE_IDENTITY()");}function
explain($g,$F){$g->query("SET SHOWPLAN_ALL ON");$H=$g->query($F);$g->query("SET SHOWPLAN_ALL OFF");return$H;}function
found_rows($R,$Z){}function
foreign_keys($Q){$H=array();foreach(get_rows("EXEC sp_fkeys @fktable_name = ".q($Q))as$I){$q=&$H[$I["FK_NAME"]];$q["db"]=$I["PKTABLE_QUALIFIER"];$q["table"]=$I["PKTABLE_NAME"];$q["source"][]=$I["FKCOLUMN_NAME"];$q["target"][]=$I["PKCOLUMN_NAME"];}return$H;}function
truncate_tables($S){return
apply_queries("TRUNCATE TABLE",$S);}function
drop_views($aj){return
queries("DROP VIEW ".implode(", ",array_map('table',$aj)));}function
drop_tables($S){return
queries("DROP TABLE ".implode(", ",array_map('table',$S)));}function
move_tables($S,$aj,$Xh){return
apply_queries("ALTER SCHEMA ".idf_escape($Xh)." TRANSFER",array_merge($S,$aj));}function
trigger($B){if($B=="")return
array();$J=get_rows("SELECT s.name [Trigger],
CASE WHEN OBJECTPROPERTY(s.id, 'ExecIsInsertTrigger') = 1 THEN 'INSERT' WHEN OBJECTPROPERTY(s.id, 'ExecIsUpdateTrigger') = 1 THEN 'UPDATE' WHEN OBJECTPROPERTY(s.id, 'ExecIsDeleteTrigger') = 1 THEN 'DELETE' END [Event],
CASE WHEN OBJECTPROPERTY(s.id, 'ExecIsInsteadOfTrigger') = 1 THEN 'INSTEAD OF' ELSE 'AFTER' END [Timing],
c.text
FROM sysobjects s
JOIN syscomments c ON s.id = c.id
WHERE s.xtype = 'TR' AND s.name = ".q($B));$H=reset($J);if($H)$H["Statement"]=preg_replace('~^.+\s+AS\s+~isU','',$H["text"]);return$H;}function
triggers($Q){$H=array();foreach(get_rows("SELECT sys1.name,
CASE WHEN OBJECTPROPERTY(sys1.id, 'ExecIsInsertTrigger') = 1 THEN 'INSERT' WHEN OBJECTPROPERTY(sys1.id, 'ExecIsUpdateTrigger') = 1 THEN 'UPDATE' WHEN OBJECTPROPERTY(sys1.id, 'ExecIsDeleteTrigger') = 1 THEN 'DELETE' END [Event],
CASE WHEN OBJECTPROPERTY(sys1.id, 'ExecIsInsteadOfTrigger') = 1 THEN 'INSTEAD OF' ELSE 'AFTER' END [Timing]
FROM sysobjects sys1
JOIN sysobjects sys2 ON sys1.parent_obj = sys2.id
WHERE sys1.xtype = 'TR' AND sys2.name = ".q($Q))as$I)$H[$I["name"]]=array($I["Timing"],$I["Event"]);return$H;}function
trigger_options(){return
array("Timing"=>array("AFTER","INSTEAD OF"),"Event"=>array("INSERT","UPDATE","DELETE"),"Type"=>array("AS"),);}function
schemas(){return
get_vals("SELECT name FROM sys.schemas");}function
get_schema(){global$g;if($_GET["ns"]!="")return$_GET["ns"];return$g->result("SELECT SCHEMA_NAME()");}function
set_schema($ah){return
true;}function
use_sql($j){return"USE ".idf_escape($j);}function
show_variables(){return
array();}function
show_status(){return
array();}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
support($Pc){return
preg_match('~^(comment|columns|database|drop_col|indexes|descidx|scheme|sql|table|trigger|view|view_trigger)$~',$Pc);}$x="mssql";$U=array();$Hh=array();foreach(array('Numbers'=>array("tinyint"=>3,"smallint"=>5,"int"=>10,"bigint"=>20,"bit"=>1,"decimal"=>0,"real"=>12,"float"=>53,"smallmoney"=>10,"money"=>20),'Date and time'=>array("date"=>10,"smalldatetime"=>19,"datetime"=>19,"datetime2"=>19,"time"=>8,"datetimeoffset"=>10),'Strings'=>array("char"=>8000,"varchar"=>8000,"text"=>2147483647,"nchar"=>4000,"nvarchar"=>4000,"ntext"=>1073741823),'Binary'=>array("binary"=>8000,"varbinary"=>8000,"image"=>2147483647),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}$Ii=array();$vf=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","IN","IS NULL","NOT LIKE","NOT IN","IS NOT NULL");$kd=array("len","lower","round","upper");$qd=array("avg","count","count distinct","max","min","sum");$mc=array(array("date|time"=>"getdate",),array("int|decimal|real|float|money|datetime"=>"+/-","char|text"=>"+",));}$ec['firebird']='Firebird (alpha)';if(isset($_GET["firebird"])){$hg=array("interbase");define("DRIVER","firebird");if(extension_loaded("interbase")){class
Min_DB{var$extension="Firebird",$server_info,$affected_rows,$errno,$error,$_link,$_result;function
connect($M,$V,$E){$this->_link=ibase_connect($M,$V,$E);if($this->_link){$Mi=explode(':',$M);$this->service_link=ibase_service_attach($Mi[0],$V,$E);$this->server_info=ibase_server_info($this->service_link,IBASE_SVC_SERVER_VERSION);}else{$this->errno=ibase_errcode();$this->error=ibase_errmsg();}return(bool)$this->_link;}function
quote($P){return"'".str_replace("'","''",$P)."'";}function
select_db($j){return($j=="domain");}function
query($F,$Ci=false){$G=ibase_query($F,$this->_link);if(!$G){$this->errno=ibase_errcode();$this->error=ibase_errmsg();return
false;}$this->error="";if($G===true){$this->affected_rows=ibase_affected_rows($this->_link);return
true;}return
new
Min_Result($G);}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
result($F,$o=0){$G=$this->query($F);if(!$G||!$G->num_rows)return
false;$I=$G->fetch_row();return$I[$o];}}class
Min_Result{var$num_rows,$_result,$_offset=0;function
__construct($G){$this->_result=$G;}function
fetch_assoc(){return
ibase_fetch_assoc($this->_result);}function
fetch_row(){return
ibase_fetch_row($this->_result);}function
fetch_field(){$o=ibase_field_info($this->_result,$this->_offset++);return(object)array('name'=>$o['name'],'orgname'=>$o['name'],'type'=>$o['type'],'charsetnr'=>$o['length'],);}function
__destruct(){ibase_free_result($this->_result);}}}class
Min_Driver
extends
Min_SQL{}function
idf_escape($u){return'"'.str_replace('"','""',$u).'"';}function
table($u){return
idf_escape($u);}function
connect(){global$b;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2]))return$g;return$g->error;}function
get_databases($ad){return
array("domain");}function
limit($F,$Z,$z,$C=0,$L=" "){$H='';$H.=($z!==null?$L."FIRST $z".($C?" SKIP $C":""):"");$H.=" $F$Z";return$H;}function
limit1($Q,$F,$Z,$L="\n"){return
limit($F,$Z,1,0,$L);}function
db_collation($l,$pb){}function
engines(){return
array();}function
logged_user(){global$b;$Hb=$b->credentials();return$Hb[1];}function
tables_list(){global$g;$F='SELECT RDB$RELATION_NAME FROM rdb$relations WHERE rdb$system_flag = 0';$G=ibase_query($g->_link,$F);$H=array();while($I=ibase_fetch_assoc($G))$H[$I['RDB$RELATION_NAME']]='table';ksort($H);return$H;}function
count_tables($k){return
array();}function
table_status($B="",$Oc=false){global$g;$H=array();$Mb=tables_list();foreach($Mb
as$v=>$X){$v=trim($v);$H[$v]=array('Name'=>$v,'Engine'=>'standard',);if($B==$v)return$H[$v];}return$H;}function
is_view($R){return
false;}function
fk_support($R){return
preg_match('~InnoDB|IBMDB2I~i',$R["Engine"]);}function
fields($Q){global$g;$H=array();$F='SELECT r.RDB$FIELD_NAME AS field_name,
r.RDB$DESCRIPTION AS field_description,
r.RDB$DEFAULT_VALUE AS field_default_value,
r.RDB$NULL_FLAG AS field_not_null_constraint,
f.RDB$FIELD_LENGTH AS field_length,
f.RDB$FIELD_PRECISION AS field_precision,
f.RDB$FIELD_SCALE AS field_scale,
CASE f.RDB$FIELD_TYPE
WHEN 261 THEN \'BLOB\'
WHEN 14 THEN \'CHAR\'
WHEN 40 THEN \'CSTRING\'
WHEN 11 THEN \'D_FLOAT\'
WHEN 27 THEN \'DOUBLE\'
WHEN 10 THEN \'FLOAT\'
WHEN 16 THEN \'INT64\'
WHEN 8 THEN \'INTEGER\'
WHEN 9 THEN \'QUAD\'
WHEN 7 THEN \'SMALLINT\'
WHEN 12 THEN \'DATE\'
WHEN 13 THEN \'TIME\'
WHEN 35 THEN \'TIMESTAMP\'
WHEN 37 THEN \'VARCHAR\'
ELSE \'UNKNOWN\'
END AS field_type,
f.RDB$FIELD_SUB_TYPE AS field_subtype,
coll.RDB$COLLATION_NAME AS field_collation,
cset.RDB$CHARACTER_SET_NAME AS field_charset
FROM RDB$RELATION_FIELDS r
LEFT JOIN RDB$FIELDS f ON r.RDB$FIELD_SOURCE = f.RDB$FIELD_NAME
LEFT JOIN RDB$COLLATIONS coll ON f.RDB$COLLATION_ID = coll.RDB$COLLATION_ID
LEFT JOIN RDB$CHARACTER_SETS cset ON f.RDB$CHARACTER_SET_ID = cset.RDB$CHARACTER_SET_ID
WHERE r.RDB$RELATION_NAME = '.q($Q).'
ORDER BY r.RDB$FIELD_POSITION';$G=ibase_query($g->_link,$F);while($I=ibase_fetch_assoc($G))$H[trim($I['FIELD_NAME'])]=array("field"=>trim($I["FIELD_NAME"]),"full_type"=>trim($I["FIELD_TYPE"]),"type"=>trim($I["FIELD_SUB_TYPE"]),"default"=>trim($I['FIELD_DEFAULT_VALUE']),"null"=>(trim($I["FIELD_NOT_NULL_CONSTRAINT"])=="YES"),"auto_increment"=>'0',"collation"=>trim($I["FIELD_COLLATION"]),"privileges"=>array("insert"=>1,"select"=>1,"update"=>1),"comment"=>trim($I["FIELD_DESCRIPTION"]),);return$H;}function
indexes($Q,$h=null){$H=array();return$H;}function
foreign_keys($Q){return
array();}function
collations(){return
array();}function
information_schema($l){return
false;}function
error(){global$g;return
h($g->error);}function
types(){return
array();}function
schemas(){return
array();}function
get_schema(){return"";}function
set_schema($ah){return
true;}function
support($Pc){return
preg_match("~^(columns|sql|status|table)$~",$Pc);}$x="firebird";$vf=array("=");$kd=array();$qd=array();$mc=array();}$ec["simpledb"]="SimpleDB";if(isset($_GET["simpledb"])){$hg=array("SimpleXML + allow_url_fopen");define("DRIVER","simpledb");if(class_exists('SimpleXMLElement')&&ini_bool('allow_url_fopen')){class
Min_DB{var$extension="SimpleXML",$server_info='2009-04-15',$error,$timeout,$next,$affected_rows,$_result;function
select_db($j){return($j=="domain");}function
query($F,$Ci=false){$Of=array('SelectExpression'=>$F,'ConsistentRead'=>'true');if($this->next)$Of['NextToken']=$this->next;$G=sdb_request_all('Select','Item',$Of,$this->timeout);$this->timeout=0;if($G===false)return$G;if(preg_match('~^\s*SELECT\s+COUNT\(~i',$F)){$Lh=0;foreach($G
as$be)$Lh+=$be->Attribute->Value;$G=array((object)array('Attribute'=>array((object)array('Name'=>'Count','Value'=>$Lh,))));}return
new
Min_Result($G);}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
quote($P){return"'".str_replace("'","''",$P)."'";}}class
Min_Result{var$num_rows,$_rows=array(),$_offset=0;function
__construct($G){foreach($G
as$be){$I=array();if($be->Name!='')$I['itemName()']=(string)$be->Name;foreach($be->Attribute
as$Ia){$B=$this->_processValue($Ia->Name);$Y=$this->_processValue($Ia->Value);if(isset($I[$B])){$I[$B]=(array)$I[$B];$I[$B][]=$Y;}else$I[$B]=$Y;}$this->_rows[]=$I;foreach($I
as$y=>$X){if(!isset($this->_rows[0][$y]))$this->_rows[0][$y]=null;}}$this->num_rows=count($this->_rows);}function
_processValue($pc){return(is_object($pc)&&$pc['encoding']=='base64'?base64_decode($pc):(string)$pc);}function
fetch_assoc(){$I=current($this->_rows);if(!$I)return$I;$H=array();foreach($this->_rows[0]as$y=>$X)$H[$y]=$I[$y];next($this->_rows);return$H;}function
fetch_row(){$H=$this->fetch_assoc();if(!$H)return$H;return
array_values($H);}function
fetch_field(){$he=array_keys($this->_rows[0]);return(object)array('name'=>$he[$this->_offset++]);}}}class
Min_Driver
extends
Min_SQL{public$kg="itemName()";function
_chunkRequest($Ed,$va,$Of,$Ec=array()){global$g;foreach(array_chunk($Ed,25)as$ib){$Pf=$Of;foreach($ib
as$s=>$t){$Pf["Item.$s.ItemName"]=$t;foreach($Ec
as$y=>$X)$Pf["Item.$s.$y"]=$X;}if(!sdb_request($va,$Pf))return
false;}$g->affected_rows=count($Ed);return
true;}function
_extractIds($Q,$wg,$z){$H=array();if(preg_match_all("~itemName\(\) = (('[^']*+')+)~",$wg,$De))$H=array_map('idf_unescape',$De[1]);else{foreach(sdb_request_all('Select','Item',array('SelectExpression'=>'SELECT itemName() FROM '.table($Q).$wg.($z?" LIMIT 1":"")))as$be)$H[]=$be->Name;}return$H;}function
select($Q,$K,$Z,$nd,$_f=array(),$z=1,$D=0,$mg=false){global$g;$g->next=$_GET["next"];$H=parent::select($Q,$K,$Z,$nd,$_f,$z,$D,$mg);$g->next=0;return$H;}function
delete($Q,$wg,$z=0){return$this->_chunkRequest($this->_extractIds($Q,$wg,$z),'BatchDeleteAttributes',array('DomainName'=>$Q));}function
update($Q,$N,$wg,$z=0,$L="\n"){$Vb=array();$Td=array();$s=0;$Ed=$this->_extractIds($Q,$wg,$z);$t=idf_unescape($N["`itemName()`"]);unset($N["`itemName()`"]);foreach($N
as$y=>$X){$y=idf_unescape($y);if($X=="NULL"||($t!=""&&array($t)!=$Ed))$Vb["Attribute.".count($Vb).".Name"]=$y;if($X!="NULL"){foreach((array)$X
as$de=>$W){$Td["Attribute.$s.Name"]=$y;$Td["Attribute.$s.Value"]=(is_array($X)?$W:idf_unescape($W));if(!$de)$Td["Attribute.$s.Replace"]="true";$s++;}}}$Of=array('DomainName'=>$Q);return(!$Td||$this->_chunkRequest(($t!=""?array($t):$Ed),'BatchPutAttributes',$Of,$Td))&&(!$Vb||$this->_chunkRequest($Ed,'BatchDeleteAttributes',$Of,$Vb));}function
insert($Q,$N){$Of=array("DomainName"=>$Q);$s=0;foreach($N
as$B=>$Y){if($Y!="NULL"){$B=idf_unescape($B);if($B=="itemName()")$Of["ItemName"]=idf_unescape($Y);else{foreach((array)$Y
as$X){$Of["Attribute.$s.Name"]=$B;$Of["Attribute.$s.Value"]=(is_array($Y)?$X:idf_unescape($Y));$s++;}}}}return
sdb_request('PutAttributes',$Of);}function
insertUpdate($Q,$J,$kg){foreach($J
as$N){if(!$this->update($Q,$N,"WHERE `itemName()` = ".q($N["`itemName()`"])))return
false;}return
true;}function
begin(){return
false;}function
commit(){return
false;}function
rollback(){return
false;}function
slowQuery($F,$fi){$this->_conn->timeout=$fi;return$F;}}function
connect(){global$b;list(,,$E)=$b->credentials();if($E!="")return'Database does not support password.';return
new
Min_DB;}function
support($Pc){return
preg_match('~sql~',$Pc);}function
logged_user(){global$b;$Hb=$b->credentials();return$Hb[1];}function
get_databases(){return
array("domain");}function
collations(){return
array();}function
db_collation($l,$pb){}function
tables_list(){global$g;$H=array();foreach(sdb_request_all('ListDomains','DomainName')as$Q)$H[(string)$Q]='table';if($g->error&&defined("PAGE_HEADER"))echo"".error()."\n";return$H;}function
table_status($B="",$Oc=false){$H=array();foreach(($B!=""?array($B=>true):tables_list())as$Q=>$T){$I=array("Name"=>$Q,"Auto_increment"=>"");if(!$Oc){$Qe=sdb_request('DomainMetadata',array('DomainName'=>$Q));if($Qe){foreach(array("Rows"=>"ItemCount","Data_length"=>"ItemNamesSizeBytes","Index_length"=>"AttributeValuesSizeBytes","Data_free"=>"AttributeNamesSizeBytes",)as$y=>$X)$I[$y]=(string)$Qe->$X;}}if($B!="")return$I;$H[$Q]=$I;}return$H;}function
explain($g,$F){}function
error(){global$g;return
h($g->error);}function
information_schema(){}function
is_view($R){}function
indexes($Q,$h=null){return
array(array("type"=>"PRIMARY","columns"=>array("itemName()")),);}function
fields($Q){return
fields_from_edit();}function
foreign_keys($Q){return
array();}function
table($u){return
idf_escape($u);}function
idf_escape($u){return"`".str_replace("`","``",$u)."`";}function
limit($F,$Z,$z,$C=0,$L=" "){return" $F$Z".($z!==null?$L."LIMIT $z":"");}function
unconvert_field($o,$H){return$H;}function
fk_support($R){}function
engines(){return
array();}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){return($Q==""&&sdb_request('CreateDomain',array('DomainName'=>$B)));}function
drop_tables($S){foreach($S
as$Q){if(!sdb_request('DeleteDomain',array('DomainName'=>$Q)))return
false;}return
true;}function
count_tables($k){foreach($k
as$l)return
array($l=>count(tables_list()));}function
found_rows($R,$Z){return($Z?null:$R["Rows"]);}function
last_id(){}function
hmac($Ba,$Mb,$y,$_g=false){$Va=64;if(strlen($y)>$Va)$y=pack("H*",$Ba($y));$y=str_pad($y,$Va,"\0");$ee=$y^str_repeat("\x36",$Va);$fe=$y^str_repeat("\x5C",$Va);$H=$Ba($fe.pack("H*",$Ba($ee.$Mb)));if($_g)$H=pack("H*",$H);return$H;}function
sdb_request($va,$Of=array()){global$b,$g;list($Ad,$Of['AWSAccessKeyId'],$dh)=$b->credentials();$Of['Action']=$va;$Of['Timestamp']=gmdate('Y-m-d\TH:i:s+00:00');$Of['Version']='2009-04-15';$Of['SignatureVersion']=2;$Of['SignatureMethod']='HmacSHA1';ksort($Of);$F='';foreach($Of
as$y=>$X)$F.='&'.rawurlencode($y).'='.rawurlencode($X);$F=str_replace('%7E','~',substr($F,1));$F.="&Signature=".urlencode(base64_encode(hmac('sha1',"POST\n".preg_replace('~^https?://~','',$Ad)."\n/\n$F",$dh,true)));@ini_set('track_errors',1);$Tc=@file_get_contents((preg_match('~^https?://~',$Ad)?$Ad:"http://$Ad"),false,stream_context_create(array('http'=>array('method'=>'POST','content'=>$F,'ignore_errors'=>1,))));if(!$Tc){$g->error=$php_errormsg;return
false;}libxml_use_internal_errors(true);$nj=simplexml_load_string($Tc);if(!$nj){$n=libxml_get_last_error();$g->error=$n->message;return
false;}if($nj->Errors){$n=$nj->Errors->Error;$g->error="$n->Message ($n->Code)";return
false;}$g->error='';$Wh=$va."Result";return($nj->$Wh?$nj->$Wh:true);}function
sdb_request_all($va,$Wh,$Of=array(),$fi=0){$H=array();$Dh=($fi?microtime(true):0);$z=(preg_match('~LIMIT\s+(\d+)\s*$~i',$Of['SelectExpression'],$A)?$A[1]:0);do{$nj=sdb_request($va,$Of);if(!$nj)break;foreach($nj->$Wh
as$pc)$H[]=$pc;if($z&&count($H)>=$z){$_GET["next"]=$nj->NextToken;break;}if($fi&µtime(true)-$Dh>$fi)return
false;$Of['NextToken']=$nj->NextToken;if($z)$Of['SelectExpression']=preg_replace('~\d+\s*$~',$z-count($H),$Of['SelectExpression']);}while($nj->NextToken);return$H;}$x="simpledb";$vf=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","IN","IS NULL","NOT LIKE","IS NOT NULL");$kd=array();$qd=array("count");$mc=array(array("json"));}$ec["mongo"]="MongoDB";if(isset($_GET["mongo"])){$hg=array("mongo","mongodb");define("DRIVER","mongo");if(class_exists('MongoDB')){class
Min_DB{var$extension="Mongo",$server_info=MongoClient::VERSION,$error,$last_id,$_link,$_db;function
connect($Ki,$yf){return@new
MongoClient($Ki,$yf);}function
query($F){return
false;}function
select_db($j){try{$this->_db=$this->_link->selectDB($j);return
true;}catch(Exception$Ac){$this->error=$Ac->getMessage();return
false;}}function
quote($P){return$P;}}class
Min_Result{var$num_rows,$_rows=array(),$_offset=0,$_charset=array();function
__construct($G){foreach($G
as$be){$I=array();foreach($be
as$y=>$X){if(is_a($X,'MongoBinData'))$this->_charset[$y]=63;$I[$y]=(is_a($X,'MongoId')?'ObjectId("'.strval($X).'")':(is_a($X,'MongoDate')?gmdate("Y-m-d H:i:s",$X->sec)." GMT":(is_a($X,'MongoBinData')?$X->bin:(is_a($X,'MongoRegex')?strval($X):(is_object($X)?get_class($X):$X)))));}$this->_rows[]=$I;foreach($I
as$y=>$X){if(!isset($this->_rows[0][$y]))$this->_rows[0][$y]=null;}}$this->num_rows=count($this->_rows);}function
fetch_assoc(){$I=current($this->_rows);if(!$I)return$I;$H=array();foreach($this->_rows[0]as$y=>$X)$H[$y]=$I[$y];next($this->_rows);return$H;}function
fetch_row(){$H=$this->fetch_assoc();if(!$H)return$H;return
array_values($H);}function
fetch_field(){$he=array_keys($this->_rows[0]);$B=$he[$this->_offset++];return(object)array('name'=>$B,'charsetnr'=>$this->_charset[$B],);}}class
Min_Driver
extends
Min_SQL{public$kg="_id";function
select($Q,$K,$Z,$nd,$_f=array(),$z=1,$D=0,$mg=false){$K=($K==array("*")?array():array_fill_keys($K,true));$vh=array();foreach($_f
as$X){$X=preg_replace('~ DESC$~','',$X,1,$Eb);$vh[$X]=($Eb?-1:1);}return
new
Min_Result($this->_conn->_db->selectCollection($Q)->find(array(),$K)->sort($vh)->limit($z!=""?+$z:0)->skip($D*$z));}function
insert($Q,$N){try{$H=$this->_conn->_db->selectCollection($Q)->insert($N);$this->_conn->errno=$H['code'];$this->_conn->error=$H['err'];$this->_conn->last_id=$N['_id'];return!$H['err'];}catch(Exception$Ac){$this->_conn->error=$Ac->getMessage();return
false;}}}function
get_databases($ad){global$g;$H=array();$Rb=$g->_link->listDBs();foreach($Rb['databases']as$l)$H[]=$l['name'];return$H;}function
count_tables($k){global$g;$H=array();foreach($k
as$l)$H[$l]=count($g->_link->selectDB($l)->getCollectionNames(true));return$H;}function
tables_list(){global$g;return
array_fill_keys($g->_db->getCollectionNames(true),'table');}function
drop_databases($k){global$g;foreach($k
as$l){$Mg=$g->_link->selectDB($l)->drop();if(!$Mg['ok'])return
false;}return
true;}function
indexes($Q,$h=null){global$g;$H=array();foreach($g->_db->selectCollection($Q)->getIndexInfo()as$v){$Yb=array();foreach($v["key"]as$e=>$T)$Yb[]=($T==-1?'1':null);$H[$v["name"]]=array("type"=>($v["name"]=="_id_"?"PRIMARY":($v["unique"]?"UNIQUE":"INDEX")),"columns"=>array_keys($v["key"]),"lengths"=>array(),"descs"=>$Yb,);}return$H;}function
fields($Q){return
fields_from_edit();}function
found_rows($R,$Z){global$g;return$g->_db->selectCollection($_GET["select"])->count($Z);}$vf=array("=");}elseif(class_exists('MongoDB\Driver\Manager')){class
Min_DB{var$extension="MongoDB",$server_info=MONGODB_VERSION,$error,$last_id;var$_link;var$_db,$_db_name;function
connect($Ki,$yf){$kb='MongoDB\Driver\Manager';return
new$kb($Ki,$yf);}function
query($F){return
false;}function
select_db($j){$this->_db_name=$j;return
true;}function
quote($P){return$P;}}class
Min_Result{var$num_rows,$_rows=array(),$_offset=0,$_charset=array();function
__construct($G){foreach($G
as$be){$I=array();foreach($be
as$y=>$X){if(is_a($X,'MongoDB\BSON\Binary'))$this->_charset[$y]=63;$I[$y]=(is_a($X,'MongoDB\BSON\ObjectID')?'MongoDB\BSON\ObjectID("'.strval($X).'")':(is_a($X,'MongoDB\BSON\UTCDatetime')?$X->toDateTime()->format('Y-m-d H:i:s'):(is_a($X,'MongoDB\BSON\Binary')?$X->bin:(is_a($X,'MongoDB\BSON\Regex')?strval($X):(is_object($X)?json_encode($X,256):$X)))));}$this->_rows[]=$I;foreach($I
as$y=>$X){if(!isset($this->_rows[0][$y]))$this->_rows[0][$y]=null;}}$this->num_rows=$G->count;}function
fetch_assoc(){$I=current($this->_rows);if(!$I)return$I;$H=array();foreach($this->_rows[0]as$y=>$X)$H[$y]=$I[$y];next($this->_rows);return$H;}function
fetch_row(){$H=$this->fetch_assoc();if(!$H)return$H;return
array_values($H);}function
fetch_field(){$he=array_keys($this->_rows[0]);$B=$he[$this->_offset++];return(object)array('name'=>$B,'charsetnr'=>$this->_charset[$B],);}}class
Min_Driver
extends
Min_SQL{public$kg="_id";function
select($Q,$K,$Z,$nd,$_f=array(),$z=1,$D=0,$mg=false){global$g;$K=($K==array("*")?array():array_fill_keys($K,1));if(count($K)&&!isset($K['_id']))$K['_id']=0;$Z=where_to_query($Z);$vh=array();foreach($_f
as$X){$X=preg_replace('~ DESC$~','',$X,1,$Eb);$vh[$X]=($Eb?-1:1);}if(isset($_GET['limit'])&&is_numeric($_GET['limit'])&&$_GET['limit']>0)$z=$_GET['limit'];$z=min(200,max(1,(int)$z));$sh=$D*$z;$kb='MongoDB\Driver\Query';$F=new$kb($Z,array('projection'=>$K,'limit'=>$z,'skip'=>$sh,'sort'=>$vh));$Pg=$g->_link->executeQuery("$g->_db_name.$Q",$F);return
new
Min_Result($Pg);}function
update($Q,$N,$wg,$z=0,$L="\n"){global$g;$l=$g->_db_name;$Z=sql_query_where_parser($wg);$kb='MongoDB\Driver\BulkWrite';$Za=new$kb(array());if(isset($N['_id']))unset($N['_id']);$Jg=array();foreach($N
as$y=>$Y){if($Y=='NULL'){$Jg[$y]=1;unset($N[$y]);}}$Ji=array('$set'=>$N);if(count($Jg))$Ji['$unset']=$Jg;$Za->update($Z,$Ji,array('upsert'=>false));$Pg=$g->_link->executeBulkWrite("$l.$Q",$Za);$g->affected_rows=$Pg->getModifiedCount();return
true;}function
delete($Q,$wg,$z=0){global$g;$l=$g->_db_name;$Z=sql_query_where_parser($wg);$kb='MongoDB\Driver\BulkWrite';$Za=new$kb(array());$Za->delete($Z,array('limit'=>$z));$Pg=$g->_link->executeBulkWrite("$l.$Q",$Za);$g->affected_rows=$Pg->getDeletedCount();return
true;}function
insert($Q,$N){global$g;$l=$g->_db_name;$kb='MongoDB\Driver\BulkWrite';$Za=new$kb(array());if(isset($N['_id'])&&empty($N['_id']))unset($N['_id']);$Za->insert($N);$Pg=$g->_link->executeBulkWrite("$l.$Q",$Za);$g->affected_rows=$Pg->getInsertedCount();return
true;}}function
get_databases($ad){global$g;$H=array();$kb='MongoDB\Driver\Command';$sb=new$kb(array('listDatabases'=>1));$Pg=$g->_link->executeCommand('admin',$sb);foreach($Pg
as$Rb){foreach($Rb->databases
as$l)$H[]=$l->name;}return$H;}function
count_tables($k){$H=array();return$H;}function
tables_list(){global$g;$kb='MongoDB\Driver\Command';$sb=new$kb(array('listCollections'=>1));$Pg=$g->_link->executeCommand($g->_db_name,$sb);$qb=array();foreach($Pg
as$G)$qb[$G->name]='table';return$qb;}function
drop_databases($k){return
false;}function
indexes($Q,$h=null){global$g;$H=array();$kb='MongoDB\Driver\Command';$sb=new$kb(array('listIndexes'=>$Q));$Pg=$g->_link->executeCommand($g->_db_name,$sb);foreach($Pg
as$v){$Yb=array();$f=array();foreach(get_object_vars($v->key)as$e=>$T){$Yb[]=($T==-1?'1':null);$f[]=$e;}$H[$v->name]=array("type"=>($v->name=="_id_"?"PRIMARY":(isset($v->unique)?"UNIQUE":"INDEX")),"columns"=>$f,"lengths"=>array(),"descs"=>$Yb,);}return$H;}function
fields($Q){$p=fields_from_edit();if(!count($p)){global$m;$G=$m->select($Q,array("*"),null,null,array(),10);while($I=$G->fetch_assoc()){foreach($I
as$y=>$X){$I[$y]=null;$p[$y]=array("field"=>$y,"type"=>"string","null"=>($y!=$m->primary),"auto_increment"=>($y==$m->primary),"privileges"=>array("insert"=>1,"select"=>1,"update"=>1,),);}}}return$p;}function
found_rows($R,$Z){global$g;$Z=where_to_query($Z);$kb='MongoDB\Driver\Command';$sb=new$kb(array('count'=>$R['Name'],'query'=>$Z));$Pg=$g->_link->executeCommand($g->_db_name,$sb);$ni=$Pg->toArray();return$ni[0]->n;}function
sql_query_where_parser($wg){$wg=trim(preg_replace('/WHERE[\s]?[(]?\(?/','',$wg));$wg=preg_replace('/\)\)\)$/',')',$wg);$kj=explode(' AND ',$wg);$lj=explode(') OR (',$wg);$Z=array();foreach($kj
as$ij)$Z[]=trim($ij);if(count($lj)==1)$lj=array();elseif(count($lj)>1)$Z=array();return
where_to_query($Z,$lj);}function
where_to_query($gj=array(),$hj=array()){global$b;$Mb=array();foreach(array('and'=>$gj,'or'=>$hj)as$T=>$Z){if(is_array($Z)){foreach($Z
as$Hc){list($nb,$tf,$X)=explode(" ",$Hc,3);if($nb=="_id"){$X=str_replace('MongoDB\BSON\ObjectID("',"",$X);$X=str_replace('")',"",$X);$kb='MongoDB\BSON\ObjectID';$X=new$kb($X);}if(!in_array($tf,$b->operators))continue;if(preg_match('~^\(f\)(.+)~',$tf,$A)){$X=(float)$X;$tf=$A[1];}elseif(preg_match('~^\(date\)(.+)~',$tf,$A)){$Ob=new
DateTime($X);$kb='MongoDB\BSON\UTCDatetime';$X=new$kb($Ob->getTimestamp()*1000);$tf=$A[1];}switch($tf){case'=':$tf='$eq';break;case'!=':$tf='$ne';break;case'>':$tf='$gt';break;case'<':$tf='$lt';break;case'>=':$tf='$gte';break;case'<=':$tf='$lte';break;case'regex':$tf='$regex';break;default:continue
2;}if($T=='and')$Mb['$and'][]=array($nb=>array($tf=>$X));elseif($T=='or')$Mb['$or'][]=array($nb=>array($tf=>$X));}}}return$Mb;}$vf=array("=","!=",">","<",">=","<=","regex","(f)=","(f)!=","(f)>","(f)<","(f)>=","(f)<=","(date)=","(date)!=","(date)>","(date)<","(date)>=","(date)<=",);}function
table($u){return$u;}function
idf_escape($u){return$u;}function
table_status($B="",$Oc=false){$H=array();foreach(tables_list()as$Q=>$T){$H[$Q]=array("Name"=>$Q);if($B==$Q)return$H[$Q];}return$H;}function
create_database($l,$d){return
true;}function
last_id(){global$g;return$g->last_id;}function
error(){global$g;return
h($g->error);}function
collations(){return
array();}function
logged_user(){global$b;$Hb=$b->credentials();return$Hb[1];}function
connect(){global$b;$g=new
Min_DB;list($M,$V,$E)=$b->credentials();$yf=array();if($V.$E!=""){$yf["username"]=$V;$yf["password"]=$E;}$l=$b->database();if($l!="")$yf["db"]=$l;if(($La=getenv("MONGO_AUTH_SOURCE")))$yf["authSource"]=$La;try{$g->_link=$g->connect("mongodb://$M",$yf);if($E!=""){$yf["password"]="";try{$g->connect("mongodb://$M",$yf);return'Database does not support password.';}catch(Exception$Ac){}}return$g;}catch(Exception$Ac){return$Ac->getMessage();}}function
alter_indexes($Q,$c){global$g;foreach($c
as$X){list($T,$B,$N)=$X;if($N=="DROP")$H=$g->_db->command(array("deleteIndexes"=>$Q,"index"=>$B));else{$f=array();foreach($N
as$e){$e=preg_replace('~ DESC$~','',$e,1,$Eb);$f[$e]=($Eb?-1:1);}$H=$g->_db->selectCollection($Q)->ensureIndex($f,array("unique"=>($T=="UNIQUE"),"name"=>$B,));}if($H['errmsg']){$g->error=$H['errmsg'];return
false;}}return
true;}function
support($Pc){return
preg_match("~database|indexes|descidx~",$Pc);}function
db_collation($l,$pb){}function
information_schema(){}function
is_view($R){}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
foreign_keys($Q){return
array();}function
fk_support($R){}function
engines(){return
array();}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){global$g;if($Q==""){$g->_db->createCollection($B);return
true;}}function
drop_tables($S){global$g;foreach($S
as$Q){$Mg=$g->_db->selectCollection($Q)->drop();if(!$Mg['ok'])return
false;}return
true;}function
truncate_tables($S){global$g;foreach($S
as$Q){$Mg=$g->_db->selectCollection($Q)->remove();if(!$Mg['ok'])return
false;}return
true;}$x="mongo";$kd=array();$qd=array();$mc=array(array("json"));}$ec["elastic"]="Elasticsearch (beta)";if(isset($_GET["elastic"])){$hg=array("json + allow_url_fopen");define("DRIVER","elastic");if(function_exists('json_decode')&&ini_bool('allow_url_fopen')){class
Min_DB{var$extension="JSON",$server_info,$errno,$error,$_url;function
rootQuery($Yf,$_b=array(),$Re='GET'){@ini_set('track_errors',1);$Tc=@file_get_contents("$this->_url/".ltrim($Yf,'/'),false,stream_context_create(array('http'=>array('method'=>$Re,'content'=>$_b===null?$_b:json_encode($_b),'header'=>'Content-Type: application/json','ignore_errors'=>1,))));if(!$Tc){$this->error=$php_errormsg;return$Tc;}if(!preg_match('~^HTTP/[0-9.]+ 2~i',$http_response_header[0])){$this->error=$Tc;return
false;}$H=json_decode($Tc,true);if($H===null){$this->errno=json_last_error();if(function_exists('json_last_error_msg'))$this->error=json_last_error_msg();else{$zb=get_defined_constants(true);foreach($zb['json']as$B=>$Y){if($Y==$this->errno&&preg_match('~^JSON_ERROR_~',$B)){$this->error=$B;break;}}}}return$H;}function
query($Yf,$_b=array(),$Re='GET'){return$this->rootQuery(($this->_db!=""?"$this->_db/":"/").ltrim($Yf,'/'),$_b,$Re);}function
connect($M,$V,$E){preg_match('~^(https?://)?(.*)~',$M,$A);$this->_url=($A[1]?$A[1]:"http://")."$V:$E@$A[2]";$H=$this->query('');if($H)$this->server_info=$H['version']['number'];return(bool)$H;}function
select_db($j){$this->_db=$j;return
true;}function
quote($P){return$P;}}class
Min_Result{var$num_rows,$_rows;function
__construct($J){$this->num_rows=count($J);$this->_rows=$J;reset($this->_rows);}function
fetch_assoc(){$H=current($this->_rows);next($this->_rows);return$H;}function
fetch_row(){return
array_values($this->fetch_assoc());}}}class
Min_Driver
extends
Min_SQL{function
select($Q,$K,$Z,$nd,$_f=array(),$z=1,$D=0,$mg=false){global$b;$Mb=array();$F="$Q/_search";if($K!=array("*"))$Mb["fields"]=$K;if($_f){$vh=array();foreach($_f
as$nb){$nb=preg_replace('~ DESC$~','',$nb,1,$Eb);$vh[]=($Eb?array($nb=>"desc"):$nb);}$Mb["sort"]=$vh;}if($z){$Mb["size"]=+$z;if($D)$Mb["from"]=($D*$z);}foreach($Z
as$X){list($nb,$tf,$X)=explode(" ",$X,3);if($nb=="_id")$Mb["query"]["ids"]["values"][]=$X;elseif($nb.$X!=""){$ai=array("term"=>array(($nb!=""?$nb:"_all")=>$X));if($tf=="=")$Mb["query"]["filtered"]["filter"]["and"][]=$ai;else$Mb["query"]["filtered"]["query"]["bool"]["must"][]=$ai;}}if($Mb["query"]&&!$Mb["query"]["filtered"]["query"]&&!$Mb["query"]["ids"])$Mb["query"]["filtered"]["query"]=array("match_all"=>array());$Dh=microtime(true);$ch=$this->_conn->query($F,$Mb);if($mg)echo$b->selectQuery("$F: ".json_encode($Mb),$Dh,!$ch);if(!$ch)return
false;$H=array();foreach($ch['hits']['hits']as$_d){$I=array();if($K==array("*"))$I["_id"]=$_d["_id"];$p=$_d['_source'];if($K!=array("*")){$p=array();foreach($K
as$y)$p[$y]=$_d['fields'][$y];}foreach($p
as$y=>$X){if($Mb["fields"])$X=$X[0];$I[$y]=(is_array($X)?json_encode($X):$X);}$H[]=$I;}return
new
Min_Result($H);}function
update($T,$Ag,$wg,$z=0,$L="\n"){$Wf=preg_split('~ *= *~',$wg);if(count($Wf)==2){$t=trim($Wf[1]);$F="$T/$t";return$this->_conn->query($F,$Ag,'POST');}return
false;}function
insert($T,$Ag){$t="";$F="$T/$t";$Mg=$this->_conn->query($F,$Ag,'POST');$this->_conn->last_id=$Mg['_id'];return$Mg['created'];}function
delete($T,$wg,$z=0){$Ed=array();if(is_array($_GET["where"])&&$_GET["where"]["_id"])$Ed[]=$_GET["where"]["_id"];if(is_array($_POST['check'])){foreach($_POST['check']as$db){$Wf=preg_split('~ *= *~',$db);if(count($Wf)==2)$Ed[]=trim($Wf[1]);}}$this->_conn->affected_rows=0;foreach($Ed
as$t){$F="{$T}/{$t}";$Mg=$this->_conn->query($F,'{}','DELETE');if(is_array($Mg)&&$Mg['found']==true)$this->_conn->affected_rows++;}return$this->_conn->affected_rows;}}function
connect(){global$b;$g=new
Min_DB;list($M,$V,$E)=$b->credentials();if($E!=""&&$g->connect($M,$V,""))return'Database does not support password.';if($g->connect($M,$V,$E))return$g;return$g->error;}function
support($Pc){return
preg_match("~database|table|columns~",$Pc);}function
logged_user(){global$b;$Hb=$b->credentials();return$Hb[1];}function
get_databases(){global$g;$H=$g->rootQuery('_aliases');if($H){$H=array_keys($H);sort($H,SORT_STRING);}return$H;}function
collations(){return
array();}function
db_collation($l,$pb){}function
engines(){return
array();}function
count_tables($k){global$g;$H=array();$G=$g->query('_stats');if($G&&$G['indices']){$Md=$G['indices'];foreach($Md
as$Ld=>$Eh){$Kd=$Eh['total']['indexing'];$H[$Ld]=$Kd['index_total'];}}return$H;}function
tables_list(){global$g;$H=$g->query('_mapping');if($H)$H=array_fill_keys(array_keys($H[$g->_db]["mappings"]),'table');return$H;}function
table_status($B="",$Oc=false){global$g;$ch=$g->query("_search",array("size"=>0,"aggregations"=>array("count_by_type"=>array("terms"=>array("field"=>"_type")))),"POST");$H=array();if($ch){$S=$ch["aggregations"]["count_by_type"]["buckets"];foreach($S
as$Q){$H[$Q["key"]]=array("Name"=>$Q["key"],"Engine"=>"table","Rows"=>$Q["doc_count"],);if($B!=""&&$B==$Q["key"])return$H[$B];}}return$H;}function
error(){global$g;return
h($g->error);}function
information_schema(){}function
is_view($R){}function
indexes($Q,$h=null){return
array(array("type"=>"PRIMARY","columns"=>array("_id")),);}function
fields($Q){global$g;$G=$g->query("$Q/_mapping");$H=array();if($G){$_e=$G[$Q]['properties'];if(!$_e)$_e=$G[$g->_db]['mappings'][$Q]['properties'];if($_e){foreach($_e
as$B=>$o){$H[$B]=array("field"=>$B,"full_type"=>$o["type"],"type"=>$o["type"],"privileges"=>array("insert"=>1,"select"=>1,"update"=>1),);if($o["properties"]){unset($H[$B]["privileges"]["insert"]);unset($H[$B]["privileges"]["update"]);}}}}return$H;}function
foreign_keys($Q){return
array();}function
table($u){return$u;}function
idf_escape($u){return$u;}function
convert_field($o){}function
unconvert_field($o,$H){return$H;}function
fk_support($R){}function
found_rows($R,$Z){return
null;}function
create_database($l){global$g;return$g->rootQuery(urlencode($l),null,'PUT');}function
drop_databases($k){global$g;return$g->rootQuery(urlencode(implode(',',$k)),array(),'DELETE');}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){global$g;$sg=array();foreach($p
as$Mc){$Rc=trim($Mc[1][0]);$Sc=trim($Mc[1][1]?$Mc[1][1]:"text");$sg[$Rc]=array('type'=>$Sc);}if(!empty($sg))$sg=array('properties'=>$sg);return$g->query("_mapping/{$B}",$sg,'PUT');}function
drop_tables($S){global$g;$H=true;foreach($S
as$Q)$H=$H&&$g->query(urlencode($Q),array(),'DELETE');return$H;}function
last_id(){global$g;return$g->last_id;}$x="elastic";$vf=array("=","query");$kd=array();$qd=array();$mc=array(array("json"));$U=array();$Hh=array();foreach(array('Numbers'=>array("long"=>3,"integer"=>5,"short"=>8,"byte"=>10,"double"=>20,"float"=>66,"half_float"=>12,"scaled_float"=>21),'Date and time'=>array("date"=>10),'Strings'=>array("string"=>65535,"text"=>65535),'Binary'=>array("binary"=>255),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}}$ec["clickhouse"]="ClickHouse (alpha)";if(isset($_GET["clickhouse"])){define("DRIVER","clickhouse");class
Min_DB{var$extension="JSON",$server_info,$errno,$_result,$error,$_url;var$_db='default';function
rootQuery($l,$F){@ini_set('track_errors',1);$Tc=@file_get_contents("$this->_url/?database=$l",false,stream_context_create(array('http'=>array('method'=>'POST','content'=>$this->isQuerySelectLike($F)?"$F FORMAT JSONCompact":$F,'header'=>'Content-type: application/x-www-form-urlencoded','ignore_errors'=>1,))));if($Tc===false){$this->error=$php_errormsg;return$Tc;}if(!preg_match('~^HTTP/[0-9.]+ 2~i',$http_response_header[0])){$this->error=$Tc;return
false;}$H=json_decode($Tc,true);if($H===null){if(!$this->isQuerySelectLike($F)&&$Tc==='')return
true;$this->errno=json_last_error();if(function_exists('json_last_error_msg'))$this->error=json_last_error_msg();else{$zb=get_defined_constants(true);foreach($zb['json']as$B=>$Y){if($Y==$this->errno&&preg_match('~^JSON_ERROR_~',$B)){$this->error=$B;break;}}}}return
new
Min_Result($H);}function
isQuerySelectLike($F){return(bool)preg_match('~^(select|show)~i',$F);}function
query($F){return$this->rootQuery($this->_db,$F);}function
connect($M,$V,$E){preg_match('~^(https?://)?(.*)~',$M,$A);$this->_url=($A[1]?$A[1]:"http://")."$V:$E@$A[2]";$H=$this->query('SELECT 1');return(bool)$H;}function
select_db($j){$this->_db=$j;return
true;}function
quote($P){return"'".addcslashes($P,"\\'")."'";}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
result($F,$o=0){$G=$this->query($F);return$G['data'];}}class
Min_Result{var$num_rows,$_rows,$columns,$meta,$_offset=0;function
__construct($G){$this->num_rows=$G['rows'];$this->_rows=$G['data'];$this->meta=$G['meta'];$this->columns=array_column($this->meta,'name');reset($this->_rows);}function
fetch_assoc(){$I=current($this->_rows);next($this->_rows);return$I===false?false:array_combine($this->columns,$I);}function
fetch_row(){$I=current($this->_rows);next($this->_rows);return$I;}function
fetch_field(){$e=$this->_offset++;$H=new
stdClass;if($ecolumns)){$H->name=$this->meta[$e]['name'];$H->orgname=$H->name;$H->type=$this->meta[$e]['type'];}return$H;}}class
Min_Driver
extends
Min_SQL{function
delete($Q,$wg,$z=0){if($wg==='')$wg='WHERE 1=1';return
queries("ALTER TABLE ".table($Q)." DELETE $wg");}function
update($Q,$N,$wg,$z=0,$L="\n"){$Vi=array();foreach($N
as$y=>$X)$Vi[]="$y = $X";$F=$L.implode(",$L",$Vi);return
queries("ALTER TABLE ".table($Q)." UPDATE $F$wg");}}function
idf_escape($u){return"`".str_replace("`","``",$u)."`";}function
table($u){return
idf_escape($u);}function
explain($g,$F){return'';}function
found_rows($R,$Z){$J=get_vals("SELECT COUNT(*) FROM ".idf_escape($R["Name"]).($Z?" WHERE ".implode(" AND ",$Z):""));return
empty($J)?false:$J[0];}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){$c=$_f=array();foreach($p
as$o){if($o[1][2]===" NULL")$o[1][1]=" Nullable({$o[1][1]})";elseif($o[1][2]===' NOT NULL')$o[1][2]='';if($o[1][3])$o[1][3]='';$c[]=($o[1]?($Q!=""?($o[0]!=""?"MODIFY COLUMN ":"ADD COLUMN "):" ").implode($o[1]):"DROP COLUMN ".idf_escape($o[0]));$_f[]=$o[1][0];}$c=array_merge($c,$cd);$O=($uc?" ENGINE ".$uc:"");if($Q=="")return
queries("CREATE TABLE ".table($B)." (\n".implode(",\n",$c)."\n)$O$Uf".' ORDER BY ('.implode(',',$_f).')');if($Q!=$B){$G=queries("RENAME TABLE ".table($Q)." TO ".table($B));if($c)$Q=$B;else
return$G;}if($O)$c[]=ltrim($O);return($c||$Uf?queries("ALTER TABLE ".table($Q)."\n".implode(",\n",$c).$Uf):true);}function
truncate_tables($S){return
apply_queries("TRUNCATE TABLE",$S);}function
drop_views($aj){return
drop_tables($aj);}function
drop_tables($S){return
apply_queries("DROP TABLE",$S);}function
connect(){global$b;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2]))return$g;return$g->error;}function
get_databases($ad){global$g;$G=get_rows('SHOW DATABASES');$H=array();foreach($G
as$I)$H[]=$I['name'];sort($H);return$H;}function
limit($F,$Z,$z,$C=0,$L=" "){return" $F$Z".($z!==null?$L."LIMIT $z".($C?", $C":""):"");}function
limit1($Q,$F,$Z,$L="\n"){return
limit($F,$Z,1,0,$L);}function
db_collation($l,$pb){}function
engines(){return
array('MergeTree');}function
logged_user(){global$b;$Hb=$b->credentials();return$Hb[1];}function
tables_list(){$G=get_rows('SHOW TABLES');$H=array();foreach($G
as$I)$H[$I['name']]='table';ksort($H);return$H;}function
count_tables($k){return
array();}function
table_status($B="",$Oc=false){global$g;$H=array();$S=get_rows("SELECT name, engine FROM system.tables WHERE database = ".q($g->_db));foreach($S
as$Q){$H[$Q['name']]=array('Name'=>$Q['name'],'Engine'=>$Q['engine'],);if($B===$Q['name'])return$H[$Q['name']];}return$H;}function
is_view($R){return
false;}function
fk_support($R){return
false;}function
convert_field($o){}function
unconvert_field($o,$H){if(in_array($o['type'],array("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64","Float32","Float64")))return"to$o[type]($H)";return$H;}function
fields($Q){$H=array();$G=get_rows("SELECT name, type, default_expression FROM system.columns WHERE ".idf_escape('table')." = ".q($Q));foreach($G
as$I){$T=trim($I['type']);$ff=strpos($T,'Nullable(')===0;$H[trim($I['name'])]=array("field"=>trim($I['name']),"full_type"=>$T,"type"=>$T,"default"=>trim($I['default_expression']),"null"=>$ff,"auto_increment"=>'0',"privileges"=>array("insert"=>1,"select"=>1,"update"=>0),);}return$H;}function
indexes($Q,$h=null){return
array();}function
foreign_keys($Q){return
array();}function
collations(){return
array();}function
information_schema($l){return
false;}function
error(){global$g;return
h($g->error);}function
types(){return
array();}function
schemas(){return
array();}function
get_schema(){return"";}function
set_schema($ah){return
true;}function
auto_increment(){return'';}function
last_id(){return
0;}function
support($Pc){return
preg_match("~^(columns|sql|status|table|drop_col)$~",$Pc);}$x="clickhouse";$U=array();$Hh=array();foreach(array('Numbers'=>array("Int8"=>3,"Int16"=>5,"Int32"=>10,"Int64"=>19,"UInt8"=>3,"UInt16"=>5,"UInt32"=>10,"UInt64"=>20,"Float32"=>7,"Float64"=>16,'Decimal'=>38,'Decimal32'=>9,'Decimal64'=>18,'Decimal128'=>38),'Date and time'=>array("Date"=>13,"DateTime"=>20),'Strings'=>array("String"=>0),'Binary'=>array("FixedString"=>0),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}$Ii=array();$vf=array("=","<",">","<=",">=","!=","~","!~","LIKE","LIKE %%","IN","IS NULL","NOT LIKE","NOT IN","IS NOT NULL","SQL");$kd=array();$qd=array("avg","count","count distinct","max","min","sum");$mc=array();}$ec=array("server"=>"MySQL")+$ec;if(!defined("DRIVER")){$hg=array("MySQLi","MySQL","PDO_MySQL");define("DRIVER","server");if(extension_loaded("mysqli")){class
Min_DB
extends
MySQLi{var$extension="MySQLi";function
__construct(){parent::init();}function
connect($M="",$V="",$E="",$j=null,$dg=null,$uh=null){global$b;mysqli_report(MYSQLI_REPORT_OFF);list($Ad,$dg)=explode(":",$M,2);$Ch=$b->connectSsl();if($Ch)$this->ssl_set($Ch['key'],$Ch['cert'],$Ch['ca'],'','');$H=@$this->real_connect(($M!=""?$Ad:ini_get("mysqli.default_host")),($M.$V!=""?$V:ini_get("mysqli.default_user")),($M.$V.$E!=""?$E:ini_get("mysqli.default_pw")),$j,(is_numeric($dg)?$dg:ini_get("mysqli.default_port")),(!is_numeric($dg)?$dg:$uh),($Ch?64:0));$this->options(MYSQLI_OPT_LOCAL_INFILE,false);return$H;}function
set_charset($cb){if(parent::set_charset($cb))return
true;parent::set_charset('utf8');return$this->query("SET NAMES $cb");}function
result($F,$o=0){$G=$this->query($F);if(!$G)return
false;$I=$G->fetch_array();return$I[$o];}function
quote($P){return"'".$this->escape_string($P)."'";}}}elseif(extension_loaded("mysql")&&!((ini_bool("sql.safe_mode")||ini_bool("mysql.allow_local_infile"))&&extension_loaded("pdo_mysql"))){class
Min_DB{var$extension="MySQL",$server_info,$affected_rows,$errno,$error,$_link,$_result;function
connect($M,$V,$E){if(ini_bool("mysql.allow_local_infile")){$this->error=sprintf('Disable %s or enable %s or %s extensions.',"'mysql.allow_local_infile'","MySQLi","PDO_MySQL");return
false;}$this->_link=@mysql_connect(($M!=""?$M:ini_get("mysql.default_host")),("$M$V"!=""?$V:ini_get("mysql.default_user")),("$M$V$E"!=""?$E:ini_get("mysql.default_password")),true,131072);if($this->_link)$this->server_info=mysql_get_server_info($this->_link);else$this->error=mysql_error();return(bool)$this->_link;}function
set_charset($cb){if(function_exists('mysql_set_charset')){if(mysql_set_charset($cb,$this->_link))return
true;mysql_set_charset('utf8',$this->_link);}return$this->query("SET NAMES $cb");}function
quote($P){return"'".mysql_real_escape_string($P,$this->_link)."'";}function
select_db($j){return
mysql_select_db($j,$this->_link);}function
query($F,$Ci=false){$G=@($Ci?mysql_unbuffered_query($F,$this->_link):mysql_query($F,$this->_link));$this->error="";if(!$G){$this->errno=mysql_errno($this->_link);$this->error=mysql_error($this->_link);return
false;}if($G===true){$this->affected_rows=mysql_affected_rows($this->_link);$this->info=mysql_info($this->_link);return
true;}return
new
Min_Result($G);}function
multi_query($F){return$this->_result=$this->query($F);}function
store_result(){return$this->_result;}function
next_result(){return
false;}function
result($F,$o=0){$G=$this->query($F);if(!$G||!$G->num_rows)return
false;return
mysql_result($G->_result,0,$o);}}class
Min_Result{var$num_rows,$_result,$_offset=0;function
__construct($G){$this->_result=$G;$this->num_rows=mysql_num_rows($G);}function
fetch_assoc(){return
mysql_fetch_assoc($this->_result);}function
fetch_row(){return
mysql_fetch_row($this->_result);}function
fetch_field(){$H=mysql_fetch_field($this->_result,$this->_offset++);$H->orgtable=$H->table;$H->orgname=$H->name;$H->charsetnr=($H->blob?63:0);return$H;}function
__destruct(){mysql_free_result($this->_result);}}}elseif(extension_loaded("pdo_mysql")){class
Min_DB
extends
Min_PDO{var$extension="PDO_MySQL";function
connect($M,$V,$E){global$b;$yf=array(PDO::MYSQL_ATTR_LOCAL_INFILE=>false);$Ch=$b->connectSsl();if($Ch){if(!empty($Ch['key']))$yf[PDO::MYSQL_ATTR_SSL_KEY]=$Ch['key'];if(!empty($Ch['cert']))$yf[PDO::MYSQL_ATTR_SSL_CERT]=$Ch['cert'];if(!empty($Ch['ca']))$yf[PDO::MYSQL_ATTR_SSL_CA]=$Ch['ca'];}$this->dsn("mysql:charset=utf8;host=".str_replace(":",";unix_socket=",preg_replace('~:(\d)~',';port=\1',$M)),$V,$E,$yf);return
true;}function
set_charset($cb){$this->query("SET NAMES $cb");}function
select_db($j){return$this->query("USE ".idf_escape($j));}function
query($F,$Ci=false){$this->setAttribute(1000,!$Ci);return
parent::query($F,$Ci);}}}class
Min_Driver
extends
Min_SQL{function
insert($Q,$N){return($N?parent::insert($Q,$N):queries("INSERT INTO ".table($Q)." ()\nVALUES ()"));}function
insertUpdate($Q,$J,$kg){$f=array_keys(reset($J));$ig="INSERT INTO ".table($Q)." (".implode(", ",$f).") VALUES\n";$Vi=array();foreach($f
as$y)$Vi[$y]="$y = VALUES($y)";$Kh="\nON DUPLICATE KEY UPDATE ".implode(", ",$Vi);$Vi=array();$te=0;foreach($J
as$N){$Y="(".implode(", ",$N).")";if($Vi&&(strlen($ig)+$te+strlen($Y)+strlen($Kh)>1e6)){if(!queries($ig.implode(",\n",$Vi).$Kh))return
false;$Vi=array();$te=0;}$Vi[]=$Y;$te+=strlen($Y)+2;}return
queries($ig.implode(",\n",$Vi).$Kh);}function
slowQuery($F,$fi){if(min_version('5.7.8','10.1.2')){if(preg_match('~MariaDB~',$this->_conn->server_info))return"SET STATEMENT max_statement_time=$fi FOR $F";elseif(preg_match('~^(SELECT\b)(.+)~is',$F,$A))return"$A[1] /*+ MAX_EXECUTION_TIME(".($fi*1000).") */ $A[2]";}}function
convertSearch($u,$X,$o){return(preg_match('~char|text|enum|set~',$o["type"])&&!preg_match("~^utf8~",$o["collation"])&&preg_match('~[\x80-\xFF]~',$X['val'])?"CONVERT($u USING ".charset($this->_conn).")":$u);}function
warnings(){$G=$this->_conn->query("SHOW WARNINGS");if($G&&$G->num_rows){ob_start();select($G);return
ob_get_clean();}}function
tableHelp($B){$Ae=preg_match('~MariaDB~',$this->_conn->server_info);if(information_schema(DB))return
strtolower(($Ae?"information-schema-$B-table/":str_replace("_","-",$B)."-table.html"));if(DB=="mysql")return($Ae?"mysql$B-table/":"system-database.html");}}function
idf_escape($u){return"`".str_replace("`","``",$u)."`";}function
table($u){return
idf_escape($u);}function
connect(){global$b,$U,$Hh;$g=new
Min_DB;$Hb=$b->credentials();if($g->connect($Hb[0],$Hb[1],$Hb[2])){$g->set_charset(charset($g));$g->query("SET sql_quote_show_create = 1, autocommit = 1");if(min_version('5.7.8',10.2,$g)){$Hh['Strings'][]="json";$U["json"]=4294967295;}return$g;}$H=$g->error;if(function_exists('iconv')&&!is_utf8($H)&&strlen($Yg=iconv("windows-1250","utf-8",$H))>strlen($H))$H=$Yg;return$H;}function
get_databases($ad){$H=get_session("dbs");if($H===null){$F=(min_version(5)?"SELECT SCHEMA_NAME FROM information_schema.SCHEMATA ORDER BY SCHEMA_NAME":"SHOW DATABASES");$H=($ad?slow_query($F):get_vals($F));restart_session();set_session("dbs",$H);stop_session();}return$H;}function
limit($F,$Z,$z,$C=0,$L=" "){return" $F$Z".($z!==null?$L."LIMIT $z".($C?" OFFSET $C":""):"");}function
limit1($Q,$F,$Z,$L="\n"){return
limit($F,$Z,1,0,$L);}function
db_collation($l,$pb){global$g;$H=null;$i=$g->result("SHOW CREATE DATABASE ".idf_escape($l),1);if(preg_match('~ COLLATE ([^ ]+)~',$i,$A))$H=$A[1];elseif(preg_match('~ CHARACTER SET ([^ ]+)~',$i,$A))$H=$pb[$A[1]][-1];return$H;}function
engines(){$H=array();foreach(get_rows("SHOW ENGINES")as$I){if(preg_match("~YES|DEFAULT~",$I["Support"]))$H[]=$I["Engine"];}return$H;}function
logged_user(){global$g;return$g->result("SELECT USER()");}function
tables_list(){return
get_key_vals(min_version(5)?"SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME":"SHOW TABLES");}function
count_tables($k){$H=array();foreach($k
as$l)$H[$l]=count(get_vals("SHOW TABLES IN ".idf_escape($l)));return$H;}function
table_status($B="",$Oc=false){$H=array();foreach(get_rows($Oc&&min_version(5)?"SELECT TABLE_NAME AS Name, ENGINE AS Engine, TABLE_COMMENT AS Comment FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ".($B!=""?"AND TABLE_NAME = ".q($B):"ORDER BY Name"):"SHOW TABLE STATUS".($B!=""?" LIKE ".q(addcslashes($B,"%_\\")):""))as$I){if($I["Engine"]=="InnoDB")$I["Comment"]=preg_replace('~(?:(.+); )?InnoDB free: .*~','\1',$I["Comment"]);if(!isset($I["Engine"]))$I["Comment"]="";if($B!="")return$I;$H[$I["Name"]]=$I;}return$H;}function
is_view($R){return$R["Engine"]===null;}function
fk_support($R){return
preg_match('~InnoDB|IBMDB2I~i',$R["Engine"])||(preg_match('~NDB~i',$R["Engine"])&&min_version(5.6));}function
fields($Q){$H=array();foreach(get_rows("SHOW FULL COLUMNS FROM ".table($Q))as$I){preg_match('~^([^( ]+)(?:\((.+)\))?( unsigned)?( zerofill)?$~',$I["Type"],$A);$H[$I["Field"]]=array("field"=>$I["Field"],"full_type"=>$I["Type"],"type"=>$A[1],"length"=>$A[2],"unsigned"=>ltrim($A[3].$A[4]),"default"=>($I["Default"]!=""||preg_match("~char|set~",$A[1])?$I["Default"]:null),"null"=>($I["Null"]=="YES"),"auto_increment"=>($I["Extra"]=="auto_increment"),"on_update"=>(preg_match('~^on update (.+)~i',$I["Extra"],$A)?$A[1]:""),"collation"=>$I["Collation"],"privileges"=>array_flip(preg_split('~, *~',$I["Privileges"])),"comment"=>$I["Comment"],"primary"=>($I["Key"]=="PRI"),"generated"=>preg_match('~^(VIRTUAL|PERSISTENT|STORED)~',$I["Extra"]),);}return$H;}function
indexes($Q,$h=null){$H=array();foreach(get_rows("SHOW INDEX FROM ".table($Q),$h)as$I){$B=$I["Key_name"];$H[$B]["type"]=($B=="PRIMARY"?"PRIMARY":($I["Index_type"]=="FULLTEXT"?"FULLTEXT":($I["Non_unique"]?($I["Index_type"]=="SPATIAL"?"SPATIAL":"INDEX"):"UNIQUE")));$H[$B]["columns"][]=$I["Column_name"];$H[$B]["lengths"][]=($I["Index_type"]=="SPATIAL"?null:$I["Sub_part"]);$H[$B]["descs"][]=null;}return$H;}function
foreign_keys($Q){global$g,$qf;static$ag='(?:`(?:[^`]|``)+`|"(?:[^"]|"")+")';$H=array();$Fb=$g->result("SHOW CREATE TABLE ".table($Q),1);if($Fb){preg_match_all("~CONSTRAINT ($ag) FOREIGN KEY ?\\(((?:$ag,? ?)+)\\) REFERENCES ($ag)(?:\\.($ag))? \\(((?:$ag,? ?)+)\\)(?: ON DELETE ($qf))?(?: ON UPDATE ($qf))?~",$Fb,$De,PREG_SET_ORDER);foreach($De
as$A){preg_match_all("~$ag~",$A[2],$wh);preg_match_all("~$ag~",$A[5],$Xh);$H[idf_unescape($A[1])]=array("db"=>idf_unescape($A[4]!=""?$A[3]:$A[4]),"table"=>idf_unescape($A[4]!=""?$A[4]:$A[3]),"source"=>array_map('idf_unescape',$wh[0]),"target"=>array_map('idf_unescape',$Xh[0]),"on_delete"=>($A[6]?$A[6]:"RESTRICT"),"on_update"=>($A[7]?$A[7]:"RESTRICT"),);}}return$H;}function
view($B){global$g;return
array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\s+AS\s+~isU','',$g->result("SHOW CREATE VIEW ".table($B),1)));}function
collations(){$H=array();foreach(get_rows("SHOW COLLATION")as$I){if($I["Default"])$H[$I["Charset"]][-1]=$I["Collation"];else$H[$I["Charset"]][]=$I["Collation"];}ksort($H);foreach($H
as$y=>$X)asort($H[$y]);return$H;}function
information_schema($l){return(min_version(5)&&$l=="information_schema")||(min_version(5.5)&&$l=="performance_schema");}function
error(){global$g;return
h(preg_replace('~^You have an error.*syntax to use~U',"Syntax error",$g->error));}function
create_database($l,$d){return
queries("CREATE DATABASE ".idf_escape($l).($d?" COLLATE ".q($d):""));}function
drop_databases($k){$H=apply_queries("DROP DATABASE",$k,'idf_escape');restart_session();set_session("dbs",null);return$H;}function
rename_database($B,$d){$H=false;if(create_database($B,$d)){$Kg=array();foreach(tables_list()as$Q=>$T)$Kg[]=table($Q)." TO ".idf_escape($B).".".table($Q);$H=(!$Kg||queries("RENAME TABLE ".implode(", ",$Kg)));if($H)queries("DROP DATABASE ".idf_escape(DB));restart_session();set_session("dbs",null);}return$H;}function
auto_increment(){$Na=" PRIMARY KEY";if($_GET["create"]!=""&&$_POST["auto_increment_col"]){foreach(indexes($_GET["create"])as$v){if(in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"],$v["columns"],true)){$Na="";break;}if($v["type"]=="PRIMARY")$Na=" UNIQUE";}}return" AUTO_INCREMENT$Na";}function
alter_table($Q,$B,$p,$cd,$ub,$uc,$d,$Ma,$Uf){$c=array();foreach($p
as$o)$c[]=($o[1]?($Q!=""?($o[0]!=""?"CHANGE ".idf_escape($o[0]):"ADD"):" ")." ".implode($o[1]).($Q!=""?$o[2]:""):"DROP ".idf_escape($o[0]));$c=array_merge($c,$cd);$O=($ub!==null?" COMMENT=".q($ub):"").($uc?" ENGINE=".q($uc):"").($d?" COLLATE ".q($d):"").($Ma!=""?" AUTO_INCREMENT=$Ma":"");if($Q=="")return
queries("CREATE TABLE ".table($B)." (\n".implode(",\n",$c)."\n)$O$Uf");if($Q!=$B)$c[]="RENAME TO ".table($B);if($O)$c[]=ltrim($O);return($c||$Uf?queries("ALTER TABLE ".table($Q)."\n".implode(",\n",$c).$Uf):true);}function
alter_indexes($Q,$c){foreach($c
as$y=>$X)$c[$y]=($X[2]=="DROP"?"\nDROP INDEX ".idf_escape($X[1]):"\nADD $X[0] ".($X[0]=="PRIMARY"?"KEY ":"").($X[1]!=""?idf_escape($X[1])." ":"")."(".implode(", ",$X[2]).")");return
queries("ALTER TABLE ".table($Q).implode(",",$c));}function
truncate_tables($S){return
apply_queries("TRUNCATE TABLE",$S);}function
drop_views($aj){return
queries("DROP VIEW ".implode(", ",array_map('table',$aj)));}function
drop_tables($S){return
queries("DROP TABLE ".implode(", ",array_map('table',$S)));}function
move_tables($S,$aj,$Xh){$Kg=array();foreach(array_merge($S,$aj)as$Q)$Kg[]=table($Q)." TO ".idf_escape($Xh).".".table($Q);return
queries("RENAME TABLE ".implode(", ",$Kg));}function
copy_tables($S,$aj,$Xh){queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'");foreach($S
as$Q){$B=($Xh==DB?table("copy_$Q"):idf_escape($Xh).".".table($Q));if(($_POST["overwrite"]&&!queries("\nDROP TABLE IF EXISTS $B"))||!queries("CREATE TABLE $B LIKE ".table($Q))||!queries("INSERT INTO $B SELECT * FROM ".table($Q)))return
false;foreach(get_rows("SHOW TRIGGERS LIKE ".q(addcslashes($Q,"%_\\")))as$I){$xi=$I["Trigger"];if(!queries("CREATE TRIGGER ".($Xh==DB?idf_escape("copy_$xi"):idf_escape($Xh).".".idf_escape($xi))." $I[Timing] $I[Event] ON $B FOR EACH ROW\n$I[Statement];"))return
false;}}foreach($aj
as$Q){$B=($Xh==DB?table("copy_$Q"):idf_escape($Xh).".".table($Q));$Zi=view($Q);if(($_POST["overwrite"]&&!queries("DROP VIEW IF EXISTS $B"))||!queries("CREATE VIEW $B AS $Zi[select]"))return
false;}return
true;}function
trigger($B){if($B=="")return
array();$J=get_rows("SHOW TRIGGERS WHERE `Trigger` = ".q($B));return
reset($J);}function
triggers($Q){$H=array();foreach(get_rows("SHOW TRIGGERS LIKE ".q(addcslashes($Q,"%_\\")))as$I)$H[$I["Trigger"]]=array($I["Timing"],$I["Event"]);return$H;}function
trigger_options(){return
array("Timing"=>array("BEFORE","AFTER"),"Event"=>array("INSERT","UPDATE","DELETE"),"Type"=>array("FOR EACH ROW"),);}function
routine($B,$T){global$g,$wc,$Rd,$U;$Ca=array("bool","boolean","integer","double precision","real","dec","numeric","fixed","national char","national varchar");$xh="(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)";$Bi="((".implode("|",array_merge(array_keys($U),$Ca)).")\\b(?:\\s*\\(((?:[^'\")]|$wc)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?";$ag="$xh*(".($T=="FUNCTION"?"":$Rd).")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$Bi";$i=$g->result("SHOW CREATE $T ".idf_escape($B),2);preg_match("~\\(((?:$ag\\s*,?)*)\\)\\s*".($T=="FUNCTION"?"RETURNS\\s+$Bi\\s+":"")."(.*)~is",$i,$A);$p=array();preg_match_all("~$ag\\s*,?~is",$A[1],$De,PREG_SET_ORDER);foreach($De
as$Nf)$p[]=array("field"=>str_replace("``","`",$Nf[2]).$Nf[3],"type"=>strtolower($Nf[5]),"length"=>preg_replace_callback("~$wc~s",'normalize_enum',$Nf[6]),"unsigned"=>strtolower(preg_replace('~\s+~',' ',trim("$Nf[8] $Nf[7]"))),"null"=>1,"full_type"=>$Nf[4],"inout"=>strtoupper($Nf[1]),"collation"=>strtolower($Nf[9]),);if($T!="FUNCTION")return
array("fields"=>$p,"definition"=>$A[11]);return
array("fields"=>$p,"returns"=>array("type"=>$A[12],"length"=>$A[13],"unsigned"=>$A[15],"collation"=>$A[16]),"definition"=>$A[17],"language"=>"SQL",);}function
routines(){return
get_rows("SELECT ROUTINE_NAME AS SPECIFIC_NAME, ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = ".q(DB));}function
routine_languages(){return
array();}function
routine_id($B,$I){return
idf_escape($B);}function
last_id(){global$g;return$g->result("SELECT LAST_INSERT_ID()");}function
explain($g,$F){return$g->query("EXPLAIN ".(min_version(5.1)?"PARTITIONS ":"").$F);}function
found_rows($R,$Z){return($Z||$R["Engine"]!="InnoDB"?null:$R["Rows"]);}function
types(){return
array();}function
schemas(){return
array();}function
get_schema(){return"";}function
set_schema($ah,$h=null){return
true;}function
create_sql($Q,$Ma,$Ih){global$g;$H=$g->result("SHOW CREATE TABLE ".table($Q),1);if(!$Ma)$H=preg_replace('~ AUTO_INCREMENT=\d+~','',$H);return$H;}function
truncate_sql($Q){return"TRUNCATE ".table($Q);}function
use_sql($j){return"USE ".idf_escape($j);}function
trigger_sql($Q){$H="";foreach(get_rows("SHOW TRIGGERS LIKE ".q(addcslashes($Q,"%_\\")),null,"-- ")as$I)$H.="\nCREATE TRIGGER ".idf_escape($I["Trigger"])." $I[Timing] $I[Event] ON ".table($I["Table"])." FOR EACH ROW\n$I[Statement];;\n";return$H;}function
show_variables(){return
get_key_vals("SHOW VARIABLES");}function
process_list(){return
get_rows("SHOW FULL PROCESSLIST");}function
show_status(){return
get_key_vals("SHOW STATUS");}function
convert_field($o){if(preg_match("~binary~",$o["type"]))return"HEX(".idf_escape($o["field"]).")";if($o["type"]=="bit")return"BIN(".idf_escape($o["field"])." + 0)";if(preg_match("~geometry|point|linestring|polygon~",$o["type"]))return(min_version(8)?"ST_":"")."AsWKT(".idf_escape($o["field"]).")";}function
unconvert_field($o,$H){if(preg_match("~binary~",$o["type"]))$H="UNHEX($H)";if($o["type"]=="bit")$H="CONV($H, 2, 10) + 0";if(preg_match("~geometry|point|linestring|polygon~",$o["type"]))$H=(min_version(8)?"ST_":"")."GeomFromText($H, SRID($o[field]))";return$H;}function
support($Pc){return!preg_match("~scheme|sequence|type|view_trigger|materializedview".(min_version(8)?"":"|descidx".(min_version(5.1)?"":"|event|partitioning".(min_version(5)?"":"|routine|trigger|view")))."~",$Pc);}function
kill_process($X){return
queries("KILL ".number($X));}function
connection_id(){return"SELECT CONNECTION_ID()";}function
max_connections(){global$g;return$g->result("SELECT @@max_connections");}$x="sql";$U=array();$Hh=array();foreach(array('Numbers'=>array("tinyint"=>3,"smallint"=>5,"mediumint"=>8,"int"=>10,"bigint"=>20,"decimal"=>66,"float"=>12,"double"=>21),'Date and time'=>array("date"=>10,"datetime"=>19,"timestamp"=>19,"time"=>10,"year"=>4),'Strings'=>array("char"=>255,"varchar"=>65535,"tinytext"=>255,"text"=>65535,"mediumtext"=>16777215,"longtext"=>4294967295),'Lists'=>array("enum"=>65535,"set"=>64),'Binary'=>array("bit"=>20,"binary"=>255,"varbinary"=>65535,"tinyblob"=>255,"blob"=>65535,"mediumblob"=>16777215,"longblob"=>4294967295),'Geometry'=>array("geometry"=>0,"point"=>0,"linestring"=>0,"polygon"=>0,"multipoint"=>0,"multilinestring"=>0,"multipolygon"=>0,"geometrycollection"=>0),)as$y=>$X){$U+=$X;$Hh[$y]=array_keys($X);}$Ii=array("unsigned","zerofill","unsigned zerofill");$vf=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","REGEXP","IN","FIND_IN_SET","IS NULL","NOT LIKE","NOT REGEXP","NOT IN","IS NOT NULL","SQL");$kd=array("char_length","date","from_unixtime","lower","round","floor","ceil","sec_to_time","time_to_sec","upper");$qd=array("avg","count","count distinct","group_concat","max","min","sum");$mc=array(array("char"=>"md5/sha1/password/encrypt/uuid","binary"=>"md5/sha1","date|time"=>"now",),array(number_type()=>"+/-","date"=>"+ interval/- interval","time"=>"addtime/subtime","char|text"=>"concat",));}define("SERVER",$_GET[DRIVER]);define("DB",$_GET["db"]);define("ME",str_replace(":","%3a",preg_replace('~^[^?]*/([^?]*).*~','\1',$_SERVER["REQUEST_URI"])).'?'.(sid()?SID.'&':'').(SERVER!==null?DRIVER."=".urlencode(SERVER).'&':'').(isset($_GET["username"])?"username=".urlencode($_GET["username"]).'&':'').(DB!=""?'db='.urlencode(DB).'&'.(isset($_GET["ns"])?"ns=".urlencode($_GET["ns"])."&":""):''));$ia="4.7.5";class
Adminer{var$operators;function
name(){return"Adminer";}function
credentials(){return
array(SERVER,$_GET["username"],get_password());}function
connectSsl(){}function
permanentLogin($i=false){return
password_file($i);}function
bruteForceKey(){return$_SERVER["REMOTE_ADDR"];}function
serverName($M){return
h($M);}function
database(){return
DB;}function
databases($ad=true){return
get_databases($ad);}function
schemas(){return
schemas();}function
queryTimeout(){return
2;}function
headers(){}function
csp(){return
csp();}function
head(){return
true;}function
css(){$H=array();$Uc="adminer.css";if(file_exists($Uc))$H[]="$Uc?v=".crc32(file_get_contents($Uc));return$H;}function
loginForm(){global$ec;echo"\n",$this->loginFormField('driver',''.'System'.' | ',html_select("auth[driver]",$ec,DRIVER,"loginDriver(this);")."\n"),$this->loginFormField('server',' |
---|
'.'Server'.' | ',''."\n"),$this->loginFormField('username',' |
---|
'.'Username'.' | ',''.script("focus(qs('#username')); qs('#username').form['auth[driver]'].onchange();")),$this->loginFormField('password',' |
---|
'.'Password'.' | ',''."\n"),$this->loginFormField('db',' |
---|
'.'Database'.' | ',''."\n")," |
---|
\n","\n",checkbox("auth[permanent]",1,$_COOKIE["adminer_permanent"],'Permanent login')."\n";}function
loginFormField($B,$xd,$Y){return$xd.$Y;}function
login($ye,$E){return
true;}function
tableName($Oh){return
h($Oh["Name"]);}function
fieldName($o,$_f=0){return''.h($o["field"]).'';}function
selectLinks($Oh,$N=""){global$x,$m;echo'
';$we=array("select"=>'Select data');if(support("table")||support("indexes"))$we["table"]='Show structure';if(support("table")){if(is_view($Oh))$we["view"]='Alter view';else$we["create"]='Alter table';}if($N!==null)$we["edit"]='New item';$B=$Oh["Name"];foreach($we
as$y=>$X)echo" $X";echo
doc_link(array($x=>$m->tableHelp($B)),"?"),"\n";}function
foreignKeys($Q){return
foreign_keys($Q);}function
backwardKeys($Q,$Nh){return
array();}function
backwardKeysPrint($Pa,$I){}function
selectQuery($F,$Dh,$Nc=false){global$x,$m;$H="
\n";if(!$Nc&&($dj=$m->warnings())){$t="warnings";$H=", ".'Warnings'."".script("qsl('a').onclick = partial(toggle, '$t');","")."$H\n$dj
\n";}return"".h(str_replace("\n"," ",$F))."
(".format_time($Dh).")".(support("sql")?" ".'Edit'."":"").$H;}function
sqlCommandQuery($F){return
shorten_utf8(trim($F),1000);}function
rowDescription($Q){return"";}function
rowDescriptions($J,$dd){return$J;}function
selectLink($X,$o){}function
selectVal($X,$_,$o,$Hf){$H=($X===null?"NULL":(preg_match("~char|binary|boolean~",$o["type"])&&!preg_match("~var~",$o["type"])?"$X
":$X));if(preg_match('~blob|bytea|raw|file~',$o["type"])&&!is_utf8($X))$H="".lang(array('%d byte','%d bytes'),strlen($Hf))."";if(preg_match('~json~',$o["type"]))$H="$H
";return($_?"$H":$H);}function
editVal($X,$o){return$X;}function
tableStructurePrint($p){echo"
\n";}function
tableIndexesPrint($w){echo"\n";foreach($w
as$B=>$v){ksort($v["columns"]);$mg=array();foreach($v["columns"]as$y=>$X)$mg[]="".h($X)."".($v["lengths"][$y]?"(".$v["lengths"][$y].")":"").($v["descs"][$y]?" DESC":"");echo"$v[type] | ".implode(", ",$mg)."\n";}echo" |
---|
\n";}function
selectColumnsPrint($K,$f){global$kd,$qd;print_fieldset("select",'Select',$K);$s=0;$K[""]=array();foreach($K
as$y=>$X){$X=$_GET["columns"][$y];$e=select_input(" name='columns[$s][col]'",$f,$X["col"],($y!==""?"selectFieldChange":"selectAddRow"));echo"".($kd||$qd?"".on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'",1).script("qsl('select').onchange = function () { helpClose();".($y!==""?"":" qsl('select, input', this.parentNode).onchange();")." };","")."($e)":$e)."
\n";$s++;}echo"\n";}function
selectSearchPrint($Z,$f,$w){print_fieldset("search",'Search',$Z);foreach($w
as$s=>$v){if($v["type"]=="FULLTEXT"){echo"(".implode(", ",array_map('h',$v["columns"])).") AGAINST"," ",script("qsl('input').oninput = selectFieldChange;",""),checkbox("boolean[$s]",1,isset($_GET["boolean"][$s]),"BOOL"),"
\n";}}$bb="this.parentNode.firstChild.onchange();";foreach(array_merge((array)$_GET["where"],array(array()))as$s=>$X){if(!$X||("$X[col]$X[val]"!=""&&in_array($X["op"],$this->operators))){echo"".select_input(" name='where[$s][col]'",$f,$X["col"],($X?"selectFieldChange":"selectAddRow"),"(".'anywhere'.")"),html_select("where[$s][op]",$this->operators,$X["op"],$bb),"",script("mixin(qsl('input'), {oninput: function () { $bb }, onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});",""),"
\n";}}echo"\n";}function
selectOrderPrint($_f,$f,$w){print_fieldset("sort",'Sort',$_f);$s=0;foreach((array)$_GET["order"]as$y=>$X){if($X!=""){echo"".select_input(" name='order[$s]'",$f,$X,"selectFieldChange"),checkbox("desc[$s]",1,isset($_GET["desc"][$y]),'descending')."
\n";$s++;}}echo"".select_input(" name='order[$s]'",$f,"","selectAddRow"),checkbox("desc[$s]",1,false,'descending')."
\n","\n";}function
selectLimitPrint($z){echo"\n";}function
selectLengthPrint($di){if($di!==null){echo"\n";}}function
selectActionPrint($w){echo"\n";}function
selectCommandPrint(){return!information_schema(DB);}function
selectImportPrint(){return!information_schema(DB);}function
selectEmailPrint($rc,$f){}function
selectColumnsProcess($f,$w){global$kd,$qd;$K=array();$nd=array();foreach((array)$_GET["columns"]as$y=>$X){if($X["fun"]=="count"||($X["col"]!=""&&(!$X["fun"]||in_array($X["fun"],$kd)||in_array($X["fun"],$qd)))){$K[$y]=apply_sql_function($X["fun"],($X["col"]!=""?idf_escape($X["col"]):"*"));if(!in_array($X["fun"],$qd))$nd[]=$K[$y];}}return
array($K,$nd);}function
selectSearchProcess($p,$w){global$g,$m;$H=array();foreach($w
as$s=>$v){if($v["type"]=="FULLTEXT"&&$_GET["fulltext"][$s]!="")$H[]="MATCH (".implode(", ",array_map('idf_escape',$v["columns"])).") AGAINST (".q($_GET["fulltext"][$s]).(isset($_GET["boolean"][$s])?" IN BOOLEAN MODE":"").")";}foreach((array)$_GET["where"]as$y=>$X){if("$X[col]$X[val]"!=""&&in_array($X["op"],$this->operators)){$ig="";$wb=" $X[op]";if(preg_match('~IN$~',$X["op"])){$Hd=process_length($X["val"]);$wb.=" ".($Hd!=""?$Hd:"(NULL)");}elseif($X["op"]=="SQL")$wb=" $X[val]";elseif($X["op"]=="LIKE %%")$wb=" LIKE ".$this->processInput($p[$X["col"]],"%$X[val]%");elseif($X["op"]=="ILIKE %%")$wb=" ILIKE ".$this->processInput($p[$X["col"]],"%$X[val]%");elseif($X["op"]=="FIND_IN_SET"){$ig="$X[op](".q($X["val"]).", ";$wb=")";}elseif(!preg_match('~NULL$~',$X["op"]))$wb.=" ".$this->processInput($p[$X["col"]],$X["val"]);if($X["col"]!="")$H[]=$ig.$m->convertSearch(idf_escape($X["col"]),$X,$p[$X["col"]]).$wb;else{$rb=array();foreach($p
as$B=>$o){if((preg_match('~^[-\d.'.(preg_match('~IN$~',$X["op"])?',':'').']+$~',$X["val"])||!preg_match('~'.number_type().'|bit~',$o["type"]))&&(!preg_match("~[\x80-\xFF]~",$X["val"])||preg_match('~char|text|enum|set~',$o["type"])))$rb[]=$ig.$m->convertSearch(idf_escape($B),$X,$o).$wb;}$H[]=($rb?"(".implode(" OR ",$rb).")":"1 = 0");}}}return$H;}function
selectOrderProcess($p,$w){$H=array();foreach((array)$_GET["order"]as$y=>$X){if($X!="")$H[]=(preg_match('~^((COUNT\(DISTINCT |[A-Z0-9_]+\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\)|COUNT\(\*\))$~',$X)?$X:idf_escape($X)).(isset($_GET["desc"][$y])?" DESC":"");}return$H;}function
selectLimitProcess(){return(isset($_GET["limit"])?$_GET["limit"]:"50");}function
selectLengthProcess(){return(isset($_GET["text_length"])?$_GET["text_length"]:"100");}function
selectEmailProcess($Z,$dd){return
false;}function
selectQueryBuild($K,$Z,$nd,$_f,$z,$D){return"";}function
messageQuery($F,$ei,$Nc=false){global$x,$m;restart_session();$yd=&get_session("queries");if(!$yd[$_GET["db"]])$yd[$_GET["db"]]=array();if(strlen($F)>1e6)$F=preg_replace('~[\x80-\xFF]+$~','',substr($F,0,1e6))."\n…";$yd[$_GET["db"]][]=array($F,time(),$ei);$Ah="sql-".count($yd[$_GET["db"]]);$H="".'SQL command'."\n";if(!$Nc&&($dj=$m->warnings())){$t="warnings-".count($yd[$_GET["db"]]);$H="".'Warnings'.", $H\n$dj
\n";}return" ".@date("H:i:s").""." $H".shorten_utf8($F,1000)."
".($ei?"
($ei)":'').(support("sql")?'
'.'Edit'.'':'').'
';}function
editFunctions($o){global$mc;$H=($o["null"]?"NULL/":"");foreach($mc
as$y=>$kd){if(!$y||(!isset($_GET["call"])&&(isset($_GET["select"])||where($_GET)))){foreach($kd
as$ag=>$X){if(!$ag||preg_match("~$ag~",$o["type"]))$H.="/$X";}if($y&&!preg_match('~set|blob|bytea|raw|file~',$o["type"]))$H.="/SQL";}}if($o["auto_increment"]&&!isset($_GET["select"])&&!where($_GET))$H='Auto Increment';return
explode("/",$H);}function
editInput($Q,$o,$Ja,$Y){if($o["type"]=="enum")return(isset($_GET["select"])?" ":"").($o["null"]?" ":"").enum_input("radio",$Ja,$o,$Y,0);return"";}function
editHint($Q,$o,$Y){return"";}function
processInput($o,$Y,$r=""){if($r=="SQL")return$Y;$B=$o["field"];$H=q($Y);if(preg_match('~^(now|getdate|uuid)$~',$r))$H="$r()";elseif(preg_match('~^current_(date|timestamp)$~',$r))$H=$r;elseif(preg_match('~^([+-]|\|\|)$~',$r))$H=idf_escape($B)." $r $H";elseif(preg_match('~^[+-] interval$~',$r))$H=idf_escape($B)." $r ".(preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+\$~i",$Y)?$Y:$H);elseif(preg_match('~^(addtime|subtime|concat)$~',$r))$H="$r(".idf_escape($B).", $H)";elseif(preg_match('~^(md5|sha1|password|encrypt)$~',$r))$H="$r($H)";return
unconvert_field($o,$H);}function
dumpOutput(){$H=array('text'=>'open','file'=>'save');if(function_exists('gzencode'))$H['gz']='gzip';return$H;}function
dumpFormat(){return
array('sql'=>'SQL','csv'=>'CSV,','csv;'=>'CSV;','tsv'=>'TSV');}function
dumpDatabase($l){}function
dumpTable($Q,$Ih,$ae=0){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($Ih)dump_csv(array_keys(fields($Q)));}else{if($ae==2){$p=array();foreach(fields($Q)as$B=>$o)$p[]=idf_escape($B)." $o[full_type]";$i="CREATE TABLE ".table($Q)." (".implode(", ",$p).")";}else$i=create_sql($Q,$_POST["auto_increment"],$Ih);set_utf8mb4($i);if($Ih&&$i){if($Ih=="DROP+CREATE"||$ae==1)echo"DROP ".($ae==2?"VIEW":"TABLE")." IF EXISTS ".table($Q).";\n";if($ae==1)$i=remove_definer($i);echo"$i;\n\n";}}}function
dumpData($Q,$Ih,$F){global$g,$x;$Fe=($x=="sqlite"?0:1048576);if($Ih){if($_POST["format"]=="sql"){if($Ih=="TRUNCATE+INSERT")echo
truncate_sql($Q).";\n";$p=fields($Q);}$G=$g->query($F,1);if($G){$Td="";$Ya="";$he=array();$Kh="";$Qc=($Q!=''?'fetch_assoc':'fetch_row');while($I=$G->$Qc()){if(!$he){$Vi=array();foreach($I
as$X){$o=$G->fetch_field();$he[]=$o->name;$y=idf_escape($o->name);$Vi[]="$y = VALUES($y)";}$Kh=($Ih=="INSERT+UPDATE"?"\nON DUPLICATE KEY UPDATE ".implode(", ",$Vi):"").";\n";}if($_POST["format"]!="sql"){if($Ih=="table"){dump_csv($he);$Ih="INSERT";}dump_csv($I);}else{if(!$Td)$Td="INSERT INTO ".table($Q)." (".implode(", ",array_map('idf_escape',$he)).") VALUES";foreach($I
as$y=>$X){$o=$p[$y];$I[$y]=($X!==null?unconvert_field($o,preg_match(number_type(),$o["type"])&&!preg_match('~\[~',$o["full_type"])&&is_numeric($X)?$X:q(($X===false?0:$X))):"NULL");}$Yg=($Fe?"\n":" ")."(".implode(",\t",$I).")";if(!$Ya)$Ya=$Td.$Yg;elseif(strlen($Ya)+4+strlen($Yg)+strlen($Kh)<$Fe)$Ya.=",$Yg";else{echo$Ya.$Kh;$Ya=$Td.$Yg;}}}if($Ya)echo$Ya.$Kh;}elseif($_POST["format"]=="sql")echo"-- ".str_replace("\n"," ",$g->error)."\n";}}function
dumpFilename($Cd){return
friendly_url($Cd!=""?$Cd:(SERVER!=""?SERVER:"localhost"));}function
dumpHeaders($Cd,$Ue=false){$Kf=$_POST["output"];$Ic=(preg_match('~sql~',$_POST["format"])?"sql":($Ue?"tar":"csv"));header("Content-Type: ".($Kf=="gz"?"application/x-gzip":($Ic=="tar"?"application/x-tar":($Ic=="sql"||$Kf!="file"?"text/plain":"text/csv")."; charset=utf-8")));if($Kf=="gz")ob_start('ob_gzencode',1e6);return$Ic;}function
importServerPath(){return"adminer.sql";}function
homepage(){echo''.($_GET["ns"]==""&&support("database")?''.'Alter database'."\n":""),(support("scheme")?"".($_GET["ns"]!=""?'Alter schema':'Create schema')."\n":""),($_GET["ns"]!==""?''.'Database schema'."\n":""),(support("privileges")?"".'Privileges'."\n":"");return
true;}function
navigation($Te){global$ia,$x,$ec,$g;echo'
';if($Te=="auth"){$Kf="";foreach((array)$_SESSION["pwds"]as$Xi=>$mh){foreach($mh
as$M=>$Si){foreach($Si
as$V=>$E){if($E!==null){$Rb=$_SESSION["db"][$Xi][$M][$V];foreach(($Rb?array_keys($Rb):array(""))as$l)$Kf.="($ec[$Xi]) ".h($V.($M!=""?"@".$this->serverName($M):"").($l!=""?" - $l":""))."\n";}}}}if($Kf)echo"\n".script("mixin(qs('#logins'), {onmouseover: menuOver, onmouseout: menuOut});");}else{if($_GET["ns"]!==""&&!$Te&&DB!=""){$g->select_db(DB);$S=table_status('',true);}echo
script_src(preg_replace("~\\?.*~","",ME)."?file=jush.js&version=4.7.5");if(support("sql")){echo'
';}$this->databasesPrint($Te);if(DB==""||!$Te){echo"".(support("sql")?"".'SQL command'."\n".'Import'."\n":"")."";if(support("dump"))echo"".'Export'."\n";}if($_GET["ns"]!==""&&!$Te&&DB!=""){echo'".'Create table'."\n";if(!$S)echo"
".'No tables.'."\n";else$this->tablesPrint($S);}}}function
databasesPrint($Te){global$b,$g;$k=$this->databases();if($k&&!in_array(DB,$k))array_unshift($k,DB);echo'
\n";}function
tablesPrint($S){echo"".script("mixin(qs('#tables'), {onmouseover: menuOver, onmouseout: menuOut});");foreach($S
as$Q=>$O){$B=$this->tableName($O);if($B!=""){echo'- ".'select'." ",(support("table")||support("indexes")?'$B":"$B")."\n";}}echo"
\n";}}$b=(function_exists('adminer_object')?adminer_object():new
Adminer);if($b->operators===null)$b->operators=$vf;function
page_header($hi,$n="",$Xa=array(),$ii=""){global$ca,$ia,$b,$ec,$x;page_headers();if(is_ajax()&&$n){page_messages($n);exit;}$ji=$hi.($ii!=""?": $ii":"");$ki=strip_tags($ji.(SERVER!=""&&SERVER!="localhost"?h(" - ".SERVER):"")." - ".$b->name());echo'
',$ki,'
',script_src(preg_replace("~\\?.*~","",ME)."?file=functions.js&version=4.7.5");if($b->head()){echo'
';foreach($b->css()as$Jb){echo'
';}}echo'
';$Uc=get_temp_dir()."/adminer.version";if(!$_COOKIE["adminer_version"]&&function_exists('openssl_verify')&&file_exists($Uc)&&filemtime($Uc)+86400>time()){$Yi=unserialize(file_get_contents($Uc));$tg="-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWOVuF5uw7/+Z70djoK
RlHIZFZPO0uYRezq90+7Amk+FDNd7KkL5eDve+vHRJBLAszF/7XKXe11xwliIsFs
DFWQlsABVZB3oisKCBEuI71J4kPH8dKGEWR9jDHFw3cWmoH3PmqImX6FISWbG3B8
h7FIx3jEaw5ckVPVTeo5JRm/1DZzJxjyDenXvBQ/6o9DgZKeNDgxwKzH+sw9/YCO
jHnq1cFpOIISzARlrHMa/43YfeNRAm/tsBXjSxembBPo7aQZLAWHmaj5+K19H10B
nCpz9Y++cipkVEiKRGih4ZEvjoFysEOdRLj6WiD/uUNky4xGeA6LaJqh5XpkFkcQ
fQIDAQAB
-----END PUBLIC KEY-----
";if(openssl_verify($Yi["version"],base64_decode($Yi["signature"]),$tg)==1)$_COOKIE["adminer_version"]=$Yi["version"];}echo'
',script("mixin(qs('#help'), {onmouseover: function () { helpOpen = 1; }, onmouseout: helpMouseout});"),'
';if($Xa!==null){$_=substr(preg_replace('~\b(username|db|ns)=[^&]*&~','',ME),0,-1);echo'
'.$ec[DRIVER].' » ';$_=substr(preg_replace('~\b(db|ns)=[^&]*&~','',ME),0,-1);$M=$b->serverName(SERVER);$M=($M!=""?$M:'Server');if($Xa===false)echo"$M\n";else{echo"$M » ";if($_GET["ns"]!=""||(DB!=""&&is_array($Xa)))echo''.h(DB).' » ';if(is_array($Xa)){if($_GET["ns"]!="")echo''.h($_GET["ns"]).' » ';foreach($Xa
as$y=>$X){$Xb=(is_array($X)?$X[1]:h($X));if($Xb!="")echo"$Xb » ";}}echo"$hi\n";}}echo"
$ji
\n","
\n";restart_session();page_messages($n);$k=&get_session("dbs");if(DB!=""&&$k&&!in_array(DB,$k,true))$k=null;stop_session();define("PAGE_HEADER",1);}function
page_headers(){global$b;header("Content-Type: text/html; charset=utf-8");header("Cache-Control: no-cache");header("X-Frame-Options: deny");header("X-XSS-Protection: 0");header("X-Content-Type-Options: nosniff");header("Referrer-Policy: origin-when-cross-origin");foreach($b->csp()as$Ib){$wd=array();foreach($Ib
as$y=>$X)$wd[]="$y $X";header("Content-Security-Policy: ".implode("; ",$wd));}$b->headers();}function
csp(){return
array(array("script-src"=>"'self' 'unsafe-inline' 'nonce-".get_nonce()."' 'strict-dynamic'","connect-src"=>"'self'","frame-src"=>"https://www.adminer.org","object-src"=>"'none'","base-uri"=>"'none'","form-action"=>"'self'",),);}function
get_nonce(){static$df;if(!$df)$df=base64_encode(rand_string());return$df;}function
page_messages($n){$Ki=preg_replace('~^[^?]*~','',$_SERVER["REQUEST_URI"]);$Pe=$_SESSION["messages"][$Ki];if($Pe){echo"
".implode("
\n
",$Pe)."
".script("messagesPrint();");unset($_SESSION["messages"][$Ki]);}if($n)echo"
$n
\n";}function
page_footer($Te=""){global$b,$oi;echo'
';if($Te!="auth"){echo'
';}echo'
',script("setupSubmitHighlight(document);");}function
int32($We){while($We>=2147483648)$We-=4294967296;while($We<=-2147483649)$We+=4294967296;return(int)$We;}function
long2str($W,$cj){$Yg='';foreach($W
as$X)$Yg.=pack('V',$X);if($cj)return
substr($Yg,0,end($W));return$Yg;}function
str2long($Yg,$cj){$W=array_values(unpack('V*',str_pad($Yg,4*ceil(strlen($Yg)/4),"\0")));if($cj)$W[]=strlen($Yg);return$W;}function
xxtea_mx($pj,$oj,$Lh,$de){return
int32((($pj>>5&0x7FFFFFF)^$oj<<2)+(($oj>>3&0x1FFFFFFF)^$pj<<4))^int32(($Lh^$oj)+($de^$pj));}function
encrypt_string($Gh,$y){if($Gh=="")return"";$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Gh,true);$We=count($W)-1;$pj=$W[$We];$oj=$W[0];$ug=floor(6+52/($We+1));$Lh=0;while($ug-->0){$Lh=int32($Lh+0x9E3779B9);$lc=$Lh>>2&3;for($Lf=0;$Lf<$We;$Lf++){$oj=$W[$Lf+1];$Ve=xxtea_mx($pj,$oj,$Lh,$y[$Lf&3^$lc]);$pj=int32($W[$Lf]+$Ve);$W[$Lf]=$pj;}$oj=$W[0];$Ve=xxtea_mx($pj,$oj,$Lh,$y[$Lf&3^$lc]);$pj=int32($W[$We]+$Ve);$W[$We]=$pj;}return
long2str($W,false);}function
decrypt_string($Gh,$y){if($Gh=="")return"";if(!$y)return
false;$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Gh,false);$We=count($W)-1;$pj=$W[$We];$oj=$W[0];$ug=floor(6+52/($We+1));$Lh=int32($ug*0x9E3779B9);while($Lh){$lc=$Lh>>2&3;for($Lf=$We;$Lf>0;$Lf--){$pj=$W[$Lf-1];$Ve=xxtea_mx($pj,$oj,$Lh,$y[$Lf&3^$lc]);$oj=int32($W[$Lf]-$Ve);$W[$Lf]=$oj;}$pj=$W[$We];$Ve=xxtea_mx($pj,$oj,$Lh,$y[$Lf&3^$lc]);$oj=int32($W[0]-$Ve);$W[0]=$oj;$Lh=int32($Lh-0x9E3779B9);}return
long2str($W,true);}$g='';$vd=$_SESSION["token"];if(!$vd)$_SESSION["token"]=rand(1,1e6);$oi=get_token();$bg=array();if($_COOKIE["adminer_permanent"]){foreach(explode(" ",$_COOKIE["adminer_permanent"])as$X){list($y)=explode(":",$X);$bg[$y]=$X;}}function
add_invalid_login(){global$b;$id=file_open_lock(get_temp_dir()."/adminer.invalid");if(!$id)return;$Wd=unserialize(stream_get_contents($id));$ei=time();if($Wd){foreach($Wd
as$Xd=>$X){if($X[0]<$ei)unset($Wd[$Xd]);}}$Vd=&$Wd[$b->bruteForceKey()];if(!$Vd)$Vd=array($ei+30*60,0);$Vd[1]++;file_write_unlock($id,serialize($Wd));}function
check_invalid_login(){global$b;$Wd=unserialize(@file_get_contents(get_temp_dir()."/adminer.invalid"));$Vd=$Wd[$b->bruteForceKey()];$cf=($Vd[1]>29?$Vd[0]-time():0);if($cf>0)auth_error(lang(array('Too many unsuccessful logins, try again in %d minute.','Too many unsuccessful logins, try again in %d minutes.'),ceil($cf/60)));}$Ka=$_POST["auth"];if($Ka){session_regenerate_id();$Xi=$Ka["driver"];$M=$Ka["server"];$V=$Ka["username"];$E=(string)$Ka["password"];$l=$Ka["db"];set_password($Xi,$M,$V,$E);$_SESSION["db"][$Xi][$M][$V][$l]=true;if($Ka["permanent"]){$y=base64_encode($Xi)."-".base64_encode($M)."-".base64_encode($V)."-".base64_encode($l);$ng=$b->permanentLogin(true);$bg[$y]="$y:".base64_encode($ng?encrypt_string($E,$ng):"");cookie("adminer_permanent",implode(" ",$bg));}if(count($_POST)==1||DRIVER!=$Xi||SERVER!=$M||$_GET["username"]!==$V||DB!=$l)redirect(auth_url($Xi,$M,$V,$l));}elseif($_POST["logout"]){if($vd&&!verify_token()){page_header('Logout','Invalid CSRF token. Send the form again.');page_footer("db");exit;}else{foreach(array("pwds","db","dbs","queries")as$y)set_session($y,null);unset_permanent();redirect(substr(preg_replace('~\b(username|db|ns)=[^&]*&~','',ME),0,-1),'Logout successful.'.' '.'Thanks for using Adminer, consider donating.');}}elseif($bg&&!$_SESSION["pwds"]){session_regenerate_id();$ng=$b->permanentLogin();foreach($bg
as$y=>$X){list(,$jb)=explode(":",$X);list($Xi,$M,$V,$l)=array_map('base64_decode',explode("-",$y));set_password($Xi,$M,$V,decrypt_string(base64_decode($jb),$ng));$_SESSION["db"][$Xi][$M][$V][$l]=true;}}function
unset_permanent(){global$bg;foreach($bg
as$y=>$X){list($Xi,$M,$V,$l)=array_map('base64_decode',explode("-",$y));if($Xi==DRIVER&&$M==SERVER&&$V==$_GET["username"]&&$l==DB)unset($bg[$y]);}cookie("adminer_permanent",implode(" ",$bg));}function
auth_error($n){global$b,$vd;$nh=session_name();if(isset($_GET["username"])){header("HTTP/1.1 403 Forbidden");if(($_COOKIE[$nh]||$_GET[$nh])&&!$vd)$n='Session expired, please login again.';else{restart_session();add_invalid_login();$E=get_password();if($E!==null){if($E===false)$n.='
'.sprintf('Master password expired. Implement %s method to make it permanent.',target_blank(),'permanentLogin()
');set_password(DRIVER,SERVER,$_GET["username"],null);}unset_permanent();}}if(!$_COOKIE[$nh]&&$_GET[$nh]&&ini_bool("session.use_only_cookies"))$n='Session support must be enabled.';$Of=session_get_cookie_params();cookie("adminer_key",($_COOKIE["adminer_key"]?$_COOKIE["adminer_key"]:rand_string()),$Of["lifetime"]);page_header('Login',$n,null);echo"\n";page_footer("auth");exit;}if(isset($_GET["username"])&&!class_exists("Min_DB")){unset($_SESSION["pwds"][DRIVER]);unset_permanent();page_header('No extension',sprintf('None of the supported PHP extensions (%s) are available.',implode(", ",$hg)),false);page_footer("auth");exit;}stop_session(true);if(isset($_GET["username"])&&is_string(get_password())){list($Ad,$dg)=explode(":",SERVER,2);if(is_numeric($dg)&&$dg<1024)auth_error('Connecting to privileged ports is not allowed.');check_invalid_login();$g=connect();$m=new
Min_Driver($g);}$ye=null;if(!is_object($g)||($ye=$b->login($_GET["username"],get_password()))!==true){$n=(is_string($g)?h($g):(is_string($ye)?$ye:'Invalid credentials.'));auth_error($n.(preg_match('~^ | $~',get_password())?'
'.'There is a space in the input password which might be the cause.':''));}if($Ka&&$_POST["token"])$_POST["token"]=$oi;$n='';if($_POST){if(!verify_token()){$Qd="max_input_vars";$Je=ini_get($Qd);if(extension_loaded("suhosin")){foreach(array("suhosin.request.max_vars","suhosin.post.max_vars")as$y){$X=ini_get($y);if($X&&(!$Je||$X<$Je)){$Qd=$y;$Je=$X;}}}$n=(!$_POST["token"]&&$Je?sprintf('Maximum number of allowed fields exceeded. Please increase %s.',"'$Qd'"):'Invalid CSRF token. Send the form again.'.' '.'If you did not send this request from Adminer then close this page.');}}elseif($_SERVER["REQUEST_METHOD"]=="POST"){$n=sprintf('Too big POST data. Reduce the data or increase the %s configuration directive.',"'post_max_size'");if(isset($_GET["sql"]))$n.=' '.'You can upload a big SQL file via FTP and import it from server.';}function
select($G,$h=null,$Cf=array(),$z=0){global$x;$we=array();$w=array();$f=array();$Ua=array();$U=array();$H=array();odd('');for($s=0;(!$z||$s<$z)&&($I=$G->fetch_row());$s++){if(!$s){echo"":"".'No rows.')."\n";return$H;}function
referencable_primary($hh){$H=array();foreach(table_status('',true)as$Ph=>$Q){if($Ph!=$hh&&fk_support($Q)){foreach(fields($Ph)as$o){if($o["primary"]){if($H[$Ph]){unset($H[$Ph]);break;}$H[$Ph]=$o;}}}}return$H;}function
adminer_settings(){parse_str($_COOKIE["adminer_settings"],$ph);return$ph;}function
adminer_setting($y){$ph=adminer_settings();return$ph[$y];}function
set_adminer_settings($ph){return
cookie("adminer_settings",http_build_query($ph+adminer_settings()));}function
textarea($B,$Y,$J=10,$rb=80){global$x;echo"";}function
edit_type($y,$o,$pb,$ed=array(),$Lc=array()){global$Hh,$U,$Ii,$qf;$T=$o["type"];echo'
',on_help("getTarget(event).value",1),script("mixin(qsl('select'), {onfocus: function () { lastType = selectValue(this); }, onchange: editingTypeChange});",""),' | ',script("mixin(qsl('input'), {onfocus: editingLengthFocus, oninput: editingLengthChange});",""),' | ',"',($Ii?"':''),(isset($o['on_update'])?"':''),($ed?" ":" ");}function
process_length($te){global$wc;return(preg_match("~^\\s*\\(?\\s*$wc(?:\\s*,\\s*$wc)*+\\s*\\)?\\s*\$~",$te)&&preg_match_all("~$wc~",$te,$De)?"(".implode(",",$De[0]).")":preg_replace('~^[0-9].*~','(\0)',preg_replace('~[^-0-9,+()[\]]~','',$te)));}function
process_type($o,$ob="COLLATE"){global$Ii;return" $o[type]".process_length($o["length"]).(preg_match(number_type(),$o["type"])&&in_array($o["unsigned"],$Ii)?" $o[unsigned]":"").(preg_match('~char|text|enum|set~',$o["type"])&&$o["collation"]?" $ob ".q($o["collation"]):"");}function
process_field($o,$Ai){return
array(idf_escape(trim($o["field"])),process_type($Ai),($o["null"]?" NULL":" NOT NULL"),default_value($o),(preg_match('~timestamp|datetime~',$o["type"])&&$o["on_update"]?" ON UPDATE $o[on_update]":""),(support("comment")&&$o["comment"]!=""?" COMMENT ".q($o["comment"]):""),($o["auto_increment"]?auto_increment():null),);}function
default_value($o){$Tb=$o["default"];return($Tb===null?"":" DEFAULT ".(preg_match('~char|binary|text|enum|set~',$o["type"])||preg_match('~^(?![a-z])~i',$Tb)?q($Tb):$Tb));}function
type_class($T){foreach(array('char'=>'text','date'=>'time|year','binary'=>'blob','enum'=>'set',)as$y=>$X){if(preg_match("~$y|$X~",$T))return" class='$y'";}}function
edit_fields($p,$pb,$T="TABLE",$ed=array()){global$Rd;$p=array_values($p);echo'
';if($T=="PROCEDURE"){echo'';}echo' | ',($T=="TABLE"?'Column name':'Parameter name'),' | Type',script("qs('#enum-edit').onblur = editingLengthBlur;"),' | Length
| ','Options';if($T=="TABLE"){echo' | NULL
| AI',doc_link(array('sql'=>"example-auto-increment.html",'mariadb'=>"auto_increment/",'sqlite'=>"autoinc.html",'pgsql'=>"datatype.html#DATATYPE-SERIAL",'mssql'=>"ms186775.aspx",)),' | Default value
',(support("comment")?" | ',"".script("row_count = ".count($p).";"),' |
|
',script("mixin(qsl('tbody'), {onclick: editingClick, onkeydown: editingKeydown, oninput: editingInput});");foreach($p
as$s=>$o){$s++;$Df=$o[($_POST?"orig":"field")];$bc=(isset($_POST["add"][$s-1])||(isset($o["field"])&&!$_POST["drop_col"][$s]))&&(support("drop_col")||$Df=="");echo'
',($T=="PROCEDURE"?"".html_select("fields[$s][inout]",explode("|",$Rd),$o["inout"]):""),' | ';if($bc){echo'',script("qsl('input').oninput = function () { editingNameChange.call(this);".($o["field"]!=""||count($p)>1?"":" editingAddRow.call(this);")." };","");}echo'';edit_type("fields[$s]",$o,$pb,$ed);if($T=="TABLE"){echo' | ',checkbox("fields[$s][null]",1,$o["null"],"","","block","label-null"),' | | ',checkbox("fields[$s][has_default]",1,$o["has_default"],"","","","label-default"),'',(support("comment")?" | ":"");}echo" | ",(support("move_col")?" "." "." ":""),($Df==""||support("drop_col")?"":"");}}function
process_fields(&$p){$C=0;if($_POST["up"]){$ne=0;foreach($p
as$y=>$o){if(key($_POST["up"])==$y){unset($p[$y]);array_splice($p,$ne,0,array($o));break;}if(isset($o["field"]))$ne=$C;$C++;}}elseif($_POST["down"]){$gd=false;foreach($p
as$y=>$o){if(isset($o["field"])&&$gd){unset($p[key($_POST["down"])]);array_splice($p,$C,0,array($gd));break;}if(key($_POST["down"])==$y)$gd=$o;$C++;}}elseif($_POST["add"]){$p=array_values($p);array_splice($p,key($_POST["add"]),0,array(array()));}elseif(!$_POST["drop_col"])return
false;return
true;}function
normalize_enum($A){return"'".str_replace("'","''",addcslashes(stripcslashes(str_replace($A[0][0].$A[0][0],$A[0][0],substr($A[0],1,-1))),'\\'))."'";}function
grant($ld,$pg,$f,$pf){if(!$pg)return
true;if($pg==array("ALL PRIVILEGES","GRANT OPTION"))return($ld=="GRANT"?queries("$ld ALL PRIVILEGES$pf WITH GRANT OPTION"):queries("$ld ALL PRIVILEGES$pf")&&queries("$ld GRANT OPTION$pf"));return
queries("$ld ".preg_replace('~(GRANT OPTION)\([^)]*\)~','\1',implode("$f, ",$pg).$f).$pf);}function
drop_create($fc,$i,$gc,$bi,$ic,$xe,$Oe,$Me,$Ne,$mf,$Ze){if($_POST["drop"])query_redirect($fc,$xe,$Oe);elseif($mf=="")query_redirect($i,$xe,$Ne);elseif($mf!=$Ze){$Gb=queries($i);queries_redirect($xe,$Me,$Gb&&queries($fc));if($Gb)queries($gc);}else
queries_redirect($xe,$Me,queries($bi)&&queries($ic)&&queries($fc)&&queries($i));}function
create_trigger($pf,$I){global$x;$gi=" $I[Timing] $I[Event]".($I["Event"]=="UPDATE OF"?" ".idf_escape($I["Of"]):"");return"CREATE TRIGGER ".idf_escape($I["Trigger"]).($x=="mssql"?$pf.$gi:$gi.$pf).rtrim(" $I[Type]\n$I[Statement]",";").";";}function
create_routine($Ug,$I){global$Rd,$x;$N=array();$p=(array)$I["fields"];ksort($p);foreach($p
as$o){if($o["field"]!="")$N[]=(preg_match("~^($Rd)\$~",$o["inout"])?"$o[inout] ":"").idf_escape($o["field"]).process_type($o,"CHARACTER SET");}$Ub=rtrim("\n$I[definition]",";");return"CREATE $Ug ".idf_escape(trim($I["name"]))." (".implode(", ",$N).")".(isset($_GET["function"])?" RETURNS".process_type($I["returns"],"CHARACTER SET"):"").($I["language"]?" LANGUAGE $I[language]":"").($x=="pgsql"?" AS ".q($Ub):"$Ub;");}function
remove_definer($F){return
preg_replace('~^([A-Z =]+) DEFINER=`'.preg_replace('~@(.*)~','`@`(%|\1)',logged_user()).'`~','\1',$F);}function
format_foreign_key($q){global$qf;$l=$q["db"];$ef=$q["ns"];return" FOREIGN KEY (".implode(", ",array_map('idf_escape',$q["source"])).") REFERENCES ".($l!=""&&$l!=$_GET["db"]?idf_escape($l).".":"").($ef!=""&&$ef!=$_GET["ns"]?idf_escape($ef).".":"").table($q["table"])." (".implode(", ",array_map('idf_escape',$q["target"])).")".(preg_match("~^($qf)\$~",$q["on_delete"])?" ON DELETE $q[on_delete]":"").(preg_match("~^($qf)\$~",$q["on_update"])?" ON UPDATE $q[on_update]":"");}function
tar_file($Uc,$li){$H=pack("a100a8a8a8a12a12",$Uc,644,0,0,decoct($li->size),decoct(time()));$hb=8*32;for($s=0;$ssend();echo
str_repeat("\0",511-($li->size+511)%512);}function
ini_bytes($Qd){$X=ini_get($Qd);switch(strtolower(substr($X,-1))){case'g':$X*=1024;case'm':$X*=1024;case'k':$X*=1024;}return$X;}function
doc_link($Zf,$ci="?"){global$x,$g;$lh=$g->server_info;$Yi=preg_replace('~^(\d\.?\d).*~s','\1',$lh);$Ni=array('sql'=>"https://dev.mysql.com/doc/refman/$Yi/en/",'sqlite'=>"https://www.sqlite.org/",'pgsql'=>"https://www.postgresql.org/docs/$Yi/",'mssql'=>"https://msdn.microsoft.com/library/",'oracle'=>"https://www.oracle.com/pls/topic/lookup?ctx=db".preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s','\1\2',$lh)."&id=",);if(preg_match('~MariaDB~',$lh)){$Ni['sql']="https://mariadb.com/kb/en/library/";$Zf['sql']=(isset($Zf['mariadb'])?$Zf['mariadb']:str_replace(".html","/",$Zf['sql']));}return($Zf[$x]?"$ci":"");}function
ob_gzencode($P){return
gzencode($P);}function
db_size($l){global$g;if(!$g->select_db($l))return"?";$H=0;foreach(table_status()as$R)$H+=$R["Data_length"]+$R["Index_length"];return
format_number($H);}function
set_utf8mb4($i){global$g;static$N=false;if(!$N&&preg_match('~\butf8mb4~i',$i)){$N=true;echo"SET NAMES ".charset($g).";\n\n";}}function
connect_error(){global$b,$g,$oi,$n,$ec;if(DB!=""){header("HTTP/1.1 404 Not Found");page_header('Database'.": ".h(DB),'Invalid database.',true);}else{if($_POST["db"]&&!$n)queries_redirect(substr(ME,0,-1),'Databases have been dropped.',drop_databases($_POST["db"]));page_header('Select database',$n,false);echo" \n";foreach(array('database'=>'Create database','privileges'=>'Privileges','processlist'=>'Process list','variables'=>'Variables','status'=>'Status',)as$y=>$X){if(support($y))echo"$X\n";}echo" ".sprintf('%s version: %s through PHP extension %s',$ec[DRIVER],"".h($g->server_info)."","$g->extension")."\n"," ".sprintf('Logged as: %s',"".h(logged_user())."")."\n";$k=$b->databases();if($k){$bh=support("scheme");$pb=collations();echo" \n",script("tableCheck();");}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$g->select_db(DB):isset($_GET["sql"])||isset($_GET["dump"])||isset($_GET["database"])||isset($_GET["processlist"])||isset($_GET["privileges"])||isset($_GET["user"])||isset($_GET["variables"])||$_GET["script"]=="connect"||$_GET["script"]=="kill")){if(DB!=""||$_GET["refresh"]){restart_session();set_session("dbs",null);}connect_error();exit;}if(support("scheme")&&DB!=""&&$_GET["ns"]!==""){if(!isset($_GET["ns"]))redirect(preg_replace('~ns=[^&]*&~','',ME)."ns=".get_schema());if(!set_schema($_GET["ns"])){header("HTTP/1.1 404 Not Found");page_header('Schema'.": ".h($_GET["ns"]),'Invalid schema.',true);page_footer("ns");exit;}}$qf="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class
TmpFile{var$handler;var$size;function
__construct(){$this->handler=tmpfile();}function
write($Ab){$this->size+=strlen($Ab);fwrite($this->handler,$Ab);}function
send(){fseek($this->handler,0);fpassthru($this->handler);fclose($this->handler);}}$wc="'(?:''|[^'\\\\]|\\\\.)*'";$Rd="IN|OUT|INOUT";if(isset($_GET["select"])&&($_POST["edit"]||$_POST["clone"])&&!$_POST["save"])$_GET["edit"]=$_GET["select"];if(isset($_GET["callf"]))$_GET["call"]=$_GET["callf"];if(isset($_GET["function"]))$_GET["procedure"]=$_GET["function"];if(isset($_GET["download"])){$a=$_GET["download"];$p=fields($a);header("Content-Type: application/octet-stream");header("Content-Disposition: attachment; filename=".friendly_url("$a-".implode("_",$_GET["where"])).".".friendly_url($_GET["field"]));$K=array(idf_escape($_GET["field"]));$G=$m->select($a,$K,array(where($_GET,$p)),$K);$I=($G?$G->fetch_row():array());echo$m->value($I[0],$p[$_GET["field"]]);exit;}elseif(isset($_GET["table"])){$a=$_GET["table"];$p=fields($a);if(!$p)$n=error();$R=table_status1($a,true);$B=$b->tableName($R);page_header(($p&&is_view($R)?$R['Engine']=='materialized view'?'Materialized view':'View':'Table').": ".($B!=""?$B:h($a)),$n);$b->selectLinks($R);$ub=$R["Comment"];if($ub!="")echo"".'Comment'.": ".h($ub)."\n";if($p)$b->tableStructurePrint($p);if(!is_view($R)){if(support("indexes")){echo" ".'Indexes'."\n";$w=indexes($a);if($w)$b->tableIndexesPrint($w);echo''.'Alter indexes'."\n";}if(fk_support($R)){echo" ".'Foreign keys'."\n";$ed=foreign_keys($a);if($ed){echo"\n","".'Source'." | ".'Target'." | ".'ON DELETE'." | ".'ON UPDATE'." | | \n";foreach($ed
as$B=>$q){echo"","".implode(", ",array_map('h',$q["source"])).""," | ".($q["db"]!=""?"".h($q["db"]).".":"").($q["ns"]!=""?"".h($q["ns"]).".":"").h($q["table"])."","(".implode(", ",array_map('h',$q["target"])).")"," | ".h($q["on_delete"])."\n"," | ".h($q["on_update"])."\n",' | '.'Alter'.'';}echo" | \n";}echo''.'Add foreign key'."\n";}}if(support(is_view($R)?"view_trigger":"trigger")){echo" ".'Triggers'."\n";$_i=triggers($a);if($_i){echo"\n";foreach($_i
as$y=>$X)echo"".h($X[0])." | ".h($X[1])." | ".h($y)." | ".'Alter'."\n";echo" |
---|
\n";}echo''.'Add trigger'."\n";}}elseif(isset($_GET["schema"])){page_header('Database schema',"",array(),h(DB.($_GET["ns"]?".$_GET[ns]":"")));$Rh=array();$Sh=array();$ea=($_GET["schema"]?$_GET["schema"]:$_COOKIE["adminer_schema-".str_replace(".","_",DB)]);preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~',$ea,$De,PREG_SET_ORDER);foreach($De
as$s=>$A){$Rh[$A[1]]=array($A[2],$A[3]);$Sh[]="\n\t'".js_escape($A[1])."': [ $A[2], $A[3] ]";}$pi=0;$Ra=-1;$ah=array();$Fg=array();$re=array();foreach(table_status('',true)as$Q=>$R){if(is_view($R))continue;$eg=0;$ah[$Q]["fields"]=array();foreach(fields($Q)as$B=>$o){$eg+=1.25;$o["pos"]=$eg;$ah[$Q]["fields"][$B]=$o;}$ah[$Q]["pos"]=($Rh[$Q]?$Rh[$Q]:array($pi,0));foreach($b->foreignKeys($Q)as$X){if(!$X["db"]){$pe=$Ra;if($Rh[$Q][1]||$Rh[$X["table"]][1])$pe=min(floatval($Rh[$Q][1]),floatval($Rh[$X["table"]][1]))-1;else$Ra-=.1;while($re[(string)$pe])$pe-=.0001;$ah[$Q]["references"][$X["table"]][(string)$pe]=array($X["source"],$X["target"]);$Fg[$X["table"]][$Q][(string)$pe]=$X["target"];$re[(string)$pe]=true;}}$pi=max($pi,$ah[$Q]["pos"][0]+2.5+$eg);}echo'
';foreach($ah
as$B=>$Q){echo" ",' '.h($B)."",script("qsl('div').onmousedown = schemaMousedown;");foreach($Q["fields"]as$o){$X=' '.h($o["field"]).'';echo" ".($o["primary"]?" $X":$X);}foreach((array)$Q["references"]as$Yh=>$Gg){foreach($Gg
as$pe=>$Cg){$qe=$pe-$Rh[$B][1];$s=0;foreach($Cg[0]as$wh)echo"\n ";}}foreach((array)$Fg[$B]as$Yh=>$Gg){foreach($Gg
as$pe=>$f){$qe=$pe-$Rh[$B][1];$s=0;foreach($f
as$Xh)echo"\n ";}}echo"\n \n";}foreach($ah
as$B=>$Q){foreach((array)$Q["references"]as$Yh=>$Gg){foreach($Gg
as$pe=>$Cg){$Se=$pi;$He=-10;foreach($Cg[0]as$y=>$wh){$fg=$Q["pos"][0]+$Q["fields"][$wh]["pos"];$gg=$ah[$Yh]["pos"][0]+$ah[$Yh]["fields"][$Cg[1][$y]]["pos"];$Se=min($Se,$fg,$gg);$He=max($He,$fg,$gg);}echo" \n";}}}echo'
Permanent link
';}elseif(isset($_GET["dump"])){$a=$_GET["dump"];if($_POST&&!$n){$Db="";foreach(array("output","format","db_style","routines","events","table_style","auto_increment","triggers","data_style")as$y)$Db.="&$y=".urlencode($_POST[$y]);cookie("adminer_export",substr($Db,1));$S=array_flip((array)$_POST["tables"])+array_flip((array)$_POST["data"]);$Ic=dump_headers((count($S)==1?key($S):DB),(DB==""||count($S)>1));$Zd=preg_match('~sql~',$_POST["format"]);if($Zd){echo"-- Adminer $ia ".$ec[DRIVER]." dump\n\n";if($x=="sql"){echo"SET NAMES utf8;
SET time_zone = '+00:00';
".($_POST["data_style"]?"SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
":"")."
";$g->query("SET time_zone = '+00:00';");}}$Ih=$_POST["db_style"];$k=array(DB);if(DB==""){$k=$_POST["databases"];if(is_string($k))$k=explode("\n",rtrim(str_replace("\r","",$k),"\n"));}foreach((array)$k
as$l){$b->dumpDatabase($l);if($g->select_db($l)){if($Zd&&preg_match('~CREATE~',$Ih)&&($i=$g->result("SHOW CREATE DATABASE ".idf_escape($l),1))){set_utf8mb4($i);if($Ih=="DROP+CREATE")echo"DROP DATABASE IF EXISTS ".idf_escape($l).";\n";echo"$i;\n";}if($Zd){if($Ih)echo
use_sql($l).";\n\n";$Jf="";if($_POST["routines"]){foreach(array("FUNCTION","PROCEDURE")as$Ug){foreach(get_rows("SHOW $Ug STATUS WHERE Db = ".q($l),null,"-- ")as$I){$i=remove_definer($g->result("SHOW CREATE $Ug ".idf_escape($I["Name"]),2));set_utf8mb4($i);$Jf.=($Ih!='DROP+CREATE'?"DROP $Ug IF EXISTS ".idf_escape($I["Name"]).";;\n":"")."$i;;\n\n";}}}if($_POST["events"]){foreach(get_rows("SHOW EVENTS",null,"-- ")as$I){$i=remove_definer($g->result("SHOW CREATE EVENT ".idf_escape($I["Name"]),3));set_utf8mb4($i);$Jf.=($Ih!='DROP+CREATE'?"DROP EVENT IF EXISTS ".idf_escape($I["Name"]).";;\n":"")."$i;;\n\n";}}if($Jf)echo"DELIMITER ;;\n\n$Jf"."DELIMITER ;\n\n";}if($_POST["table_style"]||$_POST["data_style"]){$aj=array();foreach(table_status('',true)as$B=>$R){$Q=(DB==""||in_array($B,(array)$_POST["tables"]));$Mb=(DB==""||in_array($B,(array)$_POST["data"]));if($Q||$Mb){if($Ic=="tar"){$li=new
TmpFile;ob_start(array($li,'write'),1e5);}$b->dumpTable($B,($Q?$_POST["table_style"]:""),(is_view($R)?2:0));if(is_view($R))$aj[]=$B;elseif($Mb){$p=fields($B);$b->dumpData($B,$_POST["data_style"],"SELECT *".convert_fields($p,$p)." FROM ".table($B));}if($Zd&&$_POST["triggers"]&&$Q&&($_i=trigger_sql($B)))echo"\nDELIMITER ;;\n$_i\nDELIMITER ;\n";if($Ic=="tar"){ob_end_flush();tar_file((DB!=""?"":"$l/")."$B.csv",$li);}elseif($Zd)echo"\n";}}foreach($aj
as$Zi)$b->dumpTable($Zi,$_POST["table_style"],1);if($Ic=="tar")echo
pack("x512");}}}if($Zd)echo"-- ".$g->result("SELECT NOW()")."\n";exit;}page_header('Export',$n,($_GET["export"]!=""?array("table"=>$_GET["export"]):array()),h(DB));echo'
';$Wc=true;foreach($jg
as$y=>$X){if($y!=""&&$X>1){echo($Wc?"":" ")."".h($y)."";$Wc=false;}}}elseif(isset($_GET["privileges"])){page_header('Privileges');echo' '.'Create user'."";$G=$g->query("SELECT User, Host FROM mysql.".(DB==""?"user":"db WHERE ".q(DB)." LIKE Db")." ORDER BY Host, User");$ld=$G;if(!$G)$G=$g->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");echo" \n";}elseif(isset($_GET["sql"])){if(!$n&&$_POST["export"]){dump_headers("sql");$b->dumpTable("","");$b->dumpData("","table",$_POST["query"]);exit;}restart_session();$zd=&get_session("queries");$yd=&$zd[DB];if(!$n&&$_POST["clear"]){$yd=array();redirect(remove_from_uri("history"));}page_header((isset($_GET["import"])?'Import':'SQL command'),$n);if(!$n&&$_POST){$id=false;if(!isset($_GET["import"]))$F=$_POST["query"];elseif($_POST["webfile"]){$_h=$b->importServerPath();$id=@fopen((file_exists($_h)?$_h:"compress.zlib://$_h.gz"),"rb");$F=($id?fread($id,1e6):false);}else$F=get_file("sql_file",true);if(is_string($F)){if(function_exists('memory_get_usage'))@ini_set("memory_limit",max(ini_bytes("memory_limit"),2*strlen($F)+memory_get_usage()+8e6));if($F!=""&&strlen($F)<1e6){$ug=$F.(preg_match("~;[ \t\r\n]*\$~",$F)?"":";");if(!$yd||reset(end($yd))!=$ug){restart_session();$yd[]=array($ug,time());set_session("queries",$zd);stop_session();}}$xh="(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)";$Wb=";";$C=0;$tc=true;$h=connect();if(is_object($h)&&DB!=""){$h->select_db(DB);if($_GET["ns"]!="")set_schema($_GET["ns"],$h);}$tb=0;$yc=array();$Qf='[\'"'.($x=="sql"?'`#':($x=="sqlite"?'`[':($x=="mssql"?'[':''))).']|/\*|-- |$'.($x=="pgsql"?'|\$[^$]*\$':'');$qi=microtime(true);parse_str($_COOKIE["adminer_export"],$xa);$kc=$b->dumpFormat();unset($kc["sql"]);while($F!=""){if(!$C&&preg_match("~^$xh*+DELIMITER\\s+(\\S+)~i",$F,$A)){$Wb=$A[1];$F=substr($F,strlen($A[0]));}else{preg_match('('.preg_quote($Wb)."\\s*|$Qf)",$F,$A,PREG_OFFSET_CAPTURE,$C);list($gd,$eg)=$A[0];if(!$gd&&$id&&!feof($id))$F.=fread($id,1e5);else{if(!$gd&&rtrim($F)=="")break;$C=$eg+strlen($gd);if($gd&&rtrim($gd)!=$Wb){while(preg_match('('.($gd=='/*'?'\*/':($gd=='['?']':(preg_match('~^-- |^#~',$gd)?"\n":preg_quote($gd)."|\\\\."))).'|$)s',$F,$A,PREG_OFFSET_CAPTURE,$C)){$Yg=$A[0][0];if(!$Yg&&$id&&!feof($id))$F.=fread($id,1e5);else{$C=$A[0][1]+strlen($Yg);if($Yg[0]!="\\")break;}}}else{$tc=false;$ug=substr($F,0,$eg);$tb++;$mg="".$b->sqlCommandQuery($ug)." \n";if($x=="sqlite"&&preg_match("~^$xh*+ATTACH\\b~i",$ug,$A)){echo$mg,"".'ATTACH queries are not supported.'."\n";$yc[]=" $tb";if($_POST["error_stops"])break;}else{if(!$_POST["only_errors"]){echo$mg;ob_flush();flush();}$Dh=microtime(true);if($g->multi_query($ug)&&is_object($h)&&preg_match("~^$xh*+USE\\b~i",$ug))$h->query($ug);do{$G=$g->store_result();if($g->error){echo($_POST["only_errors"]?$mg:"")," ".'Error in query'.($g->errno?" ($g->errno)":"").": ".error()."\n";$yc[]=" $tb";if($_POST["error_stops"])break
2;}else{$ei=" (".format_time($Dh).")".(strlen($ug)<1000?" ".'Edit'."":"");$za=$g->affected_rows;$dj=($_POST["only_errors"]?"":$m->warnings());$ej="warnings-$tb";if($dj)$ei.=", ".'Warnings'."".script("qsl('a').onclick = partial(toggle, '$ej');","");$Fc=null;$Gc="explain-$tb";if(is_object($G)){$z=$_POST["limit"];$Cf=select($G,$h,array(),$z);if(!$_POST["only_errors"]){echo" \n";}}else{if(preg_match("~^$xh*+(CREATE|DROP|ALTER)$xh++(DATABASE|SCHEMA)\\b~i",$ug)){restart_session();set_session("dbs",null);stop_session();}if(!$_POST["only_errors"])echo"".lang(array('Query executed OK, %d row affected.','Query executed OK, %d rows affected.'),$za)."$ei\n";}echo($dj?" \n$dj \n":"");if($Fc){echo"\n";select($Fc,$h,$Cf);echo" \n";}}$Dh=microtime(true);}while($g->next_result());}$F=substr($F,$C);$C=0;}}}}if($tc)echo"".'No commands to execute.'."\n";elseif($_POST["only_errors"]){echo" ".lang(array('%d query executed OK.','%d queries executed OK.'),$tb-count($yc))," (".format_time($qi).")\n";}elseif($yc&&$tb>1)echo" ".'Error in query'.": ".implode("",$yc)."\n";}else
echo" ".upload_error($F)."\n";}echo'
';}elseif(isset($_GET["edit"])){$a=$_GET["edit"];$p=fields($a);$Z=(isset($_GET["select"])?($_POST["check"]&&count($_POST["check"])==1?where_check($_POST["check"][0],$p):""):where($_GET,$p));$Ji=(isset($_GET["select"])?$_POST["edit"]:$Z);foreach($p
as$B=>$o){if(!isset($o["privileges"][$Ji?"update":"insert"])||$b->fieldName($o)==""||$o["generated"])unset($p[$B]);}if($_POST&&!$n&&!isset($_GET["select"])){$xe=$_POST["referer"];if($_POST["insert"])$xe=($Ji?null:$_SERVER["REQUEST_URI"]);elseif(!preg_match('~^.+&select=.+$~',$xe))$xe=ME."select=".urlencode($a);$w=indexes($a);$Ei=unique_array($_GET["where"],$w);$xg="\nWHERE $Z";if(isset($_POST["delete"]))queries_redirect($xe,'Item has been deleted.',$m->delete($a,$xg,!$Ei));else{$N=array();foreach($p
as$B=>$o){$X=process_input($o);if($X!==false&&$X!==null)$N[idf_escape($B)]=$X;}if($Ji){if(!$N)redirect($xe);queries_redirect($xe,'Item has been updated.',$m->update($a,$N,$xg,!$Ei));if(is_ajax()){page_headers();page_messages($n);exit;}}else{$G=$m->insert($a,$N);$oe=($G?last_id():0);queries_redirect($xe,sprintf('Item%s has been inserted.',($oe?" $oe":"")),$G);}}}$I=null;if($_POST["save"])$I=(array)$_POST["fields"];elseif($Z){$K=array();foreach($p
as$B=>$o){if(isset($o["privileges"]["select"])){$Ga=convert_field($o);if($_POST["clone"]&&$o["auto_increment"])$Ga="''";if($x=="sql"&&preg_match("~enum|set~",$o["type"]))$Ga="1*".idf_escape($B);$K[]=($Ga?"$Ga AS ":"").idf_escape($B);}}$I=array();if(!support("table"))$K=array("*");if($K){$G=$m->select($a,$K,array($Z),$K,array(),(isset($_GET["select"])?2:1));if(!$G)$n=error();else{$I=$G->fetch_assoc();if(!$I)$I=false;}if(isset($_GET["select"])&&(!$I||$G->fetch_assoc()))$I=null;}}if(!support("table")&&!$p){if(!$Z){$G=$m->select($a,array("*"),$Z,array("*"));$I=($G?$G->fetch_assoc():false);if(!$I)$I=array($m->primary=>"");}if($I){foreach($I
as$y=>$X){if(!$Z)$I[$y]=null;$p[$y]=array("field"=>$y,"null"=>($y!=$m->primary),"auto_increment"=>($y==$m->primary));}}}edit_form($a,$p,$I,$Ji);}elseif(isset($_GET["create"])){$a=$_GET["create"];$Sf=array();foreach(array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST')as$y)$Sf[$y]=$y;$Eg=referencable_primary($a);$ed=array();foreach($Eg
as$Ph=>$o)$ed[str_replace("`","``",$Ph)."`".str_replace("`","``",$o["field"])]=$Ph;$Ff=array();$R=array();if($a!=""){$Ff=fields($a);$R=table_status($a);if(!$R)$n='No tables.';}$I=$_POST;$I["fields"]=(array)$I["fields"];if($I["auto_increment_col"])$I["fields"][$I["auto_increment_col"]]["auto_increment"]=true;if($_POST)set_adminer_settings(array("comments"=>$_POST["comments"],"defaults"=>$_POST["defaults"]));if($_POST&&!process_fields($I["fields"])&&!$n){if($_POST["drop"])queries_redirect(substr(ME,0,-1),'Table has been dropped.',drop_tables(array($a)));else{$p=array();$Da=array();$Oi=false;$cd=array();$Ef=reset($Ff);$Aa=" FIRST";foreach($I["fields"]as$y=>$o){$q=$ed[$o["type"]];$Ai=($q!==null?$Eg[$q]:$o);if($o["field"]!=""){if(!$o["has_default"])$o["default"]=null;if($y==$I["auto_increment_col"])$o["auto_increment"]=true;$rg=process_field($o,$Ai);$Da[]=array($o["orig"],$rg,$Aa);if($rg!=process_field($Ef,$Ef)){$p[]=array($o["orig"],$rg,$Aa);if($o["orig"]!=""||$Aa)$Oi=true;}if($q!==null)$cd[idf_escape($o["field"])]=($a!=""&&$x!="sqlite"?"ADD":" ").format_foreign_key(array('table'=>$ed[$o["type"]],'source'=>array($o["field"]),'target'=>array($Ai["field"]),'on_delete'=>$o["on_delete"],));$Aa=" AFTER ".idf_escape($o["field"]);}elseif($o["orig"]!=""){$Oi=true;$p[]=array($o["orig"]);}if($o["orig"]!=""){$Ef=next($Ff);if(!$Ef)$Aa="";}}$Uf="";if($Sf[$I["partition_by"]]){$Vf=array();if($I["partition_by"]=='RANGE'||$I["partition_by"]=='LIST'){foreach(array_filter($I["partition_names"])as$y=>$X){$Y=$I["partition_values"][$y];$Vf[]="\n PARTITION ".idf_escape($X)." VALUES ".($I["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$Uf.="\nPARTITION BY $I[partition_by]($I[partition])".($Vf?" (".implode(",",$Vf)."\n)":($I["partitions"]?" PARTITIONS ".(+$I["partitions"]):""));}elseif(support("partitioning")&&preg_match("~partitioned~",$R["Create_options"]))$Uf.="\nREMOVE PARTITIONING";$Le='Table has been altered.';if($a==""){cookie("adminer_engine",$I["Engine"]);$Le='Table has been created.';}$B=trim($I["name"]);queries_redirect(ME.(support("table")?"table=":"select=").urlencode($B),$Le,alter_table($a,$B,($x=="sqlite"&&($Oi||$cd)?$Da:$p),$cd,($I["Comment"]!=$R["Comment"]?$I["Comment"]:null),($I["Engine"]&&$I["Engine"]!=$R["Engine"]?$I["Engine"]:""),($I["Collation"]&&$I["Collation"]!=$R["Collation"]?$I["Collation"]:""),($I["Auto_increment"]!=""?number($I["Auto_increment"]):""),$Uf));}}page_header(($a!=""?'Alter table':'Create table'),$n,array("table"=>$a),h($a));if(!$_POST){$I=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($U["int"])?"int":(isset($U["integer"])?"integer":"")),"on_update"=>"")),"partition_names"=>array(""),);if($a!=""){$I=$R;$I["name"]=$a;$I["fields"]=array();if(!$_GET["auto_increment"])$I["Auto_increment"]="";foreach($Ff
as$o){$o["has_default"]=isset($o["default"]);$I["fields"][]=$o;}if(support("partitioning")){$jd="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($a);$G=$g->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $jd ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($I["partition_by"],$I["partitions"],$I["partition"])=$G->fetch_row();$Vf=get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $jd AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");$Vf[""]="";$I["partition_names"]=array_keys($Vf);$I["partition_values"]=array_values($Vf);}}}$pb=collations();$vc=engines();foreach($vc
as$uc){if(!strcasecmp($uc,$I["Engine"])){$I["Engine"]=$uc;break;}}echo'
',script("qs('#form')['defaults'].onclick();".(support("comment")?" editingCommentsClick(qs('#form')['comments']);":""));}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Jd=array("PRIMARY","UNIQUE","INDEX");$R=table_status($a,true);if(preg_match('~MyISAM|M?aria'.(min_version(5.6,'10.0.5')?'|InnoDB':'').'~i',$R["Engine"]))$Jd[]="FULLTEXT";if(preg_match('~MyISAM|M?aria'.(min_version(5.7,'10.2.2')?'|InnoDB':'').'~i',$R["Engine"]))$Jd[]="SPATIAL";$w=indexes($a);$kg=array();if($x=="mongo"){$kg=$w["_id_"];unset($Jd[0]);unset($w["_id_"]);}$I=$_POST;if($_POST&&!$n&&!$_POST["add"]&&!$_POST["drop_col"]){$c=array();foreach($I["indexes"]as$v){$B=$v["name"];if(in_array($v["type"],$Jd)){$f=array();$ue=array();$Yb=array();$N=array();ksort($v["columns"]);foreach($v["columns"]as$y=>$e){if($e!=""){$te=$v["lengths"][$y];$Xb=$v["descs"][$y];$N[]=idf_escape($e).($te?"(".(+$te).")":"").($Xb?" DESC":"");$f[]=$e;$ue[]=($te?$te:null);$Yb[]=$Xb;}}if($f){$Dc=$w[$B];if($Dc){ksort($Dc["columns"]);ksort($Dc["lengths"]);ksort($Dc["descs"]);if($v["type"]==$Dc["type"]&&array_values($Dc["columns"])===$f&&(!$Dc["lengths"]||array_values($Dc["lengths"])===$ue)&&array_values($Dc["descs"])===$Yb){unset($w[$B]);continue;}}$c[]=array($v["type"],$B,$N);}}}foreach($w
as$B=>$Dc)$c[]=array($Dc["type"],$B,"DROP");if(!$c)redirect(ME."table=".urlencode($a));queries_redirect(ME."table=".urlencode($a),'Indexes have been altered.',alter_indexes($a,$c));}page_header('Indexes',$n,array("table"=>$a),h($a));$p=array_keys(fields($a));if($_POST["add"]){foreach($I["indexes"]as$y=>$v){if($v["columns"][count($v["columns"])]!="")$I["indexes"][$y]["columns"][]="";}$v=end($I["indexes"]);if($v["type"]||array_filter($v["columns"],'strlen'))$I["indexes"][]=array("columns"=>array(1=>""));}if(!$I){foreach($w
as$y=>$v){$w[$y]["name"]=$y;$w[$y]["columns"][]="";}$w[]=array("columns"=>array(1=>""));$I["indexes"]=$w;}echo'
';}elseif(isset($_GET["database"])){$I=$_POST;if($_POST&&!$n&&!isset($_POST["add_x"])){$B=trim($I["name"]);if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),'Database has been dropped.',drop_databases(array(DB)));}elseif(DB!==$B){if(DB!=""){$_GET["db"]=$B;queries_redirect(preg_replace('~\bdb=[^&]*&~','',ME)."db=".urlencode($B),'Database has been renamed.',rename_database($B,$I["collation"]));}else{$k=explode("\n",str_replace("\r","",$B));$Jh=true;$ne="";foreach($k
as$l){if(count($k)==1||$l!=""){if(!create_database($l,$I["collation"]))$Jh=false;$ne=$l;}}restart_session();set_session("dbs",null);queries_redirect(ME."db=".urlencode($ne),'Database has been created.',$Jh);}}else{if(!$I["collation"])redirect(substr(ME,0,-1));query_redirect("ALTER DATABASE ".idf_escape($B).(preg_match('~^[a-z0-9_]+$~i',$I["collation"])?" COLLATE $I[collation]":""),substr(ME,0,-1),'Database has been altered.');}}page_header(DB!=""?'Alter database':'Create database',$n,array(),h(DB));$pb=collations();$B=DB;if($_POST)$B=$I["name"];elseif(DB!="")$I["collation"]=db_collation(DB,$pb);elseif($x=="sql"){foreach(get_vals("SHOW GRANTS")as$ld){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\.\*)?~',$ld,$A)&&$A[1]){$B=stripcslashes(idf_unescape("`$A[2]`"));break;}}}echo'
';}elseif(isset($_GET["scheme"])){$I=$_POST;if($_POST&&!$n){$_=preg_replace('~ns=[^&]*&~','',ME)."ns=";if($_POST["drop"])query_redirect("DROP SCHEMA ".idf_escape($_GET["ns"]),$_,'Schema has been dropped.');else{$B=trim($I["name"]);$_.=urlencode($B);if($_GET["ns"]=="")query_redirect("CREATE SCHEMA ".idf_escape($B),$_,'Schema has been created.');elseif($_GET["ns"]!=$B)query_redirect("ALTER SCHEMA ".idf_escape($_GET["ns"])." RENAME TO ".idf_escape($B),$_,'Schema has been altered.');else
redirect($_);}}page_header($_GET["ns"]!=""?'Alter schema':'Create schema',$n);if(!$I)$I["name"]=$_GET["ns"];echo'
';}elseif(isset($_GET["call"])){$da=($_GET["name"]?$_GET["name"]:$_GET["call"]);page_header('Call'.": ".h($da),$n);$Ug=routine($_GET["call"],(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Hd=array();$Jf=array();foreach($Ug["fields"]as$s=>$o){if(substr($o["inout"],-3)=="OUT")$Jf[$s]="@".idf_escape($o["field"])." AS ".idf_escape($o["field"]);if(!$o["inout"]||substr($o["inout"],0,2)=="IN")$Hd[]=$s;}if(!$n&&$_POST){$ab=array();foreach($Ug["fields"]as$y=>$o){if(in_array($y,$Hd)){$X=process_input($o);if($X===false)$X="''";if(isset($Jf[$y]))$g->query("SET @".idf_escape($o["field"])." = $X");}$ab[]=(isset($Jf[$y])?"@".idf_escape($o["field"]):$X);}$F=(isset($_GET["callf"])?"SELECT":"CALL")." ".table($da)."(".implode(", ",$ab).")";$Dh=microtime(true);$G=$g->multi_query($F);$za=$g->affected_rows;echo$b->selectQuery($F,$Dh,!$G);if(!$G)echo"".error()."\n";else{$h=connect();if(is_object($h))$h->select_db(DB);do{$G=$g->store_result();if(is_object($G))select($G,$h);else
echo" ".lang(array('Routine has been called, %d row affected.','Routine has been called, %d rows affected.'),$za)."\n";}while($g->next_result());if($Jf)select($g->query("SELECT ".implode(", ",$Jf)));}}echo'
';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];$B=$_GET["name"];$I=$_POST;if($_POST&&!$n&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){$Le=($_POST["drop"]?'Foreign key has been dropped.':($B!=""?'Foreign key has been altered.':'Foreign key has been created.'));$xe=ME."table=".urlencode($a);if(!$_POST["drop"]){$I["source"]=array_filter($I["source"],'strlen');ksort($I["source"]);$Xh=array();foreach($I["source"]as$y=>$X)$Xh[$y]=$I["target"][$y];$I["target"]=$Xh;}if($x=="sqlite")queries_redirect($xe,$Le,recreate_table($a,$a,array(),array(),array(" $B"=>($_POST["drop"]?"":" ".format_foreign_key($I)))));else{$c="ALTER TABLE ".table($a);$fc="\nDROP ".($x=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($B);if($_POST["drop"])query_redirect($c.$fc,$xe,$Le);else{query_redirect($c.($B!=""?"$fc,":"")."\nADD".format_foreign_key($I),$xe,$Le);$n='Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.'." $n";}}}page_header('Foreign key',$n,array("table"=>$a),h($a));if($_POST){ksort($I["source"]);if($_POST["add"])$I["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$I["target"]=array();}elseif($B!=""){$ed=foreign_keys($a);$I=$ed[$B];$I["source"][]="";}else{$I["table"]=$a;$I["source"]=array("");}echo'
';}elseif(isset($_GET["view"])){$a=$_GET["view"];$I=$_POST;$Gf="VIEW";if($x=="pgsql"&&$a!=""){$O=table_status($a);$Gf=strtoupper($O["Engine"]);}if($_POST&&!$n){$B=trim($I["name"]);$Ga=" AS\n$I[select]";$xe=ME."table=".urlencode($B);$Le='View has been altered.';$T=($_POST["materialized"]?"MATERIALIZED VIEW":"VIEW");if(!$_POST["drop"]&&$a==$B&&$x!="sqlite"&&$T=="VIEW"&&$Gf=="VIEW")query_redirect(($x=="mssql"?"ALTER":"CREATE OR REPLACE")." VIEW ".table($B).$Ga,$xe,$Le);else{$Zh=$B."_adminer_".uniqid();drop_create("DROP $Gf ".table($a),"CREATE $T ".table($B).$Ga,"DROP $T ".table($B),"CREATE $T ".table($Zh).$Ga,"DROP $T ".table($Zh),($_POST["drop"]?substr(ME,0,-1):$xe),'View has been dropped.',$Le,'View has been created.',$a,$B);}}if(!$_POST&&$a!=""){$I=view($a);$I["name"]=$a;$I["materialized"]=($Gf!="VIEW");if(!$n)$n=error();}page_header(($a!=""?'Alter view':'Create view'),$n,array("table"=>$a),h($a));echo'
';}elseif(isset($_GET["event"])){$aa=$_GET["event"];$Ud=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$Fh=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");$I=$_POST;if($_POST&&!$n){if($_POST["drop"])query_redirect("DROP EVENT ".idf_escape($aa),substr(ME,0,-1),'Event has been dropped.');elseif(in_array($I["INTERVAL_FIELD"],$Ud)&&isset($Fh[$I["STATUS"]])){$Zg="\nON SCHEDULE ".($I["INTERVAL_VALUE"]?"EVERY ".q($I["INTERVAL_VALUE"])." $I[INTERVAL_FIELD]".($I["STARTS"]?" STARTS ".q($I["STARTS"]):"").($I["ENDS"]?" ENDS ".q($I["ENDS"]):""):"AT ".q($I["STARTS"]))." ON COMPLETION".($I["ON_COMPLETION"]?"":" NOT")." PRESERVE";queries_redirect(substr(ME,0,-1),($aa!=""?'Event has been altered.':'Event has been created.'),queries(($aa!=""?"ALTER EVENT ".idf_escape($aa).$Zg.($aa!=$I["EVENT_NAME"]?"\nRENAME TO ".idf_escape($I["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($I["EVENT_NAME"]).$Zg)."\n".$Fh[$I["STATUS"]]." COMMENT ".q($I["EVENT_COMMENT"]).rtrim(" DO\n$I[EVENT_DEFINITION]",";").";"));}}page_header(($aa!=""?'Alter event'.": ".h($aa):'Create event'),$n);if(!$I&&$aa!=""){$J=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($aa));$I=reset($J);}echo'
';}elseif(isset($_GET["procedure"])){$da=($_GET["name"]?$_GET["name"]:$_GET["procedure"]);$Ug=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$I=$_POST;$I["fields"]=(array)$I["fields"];if($_POST&&!process_fields($I["fields"])&&!$n){$Df=routine($_GET["procedure"],$Ug);$Zh="$I[name]_adminer_".uniqid();drop_create("DROP $Ug ".routine_id($da,$Df),create_routine($Ug,$I),"DROP $Ug ".routine_id($I["name"],$I),create_routine($Ug,array("name"=>$Zh)+$I),"DROP $Ug ".routine_id($Zh,$I),substr(ME,0,-1),'Routine has been dropped.','Routine has been altered.','Routine has been created.',$da,$I["name"]);}page_header(($da!=""?(isset($_GET["function"])?'Alter function':'Alter procedure').": ".h($da):(isset($_GET["function"])?'Create function':'Create procedure')),$n);if(!$_POST&&$da!=""){$I=routine($_GET["procedure"],$Ug);$I["name"]=$da;}$pb=get_vals("SHOW CHARACTER SET");sort($pb);$Vg=routine_languages();echo'
';}elseif(isset($_GET["sequence"])){$fa=$_GET["sequence"];$I=$_POST;if($_POST&&!$n){$_=substr(ME,0,-1);$B=trim($I["name"]);if($_POST["drop"])query_redirect("DROP SEQUENCE ".idf_escape($fa),$_,'Sequence has been dropped.');elseif($fa=="")query_redirect("CREATE SEQUENCE ".idf_escape($B),$_,'Sequence has been created.');elseif($fa!=$B)query_redirect("ALTER SEQUENCE ".idf_escape($fa)." RENAME TO ".idf_escape($B),$_,'Sequence has been altered.');else
redirect($_);}page_header($fa!=""?'Alter sequence'.": ".h($fa):'Create sequence',$n);if(!$I)$I["name"]=$fa;echo'
';}elseif(isset($_GET["type"])){$ga=$_GET["type"];$I=$_POST;if($_POST&&!$n){$_=substr(ME,0,-1);if($_POST["drop"])query_redirect("DROP TYPE ".idf_escape($ga),$_,'Type has been dropped.');else
query_redirect("CREATE TYPE ".idf_escape(trim($I["name"]))." $I[as]",$_,'Type has been created.');}page_header($ga!=""?'Alter type'.": ".h($ga):'Create type',$n);if(!$I)$I["as"]="AS ";echo'
';}elseif(isset($_GET["trigger"])){$a=$_GET["trigger"];$B=$_GET["name"];$zi=trigger_options();$I=(array)trigger($B)+array("Trigger"=>$a."_bi");if($_POST){if(!$n&&in_array($_POST["Timing"],$zi["Timing"])&&in_array($_POST["Event"],$zi["Event"])&&in_array($_POST["Type"],$zi["Type"])){$pf=" ON ".table($a);$fc="DROP TRIGGER ".idf_escape($B).($x=="pgsql"?$pf:"");$xe=ME."table=".urlencode($a);if($_POST["drop"])query_redirect($fc,$xe,'Trigger has been dropped.');else{if($B!="")queries($fc);queries_redirect($xe,($B!=""?'Trigger has been altered.':'Trigger has been created.'),queries(create_trigger($pf,$_POST)));if($B!="")queries(create_trigger($pf,$I+array("Type"=>reset($zi["Type"]))));}}$I=$_POST;}page_header(($B!=""?'Alter trigger'.": ".h($B):'Create trigger'),$n,array("table"=>$a));echo'
';}elseif(isset($_GET["user"])){$ha=$_GET["user"];$pg=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$I){foreach(explode(",",($I["Privilege"]=="Grant option"?"":$I["Context"]))as$Bb)$pg[$Bb][$I["Privilege"]]=$I["Comment"];}$pg["Server Admin"]+=$pg["File access on server"];$pg["Databases"]["Create routine"]=$pg["Procedures"]["Create routine"];unset($pg["Procedures"]["Create routine"]);$pg["Columns"]=array();foreach(array("Select","Insert","Update","References")as$X)$pg["Columns"][$X]=$pg["Tables"][$X];unset($pg["Server Admin"]["Usage"]);foreach($pg["Tables"]as$y=>$X)unset($pg["Databases"][$y]);$Ye=array();if($_POST){foreach($_POST["objects"]as$y=>$X)$Ye[$X]=(array)$Ye[$X]+(array)$_POST["grants"][$y];}$md=array();$nf="";if(isset($_GET["host"])&&($G=$g->query("SHOW GRANTS FOR ".q($ha)."@".q($_GET["host"])))){while($I=$G->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$I[0],$A)&&preg_match_all('~ *([^(,]*[^ ,(])( *\([^)]+\))?~',$A[1],$De,PREG_SET_ORDER)){foreach($De
as$X){if($X[1]!="USAGE")$md["$A[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$I[0]))$md["$A[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$I[0],$A))$nf=$A[1];}}if($_POST&&!$n){$of=(isset($_GET["host"])?q($ha)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $of",ME."privileges=",'User has been dropped.');else{$af=q($_POST["user"])."@".q($_POST["host"]);$Xf=$_POST["pass"];if($Xf!=''&&!$_POST["hashed"]&&!min_version(8)){$Xf=$g->result("SELECT PASSWORD(".q($Xf).")");$n=!$Xf;}$Gb=false;if(!$n){if($of!=$af){$Gb=queries((min_version(5)?"CREATE USER":"GRANT USAGE ON *.* TO")." $af IDENTIFIED BY ".(min_version(8)?"":"PASSWORD ").q($Xf));$n=!$Gb;}elseif($Xf!=$nf)queries("SET PASSWORD FOR $af = ".q($Xf));}if(!$n){$Rg=array();foreach($Ye
as$if=>$ld){if(isset($_GET["grant"]))$ld=array_filter($ld);$ld=array_keys($ld);if(isset($_GET["grant"]))$Rg=array_diff(array_keys(array_filter($Ye[$if],'strlen')),$ld);elseif($of==$af){$lf=array_keys((array)$md[$if]);$Rg=array_diff($lf,$ld);$ld=array_diff($ld,$lf);unset($md[$if]);}if(preg_match('~^(.+)\s*(\(.*\))?$~U',$if,$A)&&(!grant("REVOKE",$Rg,$A[2]," ON $A[1] FROM $af")||!grant("GRANT",$ld,$A[2]," ON $A[1] TO $af"))){$n=true;break;}}}if(!$n&&isset($_GET["host"])){if($of!=$af)queries("DROP USER $of");elseif(!isset($_GET["grant"])){foreach($md
as$if=>$Rg){if(preg_match('~^(.+)(\(.*\))?$~U',$if,$A))grant("REVOKE",array_keys($Rg),$A[2]," ON $A[1] FROM $af");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?'User has been altered.':'User has been created.'),!$n);if($Gb)$g->query("DROP USER $af");}}page_header((isset($_GET["host"])?'Username'.": ".h("$ha@$_GET[host]"):'Create user'),$n,array("privileges"=>array('','Privileges')));if($_POST){$I=$_POST;$md=$Ye;}else{$I=$_GET+array("host"=>$g->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$I["pass"]=$nf;if($nf!="")$I["hashed"]=true;$md[(DB==""||$md?"":idf_escape(addcslashes(DB,"%_\\"))).".*"]=array();}echo'
';}elseif(isset($_GET["processlist"])){if(support("kill")&&$_POST&&!$n){$je=0;foreach((array)$_POST["kill"]as$X){if(kill_process($X))$je++;}queries_redirect(ME."processlist=",lang(array('%d process has been killed.','%d processes have been killed.'),$je),$je||!$_POST["kill"]);}page_header('Process list',$n);echo'
',script("tableCheck();");}elseif(isset($_GET["select"])){$a=$_GET["select"];$R=table_status1($a);$w=indexes($a);$p=fields($a);$ed=column_foreign_keys($a);$kf=$R["Oid"];parse_str($_COOKIE["adminer_import"],$ya);$Sg=array();$f=array();$di=null;foreach($p
as$y=>$o){$B=$b->fieldName($o);if(isset($o["privileges"]["select"])&&$B!=""){$f[$y]=html_entity_decode(strip_tags($B),ENT_QUOTES);if(is_shortable($o))$di=$b->selectLengthProcess();}$Sg+=$o["privileges"];}list($K,$nd)=$b->selectColumnsProcess($f,$w);$Yd=count($nd)selectSearchProcess($p,$w);$_f=$b->selectOrderProcess($p,$w);$z=$b->selectLimitProcess();if($_GET["val"]&&is_ajax()){header("Content-Type: text/plain; charset=utf-8");foreach($_GET["val"]as$Fi=>$I){$Ga=convert_field($p[key($I)]);$K=array($Ga?$Ga:idf_escape(key($I)));$Z[]=where_check($Fi,$p);$H=$m->select($a,$K,$Z,$K);if($H)echo
reset($H->fetch_row());}exit;}$kg=$Hi=null;foreach($w
as$v){if($v["type"]=="PRIMARY"){$kg=array_flip($v["columns"]);$Hi=($K?$kg:array());foreach($Hi
as$y=>$X){if(in_array(idf_escape($y),$K))unset($Hi[$y]);}break;}}if($kf&&!$kg){$kg=$Hi=array($kf=>0);$w[]=array("type"=>"PRIMARY","columns"=>array($kf));}if($_POST&&!$n){$jj=$Z;if(!$_POST["all"]&&is_array($_POST["check"])){$gb=array();foreach($_POST["check"]as$db)$gb[]=where_check($db,$p);$jj[]="((".implode(") OR (",$gb)."))";}$jj=($jj?"\nWHERE ".implode(" AND ",$jj):"");if($_POST["export"]){cookie("adminer_import","output=".urlencode($_POST["output"])."&format=".urlencode($_POST["format"]));dump_headers($a);$b->dumpTable($a,"");$jd=($K?implode(", ",$K):"*").convert_fields($f,$p,$K)."\nFROM ".table($a);$pd=($nd&&$Yd?"\nGROUP BY ".implode(", ",$nd):"").($_f?"\nORDER BY ".implode(", ",$_f):"");if(!is_array($_POST["check"])||$kg)$F="SELECT $jd$jj$pd";else{$Di=array();foreach($_POST["check"]as$X)$Di[]="(SELECT".limit($jd,"\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$p).$pd,1).")";$F=implode(" UNION ALL ",$Di);}$b->dumpData($a,"table",$F);exit;}if(!$b->selectEmailProcess($Z,$ed)){if($_POST["save"]||$_POST["delete"]){$G=true;$za=0;$N=array();if(!$_POST["delete"]){foreach($f
as$B=>$X){$X=process_input($p[$B]);if($X!==null&&($_POST["clone"]||$X!==false))$N[idf_escape($B)]=($X!==false?$X:idf_escape($B));}}if($_POST["delete"]||$N){if($_POST["clone"])$F="INTO ".table($a)." (".implode(", ",array_keys($N)).")\nSELECT ".implode(", ",$N)."\nFROM ".table($a);if($_POST["all"]||($kg&&is_array($_POST["check"]))||$Yd){$G=($_POST["delete"]?$m->delete($a,$jj):($_POST["clone"]?queries("INSERT $F$jj"):$m->update($a,$N,$jj)));$za=$g->affected_rows;}else{foreach((array)$_POST["check"]as$X){$fj="\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$p);$G=($_POST["delete"]?$m->delete($a,$fj,1):($_POST["clone"]?queries("INSERT".limit1($a,$F,$fj)):$m->update($a,$N,$fj,1)));if(!$G)break;$za+=$g->affected_rows;}}}$Le=lang(array('%d item has been affected.','%d items have been affected.'),$za);if($_POST["clone"]&&$G&&$za==1){$oe=last_id();if($oe)$Le=sprintf('Item%s has been inserted.'," $oe");}queries_redirect(remove_from_uri($_POST["all"]&&$_POST["delete"]?"page":""),$Le,$G);if(!$_POST["delete"]){edit_form($a,$p,(array)$_POST["fields"],!$_POST["clone"]);page_footer();exit;}}elseif(!$_POST["import"]){if(!$_POST["val"])$n='Ctrl+click on a value to modify it.';else{$G=true;$za=0;foreach($_POST["val"]as$Fi=>$I){$N=array();foreach($I
as$y=>$X){$y=bracket_escape($y,1);$N[idf_escape($y)]=(preg_match('~char|text~',$p[$y]["type"])||$X!=""?$b->processInput($p[$y],$X):"NULL");}$G=$m->update($a,$N," WHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($Fi,$p),!$Yd&&!$kg," ");if(!$G)break;$za+=$g->affected_rows;}queries_redirect(remove_from_uri(),lang(array('%d item has been affected.','%d items have been affected.'),$za),$G);}}elseif(!is_string($Tc=get_file("csv_file",true)))$n=upload_error($Tc);elseif(!preg_match('~~u',$Tc))$n='File must be in UTF-8 encoding.';else{cookie("adminer_import","output=".urlencode($ya["output"])."&format=".urlencode($_POST["separator"]));$G=true;$rb=array_keys($p);preg_match_all('~(?>"[^"]*"|[^"\r\n]+)+~',$Tc,$De);$za=count($De[0]);$m->begin();$L=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));$J=array();foreach($De[0]as$y=>$X){preg_match_all("~((?>\"[^\"]*\")+|[^$L]*)$L~",$X.$L,$Ee);if(!$y&&!array_diff($Ee[1],$rb)){$rb=$Ee[1];$za--;}else{$N=array();foreach($Ee[1]as$s=>$nb)$N[idf_escape($rb[$s])]=($nb==""&&$p[$rb[$s]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$nb))));$J[]=$N;}}$G=(!$J||$m->insertUpdate($a,$J,$kg));if($G)$G=$m->commit();queries_redirect(remove_from_uri("page"),lang(array('%d row has been imported.','%d rows have been imported.'),$za),$G);$m->rollback();}}}$Ph=$b->tableName($R);if(is_ajax()){page_headers();ob_start();}else
page_header('Select'.": $Ph",$n);$N=null;if(isset($Sg["insert"])||!support("table")){$N="";foreach((array)$_GET["where"]as$X){if($ed[$X["col"]]&&count($ed[$X["col"]])==1&&($X["op"]=="="||(!$X["op"]&&!preg_match('~[_%]~',$X["val"]))))$N.="&set".urlencode("[".bracket_escape($X["col"])."]")."=".urlencode($X["val"]);}}$b->selectLinks($R,$N);if(!$f&&support("table"))echo"".'Unable to select the table'.($p?".":": ".error())."\n";else{echo" \n";$D=$_GET["page"];if($D=="last"){$hd=$g->result(count_rows($a,$Z,$Yd,$nd));$D=floor(max(0,$hd-1)/$z);}$eh=$K;$od=$nd;if(!$eh){$eh[]="*";$Cb=convert_fields($f,$p,$K);if($Cb)$eh[]=substr($Cb,2);}foreach($K
as$y=>$X){$o=$p[idf_unescape($X)];if($o&&($Ga=convert_field($o)))$eh[$y]="$Ga AS $X";}if(!$Yd&&$Hi){foreach($Hi
as$y=>$X){$eh[]=idf_escape($y);if($od)$od[]=idf_escape($y);}}$G=$m->select($a,$eh,$Z,$od,$_f,$z,$D,true);if(!$G)echo"".error()."\n";else{if($x=="mssql"&&$D)$G->seek($z*$D);$sc=array();echo" \n",(!$nd&&$K?"":script("tableCheck();"));}}}if(is_ajax()){ob_end_clean();exit;}}elseif(isset($_GET["variables"])){$O=isset($_GET["status"]);page_header($O?'Status':'Variables');$Wi=($O?show_status():show_variables());if(!$Wi)echo"".'No rows.'."\n";else{echo" \n";foreach($Wi
as$y=>$X){echo"","".h($y)." "," | ".h($X);}echo" | \n";}}elseif(isset($_GET["script"])){header("Content-Type: text/javascript; charset=utf-8");if($_GET["script"]=="db"){$Mh=array("Data_length"=>0,"Index_length"=>0,"Data_free"=>0);foreach(table_status()as$B=>$R){json_row("Comment-$B",h($R["Comment"]));if(!is_view($R)){foreach(array("Engine","Collation")as$y)json_row("$y-$B",h($R[$y]));foreach($Mh+array("Auto_increment"=>0,"Rows"=>0)as$y=>$X){if($R[$y]!=""){$X=format_number($R[$y]);json_row("$y-$B",($y=="Rows"&&$X&&$R["Engine"]==($zh=="pgsql"?"table":"InnoDB")?"~ $X":$X));if(isset($Mh[$y]))$Mh[$y]+=($R["Engine"]!="InnoDB"||$y!="Data_free"?$R[$y]:0);}elseif(array_key_exists($y,$R))json_row("$y-$B");}}}foreach($Mh
as$y=>$X)json_row("sum-$y",format_number($X));json_row("");}elseif($_GET["script"]=="kill")$g->query("KILL ".number($_POST["kill"]));else{foreach(count_tables($b->databases())as$l=>$X){json_row("tables-$l",$X);json_row("size-$l",db_size($l));}json_row("");}exit;}else{$Vh=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Vh&&!$n&&!$_POST["search"]){$G=true;$Le="";if($x=="sql"&&$_POST["tables"]&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"]))queries("SET foreign_key_checks = 0");if($_POST["truncate"]){if($_POST["tables"])$G=truncate_tables($_POST["tables"]);$Le='Tables have been truncated.';}elseif($_POST["move"]){$G=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$Le='Tables have been moved.';}elseif($_POST["copy"]){$G=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$Le='Tables have been copied.';}elseif($_POST["drop"]){if($_POST["views"])$G=drop_views($_POST["views"]);if($G&&$_POST["tables"])$G=drop_tables($_POST["tables"]);$Le='Tables have been dropped.';}elseif($x!="sql"){$G=($x=="sqlite"?queries("VACUUM"):apply_queries("VACUUM".($_POST["optimize"]?"":" ANALYZE"),$_POST["tables"]));$Le='Tables have been optimized.';}elseif(!$_POST["tables"])$Le='No tables.';elseif($G=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"])))){while($I=$G->fetch_assoc())$Le.="".h($I["Table"]).": ".h($I["Msg_text"])." ";}queries_redirect(substr(ME,0,-1),$Le,$G);}page_header(($_GET["ns"]==""?'Database'.": ".h(DB):'Schema'.": ".h($_GET["ns"])),$n,true);if($b->homepage()){if($_GET["ns"]!==""){echo"".'Tables and views'."\n";$Uh=tables_list();if(!$Uh)echo"".'No tables.'."\n";else{echo" \n",script("tableCheck();");}echo''.'Create table'."\n",(support("view")?''.'Create view'."\n":"");if(support("routine")){echo" ".'Routines'."\n";$Wg=routines();if($Wg){echo"\n",''.'Name'.' | '.'Type'.' | '.'Return type'." | | \n";odd('');foreach($Wg
as$I){$B=($I["SPECIFIC_NAME"]==$I["ROUTINE_NAME"]?"":"&name=".urlencode($I["ROUTINE_NAME"]));echo'',''.h($I["ROUTINE_NAME"]).'',' | '.h($I["ROUTINE_TYPE"]),' | '.h($I["DTD_IDENTIFIER"]),' | '.'Alter'."";}echo" | \n";}echo''.(support("procedure")?''.'Create procedure'.'':'').''.'Create function'."\n";}if(support("sequence")){echo" ".'Sequences'."\n";$kh=get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema() ORDER BY sequence_name");if($kh){echo"\n","".'Name'." | \n";odd('');foreach($kh
as$X)echo"".h($X)."\n";echo" |
---|
\n";}echo"".'Create sequence'."\n";}if(support("type")){echo" ".'User types'."\n";$Ri=types();if($Ri){echo"\n","".'Name'." | \n";odd('');foreach($Ri
as$X)echo"".h($X)."\n";echo" |
---|
\n";}echo"".'Create type'."\n";}if(support("event")){echo" ".'Events'."\n";$J=get_rows("SHOW EVENTS");if($J){echo"\n","".'Name'." | ".'Schedule'." | ".'Start'." | ".'End'." | | \n";foreach($J
as$I){echo"","".h($I["Name"])," | ".($I["Execute at"]?'At given time'." | ".$I["Execute at"]:'Every'." ".$I["Interval value"]." ".$I["Interval field"]." | $I[Starts]")," | $I[Ends]",' | '.'Alter'.'';}echo" | \n";$_c=$g->result("SELECT @@event_scheduler");if($_c&&$_c!="ON")echo"event_scheduler : ".h($_c)."\n";}echo'
'.'Create event'."\n";}if($Uh)echo
script("ajaxSetHtml('".js_escape(ME)."script=db');");}}}page_footer();
|