micke salloum Posted September 5, 2018 Share Posted September 5, 2018 (edited) 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_create.php Edited September 5, 2018 by micke salloum Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 5, 2018 Share Posted September 5, 2018 (edited) You are more likly to get an answer if you post in the add-on's support thread. Support thread at http://www.oscommerce.com/forums/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 September 5, 2018 by JcMagpie Quote Link to comment Share on other sites More sharing options...
bonbec Posted September 5, 2018 Share Posted September 5, 2018 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. Quote with OsC 2.2 since 2006 ... Link to comment Share on other sites More sharing options...
micke salloum Posted September 7, 2018 Author Share Posted September 7, 2018 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://www.oscommerce.com/forums/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) Quote Link to comment Share on other sites More sharing options...
micke salloum Posted September 7, 2018 Author Share Posted September 7, 2018 The support thread http://www.oscommerce.com/forums/topic/410223-tickethelpsupport-system/ is archived and thereby i was not able to submit the question there Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 7, 2018 Share Posted September 7, 2018 Try, $ticket_link_id = ''; for ($x=0;$x<5;$x++) { $ticket_link_id .= substr($time,$x,1) . tep_create_random_value(1, $type = 'integer'); } Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 7, 2018 Share Posted September 7, 2018 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(); Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 7, 2018 Share Posted September 7, 2018 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 Quote Link to comment Share on other sites More sharing options...
micke salloum Posted September 10, 2018 Author Share Posted September 10, 2018 (edited) 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 September 10, 2018 by micke salloum Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 10, 2018 Share Posted September 10, 2018 use for ($x=4;$x<10;$x++) Quote Link to comment Share on other sites More sharing options...
MrPhil Posted September 10, 2018 Share Posted September 10, 2018 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. Quote Link to comment Share on other sites More sharing options...
♥JcMagpie Posted September 10, 2018 Share Posted September 10, 2018 😂 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); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.