4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Need help convering this perl script from php to perl
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Nik
Junior WebHelper
Junior WebHelper


Joined: 29 Apr 2003
Posts: 2

PostPosted: Tue Apr 29, 2003 4:39 pm (20 years, 11 months ago) Reply with QuoteBack to Top

This is the php script that i want to convert to perl:

Code:

<?php
ob_start();  error_reporting(E_ALL);  $xronos=date("l dS of F h:i:s A");  $host=gethostbyaddr($_SERVER['REMOTE_ADDR']);  $i=0;
echo "<body background=images/anemos.jpg>";
echo "<font size=5 color=Yellow>";

if (@mysql_connect('localhost', 'nik', 'macgyver'));
else @mysql_connect('localhost', 'root');
mysql_select_db('db_nik');

$data = file("data.txt");
$diary = file("diary.txt");
?>


<script type="text/javascript">
var textToShow = "<? echo join('"+String.fromCharCode(13)+"', array_map('addslashes', (array_map('trim', $data)))); ?>";
var pos = 0;
var tm;

function init()
{ tm = setInterval("type()", 50) }

function type()
{
   if (textToShow.length != pos)
   {
      d = document.getElementById("divText");
      c = textToShow.charAt(pos++);
      if (c.charCodeAt(0) != 13)
         d.appendChild(document.createTextNode(c));
      else
         d.appendChild(document.createElement("br"));
   }
   else
      clearInterval(tm);
}
</script>

<center><font size=5 color=LightGreen>- &#919; &#949;&#965;&#967;&#942; &#964;&#959;&#965; &#921;&#951;&#963;&#959;&#973; -<p>
<body background=images/anemos.jpg onload=javascript:init()>
  <div id=DivText align=Left style="
    background: url(images/blueblack.jpg);
    border-color: Yellow;
    border-style: Groove;
    border-width: 10;
    width: 900;
    height: 520;
    color: LightBlue;
    font-face: Com;
    font-size: 18">
  </div>
</body><p>

<form action="logos_post.php" method="post">
<table border=1 width=80% align=Center bordercolor=Yellow style='border-style: solid; border-width: 5' background=images/blue.jpg>
  <tr>
    <td align=center> <font size=5 color=Lightgreen>&#928;&#974;&#962; &#963;&#949; &#955;&#941;&#957;&#949;?</font> </td>
    <td align=center> <input type="text" name="onoma"> </td>
  </tr>
  <tr>
    <td align=center> <font size=5 color=Lightgreen>&#928;&#959;&#953;&#972; &#949;&#943;&#957;&#945;&#953; &#964;&#959; &#963;&#967;&#972;&#955;&#953;&#959; &#963;&#959;&#965; &#949;&#960;&#943; &#964;&#959;&#965; &#952;&#941;&#956;&#945;&#964;&#959;&#962;?</font> </td>
    <td align=center> <textarea name="sxolio" rows=4 cols=25 wrap="on"></textarea> </td>
  </tr>
  <tr>
    <td align=center> <font size=5 color=Lightgreen>&#928;&#959;&#953;&#972; &#949;&#943;&#957;&#945;&#953; &#964;&#959; e-mail &#963;&#959;&#965;?</font> </td>
    <td align=center> <input type="text" name="email"> </td>
  </tr>
  <tr>
    <td align=center> <input type="submit" name="emfanisi" value="&#917;&#956;&#966;&#940;&#957;&#953;&#963;&#951;"> </td>
    <td align=center> <input type="submit" name="kataxorisi" value="&#913;&#960;&#959;&#963;&#964;&#959;&#955;&#942;"> </td>
  </tr>
</table>
</form><br>


<?
echo "<center><font size=4 color=Cyan>";

foreach($diary as $lineno=>$line)
  if($line=="\n") unset($diary[$lineno]);

$diary = array_values($diary);
$quote=$diary[rand(0, count ($diary)-1)];

echo "<table border=1 width=90% align=Center bordercolor=Yellow style='border-style: solid; border-width: 5' background=images/blue.jpg>";
  echo "<tr>";
    echo "<td>";
       echo "<center><font size=4 color=Cyan>$quote";
    echo "</td>";
  echo "</tr>";
echo "</table>";

echo "<br>";
echo "<center><font size=4 color=Orange> $xronos";
echo "<center><font size=4 color=Pink> $host";

mysql_query("UPDATE counter SET logos=logos+1");
$sql = mysql_query("SELECT logos FROM counter");
$logos = mysql_fetch_array($sql);

echo "<center><font size=5 color=Yellow> $logos[0]";
echo "<center><a href=personal><img src=images/cross.gif></a>";

mail ("nik0s@mycosmos.gr", "&#917;&#960;&#943;&#963;&#954;&#949;&#968;&#951; &#923;&#972;&#947;&#959;&#965; $host => $logos[0]", "", "From: 007@spy.gr");
?>




I have tried to make it to perl but i could only manage this:
Code:

#!perl
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use DBI;
use DBD::mysql;

$xronos = localtime;  $i=0;
$iaddr = pack 'C4', split /\./, $ip;
($host) = gethostbyaddr($iaddr, 2);

$db = DBI->connect("DBI:mysql:nik_db", {RaiseError => 1}) or
$db = DBI->connect("DBI:mysql:nik_db", "nik", "macgyver", {RaiseError => 1});

print header(), start_html( -title => "Didaxes Patros Paisiou", -background => "/images/anemos.jpg" );

open(IN, "data.txt");
while ($x=<IN>) {
   print p(b($x));
}
close(IN);

print br(), br();
print table( {-border => 5, -align => "center", -background => "images/blue.jpg"},
      Tr( th( [h3("Pos se lene file"),         textfield('onoma')] ) ),
      Tr( th( [h3("Poio einai to sxolio sou"), textarea( -name => "sxolio", -rows => 4, -columns => 25 )] ) ),
      Tr( th( [h3("Poio einai to e-mail sou"), textfield('email')] ) ) ),
      br(), br(), br();

open(IN, "diary.txt");
while (<IN>) {
   push (@diary, $_);
}
$quote=$diary[int(rand(@diary))];

print table( {-border => 5, -align => "center", -background => "images/blue.jpg"},
     Tr( th( h4( {-align => "center"}, $quote ) ) ) );

$sql = "UPDATE counter SET visitor = visitor + 1";
$db->do( $sql );

$st = $db->prepare( "SELECT visitor FROM counter" );
$st->execute();
@visitor = $st->fetchrow_array();

print h3( {-align => "center"}, $xronos);
print h3( {-align => "center"}, $host);
print h3( {-align => "center"}, $visitor[0]);           

#a( {-href => "personal"}, "img src=images/cross.gif" );
#exec("mail nik0s\@mycosmos.gr");


Pls help me with this, i am having very hard time converting it...

Thank you.

________________________________
Intel Inside, Idiot Outside !!
OfflineView User's ProfileFind all posts by NikSend Personal MessageSend emailVisit Poster's Website
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Tue Apr 29, 2003 5:41 pm (20 years, 11 months ago) Reply with QuoteBack to Top

Why do you need to convert it if you don't mind me asking?
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Nik
Junior WebHelper
Junior WebHelper


Joined: 29 Apr 2003
Posts: 2

PostPosted: Wed Apr 30, 2003 12:36 am (20 years, 11 months ago) Reply with QuoteBack to Top

well i am almost there.....because i have quit php an iam learning perl

Code:

#!perl
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use Socket;
use DBI;
use DBD::mysql;

$xronos = localtime;  $i=0;
$host = gethostbyaddr(inet_aton($ENV{REMOTE_ADDR}), AF_INET);

$db = DBI->connect("DBI:mysql:nik_db", {RaiseError => 1}) or
$db = DBI->connect("DBI:mysql:nik_db", "nik", "macgyver", {RaiseError => 1});

print header(), start_html( {-title => "Didaxes Patros Paisiou", -background => "http://localhost/images/anemos.jpg"} );

open(IN, "<data.txt") || die $!;
   @data = <IN>;
close(IN);
$data = join("", @data);


#*******************************************************************************
print <<ENDOFHTML;
<html><head><title></title>
<script type="text/javascript">
var textToShow = "$data";
var pos = 0;
var tm;

function init()
{ tm = setInterval("type()", 50) }

function type()
{
   if (textToShow.length != pos)
   {
      d = document.getElementById("divText");
      c = textToShow.charAt(pos++);
      if (c.charCodeAt(0) != 13)
         d.appendChild(document.createTextNode(c));
      else
         d.appendChild(document.createElement("br"));
   }
   else
      clearInterval(tm);
}
</script>


<center><font size=5 color=LightGreen>- ? e??? t?? ??s?? -<br>
<body background=images/anemos.jpg onload=javascript:init()>
  <center>
  <div id="DivText" align="Left" style="
    background: url(images/blueblack.jpg);
    border-color: Yellow;
    border-style: Groove;
    border-width: 10;
    width: 900;
    height: 500;
    color: LightBlue;
    font-face: Com;
    font-size: 19">
  </div>
</body>
</html>
ENDOFHTML
#*******************************************************************************


print br(), br();
print table( {-border => 5, -align => "center", -background => "http://localhost/images/blue.jpg"},
      Tr( th( [h3("Pos se lene file"),         textfield('onoma')] ) ),
      Tr( th( [h3("Poio einai to sxolio sou"), textarea( -name => "sxolio", -rows => 4, -columns => 25 )] ) ),
      Tr( th( [h3("Poio einai to e-mail sou"), textfield('email')] ) ) ),
      br(), br();

open(IN, "<tips.txt") || die $!;
   @tips = <IN>;
close(IN);
$tips=$tips[int(rand(@tips))];

print table( {-border => 5, -align => "center", -background => "http://localhost/images/blue.jpg"},
      Tr( th( h4( {-align => "center"}, $tips ) ) ) );

$sql = "UPDATE counter SET visitor = visitor + 1";
$db->do( $sql );

$st = $db->prepare( "SELECT visitor FROM counter" );
$st->execute();
@visitor = $st->fetchrow_array();

print h3( {-align => "center"}, $xronos);
print h3( {-align => "center"}, $host);
print h3( {-align => "center"}, $visitor[0]);             

print a( {href => "http://www.jokes.gr"}, img {src => "http://localhost/images/cross.gif"} );
#exec("mail nik0s\@mycosmos.gr");


well the scripts works but i cant seem to see one char afer another like typing in the js. could u hel me correct it??

and also the exec thing?

________________________________
Intel Inside, Idiot Outside !!
OfflineView User's ProfileFind all posts by NikSend Personal MessageSend emailVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.26808 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme