Compdigitec Labs

Switching page orientation in OpenOffice.org

By admin | November 6, 2008

If you need to switch the page orientation (from portarit to landscape, or vise versa), here is how to do it (OpenOffice 2.x and plus):

  1. Start by opening your document in OpenOffice.
  2. Format Menu in OpenOffice.orgOpen the “Format” menu and click “Page…“.
  3. Go to the “Page” tab and choose “Portrait” or “Landscape“.
  4. Changing Page Orientation in OpenOffice.orgYou’re done! Save the document if you wish.

If you found this article interesting or helpful, please help Compdigitec Labs by spreading the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

Topics: Linux, Windows | 5 Comments »

Allowing shorter passwords in AutoIndex

By admin | October 30, 2008

If you’ve ever found AutoIndex PHP Script‘s password valiator’s resrictions on a long password annoying, you’re not alone. Fortunately, we have found a workaround for it.

Steps

  1. Download the AutoIndex script.
  2. Extract the archive and open classes/Admin.php
  3. Find the line that says “private static function validate_new_password($pass1, $pass2)“.
  4. Move further down to the line that says “if (strlen($pass1) < ” and:
  5. Change the minimal password length (the number after “$pass1) < “),
  6. (Optional) …and the accompanying message following it.
  7. Save and you’re done!

If you found this post on allowing shorter passwords in AutoIndex helpful, please help Compdigitec by spreading the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

Topics: Internet, PHP | 5 Comments »

Setting up a Wikipedia clone (part 2)

By admin | September 28, 2008

This is the second part to creating your own Wikipedia clone. If you haven’t already read done part 1, then you must do part 1 before continuing. This part deals with making your MediaWiki more Wikipedia-ish.

  1. Install the Cite extension to enable <ref> and <references />.
  2. Create a template with text that states that the page contains text from Wikipedia. Here, it will be assumed {{wikipedia}}. Note that to comply with the GFDL, you need to include a list of contributors (available through history) and a link to the original Wikipedia page.
  3. Copy the following basic templates from Wikipedia, acknowledging it with (replace {{wikipedia}} with your template name above) <noinclude>{{wikipedia|Template:templatename}}</noinclude>:

You’re done part 2 of making a Wikipedia clone! Read on to part 3 to keep going. You can also subscribe to our RSS feed.

Topics: Internet | 8 Comments »

Creating a Wikipedia clone (part 1)

By admin | September 25, 2008

If you ever wanted to set up your own topic-specific or subject-specific Wikipedia®, then you’re in luck! We’re here to give you simple and easy to follow instruction on creating your own mini-Wikipedia®.

Before you start:

  1. Download MediaWiki and install it to /w.
  2. Go to your wiki in your web browser (go to yoursite.example/w/)
  3. Configure your new Wiki. You need to have your MySQL database name&pass ready – if you don’t have them, ask your system administrator. Select GFDL license/no license.
  4. When you are done, move /w/config/LocalSettings.php to /w/LocalSettings.php and delete /w/config.
  5. Go to your new wiki!
  6. Download the ParserFunctions and extract it to /w/extensions/. Add require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
    to the end of /w/LocalSettings.php.
  7. You’re done setting up basic features! Read the next part to find out more.

Don’t forget to read the next part to creating a Wikipedia clone!

Topics: Internet | 1 Comment »

Using apt-get in Ubuntu Linux

By admin | September 21, 2008

If you ever need to install packages (built-in), but cannot use Synaptic, then here are some useful tips on using apt-get in Ubuntu:

  1. sudo apt-get install package – Installs package and it’s dependencies
  2. sudo apt-get remove package – Removes package, but you need to use #4 to remove unused dependencies
  3. sudo apt-get update – Updates the package list (checks for updates)
  4. sudo apt-get autoremove – See #2, removes leftover dependencies
  5. sudo apt-get clean – Removes leftover cached packages. Use this to free up space on your root partition
  6. sudo apt-get -s ACTION – Performs a simulation run of ACTION. Does not actually do anything.
  7. sudo apt-get -d ACTION – Downloads the package only. Does not actually install it. Use ACTION with install.
  8. sudo apt-get -f install – Fixes broken dependencies.
  9. sudo apt-get autoclean – See #5 above.
  10. sudo apt-get purge – Remove and purge packages.
  11. sudo apt-get moo – Self-explaining. (Will format your hard disk and render it unusable.)

If you found this list useful or helpful, please help Compdigitec by spreading the word. Don’t forget to subscribe to Compdigitec Labs!

Topics: Linux | 6 Comments »

Enabling and in MediaWiki

By admin | September 14, 2008

If you have a MediaWiki installation and decide to make it Wikipedia-like, you will find that the <ref> tags and the <references /> tags don’t work like they do in Wikipedia. Below is a screenshot of the citation tags not working:
MediaWiki 1.12 without the Cite extension

To fix this problem, you need to install the Cite extenstion for MediaWiki. Below is a step-by-step guide to installing the Cite extension:

  1. Download the Cite extension – ZIP format, RAR format or 7zip format.
  2. Extract it to a temporary location.
  3. Upload the “Cite” folder to your extensions folder.
  4. Edit LocalSettings.php and add:
    require_once( $IP.'/extensions/Cite/Cite.php' );

    after the line

    require_once( "$IP/includes/DefaultSettings.php" );
  5. Now refresh the page and try again!

If you found this article helpful, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

Topics: (X)HTML, Internet | 9 Comments »

SimpleXML – solution for XML manipulation in PHP

By admin | September 7, 2008

If you ever do get the need to manipulate (read/write) XML, you could try using the PHP DOM API, but it’s very difficult to use the DOM. An good extension-less way to access and manipulate XML instead is SimpleXML. It’s very easy to use compared to DOM and features a easy way to access attributes and tags in any XML document.

XML file (sample.xml)
<?xml version=”1.0″ ?>
<root><example>This is example number 1</example><example><tag>This is a tag.</tag></example></root>

Reading a XML file
<?php
$a = new SimpleXMLElement(file_get_contents(“sample.xml”));
echo $a->example[0];
?>

The example above will read the sample XML file above and will output the contents of the first <example> element.

Writing a XML file

<?php
$a = new SimpleXMLElement(‘<?xml version=”1.0″ ?><root></root>’);
for($i = 1; $i <= 9; $i++) {
$a->addChild(“element$i”,”Hello”);
}
echo $a->asXML();
?>

The above example will create the following XML file:

<?xml version=”1.0″?>
<root><element1>Hello</element1><element2>Hello</element2><element3>Hello</element3><element4>Hello</element4><element5>Hello</element5><element6>Hello</element6><element7>Hello</element7><element8>Hello</element8><element9>Hello</element9></root>

So as you can see, you can very easily manipulate XML with SimpleXML. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

Topics: (X)HTML, PHP | 9 Comments »

How to get the initial help on sudo to reappear in Ubuntu

By admin | September 4, 2008

If you’ve used a new, fresh Ubuntu install, you’ll notice that the first time you open the terminal, you would get the following message before your first sudo (or su):

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

However, after your first sudo or su, this message disappears when you open the terminal. If you (for somewhat reason) need to reactivate this message, simply delete ~/.sudo_as_admin_successful with the following command: rm ~/.sudo_as_admin_successful.

If you found this article interesting or helpful, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!

Topics: Linux | 10 Comments »

How to force mkdir to create a directory if there isn’t already one

By admin | September 3, 2008

If you’ve ever tried to make a directory if there isn’t one existing, you probably have bumped into the following error:
mkdir: cannot create directory `the_directory': File exists

To fix this, use this instead to suppress error and create parent directories if needed:
mkdir -p your_directory

For more information, see the mkdir page at Wikipedia.

Topics: Linux | 8 Comments »

12 things you need to know about PHP

By admin | September 2, 2008

Are you still thinking that PHP is an web-only language or is “not a real language”? Well, that used to be true with PHP 2.0, but with PHP5, it’s not so true anymore. Here are 12 things you need to know about PHP:

  1. PHP is not only for the web. PHP used to be only a web module or a CGI script, but that has since changed, since with the PHP CLI and the PHP-GTK2 binding. See #3 and #4.
  2. PHP is a real language. Despite the myths, PHP is an actual programming language. This is a very bad myth, since when someone asks for help on PHP in a forum or a mailing list, they will get a reply like “get a real language like C”. PHP is just as real as any other programming language.
  3. PHP can be used to write command line (DOS/Bash) scripts. Using the PHP CLI, one can write command line PHP scripts just like C or Java.
  4. PHP can be used to write graphical applications. Using the PHP-GTK2 binding, one can write graphical PHP applications.
  5. PHP can be used to write OpenGL applications. Although this appears to be experimental, one can actually write applications that use OpenGL using php-opengl.
  6. PHP is not a language with security holes. Most cases of PHP and bad security are because of poorly written scripts that rely on insecure programming practices (such as register_globals).
  7. PHP is not a languang without OOP (object oriented programming). Read PHP’s page on PHP5 object oriented programming – you will see that it is like most other OOP implementations.
  8. PHP is not a typeless language. Despite rumors, PHP is a typed language (even though it is not strongly typed). See PHP’s types page for more info.
  9. PHP is a free and open source language. The PHP interpreter is released under the free PHP License. If you don’t like the PHP License version, then use the LGPL’d version by Roadsend PHP.
  10. PHP can be used to write web robots (bots). Using cURL, PHP’s built-in www functions or the http class, one can write web robots with PHP too.
  11. PHP is not an ancient language. It is fairly modern, and is 4th generation too.
  12. PHP is not useless.

If you found this article helpful or useful, please help Compdigitec by spreading the word or by leaving a comment. Don’t forget to subscribe to Compdigitec Labs!

Topics: PHP | 19 Comments »

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles! « Older Entries Newer Entries »