Sep 24 2007

Password Protecting a Zip File Using PHP

Tag: Programming & InternetDustin @ 10:47 am

I needed a way to add a password to zip files I was creating in PHP, but it seems support for that is lacking. So I resorted to using Info-ZIP. This particular site I was running PHP on a Windows IIS server. Info-ZIP is free and supported on multiple platforms. I downloaded the Windows binary file and put zip.exe in my C:\WINDOWS folder. I then had to give the Internet User Execute permission on C:\WINDOWS\System32\cmd.exe in order for me to call the system() function in php.

Then I wrote a quick test script that seemed to work:

<?php
$filename = "filename.zip";
$pdf = "document.pdf";
echo system("zip -P 1234 -j $filename \"$pdf\"");


Jul 02 2007

Sortable (Drag & Drop) Table Rows

Tag: Programming & InternetDustin @ 6:10 am

OK, here’s the problem. I need an easy way to sort table rows for my new mini site at www.BigBangHosts.com (on the admin side). I normally use script.aculo.us for my DHTML & Ajax needs, but in this case I couldn’t find what I needed. I wanted and easy way to sort table rows and store the new sorting in the database. This would easily allow me to change the rankings of various hosts in my admin control panel.

Option 1 was to create a separate page just for sorting. This way I could use a list. The reason I didn’t like this options was because I would not be able to see all the features of each host at a glance as I could with a table.

Digging deep into the Google results I found this demo script that was simply awesome. In order to get it to work for my needs I did the following:

  1. Viewed the source and got the javascript that did the sorting work.
  2. Downloaded dhtmlapi.js from www.howtocreate.co.uk
  3. Added a kludgey hack at the end of the stopDrop() function to post the new order to a php script
  4. Used PHP to write to the database.

The result allows me to drag and drop and everything is seamlessly saved!

Kludgey Hack =
var getstr = "";
for( var i = 0, x = theTable.getElementsByTagName('tr'); x[i]; i++ ) {
getstr += x[i].id;
}
var runscript = new Image();
runscript.src = ’sortrank.php?order=’+getstr;

PHP Snippet (table row had id values of “id{row_id}”)=
$order = split('id', $_GET['order']);
array_shift($order);

foreach ($order as $val) {
$sql = “update hosts set rank=”.++$rank.” where id=$val;”;
query($sql);
}

Special thanks to Mark Wilton-Jones for doing virtually all the work for me.


May 24 2007

More Evidence of My Nerdiness

Tag: Humor, Programming & InternetDustin @ 10:17 am

I saw this joke online today and I got it right away and thought it was quite humorous:

Q: Why do computer geeks confuse Halloween & Christmas?

A: 31 OCT = 25 DEC

So I rushed off to tell my fellow programmers and they just didn’t get it. I even wrote it down for them. Hmph. A joke is just not funny when you have to explain so I won’t.

Along the same lines I also like the often quoted:

There are only 10 types of people in the world… Those who understand binary and those who don’t.


Apr 09 2007

Under Cover Profits

Tag: Internet Marketing, Programming & InternetDustin @ 3:58 pm

If you are into affiliate marketing at all, or have been in the past year, you probably remember the whole “The Death Of Adsense” report that came out last year. In was in the middle of these reports that I first heard about John Jonas. He did a marketing call with Scott Boulch, the author of The Death Of Adsense. I listened to it on my iPod while working out during lunch one day. I couldn’t believe how much information John was sharing on that call and how straight up honest he was. I agreed spot on with everything he said - especially his product reviews. After listening to that call, I found his website and email list “What’s crap and what’s not.” It was refreshing to say the least.

I was especially intrigued by an email John sent to his list back on December 2nd. He had initially send an email hyping Competition Dominator, but came back saying it was crap based on further use. I find some of the comments left to this email humorous. I think it was mostly people who wasted their money on the product just chirping to try to justify their purchase to themselves.

I found this comment especially humorous and ironic:

Worst Review Ever… Revealing Ignorance

Submitted by Anonymous on Tue, 2006-12-05 17:02.

Well, you sure know how to make enemies and to lose credibility. Any one that trashes an excellent product because they have their own agenda to sell their own product should be ignored or worse.

You’ve lost all credibility with me and I hope with many of your subscribers and readers who are using it and know it’s **not** crap.

Chris and Goran are some of the best software developers I know and honestly.. this product is powerful in so many ways.

If you can’t make it work for you or don’t see the value of it, it only means one of two things to me: A) You’re not very bright. B) You’re trashing it so people will buy your product instead.

More likely it’s both.

You don’t even use your last name on your PR Zero pages here. A lot of credibility you…

(BTW, that post is a PR2 and the site as a whole is a PR4)

Well, John finally released his product. Again, I was surprised at the detail he showed in his videos - especially how to do the stuff manually. From a web programmer and automation engineer it looked to me like he was giving away the farm before he even released the product. He actually showed you how he made the software work! I think this was to prove how legit the software really is - no false claims, no smoke & mirrors.

I waited for the released and when I saw that it was nearly $300 per month, I can’t say I was surprised. I figured it might be as much because if used properly, this software could easily pay for itself with minimal effort - unlike most software that makes that claim. I had the opportunity to order it, but I didn’t. But let me tell you a little bit more about myself to explain why…

I think I first got started with Internet marking back in 2003. I had a few websites and I was even selling Palm & Pocket PC software to a niche market (but I can’t say I even know what “niche market” meant at that time). I had a co-worker that started telling me about the money he was making on the side with various things he was doing. Ultimately, he started making HUGE money using Google Adwords. He referred me to the Google Cash book by Chris Carpenter. I bought it and read it. I spend a few months trying this stuff out. I racked up thousands of dollars on my credit card, but the affiliate commissions I got seemed to barely break even. I think out of all the campaigns I tried only one or two of them made fairly decent returns - or so I thought. As I was trying results I later learned that most of the sales for my best profiting campaign were fraudulent so I never got paid. I lost big time. I cut my losses and figured this system is just not for me and gave up on it - even though my friend was making 5 figures a month with it.

I never really lost interest with Adwords though. With the Death of Adsense report, I learned how I could better improve reporting. I tried again, but still I could never seem to find a profitable campaign I was always losing money. Most of all, I didn’t want to get out my credit card again. I was on cash only basis from here on out!

So in essence, this is the reason I did not buy John’s software. I simply didn’t have the cash on hand in my “business” account. Everything I do on the side I keep in a separate account. This is sort of my “playground” to earn extra money. We have a baby on the way due in September and my wife (who doesn’t understand much of this stuff anyway) was not very keen on the idea of me spending that much money on software I couldn’t very well explain to her.

On day 2 I was surprised that there were open spots still available for UnderCoverProfits (UCP). I sent John a message and asked out of curiosity how many seats were still available. There were only 6 left! I explained that I couldn’t afford it but I thought about writing my own version that essentially did the same. I was surprised at his response. He was positive and encouraging - even offering tips and suggestions!

Well it took only 3 days to write the features that I saw on John’s videos. Granted, I don’t have all the features, I don’t have keywords sorted by campaigns, and I don’t have the ability to find other ad campaigns existing for a certain clickbank user. But I have the core functionality that makes the software so valuable. In his videos, John used “panic attack” to demonstrate one profitable campaign he found. Here are my results after 12 days of monitoring (click to see full size):

Panic Attack

I don’t have a full month of data for any keywords yet, but I got excited with results I have already started seeing so I tried out some ads. The first one I tried was profitable! It’s a ClickBank product and honestly, I have never had success with any ClickBank products - even though that is what all the gurus rave about.

As you can see from the screen shot below, I’m actually getting some “bars” in ClickBank now!

ClickBank

On that first campaign I’ve tried, I’ve netted $180 in 5 days. I understand all the tracking techniques and all the principles behind tracking, testing, landing pages, etc. My problems has always been to know what products will actually make more than I have to spend on them to get the traffic. Now, thanks to John, I have a tool that will help.

It’s funny, when I told my wife about the results. She said, “maybe you should buy his software now.” It’s certainly a good idea. Like I said, I don’t have all the features John has. My biggest concern is that I’m running this on my own hosting account. I have to query Google every day for each of my keywords. John has 30 servers and 1500 IP addresses set up. Obviously he has a safer and more reliable system. Well, now its obviously a bit too late even if I wanted to. The seats are full so I would have to get on the waiting list like everyone else.

So to sum up this post, thank you John for awesome software you have released to the public. Even though I have not purchased it, your help and suggestions have gotten me back in the game after two years on the disabled list!


Mar 29 2007

Sorting an HTML Table

Tag: Programming & InternetDustin @ 9:36 am

Oh, sometimes I really LOVE the web 2.0 javascript features. Take for example sorting tables. Now the old school method of doing this is to programatically send the column you want to sort by and whether you will be sorting ascending or descending and pass it to the page in a get variable. It is really a pain in the butt to code.

Well, thanks to Stuart Langridge, making tables sortable is a breeze. And it doesn’t require you do a page refresh to sort the table.

The downside is that it doesn’t work on browsers that don’t support Javascript, but unless you are trying to support pocket pc’s or something, this is pretty much a non-issue.

* One thing to watch out for, notice the name of the javascript file is sorttable.js (extra ‘t’ - the script makes a “sort-table”) and the class you need for your table is “sortable” (no extra ‘t’ - the table is now “sortable”). I sort (no pun intended) of missed this and it had me boggled for couple minutes.


Mar 28 2007

Word Wrap / Reflow in Firefox Table Cell

Tag: Programming & InternetDustin @ 8:53 am

OK, this bug is just insane. I’ve got a table cell displaying very long URLs. Oddly, there is no CSS style that allows Firefox to “reflow” or wrap the text based on a given width.

This bit of CSS solves the problem for virtually every other popular browser:

td {
width: 450px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

… but it does nothing for Firefox.

That led me to find a programmable solution to my problem. What I did was use regular expression to add a zero-width character after any character that is not a letter or number. The character will wrap when it reaches a “barrier”.

Here’s the code in php:

$url = preg_replace('/([^a-zA-Z0-9])/’, “$1&#8203;​​​”, $url);

Or, for you smarty fans:

{$url|regex_replace:"/([^a-zA-Z0-9])/”:”\$1​​​&#8203;”}


Mar 27 2007

A generic error occurred in GDI+.

Tag: Programming & InternetDustin @ 3:24 pm

Sometime I run into errors that seem to make no sense and it takes me a while to find the answer as to why. Such is the case with this error. I wrote a routine in VB.NET to split a multi-page tiff file. Every once in a while, I would get this less than helpful error: “A generic error occurred in GDI+.” when calling the Image.Save() function.

Thanks to another frustrated user that found the solution I was able to see that sometime the folder I was sending files to did not exist. So rather GDI telling me that the save path did not exist it simply threw a generic error. Thanks!

So as long as you’re reading this, I might as well share the function that splits a multi-page tiff file. There are actually two functions. UniqueName is a recursive function that makes sure you don’t overwrite an existing file.
Continue reading “A generic error occurred in GDI+.”


Mar 09 2007

Clicky Is So Much Easier!

Tag: Programming & Internet, Web SitesDustin @ 9:24 am

I wrote a post about how to hack Google Analytics to show the full path on referrer URL. Honestly, its a pain in the butt at best. I went digging around the net and came across a new stat tool that shows the full URL. It’s called Clicky and I have to say, it is so much easier to use that Google Analytics.

A long time ago I used to use pphlogger, which was nice, but I had to install it on my own server and it seem to create a lot of overhead. What I like about it is that I could see what a particular visitor did while on the site.

Clicky gives you the same functionality, but it is in a much nicer format and easier to read.

Plus, they are adding new cool tools continually, like the spy, with allows you to see traffic occurring in real time! This may only be useful to you if you get a lot of traffic ;)

One more feature I have to mention is the ability to make a sites stats public. I set up clicky for a customer and sent her the link the my stats. She LOVES it and she doesn’t have to remember another login to see them. Kudos to me!

So, let’s see what people searched for yesterday to find my blog…

Clicky Searches

So, what are you waiting for, go get Clicky. They have free basic accounts and cheap plans if you have enormous traffic or want a few special features such as the spy and RSS feeds - you do get a free trial on these when you initially sign up.


Feb 28 2007

Gmail Delete Shortcut Key

Tag: Programming & Internet, Web SitesDustin @ 1:57 pm

Gmail Trash

I love Gmail, but I find it rather annoying that they feel you never need to delete an email. It took them about 2 years to add the delete button. I don’t know why they didn’t add a shortcut key with it. Certainly, they must have had thousands of requests for it already.Well, I’m happy to report that you can get a shortcut key to move your messages to the trash. But you will need the following:

  1. Firefox
  2. Greasemonkey
  3. Gmail Macros

What to do:

Install Firefox (if you are not using it already), then install the Greasemonkey extension. Then download the Gmail Macros script for Greasemonkey and read this post carefully to learn how it works. Now you can press ‘t’ (for trash) to move that non-spam, unimportant message to the trash!

Technorati Tags: , , , ,


Feb 12 2007

Crop An Image (Bitmap) in C# or VB.NET

Tag: Programming & InternetDustin @ 2:32 pm

I looked all over the net for some sort of function and what I ended up with seemed rather simple function to crop an bitmap.

Here is the function in C#
public Bitmap CropBitmap(Bitmap bitmap, int cropX, int cropY, int cropWidth, int cropHeight)
{
Rectangle rect = new Rectangle(cropX, cropY, cropWidth, cropHeight);
Bitmap cropped = bitmap.Clone(rect, bitmap.PixelFormat);
return cropped;
}

And the same 3-liner in VB.NET
Private Function CropBitmap(ByRef bmp As Bitmap, ByVal cropX As Integer, ByVal cropY As Integer, ByVal cropWidth As Integer, ByVal cropHeight As Integer) As Bitmap
Dim rect As New Rectangle(cropX, cropY, cropWidth, cropHeight)
Dim cropped As Bitmap = bmp.Clone(rect, bmp.PixelFormat)
Return cropped
End Function

(Sorry the format is not that great on my blog here.)

Technorati Tags: , , , , ,


« Previous PageNext Page »


ss_blog_claim=4973c51f5e7bec57951f995fed1b85f3 ss_blog_claim=4973c51f5e7bec57951f995fed1b85f3