I have a need for a notification system

IanBlackford

New member
Joined
May 31, 2013
Messages
2
Hi,

Really sorry if this is in the wrong place, but I think it's something that can be solved with the API. However, if you reply to this please understand that I know nothing about the structure of the DA code, or files or how it all works. I have a reseller account and I can operate DA, but my knowledge does not extend very far after that. Please treat me as a complete novice.

Here is what I want to achieve, I want to be notified every year on the anniversary of setting up an account, so if I set up an account today, I want to have an email sent to me in 12months (then 24months, then 36 months etc) reminding me to invoice the client for their hosting. I was hoping this would be a core feature in DA but it seems that it isn't, so I started looking at the API to see if I could work something out for myself, but I'm not that good I'm afraid which is why I'm turning to the forum for some guidance.

It seems that other people have wanted something similar to this, but they have talked about a billing plugin. I don't want that, I have my accounts package for invoicing, I just need a reminder to generate my invoice.

So I was thinking, is there a way of running a daily cron job to look up the creation date of an account? If so - how do I construct that via the API?

I found this example:

<?php

include 'httpsocket.php';

$sock = new HTTPSocket;

$sock->connect('domain',2222);
$sock->set_login('un','pw');

$sock->query('/CMD_API_SHOW_ALL_USERS');
$result = $sock->fetch_parsed_body();

print_r($result);

?>

Which I thought might start me off, but I don't know how to put it into practice. I understand how to add my domain, UN and PW into the above, but where do I save the file and how do I call it.

Of course that might be not the place to start, so I'd appreciate a little help if possible.

I know what i want but maybe I haven't explained myself very well, if you are confused please reply and I'll try and make it clearer.

Thanks in advance.

Ian
 
Hello Ian,

Did you check this: http://www.directadmin.com/api.html ?

but where do I save the file and how do I call it.

Let's say, you've got your own example.com domain added into directadmin, so you should create an empty file somewhere in example.com/public_html/, for example:

example.com/public_html/cron/script.php

Then you add your code into the file and save. You can use either FTP client or DirectAdmin File Manager for the purposes.
Remember to put near to the script httpsocket.php file.

After that, you can trigger your script in a browser:

http://www.example.com/cron/script.php

Then you create a cronjob in Directadmin, something like the following

Code:
30 3 * * * /usr/bin/wget -O /dev/null http://www.example.com/cron/script.php >/dev/null 2>&1

to run it every night.

Note, you might need to limit access to the script by listing allowed IPs in a proper syntax in example.com/public_html/cron/.htaccess

And of course you should modify example.com/public_html/cron/script.php to fit your needs.

p.s. Some of use here offer commercial services, including coding and script-writing. Please feel free to send a PM to one of us (me as well) if you are interested.
 
Or even bite the bullet and buy some billing software, everything will be automated then. I know you said you do not want this path, but when client bases grow....
 
Thanks for your replies, I'll reply to both of you here:

Alex, I have looked at the API pages and I'm confused by it all. That's where I got the sample code from which I posted above. I understand about uploading it, but when I do it errors on the first line where it tires to include a file. That's logical as I haven't told it where the file is, which made me think that code like that should be hosted in the DA install - hence my question about where to save the file and how to call it.

Peter, I've been looking around at other billing software, I already have Sage which is fine except it doesn't do recurring invoices.

So coming back to my original need which is a simple notification system at the 12month point of the account, do you think this is an easy task to solve? Is it that DA store the account details in a MySQL database and all I would need to to is write a PHP script to read the data field of all the records in my account and email me a reminder?


Further to this, I 'might' have found a solution just now... there is a service called followupthen.com which is simple and amazing. Just create an email and send it to them like this: [email protected] or [email protected] and on that time and date they send the email back to you.

I've just tested the DA account set up, and it seems you can chain emails in the email field with a comma. So I can just add a @followupthen.com email and set it for a years time (recurring) and I will get a reminder in 12months.

It's a bit of a 'hack' I agree but until something better comes along....

I'd still like to get a proper solution to this, so I'm still very interested in your advice on the API method - and billing software ideas.

Thanks once again

Ian
 
I've just tested the DA account set up, and it seems you can chain emails in the email field with a comma. So I can just add a @followupthen.com email and set it for a years time (recurring) and I will get a reminder in 12months.

I wouldn't want 3rd party services to get emails with account credentials...

do you think this is an easy task to solve

Yes, I do. I've already done a similar plugin for one of my customer.

Is it that DA store the account details in a MySQL database and all I would need to to is write a PHP script to read the data field of all the records in my account and email me a reminder?

Directadmin stores user's data in text files on HDD, you can read them, as they contain Date of Account Creation directly or via API.
 
Back
Top