Portal Home > Knowledgebase > Articles Database > Trying to create a simple PHP script, help please


Trying to create a simple PHP script, help please




Posted by zildjian2000, 12-31-2007, 07:05 PM
I'm trying to make a pretty simple PHP script. I need the ablity to create websites from my blackberry. I can currently do it, however, I have to use three different things and would like to make it one easy step. Here's what I do Use Setup Account Script SSH to the server and use wget and unzip functions Use script to send email out I would like the ablity to do all of this from one PHP script though, or at least, eliminate the need of using SSH. Here's what I need the script to do 1. Create a cPanel Account (I already got a script for this, so this part shouldn't be too hard to intergrate) 2. wget a file from another server and unzip it. The file will be named www so all that needs to happen is for the script to grab the file from the other server and place it in the new account's directoy and then unzip it 3. Send a pre-set email out (I already setup this part, so that shouldn't be much trouble) If it is possible, what I would love the script to also do is to put the domain into a common file the website has. So I guess what my question is: How do I write a php file so that it will grab files from another server, put them in the right folder on my server, and then unzip them? And, if possible, how would I write it so that it inserts a domain name into the common file? Each script would need the same values (e.g. domain, username, etc.) so I'm really trying to make them into one.

Posted by Rich, 01-01-2008, 10:05 PM
This would probably be better suited for the Employment offers/requests forum, but I'll give you some direction here. Look into PHP's built in FTP functions (http://us.php.net/ftp). Using the examples there, you should be able to write a PHP script that can connect, fetch and place any files you need. If I'm understanding you correctly, fwrite() should help you write to your common file.

Posted by foobic, 01-01-2008, 10:35 PM
Alternatively, since you're already using shell commands to fetch and unzip the file, you could just write a little bash script based on your history to automate this, eg.

Posted by zildjian2000, 01-02-2008, 03:43 AM
Rich: I'm not asking for someone to write the script and send it to me, but rather send me in the right direction/give me advice. I could pay to have someone write the script, and I may end up doing that, but in the long run it's a lot better if I get a feel for PHP seeing as I am a web host and it is a big part of web hosting. Anyway, thank you for your advice, I will look at those links foobic: Thank you for that, however, I am a bit lost on what you said. I only know a bit about PHP (I know that $domain for instance is a value that I would set prior to that and whenever I say $domain it will use that value.) I have modified scripts before to my needs using the information I found in the code to write it, but my point is, even though I know some, a lot of it is very foreign to me. Could you explain a little bit more on what some of those values mean, e.g. what is bash? So you can run SSH commands through PHP?

Posted by foobic, 01-02-2008, 04:40 AM
No offense intended, but I think you need to do a bit more research before asking for such basic information. You could start with these. http://www.google.com/search?q=bash+...cript+tutorial http://au2.php.net/manual/en/function.shell-exec.php

Posted by isurus, 01-03-2008, 04:28 AM
Hello, Is this data identical for all new accounts? eg a holding page? If so, save some scripting and use the skel directory: http://hosting.mixcat.com/docs/cpane...-directory.htm If the only thing that differs is that you have want to display the domain name then write the holding page so that it determines the domain name automatically.

Posted by zildjian2000, 01-03-2008, 07:31 PM
Unfortunetly it isn't the same for each new account. I sell multiple different websites and when I sell a website I want to tell it to grab one of the websites (I would have multiple different scripts, one for each page) and bring it over to that account. Also, you said that I can set the page to say the domain name. Is that possible to do for any file? Because when I bring the files over it would be awesome if they would work based on what domain they were on Or, is it possible to use the PHP script to write other files?

Posted by isurus, 01-04-2008, 08:03 AM
They would have to be files that are parsed on the server - eg php files. (You can configure your server so that it will treat .html files (etc) as php files too if you need to, but this will increase your server load). To get the host name use $_SERVER['HTTP_HOST'], for example: See http://www.php.net/reserved.variables for more details. Rich already gave you a pointer for this: the php function fwrite(). I think that it is good that you are interested in learning about PHP, but this script needs to be written very carefully to avoid leaving any security holes - it is dealing with account creation etc. Your business would suffer from an enormous loss of face if a malicious user found a hole in your script and used it to overwrite your existing customer's sites (for example). I suggest that you hire an experienced coder to write this for you, and learn more about php with some less security-sensitive scripts to start with.

Posted by zildjian2000, 01-05-2008, 05:37 PM
I actually wouldn't mind paying someone to do it, I even put a request in the scripts section, but no one has replied to it. So I also had this thread so I could do it myself if no one responded. Plus, what I need to do is pretty simple. I have the account creation script, I have the email script, I just need to put them together and have a script that runs SSH commands.

Posted by isurus, 01-07-2008, 10:23 AM
Then I guess that I'd better do it myself Have PMed you.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Namecheap (Views: 672)
Nexpoint Down (Views: 682)
Hudsondigital down (Views: 650)

Language: