function toggle(id){var el=document.getElementById(id);el.className=(el.className=='hidden'?'':'hidden');return true;}function cookie(assign,days){var date=new Date();date.setDate(date.getDate()+days);document.cookie=assign+'; expires='+date;}function verifyVersion(){cookie('adminer_version=0',1);var script=document.createElement('script');script.src=location.protocol+'//www.adminer.org/version.php';document.body.appendChild(script);}function selectValue(select){var selected=select.options[select.selectedIndex];return((selected.attributes.value||{}).specified?selected.value:selected.text);}function parentTag(el,tag){var re=new RegExp('^'+tag+'$','i');while(!re.test(el.tagName)){el=el.parentNode;}return el;}function trCheck(el){var tr=parentTag(el,'tr');tr.className=tr.className.replace(/(^|\s)checked(\s|$)/,'$2')+(el.checked?' checked':'');}function formCheck(el,name){var elems=el.form.elements;for(var i=0;i=0){input.maxLength=input.origMaxLength;}}function ajax(url,callback,data){var request=(window.XMLHttpRequest?new XMLHttpRequest():(window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):false));if(request){request.open((data?'POST':'GET'),url);if(data){request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');}request.setRequestHeader('X-Requested-With','XMLHttpRequest');request.onreadystatechange=function(){if(request.readyState==4){callback(request);}};request.send(data);}return request;}function ajaxSetHtml(url){return ajax(url,function(request){if(request.status){var data=eval('('+request.responseText+')');for(var key in data){setHtml(key,data[key]);}}});}function selectDblClick(td,event,text){if(/input|textarea/i.test(td.firstChild.tagName)){return;}var original=td.innerHTML;var input=document.createElement(text?'textarea':'input');input.onkeydown=function(event){if(!event){event=window.event;}if(event.keyCode==27&&!(event.ctrlKey||event.shiftKey||event.altKey||event.metaKey)){td.innerHTML=original;}};var pos=event.rangeOffset;var value=td.firstChild.alt||td.textContent||td.innerText;input.style.width=Math.max(td.clientWidth-14,20)+'px';if(text){var rows=1;value.replace(/\n/g,function(){rows++;});input.rows=rows;}if(value=='\u00A0'||td.getElementsByTagName('i').length){value='';}if(document.selection){var range=document.selection.createRange();range.moveToPoint(event.clientX,event.clientY);var range2=range.duplicate();range2.moveToElementText(td);range2.setEndPoint('EndToEnd',range);pos=range2.text.length;}td.innerHTML='';td.appendChild(input);input.focus();if(text==2){return ajax(location.href+'&'+encodeURIComponent(td.id)+'=',function(request){if(request.status){input.value=request.responseText;input.name=td.id;}});}input.value=value;input.name=td.id;input.selectionStart=pos;input.selectionEnd=pos;if(document.selection){var range=document.selection.createRange();range.moveEnd('character',-input.value.length+pos);range.select();}}function eventStop(event){if(event.stopPropagation){event.stopPropagation();}else{event.cancelBubble=true;}}var jushRoot=location.protocol + '//www.adminer.org/static/';function bodyLoad(version){if(jushRoot){var link=document.createElement('link');link.rel='stylesheet';link.type='text/css';link.href=jushRoot+'jush.css';document.getElementsByTagName('head')[0].appendChild(link);var script=document.createElement('script');script.src=jushRoot+'jush.js';script.onload=function(){if(window.jush){jush.create_links=' target="_blank" rel="noreferrer"';jush.urls.sql_sqlset=jush.urls.sql[0]=jush.urls.sqlset[0]=jush.urls.sqlstatus[0]='http://dev.mysql.com/doc/refman/'+version+'/en/$key';var pgsql='http://www.postgresql.org/docs/'+version+'/static/';jush.urls.pgsql_pgsqlset=jush.urls.pgsql[0]=pgsql+'$key';jush.urls.pgsqlset[0]=pgsql+'runtime-config-$key.html#GUC-$1';if(window.jushLinks){jush.custom_links=jushLinks;}jush.highlight_tag('code',0);}};script.onreadystatechange=function(){if(/^(loaded|complete)$/.test(script.readyState)){script.onload();}};document.body.appendChild(script);}}function formField(form,name){for(var i=0;i=allowed){return false;}var match=/(\d+)(\.\d+)?/.exec(button.name);var x=match[0]+(match[2]?added.substr(match[2].length):added)+'1';var row=parentTag(button,'tr');var row2=row.cloneNode(true);var tags=row.getElementsByTagName('select');var tags2=row2.getElementsByTagName('select');for(var i=0;i",$L);}function checkbox($_,$X,$Oa,$Uc="",$Nd="",$Pc=false){static$q=0;$q++;$F="";return($Uc!=""?"":$F);}function optionlist($Rd,$cf=null,$jg=false){$F="";foreach($Rd as$Qc=>$V){$Sd=array($Qc=>$V);if(is_array($V)){$F.='';$Sd=$V;}foreach($Sd as$v=>$W)$F.=''.h($W);if(is_array($V))$F.='';}return$F;}function html_select($_,$Rd,$X="",$Md=true){if($Md)return"";$F="";foreach($Rd as$v=>$W)$F.="";return$F;}function confirm($fb=""){return" onclick=\"return confirm('".lang(0).($fb?" (' + $fb + ')":"")."');\"";}function print_fieldset($q,$bd,$pg=false,$Nd=""){echo"
$bd
\n";}function selectSearchPrint($Z,$f,$t){print_fieldset("search",lang(38),$Z);foreach($t as$p=>$s){if($s["type"]=="FULLTEXT"){echo"(".implode(", ",array_map('h',$s["columns"])).") AGAINST"," ",checkbox("boolean[$p]",1,isset($_GET["boolean"][$p]),"BOOL"),"
\n";}}$_GET["where"]=(array)$_GET["where"];reset($_GET["where"]);$Ma="this.nextSibling.onchange();";for($p=0;$p<=count($_GET["where"]);$p++){list(,$W)=each($_GET["where"]);if(!$W||("$W[col]$W[val]"!=""&&in_array($W["op"],$this->operators))){echo"
",html_select("where[$p][op]",$this->operators,$W["op"],$Ma),"
\n";}}echo"\n";}function selectOrderPrint($Td,$f,$t){print_fieldset("sort",lang(40),$Td);$p=0;foreach((array)$_GET["order"]as$v=>$W){if(isset($f[$W])){echo"
",checkbox("desc[$p]",1,isset($_GET["desc"][$v]),lang(41))."
\n";$p++;}}echo"
","
\n";echo"\n";}function selectLimitPrint($x){echo"
".lang(42)."
";echo"","
\n";}function selectLengthPrint($Hf){if($Hf!==null){echo"
".lang(43)."
",'',"
\n";}}function selectActionPrint($t){echo"
".lang(44)."
",""," ","\n","
\n";}function selectCommandPrint(){return!information_schema(DB);}function selectImportPrint(){return true;}function selectEmailPrint($Fb,$f){}function selectColumnsProcess($f,$t){global$rc,$wc;$I=array();$uc=array();foreach((array)$_GET["columns"]as$v=>$W){if($W["fun"]=="count"||(isset($f[$W["col"]])&&(!$W["fun"]||in_array($W["fun"],$rc)||in_array($W["fun"],$wc)))){$I[$v]=apply_sql_function($W["fun"],(isset($f[$W["col"]])?idf_escape($W["col"]):"*"));if(!in_array($W["fun"],$wc))$uc[]=$I[$v];}}return array($I,$uc);}function selectSearchProcess($m,$t){global$u;$F=array();foreach($t as$p=>$s){if($s["type"]=="FULLTEXT"&&$_GET["fulltext"][$p]!="")$F[]="MATCH (".implode(", ",array_map('idf_escape',$s["columns"])).") AGAINST (".q($_GET["fulltext"][$p]).(isset($_GET["boolean"][$p])?" IN BOOLEAN MODE":"").")";}foreach((array)$_GET["where"]as$W){if("$W[col]$W[val]"!=""&&in_array($W["op"],$this->operators)){$ab=" $W[op]";if(ereg('IN$',$W["op"])){$Dc=process_length($W["val"]);$ab.=" (".($Dc!=""?$Dc:"NULL").")";}elseif(!$W["op"])$ab.=$W["val"];elseif($W["op"]=="LIKE %%")$ab=" LIKE ".$this->processInput($m[$W["col"]],"%$W[val]%");elseif(!ereg('NULL$',$W["op"]))$ab.=" ".$this->processInput($m[$W["col"]],$W["val"]);if($W["col"]!="")$F[]=idf_escape($W["col"]).$ab;else{$Ua=array();foreach($m as$_=>$l){if(is_numeric($W["val"])||!ereg('int|float|double|decimal|bit',$l["type"])){$_=idf_escape($_);$Ua[]=($u=="sql"&&ereg('char|text|enum|set',$l["type"])&&!ereg('^utf8',$l["collation"])?"CONVERT($_ USING utf8)":$_);}}$F[]=($Ua?"(".implode("$ab OR ",$Ua)."$ab)":"0");}}}return$F;}function selectOrderProcess($m,$t){$F=array();foreach((array)$_GET["order"]as$v=>$W){if(isset($m[$W])||preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\\)|COUNT\\(\\*\\))$~',$W))$F[]=(isset($m[$W])?idf_escape($W):$W).(isset($_GET["desc"][$v])?" DESC":"");}return$F;}function selectLimitProcess(){return(isset($_GET["limit"])?$_GET["limit"]:"30");}function selectLengthProcess(){return(isset($_GET["text_length"])?$_GET["text_length"]:"100");}function selectEmailProcess($Z,$jc){return false;}function messageQuery($D){global$u;static$fb=0;restart_session();$q="sql-".($fb++);$yc=&get_session("queries");if(strlen($D)>1e6)$D=ereg_replace('[\x80-\xFF]+$','',substr($D,0,1e6))."\n...";$yc[$_GET["db"]][]=array($D,time());return" ".@date("H:i:s")." ".lang(46)."';}function editFunctions($l){global$Cb;$F=($l["null"]?"NULL/":"");foreach($Cb as$v=>$rc){if(!$v||(!isset($_GET["call"])&&(isset($_GET["select"])||where($_GET)))){foreach($rc as$oe=>$W){if(!$oe||ereg($oe,$l["type"]))$F.="/$W";}if($v&&!ereg('set|blob|bytea|raw|file',$l["type"]))$F.="/=";}}return explode("/",$F);}function editInput($N,$l,$_a,$X){if($l["type"]=="enum")return(isset($_GET["select"])?" ":"").($l["null"]?" ":"").enum_input("radio",$_a,$l,$X,0);return"";}function processInput($l,$X,$o=""){if($o=="=")return$X;$_=$l["field"];$F=($l["type"]=="bit"&&ereg("^([0-9]+|b'[0-1]+')\$",$X)?$X:q($X));if(ereg('^(now|getdate|uuid)$',$o))$F="$o()";elseif(ereg('^current_(date|timestamp)$',$o))$F=$o;elseif(ereg('^([+-]|\\|\\|)$',$o))$F=idf_escape($_)." $o $F";elseif(ereg('^[+-] interval$',$o))$F=idf_escape($_)." $o ".(preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i",$X)?$X:$F);elseif(ereg('^(addtime|subtime|concat)$',$o))$F="$o(".idf_escape($_).", $F)";elseif(ereg('^(md5|sha1|password|encrypt|hex)$',$o))$F="$o($F)";if(ereg("binary",$l["type"]))$F="unhex($F)";return$F;}function dumpOutput(){$F=array('text'=>lang(47),'file'=>lang(48));if(function_exists('gzencode'))$F['gz']='gzip';if(function_exists('bzcompress'))$F['bz2']='bzip2';return$F;}function dumpFormat(){return array('sql'=>'SQL','csv'=>'CSV,','csv;'=>'CSV;','tsv'=>'TSV');}function dumpTable($N,$M,$Nc=false){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($M)dump_csv(array_keys(fields($N)));}elseif($M){$gb=create_sql($N,$_POST["auto_increment"]);if($gb){if($M=="DROP+CREATE")echo"DROP ".($Nc?"VIEW":"TABLE")." IF EXISTS ".table($N).";\n";if($Nc)$gb=remove_definer($gb);echo($M!="CREATE+ALTER"?$gb:($Nc?substr_replace($gb," OR REPLACE",6,0):substr_replace($gb," IF NOT EXISTS",12,0))).";\n\n";}if($M=="CREATE+ALTER"&&!$Nc){$D="SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ".q($N)." ORDER BY ORDINAL_POSITION";echo"DELIMITER ;; CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN DECLARE _column_name, _collation_name, after varchar(64) DEFAULT ''; DECLARE _column_type, _column_default text; DECLARE _is_nullable char(3); DECLARE _extra varchar(30); DECLARE _column_comment varchar(255); DECLARE done, set_after bool DEFAULT 0; DECLARE add_columns text DEFAULT '";$m=array();$ua="";foreach(get_rows($D)as$G){$qb=$G["COLUMN_DEFAULT"];$G["default"]=($qb!==null?q($qb):"NULL");$G["after"]=q($ua);$G["alter"]=escape_string(idf_escape($G["COLUMN_NAME"])." $G[COLUMN_TYPE]".($G["COLLATION_NAME"]?" COLLATE $G[COLLATION_NAME]":"").($qb!==null?" DEFAULT ".($qb=="CURRENT_TIMESTAMP"?$qb:$G["default"]):"").($G["IS_NULLABLE"]=="YES"?"":" NOT NULL").($G["EXTRA"]?" $G[EXTRA]":"").($G["COLUMN_COMMENT"]?" COMMENT ".q($G["COLUMN_COMMENT"]):"").($ua?" AFTER ".idf_escape($ua):" FIRST"));echo", ADD $G[alter]";$m[]=$G;$ua=$G["COLUMN_NAME"];}echo"'; DECLARE columns CURSOR FOR $D; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; SET @alter_table = ''; OPEN columns; REPEAT FETCH columns INTO _column_name, _column_default, _is_nullable, _collation_name, _column_type, _extra, _column_comment; IF NOT done THEN SET set_after = 1; CASE _column_name";foreach($m as$G)echo" WHEN ".q($G["COLUMN_NAME"])." THEN SET add_columns = REPLACE(add_columns, ', ADD $G[alter]', IF( _column_default <=> $G[default] AND _is_nullable = '$G[IS_NULLABLE]' AND _collation_name <=> ".(isset($G["COLLATION_NAME"])?"'$G[COLLATION_NAME]'":"NULL")." AND _column_type = ".q($G["COLUMN_TYPE"])." AND _extra = '$G[EXTRA]' AND _column_comment = ".q($G["COLUMN_COMMENT"])." AND after = $G[after] , '', ', MODIFY $G[alter]'));";echo" ELSE SET @alter_table = CONCAT(@alter_table, ', DROP ', _column_name); SET set_after = 0; END CASE; IF set_after THEN SET after = _column_name; END IF; END IF; UNTIL done END REPEAT; CLOSE columns; IF @alter_table != '' OR add_columns != '' THEN SET alter_command = CONCAT(alter_command, 'ALTER TABLE ".table($N)."', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n'); END IF; END;; DELIMITER ; CALL adminer_alter(@adminer_alter); DROP PROCEDURE adminer_alter; ";}}}function dumpData($N,$M,$D){global$g,$u;$ld=($u=="sqlite"?0:1048576);if($M){if($_POST["format"]=="sql"&&$M=="TRUNCATE+INSERT")echo truncate_sql($N).";\n";if($_POST["format"]=="sql")$m=fields($N);$E=$g->query($D,1);if($E){$Kc="";$Ka="";$Sc=array();while($G=$E->fetch_row()){if(!$Sc){foreach($G as$W){$l=$E->fetch_field();$Sc[]=$l->name;}}if($_POST["format"]!="sql"){if($M=="table"){dump_csv($Sc);$M="INSERT";}dump_csv($G);}else{if(!$Kc)$Kc="INSERT INTO ".table($N)." (".implode(", ",array_map('idf_escape',$Sc)).") VALUES";foreach($G as$v=>$W)$G[$v]=($W!==null?(ereg('int|float|double|decimal|bit',$m[$Sc[$v]]["type"])?$W:q($W)):"NULL");$Xe=implode(",\t",$G);if($M=="INSERT+UPDATE"){$K=array();foreach($G as$v=>$W)$K[]=idf_escape($Sc[$v])." = $W";echo"$Kc ($Xe) ON DUPLICATE KEY UPDATE ".implode(", ",$K).";\n";}else{$Xe=($ld?"\n":" ")."($Xe)";if(!$Ka)$Ka=$Kc.$Xe;elseif(strlen($Ka)+4+strlen($Xe)<$ld)$Ka.=",$Xe";else{echo"$Ka;\n";$Ka=$Kc.$Xe;}}}}if($_POST["format"]=="sql"&&$M!="INSERT+UPDATE"&&$Ka){$Ka.=";\n";echo$Ka;}}elseif($_POST["format"]=="sql")echo"-- ".str_replace("\n"," ",$g->error)."\n";}}function dumpFilename($Bc){return friendly_url($Bc!=""?$Bc:(SERVER!=""?SERVER:"localhost"));}function dumpHeaders($Bc,$yd=false){$de=$_POST["output"];$Yb=($_POST["format"]=="sql"?"sql":($yd?"tar":"csv"));header("Content-Type: ".($de=="bz2"?"application/x-bzip":($de=="gz"?"application/x-gzip":($Yb=="tar"?"application/x-tar":($Yb=="sql"||$de!="file"?"text/plain":"text/csv")."; charset=utf-8"))));if($de=="bz2")ob_start('bzcompress',1e6);if($de=="gz")ob_start('gzencode',1e6);return$Yb;}function homepage(){echo'

'.($_GET["ns"]==""?''.lang(49)."\n":""),(support("scheme")?"".($_GET["ns"]!=""?lang(50):lang(51))."\n":""),($_GET["ns"]!==""?''.lang(52)."\n":""),(support("privileges")?"".lang(53)."\n":"");return true;}function navigation($xd){global$ia,$g,$Q,$u,$xb;echo'

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

';if($xd=="auth"){$gc=true;foreach((array)$_SESSION["pwds"]as$wb=>$hf){foreach($hf as$J=>$kg){foreach($kg as$U=>$B){if($B!==null){if($gc){echo"

\n";$gc=false;}echo"($xb[$wb]) ".h($U.($J!=""?"@$J":""))."
\n";}}}}}else{$i=$this->databases();echo'

';if(DB==""||!$xd){echo"".lang(46)."\n";if(support("dump"))echo"".lang(54)."\n";}echo'

';hidden_fields_get();echo($i?html_select("db",array(""=>"(".lang(56).")")+$i,DB,"this.form.submit();"):''),' ';if($xd!="db"&&DB!=""&&$g->select_db(DB)){if(support("scheme")){echo"
".html_select("ns",array(""=>"(".lang(57).")")+schemas(),$_GET["ns"],"this.form.submit();");if($_GET["ns"]!="")set_schema($_GET["ns"]);}}echo(isset($_GET["sql"])?'':(isset($_GET["schema"])?'':(isset($_GET["dump"])?'':""))),"

\n";if($_GET["ns"]!==""&&!$xd&&DB!=""){echo'

".lang(58)."\n";$P=tables_list();if(!$P)echo"

".lang(6)."\n";else{$this->tablesPrint($P);$ed=array();foreach($P as$N=>$S)$ed[]=preg_quote($N,'/');echo"\n";}}}}function tablesPrint($P){echo"

\n";foreach($P as$N=>$S){echo'".lang(59)." ",'".$this->tableName(array("Name"=>$N))."
\n";}}}$b=(function_exists('adminer_object')?adminer_object():new Adminer);if($b->operators===null)$b->operators=$Pd;function page_header($Kf,$k="",$Ja=array(),$Lf=""){global$ca,$b,$g,$xb;header("Content-Type: text/html; charset=utf-8");if($b->headers()){header("X-Frame-Options: deny");header("X-XSS-Protection: 0");}$Mf=$Kf.($Lf!=""?": ".h($Lf):"");$Nf=strip_tags($Mf.(SERVER!=""&&SERVER!="localhost"?h(" - ".SERVER):"")." - ".$b->name());echo' ',$Nf,' ';if($b->head()){echo' ';if(file_exists("adminer.css")){echo' ';}}echo'

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

$Mf

\n";restart_session();$hg=preg_replace('~^[^?]*~','',$_SERVER["REQUEST_URI"]);$ud=$_SESSION["messages"][$hg];if($ud){echo"
".implode("
\n
",$ud)."
\n";unset($_SESSION["messages"][$hg]);}$i=&get_session("dbs");if(DB!=""&&$i&&!in_array(DB,$i,true))$i=null;if($k)echo"
$k
\n";define("PAGE_HEADER",1);}function page_footer($xd=""){global$b;echo'
';switch_lang();echo' ';}function int32($_d){while($_d>=2147483648)$_d-=4294967296;while($_d<=-2147483649)$_d+=4294967296;return(int)$_d;}function long2str($V,$qg){$Xe='';foreach($V as$W)$Xe.=pack('V',$W);if($qg)return substr($Xe,0,end($V));return$Xe;}function str2long($Xe,$qg){$V=array_values(unpack('V*',str_pad($Xe,4*ceil(strlen($Xe)/4),"\0")));if($qg)$V[]=strlen($Xe);return$V;}function xxtea_mx($ug,$tg,$uf,$Qc){return int32((($ug>>5&0x7FFFFFF)^$tg<<2)+(($tg>>3&0x1FFFFFFF)^$ug<<4))^int32(($uf^$tg)+($Qc^$ug));}function encrypt_string($pf,$v){if($pf=="")return"";$v=array_values(unpack("V*",pack("H*",md5($v))));$V=str2long($pf,true);$_d=count($V)-1;$ug=$V[$_d];$tg=$V[0];$C=floor(6+52/($_d+1));$uf=0;while($C-->0){$uf=int32($uf+0x9E3779B9);$Bb=$uf>>2&3;for($ee=0;$ee<$_d;$ee++){$tg=$V[$ee+1];$zd=xxtea_mx($ug,$tg,$uf,$v[$ee&3^$Bb]);$ug=int32($V[$ee]+$zd);$V[$ee]=$ug;}$tg=$V[0];$zd=xxtea_mx($ug,$tg,$uf,$v[$ee&3^$Bb]);$ug=int32($V[$_d]+$zd);$V[$_d]=$ug;}return long2str($V,false);}function decrypt_string($pf,$v){if($pf=="")return"";$v=array_values(unpack("V*",pack("H*",md5($v))));$V=str2long($pf,false);$_d=count($V)-1;$ug=$V[$_d];$tg=$V[0];$C=floor(6+52/($_d+1));$uf=int32($C*0x9E3779B9);while($uf){$Bb=$uf>>2&3;for($ee=$_d;$ee>0;$ee--){$ug=$V[$ee-1];$zd=xxtea_mx($ug,$tg,$uf,$v[$ee&3^$Bb]);$tg=int32($V[$ee]-$zd);$V[$ee]=$tg;}$ug=$V[$_d];$zd=xxtea_mx($ug,$tg,$uf,$v[$ee&3^$Bb]);$tg=int32($V[0]-$zd);$V[0]=$tg;$uf=int32($uf-0x9E3779B9);}return long2str($V,true);}$g='';$Q=$_SESSION["token"];if(!$_SESSION["token"])$_SESSION["token"]=rand(1,1e6);$pe=array();if($_COOKIE["adminer_permanent"]){foreach(explode(" ",$_COOKIE["adminer_permanent"])as$W){list($v)=explode(":",$W);$pe[$v]=$W;}}$Aa=$_POST["auth"];if($Aa){session_regenerate_id();$_SESSION["pwds"][$Aa["driver"]][$Aa["server"]][$Aa["username"]]=$Aa["password"];if($Aa["permanent"]){$v=base64_encode($Aa["driver"])."-".base64_encode($Aa["server"])."-".base64_encode($Aa["username"]);$_e=$b->permanentLogin();$pe[$v]="$v:".base64_encode($_e?encrypt_string($Aa["password"],$_e):"");cookie("adminer_permanent",implode(" ",$pe));}if(count($_POST)==1||DRIVER!=$Aa["driver"]||SERVER!=$Aa["server"]||$_GET["username"]!==$Aa["username"]||DB!=$Aa["db"])redirect(auth_url($Aa["driver"],$Aa["server"],$Aa["username"],$Aa["db"]));}elseif($_POST["logout"]){if($Q&&$_POST["token"]!=$Q){page_header(lang(55),lang(61));page_footer("db");exit;}else{foreach(array("pwds","dbs","queries")as$v)set_session($v,null);$v=base64_encode(DRIVER)."-".base64_encode(SERVER)."-".base64_encode($_GET["username"]);if($pe[$v]){unset($pe[$v]);cookie("adminer_permanent",implode(" ",$pe));}redirect(substr(preg_replace('~(username|db|ns)=[^&]*&~','',ME),0,-1),lang(62));}}elseif($pe&&!$_SESSION["pwds"]){session_regenerate_id();$_e=$b->permanentLogin();foreach($pe as$v=>$W){list(,$Qa)=explode(":",$W);list($wb,$J,$U)=array_map('base64_decode',explode("-",$v));$_SESSION["pwds"][$wb][$J][$U]=decrypt_string(base64_decode($Qa),$_e);}}function auth_error($Sb=null){global$g,$b,$Q;$if=session_name();$k="";if(!$_COOKIE[$if]&&$_GET[$if]&&ini_bool("session.use_only_cookies"))$k=lang(63);elseif(isset($_GET["username"])){if(($_COOKIE[$if]||$_GET[$if])&&!$Q)$k=lang(64);else{$B=&get_session("pwds");if($B!==null){$k=h($Sb?$Sb->getMessage():(is_string($g)?$g:lang(65)));$B=null;}}}page_header(lang(25),$k,null);echo"
\n";$b->loginForm();echo"
";hidden_fields($_POST,array("auth"));echo"
\n","
\n";page_footer("auth");}if(isset($_GET["username"])){if(!class_exists("Min_DB")){unset($_SESSION["pwds"][DRIVER]);page_header(lang(66),lang(67,implode(", ",$ue)),false);page_footer("auth");exit;}$g=connect();}if(is_string($g)||!$b->login($_GET["username"],get_session("pwds"))){auth_error();exit;}$Q=$_SESSION["token"];if($Aa&&$_POST["token"])$_POST["token"]=$Q;$k=($_POST?($_POST["token"]==$Q?"":lang(61)):($_SERVER["REQUEST_METHOD"]!="POST"?"":lang(68,'"post_max_size"')));function connect_error(){global$b,$g,$Q,$k,$xb;$i=array();if(DB!="")page_header(lang(24).": ".h(DB),lang(69),true);else{if($_POST["db"]&&!$k)queries_redirect(substr(ME,0,-1),lang(70),drop_databases($_POST["db"]));page_header(lang(71),$k,false);echo"

".lang(72)."\n";foreach(array('privileges'=>lang(53),'processlist'=>lang(73),'variables'=>lang(74),'status'=>lang(75),)as$v=>$W){if(support($v))echo"$W\n";}echo"

".lang(76,$xb[DRIVER],"$g->server_info","$g->extension")."\n","

".lang(77,"".h(logged_user())."")."\n";if($_GET["refresh"])set_session("dbs",null);$i=$b->databases();if($i){$af=support("scheme");$Ta=collations();echo"

\n","\n","\n";foreach($i as$j){$Se=h(ME)."db=".urlencode($j);echo"
 ".lang(24)."".lang(78)."".lang(79)."
".checkbox("db[]",$j,in_array($j,(array)$_POST["db"])),"".h($j)."","".nbsp(db_collation($j,$Ta))."","?","\n";}echo"
\n","\n","

\n","\n","".lang(81)."\n","

\n";}}page_footer("db");if($i)echo"\n";}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];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")){if(DB!="")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"])){page_header(lang(82).": ".h($_GET["ns"]),lang(83),true);page_footer("ns");exit;}}function select($E,$h=null,$Ac="",$Wd=array()){$ed=array();$t=array();$f=array();$Ha=array();$T=array();$F=array();odd('');for($p=0;$G=$E->fetch_row();$p++){if(!$p){echo"\n","";for($Oc=0;$Ocfetch_field();$_=$l->name;$Vd=$l->orgtable;$Ud=$l->orgname;$F[$l->table]=$Vd;if($Ac)$ed[$Oc]=($_=="table"?"table=":($_=="possible_keys"?"indexes=":null));elseif($Vd!=""){if(!isset($t[$Vd])){$t[$Vd]=array();foreach(indexes($Vd,$h)as$s){if($s["type"]=="PRIMARY"){$t[$Vd]=array_flip($s["columns"]);break;}}$f[$Vd]=$t[$Vd];}if(isset($f[$Vd][$Ud])){unset($f[$Vd][$Ud]);$t[$Vd][$Ud]=$Oc;$ed[$Oc]=$Vd;}}if($l->charsetnr==63)$Ha[$Oc]=true;$T[$Oc]=$l->type;$_=h($_);echo"name!=$Ud?" title='".h(($Vd!=""?"$Vd.":"").$Ud)."'":"").">".($Ac?"$_":$_);}echo"\n";}echo"";foreach($G as$v=>$W){if($W===null)$W="NULL";elseif($Ha[$v]&&!is_utf8($W))$W="".lang(34,strlen($W))."";elseif(!strlen($W))$W=" ";else{$W=h($W);if($T[$v]==254)$W="$W";}if(isset($ed[$v])&&!$f[$ed[$v]]){if($Ac){$N=$G[array_search("table=",$ed)];$y=$ed[$v].urlencode($Wd[$N]!=""?$Wd[$N]:$N);}else{$y="edit=".urlencode($ed[$v]);foreach($t[$ed[$v]]as$Ra=>$Oc)$y.="&where".urlencode("[".bracket_escape($Ra)."]")."=".urlencode($G[$Oc]);}$W="$W";}echo"
$W";}}echo($p?"
":"

".lang(84))."\n";return$F;}function referencable_primary($df){$F=array();foreach(table_status()as$yf=>$N){if($yf!=$df&&fk_support($N)){foreach(fields($yf)as$l){if($l["primary"]){if($F[$yf]){unset($F[$yf]);break;}$F[$yf]=$l;}}}}return$F;}function textarea($_,$X,$H=10,$Ua=80){echo"";}function format_time($mf,$Ib){return" (".lang(85,max(0,array_sum(explode(" ",$Ib))-array_sum(explode(" ",$mf)))).")";}function edit_type($v,$l,$Ta,$kc=array()){global$qf,$T,$fg,$Ld;echo' ',"',($fg?"':''),($kc?" ":" ");}function process_length($w){global$Lb;return(preg_match("~^\\s*(?:$Lb)(?:\\s*,\\s*(?:$Lb))*\\s*\$~",$w)&&preg_match_all("~$Lb~",$w,$jd)?implode(",",$jd[0]):preg_replace('~[^0-9,+-]~','',$w));}function process_type($l,$Sa="COLLATE"){global$fg;return" $l[type]".($l["length"]!=""?"(".process_length($l["length"]).")":"").(ereg('int|float|double|decimal',$l["type"])&&in_array($l["unsigned"],$fg)?" $l[unsigned]":"").(ereg('char|text|enum|set',$l["type"])&&$l["collation"]?" $Sa ".q($l["collation"]):"");}function process_field($l,$Xf){return array(idf_escape(trim($l["field"])),process_type($Xf),($l["null"]?" NULL":" NOT NULL"),(isset($l["default"])?" DEFAULT ".(($l["type"]=="timestamp"&&eregi('^CURRENT_TIMESTAMP$',$l["default"]))||($l["type"]=="bit"&&ereg("^([0-9]+|b'[0-1]+')\$",$l["default"]))?$l["default"]:q($l["default"])):""),($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($S){foreach(array('char'=>'text','date'=>'time|year','binary'=>'blob','enum'=>'set',)as$v=>$W){if(ereg("$v|$W",$S))return" class='$v'";}}function edit_fields($m,$Ta,$S="TABLE",$xa=0,$kc=array(),$Ya=false){global$Ic;echo' ';if($S=="PROCEDURE"){echo' ';}echo'',($S=="TABLE"?lang(89):lang(90)),'',lang(91),' ',lang(92),'',lang(93);if($S=="TABLE"){echo'NULL AI

".lang(96).": ".h($Xa)."\n";if($m){echo"\n","\n";foreach($m as$l){echo"
".lang(103)."".lang(91).(support("comment")?"".lang(96):"")."
".h($l["field"]),"".h($l["full_type"]).($l["null"]?" NULL":"").($l["auto_increment"]?" ".lang(94)."":""),(isset($l["default"])?" [".h($l["default"])."]":""),(support("comment")?"".nbsp($l["comment"]):""),"\n";}echo"
\n";if(!is_view($O)){echo"

".lang(104)."

\n";$t=indexes($a);if($t){echo"\n";foreach($t as$_=>$s){ksort($s["columns"]);$ze=array();foreach($s["columns"]as$v=>$W)$ze[]="".h($W)."".($s["lengths"][$v]?"(".$s["lengths"][$v].")":"");echo"
$s[type]".implode(", ",$ze)."\n";}echo"
\n";}echo'

'.lang(105)."\n";if(fk_support($O)){echo"

".lang(86)."

\n";$kc=foreign_keys($a);if($kc){echo"\n","\n";foreach($kc as$_=>$n){echo"","
".lang(106)."".lang(107)."".lang(88)."".lang(108).($u!="sqlite"?" ":"")."
".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",($u=="sqlite"?"":''.lang(109).'');}echo"
\n";}if($u!="sqlite")echo'

'.lang(110)."\n";}if(support("trigger")){echo"

".lang(111)."

\n";$Wf=triggers($a);if($Wf){echo"\n";foreach($Wf as$v=>$W)echo"
$W[0]$W[1]".h($v)."".lang(109)."\n";echo"
\n";}echo'

'.lang(112)."\n";}}}}elseif(isset($_GET["schema"])){page_header(lang(52),"",array(),DB.($_GET["ns"]?".$_GET[ns]":""));$_f=array();$Af=array();$_="adminer_schema";$ea=($_GET["schema"]?$_GET["schema"]:$_COOKIE[($_COOKIE["$_-".DB]?"$_-".DB:$_)]);preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~',$ea,$jd,PREG_SET_ORDER);foreach($jd as$p=>$z){$_f[$z[1]]=array($z[2],$z[3]);$Af[]="\n\t'".js_escape($z[1])."': [ $z[2], $z[3] ]";}$Of=0;$Ga=-1;$Ze=array();$Le=array();$ad=array();foreach(table_status()as$O){if(!isset($O["Engine"]))continue;$re=0;$Ze[$O["Name"]]["fields"]=array();foreach(fields($O["Name"])as$_=>$l){$re+=1.25;$l["pos"]=$re;$Ze[$O["Name"]]["fields"][$_]=$l;}$Ze[$O["Name"]]["pos"]=($_f[$O["Name"]]?$_f[$O["Name"]]:array($Of,0));foreach($b->foreignKeys($O["Name"])as$W){if(!$W["db"]){$Yc=$Ga;if($_f[$O["Name"]][1]||$_f[$W["table"]][1])$Yc=min(floatval($_f[$O["Name"]][1]),floatval($_f[$W["table"]][1]))-1;else$Ga-=.1;while($ad[(string)$Yc])$Yc-=.0001;$Ze[$O["Name"]]["references"][$W["table"]][(string)$Yc]=array($W["source"],$W["target"]);$Le[$W["table"]][$O["Name"]][(string)$Yc]=$W["target"];$ad[(string)$Yc]=true;}}$Of=max($Of,$Ze[$O["Name"]]["pos"][0]+2.5+$re);}echo'

';foreach($Ze as$_=>$N){echo"
",''.h($_)."";foreach($N["fields"]as$l){$W=''.h($l["field"]).'';echo"
".($l["primary"]?"$W":$W);}foreach((array)$N["references"]as$Ff=>$Me){foreach($Me as$Yc=>$Ie){$Zc=$Yc-$_f[$_][1];$p=0;foreach($Ie[0]as$jf)echo"\n
";}}foreach((array)$Le[$_]as$Ff=>$Me){foreach($Me as$Yc=>$f){$Zc=$Yc-$_f[$_][1];$p=0;foreach($f as$Ef)echo"\n
";}}echo"\n
\n";}foreach($Ze as$_=>$N){foreach((array)$N["references"]as$Ff=>$Me){foreach($Me as$Yc=>$Ie){$wd=$Of;$nd=-10;foreach($Ie[0]as$v=>$jf){$se=$N["pos"][0]+$N["fields"][$jf]["pos"];$te=$Ze[$Ff]["pos"][0]+$Ze[$Ff]["fields"][$Ie[1][$v]]["pos"];$wd=min($wd,$se,$te);$nd=max($nd,$se,$te);}echo"
\n";}}}echo'

',lang(113),' ';}elseif(isset($_GET["dump"])){$a=$_GET["dump"];if($_POST){$eb="";foreach(array("output","format","db_style","routines","events","table_style","auto_increment","triggers","data_style")as$v)$eb.="&$v=".urlencode($_POST[$v]);cookie("adminer_export",substr($eb,1));$Yb=dump_headers(($a!=""?$a:DB),(DB==""||count((array)$_POST["tables"]+(array)$_POST["data"])>1));$Mc=($_POST["format"]=="sql");if($Mc)echo"-- Adminer $ia ".$xb[DRIVER]." dump ".($u!="sql"?"":"SET NAMES utf8; SET foreign_key_checks = 0; SET time_zone = ".q($g->result("SELECT @@time_zone"))."; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; ");$M=$_POST["db_style"];$i=array(DB);if(DB==""){$i=$_POST["databases"];if(is_string($i))$i=explode("\n",rtrim(str_replace("\r","",$i),"\n"));}foreach((array)$i as$j){if($g->select_db($j)){if($Mc&&ereg('CREATE',$M)&&($gb=$g->result("SHOW CREATE DATABASE ".idf_escape($j),1))){if($M=="DROP+CREATE")echo"DROP DATABASE IF EXISTS ".idf_escape($j).";\n";echo($M=="CREATE+ALTER"?preg_replace('~^CREATE DATABASE ~','\\0IF NOT EXISTS ',$gb):$gb).";\n";}if($Mc){if($M)echo use_sql($j).";\n\n";if(in_array("CREATE+ALTER",array($M,$_POST["table_style"])))echo"SET @adminer_alter = '';\n\n";$ce="";if($_POST["routines"]){foreach(array("FUNCTION","PROCEDURE")as$Te){foreach(get_rows("SHOW $Te STATUS WHERE Db = ".q($j),null,"-- ")as$G)$ce.=($M!='DROP+CREATE'?"DROP $Te IF EXISTS ".idf_escape($G["Name"]).";;\n":"").remove_definer($g->result("SHOW CREATE $Te ".idf_escape($G["Name"]),2)).";;\n\n";}}if($_POST["events"]){foreach(get_rows("SHOW EVENTS",null,"-- ")as$G)$ce.=($M!='DROP+CREATE'?"DROP EVENT IF EXISTS ".idf_escape($G["Name"]).";;\n":"").remove_definer($g->result("SHOW CREATE EVENT ".idf_escape($G["Name"]),3)).";;\n\n";}if($ce)echo"DELIMITER ;;\n\n$ce"."DELIMITER ;\n\n";}if($_POST["table_style"]||$_POST["data_style"]){$Y=array();foreach(table_status()as$O){$N=(DB==""||in_array($O["Name"],(array)$_POST["tables"]));$lb=(DB==""||in_array($O["Name"],(array)$_POST["data"]));if($N||$lb){if(!is_view($O)){if($Yb=="tar")ob_start();$b->dumpTable($O["Name"],($N?$_POST["table_style"]:""));if($lb)$b->dumpData($O["Name"],$_POST["data_style"],"SELECT * FROM ".table($O["Name"]));if($Mc&&$_POST["triggers"]&&$N&&($Wf=trigger_sql($O["Name"],$_POST["table_style"])))echo"\nDELIMITER ;;\n$Wf\nDELIMITER ;\n";if($Yb=="tar")echo tar_file((DB!=""?"":"$j/")."$O[Name].csv",ob_get_clean());elseif($Mc)echo"\n";}elseif($Mc)$Y[]=$O["Name"];}}foreach($Y as$og)$b->dumpTable($og,$_POST["table_style"],true);if($Yb=="tar")echo pack("x512");}if($M=="CREATE+ALTER"&&$Mc){$D="SELECT TABLE_NAME, ENGINE, TABLE_COLLATION, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE()";echo"DELIMITER ;; CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN DECLARE _table_name, _engine, _table_collation varchar(64); DECLARE _table_comment varchar(64); DECLARE done bool DEFAULT 0; DECLARE tables CURSOR FOR $D; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN tables; REPEAT FETCH tables INTO _table_name, _engine, _table_collation, _table_comment; IF NOT done THEN CASE _table_name";foreach(get_rows($D)as$G){$Xa=q($G["ENGINE"]=="InnoDB"?preg_replace('~(?:(.+); )?InnoDB free: .*~','\\1',$G["TABLE_COMMENT"]):$G["TABLE_COMMENT"]);echo" WHEN ".q($G["TABLE_NAME"])." THEN ".(isset($G["ENGINE"])?"IF _engine != '$G[ENGINE]' OR _table_collation != '$G[TABLE_COLLATION]' OR _table_comment != $Xa THEN ALTER TABLE ".idf_escape($G["TABLE_NAME"])." ENGINE=$G[ENGINE] COLLATE=$G[TABLE_COLLATION] COMMENT=$Xa; END IF":"BEGIN END").";";}echo" ELSE SET alter_command = CONCAT(alter_command, 'DROP TABLE `', REPLACE(_table_name, '`', '``'), '`;\\n'); END CASE; END IF; UNTIL done END REPEAT; CLOSE tables; END;; DELIMITER ; CALL adminer_alter(@adminer_alter); DROP PROCEDURE adminer_alter; ";}if(in_array("CREATE+ALTER",array($M,$_POST["table_style"]))&&$Mc)echo"SELECT @adminer_alter;\n";}}if($Mc)echo"-- ".$g->result("SELECT NOW()")."\n";exit;}page_header(lang(114),"",($_GET["export"]!=""?array("table"=>$_GET["export"]):array()),DB);echo'

';$ob=array('','USE','DROP+CREATE','CREATE');$Bf=array('','DROP+CREATE','CREATE');$mb=array('','TRUNCATE+INSERT','INSERT');if($u=="sql"){$ob[]='CREATE+ALTER';$Bf[]='CREATE+ALTER';$mb[]='INSERT+UPDATE';}parse_str($_COOKIE["adminer_export"],$G);if(!$G)$G=array("output"=>"text","format"=>"sql","db_style"=>(DB!=""?"":"CREATE"),"table_style"=>"DROP+CREATE","data_style"=>"INSERT");if(!isset($G["events"])){$G["routines"]=$G["events"]=($_GET["dump"]=="");$G["triggers"]=$G["table_style"];}echo"
".lang(115)."".html_select("output",$b->dumpOutput(),$G["output"],0)."\n";echo"
".lang(116)."".html_select("format",$b->dumpFormat(),$G["format"],0)."\n";echo($u=="sqlite"?"":"
".lang(24)."".html_select('db_style',$ob,$G["db_style"]).(support("routine")?checkbox("routines",1,$G["routines"],lang(117)):"").(support("event")?checkbox("events",1,$G["events"],lang(118)):"")),"
".lang(79)."".html_select('table_style',$Bf,$G["table_style"]).checkbox("auto_increment",1,$G["auto_increment"],lang(94)).(support("trigger")?checkbox("triggers",1,$G["triggers"],lang(111)):""),"
".lang(119)."".html_select('data_style',$mb,$G["data_style"]),'

';$we=array();if(DB!=""){$Oa=($a!=""?"":" checked");echo"","\n";$Y="";foreach(table_status()as$O){$_=$O["Name"];$ve=ereg_replace("_.*","",$_);$Oa=($a==""||$a==(substr($a,-1)=="%"?"$ve%":$_));$ze="\n";$i=$b->databases();if($i){foreach($i as$j){if(!information_schema($j)){$ve=ereg_replace("_.*","",$j);echo"
","","
".checkbox("tables[]",$_,$Oa,$_,"checkboxClick(event, this); formUncheck('check-tables');");if(is_view($O))$Y.="$ze\n";else echo"$ze\n";$we[$ve]++;}echo$Y;}else{echo"
".checkbox("databases[]",$j,$a==""||$a=="$ve%",$j,"formUncheck('check-databases');")."\n";$we[$ve]++;}}}else echo"
";}echo'

';$gc=true;foreach($we as$v=>$W){if($v!=""&&$W>1){echo($gc?"

":" ")."".h($v)."";$gc=false;}}}elseif(isset($_GET["privileges"])){page_header(lang(53));$E=$g->query("SELECT User, Host FROM mysql.".(DB==""?"user":"db WHERE ".q(DB)." LIKE Db")." ORDER BY Host, User");$sc=$E;if(!$E)$E=$g->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");echo"

\n";hidden_fields_get();echo"\n",($sc?"":"\n"),"\n","\n";while($G=$E->fetch_assoc())echo'
".lang(22)."".lang(21)." 
'.h($G["User"])."".h($G["Host"]).''.lang(33)."\n";if(!$sc||DB!="")echo"\n";echo"
\n","

\n",'

'.lang(120)."";}elseif(isset($_GET["sql"])){if(!$k&&$_POST["export"]){dump_headers("sql");$b->dumpTable("","");$b->dumpData("","table",$_POST["query"]);exit;}restart_session();$zc=&get_session("queries");$yc=&$zc[DB];if(!$k&&$_POST["clear"]){$yc=array();redirect(remove_from_uri("history"));}page_header(lang(46),$k);if(!$k&&$_POST){$oc=false;$D=$_POST["query"];if($_POST["webfile"]){$oc=@fopen((file_exists("adminer.sql")?"adminer.sql":(file_exists("adminer.sql.gz")?"compress.zlib://adminer.sql.gz":"compress.bzip2://adminer.sql.bz2")),"rb");$D=($oc?fread($oc,1e6):false);}elseif($_FILES&&$_FILES["sql_file"]["error"]!=UPLOAD_ERR_NO_FILE)$D=get_file("sql_file",true);if(is_string($D)){if(function_exists('memory_get_usage'))@ini_set("memory_limit",max(ini_bytes("memory_limit"),2*strlen($D)+memory_get_usage()+8e6));if($D!=""&&strlen($D)<1e6){$C=$D.(ereg(";[ \t\r\n]*\$",$D)?"":";");if(!$yc||reset(end($yc))!=$C)$yc[]=array($C,time());}$kf="(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";if(!ini_bool("session.use_cookies"))session_write_close();$rb=";";$A=0;$Hb=true;$h=connect();if(is_object($h)&&DB!="")$h->select_db(DB);$Wa=0;$Ob=array();$dd=0;$ie='[\'"'.($u=="sql"?'`#':($u=="sqlite"?'`[':($u=="mssql"?'[':''))).']|/\\*|-- |$'.($u=="pgsql"?'|\\$[^$]*\\$':'');$Pf=microtime();parse_str($_COOKIE["adminer_export"],$qa);$Ab=$b->dumpFormat();unset($Ab["sql"]);while($D!=""){if(!$A&&preg_match("~^$kf*DELIMITER\\s+(\\S+)~i",$D,$z)){$rb=$z[1];$D=substr($D,strlen($z[0]));}else{preg_match('('.preg_quote($rb)."\\s*|$ie)",$D,$z,PREG_OFFSET_CAPTURE,$A);list($mc,$re)=$z[0];if(!$mc&&$oc&&!feof($oc))$D.=fread($oc,1e5);else{if(!$mc&&rtrim($D)=="")break;$A=$re+strlen($mc);if($mc&&rtrim($mc)!=$rb){while(preg_match('('.($mc=='/*'?'\\*/':($mc=='['?']':(ereg('^-- |^#',$mc)?"\n":preg_quote($mc)."|\\\\."))).'|$)s',$D,$z,PREG_OFFSET_CAPTURE,$A)){$Xe=$z[0][0];if(!$Xe&&$oc&&!feof($oc))$D.=fread($oc,1e5);else{$A=$z[0][1]+strlen($Xe);if($Xe[0]!="\\")break;}}}else{$Hb=false;$C=substr($D,0,$re);$Wa++;$ze="

".shorten_utf8(trim($C),1000)."
\n";if(!$_POST["only_errors"]){echo$ze;ob_flush();flush();}$mf=microtime();if($g->multi_query($C)&&is_object($h)&&preg_match("~^$kf*USE\\b~isU",$C))$h->query($C);do{$E=$g->store_result();$Ib=microtime();$If=format_time($mf,$Ib).(strlen($C)<1000?" ".lang(33)."":"");if($g->error){echo($_POST["only_errors"]?$ze:""),"

".lang(121).": ".error()."\n";$Ob[]=" $Wa";if($_POST["error_stops"])break 2;}elseif(is_object($E)){$Wd=select($E,$h);if(!$_POST["only_errors"]){echo"

\n","

".($E->num_rows?lang(122,$E->num_rows):"").$If;$q="export-$Wa";$Xb=", ".lang(114)."\n";if($h&&preg_match("~^($kf|\\()*SELECT\\b~isU",$C)&&($Wb=explain($h,$C))){$q="explain-$Wa";echo", EXPLAIN$Xb","

\n";}else echo$Xb;echo"
\n";}}else{if(preg_match("~^$kf*(CREATE|DROP|ALTER)$kf+(DATABASE|SCHEMA)\\b~isU",$C)){restart_session();set_session("dbs",null);session_write_close();}if(!$_POST["only_errors"])echo"

".lang(123,$g->affected_rows)."$If\n";}$mf=$Ib;}while($g->next_result());$dd+=substr_count($C.$mc,"\n");$D=substr($D,$A);$A=0;}}}}if($Hb)echo"

".lang(124)."\n";elseif($_POST["only_errors"])echo"

".lang(125,$Wa-count($Ob)).format_time($Pf,microtime())."\n";elseif($Ob&&$Wa>1)echo"

".lang(121).": ".implode("",$Ob)."\n";}else echo"

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

';$C=$_GET["sql"];if($_POST)$C=$_POST["query"];elseif($_GET["history"]=="all")$C=$yc;elseif($_GET["history"]!="")$C=$yc[$_GET["history"]][0];textarea("query",$C,20);echo($_POST?"":"\n"),"

".(ini_bool("file_uploads")?lang(126).': (< '.ini_get("upload_max_filesize").'B)':lang(127)),'

',checkbox("error_stops",1,$_POST["error_stops"],lang(129))."\n",checkbox("only_errors",1,$_POST["only_errors"],lang(130))."\n";print_fieldset("webfile",lang(131),$_POST["webfile"],"document.getElementById('form')['only_errors'].checked = true; ");$Za=array();foreach(array("gz"=>"zlib","bz2"=>"bz2")as$v=>$W){if(extension_loaded($W))$Za[]=".$v";}echo lang(132,"adminer.sql".($Za?"[".implode("|",$Za)."]":"").""),' ',"\n";if($yc){print_fieldset("history",lang(134),$_GET["history"]!="");foreach($yc as$v=>$W){list($C,$If)=$W;echo''.lang(33)." ".@date("H:i:s",$If)." ".shorten_utf8(ltrim(str_replace("\n"," ",str_replace("\r","",preg_replace('~^(#|-- ).*~m','',$C)))),80,"")."
\n";}echo"\n","".lang(136)."\n","\n";}echo'

';}elseif(isset($_GET["edit"])){$a=$_GET["edit"];$Z=(isset($_GET["select"])?(count($_POST["check"])==1?where_check($_POST["check"][0]):""):where($_GET));$gg=(isset($_GET["select"])?$_POST["edit"]:$Z);$m=fields($a);foreach($m as$_=>$l){if(!isset($l["privileges"][$gg?"update":"insert"])||$b->fieldName($l)=="")unset($m[$_]);}if($_POST&&!$k&&!isset($_GET["select"])){$fd=$_POST["referer"];if($_POST["insert"])$fd=($gg?null:$_SERVER["REQUEST_URI"]);elseif(!ereg('^.+&select=.+$',$fd))$fd=ME."select=".urlencode($a);if(isset($_POST["delete"]))query_redirect("DELETE".limit1("FROM ".table($a)," WHERE $Z"),$fd,lang(137));else{$K=array();foreach($m as$_=>$l){$W=process_input($l);if($W!==false&&$W!==null)$K[idf_escape($_)]=($gg?"\n".idf_escape($_)." = $W":$W);}if($gg){if(!$K)redirect($fd);query_redirect("UPDATE".limit1(table($a)." SET".implode(",",$K),"\nWHERE $Z"),$fd,lang(138));}else{$E=insert_into($a,$K);$Xc=($E?last_id():0);queries_redirect($fd,lang(139,($Xc?" $Xc":"")),$E);}}}$yf=$b->tableName(table_status($a));page_header(($gg?lang(33):lang(140)),$k,array("select"=>array($a,$yf)),$yf);$G=null;if($_POST["save"])$G=(array)$_POST["fields"];elseif($Z){$I=array();foreach($m as$_=>$l){if(isset($l["privileges"]["select"]))$I[]=($_POST["clone"]&&$l["auto_increment"]?"'' AS ":($u=="sql"&&ereg("enum|set",$l["type"])?"1*".idf_escape($_)." AS ":"")).idf_escape($_);}$G=array();if($I){$H=get_rows("SELECT".limit(implode(", ",$I)." FROM ".table($a)," WHERE $Z",(isset($_GET["select"])?2:1)));$G=(isset($_GET["select"])&&count($H)!=1?null:reset($H));}}if($G===false)echo"

".lang(84)."\n";echo'

';if($m){echo"\n";foreach($m as$_=>$l){echo"
".$b->fieldName($l);$qb=$_GET["set"][bracket_escape($_)];$X=($G!==null?($G[$_]!=""&&$u=="sql"&&ereg("enum|set",$l["type"])?(is_array($G[$_])?array_sum($G[$_]):+$G[$_]):$G[$_]):(!$gg&&$l["auto_increment"]?"":(isset($_GET["select"])?false:($qb!==null?$qb:$l["default"]))));if(!$_POST["save"]&&is_string($X))$X=$b->editVal($X,$l);$o=($_POST["save"]?(string)$_POST["function"][$_]:($gg&&$l["on_update"]=="CURRENT_TIMESTAMP"?"now":($X===false?null:($X!==null?'':'NULL'))));if($l["type"]=="timestamp"&&$X=="CURRENT_TIMESTAMP"){$X="";$o="now";}input($l,$X,$o);echo"\n";}echo"
\n";}echo'

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

';}elseif(isset($_GET["create"])){$a=$_GET["create"];$je=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$Ke=referencable_primary($a);$kc=array();foreach($Ke as$yf=>$l)$kc[str_replace("`","``",$yf)."`".str_replace("`","``",$l["field"])]=$yf;$Zd=array();$ae=array();if($a!=""){$Zd=fields($a);$ae=table_status($a);}if($_POST&&!$_POST["fields"])$_POST["fields"]=array();if($_POST&&!$k&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"])query_redirect("DROP TABLE ".table($a),substr(ME,0,-1),lang(145));else{$m=array();$wa=array();$ig=false;$ic=array();ksort($_POST["fields"]);$Yd=reset($Zd);$ua=" FIRST";foreach($_POST["fields"]as$v=>$l){$n=$kc[$l["type"]];$Xf=($n!==null?$Ke[$n]:$l);if($l["field"]!=""){if(!$l["has_default"])$l["default"]=null;$qb=eregi_replace(" *on update CURRENT_TIMESTAMP","",$l["default"]);if($qb!=$l["default"]){$l["on_update"]="CURRENT_TIMESTAMP";$l["default"]=$qb;}if($v==$_POST["auto_increment_col"])$l["auto_increment"]=true;$De=process_field($l,$Xf);$wa[]=array($l["orig"],$De,$ua);if($De!=process_field($Yd,$Yd)){$m[]=array($l["orig"],$De,$ua);if($l["orig"]!=""||$ua)$ig=true;}if($n!==null)$ic[idf_escape($l["field"])]=($a!=""&&$u!="sqlite"?"ADD":" ")." FOREIGN KEY (".idf_escape($l["field"]).") REFERENCES ".table($kc[$l["type"]])." (".idf_escape($Xf["field"]).")".(ereg("^($Ld)\$",$l["on_delete"])?" ON DELETE $l[on_delete]":"");$ua=" AFTER ".idf_escape($l["field"]);}elseif($l["orig"]!=""){$ig=true;$m[]=array($l["orig"]);}if($l["orig"]!=""){$Yd=next($Zd);if(!$Yd)$ua="";}}$le="";if(in_array($_POST["partition_by"],$je)){$me=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$v=>$W){$X=$_POST["partition_values"][$v];$me[]="\nPARTITION ".idf_escape($W)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($X!=""?" ($X)":" MAXVALUE");}}$le.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($me?" (".implode(",",$me)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif($a!=""&&support("partitioning"))$le.="\nREMOVE PARTITIONING";$qd=lang(146);if($a==""){cookie("adminer_engine",$_POST["Engine"]);$qd=lang(147);}$_=trim($_POST["name"]);queries_redirect(ME."table=".urlencode($_),$qd,alter_table($a,$_,($u=="sqlite"&&($ig||$ic)?$wa:$m),$ic,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$ae["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$ae["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$le));}}page_header(($a!=""?lang(30):lang(148)),$k,array("table"=>$a),$a);$G=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($T["int"])?"int":(isset($T["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$G=$_POST;if($G["auto_increment_col"])$G["fields"][$G["auto_increment_col"]]["auto_increment"]=true;process_fields($G["fields"]);}elseif($a!=""){$G=$ae;$G["name"]=$a;$G["fields"]=array();if(!$_GET["auto_increment"])$G["Auto_increment"]="";foreach($Zd as$l){$l["has_default"]=isset($l["default"]);if($l["on_update"])$l["default"].=" ON UPDATE $l[on_update]";$G["fields"][]=$l;}if(support("partitioning")){$pc="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($a);$E=$g->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $pc ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($G["partition_by"],$G["partitions"],$G["partition"])=$E->fetch_row();$G["partition_names"]=array();$G["partition_values"]=array();foreach(get_rows("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $pc AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION")as$We){$G["partition_names"][]=$We["PARTITION_NAME"];$G["partition_values"][]=$We["PARTITION_DESCRIPTION"];}$G["partition_names"][]="";}}$Ta=collations();$tf=floor(extension_loaded("suhosin")?(min(ini_get("suhosin.request.max_vars"),ini_get("suhosin.post.max_vars"))-13)/10:0);if($tf&&count($G["fields"])>$tf)echo"

".h(lang(149,'suhosin.post.max_vars','suhosin.request.max_vars'))."\n";$Kb=engines();foreach($Kb as$Jb){if(!strcasecmp($Jb,$G["Engine"])){$G["Engine"]=$Jb;break;}}echo'

',lang(150),': ';if($a==""&&!$_POST){?>"(".lang(151).")")+$Kb,$G["Engine"]):""),' ',($Ta&&!ereg("sqlite|mssql",$u)?html_select("Collation",array(""=>"(".lang(87).")")+$Ta,$G["Collation"]):""),' ';$Ya=($_POST?$_POST["comments"]:$G["Comment"]!="");if(!$_POST&&!$Ya){foreach($G["fields"]as$l){if($l["comment"]!=""){$Ya=true;break;}}}edit_fields($G["fields"],$Ta,"TABLE",$tf,$kc,$Ya);echo'

',lang(94),': ',(support("comment")?checkbox("comments",1,$Ya,lang(96),"columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus();",true).' ':''),'

';if($_GET["create"]!=""){echo'';}echo' ';if(support("partitioning")){$ke=ereg('RANGE|LIST',$G["partition_by"]);print_fieldset("partition",lang(152),$G["partition_by"]);echo'

',html_select("partition_by",array(-1=>"")+$je,$G["partition_by"],"partitionByChange(this);"),'() ',lang(153),': ';foreach($G["partition_names"]as$v=>$W){echo'',' ';}echo'

';}elseif(isset($_GET["indexes"])){$a=$_GET["indexes"];$Ec=array("PRIMARY","UNIQUE","INDEX");$O=table_status($a);if(eregi("MyISAM|M?aria",$O["Engine"]))$Ec[]="FULLTEXT";$t=indexes($a);if($u=="sqlite"){unset($Ec[0]);unset($t[""]);}if($_POST&&!$k&&!$_POST["add"]){$c=array();foreach($_POST["indexes"]as$s){$_=$s["name"];if(in_array($s["type"],$Ec)){$f=array();$cd=array();$K=array();ksort($s["columns"]);foreach($s["columns"]as$v=>$e){if($e!=""){$w=$s["lengths"][$v];$K[]=idf_escape($e).($w?"(".(+$w).")":"");$f[]=$e;$cd[]=($w?$w:null);}}if($f){$Vb=$t[$_];if($Vb){ksort($Vb["columns"]);ksort($Vb["lengths"]);if($s["type"]==$Vb["type"]&&array_values($Vb["columns"])===$f&&(!$Vb["lengths"]||array_values($Vb["lengths"])===$cd)){unset($t[$_]);continue;}}$c[]=array($s["type"],$_,"(".implode(", ",$K).")");}}}foreach($t as$_=>$Vb)$c[]=array($Vb["type"],$_,"DROP");if(!$c)redirect(ME."table=".urlencode($a));queries_redirect(ME."table=".urlencode($a),lang(156),alter_indexes($a,$c));}page_header(lang(104),$k,array("table"=>$a),$a);$m=array_keys(fields($a));$G=array("indexes"=>$t);if($_POST){$G=$_POST;if($_POST["add"]){foreach($G["indexes"]as$v=>$s){if($s["columns"][count($s["columns"])]!="")$G["indexes"][$v]["columns"][]="";}$s=end($G["indexes"]);if($s["type"]||array_filter($s["columns"],'strlen')||array_filter($s["lengths"],'strlen'))$G["indexes"][]=array("columns"=>array(1=>""));}}else{foreach($G["indexes"]as$v=>$s){$G["indexes"][$v]["name"]=$v;$G["indexes"][$v]["columns"][]="";}$G["indexes"][]=array("columns"=>array(1=>""));}echo'
';$Oc=1;foreach($G["indexes"]as$s){echo"
',lang(157),'',lang(158),'',lang(159),'
".html_select("indexes[$Oc][type]",array(-1=>"")+$Ec,$s["type"],($Oc==count($G["indexes"])?"indexesAddRow(this);":1))."";ksort($s["columns"]);$p=1;foreach($s["columns"]as$v=>$e){echo"".html_select("indexes[$Oc][columns][$p]",array(-1=>"")+$m,$e,($p==count($s["columns"])?"indexesAddColumn":"indexesChangeColumn")."(this, '".js_escape($u=="sql"?"":$_GET["indexes"]."_")."');")," ";$p++;}echo"\n";$Oc++;}echo'

';}elseif(isset($_GET["database"])){if($_POST&&!$k&&!isset($_POST["add_x"])){restart_session();$_=trim($_POST["name"]);if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),lang(160),drop_databases(array(DB)));}elseif(DB!==$_){if(DB!=""){$_GET["db"]=$_;queries_redirect(preg_replace('~db=[^&]*&~','',ME)."db=".urlencode($_),lang(161),rename_database($_,$_POST["collation"]));}else{$i=explode("\n",str_replace("\r","",$_));$rf=true;$Wc="";foreach($i as$j){if(count($i)==1||$j!=""){if(!create_database($j,$_POST["collation"]))$rf=false;$Wc=$j;}}queries_redirect(ME."db=".urlencode($Wc),lang(162),$rf);}}else{if(!$_POST["collation"])redirect(substr(ME,0,-1));query_redirect("ALTER DATABASE ".idf_escape($_).(eregi('^[a-z0-9_]+$',$_POST["collation"])?" COLLATE $_POST[collation]":""),substr(ME,0,-1),lang(163));}}page_header(DB!=""?lang(49):lang(164),$k,array(),DB);$Ta=collations();$_=DB;$Sa=null;if($_POST){$_=$_POST["name"];$Sa=$_POST["collation"];}elseif(DB!="")$Sa=db_collation(DB,$Ta);elseif($u=="sql"){foreach(get_vals("SHOW GRANTS")as$sc){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~',$sc,$z)&&$z[1]){$_=stripcslashes(idf_unescape("`$z[2]`"));break;}}}echo'

',($_POST["add_x"]||strpos($_,"\n")?'
':'')."\n".($Ta?html_select("collation",array(""=>"(".lang(87).")")+$Ta,$Sa):"");?> ';if(DB!="")echo"\n";elseif(!$_POST["add_x"]&&$_GET["db"]=="")echo"\n";echo'

';}elseif(isset($_GET["scheme"])){if($_POST&&!$k){$y=preg_replace('~ns=[^&]*&~','',ME)."ns=";if($_POST["drop"])query_redirect("DROP SCHEMA ".idf_escape($_GET["ns"]),$y,lang(165));else{$_=trim($_POST["name"]);$y.=urlencode($_);if($_GET["ns"]=="")query_redirect("CREATE SCHEMA ".idf_escape($_),$y,lang(166));elseif($_GET["ns"]!=$_)query_redirect("ALTER SCHEMA ".idf_escape($_GET["ns"])." RENAME TO ".idf_escape($_),$y,lang(167));else redirect($y);}}page_header($_GET["ns"]!=""?lang(50):lang(51),$k);$G=$_POST;if(!$G)$G=array("name"=>$_GET["ns"]);echo'

"> ';if($_GET["ns"]!="")echo"\n";echo'

';}elseif(isset($_GET["call"])){$da=$_GET["call"];page_header(lang(168).": ".h($da),$k);$Te=routine($da,(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Dc=array();$ce=array();foreach($Te["fields"]as$p=>$l){if(substr($l["inout"],-3)=="OUT")$ce[$p]="@".idf_escape($l["field"])." AS ".idf_escape($l["field"]);if(!$l["inout"]||substr($l["inout"],0,2)=="IN")$Dc[]=$p;}if(!$k&&$_POST){$La=array();foreach($Te["fields"]as$v=>$l){if(in_array($v,$Dc)){$W=process_input($l);if($W===false)$W="''";if(isset($ce[$v]))$g->query("SET @".idf_escape($l["field"])." = $W");}$La[]=(isset($ce[$v])?"@".idf_escape($l["field"]):$W);}$D=(isset($_GET["callf"])?"SELECT":"CALL")." ".idf_escape($da)."(".implode(", ",$La).")";echo"

".h($D)." ".lang(33)."\n";if(!$g->multi_query($D))echo"

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

".lang(169,$g->affected_rows)."\n";}while($g->next_result());if($ce)select($g->query("SELECT ".implode(", ",$ce)));}}echo'

';if($Dc){echo"\n";foreach($Dc as$v){$l=$Te["fields"][$v];$_=$l["field"];echo"
".$b->fieldName($l);$X=$_POST["fields"][$_];if($X!=""){if($l["type"]=="enum")$X=+$X;if($l["type"]=="set")$X=array_sum($X);}input($l,$X,(string)$_POST["function"][$_]);echo"\n";}echo"
\n";}echo'

';}elseif(isset($_GET["foreign"])){$a=$_GET["foreign"];if($_POST&&!$k&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"])query_redirect("ALTER TABLE ".table($a)."\nDROP ".($u=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($a),lang(170));else{$jf=array_filter($_POST["source"],'strlen');ksort($jf);$Ef=array();foreach($jf as$v=>$W)$Ef[$v]=$_POST["target"][$v];query_redirect("ALTER TABLE ".table($a).($_GET["name"]!=""?"\nDROP ".($u=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$jf)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$Ef)).")".(ereg("^($Ld)\$",$_POST["on_delete"])?" ON DELETE $_POST[on_delete]":"").(ereg("^($Ld)\$",$_POST["on_update"])?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($a),($_GET["name"]!=""?lang(171):lang(172)));$k=lang(173)."
$k";}}page_header(lang(174),$k,array("table"=>$a),$a);$G=array("table"=>$a,"source"=>array(""));if($_POST){$G=$_POST;ksort($G["source"]);if($_POST["add"])$G["source"][]="";elseif($_POST["change"]||$_POST["change-js"])$G["target"]=array();}elseif($_GET["name"]!=""){$kc=foreign_keys($a);$G=$kc[$_GET["name"]];$G["source"][]="";}$jf=array_keys(fields($a));$Ef=($a===$G["table"]?$jf:array_keys(fields($G["table"])));$Je=array();foreach(table_status()as$_=>$O){if(fk_support($O))$Je[]=$_;}echo'

';if($G["db"]==""&&$G["ns"]==""){echo lang(175),': ',html_select("table",$Je,$G["table"],"this.form['change-js'].value = '1'; this.form.submit();"),'

';$Oc=0;foreach($G["source"]as$v=>$W){echo"","
',lang(106),'',lang(107),'
".html_select("source[".(+$v)."]",array(-1=>"")+$jf,$W,($Oc==count($G["source"])-1?"foreignAddRow(this);":1)),"".html_select("target[".(+$v)."]",$Ef,$G["target"][$v]);$Oc++;}echo'

',lang(88),': ',html_select("on_delete",array(-1=>"")+explode("|",$Ld),$G["on_delete"]),' ',lang(108),': ',html_select("on_update",array(-1=>"")+explode("|",$Ld),$G["on_update"]),'

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

';}elseif(isset($_GET["view"])){$a=$_GET["view"];$zb=false;if($_POST&&!$k){$_=trim($_POST["name"]);$zb=drop_create("DROP VIEW ".table($a),"CREATE VIEW ".table($_)." AS\n$_POST[select]",($_POST["drop"]?substr(ME,0,-1):ME."table=".urlencode($_)),lang(178),lang(179),lang(180),$a);}page_header(($a!=""?lang(29):lang(181)),$k,array("table"=>$a),$a);$G=$_POST;if(!$G&&$a!=""){$G=view($a);$G["name"]=$a;}echo'

',lang(159),':

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

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

';}elseif(isset($_GET["event"])){$aa=$_GET["event"];$Lc=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$of=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");if($_POST&&!$k){if($_POST["drop"])query_redirect("DROP EVENT ".idf_escape($aa),substr(ME,0,-1),lang(182));elseif(in_array($_POST["INTERVAL_FIELD"],$Lc)&&isset($of[$_POST["STATUS"]])){$Ye="\nON SCHEDULE ".($_POST["INTERVAL_VALUE"]?"EVERY ".q($_POST["INTERVAL_VALUE"])." $_POST[INTERVAL_FIELD]".($_POST["STARTS"]?" STARTS ".q($_POST["STARTS"]):"").($_POST["ENDS"]?" ENDS ".q($_POST["ENDS"]):""):"AT ".q($_POST["STARTS"]))." ON COMPLETION".($_POST["ON_COMPLETION"]?"":" NOT")." PRESERVE";queries_redirect(substr(ME,0,-1),($aa!=""?lang(183):lang(184)),queries(($aa!=""?"ALTER EVENT ".idf_escape($aa).$Ye.($aa!=$_POST["EVENT_NAME"]?"\nRENAME TO ".idf_escape($_POST["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($_POST["EVENT_NAME"]).$Ye)."\n".$of[$_POST["STATUS"]]." COMMENT ".q($_POST["EVENT_COMMENT"]).rtrim(" DO\n$_POST[EVENT_DEFINITION]",";").";"));}}page_header(($aa!=""?lang(185).": ".h($aa):lang(186)),$k);$G=$_POST;if(!$G&&$aa!=""){$H=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($aa));$G=reset($H);}echo'
',lang(159),'
',lang(187),'
',lang(188),'
',lang(189),' ',html_select("INTERVAL_FIELD",$Lc,$G["INTERVAL_FIELD"]),'
',lang(75),'',html_select("STATUS",$of,$G["STATUS"]),'
',lang(96),'
 ',checkbox("ON_COMPLETION","PRESERVE",$G["ON_COMPLETION"]=="PRESERVE",lang(190)),'

';textarea("EVENT_DEFINITION",$G["EVENT_DEFINITION"]);echo'

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

';}elseif(isset($_GET["procedure"])){$da=$_GET["procedure"];$Te=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$Ue=routine_languages();$zb=false;if($_POST&&!$k&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){$K=array();$m=(array)$_POST["fields"];ksort($m);foreach($m as$l){if($l["field"]!="")$K[]=(ereg("^($Ic)\$",$l["inout"])?"$l[inout] ":"").idf_escape($l["field"]).process_type($l,"CHARACTER SET");}$zb=drop_create("DROP $Te ".idf_escape($da),"CREATE $Te ".idf_escape(trim($_POST["name"]))." (".implode(", ",$K).")".(isset($_GET["function"])?" RETURNS".process_type($_POST["returns"],"CHARACTER SET"):"").(in_array($_POST["language"],$Ue)?" LANGUAGE $_POST[language]":"").rtrim("\n$_POST[definition]",";").";",substr(ME,0,-1),lang(191),lang(192),lang(193),$da);}page_header(($da!=""?(isset($_GET["function"])?lang(194):lang(195)).": ".h($da):(isset($_GET["function"])?lang(196):lang(197))),$k);$Ta=get_vals("SHOW CHARACTER SET");sort($Ta);$G=array("fields"=>array());if($_POST){$G=$_POST;$G["fields"]=(array)$G["fields"];process_fields($G["fields"]);}elseif($da!=""){$G=routine($da,$Te);$G["name"]=$da;}echo'

',lang(159),': ',($Ue?lang(8).": ".html_select("language",$Ue,$G["language"]):""),' ';edit_fields($G["fields"],$Ta,$Te);if(isset($_GET["function"])){echo"
".lang(198);edit_type("returns",$G["returns"],$Ta);}echo'

';textarea("definition",$G["definition"]);echo'

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

';}elseif(isset($_GET["sequence"])){$fa=$_GET["sequence"];if($_POST&&!$k){$y=substr(ME,0,-1);$_=trim($_POST["name"]);if($_POST["drop"])query_redirect("DROP SEQUENCE ".idf_escape($fa),$y,lang(199));elseif($fa=="")query_redirect("CREATE SEQUENCE ".idf_escape($_),$y,lang(200));elseif($fa!=$_)query_redirect("ALTER SEQUENCE ".idf_escape($fa)." RENAME TO ".idf_escape($_),$y,lang(201));else redirect($y);}page_header($fa!=""?lang(202).": ".h($fa):lang(203),$k);$G=$_POST;if(!$G)$G=array("name"=>$fa);echo'

';if($fa!="")echo"\n";echo'

';}elseif(isset($_GET["type"])){$ga=$_GET["type"];if($_POST&&!$k){$y=substr(ME,0,-1);if($_POST["drop"])query_redirect("DROP TYPE ".idf_escape($ga),$y,lang(204));else query_redirect("CREATE TYPE ".idf_escape(trim($_POST["name"]))." $_POST[as]",$y,lang(205));}page_header($ga!=""?lang(206).": ".h($ga):lang(207),$k);$G=$_POST;if(!$G)$G=array("as"=>"AS ");echo'

';if($ga!="")echo"\n";else{echo"\n";textarea("as",$G["as"]);echo"

\n";}echo'

';}elseif(isset($_GET["trigger"])){$a=$_GET["trigger"];$Vf=trigger_options();$Tf=array("INSERT","UPDATE","DELETE");$zb=false;if($_POST&&!$k&&in_array($_POST["Timing"],$Vf["Timing"])&&in_array($_POST["Event"],$Tf)&&in_array($_POST["Type"],$Vf["Type"])){$Jf=" $_POST[Timing] $_POST[Event]";$Kd=" ON ".table($a);$zb=drop_create("DROP TRIGGER ".idf_escape($_GET["name"]).($u=="pgsql"?$Kd:""),"CREATE TRIGGER ".idf_escape($_POST["Trigger"]).($u=="mssql"?$Kd.$Jf:$Jf.$Kd).rtrim(" $_POST[Type]\n$_POST[Statement]",";").";",ME."table=".urlencode($a),lang(208),lang(209),lang(210),$_GET["name"]);}page_header(($_GET["name"]!=""?lang(211).": ".h($_GET["name"]):lang(212)),$k,array("table"=>$a));$G=$_POST;if(!$G)$G=trigger($_GET["name"])+array("Trigger"=>$a."_bi");echo'
',lang(213),'',html_select("Timing",$Vf["Timing"],$G["Timing"],"if (/^".preg_quote($a,"/")."_[ba][iud]$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '".js_escape($a)."_' + selectValue(this).charAt(0).toLowerCase() + selectValue(this.form['Event']).charAt(0).toLowerCase();"),'
',lang(214),'',html_select("Event",$Tf,$G["Event"],"this.form['Timing'].onchange();"),'
',lang(91),'',html_select("Type",$Vf["Type"],$G["Type"]),'

',lang(159),':

';textarea("Statement",$G["Statement"]);echo'

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

';}elseif(isset($_GET["user"])){$ha=$_GET["user"];$Be=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$G){foreach(explode(",",($G["Privilege"]=="Grant option"?"":$G["Context"]))as$db)$Be[$db][$G["Privilege"]]=$G["Comment"];}$Be["Server Admin"]+=$Be["File access on server"];$Be["Databases"]["Create routine"]=$Be["Procedures"]["Create routine"];unset($Be["Procedures"]["Create routine"]);$Be["Columns"]=array();foreach(array("Select","Insert","Update","References")as$W)$Be["Columns"][$W]=$Be["Tables"][$W];unset($Be["Server Admin"]["Usage"]);foreach($Be["Tables"]as$v=>$W)unset($Be["Databases"][$v]);$Bd=array();if($_POST){foreach($_POST["objects"]as$v=>$W)$Bd[$W]=(array)$Bd[$W]+(array)$_POST["grants"][$v];}$tc=array();$Id="";if(isset($_GET["host"])&&($E=$g->query("SHOW GRANTS FOR ".q($ha)."@".q($_GET["host"])))){while($G=$E->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$G[0],$z)&&preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~',$z[1],$jd,PREG_SET_ORDER)){foreach($jd as$W){if($W[1]!="USAGE")$tc["$z[2]$W[2]"][$W[1]]=true;if(ereg(' WITH GRANT OPTION',$G[0]))$tc["$z[2]$W[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$G[0],$z))$Id=$z[1];}}if($_POST&&!$k){$Jd=(isset($_GET["host"])?q($ha)."@".q($_GET["host"]):"''");$Cd=q($_POST["user"])."@".q($_POST["host"]);$ne=q($_POST["pass"]);if($_POST["drop"])query_redirect("DROP USER $Jd",ME."privileges=",lang(215));else{$ib=false;if($Jd!=$Cd){$ib=queries(($g->server_info<5?"GRANT USAGE ON *.* TO":"CREATE USER")." $Cd IDENTIFIED BY".($_POST["hashed"]?" PASSWORD":"")." $ne");$k=!$ib;}elseif($_POST["pass"]!=$Id||!$_POST["hashed"])queries("SET PASSWORD FOR $Cd = ".($_POST["hashed"]?$ne:"PASSWORD($ne)"));if(!$k){$Qe=array();foreach($Bd as$Fd=>$sc){if(isset($_GET["grant"]))$sc=array_filter($sc);$sc=array_keys($sc);if(isset($_GET["grant"]))$Qe=array_diff(array_keys(array_filter($Bd[$Fd],'strlen')),$sc);elseif($Jd==$Cd){$Hd=array_keys((array)$tc[$Fd]);$Qe=array_diff($Hd,$sc);$sc=array_diff($sc,$Hd);unset($tc[$Fd]);}if(preg_match('~^(.+)\\s*(\\(.*\\))?$~U',$Fd,$z)&&(!grant("REVOKE",$Qe,$z[2]," ON $z[1] FROM $Cd")||!grant("GRANT",$sc,$z[2]," ON $z[1] TO $Cd"))){$k=true;break;}}}if(!$k&&isset($_GET["host"])){if($Jd!=$Cd)queries("DROP USER $Jd");elseif(!isset($_GET["grant"])){foreach($tc as$Fd=>$Qe){if(preg_match('~^(.+)(\\(.*\\))?$~U',$Fd,$z))grant("REVOKE",array_keys($Qe),$z[2]," ON $z[1] FROM $Cd");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?lang(216):lang(217)),!$k);if($ib)$g->query("DROP USER $Cd");}}page_header((isset($_GET["host"])?lang(22).": ".h("$ha@$_GET[host]"):lang(120)),$k,array("privileges"=>array('',lang(53))));if($_POST){$G=$_POST;$tc=$Bd;}else{$G=$_GET+array("host"=>$g->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$G["pass"]=$Id;if($Id!="")$G["hashed"]=true;$tc[(DB!=""&&!isset($_GET["host"])?idf_escape(addcslashes(DB,"%_")):"").".*"]=array();}echo'
',lang(21),'
',lang(22),'
',lang(23),' ';if(!$G["hashed"]){echo'';}echo checkbox("hashed",1,$G["hashed"],lang(218),"typePassword(this.form['pass'], this.checked);"),'
';echo"\n","\n";foreach(array(""=>"","Server Admin"=>lang(21),"Databases"=>lang(24),"Tables"=>lang(102),"Columns"=>lang(103),"Procedures"=>lang(219),)as$db=>$sb){foreach((array)$Be[$db]as$Ae=>$Xa){echo"$sb'.h($Ae);$p=0;foreach($tc as$Fd=>$sc){$_="'grants[$p][".h(strtoupper($Ae))."]'";$X=$sc[strtoupper($Ae)];if($db=="Server Admin"&&$Fd!=(isset($tc["*.*"])?"*.*":".*"))echo"
".lang(53)."";$p=0;foreach($tc as$Fd=>$sc){echo''.($Fd!="*.*"?"":"*.*");$p++;}echo"
 ";elseif(isset($_GET["grant"]))echo"";else echo"";$p++;}}}echo"
\n",'

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

';}elseif(isset($_GET["processlist"])){if(support("kill")&&$_POST&&!$k){$Tc=0;foreach((array)$_POST["kill"]as$W){if(queries("KILL ".(+$W)))$Tc++;}queries_redirect(ME."processlist=",lang(222,$Tc),$Tc||!$_POST["kill"]);}page_header(lang(73),$k);echo'
';$p=-1;foreach(process_list()as$p=>$G){if(!$p)echo"".(support("kill")?"\n";echo"".(support("kill")?"
 ":"")."".implode("",array_keys($G))."
".checkbox("kill[]",$G["Id"],0):"");foreach($G as$v=>$W)echo"".(($u=="sql"&&$v=="Info"&&ereg("Query|Killed",$G["Command"])&&$W!="")||($u=="pgsql"&&$v=="current_query"&&$W!="")||($u=="oracle"&&$v=="sql_text"&&$W!="")?"".shorten_utf8($W,100,"").' '.lang(33).'':nbsp($W));echo"\n";}echo'

';if(support("kill")){echo($p+1)."/".lang(223,$g->result("SELECT @@max_connections")),"

\n";}echo'

';}elseif(isset($_GET["select"])){$a=$_GET["select"];$O=table_status($a);$t=indexes($a);$m=fields($a);$kc=column_foreign_keys($a);$Gd="";if($O["Oid"]=="t"){$Gd=($u=="sqlite"?"rowid":"oid");$t[]=array("type"=>"PRIMARY","columns"=>array($Gd));}parse_str($_COOKIE["adminer_import"],$ra);$Re=array();$f=array();$Hf=null;foreach($m as$v=>$l){$_=$b->fieldName($l);if(isset($l["privileges"]["select"])&&$_!=""){$f[$v]=html_entity_decode(strip_tags($_));if(ereg('text|lob',$l["type"]))$Hf=$b->selectLengthProcess();}$Re+=$l["privileges"];}list($I,$uc)=$b->selectColumnsProcess($f,$t);$Z=$b->selectSearchProcess($m,$t);$Td=$b->selectOrderProcess($m,$t);$x=$b->selectLimitProcess();$pc=($I?implode(", ",$I):($Gd?"$Gd, ":"")."*")."\nFROM ".table($a);$vc=($uc&&count($uc)$G)echo$g->result("SELECT".limit(idf_escape(key($G))." FROM ".table($a)," WHERE ".where_check($cg).($Z?" AND ".implode(" AND ",$Z):"").($Td?" ORDER BY ".implode(", ",$Td):""),1));exit;}if($_POST&&!$k){$sg="(".implode(") OR (",array_map('where_check',(array)$_POST["check"])).")";$xe=$eg=null;foreach($t as$s){if($s["type"]=="PRIMARY"){$xe=array_flip($s["columns"]);$eg=($I?$xe:array());break;}}foreach((array)$eg as$v=>$W){if(in_array(idf_escape($v),$I))unset($eg[$v]);}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"])||$eg===array()){$rg=$Z;if(is_array($_POST["check"]))$rg[]="($sg)";$D="SELECT $pc".($rg?"\nWHERE ".implode(" AND ",$rg):"").$vc;}else{$ag=array();foreach($_POST["check"]as$W)$ag[]="(SELECT".limit($pc,"\nWHERE ".($Z?implode(" AND ",$Z)." AND ":"").where_check($W).$vc,1).")";$D=implode(" UNION ALL ",$ag);}$b->dumpData($a,"table",$D);exit;}if(!$b->selectEmailProcess($Z,$kc)){if($_POST["save"]||$_POST["delete"]){$E=true;$sa=0;$D=table($a);$K=array();if(!$_POST["delete"]){foreach($f as$_=>$W){$W=process_input($m[$_]);if($W!==null){if($_POST["clone"])$K[idf_escape($_)]=($W!==false?$W:idf_escape($_));elseif($W!==false)$K[]=idf_escape($_)." = $W";}}$D.=($_POST["clone"]?" (".implode(", ",array_keys($K)).")\nSELECT ".implode(", ",$K)."\nFROM ".table($a):" SET\n".implode(",\n",$K));}if($_POST["delete"]||$K){$Va="UPDATE";if($_POST["delete"]){$Va="DELETE";$D="FROM $D";}if($_POST["clone"]){$Va="INSERT";$D="INTO $D";}if($_POST["all"]||($eg===array()&&$_POST["check"])||count($uc)affected_rows;}else{foreach((array)$_POST["check"]as$W){$E=queries($Va.limit1($D,"\nWHERE ".where_check($W)));if(!$E)break;$sa+=$g->affected_rows;}}}$qd=lang(225,$sa);if($_POST["clone"]&&$E&&$sa==1){$Xc=last_id();if($Xc)$qd=lang(139," $Xc");}queries_redirect(remove_from_uri("page"),$qd,$E);}elseif(!$_POST["import"]){if(!$_POST["val"])$k=lang(226);else{$E=true;$sa=0;foreach($_POST["val"]as$cg=>$G){$K=array();foreach($G as$v=>$W){$v=bracket_escape($v,1);$K[]=idf_escape($v)." = ".(ereg('char|text',$m[$v]["type"])||$W!=""?$b->processInput($m[$v],$W):"NULL");}$D=table($a)." SET ".implode(", ",$K);$rg=" WHERE ".where_check($cg).($Z?" AND ".implode(" AND ",$Z):"");$E=queries("UPDATE".(count($uc)affected_rows;}queries_redirect(remove_from_uri(),lang(225,$sa),$E);}}elseif(is_string($dc=get_file("csv_file",true))){cookie("adminer_import","output=".urlencode($ra["output"])."&format=".urlencode($_POST["separator"]));$E=true;$Ua=array_keys($m);preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~',$dc,$jd);$sa=count($jd[0]);begin();$ef=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));foreach($jd[0]as$v=>$W){preg_match_all("~((\"[^\"]*\")+|[^$ef]*)$ef~",$W.$ef,$kd);if(!$v&&!array_diff($kd[1],$Ua)){$Ua=$kd[1];$sa--;}else{$K=array();foreach($kd[1]as$p=>$Ra)$K[idf_escape($Ua[$p])]=($Ra==""&&$m[$Ua[$p]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$Ra))));$E=insert_update($a,$K,$xe);if(!$E)break;}}if($E)queries("COMMIT");queries_redirect(remove_from_uri("page"),lang(227,$sa),$E);queries("ROLLBACK");}else$k=upload_error($dc);}}$yf=$b->tableName($O);page_header(lang(35).": $yf",$k);session_write_close();$K=null;if(isset($Re["insert"])){$K="";foreach((array)$_GET["where"]as$W){if(count($kc[$W["col"]])==1&&($W["op"]=="="||(!$W["op"]&&!ereg('[_%]',$W["val"]))))$K.="&set".urlencode("[".bracket_escape($W["col"])."]")."=".urlencode($W["val"]);}}$b->selectLinks($O,$K);if(!$f)echo"

".lang(228).($m?".":": ".error())."\n";else{echo"

\n","
";hidden_fields_get();echo(DB!=""?''.(isset($_GET["ns"])?'':""):"");echo'',"
\n";$b->selectColumnsPrint($I,$f);$b->selectSearchPrint($Z,$f,$t);$b->selectOrderPrint($Td,$f,$t);$b->selectLimitPrint($x);$b->selectLengthPrint($Hf);$b->selectActionPrint($t);echo"
\n";$fe=$_GET["page"];if($fe=="last"){$nc=$g->result("SELECT COUNT(*) FROM ".table($a).($Z?" WHERE ".implode(" AND ",$Z):""));$fe=floor(max(0,$nc-1)/$x);}$D="SELECT".limit((+$x&&$uc&&count($uc)selectQuery($D);$E=$g->query($D);if(!$E)echo"

".error()."\n";else{if($u=="mssql")$E->seek($x*$fe);$Gb=array();echo"

\n";$H=array();while($G=$E->fetch_assoc()){if($fe&&$u=="oracle")unset($G["RNUM"]);$H[]=$G;}if($_GET["page"]!="last")$nc=(+$x&&$uc&&count($uc)result(" SELECT FOUND_ROWS()"):$g->result("SELECT COUNT(*) FROM ($D) x")):count($H));if(!$H)echo"

".lang(84)."\n";else{$Fa=$b->backwardKeys($a,$yf);echo"\n","".(!$uc&&$I?"":"\n";foreach($b->rowDescriptions($H,$kc)as$_d=>$G){$bg=unique_array($H[$_d],$t);$cg="";foreach($bg as$v=>$W)$cg.="&".($W!==null?urlencode("where[".bracket_escape($v)."]")."=".urlencode($W):"null%5B%5D=".urlencode($v));echo"".(!$uc&&$I?"":"\n";}echo"
".lang(229)."");$Ad=array();$rc=array();reset($I);$Ge=1;foreach($H[0]as$v=>$W){if($v!=$Gd){$W=$_GET["columns"][key($I)];$l=$m[$I?($W?$W["col"]:current($I)):$v];$_=($l?$b->fieldName($l,$Ge):"*");if($_!=""){$Ge++;$Ad[$v]=$_;$e=idf_escape($v);$Ac=remove_from_uri('(order|desc)[^=]*|page').'&order%5B0%5D='.urlencode($v);$sb="&desc%5B0%5D=1";echo'','';echo(!$I||$W?apply_sql_function($W["fun"],$_):h(current($I)))."";echo"";}$rc[$v]=$W["fun"];next($I);}}$cd=array();if($_GET["modify"]){foreach($H as$G){foreach($G as$v=>$W)$cd[$v]=max($cd[$v],min(40,strlen(utf8_decode($W))));}}echo($Fa?"".lang(230):"")."
".checkbox("check[]",substr($cg,1),in_array(substr($cg,1),(array)$_POST["check"]),"","this.form['all'].checked = false; formUncheck('all-page');").(count($uc)".lang(229).""));foreach($G as$v=>$W){if(isset($Ad[$v])){$l=$m[$v];if($W!=""&&(!isset($Gb[$v])||$Gb[$v]!=""))$Gb[$v]=(is_mail($W)?$Ad[$v]:"");$y="";$W=$b->editVal($W,$l);if($W!==null){if(ereg('blob|bytea|raw|file',$l["type"])&&$W!="")$y=h(ME.'download='.urlencode($a).'&field='.urlencode($v).$cg);if($W==="")$W=" ";elseif(is_utf8($W)){if($Hf!=""&&ereg('text|blob',$l["type"]))$W=shorten_utf8($W,max(0,+$Hf));else$W=h($W);}if(!$y){foreach((array)$kc[$v]as$n){if(count($kc[$v])==1||end($n["source"])==$v){$y="";foreach($n["source"]as$p=>$jf)$y.=where_link($p,$n["target"][$p],$H[$_d][$jf]);$y=h(($n["db"]!=""?preg_replace('~([?&]db=)[^&]+~','\\1'.urlencode($n["db"]),ME):ME).'select='.urlencode($n["table"]).$y);if(count($n["source"])==1)break;}}}if($v=="COUNT(*)"){$y=h(ME."select=".urlencode($a));$p=0;foreach((array)$_GET["where"]as$V){if(!array_key_exists($V["col"],$bg))$y.=h(where_link($p++,$V["col"],$V["val"],$V["op"]));}foreach($bg as$Qc=>$V)$y.=h(where_link($p++,$Qc,$V));}}if(!$y){if(is_mail($W))$y="mailto:$W";if($Ee=is_url($G[$v]))$y=($Ee=="http"&&$ba?$G[$v]:"$Ee://www.adminer.org/redirect/?url=".urlencode($G[$v]));}$q=h("val[$cg][".bracket_escape($v)."]");$X=$_POST["val"][$cg][bracket_escape($v)];$xc=h($X!==null?$X:$G[$v]);$hd=strpos($W,"...");$Db=is_utf8($W)&&$H[$_d][$v]==$G[$v]&&!$rc[$v];$Gf=ereg('text|lob',$l["type"]);echo(($_GET["modify"]&&$Db)||$X!==null?"".($Gf?"":""):"".$b->selectVal($W,$y,$l));}}if($Fa)echo"";$b->backwardKeysPrint($Fa,$H[$_d]);echo"
\n",(!$uc&&$I?"":"\n");}if($H||$fe){$Rb=true;if($_GET["page"]!="last"&&+$x&&count($uc)>=count($I)&&($nc>=$x||$fe)){$nc=found_rows($O,$Z);if($ncresult("SELECT COUNT(*) FROM ".table($a).($Z?" WHERE ".implode(" AND ",$Z):""));}else$Rb=false;}echo"

";if(+$x&&$nc>$x){$md=floor(($nc-1)/$x);echo'".lang(232).":",pagination(0,$fe).($fe>5?" ...":"");for($p=max(1,$fe-4);$p'.lang(233)."");}echo" (".($Rb?"":"~ ").lang(122,$nc).") ".checkbox("all",1,0,lang(234))."\n";if($b->selectCommandPrint()){echo'

',lang(33),'
';}$lc=$b->dumpFormat();if($lc){print_fieldset("export",lang(114));$de=$b->dumpOutput();echo($de?html_select("output",$de,$ra["output"])." ":""),html_select("format",$lc,$ra["format"])," \n","\n";}}if($b->selectImportPrint()){print_fieldset("import",lang(236),!$H);echo" ",html_select("separator",array("csv"=>"CSV,","csv;"=>"CSV;","tsv"=>"TSV"),$ra["format"],1);echo" ","\n","\n";}$b->selectEmailPrint(array_filter($Gb,'strlen'),$f);echo"\n";}}}elseif(isset($_GET["variables"])){$nf=isset($_GET["status"]);page_header($nf?lang(75):lang(74));$mg=($nf?show_status():show_variables());if(!$mg)echo"

".lang(84)."\n";else{echo"\n";foreach($mg as$v=>$W){echo"","
".h($v)."","".nbsp($W);}echo"
\n";}}elseif(isset($_GET["script"])){header("Content-Type: text/javascript; charset=utf-8");if($_GET["script"]=="db"){$vf=array("Data_length"=>0,"Index_length"=>0,"Data_free"=>0);foreach(table_status()as$O){$q=js_escape($O["Name"]);json_row("Comment-$q",nbsp($O["Comment"]));if(!is_view($O)){foreach(array("Engine","Collation")as$v)json_row("$v-$q",nbsp($O[$v]));foreach($vf+array("Auto_increment"=>0,"Rows"=>0)as$v=>$W){if($O[$v]!=""){$W=number_format($O[$v],0,'.',lang(7));json_row("$v-$q",($v=="Rows"&&$W&&$O["Engine"]==($lf=="pgsql"?"table":"InnoDB")?"~ $W":$W));if(isset($vf[$v]))$vf[$v]+=($O["Engine"]!="InnoDB"||$v!="Data_free"?$O[$v]:0);}elseif(array_key_exists($v,$O))json_row("$v-$q");}}}foreach($vf as$v=>$W)json_row("sum-$v",number_format($W,0,'.',lang(7)));json_row("");}else{foreach(count_tables($b->databases())as$j=>$W)json_row("tables-".js_escape($j),$W);json_row("");}exit;}else{$Df=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Df&&!$k&&!$_POST["search"]){$E=true;$qd="";if($u=="sql"&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"]))queries("SET foreign_key_checks = 0");if($_POST["truncate"]){if($_POST["tables"])$E=truncate_tables($_POST["tables"]);$qd=lang(237);}elseif($_POST["move"]){$E=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$qd=lang(238);}elseif($_POST["copy"]){$E=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$qd=lang(239);}elseif($_POST["drop"]){if($_POST["views"])$E=drop_views($_POST["views"]);if($E&&$_POST["tables"])$E=drop_tables($_POST["tables"]);$qd=lang(240);}elseif($u!="sql"){$E=($u=="sqlite"?queries("VACUUM"):apply_queries("VACUUM".($_POST["optimize"]?"":" ANALYZE"),$_POST["tables"]));$qd=lang(241);}elseif($_POST["tables"]&&($E=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"]))))){while($G=$E->fetch_assoc())$qd.="".h($G["Table"]).": ".h($G["Msg_text"])."
";}queries_redirect(substr(ME,0,-1),$qd,$E);}page_header(($_GET["ns"]==""?lang(24).": ".h(DB):lang(82).": ".h($_GET["ns"])),$k,true);if($b->homepage()){if($_GET["ns"]!==""){echo"

".lang(242)."

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

".lang(6)."\n";else{echo"

\n","

".lang(243).": \n";if($_POST["search"]&&$_POST["query"]!="")search_tables();echo"\n",'\n";foreach($Cf as$_=>$S){$og=($S!==null&&!eregi("table",$S));echo'
',''.lang(102),''.lang(244),''.lang(78),''.lang(245),''.lang(246),''.lang(247),''.lang(94),''.lang(248),(support("comment")?''.lang(96):''),"
'.checkbox(($og?"views[]":"tables[]"),$_,in_array($_,$Df,true),"","formUncheck('check-all');"),''.h($_).'';if($og){echo''.lang(101).'','?';}else{foreach(array("Engine"=>array(),"Collation"=>array(),"Data_length"=>array("create",lang(30)),"Index_length"=>array("indexes",lang(105)),"Data_free"=>array("edit",lang(31)),"Auto_increment"=>array("auto_increment=1&create",lang(30)),"Rows"=>array("select",lang(27)),)as$v=>$y)echo($y?"?":" ");}echo(support("comment")?" ":"");}echo"
 ".lang(223,count($Cf)),"".nbsp($u=="sql"?$g->result("SELECT @@storage_engine"):""),"".nbsp(db_collation(DB,collations()));foreach(array("Data_length","Index_length","Data_free")as$v)echo" ";echo"
\n","\n";if(!information_schema(DB)){echo"

".(ereg('^(sql|sqlite|pgsql)$',$u)?($u!="sqlite"?" ":"")." ":"").($u=="sql"?" ":"")." \n";$i=(support("scheme")?schemas():$b->databases());if(count($i)!=1&&$u!="sqlite"){$j=(isset($_POST["target"])?$_POST["target"]:(support("scheme")?$_GET["ns"]:DB));echo"

".lang(254).": ",($i?html_select("target",$i,$j):'')," ",(support("copy")?" ":""),"\n";}echo"\n";}echo"

\n";}echo'

'.lang(148)."\n";if(support("view"))echo''.lang(181)."\n";if(support("routine")){echo"

".lang(117)."

\n";$Ve=routines();if($Ve){echo"\n",'\n";odd('');foreach($Ve as$G){echo'','
'.lang(159).''.lang(91).''.lang(198)." 
'.h($G["ROUTINE_NAME"]).'',''.h($G["ROUTINE_TYPE"]),''.h($G["DTD_IDENTIFIER"]),''.lang(109)."";}echo"
\n";}echo'

'.(support("procedure")?''.lang(197).' ':'').''.lang(196)."\n";}if(support("sequence")){echo"

".lang(257)."

\n";$ff=get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");if($ff){echo"\n","\n";odd('');foreach($ff as$W)echo"
".lang(159)."
".h($W)."\n";echo"
\n";}echo"

".lang(203)."\n";}if(support("type")){echo"

".lang(12)."

\n";$T=types();if($T){echo"\n","\n";odd('');foreach($T as$W)echo"
".lang(159)."
".h($W)."\n";echo"
\n";}echo"

".lang(207)."\n";}if(support("event")){echo"

".lang(118)."

\n";$H=get_rows("SHOW EVENTS");if($H){echo"\n","\n";foreach($H as$G){echo"",'
".lang(159)."".lang(258)."".lang(187)."".lang(188)."
'.h($G["Name"])."","".($G["Execute at"]?lang(259)."".$G["Execute at"]:lang(189)." ".$G["Interval value"]." ".$G["Interval field"]."$G[Starts]"),"$G[Ends]";}echo"
\n";$Qb=$g->result("SELECT @@event_scheduler");if($Qb&&$Qb!="ON")echo"

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

'.lang(186)."\n";}if($Cf)echo"\n";}}}page_footer();