Personal website of Jeremy Morgan Me Saab Engine
Quick Menu [hide]
Big Menu [hide]
Toggle  Wiki
Banners [hide]

Powered by TikiWiki
Powered by PHP
Powered by Smarty
Powered by ADOdb
Made with CSS
Powered by RDF
openSUSE.org
RSSWiki
rssArticles
RSSImage Galleries
rssDirectories
Y-O-D-A Yoda
By: Jeremy Morgan  on: Wed 07 of Mar, 2007 [21:00 UTC]  (1288 reads)
Weird Al getting his Yoda on.



http://www.youtube.com/watch?v=WQ6hfXdxw5w
Extracting HTML Links with PHP
By: Jeremy Morgan  on: Fri 22 of Dec, 2006 [22:44 UTC]  (1045 reads)
This semester at work I've been building PHP based applications to help out my productivity. My most recent application is a web crawler I've named Mucs (Multiple Use Crawler Script). I decided to build my own crawler because I wanted to be able to have full control over the behavior of the crawler, and so that I can more easily create custom reports for myself and coworkers. I was surprised at how quickly my script could recursively transverse entire web sites.

Anyways, I figured I would start sharing some tricks I've learned as I've been working on this project. The first tip I'm going to post is how to extract the links from a page.

Basic PHP code for extracting html links:
$url="http://someserver.com/somepage.html";

//Grab entire web page
$input = @file_get_contents($url) or die('Failed to open: $url');

//Remove all tags except for links (best way I could find to remove commented out links)
$input = strip_tags($input, '<a>');

//Perl-Style Regular Expression for finding the contents of the <a> tag
$regex_link = "/]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)/siU";

//Finds links
if(preg_match_all($regex_link, $input, $matches)) {
  foreach ( $matches[2] as $link ) {
	echo $link."<br/>\n";
  }
}

As long as TikiWiki didn't mess up the source code above this should print out the contents of every uncommented the href attribute on a given page. There is still more work to be done to get it to actually filter, canonicalize, and construct absolute urls for recursive crawling. Version 0.5 of my crawler is currently 437 lines long and I will be going into more detail on how to get your own PHP crawler off the ground over the next several weeks. There may even be a wiki page set up in the near future.

EDIT: Let me know if the any source code doesn't work. I have to manually enter in the html code for greater than and less than characters.
The Elder Scrolls 4: Oblivion - Resumed
By: Jeremy Morgan  on: Thu 21 of Dec, 2006 [13:16 UTC]  (1337 reads)
Last week I started playing Oblivion again after a 6 month hiatus. My character is currently a level 32 Battle Mage Dunmer (Dark Elf). I'm only 156 hours into the game and have finished all the major quest lines except for the main quest and the Daedric Quests. I plan on finishing up the Daedric Quests and then close shut the jaws of Oblivion!
Final Fantasy XII - Paused
By: Jeremy Morgan  on: Sat 16 of Dec, 2006 [18:09 UTC]  (2890 reads)
I've taken a break from FF XII. Currently my main characters are all level 57, I'm almost 65 hours into it. Will pick it back up when I'm done with Oblivion.
How to Enable EMS (expanded memory support) in Windows 95/98
By: Jeremy Morgan  on: Thu 07 of Dec, 2006 [12:32 UTC]  (3158 reads)
I recently got interested in running some old PC games with Virtual PC on my iBook G4. I tried FreeDOS but it wouldn't run The Elder Scrolls: Arena no mater what I tried. I have no clue where my MS-DOS 6.22 disks are any more, and if I knew, they probably don't work anymore. I went into my cd-binder and dusted off my copy of Windows 98 SE. I get the base install done. Download IE 6, Firefox 2, and ran Windows update. Took about 2 hours total, beer and xbox live arcade helped with the time.

Now I get to the point where I'm going to try to run Arena, I get an error along the lines of "Not enough EMS." Well, it's been ages since I edited a config.sys file. I did some research on the web and came up with this config.sys code:

dos=umb,high
device=c:\windows\himem.sys /testmem:off
device=c:\windows\emm386.exe ram


Worked like a charm. Arena actually runs faster on my 1.0ghz iBook G4's Virtual PC running Windows 98 SE than it did on my 1.6ghz P4 running DOSBox.

Reference: http://www.columbia.edu/~em36/wpdos/windows.html#expanded95
Final Fantasy XII - Started
By: Jeremy Morgan  on: Wed 08 of Nov, 2006 [01:03 UTC]  (4374 reads)
I picked up FF XII and am 5 hours into it. I'm done with the "tutorial phase" as so many have called it and am actually enjoy the controversial gambit system.
Final Fantasy VI - Paused
By: Jeremy Morgan  on: Fri 03 of Nov, 2006 [16:53 UTC]  (847 reads)
I'm a little burned out from playing FF VI, 40 hours in so far, I havn't been following any faqs so I'm not sure how close to the end I am. I will probably pick it back up again after I'm done with Final Fantasy XII, which I should be picking up any day now.
Xbox Live Gamer Tag
By: Jeremy Morgan  on: Sat 21 of Oct, 2006 [13:23 UTC]  (1053 reads)
Looks like my gamer tag on the upper right hand side is busted. After further review, it looks like many of them are, even the example one on http://www.xbox.com/en-US/MyXbox/embedgamercard.htm . But Major Nelsons's works.... Cheater!
PHP Injection and MySQL's LIKE
By: Jeremy Morgan  on: Fri 20 of Oct, 2006 [14:45 UTC]  (975 reads)
I have been using sprintf() and mysql_real_escape_string() with a custom function called quote_smart as a way to prevent bad people from injecting malicious code into my SQL query strings. Everything went smoothly when I first started to switch all my web apps over to this syetem. Then I came to a search script that used MySQL's LIKE with wildcards.

Example:
SELECT * FROM catalog WHERE title LIKE '%$search%';

The problem with this is that sprintf() uses % as place holders for variables to be added.

Just in case you came to this article looking for a solution to prevent injection, I will show a basic example of using sprintf() with mysql_real_escape_string() and quote_smart:

$name = trim($_POST['name']);
$position = trim($_POST['position']);

$active="0";
if (isset($_POST['active'])) {
     if ($_POST['active'] == "1") {
          $active="1";
     }
}

$query = sprintf("INSERT INTO table1 (name, position, active) VALUES (%s, %u, %u)", 
    quote_smart($name),
    quote_smart($position),
    quote_smart($active));

%s means the variable to be inserted is a string, %b would be binary, %u would be an decimal interger, etc etc. More information can be found in the PHP Manual entry.

This is the quote_smart function I’ve been using (found all over the web):

function quote_smart($value) {
     //stripslashes
     if (get_magic_quotes_gpc()) {
          $value = stripslashes($value);
     }
     //if it's not an number then put it in quotes.
     if (!is_numeric($value)) {
          $value = "'" . mysql_real_escape_string($value) . "'";
     }
     return $value;
}

That works pretty well. But what if you wanted to prevent people from injecting bad code into a search query? Both PHP’s sprintf() and MySQL’s LIKE use the percent sign (%). That stumped me the first time I came across this. I put my logic cap on and eventually figured out that I just have to put the percent signs for the LIKE wildcards inside the quote_smart argument!

$search = trim($_GET['search']);
			
$where = sprintf(" WHERE name LIKE %s",
     quote_smart("%$search%"));

$query = "SELECT * FROM table1$where ORDER BY name;";

Like always, I was thinking the solution was going to be harder than it was. Hopefully this information will help other PHP Developers who were just as tired as I was when i first came across this.

More Information:
sprintf() - PHP Manual
mysql_real_escape_string() - PHP Manual
quote_smart example - One of many

Kutaragi doesn't care.
By: Jeremy Morgan  on: Sat 30 of Sep, 2006 [14:53 UTC]  (1622 reads)
http://www.gamespot.com/news/6159054.html

I guess this is the first Video games news item I felt was worth me commenting on.

Kutaragi doesn’t care about the competition??? The Xbox 360 might not be selling like hot cakes in Japan, but it’s doing pretty well in the rest of the world (6.1 million units sold so far). Sony is only going to have 500,000 consoles at launch and will be divided between US and Japan. Europe and (I assume) the rest of the world will not have any available until spring ’07. Sony has been spinning their wheels and getting nowhere with production. For the record, the Xbox 360 sold 1.5 Million worldwide in its first quarter.

What about Nintendo? Well, I might not be any businesses or marketing expert, but judging by the way the DS is doing in Japan (and quite frankly the world) I wouldn’t be surprised if Nintendo does equally well with the Wii.

It was the same arrogance by Nintendo in the 90’s that put the Playstation franchise where it is today. Blu-ray will be this generation’s N64 Cartridge.

Page: 1/3  [next]
Calendar-Filter [hide]
1)   Resume
2)   Saab 900 Parts List
3)   HomePage
4)   Biography
Last Images [hide]
Random Images [hide]
image
Powered by TikiWiki Powered by PHP Powered by Smarty Powered by ADOdb Made with CSS Powered by RDF
RSS Wiki rss Articles RSS Image Galleries rss Directories