Technology Software

How to Create a Script to Access CPanel

    • 1). Open a new Notepad file or an equivalent basic text program and name it something like cPanelscript.php.

    • 2). Create the opening "<?" and closing "?>" tags to let the server know that you are writing a PHP script.

    • 3). Use the "Class" command to create a new working class and name it something similar to cPanel Script. Put the opening "{" symbol after the name to indicate the beginning of the functions of the new class. Add in new variables using the "Var" command to hold values for your cPanel user name, password, port number, domain name, and root directory. Name them according to their uses and set their initial values to NULL by typing out code that looks like "var $cPanel password = "":"

    • 4). Add a new function and pass all of the previously made variables to it by typing out a line of code similar to "function AccessCpanel($cPanelPassword, $cPanelPortNumber, $UserName)." Use the "This" command to show the file path to follow to access the various web page information in cPanel by typing out "$this->cPanelRootDrive ="http://".$this->cPanelNameofDomain.";"

    • 5). Make a second function to drill down to a specific page and display the information on it using the "sprintF" command. Pass a new variable to the function that includes the specific page file path found in the previously created function.

    • 6). Insert a final function to pull the data logs that cPanel looks at to compile it's information but do not pass any variables to it. Use the "This" command again to retrieve a full listing of the data logs available by typing out "this->fetchPage("data/index.html")" Finish the class off by returning the data found in the listing.

Leave a reply