',($T=="PROCEDURE"?"".html_select("fields[$t][inout]",explode("|",$Ud),$o["inout"]):""),' | ';if($fc){echo'';}echo'';edit_type("fields[$t]",$o,$nb,$hd);if($T=="TABLE"){echo' | ',checkbox("fields[$t][null]",1,$o["null"],"","","block","label-null"),' | | ',checkbox("fields[$t][has_default]",1,$o["has_default"],"","","","label-default"),'',(support("comment")?" | ":"");}echo" | ",(support("move_col")?" "." "." ":""),($Ef==""||support("drop_col")?"":"");}}function
process_fields(&$p){$jf=0;if($_POST["up"]){$pe=0;foreach($p
as$z=>$o){if(key($_POST["up"])==$z){unset($p[$z]);array_splice($p,$pe,0,array($o));break;}if(isset($o["field"]))$pe=$jf;$jf++;}}elseif($_POST["down"]){$jd=false;foreach($p
as$z=>$o){if(isset($o["field"])&&$jd){unset($p[key($_POST["down"])]);array_splice($p,$jf,0,array($jd));break;}if(key($_POST["down"])==$z)$jd=$o;$jf++;}}elseif($_POST["add"]){$p=array_values($p);array_splice($p,key($_POST["add"]),0,array(array()));}elseif(!$_POST["drop_col"])return
false;return
true;}function
normalize_enum($C){return"'".str_replace("'","''",addcslashes(stripcslashes(str_replace($C[0][0].$C[0][0],$C[0][0],substr($C[0],1,-1))),'\\'))."'";}function
grant($od,$rg,$e,$qf){if(!$rg)return
true;if($rg==array("ALL PRIVILEGES","GRANT OPTION"))return($od=="GRANT"?queries("$od ALL PRIVILEGES$qf WITH GRANT OPTION"):queries("$od ALL PRIVILEGES$qf")&&queries("$od GRANT OPTION$qf"));return
queries("$od ".preg_replace('~(GRANT OPTION)\([^)]*\)~','\1',implode("$e, ",$rg).$e).$qf);}function
drop_create($jc,$i,$kc,$ci,$mc,$B,$Pe,$Ne,$Oe,$nf,$af){if($_POST["drop"])query_redirect($jc,$B,$Pe);elseif($nf=="")query_redirect($i,$B,$Oe);elseif($nf!=$af){$Kb=queries($i);queries_redirect($B,$Ne,$Kb&&queries($jc));if($Kb)queries($kc);}else
queries_redirect($B,$Ne,queries($ci)&&queries($mc)&&queries($jc)&&queries($i));}function
create_trigger($qf,$J){global$y;$hi=" $J[Timing] $J[Event]".($J["Event"]=="UPDATE OF"?" ".idf_escape($J["Of"]):"");return"CREATE TRIGGER ".idf_escape($J["Trigger"]).($y=="mssql"?$qf.$hi:$hi.$qf).rtrim(" $J[Type]\n$J[Statement]",";").";";}function
create_routine($Vg,$J){global$Ud,$y;$N=array();$p=(array)$J["fields"];ksort($p);foreach($p
as$o){if($o["field"]!="")$N[]=(preg_match("~^($Ud)\$~",$o["inout"])?"$o[inout] ":"").idf_escape($o["field"]).process_type($o,"CHARACTER SET");}$Zb=rtrim("\n$J[definition]",";");return"CREATE $Vg ".idf_escape(trim($J["name"]))." (".implode(", ",$N).")".(isset($_GET["function"])?" RETURNS".process_type($J["returns"],"CHARACTER SET"):"").($J["language"]?" LANGUAGE $J[language]":"").($y=="pgsql"?" AS ".q($Zb):"$Zb;");}function
remove_definer($G){return
preg_replace('~^([A-Z =]+) DEFINER=`'.preg_replace('~@(.*)~','`@`(%|\1)',logged_user()).'`~','\1',$G);}function
format_foreign_key($r){global$rf;$l=$r["db"];$ef=$r["ns"];return" FOREIGN KEY (".implode(", ",array_map('idf_escape',$r["source"])).") REFERENCES ".($l!=""&&$l!=$_GET["db"]?idf_escape($l).".":"").($ef!=""&&$ef!=$_GET["ns"]?idf_escape($ef).".":"").table($r["table"])." (".implode(", ",array_map('idf_escape',$r["target"])).")".(preg_match("~^($rf)\$~",$r["on_delete"])?" ON DELETE $r[on_delete]":"").(preg_match("~^($rf)\$~",$r["on_update"])?" ON UPDATE $r[on_update]":"");}function
tar_file($q,$mi){$I=pack("a100a8a8a8a12a12",$q,644,0,0,decoct($mi->size),decoct(time()));$fb=8*32;for($t=0;$tsend();echo
str_repeat("\0",511-($mi->size+511)%512);}function
ini_bytes($Td){$X=ini_get($Td);switch(strtolower(substr($X,-1))){case'g':$X*=1024;case'm':$X*=1024;case'k':$X*=1024;}return$X;}function
doc_link($ag,$di="?"){global$y,$g;$mh=$g->server_info;$Yi=preg_replace('~^(\d\.?\d).*~s','\1',$mh);$Ni=array('sql'=>"https://dev.mysql.com/doc/refman/$Yi/en/",'sqlite'=>"https://www.sqlite.org/",'pgsql'=>"https://www.postgresql.org/docs/$Yi/",'mssql'=>"https://msdn.microsoft.com/library/",'oracle'=>"https://www.oracle.com/pls/topic/lookup?ctx=db".preg_replace('~^.* (\d+)\.(\d+)\.\d+\.\d+\.\d+.*~s','\1\2',$mh)."&id=",);if(preg_match('~MariaDB~',$mh)){$Ni['sql']="https://mariadb.com/kb/en/library/";$ag['sql']=(isset($ag['mariadb'])?$ag['mariadb']:str_replace(".html","/",$ag['sql']));}return($ag[$y]?"$di":"");}function
ob_gzencode($P){return
gzencode($P);}function
db_size($l){global$g;if(!$g->select_db($l))return"?";$I=0;foreach(table_status()as$R)$I+=$R["Data_length"]+$R["Index_length"];return
format_number($I);}function
set_utf8mb4($i){global$g;static$N=false;if(!$N&&preg_match('~\butf8mb4~i',$i)){$N=true;echo"SET NAMES ".charset($g).";\n\n";}}function
connect_error(){global$b,$g,$pi,$n,$ic;if(DB!=""){header("HTTP/1.1 404 Not Found");page_header(lang(37).": ".h(DB),lang(112),true);}else{if($_POST["db"]&&!$n)queries_redirect(substr(ME,0,-1),lang(113),drop_databases($_POST["db"]));page_header(lang(114),$n,false);echo" \n";foreach(array('database'=>lang(115),'privileges'=>lang(71),'processlist'=>lang(116),'variables'=>lang(117),'status'=>lang(118),)as$z=>$X){if(support($z))echo"$X\n";}echo" ".lang(119,$ic[DRIVER],"".h($g->server_info)."","$g->extension")."\n"," ".lang(120,"".h(logged_user())."")."\n";$k=$b->databases();if($k){$ch=support("scheme");$nb=collations();echo" \n",script("tableCheck();");}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$g->select_db(DB):isset($_GET["sql"])||isset($_GET["dump"])||isset($_GET["database"])||isset($_GET["processlist"])||isset($_GET["privileges"])||isset($_GET["user"])||isset($_GET["variables"])||$_GET["script"]=="connect"||$_GET["script"]=="kill")){if(DB!=""||$_GET["refresh"]){restart_session();set_session("dbs",null);}connect_error();exit;}if(support("scheme")&&DB!=""&&$_GET["ns"]!==""){if(!isset($_GET["ns"]))redirect(preg_replace('~ns=[^&]*&~','',ME)."ns=".get_schema());if(!set_schema($_GET["ns"])){header("HTTP/1.1 404 Not Found");page_header(lang(77).": ".h($_GET["ns"]),lang(128),true);page_footer("ns");exit;}}$rf="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class
TmpFile{var$handler;var$size;function
__construct(){$this->handler=tmpfile();}function
write($Db){$this->size+=strlen($Db);fwrite($this->handler,$Db);}function
send(){fseek($this->handler,0);fpassthru($this->handler);fclose($this->handler);}}$_c="'(?:''|[^'\\\\]|\\\\.)*'";$Ud="IN|OUT|INOUT";if(isset($_GET["select"])&&($_POST["edit"]||$_POST["clone"])&&!$_POST["save"])$_GET["edit"]=$_GET["select"];if(isset($_GET["callf"]))$_GET["call"]=$_GET["callf"];if(isset($_GET["function"]))$_GET["procedure"]=$_GET["function"];if(isset($_GET["download"])){$a=$_GET["download"];$p=fields($a);header("Content-Type: application/octet-stream");header("Content-Disposition: attachment; filename=".friendly_url("$a-".implode("_",$_GET["where"])).".".friendly_url($_GET["field"]));$L=array(idf_escape($_GET["field"]));$H=$m->select($a,$L,array(where($_GET,$p)),$L);$J=($H?$H->fetch_row():array());echo$m->value($J[0],$p[$_GET["field"]]);exit;}elseif(isset($_GET["table"])){$a=$_GET["table"];$p=fields($a);if(!$p)$n=error();$R=table_status1($a,true);$D=$b->tableName($R);page_header(($p&&is_view($R)?$R['Engine']=='materialized view'?lang(129):lang(130):lang(131)).": ".($D!=""?$D:h($a)),$n);$b->selectLinks($R);$sb=$R["Comment"];if($sb!="")echo"".lang(50).": ".h($sb)."\n";if($p)$b->tableStructurePrint($p);if(!is_view($R)){if(support("indexes")){echo" ".lang(132)."\n";$x=indexes($a);if($x)$b->tableIndexesPrint($x);echo''.lang(133)."\n";}if(fk_support($R)){echo" ".lang(100)."\n";$hd=foreign_keys($a);if($hd){echo"\n","".lang(134)." | ".lang(135)." | ".lang(103)." | ".lang(102)." | | \n";foreach($hd
as$D=>$r){echo"","".implode(", ",array_map('h',$r["source"])).""," | ".($r["db"]!=""?"".h($r["db"]).".":"").($r["ns"]!=""?"".h($r["ns"]).".":"").h($r["table"])."","(".implode(", ",array_map('h',$r["target"])).")"," | ".h($r["on_delete"])."\n"," | ".h($r["on_update"])."\n",' | '.lang(136).'';}echo" | \n";}echo''.lang(137)."\n";}}if(support(is_view($R)?"view_trigger":"trigger")){echo" ".lang(138)."\n";$Ai=triggers($a);if($Ai){echo"\n";foreach($Ai
as$z=>$X)echo"".h($X[0])." | ".h($X[1])." | ".h($z)." | ".lang(136)."\n";echo" |
---|
\n";}echo''.lang(139)."\n";}}elseif(isset($_GET["schema"])){page_header(lang(70),"",array(),h(DB.($_GET["ns"]?".$_GET[ns]":"")));$Sh=array();$Th=array();$ea=($_GET["schema"]?$_GET["schema"]:$_COOKIE["adminer_schema-".str_replace(".","_",DB)]);preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~',$ea,$Ee,PREG_SET_ORDER);foreach($Ee
as$t=>$C){$Sh[$C[1]]=array($C[2],$C[3]);$Th[]="\n\t'".js_escape($C[1])."': [ $C[2], $C[3] ]";}$qi=0;$Qa=-1;$bh=array();$Gg=array();$te=array();foreach(table_status('',true)as$Q=>$R){if(is_view($R))continue;$gg=0;$bh[$Q]["fields"]=array();foreach(fields($Q)as$D=>$o){$gg+=1.25;$o["pos"]=$gg;$bh[$Q]["fields"][$D]=$o;}$bh[$Q]["pos"]=($Sh[$Q]?$Sh[$Q]:array($qi,0));foreach($b->foreignKeys($Q)as$X){if(!$X["db"]){$re=$Qa;if($Sh[$Q][1]||$Sh[$X["table"]][1])$re=min(floatval($Sh[$Q][1]),floatval($Sh[$X["table"]][1]))-1;else$Qa-=.1;while($te[(string)$re])$re-=.0001;$bh[$Q]["references"][$X["table"]][(string)$re]=array($X["source"],$X["target"]);$Gg[$X["table"]][$Q][(string)$re]=$X["target"];$te[(string)$re]=true;}}$qi=max($qi,$bh[$Q]["pos"][0]+2.5+$gg);}echo'
';foreach($bh
as$D=>$Q){echo" ",' '.h($D)."",script("qsl('div').onmousedown = schemaMousedown;");foreach($Q["fields"]as$o){$X=' '.h($o["field"]).'';echo" ".($o["primary"]?" $X":$X);}foreach((array)$Q["references"]as$Zh=>$Hg){foreach($Hg
as$re=>$Dg){$se=$re-$Sh[$D][1];$t=0;foreach($Dg[0]as$xh)echo"\n ";}}foreach((array)$Gg[$D]as$Zh=>$Hg){foreach($Hg
as$re=>$e){$se=$re-$Sh[$D][1];$t=0;foreach($e
as$Yh)echo"\n ";}}echo"\n \n";}foreach($bh
as$D=>$Q){foreach((array)$Q["references"]as$Zh=>$Hg){foreach($Hg
as$re=>$Dg){$Se=$qi;$Ie=-10;foreach($Dg[0]as$z=>$xh){$hg=$Q["pos"][0]+$Q["fields"][$xh]["pos"];$ig=$bh[$Zh]["pos"][0]+$bh[$Zh]["fields"][$Dg[1][$z]]["pos"];$Se=min($Se,$hg,$ig);$Ie=max($Ie,$hg,$ig);}echo" \n";}}}echo'
',lang(140),'
';}elseif(isset($_GET["dump"])){$a=$_GET["dump"];if($_POST&&!$n){$Gb="";foreach(array("output","format","db_style","routines","events","table_style","auto_increment","triggers","data_style")as$z)$Gb.="&$z=".urlencode($_POST[$z]);cookie("adminer_export",substr($Gb,1));$S=array_flip((array)$_POST["tables"])+array_flip((array)$_POST["data"]);$Mc=dump_headers((count($S)==1?key($S):DB),(DB==""||count($S)>1));$ce=preg_match('~sql~',$_POST["format"]);if($ce){echo"-- Adminer $ia ".$ic[DRIVER]." ".str_replace("\n"," ",$g->server_info)." dump\n\n";if($y=="sql"){echo"SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
".($_POST["data_style"]?"SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
":"")."
";$g->query("SET time_zone = '+00:00'");$g->query("SET sql_mode = ''");}}$Jh=$_POST["db_style"];$k=array(DB);if(DB==""){$k=$_POST["databases"];if(is_string($k))$k=explode("\n",rtrim(str_replace("\r","",$k),"\n"));}foreach((array)$k
as$l){$b->dumpDatabase($l);if($g->select_db($l)){if($ce&&preg_match('~CREATE~',$Jh)&&($i=$g->result("SHOW CREATE DATABASE ".idf_escape($l),1))){set_utf8mb4($i);if($Jh=="DROP+CREATE")echo"DROP DATABASE IF EXISTS ".idf_escape($l).";\n";echo"$i;\n";}if($ce){if($Jh)echo
use_sql($l).";\n\n";$Kf="";if($_POST["routines"]){foreach(array("FUNCTION","PROCEDURE")as$Vg){foreach(get_rows("SHOW $Vg STATUS WHERE Db = ".q($l),null,"-- ")as$J){$i=remove_definer($g->result("SHOW CREATE $Vg ".idf_escape($J["Name"]),2));set_utf8mb4($i);$Kf.=($Jh!='DROP+CREATE'?"DROP $Vg IF EXISTS ".idf_escape($J["Name"]).";;\n":"")."$i;;\n\n";}}}if($_POST["events"]){foreach(get_rows("SHOW EVENTS",null,"-- ")as$J){$i=remove_definer($g->result("SHOW CREATE EVENT ".idf_escape($J["Name"]),3));set_utf8mb4($i);$Kf.=($Jh!='DROP+CREATE'?"DROP EVENT IF EXISTS ".idf_escape($J["Name"]).";;\n":"")."$i;;\n\n";}}if($Kf)echo"DELIMITER ;;\n\n$Kf"."DELIMITER ;\n\n";}if($_POST["table_style"]||$_POST["data_style"]){$aj=array();foreach(table_status('',true)as$D=>$R){$Q=(DB==""||in_array($D,(array)$_POST["tables"]));$Qb=(DB==""||in_array($D,(array)$_POST["data"]));if($Q||$Qb){if($Mc=="tar"){$mi=new
TmpFile;ob_start(array($mi,'write'),1e5);}$b->dumpTable($D,($Q?$_POST["table_style"]:""),(is_view($R)?2:0));if(is_view($R))$aj[]=$D;elseif($Qb){$p=fields($D);$b->dumpData($D,$_POST["data_style"],"SELECT *".convert_fields($p,$p)." FROM ".table($D));}if($ce&&$_POST["triggers"]&&$Q&&($Ai=trigger_sql($D)))echo"\nDELIMITER ;;\n$Ai\nDELIMITER ;\n";if($Mc=="tar"){ob_end_flush();tar_file((DB!=""?"":"$l/")."$D.csv",$mi);}elseif($ce)echo"\n";}}if(function_exists('foreign_keys_sql')){foreach(table_status('',true)as$D=>$R){$Q=(DB==""||in_array($D,(array)$_POST["tables"]));if($Q&&!is_view($R))echo
foreign_keys_sql($D);}}foreach($aj
as$Zi)$b->dumpTable($Zi,$_POST["table_style"],1);if($Mc=="tar")echo
pack("x512");}}}if($ce)echo"-- ".$g->result("SELECT NOW()")."\n";exit;}page_header(lang(73),$n,($_GET["export"]!=""?array("table"=>$_GET["export"]):array()),h(DB));echo'
';$Zc=true;foreach($lg
as$z=>$X){if($z!=""&&$X>1){echo($Zc?"":" ")."".h($z)."";$Zc=false;}}}elseif(isset($_GET["privileges"])){page_header(lang(71));echo' '.lang(146)."";$H=$g->query("SELECT User, Host FROM mysql.".(DB==""?"user":"db WHERE ".q(DB)." LIKE Db")." ORDER BY Host, User");$od=$H;if(!$H)$H=$g->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");echo" \n";}elseif(isset($_GET["sql"])){if(!$n&&$_POST["export"]){dump_headers("sql");$b->dumpTable("","");$b->dumpData("","table",$_POST["query"]);exit;}restart_session();$Bd=&get_session("queries");$Ad=&$Bd[DB];if(!$n&&$_POST["clear"]){$Ad=array();redirect(remove_from_uri("history"));}page_header((isset($_GET["import"])?lang(72):lang(64)),$n);if(!$n&&$_POST){$ld=false;if(!isset($_GET["import"]))$G=$_POST["query"];elseif($_POST["webfile"]){$Ah=$b->importServerPath();$ld=@fopen((file_exists($Ah)?$Ah:"compress.zlib://$Ah.gz"),"rb");$G=($ld?fread($ld,1e6):false);}else$G=get_file("sql_file",true);if(is_string($G)){if(function_exists('memory_get_usage'))@ini_set("memory_limit",max(ini_bytes("memory_limit"),2*strlen($G)+memory_get_usage()+8e6));if($G!=""&&strlen($G)<1e6){$wg=$G.(preg_match("~;[ \t\r\n]*\$~",$G)?"":";");if(!$Ad||reset(end($Ad))!=$wg){restart_session();$Ad[]=array($wg,time());set_session("queries",$Bd);stop_session();}}$yh="(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)";$ac=";";$jf=0;$xc=true;$h=connect();if(is_object($h)&&DB!=""){$h->select_db(DB);if($_GET["ns"]!="")set_schema($_GET["ns"],$h);}$rb=0;$Bc=array();$Rf='[\'"'.($y=="sql"?'`#':($y=="sqlite"?'`[':($y=="mssql"?'[':''))).']|/\*|-- |$'.($y=="pgsql"?'|\$[^$]*\$':'');$ri=microtime(true);parse_str($_COOKIE["adminer_export"],$ya);$oc=$b->dumpFormat();unset($oc["sql"]);while($G!=""){if(!$jf&&preg_match("~^$yh*+DELIMITER\\s+(\\S+)~i",$G,$C)){$ac=$C[1];$G=substr($G,strlen($C[0]));}else{preg_match('('.preg_quote($ac)."\\s*|$Rf)",$G,$C,PREG_OFFSET_CAPTURE,$jf);list($jd,$gg)=$C[0];if(!$jd&&$ld&&!feof($ld))$G.=fread($ld,1e5);else{if(!$jd&&rtrim($G)=="")break;$jf=$gg+strlen($jd);if($jd&&rtrim($jd)!=$ac){while(preg_match('('.($jd=='/*'?'\*/':($jd=='['?']':(preg_match('~^-- |^#~',$jd)?"\n":preg_quote($jd)."|\\\\."))).'|$)s',$G,$C,PREG_OFFSET_CAPTURE,$jf)){$Zg=$C[0][0];if(!$Zg&&$ld&&!feof($ld))$G.=fread($ld,1e5);else{$jf=$C[0][1]+strlen($Zg);if($Zg[0]!="\\")break;}}}else{$xc=false;$wg=substr($G,0,$gg);$rb++;$og="".$b->sqlCommandQuery($wg)." \n";if($y=="sqlite"&&preg_match("~^$yh*+ATTACH\\b~i",$wg,$C)){echo$og,"".lang(147)."\n";$Bc[]=" $rb";if($_POST["error_stops"])break;}else{if(!$_POST["only_errors"]){echo$og;ob_flush();flush();}$Eh=microtime(true);if($g->multi_query($wg)&&is_object($h)&&preg_match("~^$yh*+USE\\b~i",$wg))$h->query($wg);do{$H=$g->store_result();if($g->error){echo($_POST["only_errors"]?$og:"")," ".lang(148).($g->errno?" ($g->errno)":"").": ".error()."\n";$Bc[]=" $rb";if($_POST["error_stops"])break
2;}else{$fi=" (".format_time($Eh).")".(strlen($wg)<1000?" ".lang(10)."":"");$_a=$g->affected_rows;$dj=($_POST["only_errors"]?"":$m->warnings());$ej="warnings-$rb";if($dj)$fi.=", ".lang(46)."".script("qsl('a').onclick = partial(toggle, '$ej');","");$Jc=null;$Kc="explain-$rb";if(is_object($H)){$_=$_POST["limit"];$Df=select($H,$h,array(),$_);if(!$_POST["only_errors"]){echo" \n";}}else{if(preg_match("~^$yh*+(CREATE|DROP|ALTER)$yh++(DATABASE|SCHEMA)\\b~i",$wg)){restart_session();set_session("dbs",null);stop_session();}if(!$_POST["only_errors"])echo"".lang(151,$_a)."$fi\n";}echo($dj?" \n$dj \n":"");if($Jc){echo"\n";select($Jc,$h,$Df);echo" \n";}}$Eh=microtime(true);}while($g->next_result());}$G=substr($G,$jf);$jf=0;}}}}if($xc)echo"".lang(152)."\n";elseif($_POST["only_errors"]){echo" ".lang(153,$rb-count($Bc))," (".format_time($ri).")\n";}elseif($Bc&&$rb>1)echo" ".lang(148).": ".implode("",$Bc)."\n";}else
echo" ".upload_error($G)."\n";}echo'
';}elseif(isset($_GET["edit"])){$a=$_GET["edit"];$p=fields($a);$Z=(isset($_GET["select"])?($_POST["check"]&&count($_POST["check"])==1?where_check($_POST["check"][0],$p):""):where($_GET,$p));$Ki=(isset($_GET["select"])?$_POST["edit"]:$Z);foreach($p
as$D=>$o){if(!isset($o["privileges"][$Ki?"update":"insert"])||$b->fieldName($o)==""||$o["generated"])unset($p[$D]);}if($_POST&&!$n&&!isset($_GET["select"])){$B=$_POST["referer"];if($_POST["insert"])$B=($Ki?null:$_SERVER["REQUEST_URI"]);elseif(!preg_match('~^.+&select=.+$~',$B))$B=ME."select=".urlencode($a);$x=indexes($a);$Fi=unique_array($_GET["where"],$x);$zg="\nWHERE $Z";if(isset($_POST["delete"]))queries_redirect($B,lang(166),$m->delete($a,$zg,!$Fi));else{$N=array();foreach($p
as$D=>$o){$X=process_input($o);if($X!==false&&$X!==null)$N[idf_escape($D)]=$X;}if($Ki){if(!$N)redirect($B);queries_redirect($B,lang(167),$m->update($a,$N,$zg,!$Fi));if(is_ajax()){page_headers();page_messages($n);exit;}}else{$H=$m->insert($a,$N);$qe=($H?last_id():0);queries_redirect($B,lang(168,($qe?" $qe":"")),$H);}}}$J=null;if($_POST["save"])$J=(array)$_POST["fields"];elseif($Z){$L=array();foreach($p
as$D=>$o){if(isset($o["privileges"]["select"])){$Ga=convert_field($o);if($_POST["clone"]&&$o["auto_increment"])$Ga="''";if($y=="sql"&&preg_match("~enum|set~",$o["type"]))$Ga="1*".idf_escape($D);$L[]=($Ga?"$Ga AS ":"").idf_escape($D);}}$J=array();if(!support("table"))$L=array("*");if($L){$H=$m->select($a,$L,array($Z),$L,array(),(isset($_GET["select"])?2:1));if(!$H)$n=error();else{$J=$H->fetch_assoc();if(!$J)$J=false;}if(isset($_GET["select"])&&(!$J||$H->fetch_assoc()))$J=null;}}if(!support("table")&&!$p){if(!$Z){$H=$m->select($a,array("*"),$Z,array("*"));$J=($H?$H->fetch_assoc():false);if(!$J)$J=array($m->primary=>"");}if($J){foreach($J
as$z=>$X){if(!$Z)$J[$z]=null;$p[$z]=array("field"=>$z,"null"=>($z!=$m->primary),"auto_increment"=>($z==$m->primary));}}}edit_form($a,$p,$J,$Ki);}elseif(isset($_GET["create"])){$a=$_GET["create"];$Tf=array();foreach(array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST')as$z)$Tf[$z]=$z;$Fg=referencable_primary($a);$hd=array();foreach($Fg
as$Qh=>$o)$hd[str_replace("`","``",$Qh)."`".str_replace("`","``",$o["field"])]=$Qh;$Gf=array();$R=array();if($a!=""){$Gf=fields($a);$R=table_status($a);if(!$R)$n=lang(9);}$J=$_POST;$J["fields"]=(array)$J["fields"];if($J["auto_increment_col"])$J["fields"][$J["auto_increment_col"]]["auto_increment"]=true;if($_POST)set_adminer_settings(array("comments"=>$_POST["comments"],"defaults"=>$_POST["defaults"]));if($_POST&&!process_fields($J["fields"])&&!$n){if($_POST["drop"])queries_redirect(substr(ME,0,-1),lang(169),drop_tables(array($a)));else{$p=array();$Da=array();$Oi=false;$fd=array();$Ff=reset($Gf);$Ba=" FIRST";foreach($J["fields"]as$z=>$o){$r=$hd[$o["type"]];$Bi=($r!==null?$Fg[$r]:$o);if($o["field"]!=""){if(!$o["has_default"])$o["default"]=null;if($z==$J["auto_increment_col"])$o["auto_increment"]=true;$tg=process_field($o,$Bi);$Da[]=array($o["orig"],$tg,$Ba);if(!$Ff||$tg!=process_field($Ff,$Ff)){$p[]=array($o["orig"],$tg,$Ba);if($o["orig"]!=""||$Ba)$Oi=true;}if($r!==null)$fd[idf_escape($o["field"])]=($a!=""&&$y!="sqlite"?"ADD":" ").format_foreign_key(array('table'=>$hd[$o["type"]],'source'=>array($o["field"]),'target'=>array($Bi["field"]),'on_delete'=>$o["on_delete"],));$Ba=" AFTER ".idf_escape($o["field"]);}elseif($o["orig"]!=""){$Oi=true;$p[]=array($o["orig"]);}if($o["orig"]!=""){$Ff=next($Gf);if(!$Ff)$Ba="";}}$Vf="";if($Tf[$J["partition_by"]]){$Wf=array();if($J["partition_by"]=='RANGE'||$J["partition_by"]=='LIST'){foreach(array_filter($J["partition_names"])as$z=>$X){$Y=$J["partition_values"][$z];$Wf[]="\n PARTITION ".idf_escape($X)." VALUES ".($J["partition_by"]=='RANGE'?"LESS THAN":"IN").($Y!=""?" ($Y)":" MAXVALUE");}}$Vf.="\nPARTITION BY $J[partition_by]($J[partition])".($Wf?" (".implode(",",$Wf)."\n)":($J["partitions"]?" PARTITIONS ".(+$J["partitions"]):""));}elseif(support("partitioning")&&preg_match("~partitioned~",$R["Create_options"]))$Vf.="\nREMOVE PARTITIONING";$Me=lang(170);if($a==""){cookie("adminer_engine",$J["Engine"]);$Me=lang(171);}$D=trim($J["name"]);queries_redirect(ME.(support("table")?"table=":"select=").urlencode($D),$Me,alter_table($a,$D,($y=="sqlite"&&($Oi||$fd)?$Da:$p),$fd,($J["Comment"]!=$R["Comment"]?$J["Comment"]:null),($J["Engine"]&&$J["Engine"]!=$R["Engine"]?$J["Engine"]:""),($J["Collation"]&&$J["Collation"]!=$R["Collation"]?$J["Collation"]:""),($J["Auto_increment"]!=""?number($J["Auto_increment"]):""),$Vf));}}page_header(($a!=""?lang(44):lang(74)),$n,array("table"=>$a),h($a));if(!$_POST){$J=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($U["int"])?"int":(isset($U["integer"])?"integer":"")),"on_update"=>"")),"partition_names"=>array(""),);if($a!=""){$J=$R;$J["name"]=$a;$J["fields"]=array();if(!$_GET["auto_increment"])$J["Auto_increment"]="";foreach($Gf
as$o){$o["has_default"]=isset($o["default"]);$J["fields"][]=$o;}if(support("partitioning")){$md="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($a);$H=$g->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $md ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($J["partition_by"],$J["partitions"],$J["partition"])=$H->fetch_row();$Wf=get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $md AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");$Wf[""]="";$J["partition_names"]=array_keys($Wf);$J["partition_values"]=array_values($Wf);}}}$nb=collations();$zc=engines();foreach($zc
as$yc){if(!strcasecmp($yc,$J["Engine"])){$J["Engine"]=$yc;break;}}echo'
';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Md=array("PRIMARY","UNIQUE","INDEX");$R=table_status($a,true);if(preg_match('~MyISAM|M?aria'.(min_version(5.6,'10.0.5')?'|InnoDB':'').'~i',$R["Engine"]))$Md[]="FULLTEXT";if(preg_match('~MyISAM|M?aria'.(min_version(5.7,'10.2.2')?'|InnoDB':'').'~i',$R["Engine"]))$Md[]="SPATIAL";$x=indexes($a);$mg=array();if($y=="mongo"){$mg=$x["_id_"];unset($Md[0]);unset($x["_id_"]);}$J=$_POST;if($_POST&&!$n&&!$_POST["add"]&&!$_POST["drop_col"]){$c=array();foreach($J["indexes"]as$w){$D=$w["name"];if(in_array($w["type"],$Md)){$e=array();$we=array();$cc=array();$N=array();ksort($w["columns"]);foreach($w["columns"]as$z=>$d){if($d!=""){$ve=$w["lengths"][$z];$bc=$w["descs"][$z];$N[]=idf_escape($d).($ve?"(".(+$ve).")":"").($bc?" DESC":"");$e[]=$d;$we[]=($ve?$ve:null);$cc[]=$bc;}}if($e){$Ic=$x[$D];if($Ic){ksort($Ic["columns"]);ksort($Ic["lengths"]);ksort($Ic["descs"]);if($w["type"]==$Ic["type"]&&array_values($Ic["columns"])===$e&&(!$Ic["lengths"]||array_values($Ic["lengths"])===$we)&&array_values($Ic["descs"])===$cc){unset($x[$D]);continue;}}$c[]=array($w["type"],$D,$N);}}}foreach($x
as$D=>$Ic)$c[]=array($Ic["type"],$D,"DROP");if(!$c)redirect(ME."table=".urlencode($a));queries_redirect(ME."table=".urlencode($a),lang(180),alter_indexes($a,$c));}page_header(lang(132),$n,array("table"=>$a),h($a));$p=array_keys(fields($a));if($_POST["add"]){foreach($J["indexes"]as$z=>$w){if($w["columns"][count($w["columns"])]!="")$J["indexes"][$z]["columns"][]="";}$w=end($J["indexes"]);if($w["type"]||array_filter($w["columns"],'strlen'))$J["indexes"][]=array("columns"=>array(1=>""));}if(!$J){foreach($x
as$z=>$w){$x[$z]["name"]=$z;$x[$z]["columns"][]="";}$x[]=array("columns"=>array(1=>""));$J["indexes"]=$x;}echo'
';}elseif(isset($_GET["database"])){$J=$_POST;if($_POST&&!$n&&!isset($_POST["add_x"])){$D=trim($J["name"]);if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),lang(184),drop_databases(array(DB)));}elseif(DB!==$D){if(DB!=""){$_GET["db"]=$D;queries_redirect(preg_replace('~\bdb=[^&]*&~','',ME)."db=".urlencode($D),lang(185),rename_database($D,$J["collation"]));}else{$k=explode("\n",str_replace("\r","",$D));$Kh=true;$pe="";foreach($k
as$l){if(count($k)==1||$l!=""){if(!create_database($l,$J["collation"]))$Kh=false;$pe=$l;}}restart_session();set_session("dbs",null);queries_redirect(ME."db=".urlencode($pe),lang(186),$Kh);}}else{if(!$J["collation"])redirect(substr(ME,0,-1));query_redirect("ALTER DATABASE ".idf_escape($D).(preg_match('~^[a-z0-9_]+$~i',$J["collation"])?" COLLATE $J[collation]":""),substr(ME,0,-1),lang(187));}}page_header(DB!=""?lang(67):lang(115),$n,array(),h(DB));$nb=collations();$D=DB;if($_POST)$D=$J["name"];elseif(DB!="")$J["collation"]=db_collation(DB,$nb);elseif($y=="sql"){foreach(get_vals("SHOW GRANTS")as$od){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\.\*)?~',$od,$C)&&$C[1]){$D=stripcslashes(idf_unescape("`$C[2]`"));break;}}}echo'
';}elseif(isset($_GET["scheme"])){$J=$_POST;if($_POST&&!$n){$A=preg_replace('~ns=[^&]*&~','',ME)."ns=";if($_POST["drop"])query_redirect("DROP SCHEMA ".idf_escape($_GET["ns"]),$A,lang(188));else{$D=trim($J["name"]);$A.=urlencode($D);if($_GET["ns"]=="")query_redirect("CREATE SCHEMA ".idf_escape($D),$A,lang(189));elseif($_GET["ns"]!=$D)query_redirect("ALTER SCHEMA ".idf_escape($_GET["ns"])." RENAME TO ".idf_escape($D),$A,lang(190));else
redirect($A);}}page_header($_GET["ns"]!=""?lang(68):lang(69),$n);if(!$J)$J["name"]=$_GET["ns"];echo'
';}elseif(isset($_GET["call"])){$da=($_GET["name"]?$_GET["name"]:$_GET["call"]);page_header(lang(191).": ".h($da),$n);$Vg=routine($_GET["call"],(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Kd=array();$Kf=array();foreach($Vg["fields"]as$t=>$o){if(substr($o["inout"],-3)=="OUT")$Kf[$t]="@".idf_escape($o["field"])." AS ".idf_escape($o["field"]);if(!$o["inout"]||substr($o["inout"],0,2)=="IN")$Kd[]=$t;}if(!$n&&$_POST){$Ya=array();foreach($Vg["fields"]as$z=>$o){if(in_array($z,$Kd)){$X=process_input($o);if($X===false)$X="''";if(isset($Kf[$z]))$g->query("SET @".idf_escape($o["field"])." = $X");}$Ya[]=(isset($Kf[$z])?"@".idf_escape($o["field"]):$X);}$G=(isset($_GET["callf"])?"SELECT":"CALL")." ".table($da)."(".implode(", ",$Ya).")";$Eh=microtime(true);$H=$g->multi_query($G);$_a=$g->affected_rows;echo$b->selectQuery($G,$Eh,!$H);if(!$H)echo"".error()."\n";else{$h=connect();if(is_object($h))$h->select_db(DB);do{$H=$g->store_result();if(is_object($H))select($H,$h);else
echo" ".lang(192,$_a)." ".@date("H:i:s")."\n";}while($g->next_result());if($Kf)select($g->query("SELECT ".implode(", ",$Kf)));}}echo'
';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];$D=$_GET["name"];$J=$_POST;if($_POST&&!$n&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){$Me=($_POST["drop"]?lang(193):($D!=""?lang(194):lang(195)));$B=ME."table=".urlencode($a);if(!$_POST["drop"]){$J["source"]=array_filter($J["source"],'strlen');ksort($J["source"]);$Yh=array();foreach($J["source"]as$z=>$X)$Yh[$z]=$J["target"][$z];$J["target"]=$Yh;}if($y=="sqlite")queries_redirect($B,$Me,recreate_table($a,$a,array(),array(),array(" $D"=>($_POST["drop"]?"":" ".format_foreign_key($J)))));else{$c="ALTER TABLE ".table($a);$jc="\nDROP ".($y=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($D);if($_POST["drop"])query_redirect($c.$jc,$B,$Me);else{query_redirect($c.($D!=""?"$jc,":"")."\nADD".format_foreign_key($J),$B,$Me);$n=lang(196)." $n";}}}page_header(lang(197),$n,array("table"=>$a),h($a));if($_POST){ksort($J["source"]);if($_POST["add"])$J["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$J["target"]=array();}elseif($D!=""){$hd=foreign_keys($a);$J=$hd[$D];$J["source"][]="";}else{$J["table"]=$a;$J["source"]=array("");}echo'
';}elseif(isset($_GET["view"])){$a=$_GET["view"];$J=$_POST;$Hf="VIEW";if($y=="pgsql"&&$a!=""){$O=table_status($a);$Hf=strtoupper($O["Engine"]);}if($_POST&&!$n){$D=trim($J["name"]);$Ga=" AS\n$J[select]";$B=ME."table=".urlencode($D);$Me=lang(201);$T=($_POST["materialized"]?"MATERIALIZED VIEW":"VIEW");if(!$_POST["drop"]&&$a==$D&&$y!="sqlite"&&$T=="VIEW"&&$Hf=="VIEW")query_redirect(($y=="mssql"?"ALTER":"CREATE OR REPLACE")." VIEW ".table($D).$Ga,$B,$Me);else{$ai=$D."_adminer_".uniqid();drop_create("DROP $Hf ".table($a),"CREATE $T ".table($D).$Ga,"DROP $T ".table($D),"CREATE $T ".table($ai).$Ga,"DROP $T ".table($ai),($_POST["drop"]?substr(ME,0,-1):$B),lang(202),$Me,lang(203),$a,$D);}}if(!$_POST&&$a!=""){$J=view($a);$J["name"]=$a;$J["materialized"]=($Hf!="VIEW");if(!$n)$n=error();}page_header(($a!=""?lang(43):lang(204)),$n,array("table"=>$a),h($a));echo'
';}elseif(isset($_GET["event"])){$aa=$_GET["event"];$Xd=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$Gh=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");$J=$_POST;if($_POST&&!$n){if($_POST["drop"])query_redirect("DROP EVENT ".idf_escape($aa),substr(ME,0,-1),lang(205));elseif(in_array($J["INTERVAL_FIELD"],$Xd)&&isset($Gh[$J["STATUS"]])){$ah="\nON SCHEDULE ".($J["INTERVAL_VALUE"]?"EVERY ".q($J["INTERVAL_VALUE"])." $J[INTERVAL_FIELD]".($J["STARTS"]?" STARTS ".q($J["STARTS"]):"").($J["ENDS"]?" ENDS ".q($J["ENDS"]):""):"AT ".q($J["STARTS"]))." ON COMPLETION".($J["ON_COMPLETION"]?"":" NOT")." PRESERVE";queries_redirect(substr(ME,0,-1),($aa!=""?lang(206):lang(207)),queries(($aa!=""?"ALTER EVENT ".idf_escape($aa).$ah.($aa!=$J["EVENT_NAME"]?"\nRENAME TO ".idf_escape($J["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($J["EVENT_NAME"]).$ah)."\n".$Gh[$J["STATUS"]]." COMMENT ".q($J["EVENT_COMMENT"]).rtrim(" DO\n$J[EVENT_DEFINITION]",";").";"));}}page_header(($aa!=""?lang(208).": ".h($aa):lang(209)),$n);if(!$J&&$aa!=""){$K=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($aa));$J=reset($K);}echo'
';}elseif(isset($_GET["procedure"])){$da=($_GET["name"]?$_GET["name"]:$_GET["procedure"]);$Vg=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$J=$_POST;$J["fields"]=(array)$J["fields"];if($_POST&&!process_fields($J["fields"])&&!$n){$Ef=routine($_GET["procedure"],$Vg);$ai="$J[name]_adminer_".uniqid();drop_create("DROP $Vg ".routine_id($da,$Ef),create_routine($Vg,$J),"DROP $Vg ".routine_id($J["name"],$J),create_routine($Vg,array("name"=>$ai)+$J),"DROP $Vg ".routine_id($ai,$J),substr(ME,0,-1),lang(214),lang(215),lang(216),$da,$J["name"]);}page_header(($da!=""?(isset($_GET["function"])?lang(217):lang(218)).": ".h($da):(isset($_GET["function"])?lang(219):lang(220))),$n);if(!$_POST&&$da!=""){$J=routine($_GET["procedure"],$Vg);$J["name"]=$da;}$nb=get_vals("SHOW CHARACTER SET");sort($nb);$Wg=routine_languages();echo'
';}elseif(isset($_GET["sequence"])){$fa=$_GET["sequence"];$J=$_POST;if($_POST&&!$n){$A=substr(ME,0,-1);$D=trim($J["name"]);if($_POST["drop"])query_redirect("DROP SEQUENCE ".idf_escape($fa),$A,lang(222));elseif($fa=="")query_redirect("CREATE SEQUENCE ".idf_escape($D),$A,lang(223));elseif($fa!=$D)query_redirect("ALTER SEQUENCE ".idf_escape($fa)." RENAME TO ".idf_escape($D),$A,lang(224));else
redirect($A);}page_header($fa!=""?lang(225).": ".h($fa):lang(226),$n);if(!$J)$J["name"]=$fa;echo'
';}elseif(isset($_GET["type"])){$ga=$_GET["type"];$J=$_POST;if($_POST&&!$n){$A=substr(ME,0,-1);if($_POST["drop"])query_redirect("DROP TYPE ".idf_escape($ga),$A,lang(227));else
query_redirect("CREATE TYPE ".idf_escape(trim($J["name"]))." $J[as]",$A,lang(228));}page_header($ga!=""?lang(229).": ".h($ga):lang(230),$n);if(!$J)$J["as"]="AS ";echo'
';}elseif(isset($_GET["trigger"])){$a=$_GET["trigger"];$D=$_GET["name"];$_i=trigger_options();$J=(array)trigger($D)+array("Trigger"=>$a."_bi");if($_POST){if(!$n&&in_array($_POST["Timing"],$_i["Timing"])&&in_array($_POST["Event"],$_i["Event"])&&in_array($_POST["Type"],$_i["Type"])){$qf=" ON ".table($a);$jc="DROP TRIGGER ".idf_escape($D).($y=="pgsql"?$qf:"");$B=ME."table=".urlencode($a);if($_POST["drop"])query_redirect($jc,$B,lang(231));else{if($D!="")queries($jc);queries_redirect($B,($D!=""?lang(232):lang(233)),queries(create_trigger($qf,$_POST)));if($D!="")queries(create_trigger($qf,$J+array("Type"=>reset($_i["Type"]))));}}$J=$_POST;}page_header(($D!=""?lang(234).": ".h($D):lang(235)),$n,array("table"=>$a));echo'
';}elseif(isset($_GET["user"])){$ha=$_GET["user"];$rg=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$J){foreach(explode(",",($J["Privilege"]=="Grant option"?"":$J["Context"]))as$Eb)$rg[$Eb][$J["Privilege"]]=$J["Comment"];}$rg["Server Admin"]+=$rg["File access on server"];$rg["Databases"]["Create routine"]=$rg["Procedures"]["Create routine"];unset($rg["Procedures"]["Create routine"]);$rg["Columns"]=array();foreach(array("Select","Insert","Update","References")as$X)$rg["Columns"][$X]=$rg["Tables"][$X];unset($rg["Server Admin"]["Usage"]);foreach($rg["Tables"]as$z=>$X)unset($rg["Databases"][$z]);$Ze=array();if($_POST){foreach($_POST["objects"]as$z=>$X)$Ze[$X]=(array)$Ze[$X]+(array)$_POST["grants"][$z];}$pd=array();$of="";if(isset($_GET["host"])&&($H=$g->query("SHOW GRANTS FOR ".q($ha)."@".q($_GET["host"])))){while($J=$H->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$J[0],$C)&&preg_match_all('~ *([^(,]*[^ ,(])( *\([^)]+\))?~',$C[1],$Ee,PREG_SET_ORDER)){foreach($Ee
as$X){if($X[1]!="USAGE")$pd["$C[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$J[0]))$pd["$C[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$J[0],$C))$of=$C[1];}}if($_POST&&!$n){$pf=(isset($_GET["host"])?q($ha)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $pf",ME."privileges=",lang(238));else{$bf=q($_POST["user"])."@".q($_POST["host"]);$Yf=$_POST["pass"];if($Yf!=''&&!$_POST["hashed"]&&!min_version(8)){$Yf=$g->result("SELECT PASSWORD(".q($Yf).")");$n=!$Yf;}$Kb=false;if(!$n){if($pf!=$bf){$Kb=queries((min_version(5)?"CREATE USER":"GRANT USAGE ON *.* TO")." $bf IDENTIFIED BY ".(min_version(8)?"":"PASSWORD ").q($Yf));$n=!$Kb;}elseif($Yf!=$of)queries("SET PASSWORD FOR $bf = ".q($Yf));}if(!$n){$Sg=array();foreach($Ze
as$hf=>$od){if(isset($_GET["grant"]))$od=array_filter($od);$od=array_keys($od);if(isset($_GET["grant"]))$Sg=array_diff(array_keys(array_filter($Ze[$hf],'strlen')),$od);elseif($pf==$bf){$mf=array_keys((array)$pd[$hf]);$Sg=array_diff($mf,$od);$od=array_diff($od,$mf);unset($pd[$hf]);}if(preg_match('~^(.+)\s*(\(.*\))?$~U',$hf,$C)&&(!grant("REVOKE",$Sg,$C[2]," ON $C[1] FROM $bf")||!grant("GRANT",$od,$C[2]," ON $C[1] TO $bf"))){$n=true;break;}}}if(!$n&&isset($_GET["host"])){if($pf!=$bf)queries("DROP USER $pf");elseif(!isset($_GET["grant"])){foreach($pd
as$hf=>$Sg){if(preg_match('~^(.+)(\(.*\))?$~U',$hf,$C))grant("REVOKE",array_keys($Sg),$C[2]," ON $C[1] FROM $bf");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?lang(239):lang(240)),!$n);if($Kb)$g->query("DROP USER $bf");}}page_header((isset($_GET["host"])?lang(35).": ".h("$ha@$_GET[host]"):lang(146)),$n,array("privileges"=>array('',lang(71))));if($_POST){$J=$_POST;$pd=$Ze;}else{$J=$_GET+array("host"=>$g->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$J["pass"]=$of;if($of!="")$J["hashed"]=true;$pd[(DB==""||$pd?"":idf_escape(addcslashes(DB,"%_\\"))).".*"]=array();}echo'
';}elseif(isset($_GET["processlist"])){if(support("kill")&&$_POST&&!$n){$ke=0;foreach((array)$_POST["kill"]as$X){if(kill_process($X))$ke++;}queries_redirect(ME."processlist=",lang(245,$ke),$ke||!$_POST["kill"]);}page_header(lang(116),$n);echo'
',script("tableCheck();");}elseif(isset($_GET["select"])){$a=$_GET["select"];$R=table_status1($a);$x=indexes($a);$p=fields($a);$hd=column_foreign_keys($a);$kf=$R["Oid"];parse_str($_COOKIE["adminer_import"],$za);$Tg=array();$e=array();$ei=null;foreach($p
as$z=>$o){$D=$b->fieldName($o);if(isset($o["privileges"]["select"])&&$D!=""){$e[$z]=html_entity_decode(strip_tags($D),ENT_QUOTES);if(is_shortable($o))$ei=$b->selectLengthProcess();}$Tg+=$o["privileges"];}list($L,$qd)=$b->selectColumnsProcess($e,$x);$be=count($qd)selectSearchProcess($p,$x);$Af=$b->selectOrderProcess($p,$x);$_=$b->selectLimitProcess();if($_GET["val"]&&is_ajax()){header("Content-Type: text/plain; charset=utf-8");foreach($_GET["val"]as$Gi=>$J){$Ga=convert_field($p[key($J)]);$L=array($Ga?$Ga:idf_escape(key($J)));$Z[]=where_check($Gi,$p);$I=$m->select($a,$L,$Z,$L);if($I)echo
reset($I->fetch_row());}exit;}$mg=$Ii=null;foreach($x
as$w){if($w["type"]=="PRIMARY"){$mg=array_flip($w["columns"]);$Ii=($L?$mg:array());foreach($Ii
as$z=>$X){if(in_array(idf_escape($z),$L))unset($Ii[$z]);}break;}}if($kf&&!$mg){$mg=$Ii=array($kf=>0);$x[]=array("type"=>"PRIMARY","columns"=>array($kf));}if($_POST&&!$n){$jj=$Z;if(!$_POST["all"]&&is_array($_POST["check"])){$eb=array();foreach($_POST["check"]as$bb)$eb[]=where_check($bb,$p);$jj[]="((".implode(") OR (",$eb)."))";}$jj=($jj?"\nWHERE ".implode(" AND ",$jj):"");if($_POST["export"]){cookie("adminer_import","output=".urlencode($_POST["output"])."&format=".urlencode($_POST["format"]));dump_headers($a);$b->dumpTable($a,"");$md=($L?implode(", ",$L):"*").convert_fields($e,$p,$L)."\nFROM ".table($a);$sd=($qd&&$be?"\nGROUP BY ".implode(", ",$qd):"").($Af?"\nORDER BY ".implode(", ",$Af):"");if(!is_array($_POST["check"])||$mg)$G="SELECT $md$jj$sd";else{$Ei=array();foreach($_POST["check"]as$X)$Ei[]="(SELECT".limit($md,"\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$p).$sd,1).")";$G=implode(" UNION ALL ",$Ei);}$b->dumpData($a,"table",$G);exit;}if(!$b->selectEmailProcess($Z,$hd)){if($_POST["save"]||$_POST["delete"]){$H=true;$_a=0;$N=array();if(!$_POST["delete"]){foreach($e
as$D=>$X){$X=process_input($p[$D]);if($X!==null&&($_POST["clone"]||$X!==false))$N[idf_escape($D)]=($X!==false?$X:idf_escape($D));}}if($_POST["delete"]||$N){if($_POST["clone"])$G="INTO ".table($a)." (".implode(", ",array_keys($N)).")\nSELECT ".implode(", ",$N)."\nFROM ".table($a);if($_POST["all"]||($mg&&is_array($_POST["check"]))||$be){$H=($_POST["delete"]?$m->delete($a,$jj):($_POST["clone"]?queries("INSERT $G$jj"):$m->update($a,$N,$jj)));$_a=$g->affected_rows;}else{foreach((array)$_POST["check"]as$X){$fj="\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($X,$p);$H=($_POST["delete"]?$m->delete($a,$fj,1):($_POST["clone"]?queries("INSERT".limit1($a,$G,$fj)):$m->update($a,$N,$fj,1)));if(!$H)break;$_a+=$g->affected_rows;}}}$Me=lang(249,$_a);if($_POST["clone"]&&$H&&$_a==1){$qe=last_id();if($qe)$Me=lang(168," $qe");}queries_redirect(remove_from_uri($_POST["all"]&&$_POST["delete"]?"page":""),$Me,$H);if(!$_POST["delete"]){edit_form($a,$p,(array)$_POST["fields"],!$_POST["clone"]);page_footer();exit;}}elseif(!$_POST["import"]){if(!$_POST["val"])$n=lang(250);else{$H=true;$_a=0;foreach($_POST["val"]as$Gi=>$J){$N=array();foreach($J
as$z=>$X){$z=bracket_escape($z,1);$N[idf_escape($z)]=(preg_match('~char|text~',$p[$z]["type"])||$X!=""?$b->processInput($p[$z],$X):"NULL");}$H=$m->update($a,$N," WHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($Gi,$p),!$be&&!$mg," ");if(!$H)break;$_a+=$g->affected_rows;}queries_redirect(remove_from_uri(),lang(249,$_a),$H);}}elseif(!is_string($Xc=get_file("csv_file",true)))$n=upload_error($Xc);elseif(!preg_match('~~u',$Xc))$n=lang(251);else{cookie("adminer_import","output=".urlencode($za["output"])."&format=".urlencode($_POST["separator"]));$H=true;$pb=array_keys($p);preg_match_all('~(?>"[^"]*"|[^"\r\n]+)+~',$Xc,$Ee);$_a=count($Ee[0]);$m->begin();$jh=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));$K=array();foreach($Ee[0]as$z=>$X){preg_match_all("~((?>\"[^\"]*\")+|[^$jh]*)$jh~",$X.$jh,$Fe);if(!$z&&!array_diff($Fe[1],$pb)){$pb=$Fe[1];$_a--;}else{$N=array();foreach($Fe[1]as$t=>$kb)$N[idf_escape($pb[$t])]=($kb==""&&$p[$pb[$t]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$kb))));$K[]=$N;}}$H=(!$K||$m->insertUpdate($a,$K,$mg));if($H)$H=$m->commit();queries_redirect(remove_from_uri("page"),lang(252,$_a),$H);$m->rollback();}}}$Qh=$b->tableName($R);if(is_ajax()){page_headers();ob_start();}else
page_header(lang(53).": $Qh",$n);$N=null;if(isset($Tg["insert"])||!support("table")){$N="";foreach((array)$_GET["where"]as$X){if($hd[$X["col"]]&&count($hd[$X["col"]])==1&&($X["op"]=="="||(!$X["op"]&&!preg_match('~[_%]~',$X["val"]))))$N.="&set".urlencode("[".bracket_escape($X["col"])."]")."=".urlencode($X["val"]);}}$b->selectLinks($R,$N);if(!$e&&support("table"))echo"".lang(253).($p?".":": ".error())."\n";else{echo" \n";$E=$_GET["page"];if($E=="last"){$kd=$g->result(count_rows($a,$Z,$be,$qd));$E=floor(max(0,$kd-1)/$_);}$eh=$L;$rd=$qd;if(!$eh){$eh[]="*";$Fb=convert_fields($e,$p,$L);if($Fb)$eh[]=substr($Fb,2);}foreach($L
as$z=>$X){$o=$p[idf_unescape($X)];if($o&&($Ga=convert_field($o)))$eh[$z]="$Ga AS $X";}if(!$be&&$Ii){foreach($Ii
as$z=>$X){$eh[]=idf_escape($z);if($rd)$rd[]=idf_escape($z);}}$H=$m->select($a,$eh,$Z,$rd,$Af,$_,$E,true);if(!$H)echo"".error()."\n";else{if($y=="mssql"&&$E)$H->seek($_*$E);$wc=array();echo" \n",(!$qd&&$L?"":script("tableCheck();"));}}}if(is_ajax()){ob_end_clean();exit;}}elseif(isset($_GET["variables"])){$O=isset($_GET["status"]);page_header($O?lang(118):lang(117));$Wi=($O?show_status():show_variables());if(!$Wi)echo"".lang(12)."\n";else{echo" \n";foreach($Wi
as$z=>$X){echo"","".h($z)." "," | ".h($X);}echo" | \n";}}elseif(isset($_GET["script"])){header("Content-Type: text/javascript; charset=utf-8");if($_GET["script"]=="db"){$Nh=array("Data_length"=>0,"Index_length"=>0,"Data_free"=>0);foreach(table_status()as$D=>$R){json_row("Comment-$D",h($R["Comment"]));if(!is_view($R)){foreach(array("Engine","Collation")as$z)json_row("$z-$D",h($R[$z]));foreach($Nh+array("Auto_increment"=>0,"Rows"=>0)as$z=>$X){if($R[$z]!=""){$X=format_number($R[$z]);json_row("$z-$D",($z=="Rows"&&$X&&$R["Engine"]==($_h=="pgsql"?"table":"InnoDB")?"~ $X":$X));if(isset($Nh[$z]))$Nh[$z]+=($R["Engine"]!="InnoDB"||$z!="Data_free"?$R[$z]:0);}elseif(array_key_exists($z,$R))json_row("$z-$D");}}}foreach($Nh
as$z=>$X)json_row("sum-$z",format_number($X));json_row("");}elseif($_GET["script"]=="kill")$g->query("KILL ".number($_POST["kill"]));else{foreach(count_tables($b->databases())as$l=>$X){json_row("tables-$l",$X);json_row("size-$l",db_size($l));}json_row("");}exit;}else{$Wh=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Wh&&!$n&&!$_POST["search"]){$H=true;$Me="";if($y=="sql"&&$_POST["tables"]&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"]))queries("SET foreign_key_checks = 0");if($_POST["truncate"]){if($_POST["tables"])$H=truncate_tables($_POST["tables"]);$Me=lang(263);}elseif($_POST["move"]){$H=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$Me=lang(264);}elseif($_POST["copy"]){$H=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$Me=lang(265);}elseif($_POST["drop"]){if($_POST["views"])$H=drop_views($_POST["views"]);if($H&&$_POST["tables"])$H=drop_tables($_POST["tables"]);$Me=lang(266);}elseif($y!="sql"){$H=($y=="sqlite"?queries("VACUUM"):apply_queries("VACUUM".($_POST["optimize"]?"":" ANALYZE"),$_POST["tables"]));$Me=lang(267);}elseif(!$_POST["tables"])$Me=lang(9);elseif($H=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"])))){while($J=$H->fetch_assoc())$Me.="".h($J["Table"]).": ".h($J["Msg_text"])." ";}queries_redirect(substr(ME,0,-1),$Me,$H);}page_header(($_GET["ns"]==""?lang(37).": ".h(DB):lang(77).": ".h($_GET["ns"])),$n,true);if($b->homepage()){if($_GET["ns"]!==""){echo"".lang(268)."\n";$Vh=tables_list();if(!$Vh)echo"".lang(9)."\n";else{echo" \n",script("tableCheck();");}echo''.lang(74)."\n",(support("view")?''.lang(204)."\n":"");if(support("routine")){echo" ".lang(143)."\n";$Xg=routines();if($Xg){echo"\n",''.lang(183).' | '.lang(49).' | '.lang(221)." | | \n";odd('');foreach($Xg
as$J){$D=($J["SPECIFIC_NAME"]==$J["ROUTINE_NAME"]?"":"&name=".urlencode($J["ROUTINE_NAME"]));echo'',''.h($J["ROUTINE_NAME"]).'',' | '.h($J["ROUTINE_TYPE"]),' | '.h($J["DTD_IDENTIFIER"]),' | '.lang(136)."";}echo" | \n";}echo''.(support("procedure")?''.lang(220).'':'').''.lang(219)."\n";}if(support("sequence")){echo" ".lang(285)."\n";$lh=get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema() ORDER BY sequence_name");if($lh){echo"\n","".lang(183)." | \n";odd('');foreach($lh
as$X)echo"".h($X)."\n";echo" |
---|
\n";}echo"".lang(226)."\n";}if(support("type")){echo" ".lang(26)."\n";$Ri=types();if($Ri){echo"\n","".lang(183)." | \n";odd('');foreach($Ri
as$X)echo"".h($X)."\n";echo" |
---|
\n";}echo"".lang(230)."\n";}if(support("event")){echo" ".lang(144)."\n";$K=get_rows("SHOW EVENTS");if($K){echo"\n","".lang(183)." | ".lang(286)." | ".lang(210)." | ".lang(211)." | | \n";foreach($K
as$J){echo"","".h($J["Name"])," | ".($J["Execute at"]?lang(287)." | ".$J["Execute at"]:lang(212)." ".$J["Interval value"]." ".$J["Interval field"]." | $J[Starts]")," | $J[Ends]",' | '.lang(136).'';}echo" | \n";$Ec=$g->result("SELECT @@event_scheduler");if($Ec&&$Ec!="ON")echo"event_scheduler : ".h($Ec)."\n";}echo'
'.lang(209)."\n";}if($Vh)echo
script("ajaxSetHtml('".js_escape(ME)."script=db');");}}}page_footer(); |