Im using osTicket 1.6RC3 in my native language so I prefer random code instead of english words... so I made a search in google for a code to adapt in osTicket.
Here is what I have done ;)
Please remember that those changes are done in RC3 ver.
Code which I implemented in osTicket is quite easy.
You can find description of captcha code itself here:
http://www.white-hat-web-design.co.uk/articles/php-captcha.php(http://www.white-hat-web-design.co.uk/articles/php-captcha.php)
Download the package from (here)
Upload two files: CaptchaSecurityImages.php and monofont.ttf into the main directory of osTicket.
Now lets make some changes in few files.
First:
class.ticket.php
In the code search for this function:
function create($var,&$errors,$origin,$autorespond=true,$alertstaff=true) {
global $cfg,$thisclient,$_FILES;
$id=0;
$fields=array();
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Name required');
$fields = array('type'=>'email', 'required'=>1, 'error'=>'Valid email required');
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Subject required');
$fields = array('type'=>'text', 'required'=>1, 'error'=>'Message required');
if(strcasecmp($origin,'web')==0) { //Help topic only applicable on web tickets.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic');
// INSERT CODE HERE
}elseif(strcasecmp($origin,'staff')==0){ //tickets created by staff...e.g on callins.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required');
$fields = array('type'=>'string', 'required'=>1, 'error'=>'Indicate source');
}else { //Incoming emails (PIPE or POP.
$fields = array('type'=>'int', 'required'=>1, 'error'=>'Email unknown');
}
$fields = array('type'=>'int', 'required'=>0, 'error'=>'Invalid Priority');
$fields = array('type'=>'phone', 'required'=>0, 'error'=>'Phone # required');
$validate = new Validator($fields);
if(!$validate->validate($var)){
$errors=array_merge($errors,$validate->errors());
}
Instead of '//INSERT CODE HERE' paste
$fields = array('type'=>'code', 'required'=>1, 'error'=>'Please type correct CAPTCHA code');
Done here.
2nd file is class.validator.php
Search for:
case 'integer':
case 'int':
if(!is_numeric($this->input))
$this->errors=$field;
break;
case 'double':
if(!is_numeric($this->input))
$this->errors=$field;
break;
case 'text':
// INSERT CODE HERE
case 'string':
Replace dummy line //INSERT ... with:
case 'code':
if( $_SESSION != $_POST)
$this->errors=$field;
break;
Now the last part. Lets make an Input field and place for image itself on open.php form.
File: open.inc.php
Just at the beggining you can see:
<?php
if(!defined('OSTCLIENTINC')) die('Kwaheri rafiki wangu?'); //Say bye to our friend..
// INSERT CODE HERE
As usual replace the dummy line with:
session_start();
Next, search for:
<tr>
<th>Attachment:</th>
<td>
<input type="file" name="attachment"><font class="error"> <?=$errors?></font>
</td>
</tr>
<?}?>
// INSERT CODE HERE
As usual replace the dummy code with:
<tr>
<th>Security code:</th>
<td valign="middle">
<img src="CaptchaSecurityImages.php?width=100&height=40&characters=5"/><br />
<input id="security_code" name="security_code" type="text" size="15"><font class="error"> * <?=$errors?></font>
</td>
</tr>
I hope the modification will become useful ;)
Greets.