Running a self-serve "web-version" of a PC-based code generating program

Hello Experts... I wonder if this can be done. I've developed an application in Delphi programming language, and in order for users to activate the demo of it, they need to get an activation code (...long story as to why). Anyway, the code generator program is a local Windows software that I have on my computer ("Code-Lock")... but I'm wondering instead of me being occupied with sending out activation codes to users, is there some way I can "automate" this and let the users go to a website and get their own code - everybody wins this way.
   Ideally, I'd like to tell my demo users to go to a very simple webpage that lets them enter only 2 things - a computer-specific code that my demo generates on their system, and a "Username" that they just make up. So just 2 fields. They could just click a "Submit" button to send these two fields to a "web version" of my "Code-Lock" code-generating program (see screenshot attached), then an activation code is generated for them, and sent back to the webpage and displayed to them.
   In the attached screenshot of the code-generating program ("Code-Lock"), the 2 items they would submit are the ones circled in green - these items would need to be plopped into the appropriate fields in Code-Lock, then the items circled in red would be filled in automatically (they always remain constant). Then the "Generate Key" button would need to be invoked with the resulting activation code being shown in the area circled in yellow. My hope is that all this could be done invisibly to the user, and then the final activation code from the yellow circled area could be displayed on the webpage to the user.
   A lot to ask, and maybe it's just not possible... what do you think?

Thanks!
    Shawn
codelock-sshot.JPG
shawn857Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shawn857Author Commented:
Please note, an update to this: I just discovered that my "Code-Lock" Windows app has a command-line version:

Code-LockKeygen.exe  Program Code|User Data|Name of User|Filename|60 Days Protection Option

All the necessary parameters can be "piped" into that .exe. That should make things quite a bit simpler, no?

Thanks!
   Shawn
0
Terry WoodsIT GuruCommented:
It should be a cinch for a web developer to put this together, given a web server with access to run the .exe file. PHP can be configured to do this.

Would there be any limit on how may codes were generated? Do you have a website already? If so, what web server software does it use? eg apache or IIS?
0
shawn857Author Commented:
Thanks Terry, I've learned a few things since I posted this question. Mainly, that my exe file also comes in ActiveX DLL form, along with PHP scripts to execute it (...only found this out after I posted, it's amazing what you can find out if you just read the documentation more closely). In the docs, it says the DLL can be invoked in 1 of 2 ways:

(1) On a IIS server with PHP;
(2) On a Windows server with ASP script;

... with accompanying code examples for each. After discovering this, I thought I had it made. But being totally naive to all of this web development stuff, I tried setting up my webhost (Linux) with the scripts and DLL. Ran it and of course it wouldn't run the DLL. My webhost told me I would need a Windows server to run it. So the last couple of days I've been spending finding a budget-priced Windows server to run just this. I found one yesterday (M2Host.com) and they assured me it would work no problem. So I signed up today  and of course, it wouldn't work. Their tech staff is trying to figure out why and are going to get back to me.
   So it looks like I've got a handle on it, hopefully. But along the way I've learned that this *may* also run on a Linux server (which my webhost already is) that has something called "Turnkey ASP NET". I don't know if this requires that the DLL is originally written in .NET or not. I'm pretty sure it wasn't, as I purchased it about 10 years ago - I think it was created in Visual Basic. Do you have anything you can add, or any thoughts?

Thanks!
    Shawn
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Terry WoodsIT GuruCommented:
Just that PHP & Apache can run on a windows server. PHP can run an .exe file I believe, so that would allow you to use the .exe version to provide the code. Not sure about using DLL's though, sorry.
0
shawn857Author Commented:
So it's not possible to run the windows .exe file somehow on a Linux server then?

Thanks
   Shawn
0
Terry WoodsIT GuruCommented:
Not the .exe, no. You can install "WINE" to linux, but if I understand correctly doing that involves essentially installing Windows to a virtual server running within Linux, so it's probably not much different to just using a Windows box in the first place.
0
shawn857Author Commented:
OK, thanks. Terry, here is an update as to where I'm at now: my new Windows server host M2Host.com say they can't run my script/DLL and insist it's a coding error on my end. I am stumped. To test, I made the simplest, most bare bones of a PHP file to try this... using example code straight from the documentation that came with my DLL:


<?php
$objKG = new COM("CodeLockKeyGen.KeyGen");
$result = $objKG->Get_RegistrationCode("12345678", "ED3E78BDB99C15A36DB6746B9966B6ECCFF62E8202EEB9956DC83B7F15C4AF00", "ChosenBytes", "RegFile - ChosenBytes.txt", True);
echo $result;
?>

It keeps giving me "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed."

Terry, if I could send you the DLL file privately, do you think you would be able to test it for me on your end?  (provided you have access to a Windows server). I'd prefer not to attach it to this message for the whole world to have free access to it.

Thank you
    Shawn
0
Terry WoodsIT GuruCommented:
I don't have access to a windows server suitable for testing, sorry.

An internal server error gives you more detail in the error log for the web server generally. Is it running Apache? If so, see if you can get access to the apache error log, and see what the error is.

Also, if you want to do a "Hello world" test just to make sure php is working, then change the script to:
<?php
die("Hello world");

Open in new window

to ensure that at least that much is working.
0
shawn857Author Commented:
Yep I did do the "hello world" simple test Terry, and it does work, so we know at least that PHP works. The host I'm using is a Windows server... I thought Apache was a Linux thing? Sorry, I know very little about this stuff.
   I can check the error log, but I'm not sure where to look. This windows server comes with a Plesk control panel... would it be somewhere in there?

Thanks
   Shawn
0
Terry WoodsIT GuruCommented:
On Windows, you are still running a web server to serve the web content. This could be Apache or IIS. It's the web server that's running PHP, and then returning an internal server error. That error looks familiar as an Apache error, but maybe IIS produces something similar?

Yes, you could try to find an error log from plesk, and look for an error that appears time stamped with the time that the error 500 was generated.
0
shawn857Author Commented:
I couldn't find any error log in Plesk - this is all new to me, that's why I came her for guidance... this is all ready to about drive me to the looney bin. I've given up on the idea of getting the DLL to work... there is also a command-line EXE that I have that would suffice. You had mentioned earlier that the PHP to run the command line EXE would be a snap... can you help me with that? I can run the command line EXE fine here on my PC in a .BAT file, so I tried to translate that over to a PHP script but it's not working. I think it;s getting messed up on the double-quotes within my command string and arguments string. My BAT file looked like this:

CodeLockKeygenCMD.exe "12345678|ED3E78BDB99C15A36DB6746B9966B6ECCFF62E8202EEB9956DC83B7F15C4AF00|ChosenBytes|reg4.txt|1"

Open in new window


You'll note that the whole argument string (there are 5 arguments that are pipe-delimited), has to be surrounded by double-quotes. The reg4.txt parameter is the filename where the output goes - the output does not get echoed back to the screen. In PHP exec, the whole command string plus the arguments needs to be surrounded by double-quotes, so I think it's getting messed up there. I'm not handing the double-quotes right in the exec or shell_exec command I guess.
  I have some HTML tracing commands in my PHP file (ie. "I am here", etc) and In my numerous trials, the output shows my trace commands before and after the call to exec... so it does pass through my exec command, but my reg4.txt output file doesn't get created. Or if it does get created, I don't know where it's putting it in the directory structure. This is all driving me crazy...

Thanks
   Shawn
0
Terry WoodsIT GuruCommented:
To run the .exe from php try using this:
http://php.net/manual/en/function.exec.php

Note that even though the code is pretty simple, there is a chance that Apache is configured to disallow running of exe files depending on the directory. There's a note on a safe mode at the above link. To test, you could change the command to just 'dir' to see what you get.

eg something like this
<?php
$command = 'CodeLockKeygenCMD.exe "12345678|ED3E78BDB99C15A36DB6746B9966B6ECCFF62E8202EEB9956DC83B7F15C4AF00|ChosenBytes|reg4.txt|1"';
exec($command, $results, $status);
print "Results:";
print_r($results);
print "Status: $status";

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.