-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poster.pl
230 lines (200 loc) · 7.54 KB
/
poster.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/usr/bin/perl
# Felipe Gonzalez Perl Blog Admin
########################################################
#
# COPYRIGHT NOTICE
# Copyright 2004 Felipe A. Gonzalez
# All Rights Reserved.
#
# This script can be used\modified free of charge
# as long as you don't change this header, or the
# parts of this script that generates the script
# info. If you really need to remove these, go to
#
#
# By using this script you agree to indemnify me from
# any liability that might arise from its use.
#
# Redistributing\selling the code for this program
# without prior written consent is expressly
# forbidden.
#
########################################################
#
# By Computer Science Engineer: Felipe Alfonso Gonzalez
# EMail: (f.alfonso@res-ear.ch)
# Started : Jan 16, 2005
#
########################################################
#
# If this script doesn't work for you try
# adjusting the first line above to
# #!/usr/local/bin/perl
# DO NOT REMOVE THE # OR ! or add any spaces.
#
# IF YOU WANT TO USE IT FOR YOUR OWN DONT FORGET
# TO MAKE IT EXECTUABLE, (CHMOD +X *.pl) AND TO
# GIVE IT THE RIGHT PERMISSIONS, (CHMOD 755 *.pl).
########################################################
my($database,$host,$data_source,$username,$password,$dbh,$usr_log,$usr_pwd);
########################################################
# DB Configuration
########################################################
$database = "felipe";
$host = "localhost";
$username = "root2";
# set the password here;
$password = "root2";
#------------------------------------------------------
$data_source = "DBI:mysql:$database:$host";
########################################################
#calling the libraries
#llamando a las librerias
use CGI;
use strict;
use warnings;
use DBI;
my $cgi=new CGI; #read in parameters
#print $cgi->header(); #print a header
print "Content-type: text/html\n\n";
print "<title>PerlMemoPad - Perl Mini Weblog</title>";
print "<link href=\"./style.css\" rel=\"stylesheet\" type=\"text/css\" >";
print " <link rel=\"icon\" href=\"./favicon.ico\" type=\"image/ico\" > ";
print " <link rel=\"shortcut icon\" href=\"./favicon.ico\" type=\"image/ico\" > ";
#print "<script type=\"text/javascript\" language=\"javascript\" src=\"js.js\"></script>";
#print "<script language=\"JavaScript\">
#<!--
#var username = prompt(\"Ingrese Nombre de Usuario\",\"\")
#var password = prompt(\"Ingrese Password\",\"\")
#if (username !=\"$usr_log\" || password !=\"$usr_pwd\")
#{ top.location=\"about:Bad Username and/or Password\" }
#else
#//{
#//top.location=\"./blog.pl\"
#//}
#//-->
#</script>";
my ($qs);
my $version = "1.0b";
#print $cgi->start_html("written at the fly and left behind by the world wide web - in version $version"); #generate html document
print "<pre>";
#print" -- - *.cgi-bin:,:/,,*.pl,,,,.. post it,. at any time\n";
print" a note: html, is a href=blahblahblah.html target=_blank\n";
print" do not use quotation marks.i\n";
# print " <b> <a href=\"post.pl\">./post.pl</a></b><br>\n";
#generrating a input box text for search paarameters
#print " <br><form method=\"post\" action=\"py.pl?$qs \">";
#print "<input type=text name=\"qs\">";
#print " <input type=\"submit\" value=\"Buscar Noticias\">";
#print "</center><br>";
#----- printing sys info
#my $sys = "system(\"uptime\");";
#print "<br>$sys<br>";
#system("uptime");
#print "<h3>";
#system("date");
#print "</h3>";
print "<hr size=1><br>";
#end
#print "Results:<i><b> ", $cgi->param('qs'), "</b></i> .
# Results:<br>";
#
#delcaring the variables
my ($sth, $sth2, $sth3, $a, $b, $c, $d);
#conection to the db using the DBI library application
#my $dbh=DBI->connect('dbi:mysql:py', 'root', 'fafarafa') ||
#my $dbh=DBI->connect('DBI:mysql:database=py;host=sdf.zapto.org','root','') ||
# die "Error opening database: $DBI::errstr\n";
$dbh = DBI->connect($data_source, $username, $password) or die "Imposible conectar con $data_source: " . $dbh->errstr . "\n";
#$dbh->disconnect || die "Failed to disconnect\n";
#in the following section the intention is to build an sql with post var
#$qs = $FORM{'s'};
#my($qs);
#if ($FORM{'qs'} eq "$qs") {
#my $qs = $cgi->param('qs');
#if (my $qs = $cgi->param('qs')) {
#}
#print "$sth\n";
$sth2=$dbh->prepare("select * from pmpad ORDER BY id DESC;") ||
die "Prepare failed: $DBI::errstr\n";
#print "$sth\n";
$sth2->execute() ||
die "Couldn't execute query: $DBI::errstr\n";
#my ($e);
#built a boocle to display the reached notices
#my("$a, $b, $c, $d");
#time
while (($a, $b, $c, $d) = $sth2 ->fetchrow_array) {
#print "<pre>";
#print "<a href=\"?id=$a\">";
#print "<s><b><i>ID: $a </i></b></s>\n";
#print "</a>";
#print " date: $b\n";
#print " --<a href=\"?id=$a#show\"> $c </a>";
#print " --<a href=\"comment.pl?id=$a\"> $c </a>";
print " $b\n ";
#print " $time\n";
print $c;
#print " </pre>";
}
#variables
my ($sth5, $date, $subject, $FORM, $submit, $message, $post);
#my ($sth5, $date );
print "<form action=\"poster.pl?id=\"$a\"\" method=post>";
print "<table><tr><td>";
print "<font size=1 face=terminal> ";
print "<textarea name=\"subject\" size=24 class=white rows=3 cols=28 wrap=virtual></textarea><br> ";
#print "<textarea name=subject class=white rows=8 cols=28 wrap=virtual>subject</textarea> ";
print "<font size=1 face=terminal> ";
print "<s> ";
print "<textarea name=message class=white rows=8 cols=28 wrap=virtual></textarea> ";
print "<s><input type=submit class=white value=\"post\"> <input type=reset class=white value=\"reset\"></td></tr></s>";
print "</table></form>";
#inserting the data into the database
if (my $subject = $cgi->param('subject')) {
my $message = $cgi->param('message');
my($time);
$time=(localtime(time));
#print "$time";
$sth5=$dbh->prepare("INSERT INTO `pmpad` ( `id` , `date` , `pre_note` , `note` )
VALUES (
'', '$time', '$subject', '$message'
);") ||
die "Prepare failed: $DBI::errstr\n";
$sth5->execute() ||
die "Couldn't execute query: $DBI::errstr\n";
print " Submitted! ";
print "<script LANGUAGE=\"JavaScript\">
var pagina=\"poster.pl\"
function redireccionar()
{
location.href=pagina
}
setTimeout (\"redireccionar()\", 1000);
</script>";
}
print "<hr size=1><br>";
print "<left>Programmed in Perl / MySQL by Felipe Alfonso Gonzalez (felipe\@nic-nac-project.org)</left>";
print "</pre>\n";
#display for id
#my($id, $sth3);
if (my $id = $cgi->param('id')) {
$sth3=$dbh->prepare("select * from pmpad where id like '%$id%' ;") ||
die "Prepare failed: $DBI::errstr\n";
#print "$sth\n";
$sth3->execute() ||
die "Couldn't execute query: $DBI::errstr\n";
my($k,$l, $z, $x, $v);
while (($k, $l , $z, $x, $c) = $sth3 ->fetchrow_array) {
print "<a name=\"show\">";
print "<pre>";
print ("$k\n");
print ("$l\n");
print ("$z\n");
print ("$x\n");
print ("$v\n");
print "</font></pre>";
}
}
#
print $cgi->end_html();