XoopsModules25x/adminer

View on GitHub

Showing 193 of 307 total issues

Function auth_error has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

as$x=>$V){list($X,$O,$T,$h)=array_map('base64_decode',explode("-",$x));if($X==DRIVER&&$O==SERVER&&$T==$_GET["username"]&&$h==DB)unset($gd[$x]);}cookie("adminer_permanent",implode(" ",$gd));}function
auth_error($k){global$b,$Zb;$k=h($k);$Od=session_name();if(isset($_GET["username"])){header("HTTP/1.1 403 Forbidden");if(($_COOKIE[$Od]||$_GET[$Od])&&!$Zb)$k='Session expired, please login again.';else{add_invalid_login();$G=get_password();if($G!==null){if($G===false)$k.='<br>'.sprintf('Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.','<code>permanentLogin()</code>');set_password(DRIVER,SERVER,$_GET["username"],null);}unset_permanent();}}if(!$_COOKIE[$Od]&&$_GET[$Od]&&ini_bool("session.use_only_cookies"))$k='Session support must be enabled.';$ed=session_get_cookie_params();cookie("adminer_key",($_COOKIE["adminer_key"]?$_COOKIE["adminer_key"]:rand_string()),$ed["lifetime"]);page_header('Login',$k,null);echo"<form action='' method='post'>\n";$b->loginForm();echo"<div>";hidden_fields($_POST,array("auth"));echo"</div>\n","</form>\n";page_footer("auth");exit;}if(isset($_GET["username"])){if(!class_exists("Min_DB")){unset($_SESSION["pwds"][DRIVER]);unset_permanent();page_header('No extension',sprintf('None of the supported PHP extensions (%s) are available.',implode(", ",$kd)),false);page_footer("auth");exit;}$f=connect();}$i=new
Severity: Minor
Found in include/editor.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function _applyPlugin has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    function _applyPlugin($function, $args) {
        foreach ($this->plugins as $plugin) {
            if (method_exists($plugin, $function)) {
                switch (count($args)) { // call_user_func_array() doesn't work well with references
                    case 0: $return = $plugin->$function(); break;
Severity: Minor
Found in include/plugins/plugin.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function auth_error has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

as$z=>$X){list($Jg,$O,$V,$i)=array_map('base64_decode',explode("-",$z));if($Jg==DRIVER&&$O==SERVER&&$V==$_GET["username"]&&$i==DB)unset($ze[$z]);}cookie("adminer_permanent",implode(" ",$ze));}function
auth_error($k){global$b,$Dc;$k=h($k);$wf=session_name();if(isset($_GET["username"])){header("HTTP/1.1 403 Forbidden");if(($_COOKIE[$wf]||$_GET[$wf])&&!$Dc)$k='Session expired, please login again.';else{add_invalid_login();$we=get_password();if($we!==null){if($we===false)$k.='<br>'.sprintf('Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.','<code>permanentLogin()</code>');set_password(DRIVER,SERVER,$_GET["username"],null);}unset_permanent();}}if(!$_COOKIE[$wf]&&$_GET[$wf]&&ini_bool("session.use_only_cookies"))$k='Session support must be enabled.';$pe=session_get_cookie_params();cookie("adminer_key",($_COOKIE["adminer_key"]?$_COOKIE["adminer_key"]:rand_string()),$pe["lifetime"]);page_header('Login',$k,null);echo"<form action='' method='post'>\n";$b->loginForm();echo"<div>";hidden_fields($_POST,array("auth"));echo"</div>\n","</form>\n";page_footer("auth");exit;}if(isset($_GET["username"])){if(!class_exists("Min_DB")){unset($_SESSION["pwds"][DRIVER]);unset_permanent();page_header('No extension',sprintf('None of the supported PHP extensions (%s) are available.',implode(", ",$Ee)),false);page_footer("auth");exit;}$e=connect();}$j=new
Severity: Minor
Found in include/adminer.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method create_xml_response has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function create_xml_response() 
{
  global $linenumber, $foffset, $totalqueries, $curfilename, $delimiter,
                 $lines_this, $lines_done, $lines_togo, $lines_tota,
                 $queries_this, $queries_done, $queries_togo, $queries_tota,
Severity: Minor
Found in include/bigdump.php - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

    as$i=>$S){$hf=h(ME)."db=".urlencode($i);echo"<tr".odd().">".(support("database")?"<td>".checkbox("db[]",$i,in_array($i,(array)$_POST["db"])):""),"<th><a href='$hf'>".h($i)."</a>";$Wa=nbsp(db_collation($i,$Xa));echo"<td>".(support("database")?"<a href='$hf".($of?"&amp;ns=":"")."&amp;database=' title='".'Alter database'."'>$Wa</a>":$Wa),"<td align='right'><a href='$hf&amp;schema=' id='tables-".h($i)."' title='".'Database schema'."'>".($_GET["dbsize"]?$S:"?")."</a>","<td align='right' id='size-".h($i)."'>".($_GET["dbsize"]?db_size($i):"?"),"\n";}echo"</table>\n",(support("database")?"<fieldset><legend>".'Selected'." <span id='selected'></span></legend><div>\n"."<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^db/));\">\n"."<input type='submit' name='drop' value='".'Drop'."'".confirm().">\n"."</div></fieldset>\n":""),"<script type='text/javascript'>tableCheck();</script>\n","<input type='hidden' name='token' value='$T'>\n","</form>\n";}}page_footer("db");}if(isset($_GET["status"]))$_GET["variables"]=$_GET["status"];if(isset($_GET["import"]))$_GET["sql"]=$_GET["import"];if(!(DB!=""?$e->select_db(DB):isset($_GET["sql"])||isset($_GET["dump"])||isset($_GET["database"])||isset($_GET["processlist"])||isset($_GET["privileges"])||isset($_GET["user"])||isset($_GET["variables"])||$_GET["script"]=="connect"||$_GET["script"]=="kill")){if(DB!=""||$_GET["refresh"]){restart_session();set_session("dbs",null);}connect_error();exit;}$Vd="RESTRICT|NO ACTION|CASCADE|SET NULL|SET DEFAULT";class
    Severity: Critical
    Found in include/adminer.php - About 1 hr to fix

      Function dumpData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          function dumpData($table, $style, $query) {
              if ($_POST['format'] == 'json') {
                  if ($this->database) {
                      echo ",\n";
                  } else {
      Severity: Minor
      Found in include/plugins/dump-json.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function selectSearchPrint has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      selectColumnsPrint($N,$e){}function
      selectSearchPrint($Y,$e,$t){$Y=(array)$_GET["where"];echo'<fieldset id="fieldset-search"><legend>'.'Search'."</legend><div>\n";$qc=array();foreach($Y
      as$x=>$V)$qc[$V["col"]]=$x;$q=0;$m=fields($_GET["select"]);foreach($e
      as$D=>$db){$l=$m[$D];if(preg_match("~enum~",$l["type"])||like_bool($l)){$x=$qc[$D];$q--;echo"<div>".h($db)."<input type='hidden' name='where[$q][col]' value='".h($D)."'>:",(like_bool($l)?" <select name='where[$q][val]'>".optionlist(array(""=>"",'no','yes'),$Y[$x]["val"],true)."</select>":enum_input("checkbox"," name='where[$q][val][]'",$l,(array)$Y[$x]["val"],($l["null"]?0:null))),"</div>\n";unset($e[$D]);}elseif(is_array($Xc=$this->_foreignKeyOptions($_GET["select"],$D))){if($m[$D]["null"])$Xc[0]='('.'empty'.')';$x=$qc[$D];$q--;echo"<div>".h($db)."<input type='hidden' name='where[$q][col]' value='".h($D)."'><input type='hidden' name='where[$q][op]' value='='>: <select name='where[$q][val]'>".optionlist($Xc,$Y[$x]["val"],true)."</select></div>\n";unset($e[$D]);}}$q=0;foreach($Y
      as$V){if(($V["col"]==""||$e[$V["col"]])&&"$V[col]$V[val]"!=""){echo"<div><select name='where[$q][col]'><option value=''>(".'anywhere'.")".optionlist($e,$V["col"],true)."</select>",html_select("where[$q][op]",array(-1=>"")+$this->operators,$V["op"]),"<input type='search' name='where[$q][val]' value='".h($V["val"])."' onkeydown='selectSearchKeydown(this, event);' onsearch='selectSearchSearch(this);'></div>\n";$q++;}}echo"<div><select name='where[$q][col]' onchange='this.nextSibling.nextSibling.onchange();'><option value=''>(".'anywhere'.")".optionlist($e,null,true)."</select>",html_select("where[$q][op]",array(-1=>"")+$this->operators),"<input type='search' name='where[$q][val]' onchange='selectAddRow(this);' onsearch='selectSearch(this);'></div>\n","</div></fieldset>\n";}function
      Severity: Minor
      Found in include/editor.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function get_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      pagination($F,$Ya){return" ".($F==$Ya?$F+1:'<a href="'.h(remove_from_uri("page").($F?"&page=$F".($_GET["next"]?"&next=".urlencode($_GET["next"]):""):"")).'">'.($F+1)."</a>");}function
      get_file($x,$bb=false){$Eb=$_FILES[$x];if(!$Eb)return
      null;foreach($Eb
      as$x=>$V)$Eb[$x]=(array)$V;$K='';foreach($Eb["error"]as$x=>$k){if($k)return$k;$D=$Eb["name"][$x];$pe=$Eb["tmp_name"][$x];$Ta=file_get_contents($bb&&preg_match('~\\.gz$~',$D)?"compress.zlib://$pe":$pe);if($bb){$Td=substr($Ta,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$Td,$yd))$Ta=iconv("utf-16","utf-8",$Ta);elseif($Td=="\xEF\xBB\xBF")$Ta=substr($Ta,3);$K.=$Ta."\n\n";}else$K.=$Ta;}return$K;}function
      Severity: Minor
      Found in include/editor.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function get_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      pagination($G,$nb){return" ".($G==$nb?$G+1:'<a href="'.h(remove_from_uri("page").($G?"&page=$G".($_GET["next"]?"&next=".urlencode($_GET["next"]):""):"")).'">'.($G+1)."</a>");}function
      get_file($z,$ub=false){$mc=$_FILES[$z];if(!$mc)return
      null;foreach($mc
      as$z=>$X)$mc[$z]=(array)$X;$K='';foreach($mc["error"]as$z=>$k){if($k)return$k;$F=$mc["name"][$z];$jg=$mc["tmp_name"][$z];$fb=file_get_contents($ub&&preg_match('~\\.gz$~',$F)?"compress.zlib://$jg":$jg);if($ub){$Cf=substr($fb,0,3);if(function_exists("iconv")&&preg_match("~^\xFE\xFF|^\xFF\xFE~",$Cf,$af))$fb=iconv("utf-16","utf-8",$fb);elseif($Cf=="\xEF\xBB\xBF")$fb=substr($fb,3);$K.=$fb."\n\n";}else$K.=$fb;}return$K;}function
      Severity: Minor
      Found in include/adminer.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function edit_fields has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      type_class($U){foreach(array('char'=>'text','date'=>'time|year','binary'=>'blob','enum'=>'set',)as$z=>$X){if(preg_match("~$z|$X~",$U))return" class='$z'";}}function
      edit_fields($m,$Xa,$U="TABLE",$o=array(),$cb=false){global$e,$Oc;$m=array_values($m);echo'<thead><tr class="wrap">
      ';if($U=="PROCEDURE"){echo'<td>&nbsp;';}echo'<th>',($U=="TABLE"?'Column name':'Parameter name'),'<td>Type<textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur(this);"></textarea>
      <td>Length
      <td>Options
      Severity: Minor
      Found in include/adminer.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function search_tables has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      fields_from_edit(){global$i;$K=array();foreach((array)$_POST["field_keys"]as$x=>$V){if($V!=""){$V=bracket_escape($V);$_POST["function"][$V]=$_POST["field_funs"][$x];$_POST["fields"][$V]=$_POST["field_vals"][$x];}}foreach((array)$_POST["fields"]as$x=>$V){$D=bracket_escape($x,1);$K[$D]=array("field"=>$D,"privileges"=>array("insert"=>1,"update"=>1),"null"=>1,"auto_increment"=>($x==$i->primary),);}return$K;}function
      search_tables(){global$b,$f;$_GET["where"][0]["op"]="LIKE %%";$_GET["where"][0]["val"]=$_POST["query"];$Qb=false;foreach(table_status('',true)as$R=>$S){$D=$b->tableName($S);if(isset($S["Engine"])&&$D!=""&&(!$_POST["tables"]||in_array($R,$_POST["tables"]))){$J=$f->query("SELECT".limit("1 FROM ".table($R)," WHERE ".implode(" AND ",$b->selectSearchProcess(fields($R),array())),1));if(!$J||$J->fetch_row()){if(!$Qb){echo"<ul>\n";$Qb=true;}echo"<li>".($J?"<a href='".h(ME."select=".urlencode($R)."&where[0][op]=".urlencode($_GET["where"][0]["op"])."&where[0][val]=".urlencode($_GET["where"][0]["val"]))."'>$D</a>\n":"$D: <span class='error'>".error()."</span>\n");}}}echo($Qb?"</ul>":"<p class='message'>".'No tables.')."\n";}function
      Severity: Minor
      Found in include/editor.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function insertUpdate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      insert($Q,$P){return($P?parent::insert($Q,$P):queries("INSERT INTO ".table($Q)." ()\nVALUES ()"));}function
      insertUpdate($Q,$M,$He){$d=array_keys(reset($M));$Fe="INSERT INTO ".table($Q)." (".implode(", ",$d).") VALUES\n";$Hg=array();foreach($d
      as$z)$Hg[$z]="$z = VALUES($z)";$Kf="\nON DUPLICATE KEY UPDATE ".implode(", ",$Hg);$Hg=array();$ld=0;foreach($M
      as$P){$Y="(".implode(", ",$P).")";if($Hg&&(strlen($Fe)+$ld+strlen($Y)+strlen($Kf)>1e6)){if(!queries($Fe.implode(",\n",$Hg).$Kf))return
      false;$Hg=array();$ld=0;}$Hg[]=$Y;$ld+=strlen($Y)+2;}return
      Severity: Minor
      Found in include/adminer.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function dumpData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          function dumpData($table, $style, $query) {
              if ($_POST['format'] == 'xml') {
                  if (!$this->database) {
                      $this->database = true;
                      echo "<database name='" . h(DB) . "'>\n";
      Severity: Minor
      Found in include/plugins/dump-xml.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function search_tables has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      fields_from_edit(){global$j;$K=array();foreach((array)$_POST["field_keys"]as$z=>$X){if($X!=""){$X=bracket_escape($X);$_POST["function"][$X]=$_POST["field_funs"][$z];$_POST["fields"][$X]=$_POST["field_vals"][$z];}}foreach((array)$_POST["fields"]as$z=>$X){$F=bracket_escape($z,1);$K[$F]=array("field"=>$F,"privileges"=>array("insert"=>1,"update"=>1),"null"=>1,"auto_increment"=>($z==$j->primary),);}return$K;}function
      search_tables(){global$b,$e;$_GET["where"][0]["op"]="LIKE %%";$_GET["where"][0]["val"]=$_POST["query"];$uc=false;foreach(table_status('',true)as$Q=>$R){$F=$b->tableName($R);if(isset($R["Engine"])&&$F!=""&&(!$_POST["tables"]||in_array($Q,$_POST["tables"]))){$J=$e->query("SELECT".limit("1 FROM ".table($Q)," WHERE ".implode(" AND ",$b->selectSearchProcess(fields($Q),array())),1));if(!$J||$J->fetch_row()){if(!$uc){echo"<ul>\n";$uc=true;}echo"<li>".($J?"<a href='".h(ME."select=".urlencode($Q)."&where[0][op]=".urlencode($_GET["where"][0]["op"])."&where[0][val]=".urlencode($_GET["where"][0]["val"]))."'>$F</a>\n":"$F: <span class='error'>".error()."</span>\n");}}}echo($uc?"</ul>":"<p class='message'>".'No tables.')."\n";}function
      Severity: Minor
      Found in include/adminer.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function insertUpdate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      insert($R,$P){return($P?parent::insert($R,$P):queries("INSERT INTO ".table($R)." ()\nVALUES ()"));}function
      insertUpdate($R,$M,$md){$e=array_keys(reset($M));$ld="INSERT INTO ".table($R)." (".implode(", ",$e).") VALUES\n";$Ge=array();foreach($e
      as$x)$Ge[$x]="$x = VALUES($x)";$Zd="\nON DUPLICATE KEY UPDATE ".implode(", ",$Ge);$Ge=array();$xc=0;foreach($M
      as$P){$W="(".implode(", ",$P).")";if($Ge&&(strlen($ld)+$xc+strlen($W)+strlen($Zd)>1e6)){if(!queries($ld.implode(",\n",$Ge).$Zd))return
      false;$Ge=array();$xc=0;}$Ge[]=$W;$xc+=strlen($W)+2;}return
      Severity: Minor
      Found in include/editor.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method drop_create has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      drop_create($Fb,$g,$Gb,$Yf,$Hb,$B,$Ad,$zd,$_d,$Rd,$Id){if($_POST["drop"])query_redirect($Fb,$B,$Ad);elseif($Rd=="")query_redirect($g,$B,$_d);elseif($Rd!=$Id){$lb=queries($g);queries_redirect($B,$zd,$lb&&queries($Fb));if($lb)queries($Gb);}else
      Severity: Major
      Found in include/adminer.php - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

        as$x=>$V){if($x===""||!$V)break;$Ib++;}$Sc=($Ib?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($l["field"])))."]']; if ($Ib > f.selectedIndex) f.selectedIndex = $Ib;\" onkeyup='keyupChange.call(this);'":"");$c.=$Sc;$Yb=(in_array($o,$Tb)||isset($Tb[$o]));echo(count($Tb)>1?"<select name='function[$D]' onchange='functionChange(this);'".on_help("getTarget(event).value.replace(/^SQL\$/, '')",1).">".optionlist($Tb,$o===null||$Yb?$o:"")."</select>":nbsp(reset($Tb))).'<td>';$mc=$b->editInput($_GET["edit"],$l,$c,$W);if($mc!="")echo$mc;elseif($l["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$Bc);foreach($Bc[1]as$q=>$V){$V=stripcslashes(str_replace("''","'",$V));$Fa=(is_int($W)?($W>>$q)&1:in_array($V,explode(",",$W),true));echo" <label><input type='checkbox' name='fields[$D][$q]' value='".(1<<$q)."'".($Fa?' checked':'')."$Sc>".h($b->editVal($V,$l)).'</label>';}}elseif(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads"))echo"<input type='file' name='fields-$D'$Sc>";elseif(($ge=preg_match('~text|lob~',$l["type"]))||preg_match("~\n~",$W)){if($ge&&$v!="sqlite")$c.=" cols='50' rows='12'";else{$M=min(12,substr_count($W,"\n")+1);$c.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"<textarea$c>".h($W).'</textarea>';}elseif($o=="json")echo"<textarea$c cols='50' rows='12' class='jush-js'>".h($W).'</textarea>';else{$Gc=(!preg_match('~int~',$l["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$l["length"],$A)?((preg_match("~binary~",$l["type"])?2:1)*$A[1]+($A[3]?1:0)+($A[2]&&!$l["unsigned"]?1:0)):($we[$l["type"]]?$we[$l["type"]]+($l["unsigned"]?0:1):0));if($v=='sql'&&$f->server_info>=5.6&&preg_match('~time~',$l["type"]))$Gc+=7;echo"<input".((!$Yb||$o==="")&&preg_match('~(?<!o)int~',$l["type"])?" type='number'":"")." value='".h($W)."'".($Gc?" maxlength='$Gc'":"").(preg_match('~char|binary~',$l["type"])&&$Gc>20?" size='40'":"")."$c>";}}}function
        Severity: Critical
        Found in include/editor.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

          as$z=>$X){if($z===""||!$X)break;$pc++;}$Wd=($pc?" onchange=\"var f = this.form['function[".h(js_escape(bracket_escape($l["field"])))."]']; if ($pc > f.selectedIndex) f.selectedIndex = $pc;\" onkeyup='keyupChange.call(this);'":"");$wa.=$Wd;$Cc=(in_array($q,$xc)||isset($xc[$q]));echo(count($xc)>1?"<select name='function[$F]' onchange='functionChange(this);'".on_help("getTarget(event).value.replace(/^SQL\$/, '')",1).">".optionlist($xc,$q===null||$Cc?$q:"")."</select>":nbsp(reset($xc))).'<td>';$Pc=$b->editInput($_GET["edit"],$l,$wa,$Y);if($Pc!="")echo$Pc;elseif($l["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$l["length"],$rd);foreach($rd[1]as$t=>$X){$X=stripcslashes(str_replace("''","'",$X));$Na=(is_int($Y)?($Y>>$t)&1:in_array($X,explode(",",$Y),true));echo" <label><input type='checkbox' name='fields[$F][$t]' value='".(1<<$t)."'".($Na?' checked':'')."$Wd>".h($b->editVal($X,$l)).'</label>';}}elseif(preg_match('~blob|bytea|raw|file~',$l["type"])&&ini_bool("file_uploads"))echo"<input type='file' name='fields-$F'$Wd>";elseif(($Zf=preg_match('~text|lob~',$l["type"]))||preg_match("~\n~",$Y)){if($Zf&&$y!="sqlite")$wa.=" cols='50' rows='12'";else{$M=min(12,substr_count($Y,"\n")+1);$wa.=" cols='30' rows='$M'".($M==1?" style='height: 1.2em;'":"");}echo"<textarea$wa>".h($Y).'</textarea>';}elseif($q=="json")echo"<textarea$wa cols='50' rows='12' class='jush-js'>".h($Y).'</textarea>';else{$yd=(!preg_match('~int~',$l["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$l["length"],$C)?((preg_match("~binary~",$l["type"])?2:1)*$C[1]+($C[3]?1:0)+($C[2]&&!$l["unsigned"]?1:0)):($tg[$l["type"]]?$tg[$l["type"]]+($l["unsigned"]?0:1):0));if($y=='sql'&&$e->server_info>=5.6&&preg_match('~time~',$l["type"]))$yd+=7;echo"<input".((!$Cc||$q==="")&&preg_match('~(?<!o)int~',$l["type"])?" type='number'":"")." value='".h($Y)."'".($yd?" maxlength='$yd'":"").(preg_match('~char|binary~',$l["type"])&&$yd>20?" size='40'":"")."$wa>";}}}function
          Severity: Critical
          Found in include/adminer.php - About 1 hr to fix

            Function hidden_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            preg_replace('~[^a-z0-9_]~i','-',$X);}function
            hidden_fields($Me,$Kc=array()){while(list($z,$X)=each($Me)){if(!in_array($z,$Kc)){if(is_array($X)){foreach($X
            as$Zc=>$W)$Me[$z."[$Zc]"]=$W;}else
            echo'<input type="hidden" name="'.h($z).'" value="'.h($X).'">';}}}function
            Severity: Minor
            Found in include/adminer.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function lzw_decompress has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            verify_token(){list($qe,$vd)=explode(":",$_POST["token"]);return($vd^$_SESSION["token"])==$qe;}function
            lzw_decompress($za){$gb=256;$_a=8;$Ka=array();$Bd=0;$Cd=0;for($q=0;$q<strlen($za);$q++){$Bd=($Bd<<8)+ord($za[$q]);$Cd+=8;if($Cd>=$_a){$Cd-=$_a;$Ka[]=$Bd>>$Cd;$Bd&=(1<<$Cd)-1;$gb++;if($gb>>$_a)$_a++;}}$fb=range("\0","\xFF");$K="";foreach($Ka
            as$q=>$Ja){$ob=$fb[$Ja];if(!isset($ob))$ob=$Ne.$Ne[0];$K.=$ob;if($q)$fb[]=$Ne.$ob[0];$Ne=$ob;}return$K;}function
            Severity: Minor
            Found in include/editor.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Severity
            Category
            Status
            Source
            Language