wgetting a forum as a registered user - authentication

I want to sample the main page of a forum to do some statistics. The main page is only visible to registered members. How would I download it using wget? I tried logging in via a browser, then passing that browser's cookie file to wget, but it doesn't work.
EDIT: Here's the login form code:
<table border="0" cellpadding="3" cellspacing="1" width="100%">
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td width="45%" align="right"><span class="gen">User:</span></td>
<td><input type="text" name="username" size="25" maxlength="40" value="" class="post2" id="focus" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
</tr>
<tr>
<td align="right"><span class="gen">Password:</span></td>
<td><input type="password" name="password" size="25" maxlength="25" class="post2" onFocus="Active(this)" onBlur="NotActive(this)" /></td>
</tr>
<tr align="center">
<td colspan="2"><span class="gen">Remember me: <input type="checkbox" name="autologin" /></span></td>
</tr>
<tr align="center">
<td colspan="2"><input type="hidden" name="redirect" value="" /><input type="submit" name="login" class="mainoption" value="Log in" /></td>
</tr>
<tr align="center">
<td colspan="2"><span class="gensmall">I forgot the password</span></td>
</tr>
</table>

Wget accept some parameters like --http-user=user --http-passwd=password, aside with proxies and certificate methods. Did you try one of these ?
How does the forum authentification works ?

Look at the construction of the login form within that page. If it's a typical POST form, retrieve the names of the elements which make up the form, and construct a wget query which will pass these in to the page that the form is submitted to
In this example, the form fields are called 'username' and 'password':
wget http://www.myforum.com/login.php --post-data="username=jeffrey&password=mypassword"
You will than have downloaded just the login page. With some configuration of other wget options, you should then be able to get it to traverse to the homepage and download this (especially if there is a link to it on the post login page). You may even get lucky and your forum automatically redirects you to the main page after login; in which case, wget will download this for you at that point (depending on the type of redirection issued by the server).

Related

How can I add info icon with details next to input fields?

My input fields look like this:
<table class="something">
<tbody>
<tr>
<td style="vertical-align:top;width:60%;padding-right:25px">
<label><i class="far fa-calendar-alt"></i> Something:</label> (<em>something</em>) </td>
<td style="vertical-align:top;width:20%">
<label class="something" for="something">something:</label>
<input id="something" name="something" step="any" type="number" value=""> </td>
</tr>
</tbody>
</table>
How can I add an info icon with some text next to my inputs? I've found some solutions, but those are not fully responsive, they didn't work in all devices. A good example of what I want: https://bankmonitor.hu/lakashitel-kalkulator/?link_type=tile-menu-item
Thank you!

Selenium - Navigation gets stuck after clicking a drop down (prior to an iframe switch)

The code clicks and pops up an overlay (successful). I am able to switch to iframe (using the driver.switchTo().frame(2)). Once selecting an element and clicking the Accept button, the overlay closes. Now I switch back to the main page using driver.switchTo().defaultContent(). The problem occurs soon after the code clicks a dropdown in the main page. This dropdown is not the typical Select or Option type (Select() or <option>). The elements are listed in a <table>.
There is no error displayed in the console but the program hangs. It stops the navigation after clicking the drop down and then no response.
Please find the html portion:
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl03"
id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_ctl03" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl04"
id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_ctl04" value="-1" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl05" />
<input type="hidden" name="ctl00$cph$ctl02$TEST$FORM$ctl06$ctl32$ctl01$ctl06" />
<div id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_outerFrame"
class="DropdownOuterContainer theme2 boarderA font7 shadow1" style="display:none;">
<div id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_innerFrame"
class="DropdownInnerContainer" style="z-index:99;">
<table id="ctl00_cph_ctl02_TEST_FORM_ctl06_ctl32_ctl01_tbl"
class="DropdownItemContainer" list="120">
<tr class="">
<td value="" index="0" title="">
</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act1" index="1" plid="1001">Act1</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act2" index="2" plid="1002">Act2</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act3" index="3" plid="1003">Act3</td>
<td class="BorderCell"></td>
</tr>
<tr class="">
<td value="Act4" index="4" plid="1004">Act4</td>
<td class="BorderCell"></td>
</tr>
</table>
In the code I am trying to select an option 'Act1' using the below statements. Note that only the first line executes, i.e, it clicks the drop down but then it doesn't move forward to the next step, where the selection happens.
driver.findElement(By.xpath(".//*[#id='ctl00_cph_ctl02_TEST$FORM_ctl06_ctl32_ctl01']")).click();
driver.findElement(By.xpath(".//*[#id='ctl00_cph_ctl02_TEST$FORM_ctl06_ctl32_ctl01_tbl']/tbody/tr/td[1][contains(text(),'Act1')]")).click();

click on a checkbox selenium java

Hi, I want to b able to click on a check box based on a value. Below is the html of the same:
<tbody>
<tr>
<th>Record Type</th>
<th style="text-align:center">Has Access?</th>
<th style="text-align:center">Can Create?</th>
<th style="text-align:center">Can Read All Records?</th>
</tr>
<tr>
<td>
<input id="ORMW.S2.0.Object Type" class="readOnlyField" type="text" value="Account" maxlength="255" size="25" name="ORMW.S2.0.Object Type" readonly="readonly"/>
</td>
<td align="center">
<input id="ORMW.S2.0.Has Access_VP123456" type="checkbox" onclick="cbValue(this,'ORMW.S2.0.Has\x20Access');" style="margin-left:0px;margin-top:1px;height:10px;width:10px;vertical-align:middle"/>
<input id="ORMW.S2.0.Has Access" type="hidden" value="Y" tabindex="-1" name="ORMW.S2.0.Has Access"/>
</td>
<td align="center">
<td align="center">
I want to click on checkbox based on the value account here.
Next query will search element by #value='Account' then traverse up to the first tr and then search your checkbox:
//input[#type='text' and #value='Account']/ancestor::tr[1]//input[#type='checkbox']
you can also try this:
//input[#type='checkbox' and preceding-sibling::input[#type='text' and #value='Account']]

CFFILE upload - insert file location into SQL db at the same time?

I have a little page that has a form with a few fields in it. Also included is a file upload function. I need to be able to have the filename of the file being uploaded to be inserted into the 'sURL' field, when the form is submitted. (The sURL field can be populated automatically with this filename or can also be manually entered if it is an external URL). I have looked at other people with this issue and there seems to be no straightforward fix? Is anyone able to shed some light?
<html><head>
<title>New Survey Entry</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
function check ( form )
{
if (form.ul_path.value == "") {
alert( "Please select the file to upload." );
form.ul_path.focus();
return false ;
}
return true ;
}
</script>
<CFIF NOT isDefined("dir")>
<CFSET dir = "">
</CFIF>
<CFIF NOT isDefined("clientFile")>
<CFSET clientFile = "">
</CFIF>
<CFQUERY NAME="getpub" DATASOURCE="testpage" DBTYPE="ODBC">
SELECT *
FROM surveypubs
ORDER BY sGroup asc
</CFQUERY>
<h2><center>NEW SURVEY ENTRY</center></h2>
<table cellpadding="3" cellspacing="3" class="font13">
<cfoutput>
<form name="input" enctype="multipart/form-data" action="index.cfml?cat=test&page=insertSurvey" method="post">
<tr>
<td valign="middle" align="left"><b>Year:</b></td>
<td colspan="3"><input name="sYear" type="text" size="8" value="<CFOUTPUT>#year(now())#</CFOUTPUT>"><input name="sYear_required" type="hidden" value="You must enter a Year."></td>
</tr>
</cfoutput>
<tr>
<td valign="middle" align="left"><b>Group:</b></td>
<td colspan="3"> <select name="sGroup">
<option value="">--- Select One ---</option>
<cfoutput query="getpub"><option value="#sGroup#">#sGroup#</option></cfoutput>
</select> <br> Don't see the Survey Group? Click here to add.
</td>
</div><br><br>
</tr>
<tr>
<td valign="middle" align="left"><b>Title:</b></td>
<td colspan="3"><input name="sTitle" type="text" size="85"><input name="sTitle_required" type="hidden" value="You must enter a Title."></td>
</tr>
<tr>
<td valign="middle" align="left"><b>Comment:</b></td>
<td colspan="3"><input name="sComment" type="text" size="85"></td>
</tr>
<tr>
<td valign="middle" align="left"><b>URL:</b></td>
<td colspan="3"><input name="sURL" type="text" size="85"></td>
</tr>
<td valign="bottom" align="left"><b>URL Type:</b></td>
<td colspan="3">
<input type="radio" name="surlType" value="0" checked> Internal <input type="radio" name="surlType" value="1"> External</td>
</tr>
<cfoutput>
<input name="dateAdded" type="hidden" value="#dateformat(now(),"mm-dd-yyyy")#">
</cfoutput>
<tr>
<td></td>
<form action="/index.cfml?cat=test&page=inputSurvey" method="POST" enctype="multipart/form-data" name="upload_form" id="upload_form" onsubmit="return check(this);">
<CFIF structKeyExists(form, "ul_path") and len(form["ul_path"])>
<CFFILE ACTION="UPLOAD" FILEFIELD="ul_path" DESTINATION="D:\testpage\docs\" NAMECONFLICT="OverWrite">
<CFSET ClientFilePath = "#clientDirectory#\#clientFile#">
</CFIF>
<td colspan="3" align="left">Click on the Browse button to select the file to Upload:<br>
<input type="file" name="ul_path" id="ul_path" style="height: 22px;width: 350px;" value=""></td>
</tr>
<tr>
<td></td>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit"> <input name="clear" value="Clear" type="reset"> <input type="button" name="back" value="Back" class="input" onClick="javascript:history.back();"></td>
</tr>
</table>
</form>
<cfif isDefined("CFFILE.ClientFile")>
<cfset form.sURL = "#CFFILE.ClientFile#">
<cfelse>
<cfset form.sURL = "null">
</cfif>
<cfoutput><input type="hidden" name="sURL" id="sURL" value="http://testpage.com/docs/#ClientFile#"/></cfoutput>
</form>
</body>
</html>
Use the result attribute of cffile, this will then give you a structure of data about your upload, including the directory the file was stored in as well as the file name. Add result='moo' to your cffile call and then do a cfdump of moo to see all the data.
Check out this link for more info on what is returned in result
I sense that what you are trying to do is not being answered here. What you seem to be trying to do is on the client before the file is uploaded. You wish to collect the name of the file the user has chosen from his or her file system and using JS populate some other form field - which may contain the name of the file or possible some URL value or something else provided by the user.
That's different from collecting the name of the form after it is submitted because it runs afoul of browser protections. I really don't think there's an adequate solution in JS to this. You might find a solution that works in some browsers but I doubt it will be consistent.
I could be wrong of course. I'd be glad to have someone show me a solution.

how to pass value of text to "a href"

I need you help me with asp code.
I got a home page that contained User Name and Password for user to log in by using a href attribute and i don't know how to pass the value of text to a href to login.asp file.
Please help me!
Example:
<table>
<tr>
<td>User</td>
<td><input type="text" id="user"/></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="pass"/></td>
</tr>
<tr>
<td>Log in</td>
</tr>
</table>
First of all the username and password text box must be inside a form element
e.g.
<form name="myForm" id="myForm" method="post" action="login.asp">
<input type="text" name="username"/>
<input type="password" name="password"/>
Login
</form>
and in your .asp page you can get the values as
Request.Form("username")
Request.Form("password")