POST Array


SimonF

6 posts in this topic Last Reply

Recommended Posts

Hi is there a defined method for clear POST data within unraid Plugins.

 

I have created a test page but options I tried refresh with F5 always prompts for re-submission.

 

 

 

image.thumb.png.bc071f229820988d3f2ff4232a614a7f.png

 

Source Code for page below. I have copied processtargetcli function from lib.php and modified.  Real page has more selections that test page but trying to find solution for single entry first.

 

Menu="SystemInformation"
Title="iSCSITest"
Tag="save"
---
<?PHP

#require_once "$docroot/plugins/unraid.iSCSI/include/lib.php";

function processTargetcli($cmdstr) {
    # Write command string a process
    # targetctl  /tmp/string > /var/run/targetcli.last
    #exec($cmdstr  ,$tj) ;
    $debug=true;
  $cmd=$cmdstr."\nexit\n"  ;
  exec("echo \"$cmd\" >/tmp/iscsicmd.run", $output, $myreturn );
    $cmd="targetcli </tmp/iscsicmd.run ";
    exec($cmd, $output, $return) ;
    
    if ($debug) {
        echo "\n" ;
        var_dump($return) ;
        var_dump($output) ;
    }
    return($return) ;
   
}

# /iscsi/iqn.2003-01.org.linux-iscsi.tower.x8664:sn.ee5cd767532c/tpg1/luns  create /backstores/ramdisk/testramdisk add_mapped_luns=false 

if (count($_POST)) {

  var_dump($_POST) ;


if(isset($_POST['#applytgt'])) {
    if ($_POST['#applytgt'] == "_(Add Target)_") {
      $tgtname=$_POST["newtgt"];
      $cmdstr="/iscsi/ create ".$tgtname;
      $test=processTargetcli($cmdstr) ;
      if ($test=0) 
       $_POST = array();
 
      
    }
}
    

  $_POST=array() ;
  echo '<script>window.opener.location.reload(true);</script>';
}
    
?>

<style>
table.pre{margin-top:0;background:transparent}
table.pre td:first-child{width:144px}
table tr td{padding:0 0 3px 0;margin:0}
table tr td.thin{line-height:8px;height:8px}
</style>

<form id="newtgt" method="POST"    >
<b>_(Create Target:)_</b>
<input type="text" name="newtgt" placeholder="Auto create random name"/>
<input type="submit" name="#applytgt" value='_(Add Target)_'>
</form>


 

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.