The php script will reside on my website <[login to view URL]>
which is running a Linux Server, hosted by [login to view URL]
Theere will be no human intervention and
the php script will be running 24/7.
Customers will make a call to the php script on the website,
giving a parameter number, which defines the customised Book.
The script will use a file [[login to view URL]][1]
and will use this to create a customised ebook.
It will need three find/replace operations on the first page only.
After the edits, the .txt file will be passed to a text to pdf converter
and will generate a customised ebook in .pdf format.
The script will use the sample script provided
to generate two emails to specified email addresses,
in a particular format. Details follow...
## Deliverables
The first task is to examine the format of the call,
which should be of the form [[login to view URL]][2]
where NNNNN is a digital integer parameter. [eg. 1017]
The value of the parameter must be greater than 998 and
less than or equal to [[login to view URL]][3]
If the parameter is incorrect then give the message
"Incorrect Parameter" and abort.
Otherwise
Pull in first_name, last_name, active_email from a Screen.
[I will provide a working script which does most of this,
needing a few line edits only.]
Using the sample script, generate two emails in the correct format
Using the screen parameters first_name, last_name and active_email.
and send them to <joinatm@[login to view URL]> and <join2atm@[login to view URL]>
load the NNNNNN parameter into the key field book_number
in the MySQL database book_data and read in one record.
Examine the field book_flag in the MySQL database,
If it contains null then a customised ebook is required.
If it does not contain null, then a customised ebook already exists,
so simply reset the timer for the latest call [see later for this].
To generate a customised ebook:-
Pick up the text file [[login to view URL]][4],
which is the text file for the customised ebook.
make a copy called [login to view URL]
[where nnnnnn is the key field book_number in the database record].
On the first page only, find XXXXXX
and replace it by the field first_name in the database record.
On the first page only, find YYYYYY
and replace it by the field last_name in the database record.
On the first page only, find NNNNNN
and replace it by the field book_numberin the database record.
That concludes the edits needed to customise the ebook.
Now run the text to pdf utility form2pdf [which I will supply],
to generate a customised ebook called [login to view URL] [eg [login to view URL]]
This ebook will be temporarily stored in [[login to view URL]][5] -
for up to twelve hours, where it will be available for download.
Set up a twelve hour timer and
store it in the field book_flag in the MySQL database as [login to view URL]
Display a message
"Your ebook can be downloaded from ([[login to view URL]][5])
and the download will expire in twelve hours."
NB. In the event of multiple calls for the same ebook,
the field book_flag will be reset to a new 12 hour time for each call.
Continue monitoring the field book_flag and when the timer runs out
delete the customised ebook [[login to view URL]][5]
to save space on the server.
Reset the field book_flag in the MySQL database in the NNNNNN record to null.
End of script...