Archive for the ‘code’ Category

gettinig PDF form field names

Wednesday, October 21st, 2009

If you have a PDF and want to fill the pdf programmatic-ally, You can but you need those pdf’s form fields.

Here’s a simple Java Class which can help you. I am using iText as my PDF library.

import java.util.HashMap;
import java.util.Iterator;
import com.lowagie.text.pdf.*;

public class iTextSample {
public static void main(String[] args) throws Exception{
PdfReader reader = new PdfReader(“/Users/Admin/Public/jars/a.pdf”);
boolean test = reader.isEncrypted();

System.out.println(test);

AcroFields form = reader.getAcroFields();
HashMap fields = form.getFields();
System.out.println(“Total Fields: ” + fields.size());
String key;
for (Iterator i = fields.keySet().iterator(); i.hasNext(); ) {
key = (String) i.next();
switch(form.getFieldType(key)) {

case AcroFields.FIELD_TYPE_TEXT:
{
System.out.print(key + “: “);
System.out.print(“Text”);
System.out.print(“, At Page:” + form.getFieldItem(key).getPage(0));
System.out.println(“, at tab:” + form.getFieldItem(key).getTabOrder(0));
}
break;

}
}
}
}

Stop using rediff

Thursday, July 9th, 2009

I have reasons to believe that rediff’s code quality has become really pathetic day by day. Delivery managers aren’t paying attention to the feedbacks. They keep putting bad code and pile up stacks of powerful servers to hide their bad programming practices!

Its high time Rediff ! WAKE UP!

After my initial post on a full quality analysis of rediff which can be found here I thought they would improve the quality but they went worse. Neither did they improve the quality but they left out loop holes for themselves for hackers to hack in.

The below screenshots would explain:

rediff_bad_coding Click to enlarge

rediff_code_horror Click to enlarge

I did email the product manager, but he asked me to wait and I’m still waiting!!

Picture 3 Click to enlarge.

So now I’ve decided that I will stop using Rediff, and go to other news sites which are good for my browser.

SSH proxy – Running SSH over blocked ports, SSH on mobile phones, SSH over HTTP

Thursday, February 12th, 2009

Imagine yourself in a scenario where you’re a behind a firewall and cannot access the SSH, or you’re controlling your servers via your mobile. Here’s a quick way to manage your servers through HTTP via command line. You can fire scripts, run shell commands etc.

Be careful, it will not ask you any username/password and runs with username Apache/SYSTEM.

The script is tested over linux and windows servers!

ssh-over-http1

ssh-over-http2

All you need is an Apache server with PHP installed. Just create a PHP file and insert the following code.

Put in a comment if this really helped you!

//— BEGIN OF CODE—-

<html>
<head>
<title>HussuLinux SSH over HTTP…</title>
</head>
<body>
<form id=”form1″ name=”form1″ method=”post” action=”">
<label>Enter Command
<input type=”text” name=”cmd” />
</label>
<input type=”submit” name=”Submit” value=”Submit” />
</form>

Output :
<textarea cols=”100″ rows=”30″>
<?php
$cmd = $_POST['cmd'];
if ($cmd==”")
{
//Do Nothing!
}
else
{
echo htmlspecialchars((shell_exec($cmd)));
}
?>
</textarea>
</body>
</html>

//— END OF CODE—–