From 10376658b2d19c49fd906424e721f4f53fdba630 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 29 Mar 2015 17:54:27 +0200 Subject: [PATCH] Commit to update adminer --- _sakura/components/Main.php | 7 +- _sakura/components/Sessions.php | 9 +- _sakura/components/Users.php | 12 + _sakura/sakura.php | 12 +- main/sqladmin_.php | 467 ++++++++++++++++---------------- 5 files changed, 266 insertions(+), 241 deletions(-) create mode 100644 _sakura/components/Users.php diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index 70cc95c..b621cf0 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -17,10 +17,6 @@ class Main { if(version_compare(phpversion(), '5.4.0', '<')) die('

Upgrade your PHP Version to at least PHP 5.4!

'); - // Start session - if(session_status() != PHP_SESSION_ACTIVE) - session_start(); - // Configuration Management and local configuration Configuration::init($config); @@ -30,6 +26,9 @@ class Main { // "Dynamic" Configuration Configuration::initDB(); + // Create new session + Session::init(); + // Templating engine self::initTwig(); diff --git a/_sakura/components/Sessions.php b/_sakura/components/Sessions.php index bc62089..51689b0 100644 --- a/_sakura/components/Sessions.php +++ b/_sakura/components/Sessions.php @@ -7,6 +7,13 @@ namespace Sakura; class Session { - + // Initiate new session + public static function init() { + + // Start PHP session + if(session_status() != PHP_SESSION_ACTIVE) + session_start(); + + } } diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php new file mode 100644 index 0000000..0775c8b --- /dev/null +++ b/_sakura/components/Users.php @@ -0,0 +1,12 @@ + */ +// Declare namespace +namespace Sakura; + // Start output buffering ob_start(); - + // Define Sakura version -define('SAKURA_VERSION', '20150325'); +define('SAKURA_VERSION', '20150329'); // Define Sakura Path define('ROOT_DIRECTORY', str_replace('_sakura', '', dirname(__FILE__))); @@ -25,6 +28,7 @@ require_once ROOT_DIRECTORY .'_sakura/components/Main.php'; require_once ROOT_DIRECTORY .'_sakura/components/Hashing.php'; require_once ROOT_DIRECTORY .'_sakura/components/Configuration.php'; require_once ROOT_DIRECTORY .'_sakura/components/Sessions.php'; +require_once ROOT_DIRECTORY .'_sakura/components/Users.php'; // Generate path to database driver $_DBNGNPATH = ROOT_DIRECTORY .'_sakura/components/database/' . $fiiConf['db']['driver'] . '.php'; @@ -40,12 +44,12 @@ else set_error_handler(array('Sakura\Main', 'ErrorHandler')); // Initialise Flashii Class -Sakura\Main::init($fiiConf); +Main::init($fiiConf); // Set base page rendering data $renderData = array( 'sakura' => [ 'version' => SAKURA_VERSION, - 'urls' => $fiiConf['urls'] + 'urls' => Configuration::getLocalConfig('urls') ] ); diff --git a/main/sqladmin_.php b/main/sqladmin_.php index 7118ac3..66b56b4 100644 --- a/main/sqladmin_.php +++ b/main/sqladmin_.php @@ -5,8 +5,8 @@ * @copyright 2007 Jakub Vrana * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) -* @version 4.2.0 -*/error_reporting(6135);$pc=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($pc||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$yg=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($yg)$$X=$yg;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");if(isset($_GET["file"])){if($_SERVER["HTTP_IF_MODIFIED_SINCE"]){header("HTTP/1.1 304 Not Modified");exit;}header("Expires: ".gmdate("D, d M Y H:i:s",time()+365*24*60*60)." GMT");header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");if($_GET["file"]=="favicon.ico"){header("Content-Type: image/x-icon");echo +* @version 4.2.1 +*/error_reporting(6135);$oc=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($oc||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$yg=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($yg)$$X=$yg;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");if(isset($_GET["file"])){if($_SERVER["HTTP_IF_MODIFIED_SINCE"]){header("HTTP/1.1 304 Not Modified");exit;}header("Expires: ".gmdate("D, d M Y H:i:s",time()+365*24*60*60)." GMT");header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");if($_GET["file"]=="favicon.ico"){header("Content-Type: image/x-icon");echo lzw_decompress("\0\0\0` \0\0\n @\0C\"\0`EQ?tvM'Jdd\\b0\0\"fӈs5AXPaJ08#RTz`#.cXȀ?-\0Im?.M\0ȯ(̉/(%\0");}elseif($_GET["file"]=="default.css"){header("Content-Type: text/css; charset=utf-8");echo lzw_decompress("\n1ٌ̇l7B14vb0fsn2Bѱ٘n:#(b.\rDc)a7El ñi1̎s-4f i7 Févt2! r0t~U'3MWB'cP:6T\rcAzr_WK\r-VNFS%~c&\\^ruŎÞً4'7kQh'g\rFB\ryT7SSP1=ǤcI:dm>S8LJt.M ϋ`'C889 Q2#8А6mjh<9/:J)ʂ\0d>!\0Zvno(k7s> !R\"*nS\0@P\"(#[@g ozn9k8n1I* =n0c(;à!*c>ΎE7DLJ1J=1L?s=#`3\$4uȱzGC YAt?;Qk&YPuǯ}UaHV%G;slڴIH3xw0t6%MR%jhB<\0AQ-ʈ QH\nvL+væ<\rv\\*Ӵݢgn˩ TЩ2P\rߋ\"+z8:#2J[i;zr3 #ى:n\r㽃epdݍ 2c4k\rGE6_މb/HB%0>hoWnxl֍浃CQ^\r4lK{Z:Ã.pĂJB-+B(T%J0lT`+-@BۄV\0C,0tF?Ġ\na@Ɍ>ZECO-^Q&)I)R]\r97_\rF80Ob >\nR_8٫ ov0bCAF!tă%0/zAYO(4 '] I8hH053@x&n|T)`.s6eYDzJѓ.{GEbӋ2{\$**@C-:zYHZI5F]YCOA`x'.*9t'{(wP=**xwr*cc|DV\rV.0 Vd?Ҁ,E͝`T6ۈ-ڎT[ѐz.Ar̀Pnc= a9Fn!u A0iPJ6e T]V[\rXav k\n+Eܕ*\0~@g\"NCI\$Ɍx@Wy*vuD\0v댆V\0V`GuE֕flh@)0@T7§RAٷ3ۘ/Q],s{VRFA<vץ%@9F5t%+ /8;WJo:N` h{ܣ Ԑ8Eu&W|ɆU&\r\"|-udžN:ncfV# U20>\">`k]-xS͇ТcB}&`r+E\$yNb,Wx -9r,`+ˊC)7x\rWfMSR \\zQ̓u A24L&Hi µS\$)eg rȌ\$]ZiYskWn>7E1k8drkEwwcmTya\$tx\rB=*<l fKN/ lkH8.?f6ч{gi/\"@ K@2a|#,Z wd6w^&tP].Tkro\ro=%h`:\0᱂ |ꊣa Ԯ6*:*rO-^nM}Aya\nu^rnO\r`T~</wy}:|̡6v \rcٸߣC/6ഷ#p@p `Zch\0 \0o 4OO i\0-\n/\0D. .Đ\0fiȫ\0ID\0\r0foGeJ|\rl 3~ iP&/\09 ^\0r0] ›o .\" M vPZm pP ڜޏ{C ?kϼ}d ʏ~=.- m1> hЕ1;QIOP\rcpApVk\rQ* Q}q>u15BqQ[1flap\0*JQ=G _bGHF.0 = 2P P!#(3 \n!1&72f`/\0\"PU \$\r0 ,QrU&2f_X ]9\"S''y8\rkW)O)*Ra%\\ i%&ҳ+r3S`,v&2L&Pu*-0\"%HĬԞ@ؓHBP(\$p&,1M ح;\rn. I.',1)42u+3 ` S pL\nt_*S3;6r'h3555䜋d2q+68O7sC\"pm8ҭ69m\n@e0<8B8<,(8\0 0J<@IR6pԭmG\"116.\"5̂:8bA1;';?<*\$,̍o= T/3#҆");}elseif($_GET["file"]=="functions.js"){header("Content-Type: text/javascript; charset=utf-8");echo lzw_decompress("f:gCI\n0S a9S`&(n0QIf\$At^ sGtf6ey()LSP'R'fq]\"s> )`H2Eq9?*)t'ϧ\n \rs2Xœej:9^1cȝ:Y@u㓛4X&|)ђ-Kx S1\$@\\!x]\0FCO:1K*F4 ak KϚ2lp3J<,28# \r hF݉2Pl(\$ְ\nJ۷-ǰcc~Frtbm{h.{tkBKcz4C9۫~>`ƓC s:!cڵ*WHX:W;Nj*/(_p3HIKln!trG㭺tC v?m㤣\0Coܥcbf6I'\rb7h`9id5taM={ɩ`NoK !d4zWXdmH*S ]3&\0ڰ d%A- ( Q}U !t7 䋆>xt{mY0@^\"= @t\r+Y.X\nI'KT^(D.@ ++@3X aE!,Y2-432Ԍ MOI\$q% ċGX9[R\0nи PJy\r Bp\\HpgSɼFaejk.4C.^yi9PĈe\"ΔNYBH#8B1\"j\\کx#@G 92f.ЌpsrTJxk4KIlf8zKȇ>AKn^=&A*?' ^%; 4܀9QhN>M=['vHIJvRt<Ҳ^z‰B^h'ɩ)-'#9JT)@jO!c,ej@H,javZ>ҷ)E`\0\nTP8LX'L {XzoD%sPW:[=v0?ܷ,%{\". .YIB \nWpV)qAMV5IPοˎ(b.\$[Қj@h\nF-4 8nj+VMxnjmb\$ \n'~ Z@ VL\"p5O,\0K\0-6\r:pDbՐn\$mm\$i )O6 (APIP+VHpn4?BMJF.0+ij P(&a%l]'^@(5N fscbz >x\0k Đ\rJH'3 (Fт z`O qX`r\r 1,gk lv|+kf'=R@46` -.i~4#<\$R |u2N;Bn<-#{%b=#(J1b%gzG21^8w b^%/ G*7D\0^ rc p\nL, 0+ Xr\$ 8-)+(D \nb s12G\\{.I~`*l]N X.#%\$KS'36\$CrC0B\r--H| Ȇ,\"57ӒT)n ĸ/2La72K1/ d\"4SH ͌1\0O6R8|S|+rӲ\$O\re(\r\"8ӎs\r2!*mNTQ]jk+15Rh1Qz`pRE -SS\r1@vo.tTUFqE;g\\\"DQ`sIv`0 +KpT)|l 8%'LLJ@\r&+ ԃX&t \\*'4NƣO\0OTDb\r1PL\0gM\"O>Cw]770 !\"ː4\0zW2 D\\W<2\"_ xw|qJ&e24\"qX:d6+-̓/ӄ[V71\rc\n\0\n`J ~+'1f!G\0[a\rv\0^\0ZK ~Ʌ7w%/(F?`z%vjyj\$w/!fqT,ӉY7I*jF,yRK~ rr菒_W|x;`㍃nn<'%xр 8߀ b_J \"h`Ev\\ˁ#\"4ٛɖلxdLFq9TljV#q-=qD2Mދud+rTtgcfnx^@da&\n\0B|:I+,7'8\\P,\"-scsvG'W\$=}[~ YycYi2sw4\rK.PU@ 珜\nAi2قY~'AmqӚ,4<ss򉬜#@`X\rͲ1 E=G4vG\0R'Y@7:@fPV{!\"z7Mo[D!*W2j2g8|L\$ DiG}GRb!r&- 3ԣmș\r0qh1Ki,| ezHYFdiS3b\r>]:~=!}i'] 2(\nFgX Xn}#ܗn`\r?t XQɑLZny~?nNr\0\$oj7Z&9S tU`tc*7s\r|w盕N)=\$Z'ˀ a!#Uȕe^ia0-ʀ!JD`fd0) RH+dI6AfvۓxT{C 1&GO \\Ex(.nP\"(02쮇dW=.@gG['jZ2='!K5f)R(r1j\rX1i5\$ Ļt, o\0p2,m%unoS 0PJ\\6sp)jL?ֲ~9d\r-,@%Zf QY,pXRCiJ!3#Y nc|@ (ɲ\"q\n_)1!8\0ы `cC}(_2 8MY ^3.U]!4a\ngJKЋ`9LH) Xn00܌S4EP`+ I4YFXI9hWIJE9!k#H]f7< fm(Q<@0 |&'@4 vȞ\0/ A\"&0yS<'5UZq%\"3 Rr鋞Ip:\0-PXT\\\0NYI2\0&n;2g|9N}ANP欫\0>&T D5sb\",VSPО2` .e@\\RDw4\$(⒢ 'b2\0\$Bf7\"q%W@\0`E]BJSxo\r8By(\n S =@7UA\r{\$bc\n\\\".h^\0`\"^L\0@9 W\0RO`eN=8ogv3n-CFq!Bp-qa7Mb'sK'MqHZm\$1IOj5lkgmzi6A\\@d,\n@Ӯ4tiJ\0l(k哊Vˆ\0Oiȭm(9tЅA\0fT~\$S]\\d[9g2\rpB֠x\0- 6eEA1\"y,+V]ٔimtW[B<&`bmqH|fSZ-?g DOQAVθE3 Q`T&AƩ\0\n%a\\Si 'bhH^|} O!.ɞW!\$Lyи:ݻ[:HD\0 v\0v*l{(.uŕRÕZt m+lLY<+1 !05/>T:Z6ISǯՠ?La,l.=[3tlhʲ0XhF⧂xPFh‚Vu0a,،9\n`nTŬb7l \$M9+Ldl6Y5+ZreI qPZ40YaE'5 pmK`آ|\r|\$CKBxRյmt8ogIu1ZeИϓO%MCS nwݧAut\$2{6X2V'ݼ/o[\\]s0!%}xY7+?aI[#U\0c{2f*F2}\0bm@zdX!T˔Md&ےI8.tJd/\0X{I K~^7C @D&]&SCVۧdyD՗41\$ F'\\2Et@}fA8.iK6~kOrW['/FL`J8EݦvVR%꒡*ɀJ^rcH7t:n7m x]&ze)5JtA֫)ZK%/n e®|6ɘc|Ԗ\\>ۖK~Ԃ۾ò\0-MliRdB|!O\$=\$Y;z]a8p!T\0.\r>(28i,XW4Z8h%Z6jDs2 M_\nҤ6ՖRTQY,`F/S\"`nHWy!2\"\\\0=66B )\\-UιWp )}q!p\\\nRXlJ-# Sm=\\KE1#H2 _Mm.Hҥo&!΃9V'+*U_)L.&J p5kB5T,M\"7Q\"\$aE7):Ţr:*.5|=a68JZLivBx t>mY9N\"4Ub,p1wP>A:n WqhR;Z\0b,=Cp\0,R^rk7G>MiVi)h9+2Jս!~4V4疮l=e恺։,d #ZiYſiH#[Jk ɕkKax\n PTٲc8r~9dO,᠍DA^d=?O5E5O߲j)j#[eMݐViaqp Kt -9+ċ̙YN6\rH[ŹK:fQ\nAJ]eo Ҹ?-r:s)1 lS+dFz3<k^6\0Ae8fifj*rfi&V>Lzu'3I5k5Ƒ#la|@̗ lh9C拑,K,&nBUze7\n:X@I\n<+\r&mf[d++A3Dm7BD`9 Eh(N̓k :U)1뵙'\nL& \$8ElDihq%\"NcI@회6|Pe,{ śfu\"f(l-\\P5f|kP\nh(p&Nzb\r3*ֈL{zuLeoPͲVz\n<|N1l)9z*j#h)y_!gut!^My\rj4xҞ\"U] Xj>Cr:w\n׭t`%!CzȐ\0^Jxa4.cXmUY|\rHR%#N\$00.淝:2OA&\02 y0apYC\0{ IU1>|4 \0W@oQ\0An߈y.hFP\nx<\rDx}.Bh\0ʳ!uBE61U`i9噎=Kmi{?H˭wk>G)v-٥Z:m+CsQh\n[W)3ï\nH\0\n9\rsd3|h|9p,^WsգŒC/c\">AaNh0 {8Bȇ@0!t O-\n^9j/N7D\"pHsq^5Nˢ߁ ɗp WoyYr4Ί-9SXŞ&'Cuaz~d\n7 ??mnvKҶkWǐm+ba9\\/~˸ݸ|tcp%F0}p z\0Z5=qtTU\" u<.ugW&¿]f3י9 ?h6m\0tŏf,]\$u^-_UGԾ%&i(]0kGr'z \$?P~Kq\\*_gW2t");}elseif($_GET["file"]=="jush.js"){header("Content-Type: text/javascript; charset=utf-8");echo @@ -19,8 +19,8 @@ escape_string($X){return substr(q($X),1,-1);}function number($X){return preg_replace('~[^0-9]+~','',$X);}function -remove_slashes($Ne,$pc=false){if(get_magic_quotes_gpc()){while(list($y,$X)=each($Ne)){foreach($X -as$ad=>$W){unset($Ne[$y][$ad]);if(is_array($W)){$Ne[$y][stripslashes($ad)]=$W;$Ne[]=&$Ne[$y][stripslashes($ad)];}else$Ne[$y][stripslashes($ad)]=($pc?$W:stripslashes($W));}}}}function +remove_slashes($Ne,$oc=false){if(get_magic_quotes_gpc()){while(list($y,$X)=each($Ne)){foreach($X +as$ad=>$W){unset($Ne[$y][$ad]);if(is_array($W)){$Ne[$y][stripslashes($ad)]=$W;$Ne[]=&$Ne[$y][stripslashes($ad)];}else$Ne[$y][stripslashes($ad)]=($oc?$W:stripslashes($W));}}}}function bracket_escape($Kc,$_a=false){static$mg=array(':'=>':1',']'=>':2','['=>':3');return strtr($Kc,($_a?array_flip($mg):$mg));}function charset($e){return(version_compare($e->server_info,"5.5.3")>=0?"utf8mb4":"utf8");}function @@ -42,7 +42,7 @@ bold($Ga,$Ra=""){return($Ga?" class='active $Ra'":($Ra?" class='$Ra'":""));}func odd($K=' class="odd"'){static$s=0;if(!$K)$s=-1;return($s++%2?$K:'');}function js_escape($Gf){return addcslashes($Gf,"\r\n'\\/");}function -json_row($y,$X=null){static$qc=true;if($qc)echo"{";if($y!=""){echo($qc?"":",")."\n\t\"".addcslashes($y,"\r\n\"\\/").'": '.($X!==null?'"'.addcslashes($X,"\r\n\"\\/").'"':'undefined');$qc=false;}else{echo"\n}\n";$qc=true;}}function +json_row($y,$X=null){static$pc=true;if($pc)echo"{";if($y!=""){echo($pc?"":",")."\n\t\"".addcslashes($y,"\r\n\"\\/").'": '.($X!==null?'"'.addcslashes($X,"\r\n\"\\/").'"':'undefined');$pc=false;}else{echo"\n}\n";$pc=true;}}function ini_bool($Oc){$X=ini_get($Oc);return(preg_match('~^(on|true|yes)$~i',$X)||(int)$X);}function sid(){static$K;if($K===null)$K=(SID&&!($_COOKIE&&ini_bool("session.use_cookies")));return$K;}function set_password($Jg,$O,$V,$G){$_SESSION["pwds"][$Jg][$O][$V]=($_COOKIE["adminer_key"]&&is_string($G)?array(encrypt_string($G,$_COOKIE["adminer_key"])):$G);}function @@ -50,34 +50,34 @@ get_password(){$K=get_session("pwds");if(is_array($K))$K=($_COOKIE["adminer_key" q($Gf){global$e;return$e->quote($Gf);}function get_vals($I,$c=0){global$e;$K=array();$J=$e->query($I);if(is_object($J)){while($L=$J->fetch_row())$K[]=$L[$c];}return$K;}function get_key_vals($I,$f=null,$cg=0){global$e;if(!is_object($f))$f=$e;$K=array();$f->timeout=$cg;$J=$f->query($I);$f->timeout=0;if(is_object($J)){while($L=$J->fetch_row())$K[$L[0]]=$L[1];}return$K;}function -get_rows($I,$f=null,$j="

"){global$e;$eb=(is_object($f)?$f:$e);$K=array();$J=$eb->query($I);if(is_object($J)){while($L=$J->fetch_assoc())$K[]=$L;}elseif(!$J&&!is_object($f)&&$j&&defined("PAGE_HEADER"))echo$j.error()."\n";return$K;}function +get_rows($I,$f=null,$k="

"){global$e;$eb=(is_object($f)?$f:$e);$K=array();$J=$eb->query($I);if(is_object($J)){while($L=$J->fetch_assoc())$K[]=$L;}elseif(!$J&&!is_object($f)&&$k&&defined("PAGE_HEADER"))echo$k.error()."\n";return$K;}function unique_array($L,$v){foreach($v as$u){if(preg_match("~PRIMARY|UNIQUE~",$u["type"])){$K=array();foreach($u["columns"]as$y){if(!isset($L[$y]))continue 2;$K[$y]=$L[$y];}return$K;}}}function escape_key($y){if(preg_match('(^([\w(]+)('.str_replace("_",".*",preg_quote(idf_escape("_"))).')([ \w)]+)$)',$y,$B))return$B[1].idf_escape(idf_unescape($B[2])).$B[3];return idf_escape($y);}function -where($Z,$l=array()){global$e,$x;$K=array();foreach((array)$Z["where"]as$y=>$X){$y=bracket_escape($y,1);$c=escape_key($y);$K[]=$c.(($x=="sql"&&preg_match('~^[0-9]*\\.[0-9]*$~',$X))||$x=="mssql"?" LIKE ".q(addcslashes($X,"%_\\")):" = ".unconvert_field($l[$y],q($X)));if($x=="sql"&&preg_match('~char|text~',$l[$y]["type"])&&preg_match("~[^ -@]~",$X))$K[]="$c = ".q($X)." COLLATE ".charset($e)."_bin";}foreach((array)$Z["null"]as$y)$K[]=escape_key($y)." IS NULL";return +where($Z,$m=array()){global$e,$x;$K=array();foreach((array)$Z["where"]as$y=>$X){$y=bracket_escape($y,1);$c=escape_key($y);$K[]=$c.(($x=="sql"&&preg_match('~^[0-9]*\\.[0-9]*$~',$X))||$x=="mssql"?" LIKE ".q(addcslashes($X,"%_\\")):" = ".unconvert_field($m[$y],q($X)));if($x=="sql"&&preg_match('~char|text~',$m[$y]["type"])&&preg_match("~[^ -@]~",$X))$K[]="$c = ".q($X)." COLLATE ".charset($e)."_bin";}foreach((array)$Z["null"]as$y)$K[]=escape_key($y)." IS NULL";return implode(" AND ",$K);}function -where_check($X,$l=array()){parse_str($X,$Ma);remove_slashes(array(&$Ma));return -where($Ma,$l);}function +where_check($X,$m=array()){parse_str($X,$Ma);remove_slashes(array(&$Ma));return +where($Ma,$m);}function where_link($s,$c,$Y,$ae="="){return"&where%5B$s%5D%5Bcol%5D=".urlencode($c)."&where%5B$s%5D%5Bop%5D=".urlencode(($Y!==null?$ae:"IS NULL"))."&where%5B$s%5D%5Bval%5D=".urlencode($Y);}function -convert_fields($d,$l,$N=array()){$K="";foreach($d -as$y=>$X){if($N&&!in_array(idf_escape($y),$N))continue;$ua=convert_field($l[$y]);if($ua)$K.=", $ua AS ".idf_escape($y);}return$K;}function +convert_fields($d,$m,$N=array()){$K="";foreach($d +as$y=>$X){if($N&&!in_array(idf_escape($y),$N))continue;$ua=convert_field($m[$y]);if($ua)$K.=", $ua AS ".idf_escape($y);}return$K;}function cookie($E,$Y,$od=2592000){global$ba;$re=array($E,(preg_match("~\n~",$Y)?"":$Y),($od?time()+$od:0),preg_replace('~\\?.*~','',$_SERVER["REQUEST_URI"]),"",$ba);if(version_compare(PHP_VERSION,'5.2.0')>=0)$re[]=true;return call_user_func_array('setcookie',$re);}function restart_session(){if(!ini_bool("session.use_cookies"))session_start();}function stop_session(){if(!ini_bool("session.use_cookies"))session_write_close();}function&get_session($y){return$_SESSION[$y][DRIVER][SERVER][$_GET["username"]];}function set_session($y,$X){$_SESSION[$y][DRIVER][SERVER][$_GET["username"]]=$X;}function -auth_url($Jg,$O,$V,$h=null){global$Fb;preg_match('~([^?]*)\\??(.*)~',remove_from_uri(implode("|",array_keys($Fb))."|username|".($h!==null?"db|":"").session_name()),$B);return"$B[1]?".(sid()?SID."&":"").($Jg!="server"||$O!=""?urlencode($Jg)."=".urlencode($O)."&":"")."username=".urlencode($V).($h!=""?"&db=".urlencode($h):"").($B[2]?"&$B[2]":"");}function +auth_url($Jg,$O,$V,$i=null){global$Eb;preg_match('~([^?]*)\\??(.*)~',remove_from_uri(implode("|",array_keys($Eb))."|username|".($i!==null?"db|":"").session_name()),$B);return"$B[1]?".(sid()?SID."&":"").($Jg!="server"||$O!=""?urlencode($Jg)."=".urlencode($O)."&":"")."username=".urlencode($V).($i!=""?"&db=".urlencode($i):"").($B[2]?"&$B[2]":"");}function is_ajax(){return($_SERVER["HTTP_X_REQUESTED_WITH"]=="XMLHttpRequest");}function redirect($A,$C=null){if($C!==null){restart_session();$_SESSION["messages"][preg_replace('~^[^?]*~','',($A!==null?$A:$_SERVER["REQUEST_URI"]))][]=$C;}if($A!==null){if($A=="")$A=".";header("Location: $A");exit;}}function -query_redirect($I,$A,$C,$Ve=true,$dc=true,$jc=false,$bg=""){global$e,$j,$b;if($dc){$Cf=microtime(true);$jc=!$e->query($I);$bg=format_time($Cf);}$Bf="";if($I)$Bf=$b->messageQuery($I,$bg);if($jc){$j=error().$Bf;return +query_redirect($I,$A,$C,$Ve=true,$cc=true,$ic=false,$bg=""){global$e,$k,$b;if($cc){$Cf=microtime(true);$ic=!$e->query($I);$bg=format_time($Cf);}$Bf="";if($I)$Bf=$b->messageQuery($I,$bg);if($ic){$k=error().$Bf;return false;}if($Ve)redirect($A,$C.$Bf);return true;}function queries($I){global$e;static$Qe=array();static$Cf;if(!$Cf)$Cf=microtime(true);if($I===null)return array(implode("\n",$Qe),format_time($Cf));$Qe[]=(preg_match('~;$~',$I)?"DELIMITER ;;\n$I;\nDELIMITER ":$I).";";return$e->query($I);}function -apply_queries($I,$S,$Zb='table'){foreach($S -as$Q){if(!queries("$I ".$Zb($Q)))return +apply_queries($I,$S,$Yb='table'){foreach($S +as$Q){if(!queries("$I ".$Yb($Q)))return false;}return true;}function queries_redirect($A,$C,$Ve){list($Qe,$bg)=queries(null);return @@ -86,11 +86,11 @@ format_time($Cf){return sprintf('%.3f s',max(0,microtime(true)-$Cf));}function remove_from_uri($qe=""){return substr(preg_replace("~(?<=[?&])($qe".(SID?"":"|".session_name()).")=[^&]*&~",'',"$_SERVER[REQUEST_URI]&"),0,-1);}function -pagination($F,$ob){return" ".($F==$ob?$F+1:''.($F+1)."");}function -get_file($y,$vb=false){$nc=$_FILES[$y];if(!$nc)return -null;foreach($nc -as$y=>$X)$nc[$y]=(array)$X;$K='';foreach($nc["error"]as$y=>$j){if($j)return$j;$E=$nc["name"][$y];$jg=$nc["tmp_name"][$y];$fb=file_get_contents($vb&&preg_match('~\\.gz$~',$E)?"compress.zlib://$jg":$jg);if($vb){$Cf=substr($fb,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$Cf,$bf))$fb=iconv("utf-16","utf-8",$fb);elseif($Cf=="\xEF\xBB\xBF")$fb=substr($fb,3);$K.=$fb."\n\n";}else$K.=$fb;}return$K;}function -upload_error($j){$yd=($j==UPLOAD_ERR_INI_SIZE?ini_get("upload_max_filesize"):0);return($j?'Unable to upload a file.'.($yd?" ".sprintf('Maximum allowed file size is %sB.',$yd):""):'File does not exist.');}function +pagination($F,$nb){return" ".($F==$nb?$F+1:''.($F+1)."");}function +get_file($y,$ub=false){$mc=$_FILES[$y];if(!$mc)return +null;foreach($mc +as$y=>$X)$mc[$y]=(array)$X;$K='';foreach($mc["error"]as$y=>$k){if($k)return$k;$E=$mc["name"][$y];$jg=$mc["tmp_name"][$y];$fb=file_get_contents($ub&&preg_match('~\\.gz$~',$E)?"compress.zlib://$jg":$jg);if($ub){$Cf=substr($fb,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$Cf,$bf))$fb=iconv("utf-16","utf-8",$fb);elseif($Cf=="\xEF\xBB\xBF")$fb=substr($fb,3);$K.=$fb."\n\n";}else$K.=$fb;}return$K;}function +upload_error($k){$yd=($k==UPLOAD_ERR_INI_SIZE?ini_get("upload_max_filesize"):0);return($k?'Unable to upload a file.'.($yd?" ".sprintf('Maximum allowed file size is %sB.',$yd):""):'File does not exist.');}function repeat_pattern($ze,$md){return str_repeat("$ze{0,65535}",$md/65535)."$ze{0,".($md%65535)."}";}function is_utf8($X){return(preg_match('~~u',$X)&&!preg_match('~[\\0-\\x8\\xB\\xC\\xE-\\x1F]~',$X));}function @@ -104,40 +104,40 @@ hidden_fields($Ne,$Lc=array()){while(list($y,$X)=each($Ne)){if(!in_array($y,$Lc) as$ad=>$W)$Ne[$y."[$ad]"]=$W;}else echo'';}}}function hidden_fields_get(){echo(sid()?'':''),(SERVER!==null?'':""),'';}function -table_status1($Q,$kc=false){$K=table_status($Q,$kc);return($K?$K:array("Name"=>$Q));}function -column_foreign_keys($Q){global$b;$K=array();foreach($b->foreignKeys($Q)as$m){foreach($m["source"]as$X)$K[$X][]=$m;}return$K;}function -enum_input($U,$wa,$k,$Y,$Tb=null){global$b;preg_match_all("~'((?:[^']|'')*)'~",$k["length"],$td);$K=($Tb!==null?"":"");foreach($td[1]as$s=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?$Y==$s+1:(is_array($Y)?in_array($s+1,$Y):$Y===$X));$K.=" ';}return$K;}function -input($k,$Y,$p){global$e,$tg,$b,$x;$E=h(bracket_escape($k["field"]));echo"";if(is_array($Y)&&!$p){$ta=array($Y);if(version_compare(PHP_VERSION,5.4)>=0)$ta[]=JSON_PRETTY_PRINT;$Y=call_user_func_array('json_encode',$ta);$p="json";}$df=($x=="mssql"&&$k["auto_increment"]);if($df&&!$_POST["save"])$p=null;$yc=(isset($_GET["select"])||$df?array("orig"=>'original'):array())+$b->editFunctions($k);$wa=" name='fields[$E]'";if($k["type"]=="enum")echo -nbsp($yc[""])."".$b->editInput($_GET["edit"],$k,$wa,$Y);else{$qc=0;foreach($yc -as$y=>$X){if($y===""||!$X)break;$qc++;}$Yd=($qc?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($k["field"])))."]']; if ($qc > f.selectedIndex) f.selectedIndex = $qc;\" onkeyup='keyupChange.call(this);'":"");$wa.=$Yd;$Dc=(in_array($p,$yc)||isset($yc[$p]));echo(count($yc)>1?"":nbsp(reset($yc))).'';$Qc=$b->editInput($_GET["edit"],$k,$wa,$Y);if($Qc!="")echo$Qc;elseif($k["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$k["length"],$td);foreach($td[1]as$s=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?($Y>>$s)&1:in_array($X,explode(",",$Y),true));echo" ';}}elseif(preg_match('~blob|bytea|raw|file~',$k["type"])&&ini_bool("file_uploads"))echo"";elseif(($Zf=preg_match('~text|lob~',$k["type"]))||preg_match("~\n~",$Y)){if($Zf&&$x!="sqlite")$wa.=" cols='50' rows='12'";else{$M=min(12,substr_count($Y,"\n")+1);$wa.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"".h($Y).'';}elseif($p=="json")echo"".h($Y).'';else{$_d=(!preg_match('~int~',$k["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$k["length"],$B)?((preg_match("~binary~",$k["type"])?2:1)*$B[1]+($B[3]?1:0)+($B[2]&&!$k["unsigned"]?1:0)):($tg[$k["type"]]?$tg[$k["type"]]+($k["unsigned"]?0:1):0));if($x=='sql'&&$e->server_info>=5.6&&preg_match('~time~',$k["type"]))$_d+=7;echo"20?" size='40'":"")."$wa>";}}}function -process_input($k){global$b;$Kc=bracket_escape($k["field"]);$p=$_POST["function"][$Kc];$Y=$_POST["fields"][$Kc];if($k["type"]=="enum"){if($Y==-1)return -false;if($Y=="")return"NULL";return+$Y;}if($k["auto_increment"]&&$Y=="")return -null;if($p=="orig")return($k["on_update"]=="CURRENT_TIMESTAMP"?idf_escape($k["field"]):false);if($p=="NULL")return"NULL";if($k["type"]=="set")return +table_status1($Q,$jc=false){$K=table_status($Q,$jc);return($K?$K:array("Name"=>$Q));}function +column_foreign_keys($Q){global$b;$K=array();foreach($b->foreignKeys($Q)as$n){foreach($n["source"]as$X)$K[$X][]=$n;}return$K;}function +enum_input($U,$wa,$l,$Y,$Sb=null){global$b;preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$td);$K=($Sb!==null?"":"");foreach($td[1]as$s=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?$Y==$s+1:(is_array($Y)?in_array($s+1,$Y):$Y===$X));$K.=" ';}return$K;}function +input($l,$Y,$p){global$e,$tg,$b,$x;$E=h(bracket_escape($l["field"]));echo"";if(is_array($Y)&&!$p){$ta=array($Y);if(version_compare(PHP_VERSION,5.4)>=0)$ta[]=JSON_PRETTY_PRINT;$Y=call_user_func_array('json_encode',$ta);$p="json";}$df=($x=="mssql"&&$l["auto_increment"]);if($df&&!$_POST["save"])$p=null;$yc=(isset($_GET["select"])||$df?array("orig"=>'original'):array())+$b->editFunctions($l);$wa=" name='fields[$E]'";if($l["type"]=="enum")echo +nbsp($yc[""])."".$b->editInput($_GET["edit"],$l,$wa,$Y);else{$pc=0;foreach($yc +as$y=>$X){if($y===""||!$X)break;$pc++;}$Yd=($pc?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($l["field"])))."]']; if ($pc > f.selectedIndex) f.selectedIndex = $pc;\" onkeyup='keyupChange.call(this);'":"");$wa.=$Yd;$Dc=(in_array($p,$yc)||isset($yc[$p]));echo(count($yc)>1?"":nbsp(reset($yc))).'';$Qc=$b->editInput($_GET["edit"],$l,$wa,$Y);if($Qc!="")echo$Qc;elseif($l["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$td);foreach($td[1]as$s=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?($Y>>$s)&1:in_array($X,explode(",",$Y),true));echo" ';}}elseif(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads"))echo"";elseif(($Zf=preg_match('~text|lob~',$l["type"]))||preg_match("~\n~",$Y)){if($Zf&&$x!="sqlite")$wa.=" cols='50' rows='12'";else{$M=min(12,substr_count($Y,"\n")+1);$wa.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"".h($Y).'';}elseif($p=="json")echo"".h($Y).'';else{$_d=(!preg_match('~int~',$l["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$l["length"],$B)?((preg_match("~binary~",$l["type"])?2:1)*$B[1]+($B[3]?1:0)+($B[2]&&!$l["unsigned"]?1:0)):($tg[$l["type"]]?$tg[$l["type"]]+($l["unsigned"]?0:1):0));if($x=='sql'&&$e->server_info>=5.6&&preg_match('~time~',$l["type"]))$_d+=7;echo"20?" size='40'":"")."$wa>";}}}function +process_input($l){global$b;$Kc=bracket_escape($l["field"]);$p=$_POST["function"][$Kc];$Y=$_POST["fields"][$Kc];if($l["type"]=="enum"){if($Y==-1)return +false;if($Y=="")return"NULL";return+$Y;}if($l["auto_increment"]&&$Y=="")return +null;if($p=="orig")return($l["on_update"]=="CURRENT_TIMESTAMP"?idf_escape($l["field"]):false);if($p=="NULL")return"NULL";if($l["type"]=="set")return array_sum((array)$Y);if($p=="json"){$p="";$Y=json_decode($Y,true);if(!is_array($Y))return -false;return$Y;}if(preg_match('~blob|bytea|raw|file~',$k["type"])&&ini_bool("file_uploads")){$nc=get_file("fields-$Kc");if(!is_string($nc))return +false;return$Y;}if(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads")){$mc=get_file("fields-$Kc");if(!is_string($mc))return false;return -q($nc);}return$b->processInput($k,$Y,$p);}function -fields_from_edit(){global$i;$K=array();foreach((array)$_POST["field_keys"]as$y=>$X){if($X!=""){$X=bracket_escape($X);$_POST["function"][$X]=$_POST["field_funs"][$y];$_POST["fields"][$X]=$_POST["field_vals"][$y];}}foreach((array)$_POST["fields"]as$y=>$X){$E=bracket_escape($y,1);$K[$E]=array("field"=>$E,"privileges"=>array("insert"=>1,"update"=>1),"null"=>1,"auto_increment"=>($y==$i->primary),);}return$K;}function +q($mc);}return$b->processInput($l,$Y,$p);}function +fields_from_edit(){global$j;$K=array();foreach((array)$_POST["field_keys"]as$y=>$X){if($X!=""){$X=bracket_escape($X);$_POST["function"][$X]=$_POST["field_funs"][$y];$_POST["fields"][$X]=$_POST["field_vals"][$y];}}foreach((array)$_POST["fields"]as$y=>$X){$E=bracket_escape($y,1);$K[$E]=array("field"=>$E,"privileges"=>array("insert"=>1,"update"=>1),"null"=>1,"auto_increment"=>($y==$j->primary),);}return$K;}function search_tables(){global$b,$e;$_GET["where"][0]["op"]="LIKE %%";$_GET["where"][0]["val"]=$_POST["query"];$vc=false;foreach(table_status('',true)as$Q=>$R){$E=$b->tableName($R);if(isset($R["Engine"])&&$E!=""&&(!$_POST["tables"]||in_array($Q,$_POST["tables"]))){$J=$e->query("SELECT".limit("1 FROM ".table($Q)," WHERE ".implode(" AND ",$b->selectSearchProcess(fields($Q),array())),1));if(!$J||$J->fetch_row()){if(!$vc){echo"

    \n";$vc=true;}echo"
  • ".($J?"$E\n":"$E: ".error()."\n");}}}echo($vc?"
":"

".'No tables.')."\n";}function dump_headers($Jc,$Gd=false){global$b;$K=$b->dumpHeaders($Jc,$Gd);$oe=$_POST["output"];if($oe!="text")header("Content-Disposition: attachment; filename=".$b->dumpFilename($Jc).".$K".($oe!="file"&&!preg_match('~[^0-9a-z]~',$oe)?".$oe":""));session_write_close();ob_flush();flush();return$K;}function dump_csv($L){foreach($L as$y=>$X){if(preg_match("~[\"\n,;\t]~",$X)||$X==="")$L[$y]='"'.str_replace('"','""',$X).'"';}echo implode(($_POST["format"]=="csv"?",":($_POST["format"]=="tsv"?"\t":";")),$L)."\r\n";}function apply_sql_function($p,$c){return($p?($p=="unixepoch"?"DATETIME($c, '$p')":($p=="count distinct"?"COUNT(DISTINCT ":strtoupper("$p("))."$c)"):$c);}function -get_temp_dir(){$K=ini_get("upload_tmp_dir");if(!$K){if(function_exists('sys_get_temp_dir'))$K=sys_get_temp_dir();else{$oc=@tempnam("","");if(!$oc)return -false;$K=dirname($oc);unlink($oc);}}return$K;}function -password_file($kb){$oc=get_temp_dir()."/adminer.key";$K=@file_get_contents($oc);if($K||!$kb)return$K;$o=@fopen($oc,"w");if($o){chmod($oc,0660);$K=rand_string();fwrite($o,$K);fclose($o);}return$K;}function +get_temp_dir(){$K=ini_get("upload_tmp_dir");if(!$K){if(function_exists('sys_get_temp_dir'))$K=sys_get_temp_dir();else{$nc=@tempnam("","");if(!$nc)return +false;$K=dirname($nc);unlink($nc);}}return$K;}function +password_file($g){$nc=get_temp_dir()."/adminer.key";$K=@file_get_contents($nc);if($K||!$g)return$K;$o=@fopen($nc,"w");if($o){chmod($nc,0660);$K=rand_string();fwrite($o,$K);fclose($o);}return$K;}function rand_string(){return md5(uniqid(mt_rand(),true));}function -select_value($X,$_,$k,$ag){global$b,$ba;if(is_array($X)){$K="";foreach($X -as$ad=>$W)$K.="".($X!=array_values($X)?"".h($ad):"")."".select_value($W,$_,$k,$ag);return"$K
";}if(!$_)$_=$b->selectLink($X,$k);if($_===null){if(is_mail($X))$_="mailto:$X";if($Pe=is_url($X))$_=(($Pe=="http"&&$ba)||preg_match('~WebKit~i',$_SERVER["HTTP_USER_AGENT"])?$X:"$Pe://www.adminer.org/redirect/?url=".urlencode($X));}$K=$b->editVal($X,$k);if($K!==null){if($K==="")$K=" ";elseif(!is_utf8($K))$K="\0";elseif($ag!=""&&is_shortable($k))$K=shorten_utf8($K,max(0,+$ag));else$K=h($K);}return$b->selectVal($K,$_,$k,$X);}function -is_mail($Qb){$va='[-a-z0-9!#$%&\'*+/=?^_`{|}~]';$Eb='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';$ze="$va+(\\.$va+)*@($Eb?\\.)+$Eb";return -is_string($Qb)&&preg_match("(^$ze(,\\s*$ze)*\$)i",$Qb);}function -is_url($Gf){$Eb='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';return(preg_match("~^(https?)://($Eb?\\.)+$Eb(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i",$Gf,$B)?strtolower($B[1]):"");}function -is_shortable($k){return -preg_match('~char|text|lob|geometry|point|linestring|polygon|string~',$k["type"]);}function +select_value($X,$_,$l,$ag){global$b,$ba;if(is_array($X)){$K="";foreach($X +as$ad=>$W)$K.="".($X!=array_values($X)?"".h($ad):"")."".select_value($W,$_,$l,$ag);return"$K
";}if(!$_)$_=$b->selectLink($X,$l);if($_===null){if(is_mail($X))$_="mailto:$X";if($Pe=is_url($X))$_=(($Pe=="http"&&$ba)||preg_match('~WebKit~i',$_SERVER["HTTP_USER_AGENT"])?$X:"$Pe://www.adminer.org/redirect/?url=".urlencode($X));}$K=$b->editVal($X,$l);if($K!==null){if($K==="")$K=" ";elseif(!is_utf8($K))$K="\0";elseif($ag!=""&&is_shortable($l))$K=shorten_utf8($K,max(0,+$ag));else$K=h($K);}return$b->selectVal($K,$_,$l,$X);}function +is_mail($Pb){$va='[-a-z0-9!#$%&\'*+/=?^_`{|}~]';$Db='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';$ze="$va+(\\.$va+)*@($Db?\\.)+$Db";return +is_string($Pb)&&preg_match("(^$ze(,\\s*$ze)*\$)i",$Pb);}function +is_url($Gf){$Db='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';return(preg_match("~^(https?)://($Db?\\.)+$Db(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i",$Gf,$B)?strtolower($B[1]):"");}function +is_shortable($l){return +preg_match('~char|text|lob|geometry|point|linestring|polygon|string~',$l["type"]);}function count_rows($Q,$Z,$Wc,$r){global$x;$I=" FROM ".table($Q).($Z?" WHERE ".implode(" AND ",$Z):"");return($Wc&&($x=="sql"||count($r)==1)?"SELECT COUNT(DISTINCT ".implode(", ",$r).")$I":"SELECT COUNT(*)".($Wc?" FROM (SELECT 1$I$_c) x":$I));}function -slow_query($I){global$b,$T;$h=$b->database();$cg=$b->queryTimeout();if(support("kill")&&is_object($f=connect())&&($h==""||$f->select_db($h))){$cd=$f->result("SELECT CONNECTION_ID()");echo'\n"));if(isset($_GET["select"]))hidden_fields(array("check"=>(array)$_POST["check"],"clone"=>$_POST["clone"],"all"=>$_POST["all"]));echo' +edit_form($a,$m,$L,$Ag){global$b,$x,$T,$k;$Pf=$b->tableName(table_status1($a,true));page_header(($Ag?'Edit':'Insert'),$k,array("select"=>array($a,$Pf)),$Pf);if($L===false)echo"

".'No rows.'."\n";echo'

+';if(!$m)echo"

".'You have no privileges to update this table.'."\n";else{echo"\n";foreach($m +as$E=>$l){echo""."
".$b->fieldName($l);$vb=$_GET["set"][bracket_escape($E)];if($vb===null){$vb=$l["default"];if($l["type"]=="bit"&&preg_match("~^b'([01]*)'\$~",$vb,$bf))$vb=$bf[1];}$Y=($L!==null?($L[$E]!=""&&$x=="sql"&&preg_match("~enum|set~",$l["type"])?(is_array($L[$E])?array_sum($L[$E]):+$L[$E]):$L[$E]):(!$Ag&&$l["auto_increment"]?"":(isset($_GET["select"])?false:$vb)));if(!$_POST["save"]&&is_string($Y))$Y=$b->editVal($Y,$l);$p=($_POST["save"]?(string)$_POST["function"][$E]:($Ag&&$l["on_update"]=="CURRENT_TIMESTAMP"?"now":($Y===false?null:($Y!==null?'':'NULL'))));if(preg_match("~time~",$l["type"])&&$Y=="CURRENT_TIMESTAMP"){$Y="";$p="now";}input($l,$Y,$p);echo"\n";}if(!support("table"))echo"
"."".html_select("field_funs[]",$b->editFunctions(array("null"=>isset($_GET["select"])))).""."\n";echo"
\n";}echo"

\n";if($m){echo"\n";if(!isset($_GET["select"]))echo"\n";}echo($Ag?"\n":($_POST||!$m?"":"\n"));if(isset($_GET["select"]))hidden_fields(array("check"=>(array)$_POST["check"],"clone"=>$_POST["clone"],"all"=>$_POST["all"]));echo'

-';}global$b,$e,$Fb,$Mb,$Wb,$j,$yc,$Ac,$ba,$Pc,$x,$ca,$fd,$Xd,$_e,$Hf,$Ec,$T,$og,$tg,$_g,$ga;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]";$ba=$_SERVER["HTTPS"]&&strcasecmp($_SERVER["HTTPS"],"off");@ini_set("session.use_trans_sid",false);session_cache_limiter("");if(!defined("SID")){session_name("adminer_sid");$re=array(0,preg_replace('~\\?.*~','',$_SERVER["REQUEST_URI"]),"",$ba);if(version_compare(PHP_VERSION,'5.2.0')>=0)$re[]=true;call_user_func_array('session_set_cookie_params',$re);session_start();}remove_slashes(array(&$_GET,&$_POST,&$_COOKIE),$pc);if(get_magic_quotes_runtime())set_magic_quotes_runtime(false);@set_time_limit(0);@ini_set("zend.ze1_compatibility_mode",false);@ini_set("precision",20);function +';}global$b,$e,$Eb,$Lb,$Vb,$k,$yc,$Ac,$ba,$Pc,$x,$ca,$fd,$Xd,$_e,$Hf,$Ec,$T,$og,$tg,$_g,$ga;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]";$ba=$_SERVER["HTTPS"]&&strcasecmp($_SERVER["HTTPS"],"off");@ini_set("session.use_trans_sid",false);session_cache_limiter("");if(!defined("SID")){session_name("adminer_sid");$re=array(0,preg_replace('~\\?.*~','',$_SERVER["REQUEST_URI"]),"",$ba);if(version_compare(PHP_VERSION,'5.2.0')>=0)$re[]=true;call_user_func_array('session_set_cookie_params',$re);session_start();}remove_slashes(array(&$_GET,&$_POST,&$_COOKIE),$oc);if(get_magic_quotes_runtime())set_magic_quotes_runtime(false);@set_time_limit(0);@ini_set("zend.ze1_compatibility_mode",false);@ini_set("precision",20);function get_lang(){return'en';}function lang($ng,$Od=null){if(is_array($ng)){$Ce=($Od==1?0:1);$ng=$ng[$Ce];}$ng=str_replace("%d","%s",$ng);$Od=format_number($Od);return sprintf($ng,$Od);}if(extension_loaded('pdo')){class @@ -164,7 +164,7 @@ Min_PDO extends PDO{var$_result,$server_info,$affected_rows,$errno,$error;function __construct(){global$b;$Ce=array_search("SQL",$b->operators);if($Ce!==false)unset($b->operators[$Ce]);}function -dsn($Jb,$V,$G){try{parent::__construct($Jb,$V,$G);}catch(Exception$bc){auth_error($bc->getMessage());}$this->setAttribute(13,array('Min_PDOStatement'));$this->server_info=$this->getAttribute(4);}function +dsn($Ib,$V,$G){try{parent::__construct($Ib,$V,$G);}catch(Exception$ac){auth_error($ac->getMessage());}$this->setAttribute(13,array('Min_PDOStatement'));$this->server_info=$this->getAttribute(4);}function query($I,$ug=false){$J=parent::query($I);$this->error="";if(!$J){list(,$this->errno,$this->error)=$this->errorInfo();return false;}$this->store_result($J);return$J;}function multi_query($I){return$this->_result=$this->query($I);}function @@ -173,14 +173,14 @@ false;}if($J->columnCount()){$J->num_rows=$J->rowCount();return$J;}$this->affect true;}function next_result(){if(!$this->_result)return false;$this->_result->_offset=0;return@$this->_result->nextRowset();}function -result($I,$k=0){$J=$this->query($I);if(!$J)return -false;$L=$J->fetch();return$L[$k];}}class +result($I,$l=0){$J=$this->query($I);if(!$J)return +false;$L=$J->fetch();return$L[$l];}}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(){$L=(object)$this->getColumnMeta($this->_offset++);$L->orgtable=$L->table;$L->orgname=$L->name;$L->charsetnr=(in_array("blob",(array)$L->flags)?63:0);return$L;}}}$Fb=array();class +fetch_field(){$L=(object)$this->getColumnMeta($this->_offset++);$L->orgtable=$L->table;$L->orgname=$L->name;$L->charsetnr=(in_array("blob",(array)$L->flags)?63:0);return$L;}}}$Eb=array();class Min_SQL{var$_conn;function Min_SQL($e){$this->_conn=$e;}function select($Q,$N,$Z,$r,$fe=array(),$z=1,$F=0,$Je=false){global$b,$x;$Wc=(count($r)selectQueryBuild($N,$Z,$r,$fe,$z,$F);if(!$I)$I="SELECT".limit(($_GET["page"]!="last"&&+$z&&$r&&$Wc&&$x=="sql"?"SQL_CALC_FOUND_ROWS ":"").implode(", ",$N)."\nFROM ".table($Q),($Z?"\nWHERE ".implode(" AND ",$Z):"").($r&&$Wc?"\nGROUP BY ".implode(", ",$r):"").($fe?"\nORDER BY ".implode(", ",$fe):""),($z!=""?+$z:null),($F?$z*$F:0),"\n");$Cf=microtime(true);$K=$this->_conn->query($I);if($Je)echo$b->selectQuery($I,format_time($Cf));return$K;}function @@ -198,22 +198,24 @@ queries("BEGIN");}function commit(){return queries("COMMIT");}function rollback(){return -queries("ROLLBACK");}}$Fb=array("server"=>"MySQL")+$Fb;if(!defined("DRIVER")){$Fe=array("MySQLi","MySQL","PDO_MySQL");define("DRIVER","server");if(extension_loaded("mysqli")){class +queries("ROLLBACK");}}$Eb=array("server"=>"MySQL")+$Eb;if(!defined("DRIVER")){$Fe=array("MySQLi","MySQL","PDO_MySQL");define("DRIVER","server");if(extension_loaded("mysqli")){class Min_DB extends MySQLi{var$extension="MySQLi";function Min_DB(){parent::init();}function connect($O,$V,$G){mysqli_report(MYSQLI_REPORT_OFF);list($Hc,$Be)=explode(":",$O,2);$K=@$this->real_connect(($O!=""?$Hc:ini_get("mysqli.default_host")),($O.$V!=""?$V:ini_get("mysqli.default_user")),($O.$V.$G!=""?$G:ini_get("mysqli.default_pw")),null,(is_numeric($Be)?$Be:ini_get("mysqli.default_port")),(!is_numeric($Be)?$Be:null));return$K;}function -result($I,$k=0){$J=$this->query($I);if(!$J)return -false;$L=$J->fetch_array();return$L[$k];}function +set_charset($La){if(parent::set_charset($La))return +true;parent::set_charset('utf8');return$this->query("SET NAMES $La");}function +result($I,$l=0){$J=$this->query($I);if(!$J)return +false;$L=$J->fetch_array();return$L[$l];}function quote($Gf){return"'".$this->escape_string($Gf)."'";}}}elseif(extension_loaded("mysql")&&!(ini_get("sql.safe_mode")&&extension_loaded("pdo_mysql"))){class Min_DB{var$extension="MySQL",$server_info,$affected_rows,$errno,$error,$_link,$_result;function connect($O,$V,$G){$this->_link=@mysql_connect(($O!=""?$O:ini_get("mysql.default_host")),("$O$V"!=""?$V:ini_get("mysql.default_user")),("$O$V$G"!=""?$G: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($La){if(function_exists('mysql_set_charset'))return -mysql_set_charset($La,$this->_link);return$this->query("SET NAMES $La");}function +set_charset($La){if(function_exists('mysql_set_charset')){if(mysql_set_charset($La,$this->_link))return +true;mysql_set_charset('utf8',$this->_link);}return$this->query("SET NAMES $La");}function quote($Gf){return"'".mysql_real_escape_string($Gf,$this->_link)."'";}function -select_db($rb){return -mysql_select_db($rb,$this->_link);}function +select_db($qb){return +mysql_select_db($qb,$this->_link);}function query($I,$ug=false){$J=@($ug?mysql_unbuffered_query($I,$this->_link):mysql_query($I,$this->_link));$this->error="";if(!$J){$this->errno=mysql_errno($this->_link);$this->error=mysql_error($this->_link);return false;}if($J===true){$this->affected_rows=mysql_affected_rows($this->_link);$this->info=mysql_info($this->_link);return true;}return @@ -223,9 +225,9 @@ multi_query($I){return$this->_result=$this->query($I);}function store_result(){return$this->_result;}function next_result(){return false;}function -result($I,$k=0){$J=$this->query($I);if(!$J||!$J->num_rows)return +result($I,$l=0){$J=$this->query($I);if(!$J||!$J->num_rows)return false;return -mysql_result($J->_result,0,$k);}}class +mysql_result($J->_result,0,$l);}}class Min_Result{var$num_rows,$_result,$_offset=0;function Min_Result($J){$this->_result=$J;$this->num_rows=mysql_num_rows($J);}function fetch_assoc(){return @@ -240,7 +242,7 @@ Min_PDO{var$extension="PDO_MySQL";function connect($O,$V,$G){$this->dsn("mysql:charset=utf8;host=".str_replace(":",";unix_socket=",preg_replace('~:(\\d)~',';port=\\1',$O)),$V,$G);return true;}function set_charset($La){$this->query("SET NAMES $La");}function -select_db($rb){return$this->query("USE ".idf_escape($rb));}function +select_db($qb){return$this->query("USE ".idf_escape($qb));}function query($I,$ug=false){$this->setAttribute(1000,!$ug);return parent::query($I,$ug);}}}class Min_Driver @@ -256,41 +258,41 @@ idf_escape($Kc){return"`".str_replace("`","``",$Kc)."`";}function table($Kc){return idf_escape($Kc);}function connect(){global$b;$e=new -Min_DB;$nb=$b->credentials();if($e->connect($nb[0],$nb[1],$nb[2])){$e->set_charset(charset($e));$e->query("SET sql_quote_show_create = 1, autocommit = 1");return$e;}$K=$e->error;if(function_exists('iconv')&&!is_utf8($K)&&strlen($mf=iconv("windows-1250","utf-8",$K))>strlen($K))$K=$mf;return$K;}function -get_databases($rc){global$e;$K=get_session("dbs");if($K===null){$I=($e->server_info>=5?"SELECT SCHEMA_NAME FROM information_schema.SCHEMATA":"SHOW DATABASES");$K=($rc?slow_query($I):get_vals($I));restart_session();set_session("dbs",$K);stop_session();}return$K;}function +Min_DB;$mb=$b->credentials();if($e->connect($mb[0],$mb[1],$mb[2])){$e->set_charset(charset($e));$e->query("SET sql_quote_show_create = 1, autocommit = 1");return$e;}$K=$e->error;if(function_exists('iconv')&&!is_utf8($K)&&strlen($mf=iconv("windows-1250","utf-8",$K))>strlen($K))$K=$mf;return$K;}function +get_databases($qc){global$e;$K=get_session("dbs");if($K===null){$I=($e->server_info>=5?"SELECT SCHEMA_NAME FROM information_schema.SCHEMATA":"SHOW DATABASES");$K=($qc?slow_query($I):get_vals($I));restart_session();set_session("dbs",$K);stop_session();}return$K;}function limit($I,$Z,$z,$Qd=0,$tf=" "){return" $I$Z".($z!==null?$tf."LIMIT $z".($Qd?" OFFSET $Qd":""):"");}function limit1($I,$Z){return limit($I,$Z,1);}function -db_collation($h,$Xa){global$e;$K=null;$kb=$e->result("SHOW CREATE DATABASE ".idf_escape($h),1);if(preg_match('~ COLLATE ([^ ]+)~',$kb,$B))$K=$B[1];elseif(preg_match('~ CHARACTER SET ([^ ]+)~',$kb,$B))$K=$Xa[$B[1]][-1];return$K;}function +db_collation($i,$Xa){global$e;$K=null;$g=$e->result("SHOW CREATE DATABASE ".idf_escape($i),1);if(preg_match('~ COLLATE ([^ ]+)~',$g,$B))$K=$B[1];elseif(preg_match('~ CHARACTER SET ([^ ]+)~',$g,$B))$K=$Xa[$B[1]][-1];return$K;}function engines(){$K=array();foreach(get_rows("SHOW ENGINES")as$L){if(preg_match("~YES|DEFAULT~",$L["Support"]))$K[]=$L["Engine"];}return$K;}function logged_user(){global$e;return$e->result("SELECT USER()");}function tables_list(){global$e;return get_key_vals($e->server_info>=5?"SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ORDER BY TABLE_NAME":"SHOW TABLES");}function -count_tables($g){$K=array();foreach($g -as$h)$K[$h]=count(get_vals("SHOW TABLES IN ".idf_escape($h)));return$K;}function -table_status($E="",$kc=false){global$e;$K=array();foreach(get_rows($kc&&$e->server_info>=5?"SELECT TABLE_NAME AS Name, Engine, TABLE_COMMENT AS Comment FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ".($E!=""?"AND TABLE_NAME = ".q($E):"ORDER BY Name"):"SHOW TABLE STATUS".($E!=""?" LIKE ".q(addcslashes($E,"%_\\")):""))as$L){if($L["Engine"]=="InnoDB")$L["Comment"]=preg_replace('~(?:(.+); )?InnoDB free: .*~','\\1',$L["Comment"]);if(!isset($L["Engine"]))$L["Comment"]="";if($E!="")return$L;$K[$L["Name"]]=$L;}return$K;}function +count_tables($h){$K=array();foreach($h +as$i)$K[$i]=count(get_vals("SHOW TABLES IN ".idf_escape($i)));return$K;}function +table_status($E="",$jc=false){global$e;$K=array();foreach(get_rows($jc&&$e->server_info>=5?"SELECT TABLE_NAME AS Name, Engine, TABLE_COMMENT AS Comment FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() ".($E!=""?"AND TABLE_NAME = ".q($E):"ORDER BY Name"):"SHOW TABLE STATUS".($E!=""?" LIKE ".q(addcslashes($E,"%_\\")):""))as$L){if($L["Engine"]=="InnoDB")$L["Comment"]=preg_replace('~(?:(.+); )?InnoDB free: .*~','\\1',$L["Comment"]);if(!isset($L["Engine"]))$L["Comment"]="";if($E!="")return$L;$K[$L["Name"]]=$L;}return$K;}function is_view($R){return$R["Engine"]===null;}function fk_support($R){global$e;return preg_match('~InnoDB|IBMDB2I~i',$R["Engine"])||(preg_match('~NDB~i',$R["Engine"])&&version_compare($e->server_info,'5.6')>=0);}function fields($Q){$K=array();foreach(get_rows("SHOW FULL COLUMNS FROM ".table($Q))as$L){preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~',$L["Type"],$B);$K[$L["Field"]]=array("field"=>$L["Field"],"full_type"=>$L["Type"],"type"=>$B[1],"length"=>$B[2],"unsigned"=>ltrim($B[3].$B[4]),"default"=>($L["Default"]!=""||preg_match("~char|set~",$B[1])?$L["Default"]:null),"null"=>($L["Null"]=="YES"),"auto_increment"=>($L["Extra"]=="auto_increment"),"on_update"=>(preg_match('~^on update (.+)~i',$L["Extra"],$B)?$B[1]:""),"collation"=>$L["Collation"],"privileges"=>array_flip(preg_split('~, *~',$L["Privileges"])),"comment"=>$L["Comment"],"primary"=>($L["Key"]=="PRI"),);}return$K;}function indexes($Q,$f=null){$K=array();foreach(get_rows("SHOW INDEX FROM ".table($Q),$f)as$L){$K[$L["Key_name"]]["type"]=($L["Key_name"]=="PRIMARY"?"PRIMARY":($L["Index_type"]=="FULLTEXT"?"FULLTEXT":($L["Non_unique"]?"INDEX":"UNIQUE")));$K[$L["Key_name"]]["columns"][]=$L["Column_name"];$K[$L["Key_name"]]["lengths"][]=$L["Sub_part"];$K[$L["Key_name"]]["descs"][]=null;}return$K;}function -foreign_keys($Q){global$e,$Xd;static$ze='`(?:[^`]|``)+`';$K=array();$lb=$e->result("SHOW CREATE TABLE ".table($Q),1);if($lb){preg_match_all("~CONSTRAINT ($ze) FOREIGN KEY ?\\(((?:$ze,? ?)+)\\) REFERENCES ($ze)(?:\\.($ze))? \\(((?:$ze,? ?)+)\\)(?: ON DELETE ($Xd))?(?: ON UPDATE ($Xd))?~",$lb,$td,PREG_SET_ORDER);foreach($td +foreign_keys($Q){global$e,$Xd;static$ze='`(?:[^`]|``)+`';$K=array();$kb=$e->result("SHOW CREATE TABLE ".table($Q),1);if($kb){preg_match_all("~CONSTRAINT ($ze) FOREIGN KEY ?\\(((?:$ze,? ?)+)\\) REFERENCES ($ze)(?:\\.($ze))? \\(((?:$ze,? ?)+)\\)(?: ON DELETE ($Xd))?(?: ON UPDATE ($Xd))?~",$kb,$td,PREG_SET_ORDER);foreach($td as$B){preg_match_all("~$ze~",$B[2],$_f);preg_match_all("~$ze~",$B[5],$Vf);$K[idf_unescape($B[1])]=array("db"=>idf_unescape($B[4]!=""?$B[3]:$B[4]),"table"=>idf_unescape($B[4]!=""?$B[4]:$B[3]),"source"=>array_map('idf_unescape',$_f[0]),"target"=>array_map('idf_unescape',$Vf[0]),"on_delete"=>($B[6]?$B[6]:"RESTRICT"),"on_update"=>($B[7]?$B[7]:"RESTRICT"),);}}return$K;}function view($E){global$e;return array("select"=>preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU','',$e->result("SHOW CREATE VIEW ".table($E),1)));}function collations(){$K=array();foreach(get_rows("SHOW COLLATION")as$L){if($L["Default"])$K[$L["Charset"]][-1]=$L["Collation"];else$K[$L["Charset"]][]=$L["Collation"];}ksort($K);foreach($K as$y=>$X)asort($K[$y]);return$K;}function -information_schema($h){global$e;return($e->server_info>=5&&$h=="information_schema")||($e->server_info>=5.5&&$h=="performance_schema");}function +information_schema($i){global$e;return($e->server_info>=5&&$i=="information_schema")||($e->server_info>=5.5&&$i=="performance_schema");}function error(){global$e;return h(preg_replace('~^You have an error.*syntax to use~U',"Syntax error",$e->error));}function error_line(){global$e;if(preg_match('~ at line ([0-9]+)$~',$e->error,$bf))return$bf[1]-1;}function -create_database($h,$Wa){return -queries("CREATE DATABASE ".idf_escape($h).($Wa?" COLLATE ".q($Wa):""));}function -drop_databases($g){$K=apply_queries("DROP DATABASE",$g,'idf_escape');restart_session();set_session("dbs",null);return$K;}function +create_database($i,$Wa){return +queries("CREATE DATABASE ".idf_escape($i).($Wa?" COLLATE ".q($Wa):""));}function +drop_databases($h){$K=apply_queries("DROP DATABASE",$h,'idf_escape');restart_session();set_session("dbs",null);return$K;}function rename_database($E,$Wa){$K=false;if(create_database($E,$Wa)){$cf=array();foreach(tables_list()as$Q=>$U)$cf[]=table($Q)." TO ".idf_escape($E).".".table($Q);$K=(!$cf||queries("RENAME TABLE ".implode(", ",$cf)));if($K)queries("DROP DATABASE ".idf_escape(DB));restart_session();set_session("dbs",null);}return$K;}function auto_increment(){$za=" PRIMARY KEY";if($_GET["create"]!=""&&$_POST["auto_increment_col"]){foreach(indexes($_GET["create"])as$u){if(in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"],$u["columns"],true)){$za="";break;}if($u["type"]=="PRIMARY")$za=" UNIQUE";}}return" AUTO_INCREMENT$za";}function -alter_table($Q,$E,$l,$sc,$bb,$Ub,$Wa,$ya,$ve){$sa=array();foreach($l -as$k)$sa[]=($k[1]?($Q!=""?($k[0]!=""?"CHANGE ".idf_escape($k[0]):"ADD"):" ")." ".implode($k[1]).($Q!=""?$k[2]:""):"DROP ".idf_escape($k[0]));$sa=array_merge($sa,$sc);$Df=($bb!==null?" COMMENT=".q($bb):"").($Ub?" ENGINE=".q($Ub):"").($Wa?" COLLATE ".q($Wa):"").($ya!=""?" AUTO_INCREMENT=$ya":"");if($Q=="")return +alter_table($Q,$E,$m,$rc,$bb,$Tb,$Wa,$ya,$ve){$sa=array();foreach($m +as$l)$sa[]=($l[1]?($Q!=""?($l[0]!=""?"CHANGE ".idf_escape($l[0]):"ADD"):" ")." ".implode($l[1]).($Q!=""?$l[2]:""):"DROP ".idf_escape($l[0]));$sa=array_merge($sa,$rc);$Df=($bb!==null?" COMMENT=".q($bb):"").($Tb?" ENGINE=".q($Tb):"").($Wa?" COLLATE ".q($Wa):"").($ya!=""?" AUTO_INCREMENT=$ya":"");if($Q=="")return queries("CREATE TABLE ".table($E)." (\n".implode(",\n",$sa)."\n)$Df$ve");if($Q!=$E)$sa[]="RENAME TO ".table($E);if($Df)$sa[]=ltrim($Df);return($sa||$ve?queries("ALTER TABLE ".table($Q)."\n".implode(",\n",$sa).$ve):true);}function alter_indexes($Q,$sa){foreach($sa as$y=>$X)$sa[$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 @@ -315,10 +317,10 @@ reset($M);}function triggers($Q){$K=array();foreach(get_rows("SHOW TRIGGERS LIKE ".q(addcslashes($Q,"%_\\")))as$L)$K[$L["Trigger"]]=array($L["Timing"],$L["Event"]);return$K;}function trigger_options(){return array("Timing"=>array("BEFORE","AFTER"),"Event"=>array("INSERT","UPDATE","DELETE"),"Type"=>array("FOR EACH ROW"),);}function -routine($E,$U){global$e,$Wb,$Pc,$tg;$qa=array("bool","boolean","integer","double precision","real","dec","numeric","fixed","national char","national varchar");$sg="((".implode("|",array_merge(array_keys($tg),$qa)).")\\b(?:\\s*\\(((?:[^'\")]|$Wb)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?";$ze="\\s*(".($U=="FUNCTION"?"":$Pc).")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$sg";$kb=$e->result("SHOW CREATE $U ".idf_escape($E),2);preg_match("~\\(((?:$ze\\s*,?)*)\\)\\s*".($U=="FUNCTION"?"RETURNS\\s+$sg\\s+":"")."(.*)~is",$kb,$B);$l=array();preg_match_all("~$ze\\s*,?~is",$B[1],$td,PREG_SET_ORDER);foreach($td -as$qe){$E=str_replace("``","`",$qe[2]).$qe[3];$l[]=array("field"=>$E,"type"=>strtolower($qe[5]),"length"=>preg_replace_callback("~$Wb~s",'normalize_enum',$qe[6]),"unsigned"=>strtolower(preg_replace('~\\s+~',' ',trim("$qe[8] $qe[7]"))),"null"=>1,"full_type"=>$qe[4],"inout"=>strtoupper($qe[1]),"collation"=>strtolower($qe[9]),);}if($U!="FUNCTION")return -array("fields"=>$l,"definition"=>$B[11]);return -array("fields"=>$l,"returns"=>array("type"=>$B[12],"length"=>$B[13],"unsigned"=>$B[15],"collation"=>$B[16]),"definition"=>$B[17],"language"=>"SQL",);}function +routine($E,$U){global$e,$Vb,$Pc,$tg;$qa=array("bool","boolean","integer","double precision","real","dec","numeric","fixed","national char","national varchar");$sg="((".implode("|",array_merge(array_keys($tg),$qa)).")\\b(?:\\s*\\(((?:[^'\")]|$Vb)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?";$ze="\\s*(".($U=="FUNCTION"?"":$Pc).")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$sg";$g=$e->result("SHOW CREATE $U ".idf_escape($E),2);preg_match("~\\(((?:$ze\\s*,?)*)\\)\\s*".($U=="FUNCTION"?"RETURNS\\s+$sg\\s+":"")."(.*)~is",$g,$B);$m=array();preg_match_all("~$ze\\s*,?~is",$B[1],$td,PREG_SET_ORDER);foreach($td +as$qe){$E=str_replace("``","`",$qe[2]).$qe[3];$m[]=array("field"=>$E,"type"=>strtolower($qe[5]),"length"=>preg_replace_callback("~$Vb~s",'normalize_enum',$qe[6]),"unsigned"=>strtolower(preg_replace('~\\s+~',' ',trim("$qe[8] $qe[7]"))),"null"=>1,"full_type"=>$qe[4],"inout"=>strtoupper($qe[1]),"collation"=>strtolower($qe[9]),);}if($U!="FUNCTION")return +array("fields"=>$m,"definition"=>$B[11]);return +array("fields"=>$m,"returns"=>array("type"=>$B[12],"length"=>$B[13],"unsigned"=>$B[15],"collation"=>$B[16]),"definition"=>$B[17],"language"=>"SQL",);}function routines(){return get_rows("SELECT ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = ".q(DB));}function routine_languages(){return @@ -335,7 +337,7 @@ set_schema($of){return true;}function create_sql($Q,$ya){global$e;$K=$e->result("SHOW CREATE TABLE ".table($Q),1);if(!$ya)$K=preg_replace('~ AUTO_INCREMENT=\\d+~','',$K);return$K;}function truncate_sql($Q){return"TRUNCATE ".table($Q);}function -use_sql($rb){return"USE ".idf_escape($rb);}function +use_sql($qb){return"USE ".idf_escape($qb);}function trigger_sql($Q,$If){$K="";foreach(get_rows("SHOW TRIGGERS LIKE ".q(addcslashes($Q,"%_\\")),null,"-- ")as$L)$K.="\n".($If=='CREATE+ALTER'?"DROP TRIGGER IF EXISTS ".idf_escape($L["Trigger"]).";;\n":"")."CREATE TRIGGER ".idf_escape($L["Trigger"])." $L[Timing] $L[Event] ON ".table($L["Table"])." FOR EACH ROW\n$L[Statement];;\n";return$K;}function show_variables(){return get_key_vals("SHOW VARIABLES");}function @@ -343,20 +345,20 @@ process_list(){return get_rows("SHOW FULL PROCESSLIST");}function show_status(){return get_key_vals("SHOW STATUS");}function -convert_field($k){if(preg_match("~binary~",$k["type"]))return"HEX(".idf_escape($k["field"]).")";if($k["type"]=="bit")return"BIN(".idf_escape($k["field"])." + 0)";if(preg_match("~geometry|point|linestring|polygon~",$k["type"]))return"AsWKT(".idf_escape($k["field"]).")";}function -unconvert_field($k,$K){if(preg_match("~binary~",$k["type"]))$K="UNHEX($K)";if($k["type"]=="bit")$K="CONV($K, 2, 10) + 0";if(preg_match("~geometry|point|linestring|polygon~",$k["type"]))$K="GeomFromText($K)";return$K;}function -support($lc){global$e;return!preg_match("~scheme|sequence|type|view_trigger".($e->server_info<5.1?"|event|partitioning".($e->server_info<5?"|routine|trigger|view":""):"")."~",$lc);}$x="sql";$tg=array();$Hf=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){$tg+=$X;$Hf[$y]=array_keys($X);}$_g=array("unsigned","zerofill","unsigned zerofill");$be=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","REGEXP","IN","IS NULL","NOT LIKE","NOT REGEXP","NOT IN","IS NOT NULL","SQL");$yc=array("char_length","date","from_unixtime","lower","round","sec_to_time","time_to_sec","upper");$Ac=array("avg","count","count distinct","group_concat","max","min","sum");$Mb=array(array("char"=>"md5/sha1/password/encrypt/uuid","binary"=>"md5/sha1","date|time"=>"now",),array("(^|[^o])int|float|double|decimal"=>"+/-","date"=>"+ interval/- interval","time"=>"addtime/subtime","char|text"=>"concat",));}define("SERVER",$_GET[DRIVER]);define("DB",$_GET["db"]);define("ME",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"])."&":""):''));$ga="4.2.0";class +convert_field($l){if(preg_match("~binary~",$l["type"]))return"HEX(".idf_escape($l["field"]).")";if($l["type"]=="bit")return"BIN(".idf_escape($l["field"])." + 0)";if(preg_match("~geometry|point|linestring|polygon~",$l["type"]))return"AsWKT(".idf_escape($l["field"]).")";}function +unconvert_field($l,$K){if(preg_match("~binary~",$l["type"]))$K="UNHEX($K)";if($l["type"]=="bit")$K="CONV($K, 2, 10) + 0";if(preg_match("~geometry|point|linestring|polygon~",$l["type"]))$K="GeomFromText($K)";return$K;}function +support($kc){global$e;return!preg_match("~scheme|sequence|type|view_trigger".($e->server_info<5.1?"|event|partitioning".($e->server_info<5?"|routine|trigger|view":""):"")."~",$kc);}$x="sql";$tg=array();$Hf=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){$tg+=$X;$Hf[$y]=array_keys($X);}$_g=array("unsigned","zerofill","unsigned zerofill");$be=array("=","<",">","<=",">=","!=","LIKE","LIKE %%","REGEXP","IN","IS NULL","NOT LIKE","NOT REGEXP","NOT IN","IS NOT NULL","SQL");$yc=array("char_length","date","from_unixtime","lower","round","sec_to_time","time_to_sec","upper");$Ac=array("avg","count","count distinct","group_concat","max","min","sum");$Lb=array(array("char"=>"md5/sha1/password/encrypt/uuid","binary"=>"md5/sha1","date|time"=>"now",),array("(^|[^o])int|float|double|decimal"=>"+/-","date"=>"+ interval/- interval","time"=>"addtime/subtime","char|text"=>"concat",));}define("SERVER",$_GET[DRIVER]);define("DB",$_GET["db"]);define("ME",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"])."&":""):''));$ga="4.2.1";class Adminer{var$operators;function name(){return"Adminer";}function credentials(){return array(SERVER,$_GET["username"],get_password());}function -permanentLogin($kb=false){return -password_file($kb);}function +permanentLogin($g=false){return +password_file($g);}function bruteForceKey(){return$_SERVER["REMOTE_ADDR"];}function database(){return DB;}function -databases($rc=true){return -get_databases($rc);}function +databases($qc=true){return +get_databases($qc);}function schemas(){return schemas();}function queryTimeout(){return @@ -365,8 +367,8 @@ headers(){return true;}function head(){return true;}function -loginForm(){global$Fb;echo' -
System',html_select("auth[driver]",$Fb,DRIVER,"loginDriver(this);"),'
Server +loginForm(){global$Eb;echo' + +edit_fields($m,$Xa,$U="TABLE",$tc=array(),$cb=false){global$e,$Pc;echo' ';if($U=="PROCEDURE"){echo' -';foreach($l -as$s=>$k){$s++;$je=$k[($_POST?"orig":"field")];$Bb=(isset($_POST["add"][$s-1])||(isset($k["field"])&&!$_POST["drop_col"][$s]))&&(support("drop_col")||$je=="");echo' -',($U=="PROCEDURE"?"
System',html_select("auth[driver]",$Eb,DRIVER,"loginDriver(this);"),'
Server
Username
Password
Database" autocapitalize="off"> @@ -383,7 +385,7 @@ login($rd,$G){return true;}function tableName($Of){return h($Of["Name"]);}function -fieldName($k,$fe=0){return''.h($k["field"]).'';}function +fieldName($l,$fe=0){return''.h($l["field"]).'';}function selectLinks($Of,$P=""){echo'

".h(str_replace("\n"," ",$I))." ($bg)".(support("sql")?" ".'Edit'."":"")."

";}function rowDescription($Q){return"";}function -rowDescriptions($M,$tc){return$M;}function -selectLink($X,$k){}function -selectVal($X,$_,$k,$me){$K=($X===null?"NULL":(preg_match("~char|binary~",$k["type"])&&!preg_match("~var~",$k["type"])?"$X":$X));if(preg_match('~blob|bytea|raw|file~',$k["type"])&&!is_utf8($X))$K=lang(array('%d byte','%d bytes'),strlen($me));return($_?"$K":$K);}function -editVal($X,$k){return$X;}function +rowDescriptions($M,$sc){return$M;}function +selectLink($X,$l){}function +selectVal($X,$_,$l,$me){$K=($X===null?"NULL":(preg_match("~char|binary~",$l["type"])&&!preg_match("~var~",$l["type"])?"$X":$X));if(preg_match('~blob|bytea|raw|file~',$l["type"])&&!is_utf8($X))$K=lang(array('%d byte','%d bytes'),strlen($me));return($_?"$K":$K);}function +editVal($X,$l){return$X;}function selectColumnsPrint($N,$d){global$yc,$Ac;print_fieldset("select",'Select',$N);$s=0;$N[""]=array();foreach($N as$y=>$X){$X=$_GET["columns"][$y];$c=select_input(" name='columns[$s][col]' onchange='".($y!==""?"selectFieldChange(this.form)":"selectAddRow(this)").";'",$d,$X["col"]);echo"
".($yc||$Ac?""."($c)":$c)."
\n";$s++;}echo"\n";}function selectSearchPrint($Z,$d,$v){print_fieldset("search",'Search',$Z);foreach($v @@ -409,69 +411,69 @@ as$u){if($u["type"]!="FULLTEXT")$d[reset($u["columns"])]=1;}$d[""]=1;foreach($d as$y=>$X)json_row($y);echo";\n","selectFieldChange(document.getElementById('form'));\n","\n","\n";}function selectCommandPrint(){return!information_schema(DB);}function selectImportPrint(){return!information_schema(DB);}function -selectEmailPrint($Rb,$d){}function +selectEmailPrint($Qb,$d){}function selectColumnsProcess($d,$v){global$yc,$Ac;$N=array();$r=array();foreach((array)$_GET["columns"]as$y=>$X){if($X["fun"]=="count"||($X["col"]!=""&&(!$X["fun"]||in_array($X["fun"],$yc)||in_array($X["fun"],$Ac)))){$N[$y]=apply_sql_function($X["fun"],($X["col"]!=""?idf_escape($X["col"]):"*"));if(!in_array($X["fun"],$Ac))$r[]=$N[$y];}}return array($N,$r);}function -selectSearchProcess($l,$v){global$e,$x;$K=array();foreach($v -as$s=>$u){if($u["type"]=="FULLTEXT"&&$_GET["fulltext"][$s]!="")$K[]="MATCH (".implode(", ",array_map('idf_escape',$u["columns"])).") AGAINST (".q($_GET["fulltext"][$s]).(isset($_GET["boolean"][$s])?" IN BOOLEAN MODE":"").")";}foreach((array)$_GET["where"]as$X){if("$X[col]$X[val]"!=""&&in_array($X["op"],$this->operators)){$db=" $X[op]";if(preg_match('~IN$~',$X["op"])){$Mc=process_length($X["val"]);$db.=" ".($Mc!=""?$Mc:"(NULL)");}elseif($X["op"]=="SQL")$db=" $X[val]";elseif($X["op"]=="LIKE %%")$db=" LIKE ".$this->processInput($l[$X["col"]],"%$X[val]%");elseif($X["op"]=="ILIKE %%")$db=" ILIKE ".$this->processInput($l[$X["col"]],"%$X[val]%");elseif(!preg_match('~NULL$~',$X["op"]))$db.=" ".$this->processInput($l[$X["col"]],$X["val"]);if($X["col"]!="")$K[]=idf_escape($X["col"]).$db;else{$Ya=array();foreach($l -as$E=>$k){$Yc=preg_match('~char|text|enum|set~',$k["type"]);if((is_numeric($X["val"])||!preg_match('~(^|[^o])int|float|double|decimal|bit~',$k["type"]))&&(!preg_match("~[\x80-\xFF]~",$X["val"])||$Yc)){$E=idf_escape($E);$Ya[]=($x=="sql"&&$Yc&&!preg_match("~^utf8_~",$k["collation"])?"CONVERT($E USING ".charset($e).")":$E);}}$K[]=($Ya?"(".implode("$db OR ",$Ya)."$db)":"0");}}}return$K;}function -selectOrderProcess($l,$v){$K=array();foreach((array)$_GET["order"]as$y=>$X){if($X!="")$K[]=(preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\\)|COUNT\\(\\*\\))$~',$X)?$X:idf_escape($X)).(isset($_GET["desc"][$y])?" DESC":"");}return$K;}function +selectSearchProcess($m,$v){global$e,$x;$K=array();foreach($v +as$s=>$u){if($u["type"]=="FULLTEXT"&&$_GET["fulltext"][$s]!="")$K[]="MATCH (".implode(", ",array_map('idf_escape',$u["columns"])).") AGAINST (".q($_GET["fulltext"][$s]).(isset($_GET["boolean"][$s])?" IN BOOLEAN MODE":"").")";}foreach((array)$_GET["where"]as$X){if("$X[col]$X[val]"!=""&&in_array($X["op"],$this->operators)){$db=" $X[op]";if(preg_match('~IN$~',$X["op"])){$Mc=process_length($X["val"]);$db.=" ".($Mc!=""?$Mc:"(NULL)");}elseif($X["op"]=="SQL")$db=" $X[val]";elseif($X["op"]=="LIKE %%")$db=" LIKE ".$this->processInput($m[$X["col"]],"%$X[val]%");elseif($X["op"]=="ILIKE %%")$db=" ILIKE ".$this->processInput($m[$X["col"]],"%$X[val]%");elseif(!preg_match('~NULL$~',$X["op"]))$db.=" ".$this->processInput($m[$X["col"]],$X["val"]);if($X["col"]!="")$K[]=idf_escape($X["col"]).$db;else{$Ya=array();foreach($m +as$E=>$l){$Yc=preg_match('~char|text|enum|set~',$l["type"]);if((is_numeric($X["val"])||!preg_match('~(^|[^o])int|float|double|decimal|bit~',$l["type"]))&&(!preg_match("~[\x80-\xFF]~",$X["val"])||$Yc)){$E=idf_escape($E);$Ya[]=($x=="sql"&&$Yc&&!preg_match("~^utf8_~",$l["collation"])?"CONVERT($E USING ".charset($e).")":$E);}}$K[]=($Ya?"(".implode("$db OR ",$Ya)."$db)":"0");}}}return$K;}function +selectOrderProcess($m,$v){$K=array();foreach((array)$_GET["order"]as$y=>$X){if($X!="")$K[]=(preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\\)|COUNT\\(\\*\\))$~',$X)?$X:idf_escape($X)).(isset($_GET["desc"][$y])?" DESC":"");}return$K;}function selectLimitProcess(){return(isset($_GET["limit"])?$_GET["limit"]:"50");}function selectLengthProcess(){return(isset($_GET["text_length"])?$_GET["text_length"]:"100");}function -selectEmailProcess($Z,$tc){return +selectEmailProcess($Z,$sc){return false;}function selectQueryBuild($N,$Z,$r,$fe,$z,$F){return"";}function messageQuery($I,$bg){global$x;restart_session();$Fc=&get_session("queries");$t="sql-".count($Fc[$_GET["db"]]);if(strlen($I)>1e6)$I=preg_replace('~[\x80-\xFF]+$~','',substr($I,0,1e6))."\n...";$Fc[$_GET["db"]][]=array($I,time(),$bg);return" ".@date("H:i:s")." ".'SQL command'.""."';}function -editFunctions($k){global$Mb;$K=($k["null"]?"NULL/":"");foreach($Mb +editFunctions($l){global$Lb;$K=($l["null"]?"NULL/":"");foreach($Lb as$y=>$yc){if(!$y||(!isset($_GET["call"])&&(isset($_GET["select"])||where($_GET)))){foreach($yc -as$ze=>$X){if(!$ze||preg_match("~$ze~",$k["type"]))$K.="/$X";}if($y&&!preg_match('~set|blob|bytea|raw|file~',$k["type"]))$K.="/SQL";}}if($k["auto_increment"]&&!isset($_GET["select"])&&!where($_GET))$K='Auto Increment';return +as$ze=>$X){if(!$ze||preg_match("~$ze~",$l["type"]))$K.="/$X";}if($y&&!preg_match('~set|blob|bytea|raw|file~',$l["type"]))$K.="/SQL";}}if($l["auto_increment"]&&!isset($_GET["select"])&&!where($_GET))$K='Auto Increment';return explode("/",$K);}function -editInput($Q,$k,$wa,$Y){if($k["type"]=="enum")return(isset($_GET["select"])?" ":"").($k["null"]?" ":"").enum_input("radio",$wa,$k,$Y,0);return"";}function -processInput($k,$Y,$p=""){if($p=="SQL")return$Y;$E=$k["field"];$K=q($Y);if(preg_match('~^(now|getdate|uuid)$~',$p))$K="$p()";elseif(preg_match('~^current_(date|timestamp)$~',$p))$K=$p;elseif(preg_match('~^([+-]|\\|\\|)$~',$p))$K=idf_escape($E)." $p $K";elseif(preg_match('~^[+-] interval$~',$p))$K=idf_escape($E)." $p ".(preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i",$Y)?$Y:$K);elseif(preg_match('~^(addtime|subtime|concat)$~',$p))$K="$p(".idf_escape($E).", $K)";elseif(preg_match('~^(md5|sha1|password|encrypt)$~',$p))$K="$p($K)";return -unconvert_field($k,$K);}function +editInput($Q,$l,$wa,$Y){if($l["type"]=="enum")return(isset($_GET["select"])?" ":"").($l["null"]?" ":"").enum_input("radio",$wa,$l,$Y,0);return"";}function +processInput($l,$Y,$p=""){if($p=="SQL")return$Y;$E=$l["field"];$K=q($Y);if(preg_match('~^(now|getdate|uuid)$~',$p))$K="$p()";elseif(preg_match('~^current_(date|timestamp)$~',$p))$K=$p;elseif(preg_match('~^([+-]|\\|\\|)$~',$p))$K=idf_escape($E)." $p $K";elseif(preg_match('~^[+-] interval$~',$p))$K=idf_escape($E)." $p ".(preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i",$Y)?$Y:$K);elseif(preg_match('~^(addtime|subtime|concat)$~',$p))$K="$p(".idf_escape($E).", $K)";elseif(preg_match('~^(md5|sha1|password|encrypt)$~',$p))$K="$p($K)";return +unconvert_field($l,$K);}function dumpOutput(){$K=array('text'=>'open','file'=>'save');if(function_exists('gzencode'))$K['gz']='gzip';return$K;}function dumpFormat(){return array('sql'=>'SQL','csv'=>'CSV,','csv;'=>'CSV;','tsv'=>'TSV');}function -dumpDatabase($h){}function -dumpTable($Q,$If,$Zc=0){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($If)dump_csv(array_keys(fields($Q)));}elseif($If){if($Zc==2){$l=array();foreach(fields($Q)as$E=>$k)$l[]=idf_escape($E)." $k[full_type]";$kb="CREATE TABLE ".table($Q)." (".implode(", ",$l).")";}else$kb=create_sql($Q,$_POST["auto_increment"]);if($kb){if($If=="DROP+CREATE"||$Zc==1)echo"DROP ".($Zc==2?"VIEW":"TABLE")." IF EXISTS ".table($Q).";\n";if($Zc==1)$kb=remove_definer($kb);echo"$kb;\n\n";}}}function +dumpDatabase($i){}function +dumpTable($Q,$If,$Zc=0){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($If)dump_csv(array_keys(fields($Q)));}else{if($Zc==2){$m=array();foreach(fields($Q)as$E=>$l)$m[]=idf_escape($E)." $l[full_type]";$g="CREATE TABLE ".table($Q)." (".implode(", ",$m).")";}else$g=create_sql($Q,$_POST["auto_increment"]);set_utf8mb4($g);if($If&&$g){if($If=="DROP+CREATE"||$Zc==1)echo"DROP ".($Zc==2?"VIEW":"TABLE")." IF EXISTS ".table($Q).";\n";if($Zc==1)$g=remove_definer($g);echo"$g;\n\n";}}}function dumpData($Q,$If,$I){global$e,$x;$vd=($x=="sqlite"?0:1048576);if($If){if($_POST["format"]=="sql"){if($If=="TRUNCATE+INSERT")echo -truncate_sql($Q).";\n";$l=fields($Q);}$J=$e->query($I,1);if($J){$Rc="";$Ia="";$bd=array();$Kf="";$mc=($Q!=''?'fetch_assoc':'fetch_row');while($L=$J->$mc()){if(!$bd){$Hg=array();foreach($L -as$X){$k=$J->fetch_field();$bd[]=$k->name;$y=idf_escape($k->name);$Hg[]="$y = VALUES($y)";}$Kf=($If=="INSERT+UPDATE"?"\nON DUPLICATE KEY UPDATE ".implode(", ",$Hg):"").";\n";}if($_POST["format"]!="sql"){if($If=="table"){dump_csv($bd);$If="INSERT";}dump_csv($L);}else{if(!$Rc)$Rc="INSERT INTO ".table($Q)." (".implode(", ",array_map('idf_escape',$bd)).") VALUES";foreach($L -as$y=>$X){$k=$l[$y];$L[$y]=($X!==null?unconvert_field($k,preg_match('~(^|[^o])int|float|double|decimal~',$k["type"])&&$X!=''?$X:q($X)):"NULL");}$mf=($vd?"\n":" ")."(".implode(",\t",$L).")";if(!$Ia)$Ia=$Rc.$mf;elseif(strlen($Ia)+4+strlen($mf)+strlen($Kf)<$vd)$Ia.=",$mf";else{echo$Ia.$Kf;$Ia=$Rc.$mf;}}}if($Ia)echo$Ia.$Kf;}elseif($_POST["format"]=="sql")echo"-- ".str_replace("\n"," ",$e->error)."\n";}}function +truncate_sql($Q).";\n";$m=fields($Q);}$J=$e->query($I,1);if($J){$Rc="";$Ia="";$bd=array();$Kf="";$lc=($Q!=''?'fetch_assoc':'fetch_row');while($L=$J->$lc()){if(!$bd){$Hg=array();foreach($L +as$X){$l=$J->fetch_field();$bd[]=$l->name;$y=idf_escape($l->name);$Hg[]="$y = VALUES($y)";}$Kf=($If=="INSERT+UPDATE"?"\nON DUPLICATE KEY UPDATE ".implode(", ",$Hg):"").";\n";}if($_POST["format"]!="sql"){if($If=="table"){dump_csv($bd);$If="INSERT";}dump_csv($L);}else{if(!$Rc)$Rc="INSERT INTO ".table($Q)." (".implode(", ",array_map('idf_escape',$bd)).") VALUES";foreach($L +as$y=>$X){$l=$m[$y];$L[$y]=($X!==null?unconvert_field($l,preg_match('~(^|[^o])int|float|double|decimal~',$l["type"])&&$X!=''?$X:q($X)):"NULL");}$mf=($vd?"\n":" ")."(".implode(",\t",$L).")";if(!$Ia)$Ia=$Rc.$mf;elseif(strlen($Ia)+4+strlen($mf)+strlen($Kf)<$vd)$Ia.=",$mf";else{echo$Ia.$Kf;$Ia=$Rc.$mf;}}}if($Ia)echo$Ia.$Kf;}elseif($_POST["format"]=="sql")echo"-- ".str_replace("\n"," ",$e->error)."\n";}}function dumpFilename($Jc){return friendly_url($Jc!=""?$Jc:(SERVER!=""?SERVER:"localhost"));}function -dumpHeaders($Jc,$Gd=false){$oe=$_POST["output"];$hc=(preg_match('~sql~',$_POST["format"])?"sql":($Gd?"tar":"csv"));header("Content-Type: ".($oe=="gz"?"application/x-gzip":($hc=="tar"?"application/x-tar":($hc=="sql"||$oe!="file"?"text/plain":"text/csv")."; charset=utf-8")));if($oe=="gz")ob_start('ob_gzencode',1e6);return$hc;}function +dumpHeaders($Jc,$Gd=false){$oe=$_POST["output"];$gc=(preg_match('~sql~',$_POST["format"])?"sql":($Gd?"tar":"csv"));header("Content-Type: ".($oe=="gz"?"application/x-gzip":($gc=="tar"?"application/x-tar":($gc=="sql"||$oe!="file"?"text/plain":"text/csv")."; charset=utf-8")));if($oe=="gz")ob_start('ob_gzencode',1e6);return$gc;}function homepage(){echo'

+navigation($Fd){global$ga,$x,$Eb,$e;echo'

',$this->name(),' ',$ga,' ',(version_compare($ga,$_COOKIE["adminer_version"])<0?h($_COOKIE["adminer_version"]):""),'

-';if($Fd=="auth"){$qc=true;foreach((array)$_SESSION["pwds"]as$Jg=>$wf){foreach($wf +';if($Fd=="auth"){$pc=true;foreach((array)$_SESSION["pwds"]as$Jg=>$wf){foreach($wf as$O=>$Fg){foreach($Fg -as$V=>$G){if($G!==null){if($qc){echo"

\n";$qc=false;}$ub=$_SESSION["db"][$Jg][$O][$V];foreach(($ub?array_keys($ub):array(""))as$h)echo"($Fb[$Jg]) ".h($V.($O!=""?"@$O":"").($h!=""?" - $h":""))."
\n";}}}}}else{if($_GET["ns"]!==""&&!$Fd&&DB!=""){$e->select_db(DB);$S=table_status('',true);}if(support("sql")){echo' +as$V=>$G){if($G!==null){if($pc){echo"

\n";$pc=false;}$tb=$_SESSION["db"][$Jg][$O][$V];foreach(($tb?array_keys($tb):array(""))as$i)echo"($Eb[$Jg]) ".h($V.($O!=""?"@$O":"").($i!=""?" - $i":""))."
\n";}}}}}else{if($_GET["ns"]!==""&&!$Fd&&DB!=""){$e->select_db(DB);$S=table_status('',true);}if(support("sql")){echo' ';}$this->databasesPrint($Fd);if(DB==""||!$Fd){echo"

".'No tables.'."\n";else$this->tablesPrint($S);}}}function -databasesPrint($Fd){global$b,$e;$g=$this->databases();echo'

+databasesPrint($Fd){global$b,$e;$h=$this->databases();echo'

-';hidden_fields_get();$sb=" onmousedown='dbMouseDown(event, this);' onchange='dbChange(this);'";echo"DB: ".($g?"":''),"\n";if($Fd!="db"&&DB!=""&&$e->select_db(DB)){}echo(isset($_GET["sql"])?'':(isset($_GET["schema"])?'':(isset($_GET["dump"])?'':(isset($_GET["privileges"])?'':"")))),"

\n";}function +';hidden_fields_get();$rb=" onmousedown='dbMouseDown(event, this);' onchange='dbChange(this);'";echo"DB: ".($h?"":''),"\n";if($Fd!="db"&&DB!=""&&$e->select_db(DB)){}echo(isset($_GET["sql"])?'':(isset($_GET["schema"])?'':(isset($_GET["dump"])?'':(isset($_GET["privileges"])?'':"")))),"

\n";}function tablesPrint($S){echo"

\n";foreach($S as$Q=>$Df){echo'".'select'." ";$E=$this->tableName($Df);echo(support("table")||support("indexes")?'$E":"$E")."
\n";}}}$b=(function_exists('adminer_object')?adminer_object():new Adminer);if($b->operators===null)$b->operators=$be;function -page_header($eg,$j="",$Ha=array(),$fg=""){global$ca,$ga,$b,$Fb,$x;page_headers();if(is_ajax()&&$j){page_messages($j);exit;}$gg=$eg.($fg!=""?": $fg":"");$hg=strip_tags($gg.(SERVER!=""&&SERVER!="localhost"?h(" - ".SERVER):"")." - ".$b->name());echo' +page_header($eg,$k="",$Ha=array(),$fg=""){global$ca,$ga,$b,$Eb,$x;page_headers();if(is_ajax()&&$k){page_messages($k);exit;}$gg=$eg.($fg!=""?": $fg":"");$hg=strip_tags($gg.(SERVER!=""&&SERVER!="localhost"?h(" - ".SERVER):"")." - ".$b->name());echo' - + ',$hg,' - - -';if($b->head()){echo' - + + +';if($b->head()){echo' + ';if(file_exists("adminer.css")){echo' ';}}echo' > @@ -484,10 +486,10 @@ js_escape('You are offline.'),'\';

-';if($Ha!==null){$_=substr(preg_replace('~\b(username|db|ns)=[^&]*&~','',ME),0,-1);echo'

$gg

\n","\n";restart_session();page_messages($j);$g=&get_session("dbs");if(DB!=""&&$g&&!in_array(DB,$g,true))$g=null;stop_session();define("PAGE_HEADER",1);}function +';if($Ha!==null){$_=substr(preg_replace('~\b(username|db|ns)=[^&]*&~','',ME),0,-1);echo'

$gg

\n","\n";restart_session();page_messages($k);$h=&get_session("dbs");if(DB!=""&&$h&&!in_array(DB,$h,true))$h=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");if($b->headers()){header("X-Frame-Options: deny");header("X-XSS-Protection: 0");}}function -page_messages($j){$Bg=preg_replace('~^[^?]*~','',$_SERVER["REQUEST_URI"]);$Dd=$_SESSION["messages"][$Bg];if($Dd){echo"
".implode("
\n
",$Dd)."
\n";unset($_SESSION["messages"][$Bg]);}if($j)echo"
$j
\n";}function +page_messages($k){$Bg=preg_replace('~^[^?]*~','',$_SERVER["REQUEST_URI"]);$Dd=$_SESSION["messages"][$Bg];if($Dd){echo"
".implode("
\n
",$Dd)."
\n";unset($_SESSION["messages"][$Bg]);}if($k)echo"
$k
\n";}function page_footer($Fd=""){global$b,$T;echo'
';if($Fd!="auth"){echo'
@@ -507,86 +509,87 @@ substr($mf,0,end($W));return$mf;}function str2long($mf,$Ng){$W=array_values(unpack('V*',str_pad($mf,4*ceil(strlen($mf)/4),"\0")));if($Ng)$W[]=strlen($mf);return$W;}function xxtea_mx($Sg,$Rg,$Lf,$ad){return int32((($Sg>>5&0x7FFFFFF)^$Rg<<2)+(($Rg>>3&0x1FFFFFFF)^$Sg<<4))^int32(($Lf^$Rg)+($ad^$Sg));}function -encrypt_string($Ff,$y){if($Ff=="")return"";$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Ff,true);$D=count($W)-1;$Sg=$W[$D];$Rg=$W[0];$H=floor(6+52/($D+1));$Lf=0;while($H-->0){$Lf=int32($Lf+0x9E3779B9);$Lb=$Lf>>2&3;for($pe=0;$pe<$D;$pe++){$Rg=$W[$pe+1];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Lb]);$Sg=int32($W[$pe]+$Hd);$W[$pe]=$Sg;}$Rg=$W[0];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Lb]);$Sg=int32($W[$D]+$Hd);$W[$D]=$Sg;}return +encrypt_string($Ff,$y){if($Ff=="")return"";$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Ff,true);$D=count($W)-1;$Sg=$W[$D];$Rg=$W[0];$H=floor(6+52/($D+1));$Lf=0;while($H-->0){$Lf=int32($Lf+0x9E3779B9);$Kb=$Lf>>2&3;for($pe=0;$pe<$D;$pe++){$Rg=$W[$pe+1];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Kb]);$Sg=int32($W[$pe]+$Hd);$W[$pe]=$Sg;}$Rg=$W[0];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Kb]);$Sg=int32($W[$D]+$Hd);$W[$D]=$Sg;}return long2str($W,false);}function decrypt_string($Ff,$y){if($Ff=="")return"";if(!$y)return -false;$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Ff,false);$D=count($W)-1;$Sg=$W[$D];$Rg=$W[0];$H=floor(6+52/($D+1));$Lf=int32($H*0x9E3779B9);while($Lf){$Lb=$Lf>>2&3;for($pe=$D;$pe>0;$pe--){$Sg=$W[$pe-1];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Lb]);$Rg=int32($W[$pe]-$Hd);$W[$pe]=$Rg;}$Sg=$W[$D];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Lb]);$Rg=int32($W[0]-$Hd);$W[0]=$Rg;$Lf=int32($Lf-0x9E3779B9);}return +false;$y=array_values(unpack("V*",pack("H*",md5($y))));$W=str2long($Ff,false);$D=count($W)-1;$Sg=$W[$D];$Rg=$W[0];$H=floor(6+52/($D+1));$Lf=int32($H*0x9E3779B9);while($Lf){$Kb=$Lf>>2&3;for($pe=$D;$pe>0;$pe--){$Sg=$W[$pe-1];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Kb]);$Rg=int32($W[$pe]-$Hd);$W[$pe]=$Rg;}$Sg=$W[$D];$Hd=xxtea_mx($Sg,$Rg,$Lf,$y[$pe&3^$Kb]);$Rg=int32($W[0]-$Hd);$W[0]=$Rg;$Lf=int32($Lf-0x9E3779B9);}return long2str($W,true);}$e='';$Ec=$_SESSION["token"];if(!$Ec)$_SESSION["token"]=rand(1,1e6);$T=get_token();$_e=array();if($_COOKIE["adminer_permanent"]){foreach(explode(" ",$_COOKIE["adminer_permanent"])as$X){list($y)=explode(":",$X);$_e[$y]=$X;}}function -add_invalid_login(){global$b;$oc=get_temp_dir()."/adminer.invalid";$o=@fopen($oc,"r+");if(!$o){$o=@fopen($oc,"w");if(!$o)return;}flock($o,LOCK_EX);$Uc=unserialize(stream_get_contents($o));$bg=time();if($Uc){foreach($Uc -as$Vc=>$X){if($X[0]<$bg)unset($Uc[$Vc]);}}$Tc=&$Uc[$b->bruteForceKey()];if(!$Tc)$Tc=array($bg+30*60,0);$Tc[1]++;$uf=serialize($Uc);rewind($o);fwrite($o,$uf);ftruncate($o,strlen($uf));flock($o,LOCK_UN);fclose($o);}$xa=$_POST["auth"];if($xa){$Uc=unserialize(@file_get_contents(get_temp_dir()."/adminer.invalid"));$Tc=$Uc[$b->bruteForceKey()];$Md=($Tc[1]>30?$Tc[0]-time():0);if($Md>0)auth_error(lang(array('Too many unsuccessful logins, try again in %d minute.','Too many unsuccessful logins, try again in %d minutes.'),ceil($Md/60)));session_regenerate_id();$Jg=$xa["driver"];$O=$xa["server"];$V=$xa["username"];$G=(string)$xa["password"];$h=$xa["db"];set_password($Jg,$O,$V,$G);$_SESSION["db"][$Jg][$O][$V][$h]=true;if($xa["permanent"]){$y=base64_encode($Jg)."-".base64_encode($O)."-".base64_encode($V)."-".base64_encode($h);$Ke=$b->permanentLogin(true);$_e[$y]="$y:".base64_encode($Ke?encrypt_string($G,$Ke):"");cookie("adminer_permanent",implode(" ",$_e));}if(count($_POST)==1||DRIVER!=$Jg||SERVER!=$O||$_GET["username"]!==$V||DB!=$h)redirect(auth_url($Jg,$O,$V,$h));}elseif($_POST["logout"]){if($Ec&&!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.');}}elseif($_e&&!$_SESSION["pwds"]){session_regenerate_id();$Ke=$b->permanentLogin();foreach($_e -as$y=>$X){list(,$Qa)=explode(":",$X);list($Jg,$O,$V,$h)=array_map('base64_decode',explode("-",$y));set_password($Jg,$O,$V,decrypt_string(base64_decode($Qa),$Ke));$_SESSION["db"][$Jg][$O][$V][$h]=true;}}function +add_invalid_login(){global$b;$nc=get_temp_dir()."/adminer.invalid";$o=@fopen($nc,"r+");if(!$o){$o=@fopen($nc,"w");if(!$o)return;}flock($o,LOCK_EX);$Uc=unserialize(stream_get_contents($o));$bg=time();if($Uc){foreach($Uc +as$Vc=>$X){if($X[0]<$bg)unset($Uc[$Vc]);}}$Tc=&$Uc[$b->bruteForceKey()];if(!$Tc)$Tc=array($bg+30*60,0);$Tc[1]++;$uf=serialize($Uc);rewind($o);fwrite($o,$uf);ftruncate($o,strlen($uf));flock($o,LOCK_UN);fclose($o);}$xa=$_POST["auth"];if($xa){$Uc=unserialize(@file_get_contents(get_temp_dir()."/adminer.invalid"));$Tc=$Uc[$b->bruteForceKey()];$Md=($Tc[1]>30?$Tc[0]-time():0);if($Md>0)auth_error(lang(array('Too many unsuccessful logins, try again in %d minute.','Too many unsuccessful logins, try again in %d minutes.'),ceil($Md/60)));session_regenerate_id();$Jg=$xa["driver"];$O=$xa["server"];$V=$xa["username"];$G=(string)$xa["password"];$i=$xa["db"];set_password($Jg,$O,$V,$G);$_SESSION["db"][$Jg][$O][$V][$i]=true;if($xa["permanent"]){$y=base64_encode($Jg)."-".base64_encode($O)."-".base64_encode($V)."-".base64_encode($i);$Ke=$b->permanentLogin(true);$_e[$y]="$y:".base64_encode($Ke?encrypt_string($G,$Ke):"");cookie("adminer_permanent",implode(" ",$_e));}if(count($_POST)==1||DRIVER!=$Jg||SERVER!=$O||$_GET["username"]!==$V||DB!=$i)redirect(auth_url($Jg,$O,$V,$i));}elseif($_POST["logout"]){if($Ec&&!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.');}}elseif($_e&&!$_SESSION["pwds"]){session_regenerate_id();$Ke=$b->permanentLogin();foreach($_e +as$y=>$X){list(,$Qa)=explode(":",$X);list($Jg,$O,$V,$i)=array_map('base64_decode',explode("-",$y));set_password($Jg,$O,$V,decrypt_string(base64_decode($Qa),$Ke));$_SESSION["db"][$Jg][$O][$V][$i]=true;}}function unset_permanent(){global$_e;foreach($_e -as$y=>$X){list($Jg,$O,$V,$h)=array_map('base64_decode',explode("-",$y));if($Jg==DRIVER&&$O==SERVER&&$V==$_GET["username"]&&$h==DB)unset($_e[$y]);}cookie("adminer_permanent",implode(" ",$_e));}function -auth_error($j){global$b,$Ec;$j=h($j);$xf=session_name();if(isset($_GET["username"])){header("HTTP/1.1 403 Forbidden");if(($_COOKIE[$xf]||$_GET[$xf])&&!$Ec)$j='Session expired, please login again.';else{add_invalid_login();$G=get_password();if($G!==null){if($G===false)$j.='
'.sprintf('Master password expired. Implement %s method to make it permanent.','permanentLogin()');set_password(DRIVER,SERVER,$_GET["username"],null);}unset_permanent();}}if(!$_COOKIE[$xf]&&$_GET[$xf]&&ini_bool("session.use_only_cookies"))$j='Session support must be enabled.';$re=session_get_cookie_params();cookie("adminer_key",($_COOKIE["adminer_key"]?$_COOKIE["adminer_key"]:rand_string()),$re["lifetime"]);page_header('Login',$j,null);echo"\n";$b->loginForm();echo"
";hidden_fields($_POST,array("auth"));echo"
\n","
\n";page_footer("auth");exit;}if(isset($_GET["username"])){if(!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(", ",$Fe)),false);page_footer("auth");exit;}$e=connect();}$i=new -Min_Driver($e);if(!is_object($e)||!$b->login($_GET["username"],get_password()))auth_error((is_string($e)?$e:'Invalid credentials.'));if($xa&&$_POST["token"])$_POST["token"]=$T;$j='';if($_POST){if(!verify_token()){$Oc="max_input_vars";$zd=ini_get($Oc);if(extension_loaded("suhosin")){foreach(array("suhosin.request.max_vars","suhosin.post.max_vars")as$y){$X=ini_get($y);if($X&&(!$zd||$X<$zd)){$Oc=$y;$zd=$X;}}}$j=(!$_POST["token"]&&$zd?sprintf('Maximum number of allowed fields exceeded. Please increase %s.',"'$Oc'"):'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"){$j=sprintf('Too big POST data. Reduce the data or increase the %s configuration directive.',"'post_max_size'");if(isset($_GET["sql"]))$j.=' '.'You can upload a big SQL file via FTP and import it from server.';}if(!ini_bool("session.use_cookies")||@ini_set("session.use_cookies",false)!==false)session_write_close();function -select($J,$f=null,$ie=array(),$z=0){global$x;$qd=array();$v=array();$d=array();$Fa=array();$tg=array();$K=array();odd('');for($s=0;(!$z||$s<$z)&&($L=$J->fetch_row());$s++){if(!$s){echo"\n","";for($w=0;$wfetch_field();$E=$k->name;$he=$k->orgtable;$ge=$k->orgname;$K[$k->table]=$he;if($ie&&$x=="sql")$qd[$w]=($E=="table"?"table=":($E=="possible_keys"?"indexes=":null));elseif($he!=""){if(!isset($v[$he])){$v[$he]=array();foreach(indexes($he,$f)as$u){if($u["type"]=="PRIMARY"){$v[$he]=array_flip($u["columns"]);break;}}$d[$he]=$v[$he];}if(isset($d[$he][$ge])){unset($d[$he][$ge]);$v[$he][$ge]=$w;$qd[$w]=$he;}}if($k->charsetnr==63)$Fa[$w]=true;$tg[$w]=$k->type;echo"name!=$ge?" title='".h(($he!=""?"$he.":"").$ge)."'":"").">".h($E).($ie?doc_link(array('sql'=>"explain-output.html#explain_".strtolower($E))):"");}echo"\n";}echo"";foreach($L +as$y=>$X){list($Jg,$O,$V,$i)=array_map('base64_decode',explode("-",$y));if($Jg==DRIVER&&$O==SERVER&&$V==$_GET["username"]&&$i==DB)unset($_e[$y]);}cookie("adminer_permanent",implode(" ",$_e));}function +auth_error($k){global$b,$Ec;$k=h($k);$xf=session_name();if(isset($_GET["username"])){header("HTTP/1.1 403 Forbidden");if(($_COOKIE[$xf]||$_GET[$xf])&&!$Ec)$k='Session expired, please login again.';else{add_invalid_login();$G=get_password();if($G!==null){if($G===false)$k.='
'.sprintf('Master password expired. Implement %s method to make it permanent.','permanentLogin()');set_password(DRIVER,SERVER,$_GET["username"],null);}unset_permanent();}}if(!$_COOKIE[$xf]&&$_GET[$xf]&&ini_bool("session.use_only_cookies"))$k='Session support must be enabled.';$re=session_get_cookie_params();cookie("adminer_key",($_COOKIE["adminer_key"]?$_COOKIE["adminer_key"]:rand_string()),$re["lifetime"]);page_header('Login',$k,null);echo"
\n";$b->loginForm();echo"
";hidden_fields($_POST,array("auth"));echo"
\n","\n";page_footer("auth");exit;}if(isset($_GET["username"])){if(!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(", ",$Fe)),false);page_footer("auth");exit;}$e=connect();}$j=new +Min_Driver($e);if(!is_object($e)||!$b->login($_GET["username"],get_password()))auth_error((is_string($e)?$e:'Invalid credentials.'));if($xa&&$_POST["token"])$_POST["token"]=$T;$k='';if($_POST){if(!verify_token()){$Oc="max_input_vars";$zd=ini_get($Oc);if(extension_loaded("suhosin")){foreach(array("suhosin.request.max_vars","suhosin.post.max_vars")as$y){$X=ini_get($y);if($X&&(!$zd||$X<$zd)){$Oc=$y;$zd=$X;}}}$k=(!$_POST["token"]&&$zd?sprintf('Maximum number of allowed fields exceeded. Please increase %s.',"'$Oc'"):'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"){$k=sprintf('Too big POST data. Reduce the data or increase the %s configuration directive.',"'post_max_size'");if(isset($_GET["sql"]))$k.=' '.'You can upload a big SQL file via FTP and import it from server.';}if(!ini_bool("session.use_cookies")||@ini_set("session.use_cookies",false)!==false)session_write_close();function +select($J,$f=null,$ie=array(),$z=0){global$x;$qd=array();$v=array();$d=array();$Fa=array();$tg=array();$K=array();odd('');for($s=0;(!$z||$s<$z)&&($L=$J->fetch_row());$s++){if(!$s){echo"
\n","";for($w=0;$wfetch_field();$E=$l->name;$he=$l->orgtable;$ge=$l->orgname;$K[$l->table]=$he;if($ie&&$x=="sql")$qd[$w]=($E=="table"?"table=":($E=="possible_keys"?"indexes=":null));elseif($he!=""){if(!isset($v[$he])){$v[$he]=array();foreach(indexes($he,$f)as$u){if($u["type"]=="PRIMARY"){$v[$he]=array_flip($u["columns"]);break;}}$d[$he]=$v[$he];}if(isset($d[$he][$ge])){unset($d[$he][$ge]);$v[$he][$ge]=$w;$qd[$w]=$he;}}if($l->charsetnr==63)$Fa[$w]=true;$tg[$w]=$l->type;echo"name!=$ge?" title='".h(($he!=""?"$he.":"").$ge)."'":"").">".h($E).($ie?doc_link(array('sql'=>"explain-output.html#explain_".strtolower($E))):"");}echo"\n";}echo"";foreach($L as$y=>$X){if($X===null)$X="NULL";elseif($Fa[$y]&&!is_utf8($X))$X="".lang(array('%d byte','%d bytes'),strlen($X))."";elseif(!strlen($X))$X=" ";else{$X=h($X);if($tg[$y]==254)$X="$X";}if(isset($qd[$y])&&!$d[$qd[$y]]){if($ie&&$x=="sql"){$Q=$L[array_search("table=",$qd)];$_=$qd[$y].urlencode($ie[$Q]!=""?$ie[$Q]:$Q);}else{$_="edit=".urlencode($qd[$y]);foreach($v[$qd[$y]]as$Ua=>$w)$_.="&where".urlencode("[".bracket_escape($Ua)."]")."=".urlencode($L[$w]);}$X="$X";}echo"
$X";}}echo($s?"
":"

".'No rows.')."\n";return$K;}function -referencable_primary($sf){$K=array();foreach(table_status('',true)as$Pf=>$Q){if($Pf!=$sf&&fk_support($Q)){foreach(fields($Pf)as$k){if($k["primary"]){if($K[$Pf]){unset($K[$Pf]);break;}$K[$Pf]=$k;}}}}return$K;}function +referencable_primary($sf){$K=array();foreach(table_status('',true)as$Pf=>$Q){if($Pf!=$sf&&fk_support($Q)){foreach(fields($Pf)as$l){if($l["primary"]){if($K[$Pf]){unset($K[$Pf]);break;}$K[$Pf]=$l;}}}}return$K;}function textarea($E,$Y,$M=10,$Ya=80){global$x;echo"";}function -edit_type($y,$k,$Xa,$n=array()){global$Hf,$tg,$_g,$Xd;$U=$k["type"];echo'

-';echo"',($_g?"':''),(isset($k['on_update'])?"':''),($n?" ":" ");}function -process_length($md){global$Wb;return(preg_match("~^\\s*\\(?\\s*$Wb(?:\\s*,\\s*$Wb)*+\\s*\\)?\\s*\$~",$md)&&preg_match_all("~$Wb~",$md,$td)?"(".implode(",",$td[0]).")":preg_replace('~^[0-9].*~','(\0)',preg_replace('~[^-0-9,+()[\]]~','',$md)));}function -process_type($k,$Va="COLLATE"){global$_g;return" $k[type]".process_length($k["length"]).(preg_match('~(^|[^o])int|float|double|decimal~',$k["type"])&&in_array($k["unsigned"],$_g)?" $k[unsigned]":"").(preg_match('~char|text|enum|set~',$k["type"])&&$k["collation"]?" $Va ".q($k["collation"]):"");}function -process_field($k,$rg){global$x;$wb=$k["default"];return -array(idf_escape(trim($k["field"])),process_type($rg),($k["null"]?" NULL":" NOT NULL"),(isset($wb)?" DEFAULT ".((preg_match('~time~',$k["type"])&&preg_match('~^CURRENT_TIMESTAMP$~i',$wb))||($x=="sqlite"&&preg_match('~^CURRENT_(TIME|TIMESTAMP|DATE)$~i',$wb))||($k["type"]=="bit"&&preg_match("~^([0-9]+|b'[0-1]+')\$~",$wb))||($x=="pgsql"&&preg_match("~^[a-z]+\\(('[^']*')+\\)\$~",$wb))?$wb:q($wb)):""),(preg_match('~timestamp|datetime~',$k["type"])&&$k["on_update"]?" ON UPDATE $k[on_update]":""),(support("comment")&&$k["comment"]!=""?" COMMENT ".q($k["comment"]):""),($k["auto_increment"]?auto_increment():null),);}function +';echo"',($_g?"':''),(isset($l['on_update'])?"':''),($tc?" ":" ");}function +process_length($md){global$Vb;return(preg_match("~^\\s*\\(?\\s*$Vb(?:\\s*,\\s*$Vb)*+\\s*\\)?\\s*\$~",$md)&&preg_match_all("~$Vb~",$md,$td)?"(".implode(",",$td[0]).")":preg_replace('~^[0-9].*~','(\0)',preg_replace('~[^-0-9,+()[\]]~','',$md)));}function +process_type($l,$Va="COLLATE"){global$_g;return" $l[type]".process_length($l["length"]).(preg_match('~(^|[^o])int|float|double|decimal~',$l["type"])&&in_array($l["unsigned"],$_g)?" $l[unsigned]":"").(preg_match('~char|text|enum|set~',$l["type"])&&$l["collation"]?" $Va ".q($l["collation"]):"");}function +process_field($l,$rg){global$x;$vb=$l["default"];return +array(idf_escape(trim($l["field"])),process_type($rg),($l["null"]?" NULL":" NOT NULL"),(isset($vb)?" DEFAULT ".((preg_match('~time~',$l["type"])&&preg_match('~^CURRENT_TIMESTAMP$~i',$vb))||($x=="sqlite"&&preg_match('~^CURRENT_(TIME|TIMESTAMP|DATE)$~i',$vb))||($l["type"]=="bit"&&preg_match("~^([0-9]+|b'[0-1]+')\$~",$vb))||($x=="pgsql"&&preg_match("~^[a-z]+\\(('[^']*')+\\)\$~",$vb))?$vb:q($vb)):""),(preg_match('~timestamp|datetime~',$l["type"])&&$l["on_update"]?" ON UPDATE $l[on_update]":""),(support("comment")&&$l["comment"]!=""?" COMMENT ".q($l["comment"]):""),($l["auto_increment"]?auto_increment():null),);}function type_class($U){foreach(array('char'=>'text','date'=>'time|year','binary'=>'blob','enum'=>'set',)as$y=>$X){if(preg_match("~$y|$X~",$U))return" class='$y'";}}function -edit_fields($l,$Xa,$U="TABLE",$n=array(),$cb=false){global$e,$Pc;echo'
 ';}echo'',($U=="TABLE"?'Column name':'Parameter name'),'Type Length Options ';if($U=="TABLE"){echo'NULL AI',doc_link(array('sql'=>"example-auto-increment.html",'sqlite'=>"autoinc.html",'pgsql'=>"datatype.html#DATATYPE-SERIAL",'mssql'=>"ms186775.aspx",)),'Default value -',(support("comment")?"',"",' +',(support("comment")?"',"",'
".html_select("fields[$s][inout]",explode("|",$Pc),$k["inout"]):""),'';if($Bb){echo'1?'':' editingAddRow(this);" onkeyup="if (this.value) editingAddRow(this);'),'" maxlength="64" autocapitalize="off">';}echo' -';edit_type("fields[$s]",$k,$Xa,$n);if($U=="TABLE"){echo'',checkbox("fields[$s][null]",1,$k["null"],"","","block"),'$l){$s++;$je=$l[($_POST?"orig":"field")];$Ab=(isset($_POST["add"][$s-1])||(isset($l["field"])&&!$_POST["drop_col"][$s]))&&(support("drop_col")||$je=="");echo' +',($U=="PROCEDURE"?"".html_select("fields[$s][inout]",explode("|",$Pc),$l["inout"]):""),'';if($Ab){echo'1?'':' editingAddRow(this);" onkeyup="if (this.value) editingAddRow(this);'),'" maxlength="64" autocapitalize="off">';}echo' +';edit_type("fields[$s]",$l,$Xa,$tc);if($U=="TABLE"){echo'',checkbox("fields[$s][null]",1,$l["null"],"","","block"),' -',(support("comment")?"",(support("move_col")?" "." "." ":""),($je==""||support("drop_col")?"":""),"\n";}}function -process_fields(&$l){ksort($l);$Qd=0;if($_POST["up"]){$gd=0;foreach($l -as$y=>$k){if(key($_POST["up"])==$y){unset($l[$y]);array_splice($l,$gd,0,array($k));break;}if(isset($k["field"]))$gd=$Qd;$Qd++;}}elseif($_POST["down"]){$vc=false;foreach($l -as$y=>$k){if(isset($k["field"])&&$vc){unset($l[key($_POST["down"])]);array_splice($l,$Qd,0,array($vc));break;}if(key($_POST["down"])==$y)$vc=$k;$Qd++;}}elseif($_POST["add"]){$l=array_values($l);array_splice($l,key($_POST["add"]),0,array(array()));}elseif(!$_POST["drop_col"])return +checkbox("fields[$s][has_default]",1,$l["has_default"]),' +',(support("comment")?"",(support("move_col")?" "." "." ":""),($je==""||support("drop_col")?"":""),"\n";}}function +process_fields(&$m){ksort($m);$Qd=0;if($_POST["up"]){$gd=0;foreach($m +as$y=>$l){if(key($_POST["up"])==$y){unset($m[$y]);array_splice($m,$gd,0,array($l));break;}if(isset($l["field"]))$gd=$Qd;$Qd++;}}elseif($_POST["down"]){$vc=false;foreach($m +as$y=>$l){if(isset($l["field"])&&$vc){unset($m[key($_POST["down"])]);array_splice($m,$Qd,0,array($vc));break;}if(key($_POST["down"])==$y)$vc=$l;$Qd++;}}elseif($_POST["add"]){$m=array_values($m);array_splice($m,key($_POST["add"]),0,array(array()));}elseif(!$_POST["drop_col"])return false;return true;}function normalize_enum($B){return"'".str_replace("'","''",addcslashes(stripcslashes(str_replace($B[0][0].$B[0][0],$B[0][0],substr($B[0],1,-1))),'\\'))."'";}function grant($q,$Me,$d,$Wd){if(!$Me)return true;if($Me==array("ALL PRIVILEGES","GRANT OPTION"))return($q=="GRANT"?queries("$q ALL PRIVILEGES$Wd WITH GRANT OPTION"):queries("$q ALL PRIVILEGES$Wd")&&queries("$q GRANT OPTION$Wd"));return queries("$q ".preg_replace('~(GRANT OPTION)\\([^)]*\\)~','\\1',implode("$d, ",$Me).$d).$Wd);}function -drop_create($Gb,$kb,$Hb,$Yf,$Ib,$A,$Cd,$Ad,$Bd,$Td,$Kd){if($_POST["drop"])query_redirect($Gb,$A,$Cd);elseif($Td=="")query_redirect($kb,$A,$Bd);elseif($Td!=$Kd){$mb=queries($kb);queries_redirect($A,$Ad,$mb&&queries($Gb));if($mb)queries($Hb);}else -queries_redirect($A,$Ad,queries($Yf)&&queries($Ib)&&queries($Gb)&&queries($kb));}function +drop_create($Fb,$g,$Gb,$Yf,$Hb,$A,$Cd,$Ad,$Bd,$Td,$Kd){if($_POST["drop"])query_redirect($Fb,$A,$Cd);elseif($Td=="")query_redirect($g,$A,$Bd);elseif($Td!=$Kd){$lb=queries($g);queries_redirect($A,$Ad,$lb&&queries($Fb));if($lb)queries($Gb);}else +queries_redirect($A,$Ad,queries($Yf)&&queries($Hb)&&queries($Fb)&&queries($g));}function create_trigger($Wd,$L){global$x;$dg=" $L[Timing] $L[Event]".($L["Event"]=="UPDATE OF"?" ".idf_escape($L["Of"]):"");return"CREATE TRIGGER ".idf_escape($L["Trigger"]).($x=="mssql"?$Wd.$dg:$dg.$Wd).rtrim(" $L[Type]\n$L[Statement]",";").";";}function -create_routine($jf,$L){global$Pc;$P=array();$l=(array)$L["fields"];ksort($l);foreach($l -as$k){if($k["field"]!="")$P[]=(preg_match("~^($Pc)\$~",$k["inout"])?"$k[inout] ":"").idf_escape($k["field"]).process_type($k,"CHARACTER SET");}return"CREATE $jf ".idf_escape(trim($L["name"]))." (".implode(", ",$P).")".(isset($_GET["function"])?" RETURNS".process_type($L["returns"],"CHARACTER SET"):"").($L["language"]?" LANGUAGE $L[language]":"").rtrim("\n$L[definition]",";").";";}function +create_routine($jf,$L){global$Pc;$P=array();$m=(array)$L["fields"];ksort($m);foreach($m +as$l){if($l["field"]!="")$P[]=(preg_match("~^($Pc)\$~",$l["inout"])?"$l[inout] ":"").idf_escape($l["field"]).process_type($l,"CHARACTER SET");}return"CREATE $jf ".idf_escape(trim($L["name"]))." (".implode(", ",$P).")".(isset($_GET["function"])?" RETURNS".process_type($L["returns"],"CHARACTER SET"):"").($L["language"]?" LANGUAGE $L[language]":"").rtrim("\n$L[definition]",";").";";}function remove_definer($I){return preg_replace('~^([A-Z =]+) DEFINER=`'.preg_replace('~@(.*)~','`@`(%|\\1)',logged_user()).'`~','\\1',$I);}function -format_foreign_key($m){global$Xd;return" FOREIGN KEY (".implode(", ",array_map('idf_escape',$m["source"])).") REFERENCES ".table($m["table"])." (".implode(", ",array_map('idf_escape',$m["target"])).")".(preg_match("~^($Xd)\$~",$m["on_delete"])?" ON DELETE $m[on_delete]":"").(preg_match("~^($Xd)\$~",$m["on_update"])?" ON UPDATE $m[on_update]":"");}function -tar_file($oc,$ig){$K=pack("a100a8a8a8a12a12",$oc,644,0,0,decoct($ig->size),decoct(time()));$Pa=8*32;for($s=0;$ssend();echo +format_foreign_key($n){global$Xd;return" FOREIGN KEY (".implode(", ",array_map('idf_escape',$n["source"])).") REFERENCES ".table($n["table"])." (".implode(", ",array_map('idf_escape',$n["target"])).")".(preg_match("~^($Xd)\$~",$n["on_delete"])?" ON DELETE $n[on_delete]":"").(preg_match("~^($Xd)\$~",$n["on_update"])?" ON UPDATE $n[on_update]":"");}function +tar_file($nc,$ig){$K=pack("a100a8a8a8a12a12",$nc,644,0,0,decoct($ig->size),decoct(time()));$Pa=8*32;for($s=0;$ssend();echo str_repeat("\0",511-($ig->size+511)%512);}function ini_bytes($Oc){$X=ini_get($Oc);switch(strtolower(substr($X,-1))){case'g':$X*=1024;case'm':$X*=1024;case'k':$X*=1024;}return$X;}function doc_link($ye){global$x,$e;$Cg=array('sql'=>"http://dev.mysql.com/doc/refman/".substr($e->server_info,0,3)."/en/",'sqlite'=>"http://www.sqlite.org/",'pgsql'=>"http://www.postgresql.org/docs/".substr($e->server_info,0,3)."/static/",'mssql'=>"http://msdn.microsoft.com/library/",'oracle'=>"http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/",);return($ye[$x]?"?":"");}function ob_gzencode($Gf){return gzencode($Gf);}function -db_size($h){global$e;if(!$e->select_db($h))return"?";$K=0;foreach(table_status()as$R)$K+=$R["Data_length"]+$R["Index_length"];return +db_size($i){global$e;if(!$e->select_db($i))return"?";$K=0;foreach(table_status()as$R)$K+=$R["Data_length"]+$R["Index_length"];return format_number($K);}function -connect_error(){global$b,$e,$T,$j,$Fb;if(DB!=""){header("HTTP/1.1 404 Not Found");page_header('Database'.": ".h(DB),'Invalid database.',true);}else{if($_POST["db"]&&!$j)queries_redirect(substr(ME,0,-1),'Databases have been dropped.',drop_databases($_POST["db"]));page_header('Select database',$j,false);echo"

".sprintf('%s version: %s through PHP extension %s',$Fb[DRIVER],"".h($e->server_info)."","$e->extension")."\n","

".sprintf('Logged as: %s',"".h(logged_user())."")."\n";$g=$b->databases();if($g){$pf=support("scheme");$Xa=collations();echo"

\n","\n","".(support("database")?"\n";$g=($_GET["dbsize"]?count_tables($g):array_flip($g));foreach($g -as$h=>$S){$if=h(ME)."db=".urlencode($h);echo"".(support("database")?"
 ":"")."".'Database'." - ".'Refresh'.""."".'Collation'."".'Tables'."".'Size'." - ".'Compute'.""."
".checkbox("db[]",$h,in_array($h,(array)$_POST["db"])):""),"".h($h)."";$Wa=nbsp(db_collation($h,$Xa));echo"".(support("database")?"$Wa":$Wa),"".($_GET["dbsize"]?$S:"?")."","".($_GET["dbsize"]?db_size($h):"?"),"\n";}echo"
\n",(support("database")?"
".'Selected'."
\n"."\n"."\n"."
\n":""),"\n","\n","
\n";}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$e->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;}$Xd="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class +set_utf8mb4($g){global$e;static$P=false;if(!$P&&preg_match('~\butf8mb4~i',$g)){$P=true;echo"SET NAMES ".charset($e).";\n\n";}}function +connect_error(){global$b,$e,$T,$k,$Eb;if(DB!=""){header("HTTP/1.1 404 Not Found");page_header('Database'.": ".h(DB),'Invalid database.',true);}else{if($_POST["db"]&&!$k)queries_redirect(substr(ME,0,-1),'Databases have been dropped.',drop_databases($_POST["db"]));page_header('Select database',$k,false);echo"

".sprintf('%s version: %s through PHP extension %s',$Eb[DRIVER],"".h($e->server_info)."","$e->extension")."\n","

".sprintf('Logged as: %s',"".h(logged_user())."")."\n";$h=$b->databases();if($h){$pf=support("scheme");$Xa=collations();echo"

\n","\n","".(support("database")?"\n";$h=($_GET["dbsize"]?count_tables($h):array_flip($h));foreach($h +as$i=>$S){$if=h(ME)."db=".urlencode($i);echo"".(support("database")?"
 ":"")."".'Database'." - ".'Refresh'.""."".'Collation'."".'Tables'."".'Size'." - ".'Compute'.""."
".checkbox("db[]",$i,in_array($i,(array)$_POST["db"])):""),"".h($i)."";$Wa=nbsp(db_collation($i,$Xa));echo"".(support("database")?"$Wa":$Wa),"".($_GET["dbsize"]?$S:"?")."","".($_GET["dbsize"]?db_size($i):"?"),"\n";}echo"
\n",(support("database")?"
".'Selected'."
\n"."\n"."\n"."
\n":""),"\n","\n","
\n";}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$e->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;}$Xd="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class TmpFile{var$handler;var$size;function TmpFile(){$this->handler=tmpfile();}function write($gb){$this->size+=strlen($gb);fwrite($this->handler,$gb);}function -send(){fseek($this->handler,0);fpassthru($this->handler);fclose($this->handler);}}$Wb="'(?:''|[^'\\\\]|\\\\.)*'";$Pc="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"];$l=fields($a);header("Content-Type: application/octet-stream");header("Content-Disposition: attachment; filename=".friendly_url("$a-".implode("_",$_GET["where"])).".".friendly_url($_GET["field"]));$N=array(idf_escape($_GET["field"]));$J=$i->select($a,$N,array(where($_GET,$l)),$N);$L=($J?$J->fetch_row():array());echo$L[0];exit;}elseif(isset($_GET["table"])){$a=$_GET["table"];$l=fields($a);if(!$l)$j=error();$R=table_status1($a,true);page_header(($l&&is_view($R)?'View':'Table').": ".h($a),$j);$b->selectLinks($R);$bb=$R["Comment"];if($bb!="")echo"

".'Comment'.": ".h($bb)."\n";if($l){echo"\n","\n";foreach($l -as$k){echo"
".'Column'."".'Type'.(support("comment")?"".'Comment':"")."
".h($k["field"]),"".h($k["full_type"])."",($k["null"]?" NULL":""),($k["auto_increment"]?" ".'Auto Increment'."":""),(isset($k["default"])?" [".h($k["default"])."]":""),(support("comment")?"".nbsp($k["comment"]):""),"\n";}echo"
\n";}if(!is_view($R)){if(support("indexes")){echo"

".'Indexes'."

\n";$v=indexes($a);if($v){echo"\n";foreach($v -as$E=>$u){ksort($u["columns"]);$Je=array();foreach($u["columns"]as$y=>$X)$Je[]="".h($X)."".($u["lengths"][$y]?"(".$u["lengths"][$y].")":"").($u["descs"][$y]?" DESC":"");echo"
$u[type]".implode(", ",$Je)."\n";}echo"
\n";}echo'

".'Foreign keys'."

\n";$n=foreign_keys($a);if($n){echo"\n","\n";foreach($n -as$E=>$m){echo"","
".'Source'."".'Target'."".'ON DELETE'."".'ON UPDATE'." 
".implode(", ",array_map('h',$m["source"]))."","".($m["db"]!=""?"".h($m["db"]).".":"").($m["ns"]!=""?"".h($m["ns"]).".":"").h($m["table"])."","(".implode(", ",array_map('h',$m["target"])).")","".nbsp($m["on_delete"])."\n","".nbsp($m["on_update"])."\n",''.'Alter'.'';}echo"
\n";}echo'

".'Triggers'."

\n";$qg=triggers($a);if($qg){echo"\n";foreach($qg +send(){fseek($this->handler,0);fpassthru($this->handler);fclose($this->handler);}}$Vb="'(?:''|[^'\\\\]|\\\\.)*'";$Pc="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"];$m=fields($a);header("Content-Type: application/octet-stream");header("Content-Disposition: attachment; filename=".friendly_url("$a-".implode("_",$_GET["where"])).".".friendly_url($_GET["field"]));$N=array(idf_escape($_GET["field"]));$J=$j->select($a,$N,array(where($_GET,$m)),$N);$L=($J?$J->fetch_row():array());echo$L[0];exit;}elseif(isset($_GET["table"])){$a=$_GET["table"];$m=fields($a);if(!$m)$k=error();$R=table_status1($a,true);page_header(($m&&is_view($R)?'View':'Table').": ".h($a),$k);$b->selectLinks($R);$bb=$R["Comment"];if($bb!="")echo"

".'Comment'.": ".h($bb)."\n";if($m){echo"

\n","\n";foreach($m +as$l){echo"
".'Column'."".'Type'.(support("comment")?"".'Comment':"")."
".h($l["field"]),"".h($l["full_type"])."",($l["null"]?" NULL":""),($l["auto_increment"]?" ".'Auto Increment'."":""),(isset($l["default"])?" [".h($l["default"])."]":""),(support("comment")?"".nbsp($l["comment"]):""),"\n";}echo"
\n";}if(!is_view($R)){if(support("indexes")){echo"

".'Indexes'."

\n";$v=indexes($a);if($v){echo"\n";foreach($v +as$E=>$u){ksort($u["columns"]);$Je=array();foreach($u["columns"]as$y=>$X)$Je[]="".h($X)."".($u["lengths"][$y]?"(".$u["lengths"][$y].")":"").($u["descs"][$y]?" DESC":"");echo"
$u[type]".implode(", ",$Je)."\n";}echo"
\n";}echo'

".'Foreign keys'."

\n";$tc=foreign_keys($a);if($tc){echo"\n","\n";foreach($tc +as$E=>$n){echo"","
".'Source'."".'Target'."".'ON DELETE'."".'ON UPDATE'." 
".implode(", ",array_map('h',$n["source"]))."","".($n["db"]!=""?"".h($n["db"]).".":"").($n["ns"]!=""?"".h($n["ns"]).".":"").h($n["table"])."","(".implode(", ",array_map('h',$n["target"])).")","".nbsp($n["on_delete"])."\n","".nbsp($n["on_update"])."\n",''.'Alter'.'';}echo"
\n";}echo'

".'Triggers'."

\n";$qg=triggers($a);if($qg){echo"\n";foreach($qg as$y=>$X)echo"
".h($X[0])."".h($X[1])."".h($y)."".'Alter'."\n";echo"
\n";}echo'
+as$s=>$B){$Qf[$B[1]]=array($B[2],$B[3]);$Rf[]="\n\t'".js_escape($B[1])."': [ $B[2], $B[3] ]";}$kg=0;$Ca=-1;$of=array();$Ze=array();$kd=array();foreach(table_status('',true)as$Q=>$R){if(is_view($R))continue;$Ce=0;$of[$Q]["fields"]=array();foreach(fields($Q)as$E=>$l){$Ce+=1.25;$l["pos"]=$Ce;$of[$Q]["fields"][$E]=$l;}$of[$Q]["pos"]=($Qf[$Q]?$Qf[$Q]:array($kg,0));foreach($b->foreignKeys($Q)as$X){if(!$X["db"]){$id=$Ca;if($Qf[$Q][1]||$Qf[$X["table"]][1])$id=min(floatval($Qf[$Q][1]),floatval($Qf[$X["table"]][1]))-1;else$Ca-=.1;while($kd[(string)$id])$id-=.0001;$of[$Q]["references"][$X["table"]][(string)$id]=array($X["source"],$X["target"]);$Ze[$X["table"]][$Q][(string)$id]=$X["target"];$kd[(string)$id]=true;}}$kg=max($kg,$of[$Q]["pos"][0]+2.5+$Ce);}echo'
';foreach($of -as$E=>$Q){echo"
",''.h($E)."";foreach($Q["fields"]as$k){$X=''.h($k["field"]).'';echo"
".($k["primary"]?"$X":$X);}foreach((array)$Q["references"]as$Wf=>$af){foreach($af +as$E=>$Q){echo"
",''.h($E)."";foreach($Q["fields"]as$l){$X=''.h($l["field"]).'';echo"
".($l["primary"]?"$X":$X);}foreach((array)$Q["references"]as$Wf=>$af){foreach($af as$id=>$We){$jd=$id-$Qf[$E][1];$s=0;foreach($We[0]as$_f)echo"\n
";}}foreach((array)$Ze[$E]as$Wf=>$af){foreach($af as$id=>$d){$jd=$id-$Qf[$E][1];$s=0;foreach($d -as$Vf)echo"\n
";}}echo"\n
\n";}foreach($of +as$Vf)echo"\n
";}}echo"\n
\n";}foreach($of as$E=>$Q){foreach((array)$Q["references"]as$Wf=>$af){foreach($af as$id=>$We){$Ed=$kg;$xd=-10;foreach($We[0]as$y=>$_f){$De=$Q["pos"][0]+$Q["fields"][$_f]["pos"];$Ee=$of[$Wf]["pos"][0]+$of[$Wf]["fields"][$We[1][$y]]["pos"];$Ed=min($Ed,$De,$Ee);$xd=max($xd,$De,$Ee);}echo"
\n";}}}echo'
-';$tb=array('','USE','DROP+CREATE','CREATE');$Sf=array('','DROP+CREATE','CREATE');$qb=array('','TRUNCATE+INSERT','INSERT');if($x=="sql")$qb[]='INSERT+UPDATE';parse_str($_COOKIE["adminer_export"],$L);if(!$L)$L=array("output"=>"text","format"=>"sql","db_style"=>(DB!=""?"":"CREATE"),"table_style"=>"DROP+CREATE","data_style"=>"INSERT");if(!isset($L["events"])){$L["routines"]=$L["events"]=($_GET["dump"]=="");$L["triggers"]=$L["table_style"];}echo"
".'Output'."".html_select("output",$b->dumpOutput(),$L["output"],0)."\n";echo"
".'Format'."".html_select("format",$b->dumpFormat(),$L["format"],0)."\n";echo($x=="sqlite"?"":"
".'Database'."".html_select('db_style',$tb,$L["db_style"]).(support("routine")?checkbox("routines",1,$L["routines"],'Routines'):"").(support("event")?checkbox("events",1,$L["events"],'Events'):"")),"
".'Tables'."".html_select('table_style',$Sf,$L["table_style"]).checkbox("auto_increment",1,$L["auto_increment"],'Auto Increment').(support("trigger")?checkbox("triggers",1,$L["triggers"],'Triggers'):""),"
".'Data'."".html_select('data_style',$qb,$L["data_style"]),'
+';$sb=array('','USE','DROP+CREATE','CREATE');$Sf=array('','DROP+CREATE','CREATE');$pb=array('','TRUNCATE+INSERT','INSERT');if($x=="sql")$pb[]='INSERT+UPDATE';parse_str($_COOKIE["adminer_export"],$L);if(!$L)$L=array("output"=>"text","format"=>"sql","db_style"=>(DB!=""?"":"CREATE"),"table_style"=>"DROP+CREATE","data_style"=>"INSERT");if(!isset($L["events"])){$L["routines"]=$L["events"]=($_GET["dump"]=="");$L["triggers"]=$L["table_style"];}echo"
".'Output'."".html_select("output",$b->dumpOutput(),$L["output"],0)."\n";echo"
".'Format'."".html_select("format",$b->dumpFormat(),$L["format"],0)."\n";echo($x=="sqlite"?"":"
".'Database'."".html_select('db_style',$sb,$L["db_style"]).(support("routine")?checkbox("routines",1,$L["routines"],'Routines'):"").(support("event")?checkbox("events",1,$L["events"],'Events'):"")),"
".'Tables'."".html_select('table_style',$Sf,$L["table_style"]).checkbox("auto_increment",1,$L["auto_increment"],'Auto Increment').(support("trigger")?checkbox("triggers",1,$L["triggers"],'Triggers'):""),"
".'Data'."".html_select('data_style',$pb,$L["data_style"]),'

';$He=array();if(DB!=""){$Na=($a!=""?"":" checked");echo"","\n";$Lg="";$Tf=tables_list();foreach($Tf as$E=>$U){$Ge=preg_replace('~_.*~','',$E);$Na=($a==""||$a==(substr($a,-1)=="%"?"$Ge%":$E));$Je="\n";$g=$b->databases();if($g){foreach($g -as$h){if(!information_schema($h)){$Ge=preg_replace('~_.*~','',$h);echo"\n";$h=$b->databases();if($h){foreach($h +as$i){if(!information_schema($i)){$Ge=preg_replace('~_.*~','',$i);echo"
","","
".checkbox("tables[]",$E,$Na,$E,"checkboxClick(event, this); formUncheck('check-tables');","block");if($U!==null&&!preg_match('~table~i',$U))$Lg.="$Je\n";else -echo"$Je\n";$He[$Ge]++;}echo$Lg;if($Tf)echo"\n";}else{echo"
".checkbox("databases[]",$h,$a==""||$a=="$Ge%",$h,"formUncheck('check-databases');","block")."\n";$He[$Ge]++;}}}else +echo"$Je\n";$He[$Ge]++;}echo$Lg;if($Tf)echo"\n";}else{echo"
".checkbox("databases[]",$i,$a==""||$a=="$Ge%",$i,"formUncheck('check-databases');","block")."\n";$He[$Ge]++;}}}else echo"
";}echo'
-';$qc=true;foreach($He -as$y=>$X){if($y!=""&&$X>1){echo($qc?"

":" ")."".h($y)."";$qc=false;}}}elseif(isset($_GET["privileges"])){page_header('Privileges');$J=$e->query("SELECT User, Host FROM mysql.".(DB==""?"user":"db WHERE ".q(DB)." LIKE Db")." ORDER BY Host, User");$q=$J;if(!$J)$J=$e->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");echo"

\n";hidden_fields_get();echo"\n",($q?"":"\n"),"\n","\n";while($L=$J->fetch_assoc())echo'
".'Username'."".'Server'." 
'.h($L["User"])."".h($L["Host"]).''.'Edit'."\n";if(!$q||DB!="")echo"\n";echo"
\n","

\n",'
".shorten_utf8(trim($H),1000)."
\n";if(!$_POST["only_errors"]){echo$Je;ob_flush();flush();}$Cf=microtime(true);if($e->multi_query($H)&&is_object($f)&&preg_match("~^$Af*USE\\b~isU",$H))$f->query($H);do{$J=$e->store_result();$bg=" (".format_time($Cf).")".(strlen($H)<1000?" ".'Edit'."":"");if($e->error){echo($_POST["only_errors"]?$Je:""),"

".'Error in query'.($e->errno?" ($e->errno)":"").": ".error()."\n";$Yb[]=" $ab";if($_POST["error_stops"])break -2;}elseif(is_object($J)){$z=$_POST["limit"];$ie=select($J,$f,array(),$z);if(!$_POST["only_errors"]){echo"

\n";$Nd=$J->num_rows;echo"

".($Nd?($z&&$Nd>$z?sprintf('%d / ',$z):"").lang(array('%d row','%d rows'),$Nd):""),$bg;$t="export-$ab";$gc=", ".'Export'."\n";if($f&&preg_match("~^($Af|\\()*SELECT\\b~isU",$H)&&($fc=explain($f,$H))){$t="explain-$ab";echo", EXPLAIN$gc","

\n";}else -echo$gc;echo"
\n";}}else{if(preg_match("~^$Af*(CREATE|DROP|ALTER)$Af+(DATABASE|SCHEMA)\\b~isU",$H)){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.'),$e->affected_rows)."$bg\n";}$Cf=microtime(true);}while($e->next_result());$pd+=substr_count($H.$vc,"\n");$I=substr($I,$Qd);$Qd=0;}}}}if($Tb)echo"

".'No commands to execute.'."\n";elseif($_POST["only_errors"]){echo"

".lang(array('%d query executed OK.','%d queries executed OK.'),$ab-count($Yb))," (".format_time($lg).")\n";}elseif($Yb&&$ab>1)echo"

".'Error in query'.": ".implode("",$Yb)."\n";}else +';$pc=true;foreach($He +as$y=>$X){if($y!=""&&$X>1){echo($pc?"

":" ")."".h($y)."";$pc=false;}}}elseif(isset($_GET["privileges"])){page_header('Privileges');$J=$e->query("SELECT User, Host FROM mysql.".(DB==""?"user":"db WHERE ".q(DB)." LIKE Db")." ORDER BY Host, User");$q=$J;if(!$J)$J=$e->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");echo"

\n";hidden_fields_get();echo"\n",($q?"":"\n"),"\n","\n";while($L=$J->fetch_assoc())echo'
".'Username'."".'Server'." 
'.h($L["User"])."".h($L["Host"]).''.'Edit'."\n";if(!$q||DB!="")echo"\n";echo"
\n","

\n",'
".shorten_utf8(trim($H),1000)."
\n";if(!$_POST["only_errors"]){echo$Je;ob_flush();flush();}$Cf=microtime(true);if($e->multi_query($H)&&is_object($f)&&preg_match("~^$Af*USE\\b~isU",$H))$f->query($H);do{$J=$e->store_result();$bg=" (".format_time($Cf).")".(strlen($H)<1000?" ".'Edit'."":"");if($e->error){echo($_POST["only_errors"]?$Je:""),"

".'Error in query'.($e->errno?" ($e->errno)":"").": ".error()."\n";$Xb[]=" $ab";if($_POST["error_stops"])break +2;}elseif(is_object($J)){$z=$_POST["limit"];$ie=select($J,$f,array(),$z);if(!$_POST["only_errors"]){echo"

\n";$Nd=$J->num_rows;echo"

".($Nd?($z&&$Nd>$z?sprintf('%d / ',$z):"").lang(array('%d row','%d rows'),$Nd):""),$bg;$t="export-$ab";$fc=", ".'Export'."\n";if($f&&preg_match("~^($Af|\\()*SELECT\\b~isU",$H)&&($ec=explain($f,$H))){$t="explain-$ab";echo", EXPLAIN$fc","

\n";}else +echo$fc;echo"
\n";}}else{if(preg_match("~^$Af*(CREATE|DROP|ALTER)$Af+(DATABASE|SCHEMA)\\b~isU",$H)){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.'),$e->affected_rows)."$bg\n";}$Cf=microtime(true);}while($e->next_result());$pd+=substr_count($H.$vc,"\n");$I=substr($I,$Qd);$Qd=0;}}}}if($Sb)echo"

".'No commands to execute.'."\n";elseif($_POST["only_errors"]){echo"

".lang(array('%d query executed OK.','%d queries executed OK.'),$ab-count($Xb))," (".format_time($lg).")\n";}elseif($Xb&&$ab>1)echo"

".'Error in query'.": ".implode("",$Xb)."\n";}else echo"

".upload_error($I)."\n";}echo'

-';$dc="";if(!isset($_GET["import"])){$H=$_GET["sql"];if($_POST)$H=$_POST["query"];elseif($_GET["history"]=="all")$H=$Fc;elseif($_GET["history"]!="")$H=$Fc[$_GET["history"]][0];echo"

";textarea("query",$H,20);echo($_POST?"":"\n"),"

$dc\n",'Limit rows'.": \n";}else{echo"

".'File upload'."
",(ini_bool("file_uploads")?"SQL (< ".ini_get("upload_max_filesize")."B): \n$dc":'File uploads are disabled.'),"
\n","
".'From server'."
",sprintf('Webserver file %s',"adminer.sql".(extension_loaded("zlib")?"[.gz]":"").""),' ',"
\n","

";}echo -checkbox("error_stops",1,($_POST?$_POST["error_stops"]:isset($_GET["import"])),'Stop on error')."\n",checkbox("only_errors",1,($_POST?$_POST["only_errors"]:isset($_GET["import"])),'Show only errors')."\n","\n";if(!isset($_GET["import"])&&$Fc){print_fieldset("history",'History',$_GET["history"]!="");for($X=end($Fc);$X;$X=prev($Fc)){$y=key($Fc);list($H,$bg,$Ob)=$X;echo''.'Edit'.""." ".@date("H:i:s",$bg).""." ".shorten_utf8(ltrim(str_replace("\n"," ",str_replace("\r","",preg_replace('~^(#|-- ).*~m','',$H)))),80,"").($Ob?" ($Ob)":"")."
\n";}echo"\n","".'Edit all'."\n","\n";}echo'

-';}elseif(isset($_GET["edit"])){$a=$_GET["edit"];$l=fields($a);$Z=(isset($_GET["select"])?(count($_POST["check"])==1?where_check($_POST["check"][0],$l):""):where($_GET,$l));$Ag=(isset($_GET["select"])?$_POST["edit"]:$Z);foreach($l -as$E=>$k){if(!isset($k["privileges"][$Ag?"update":"insert"])||$b->fieldName($k)=="")unset($l[$E]);}if($_POST&&!$j&&!isset($_GET["select"])){$A=$_POST["referer"];if($_POST["insert"])$A=($Ag?null:$_SERVER["REQUEST_URI"]);elseif(!preg_match('~^.+&select=.+$~',$A))$A=ME."select=".urlencode($a);$v=indexes($a);$wg=unique_array($_GET["where"],$v);$Se="\nWHERE $Z";if(isset($_POST["delete"]))queries_redirect($A,'Item has been deleted.',$i->delete($a,$Se,!$wg));else{$P=array();foreach($l -as$E=>$k){$X=process_input($k);if($X!==false&&$X!==null)$P[idf_escape($E)]=$X;}if($Ag){if(!$P)redirect($A);queries_redirect($A,'Item has been updated.',$i->update($a,$P,$Se,!$wg));if(is_ajax()){page_headers();page_messages($j);exit;}}else{$J=$i->insert($a,$P);$hd=($J?last_id():0);queries_redirect($A,sprintf('Item%s has been inserted.',($hd?" $hd":"")),$J);}}}$L=null;if($_POST["save"])$L=(array)$_POST["fields"];elseif($Z){$N=array();foreach($l -as$E=>$k){if(isset($k["privileges"]["select"])){$ua=convert_field($k);if($_POST["clone"]&&$k["auto_increment"])$ua="''";if($x=="sql"&&preg_match("~enum|set~",$k["type"]))$ua="1*".idf_escape($E);$N[]=($ua?"$ua AS ":"").idf_escape($E);}}$L=array();if(!support("table"))$N=array("*");if($N){$J=$i->select($a,$N,array($Z),$N,array(),(isset($_GET["select"])?2:1));$L=$J->fetch_assoc();if(!$L)$L=false;if(isset($_GET["select"])&&(!$L||$J->fetch_assoc()))$L=null;}}if(!support("table")&&!$l){if(!$Z){$J=$i->select($a,array("*"),$Z,array("*"));$L=($J?$J->fetch_assoc():false);if(!$L)$L=array($i->primary=>"");}if($L){foreach($L -as$y=>$X){if(!$Z)$L[$y]=null;$l[$y]=array("field"=>$y,"null"=>($y!=$i->primary),"auto_increment"=>($y==$i->primary));}}}edit_form($a,$l,$L,$Ag);}elseif(isset($_GET["create"])){$a=$_GET["create"];$te=array();foreach(array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST')as$y)$te[$y]=$y;$Ye=referencable_primary($a);$n=array();foreach($Ye -as$Pf=>$k)$n[str_replace("`","``",$Pf)."`".str_replace("`","``",$k["field"])]=$Pf;$le=array();$R=array();if($a!=""){$le=fields($a);$R=table_status($a);if(!$R)$j='No tables.';}$L=$_POST;$L["fields"]=(array)$L["fields"];if($L["auto_increment_col"])$L["fields"][$L["auto_increment_col"]]["auto_increment"]=true;if($_POST&&!process_fields($L["fields"])&&!$j){if($_POST["drop"])queries_redirect(substr(ME,0,-1),'Table has been dropped.',drop_tables(array($a)));else{$l=array();$ra=array();$Dg=false;$sc=array();ksort($L["fields"]);$ke=reset($le);$pa=" FIRST";foreach($L["fields"]as$y=>$k){$m=$n[$k["type"]];$rg=($m!==null?$Ye[$m]:$k);if($k["field"]!=""){if(!$k["has_default"])$k["default"]=null;if($y==$L["auto_increment_col"])$k["auto_increment"]=true;$Oe=process_field($k,$rg);$ra[]=array($k["orig"],$Oe,$pa);if($Oe!=process_field($ke,$ke)){$l[]=array($k["orig"],$Oe,$pa);if($k["orig"]!=""||$pa)$Dg=true;}if($m!==null)$sc[idf_escape($k["field"])]=($a!=""&&$x!="sqlite"?"ADD":" ").format_foreign_key(array('table'=>$n[$k["type"]],'source'=>array($k["field"]),'target'=>array($rg["field"]),'on_delete'=>$k["on_delete"],));$pa=" AFTER ".idf_escape($k["field"]);}elseif($k["orig"]!=""){$Dg=true;$l[]=array($k["orig"]);}if($k["orig"]!=""){$ke=next($le);if(!$ke)$pa="";}}$ve="";if($te[$L["partition_by"]]){$we=array();if($L["partition_by"]=='RANGE'||$L["partition_by"]=='LIST'){foreach(array_filter($L["partition_names"])as$y=>$X){$Y=$L["partition_values"][$y];$we[]="\n PARTITION ".idf_escape($X)." VALUES ".($L["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$ve.="\nPARTITION BY $L[partition_by]($L[partition])".($we?" (".implode(",",$we)."\n)":($L["partitions"]?" PARTITIONS ".(+$L["partitions"]):""));}elseif(support("partitioning")&&preg_match("~partitioned~",$R["Create_options"]))$ve.="\nREMOVE PARTITIONING";$C='Table has been altered.';if($a==""){cookie("adminer_engine",$L["Engine"]);$C='Table has been created.';}$E=trim($L["name"]);queries_redirect(ME.(support("table")?"table=":"select=").urlencode($E),$C,alter_table($a,$E,($x=="sqlite"&&($Dg||$sc)?$ra:$l),$sc,($L["Comment"]!=$R["Comment"]?$L["Comment"]:null),($L["Engine"]&&$L["Engine"]!=$R["Engine"]?$L["Engine"]:""),($L["Collation"]&&$L["Collation"]!=$R["Collation"]?$L["Collation"]:""),($L["Auto_increment"]!=""?number($L["Auto_increment"]):""),$ve));}}page_header(($a!=""?'Alter table':'Create table'),$j,array("table"=>$a),h($a));if(!$_POST){$L=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($tg["int"])?"int":(isset($tg["integer"])?"integer":"")))),"partition_names"=>array(""),);if($a!=""){$L=$R;$L["name"]=$a;$L["fields"]=array();if(!$_GET["auto_increment"])$L["Auto_increment"]="";foreach($le -as$k){$k["has_default"]=isset($k["default"]);$L["fields"][]=$k;}if(support("partitioning")){$xc="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($a);$J=$e->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $xc ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($L["partition_by"],$L["partitions"],$L["partition"])=$J->fetch_row();$we=get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $xc AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");$we[""]="";$L["partition_names"]=array_keys($we);$L["partition_values"]=array_values($we);}}}$Xa=collations();$Vb=engines();foreach($Vb -as$Ub){if(!strcasecmp($Ub,$L["Engine"])){$L["Engine"]=$Ub;break;}}echo' +';$cc="";if(!isset($_GET["import"])){$H=$_GET["sql"];if($_POST)$H=$_POST["query"];elseif($_GET["history"]=="all")$H=$Fc;elseif($_GET["history"]!="")$H=$Fc[$_GET["history"]][0];echo"

";textarea("query",$H,20);echo($_POST?"":"\n"),"

$cc\n",'Limit rows'.": \n";}else{echo"

".'File upload'."
",(ini_bool("file_uploads")?"SQL (< ".ini_get("upload_max_filesize")."B): \n$cc":'File uploads are disabled.'),"
\n","
".'From server'."
",sprintf('Webserver file %s',"adminer.sql".(extension_loaded("zlib")?"[.gz]":"").""),' ',"
\n","

";}echo +checkbox("error_stops",1,($_POST?$_POST["error_stops"]:isset($_GET["import"])),'Stop on error')."\n",checkbox("only_errors",1,($_POST?$_POST["only_errors"]:isset($_GET["import"])),'Show only errors')."\n","\n";if(!isset($_GET["import"])&&$Fc){print_fieldset("history",'History',$_GET["history"]!="");for($X=end($Fc);$X;$X=prev($Fc)){$y=key($Fc);list($H,$bg,$Nb)=$X;echo''.'Edit'.""." ".@date("H:i:s",$bg).""." ".shorten_utf8(ltrim(str_replace("\n"," ",str_replace("\r","",preg_replace('~^(#|-- ).*~m','',$H)))),80,"").($Nb?" ($Nb)":"")."
\n";}echo"\n","".'Edit all'."\n","\n";}echo' +';}elseif(isset($_GET["edit"])){$a=$_GET["edit"];$m=fields($a);$Z=(isset($_GET["select"])?(count($_POST["check"])==1?where_check($_POST["check"][0],$m):""):where($_GET,$m));$Ag=(isset($_GET["select"])?$_POST["edit"]:$Z);foreach($m +as$E=>$l){if(!isset($l["privileges"][$Ag?"update":"insert"])||$b->fieldName($l)=="")unset($m[$E]);}if($_POST&&!$k&&!isset($_GET["select"])){$A=$_POST["referer"];if($_POST["insert"])$A=($Ag?null:$_SERVER["REQUEST_URI"]);elseif(!preg_match('~^.+&select=.+$~',$A))$A=ME."select=".urlencode($a);$v=indexes($a);$wg=unique_array($_GET["where"],$v);$Se="\nWHERE $Z";if(isset($_POST["delete"]))queries_redirect($A,'Item has been deleted.',$j->delete($a,$Se,!$wg));else{$P=array();foreach($m +as$E=>$l){$X=process_input($l);if($X!==false&&$X!==null)$P[idf_escape($E)]=$X;}if($Ag){if(!$P)redirect($A);queries_redirect($A,'Item has been updated.',$j->update($a,$P,$Se,!$wg));if(is_ajax()){page_headers();page_messages($k);exit;}}else{$J=$j->insert($a,$P);$hd=($J?last_id():0);queries_redirect($A,sprintf('Item%s has been inserted.',($hd?" $hd":"")),$J);}}}$L=null;if($_POST["save"])$L=(array)$_POST["fields"];elseif($Z){$N=array();foreach($m +as$E=>$l){if(isset($l["privileges"]["select"])){$ua=convert_field($l);if($_POST["clone"]&&$l["auto_increment"])$ua="''";if($x=="sql"&&preg_match("~enum|set~",$l["type"]))$ua="1*".idf_escape($E);$N[]=($ua?"$ua AS ":"").idf_escape($E);}}$L=array();if(!support("table"))$N=array("*");if($N){$J=$j->select($a,$N,array($Z),$N,array(),(isset($_GET["select"])?2:1));$L=$J->fetch_assoc();if(!$L)$L=false;if(isset($_GET["select"])&&(!$L||$J->fetch_assoc()))$L=null;}}if(!support("table")&&!$m){if(!$Z){$J=$j->select($a,array("*"),$Z,array("*"));$L=($J?$J->fetch_assoc():false);if(!$L)$L=array($j->primary=>"");}if($L){foreach($L +as$y=>$X){if(!$Z)$L[$y]=null;$m[$y]=array("field"=>$y,"null"=>($y!=$j->primary),"auto_increment"=>($y==$j->primary));}}}edit_form($a,$m,$L,$Ag);}elseif(isset($_GET["create"])){$a=$_GET["create"];$te=array();foreach(array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST')as$y)$te[$y]=$y;$Ye=referencable_primary($a);$tc=array();foreach($Ye +as$Pf=>$l)$tc[str_replace("`","``",$Pf)."`".str_replace("`","``",$l["field"])]=$Pf;$le=array();$R=array();if($a!=""){$le=fields($a);$R=table_status($a);if(!$R)$k='No tables.';}$L=$_POST;$L["fields"]=(array)$L["fields"];if($L["auto_increment_col"])$L["fields"][$L["auto_increment_col"]]["auto_increment"]=true;if($_POST&&!process_fields($L["fields"])&&!$k){if($_POST["drop"])queries_redirect(substr(ME,0,-1),'Table has been dropped.',drop_tables(array($a)));else{$m=array();$ra=array();$Dg=false;$rc=array();ksort($L["fields"]);$ke=reset($le);$pa=" FIRST";foreach($L["fields"]as$y=>$l){$n=$tc[$l["type"]];$rg=($n!==null?$Ye[$n]:$l);if($l["field"]!=""){if(!$l["has_default"])$l["default"]=null;if($y==$L["auto_increment_col"])$l["auto_increment"]=true;$Oe=process_field($l,$rg);$ra[]=array($l["orig"],$Oe,$pa);if($Oe!=process_field($ke,$ke)){$m[]=array($l["orig"],$Oe,$pa);if($l["orig"]!=""||$pa)$Dg=true;}if($n!==null)$rc[idf_escape($l["field"])]=($a!=""&&$x!="sqlite"?"ADD":" ").format_foreign_key(array('table'=>$tc[$l["type"]],'source'=>array($l["field"]),'target'=>array($rg["field"]),'on_delete'=>$l["on_delete"],));$pa=" AFTER ".idf_escape($l["field"]);}elseif($l["orig"]!=""){$Dg=true;$m[]=array($l["orig"]);}if($l["orig"]!=""){$ke=next($le);if(!$ke)$pa="";}}$ve="";if($te[$L["partition_by"]]){$we=array();if($L["partition_by"]=='RANGE'||$L["partition_by"]=='LIST'){foreach(array_filter($L["partition_names"])as$y=>$X){$Y=$L["partition_values"][$y];$we[]="\n PARTITION ".idf_escape($X)." VALUES ".($L["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$ve.="\nPARTITION BY $L[partition_by]($L[partition])".($we?" (".implode(",",$we)."\n)":($L["partitions"]?" PARTITIONS ".(+$L["partitions"]):""));}elseif(support("partitioning")&&preg_match("~partitioned~",$R["Create_options"]))$ve.="\nREMOVE PARTITIONING";$C='Table has been altered.';if($a==""){cookie("adminer_engine",$L["Engine"]);$C='Table has been created.';}$E=trim($L["name"]);queries_redirect(ME.(support("table")?"table=":"select=").urlencode($E),$C,alter_table($a,$E,($x=="sqlite"&&($Dg||$rc)?$ra:$m),$rc,($L["Comment"]!=$R["Comment"]?$L["Comment"]:null),($L["Engine"]&&$L["Engine"]!=$R["Engine"]?$L["Engine"]:""),($L["Collation"]&&$L["Collation"]!=$R["Collation"]?$L["Collation"]:""),($L["Auto_increment"]!=""?number($L["Auto_increment"]):""),$ve));}}page_header(($a!=""?'Alter table':'Create table'),$k,array("table"=>$a),h($a));if(!$_POST){$L=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($tg["int"])?"int":(isset($tg["integer"])?"integer":"")))),"partition_names"=>array(""),);if($a!=""){$L=$R;$L["name"]=$a;$L["fields"]=array();if(!$_GET["auto_increment"])$L["Auto_increment"]="";foreach($le +as$l){$l["has_default"]=isset($l["default"]);$L["fields"][]=$l;}if(support("partitioning")){$xc="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($a);$J=$e->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $xc ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($L["partition_by"],$L["partitions"],$L["partition"])=$J->fetch_row();$we=get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $xc AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");$we[""]="";$L["partition_names"]=array_keys($we);$L["partition_values"]=array_values($we);}}}$Xa=collations();$Ub=engines();foreach($Ub +as$Tb){if(!strcasecmp($Tb,$L["Engine"])){$L["Engine"]=$Tb;break;}}echo'

';if(support("columns")||$a==""){echo'Table name: -';if($a==""&&!$_POST){?>".optionlist(array(""=>"(".'engine'.")")+$Vb,$L["Engine"])."":""),' ',($Xa&&!preg_match("~sqlite|mssql~",$x)?html_select("Collation",array(""=>"(".'collation'.")")+$Xa,$L["Collation"]):""),' +';if($a==""&&!$_POST){?>".optionlist(array(""=>"(".'engine'.")")+$Ub,$L["Engine"])."":""),' ',($Xa&&!preg_match("~sqlite|mssql~",$x)?html_select("Collation",array(""=>"(".'collation'.")")+$Xa,$L["Collation"]):""),' ';}echo' ';if(support("columns")){echo' -';$cb=($_POST?$_POST["comments"]:$L["Comment"]!="");if(!$_POST&&!$cb){foreach($L["fields"]as$k){if($k["comment"]!=""){$cb=true;break;}}}edit_fields($L["fields"],$Xa,"TABLE",$n,$cb);echo'
+';$cb=($_POST?$_POST["comments"]:$L["Comment"]!="");if(!$_POST&&!$cb){foreach($L["fields"]as$l){if($l["comment"]!=""){$cb=true;break;}}}edit_fields($L["fields"],$Xa,"TABLE",$tc,$cb);echo'

Auto Increment: ',checkbox("defaults",1,true,'Default values',"columnShow(this.checked, 5)","jsonly");if(!$_POST["defaults"]){echo'';}echo(support("comment")?"".' ':''),'

@@ -664,8 +667,8 @@ Partitions: ';}echo' -';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Nc=array("PRIMARY","UNIQUE","INDEX");$R=table_status($a,true);if(preg_match('~MyISAM|M?aria'.($e->server_info>=5.6?'|InnoDB':'').'~i',$R["Engine"]))$Nc[]="FULLTEXT";$v=indexes($a);$Ie=array();if($x=="mongo"){$Ie=$v["_id_"];unset($Nc[0]);unset($v["_id_"]);}$L=$_POST;if($_POST&&!$j&&!$_POST["add"]&&!$_POST["drop_col"]){$sa=array();foreach($L["indexes"]as$u){$E=$u["name"];if(in_array($u["type"],$Nc)){$d=array();$nd=array();$zb=array();$P=array();ksort($u["columns"]);foreach($u["columns"]as$y=>$c){if($c!=""){$md=$u["lengths"][$y];$yb=$u["descs"][$y];$P[]=idf_escape($c).($md?"(".(+$md).")":"").($yb?" DESC":"");$d[]=$c;$nd[]=($md?$md:null);$zb[]=$yb;}}if($d){$ec=$v[$E];if($ec){ksort($ec["columns"]);ksort($ec["lengths"]);ksort($ec["descs"]);if($u["type"]==$ec["type"]&&array_values($ec["columns"])===$d&&(!$ec["lengths"]||array_values($ec["lengths"])===$nd)&&array_values($ec["descs"])===$zb){unset($v[$E]);continue;}}$sa[]=array($u["type"],$E,$P);}}}foreach($v -as$E=>$ec)$sa[]=array($ec["type"],$E,"DROP");if(!$sa)redirect(ME."table=".urlencode($a));queries_redirect(ME."table=".urlencode($a),'Indexes have been altered.',alter_indexes($a,$sa));}page_header('Indexes',$j,array("table"=>$a),h($a));$l=array_keys(fields($a));if($_POST["add"]){foreach($L["indexes"]as$y=>$u){if($u["columns"][count($u["columns"])]!="")$L["indexes"][$y]["columns"][]="";}$u=end($L["indexes"]);if($u["type"]||array_filter($u["columns"],'strlen'))$L["indexes"][]=array("columns"=>array(1=>""));}if(!$L){foreach($v +';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Nc=array("PRIMARY","UNIQUE","INDEX");$R=table_status($a,true);if(preg_match('~MyISAM|M?aria'.($e->server_info>=5.6?'|InnoDB':'').'~i',$R["Engine"]))$Nc[]="FULLTEXT";$v=indexes($a);$Ie=array();if($x=="mongo"){$Ie=$v["_id_"];unset($Nc[0]);unset($v["_id_"]);}$L=$_POST;if($_POST&&!$k&&!$_POST["add"]&&!$_POST["drop_col"]){$sa=array();foreach($L["indexes"]as$u){$E=$u["name"];if(in_array($u["type"],$Nc)){$d=array();$nd=array();$yb=array();$P=array();ksort($u["columns"]);foreach($u["columns"]as$y=>$c){if($c!=""){$md=$u["lengths"][$y];$xb=$u["descs"][$y];$P[]=idf_escape($c).($md?"(".(+$md).")":"").($xb?" DESC":"");$d[]=$c;$nd[]=($md?$md:null);$yb[]=$xb;}}if($d){$dc=$v[$E];if($dc){ksort($dc["columns"]);ksort($dc["lengths"]);ksort($dc["descs"]);if($u["type"]==$dc["type"]&&array_values($dc["columns"])===$d&&(!$dc["lengths"]||array_values($dc["lengths"])===$nd)&&array_values($dc["descs"])===$yb){unset($v[$E]);continue;}}$sa[]=array($u["type"],$E,$P);}}}foreach($v +as$E=>$dc)$sa[]=array($dc["type"],$E,"DROP");if(!$sa)redirect(ME."table=".urlencode($a));queries_redirect(ME."table=".urlencode($a),'Indexes have been altered.',alter_indexes($a,$sa));}page_header('Indexes',$k,array("table"=>$a),h($a));$m=array_keys(fields($a));if($_POST["add"]){foreach($L["indexes"]as$y=>$u){if($u["columns"][count($u["columns"])]!="")$L["indexes"][$y]["columns"][]="";}$u=end($L["indexes"]);if($u["type"]||array_filter($u["columns"],'strlen'))$L["indexes"][]=array("columns"=>array(1=>""));}if(!$L){foreach($v as$y=>$u){$v[$y]["name"]=$y;$v[$y]["columns"][]="";}$v[]=array("columns"=>array(1=>""));$L["indexes"]=$v;}?>

@@ -674,34 +677,34 @@ as$y=>$u){$v[$y]["name"]=$y;$v[$y]["columns"][]="";}$v[]=array("columns"=>array( Index Type Column (length) Name -  +  PRIMARY";foreach($Ie["columns"]as$y=>$c){echo -select_input(" disabled",$l,$c)," ";}echo"\n";}$w=1;foreach($L["indexes"]as$u){if(!$_POST["drop_col"]||$w!=key($_POST["drop_col"])){echo"".html_select("indexes[$w][type]",array(-1=>"")+$Nc,$u["type"],($w==count($L["indexes"])?"indexesAddRow(this);":1)),"";ksort($u["columns"]);$s=1;foreach($u["columns"]as$y=>$c){echo"".select_input(" name='indexes[$w][columns][$s]' onchange=\"".($s==count($u["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($x=="sql"?"":$_GET["indexes"]."_")."');\"",($l?array_combine($l,$l):$l),$c),($x=="sql"||$x=="mssql"?"":""),($x!="sql"?checkbox("indexes[$w][descs][$s]",1,$u["descs"][$y],'descending'):"")," ";$s++;}echo"\n","\n";}$w++;}echo' +select_input(" disabled",$m,$c)," ";}echo"\n";}$w=1;foreach($L["indexes"]as$u){if(!$_POST["drop_col"]||$w!=key($_POST["drop_col"])){echo"".html_select("indexes[$w][type]",array(-1=>"")+$Nc,$u["type"],($w==count($L["indexes"])?"indexesAddRow(this);":1)),"";ksort($u["columns"]);$s=1;foreach($u["columns"]as$y=>$c){echo"".select_input(" name='indexes[$w][columns][$s]' onchange=\"".($s==count($u["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($x=="sql"?"":$_GET["indexes"]."_")."');\"",($m?array_combine($m,$m):$m),$c),($x=="sql"||$x=="mssql"?"":""),($x!="sql"?checkbox("indexes[$w][descs][$s]",1,$u["descs"][$y],'descending'):"")," ";$s++;}echo"\n","\n";}$w++;}echo'

-';}elseif(isset($_GET["database"])){$L=$_POST;if($_POST&&!$j&&!isset($_POST["add_x"])){$E=trim($L["name"]);if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),'Database has been dropped.',drop_databases(array(DB)));}elseif(DB!==$E){if(DB!=""){$_GET["db"]=$E;queries_redirect(preg_replace('~\bdb=[^&]*&~','',ME)."db=".urlencode($E),'Database has been renamed.',rename_database($E,$L["collation"]));}else{$g=explode("\n",str_replace("\r","",$E));$Jf=true;$gd="";foreach($g -as$h){if(count($g)==1||$h!=""){if(!create_database($h,$L["collation"]))$Jf=false;$gd=$h;}}restart_session();set_session("dbs",null);queries_redirect(ME."db=".urlencode($gd),'Database has been created.',$Jf);}}else{if(!$L["collation"])redirect(substr(ME,0,-1));query_redirect("ALTER DATABASE ".idf_escape($E).(preg_match('~^[a-z0-9_]+$~i',$L["collation"])?" COLLATE $L[collation]":""),substr(ME,0,-1),'Database has been altered.');}}page_header(DB!=""?'Alter database':'Create database',$j,array(),h(DB));$Xa=collations();$E=DB;if($_POST)$E=$L["name"];elseif(DB!="")$L["collation"]=db_collation(DB,$Xa);elseif($x=="sql"){foreach(get_vals("SHOW GRANTS")as$q){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~',$q,$B)&&$B[1]){$E=stripcslashes(idf_unescape("`$B[2]`"));break;}}}echo' +';}elseif(isset($_GET["database"])){$L=$_POST;if($_POST&&!$k&&!isset($_POST["add_x"])){$E=trim($L["name"]);if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),'Database has been dropped.',drop_databases(array(DB)));}elseif(DB!==$E){if(DB!=""){$_GET["db"]=$E;queries_redirect(preg_replace('~\bdb=[^&]*&~','',ME)."db=".urlencode($E),'Database has been renamed.',rename_database($E,$L["collation"]));}else{$h=explode("\n",str_replace("\r","",$E));$Jf=true;$gd="";foreach($h +as$i){if(count($h)==1||$i!=""){if(!create_database($i,$L["collation"]))$Jf=false;$gd=$i;}}restart_session();set_session("dbs",null);queries_redirect(ME."db=".urlencode($gd),'Database has been created.',$Jf);}}else{if(!$L["collation"])redirect(substr(ME,0,-1));query_redirect("ALTER DATABASE ".idf_escape($E).(preg_match('~^[a-z0-9_]+$~i',$L["collation"])?" COLLATE $L[collation]":""),substr(ME,0,-1),'Database has been altered.');}}page_header(DB!=""?'Alter database':'Create database',$k,array(),h(DB));$Xa=collations();$E=DB;if($_POST)$E=$L["name"];elseif(DB!="")$L["collation"]=db_collation(DB,$Xa);elseif($x=="sql"){foreach(get_vals("SHOW GRANTS")as$q){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~',$q,$B)&&$B[1]){$E=stripcslashes(idf_unescape("`$B[2]`"));break;}}}echo'

',($_POST["add_x"]||strpos($E,"\n")?'
':'')."\n".($Xa?html_select("collation",array(""=>"(".'collation'.")")+$Xa,$L["collation"]).doc_link(array('sql'=>"charset-charsets.html",'mssql'=>"ms187963.aspx",)):"");?> \n";elseif(!$_POST["add_x"]&&$_GET["db"]=="")echo"\n";echo' +if(DB!="")echo"\n";elseif(!$_POST["add_x"]&&$_GET["db"]=="")echo"\n";echo'

-';}elseif(isset($_GET["call"])){$da=$_GET["call"];page_header('Call'.": ".h($da),$j);$jf=routine($da,(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Mc=array();$ne=array();foreach($jf["fields"]as$s=>$k){if(substr($k["inout"],-3)=="OUT")$ne[$s]="@".idf_escape($k["field"])." AS ".idf_escape($k["field"]);if(!$k["inout"]||substr($k["inout"],0,2)=="IN")$Mc[]=$s;}if(!$j&&$_POST){$Ja=array();foreach($jf["fields"]as$y=>$k){if(in_array($y,$Mc)){$X=process_input($k);if($X===false)$X="''";if(isset($ne[$y]))$e->query("SET @".idf_escape($k["field"])." = $X");}$Ja[]=(isset($ne[$y])?"@".idf_escape($k["field"]):$X);}$I=(isset($_GET["callf"])?"SELECT":"CALL")." ".idf_escape($da)."(".implode(", ",$Ja).")";echo"

".h($I)." ".'Edit'."\n";if(!$e->multi_query($I))echo"

".error()."\n";else{$f=connect();if(is_object($f))$f->select_db(DB);do{$J=$e->store_result();if(is_object($J))select($J,$f);else +';}elseif(isset($_GET["call"])){$da=$_GET["call"];page_header('Call'.": ".h($da),$k);$jf=routine($da,(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Mc=array();$ne=array();foreach($jf["fields"]as$s=>$l){if(substr($l["inout"],-3)=="OUT")$ne[$s]="@".idf_escape($l["field"])." AS ".idf_escape($l["field"]);if(!$l["inout"]||substr($l["inout"],0,2)=="IN")$Mc[]=$s;}if(!$k&&$_POST){$Ja=array();foreach($jf["fields"]as$y=>$l){if(in_array($y,$Mc)){$X=process_input($l);if($X===false)$X="''";if(isset($ne[$y]))$e->query("SET @".idf_escape($l["field"])." = $X");}$Ja[]=(isset($ne[$y])?"@".idf_escape($l["field"]):$X);}$I=(isset($_GET["callf"])?"SELECT":"CALL")." ".idf_escape($da)."(".implode(", ",$Ja).")";echo"

".h($I)." ".'Edit'."\n";if(!$e->multi_query($I))echo"

".error()."\n";else{$f=connect();if(is_object($f))$f->select_db(DB);do{$J=$e->store_result();if(is_object($J))select($J,$f);else echo"

".lang(array('Routine has been called, %d row affected.','Routine has been called, %d rows affected.'),$e->affected_rows)."\n";}while($e->next_result());if($ne)select($e->query("SELECT ".implode(", ",$ne)));}}echo'

';if($Mc){echo"\n";foreach($Mc -as$y){$k=$jf["fields"][$y];$E=$k["field"];echo"
".$b->fieldName($k);$Y=$_POST["fields"][$E];if($Y!=""){if($k["type"]=="enum")$Y=+$Y;if($k["type"]=="set")$Y=array_sum($Y);}input($k,$Y,(string)$_POST["function"][$E]);echo"\n";}echo"
\n";}echo'

+as$y){$l=$jf["fields"][$y];$E=$l["field"];echo"".$b->fieldName($l);$Y=$_POST["fields"][$E];if($Y!=""){if($l["type"]=="enum")$Y=+$Y;if($l["type"]=="set")$Y=array_sum($Y);}input($l,$Y,(string)$_POST["function"][$E]);echo"\n";}echo"\n";}echo'

-';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];$E=$_GET["name"];$L=$_POST;if($_POST&&!$j&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){$C=($_POST["drop"]?'Foreign key has been dropped.':($E!=""?'Foreign key has been altered.':'Foreign key has been created.'));$A=ME."table=".urlencode($a);$L["source"]=array_filter($L["source"],'strlen');ksort($L["source"]);$Vf=array();foreach($L["source"]as$y=>$X)$Vf[$y]=$L["target"][$y];$L["target"]=$Vf;if($x=="sqlite")queries_redirect($A,$C,recreate_table($a,$a,array(),array(),array(" $E"=>($_POST["drop"]?"":" ".format_foreign_key($L)))));else{$sa="ALTER TABLE ".table($a);$Gb="\nDROP ".($x=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($E);if($_POST["drop"])query_redirect($sa.$Gb,$A,$C);else{query_redirect($sa.($E!=""?"$Gb,":"")."\nADD".format_foreign_key($L),$A,$C);$j='Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.'."
$j";}}}page_header('Foreign key',$j,array("table"=>$a),h($a));if($_POST){ksort($L["source"]);if($_POST["add"])$L["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$L["target"]=array();}elseif($E!=""){$n=foreign_keys($a);$L=$n[$E];$L["source"][]="";}else{$L["table"]=$a;$L["source"]=array("");}$_f=array_keys(fields($a));$Vf=($a===$L["table"]?$_f:array_keys(fields($L["table"])));$Xe=array_keys(array_filter(table_status('',true),'fk_support'));echo' +';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];$E=$_GET["name"];$L=$_POST;if($_POST&&!$k&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){$C=($_POST["drop"]?'Foreign key has been dropped.':($E!=""?'Foreign key has been altered.':'Foreign key has been created.'));$A=ME."table=".urlencode($a);$L["source"]=array_filter($L["source"],'strlen');ksort($L["source"]);$Vf=array();foreach($L["source"]as$y=>$X)$Vf[$y]=$L["target"][$y];$L["target"]=$Vf;if($x=="sqlite")queries_redirect($A,$C,recreate_table($a,$a,array(),array(),array(" $E"=>($_POST["drop"]?"":" ".format_foreign_key($L)))));else{$sa="ALTER TABLE ".table($a);$Fb="\nDROP ".($x=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($E);if($_POST["drop"])query_redirect($sa.$Fb,$A,$C);else{query_redirect($sa.($E!=""?"$Fb,":"")."\nADD".format_foreign_key($L),$A,$C);$k='Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.'."
$k";}}}page_header('Foreign key',$k,array("table"=>$a),h($a));if($_POST){ksort($L["source"]);if($_POST["add"])$L["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$L["target"]=array();}elseif($E!=""){$tc=foreign_keys($a);$L=$tc[$E];$L["source"][]="";}else{$L["table"]=$a;$L["source"]=array("");}$_f=array_keys(fields($a));$Vf=($a===$L["table"]?$_f:array_keys(fields($L["table"])));$Xe=array_keys(array_filter(table_status('',true),'fk_support'));echo'

';if($L["db"]==""&&$L["ns"]==""){echo'Target table: @@ -716,14 +719,14 @@ ON DELETE: ',html_select("on_delete",array(-1=>"")+explode("|",$Xd),$L["on_delet

';}if($E!=""){echo'';}echo'

-';}elseif(isset($_GET["view"])){$a=$_GET["view"];$L=$_POST;if($_POST&&!$j){$E=trim($L["name"]);$ua=" AS\n$L[select]";$A=ME."table=".urlencode($E);$C='View has been altered.';if($_GET["materialized"])$U="MATERIALIZED VIEW";else{$U="VIEW";if($x=="pgsql"){$Df=table_status($E);$U=($Df?strtoupper($Df["Engine"]):$U);}}if(!$_POST["drop"]&&$a==$E&&$x!="sqlite"&&$U!="MATERIALIZED VIEW")query_redirect(($x=="mssql"?"ALTER":"CREATE OR REPLACE")." VIEW ".table($E).$ua,$A,$C);else{$Xf=$E."_adminer_".uniqid();drop_create("DROP $U ".table($a),"CREATE $U ".table($E).$ua,"DROP $U ".table($E),"CREATE $U ".table($Xf).$ua,"DROP $U ".table($Xf),($_POST["drop"]?substr(ME,0,-1):$A),'View has been dropped.',$C,'View has been created.',$a,$E);}}if(!$_POST&&$a!=""){$L=view($a);$L["name"]=$a;if(!$j)$j=error();}page_header(($a!=""?'Alter view':'Create view'),$j,array("table"=>$a),h($a));echo' +';}elseif(isset($_GET["view"])){$a=$_GET["view"];$L=$_POST;if($_POST&&!$k){$E=trim($L["name"]);$ua=" AS\n$L[select]";$A=ME."table=".urlencode($E);$C='View has been altered.';if($_GET["materialized"])$U="MATERIALIZED VIEW";else{$U="VIEW";if($x=="pgsql"){$Df=table_status($E);$U=($Df?strtoupper($Df["Engine"]):$U);}}if(!$_POST["drop"]&&$a==$E&&$x!="sqlite"&&$U!="MATERIALIZED VIEW")query_redirect(($x=="mssql"?"ALTER":"CREATE OR REPLACE")." VIEW ".table($E).$ua,$A,$C);else{$Xf=$E."_adminer_".uniqid();drop_create("DROP $U ".table($a),"CREATE $U ".table($E).$ua,"DROP $U ".table($E),"CREATE $U ".table($Xf).$ua,"DROP $U ".table($Xf),($_POST["drop"]?substr(ME,0,-1):$A),'View has been dropped.',$C,'View has been created.',$a,$E);}}if(!$_POST&&$a!=""){$L=view($a);$L["name"]=$a;if(!$k)$k=error();}page_header(($a!=""?'Alter view':'Create view'),$k,array("table"=>$a),h($a));echo'

Name:

';textarea("select",$L["select"]);echo'

';if($_GET["view"]!=""){echo'';}echo'

-';}elseif(isset($_GET["event"])){$aa=$_GET["event"];$Sc=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$Ef=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");$L=$_POST;if($_POST&&!$j){if($_POST["drop"])query_redirect("DROP EVENT ".idf_escape($aa),substr(ME,0,-1),'Event has been dropped.');elseif(in_array($L["INTERVAL_FIELD"],$Sc)&&isset($Ef[$L["STATUS"]])){$nf="\nON SCHEDULE ".($L["INTERVAL_VALUE"]?"EVERY ".q($L["INTERVAL_VALUE"])." $L[INTERVAL_FIELD]".($L["STARTS"]?" STARTS ".q($L["STARTS"]):"").($L["ENDS"]?" ENDS ".q($L["ENDS"]):""):"AT ".q($L["STARTS"]))." ON COMPLETION".($L["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).$nf.($aa!=$L["EVENT_NAME"]?"\nRENAME TO ".idf_escape($L["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($L["EVENT_NAME"]).$nf)."\n".$Ef[$L["STATUS"]]." COMMENT ".q($L["EVENT_COMMENT"]).rtrim(" DO\n$L[EVENT_DEFINITION]",";").";"));}}page_header(($aa!=""?'Alter event'.": ".h($aa):'Create event'),$j);if(!$L&&$aa!=""){$M=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($aa));$L=reset($M);}echo' +';}elseif(isset($_GET["event"])){$aa=$_GET["event"];$Sc=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$Ef=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");$L=$_POST;if($_POST&&!$k){if($_POST["drop"])query_redirect("DROP EVENT ".idf_escape($aa),substr(ME,0,-1),'Event has been dropped.');elseif(in_array($L["INTERVAL_FIELD"],$Sc)&&isset($Ef[$L["STATUS"]])){$nf="\nON SCHEDULE ".($L["INTERVAL_VALUE"]?"EVERY ".q($L["INTERVAL_VALUE"])." $L[INTERVAL_FIELD]".($L["STARTS"]?" STARTS ".q($L["STARTS"]):"").($L["ENDS"]?" ENDS ".q($L["ENDS"]):""):"AT ".q($L["STARTS"]))." ON COMPLETION".($L["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).$nf.($aa!=$L["EVENT_NAME"]?"\nRENAME TO ".idf_escape($L["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($L["EVENT_NAME"]).$nf)."\n".$Ef[$L["STATUS"]]." COMMENT ".q($L["EVENT_COMMENT"]).rtrim(" DO\n$L[EVENT_DEFINITION]",";").";"));}}page_header(($aa!=""?'Alter event'.": ".h($aa):'Create event'),$k);if(!$L&&$aa!=""){$M=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($aa));$L=reset($M);}echo'
Name @@ -735,7 +738,7 @@ ON DELETE: ',html_select("on_delete",array(-1=>"")+explode("|",$Xd),$L["on_delet ';if($aa!=""){echo'';}echo' -';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$jf=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$L=$_POST;$L["fields"]=(array)$L["fields"];if($_POST&&!process_fields($L["fields"])&&!$j){$Xf="$L[name]_adminer_".uniqid();drop_create("DROP $jf ".idf_escape($da),create_routine($jf,$L),"DROP $jf ".idf_escape($L["name"]),create_routine($jf,array("name"=>$Xf)+$L),"DROP $jf ".idf_escape($Xf),substr(ME,0,-1),'Routine has been dropped.','Routine has been altered.','Routine has been created.',$da,$L["name"]);}page_header(($da!=""?(isset($_GET["function"])?'Alter function':'Alter procedure').": ".h($da):(isset($_GET["function"])?'Create function':'Create procedure')),$j);if(!$_POST&&$da!=""){$L=routine($da,$jf);$L["name"]=$da;}$Xa=get_vals("SHOW CHARACTER SET");sort($Xa);$kf=routine_languages();echo' +';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$jf=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$L=$_POST;$L["fields"]=(array)$L["fields"];if($_POST&&!process_fields($L["fields"])&&!$k){$Xf="$L[name]_adminer_".uniqid();drop_create("DROP $jf ".idf_escape($da),create_routine($jf,$L),"DROP $jf ".idf_escape($L["name"]),create_routine($jf,array("name"=>$Xf)+$L),"DROP $jf ".idf_escape($Xf),substr(ME,0,-1),'Routine has been dropped.','Routine has been altered.','Routine has been created.',$da,$L["name"]);}page_header(($da!=""?(isset($_GET["function"])?'Alter function':'Alter procedure').": ".h($da):(isset($_GET["function"])?'Create function':'Create procedure')),$k);if(!$_POST&&$da!=""){$L=routine($da,$jf);$L["name"]=$da;}$Xa=get_vals("SHOW CHARACTER SET");sort($Xa);$kf=routine_languages();echo'

Name: ',($kf?'Language'.": ".html_select("language",$kf,$L["language"]):""),' @@ -745,7 +748,7 @@ ON DELETE: ',html_select("on_delete",array(-1=>"")+explode("|",$Xd),$L["on_delet ';if($da!=""){echo'';}echo'

-';}elseif(isset($_GET["trigger"])){$a=$_GET["trigger"];$E=$_GET["name"];$pg=trigger_options();$L=(array)trigger($E)+array("Trigger"=>$a."_bi");if($_POST){if(!$j&&in_array($_POST["Timing"],$pg["Timing"])&&in_array($_POST["Event"],$pg["Event"])&&in_array($_POST["Type"],$pg["Type"])){$Wd=" ON ".table($a);$Gb="DROP TRIGGER ".idf_escape($E).($x=="pgsql"?$Wd:"");$A=ME."table=".urlencode($a);if($_POST["drop"])query_redirect($Gb,$A,'Trigger has been dropped.');else{if($E!="")queries($Gb);queries_redirect($A,($E!=""?'Trigger has been altered.':'Trigger has been created.'),queries(create_trigger($Wd,$_POST)));if($E!="")queries(create_trigger($Wd,$L+array("Type"=>reset($pg["Type"]))));}}$L=$_POST;}page_header(($E!=""?'Alter trigger'.": ".h($E):'Create trigger'),$j,array("table"=>$a));echo' +';}elseif(isset($_GET["trigger"])){$a=$_GET["trigger"];$E=$_GET["name"];$pg=trigger_options();$L=(array)trigger($E)+array("Trigger"=>$a."_bi");if($_POST){if(!$k&&in_array($_POST["Timing"],$pg["Timing"])&&in_array($_POST["Event"],$pg["Event"])&&in_array($_POST["Type"],$pg["Type"])){$Wd=" ON ".table($a);$Fb="DROP TRIGGER ".idf_escape($E).($x=="pgsql"?$Wd:"");$A=ME."table=".urlencode($a);if($_POST["drop"])query_redirect($Fb,$A,'Trigger has been dropped.');else{if($E!="")queries($Fb);queries_redirect($A,($E!=""?'Trigger has been altered.':'Trigger has been created.'),queries(create_trigger($Wd,$_POST)));if($E!="")queries(create_trigger($Wd,$L+array("Type"=>reset($pg["Type"]))));}}$L=$_POST;}page_header(($E!=""?'Alter trigger'.": ".h($E):'Create trigger'),$k,array("table"=>$a));echo'
Time',html_select("Timing",$pg["Timing"],$L["Timing"],"triggerChange(/^".preg_quote($a,"/")."_[ba][iud]$/, '".js_escape($a)."', this.form);"),'
Event',html_select("Event",$pg["Event"],$L["Event"],"this.form['Timing'].onchange();"),(in_array("UPDATE OF",$pg["Event"])?" ":""),'
Type',html_select("Type",$pg["Type"],$L["Type"]),'
@@ -756,9 +759,9 @@ ON DELETE: ',html_select("on_delete",array(-1=>"")+explode("|",$Xd),$L["on_delet ';if($E!=""){echo'';}echo'
';}elseif(isset($_GET["user"])){$fa=$_GET["user"];$Me=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$L){foreach(explode(",",($L["Privilege"]=="Grant option"?"":$L["Context"]))as$hb)$Me[$hb][$L["Privilege"]]=$L["Comment"];}$Me["Server Admin"]+=$Me["File access on server"];$Me["Databases"]["Create routine"]=$Me["Procedures"]["Create routine"];unset($Me["Procedures"]["Create routine"]);$Me["Columns"]=array();foreach(array("Select","Insert","Update","References")as$X)$Me["Columns"][$X]=$Me["Tables"][$X];unset($Me["Server Admin"]["Usage"]);foreach($Me["Tables"]as$y=>$X)unset($Me["Databases"][$y]);$Jd=array();if($_POST){foreach($_POST["objects"]as$y=>$X)$Jd[$X]=(array)$Jd[$X]+(array)$_POST["grants"][$y];}$zc=array();$Ud="";if(isset($_GET["host"])&&($J=$e->query("SHOW GRANTS FOR ".q($fa)."@".q($_GET["host"])))){while($L=$J->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$L[0],$B)&&preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~',$B[1],$td,PREG_SET_ORDER)){foreach($td -as$X){if($X[1]!="USAGE")$zc["$B[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$L[0]))$zc["$B[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$L[0],$B))$Ud=$B[1];}}if($_POST&&!$j){$Vd=(isset($_GET["host"])?q($fa)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $Vd",ME."privileges=",'User has been dropped.');else{$Ld=q($_POST["user"])."@".q($_POST["host"]);$xe=$_POST["pass"];if($xe!=''&&!$_POST["hashed"]){$xe=$e->result("SELECT PASSWORD(".q($xe).")");$j=!$xe;}$mb=false;if(!$j){if($Vd!=$Ld){$mb=queries(($e->server_info<5?"GRANT USAGE ON *.* TO":"CREATE USER")." $Ld IDENTIFIED BY PASSWORD ".q($xe));$j=!$mb;}elseif($xe!=$Ud)queries("SET PASSWORD FOR $Ld = ".q($xe));}if(!$j){$gf=array();foreach($Jd -as$Pd=>$q){if(isset($_GET["grant"]))$q=array_filter($q);$q=array_keys($q);if(isset($_GET["grant"]))$gf=array_diff(array_keys(array_filter($Jd[$Pd],'strlen')),$q);elseif($Vd==$Ld){$Sd=array_keys((array)$zc[$Pd]);$gf=array_diff($Sd,$q);$q=array_diff($q,$Sd);unset($zc[$Pd]);}if(preg_match('~^(.+)\\s*(\\(.*\\))?$~U',$Pd,$B)&&(!grant("REVOKE",$gf,$B[2]," ON $B[1] FROM $Ld")||!grant("GRANT",$q,$B[2]," ON $B[1] TO $Ld"))){$j=true;break;}}}if(!$j&&isset($_GET["host"])){if($Vd!=$Ld)queries("DROP USER $Vd");elseif(!isset($_GET["grant"])){foreach($zc -as$Pd=>$gf){if(preg_match('~^(.+)(\\(.*\\))?$~U',$Pd,$B))grant("REVOKE",array_keys($gf),$B[2]," ON $B[1] FROM $Ld");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?'User has been altered.':'User has been created.'),!$j);if($mb)$e->query("DROP USER $Ld");}}page_header((isset($_GET["host"])?'Username'.": ".h("$fa@$_GET[host]"):'Create user'),$j,array("privileges"=>array('','Privileges')));if($_POST){$L=$_POST;$zc=$Jd;}else{$L=$_GET+array("host"=>$e->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$L["pass"]=$Ud;if($Ud!="")$L["hashed"]=true;$zc[(DB==""||$zc?"":idf_escape(addcslashes(DB,"%_\\"))).".*"]=array();}echo'
+as$X){if($X[1]!="USAGE")$zc["$B[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$L[0]))$zc["$B[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$L[0],$B))$Ud=$B[1];}}if($_POST&&!$k){$Vd=(isset($_GET["host"])?q($fa)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $Vd",ME."privileges=",'User has been dropped.');else{$Ld=q($_POST["user"])."@".q($_POST["host"]);$xe=$_POST["pass"];if($xe!=''&&!$_POST["hashed"]){$xe=$e->result("SELECT PASSWORD(".q($xe).")");$k=!$xe;}$lb=false;if(!$k){if($Vd!=$Ld){$lb=queries(($e->server_info<5?"GRANT USAGE ON *.* TO":"CREATE USER")." $Ld IDENTIFIED BY PASSWORD ".q($xe));$k=!$lb;}elseif($xe!=$Ud)queries("SET PASSWORD FOR $Ld = ".q($xe));}if(!$k){$gf=array();foreach($Jd +as$Pd=>$q){if(isset($_GET["grant"]))$q=array_filter($q);$q=array_keys($q);if(isset($_GET["grant"]))$gf=array_diff(array_keys(array_filter($Jd[$Pd],'strlen')),$q);elseif($Vd==$Ld){$Sd=array_keys((array)$zc[$Pd]);$gf=array_diff($Sd,$q);$q=array_diff($q,$Sd);unset($zc[$Pd]);}if(preg_match('~^(.+)\\s*(\\(.*\\))?$~U',$Pd,$B)&&(!grant("REVOKE",$gf,$B[2]," ON $B[1] FROM $Ld")||!grant("GRANT",$q,$B[2]," ON $B[1] TO $Ld"))){$k=true;break;}}}if(!$k&&isset($_GET["host"])){if($Vd!=$Ld)queries("DROP USER $Vd");elseif(!isset($_GET["grant"])){foreach($zc +as$Pd=>$gf){if(preg_match('~^(.+)(\\(.*\\))?$~U',$Pd,$B))grant("REVOKE",array_keys($gf),$B[2]," ON $B[1] FROM $Ld");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?'User has been altered.':'User has been created.'),!$k);if($lb)$e->query("DROP USER $Ld");}}page_header((isset($_GET["host"])?'Username'.": ".h("$fa@$_GET[host]"):'Create user'),$k,array("privileges"=>array('','Privileges')));if($_POST){$L=$_POST;$zc=$Jd;}else{$L=$_GET+array("host"=>$e->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$L["pass"]=$Ud;if($Ud!="")$L["hashed"]=true;$zc[(DB==""||$zc?"":idf_escape(addcslashes(DB,"%_\\"))).".*"]=array();}echo'
Server
Username @@ -767,13 +770,13 @@ as$Pd=>$gf){if(preg_match('~^(.+)(\\(.*\\))?$~U',$Pd,$B))grant("REVOKE",array_ke checkbox("hashed",1,$L["hashed"],'Hashed',"typePassword(this.form['pass'], this.checked);"),'
';echo"\n","\n";foreach(array(""=>"","Server Admin"=>'Server',"Databases"=>'Database',"Tables"=>'Table',"Columns"=>'Column',"Procedures"=>'Routine',)as$hb=>$yb){foreach((array)$Me[$hb]as$Le=>$bb){echo"$yb'.h($Le);$s=0;foreach($zc +as$Pd=>$q){echo'
".'Privileges'.doc_link(array('sql'=>"grant.html#priv_level"));$s=0;foreach($zc -as$Pd=>$q){echo''.($Pd!="*.*"?"":"*.*");$s++;}echo"
'.($Pd!="*.*"?"":"*.*");$s++;}echo"\n";foreach(array(""=>"","Server Admin"=>'Server',"Databases"=>'Database',"Tables"=>'Table',"Columns"=>'Column',"Procedures"=>'Routine',)as$hb=>$xb){foreach((array)$Me[$hb]as$Le=>$bb){echo"$xb'.h($Le);$s=0;foreach($zc as$Pd=>$q){$E="'grants[$s][".h(strtoupper($Le))."]'";$Y=$q[strtoupper($Le)];if($hb=="Server Admin"&&$Pd!=(isset($zc["*.*"])?"*.*":".*"))echo" ";elseif(isset($_GET["grant"]))echo"";else echo"";$s++;}}}echo"
\n",'

';if(isset($_GET["host"])){echo'';}echo'

-';}elseif(isset($_GET["processlist"])){if(support("kill")&&$_POST&&!$j){$dd=0;foreach((array)$_POST["kill"]as$X){if(queries("KILL ".number($X)))$dd++;}queries_redirect(ME."processlist=",lang(array('%d process has been killed.','%d processes have been killed.'),$dd),$dd||!$_POST["kill"]);}page_header('Process list',$j);echo' +';}elseif(isset($_GET["processlist"])){if(support("kill")&&$_POST&&!$k){$dd=0;foreach((array)$_POST["kill"]as$X){if(queries("KILL ".number($X)))$dd++;}queries_redirect(ME."processlist=",lang(array('%d process has been killed.','%d processes have been killed.'),$dd),$dd||!$_POST["kill"]);}page_header('Process list',$k);echo'
';$s=-1;foreach(process_list()as$s=>$L){if(!$s){echo"".(support("kill")?"","
 ":"");foreach($L @@ -783,22 +786,22 @@ as$y=>$X)echo"".(($x=="sql"&&$y=="Info"&&preg_match("~Query|Killed~",$L["Com

';if(support("kill")){echo($s+1)."/".sprintf('%d in total',$e->result("SELECT @@max_connections")),"

\n";}echo' -';}elseif(isset($_GET["select"])){$a=$_GET["select"];$R=table_status1($a);$v=indexes($a);$l=fields($a);$n=column_foreign_keys($a);$Rd="";if($R["Oid"]){$Rd=($x=="sqlite"?"rowid":"oid");$v[]=array("type"=>"PRIMARY","columns"=>array($Rd));}parse_str($_COOKIE["adminer_import"],$ma);$hf=array();$d=array();$ag=null;foreach($l -as$y=>$k){$E=$b->fieldName($k);if(isset($k["privileges"]["select"])&&$E!=""){$d[$y]=html_entity_decode(strip_tags($E),ENT_QUOTES);if(is_shortable($k))$ag=$b->selectLengthProcess();}$hf+=$k["privileges"];}list($N,$r)=$b->selectColumnsProcess($d,$v);$Wc=count($r)selectSearchProcess($l,$v);$fe=$b->selectOrderProcess($l,$v);$z=$b->selectLimitProcess();$xc=($N?implode(", ",$N):"*".($Rd?", $Rd":"")).convert_fields($d,$l,$N)."\nFROM ".table($a);$_c=($r&&$Wc?"\nGROUP BY ".implode(", ",$r):"").($fe?"\nORDER BY ".implode(", ",$fe):"");if($_GET["val"]&&is_ajax()){header("Content-Type: text/plain; charset=utf-8");foreach($_GET["val"]as$xg=>$L){$ua=convert_field($l[key($L)]);$N=array($ua?$ua:idf_escape(key($L)));$Z[]=where_check($xg,$l);$K=$i->select($a,$N,$Z,$N);if($K)echo -reset($K->fetch_row());}exit;}if($_POST&&!$j){$Pg=$Z;if(!$_POST["all"]&&is_array($_POST["check"])){$Oa=array();foreach($_POST["check"]as$Ma)$Oa[]=where_check($Ma,$l);$Pg[]="((".implode(") OR (",$Oa)."))";}$Pg=($Pg?"\nWHERE ".implode(" AND ",$Pg):"");$Ie=$zg=null;foreach($v +';}elseif(isset($_GET["select"])){$a=$_GET["select"];$R=table_status1($a);$v=indexes($a);$m=fields($a);$tc=column_foreign_keys($a);$Rd="";if($R["Oid"]){$Rd=($x=="sqlite"?"rowid":"oid");$v[]=array("type"=>"PRIMARY","columns"=>array($Rd));}parse_str($_COOKIE["adminer_import"],$ma);$hf=array();$d=array();$ag=null;foreach($m +as$y=>$l){$E=$b->fieldName($l);if(isset($l["privileges"]["select"])&&$E!=""){$d[$y]=html_entity_decode(strip_tags($E),ENT_QUOTES);if(is_shortable($l))$ag=$b->selectLengthProcess();}$hf+=$l["privileges"];}list($N,$r)=$b->selectColumnsProcess($d,$v);$Wc=count($r)selectSearchProcess($m,$v);$fe=$b->selectOrderProcess($m,$v);$z=$b->selectLimitProcess();$xc=($N?implode(", ",$N):"*".($Rd?", $Rd":"")).convert_fields($d,$m,$N)."\nFROM ".table($a);$_c=($r&&$Wc?"\nGROUP BY ".implode(", ",$r):"").($fe?"\nORDER BY ".implode(", ",$fe):"");if($_GET["val"]&&is_ajax()){header("Content-Type: text/plain; charset=utf-8");foreach($_GET["val"]as$xg=>$L){$ua=convert_field($m[key($L)]);$N=array($ua?$ua:idf_escape(key($L)));$Z[]=where_check($xg,$m);$K=$j->select($a,$N,$Z,$N);if($K)echo +reset($K->fetch_row());}exit;}if($_POST&&!$k){$Pg=$Z;if(!$_POST["all"]&&is_array($_POST["check"])){$Oa=array();foreach($_POST["check"]as$Ma)$Oa[]=where_check($Ma,$m);$Pg[]="((".implode(") OR (",$Oa)."))";}$Pg=($Pg?"\nWHERE ".implode(" AND ",$Pg):"");$Ie=$zg=null;foreach($v as$u){if($u["type"]=="PRIMARY"){$Ie=array_flip($u["columns"]);$zg=($N?$Ie:array());break;}}foreach((array)$zg -as$y=>$X){if(in_array(idf_escape($y),$N))unset($zg[$y]);}if($_POST["export"]){cookie("adminer_import","output=".urlencode($_POST["output"])."&format=".urlencode($_POST["format"]));dump_headers($a);$b->dumpTable($a,"");if(!is_array($_POST["check"])||$zg===array())$I="SELECT $xc$Pg$_c";else{$vg=array();foreach($_POST["check"]as$X)$vg[]="(SELECT".limit($xc,"\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$l).$_c,1).")";$I=implode(" UNION ALL ",$vg);}$b->dumpData($a,"table",$I);exit;}if(!$b->selectEmailProcess($Z,$n)){if($_POST["save"]||$_POST["delete"]){$J=true;$na=0;$P=array();if(!$_POST["delete"]){foreach($d -as$E=>$X){$X=process_input($l[$E]);if($X!==null&&($_POST["clone"]||$X!==false))$P[idf_escape($E)]=($X!==false?$X:idf_escape($E));}}if($_POST["delete"]||$P){if($_POST["clone"])$I="INTO ".table($a)." (".implode(", ",array_keys($P)).")\nSELECT ".implode(", ",$P)."\nFROM ".table($a);if($_POST["all"]||($zg===array()&&is_array($_POST["check"]))||$Wc){$J=($_POST["delete"]?$i->delete($a,$Pg):($_POST["clone"]?queries("INSERT $I$Pg"):$i->update($a,$P,$Pg)));$na=$e->affected_rows;}else{foreach((array)$_POST["check"]as$X){$Og="\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$l);$J=($_POST["delete"]?$i->delete($a,$Og,1):($_POST["clone"]?queries("INSERT".limit1($I,$Og)):$i->update($a,$P,$Og)));if(!$J)break;$na+=$e->affected_rows;}}}$C=lang(array('%d item has been affected.','%d items have been affected.'),$na);if($_POST["clone"]&&$J&&$na==1){$hd=last_id();if($hd)$C=sprintf('Item%s has been inserted.'," $hd");}queries_redirect(remove_from_uri($_POST["all"]&&$_POST["delete"]?"page":""),$C,$J);if(!$_POST["delete"]){edit_form($a,$l,(array)$_POST["fields"],!$_POST["clone"]);page_footer();exit;}}elseif(!$_POST["import"]){if(!$_POST["val"])$j='Ctrl+click on a value to modify it.';else{$J=true;$na=0;foreach($_POST["val"]as$xg=>$L){$P=array();foreach($L -as$y=>$X){$y=bracket_escape($y,1);$P[idf_escape($y)]=(preg_match('~char|text~',$l[$y]["type"])||$X!=""?$b->processInput($l[$y],$X):"NULL");}$J=$i->update($a,$P," WHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($xg,$l),!($Wc||$zg===array())," ");if(!$J)break;$na+=$e->affected_rows;}queries_redirect(remove_from_uri(),lang(array('%d item has been affected.','%d items have been affected.'),$na),$J);}}elseif(!is_string($nc=get_file("csv_file",true)))$j=upload_error($nc);elseif(!preg_match('~~u',$nc))$j='File must be in UTF-8 encoding.';else{cookie("adminer_import","output=".urlencode($ma["output"])."&format=".urlencode($_POST["separator"]));$J=true;$Ya=array_keys($l);preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~',$nc,$td);$na=count($td[0]);$i->begin();$tf=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));$M=array();foreach($td[0]as$y=>$X){preg_match_all("~((?>\"[^\"]*\")+|[^$tf]*)$tf~",$X.$tf,$ud);if(!$y&&!array_diff($ud[1],$Ya)){$Ya=$ud[1];$na--;}else{$P=array();foreach($ud[1]as$s=>$Ua)$P[idf_escape($Ya[$s])]=($Ua==""&&$l[$Ya[$s]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$Ua))));$M[]=$P;}}$J=(!$M||$i->insertUpdate($a,$M,$Ie));if($J)$i->commit();queries_redirect(remove_from_uri("page"),lang(array('%d row has been imported.','%d rows have been imported.'),$na),$J);$i->rollback();}}}$Pf=$b->tableName($R);if(is_ajax()){page_headers();ob_start();}else -page_header('Select'.": $Pf",$j);$P=null;if(isset($hf["insert"])||!support("table")){$P="";foreach((array)$_GET["where"]as$X){if(count($n[$X["col"]])==1&&($X["op"]=="="||(!$X["op"]&&!preg_match('~[_%]~',$X["val"]))))$P.="&set".urlencode("[".bracket_escape($X["col"])."]")."=".urlencode($X["val"]);}}$b->selectLinks($R,$P);if(!$d&&support("table"))echo"

".'Unable to select the table'.($l?".":": ".error())."\n";else{echo"

\n","
";hidden_fields_get();echo(DB!=""?''.(isset($_GET["ns"])?'':""):"");echo'',"
\n";$b->selectColumnsPrint($N,$d);$b->selectSearchPrint($Z,$d,$v);$b->selectOrderPrint($fe,$d,$v);$b->selectLimitPrint($z);$b->selectLengthPrint($ag);$b->selectActionPrint($v);echo"
\n";$F=$_GET["page"];if($F=="last"){$wc=$e->result(count_rows($a,$Z,$Wc,$r));$F=floor(max(0,$wc-1)/$z);}$qf=$N;if(!$qf){$qf[]="*";if($Rd)$qf[]=$Rd;}$ib=convert_fields($d,$l,$N);if($ib)$qf[]=substr($ib,2);$J=$i->select($a,$qf,$Z,$r,$fe,$z,$F,true);if(!$J)echo"

".error()."\n";else{if($x=="mssql"&&$F)$J->seek($z*$F);$Sb=array();echo"

\n";$M=array();while($L=$J->fetch_assoc()){if($F&&$x=="oracle")unset($L["RNUM"]);$M[]=$L;}if($_GET["page"]!="last"&&+$z&&$r&&$Wc&&$x=="sql")$wc=$e->result(" SELECT FOUND_ROWS()");if(!$M)echo"

".'No rows.'."\n";else{$Ba=$b->backwardKeys($a,$Pf);echo"\n","".(!$r&&$N?"":"\n";if(is_ajax()){if($z%2==1&&$F%2==1)odd();ob_end_clean();}foreach($b->rowDescriptions($M,$tc)as$D=>$L){$wg=unique_array($M[$D],$v);if(!$wg){$wg=array();foreach($M[$D]as$y=>$X){if(!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~',$y))$wg[$y]=$X;}}$xg="";foreach($wg +as$y=>$X){if(($x=="sql"||$x=="pgsql")&&strlen($X)>64){$y=(strpos($y,'(')?$y:idf_escape($y));$y="MD5(".($x=='sql'&&preg_match("~^utf8_~",$m[$y]["collation"])?$y:"CONVERT($y USING ".charset($e).")").")";$X=md5($X);}$xg.="&".($X!==null?urlencode("where[".bracket_escape($y)."]")."=".urlencode($X):"null%5B%5D=".urlencode($y));}echo"".(!$r&&$N?"":"\n";}if(is_ajax())exit;echo"
".'Modify'."");$Id=array();$yc=array();reset($N);$Ue=1;foreach($M[0]as$y=>$X){if($y!=$Rd){$X=$_GET["columns"][key($N)];$k=$l[$N?($X?$X["col"]:current($N)):$y];$E=($k?$b->fieldName($k,$Ue):($X["fun"]?"*":$y));if($E!=""){$Ue++;$Id[$y]=$E;$c=idf_escape($y);$Ic=remove_from_uri('(order|desc)[^=]*|page').'&order%5B0%5D='.urlencode($y);$yb="&desc%5B0%5D=1";echo'','';echo -apply_sql_function($X["fun"],$E)."";echo"";}$yc[$y]=$X["fun"];next($N);}}$nd=array();if($_GET["modify"]){foreach($M +as$y=>$X){if(in_array(idf_escape($y),$N))unset($zg[$y]);}if($_POST["export"]){cookie("adminer_import","output=".urlencode($_POST["output"])."&format=".urlencode($_POST["format"]));dump_headers($a);$b->dumpTable($a,"");if(!is_array($_POST["check"])||$zg===array())$I="SELECT $xc$Pg$_c";else{$vg=array();foreach($_POST["check"]as$X)$vg[]="(SELECT".limit($xc,"\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$m).$_c,1).")";$I=implode(" UNION ALL ",$vg);}$b->dumpData($a,"table",$I);exit;}if(!$b->selectEmailProcess($Z,$tc)){if($_POST["save"]||$_POST["delete"]){$J=true;$na=0;$P=array();if(!$_POST["delete"]){foreach($d +as$E=>$X){$X=process_input($m[$E]);if($X!==null&&($_POST["clone"]||$X!==false))$P[idf_escape($E)]=($X!==false?$X:idf_escape($E));}}if($_POST["delete"]||$P){if($_POST["clone"])$I="INTO ".table($a)." (".implode(", ",array_keys($P)).")\nSELECT ".implode(", ",$P)."\nFROM ".table($a);if($_POST["all"]||($zg===array()&&is_array($_POST["check"]))||$Wc){$J=($_POST["delete"]?$j->delete($a,$Pg):($_POST["clone"]?queries("INSERT $I$Pg"):$j->update($a,$P,$Pg)));$na=$e->affected_rows;}else{foreach((array)$_POST["check"]as$X){$Og="\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$m);$J=($_POST["delete"]?$j->delete($a,$Og,1):($_POST["clone"]?queries("INSERT".limit1($I,$Og)):$j->update($a,$P,$Og)));if(!$J)break;$na+=$e->affected_rows;}}}$C=lang(array('%d item has been affected.','%d items have been affected.'),$na);if($_POST["clone"]&&$J&&$na==1){$hd=last_id();if($hd)$C=sprintf('Item%s has been inserted.'," $hd");}queries_redirect(remove_from_uri($_POST["all"]&&$_POST["delete"]?"page":""),$C,$J);if(!$_POST["delete"]){edit_form($a,$m,(array)$_POST["fields"],!$_POST["clone"]);page_footer();exit;}}elseif(!$_POST["import"]){if(!$_POST["val"])$k='Ctrl+click on a value to modify it.';else{$J=true;$na=0;foreach($_POST["val"]as$xg=>$L){$P=array();foreach($L +as$y=>$X){$y=bracket_escape($y,1);$P[idf_escape($y)]=(preg_match('~char|text~',$m[$y]["type"])||$X!=""?$b->processInput($m[$y],$X):"NULL");}$J=$j->update($a,$P," WHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($xg,$m),!($Wc||$zg===array())," ");if(!$J)break;$na+=$e->affected_rows;}queries_redirect(remove_from_uri(),lang(array('%d item has been affected.','%d items have been affected.'),$na),$J);}}elseif(!is_string($mc=get_file("csv_file",true)))$k=upload_error($mc);elseif(!preg_match('~~u',$mc))$k='File must be in UTF-8 encoding.';else{cookie("adminer_import","output=".urlencode($ma["output"])."&format=".urlencode($_POST["separator"]));$J=true;$Ya=array_keys($m);preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~',$mc,$td);$na=count($td[0]);$j->begin();$tf=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));$M=array();foreach($td[0]as$y=>$X){preg_match_all("~((?>\"[^\"]*\")+|[^$tf]*)$tf~",$X.$tf,$ud);if(!$y&&!array_diff($ud[1],$Ya)){$Ya=$ud[1];$na--;}else{$P=array();foreach($ud[1]as$s=>$Ua)$P[idf_escape($Ya[$s])]=($Ua==""&&$m[$Ya[$s]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$Ua))));$M[]=$P;}}$J=(!$M||$j->insertUpdate($a,$M,$Ie));if($J)$j->commit();queries_redirect(remove_from_uri("page"),lang(array('%d row has been imported.','%d rows have been imported.'),$na),$J);$j->rollback();}}}$Pf=$b->tableName($R);if(is_ajax()){page_headers();ob_start();}else +page_header('Select'.": $Pf",$k);$P=null;if(isset($hf["insert"])||!support("table")){$P="";foreach((array)$_GET["where"]as$X){if(count($tc[$X["col"]])==1&&($X["op"]=="="||(!$X["op"]&&!preg_match('~[_%]~',$X["val"]))))$P.="&set".urlencode("[".bracket_escape($X["col"])."]")."=".urlencode($X["val"]);}}$b->selectLinks($R,$P);if(!$d&&support("table"))echo"

".'Unable to select the table'.($m?".":": ".error())."\n";else{echo"\n","

";hidden_fields_get();echo(DB!=""?''.(isset($_GET["ns"])?'':""):"");echo'',"
\n";$b->selectColumnsPrint($N,$d);$b->selectSearchPrint($Z,$d,$v);$b->selectOrderPrint($fe,$d,$v);$b->selectLimitPrint($z);$b->selectLengthPrint($ag);$b->selectActionPrint($v);echo"\n";$F=$_GET["page"];if($F=="last"){$wc=$e->result(count_rows($a,$Z,$Wc,$r));$F=floor(max(0,$wc-1)/$z);}$qf=$N;if(!$qf){$qf[]="*";if($Rd)$qf[]=$Rd;}$ib=convert_fields($d,$m,$N);if($ib)$qf[]=substr($ib,2);$J=$j->select($a,$qf,$Z,$r,$fe,$z,$F,true);if(!$J)echo"

".error()."\n";else{if($x=="mssql"&&$F)$J->seek($z*$F);$Rb=array();echo"

\n";$M=array();while($L=$J->fetch_assoc()){if($F&&$x=="oracle")unset($L["RNUM"]);$M[]=$L;}if($_GET["page"]!="last"&&+$z&&$r&&$Wc&&$x=="sql")$wc=$e->result(" SELECT FOUND_ROWS()");if(!$M)echo"

".'No rows.'."\n";else{$Ba=$b->backwardKeys($a,$Pf);echo"\n","".(!$r&&$N?"":"\n";if(is_ajax()){if($z%2==1&&$F%2==1)odd();ob_end_clean();}foreach($b->rowDescriptions($M,$n)as$D=>$L){$wg=unique_array($M[$D],$v);if(!$wg){$wg=array();foreach($M[$D]as$y=>$X){if(!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~',$y))$wg[$y]=$X;}}$xg="";foreach($wg -as$y=>$X){if(($x=="sql"||$x=="pgsql")&&strlen($X)>64){$y=(strpos($y,'(')?$y:idf_escape($y));$y="MD5(".($x=='sql'&&preg_match("~^utf8_~",$l[$y]["collation"])?$y:"CONVERT($y USING ".charset($e).")").")";$X=md5($X);}$xg.="&".($X!==null?urlencode("where[".bracket_escape($y)."]")."=".urlencode($X):"null%5B%5D=".urlencode($y));}echo"".(!$r&&$N?"":"\n";}if(is_ajax())exit;echo"
".'Modify'."");$Id=array();$yc=array();reset($N);$Ue=1;foreach($M[0]as$y=>$X){if($y!=$Rd){$X=$_GET["columns"][key($N)];$l=$m[$N?($X?$X["col"]:current($N)):$y];$E=($l?$b->fieldName($l,$Ue):($X["fun"]?"*":$y));if($E!=""){$Ue++;$Id[$y]=$E;$c=idf_escape($y);$Ic=remove_from_uri('(order|desc)[^=]*|page').'&order%5B0%5D='.urlencode($y);$xb="&desc%5B0%5D=1";echo'','';echo +apply_sql_function($X["fun"],$E)."";echo"";}$yc[$y]=$X["fun"];next($N);}}$nd=array();if($_GET["modify"]){foreach($M as$L){foreach($L -as$y=>$X)$nd[$y]=max($nd[$y],min(40,strlen(utf8_decode($X))));}}echo($Ba?"".'Relations':"")."
".checkbox("check[]",substr($xg,1),in_array(substr($xg,1),(array)$_POST["check"]),"","this.form['all'].checked = false; formUncheck('all-page');").($Wc||information_schema(DB)?"":" ".'edit'.""));foreach($L -as$y=>$X){if(isset($Id[$y])){$k=$l[$y];if($X!=""&&(!isset($Sb[$y])||$Sb[$y]!=""))$Sb[$y]=(is_mail($X)?$Id[$y]:"");$_="";if(preg_match('~blob|bytea|raw|file~',$k["type"])&&$X!="")$_=ME.'download='.urlencode($a).'&field='.urlencode($y).$xg;if(!$_&&$X!==null){foreach((array)$n[$y]as$m){if(count($n[$y])==1||end($m["source"])==$y){$_="";foreach($m["source"]as$s=>$_f)$_.=where_link($s,$m["target"][$s],$M[$D][$_f]);$_=($m["db"]!=""?preg_replace('~([?&]db=)[^&]+~','\\1'.urlencode($m["db"]),ME):ME).'select='.urlencode($m["table"]).$_;if(count($m["source"])==1)break;}}}if($y=="COUNT(*)"){$_=ME."select=".urlencode($a);$s=0;foreach((array)$_GET["where"]as$W){if(!array_key_exists($W["col"],$wg))$_.=where_link($s++,$W["col"],$W["val"],$W["op"]);}foreach($wg -as$ad=>$W)$_.=where_link($s++,$ad,$W);}$X=select_value($X,$_,$k,$ag);$t=h("val[$xg][".bracket_escape($y)."]");$Y=$_POST["val"][$xg][bracket_escape($y)];$Nb=!is_array($L[$y])&&is_utf8($X)&&$M[$D][$y]==$L[$y]&&!$yc[$y];$Zf=preg_match('~text|lob~',$k["type"]);if(($_GET["modify"]&&$Nb)||$Y!==null){$Bc=h($Y!==null?$Y:$L[$y]);echo"".($Zf?"":"");}else{$sd=strpos($X,"...");echo"$X";}}}if($Ba)echo"";$b->backwardKeysPrint($Ba,$M[$D]);echo"
\n";}if(($M||$F)&&!is_ajax()){$cc=true;if($_GET["page"]!="last"){if(!+$z)$wc=count($M);elseif($x!="sql"||!$Wc){$wc=($Wc?false:found_rows($R,$Z));if($wc$z||$F)){echo"

";$wd=($wc===false?$F+(count($M)>=$z?2:1):floor(($wc-1)/$z));if($x!="simpledb"){echo'".'Page'.":",pagination(0,$F).($F>5?" ...":"");for($s=max(1,$F-4);$s0){echo($F+5<$wd?" ...":""),($cc&&$wc!==false?pagination($wd,$F):" ".'last'."");}echo(($wc===false?count($M)+1:$wc-$F*$z)>$z?' '.'Load more data'.'':'');}else{echo'Page'.":",pagination(0,$F).($F>1?" ...":""),($F?pagination($F,$F):""),($wd>$F?pagination($F+1,$F).($wd>$F+1?" ...":""):"");}}echo"

\n",($wc!==false?"(".($cc?"":"~ ").lang(array('%d row','%d rows'),$wc).") ":"");$Cb=($cc?"":"~ ").$wc;echo -checkbox("all",1,0,'whole result',"var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$Cb' : checked); selectCount('selected2', this.checked || !checked ? '$Cb' : checked);")."\n";if($b->selectCommandPrint()){echo'Modify

+as$y=>$X)$nd[$y]=max($nd[$y],min(40,strlen(utf8_decode($X))));}}echo($Ba?"
".'Relations':"")."
".checkbox("check[]",substr($xg,1),in_array(substr($xg,1),(array)$_POST["check"]),"","this.form['all'].checked = false; formUncheck('all-page');").($Wc||information_schema(DB)?"":" ".'edit'.""));foreach($L +as$y=>$X){if(isset($Id[$y])){$l=$m[$y];if($X!=""&&(!isset($Rb[$y])||$Rb[$y]!=""))$Rb[$y]=(is_mail($X)?$Id[$y]:"");$_="";if(preg_match('~blob|bytea|raw|file~',$l["type"])&&$X!="")$_=ME.'download='.urlencode($a).'&field='.urlencode($y).$xg;if(!$_&&$X!==null){foreach((array)$tc[$y]as$n){if(count($tc[$y])==1||end($n["source"])==$y){$_="";foreach($n["source"]as$s=>$_f)$_.=where_link($s,$n["target"][$s],$M[$D][$_f]);$_=($n["db"]!=""?preg_replace('~([?&]db=)[^&]+~','\\1'.urlencode($n["db"]),ME):ME).'select='.urlencode($n["table"]).$_;if(count($n["source"])==1)break;}}}if($y=="COUNT(*)"){$_=ME."select=".urlencode($a);$s=0;foreach((array)$_GET["where"]as$W){if(!array_key_exists($W["col"],$wg))$_.=where_link($s++,$W["col"],$W["val"],$W["op"]);}foreach($wg +as$ad=>$W)$_.=where_link($s++,$ad,$W);}$X=select_value($X,$_,$l,$ag);$t=h("val[$xg][".bracket_escape($y)."]");$Y=$_POST["val"][$xg][bracket_escape($y)];$Mb=!is_array($L[$y])&&is_utf8($X)&&$M[$D][$y]==$L[$y]&&!$yc[$y];$Zf=preg_match('~text|lob~',$l["type"]);if(($_GET["modify"]&&$Mb)||$Y!==null){$Bc=h($Y!==null?$Y:$L[$y]);echo"".($Zf?"":"");}else{$sd=strpos($X,"...");echo"$X";}}}if($Ba)echo"";$b->backwardKeysPrint($Ba,$M[$D]);echo"
\n";}if(($M||$F)&&!is_ajax()){$bc=true;if($_GET["page"]!="last"){if(!+$z)$wc=count($M);elseif($x!="sql"||!$Wc){$wc=($Wc?false:found_rows($R,$Z));if($wc$z||$F)){echo"

";$wd=($wc===false?$F+(count($M)>=$z?2:1):floor(($wc-1)/$z));if($x!="simpledb"){echo'".'Page'.":",pagination(0,$F).($F>5?" ...":"");for($s=max(1,$F-4);$s0){echo($F+5<$wd?" ...":""),($bc&&$wc!==false?pagination($wd,$F):" ".'last'."");}echo(($wc===false?count($M)+1:$wc-$F*$z)>$z?' '.'Load more data'.'':'');}else{echo'Page'.":",pagination(0,$F).($F>1?" ...":""),($F?pagination($F,$F):""),($wd>$F?pagination($F+1,$F).($wd>$F+1?" ...":""):"");}}echo"

\n",($wc!==false?"(".($bc?"":"~ ").lang(array('%d row','%d rows'),$wc).") ":"");$Bb=($bc?"":"~ ").$wc;echo +checkbox("all",1,0,'whole result',"var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$Bb' : checked); selectCount('selected2', this.checked || !checked ? '$Bb' : checked);")."\n";if($b->selectCommandPrint()){echo'Modify

Selected
@@ -806,9 +809,9 @@ checkbox("all",1,0,'whole result',"var checked = formChecked(this, /check/); sel
-';}$uc=$b->dumpFormat();foreach((array)$_GET["columns"]as$c){if($c["fun"]){unset($uc['sql']);break;}}if($uc){print_fieldset("export",'Export'." ");$oe=$b->dumpOutput();echo($oe?html_select("output",$oe,$ma["output"])." ":""),html_select("format",$uc,$ma["format"])," \n","\n";}echo(!$r&&$N?"":"\n");}if($b->selectImportPrint()){print_fieldset("import",'Import',!$M);echo" ",html_select("separator",array("csv"=>"CSV,","csv;"=>"CSV;","tsv"=>"TSV"),$ma["format"],1);echo" ","\n";}$b->selectEmailPrint(array_filter($Sb,'strlen'),$d);echo"

\n","\n";}}if(is_ajax()){ob_end_clean();exit;}}elseif(isset($_GET["variables"])){$Df=isset($_GET["status"]);page_header($Df?'Status':'Variables');$Ig=($Df?show_status():show_variables());if(!$Ig)echo"

".'No rows.'."\n";else{echo"\n";foreach($Ig +';}$uc=$b->dumpFormat();foreach((array)$_GET["columns"]as$c){if($c["fun"]){unset($uc['sql']);break;}}if($uc){print_fieldset("export",'Export'." ");$oe=$b->dumpOutput();echo($oe?html_select("output",$oe,$ma["output"])." ":""),html_select("format",$uc,$ma["format"])," \n","\n";}echo(!$r&&$N?"":"\n");}if($b->selectImportPrint()){print_fieldset("import",'Import',!$M);echo" ",html_select("separator",array("csv"=>"CSV,","csv;"=>"CSV;","tsv"=>"TSV"),$ma["format"],1);echo" ","\n";}$b->selectEmailPrint(array_filter($Rb,'strlen'),$d);echo"

\n","\n";}}if(is_ajax()){ob_end_clean();exit;}}elseif(isset($_GET["variables"])){$Df=isset($_GET["status"]);page_header($Df?'Status':'Variables');$Ig=($Df?show_status():show_variables());if(!$Ig)echo"

".'No rows.'."\n";else{echo"

\n";foreach($Ig as$y=>$X){echo"","
".h($y)."","".nbsp($X);}echo"
\n";}}elseif(isset($_GET["script"])){header("Content-Type: text/javascript; charset=utf-8");if($_GET["script"]=="db"){$Mf=array("Data_length"=>0,"Index_length"=>0,"Data_free"=>0);foreach(table_status()as$E=>$R){json_row("Comment-$E",nbsp($R["Comment"]));if(!is_view($R)){foreach(array("Engine","Collation")as$y)json_row("$y-$E",nbsp($R[$y]));foreach($Mf+array("Auto_increment"=>0,"Rows"=>0)as$y=>$X){if($R[$y]!=""){$X=format_number($R[$y]);json_row("$y-$E",($y=="Rows"&&$X&&$R["Engine"]==($Bf=="pgsql"?"table":"InnoDB")?"~ $X":$X));if(isset($Mf[$y]))$Mf[$y]+=($R["Engine"]!="InnoDB"||$y!="Data_free"?$R[$y]:0);}elseif(array_key_exists($y,$R))json_row("$y-$E");}}}foreach($Mf -as$y=>$X)json_row("sum-$y",format_number($X));json_row("");}elseif($_GET["script"]=="kill")$e->query("KILL ".number($_POST["kill"]));else{foreach(count_tables($b->databases())as$h=>$X){json_row("tables-$h",$X);json_row("size-$h",db_size($h));}json_row("");}exit;}else{$Uf=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Uf&&!$j&&!$_POST["search"]){$J=true;$C="";if($x=="sql"&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"]))queries("SET foreign_key_checks = 0");if($_POST["truncate"]){if($_POST["tables"])$J=truncate_tables($_POST["tables"]);$C='Tables have been truncated.';}elseif($_POST["move"]){$J=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$C='Tables have been moved.';}elseif($_POST["copy"]){$J=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$C='Tables have been copied.';}elseif($_POST["drop"]){if($_POST["views"])$J=drop_views($_POST["views"]);if($J&&$_POST["tables"])$J=drop_tables($_POST["tables"]);$C='Tables have been dropped.';}elseif($x!="sql"){$J=($x=="sqlite"?queries("VACUUM"):apply_queries("VACUUM".($_POST["optimize"]?"":" ANALYZE"),$_POST["tables"]));$C='Tables have been optimized.';}elseif(!$_POST["tables"])$C='No tables.';elseif($J=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"])))){while($L=$J->fetch_assoc())$C.="".h($L["Table"]).": ".h($L["Msg_text"])."
";}queries_redirect(substr(ME,0,-1),$C,$J);}page_header(($_GET["ns"]==""?'Database'.": ".h(DB):'Schema'.": ".h($_GET["ns"])),$j,true);if($b->homepage()){if($_GET["ns"]!==""){echo"

".'Tables and views'."

\n";$Tf=tables_list();if(!$Tf)echo"

".'No tables.'."\n";else{echo"

\n";if(support("table")){echo"
".'Search data in tables'."
"," \n","
\n";if($_POST["search"]&&$_POST["query"]!="")search_tables();}echo"\n",'\n";$S=0;foreach($Tf -as$E=>$U){$Kg=($U!==null&&!preg_match('~table~i',$U));echo'
';$Db=doc_link(array('sql'=>'show-table-status.html'));echo''.'Table',''.'Engine'.doc_link(array('sql'=>'storage-engines.html')),''.'Collation'.doc_link(array('sql'=>'charset-mysql.html')),''.'Data Length'.$Db,''.'Index Length'.$Db,''.'Data Free'.$Db,''.'Auto Increment'.doc_link(array('sql'=>'example-auto-increment.html')),''.'Rows'.$Db,(support("comment")?''.'Comment'.$Db:''),"
'.checkbox(($Kg?"views[]":"tables[]"),$E,in_array($E,$Uf,true),"","formUncheck('check-all');"),''.(support("table")||support("indexes")?''.h($E).'':h($E));if($Kg){echo''.(preg_match('~materialized~i',$U)?'Materialized View':'View').'','?';}else{foreach(array("Engine"=>array(),"Collation"=>array(),"Data_length"=>array("create",'Alter table'),"Index_length"=>array("indexes",'Alter indexes'),"Data_free"=>array("edit",'New item'),"Auto_increment"=>array("auto_increment=1&create",'Alter table'),"Rows"=>array("select",'Select data'),)as$y=>$_){$t=" id='$y-".h($E)."'";echo($_?"".(support("table")||$y=="Rows"||(support("indexes")&&$y!="Data_length")?"?":"?"):" ");}$S++;}echo(support("comment")?" ":"");}echo"
 ".sprintf('%d in total',count($Tf)),"".nbsp($x=="sql"?$e->result("SELECT @@storage_engine"):""),"".nbsp(db_collation(DB,collations()));foreach(array("Data_length","Index_length","Data_free")as$y)echo" ";echo"
\n";if(!information_schema(DB)){$Gg=" ";$ce=" ";echo"
".'Selected'."
".($x=="sqlite"?$Gg:($x=="pgsql"?$Gg.$ce:($x=="sql"?" ".$ce." "." ":"")))." "."\n";$g=(support("scheme")?$b->schemas():$b->databases());if(count($g)!=1&&$x!="sqlite"){$h=(isset($_POST["target"])?$_POST["target"]:(support("scheme")?$_GET["ns"]:DB));echo"

".'Move to other database'.": ",($g?html_select("target",$g,$h):'')," ",(support("copy")?" ":""),"\n";}echo"\n";echo"\n","

\n";}echo"
\n","\n";}echo'

".'Routines'."

\n";$lf=routines();if($lf){echo"\n",'\n";odd('');foreach($lf +as$y=>$X)json_row("sum-$y",format_number($X));json_row("");}elseif($_GET["script"]=="kill")$e->query("KILL ".number($_POST["kill"]));else{foreach(count_tables($b->databases())as$i=>$X){json_row("tables-$i",$X);json_row("size-$i",db_size($i));}json_row("");}exit;}else{$Uf=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Uf&&!$k&&!$_POST["search"]){$J=true;$C="";if($x=="sql"&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"]))queries("SET foreign_key_checks = 0");if($_POST["truncate"]){if($_POST["tables"])$J=truncate_tables($_POST["tables"]);$C='Tables have been truncated.';}elseif($_POST["move"]){$J=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$C='Tables have been moved.';}elseif($_POST["copy"]){$J=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$C='Tables have been copied.';}elseif($_POST["drop"]){if($_POST["views"])$J=drop_views($_POST["views"]);if($J&&$_POST["tables"])$J=drop_tables($_POST["tables"]);$C='Tables have been dropped.';}elseif($x!="sql"){$J=($x=="sqlite"?queries("VACUUM"):apply_queries("VACUUM".($_POST["optimize"]?"":" ANALYZE"),$_POST["tables"]));$C='Tables have been optimized.';}elseif(!$_POST["tables"])$C='No tables.';elseif($J=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"])))){while($L=$J->fetch_assoc())$C.="".h($L["Table"]).": ".h($L["Msg_text"])."
";}queries_redirect(substr(ME,0,-1),$C,$J);}page_header(($_GET["ns"]==""?'Database'.": ".h(DB):'Schema'.": ".h($_GET["ns"])),$k,true);if($b->homepage()){if($_GET["ns"]!==""){echo"

".'Tables and views'."

\n";$Tf=tables_list();if(!$Tf)echo"

".'No tables.'."\n";else{echo"
\n";if(support("table")){echo"

".'Search data in tables'."
"," \n","
\n";if($_POST["search"]&&$_POST["query"]!="")search_tables();}echo"
'.'Name'.''.'Type'.''.'Return type'." 
\n",'\n";$S=0;foreach($Tf +as$E=>$U){$Kg=($U!==null&&!preg_match('~table~i',$U));echo'
';$Cb=doc_link(array('sql'=>'show-table-status.html'));echo''.'Table',''.'Engine'.doc_link(array('sql'=>'storage-engines.html')),''.'Collation'.doc_link(array('sql'=>'charset-mysql.html')),''.'Data Length'.$Cb,''.'Index Length'.$Cb,''.'Data Free'.$Cb,''.'Auto Increment'.doc_link(array('sql'=>'example-auto-increment.html')),''.'Rows'.$Cb,(support("comment")?''.'Comment'.$Cb:''),"
'.checkbox(($Kg?"views[]":"tables[]"),$E,in_array($E,$Uf,true),"","formUncheck('check-all');"),''.(support("table")||support("indexes")?''.h($E).'':h($E));if($Kg){echo''.(preg_match('~materialized~i',$U)?'Materialized View':'View').'','?';}else{foreach(array("Engine"=>array(),"Collation"=>array(),"Data_length"=>array("create",'Alter table'),"Index_length"=>array("indexes",'Alter indexes'),"Data_free"=>array("edit",'New item'),"Auto_increment"=>array("auto_increment=1&create",'Alter table'),"Rows"=>array("select",'Select data'),)as$y=>$_){$t=" id='$y-".h($E)."'";echo($_?"".(support("table")||$y=="Rows"||(support("indexes")&&$y!="Data_length")?"?":"?"):" ");}$S++;}echo(support("comment")?" ":"");}echo"
 ".sprintf('%d in total',count($Tf)),"".nbsp($x=="sql"?$e->result("SELECT @@storage_engine"):""),"".nbsp(db_collation(DB,collations()));foreach(array("Data_length","Index_length","Data_free")as$y)echo" ";echo"
\n";if(!information_schema(DB)){$Gg=" ";$ce=" ";echo"
".'Selected'."
".($x=="sqlite"?$Gg:($x=="pgsql"?$Gg.$ce:($x=="sql"?" ".$ce." "." ":"")))." "."\n";$h=(support("scheme")?$b->schemas():$b->databases());if(count($h)!=1&&$x!="sqlite"){$i=(isset($_POST["target"])?$_POST["target"]:(support("scheme")?$_GET["ns"]:DB));echo"

".'Move to other database'.": ",($h?html_select("target",$h,$i):'')," ",(support("copy")?" ":""),"\n";}echo"\n";echo"\n","

\n";}echo"\n","\n";}echo'

".'Routines'."

\n";$lf=routines();if($lf){echo"\n",'\n";odd('');foreach($lf as$L){echo'','
'.'Name'.''.'Type'.''.'Return type'." 
'.h($L["ROUTINE_NAME"]).'',''.h($L["ROUTINE_TYPE"]),''.h($L["DTD_IDENTIFIER"]),''.'Alter'."";}echo"
\n";}echo'

".'Events'."

\n";$M=get_rows("SHOW EVENTS");if($M){echo"\n","\n";foreach($M -as$L){echo"","
".'Name'."".'Schedule'."".'Start'."".'End'."
".h($L["Name"]),"".($L["Execute at"]?'At given time'."".$L["Execute at"]:'Every'." ".$L["Interval value"]." ".$L["Interval field"]."$L[Starts]"),"$L[Ends]",''.'Alter'.'';}echo"
\n";$ac=$e->result("SELECT @@event_scheduler");if($ac&&$ac!="ON")echo"

event_scheduler: ".h($ac)."\n";}echo'

".h($L["Name"]),"".($L["Execute at"]?'At given time'."".$L["Execute at"]:'Every'." ".$L["Interval value"]." ".$L["Interval field"]."$L[Starts]"),"$L[Ends]",''.'Alter'.'';}echo"
\n";$Zb=$e->result("SELECT @@event_scheduler");if($Zb&&$Zb!="ON")echo"

event_scheduler: ".h($Zb)."\n";}echo'