Skip to content

Instantly share code, notes, and snippets.

View SomeAB's full-sized avatar

Ahmad Bilal SomeAB

View GitHub Profile
@SomeAB
SomeAB / Hello World
Last active August 29, 2015 13:56
Hello World in Perl 5
#!/usr/bin/perl-Tw
use strict;
print "Content-type: text/html\n\n";
print "Hello World!\n";
#!/usr/bin/perl -Tw
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser); # show errors in browser
#Set cookie according to RFC 6265
my $AAA= "Set-Cookie: SID=4343; Path=/; Secure; Httponly; Domain=yourwebsite.com; lang=en-US; Max-Age=3600";
print $AAA;
#Begin script output
#!/usr/bin/perl -Tw
use cPanelUserConfig;
use CGI;
use DBI;
$dbh = DBI->connect('DBI:mysql:NameofDatabase', 'NameofUser', 'passwordofUser'
) || die "Could not connect to database: $DBI::errstr";
$dbh->do('CREATE TABLE exmpl_tbl (id INT, val VARCHAR(100))');
$dbh->do('INSERT INTO exmpl_tbl VALUES(1, ?)', undef, 'Hello');
<div id="header"><a href="#">Home</a></div>
<style type='text/CSS'>
#header {
z-index: 999;
position: fixed;
top: 0;
width: 100%;
margin-top: 0;
padding: 28px;
@SomeAB
SomeAB / Simple Login Form
Last active August 29, 2015 13:57
A login form that submits(posts) the data to a perl script
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div>
<form method="post" action="/cgi-bin/login.pl">
<p>Username:</p><input type="text" name="username" value="" maxlength="40" required autofocus></br>
<p>Password:</p><input type="password" name="password" value="" maxlength="40" required></br>
#!/usr/bin/perl -Tw
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser); # show errors in browser, can be removed later
#Catching and Holding the incoming data
my $cgi = CGI->new;
my $username = undef;
$username = $cgi->param("username");
my $password = undef;
$ sudo stat -f '%Lp%t%N' /usr/local/www/apache24/site/ *
644 /usr/local/www/apache24/fileA.html
644 /usr/local/www/apache24/fileB.html
755 /usr/local/www/apache24/cgi
644 /usr/local/www/apache24/fileC.html