/** 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){$ch=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($ch)$$X=$ch;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");functionconnection(){global$e;return$e;}functionadminer(){global$b;return$b;}functionversion(){global$ga;return$ga;}functionidf_unescape($Wc){if(!preg_match('~^[`\'"]~',$Wc))return$Wc;$td=substr($Wc,-1);returnstr_replace($td.$td,$td,substr($Wc,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($hf,$wc=false){if(function_exists("get_magic_quotes_gpc")&&get_magic_quotes_gpc()){while(list($z,$X)=each($hf)){foreach($Xas$md=>$W){unset($hf[$z][$md]);if(is_array($W)){$hf[$z][stripslashes($md)]=$W;$hf[]=&$hf[$z][stripslashes($md)];}else$hf[$z][stripslashes($md)]=($wc?$W:stripslashes($W));}}}}functionbracket_escape($Wc,$_a=false){static$Pg=array(':'=>':1',']'=>':2','['=>':3','"'=>':4');returnstrtr($Wc,($_a?array_flip($Pg):$Pg));}functionmin_version($rh,$Fd="",$f=null){global$e;if(!$f)$f=$e;$Pf=$f->server_info;if($Fd&&preg_match('~([\d.]+)-MariaDB~',$Pf,$C)){$Pf=$C[1];$rh=$Fd;}return(version_compare($Pf,$rh)>=0);}functioncharset($e){return(min_version("5.5.3",0,$e)?"utf8mb4":"utf8");}functionscript($Yf,$Og="\n"){return"<script".nonce().">$Yf</script>$Og";}functionscript_src($hh){return"<script src='".h($hh)."'".nonce()."></script>\n";}functionnonce(){return' nonce="'.get_nonce().'"';}functiontarget_blank(){return' target="_blank" rel="noreferrer noopener"';}functionh($ig){returnstr_replace("\0","�",htmlspecialchars($ig,ENT_QUOTES,'utf-8'));}functionnl_br($ig){returnstr_replace("\n","
",$ig);}functioncheckbox($E,$Y,$Na,$qd="",$qe="",$Ra="",$rd=""){$K="<input type='checkbox' name='$E' value='".h($Y)."'".($Na?" checked":"").($rd?" aria-labelledby='$rd'":"").">".($qe?script("qsl('input').onclick = function () { $qe };",""):"");return($qd!=""||$Ra?"<label".($Ra?" class='$Ra'":"").">$K".h($qd)."</label>":$K);}functionoptionlist($ue,$Kf=null,$lh=false){$K="";foreach($ueas$md=>$W){$ve=array($md=>$W);if(is_array($W)){$K.='<optgroup label="'.h($md).'">';$ve=$W;}foreach($veas$z=>$X)$K.='<option'.($lh||is_string($z)?' value="'.h($z).'"':'').(($lh||is_string($z)?(string)$z:$X)===$Kf?' selected':'').'>'.h($X);if(is_array($W))$K.='</optgroup>';}return$K;}functionhtml_select($E,$ue,$Y="",$pe=true,$rd=""){if($pe)return"<select name='".h($E)."'".($rd?" aria-labelledby='$rd'":"").">".optionlist($ue,$Y)."</select>".(is_string($pe)?script("qsl('select').onchange = function () { $pe };",""):"");$K="";foreach($ueas$z=>$X)$K.="<label><input type='radio' name='".h($E)."' value='".h($z)."'".($z==$Y?" checked":"").">".h($X)."</label>";return$K;}functionselect_input($wa,$ue,$Y="",$pe="",$Ue=""){$xg=($ue?"select":"input");return"<$xg$wa".($ue?"><option value=''>$Ue".optionlist($ue,$Y,true)."</select>":" size='10' value='".h($Y)."' placeholder='$Ue'>").($pe?script("qsl('$xg').onchange = $pe;",""):"");}functionconfirm($D="",$Lf="qsl('input')"){returnscript("$Lf.onclick = function () { return confirm('".($D?js_escape($D):'Are you sure?')."'); };","");}functionprint_fieldset($u,$yd,$uh=false){echo"<fieldset><legend>","<a href='#fieldset-$u'>$yd</a>",script("qsl('a').onclick = partial(toggle, 'fieldset-$u');",""),"</legend>","<div id='fieldset-$u'".($uh?"":" 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($ig){returnaddcslashes($ig,"\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($bd){$X=ini_get($bd);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($qh,$O,$V,$G){$_SESSION["pwds"][$qh][$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($ig){global$e;return$e->quote($ig);}functionget_vals($I,$c=0){global$e;$K=array();$J=$e->query($I);if(is_object($J)){while($L=$J->fetch_row())$K[]=$L[$c];}return$K;}functionget_key_vals($I,$f=null,$Sf=true){global$e;if(!is_object($f))$f=$e;$K=array();$J=$f->query($I);if(is_object($J)){while($L=$J->fetch_row()){if($Sf)$K[$L[0]]=$L[1];else$K[]=$L[0];}}return$K;}functionget_rows($I,$f=null,$k="<p class='error'>"){global$e;$fb=(is_object($f)?$f:$e);$K=array();$J=$fb->query($I);if(is_object($J)){while($L=$J->fetch_assoc())$K[]=$L;}elseif(!$J&&!is_object($f)&&$k&&defined("PAGE_HEADER"))echo$k.error()."\n";return$K;}functionunique_array($L,$w){foreach($was$v){if(preg_match("~PRIMARY|UNIQUE~",$v["type"])){$K=array();foreach($v["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,$m=array()){global$e,$y;$K=array();foreach((array)$Z["where"]as$z=>$X){$z=bracket_escape($z,1);$c=escape_key($z);$K[]=$c.($y=="sql"&&is_numeric($X)&&preg_match('~\.~',$X)?" LIKE ".q($X):($y=="mssql"?" LIKE ".q(preg_replace('~[_%[]~','[\0]',$X)):" = ".unconvert_field($m[$z],q($X))));if($y=="sql"&&preg_match('~char|text~',$m[$z]["type"])&&preg_match("~[^ -@]~",$X))$K[]="$c = ".q($X)." COLLATE ".charset($e)."_bin";}foreach((array)$Z["null"]as$z)$K[]=escape_key($z)." IS NULL";returnimplode(" AND ",$K);}functionwhere_check($X,$m=array()){parse_str($X,$Ma);remove_slashes(array(&$Ma));returnwhere($Ma,$m);}functionwhere_link($t,$c,$Y,$re="="){return"&where%5B$t%5D%5Bcol%5D=".urlencode($c)."&where%5B$t%5D%5Bop%5D=".urlencode(($Y!==null?$re:"IS NULL"))."&where%5B$t%5D%5Bval%5D=".urlencode($Y);}functionconvert_fields($d,$m,$N=array()){$K="";foreach($das$z=>$X){if($N&&!in_array(idf_escape($z),$N))continue;$ua=convert_field($m[$z]);if($ua)$K.=", $ua AS ".idf_escape($z);}return$K;}functioncookie($E,$Y,$Ad=2592000){global$ba;returnheader("Set-Cookie: $E=".urlencode($Y).($Ad?"; expires=".gmdate("D, d M Y H:i:s",time()+$Ad)." 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){$kh=ini_bool("session.use_cookies");if(!$kh||$zc){session_write_close();if($kh&&@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($qh,$O,$V,$i=null){global$Kb;preg_match('~([^?]*)\??(.*)~',remove_from_uri(implode("|",array_keys($Kb))."|username|".($i!==null?"db|":"").session_name()),$C);return"$C[1]?".(sid()?SID."&":"").($qh!="server"||$O!=""?urlencode($qh)."=".urlencode($O)."&":"")."username=".urlencode($V).($i!=""?"&db=".urlencode($i):"").($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,$pf=true,$jc=true,$qc=false,$Dg=""){global$e,$k,$b;if($jc){$eg=microtime(true);$qc=!$e->query($I);$Dg=format_time($eg);}$ag="";if($I)$ag=$b->messageQuery($I,$Dg,$qc);if($qc){$k=error().$ag.script("messagesPrint();");returnfalse;}if($pf)redirect($B,$D.$ag);returntrue;}functionqueries($I){global$e;static$kf=array();static$eg;if(!$eg)$eg=microtime(true);if($I===null)returnarray(implode("\n",$kf),format_time($eg));$kf[]=(preg_match('~;$~',$I)?"DELIMITER ;;\n$I;\nDELIMITER ":$I).";";return$e->query($I);}functionapply_queries($I,$S,$fc='table'){foreach($Sas$Q){if(!queries("$I ".$fc($Q)))returnfalse;}returntrue;}functionqueries_redirect($B,$D,$pf){list($kf,$Dg)=queries(null);returnquery_redirect($kf,$B,$D,$pf,false,!$pf,$Dg);}functionformat_time($eg){returnsprintf('%.3f s',max(0,microtime(true)-$eg));}functionrelative_uri(){returnstr_replace(":","%3a",preg_replace('~^[^?]*/([^?]*)~','\1',$_SERVER["REQUEST_URI"]));}functionremove_from_uri($Ie=""){returnsubstr(preg_replace("~(?<=[?&])($Ie".(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=>$k){if($k)return$k;$E=$uc["name"][$z];$Lg=$uc["tmp_name"][$z];$gb=file_get_contents($yb&&preg_match('~\.gz$~',$E)?"compress.zlib://$Lg":$Lg);if($yb){$eg=substr($gb,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$eg,$vf))$gb=iconv("utf-16","utf-8",$gb);elseif($eg=="\xEF\xBB\xBF")$gb=substr($gb,3);$K.=$gb."\n\n";}else$K.=$gb;}return$K;}functionupload_error($k){$Ld=($k==UPLOAD_ERR_INI_SIZE?ini_get("upload_max_filesize"):0);return($k?'Unable to upload a file.'.($Ld?" ".sprintf('Maximum allowed file size is %sB.',$Ld):""):'File does not exist.');}functionrepeat_pattern($Re,$zd){returnstr_repeat("$Re{0,65535}",$zd/65535)."$Re{0,".($zd%65535)."}";}functionis_utf8($X){return(preg_match('~~u',$X)&&!preg_match('~[\0-\x8\xB\xC\xE-\x1F]~',$X));}functionshorten_utf8($ig,$zd=80,$mg=""){if(!preg_match("(^(".repeat_pattern("[\t\r\n -\x{10FFFF}]",$zd).")($)?)u",$ig,$C))preg_match("(^(".repeat_pattern("[\t\r\n -~]",$zd).")($)?)",$ig,$C);returnh($C[1]).$mg.(isset($C[2])?"":"<i>…</i>");}functionformat_number($X){returnstrtr(number_format($X,0,".",','),preg_split('~~u','0123456789',-1,PREG_SPLIT_NO_EMPTY));}functionfriendly_url($X){returnpreg_replace('~[^a-z0-9_]~i','-',$X);}functionhidden_fields($hf,$Xc=array(),$af=''){$K=false;foreach($hfas$z=>$X){if(!in_array($z,$Xc)){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$b;$K=array();foreach($b->foreignKeys($Q)as$n){foreach($n["source"]as$X)$K[$X][]=$n;}return$K;}functionenum_input($U,$wa,$l,$Y,$Yb=null){global$b;preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$Gd);$K=($Yb!==null?"<label><input type='$U'$wa value='$Yb'".((is_array($Y)?in_array($Yb,$Y):$Y===0)?" checked":"")."><i>".'empty'."</i></label>":"");foreach($Gd[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($b->editVal($X,$l)).'</label>';}return$K;}functioninput($l,$Y,$q){global$Xg,$b,$y;$E=h(bracket_escape($l["field"]));echo"<td class='function'>";if(is_array($Y)&&!$q){$ta=array($Y);if(version_compare(PHP_VERSION,5.4)>=0)$ta[]=JSON_PRETTY_PRINT;$Y=call_user_func_array('json_encode',$ta);$q="json";}$xf=($y=="mssql"&&$l["auto_increment"]);if($xf&&!$_POST["save"])$q=null;$Fc=(isset($_GET["select"])||$xf?array("orig"=>'original'):array())+$b->editFunctions($l);$wa=" name='fields[$E]'";if($l["type"]=="enum")echoh($Fc[""])."