Monday, 8 June 2009

 

XRDP

I recently was asked how to provide an RDP session to a Linux Machine. Phoowey! I replied, you can't RDP to a Linux box, and yet, someone I work with pointed me in the direction of XRDP - a package on Sourceforge.

I performed the following steps on a VMWare host running Ubuntu 8.10, but there's no reason why it shouldn't work on 9.04 or even 8.04.

Why would you want to RDP to a Linux machine? If you've got a windows host, you don't always want to be running more and more different software to access that remote host - like VNC or X over SSH, so this seems like an effective solution if you don't want your client machines to need additional software.

Some people don't like to permit SSH through their firewalls as you can do an awful lot with a badly configured SSHd. In another situation, we have been using a device (which I don't manage I should add) to access a development network. This device acts as a reverse proxy, and permits access to various websites, but most importantly, also proxies access to RDP systems, so this request was driven by that need.

Here's what I did to configure up the XRDP on this Ubuntu 8.10 desktop

# apt-get install build-essential libpam0g-dev libssl-dev tightvncserver

Visit https://sourceforge.net/projects/xrdp/ then click on Download, Browse all packages, click on the latest release (currently 0.4.1), Copy the link for filename xrdp-x.x.x.tar.gz

# wget http://path/to/file/xrdp-x.x.x.tar.gz
# tar xfz xrdp-x.x.x.tar.gz
# cd xrdp-x.x.x
# make
# sudo make install
# cp /usr/local/xrdp/xrdp_control.sh /etc/init.d/
# update-rc.d -f xrdp_control.sh defaults

Labels: , ,


Thursday, 8 January 2009

 

PHP Object Orientation - a brief introduction

This week, I attended PHPNW, which is a monthly meeting for PHP developers in Manchester. While I was there, I got talking to Adrian Hardy about Object Orientated PHP - something which has confused me for a while.

Let me explain. Originally, PHP had no Object Orientation to it at all, but in late version 4, the developers started to add Object Orientated methods and calls to PHP. I never really saw the point of coding in an OO way, but we had a bit of a talk about how OO works, and I must admit, I'm a bit of a convert.

So, for a first example, Adrian talked me through writing some code. Here's what we wrote (ish - I have my own coding standards, so have changed a bit from what he told me to write, but the fundamentals are there):
class Person {
private $name='';
private $sex=FALSE;

public function setName($name='') {
$this->name=$name;
}

public function setSex($sex='') {
$this->sex=$sex;
}

public function doWalk() {
if($this->name!='') {
if($this->sex!=FALSE) {
echo "Hello, I'm {$this->name}, a {$this->sex}, and I'm going for a walk\r\n";
} else {
echo "Hello, I'm {$this->name} and I'm going for a walk\r\n";
}
}
}
}

$body_one=new Person;
$body_one->setName("Sam");
$body_two=new Person;
$body_two->setName("Bob");
$body_two->setSex("Male");
$body_one->doWalk();
$body_two->doWalk();
This should give us the text:
Hello, I'm Sam and I'm going for a walk
Hello, I'm Bob, a Male, and I'm going for a walk
Of course, all this is very good, but there are three reasons I love the idea of OO, and the first is that you can extend a class, and the second is you can auto-populate your class with all it's data using a construct function. So, here's an example of extending the class "Person" (which, in effect copies all the functions and variables from the Person Class to the Man class), and using a construct function. This will return the same result as before, but with two extra lines at the end.
class Person {
private $name='';
private $sex=FALSE;

public function setName($name='') {
$this->name=$name;
}

protected function setSex($sex='') {
$this->sex=$sex;
}
      if($this->sex!=FALSE) {

echo "Hello, I'm {$this->name}, a {$this->sex}, and I'm going for a walk\r\n";
} else {
echo "Hello, I'm {$this->name} and I'm going for a walk\r\n";
}
}
}
}

Class Man extends Person {
public function __construct($name='') {
if($name!='') {$this->name=$name;}
$this->sex="Male";
}

protected function setSex($sex='') {
if($sex!=$this->sex) {echo "Congratulations, you have changed your sex!\r\n";}
$this->sex=$sex;
}
}

$body_one=new Person;
$body_one->setName("Sam");
$body_two=new Man("Bob");
$body_one->doWalk();
$body_two->doWalk();
$body_two->setSex("Female");
$body_two->doWalk();
Now looks like:
Hello, I'm Sam and I'm going for a walk
Hello, I'm Bob, a Male, and I'm going for a walk
Congratulations, you have changed your sex!
Hello, I'm Bob, a Female, and I'm going for a walk
The last thing I like the idea of, is to auto load classes... so, in your index page, or default include, you'd include this code:
spl_autoload_register('__autoload_me');
ini_set('include_path', '.');

function __autoload_me($strClass) {
echo "Searching for: $strClass\r\n";
$strFilename="./$strClass.php";
if(file_exists($strFilename)) {
require_once($strFilename);
} else {
return false;
}
}
This spl_autoload_register can be included as many times as you want, and is called for each new class that hasn't already been retrieved. You don't need to call it __autoload_me, you could call it Class_Loading_DoHicky or Call_Classes_With_Me or whatever your coding standards say, but doing something obvious like __autoload_me means you'll never miss it :)

That's it for now, I hope I've not made it too complicated :)

Labels: , , , , ,


Thursday, 11 December 2008

 

Explaining the gibberish in my status updates

I was asked yesterday what the "gibberish" was in my status update on Facebook. I tried to explain it in a comment, but really, I ran out of space, and not being able to show people what I was talking about makes it a bit difficult!

So, here's what I wrote:
@nikdoof @dantheman @fabsh A #LUGCamp or #FOSSCamp would be a good idea, perhaps with keynotes by #UUPC, #LinuxOutlaws?
Because of the way that Facebook works, it can be updated by an external website - for example identi.ca or twitter



You will notice that both of these sites have a pretty standard template. Picture on one side, name of person next to the photo and then a message, finished by the date of the message. Like blogs, facebook and myspace, these systems are starting to become ubiqutious. Most news channels now have a twitter feed, and during the recent Presidential Elections, Barack Obama used Twitter (amongst other Social Networking systems) to rally support.

Twitter and Identi.ca (and others) are collectively known as Micro-blogs, or Microblogging sites, because of the size of the updates, which is limited to 140 characters, which is set at this size to be used (initially) with SMS, as a single SMS message would contain the nickname of the person who sent the message and their message.

Most microblogging sites follow a common convention for referring to things, so people are usually prefixed by an @ sign (for example @jontheniceguy), and a subject of interest will be prefixed by the # symbol (for example #bcliverpool). So that explains the symbols, but how about the words?

Here's what I wrote again:
@nikdoof @dantheman @fabsh A #LUGCamp or #FOSSCamp would be a good idea, perhaps with keynotes by #UUPC, #LinuxOutlaws?
So, we now know that I wrote to three people, nikdoof, dantheman and fabsh, the last two are presenters of a podcast, and the first the organiser of the Liverpool Linux Users Group, and I proposed that we should organise a "LUGCamp or FOSSCamp". LUG stands for Linux Users Group and FOSS (sometimes written as FLOSS) stands for Free (Libre) and Open Source Software. Linux is the basis of an alternative operating system to Windows or MacOS, but unlike Windows or OS X, it has a permissive license, which allows it to be given away for free, and installed on as many computers as the user wishes, without requiring any license feeds to be paid.

My inspiration for this event was another event I attended this past weekend, which was a "BarCamp". Now, a BarCamp is not something to do with drinking (although plenty occurred), but instead refers to computing jargon. A BarCamp is an "Unconference", where participants of the event, on their arrival, decide if they will be doing a talk, and if so, indicate to all the other participants by putting the details of their talk on a post-it note, which they then place on the schedule, which is usually a blank sheet of paper just detailing the available rooms. A BarCamp will tend to discuss computer topics, but can just as easily have a discussion about hypnotism, environmental issues or football! It tends to be a "geeky" event, but that isn't to say that non-geeks aren't welcome - in fact, frequently they will be welcomed to the group and encouraged to talk about what they are expert in.

By proposing that we organise a LUGCamp (a BarCamp for Linux Users) or a FOSSCamp (a BarCamp for those involved in Free and Open Source Software), I want to encourage the use of truely Free Software (which includes Linux based Operating Systems), and Open Source Software (of which Free Software is a subet), and I think a BarCamp like event would be a good way to start something up.

The last part of my text suggested that the keynote speeches (usually the inspirational talk given by a community leader or business director at the beginning or end of a conference) would be given by podcasters from the Ubuntu UK PodCast or the LinuxOutlaws Podcast. A podcast is a recorded audio or video show that is distributed via a web server and announced to RSS readers or specific "Pod Catching" software using an RSS feed.

I hope I've not missed anything out in explaining this properly, and if there's anything here I've missed, please let me know, either in the comments of this blog, or by e-mail.

Labels: , , , , , , ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]