A little script that help you create virtual subdomains in your internet domain with Wild Cards allowed.
By : dr.Freud
<?php
/* ********************************************************
* Manage Virtual Subdomains *
* developed by: Jacopo Agnesina <dr.freud@agnesina.it> *
********************************************************
- Requirements: PHP 4.2.2 [tested-on-it], MySQL 3.23 [tested-on-it],
a domain with wildcards allowed! [contact your sysamdin for info]
*********************
- Database details -
*********************
TABLE: domains
FIELDS: subdomain (char[255], Primary, Not Null); * Contain the subdomain that you
to associate to an url.
destination (char[255], Not Null); * The url where the browser will be
redirected when you query the
sub domain above.
popup (tinyint[1], Not Null, default -> 0); * For future implementation
description (text); * For future implementation
**********************************
* FREE YOUR CODE, FREE YOUR MIND *
********************************** */
/* Variables definitions */
$MySQLhost = "whatyouwant";
$MySQLuser = "whatyouwant";
$MySQLpsw = "Idonnow";
$MySQLdb = "yourdatabase"; /* Or another, it's the same */
$MyDOMAIN = "YourDomain.tld"; /* Put here you domain without WWW, for example "codewalkers.com" */
$DefaultPage = "index2.html"; /* Put here the name of the default page */
/* Connectd to the DB */
mysql_connect ($MySQLhost, $MySQLuser, $MySQLpsw);
mysql_select_db ($MySQLdb);
/* Get the hostname typed in */
$subhost = strtolower($HTTP_HOST);
/* Get away the "www." in front (in case there is one) */
$subhost = str_replace("www.", "", $subhost);
/* Delete everything after (and including) the first "/" */
$subhost2 =strstr($subhost, "/");
/* Delete the domain in the string */
$subhost =str_replace($MyDOMAIN,"",$subhost);
/* Delete dots */
$subhost =str_replace(".","",$subhost);
/* If is something */
if(strlen($subhost)>0)
{
/* Query the DB with the current Subdomain */
$RSredirect = mysql_query ("SELECT * FROM domains WHERE subdomain='$subhost'");
/* Redirect if subhost exist */
if($Rredirect = mysql_fetch_array($RSredirect))
{
header("Location: ".$Rredirect['destination']);
exit;
}
/* Go to the default page */
else
{
header("Location: $DefaultPage");
exit;
}
}
/* Go to the default page */
else
{
header("Location: $DefaultPage");
exit;
}
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Miscellaneous Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
|
|
|
|
Manage, govern, and share services across your organization by using WebSphere Service Registry and Repository. Follow the hands-on exercises to learn how to navigate the Web interface to publish, find, reuse, and update services. FREE! Go There Now!
|
|
|
|
This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. FREE! Go There Now!
|
|
|
|
Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months. FREE! Go There Now!
|
|
|
|
As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
|
|
|
|
Get a free trial download of the latest version of IBM Rational Functional Tester V7.0.1. Rational Functional Tester is an automated functional and regression testing solution for QA teams concerned with the quality of their Java, Microsoft Visual Studio .NET, and Web-based applications. FREE! Go There Now!
|
|
|
|
Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes. FREE! Go There Now!
|
|
|
|
Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |