Dedicated Servers
Managed Dedicated Servers
Semi-Dedicated Hosting
Cheap Dedicated Servers
Hyper-V VPS Hosting
Hyper-V Virtual Private Servers
Linux VPS Hosting
VPS Hosting with Root Access
Windows VPS Hosting
Windows VPS Web Hosting
Reseller Hosting
Reseller Hosting India
cPanel Shared Hosting
Linux Shared Web Hosting
Windows Hosting
Windows Shared Web Hosting
Web Hosting Blog
Web Hosting Blog India
Hosting Knowledgebase
Web Hosting Knowledgebase




  #1 (permalink)  
Old 08-16-2005, 10:34 PM
Moderator
 
Join Date: Aug 2009
Posts: 126
Default Testing Scripts on Server:

Testing Scripts on Server:

HTML
=======


File Name: test.html

<html>
<body bgcolor=pink><center>
<font face=verdana size=5>
<h2>This is a test page.</h2>
</font></center>
</body>
</html>


PHP
=====

File Name: test.php

<?php
echo "<html>
<body bgcolor=pink><center>
<font face=verdana size=5>
<h2>This is a php test file.</h2>
</font></center>
</body>
</html>";
?>



CGI/PERL
=======


File Name: 1. test.cgi
or
2. test.pl


#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "This is a test file";


ASP
=====


File Name: test.asp

<%="This is a ASP test file." %>



.SQL or .txt file
============



Save the file .sql or .txt and upload it from the phpmyadmin->'SQL tab'
->'Browse button'->And upload a file

create table test1
(
id int
)



Aspx - (asp.net script)
=================


File Name: test.aspx

<html>
<head>
<title>Test ASP.net code</title>
</head>
<script language="C#" runat="server">
void Page_Load ( Object src , EventArgs args )
{
message.Text = "Hello World...!" ;
}
</script>
<body>
<asp:Label id="message" runat="server"/>
</body>
</html>


ASP - Mysql connection code using ASP
=============================


<%
''''''''''''''''''''''''''''''''''''
' MySQL connection string
' Enter the DBName,DBUser,DBPass
''''''''''''''''''''''''''''''''''''
Dim DBName,DBUser,DBPass,objRS,objConn
DBName=""
DBUser=""
DBPass=""

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database="&DBName&";UID=" &DBUser&";pwd="&DBPass&";"

objConn.Open
Set objRS=Server.CreateObject("ADODB.Recordset")
%>


ASP-Ms Access (Without DSN/ODBC connectivity by DBPath)
============================================


Once you have uploaded your database to our server, you can use a script similar to the one provided below to connect to it from within an ASP script.

<%

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
' Access Database connection string
' Change this to the actual location of your mdb file
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
Dim DBPath,objRS,objConn
DBPath="/db/file.mdb"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.mappath(DBPath)
objConn.Open
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = objConn
Recordset1.Source = "SELECT * FROM Products WHERE ProductID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

PHP-MySQL
=========


<?

$dbhost = 'localhost';
$database = 'databasename';
$dbuser = 'username';
$dbpass = 'password';

$db=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error: Could not connect to the database.');
mysql_select_db($database,$db) or die('Could not select database');

?>


To protect a directory:
==================


Create the .htaccess file with the following para.
Code:
AuthUserFile /home/username/.htpasswd
AuthGroupFile /dev/null
AuthName "Private Area"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

Create a .htpasswd File, for the encryption username and password go through the following link:


http://www.clockwatchers.com/htaccess_tool.html


Hotlinking
========


Add the below lines to your .htaccess file to stop people from hotlinking to your .gif and .jpg files.
Quote:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?your_domain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]


Block An IP Address
=============


Quote:
order allow,deny
deny from 127.0.0.1
deny from 127.0.0.2
deny from 127.0.0.3
allow from all


Ban ISP name
=========

You can also ban ISP name
Quote:
deny from isp_name.com


It bans users with a remote hostname ending in isp_name.com.


To open a remote file through PHP function Code:
=================================



<?php
$file = fopen ("http://alxumuk.com.ru", "r");

if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}
fpassthru($file);
fclose($file);
?>



OR

Code:

<?php
$file = fopen ("http://alxumuk.com.ru", "r");

if (!$file) {
echo "<p>Unable to open remote file.\n";
exit;
}

while (!feof ($file)) {
$line = fgets ($file, 1024);
echo $line;
}
fclose($file);
?>


PHP INFO
<?
phpinfo();
?>


Perl modules
==========


To check the Perl modules

#!/usr/local/bin/perl

use GD;
# or use MD5;

Be sure that you dont use the file manager, it can cause problems... upload through FTP in ascii mode and set permissions to 755


To check the Socket Connections(fsockopen) on the Server:
================================================


<?php
if ($fp = fsockopen ('www.domainname.com', 80, $errno, $errstr, 30))
{print("fsockopen success");
}
else
{print("failed");
}
?>


Redirection code from CGI/PERL file Code:
=============================


#!/usr/bin/perl
use CGI;
my($q) = new CGI;
print $q->redirect('http://www.sportswatchesandmore.com/cgi-bin/store/agora.cgi');
print $q->end_html;


CURL
=====

paste the following code into php test file and run, Google.com should popup, if it happens then the code is running

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/");
$ret = curl_exec($ch);
print $ret;
curl_close($ch);
?>

CGI-MySQL Connectivity:
===================


Connection Strings
Perl $dbh = DBI->connect("DBI:mysql:comphobb_agbook2:localhost","c omphobb_agbook2","PASSWORD HERE");


SSI directives in asp pages
=====================

You can include SSI directives in asp pages.

<%="This is a ASP test file." %>
<!--#include file="header.asp"-->

To use server side includes, outside of your ASP code (i.e., outside of the <% and %>), include the following line:


<!--#include file="somefile.asp"-->


To check the Files count of the domain
=============================


#!/usr/bin/perl
$string = `ls -laR /home/username|wc -l`;
print "Content-type: text/plain\n\n$string";

Replace the username instead of the 'username'

PHP Mail Script Code:
================


<?php
$mail_to="test123@domainname.com";
$mail_subject="Hello";
$mail_from="test@domainname.com";
$mail_body_client="Hello";
mail($mail_to,$mail_subject,$mail_body_client,"FRO M:". $mail_from);
?>


How to send HTML email through PHP Code:
=================================


<?
$headers = "From:username@domainname.com\r\n". "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail("neoneo123456@hotmail.com", "An HTML Message", "<b>hello</b>", $headers);
?>

How to add "Return Path" and from address in your email?
=============================================


$headers = "From:username@domainname.com\r\n". "Content-Type: text/html; charset=ISO-8859-1\r\n". "Return-Path: <username@domainname.com>\n";
mail("neoneo123456@hotmail.com", "An HTML Message", "<b>hello</b>", $headers);



Code to refresh html pages :
The html code below will cause the current page to reload itself after 10 seconds.It reload itself because no URL is specified.
--------------------------------------------------------------
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="2">
<TITLE>Page</TITLE>
</HEAD>
----------------------------------------------------------------
You can also specify the page which you want to reload :
------------------------------------------------------------
<HEAD>
<META HTTP-EQUIV="Refresh"
CONTENT="2; URL=http://www.DomainName/page2.html">
<TITLE>Page</TITLE>
</HEAD>-------------------------------------------------------------------------------------
This wil cause page2.html to be loaded after every 2 seconds.



Python Test script
===============


#!/usr/bin/python

print "Content-type: text/html\n\n";
print "This is a test file of python";

Or path should be as follows:

#!/usr/local/bin/python

Extensions should be .py


MySQL Connection response time
=========================



<?php
class timemeter {
var $starttime;
function start() {
$t=microtime();
$time_b = explode (" ", $t);
$this->starttime = doubleval($time_b[0])+$time_b[1];
}

function finish() {
$t=microtime();
$time_e = explode (" ", $t);
$endtime = doubleval($time_e[0])+$time_e[1];
echo "<br> <b>",sprintf ("%01.4f", $endtime-$this->starttime),"</b> s ";
}
}


$t = new timemeter();


$t->start();

mysql_connect("127.0.0.1", "studentm_test1", "test1");
mysql_select_db("studentm_test");
mysql_close();


$t->finish();


?>




Thanks & Regards,

-Harshal
Reply With Quote
Reply

Bookmarks
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT. The time now is 04:55 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0