Forum Moderators: coopster & phranque

Message Too Old, No Replies

How to Create Subdomains with CGI / Perl?

Urgently needed due to abundant production of subdomains.

         

daowl

10:51 am on Jun 13, 2006 (gmt 0)

10+ Year Member



I need to create a large amount of subdomains, and I mean a large amount, and I can not get access to a SSH Telnet.

So, how do I get these create via CGI / Perl?

I have over 10,000 to produce, so it is needed to get done this way, so if anyone can help me it would be definitely appreciated! :-)

texmex

7:42 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



Do you REALLY mean subdomains. If so this is a DNS issue, and not something you'd do in perl. You need direct access to the DNS server responsible for your main domain, and then add the entries for the subdomains.

Or do you mean subdirectories from the root of your web. In which case the command you're looking for is mkdir

daowl

9:35 am on Jun 19, 2006 (gmt 0)

10+ Year Member



I know how to MKDIR in the web site.... But how would we find out the DNS server responsible?

In the thing of more designing web pages I am unsure of all this sort of area, as in the technical arena.

Romeo

1:06 pm on Jun 19, 2006 (gmt 0)

10+ Year Member



You want to have sub-domains like sub1.example.com ... sub9999.example.com.

3 different things to plan and do, that mostly depend on your overall applications design and logic:

(1) DNS.
Define all subdomains in your domain's zone file -- or just put a wildcard into your zone files (or let your DNS provider do that ... if he offers this .. and if he is prepared to do).
If the DNS is hosted elsewhere, you can't do with a perl/CGI script. Even if the domain's primary DNS server is hosted on the same box, on a properly adminstered webserver, you can't write the DNS zone files from a CGI script and can't reload the DNS server. This is admin work. Perhaps you could poke around with cPanel or similar admin tools to set the wildcard -- don't know.

(2) the web server config.
Define all subdomains in your webserver's (vhosts?) config -- or define a wildcard here, too (or let your server provider do that ... if he offers this .. and if he is prepared to do).
In case you decide for a wildcard, you need additional applications logic then to handle invalid subdomains.
On a properly administered webserver, you can't write the plain vhosts config from a CGI script. Perhaps you could poke around with cPanel or similar admin tools to set a wildcard for your virtual domain -- don't know.

(3) your web page layout / your web application.
The hardest part: to have a plan and corresponding applications design on what to do with those many subdomains and how to efficiently work with them.
You could create sub directories for each and every sub domain -- you could use an ftp batch script or write a perl/CGI or php script to do the mkdirs already mentioned -- or you implement the subdomains logic entirely within your application and ReWrite the subdomains within .htaccess to match that logic, perhaps database driven. Examples:
- sub1234.example.com --> example.com/sub1234/ or
- sub1234.example.com --> www.example.com/index.php?handle=sub1234

Good luck and kind regards,
R.

texmex

2:52 pm on Jun 19, 2006 (gmt 0)

10+ Year Member



I suspect that subdomains are not what you need. (Unless you're planning to set yourself up as an ISP). What are these "subdomains" going to be used for?

If you create subdirectories on your site, you don't need to do anything with Domain Name Servers. DNS is only used to find the server for a site. You can create any directory structure on your site that you want.

If you have the domain www.somedomain.com and then create a subdirectory called somedirectory with a file called somefile in that directory, you simply access the file with www.somedomain.com/somdirectory/somefile

You'll notice that this thread is actually stored in a subdirectory of forum13 from the root of www.webmasterworld.com forum13 is not a subdomain, merely a subdirectory on the site.

You can create as many directories as you like in perl using the MKDIR command.

daowl

11:40 am on Jun 20, 2006 (gmt 0)

10+ Year Member



They are going to be used for professional advertising..... I am only a pensioner that is trying to set up web site with other web sites that re-direct people to the main one....

So, with the page looking professional, the address looking professional, everything looking professional, I hope to get more people to the main site to get more people clicking on the Google links.

With the target of about 10,000 subsomains at the moment, (over about 18 actual domains), with more subdomains in the future.

So I wish to find the quickest way possible, when creating approximately 10,000 subdomains at one point in time. It is simply too long to do it via the cpanel forms.

Thanks to anyone who has taken the time to even read this, but especially make a reply.

Mistra

9:12 am on Jun 22, 2006 (gmt 0)

10+ Year Member



How about hosting your site at provider that allows you to create unlimited subdomains?

You can create as many subdomains you want in their control panel.

daowl

2:36 pm on Jun 22, 2006 (gmt 0)

10+ Year Member



The problem is, that creating 10,000 subdomains minimum.... with the slow process that going back and forth via the two cpanel pages does will take approximately 18 days work of 14 hour days.

If I can find some sort of way to do this via commands, it may only take somewhere between one and five hours work.

I may have plenty of time on my hands, but not that much time. And I am very concerned about the accuracy with the stupidness of having to manually type it in to the forms one after the other. There has to be another way. I am searching the ways above, but they are not looking promising at the moment.

texmex

1:34 am on Jun 23, 2006 (gmt 0)

10+ Year Member



Obviously whatever method you use. At some point you need to actually type in the information needed for each subdomain.

here's one method that could work.

First create a CSV file with all the data for your subdomains. You could use any method you like to produce this. (Notepad, Excel, or even Word)

You would then need to upload this file to your website.

Next you would have to create a perl script that will open the file and itterate through each line of that CSV file.

For each line it would build a form, and populate it with the data that it has just read from the file.

It will then submit the form to the handler of your usual "control panel" form.

It would then print the result of the submission (failure or success), to the browser window.

It will then go back around the loop for the next line in the CSV file.

Once you have uploaded the CSV file, and your script you would just call the script file once and sit back watching the results popup in your browser, one by one.

Before you could do this you would have to view the source of your normal "control panel" form, to find out what the field names are for each data item on the form, and also to find out where to submit the form.

There's no garauntee that this would work, as the handler for your control panel form, may reject the your submitions, (due to comming from the wrong domain.) Furthermore, your hosting service may regard this type of automation as "abuse".

daowl

8:04 am on Jun 23, 2006 (gmt 0)

10+ Year Member



It is that Perl Script that you have mentioned there that I am trying to figure out.

I have got all the subdomains listed out in a TXT. If anyone is interested, email me and I will send you an example. I just need to find that process is related with the perl to get those subdomains on the domains.

Anyone that that knows Perl and has any information about the perl either behind the CPANEL or in CO-OPERATION WITH CPANEL regards to subdomains would be greatly appreciated!

:-)

texmex

8:10 pm on Jun 23, 2006 (gmt 0)

10+ Year Member



This is a rough idea of what I had in mind. It assumes:

The text file (containing all of your domain names and associated info) has one line for each sub domain.

Within each line the separate data items are separated by commas.

You would need to view the source of your original control panel form (as this script is going to emulate it.)

Pay particular head to the names of the input fields and also check for any hidden ones.

Anyhow, my PERL is not that hot and I haven't tested this script, (so it may even have some obvious syntax errors). Hopefully, some kindly more experienced perl programmers may offer corrections/improvements.


#!/usr/bin/perl

# Modules with routines for making the browser.
use LWP::UserAgent;
use HTTP::Request::Common;

use strict;

# Find the name of your control panel form Handler
# and use it here
my $URLtoPostTo = "http://www.somedomain/cgi-bin/whatever.cgi";

#replace filename with your actual text file name
open DAT, "textfilename";

#Specify the name of the browser that you want
#this script to supply
my $BrowserName = "some browser name string";

my @records=<DAT>;

#send header back to users browser;
print "Content-type: text/html\n\n";

print <<END_OF_header;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title></title></head><body>

END_OF_header

#now itterate through each line of the text file

for (my $n=0;$n < @records;$n++)
{
#remove carriage return from end of line
chomp $records[$n];

#split record using the comma as a separator
my @record=split(',',$records[$n]);

#For this bit you need to know the names of the fields on your form
#And what order you have them in your text file

my %Fields=();

$Fields{'FirstFieldName'}=@record[0];
$Fields{'SecondFieldName'}=@record[1];
$Fields{'ThirdFieldName'}=@record[2];
$Fields{'FourthFieldName'}=@record[3];

#If your control panel form has any hidden fields
#with fixed values put them in as follows:
$Fields{'HiddenFieldName'}='HiddenFieldValue';

# Create the browser that will post the information.
my $Browser = new LWP::UserAgent;
# Insert the browser name, if specified.
if($BrowserName) { $Browser->agent($BrowserName); }

# Post the information to the CGI program.
my $Page = $Browser->request(POST $URLtoPostTo,\%Fields);

if ($Page->is_success)
{#This bit will send something to your browser
#for every successfull submition
#You can decide for yourself what details to include

print "<b>Success: </b> $Fields{'FirstFieldName'}<br>\n";
}
else
{#This bit will send info upon a failed attempt
print "<b>Failed: </b>$Fields{'FirstFieldName'}<br>\n";
print $Page->message;

#and stop trying any more
last;
}

}

#Final bit of cleaning up on the page
print '</body></html>';

texmex

1:21 am on Jun 24, 2006 (gmt 0)

10+ Year Member



Told you my perl wasn't very hot. I've just spotted a syntax error myself.

This section:


$Fields{'FirstFieldName'}=@record[0];
$Fields{'SecondFieldName'}=@record[1];
$Fields{'ThirdFieldName'}=@record[2];
$Fields{'FourthFieldName'}=@record[3];

Should have read:


$Fields{'FirstFieldName'}=$record[0];
$Fields{'SecondFieldName'}=$record[1];
$Fields{'ThirdFieldName'}=$record[2];
$Fields{'FourthFieldName'}=$record[3];

daowl

5:07 am on Jun 24, 2006 (gmt 0)

10+ Year Member



So, is that where the changing factors need to be?

$Fields{'FirstFieldName'}=$record[0];
$Fields{'SecondFieldName'}=$record[1];
$Fields{'ThirdFieldName'}=$record[2];
$Fields{'FourthFieldName'}=$record[3];

eg.

$Fields{'bob'}=$record[0];
$Fields{'henry'}=$record[1];
$Fields{'ross'}=$record[2];
$Fields{'brad'}=$record[3];

I could just create all those lines in a database to output them, and then the perl would be created you think?

Do you mind if I take this to someone else to check?

Thanks....

texmex

5:03 pm on Jun 24, 2006 (gmt 0)

10+ Year Member



Not quite. If 'bob' 'henry' and 'ross' are the names of input fields on your control panel form, you'd have it right.

It is more likely, however, that these fields are going to have names like "domainname" and "foldername"

The changing values that are going to be put into "fields" would be stored in a completely separate text file.

Copy everything in my first post from (and including)#!/usr/bin/perl to the end into a new text document.

Delete the ines that read


$Fields{'FirstFieldName'}=@record[0];
$Fields{'SecondFieldName'}=@record[1];
$Fields{'ThirdFieldName'}=@record[2];
$Fields{'FourthFieldName'}=@record[3];

and replace with something like (note dollar symbols NOT @ symbols)

$fields{'domainname'}=$record[0];
$fields{'foldername'}=$record[1];
etc..

Like I say. I don't know what the field names are on your original "control panel" form.
You will have to go into your control panel and "view source" to work that out for yourself.

Save this document and consider it your very own perl script. Do with it as you wish. By all means get someone that knows perl to give it the once over. I'd be highly surprised if there wasn't at least one more glaring syntax error lurking in there. (like I say, I'm relatively new to perl programming, so slips are only natural).

Besides this perl script you will need a text file with all the details that would look something like:


MyFirstSubDomain,subDom1Folder
MySecondSubdomain,subDom2Folder
VeryNicSubdomain,SubDom3Folder
etc..

Once the perl script has been tailored to your needs, save it as something like "domcreator.pl" in the cgi-bin directory on your website. Also save a copy of your text file there.

To start it running you woould just opoen your browser and call it as www.yourdomain.com/cgi-bin/domcreator.pl

soon as it is called, it will open your text file. Then for each line in that text file it will:

1) create a form.

2) On the form it will place a FieldName of "domainname" and give it the value of the first item in the current line of your text file.

3) It will Also create a fieldname of "foldername" and give it the value of the second item in the current line of your text file.

4) Once it has created all the data items on the form (using the values on the current line of the text file. It will submit the form to the handler.

5) It will then go on to the next line of your text file and do it all over again.

All this will be done by the script itself. The only thing you will see at your browser is one line of text for each domain being created.

daowl

9:28 am on Jun 25, 2006 (gmt 0)

10+ Year Member



Thanks greatly! Finally something I can fully understand. :-)

Your assistance has been greatly appreciated. I will see what I can get up to over the next couple of days and get back to you with an update.

texmex

1:26 pm on Jun 25, 2006 (gmt 0)

10+ Year Member



If you want help with the "tailoring" of the perl script.

Go to your "control panel" and go through all the motions of creating a new sub-domain. At this point instead of clicking the submit button, in your browser, select "View source".

Edit select all, and copy, then paste into a new text document. Save this as "controlPanel.txt". Do a search in this new document for <form Highlight this and everything that follows it until you find </form>

Copy this area to the clipboard.

Create a new post on this thread. Add [code] and [/code] tags and insert the form contents between them.

We will then be able to see the names of all the input boxes (what I have called the fieldnames), and edit the perlscript, accordingly.

You may find that there is more than one form on the page, so if the form, that you find, doesn't look right, you may have to press F3 to find the next form on the page.

Even once the perl script has been thouroughly tailored and debugged, it still may not work. The handler for your "control panel" form may reject the perl generated requests due to comming from the wrong domain.

daowl

2:36 am on Jun 26, 2006 (gmt 0)

10+ Year Member



This is it.... and as far as I can gather it is the second group of subdomains.....

<html>
<head>
<title>cPanel X</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="../style.css">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onLoad="MM_preloadImages('../images/home_on.gif','../images/logout_on.gif')">
<table width="603" border="1" cellspacing="2" cellpadding="0" bgcolor="#FFFFFF" bordercolor="#D4D9DB" align="center">
<tr valign="top">
<td height="142">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
<tr>
<td height="2" colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/frontend/bluelagoon/branding/top_01_bg.gif">
<tr>
<td><img alt="cPanel" src="/frontend/bluelagoon/branding/top_01_1.gif" width="637" height="41"></td>
<td align="right" width="44"><a target="_top" href="../index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('image01','','../images/home_on.gif',1)"><img alt="[ Home ]" name="image01" border="0" src="../images/home_off.gif" width="44" height="41"></a></td>
<td align="right" width="44"><a target="_top" href="/logout/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('image02','','../images/logout_on.gif',1)"><img alt="[ Logout ]" name="image02" border="0" src="../images/logout_off.gif" width="44" height="41"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="19" colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/frontend/bluelagoon/branding/top_01-sm_bg.gif">
<tr>
<td align="left" width="145" nowrap><img alt="" src="/frontend/bluelagoon/branding/top_01-sm_1.gif" width="145" height="70"></td>
<td align="left" width="145" nowrap><img alt="" src="/frontend/bluelagoon/branding/top_01-sm_2.gif" width="145" height="70"></td>
<td align="left" width="145" nowrap><img alt="" src="/frontend/bluelagoon/branding/top_01-sm_3.gif" width="145" height="70"></td>
<td align="left" width="145" nowrap><img alt="" src="/frontend/bluelagoon/branding/top_01-sm_4.gif" width="145" height="70"></td>
<td align="left"><img alt="" src="/frontend/bluelagoon/branding/top_01-sm_5.gif" width="145" height="70"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="2" colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/frontend/bluelagoon/branding/top_03_bg.gif">
<tr>
<td width="135" nowrap align="left"><img alt="" src="/frontend/bluelagoon/branding/top_03_1.gif" width="125" height="26"></td>
<td align="right"><img alt="" src="/frontend/bluelagoon/branding/top_03_2.gif" width="600" height="26"></td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td colspan="3">
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr valign="top">
<td>

<script>
function checksubdomain() {
var subdomain = document.domainform.domain.value;
if (subdomain == '') {
alert("Your sub domain name cannot be null.");
return false;
}
if (subdomain.indexOf(' ') > -1) {
alert("Your sub domain name cannot contain any spaces.");
return false;
}
if (subdomain.indexOf('.')!= -1) {
alert("Your sub subdomain must not contain any periods.");
return false;
}
var pattern = /(?:^[-]¦[-]$)/;
if (subdomain.match(pattern)!= null) {
alert("Sorry, your sub domain name must not begin or end with a hyphen.");
return false;
}
var pattern = /^www$/i;
if (subdomain.match(pattern)!= null) {
alert("Sorry, your sub domain name must not be 'www'. This is handled for you.");
return false;
}
return true;
}
</script>

<div align="center">
<table width="550" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="bottom">&nbsp;</td>
<td valign="middle" width="522"><font class="big">Sub Domain Maintenance</font></td>
<td valign="bottom">&nbsp;</td>
</tr>
<tr>
<td></td>
<td>
<br />
<div align="center">
Current Sub-Domains
<hr width="50%">
art-work.example.net (art-work)<br>
art-works.example.net (art-works)<br>
artwork-inc.example.net (artwork-inc)<br>
artwork.example.net (artwork)<br>

<br /><br />
<form onSubmit="return checksubdomain()" action="doadddomain.html" name="domainform">
<input type="text" name="domain">.
<select name="rootdomain"><option value="art-work.example.net">art-work.example.net</option>
<option value="art-works.example.net">art-works.example.net</option>
<option value="artwork-inc.example.net">artwork-inc.example.net</option>
<option value="artwork.example.net">artwork.example.net</option>
</select>
<input type="submit" value="Add">
<br />
<font size="-2">Note: If you wish to grant virtual ftp access to this subdomain, just create an FTP user with the same username as the subdomain base name that is listed inside the () above.</font>
</form>
<form action="doredirectdomain.html">
<select name="domain"><option value="art-work_example.net">art-work.example.net</option>
<option value="art-works_example.net">art-works.example.net</option>
<option value="artwork-inc_example.net">artwork-inc.example.net</option>
<option value="artwork_example.net">artwork.example.net</option>
</select>
<input type="submit" value="Setup Redirection">
</form>
<form action="donoredirect.html">
<select name="domain"><option value="art-work_example.net">art-work.example.net</option>
<option value="art-works_example.net">art-works.example.net</option>
<option value="artwork-inc_example.net">artwork-inc.example.net</option>
<option value="artwork_example.net">artwork.example.net</option>
</select>
<input type="submit" value="Remove Redirection">
</form>
<form action="dodeldomain.html">
<select name="domain"><option value="art-work_example.net">art-work.example.net</option>
<option value="art-works_example.net">art-works.example.net</option>
<option value="artwork-inc_example.net">artwork-inc.example.net</option>
<option value="artwork_example.net">artwork.example.net</option>
</select>
<input type="submit" value="Delete">
</form>

<b><font class="bodyblack">Note: Subdomains rely on the DNS system in order to function, which means that your DNS information must propagate throughout the different DNS servers on the Internet before your subdomain becomes fully active. This process on the average takes a few hours.</font></b>
</div>
</td>
<td></td>
</tr>
<tr>
<td valign = "bottom">&nbsp;</td>
<td valign = "bottom">&nbsp;</td>
</tr>
</table>
<br /><br />
<b>[</b> <a href="../index.html">Go Back</a><b> ]</b>
</div>
<br></td></tr></table></td></tr><tr align="center">
<td height="2" colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="/frontend/bluelagoon/branding/bottom_bg.gif">
<tr align="center">
<td><img alt="" src="/frontend/bluelagoon/branding/bottom_label.gif" width="327" height="23"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

<!---cPanel [10.8.2-RELEASE_119] (pro) Copyright (c) 1997-2006 cPanel, Inc. Licensed on aus5.unlimited-space.com --->

[edited by: jatar_k at 5:07 am (utc) on June 26, 2006]
[edit reason] changed to example.net [/edit]

perl_diver

6:57 am on Jun 26, 2006 (gmt 0)

10+ Year Member



I don't think you will not be able to access the scripts the control panel uses because you have to login to the CP. After you login there is some type of authentication used to verify you are the user making the requests to the server. You can't bypass the login session, at least you should not be able to.

daowl

11:14 am on Jun 26, 2006 (gmt 0)

10+ Year Member



Would it be possible at all to put the username and password in to the perl script, the very same u/n & p/w needed for the cpanel / domain, to enable that perl script to work?

texmex

4:15 pm on Jun 26, 2006 (gmt 0)

10+ Year Member



OK but you'll still need to do a bit more tailoring.

For authentication You need four separate data items. These are the Location, Realm, username and Password.

When you go to your "control panel" using something like Internet Explorer you will be prompted for a username and password.

The location should start with HTTP:// but Internet Explorer will not show this, but be sure to include this at the begging of the location string.

The realm (in my example is "Site Statistics") You should make sure you get this absolutely correct.

The username and password, I assume you already know.

Insert these four pieces of data into the script where I have YourLocation, YourRelm, YourUsername and YourPassword. (leave the inverted commas around them, and also leave that .':80'; after the Location)

One more slight problem is that the handler for your form is called doadddomain.html Unfortunately, this isn't the full URL to the handler. To find this, go to your "control panel" and look in the address bar of your browser. You need to take everything before the last forward slash and prefix it to the name of the handler.

For instance, if your control panel page is:
"http://www.somedomainhost/services/hostconfig/addDomain.html"

Your handlers full url would be
"http://www.somedomainhost/services/hostconfig/doadddomain.html"

Once you have worked this out, put this full string in Where I have YourFormHandler

Your text file
For the sake of this exercise I have used the name domainlist.txt This file should contain two data items per line (separated by a comma). So your domainlist.txt should look something like:
[code]
Thomas,art-works.example.net
Richard,art-works.example.net
Harry,art-works.example.net
Tom,artwork-inc.example.net
Dick,artwork-inc.example.net
[code]
etc..

I notice from your form that you appear to have a number of domains that you can choose to create your subdomains from. In your text file the second item, in each line, will be the name of the parent domain for your new subdomain. (The first being the name of the new subdomain).

Also note that your control panel form also has some validation that our perl script is NOT going to do. So ensure that none of your domain names:

have any spaces
have any periods (full stops to us Brits)
Does not start or end with a hyphen
Does not start with WWW

After all this there is still a pretty good chance that this will never work, due to other security measures on your webhosts server. If you still want to give it a whirl, the adapted perlscript follows. If you can get someone else to checkout the code first so much the better. Perl is not exactly my native tongue.

I'd also suggest that your first attempt should be with a text file containing no more than 2 records. Once you have executed the script once, you can simply replace the text file with another (containing new values), then run it again.

#!/usr/bin/perl

# Modules with routines for making the browser.
use LWP::UserAgent;
use HTTP::Request::Common;

use strict;

#Details for authentication.
my $netloc='http://YourLocation'.':80';
my $username='YourUsername';
my $password='YourPassword';
my $realm='YourRealm';

# Find the name of your control panel form Handler
# and use it here
my $URLtoPostTo = "YourFormHandler";

#replace filename with your actual text file name
open DAT, "domainlist.txt";

#Specify the name of the browser that you want
#this script to supply
my $BrowserName = "Mozilla/5.0";

my @records=<DAT>;

#send header back to users browser;
print "Content-type: text/html\n\n";

print <<END_OF_header;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title></title></head><body>

END_OF_header

#now itterate through each line of the text file

for (my $n=0;$n < @records;$n++)
{
#remove carriage return from end of line
chomp $records[$n];

#split record using the comma as a separator
my @record=split(',',$records[$n]);

#For this bit you need to know the names of the fields on your form
#And what order you have them in your text file

my %Fields=();

$Fields{'domain'}=$record[0];
$Fields{'rootdomain'}=$record;

# Create the browser that will post the information.
my $Browser = new LWP::UserAgent;
# Insert the browser name, if specified.
if($BrowserName) { $Browser->agent($BrowserName); }

#This line actually does the authentication
$page->credentials($netloc,$realm,$username => $password);

# Post the information to the CGI program.
my $Page = $Browser->request(POST $URLtoPostTo,\%Fields);

if ($Page->is_success)
{#This bit will send something to your browser
#for every successfull submition
#You can decide for yourself what details to include

print "<b>Success: </b> $Fields{'FirstFieldName'}<br>\n";
}
else
{#This bit will send info upon a failed attempt
print "<b>Failed: </b>$Fields{'FirstFieldName'}<br>\n";
print $Page->message;

#and stop trying any more
last;
}

}

#Final bit of cleaning up on the page
print '</body></html>';

[1][edited by: coopster at 10:32 pm (utc) on June 26, 2006]
[edit reason] removed url [/edit]

perl_diver

6:40 pm on Jun 26, 2006 (gmt 0)

10+ Year Member



it will be interesting to see if it works. Also, if your CP connects through a specific port you may have to take that into consideration. Something like:

http://www.example.com:2082/blah/blah

texmex

11:53 pm on Jun 26, 2006 (gmt 0)

10+ Year Member



I've just spotted another mistake on that perl script.

The part that reads


#This line actually does the authentication
$page->credentials($netloc,$realm,$username => $password);

Should read


#This line actually does the authentication
$Browser->credentials($netloc,$realm,$username => $password);

ie Replace the word "page" with "Browser" (careful, it is case sensitive).

claus

12:11 am on Jun 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Excuse me for saying so, but this is one hilarious thread :) :)

Anybody here read any SEO news sites or forums lately? Something with subdomains ring a bell anywhere? Approximately ten thousand of them?

But anyway, as the hole is being closed it's dang simple to pull off anyway.

Get that asterisk in your DNS and on your host. Then make a simple rewrite rule directing any traffic on any hostname (=subdomain) to a database lookup with "key=hostname". Add one simple rule to care for non-authorized "domains" and you're up and running on the gravy train.

And remember that v1cod1n is spelled like that. With numbers. Or like, say, "3re45.v1cod1n.example.com". I'm a pensioner too, you see :)

texmex

6:04 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



[quote="claus"]Anybody here read any SEO news sites or forums lately?[/quote]

Oh yes, I always make a point of reading my latest copy of SEO news to my grandchildren at bedtime. I've been trying to get tickets to the SEO world championships finals, but can't find out where they are being played.

Seriously though, I personally felt the mention of thousands of subdomains was something of an exageration. The SEO connection does somewhat shed a different light on things eh?

daowl

12:18 pm on Jun 28, 2006 (gmt 0)

10+ Year Member



There will not be different domains as you may have been thinking (if I got you right). The domain in the example, was example.com There was a couple of subdomains shown already organised in that script that I had sent you.

So the page that this CPanel create these subdomains in, goes to another page, then you need to go back via another page. Does that cause trouble as well then?

Created in:
http://example.net:2082/frontend/bluelagoon/subdomain/index.html

Address to get back from:
http://example.net:2082/frontend/bluelagoon/subdomain/doadddomain.html?domain=SUB_JUST_CREATED&rootdomain=ACTUAL_DOMAIN

With a click on the following link needed:
<div align="center"><b>[</b>&nbsp;<a href="index.html">Go
Back</a>&nbsp;<b>]</b></div>

[edited by: coopster at 3:50 pm (utc) on June 28, 2006]
[edit reason] generalized domain [/edit]