Maybe you could parse out the variable from the page?
Somthing like:

$page =~ /name="PHPSESSID" value="([^"+])"/
$sessionid = $1;
$action = "http://www.varig.com/gigof/web/LoginEscala.php";;
$response= $ua->request(POST $action,["PHPSESSID"=>$sessionid,
"sNomeGuerra"=>"RODRIGUES LOUREIRO",
"sEmail"=>"[EMAIL PROTECTED]",
"sMatricula"=>"856668",
"sCargo"=>"COP"]);

-----Original Message-----
From: Alexandre Loureiro [mailto:[EMAIL PROTECTED]
Sent: Saturday, November 01, 2003 11:27 PM
To: [EMAIL PROTECTED]
Subject: I can�t make perl log into a server


HI,
        I�m new to perl and using some books I�ve done some simple scripts
to make things easier. But now I�m having some problems login into a web
site ( secure using php login). I can log into the site but to navigate
futher i need a cookie to send some information to the site.
        It�s like an authentification, then it goes to empty page as follow:

<HTML>
<HEAD>
<TITLE> LOGIN VARIGOPS </TITLE>
</HEAD>
<BODY>
<Form name="frmLogin" Method="Post"
Action="http://www.varig.com/gigof/web/LoginEscala.php";> <input
type="hidden" name="PHPSESSID" value="4b48dec2dba00b149484710864f89942" />
 <Input type="hidden" name="sNomeGuerra" value="RODRIGUES LOUREIRO">
 <Input type="hidden" name="sEmail" value="[EMAIL PROTECTED]">
 <Input type="hidden" name="sMatricula" value="856668">
 <Input type="hidden" name="sCargo" value="COP">
</Form>

<script language="JavaScript">
 window.document.frmLogin.submit();
</script>
</BODY>
</HTML>

        
        This page using javascript is submited and redirected to another
page called http://www.varig.com/gigof/web/index2.htm and a cookie placed in
your machine. When i try to access one of the links iI�m redirect to the
login page again. The code for the page i try to access is: (but i�m really
interest in accessing the page tripvoo.php, with is using the cookie to
check your log)

<HTML>
<HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

<script language=JavaScript1.2>
<!--

/*
No Right Click
   
*/
 
if (window.Event) // Only Netscape will have the CAPITAL E.
  document.captureEvents(Event.MOUSEUP); // catch the mouse up event
 
function nocontextmenu()  // this function only applies to IE4, ignored
otherwise.
{
 event.cancelBubble = true
 event.returnValue = false;
 
 return false;
}
 
function norightclick(e) // This function is used by all others
{
 if (window.Event) // again, IE or NAV?
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnValue = false;
   return false;
  }
 
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others

function P7_JumpMenu(selObj,restore){ //v1.7 by Project Seven
 var theFullString = selObj.options[selObj.selectedIndex].value;
 if (restore) selObj.selectedIndex=0;
 var theLength = theFullString.length;
 var endPos = theFullString.lastIndexOf("~");
 var theUrl, theTarget, theParent;
 if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
 else {theUrl = theFullString;}
 endPos++
 if (endPos < theLength) {theTarget =
theFullString.substring(endPos,theLength)}
 else {theTarget = "window:Main";}
 if (theTarget == "window:New") {window.open(theUrl);}
 else if (theTarget == "window:Main")
{eval("parent.location='"+theUrl+"'");}
 else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}
//-->
</script>
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<script language="JavaScript"> 
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
</script>


<script type="text/javascript" language=JavaScript>
<!--
function readCookie(cookieName) {
 cookie_array = document.cookie.split ("; ")
 for (x=0; x < cookie_array.length; x++) {
  cookieParts_array = cookie_array[x].split("=")
  if (cookieParts_array[0] == cookieName) {
   return cookieParts_array[1]
  }
 }
 return null;
}
function DisplayInfo(pagina,janela,w,h,scrolling) {
 if (!scrolling) { scrolling='auto' }
 resultado =
window.open(pagina,janela,'width='+500+',height='+300+',scrollbars='+scrolli
ng+',toolbar=no,scrollbars=yes,location=no,status=no,menubar=no,resizable=ye
s,left=50,top=70')
}
// Abre popup
function falecomgigol() {
DisplayInfo('cir00403.htm','falegigof',800,600,'yes','yes');
}
// Enquete
function enquete(jan) {
DisplayInfo('',jan,500,440);
}
// Variaveis para banners
var cm8cat="br_capa";
var abc = Math.random() + "";
var num = abc.substring(2,abc.length);

// Today's Date
var now = new Date();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = now.getDate();
var yearNr=now.getYear();
if(dName==1) Day = "domingo";
if(dName==2) Day = "segunda";
if(dName==3) Day = "ter&ccedil;a";
if(dName==4) Day = "quarta";
if(dName==5) Day = "quinta";
if(dName==6) Day = "sexta";
if(dName==7) Day = "s&aacute;bado";
if(yearNr < 2000) Year = 1900 + yearNr;
else Year = yearNr;
// String to display current date.
var todaysDate =(" " + Day + ", " + dayNr + "/" + mName + "/" + Year);
function fpost()
{
sala=document._chatform.select[document._chatform.select.selectedIndex].valu
e;
nick=document._chatform.nick.value;
page = "http://chat.terra.com.br:9781/"; +sala+ "?NomeUsr=" +nick;
window.open(page,'_top');
return false;
}
//  -->
</script>
<script language="javascript">

function TrocaAzul(){
 window.TextoColorido.style.color="blue"
 tempo = setTimeout("TrocaVerde();", 300);
}

function TrocaVerde(){
 window.TextoColorido.style.color="red"
 tempo = setTimeout("TrocaAmarelo();", 300);
}

function TrocaAmarelo(){
 window.TextoColorido.style.color="gray"
 tempo = setTimeout("TrocaAzul();", 300);
}

</script>

<TITLE>:::: Bem-vindo!! Escala de Tripulantes ::::</TITLE>


<script language="JavaScript">
tempo = 10;
chars = 5;
texto = ":::: Bem-vindo!! Escala de Tripulantes ::::";
wtexto = new Array(33);
wtexto[0] = texto;
blnk = "
";//Mantenha este espa�o
for (i = 1; i < 32; i++) {
b = blnk.substring(0, i);
wtexto[i] = "";
for (j = 0; j < texto.length; j++) wtexto[i] = wtexto[i] + texto.charAt(j) +
b;
}
function animastatus() {
if (chars > -1) str = wtexto[chars];
else str = wtexto[0];
if (chars-- < -40) chars = 31;
status = str;
clearTimeout(tempo);
tempo = setTimeout("animastatus()", 70);
}
animastatus()
</script>

<SCRIPT language=JavaScript1.2>
<!--


function pop_cmr(){
 
window.open("msperro.htm","","width=600,height=300,scrollbars=scrolling,tool
bar=no,scrollbars=yes,location=no,status=no,menubar=no,resizable=yes,left=50
,top=70")
}


/*
No Right Click
   
*/
 
if (window.Event) // Only Netscape will have the CAPITAL E.
  document.captureEvents(Event.MOUSEUP); // catch the mouse up event
 
function nocontextmenu()  // this function only applies to IE4, ignored
otherwise.
{
 event.cancelBubble = true
 event.returnValue = false;
 
 return false;
}
 
function norightclick(e) // This function is used by all others
{
 if (window.Event) // again, IE or NAV?
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnValue = false;
   return false;
  }
 
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others

function P7_JumpMenu(selObj,restore){ //v1.7 by Project Seven
 var theFullString = selObj.options[selObj.selectedIndex].value;
 if (restore) selObj.selectedIndex=0;
 var theLength = theFullString.length;
 var endPos = theFullString.lastIndexOf("~");
 var theUrl, theTarget, theParent;
 if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
 else {theUrl = theFullString;}
 endPos++
 if (endPos < theLength) {theTarget =
theFullString.substring(endPos,theLength)}
 else {theTarget = "window:Main";}
 if (theTarget == "window:New") {window.open(theUrl);}
 else if (theTarget == "window:Main")
{eval("parent.location='"+theUrl+"'");}
 else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}
//-->
</SCRIPT>


<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>


<script language="JavaScript"> 
function openNewWindow(URLtoOpen, windowName, windowFeatures) {
newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
</script>

<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">



<style type="text/css">
<!--
.campos3 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size:
xxsmall; color: #000000; background: #EAECEE; border: #EAECEE; border-style:
single; border-top-width: thin; border-right-width: thin;
border-bottom-width: thin; border-left-width: thin}
-->
</style>

<style type="text/css"><!--BODY
{scrollbar-face-color:#EAECEE;scrollbar-highlight-color:#EAECEE;scrollbar-3d
light-color:#EAECEE;scrollbar-darkshadow-color:#EAECEE;scrollbar-shadow-colo
r:grey41;scrollbar-arrow-color:#5E8DD3;scrollbar-track-color:#EAECEE;}--></s
tyle>

<style type="text/css"><!--BODY
{scrollbar-face-color:EAECEE;scrollbar-highlight-color:#EAECEE;scrollbar-3dl
ight-color:#EAECEE;scrollbar-darkshadow-color:#EAECEE;scrollbar-shadow-color
:grey41;scrollbar-arrow-color:#5E8DD3;scrollbar-track-color:#EAECEE;}--></st
yle>
<script language="JavaScript">

function GOTO() {
var arquivo =
document.form1.destino.options[document.form1.destino.selectedIndex].value;
location.href=arquivo; 
return;
}

//-->

</script>
<style type="text/css">
<!--
FORM.tb{display:inline;}
.logo{text-decoration:underline;padding-top:5px;padding-bottom:5px;}
.nav2,.nav3,.nav4,.nav,.include,.select{font-family:arial,verdana,sans-serif
;}
.nav2{font-size:12pt;color:#CBD0A5;}
.nav3{font-size:12pt;font-style:italic;font-weight:bold;}
.nav4{font-size:9pt;}
A.nav{font-size:9pt;color:#CBD0A5;}
A.link{color:#03C;}A:hover{color:#CBD0A5;}
P{font:90% arial,helvetica,sans-serif;} 
.foot{font:90% arial,helvetica,sans-serif;}
.include A{font-size:9pt;color:#CBD0A5;}
.include A:hover{color:#CBD0A5};
.select{background:#CBD0A5;color:#CBD0A5;font-size:10pt;font-weight:bold;}
.headlines{text-decoration:none;color:#CBD0A5;font:9pt/9pt
geneva,arial,sans-serif;}
-->

</STYLE>



<META 
content="Escala de Tripulantes" 
name=description>
<META 
content="Escala de Tripulantes" 
name=keywords>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY bgColor=EAECEE leftMargin=0 topMargin=0 marginwidth="0"
marginheight="0" link="#000000" vlink="#000000" alink="#000000">
<script type="text/javascript" language=JavaScript>
<!--
var showPopup = readCookie('terracapa');
var Popup = new Array();

showPopup = ((showPopup == null) ? 1 : showPopup);

// nacional
 if (showPopup == 1) {
      Popup['url'] = 'cir00403.htm';
 Popup['w'] = 230;
 Popup['h'] = 220;
 showPopup = 2;

// popup back
} else if ((showPopup == 2) && (readCookie('terracapa_regional') != 'true'))
{
   Popup['url'] = 'cir00403.htm';
 Popup['w'] = 230;
 Popup['h'] = 220;
 showPopup = 0;

// regional
} else if (showPopup == 3) {
 showPopup = 1;
 document.cookie = "terracapa_regional=true;path=/;domain=.terra.com.br";

} else {
 Popup['url'] = '';
 Popup['w'] = 0;
 Popup['h'] = 0;
 showPopup = 0;
}

if (Popup['url']) DisplayInfo(Popup['url'], 'terracapa'+showPopup,
Popup['w'], Popup['h']);
document.cookie = "terracapa="+showPopup+";path=/;domain=.terra.com.br";
// -->
</script>


<font color="#FFFFFF"><br>
</font></font><font size="2"><font face="Arial, Helvetica,
sans-serif">ESCALA NA INTERNET</font></font></a><font
color="#000000"><u><font size=3><br></font></u></font></b><font size="1"
color="#000000" face="Arial, Helvetica, sans-serif">Consulte sua Escala
Planejada. <font color="#FF3333">Dispon&iacute;vel Novembro/2003
</font></font></p>


As you can see there is a function to check the cookie. I uses some
variables like made by the LoginEscala.php  (I�ve made some hacking w/ a
friend and made the script LoginEscala.php show some errors)

Like this:

Warning: session_start() [function.session-start]: The session id contains
illegal characters, valid characters are only a-z, A-Z and 0-9 in
E:\gigof\web\LoginEscala.php on line 6

Warning: session_start() [function.session-start]: Cannot send session cache
limiter - headers already sent (output started at
E:\gigof\web\LoginEscala.php:6) in E:\gigof\web\LoginEscala.php on line 6

Warning: Cannot modify header information - headers already sent by (output
started at E:\gigof\web\LoginEscala.php:6) in E:\gigof\web\LoginEscala.php
on line 15

Warning: Unknown(): The session id contains illegal characters, valid
characters are only a-z, A-Z and 0-9 in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that
the current setting of session.save_path is correct (C:\PHP\sessiondata) in
Unknown on line 0


        The problem is the variable (name="PHPSESSID"
value="4b48dec2dba00b149484710864f89942") how can i get this to send to the
script LoginEscala.php ? I�ve checked some documentation for php and this
number is stored in the variable $_SESSION below follow a part of the PHP
Manual.

  Note: As of PHP 4.1.0, $_SESSION is available as a global variable just
like $_POST, $_GET, $_REQUEST and so on. Unlike $HTTP_SESSION_VARS,
$_SESSION is always global. Therefore, you do not need to use the global
keyword for $_SESSION. Please note that this documentation has been changed
to use $_SESSION everywhere. You can substitute $HTTP_SESSION_VARS for
$_SESSION, if you prefer the former. Also note that you must start your
session using session_start() before use of $_SESSION becomes available. 

Sorry to trouble you w/ this long email but I�m very interested in solving
this with perl. 

Note: to authenticate i�ve used an example of the book Perl & LWP

Thanks in advance.

Aral

Reply via email to