Leisurehours's Blog

Ubuntu & Linux Recipes

Category: Programming

Encrypt & Secure Your Files Using vi Editor

by manojgumber

[tweetmeme service=”bit.ly” source=”LeisureHoursWP” ]

Do you know that you can encrypt your source code files and other text files using vi editor? Isn’t vi editor wonderful.

It is very simple. While creating new file which you intend to encrypt

leisurehours@wordpress-laptop : ~ $ vi -x file1.txt

To encrypt an existing file , open it with vi using -x option

leisurehours@wordpress-laptop : ~ $ vi -x file1.txt

vi editor will now ask for password twice. Whenever you will open the file again with vi editor, it will ask for password to decrypt the file. When opened using other editors , file will show only garbage text.

XML Message Forum in PHP & XML

by manojgumber

I had coded this message forum as part of an assignment. This is a really very simple message forum using only PHP and XML and no database required. It just illustrates the concepts of

  • XML
  • XSLT
  • DOM

You can download this forum here.

It contains a readme.txt file which explains how to use this.



Using xsl:value-of inside an html tag

by manojgumber

I was working on an xml assignment when I came across this problem. While writing xsl sheet for an displaying an xml file , I had to use <xsl:value-of > element inside an html tag or any other tag. But with normal syntax , things were not working. Stumbling on some books and xslt documentation , I found a way out.
Read the rest of this entry »

Maintaining Indentation while creating XML with DOMDocument in PHP

by manojgumber

I had to encounter with PHP and XML while working on an assignment. I had to create an XML document using PHP DOM . The problem was that XML file which was being created was not being properly indented and output was all appended in a single line.

My output was coming as

<forum filename="forum1.xml"><name>Forum 1 Name</name><description>This is forum 1</description></forum><forum filename="forum2.xml"><name>Forum 2 Name</name><description>This is forum 2</description></forum><forum filename="forum3.xml"><name>Forum 3 Name</name><description>This is forum 3</description></forum>

I wanted output as

<forum filename="forum1.xml">
           <name>Forum 1 Name</name>
               <description>This is forum 1</description>
      <forum filename="forum2.xml">
           <name>Forum 2 Name</name>
           <description>This is forum 2</description>
      <forum filename="forum3.xml">
           <name>Forum 3 Name</name>
           <description>This is forum 3</description>

I was looking for a solution to properly indent the output XML files. By searching through PHP Dom manual, I found the following solution Read the rest of this entry »