Page 1 of 1

how to include php code in custom fields ?

Posted: Sat Dec 11, 2010 8:40 am
by timschulte
Script URL:
Version of script: 2.2
Hosting company: ezhosting.com
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

$_SERVER['HTTP_REFERER']
REFERER
include

Write your message below:

I'd like to pass some variables to the ticket, such as where they are coming from when they hit the button to create a trouble ticket, so we know where the trouble on the site is occurring without the customer having to enter a page url in a custom field.

I was wondering how I would include the referer in one of the custom fields. When I enter:

<?php echo $_SERVER['HTTP_REFERER']; ?>

in the Options of the custom fields, it simply prints out:

<?php echo $_SERVER['HTTP_REFERER']; ?>

in the custom field, how would I get the script to evaluate the code and not display it ??

I also tried using just

echo $_SERVER['HTTP_REFERER']; without the <?php ?>
$_SERVER['HTTP_REFERER'] and also with just the system variable that I wanted as default

entry in the hesk_settings.inc.php is:

'custom6'=>array('use'=>1,'place'=>0,'type'=>'text','req'=>0,'name'=>'Referer','maxlen'=>255,'value'=>'<?php echo $_SERVER[\'HTTP_REFERER\']; ?>'),

Thanks.

Tim

Re: how to include php code in custom fields ?

Posted: Sun Dec 12, 2010 10:50 am
by Klemen
You might be better of modifying index.php file. Find

Code: Select all

if ($v['use'] && $v['place']==0)
and paste this ABOVE that code:

Code: Select all

if ($k == 'custom6')
{
echo '<input type="hidden" name="custom6" value="'.strip_tags($_SERVER['HTTP_REFERER']).'" />';
continue;
}

Re: how to include php code in custom fields ?

Posted: Wed Dec 15, 2010 1:05 am
by timschulte
Thanks that worked like a champ :)

One thing to remember if you don't want the customer to see those variables, then you need to also place that code in the ticket.php so when they pull up a ticket it hides them.

one suggestion for the next version: please put $_SERVER['HTTP_USER_AGENT'] & $_SERVER['HTTP_REFERER']
along with capturing the ip that the end user is coming from.

I have our pages click straight to the add ticket from within the website, that way I can see where they are coming from when they have troubles, the agent code gives me a heads up to what kind of browser and OS they are using and helps with trouble shooting versus asking them what they are using. just my two cents.

Thanks for a great piece of software!

Tim