Jump to content

twhiting9275

Member
  • Content Count

    1207
  • Joined

  • Last visited

  • Days Won

    17

twhiting9275 last won the day on February 9

twhiting9275 had the most liked content!

Community Reputation

51 Excellent

About twhiting9275

  • Rank
    Just Me

Recent Profile Visitors

7200 profile views
  1. Double check your code. Dependency files, everything. Try running them through a debugger 1 by 1. 10:1, if the upgrade function isn't working, it's because something, somewhere , is broken inside code, and it can't work. I've seen this way, way too many times over the years
  2. Just out of curiosity, when was the last time you were able to get DecryptPassword to work for passwords (not encrypted strings). I do believe something's changed in the last few releases, as it does not accurately decrypt passwords any more. At least where WHMCS is concerned. Don't have access to cPanel at the moment to test this It used to do this, but they've changed something, somewhere
  3. On the subject of customizing with things like 'location': It's important to understand that this is not reliable. This is why this was originally left out of the hook. IP location relies on third party services, and the IP owner, actually being up to date and honest. When it comes to location, outside of the US, not terribly accurate. Even inside of the US , it can be inaccurate . Hell, I just checked my own IP against some of the popular sites claiming to be accurate, about a 30% failure rate as far as accuracy goes This is another one of those points of failure and confusion.
  4. 'not that hard is subjective, and you didn't provide any information in your post at all. Again, it's not documented. I had to read through it a couple times, and I've been dealing with WHMCS for a number of years If the user has to do more than copy and paste something into a file, in today's world, you're going to run into issues, and of course, those are passed on to others, and make finding and resolving problems even harder. When it comes to things like this, follow the KISS principle (look it up), and you'll have fewer problems. More working parts, more components, more chances of breakage and confusion
  5. <?php /* Client area login notifications for WHMCS (works with versions 6-8) Created by whmcsguru Contributions by brian! */ use WHMCS\Database\Capsule; $myver = get_whmcs_version(); $isadmin = $_SESSION['adminid']; $admnotify = FALSE; //change this to true you want to send notifications when admin logged in.. //NOT advisable. this will let your clients know when you're logging into their account if (!empty($isadmin)) { if (!$admnotify) { return; } } function hook_client_login_notify($vars) { $mailsent=FALSE; global $myver; $myver = get_whmcs_version(); if ($myver < 8) { $userid = $vars['userid']; send_login_notify($userid); return; } if ($myver >= 8) { $user = $vars['user']; $userid = $user->id; //a dirty hack to try to work around a couple of things, maybe $acctowner = Capsule::table('tblusers_clients') ->where('auth_user_id', '=', $userid) ->where('owner', '=', 1) ->count(); $numrows = Capsule::table('tblusers_clients') ->where('auth_user_id', '=', $userid) ->count(); //we own our account. We must always notify us directly if ($acctowner > 0) { send_login_notify($userid); return; } //we don't own our account, so, notify the owner, if we only exist once. if ($numrows < 2) { foreach (Capsule::table('tblusers_clients')->WHERE('auth_user_id', '=', $userid)->get() as $userstuff){ $userid = $userstuff->auth_user_id; $clientid = $userstuff->client_id; $owner = $owner; if ($acctowner < 1) { send_login_notify($clientid, $userid); return; } } } return; } } function send_login_notify($myclient, $theuserid="") { global $myver; $ip = $_SERVER['REMOTE_ADDR'] ; $hostname = gethostbyaddr($ip); if ($myver < 8) { $clientinfo = Capsule::table('tblclients')->select('firstname', 'lastname')->WHERE('id', $myclient)->get(); foreach ($clientinfo as $clrow) { $firstname = $clrow->firstname; $lastname = $clrow->lastname; } } if ($myver >= 8) { $clientinfo = Capsule::table('tblusers')->select('first_name', 'last_name')->WHERE('id', $myclient)->get(); foreach ($clientinfo as $clrow) { $firstname = $clrow->first_name; $lastname = $clrow->last_name; } } $command = "sendemail"; $values["customtype"] = "general"; if (empty($theuserid)) { $values["customsubject"] = "Account Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p>Your account was recently successfully accessed by a remote user. If this was not you, please do contact us immediately<p>IP Address: $ip<br/>Hostname: $hostname<br />"; } elseif ($theuserid > 0) { $moreinfo = Capsule::table('tblusers')->select('first_name', 'last_name', 'email')->WHERE('id', $theuserid)->get(); //greet them foreach ($moreinfo as $userrow) { $ufirst = $userrow->first_name; $ulast = $userrow->last_name; $uemail = $userrow->email; } $values["customsubject"] = "Subaccount Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p> A subaccount of yours just logged in. Please see the details of the login below <p> Name: $ufirst $ulast Email: $uemail IP Address: $ip Hostname: $hostname<br />"; } $values["id"] = $myclient; $results = localAPI($command, $values); } if ($myver < 8) { add_hook('ClientLogin', 1, 'hook_client_login_notify'); } if ($myver >= 8) { add_hook('UserLogin', 1, 'hook_client_login_notify'); } function get_whmcs_version() { $theversion = Capsule::table('tblconfiguration')->where('setting', '=', 'Version')->value('value'); $retver = substr($theversion, 0,1); return ($retver); } Updated version! 1 - there was an issue with 7.x installs pulling the greeting name (thusly causing the notification to bail) . I had the wrong table / values used in the last update. This version corrects that, and I've tested on 7.x all the way up to 8.1. All good 2 - I added an admnotify bool . This is a quick way to test that this is working, or to send notifications if you're logged in as an admin user (really not recommended, as it'll let users know when you're logging into their account, and give them your ip address). As far as templating and the like: The reason I chose not to do this (could have , years ago) was to reduce the confusion and possible areas of issues. This way, all you have to do is drop the code into a file and you're done.
  6. Please create your own thread for your modifications, rather than diluting this one. As it is, yours is not documented, and will end up causing confusion, because of this I realize that you think you're trying to improve this, but this isn't helping at all. As posted, your modification does not work, while the hook I created can indeed simply be cut and pasted into a file and works as posted on 8.0 and 8.1.
  7. This does indeed work in both 8.0 and 8.1 . Just updated (was waiting on theme devs to release an 8.1 theme) If you're not seeing this working on 8.0 or 8.1, then something is up with your install, but the hook (as of my last update) works like a charm The most common issue is going to be you being logged in to the admin area. You'll need to be logged out entirely, or use a different browser to test this. Not sure on 7.0 yet, haven't been playing around in that beast for a bit. Will do some digging on that this afternoon, as Brian did mention it seems to not.
  8. This hook works just fine in 7 and 8.0. haven't tried 8.1 yet, but I'm sure there won't be that many issues, if any at all.
  9. You're going to need to be more specific here. What, precisely, do you want to add? The title is rather vague, so you need to provide details.
  10. Honestly? I'd say no. Put some proper protection in against password failures and you're good 🙂
  11. I would think this would only be limited by the encrypted size in the database
  12. If your DNS is hosted on your server, find the cPanel account it's in, and add ns1 and ns2.domain.com there, pointing to the appropriate IP addresses These should be 2 separate IP addresses If your DNS is hosted elsewhere (ie: cloudflare, stackpath, etc), then edit the domain there and do the same.
  13. An email address won't be the 'owner' of more than one account, or rather it shouldn't be... I'm unaware of any circumstance that this would be possible? Just checked again, to be absolutely, 100% sure , and mails fired off immediately, as long as I'm not running an admin session, hmmm. Nothing in your logs?
  14. Precisely, which is why I deliberately checked to see if they were an account owner, and if not, bailed. That said, I did a bit of work here, and once again (haha) reworked this a bit, so that it will kind of do what you want. This will notify the client of a subaccount logging in, if the following conditions are met A: The subaccount doesn't 'own' it's own account (who knows which account you're logging in for, right??) B: The subaccount doesn't have multiple subs (ie: isn't assigned to more than one client) I've tested this 5 ways from Sunday, and I believe this will work. I wasn't able to find any issues with it anyways. if you do, LMK and I'll do what I can to get it worked through. As usual, if an admin session is detected, the hook will bail (as it should). There are two separate emails that should be sent out now. One to the client, if they are logging in directly. One to the client if one of their subaccounts logs in Still nothing to directly notify subaccounts, but at least clients get notified when subaccounts login <?php /* Client area login notifications for WHMCS (works with versions 6-8) Created by whmcsguru Contributions by brian! */ use WHMCS\Database\Capsule; $myver = get_whmcs_version(); $isadmin = $_SESSION['adminid']; if (!empty($isadmin)) { //go no farther, get out of here.. No login notifications necessary return; } function hook_client_login_notify($vars) { $mailsent=FALSE; global $myver; $myver = get_whmcs_version(); if ($myver < 8) { $userid = $vars['userid']; send_login_notify($userid); } if ($myver >= 8) { $user = $vars['user']; $userid = $user->id; //a dirty hack to try to work around a couple of things, maybe $acctowner = Capsule::table('tblusers_clients') ->where('auth_user_id', '=', $userid) ->where('owner', '=', 1) ->count(); $numrows = Capsule::table('tblusers_clients') ->where('auth_user_id', '=', $userid) ->count(); //we own our account. We must always notify us directly if ($acctowner > 0) { send_login_notify($userid); return; } //we don't own our account, so, notify the owner, if we only exist once. if ($numrows < 2) { foreach (Capsule::table('tblusers_clients')->WHERE('auth_user_id', '=', $userid)->get() as $userstuff){ $userid = $userstuff->auth_user_id; $clientid = $userstuff->client_id; $owner = $owner; if ($acctowner < 1) { send_login_notify($clientid, $userid); return; } } } return; } } function send_login_notify($myclient, $theuserid="") { $ip = $_SERVER['REMOTE_ADDR'] ; $hostname = gethostbyaddr($ip); $clientinfo = Capsule::table('tblusers')->select('first_name', 'last_name')->WHERE('id', $myclient)->get(); //greet them foreach ($clientinfo as $clrow) { $firstname = $clrow->first_name; $lastname = $clrow->last_name; } $command = "sendemail"; $values["customtype"] = "general"; if (empty($theuserid)) { $values["customsubject"] = "Account Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p>Your account was recently successfully accessed by a remote user. If this was not you, please do contact us immediately<p>IP Address: $ip<br/>Hostname: $hostname<br />"; } elseif ($theuserid > 0) { $moreinfo = Capsule::table('tblusers')->select('first_name', 'last_name', 'email')->WHERE('id', $theuserid)->get(); //greet them foreach ($moreinfo as $userrow) { $ufirst = $userrow->first_name; $ulast = $userrow->last_name; $uemail = $userrow->email; } $values["customsubject"] = "Subaccount Login from $hostname"; $values["custommessage"] = "<p>Hello $firstname $lastname,<p> A subaccount of yours just logged in. Please see the details of the login below <p> Name: $ufirst $ulast Email: $uemail IP Address: $ip Hostname: $hostname<br />"; } $values["id"] = $myclient; $results = localAPI($command, $values); } function get_whmcs_version() { $theversion = Capsule::table('tblconfiguration')->where('setting', '=', 'Version')->value('value'); $retver = substr($theversion, 0,1); return ($retver); } if ($myver < 8) { add_hook('ClientLogin', 1, 'hook_client_login_notify'); } if ($myver >= 8) { add_hook('UserLogin', 1, 'hook_client_login_notify'); }
  15. That article pretty well sums it up. An active client is a client with an active product, service, or domain. As for your new client? Perhaps this is something determined by cron, as in, if the client hasn't ordered something in X days, they are considered inactive.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated