Quantcast
Channel: Open Script Solution» duplicate
Viewing all articles
Browse latest Browse all 3

How to Avoid Duplicate Ticket Content in osTicket System

$
0
0

In osTicket System, when a new ticket created, it executes INSERT INTO SQL, and then displaying the “Thank You” page afterwards. Unfortunately, when client reload or refresh that page, then it will re-execute that SQL again, since the primary key for the ticket table is an ID of the ticket which has the auto-number field. That is why the duplicate ticket content could be saved many times to the database, and it will look like a spam ticket for you. So here is the solution to avoid duplicate ticket content saved in database in osTicket System. You can apply this code for 1.6 RC4, 1.6 RC5, or 1.6 ST version.

Open your \include\class.ticket.php file, and find this following code if your osTicket version is 1.6 RC4:

  
//Any error above is fatal.
  if($errors) { return 0; }

or find this code if your osTicket version is 1.6 RC5 or 1.6 ST:

$ipaddress=$var['ip']?$var['ip']:$_SERVER['REMOTE_ADDR'];

after that code, then add the following code:

  // Added by Masino Sinaga, April 13, 2009
  // This code to avoid duplicate ticket-content saved in database
  //
  // For example: In existing condition, If user refresh/reload 
  // the page that show thank you message after client              
  // open a new ticket, the new ticket would be created
  // and that new record will be saved in database, even 
  // the new ticket has same content with the previous ticket.
  // With this MOD, system will avoid the same ticket-content
  // saved in database.
  // 
  // In other words:
  // Before: Duplicate ticket-content will be saved in database
  // After : Avoid duplicate ticket-content in database
  $sql1='SELECT email FROM '.TICKET_TABLE.' 
         WHERE email='.db_input($var['email']).'
         AND name='.db_input(Format::striptags($var['name'])).'
         AND subject='.db_input(Format::striptags($var['subject'])).'
         AND phone="'.db_input(Format::striptags($var['phone'])).'"
         AND ip_address='.db_input($ipaddress).'        
         AND source='.db_input($source).'';

  $sql2='SELECT ticket_id FROM '.TICKET_MESSAGE_TABLE.' 
         WHERE message='.db_input(Format::striptags($var['message'])).'';

  $res1=db_query($sql1);
  $res2=db_query($sql2);

  if( ($res1 && db_num_rows($res1)) && ($res2 && db_num_rows($res2)) ) {
      $errors['err']="Data already exists in database!";
      return 0;
  }
  // Added by Masino Sinaga, April 13, 2009

From that code above, assuming that the duplicate content ticket are checked based on the same data in
- email
- name
- subject
- phone
- ip_address
- source

You may customize those parameters based on your needs. For example, if you want to avoid the “ip_address” of your client since this IP Address could be changed each time your client refresh or reload the thank you page (dynamic IP), then you may not use this “ip_address” and remove it from that SQL above.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images