Archive

Archive for May, 2009

Knowing What to Use (or make) for Your Site

May 26th, 2009 admin 1 comment

So it seems quite often new webmasters are at their wit’s end when the question arises: what features does my site need? Well, this common question can be quickly turned into a daunting test of thought to new and experienced webmasters alike. So how can one even begin to approach this question? Well, why am I asking you? That’s what you’re reading this for ;) .

Alright, so you are creating a new site and are not sure what features you should start packing it with. Well, the most important thing to keep in mind is that the site should always be updated. So if at first you forget some features, don’t rush to get them finished right away; save them for future updates. By keeping sites updated, as I’ve mentioned in previous posts, you keep users coming back to your site. Once you have that out of the way, you can move on to deciding site essentials.

Deciding site essential features is an absolutely necessary step to creating a successful site. Consider your site’s purpose, function, and most importantly, what makes it unique. Whatever makes it unique should be the most important feature you first include. Followed by what it does and its purpose. For example, I have created a blog here. So I would not make this site a giant forum and expect people to simply read my blog posts, but rather I setup the blog and add an RSS feed so people can subscribe and stay updated.

So more or less, when a user is trying to figure out what is necessary, those functions that make your site worth viewing are what you need to include. Then, if you feel you’ve forgotten something, add them in for later additions so people have yet another reason to keep coming back to your site! Remember, with the web changing literally every second, one needs to keep their content and sites updated frequently (hmm maybe I should follow my own advice, eh? :p).

Regards,
Dennis M.

Categories: PHP, Software Reviews Tags: , , , , ,

Some Topic Ideas!

May 23rd, 2009 admin No comments

Hey guys, sorry for the long delay in updates, I’ve been taking topic ideas. None have quite struck my fancy (so to speak) where I feel they would make some great discussion topics. So please, send me some suggestions via email (dennis [at] microsonic [dot] org)! If I don’t get any great ones in the next day or so (well, either way really), I’ll be posting my “Deep Links Mod” for phpLD 2.x.x. Since there already is a great working one for phpLD 3.x.x, I will be releasing the one I wrote for a recent project I just finished up!

Regards,
Dennis M.

Categories: Other Tags: , , , , ,

Using the Internet as a Revenue Generator

May 18th, 2009 admin 2 comments

So I get many inquiries about how to make money on the web. Obviously, my first (and instinctive) response is to say, “Oh, it’s easy! Just develop.” But then, when I come down from cloud nine, I realize that not everyone is a developer (thus the reason I have work). Yes, anyone can certainly do it, but it is a skill acquired over a long period of time to get really good at. So what can the “average joe” do to make money on the web?

Well, really, there are many things users can do. With the recent boom of open source programs (and if you’re willing to invest, the paid programs normally are worth the extra bucks) you can open all different sorts of sites. If you’re not selling any particular product, you have to make your site appeal to the masses. The name of the game is traffic. It is the most important aspect to any successful site on the web. With no users, there is no revenue.

Let me explain. I write this blog to help people, however, I have ads. Now, they do not generate much money for me (hardly anything really), but for a site with major traffic (like myspace or facebook), these ads are generating thousands per month. The more traffic you receive, the greater than chance your ads will be clicked. The more clicks they receive, the more money you earn. That’s the basis to internet revenue if you’re not selling something.

Now, there are many great kinds of sites. Blogs are useful if you have unique content. Directories are nice if you can get your PR (Google Pagerank) up high (do this with backlinks).  But among the most effective traffic generators (not to mention the most CPU intensive and generally require a dedicated server of Virtual Private Server) are web proxies. People love these, so load these with ads and allow more or less unrestricted web access and you will probably be getting a nice chunk of change in return.

So I’ve been mainly discussing Google adsense and generally ad generating services, but do not forget keeping stats on your own (awstats is pretty good) is an always valuable technique. If you have proof (like the awstats page) of high traffic, you can sell ads directly to interested users. Say you have 1 million unique hits a month, you can sell a top banner ad for $X,XXX per month or more.

As I mentioned before, traffic is the name of the game. It bears repeating because it is the only reason for internet web site success, on all levels. Whether you are selling a product or just serving free content with some ads, the more users you get, the more products you will sell or ad clicks you will get. This means, however, you must invest time and money into advertising yourself to get your site known.

For those of you who would like to claim that advertising doesn’t really work, I challenge you to then explain to me what companies have the best sell quantities. The most heavily advertised businesses are simply among the most profitable due to the advertising and offering a (in most cases: fairly) decent product. So get out there, make sure your site is presentable, and get to advertising!

Regards,
Dennis M.

The For(); Loop

May 13th, 2009 admin No comments

Many new programmers are perplexed by the “for” loop. However, it is one of the most essential and powerful tools in any developer’s arsenal. Without it, efficient and clean programming would not be as possible. Early on, most developers seem to stick to the while(); loop. I mean sure, while(); is great for some things, but may not exist in some programming languages and not to mention won’t work for everything you need.

Let’s begin by going into the basics about the for(); loop. Well really, a lot depends on the programming language (I will provide both PHP and C++ examples in the source file). But more or less, the for(); loop is simply iteration. It will run until its defined limit is hit providing whatever results you wish. We’re going to do this in more standard languages (e.g.: C/C++ and Java) instead of PHP for mass compatibility. Just note, if you’re looking to do this for php, you do not need to define the type of variable, and your variable will just start with the “$” symbol. So for example, PHP would be for($i=0;…;…){}.

Now we’re going to write a sample program and break it down:

for(int i=0;i<=5;i++){
std::cout<< "This is line number "<< i << std::endl;
}

Now as most of you may have noticed, this is a C++ example, but will effectively explain how the loop works for ALL programming languages!

int i=0; – This simply defines the variable and starting place (0 in this case). In PHP you would simply use $i=0; and so on for the rest of the statements.
i<=5 – This tells the loop when to stop (This <= symbol means less than or equal to). When i>5, the loop will stop and proceed on to the rest of the code.
i++ – This tells what the loop should do after every time it is run. In this case, we’re using i++ which means to add 1 each time around.

Now those are the basics to the loop. What lies within is just simply the code to be executed, which could of course have conditionals and such within it as well (e.g.: if(), etc.). So now we’ll move on to a more complex example.

unsigned int choices=5;
char* choice = new char[choices];
for(int i=0;i<=choices;i++){
std::cout<<"Please enter a value: ";
std::cin>>choice[i];

if(!choice[i]){
std::cout<<"No value for choice "<< i<< std::endl;
}
}
for(int i=0;i<=choices;i++){
std::cout<<"Choice "<< i<<" was "<< choice[i] << std::endl;
}

This will store an array of choices and then after entering them, they will be printed back!

In the source below, all working examples will be provided!
For(); Loop Tutorial

So, that basically wraps everything up! If you need anymore clarification, just let me know.

Regards,
Dennis M.

Categories: C/C++, Java, Other, PHP Tags: , , , , , ,

The Basics to Mod_Rewrite

May 8th, 2009 admin No comments

Mod rewrite. A term many webmasters often hear and get that awful sense of dread coming from within. But why? What makes this term strike fear in the hearts of webmasters everywhere? Misunderstanding. Yep, that’s it. People are afraid of what they don’t understand, and rightfully so when it comes to anything .htaccess; if you don’t know what you’re doing, you could waste hours of time working on something that could have taken 5 minutes.

So now that I’ve scared all of you, how can I help this dilemma? Well, I’m going to go through the barebone basics of what mod rewrite does and why one could (and probably should) use it on a production quality site.

Let’s begin talking about what it is and what people use it for. Mod_rewrite (as the prefix implies) is an Apache mod. This allows a user to make links to page (which usually don’t exist) appear to be static. Let me explain. Many PHP developers like to use the http://YOURDOMAIN.com/?p=PAGE which is fine. In fact, it’s probably the most efficient way to go about setting up multiple pages in one document. However, this is bad for SEO: which brings us to our next point. This is usually used for SEO purposes (but obviously there could be infinitely many uses) to make keep the programming aspect as http://YOURDOMAIN.com/?p=PAGE but make users (and Search Engines) see http://YOURDOMAIN.com/PAGE.html (or whatever extension for that matter).

Now how does one use mod_rewrite. Well, the code snippets I will provide will ALWAYS go in a .htaccess file for an Apache server (and some other servers actually do use .htaccess file and so it may be valid on those as well). Since this is not a tutorial about the .htaccess file, I won’t go anymore into detail on that-just realize that if you’re using an FTP client, you will have to show hidden files to see the .htaccess because the nature of Linux (any file/folder prefixed with a “.” is automatically hidden unless otherwise specified).

Now that we have that clear let’s begin with the most basic thing that we need. We must turn the mod on, and to do so we write this:

RewriteEngine On

Like I said, this will enable the mod.

Now, to do this efficiently (unless you would like to type in all the pages manually), a knowledge of regex is necessary. Regex is by no means easy, but well worth learning if you’re serious about programming in any language. A very good reference to look at is Regular-Expressions.info as a first-hand learning source and then use Google for help with more specific issues.

Now I’m going to go through a little example (I will provide the source code for at the end of this tutorial) which will explain how to create SEO friendly URL’s by way of page-NUMBER.html.

First, we need to create the page which is going to process the information. Below is a simple PHP document in which ?p=NUM will give you a result.

/**
* .htaccess Tutorial by Dennis M.
*
* This is just the example script where we will
* be redirected to and will do all our work! :)
*
*/

if(!$_GET['p']){
$_GET['p'] = “default”;
}

// Define our pages:
switch($_GET['p']){
// Default page if unknown page, etc.
default:
print “Default page!

Try:
Page1
Page2

or Page3 (Redirects back here! :D )”;
break;
case 1:
print “This is page one, congratulations! If you’re accessing this through ?p=1 then you’re not using SEO friendly
url’s. If you’re using page-1.html then you have successfully created an SEO friendly rewrite!”;
break;
case 2:
print “This is page one, congratulations! If you’re accessing this through ?p=2 then you’re not using SEO friendly
url’s. If you’re using page-2.html then you have successfully created an SEO friendly rewrite!”;
break;
}

?>

Now, below this is the .htaccess file which will properly rewrite the URL’s. They can still be accessed by ?p=NUM, but now page-NUM.html (or just .htm for that matter) will also work!

#### mod_rewrite Tutorial by Dennis M. ####
# #
# mod_rewrite .htaccess file. This is a #
# working redirect sample! A proper SEO #
# friendly rewrite. #
# #
###########################################

# Enable mod_rewrite
RewriteEngine On

# Our rules – using regex to find page number!
# the regex will find any page-NUM num being anywhere from 1
# to 99 digits in total length
#
# The regex more deeply explained here:
# http://microsonic.org/2009/05/08/the-basics-to-mod_rewritethe-basics-to-mod_rewrite
#
RewriteRule ^page-([0-9]{1,99})\.htm(l)?$ ?p=$1 [QSA,L]

Now let’s pull this apart. Obviously, RewriteRule is exactly what it stands for-what we’re going to be changing. Now the ^ and $ symbols mark the beginning of the link (^) and the end ($) [those are standard regex start/end string symbols]. This is followed by the static part of the link or page- followed by our first regex rule. The parenthesis ( and ) set this information apart as a set. Now, the brackets [ and ] set another element which is any number 0-9. The set symbols { and } allocate length of the string. For example, this will allow any number from 0 (1 digit long) to 1000 (4 digits long) all the way up to 99… carried out 99 total digits. The next part is the \. The backslash (\) escapes our . so it’s not processed as regex (because it is a regex symbol) and so it reads as part of the static text. The htm(l)? makes the htm necessary and the l character optional (allowing .htm or .html): which is the reason for the set (l) followed by the ? meaning optional. Now, the ?p=$1 is the actual page we will be going to. ?p=NUM is the format of our initial document to access pages, so we keep that and $1 takes the value of the first set in the regex defined before. In this case it is ([0-9]{1,99}) so it grabs the number. [QSA,L] are simply anchors. Now, I recommend always using [L] when rewriting URLs so it goes to your script, otherwise it will revert to the main index of your site (YOURSITE.com/index.php?p=NUM or however you choose to rewrite).

So now you all understand what misery truly is. You’ve been introduced to .htaccess and mod_rewrite. One of the most sensitive things a webmaster has to deal with otherwise you will receive a nasty “500 Internal Server Error.” So now the only thing to do is practice, practice, practice until you become as comfortable as comfortable can be with .htaccess, mod_rewrite, and regex. Good luck!

Mod_rewrite Tutorial

Regards,
Dennis M.