Assigning IP on Cisco Routers

Sunday, October 27, 2013

 

 Here I am taking the Equipment 
    

      -  Cisco 2811
      -  Serial DCE
      -  WIC-2T

 Assigning IP addressing

     Must keep in mind that every communication is based on IP, without IP you cannot do anything

           Configuration :

                  Router> enable
                 Switch to enable Mode
               
                 Route#
                 Now we are switch mode, For configuring Our router we should
                 move to configuration mode

                 Router#config t
                 After that you'll move to  config mode
                 Router(config)#
                 Now move to that serial on which wire is connected
                 In my example it 0/3/0

                 Router(config)# int s 0/3/0
                 Now we are at interface serial 0/3/0
                 Here we have to assign the ip address 

                Router (config-if)#ip address 1.1.1.3 255.0.0.0
                In this command after right next to ip address the ip address
                you want to assign and then after that the subnet of that class 
                is written

                Router (config-if)# end

That's It Ip is assigned, Same work is to be done on the other router For communication 

               
      


How to Setup SEO Friendly 301 Redirect?



SEO Friendly 301 

The “301 Permanent Redirect” is the most efficient and search engine friendly method for redirecting websites. You can use it in several situations, including:

• to redirect an old website to a new address
• to setup several domains pointing to one website
• to enforce only one version of your website (www. or no-www)
• to harmonize a URL structure change

There are several ways to setup a 301 Redirect; below I will cover the most used ones:
PHP Single Page Redirect
In order to redirect a static page to a new address simply enter the code below inside the index.php file.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http: // www . newdomain . com / page.html");
exit();
?>
PHP Canonical Redirect
The Canonical 301 Redirect will add (or remove) the www . prefixes to all the pages inside your domain. The code below redirects the visitors of the http: // domain . com version to http: // www. domain.com.
<?php
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']
.$_SERVER['REQUEST_URI']);
}
?>
Apache .htaccess Singe Page Redirect
In order to use this method you will need to create a file named .htaccess (not supported by Windows-based hosting) and place it on the root directory of your website, then just add the code below to the file.
Redirect 301 /old/oldpage.htm /new/http : // www .domain. com/newpage.htm
Apache .htaccess Canonical Redirect
Follow the same steps as before but insert the code below instead (it will redirect all the visitors accessinghttp://domain.com/ to http://www.domain.com/)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http:// www . domain .com/$1 [r=301,nc]
ASP Single Page Redirect
This redirect method is used with the Active Server Pages platform.
<%
Response.Status="301 Moved Permanently"
Response.AddHeader='Location','http://www . new-url . com/'
%>
ASP Canonical Redirect

The Canonical Redirect with ASP must be located in a script that is executed in every page on the server before the page content starts.
<%
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("SCRIPT_NAME")
End if
%>

Create search engine in php, mysql

Saturday, March 30, 2013







                              

Database Matter

The first step is to open up phpMyAdmin or a database software and incorporate the below query into the SQL section.
1
2
3
4
5
6
CREATE TABLE `searchengine` (
`id` INT NOT NULL AUTO_INCREMENT ,
`pageurl` VARCHAR( 255 ) NOT NULL ,
`pagecontent` TEXT NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM
The above query will assist the details or information to be stored in the database.

Creating the Form

Now when the database information is now added, let us make the form that will permit the visitors or the end users to perform a search. A file 'index.php' needs to be created.
The form will be using GET instead of POST thereby making the information quite visible in the address bar.

1
2
3
4
5
6
7
8
<form action="search.php" method="GET">
<b>Enter Search Term:</b> <input type="text" name="term" size="50"> <b>Results:</b> <select name="results">
    <option>10</option>
    <option>20</option>
    <option>50</option>
</select><br>
<input type="submit" value="Search">
</form>
The form is now completed. This will permit us to enter in a query and at the same time will permit the count of results that needs to be shown on the form.

Processing the Query

Create a new file 'search.php' and this is the page where the results from the search will be displayed.
Let us connect to the database first:
1
2
3
<?php
mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
Now perform the MySQL query (as a query)
1
$sql = mysql_query("SELECT * FROM searchengine WHERE pagecontent LIKE '%$_GET[term]%' LIMIT 0,$_GET[results]");
The query mentioned above will look in the page data i.e. the Search results after entering in the keyword and display it as many times as you define it. We will create an array now to display the results.
1
2
3
while($ser = mysql_fetch_array($sql)) {
    echo "<h2><a href='$ser[pageurl]'>$ser[pageurl]</a></h2>";
}
Let us now just include a link at the bottom that navigates back to the original index page.
1
2
3
?>
<hr>
<a href="./index.php">Go Back</a>

Adding Information

We are done with the frontend formation of the search engine. We need to come up with a little form now that would store the details in the database.
Let us create a new page namely 'addurl.php' and create a simple form.
1
2
3
4
<form action="./addurl2.php" method="POST">
Page URL: <input type="text" name="url" size="50"><br>
<input type="submit" value="Add URL">
</form>
Now create a second page namely 'addurl2.php'. Here the processing of information will take place and added to the database ready to be searched.

Connect to the database

1
2
3
<?php
mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
The URL of the page will now get its source code read and made into a variable.
1
$pagedata = htmlspecialchars(file_get_contents($_POST['url']));
This little line will take away some single quotes that will more often than not disorder the query.
1
$pagedata = str_replace("'","",$pagedata);
Let us now insert the information into the database.
1
mysql_query("INSERT INTO searchengine VALUES ('','$_POST[url]','$pagedata')");
Give a small added message, just so you know it's been added.
1
2
echo "URL Added.<br><a href='./addurl.php'>Continue...</a>";
?>

Search Engine is ready!!!

So we are ready with our nice and simple search engine. One can now go to 'addurl.php' and enter the URL(s) of the page(s) that is required to be incorporated into the search engine that you have just created. Assuming you are looking in for ‘e’, there will be good amount of results for the reason that it'll be reading stuff like '<e>'.
We can make things better by following the below mentioned points.
  • We can alter the ‘addurl.php’ page that will filter out few of the words or phrases.
  • The other important thing is to include pagination and this will permit us to display more than 50 results divided on different pages.
  • An admin control panel can be created where we can add, edit and delete the results as well.
  • The most important part is the security of the search engine and preventing other people to add information. This can be done by doing a password protects on ‘addurl.php’ and ‘addurl2.php’ pages.
  • Addition of the categories such as News, Entertainment, Blogs, technology etc. can be done.
With the completion of this tutorial, we have leant on how to build a HTML form, the connection with the database, the process to read information from a database and obviously how we can add some new information into the database.

Conclusion

The article aimed to provide a simple and easy route to come up with our own Search Engine making use of PHP and SQL language.

Full Source Code of search.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<html>
<head>
    <title>WebXteria Development Article</title>
</head>
<body>
     
<form action="search.php" method="GET">
<b>Enter Search Term:</b> <input type="text" name="term" size="50"> <b>Results:</b> <select name="results">
    <option>10</option>
    <option>20</option>
    <option>50</option>
</select><br>
<input type="submit" value="Search">
</form>
 
<?php
    mysql_connect("localhost", "USERNAME", "PASSWORD");
    mysql_select_db("DATABASE");
 
$sql = mysql_query("SELECT * FROM searchengine WHERE pagecontent LIKE '%$_GET[term]%' LIMIT 0,$_GET[results]");
    while($ser = mysql_fetch_array($sql)) {
        echo "<h2><a href='$ser[pageurl]'>$ser[pageurl]</a></h2>";
    }
?>
<hr>
<a href="./index.php">Go Back</a>
 
</body>
</html>

Full Source Code of addurl.php

1
2
3
4
<form action="./addurl2.php" method="POST">
Page URL: <input type="text" name="url" size="50"><br>
<input type="submit" value="Add URL">
</form>

Full Source Code of addurl2.php

1
2
3
4
5
6
7
8
9
10
<?php
mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");
 
$pagedata = htmlspecialchars(file_get_contents($_POST['url']));
$pagedata = str_replace("'","",$pagedata);
mysql_query("INSERT INTO searchengine VALUES ('','$_POST[url]','$pagedata')");
 
echo "URL Added.<br><a href='./addurl.php'>Continue...</a>

 

Most Reading