#!/usr/bin/perl -w
# Perl Upload
# use lib
use strict;
use CGI::Pretty;
# limit 1000K bytes post, permit upload
$CGI::POST_MAX = 1024 * 1000;
$CGI::DISABLE_UPLOADS = 0;
# init variables
my $cgi = new CGI;
my $title = "Perl Upload";
if (!$cgi->param()) {
# print header
print $cgi->header(),
$cgi->start_html($title);
print $cgi->center($cgi->h1($title)),
$cgi->hr(),
$cgi->br();
# print body
print $cgi->center
(
$cgi->start_multipart_form(),
$cgi->font("Filename :"),
$cgi->filefield(-name=>"filename", -size=>"30"),
$cgi->br(),
$cgi->br(),
$cgi->submit(-value=>"Upload"),
$cgi->reset(-value=>"Clear"),
$cgi->end_form()
);
exit(0);
} else {
# get file data
my $file = $cgi->param("filename");
my @filedata = <$file>;
foreach (@filedata) {
s/ s/>/>/g;
s/\n/
\n/g;
}
# print header
print $cgi->header(),
$cgi->start_html($title);
print $cgi->center($cgi->h1($title)),
$cgi->hr(),
$cgi->br();
# print body
print $cgi->h3("$file :
\n"),
"@filedata";
exit(0);
}
Test upload script using perl
Wednesday, November 7, 2007
Posted in: Test script | 0 Comments | Email This
Php Upload script
This script is 2 separate php files and a folder. The first piece of code is the form page, save as "upform.php".
The script is the second piece of code, save as "uploader.php". save both as .php files with 644 perms. create a folder called "data" with 777 perms in the same dir as the uploader.php script.
Below is the form code, save as upform.php (or whatever)
Below is the script, save as uploader.php:
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>
Posted in: Test script | 0 Comments | Email This
Perl mail script
#!/usr/bin/perl
# This is a simple script to test sendmail.
# Replace "me" with a from address and "mydom.com" with the #sending domain.
# Replace "you" with a username to send to and "yourdom.com" #with the recipient's domain name.
# Upload this to the public_html folder as mailtest.pl and CHMOD it to 755
print "Content-type: text/plain\n\n";
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me\@mydom.com\n";
print MAIL "To: you\@yourdom.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "Perl Sendmail is working, please check your code.";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}
Posted in: Test script | 0 Comments | Email This
ASP - MS Access basic connection
<%
'==============================================
' Test MS Access Connection
' This test can be used on .NET 1.1 and 2.0
' Testing only the connection to the database
' Make sure that the IUSR = Modify on the database
'==============================================
'Dim the variables
Dim dbPath, conObj
'SET THE VARIABLES HERE
dbPath = "c:\accounts\username\wwwroot\sample.mdb"
'create the connection object
set cnn = server.createobject("ADODB.Connection")
'open connection
cnn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="+ dbPath +""
'
'This is where you would do stuff with the database
'
'close the connection and kill the object
cnn.close
Set cnn = Nothing
%>
Test MS Access Connection
If you do not see any errors then the connection was successful
Posted in: Test script | 0 Comments | Email This
How to add favicon.ico
A favicon (short for "favorites icon"), also known as a page icon, is an icon associated with a p
articular website or webpage. Browsers that support favicons may display them in the browser's UR
L bar, next to the site's name in lists of bookmarks, and next to the page's title in a tabbed do
cument interface.
1. Upload the favicon.ico in the public_html directoy
2. Add the following code under the "title" tag
Posted in: Test script | 0 Comments | Email This
Test ASPX code
Modify the test aspx code according to the requirement:
TESTING
The time is now:
Posted in: Test script | 0 Comments | Email This
How to check real path function enabled in the server
The realpath function returns canonicalized absolute pathname.
chdir('/var/www/');
echo realpath('./../../etc/passwd');
?>
It will produce the output "/etc/passwd"
The CMS software such as e107 requires the realpath function. e107 will not support hosts that di
sable the realpath() function.
Posted in: Test script | 0 Comments | Email This
Enlarging image on single click
Enlarging image on single click
You can enlarge the picture by adding following script in the body part of the html page
Note: Single click and Double click on the picture will determine the action.
Posted in: Test script | 0 Comments | Email This