Looking for help converting a XojoScript to PHP

I have a XojoScript that I have been using in an in-house tool to generate serial numbers for one of my products. This has worked well, but requires me to manually handle each user purchase.

I have been trying to learn PHP so that I can have an automated script that my payment processor can ping to generate the code and send it directly to the user. I have ported my XojoScript code to PHP and the PHP script executes and generates a code, but it does not validate as a valid code. So, obviously, I have introduced a bug into my code or there is some nuance of PHP that doesn’t port directly from Xojo that I am missing. I have been through my code many, many times and cannot find the error.

I am hopeful that someone much more familiar with PHP that I might be willing to look at my original Xojo code and my PHP port and possibly tell me where I’ve gone off the rails.

Obviously, I don’t want to share out my serial number algorithm, so I’m make a couple of key changes to the code before sharing, but I’ll keep the basic logic the same so I can easily convert back.

I’m mostly looking for a code review. I’m not looking to change my logic or method of generating the serial number (it’s not like it’s super secret as it is based on a method detailed in an old issue of RBDeveloper magazine).

I’m not looking for freebie work either. I am willing to pay someone for their assistance, if need be.

Thank you!

Your saying, you have the logic in your xojo app that determines if a code is valid… but… when PHP generates the code, your application doesn’t see it as valid?

If I understand you correctly?

Which in that case, it would mean the PHP code isn’t generating it in the same way.

Would need some sample that shows how the xojo app would be generating it… so that I would have some type of idea as to what to write in PHP.

You can send it my way, since I am a PHP guy… But, I won’t get a chance to look at it until probably late tonight EST time…

Post both codes.

Have you considered using Xojo Web?

Our registration/activation system is a Xojo Web application, so the code is identical to what we use in our Xojo based applications.

It can be frustrating at times, since my last escapade, I’ve devised a good protocol for updating my web app and have been working with it quite happily today (apart from having the wrong access to the database).

Xojo web is indeed an excellent solution. Although I recently found the limits of my Xojo Web based delivery by download I had since 2013, as my latest Windows apps are around 60 Mb. The WebFile simply crashed. So I had to resort again to Php with Passthru. The bulk of the program is still Xojo Web, I simply pass control to the script only for the actual download.

Hi Scott,

This is a long-shot, but I was having the same problem a while back and the culprit turned out to be the XOJO Chr() function. Here is some PHP code that better emulates XOJO’s implementation. I hope this helps:

function xojo_chr($n){ //this emulates the behavior of XOJO chr() function //If the number is >256, XOJO prefixes with the number of wraparounds $ret=""; if ($n>256){ //prefix with the number of wraps: chr(n\\256) then chr(n mod 256) $ret = chr(intval($n/256)) . chr($n % 256); }else{ $ret = chr($n) ; } return $ret; }

[quote=318007:@Sam Rowlands]Have you considered using Xojo Web?

Our registration/activation system is a Xojo Web application, so the code is identical to what we use in our Xojo based applications.

It can be frustrating at times, since my last escapade, I’ve devised a good protocol for updating my web app and have been working with it quite happily today (apart from having the wrong access to the database).[/quote]

I would love to use Xojo web, but my hosting provider does not support it. I also haven’t been able to find a reasonably priced hosting provider that does.

[quote=317988:@Don VF]Your saying, you have the logic in your xojo app that determines if a code is valid… but… when PHP generates the code, your application doesn’t see it as valid?

If I understand you correctly?

Which in that case, it would mean the PHP code isn’t generating it in the same way.[/quote]

This is exactly the problem.

Unfortunately, using your modified Chr() function is not, by itself, the solution. Thank you for the advice though!

Thank you everyone for your responses!

Another member of this forum reached out to me privately and helped me figure out where I went wrong. I was getting confused between Xojo’s 1-based string functions and PHP’s 0-based string functions.

Again, I do appreciate the responses!