Jump to content
micke salloum

Change the Ticket No to numbers instead of letters

Recommended Posts

Hi Everyone

I am using the OSC-SupportTicket System 1.2 for 2.3.4BS addon witn my 2.3.4 oscommerce and it works fine. I just want to change the Ticket No to numbers instead of characters. Currently when a ticket is generated the Ticket No. is something like 5z9Q5g8b2m4d1S and I would like it to be a 6 digits number such as 300100 and so on. Any help is appreciated. I attach the file that creates the support ticket

ticket no.jpg

ticket_create.php

Edited by micke salloum

Share this post


Link to post
Share on other sites

You are more likly to get an answer if you post in the add-on's support thread.

Support thread at http://forums.oscommerce.com/topic/410223-tickethelpsupport-system/

Make sure to backup first! Please backup first!!!!

Try this, Find around line 109

 $ticket_link_id = '';
      for ($x=3;$x<10;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'chars');

    }

abd replace with tis

 

 $ticket_link_id = '';
      for ($x=3;$x<7;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'integer');
      }

 

Edited by JcMagpie

 

Share this post


Link to post
Share on other sites

I don't think that's a good idea. Putting numbers increases the risk of indiscretion. It will be easy to try to look at tickets that have smaller numbers.
That said, I do not know the addon, there may be a security that verifies if the ticket number belongs to the customer.


Get the latest Responsive osCommerce CE (community edition) here .

(Live   : OsC 2.2, php 5.4 & UTF-8  |  Local : Phoenix for future shop)

Share this post


Link to post
Share on other sites
On 9/5/2018 at 3:03 PM, JcMagpie said:

You are more likly to get an answer if you post in the add-on's support thread.

Support thread at http://forums.oscommerce.com/topic/410223-tickethelpsupport-system/

Make sure to backup first! Please backup first!!!!

Try this, Find around line 109

 $ticket_link_id = '';
      for ($x=3;$x<10;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'chars');

    }

abd replace with tis

 

 $ticket_link_id = '';
      for ($x=3;$x<7;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'integer');
      }

 

Thanks a lot for the advice. I tried to change the code and the new ticket no. that was generated is 6J2r9E6C. I tried to generate one more ticket and the ticket no. was 662y9b6S. So the way the ticket no. is generated has changed but not as I want it. I want the ticket no. to simply be 6 digitats (such as 300100)

Share this post


Link to post
Share on other sites

Try,

 

$ticket_link_id = '';
      for ($x=0;$x<5;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'integer');
      }

 


 

Share this post


Link to post
Share on other sites

The ticket ID is generated by as you see it's looks to be derived from $time to try and make it individual.

 // generate LInkID
      $time = time();
      $ticket_link_id = '';
      for ($x=3;$x<10;$x++) {
        $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'chars');
      }

 

You could simply replace with a new function  that will produce a 6 digit random number, the echo is just for testing!

<?php
    function generateRandomString()  {
        $digits = '1234567890';
        $randomString = '';
        for ($i = 0; $i < 6; $i++) {
            $randomString .= $digits[rand(0, strlen($digits) - 1)];
        }
        return $randomString;
    }
    
    echo generateRandomString();


 

Share this post


Link to post
Share on other sites

test the code and see if it works for you, but this will give you a 6 digit number.

 

<?php
$time = time();
      $ticket_link_id = '';
      for ($x=3;$x<10;$x++) {
        $ticket_link_id .= substr($time,$x,1);
      }

http://sandbox.onlinephpfunctions.com/code/be738f60d027fdab32d5bae693390f06072f4205


 

Share this post


Link to post
Share on other sites
On 9/7/2018 at 3:02 PM, JcMagpie said:

test the code and see if it works for you, but this will give you a 6 digit number.

 

<?php
$time = time();
      $ticket_link_id = '';
      for ($x=3;$x<10;$x++) {
        $ticket_link_id .= substr($time,$x,1);
      }

http://sandbox.onlinephpfunctions.com/code/be738f60d027fdab32d5bae693390f06072f4205

Thanks a lot for this. It worked and it generated a 7 digits number instead of 6 digits ID. I changed for ($x=3;$x<10;$x++) { to for ($x=3;$x<9;$x++) { and now it generates a 6 digits ID

 

Is it possible to get the ticket number to generate an increment ID instead of random? Like 300100 and then 300101, 300102 etc.

Thanks in advance

Edited by micke salloum

Share this post


Link to post
Share on other sites
10 hours ago, micke salloum said:

Is it possible to get the ticket number to generate an increment ID instead of random? Like 300100 and then 300101, 300102 etc.

Now you're asking for something totally different. The best way to handle sequential numbers is to have a table holding the tickets, with an autoincrement key field for that ID. Presumably there's a table already involved here, somewhere. You could also do it with a file holding the ID, which would be incremented and written back, but that's a lot more complicated coding to ensure atomic operations.

By the way, the solutions given already in this thread are not safe. There's no guarantee that two tickets can't end up with the same "random" ID number, unless you check it against all existing ticket numbers. You would be better off using an autoincremented field value -- at least, you could guarantee that it's unique. A hash of some unique string (such as the customer name and address) might also be suitable.

Share this post


Link to post
Share on other sites

😂 Yep!  Technically true It’s already been pointed out to @micke salloum 

 

@micke salloum if you still plan to use this then perhaps you can try and mitigate the chance that 2 people will genrate the same time stamp to within a second

by using this insted?  😂 . microtime() returns the current Unix timestamp with microseconds.

 

As I don’t use this addon I have no idea what security issues if any this will pose.

$microtime = time();
      $ticket_link_id = '';
      for ($x=4;$x<10;$x++) {
        $ticket_link_id .= substr($microtime,$x,1);
      }


 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×