Web Page Templates Icons, Clipart, Logos


Hot Topics

Post Archive


May 02, 2013 10:45 AM EDT


Solid State Drives or SSDs are one of the biggest advancements to modern computing in recent years. 

Traditional hard disk drives or HDDs consist of a series of metal platters that spin around.  There are magnetic arms that then move around to read the data off of the hard drive.  This limits the speed of the hard drive to how fast those platters can spin, and because there are moving parts involved, the hard drive tends to wear out faster than any other part of the computer.  Spinning the platters also causes additional heat and noise inside the computer.

SSDs don't have moving parts.  You can think of them as basically memory or RAM that stores the data permanently.  There are differences, of course, between these two technologies, but the high level concept is the same.

Because there are no moving parts, it is much faster to read/write data.  They also use less power and create less heat. While they'll still wear out eventually, they can last longer than traditional hard drives.

The only downside, currently, is that solid state drives cost more per GB of storage.  As the technology advances, this is becoming less of a discrepancy.  The 128GB SSD cost me $150, but you can currently get a 2TB hard drive for about $100. 

How fast is an SSD vs. an HDD

The best way to explain the difference is to give you an example.  For those of you who know MySQL, you know that backing up the database consists of running MySQLDump, which writes out a file with all the insert statements that can then be read back into MySQL to recreate a database.

I used a database that is large enough to easily see the differences.  The database dump file was about 1.5GB in size. It contains 200+ tables and millions of rows of data.

First, I restored it to my traditional hard drive, then I installed an SSD, reconfigured MySQL to use the SSD as the data directory, and then restored the same file again. The rest of the PC was exactly the same, which happens to have 4GB of RAM and a 6 core AMD Phenom II 1090T Processor.  It's running Linux Fedora 14.

This computer only has SATA2 controllers, which has a limit of 3GB/s of data that can transfer across its wires.  There are now motherboards with SATA3 controllers, which increases this limit to 6GB/s. The SSD I used was a OCZ Technology 128GB Vertex 4 Series SATA 6.0 GB/s 2.5-Inch Solid State Drive.  It's backwards compatible to the SATA2 or 3.0 GB/s speed.

My traditional hard drive took 35 minutes to import.  My solid state drive took about 5.  In theory, if I had a SATA3 controller, this could be cut in half again, though I doubt it would end up that efficient.  More likely, it would be 3 1/2 to 4 minutes.  So for this one test, the SSD was 7 times faster than my regular hard drive, and might end up 10-12 times faster under SATA3. 

There are also SATA3 controller cards that you can buy for about $50.  I thought about buying one of these, but I suspect that it wouldn't give you a full 6 GB/s because I believe you'll lose some speed as it travels through the card into the motherboard.  If you've done this, please comment and let me know your findings.

When to use SSDs

Any time you need speed over raw storage, use a SSD.  Some common uses are:

  • Boot drive - you'll boot up much faster using an SSD.  Store your photos and data on a traditional HDD.
  • Database Drive - if you are running any sort of database, the hard drive is often your slowest part.  Move your data over to a SSD and you'll notice a speed increase.
  • "Working Drive" - if you're using programs such as Photoshop that saves a history of each file change, you should see an increase in performance if your working drive is an SSD especially since most Photoshop files are 100MB or more. 
  • "Swap File" - If you are using more programs than you have available RAM, some of your working data will be moved to a file called the Swap file.  Put this on your SSD for a boost in speed.
  • Any time you're using a program that is hard drive intensive (i.e. has to load or save a lot of files or data while using the program).
  • If heat is an issue, such as in a data center where you have hundreds of computers or in a server where you're striping many hard drives together, use an SSD to decrease the amount of heat produced.
  • Use a SSD to reduce the amount of noise produced by your computer.

When to use HDDs

  • When cost is a factor
  • For raw storage such as large photos and other data that doesn't need to be accessed often
  • Storing backups where speed isn't an issue



Brian technology | computers | database | mysql | linux | data backup
Jun 19, 2011 02:09 PM EDT

Choosing the Right Digital Camera

Because there are so many options, it's hard to make the best decision when purchasing a digital camera. Factors such as size, quality and even color all play their part. So, which type of camera is right for you?

Unfortunately, the answer is that it depends on what you're going to use it for.

If you want a camera that you can take around in your purse or jacket pocket, then a consumer grade point and shoot camera is a great option. These are compact and don't weigh very much. They generally have decent preset settings and make it possible for you to literally point and shoot.

If the size and weight of the camera isn't a problem and you're looking for a better photo in terms of size, color depth, and overall quality, then a DSLR is probably what you're looking for. DSLR cameras have a larger photo sensor than point and shoot cameras. This is important because each pixel is able to receive more light and data so the photo is rendered better. One example is that a photo is less grainy at higher ISO settings.

To put this into perspective, a 14MP consumer grade point and shoot claims to be able to make a good 16x20" print, while a 6MP DSLR shooting in RAW can produce a good print up to 30x40". Why? Because the sensor is more than 4 times larger in the DSLR.

And, of course, the DSLR is able to change lenses for a variety of different situations such as telephoto lenses for sports or wildlife shots, large aperture lenses for low light shots, or macro lenses for closeups of insects, flowers, or other small objects.

The downside is that these cameras are a lot heavier and bulkier, especially when factoring in the weight of the lenses. This can be a problem for spur of the moment shots or when hiking for miles. In the case of the wildlife photographer, special backpacks are available to pack lenses and camera equipment for protection and to help distribute the weight more evenly.

Brian technology | camera
May 16, 2011 01:14 PM EDT

Drawing Tablets Defined

A drawing tablet is a computer input device, similar to a keyboard or mouse, that makes it possible for people to draw graphics, pictures, and use programs that need more sensitivity than a typical mouse. They are also referred to as a digitizer, digitizing tablet, graphics pad, or graphics tablet. The device consists of two items: a pen and a pad.  When the pen touches the pad, the motion and amount of pressure applied is captured by the computer and is displayed in the computer program such as Photoshop or Illustrator. Because it renders the amount of pressure, the program is able to determine how light or dark the line is to be displayed and, in certain instances, the thickness of the line. Often, the 'eraser' side of the pen also acts as an eraser with the tablet.

Beyond the art industry, tablet technology has reached the point of sale industry as well. Many businesses are using modified tablets to record signatures for received deliveries, credit cards, checking in at hotels or at the dentist's office, etc.

Smudged graphite drawings are a thing of the past; however, it does take a little getting used to.  The line doesn't show up below the pen anymore. It shows up on the screen.

Wacom is perhaps the most popular drawing tablet vendor; however, there are many available options such as Tooya, PenPower, and VisTablet.

Brian technology | computers
Apr 04, 2011 01:21 PM EDT

E-Book Readers Defined

An e-book reader is a mobile electronic device used to read books and periodicals. They are also called e-readers or e-book devices. While any device that is capable of displaying text on a screen can act as an e-reader, only the ones with the e-paper technology are technically consider one. These are specialized devices that are geared towards making it easy to read books using an electronic device. Careful consideration has been placed on available fonts, unit's weight, battery usage and overall readability.

Current research suggests that these types of devices are more popular with the older generations, possibly because they simulate real books more closely.

Amazon Kindle leads the market with 48% (as of Q4 of 2010), followed by Barnes and Noble Nook, Pandigital, Hanvon, and Sony Reader.

For around $100, current Kindle models have a 6" screen and weigh less than 6 ounces. For approximately twice the price, the Barnes and Noble Nook is available. The Nook is more like a tablet PC than an e-book reader. It uses a color touch screen, can play interactive games, and weighs about 16 ounces. It requires more battery power than the Kindle, which uses very little battery power because of its use of e-paper technology.

Brian technology | gadgets
Mar 09, 2011 01:28 PM EDT

GPS Defined

GPS stands for the Global Positioning System, which is a navigational system based on 24 different satellites originally intended for military use. These satellites where placed into orbit by the U.S. Department of Defense; however, in the 1980s, the government made the system available for regular civilians to use.

Each GPS satellite transmits a signal to Earth indicating the current time along with its current position in the sky.  GPS devices take this information and use triangulation to calculate the user's exact location. Basically, the GPS receiver compares the time from the signal to the current time, takes the difference of these two times, and uses that to calculate the distance between the device and the satellite.

It does this for 3-4 or more satellites. This way, the device is able to determine, within a few meters, the exact location of the device and then display the coordinates on the device's map. If it's connected to 3 satellites, it can determine latitude and longitude. If it's connected to 4 or more, it can also determine altitude. 

Once it knows the position of the device, it can then compare positions of where the device was in the past. This is used to determine speed, bearing, trip distance, etc.  For example, a mountain biker at the top of the mountain can find out what their average speed was when they reach the bottom based on how long it took and the distance traveled.  They can also determine the elevation change between the top and bottom.  Many devices also allow the user to upload their trip so that they can see it on an interactive map.

GPS works around the world, 24 hours a day, and it also works during any type of weather conditions.  There are no subscription fees to use the system, although vendors may have subscriptions for add-on services such as cloud storage to keep a log of many different trips taken.

Brian gadgets | technology
Feb 09, 2011 01:00 PM EDT

Computer Memory Defined

RAM (Random Access Memory) is the short term memory for a computer or electronic device. When a program is loaded, information is taken from the hard drive and placed into the computer's memory so that it is ready for the processor to work with.

Most computers have 2-4 RAM slots, and each computer accepts a specific type of RAM based on the slot size and other characteristics. Sometimes computer memory cards are referred to as sticks because their shape is similar to a stick of gum: long, flat, and thin. Each stick of RAM has a different, and ever increasing, measurement of how much memory it can store. It wasn't too long ago that RAM could only hold a few MB, but today, it's common for RAM to hold several GB.

Regardless of the specific amount of memory each stick can hold, it is usually less than the total capacity of the computer's hard drive (except in cases where the computer does not have a hard drive though those specific cases are beyond the scope of this article), and more than the memory connected directly to the computer's processor (often referred as CPU cache or L2 cache). RAM is much far faster than the typical hard drive but slower than the CPU cache.

When the computer is turned off, all of the data stored inside RAM is erased, which is why computers have hard drives - for permanent storage even though they're many times slower than the computer's memory.

In certain cases, the quickest and cheapest way to increase the overall speed of a computer is to add more memory. If the sum of the memory required by all of the programs that are currently running on the computer exceed the total amount of available RAM, the computer will start to "swap" memory, which means it will move some of the data to and from the hard drive. This is a time consuming process and is eliminated by either closing down enough programs so the computer needs less RAM for the moment, or by adding additional memory to the computer. If a program is simply installed, but not running, it is not loaded into memory and therefore does not affect the amount of RAM needed.

Sometimes programs have what is known as a memory leak. Internet Explorer and Firefox are notorious for various memory leaks. On Windows, check your task manager or on Linux and Macs, check your system monitor, top, or ps to see which programs are loaded into RAM. If the amount of RAM is much higher than when you first loaded the program, chances are this is the case. Simply restarting the program can be a temporary fix especially if it takes several hours to notice the slowdown. In these cases, make sure you have the latest version in case the issue has been fixed, and make sure your software vendor is aware of the problem.

Brian technology | computers
Jan 12, 2011 03:20 PM EDT

Tablet PCs vs. Laptops

For those that need the power of a desktop on the go, often a notebook, netbook, or a tablet PC is the way to go. Even just a few years ago, laptops cost several thousand dollars, but prices have fallen rapidly with the advent of smart phones and tablet PCs, which has opened the market up to a much larger audience.  Those always on the go, IT admins, college students, and road warrior  salespeople are among those that benefit from mobile technology.

So, which is better?  A laptop or a tablet PC?  Tablet PCs are often smaller, have touch screen, and fit in a backpack easier than a laptop. This is great for simple applications such as receiving email, showing sales figures in PowerPoint, browsing the web, playing simple games, or other tasks. 

For more powerful applications such as photo manipulation software like Photoshop or development software like MySQL, Eclipse, or Apache, the laptop is still the preferred way to go.  The laptop is bulkier and takes a little bit longer to set up, but it generally has a larger screen and keyboard to work with.  Often the other resources are greater as well such as processor speed, memory, and hard drive space.

Another benefit to using a laptop is that it's easier to fix and replace an individual part such as the laptop screen.  If a tablet PC has a problem, the entire device often has to be replaced.

To summarize, if size and convenience is your primary objective, a tablet PC or netbook may be the right thing for you.  If processing power and a larger screen size is more important, then stick with the laptop.

Related Links

Buy Electronics - Dofield.com offers great prices on Electronics, iPhone Accessories, LED, LCD, Cell Phone Accessories, Games Accessories, Laptop Accessories and more with free shipping and top-rated customer service.

Brian computers | technology
Feb 18, 2010 04:37 AM EDT

Ruby S3 Gem - Bug in temporary_url

All in all, the Ruby S3 gem is pretty good.  The main advantage of using this gem instead of AWS::S3 is that you can connect to all 3 Amazon S3 data centers: Europe, US East, & US West.  Jakub, the author, seems pretty responsive to bug fixes, and for the most part, life is good.

I found a bug tonight on version 0.2.6 that I've submitted to Jakub, so hopefully it makes it to the core soon.  The bug relates to generating a temporary URL for private keys (i.e. not publically accessible). Basically, what it boils down to is that the different strings aren't handled right... what should be escaped isn't, and what is shouldn't.  No biggie... here's the broken code: 


def temporary_url(expires_at = Time.now + 3600)
  signature = Signature.generate_temporary_url_signature(
                :bucket => name,
                :resource => key,
                :expires_on => expires_at,
                :secret_access_key => secret_access_key)


Here's the working code:

### Fixed by Brian Broderick
def temporary_url(expires_at = Time.now + 3600)
  ckey = CGI.escape(key.to_s)
  signature = Signature.generate_temporary_url_signature(
                :bucket => name,
                :resource => ckey,
                :expires_on => expires_at.to_i,
                :secret_access_key => secret_access_key)

  str =  "#{protocol}#{host}/#{path_prefix}#{ckey}"
  str << "?Signature=#{signature}&Expires=#{expires_at.to_i.to_s}"

Basically, I'm escaping the key (as a string) and passing it to another variable because otherwise, it returns a blank string.  Then I'm converting the expires_at to an integer because normally it passes the date spelled out. I'm not using his url function because it doesn't know to escape the key, and I don't escape the signature and expires_at values because they are already taken care of from the generate_temporary_url_signature method - well signature is anyway and expires_at is just a number so it doesn't need to be escaped.  Also, you can combine the 2 str lines into 1.  I did it this way so it'll fit correctly on the webpage.

One thing to note is that you also need to pass the AWSAccessKeyId in your URL, which isn't handled in this function. 

Here's the function again, though this time, It's sitting in my own object rather than inside the gem. This way, we don't have to modify the gem directly and can get by until it gets fixed:

### Written by Brian Broderick
def self.temporary_url(key, name=S3_BUCKET, expires_at=Time.now + 3600)
  key = CGI.escape(key)
  access_key_id, secret_access_key = get_keys     
  signature = S3::Signature.generate_temporary_url_signature(
                :bucket => name,
                :resource => key,
                :expires_on => expires_at.to_i,
                :secret_access_key => secret_access_key)
  str =  "http://#{name}/#{key}?Signature=#{signature}"
  str << "&Expires=#{expires_at.to_i.to_s}&AWSAccessKeyId=#{access_key_id}"

In this case, there are a couple of minor differences.  First, I've written a function that gets my secret key and access key to keep it DRY.  The variable "name" is set to S3_BUCKET by default, which is a constant for the main bucket that I use, and key is expected to be passed in as a string rather than an S3 Object. Since I'm getting both S3 keys, I'm able to pass the access key into the return URL.  Again, go ahead and combine the two "str" lines into 1.  I did this to make it fit on the page.

Hopefully this will be of help to somebody.

Brian ruby | amazon s3 | rails
Aug 04, 2009 01:18 AM EDT

Browser Screen Size

800×600 has been the standard browser screen size for years; however, only 8% of the population still use this resolution. 1024×768 and larger now represent over 90% of the Internet. With this in mind, it’s time to start developing websites with 1024×768 in mind. However, that doesn’t mean that a person actually has this much room to view their pages, and many people with better resolutions don’t have their browser maximized.

With a couple of standard browser plugins installed, here is what I found for the two current browsers, IE7 & FF2.

Internet Explorer Version 7 - 1003×517 usable space.
Firefox Version - 999×546 usable space.

Internet Explorer 7 - 1259×773
Firefox - 1263×810

Therefore, above the fold browser space for the majority of today’s browsers is 999×517.

Darren browsers | screen size
Aug 04, 2009 01:15 AM EDT

X-Cart modification: adding a 2nd image upload field

X-Cart is an e-commerce package that is written in PHP with the use of Smarty tags for its template system. For about $200, it includes a lot of functionality out of the box, and you can buy prebuilt skins for another $60 or so. For those interested in SEO, there is a module called CDSEO that you can purchase by a third party that’ll change the URLs from including GET request variables to a folder style SEO friendly format for another $150 or so. After the add ons, you can have a cart up and running for about $400.

The smarty system leaves a lot to be desired, so beware that it’s going to take longer than you’d normally think if you want to skin the site yourself, especially the first time you work with X-cart. One of the biggest challenges is knowing which template to modify. X-cart helps with this by providing a “webmaster mode”, which changes the status bar to reflect the folder and template structure of a particular section of the page. It’s quite handy because many of the template files are in strange places, and there are a ton of different template files.

X-Cart also loads pages slower than you would expect from a PHP site, which might be because of Smarty templates, but I’m not certain of that.

Note: this article is referring to version 4.0. 4.1 is out now, but I’ve heard that the newer versions are somewhat unstable until they’ve been out there for a while. 4.1 hasn’t been around long enough for me to use in a production environment yet. These instructions will
likely help with 4.1 as well. Of course, you’ll need to modify them to fit the newer codebase.

One issue I’ve come across is the need to put a small thumbnail image for each product listed on the shopping cart checkout pages. Below is how I modified the code to allow a 2nd picture to be uploaded in X-Cart’s admin area. I use one upload for a 250 pixel wide picture on the product detail page, and a 70 pixel wide image on the cart checkout page.

This article is assuming that you know PHP pretty well and can either grasp the Smarty concepts easily or have a familiarity with them. If you need further explanation about Smarty, please comment and I’ll write more about that in another post.


Modifying X-cart to allow 2 picture upload fields

First, back up your x-cart files and database in case something goes wrong.

Then, modify the following files:

In include/product_modify.php:

Add this code directly below the ‘if’ block with the comment “Check if image selected is not expired”:
If that comment can’t be found, look for the same block of code except that it’s looking for an imtype of “T” instead of “S”.
The two “if” blocks could probably be combined into 1, if you’d like. Please note that as is, you can only upload one image at a time.
If you want to be able to upload both at once, you’ll need to modify the code beyond the example to handle that.

//Cart Image
if ($file_upload_data["imtype"] == "S") {

if ($file_upload_data["counter"] == 1) {

$smarty->assign("file_upload_data", $file_upload_data);
else {
if ($file_upload_data["source"] == "L")

Also in include/product_modify.php, change the # Prepare for thumbnail updating (around line 278) to this:

# Prepare for thumbnail updating
$image_posted = func_check_image_posted($file_upload_data, "T");
$cartimage_posted = func_check_image_posted($file_upload_data, "S");

$store_in = ($config["Images"]["thumbnails_location"] == "FS"?"FS":"DB");
$cartstore_in = ($config["Images"]["cartimages_location"] == "FS"?"FS":"DB");

And add this code block directly after the $image_posted “if” block:

if ($cartimage_posted) {

$cartimage_data = func_get_image_content($file_upload_data, $productid);
$row_exists = func_query_first("select * from $sql_tbl[thumbnails] where productid = '$productid'");
if ($row_exists['productid'] == "") {
db_query("INSERT INTO $sql_tbl[thumbnails] (productid, ".($cartstore_in == "FS"?"cartimage_path":"cartimage").", cartimage_type) VALUES ('$productid', '$cartimage_data[image]', '$cartimage_data[image_type]')");
} else {
db_query("UPDATE $sql_tbl[thumbnails] SET ".($cartstore_in == "FS"?"cartimage_path":"cartimage")." = '$cartimage_data[image]', cartimage_type = '$cartimage_data[image_type]' WHERE productid = '$productid'");

On skin1/main/product_details.tpl, add this text below the normal thumbnail table row:

<!-- Cart Image -->
{if $productids ne ''}<TD width="15" class="TableSubHead"> </TD>{/if}
<TD colspan="2">{include file="main/subheader.tpl" title="Small Cart Image"}</TD>

{if $productids ne ''}<TD width="15" class="TableSubHead"><INPUT type="checkbox" value="Y" name="fields[thumbnail]"></TD>{/if}
<TD class="ProductDetails" valign="top"><FONT class="FormButton">Small Image</FONT><BR>(recommended size 50x50 or smaller)</TD>
<TD class="ProductDetails">
{include file="product_cartthumbnail.tpl" productid=$product.productid product=$product.product}
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<INPUT type="button" value="{$lng.lbl_change_image}" onclick='javascript: if (confirm("{$lng.txt_change_image_text|strip_tags}")){ldelim}popup_image_selection("S", "{$product.productid}", "{$query_string}");{rdelim}'>
<INPUT type="button" value="{$lng.lbl_delete_image}" onclick='javascript: if (confirm("{$lng.txt_change_image_text|strip_tags}")){ldelim}self.location="product_modify.php?mode=delete_thumbnail&productid={$product.productid}"{rdelim}'>
{if $file_upload_data.file_path}
<!-- End Cart Image -->

In include/image_selection.php, add this case in the $imtype switch:

case "S":
$config_data["location"] = $config["Images"]["cartimages_location"];
$config_data["path"] = $config["Images"]["cartimages_path"];
$config_data["path_only"] = $config["Images"]["cartimages_path_only"];

Save image.php as cartimage.php, then change the code portion to the following (leave the x-cart license comment stuff alone):
Also note that I’ve included <?php even though it shows up above the comments. Of course, you only need this in one spot.

require "./top.inc.php";
require "./config.php";

if (empty($productid)) $productid = "";

$image_out = ""; $image_type = ""; $image_path = "";

if (!empty($tmp)) {


if (!empty($file_upload_data["file_path"]) && $file_upload_data["id"]==$productid && $file_upload_data["imtype"]=="S") {
$image_out = func_file_get($file_upload_data["file_path"], true);


if (empty($image_out)) {

$result = db_query("SELECT cartimage as image, cartimage_path as image_path, cartimage_type as image_type FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid = '$variantid'");
$result = db_query("SELECT cartimage as image, cartimage_path as image_path, cartimage_type as image_type FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid = ''");

if (db_num_rows($result)) {
list($image, $image_path, $image_type) = db_fetch_row($result);

if ($image == "") {
header("Content-type: image/gif");
func_readfile($default_image, true);
} else {
header("Content-type: image/gif");
func_readfile($default_image, true);
//echo "Image: " . $image_type;


if ($config["Images"]["thumbnails_location"] == "DB") {
if (!empty($image))
$image_out = $image;
$no_image_db = true;

if ($config["Images"]["thumbnails_location"] == "FS" || !empty($no_image_db)) {
if (!empty($image_path)) {
header("Content-type: $image_type");
func_readfile($image_path, true);


if (!empty($image_out)) {
header("Content-type: $image_type");
echo $image_out;
} else {
header("Content-type: image/gif");
func_readfile($default_image, true);

Create a new file called skin1/product_cartthumbnail.tpl, and put this code in it:

{* $Id: product_cartthumbnail.tpl,v 1.14 2007/09/14 09:53:29 max Exp $ *}
{if $config.Appearance.show_thumbnails eq "Y"}
<IMG id="{$id}" src="{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/cartimage.php?productid={$productid}{if $file_upload_data.file_path}&tmp=y{/if}{/if}" alt="{$product|escape}" border="0">

In include/func.php, in the func_get_image_content function, add this to the $file_upload_data[”imtype”] switch:

case "S":
$config_data["location"] = $config["Images"]["cartimages_location"];

In the database:

Modify xcart_thumbnails (assuming you used the prefix “xcart” when installing it, otherwise modify the table with the appropriate prefix)
to include the following fields:

cartimage mediumblob allow nulls
cartimage_path varchar(255) allow nulls
cartimage_type varchar(64) allow nulls

In xcart_config, add the following rows (modify the table name if you used a different prefix other than xcart):

INSERT INTO xcart_config (name, comment, value, category, orderby, type, defvalue)
values ('cartimages_location', 'location of small cart images', 'DB', 'Images', '130', 'text', 'DB')

INSERT INTO xcart_config (name, comment, value, category, orderby, type, defvalue)
values ('cartimages_path', 'FS junk - not needed', '', 'Images', '140', 'text', '')

INSERT INTO xcart_config (name, comment, value, category, orderby, type, defvalue)
values ('cartimages_path_only', 'FS junk - not needed', 'N', 'Images', '150', 'checkbox', 'N')

After that, test it and see if everything works. If not, you’ll need to troubleshoot the code to see where you missed something.

Good Luck,

Darren xcart | php | cdseo
Aug 04, 2009 01:13 AM EDT

PHP script to repair all MySQL databases and tables on a server

The repair table command in MySQL is useful to repair database indicies when they become corrupt. A prime example of when an index can become corrupt is when the power is shut off unexpectedly to a server. If the power is shut off after a row has been inserted into the table, but before its index has been updated, the table will become corrupt and unusable.

Unfortunately, there isn’t a “repair all tables” option that I know of. Instead, you can use this simple PHP script to do the trick for you. It simply calls “show databases” to loop through a list of your databases, and then “show tables” so that it knows which tables exist for the repair command. Depending on how many databases you have and the size of their tables, this can take several minutes to run.

### Enter your username and password into the connection string: ###
$dbLink = mysql_connect("localhost", "username", "password") or die("Unable to connect to the database.");

$sql = "show databases";
$query = mysql_query($sql) or die("error fetching database names");

while ($rs=mysql_fetch_array($query)) {

//echo "Database: " . $rs['Database'] . "\n";

mysql_select_db($rs['Database'],$dbLink) or die("Unable to select database: " . $rs['Database']);

$sql = "show tables";
$query2 = mysql_query($sql) or die("error fetching table names");

while ($rs2=mysql_fetch_array($query2)) {
$key = "Tables_in_" . $rs['Database'];
//echo "Table: " . $rs2[$key] . "\n";

$sql = "repair table " . $rs2[$key];
$query3 = mysql_query($sql) or die("Error repairing a table - $sql");
$rs3 = mysql_fetch_array($query3);
echo $rs3['Table'] . " | " . $rs3['Op'] . " | " . $rs3['Msg_type'] . " | " . $rs3['Msg_text'] . "\n";



echo "Finished!\n";


Darren mysql | database | tables | server
Aug 04, 2009 01:12 AM EDT

Permission problems between Plesk and Apache resulting in 403 forbidden errors

After setting up a new site in Plesk and restarting Apache, the site would only display 403 Forbidden errors. The same error occured whether we went to the exclusive IP address or the domain name so we knew that it wasn’t a DNS problem. We checked the logs and it showed that Apache was unable to read the .htaccess file. We changed the permissions on this file, which didn’t do any good.

It turned out that when Plesk set up the domain, it gave the httpdocs directory the wrong permissions. Instead of the permissions that it assigned it, we changed it to 755 or rwxr-xr-x and everything works now.

If you get permission errors in the future, be sure to check the directory the file belongs in as well.

Darren permissions | plesk | apache | errors
Aug 04, 2009 01:10 AM EDT

Securing a Linux server with Iptables

You can save and restore your iptable rules by using the iptables-save and iptables-restore commands. An example of an iptables-save file is below, and as you see it allows access to http (port 80), https (port 443), smtp and pop3 (ports 110 and 25), ftp (port 21), dns (port 53), mysql (port 3306), ssh (port 22), plesk (port 8443), and a few others. It also allows traffic through ports 51000 through 51010. This is because ProFTPd is configured to forward established connections to these ports; Otherwise, it’ll use any high port and you won’t be able to lock anything down.

# Generated by iptables-save v1.2.7a on Fri Oct 15 18:04:43 2004
:INPUT ACCEPT [6496247:1563147047]
:OUTPUT ACCEPT [10757411:8360947636]
:RH-Lokkit-0-50-INPUT - [0:0]
-A INPUT -j RH-Lokkit-0-50-INPUT
-A FORWARD -j RH-Lokkit-0-50-INPUT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 443 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –sport 443 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 8443 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 110 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 110 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 25 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 25 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 21 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 21 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 20 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 20 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 3306 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 3306 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 53 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –dport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p udp -m udp –sport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51000 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51001 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51002 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51003 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51004 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51005 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51006 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51007 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51008 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51009 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 51010 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 22 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –dport 80 –tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A RH-Lokkit-0-50-INPUT -i lo -j ACCEPT
-A RH-Lokkit-0-50-INPUT -s -p udp -m udp –dport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -s -p udp -m udp –sport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -s -p udp -m udp –sport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -s -p udp -m udp –sport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -s -p udp -m udp –sport 53 -j ACCEPT
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp –tcp-flags SYN,RST,ACK SYN -j REJECT –reject-with icmp-port-unreachable
-A RH-Lokkit-0-50-INPUT -p udp -m udp -j REJECT –reject-with icmp-port-unreachable
# Completed on Fri Oct 15 18:04:43 2004

Here is an example of a cronjob that restores the Iptables rules. I added the cronjob to ensure that IPtables was always loaded with the correct rules. This was on a dev box and we were messing with a lot of ports at the time so we wanted to make sure that it was reset periodically. It also helps for when the box was rebooted to make sure the rules were loaded. Of course, a better way to do that would be to modify the startup scripts. Also, you can put the firewall.txt file where ever you want. It doesn’t need to be in root’s home directory.

### Restore Iptables Rules
5 7,14,21 * * * /sbin/iptables-restore -c < /root/firewall.txt

And finally, to set up the ftp server to only use the specified ports, configure /etc/proftpd.conf and add this line:

PassivePorts 51000 51010

The actual ports could be any unused high port, so keep that in mind. It can also be more than 10 ports (which essentially would allow 10 concurrent connections). Whatever you do, you’ll need to make sure the iptable rules allow the ports you’re expecting FTP to transfer data on.

Darren linux | security | iptables
Aug 04, 2009 01:09 AM EDT

How to remove the annoying clicking sound when a link is clicked in Internet Explorer

When I have my headphones on and am listening to music, it’s really annoying to hear that little clicking sound everytime I click on something in Internet Explorer.

If this is annoying to you too, here is how to turn it off:

Go to Start > Settings > Control Panel > Sounds and Audio devices

Click the ’sounds’ tab. In the window, scroll down to ‘Windows Explorer’ and in the sub menu, highlight ‘Start navigation’

Click on the drop down box below where it says ‘Start’, ‘Windows Start’, or ‘Windows XP start’ (or something similar depending on your operating system) and choose ‘(none)’ instead. Click ‘Apply’, then click OK, and close the Control Panel.

That annoying clicking sound is now a thing of the past.

Darren browsers | internet explorer
Aug 04, 2009 01:07 AM EDT

Using GPG to encrypt a file

Here are some instructions on how to encrypt a file using GPG, the open source version of PGP. It’s assumed that somebody needs you to send them an encrypted file, they’ve given you their public key in a trustworthy manner, and they have the private key. It’s also assumed that you have GPG installed, but this shouldn’t be a problem because it’s usually installed by default on Linux.

First, you’ll need to create a default gpg key. To do this, you’ll need to have a directory in your home directory called “.gnupg”. If you don’t have permissions to add directories into your root (common on shared hosting plans), you’ll need an admin to create the folder (mkdir) and set the owner to your user (chown).

Once you have the folder (or if you already have permissions, it’ll create it for you), run this command and follow the instructions. If you’re not sure the answer, accept the defaults or the first option.

gpg –gen-key

They may have armored their public key, which from the help file means to “create ascii armored output”. I’m not really sure what that means, but it seems like it’s in a text friendly format. If armored, you need to dearmor it first:

gpg –dearmor some_public_key.asc

This will create a new file with the gpg extention. Next you’ll need to import the dearmored key.

gpg –import some_public_key.asc.gpg

Once imported, you’ll need to find out it’s name.

gpg –list-keys

If you want the ability to encrypt files in a script, it’s a good idea to sign the key. Otherwise, the encryption process prompts you with a question, and the only way I’ve found to bypass that question is to sign the key.

Assuming that the name of the key is “somepublic”, here is the command:

gpg –sign-key somepublic

Follow the prompts and as long as you trust that the public key is legit, tell it you trust it explicitly. To see that everything was signed correctly, run this command:

gpg –list-sigs

Now try encrypting something using the public key:

gpg -e -r somepublic testfile.txt

If everything worked correctly, you’ll now have a file called testfile.txt.gpg (and the non-encrypted version), and it should not have prompted you for anything during the process. The only way to decrypt this file is to have the private key, which is what the other person would have installed.

Darren gpg keys | encryption
Displaying posts 1 - 15 of 33 in total

Online Information for Geeks





Resource Links