Archive for the ‘php’ Category

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—–

Creating sequences in MySQL an alternative to AUTO_INCREMENT

Thursday, January 15th, 2009

MySQL doesn’t doesn’t have sequences and Auto_Increment does not suffice the need for a text based sequence generator. Or say you want to reset AUTO_INCREMENT’s value?

So here’s a workaround for a generating a sequence in MySQL which can be reset later.

Step 1: Create a Table

CREATE TABLE IF NOT EXISTS `seqgen` (
`seqno` int(4) unsigned NOT NULL,
`application_id` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Step 2: Add your application in the sequence
INSERT INTO `seqgen` (`seqno`, `application_id`) VALUES (0, ‘myappname’);
Now when inserting I have set the seqno = 0 , because I want my sequence to start with 0;

Step 3:  You can create a Stored Proc or a Function to get the value and increment it by 1
<Remember to add this Proc/Function through command line with delimiter, else it will not work>

delimiter //
CREATE PROCEDURE seq_gen( OUT nextval INT , IN applicationid text)
BEGIN
select seqno into nextval from seqgen where application_id = applicationid;
update seqgen SET seqno = seqno + 1 where application_id = applicationid;
commit;
END;
//

—OR Function —- If you use function note that you’ll have to commit it by your program, MySQL doesn’t allow implicit or explicit commit in a Stored Function. So better use Procedure..

delimiter //
CREATE FUNCTION f_seq_gen(applicationid text)
RETURNS INT
BEGIN
DECLARE
nextval INT;
select seqno into nextval from seqgen where application_id = applicationid;
update seqgen SET seqno = seqno + 1 where application_id = applicationid;
RETURN nextva;
END;
//

Step 4: Access your sequence by

select f_seq_gen(‘myappname”);

Now you can use many such applications as Sequences in MySQL

Most popular windows – linux equivalent softwares

Thursday, December 25th, 2008

0) Windows – Linux

1) uTorrent  – rTorrent

If you like uTorrent, you will definitely like rTorrent. Its much simpler and easier to use!

2) Remote Desktop – rDesktop/VNC

If you want to share desktops, use VNC. If you want to Remote desktop to a windows machine from a linux system, use rDesktop

3) Yahoo/MSN – Pidgin

Your all in one instant messenger. Gives you better features: Major one being, you can login with multiple accounts on the same system! Isn’t that cool?!

4) IE – Firefox

Ok, we all know how good firefox is!

5) Outlook – Thunderbird

DONT USE OUTLOOK unless you want to screw your system up with hackers around! Use Thunderbird for windows and linux both!

6) Photoshop – Gimp

Gimp is quite matured now! It gives  you better brushes than photoshop..

7) Dreamweaver – Quanta Plus

Used dreamweaver since long and cant use it in linux? Try Quanta..

8 ) MS Office – OpenOffice.org

I’ve personally stopped using MS Office on windows too ( Ok, Ive stopped using windows too)

9) VMWare – Virtual Box

Virtual box is still a bit buggy, but you’ll not get to know unless you’re a hacker.

10) Notepad – GEdit/VI

We all know this!

11) Media Player – VLC Player

VLC is not in looks, but neither is Media Player.

12) WSFTP – Filezilla

Use filezilla for both , windows and Linux