Skip to content

Instantly share code, notes, and snippets.

@Mstrodl
Created June 15, 2017 04:12
Show Gist options
  • Save Mstrodl/4a4e9b18948a53fe4df75003e9c5a77c to your computer and use it in GitHub Desktop.
Save Mstrodl/4a4e9b18948a53fe4df75003e9c5a77c to your computer and use it in GitHub Desktop.
#use strict;
use warnings;
print "Content-Type:text/html\r\n\r\n";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
$output = `$cgi_dir/add.sh`;
print "$output";
#!/bin/sh
DIR=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )
cd ../teacherhw
#echo "<form action=\"cgi-bin/cfg.pl\" method=\"get\"><label>Enter a username:</label><br> <input type=\"text\" name=\"username\"></input><br><label>Enter the name students refer to you as (i.e. Mr.🅱enis):</label><br><input type=\"text\" name=\"refer\"></input><br><label>Enter the subject: </label><select name=\"subject\">"
echo """
<form action="moda.pl" method="get">
<label>Enter a username:</label><br> <input type="text" name="username"></input><br>
<label>Enter an assignment (use <code>&lt;br&gt;</code> for a new line):</label><br>
<textarea rows="5" cols="45" name="assign"></textarea><br>
<label>Enter the subject: </label><select name="subject">
"""
for file in *.sub.txt
do
sub=$(echo "$file" | sed 's/.sub.txt//')
echo "<option value=\"$sub\">$sub</option>"
done
echo "<option value=\"*\">* - All you have written hw to before</option></select><br>"
echo "<input type=\"submit\" name=\"subbtn\" value=\"Save Homework\"><form>"
#!/usr/bin/perl
print "Content-Type:text/plain\r\n\r\n";
print "";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
use CGI qw(:cgi-lib :standard); # Use CGI modules that let people read data passed from a form
&ReadParse(%in); # This grabs the data passed by the form and puts it in an array
$username = $in{"username"}; # Get the user's name and assign it to variable
$refer = $in{"refer"}; # Get the user's assignment and assign it to a variable
$subject = $in{"subject"};
print "Saved assignment: ";
print "$assign\r\n\r\n";
print "for user $username\r\n\r\n";
print "DEBUG: $ENV{'QUERY_STRING'}";
system( "sh", "$cgi_dir/cfg.sh", "$username", "$refer", "$subject" );
#!/bin/sh
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
refername="$2"
username="$1"
sub="$3"
cd $DIR/..
echo "refername=$refername" > "$DIR/../teacherhw/$username.$sub.html.data.txt"
#use strict;
use warnings;
print "Content-Type:text/html\r\n\r\n";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
$output = `$cgi_dir/confweb.sh`;
print "$output";
#!/bin/sh
DIR=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )
cd ../teacherhw
echo "<form action=\"cfg.pl\" method=\"get\"><label>Enter a username:</label><br> <input type=\"text\" name=\"username\"></input><br><label>Enter the name students refer to you as (i.e. Mr.🅱enis):</label><br><input type=\"text\" name=\"refer\"></input><br><label>Enter the subject: </label><select name=\"subject\">"
for file in *.sub.txt
do
sub=$(echo "$file" | sed 's/.sub.txt//')
echo "<option value=\"$sub\">$sub</option>"
done
echo "<option value=\"*\">* - All That Have Been Setup (For fixing old cfg)</option></select><br>"
echo "<input type=\"submit\" name=\"subbtn\" value=\"Write Config\"><form>"
#!/usr/bin/perl
print "Content-Type:text/html\r\n\r\n";
print "";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
print '<form action="viewcustom.pl" method="get">';
$sdata = `$cgi_dir/dropdata.sh`;
for ($count=1; $count<15; $count++)
{
print '<label>Enter a custom code and subject:</label><br> <input type="text" name="';
print "t$count";
print '" value=""></input><select name="';
print "t$count";
print 's">';
print "$sdata";
}
print '<input value="';
print "15";
print '" name="txtboxes" type="hidden"> </input>';
print '<br><input type="submit" value="View custom feed"> </input>';
print '<form>';
print '<br><br>';
print '<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">eZhw</span> by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Matthew 🅱enis</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.';
#!/bin/bash
# dropdata.sh
#
#
# Created by Matthew 🅱enis on 3/23/15.
#
DIR=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )
ls
pwd
cd ../teacherhw
ls
pwd
for file in *.sub.txt
do
sub=$(echo "$file" | sed 's/.sub.txt//')
echo "<option value=\"$sub\">$sub</option>"
done
echo "</select><br>"
#!/usr/bin/perl
#use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;
$CGI::POST_MAX = 1024 * 50000;
my $safe_filename_characters = "a-zA-Z0-9_.-";
my $query = new CGI;
my $user = $query->param("username");
my $sub = $query->param("subject");
my $filename = $query->param("up");
if ($0=~m#^(.*)\\#) {
my $cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
my $cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
my $cgi_dir = "$1";
}
$cgi_dir = $cgi_dir;
system("bash", "mkdir", "$cgi_dir/../ups/$user . $sub;", "chmod", "777", "$cgi_dir/../ups/$user . $sub");
my $upload_dir = "$cgi_dir/../ups/$user.$sub";
if ( !$filename )
{
print $query->header ( );
print "There was a problem uploading your attachment (try a smaller file).";
exit;
}
my ( $name, $path, $extension ) = fileparse ( $filename, '..*' );
$filename = $name . $extension;
$filename =~ tr/ /_/;
$filename =~ s/[^$safe_filename_characters]//g;
if ( $filename =~ /^([$safe_filename_characters]+)$/ )
{
$filename = $1;
}
else
{
die "Filename contains invalid characters";
}
my $upload_filehandle = $query->upload("up");
print "$upload_dir\r";
print "$cgi_dir\r";
print "$user\r";
print "$sub\r";
print "$filename\r";
open ( UPLOADFILE, ">$cgi_dir/../ups/$user . $sub/$filename" ) or die "$!";
binmode UPLOADFILE;
while ( <$upload_filehandle> )
{
print UPLOADFILE;
}
close UPLOADFILE;
print $query->header ( );
print <<END_HTML;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thanks!</title>
<style type="text/css">
</style>
</head>
<body>
<p>Thanks $user for uploading your attachment for your $sub class!</p>
<p>Also please do your share and delete old attachments when they're no longer needed! Thanks! It helps A <u>Lot</u></p>
<p>Your upload:</p>
<p><iframe src="../ups/$user.$sub/$filename" showBorder="0" width="100%"/></p>
</body>
</html>
END_HTML
#system("bash", "source $cgi_dir/../teacherhw/$user.$sub.html.data.txt;", "rm -f $cgi_dir/../ups/$user.$sub.\$upext");
#system( "bash", "source $cgi_dir/../teacherhw/$user.$sub.html.data.txt;", "echo", "refername=\$refername", ">", "$user.$sub.html.data.txt;", "echo", "upext=$extension", ">>", "$cgi_dir/../teacherhw/$user.$sub.html.data.txt");
#use strict;
use warnings;
print "Content-Type:text/html\r\n\r\n";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
$output = `$cgi_dir/homework.sh`;
print "$output";
print '<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">eZhw</span> by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Matthew 🅱enis</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.';
#!/bin/bash
# homework.sh
#
# Yaay! It's Editable Without The Need For My Original Setup Scripts!
#
# Created by Matthew 🅱enis on 3/21/15.
#
#Basic Setup For Generic Parts Of Page
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd "$DIR/../teacherhw"
echo '<head><style>p {font-size: 75%;} h3 {font-size: 1.1em;}</style></head>'
echo '<html> <body> <h1>Homework</h1> <style> h1 { color: red; } h2 { color: orange; } h3 { color: #3333FF; } </style>'
#Code Has Long Since Improved From This Rough Idea ;)
#
#for file in *.html
#do
#source $file.data.txt
##echo '<html> <body> <h1>Homework</h1> <style> h1 { color: red; } h2 { color: orange; } h3 { color: yellow; } </style>'
#echo "<h2>$sub</h2>"
#echo '<h3>'
#echo "$name"
#echo '</h3> <iframe src=/teacherhw/'
#echo "$file"
#echo 'scrolling=no> <p>your browser doesnt support iframe</p> </iframe>'
#done
# Hope This Works!
# Achievement Get! Be Semi Geeky!
#
###Searches for all subjects and loads config
for file in *.sub.txt
do
#source $file
sub=$(echo $file | sed 's/.\{8\}$//')
echo '<h2>'
echo "$sub"
echo '</h2>'
#########Adds All Teachers In The Loaded Subject
for file in *.$sub.html
do
source $file.data.txt
username=$(echo $file | sed s/\.$sub\.html//)
echo '<h3>'
echo "$refername"
echo '</h3>'
echo "<iframe src=\"../teacherhw/$file"
echo '" scrolling=no width="100%"> <p>your browser doesnt support iframe</p> </iframe>'
if [ -e $DIR/../ups/$username.$sub.$upext ]
then
echo "<br><iframe src=\"../ups/$username.$sub.$upext\" width=\"100%\"></iframe>"
fi
echo '<br><p>Custom Code: <b>'
echo "$username"
echo '</b></p>'
done
done
#!/usr/bin/perl
print "Content-Type:text/plain\r\n\r\n";
print "";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
use CGI qw(:cgi-lib :standard); # Use CGI modules that let people read data passed from a form
&ReadParse(%in); # This grabs the data passed by the form and puts it in an array
$username = $in{"username"}; # Get the user's name and assign it to variable
$assign = $in{"assign"}; # Get the user's assignment and assign it to a variable
$subject = $in{"subject"};
print "Saved assignment: ";
print "$assign\r\n\r\n";
print "for user $username\r\n\r\n";
print "DEBUG: $ENV{'QUERY_STRING'}";
system( "sh", "$cgi_dir/moda.sh", "$username", "$assign", "$subject" );
#!/bin/sh
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
username="$1"
assign="$2"
sub="$3"
cd $DIR/..
rm -f $DIR/../teacherhw/$username.html
touch $DIR/../$username.html
echo "<!DOCTYPE html> <html> <body> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <style> body { color: green; } </style> </head> $assign </body> <script type="application/javascript" src="../cgi-bin/iframeResizer.contentWindow.min.js"></script> </html>" >> "$DIR/../teacherhw/$username.$sub.html"
#use strict;
use warnings;
print "Content-Type:text/html\r\n\r\n";
if ($0=~m#^(.*)\\#) {
$cgi_dir = "$1";
} elsif ($0=~m#^(.*)/# ) {
$ cgi_dir = "$1";
} else {`pwd` =~ /(.*)/;
$ cgi_dir = "$1";
}
$output = `$cgi_dir/upweb.sh`;
print "$output";
#!/bin/sh
DIR=$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )
cd ../teacherhw
#echo "<form action=\"cgi-bin/cfg.pl\" method=\"get\"><label>Enter a username:</label><br> <input type=\"text\" name=\"username\"></input><br><label>Enter the name students refer to you as (i.e. Mr.🅱enis):</label><br><input type=\"text\" name=\"refer\"></input><br><label>Enter the subject: </label><select name=\"subject\">"
echo """
<form action="fileup.pl" method="post">
<label>Enter a username:</label><br> <input type="text" name="username"></input><br>
<label>Select Attachment (WARNING THIS WILL OVERWRITE PREVIOUS ATTACHMENTS!): </label><input type=file name="up"><br>
<label>Enter a subject: </label><select name="subject">
"""
for file in *.sub.txt
do
sub=$(echo "$file" | sed 's/.sub.txt//')
echo "<option value=\"$sub\">$sub</option>"
done
echo "<option value=\"*\">* - All you have written hw to before</option></select><br>"
echo "<br><input type=submit name=\"Upload Attachment\">"
#!/usr/bin/perl
print "Content-Type:text/html\r\n\r\n";
print "";
use CGI qw(:cgi-lib :standard); # Use CGI modules that let people read data passed from a form
&ReadParse(%in); # This grabs the data passed by the form and puts it in an array
$txtboxes = $in{"txtboxes"};
#This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/.
print '<html> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /> <body><h1>Custom Homework Feed</h1>';
#print '<script type="text/javascript" src="jquery.browser.js"></script>';
#print '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>';
print "<style>";
print "iframe {";
print "border: 0px solid #ffffff;";
print "}";
print "</style>";
$t1 = $in{"t1"};
$t2 = $in{"t2"};
$t3 = $in{"t3"};
$t4 = $in{"t4"};
$t5 = $in{"t5"};
$t6 = $in{"t6"};
$t7 = $in{"t7"};
$t8 = $in{"t8"};
$t9 = $in{"t9"};
$t10 = $in{"t10"};
$t11 = $in{"t11"};
$t12 = $in{"t12"};
$t13 = $in{"t13"};
$t14 = $in{"t14"};
$t1s = $in{"t1s"};
$t2s = $in{"t2s"};
$t3s = $in{"t3s"};
$t4s = $in{"t4s"};
$t5s = $in{"t5s"};
$t6s = $in{"t6s"};
$t7s = $in{"t7s"};
$t8s = $in{"t8s"};
$t9s = $in{"t9s"};
$t10s = $in{"t10s"};
$t11s = $in{"t11s"};
$t12s = $in{"t12s"};
$t13s = $in{"t13s"};
$t14s = $in{"t14s"};
if ($t1 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t1.$t1s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t2 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t2.$t2s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t3 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t3.$t3s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t4 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t4.$t4s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t5 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t5.$t5s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t6 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t6.$t6s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t7 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t7.$t7s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t8 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t8.$t8s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t9 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t9.$t9s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t10 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t10.$t10s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t11 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t11.$t11s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t12 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t12.$t12s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t13 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t13.$t13s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
if ($t14 eq '')
{ } else {
print '<iframe src="../teacherhw/';
print "$t14.t14s";
print '.html" scrolling=no marginheight="0" ';
print "";
print '> <p>your browser doesnt support iframe</p> </iframe> <br>';
}
print '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>';
print "\n";
print '<script type="application/javascript" src="jquery.iframeResizer.min.js">';
print "\n";
print "\t\t\t";
print '$(';
print "'iframe'";
print ').iFrameSizer({';
print "\n\t\t\t\t";
print 'log: true,';
print "\n\t\t\t\t";
print 'doWidth: true,';
print "\n\t\t\t\t";
print 'doHeight: true,';
print "\n\t\t\t";
print '});';
print "\n";
#print '<br>';
print "\n\t\t";
print '</script>';
print "\n\n\t\t";
print '<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">eZhw</span> by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Matthew 🅱enis</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment