I've created a customer form to ask for our clients to put in a machine (Computer Name) but many times they forget, I've found this php script online and have looked around the ticket.php and form.php and not seeing the "Machine Name" field I've created on the forms, does anyone know of a good way of doing this.

<?php $hostname = gethostbyaddr($_SERVER); echo $hostname; ?>

Fields are stored in the database and generated by the display code, so I cannot think of a way that you can do this easily...Of course I dont think that you need to. The IP address that the request comes from is already stored in the ticket (ost_ticket table, ip_address field).  So what you would need to do is edit the ticket view and run your code./include/staff/ticket-view.inc.phpcirca line 254-256changeif($ticket->getIP())    echo '&nbsp;&nbsp; <span class="faded">('.$ticket->getIP().')</span>';?>to if($ticket->getIP())    echo '&nbsp;&nbsp; <span class="faded">('.$ticket->getIP().')</span>';    $hostname = gethostbyaddr($_SERVER);    echo '&nbsp;&nbsp; <span class="faded">('.$hostname.')</span>';?>

Ok tried it and it gave me an IP address but it's not the right one, and it didn't give the computer name, do you know a way or a better code for this? The IP address it gives normally is the public IP and if I had the computer local IP it would help when finding out the name if I had to. We do remote support of networks and a lot of the time it hard to get clients to take the time to fill out these forms so we can help without spending a lot of time calling them to find the right computer name.

I don't think that this will ever work the way that you want it to all the time.  Machine name resolution will entirely depend on if your running your own DNS internally and if it resolved correctly.  External traffic will often result in the external wan IP address if the company uses NAT.  You're best bet might just be to make your "Machine Name" field required.

Write a Reply...