Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

Add new user usign PHP and API issue

Questions regarding the API
Application Programming Interface
Locked
  • Print view
Advanced search
8 posts • Page 1 of 1
www.rinku31
Posts: 21
Joined: Thu Jun 04, 2015 9:22 am

Add new user usign PHP and API issue

Post by www.rinku31 » Wed Mar 02, 2016 7:30 pm

Hi

I want to provide free web hosting but single domain per user name and email address. so i created a package called Free. using free package, we can add only single domain.

when i add a new user using PHP and API, then it checks only user name. if user name exit, it returns already exit (error 4) otherwise it adds new user.

BUT similarly i want to check email id. i mean, if email id of new user already present with any already registered user name, then it should return "user exit code 4". but it adds new user name without checking email id.

That is my problem. How we can fix it?

I want to check user name and email id both. if both available then a user can register otherwise he should visit already exit.

in other world, a user name must have unique email id.

Please help.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Add new user usign PHP and API issue

Post by tjebbeke » Thu Mar 03, 2016 8:33 am

It isn't easy to change this. You need to change some code for this. I suggest you build a website with database and save there all the usernames, emails, etc. to check if the username and email already exist.
Top

www.rinku31
Posts: 21
Joined: Thu Jun 04, 2015 9:22 am

Re: Add new user usign PHP and API issue

Post by www.rinku31 » Thu Mar 03, 2016 1:54 pm

This is nice think but i will provide vestacp login details so they can easily change email id.

can you please help, i want to disable email change feature similar like user name.

we can not change user name. i also want to disable email change feature?

where i need to hide email field when you use click on edit for user, then it should not display email field.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Add new user usign PHP and API issue

Post by tjebbeke » Thu Mar 03, 2016 9:55 pm

You can edit the source code, the source code is available on Github: https://github.com/serghey-rodin/vesta and you can find it in /user/local/vesta. The web folder is the UI part There you can try to disable the email field.
Top

www.rinku31
Posts: 21
Joined: Thu Jun 04, 2015 9:22 am

Re: Add new user usign PHP and API issue

Post by www.rinku31 » Fri Mar 04, 2016 5:34 am

I think i need to update this:

Code: Select all

  // Change contact email
    if (($v_email != $_POST['v_email']) && (empty($_SESSION['error_msg']))) {
        if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
            $_SESSION['error_msg'] = __('Please enter valid email address.');
        } else {
            $v_email = escapeshellarg($_POST['v_email']);
            exec (VESTA_CMD."v-change-user-contact ".escapeshellarg($v_username)." ".$v_email, $output, $return_var);
            check_return_code($return_var,$output);
            unset($output);
        }
    }
With

Code: Select all

  // Change contact email
    if (($v_email != $_POST['v_email']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
        if (!filter_var($_POST['v_email'], FILTER_VALIDATE_EMAIL)) {
            $_SESSION['error_msg'] = __('Please enter valid email address.');
        } else {
            $v_email = escapeshellarg($_POST['v_email']);
            exec (VESTA_CMD."v-change-user-contact ".escapeshellarg($v_username)." ".$v_email, $output, $return_var);
            check_return_code($return_var,$output);
            unset($output);
        }
    }
I added && ($_SESSION['user'] == 'admin') so only admin can change email.

Also i added disabled in edit_user.html file for email field.

Thank you for your help. i think now it is working according my need.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: Add new user usign PHP and API issue

Post by tjebbeke » Fri Mar 04, 2016 5:17 pm

The only problem you now have is when there is a new vesta update.
Top

www.rinku31
Posts: 21
Joined: Thu Jun 04, 2015 9:22 am

Re: Add new user usign PHP and API issue

Post by www.rinku31 » Fri Mar 04, 2016 5:27 pm

Yes i have disabled auto update. i will update and just after i will update these files again.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Add new user usign PHP and API issue

Post by skurudo » Fri Sep 23, 2016 12:36 pm

API documentation and examples:
http://vestacp.com/docs/API.pdf

CLI commands list and descriptions:
http://vestacp.com/docs/CLI.txt

-> viewtopic.php?f=18&t=12610
Top


Locked
  • Print view

8 posts • Page 1 of 1

Return to “Scripting / API”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password