Loading...


Ask A Question?

 
 
 
 
 
 
Posted in Computers & Tech / Programming / Programming General / BASIC / Visual Basic (.NET)
Author: QuantumFlux Total-Replies: 1


I don't know if anyone here uses Power Basic 8, but I'm having a bit of a problem with displaying a bitmap from memory onto the screen. I'm trying to make a SPR (Ragnarok Online sprite) file viewer. The SPR file contains a header with info on how many frames are in the file and dimensions and size, then the actual bitmap data is RLE compressed and at the very end is the pallete info. Well I wrote a program that can read the file and decodes the bitmap data and I can create a user define type of a bitmap and set it all up with the appropriate data. So far I can save the bitmap out to a file by saving the user define type variable, but what I don't exacly know how to do is to display the bitmap to the screen, I learned a little about GDI but perhaps if anyone is familiar with Power Basic they can point me in the right direction. Thanks in advanced.

Thu Feb 9, 2006    Reply    New Discussion   
 

Posted in Computers & Tech / How-To's and Tutorials / Programming / .NET (VB, C# & J#)
Author: CaptainRon Total-Replies: 2


Performing DOS Operations from Visual Basic

By: Abhishek Chatterjee

Language: Visual Basic 6.0 and below

Difficulty: Beginner

Does your project need to perform some DOS based or Command line operations? Although there are many techniques to do the same, but performing tasks like calling the DIR DOS command to list the contents of the directory or calling the Move command to move a folder, and the like, can't be done as smoothly by the built in functions of VB or the Windows API.

The technique that I introduce to you is extremely simple, doesn't require any high level programming knowledge of Windows API or anything else. All you need to know to be able to work smoothly is to know File handling using VB. Although I do introduce you to some basic File I/O concepts, its suggested that you read further about it.

The Technique:

Whenever you needed to do a DOS task repeatedly, what did you do? Create a shell program (Batch file) and run it. Well that is exactly what we are about to do here. All those of you who know File I/O well, are already on track of introducing DOS operations into their projects. Just follow these steps:

* Start your project and create a new function/subroutine that will create a batch file and execute it.
* Creating a batch file is simple. Create a variable called strFileText which will hold the contents of the batch file.
* Suppose you want to use the move command to move a folder from a specified location to another. So the function declaration will look something like this:

Public Function MoveFolder(strSource as String, strDestination as String)

Now generate a DOS command from the parameters passed above and store in the buffer variable declared above called strFileText.

strFileText = "move " & strSource & " " & strDestination

Now write the file to disk by using File I/O as shown below.

* fnum = FreeFile() 'Assign a free file no. to fnum
* Open app.path & "\dos.bat" For Output As fnum 'Let the .bat file be in the same location as your .exe
* Print #fnum, strFileText 'Write the contents of strFileText to the batch file.
* Close #fnum


Now when the Batch file is written to disk, all we need to do is call it.

Shell( App.Path & "\dos.bat", vbHide)

The batch file will execute without showing itself on the screen and exit after its done.
Since this example was a very basic one, anyone who knows about Dos and Batch files, its no big deal. You can create a fully customized Batch file by controlling the contents of strFileText.

Now, suppose you run a DOS program, and you want to see what was the output, or let your software know about the output, you must do the good old piping tactic.

This command will store the output in a text file:

C:\>DIR *.* > output.txt

The complete C Drive directory listing is stored in a file called output.txt. All you need to do is open it using File I/O and read the contents.

To give input to a program do the following:

Store the sequential key inputs in a text file. Then issue the input pipe as follows:

C:\>flames.exe < input.txt

So by now many of you would have already made plans to make GUI interfaces to some XP console commands... eh?
If someones tries things out, please make GUI's for CHKDSK and the NET commands. (I am too lazy to spend my weekends on these)

Tue Sep 13, 2005    Reply    New Discussion   
 
Posted in Computers & Tech / How-To's and Tutorials / Programming
Author: evought Total-Replies: 3


CVS Basics

Some Basic Recipes for Using the Concurrent Versioning System (CVS)
in Group Projects


This is a basic How-To for using CVS in group projects. CVS is popular with many projects, especially open source packages hosted on sites like SourceForge. CVS is a very flexible and powerful tool, but its dozens of commands and options can be daunting for the new user. Many references tell you what the commands are for and how they work, but what is often missing is a list of common recipes for getting common tasks done. This guide will give you some simple command combinations for common tasks and some general principles. I try to focus on things the manual does not tell you.

This How-To is geared toward the command-line (UNIX, Linux, BSD, or Mac OS X) user. If you are using a special GUI or CVS support built into your editor, this tutorial won't make sense to you. This is also not a manual substitute; use it as a starting point for exploring the manual and learning more powerful features.

Getting the Code

There are two basic ways to get code from CVS. Which one you use depends on what you want to do with it. The first method, 'cvs checkout' will give you the code with everything you need to commit your changes back to the shared repository.

CODE

cvs checkout myproject


This checks out a copy of 'myproject'. Specifically, it creates a local 'myproject' directory and puts a copy of the code in that directory. It will spit out a list of the files it is copying as it works. CVS creates a 'sandbox': a safe place where you can play with your own copy of the code without messing up anyone else. Nothing you do affects other developers until you commit changes back to the repository.

You need to tell CVS where to get the project from, and this usually involves the '-d' option:

CODE

cvs -d:ext:ericvought@cvs.sourceforge.net:/cvsroot/crystal checkout


which can get fairly complex. I will not get into that here. Your project documentation or project manager should tell you what you need. After checkout, if you are in your project directory, CVS remembers the location and you do not need it anymore (it is stored in CVS/Root if you want to know). These options can be hard to type everytime you do a checkout, though, and it is easier to put it in an environment variable:

CODE

export CVSROOT=:ext:ericvought@cvs.sourceforge.net:/cvsroot/crystal
cvs checkout myproject


Put the export command in your shell startup script (e.g. .bash_profile). If, like me, you work on more than one project, make a couple of variables:

CODE

export CVS_CS=:ext:ericvought@cvs.sourceforge.net:/cvsroot/crystal
export CVS_LOCAL=:ext:evought@palantir:/cvsroot
export CVSROOT=$CVS_LOCAL


Then you can select the other project two different ways:

CODE

cvs -d$CVS_CS checkout cs


---or---

CODE

export CVSROOT=$CVS_CS
cvs checkout cs


Another method of getting the code which is not mentioned nearly often enough is by 'cvs export'. This gives you a copy of the code *without* any of the version information and is particularly useful if 1) you just want to look at it, not work with it, 2) you are packaging it for someone else, or 3) you want to pull it in to your own repository as a starting point for your own work.

CODE

cvs export -D now myproject


Export is faster than checkout and all of the 'CVS' directories cvs normally creates will not be in the way when you are working with the code. '-D now' gets the latest version; check the manual for other ways of specifying the version to fetch.

You can use a compression option (-z) with cvs and it is particularly useful when doing checkouts or exports over slow links:

CODE

cvs -z3 checkout foo


gets foo using a medium-fast compression and will usually use less time and bandwidth for the checkout.

What Have I Done?

OK, now you have the code. Maybe you've played with it a little. Maybe you have built it and do not know which files came from the repository and which from the compiler. 'cvs status' tells you some useful information about a file:

CODE

Palantir:~/Projects/cs-tree/cs evought$ cvs status docs/history.txt
===================================================================
File: history.txt       Status: Up-to-date

  Working revision:    1.8979
  Repository revision: 1.8979  /cvsroot/crystal/CS/docs/history.txt,v
  Sticky Tag:          (none)
  Sticky Date:         (none)
  Sticky Options:      (none)


This file is up to date. Nothing has been changed, either locally or in the repository.

CODE

Palantir:~/Projects/cs-tree/cs evought$ cvs status docs/history.txt
===================================================================
File: history.txt       Status: Locally Modified

  Working revision:    1.8979
  Repository revision: 1.8979  /cvsroot/crystal/CS/docs/history.txt,v
  Sticky Tag:          (none)
  Sticky Date:         (none)
  Sticky Options:      (none)


Now, status shows that the file is locally modified (changed by me).Next we see a file which has been changed by someone else and my copy is out of date. Note the different version numbers:

CODE

Palantir:~/Projects/cs-tree/CS evought$ cvs status docs/history.txt
===================================================================
File: history.txt       Status: Needs Patch

  Working revision:    1.8981
  Repository revision: 1.8984  /cvsroot/crystal/CS/docs/history.txt,v
  Sticky Tag:          (none)
  Sticky Date:         (none)
  Sticky Options:      (none)


Now, what if I decide that I do not want my changes? I said above that nothing you do affects another developer until you commit changes. You can always abandon your whole checkout and get another copy. Individual changes can be backed out using some esoteric forms of the merge command, but to just undo a single file, the easiest way to do it is hard for some people to get used to: just delete the file. When you do a 'cvs update' the file will come back as good as new. Don't panic. It works.

What Has Changed?

At some point, you may want to find out what other people have been doing with your project. 'cvs status' is fine for a single file, but if you want to know what might have been changed in a whole directory tree, 'cvs update' is the way.
'update'?!, you ask.Won't that change my sandbox even if I do not want the changes? Yes, but you can tell it not to:

CODE

cvs -qn update


This is a magic recipe which tells CVS to check what is available without changing anything. The 'q' option tells it to summarize. Otherwise, it will tell you every time it checks a new directory, which, in many projects fills several screens and can obscure the actual changes. The output uses letter codes in front of the file names to tell you their status:

CODE

A foo.txt
M bar.txt
U baz.txt
? foo.bak


'foo.txt' is locally added; 'bar.txt' has been locally modified; baz.txt has an update in the repository, and 'foo.bak' us unknown. It is locally created and cvs does not know anything about it. If you clean your sandbox first, you will see less of the '?' unknown files (In many projects, this is 'make clean' or 'jam clean'). To find out more about the changes, use 'cvs log' and 'cvs diff'.

CODE

cvs log -r -N


'cvs log' gives you the history of the file which will let you read the comments. The '-r' option lets you select which changes to view the comments from. With no argument as seen here, it gives the latest check-in, which is usually what you want. '-N' skips tag information which can be lengthy in some projects.

cvs diff -c baz.txt

'cvs diff' gives you an output of exactly which lines were changed. The '-c' option outputs a context diff which gives you some of the unchanged lines on either side and is likely to be more readable than the 'standard' format.


Commit Early and Often

It is good manners and good practice to commit your changes often. Frequent commits makes it easier to sort out which changes may have broken something, makes for more specific log messages,and protects you work in case of local accident (accidental deletion, drive crash, whatever). Only commit something which works, though, so plan your changes to be in bite-sized, easily understandable chunks. Commit related changes to several files at once to make the log messages more understandable and so that other developers only get the complete set of changes.

Update-Before-Commit

Before you commit your changes, update your sandbox. This prevents conflicting changes from getting into the repository. The update may break your local code, but you are then in a position to fix it and you still have in mind what you have changed. If the repository version gets broken, someone will need to sort it out down the road and will not have a clue where to start.

Do a 'cvs update' to get the latest version, compile, run whatever tests you have, then commit.

Do Not Version Control Project Files (MSVC, etc.)

As a general rule, never put IDE project files into the repository (for MSVC or CodeWarrior for instance). The project files do not version control well. When two developers each add a file, a conflict occurs and some of the project formats are ugly to change by hand. Even if everyone uses the same IDE, the project files often save your individual preferences and people start fighting over the back-and-forth updates. If different IDEs are used, multiple project files have to be maintained and a nightmare ensues when files are added or removed. It is generally much better to use stand-alone build tools like 'make', 'jam' or 'ant' and let people use whatever editor they wish. You can keep your own IDE project file in a different directory (outside the code) or just use an editor which does not need them.

Use Your ~/.cvsrc

CVS allows you to create a file in your home directory to specify the common options you use. The file is called '.cvsrc' and contains one command per line. 'cvs' specifies global options and a command name specifies options for that command. For example:

CODE

cvs -z3 -q
update -d
diff -c


This saves a good bit of later typing. ('update -d' adds any directories to your sandbox which are new in the repository; normally you have to use 'checkout' to get new subdirectories.)If you want to use a different option for a particular command, say, no compression, specify something different:

CODE

cvs -z0 checkout foo


Will use no compression. Also, you can use the -f option to ignore what you specified in your .cvsrc file for that command:

CODE

cvs -f checkout foo


Scripting Makes It Easier

CVS is very powerful and flexible; it also is designed to be combined with scripting, and some lightweight scripts can your job faster and easier. Consider:

CODE

cvs -f -qn update -d |grep -v '^?'


This forces CVS to ignore options in the .cvsrc ('-f', always wise with scripts), quietly ('-q') and without changing anything ('-n') check for updates, including new subdirectories ('-d'), then pipes the output through grep (search utility) and removes ('-v') any line which starts with a question mark ('^?'). This gives you a quick look at what has changed without seeing local build files, editor backups and so forth and without having to clean your local tree and then possibly rebuild. It is a bit much to type each time, but putting it in a shell script or function named 'cvscheck', or instance, can make your job much more pleasant.

Conclusion

Well, hopefully, you have a few pointers in the right direction. In an active project, you will spend a lot of time using CVS, so it is worth putting in the effort to learn and explore.

Changes

2 Dec 2009 - Fixed many typos. Fixed cvs export example (missing project directory argument). Made it more clear what the '-f' option does.

Mon Nov 14, 2005    Reply    New Discussion   
 

Posted in Computers & Tech / Search Engines / SE Technology
Author: ramin Total-Replies: 4


hi
dears if you want to know what is google adsense
go on read this articleh

QUOTE

The Basics On How TO Start Making Money With Adsense

Adsense is considered as one of the most powerful tool in a website publisher’s arsenal. It enables a person to monetize their sites easily. If used properly, it can generate a very large and healthy income for them. However if you are not using them rightly and just maximizing the income you squeeze from it, you are actually leaving a lot of money on the table. Something all people hate doing.

How you can start earning money with Adsense can be done easily and quickly. You will be amazed at the results you will be getting in such a short period of time.

Start by writing some quality content articles which are also keyword incorporated. There are a lot of people given the gift of being good with words. Writing comes easy for them. Why not make it work in such a way that you will be earning some extra cash in the process.

There are actually three steps to put into mind before you begin writing your ads and having an effective Adsense.

Keyword search. Find some popular subjects, keywords or phrase. Select the ones which you think has more people clicking through. This is actually a keyword selector and suggestion tool that some sites are offering to those who are just their Adsense business.

Writing articles. Start writing original content with keywords from the topics that you have achieved in your search. Take note that search engines are taking pride in the quality of their articles and what you will be writing should keep up with their demands.

Quality content site. Build a quality content site incorporated with Adsense ads that is targeting the subject and keywords of your articles and websites. This is where all that you’ve done initially will go to and this is also where they will prove their worth to you.

The proper positioning of your ads should be done with care. Try to position your ads where surfers are most likely to click on them. According to research, the one place that surfers look first when they visit a certain site is the top left. The reason behind this is not known. Maybe it is because some of the most useful search engine results are at the top of all other rankings. So visitors tend to look in that same place when browsing through other sites.

Some of those who are just starting at this business may think they are doing pretty well already and thinking that their clickthrough rates and CPM figures are quite healthy. However, there are more techniques and styles to generate more clicks to double your earnings. By knowing these tecniques and working them to your advantage, you will realize that you will be getting three times more than other people who have been previously doing what they are doing.

Finally, Adsense has some excellent tracking statistics that allows webmasters and publishers to track their results across a number of site on a site by site, page by page, or any other basis you wanted. You should be aware oft his capability and make the most of it because it is one powerful tool that will help you find out which ads are performing best. This way, you can fine tune your Adsense ads and focus more on the ones being visited the most rather than those who are being ignored.

Another thing you should know. Banners and skyscrapers are dead. Ask the experts. So better forget about banners and skyscrapers. Surfers universally ignore these kinds of ad formats. The reason behind this is that they are recognized as an advert and advert are rarely of any interest that’s why people ignore them.

To really start making money with Adsense, you should have a definite focus on what you wanted to achieve and how you will go about achieving them. As with any other kind of business ventures, time is needed coupled with patience.

Do not just ignore your site and your Adsense once you have finished accomplishing them. Spare some time, even an hour, making adjustments to the Adsense ads on your sites to quickly trigger your Adsense income.

Give it a try and you would not regret having gotten into Adsense in the first place.

Fri Oct 13, 2006    Reply    New Discussion   
 
Posted in Computers & Tech / Operating Systems / MacOS
Author: finaldesign Total-Replies: 12


So, it's released, and basic model costs 2,000$. You can read here what it has inside. I think the interesting fact about this new apple product is that it's powered with Intel's processor. I wonder, how hard would it be to replace apple's software with custom version of linux or windows? :D Anyway, I would say it's a smart move, using intel. Apple claims it's now 4x times faster than regular apple's G processors... :D
What do you think? Is it worth? ;)

Fri Jan 13, 2006    Reply    New Discussion   
 
Posted in Computers & Tech / Programming / Game Programming
Author: IcedMetal Total-Replies: 5


Well as I have said I have not really used DarkBASIC but I have used Blitz3D. I found Blitz3d very easy to learn and very powerful. I do not know which is more expensive but I really liked Blitz3D. I vote for that one.

Fri Jun 10, 2005    Reply    New Discussion   
 

Posted in Computers & Tech / What's New...?
Author: TeamEFX Total-Replies: 4


This is a pretty neat IDEA.

I found this from DIGG.com

The idea is to 'skip' onto water with a HYDROFOIL
that glides along the top of the water with your own strength.
You basically push up and down with it, causing the
hydrofoil to glide on top of the water.

Check it out.

PS. Any idea how to make one?

http://www.instructables.com/id/EJO9MA800YEXCFI61R
"
introHow to "Fly" a Human Powered Hydrofoil - the "Aquaskipper"
The "Aquaskipper" is a human powered hydrofoil made by Inventist.com .
It's similar to the original Swedish Trampofoil, which is no longer available.
There's also one called the "Pumpabike" from South Africa.

They're also called "hull-less watercraft" and "flapping wing propulsion vessels".
You bounce up and down to make the wing fly and propel you.
If you stop you fall into the water and swim back to the dock.
It's completely ridiculous and works really well once you get the hang of it.

It's hard to do at first but that seems to make it even more fun.
"

Thu Feb 8, 2007    Reply    New Discussion   
 
Posted in Computers & Tech / Search Engines / Yahoo!
Author: tansqrx Total-Replies: 5


I just received a very weird message when I logged into Messenger today. It said “Congratulations, you are a Power User!” The pop-up was in its separate window similar to the annoying Insider and had a Learn More, Choose Your Icon, and No Thanks button (the Learn More button didn’t work). After doing a quick Google search (http://help.yahoo.com/l/us/yahoo/messenger/messenger9/pwrusr/pwrusr-01.html) (http://messenger.yahoo.com/powerusers) I found that this thing does really exist and wasn’t some ad pop-up that somehow got past my defenses. Here are a few of the “benefits”:

• A special online icon
• A Power Users Yahoo! Group
• Better live customer support

This is the first time that I have heard of such a thing and I will have to investigate the possibilities. I am assuming that the non-standard icons and the pop-up box are built into Messenger 9. If they are not then it opens up new possibilities for code execution and at the very least I will have to see how this changes the YMSG protocol. I would like your input to see if this has been around for awhile and if anyone else has additional information.

Wed Jul 30, 2008    Reply    New Discussion   
 
Posted in Computers & Tech / Hardware Workshop
Author: Soleq Total-Replies: 5


Gee, don't you hate it when you go to turn on the computer, expecting everything to go as normal, and then nothing happens? You push the button again and again, but still, silence? Yeah, I know what you're thinking: either the cord's loose or I'm an idiot and the power's out again. But nope, both are normal, so the only thing left is something wrong with the computer. Well, more often than not, it's a failed power supply. Most of the time you'll get the dreaded dead response, others you'll get neat sparks and smoke. Either case, it's not good.

Anyway, after that's all said and done, and the power supply's been replaced, what you're left with is a dead PS. My question is, how would one rebuild it so it's functional again? I've had several power supplies die in my times, and I'm sick of basically throwing them out. Are there any diagrams online somewhere that people could point me at telling me how to rebuild them?

Fri Apr 15, 2005    New Discussion   
 
Posted in Computers & Tech / How-To's and Tutorials / Hardware related Stuff
Author: Antnydude47 Total-Replies: 3


Your computer is a powerful tool to demonstrate your thoughts, but often the screen is too small for a whole class to see. There are several options for projecting your screen and they all follow some basic hook up procedures. The main options are:

1. Scan Converter which shows your computer desktop on a TV screen
2. LCD panel to place on strong overhead projectors
3. Projector which shows your computer desktop on a screen projection
4. (Different setup procedures not listed) Software to broadcast to other computers (see your tech person for availability)
Any computer with a separate CPU (the computer box) and monitor can usually support a projector, LCD panel, or scan converter because they already have a port to plug the monitor in (this is where you’ll plug the device(s) in). The "all-in-one" computers (monitor and CPU in one box) will not support a projector, LCD panel, or scan converter unless a separate external monitor port has been installed.
Here’s what you do:

- Read the instructions that came with the projector, LCD panel, or scan converter.
- Plug the monitor-type cable from the input port on projector, LCD panel, or scan converter into the monitor port in the CPU.
- Plug the actual monitor cable into the monitor output port on projector, LCD panel, or scan converter.
- Turn on the projector, LCD panel, or scan converter.
- Turn on or restart the computer. This will allow the computer to sense the device if it needs to.
- If it’s a scan converter, plug the smaller, video cable into both the scan converter (video out) and the TV (video in).
- Turn the TV on and turn to channel 3 (or 4 or Aux). For newer TVs, you can scroll through a menu where you can choose the input type--choose "Video" or "Ext" or an equivalent (This is one of those "Play with it!" moments where you experiment with the settings until the you see the desktop on the TV.)
- If it’s a projector or LCD panel, there’s probably a "sleep" or "power" button that will turn on the lamp. Once it’s on, use the menu buttons on the projector to select the input settings so that you can see the desktop being projected.

Notice from SpaceWaste:
Seemed more suitable as a tutorial :P - SpaceWaste
Topic edited to make it more relevant to content - m^e

Sun Apr 3, 2005    Reply    New Discussion   
 
Posted in Computers & Tech / How-To's and Tutorials / Programming / PHP
Author: vujsa Total-Replies: 9


This topic is a follow up to CMS101 - Content Management System Design and PHP Tutorial: Menu Or Sidebar Script For CMS101
[highlight=teal][hr=teal] [/hr][/highlight]
Overview:
[hr=0] [/hr]
Now that we have discussed the basic concepts of a CMS written in PHP, we should begin to think about ways to make those concepts more useful and more powerful. Basically, using only what we have discussed so far, your website would still need a file for each and every page you wanted to display to your users. What we will discuss now a method of only creating one template file and a script that will automatically change the content of the page based on the url used to get to the page. This would give you dynaically generated webpages.

Additionally, we will discuss ways of storing your data in a flat file database. In these databases, we will store information about your menu items and advertising banners.

Purpose:
[hr=0] [/hr]
While the use of a seperate menu script that included on every page in your website is very handy when it comes to making changes to your website menu, this is only one very small time saving tool for a web master. With the system discussed in CMS101 - Content Management System Design a full website overhaul would still require the webmaster to edit several file in the same way every time. The template of each page would need to be updated. This would take a lot of time to do and after the first 10 pages or so would get rather tedious. It would be much better to have a single template file that is used for the entire website. Then only the single template file would need to be updated when a change was desired.
Editing would be simplified even more if the majority of the content for the website was stored in an easy to read and logical system of data files. This would make finding the right data to edite much easier since it would be mostly a text file. I know there have been times where I've gotten lost in my code and edited the wrong portion of the file. This would reduce those user errors most of use have encountered. For the menu script, having a seperate database file for the menu items would allow you to enter only the most basic information needed to generate the menu. Then the need to remember how to properly use the menu generation function will be eliminated.

Technical:
[hr=0] [/hr]
We will first need to create a template for our website and code it to use different content based on the url used to access the page. We can use the template from the previous lesson as the basis for the new one. For now the only change will be for the main content area. To do this, we will add some code to the beginning of the file that will identify the correct content to be displayed in the main content area of the webpage then in the main content area of the template, we will insert that content.

In order to identify the correct content to display on the webpage, we will need to encode some data in the url for the webpage like so:
For this lesson, the url for the website will be www.mycms.com/index.php. This will be the front page or default page of the website. If we want a different page, we will need to pass a variable through the url. www.mycms.com/index.php?page=links should display a page with a list of links on it. However, www.mycms.com/index.php?page=news1 should display a page with some type of news article or articles on it. It is important to be able to display the correct conten all of the time and if an error occurs either display an error message or the default page instead of the error code that would be generated. While explaining to your user that either the data they requested could not be found or no longer exists is a very professional way of dealling with an error, allowing the user to view a generic server generated PHP code error instead is very unprofessional. To prevent this, we need to be sure that www.mycms.com/index.php?page=gjhgjhgkjg will either display the default page or a professional looking message that the content could not be found.

Here is how we would retrieve the desired content from the url provided and check to see if the content is valid.

CODE

<?php
$page= $_GET['page'];
$content_file = 'content/pages/'. $page . '.php';

// Now we check to see if that file exists
if (file_exists($content_file)) {
$main_content_file = $content_file;
}
else {
$main_content_file = 'content/pages/default.php';
}
?>


We of course place that script at the beginning of the index.php file and where the content is to be displayed we insert <?php include($main_content_file); ?> like so:
index.php:

CODE

<?php
$page= $_GET['page'];
$content_file = 'content/pages/'. $page . '.php';

// Now we check to see if that file exists
if (file_exists($content_file)) {
$main_content_file = $content_file;
}
else {
$main_content_file = 'content/pages/default.php';
}
?>
<html>
<head>
<title>My CMS 2</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" style="font-family: verdana;">
<table width="100%">
<tr>
<td colspan="2" bgcolor=silver>
<?php include("header.php"); ?> <!-- Used for Banner Advertising etc... -->
</td>
</tr>

<tr>
<td width="150" bgcolor=red valign="top">
<?php include("menu.php"); ?> <!-- Used for The Main Menu... -->
</td>

<td bgcolor=navy>
<?php include($main_content_file); ?> <!-- Here is where our selected content will be displayed -->
</td>
</tr>

<tr>
<td colspan="2" bgcolor=purple>
<?php include("footer.php"); ?> <!-- Banner Ads, Copyright Info., etc... -->
</td>
</tr>
</table>
</body>
</html>


Now as long as as you create a file that matches the filename passed in the url, the content will be displayed.
Here is an example:
index.php?page=main --> content/pages/main.php
index.php?page=news --> content/pages/news.php
index.php?page=links --> content/pages/links.php
index.php?page=other --> content/pages/other.php
index.php?page=default --> content/pages/default.php

You could also add to the script to allow you to use the same system for other parts of your webpage.
you can pass multiple arguments in the url like so:
www.mycms.com/index.php?page=main&header=header1
With this you could also specify which header file to use. If you had a header file named header1.php, the contents of it could be inserted in the header while the contents of main.php would be inserted in the main content area.

To do this, you need to modify the script at the beginning of the index.php like so:

CODE

<?php
$page= $_GET['page'];
$header= $_GET['header'];
$content_file = 'content/pages/'. $page . '.php';
$header_file = 'content/headers/'. $header. '.php';

// First we check the content file and assign a value to it's variable
if (file_exists($content_file)) {
$main_content_file = $content_file;
}
else {
$main_content_file = 'content/pages/default.php';
}

// Next we check the header file and assign a value to it's variable
if (file_exists($header_file)) {
$main_header_file = $header_file;
}
else {
$main_header_file = 'content/headers/header_default.php';
}
?>

We then add <?php include($main_header_file); ?> to the place where we want the header to be displayed.

[hr=0] [/hr]
Our next goal is to use a flat file database as the source of the menu to be generated in menu.php.

A flat file database is simply a text file that uses some means of data seperation to store information. For our script we would create such a database in a new directory:
databases/menu.db

CODE

Search Engines|header
Alta Vista|www.altavista.com
Excite|www.excite.com
Google|www.google.com
Lycos|www.lycos.com
Yahoo|www.yahoo.com
Public Forums|header
AstaHost|www.astahost.com/index.php
Trap17|www.trap17.com
AntiLost|www.antilost.com
Online References|header
Dictionary|www.dictionary.com
Thesaurus|www.thesaurus.com
Maps|www.mapquest.com
Phone|www.sbc.com

Note here that we use the pipe "|" charater to seperate the link name from the link url. We will write our script to read each line individually so each line effectively acts as the records seperator.

Here is the code we will use in menu.php

CODE

<?php
function make_menu($name, $url) {
if ($url == 'header') {
$link = "<span style=\"font-color: lime; font-weight: bold;\">" . $name . "</span><br>";
}
else {
$link = "<a href=\"http://" . $url . "\" style=\"font-size: 8pt;\"> ♦ " . $name . "</a><br>";
}
return $link;
}


$handle = @fopen("databases/menu.db", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle);
$menu_array = explode("|", $buffer);
echo make_menu(trim($menu_array[0]), trim($menu_array[1]));
}
fclose($handle);
}
?>


The first part of menu.php is nearly the same as the one used in CMS101 - Content Management System Design.

The second part of the script replaces the old individual make_menu() funtion calls with code that will read data from the database and automatically pass the information on to the make_menu() function. This code first opens the file for reading and then begins to read from the first line. Once the first line is read and the data is processed, the code goes to the next line. Prior to reading any line, the script first checks to see if there is data on that line. This is done with the feof() function to see if the end of the file has been reached. As long as the end of the file has not been reached, the script will read each line and pass that lines data to the make_menu() function. The explode() function reads the line and breaks the data into each field based on the location of the pipe character. The trim() function ensures that only the data is passed to the make_menu() function be removing all whitespace before and after the data.

The benefit of using this type of database system to store the data for your menu is that the database is very easy to read. When editing the menu, all you need to do is insert or delete lines of data where you want the menu item to be located. For those that are less interested in scripting and programing, there is an added bonus of not having to worry about damaging the script each time you edit the database since the two are seperated from one another.

It should now be getting clearer how using a template or CMS system on your website can make the day to day administration of your website much easier. Please understand that this tutorial is not a template layout and design how-to. It is a tutorial on how to create a template system. For information about template layout, design and/or style, please look at forum categories related to website design. This is a PHP scripting how to. I'm not very good at the overall look and fell of website design. Please don't ask me about that type of stuff.

I hope that this information will be helpfull. :lol:

vujsa

Mon Apr 3, 2006    Reply    New Discussion   
 
Posted in Computers & Tech / What's New...?
Author: Laos Total-Replies: 11


Well,

For all you living in a rock for the past 6 years, you may not know that were starting to work the kinks out of a box 5 feet below the ground in front of your house/apartment, that needs 10-20$ a month at most to maintain, and can power 3-5 houses?!

A Fuel Cell.

A hydrogen Powered Generator. But theres somthing special about it...

A fuel cell when using Hydrogen fuel gives off two items

1. Electricity

2. H2O ( Water)

But what if, you do this,

Connect a pump to take the water and put it throught a separator. Then Hydrogen is then put into the Fuel cell and becomes power. and the cycle continues. While a pipe sends the oxygen out into the area, so you can breath :o

So basically you got a self sustained power source needing 1 thing... A Start up Fuel unit.

Some of the electricty is using it to power, the rest you use

Wouldnt that solve tons of problems once the Mass production kinks are out?

Wed Mar 15, 2006    Reply    New Discussion   
 
Posted in Astahost / Hosted Members Support / Misc. Issues with no other for..
Author: madcrow Total-Replies: 6


The site that I'm running is basically an oldskool BBS powered by web technology, but it's currently missing something: online games. Given my theme, I was wondering if there's any source for modern PHP versions of varoius oldskool BBS games like Empire, TradeWars, DopeWars, etc? I'd be especially interested if someone could point me to a web version of the classic C64 BBS game Murder Motel...

Tue Apr 26, 2005    Reply    New Discussion   
 
Posted in Computers & Tech / How-To's and Tutorials / Programming / C and C++
Author: qwijibow Total-Replies: 4


This example assumes you already know basic c++ functions and classes.
it is by no means a complete c++ tutorial, but should give you a good idea of the power of c++.

In this tutorial, i will be using virtualisation, abstraction, and polymorphism to draw a simple picture.
the code is not complete, because i dont want to tie it into any specific operating system.
i will use onlt standard template library finctions, and graphics requires the use of OS specific API's/

We are going to write a program, which holds an array or different shapes.
and (if complete) would draw thenm ot the screen.. (for this example, the will just output somthing like "I am a circle, radius 12, x=20, y=50"

It doesnt sound impressive, but we will be using a single array to hold different classes without using a container. In other words, its like having an array that holds some integers, some booleans, and some strings. it is normally not allowed.

first, before the code, some simple definitions.

=============================
Virtual functions:
=============================
A virtual function is a function which apears to exist to some parts of the code, but aprears not to exist to other parts of the code.

a Pure virtual function is the same, but has no function body. if a class has at least one pure virtual function, then it is considered abstract. meaning it cannot be used directly, but can be used as a template for other functions.

Take a look at the following example program

CODE

#include<iostream>
using namespace std;

class base_class {
public:
[tab][/tab]void function1() {
 cout << "function1 of base_class" << endl;
[tab][/tab]}

[tab][/tab]virtual void function2() {
 cout << "function2 of base_class" << endl;
[tab][/tab]}
};

class sub_class : public base_class {
public:
[tab][/tab]void function2() {
 cout << "function2 of sub_class" << endl;
[tab][/tab]}
};

class sub_class2 : public base_class {};

int main() {

[tab][/tab]base_class BASE;
[tab][/tab]sub_class SUB_A;
[tab][/tab]sub_class2 SUB_B;

[tab][/tab]BASE.function1(); // outputs "function1 of base_class"
[tab][/tab]BASE.function2(); // outputs "function2 of base_class"
[tab][/tab]
[tab][/tab]SUB_A.function1(); // outputs "function1 of base_class"
[tab][/tab]SUB_A.function2(); // outputs "function2 of sub_class"
[tab][/tab]
[tab][/tab]SUB_B.function1(); // outputs "function1 of base_class"
[tab][/tab]SUB_B.function2(); // outputs "function2 of base_class"

[tab][/tab]return 0;
}


virtual function2 in the base class apears to exist, except to the class sub_class, because this class defines its own function2, it over-rides the virtual function.

we could have made function2 a pure virtual function be declairing it like so....

CODE

virtual void function2() = 0;


a pure virtual function exists ONLY to be over-ridden.
you cannot declair an instance of a class containing pure virtual functions, and so if this had been the case, the line

CODE

base_class BASE;
would have caused a compile error.
a class containing pure virtual functions is called abstract.

=============================
Polymorphic objects. (the clever pointer)
=============================

In C++, the pointer rules have been relaxed.
a pointer of type XYZ can point to any class derived from XYZ

the following code example is perfectly legal in c++

CODE

class commom{};

class tree : public common{};
class bird : public common{};
class car : public common{};
class pan_galactic_gargle_blaster : public common{};

int main() {

[tab][/tab]common* array[5];
[tab][/tab]
[tab][/tab]array[0] = new common;
[tab][/tab]array[1] = new tree;
[tab][/tab]array[2] = new bird;
[tab][/tab]array[3] = new car;
[tab][/tab]array[4] = new pan_galactic_gargle_blaster;

[tab][/tab]return 0;
}


=====================================================
MAIN example, combining the 2 examples above.
======================================================
Armed with the ability to have an array of different types, and the ability to over ride functions,
we can do some very clever things.

we are going to write a simpe drawing program.
it will be an array of different shapes, the base class will have a draw() function
which draws different shapes, depending on how it is used. (polymorphic, to change shape! lol )

// include the usual stuff.

CODE

#include<iostream>
#include<vector>

using std::vector;
using std::cout;
using std::cin;


now we need our common base class

CODE

class shape {

protected:
[tab][/tab]int x_position;
[tab][/tab]int y_position;
[tab][/tab]int width;
[tab][/tab]int height;

public:
[tab][/tab]virtual void draw() = 0;

[tab][/tab]void setX(int x) {
 x_position = x;
[tab][/tab]}

[tab][/tab]void setY(int y) {
 y_position = y;
[tab][/tab]}

[tab][/tab]void setW(int w) {
 width = w;
[tab][/tab]}

[tab][/tab]void setH(int h) {
 height = h;
[tab][/tab]}
};


This is ab abstract class because it contains a pure virtual function draw.
the size variables, and manipulation functions are common to all shapes, so they go in the base class.

now lets add some shapes/

CODE

class triangle : public shape {

public:
[tab][/tab]void draw() {
[tab][/tab]
 cout << "i am a triangle" << endl;
 cout << "[tab][/tab]height:" << height << endl;
 cout << "[tab][/tab]width:" << width << endl;
 cout << "[tab][/tab]X:" << x_position << endl;
 cout << "[tab][/tab]Y:" << y_position << endl;
[tab][/tab]}
};

class circle : public shape {

public:
[tab][/tab]void draw() {
[tab][/tab]
 cout << "i am a circle" << endl;
 cout << "[tab][/tab]radius:" << height << endl;
 cout << "[tab][/tab]X:" << x_position << endl;
 cout << "[tab][/tab]Y:" << y_position << endl;
[tab][/tab]}
};

class rectangle : public shape {

public:
[tab][/tab]void draw() {
[tab][/tab]
 cout << "i am a rectangle" << endl;
 cout << "[tab][/tab]height:" << height << endl;
 cout << "[tab][/tab]width:" << width << endl;
 cout << "[tab][/tab]X:" << x_position << endl;
 cout << "[tab][/tab]Y:" << y_position << endl;
[tab][/tab]}
};

class dot : public shape {

public:
[tab][/tab]void draw() {
[tab][/tab]
 cout << "i am a dot" << endl;
 cout << "[tab][/tab]X:" << x_position << endl;
 cout << "[tab][/tab]Y:" << y_position << endl;
[tab][/tab]}
};


each class needs to override the pure virtual function in the shape class.
if a class failed to override the draw() function, then that class would in turn become abstract.

finally, let se out super cool porgram in action.

CODE

int main() {

[tab][/tab]vector<shape*> shapes;

[tab][/tab]shapes.push_back( new triangle() );
[tab][/tab]shapes.push_back( new circle() );
[tab][/tab]shapes.push_back( new rectangle() );
[tab][/tab]shapes.push_back( new dot() );
[tab][/tab]shapes.push_back( new triangle() );
[tab][/tab]shapes.push_back( new circle() );
[tab][/tab]shapes.push_back( new rectangle() );
[tab][/tab]shapes.push_back( new dot() );

[tab][/tab]// set all the shapes member variables (idealy, use random)
[tab][/tab]for(int n=0; n< shapes.size(); n++) {
 shapes[n]->setX(1);
 shapes[n]->setY(2);
 shapes[n]->setH(3);
 shapes[n]->setW(4);
[tab][/tab]}

[tab][/tab]// draw the picture !
[tab][/tab]for(int n=0; n< shapes.size(); n++) {
 shapes[n]->draw();
[tab][/tab]}
[tab][/tab]
      // clean up, prevent memory leaks.
[tab][/tab]for(int n=0; n< shapes.size(); n++) {
 delete shapes[n];
[tab][/tab]}

[tab][/tab]return 0;
}


the vector MUST be a vector of pointers to shapes, and not a vector of shapes.
the the intelligent pointer that knows what functions to call.

and just for fun, the output of the compiled program.

QUOTE

bash-2.05b$ g++ TEST.cpp -o TEST
bash-2.05b$ ./TEST
i am a triangle
        height:3
        width:4
        X:1
        Y:2
i am a circle
        radius:3
        X:1
        Y:2
i am a rectangle
        height:3
        width:4
        X:1
        Y:2
i am a dot
        X:1
        Y:2
i am a triangle
        height:3
        width:4
        X:1
        Y:2
i am a circle
        radius:3
        X:1
        Y:2
i am a rectangle
        height:3
        width:4
        X:1
        Y:2
i am a dot
        X:1
        Y:2


Even advanced C++ isnt too complicated when you understand whats happening.

Any questions / comments / surgestions ?

Fri May 6, 2005    Reply    New Discussion   
 
Posted in Computers & Tech / Programming / Game Programming
Author: tsakis Total-Replies: 21


i just walt to make games
i know some basic programming and i do the grafics myself but i still cant find a reliable machine to make my games...
i mean like i have tried different progs like DarkBasic,Macromedia flash,c++
but with none of them i dont th power i want...

i only once found a good prog BlitzBasic3d but i cant fnd a cracked version and the demo version has a code limiter...

so if there are any1 who can help me or suggest something plz pm me...

Fri Jan 6, 2006    Reply    New Discussion   
 

Ask a Question (w/o registration) to get Quick Answers!


astaHost