Viewing Category » Programming

Essential .htaccess Commands

Post Thumbnail of Essential .htaccess  Commands

Apache web servers offer a flexible way to control the server settings by using .htaccess file. This tiny is being read and translated by apache before serving the actual web pages or files. Here is a list of a few simple and useful .htaccess commands.

Changing the default index file

DirectoryIndex index.html

This code changes the default index file. An index file is the first page that will be loaded up hen visiting mywebsite.com or even mywebsite/foo/. In this case visiting mywebsite.com will load up mywebsite.com/index.html.

DirectoryIndex index.html index.php index.htm

You can also give a list of options such as shown in the snipper above. This command will search for index.html, index.php and index.htm in the exact order. If you have index.php and index.html sitting on the same folder, the one that will be loaded is index.html.

Custom error pages

ErrorDocument 404 errors/404.html

Uptime Robot Free Website Monitoring Tool

Post Thumbnail of Uptime Robot Free Website Monitoring Tool

If you have been maintaining a website or plan to maintain one, I am pretty sure that you have already known some of the trickiest part of being a webmaster. Everything starts on your work board where you plan and decide what the website will be, how people will find it and what audience you will aim to serve. Going online gives a few more hurdles such as picking the right webhosting service, for a starter, you won’t get a Linux webhosting service if you want to host ASP files and vice versa.

The hurdles gets on moving to securing your files, protecting the server, making sure that everything runs and that you have enough bandwidth or disk space to carry everything out flawlessly. Sooner or later you will hit a certain condition where uptime will be questioned. Are you 100% sure that your website is live 24 hours a day and 7 days a week?

Introducing the Robot.
Fortunately, you no longer need to sit in front of your computer checking at regular intervals to make sure that your website is live. “Uptime Robot” a web application from WebResourcesDepot & SSLmatic will dutifully alert you if your website suddenly went down so you can take an action at once.

Search Engine Friendly Redirect 301

Post Thumbnail of Search Engine Friendly Redirect 301

Sometimes we need to change filenames or directory structures but simply can’t since this always results on being penalized by search engine ranking. If a file was moved or renamed, a search engine index will end up as an error 404 which only puts you down on ranking with search engines but also drive away your visitors thinking that your website ends up broken.

A common user will use script base forwarding by manipulating the headers, it will work but the robots will get confused and may mark your site as spam. The best way to redirect in a search engine friendly way is to utilize error 301 (Moved Permanently).

Here are the steps that you need to do:

  • Make sure that you have a Linux or Unix webhost, the OS can be optional as long as you have Apache as the base server.
  • Consult your webhosting company if they support .htaccess file, a few years ago support for this file is not supported on most shared hosting accounts.
  • Open your ftp software or file manager in case you prefer a file manager
  • Navigate to the web root, in case for php hosting it is either public_html or httpdoc (httpsdocs for SSL directory)
  • Locate if you have a file named .htaccess (take note of the . and the blank filename).
  • If you have an existing .htaccess file, download the file and create a backup.
  • Add an entry taking this format redirect 301 /odlfilename http://domainname.com/newfilename

Beating Nested Encoding

Post Thumbnail of Beating Nested Encoding

Today’s modern time, code can be easily shared and reuse specially those released as open source. From time to time, developers will try to protect their work by encoding their source codes. This can be a hindrance to a newbie but totally less effective to advance users.

The most favorite method of encoding the files was to encode them using base64 _encode() and applying gzdeflate(). This will prevent some users from reading the source code but it can be easily reversed by issuing the commands

gzinflate(base64_decode());

It may sound easy but in reality, there are nested encoding being performed in hopes that the user will stop decoding them or at least make it harder until they give up. An ordinary decoding human will try around 3-5 attempts, a persistent one will try at least around 20 attempts. Sadly, experienced developers do encode their source code more than 25 and some encode them more than 50 times.

Fix Disqus Comment Count

Post Thumbnail of Fix Disqus Comment Count

I started having problem with Disqus system showing “View Comments” on the comment count slot when it was upgraded to the latest version (2.52). Playing with the Disqus admin panel gives no good result and I am pretty sure that it is working properly on earlier versions of Disqus after version 2.42 and not it looks broken.

A trip to the official plugin website for Discus was made and it yields almost nothing. This problem seems to exist on earlier versions of Disqus and have affected people since October 2009 until around June 2010. I have been using Disqus since June but was unaware of the problem for the simple reason that I don’t display comments count.

Playing and digging around the Disqus code lead me to the file named disqus.php which seems to be the heart of the plugin. A quick search for the word “View Comments” brought me down to line 697 with the following code:

function dsq_comments_number($comment_text) {
	global $post;
	if ( dsq_can_replace() ) {
		return 'View Comments';
	} else {
		return $comment_text;
	}
}

MySQL Mathematics

Post Thumbnail of MySQL Mathematics
 Coding Tips,Database Systems 15 September 2010

There are times that we want to perform mathematical equations using MySQL, I am not saying that it is wise to directly apply mathematics inside your queries but they can be useful inside stored procedures.

(Note: you need to be on INNODB engine mode to use stored procedure)

This article will show you what mathematical functions you can use that was supported by MySQL. Please also take in caution that MySQL is a database engine and not a real calculator so please avoid performing complex equations on your database.

Modulus

select 87 % 9;
+--------+
| 87 % 9 |
+--------+
|      6 |
+--------+

MySQL Shortcuts (Scores)

Post Thumbnail of MySQL Shortcuts (Scores)
 Coding Tips,Database Systems 14 September 2010

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. MySQL is primarily an RDBMS and therefore ships with no graphic user interface (GUI) tools to administer the databases or manage the data inside it.

Users can readily use the included command-line tools or download MySQL frontends from various parties that have developed software and web applications to manage MySQL database. An administrator GUI pack also exists on the official MySQL website which may require extra java modules for connectivity.

This article assumes that you already have an idea on what MySQL databases are and how to use them. Please make sure that you already have a working backup copy of your current database when using the following tips.

When moving data between two tables which you already have structures intact, you can do them using Insert / Select pair.

INSERT INTO `userrecords` (`id`, `name`, `email`,  `password`, `refferer`, `joindate`) SELECT `memberid`, `username`, `useremail`, `userpass`, `userrefferer`, SYSDATE() FROM `db.members`;

Eye Blazers Recreation Project

Post Thumbnail of Eye Blazers Recreation Project
 Programming,Publishing 18 August 2010

Discussion for recreating Eye Blazers which is a web design and programming group discontinued a few years ago.

It was made up by

  1. TrueIllussion (Dan – Designer) –  Working on designs on as freelance and employed works, produces templates and logos
  2. XyverRazzi (Rommel – Designer / HTML) - Moved to print media and specialized on wide prints
  3. Calavasa (Mercen – HTML/Content/Checker) - Currently engaged on digitizing books, documents and other records from paper to PDF/XML media formats
  4. Vhortex (Paul – Programmer) - Working on opensource with Modx and Wordpress modules and theme fixes, also working on migration of databases from MS SQL to MySQL and vice versa, shopping cart and CMS in house development

Here are the excerpt that was taken from Facebook

Dan: Will be doing designs for the site and another one site together with Rommel
Rommel: Currently building his business website and will be helped by Dan
Mercen: Will be providing content checking, grammar checks and mark up suggestion/corrections
Paul: Providing hosting space until the project site will be up and running, will be incharge of back-end programming

Department of Budget and Management Website Defaced

Post Thumbnail of Department of Budget and Management Website Defaced
 Online Security,Programming 7 August 2010
http://www.dbm.gov.ph/

A Philippine website have been attacked and defaced by a group calling themselves “Xentrix Cyber Team and Soldier of Allah”. The attackers have injected codes on the Department of Budget and Management (DBM) which in turn seems to be running on FrontPage a product from Microsoft.

The site was currently displaying a frameset that was overlaid on the normal page with reference links to

../../../profil.php?id=

which seems to fail.  The double dot and a forward slash is a directory command that tells the browser or computer to go up one directory. The 3 “../” may mean that the attackers are trying to locate the root folders there are also some chance that this is just a script error.

There seems to be a replace command that was run when viewing the source as there are a few lines that have links turned invalid by padding this web URL (address)

http://1.1.1.5/bmi/

MS SQL Server 2008 with PHP

Post Thumbnail of MS SQL Server 2008 with PHP

I personally choose not to use Micro$oft products when it is possible, but sometimes the choice is not given. For these unfortunate who have to deal with SQL Server 2008 (or 2005), here is how to get around without too many swear words and avoid licensing costs.

Requirements

  1. Windows Vista, Windows 7 or Win XP
  2. .Net Framework 3.5 SP1
  3. Windows Installer 4.5
  4. Windows PowerShell 1.0
  5. MS Core XML Services (MSXML) 6.0

Note: In order to download windows Power Shell, you need to pass the genuine windows checking. You can still google for alternative download locations preventing the need for the checking. Power Shell also comes preinstalled from windows 7 including .Net framework 3.5 but it wont eliminate the need to download the service pack.

 Page 1 of 2  1  2 »
© 2011 - 2012 Vhortex's Little Digital Journey PolkaDot designed by ZENVERSE

Optimized by SEO Ultimate