Skip to content

Commit

Permalink
fixed newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
georgiaw committed Aug 2, 2012
1 parent 055356a commit 8a96891
Show file tree
Hide file tree
Showing 15 changed files with 1,416 additions and 1,416 deletions.
Binary file modified .DS_Store
Binary file not shown.
258 changes: 129 additions & 129 deletions frameworkgui/attach2Agents.pl
@@ -1,129 +1,129 @@
#!/usr/bin/perl
use DBI;
use Cwd;

# Read the standard input (sent by the form):
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}


$number = $FORM{"agentPhNo"};
$controlnumber = $FORM{"controlPhNo"};
$path = $FORM{"agentURLPath"};
$key = $FORM{"agentControlKey"};
$platform = $FORM{"platformDD1"};



##----- put your code here
$dir = getcwd;
$configfile = $dir . "/config";
open(CONFIG, "+<$configfile");
while (<CONFIG>)
{
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
($var, $value) = split(/\s*=\s*/, $_, 2);
$Variables{$var} = ${value};
}
$Variables{"OS"} = $^O;
$webserver = $Variables{"WEBSERVER"};
$fullpath = $webserver. $path;
$command1 = "mkdir " . $fullpath;
system($command1);
$controlfile = $fullpath . "/control";
$command2 = "touch " . $controlfile;
system($command2);
$command3 = "chmod 777 " . $controlfile;
system($command3);
$picturefile = $fullpath . "/picture.jpg";
$command4 = "touch " . $picturefile;
system($command4);
$command5 = "chmod 777 " . $picturefile;
system($command5);
$textfile = $fullpath . "/text.txt";
$command6 = "touch " . $textfile;
system($command6);
$command7 = "chmod 777 " . $textfile;
system($command7);
$pictureupload = $fullpath . "/pictureupload.php";
$command8 = "touch " . $pictureupload;
system($command8);
$command9 = "chmod 777 " . $pictureupload;
system($command9);
$pictureuploadtext = "<?php\n\$base=\$_REQUEST['picture'];\necho \$base;\n\$binary=base64_decode(\$base);\nheader('Content-Type: bitmap; charset=utf-8');\n\$file = fopen('picture.jpg', 'wb');\nfwrite(\$file, \$binary);\nfclose(\$file);\n?>";
open(PICFILE, ">$pictureupload");
print PICFILE $pictureuploadtext;
close(PICFILE);
$textupload = $fullpath . "/textuploader.php";
$command10 = "touch " . $textupload;
system($command10);
$command11 = "chmod 777 " . $textupload;
system($command11);
$textuploadtext = "<?php\n\$base=\$_REQUEST['text'];\nheader('Content-Type: text; charset=utf-8');\n\$file = fopen('text.txt', 'wb');\nfwrite(\$file, \$base);\n?>";
open(TEXTFILE, ">$textupload");
print TEXTFILE $textuploadtext;
close(TEXTFILE);
$controlupload = $fullpath . "/controluploader.php";
$command12 = "touch " . $controlupload;
system($command12);
$command13 = "chmod 777 " . $controlupload;
system($command13);
$controluploadtext = "<?php\n\$base=\$_REQUEST['text'];\nheader('Content-Type: text; charset=utf-8');\n\$file = fopen('control','wb');\nfwrite(\$file, \$base);\n?>";
open(CONTROLFILE, ">$controlupload");
print CONTROLFILE $controluploadtext;
close(CONTROLFILE);
$putfile = $fullpath . "/putfunc";
$command14 = "touch " . $putfile;
system($command14);
$command15 = "chmod 777 " . $putfile;
system($command15);
$table = "agents";
$table2 = "data";
$sqlserver = $Variables{"MYSQLSERVER"};
$username = $Variables{"MYSQLUSER"};
$password = $Variables{"MYSQLPASS"};
$port = $Variables{"MYSQLPORT"};
$dbh = DBI->connect("dbi:mysql:database=framework;host=$sqlserver;port=$port", $username,$password);
$number2 = "\"" . $number . "\"";
$path2 = "\"" . $path . "\"";
$key2 = "\"" . $key . "\"";
$controlnumber2 = "\"" . $controlnumber . "\"";
$platform2 = "\"" . $platform . "\"";
$insertquery = "INSERT INTO $table (id,number,path,controlkey,controlnumber,platform) VALUES (DEFAULT,$number2,$path2,$key2,$controlnumber2,$platform2)";
$insertquery2 = "INSERT INTO $table2 (id,sms,contacts,picture,root) VALUES (DEFAULT, NULL, NULL, NULL, NULL)";
$sql = $dbh->prepare($insertquery);
$sql->execute;
$sql2 = $dbh->prepare($insertquery2);
$sql2->execute;
$query2 = "SELECT id from agents where number=" . $number;
$sql = $dbh->prepare($query2);
$idblah = $sql->execute;
@rows = $sql->fetchrow_array();
$id = @rows[0];
$startcommand = "perl agentpoll.pl " . $path . " " . $key . " " . $id;
$pid = fork;
die "fork failed" unless defined $pid;
if ($pid ==0)
{
system($startcommand);
}

##----- end of your code

my $url = "menu.pl";
print "Location: $url\n\n";
#!/usr/bin/perl
use DBI;
use Cwd;

# Read the standard input (sent by the form):
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}


$number = $FORM{"agentPhNo"};
$controlnumber = $FORM{"controlPhNo"};
$path = $FORM{"agentURLPath"};
$key = $FORM{"agentControlKey"};
$platform = $FORM{"platformDD1"};



##----- put your code here
$dir = getcwd;
$configfile = $dir . "/config";
open(CONFIG, "+<$configfile");
while (<CONFIG>)
{
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
($var, $value) = split(/\s*=\s*/, $_, 2);
$Variables{$var} = ${value};
}
$Variables{"OS"} = $^O;
$webserver = $Variables{"WEBSERVER"};
$fullpath = $webserver. $path;
$command1 = "mkdir " . $fullpath;
system($command1);
$controlfile = $fullpath . "/control";
$command2 = "touch " . $controlfile;
system($command2);
$command3 = "chmod 777 " . $controlfile;
system($command3);
$picturefile = $fullpath . "/picture.jpg";
$command4 = "touch " . $picturefile;
system($command4);
$command5 = "chmod 777 " . $picturefile;
system($command5);
$textfile = $fullpath . "/text.txt";
$command6 = "touch " . $textfile;
system($command6);
$command7 = "chmod 777 " . $textfile;
system($command7);
$pictureupload = $fullpath . "/pictureupload.php";
$command8 = "touch " . $pictureupload;
system($command8);
$command9 = "chmod 777 " . $pictureupload;
system($command9);
$pictureuploadtext = "<?php\n\$base=\$_REQUEST['picture'];\necho \$base;\n\$binary=base64_decode(\$base);\nheader('Content-Type: bitmap; charset=utf-8');\n\$file = fopen('picture.jpg', 'wb');\nfwrite(\$file, \$binary);\nfclose(\$file);\n?>";
open(PICFILE, ">$pictureupload");
print PICFILE $pictureuploadtext;
close(PICFILE);
$textupload = $fullpath . "/textuploader.php";
$command10 = "touch " . $textupload;
system($command10);
$command11 = "chmod 777 " . $textupload;
system($command11);
$textuploadtext = "<?php\n\$base=\$_REQUEST['text'];\nheader('Content-Type: text; charset=utf-8');\n\$file = fopen('text.txt', 'wb');\nfwrite(\$file, \$base);\n?>";
open(TEXTFILE, ">$textupload");
print TEXTFILE $textuploadtext;
close(TEXTFILE);
$controlupload = $fullpath . "/controluploader.php";
$command12 = "touch " . $controlupload;
system($command12);
$command13 = "chmod 777 " . $controlupload;
system($command13);
$controluploadtext = "<?php\n\$base=\$_REQUEST['text'];\nheader('Content-Type: text; charset=utf-8');\n\$file = fopen('control','wb');\nfwrite(\$file, \$base);\n?>";
open(CONTROLFILE, ">$controlupload");
print CONTROLFILE $controluploadtext;
close(CONTROLFILE);
$putfile = $fullpath . "/putfunc";
$command14 = "touch " . $putfile;
system($command14);
$command15 = "chmod 777 " . $putfile;
system($command15);
$table = "agents";
$table2 = "data";
$sqlserver = $Variables{"MYSQLSERVER"};
$username = $Variables{"MYSQLUSER"};
$password = $Variables{"MYSQLPASS"};
$port = $Variables{"MYSQLPORT"};
$dbh = DBI->connect("dbi:mysql:database=framework;host=$sqlserver;port=$port", $username,$password);
$number2 = "\"" . $number . "\"";
$path2 = "\"" . $path . "\"";
$key2 = "\"" . $key . "\"";
$controlnumber2 = "\"" . $controlnumber . "\"";
$platform2 = "\"" . $platform . "\"";
$insertquery = "INSERT INTO $table (id,number,path,controlkey,controlnumber,platform) VALUES (DEFAULT,$number2,$path2,$key2,$controlnumber2,$platform2)";
$insertquery2 = "INSERT INTO $table2 (id,sms,contacts,picture,root) VALUES (DEFAULT, NULL, NULL, NULL, NULL)";
$sql = $dbh->prepare($insertquery);
$sql->execute;
$sql2 = $dbh->prepare($insertquery2);
$sql2->execute;
$query2 = "SELECT id from agents where number=" . $number;
$sql = $dbh->prepare($query2);
$idblah = $sql->execute;
@rows = $sql->fetchrow_array();
$id = @rows[0];
$startcommand = "perl agentpoll.pl " . $path . " " . $key . " " . $id;
$pid = fork;
die "fork failed" unless defined $pid;
if ($pid ==0)
{
system($startcommand);
}

##----- end of your code

my $url = "menu.pl";
print "Location: $url\n\n";

0 comments on commit 8a96891

Please sign in to comment.