/** Adminer - Compact database management* @link https://www.adminer.org/* @author Jakub Vrana, https://www.vrana.cz/* @copyright 2007 Jakub Vrana* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)* @version 4.8.1*/functionadminer_errors($cc,$ec){return!!preg_match('~^(Trying to access array offset on value of type null|Undefined array key)~',$ec);}error_reporting(6135);set_error_handler('adminer_errors',E_WARNING);$wc=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($wc||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$fh=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($fh)$$X=$fh;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");functionconnection(){global$g;return$g;}functionadminer(){global$c;return$c;}functionversion(){global$fa;return$fa;}functionidf_unescape($v){if(!preg_match('~^[`\'"]~',$v))return$v;$wd=substr($v,-1);returnstr_replace($wd.$wd,$wd,substr($v,1,-1));}functionescape_string($X){returnsubstr(q($X),1,-1);}functionnumber($X){returnpreg_replace('~[^0-9]+~','',$X);}functionnumber_type(){return'((?<!o)int(?!er)|numeric|real|float|double|decimal|money)';}functionremove_slashes($kf,$wc=false){if(function_exists("get_magic_quotes_gpc")&&get_magic_quotes_gpc()){while(list($z,$X)=each($kf)){foreach($Xas$od=>$W){unset($kf[$z][$od]);if(is_array($W)){$kf[$z][stripslashes($od)]=$W;$kf[]=&$kf[$z][stripslashes($od)];}else$kf[$z][stripslashes($od)]=($wc?$W:stripslashes($W));}}}}functionbracket_escape($v,$_a=false){static$Sg=array(':'=>':1',']'=>':2','['=>':3','"'=>':4');returnstrtr($v,($_a?array_flip($Sg):$Sg));}functionmin_version($uh,$Id="",$h=null){global$g;if(!$h)$h=$g;$Sf=$h->server_info;if($Id&&preg_match('~([\d.]+)-MariaDB~',$Sf,$C)){$Sf=$C[1];$uh=$Id;}return(version_compare($Sf,$uh)>=0);}functioncharset($g){return(min_version("5.5.3",0,$g)?"utf8mb4":"utf8");}functionscript($bg,$Rg="\n"){return"<script".nonce().">$bg</script>$Rg";}functionscript_src($kh){return"<script src='".h($kh)."'".nonce()."></script>\n";}functionnonce(){return' nonce="'.get_nonce().'"';}functiontarget_blank(){return' target="_blank" rel="noreferrer noopener"';}functionh($lg){returnstr_replace("\0","�",htmlspecialchars($lg,ENT_QUOTES,'utf-8'));}functionnl_br($lg){returnstr_replace("\n","
",$lg);}functioncheckbox($E,$Y,$Na,$sd="",$te="",$Ra="",$td=""){$K="<input type='checkbox' name='$E' value='".h($Y)."'".($Na?" checked":"").($td?" aria-labelledby='$td'":"").">".($te?script("qsl('input').onclick = function () { $te };",""):"");return($sd!=""||$Ra?"<label".($Ra?" class='$Ra'":"").">$K".h($sd)."</label>":$K);}functionoptionlist($xe,$Nf=null,$oh=false){$K="";foreach($xeas$od=>$W){$ye=array($od=>$W);if(is_array($W)){$K.='<optgroup label="'.h($od).'">';$ye=$W;}foreach($yeas$z=>$X)$K.='<option'.($oh||is_string($z)?' value="'.h($z).'"':'').(($oh||is_string($z)?(string)$z:$X)===$Nf?' selected':'').'>'.h($X);if(is_array($W))$K.='</optgroup>';}return$K;}functionhtml_select($E,$xe,$Y="",$se=true,$td=""){if($se)return"<select name='".h($E)."'".($td?" aria-labelledby='$td'":"").">".optionlist($xe,$Y)."</select>".(is_string($se)?script("qsl('select').onchange = function () { $se };",""):"");$K="";foreach($xeas$z=>$X)$K.="<label><input type='radio' name='".h($E)."' value='".h($z)."'".($z==$Y?" checked":"").">".h($X)."</label>";return$K;}functionselect_input($wa,$xe,$Y="",$se="",$Xe=""){$_g=($xe?"select":"input");return"<$_g$wa".($xe?"><option value=''>$Xe".optionlist($xe,$Y,true)."</select>":" size='10' value='".h($Y)."' placeholder='$Xe'>").($se?script("qsl('$_g').onchange = $se;",""):"");}functionconfirm($D="",$Of="qsl('input')"){returnscript("$Of.onclick = function () { return confirm('".($D?js_escape($D):lang(0))."'); };","");}functionprint_fieldset($u,$Ad,$xh=false){echo"<fieldset><legend>","<a href='#fieldset-$u'>$Ad</a>",script("qsl('a').onclick = partial(toggle, 'fieldset-$u');",""),"</legend>","<div id='fieldset-$u'".($xh?"":" class='hidden'").">\n";}functionbold($Ga,$Ra=""){return($Ga?" class='active $Ra'":($Ra?" class='$Ra'":""));}functionodd($K=' class="odd"'){static$t=0;if(!$K)$t=-1;return($t++%2?$K:'');}functionjs_escape($lg){returnaddcslashes($lg,"\r\n'\\/");}functionjson_row($z,$X=null){static$xc=true;if($xc)echo"{";if($z!=""){echo($xc?"":",")."\n\t\"".addcslashes($z,"\r\n\t\"\\/").'": '.($X!==null?'"'.addcslashes($X,"\r\n\"\\/").'"':'null');$xc=false;}else{echo"\n}\n";$xc=true;}}functionini_bool($cd){$X=ini_get($cd);return(preg_match('~^(on|true|yes)$~i',$X)||(int)$X);}functionsid(){static$K;if($K===null)$K=(SID&&!($_COOKIE&&ini_bool("session.use_cookies")));return$K;}functionset_password($th,$O,$V,$G){$_SESSION["pwds"][$th][$O][$V]=($_COOKIE["adminer_key"]&&is_string($G)?array(encrypt_string($G,$_COOKIE["adminer_key"])):$G);}functionget_password(){$K=get_session("pwds");if(is_array($K))$K=($_COOKIE["adminer_key"]?decrypt_string($K[0],$_COOKIE["adminer_key"]):false);return$K;}functionq($lg){global$g;return$g->quote($lg);}functionget_vals($I,$d=0){global$g;$K=array();$J=$g->query($I);if(is_object($J)){while($L=$J->fetch_row())$K[]=$L[$d];}return$K;}functionget_key_vals($I,$h=null,$Vf=true){global$g;if(!is_object($h))$h=$g;$K=array();$J=$h->query($I);if(is_object($J)){while($L=$J->fetch_row()){if($Vf)$K[$L[0]]=$L[1];else$K[]=$L[0];}}return$K;}functionget_rows($I,$h=null,$m="<p class='error'>"){global$g;$fb=(is_object($h)?$h:$g);$K=array();$J=$fb->query($I);if(is_object($J)){while($L=$J->fetch_assoc())$K[]=$L;}elseif(!$J&&!is_object($h)&&$m&&defined("PAGE_HEADER"))echo$m.error()."\n";return$K;}functionunique_array($L,$x){foreach($xas$w){if(preg_match("~PRIMARY|UNIQUE~",$w["type"])){$K=array();foreach($w["columns"]as$z){if(!isset($L[$z]))continue2;$K[$z]=$L[$z];}return$K;}}}functionescape_key($z){if(preg_match('(^([\w(]+)('.str_replace("_",".*",preg_quote(idf_escape("_"))).')([ \w)]+)$)',$z,$C))return$C[1].idf_escape(idf_unescape($C[2])).$C[3];returnidf_escape($z);}functionwhere($Z,$o=array()){global$g,$y;$K=array();foreach((array)$Z["where"]as$z=>$X){$z=bracket_escape($z,1);$d=escape_key($z);$K[]=$d.($y=="sql"&&is_numeric($X)&&preg_match('~\.~',$X)?" LIKE ".q($X):($y=="mssql"?" LIKE ".q(preg_replace('~[_%[]~','[\0]',$X)):" = ".unconvert_field($o[$z],q($X))));if($y=="sql"&&preg_match('~char|text~',$o[$z]["type"])&&preg_match("~[^ -@]~",$X))$K[]="$d = ".q($X)." COLLATE ".charset($g)."_bin";}foreach((array)$Z["null"]as$z)$K[]=escape_key($z)." IS NULL";returnimplode(" AND ",$K);}functionwhere_check($X,$o=array()){parse_str($X,$Ma);remove_slashes(array(&$Ma));returnwhere($Ma,$o);}functionwhere_link($t,$d,$Y,$ue="="){return"&where%5B$t%5D%5Bcol%5D=".urlencode($d)."&where%5B$t%5D%5Bop%5D=".urlencode(($Y!==null?$ue:"IS NULL"))."&where%5B$t%5D%5Bval%5D=".urlencode($Y);}functionconvert_fields($e,$o,$N=array()){$K="";foreach($eas$z=>$X){if($N&&!in_array(idf_escape($z),$N))continue;$ua=convert_field($o[$z]);if($ua)$K.=", $ua AS ".idf_escape($z);}return$K;}functioncookie($E,$Y,$Dd=2592000){global$ba;returnheader("Set-Cookie: $E=".urlencode($Y).($Dd?"; expires=".gmdate("D, d M Y H:i:s",time()+$Dd)." GMT":"")."; path=".preg_replace('~\?.*~','',$_SERVER["REQUEST_URI"]).($ba?"; secure":"")."; HttpOnly; SameSite=lax",false);}functionrestart_session(){if(!ini_bool("session.use_cookies"))session_start();}functionstop_session($zc=false){$nh=ini_bool("session.use_cookies");if(!$nh||$zc){session_write_close();if($nh&&@ini_set("session.use_cookies",false)===false)session_start();}}function&get_session($z){return$_SESSION[$z][DRIVER][SERVER][$_GET["username"]];}functionset_session($z,$X){$_SESSION[$z][DRIVER][SERVER][$_GET["username"]]=$X;}functionauth_url($th,$O,$V,$k=null){global$Kb;preg_match('~([^?]*)\??(.*)~',remove_from_uri(implode("|",array_keys($Kb))."|username|".($k!==null?"db|":"").session_name()),$C);return"$C[1]?".(sid()?SID."&":"").($th!="server"||$O!=""?urlencode($th)."=".urlencode($O)."&":"")."username=".urlencode($V).($k!=""?"&db=".urlencode($k):"").($C[2]?"&$C[2]":"");}functionis_ajax(){return($_SERVER["HTTP_X_REQUESTED_WITH"]=="XMLHttpRequest");}functionredirect($B,$D=null){if($D!==null){restart_session();$_SESSION["messages"][preg_replace('~^[^?]*~','',($B!==null?$B:$_SERVER["REQUEST_URI"]))][]=$D;}if($B!==null){if($B=="")$B=".";header("Location: $B");exit;}}functionquery_redirect($I,$B,$D,$sf=true,$jc=true,$qc=false,$Gg=""){global$g,$m,$c;if($jc){$hg=microtime(true);$qc=!$g->query($I);$Gg=format_time($hg);}$dg="";if($I)$dg=$c->messageQuery($I,$Gg,$qc);if($qc){$m=error().$dg.script("messagesPrint();");returnfalse;}if($sf)redirect($B,$D.$dg);returntrue;}functionqueries($I){global$g;static$nf=array();static$hg;if(!$hg)$hg=microtime(true);if($I===null)returnarray(implode("\n",$nf),format_time($hg));$nf[]=(preg_match('~;$~',$I)?"DELIMITER ;;\n$I;\nDELIMITER ":$I).";";return$g->query($I);}functionapply_queries($I,$S,$fc='table'){foreach($Sas$Q){if(!queries("$I ".$fc($Q)))returnfalse;}returntrue;}functionqueries_redirect($B,$D,$sf){list($nf,$Gg)=queries(null);returnquery_redirect($nf,$B,$D,$sf,false,!$sf,$Gg);}functionformat_time($hg){returnlang(1,max(0,microtime(true)-$hg));}functionrelative_uri(){returnstr_replace(":","%3a",preg_replace('~^[^?]*/([^?]*)~','\1',$_SERVER["REQUEST_URI"]));}functionremove_from_uri($Le=""){returnsubstr(preg_replace("~(?<=[?&])($Le".(SID?"":"|".session_name()).")=[^&]*&~",'',relative_uri()."&"),0,-1);}functionpagination($F,$qb){return" ".($F==$qb?$F+1:'<a href="'.h(remove_from_uri("page").($F?"&page=$F".($_GET["next"]?"&next=".urlencode($_GET["next"]):""):"")).'">'.($F+1)."</a>");}functionget_file($z,$yb=false){$uc=$_FILES[$z];if(!$uc)returnnull;foreach($ucas$z=>$X)$uc[$z]=(array)$X;$K='';foreach($uc["error"]as$z=>$m){if($m)return$m;$E=$uc["name"][$z];$Og=$uc["tmp_name"][$z];$gb=file_get_contents($yb&&preg_match('~\.gz$~',$E)?"compress.zlib://$Og":$Og);if($yb){$hg=substr($gb,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$hg,$yf))$gb=iconv("utf-16","utf-8",$gb);elseif($hg=="\xEF\xBB\xBF")$gb=substr($gb,3);$K.=$gb."\n\n";}else$K.=$gb;}return$K;}functionupload_error($m){$Od=($m==UPLOAD_ERR_INI_SIZE?ini_get("upload_max_filesize"):0);return($m?lang(2).($Od?" ".lang(3,$Od):""):lang(4));}functionrepeat_pattern($Ue,$Bd){returnstr_repeat("$Ue{0,65535}",$Bd/65535)."$Ue{0,".($Bd%65535)."}";}functionis_utf8($X){return(preg_match('~~u',$X)&&!preg_match('~[\0-\x8\xB\xC\xE-\x1F]~',$X));}functionshorten_utf8($lg,$Bd=80,$pg=""){if(!preg_match("(^(".repeat_pattern("[\t\r\n -\x{10FFFF}]",$Bd).")($)?)u",$lg,$C))preg_match("(^(".repeat_pattern("[\t\r\n -~]",$Bd).")($)?)",$lg,$C);returnh($C[1]).$pg.(isset($C[2])?"":"<i>…</i>");}functionformat_number($X){returnstrtr(number_format($X,0,".",lang(5)),preg_split('~~u',lang(6),-1,PREG_SPLIT_NO_EMPTY));}functionfriendly_url($X){returnpreg_replace('~[^a-z0-9_]~i','-',$X);}functionhidden_fields($kf,$Yc=array(),$df=''){$K=false;foreach($kfas$z=>$X){if(!in_array($z,$Yc)){if(is_array($X))hidden_fields($X,array(),$z);else{$K=true;echo'';}}}return$K;}functionhidden_fields_get(){echo(sid()?'':''),(SERVER!==null?'':""),'';}functiontable_status1($Q,$rc=false){$K=table_status($Q,$rc);return($K?$K:array("Name"=>$Q));}functioncolumn_foreign_keys($Q){global$c;$K=array();foreach($c->foreignKeys($Q)as$p){foreach($p["source"]as$X)$K[$X][]=$p;}return$K;}functionenum_input($U,$wa,$n,$Y,$Yb=null){global$c;preg_match_all("~'((?:[^']|'')*)'~",$n["length"],$Jd);$K=($Yb!==null?"<label><input type='$U'$wa value='$Yb'".((is_array($Y)?in_array($Yb,$Y):$Y===0)?" checked":"")."><i>".lang(7)."</i></label>":"");foreach($Jd[1]as$t=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?$Y==$t+1:(is_array($Y)?in_array($t+1,$Y):$Y===$X));$K.=" <label><input type='$U'$wa value='".($t+1)."'".($Na?' checked':'').'>'.h($c->editVal($X,$n)).'</label>';}return$K;}functioninput($n,$Y,$r){global$ah,$c,$y;$E=h(bracket_escape($n["field"]));echo"<td class='function'>";if(is_array($Y)&&!$r){$ta=array($Y);if(version_compare(PHP_VERSION,5.4)>=0)$ta[]=JSON_PRETTY_PRINT;$Y=call_user_func_array('json_encode',$ta);$r="json";}$_f=($y=="mssql"&&$n["auto_increment"]);if($_f&&!$_POST["save"])$r=null;$Gc=(isset($_GET["select"])||$_f?array("orig"=>lang(8)):array())+$c->editFunctions($n);$wa=" name='fields[$E]'";if($n["type"]=="enum")echoh($Gc[""])."