Jump to content

Custom page linked to a product purchased by a user


Amorcage

Recommended Posts

Hi 🙂

I need help for custom page 😞 I am sorry. I am French and it will not be easy to understand xD

1) I use WHMCS for server rental. And in this case, I would like to create a usage panel for users related to their purchased product.
2) I saw that each product was identified by an ID in the link (ex : ?action=productdetails&id=2)
3) I have already managed to create a basic custom page only for logged in members (/panel.php)
4) Each product on the customer area will be a server on our Proxmox platform
5) I want, on my "/panel.php" page, users can interact with our homemade API but "linked" to their product (style /panel.php?action=productdetails&id=2

**Ex : **
User1 have 2 products on their customer area (prod1 and prod2)
User2 have 1 product on their customer area (Prod3)

I want User1 to have his panel for his prod1 and a panel for his prod2
User2 has his panel for his prod3.
But user 2 must not have access to prod1 or prod2

Link to comment
Share on other sites

Why are you using a custom page instead of the server module's clientarea function to provide that information?   If you do not have access to the server module's code, then using an ClientAreaProductDetailsOutput hook would be your next best option .  That hook will provide the service ID as well as should prevent users from accessing other users services without duplicating that functionality in the custom page.  You then return HTML for any additional output you may want.  This works with any server module and using javascript you can move the output to any where on the page that is needed. 

 

Link to comment
Share on other sites

On 11/22/2021 at 10:01 PM, steven99 said:

Why are you using a custom page instead of the server module's clientarea function to provide that information?   If you do not have access to the server module's code, then using an ClientAreaProductDetailsOutput hook would be your next best option .  That hook will provide the service ID as well as should prevent users from accessing other users services without duplicating that functionality in the custom page.  You then return HTML for any additional output you may want.  This works with any server module and using javascript you can move the output to any where on the page that is needed. 

 

Hi 🙂
 

It seems to be better indeed to go through /clientarea.php 🙂

But how can I "secure" my API flows so that it does not launch on the client side (but rather on the PHP side)

Link to comment
Share on other sites

  • 1 month later...
On 11/26/2021 at 10:20 AM, Amorcage said:

But how can I "secure" my API flows so that it does not launch on the client side (but rather on the PHP side)

Not sure I understand what you mean.  All API code should be within PHP and none should be visible to the client . 

If, however, you mean you're adding PHP to template (.tpl) files and enabling smarty PHP handling, then you are barking up the wrong tree.   You should be following the MVC dev pattern of having a Model (database item object - not strictly required in WHMCS case), View (template files), and Controller (where actions are handled at).   No logic (PHP) goes in to the view part of MVC and the most that should go there is like ifs, loops, etc to get the info to display in a pretty way.   Have a look at the sample provisioning module for a basic example of MVC server module.  If you have not dealt with MVC before, I would recommend to read up on it to get the basics.

As an aside, the provisioning / server modules don't actually require a server.  I prefer to call those service or product modules because of this fact.  So for example, you could have a server module that's only job is to check the weather and output that to the client when viewing the service details.   

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • 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