How to Add Captcha Security Code in osTicket System 1.6 RC5

In osTicket System version 1.6 RC5, there is no CAPTCHA feature on the open new ticket form. This will cause sometimes you will receive the ticket that contains of spam, and this will bother your ticket system. In order to decrease the spam ticket, you can implement the security code (CAPTCHA) feature as you can see from this URL: http://www.white-hat-web-design.co.uk/articles/php-captcha.php on your osTicket form. Please try the following steps.

  1. Download the file from this URL: http://www.white-hat-web-design.co.uk/articles/captcha.zip.
  2. Extract the .zip file above, then upload two files: CaptchaSecurityImages.php and monofont.ttf into the main or root directory of your osTicket.
  3. Open include\class.ticket.php file, and find this code:
            if(strcasecmp($origin,'web')==0) { //Help topic only applicable on web tickets.
                $fields['topicId']  = array('type'=>'int',      'required'=>1, 'error'=>'Select help topic');

    after that code, add the following code:

                // Begin of MOD CAPTCHA, added by Masino Sinaga, July 17, 2009
                $fields['security_code']  = array('type'=>'code',     'required'=>1, 'error'=>'Please type correct CAPTCHA code');
                // End of MOD CAPTCHA, added by Masino Sinaga, July 17, 2009
  4. Open \include\class.validator.php file, and find this code:

                case 'text':
                case 'string':
                    break;

    before that code above, please add the following code:

                // Begin of MOD CAPTCHA, added by Masino Sinaga, July 17, 2009
                case 'code':
                    if( $_SESSION['security_code'] != $_POST['security_code'])
                    $this->errors[$k]=$field['error'];
                    break;             
                // End of MOD CAPTCHA, added by Masino Sinaga, July 17, 2009
  5. Open \include\client\open.inc.php file, and find this code:

    if(!defined('OSTCLIENTINC')) die('Kwaheri rafiki!'); //Say bye to our friend..

    after that code above, please add the following code:

    // Begin of CAPTCHA feature, added by Masino Sinaga, July 17, 2009
    session_start();
    // End of CAPTCHA feature, added by Masino Sinaga, July 17, 2009

    find also this code:

        <tr>
            <th><?php echo (I_C_OPEN_ATTACHMENT) ?></th>
            <td>
                <input type="file" name="attachment"><font class="error">&nbsp;<?php echo $errors['attachment']?></font>
            </td>
        </tr>
        <?php }?>

    then after that code above, please add this following code:

    <!-- Begin of CAPTCHA feature, added by Masino Sinaga, July 17, 2009 -->
        <tr>
            <th><?php echo (I_C_OPEN_SECURITY_CODE); ?></th>
            <td valign="middle">
                <img src="CaptchaSecurityImages.php?width=100&height=38&characters=6"/>
                <input id="security_code" name="security_code" type="text" size="15"><font class="error">&nbsp;*&nbsp;<?=$errors['security_code']?></font>
            </td>
        </tr>
    <!-- End of CAPTCHA feature, added by Masino Sinaga, July 17, 2009 -->

Please note, in some part of the code above, you will find constant(s), and the other side, you will also find the sentence that has not been converted to its constant. This happened because some of the code have not been translated to the language file. Please adjust them with your need. Thank you for your understanding.

Share

3,287 viewsPrint This Post Print This Post

Comments

  1. Bayu says:

    thanks atas ilmunya… keren… kalau mau ganti ke bhs indonesia dimana tutorialnya ya?

  2. Sama-sama, mas. Untuk mengganti ke bahasa Indonesia, tinggal klik bendera Merah Putih di sebelah pojok kanan atas (sidebar) yang ada tulisan Indonesian.

  3. Bayu says:

    maksud saya, jika script osTicket mau sy ganti dlm bhs indonesia, apakah ada tutorialnya? (spt milik anda) atau ada modul bhs indonesia yg bisa di masukkan ke osTicket? thanks

  4. Wah, maaf mas. Saya salah paham kalau begitu, hehe. Kalau sekarang memang belum ada tutorialnya. Saya membuat osTicket dgn versi multi-bahasa sejak versi 1.6 RC4, dan sampai sekarang sedang dalam tahap penyesuaian dengan versi 1.6 RC5. Cukup lama waktu yang dibutuhkan untuk menterjemahkan semua string di dalam script osTicket supaya support multi-language. Kalau mas Bayu tertarik dan ingin membeli paket installasi berikut terjemahan yang sudah jadi, nanti saya hubungi kembali setelah selesai. Trims.

  5. Scott Baty says:

    I am having trouble with the image showing up. I have done exactly as told to do. Any ideas?

  6. @Scott Baty

    Can I see your live site demo?

  7. Luvian Yoga Pratama says:

    good tutorial…!

  8. Danie says:

    Great tutorial. The only problem is that for the life of me I can’t find the last code, the last stage, on the client.inc file. I have looked in some other php files as well, but I think the code has changed. Do you know of another way? Maybe if you have a moment you would be ok just to check if the OS ticket script has changed. I have pasted your code in the ”new” version, and it displays, but doesnt display the image at all.

    Cheers

  9. Joko'z Aolia says:

    Wah Blognya Keren Nich .,.,. Saya Mau Tanya ,.,. Saya PUnya Website,. Trus Saya Kebingungan Memasang Fitus Captcha atau security code pada Form Pesan ,.,. Mohon Bantuanya .,..,. Terimakasih .,.,.,

  10. @Joko’z Aolia

    Kalau untuk form pesan atau komentar, coba pakai plugin yang bernama SI Captcha Anti-Spam. Sedangkan yang di artikel ini, itu Captcha untuk osTicket System (ticketing system).

    Oke, silahkan download pluginnya dari wordpress.org atau langsung ke link ini: http://wordpress.org/extend/plugins/si-captcha-for-wordpress/ . Semoga berhasil.

  11. @Danie

    What do you mean by “last code” or “last stage”. Could you please describe it more detail, or which line of code do you mean? Also, please mention clearly in which steps you get confused, since I have tried this modification, and everything seemed okay so far.

  12. I didn’t know before how to add captcha security code in os ticket system
    thanks for sharing this method
    regards
    fm radio online

Trackbacks

  1. [...] was supposed to find, wasn’t in the file it was supposed to be. Know what I mean . Here is a link to the site. The script as modified here was originally distributed from another develope as far as I could [...]

Speak Your Mind

*


*