The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 807 - File: showthread.php PHP 7.3.12 (Linux)
File Line Function
/showthread.php 807 errorHandler->error





Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
iPXE and calling PHP
2019-02-26, 00:33
Post: #1
iPXE and calling PHP
I'd like to be able to run a php function to write the MAC and serial to a database. This is working, however when calling the php file ipxe exits and returns to the boot selection menu or boots the hard drive (depending on machine). Ideally I'd like to boot a new computer, call a function to write serial and mac to a database (using php i presume), then be able to continue in the ipxe menu to make a different boot selection.

From my testing it appears as long as php is 'ipxe compliant' and finishes running without error, it will return to ipxe menu, however because the php is running its own functions ipxe crashes with an error.

menu.ipxe
Code:
:prestage
echo Adding following details:
echo serial: ${smbios/serial}
echo mac: ${netX/mac}
sleep 3
# chain --replace --autofree http://172.16.0.17/prestage/index.php?serial=${smbios/serial}&mac=${netX/mac}
kernel http://172.16.0.17/prestage/index.php?serial=${smbios/serial}&mac=${netX/mac}
goto start

index.php - example code 'ipxe compliant' - returns to ipxe successfully
Code:
<?php
header ( "Content-type: text/plain" );
echo "#!ipxe \n";
echo "echo Dan is the man \n";
echo "sleep 5 \n";
?>

index.php - example code - breaks with error
Code:
<?php
header ( "Content-type: text/plain" );
echo "#!ipxe \n";
$serial = $_REQUEST['serial'];
$mac    = $_REQUEST['mac'];
echo "echo Dan is the man \n";
echo "sleep 5 \n";
?>

index.php - actual code works for purposes of writing database but crash exits
Code:
<?php
include "conn.php";
$serial = $_REQUEST['serial'];
$mac    = $_REQUEST['mac'];
if ($serial !="") {
    $sql = "insert into prestage (serial, mac) values ('$serial', '$mac')";
    mysqli_query($conn, $sql);
    };
    
?>

Do I need to compile ipxe binary with a different option?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
iPXE and calling PHP - ndog - 2019-02-26 00:33
RE: iPXE and calling PHP - NiKiZe - 2019-02-26, 00:55
RE: iPXE and calling PHP - ndog - 2019-02-27, 04:36
RE: iPXE and calling PHP - NiKiZe - 2019-02-27, 08:11
RE: iPXE and calling PHP - ndog - 2019-02-27, 20:59



User(s) browsing this thread: 1 Guest(s)