Tuesday, December 15, 2009

Updated Project: New Artist Schedules

Our site allgoodseats.com has been updated with our users in mind. we want to give instant access to the top artists that are playing currently while still allowing easy access to all other artists. The popular artists and their full tour schedules can be found at allgoodseats.com/concert-tickets.html. The artist schedules are updated daily so any new dates added will not be missed and you can view more information about any tour date by followoing the link for that event.

Friday, December 4, 2009

Project Finally Finished

After many weeks of writing code and debugging our new project is finally launched: Fans in the Stands. This site is all about the artists. You can view their biography, discography and tour dates. Each artist has their own page all about them with up to date tour schedule. Each tour date has its own event page with more information.

Lots of functionality in this site and the potential to add lots more. User accounts will probably be added in the future where fans can favorite artists and receive live updates of those artist's tours or be notified of artists coming near their city. If you have any ideas or criticisms please respond.

Sunday, November 29, 2009

Simple Header Reader

Well I tried doing a search on this myself but after many unsuccessful searches I decided to tackle the task myself (I really thought I would find something quickly). I figured it would be simple so someone must have done something on the topic before and I proved myself wrong - well about the finding part, it was rather simple.

Anyway what this little function does is read only the headers of a page using PhP's curl() functions and returns them as an associative array. A great way to check if you need to update an RSS cache or something similar.

function checkHeaders($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
$content = curl_exec($ch);
curl_close($ch);
preg_match_all('/[^:]*[\r\n]|([^:]*):(.*)[\r\n]/', $content, $matches, PREG_SET_ORDER);
foreach ( $matches as $match ) {
if ( !empty($match[0]) ) {
if( strstr($match[0], 'HTTP') === false )
$headers[$match[1]] = $match[2];
else
$headers['HTTP'] = $match[0];
}
}
return $headers;
}

The HTTP header index will simply be 'HTTP' every other header will be in the form <header> => <value>.
example:

['Content-Type'] => ['text/xml']

enjoy :)

Tuesday, November 24, 2009

PHP Curl download via FTP access - Part 1

Downloading files via FTP in PhP is fairly easy even if you need FTP access. If your host supports it you just grab the file via PhP's fgets() function (or fread() if u need binary-safe). If you do need FTP access heres a quick snippet to connect:

$fp = ftp_connect($ftpServer);
$lh = ftp_login($fp, $ftpUser, $ftpPass);
$data = fgets($fp);
And you have your file;

additionally you can add a file_put_contents($local, $data); to write it to your local server.
However if your host doesn't support this you'll have to go with the curl method. First step is to make sure the library is installed on your server. Most come with it pre-installed these days so you should be good but to check simple echo phpinfo() and search for "curl" to see what you have.
Next step is to login to FTP via curl which you can do using this format:
$url = "ftp://$ftpUser:$ftpPass@$ftpServer";
it is a good idea to urlencode() your $ftpUser and $ftpPass because if it has a semicolon or at symbol most servers won't know how to interpret what you are trying to do. (Took me like an hour to figure out why it wasn't working for me :\). Once you know you have access you can continue the script and download a remote file to your local server as follows:

$ftpServer = <hosted_file>;
$ftpUser = urlencode(<ftp_user_name>);
$ftpPass = urlencode(<ftp_password>);
$local = <local_file_location>; //be sure to use full path here
$url = "ftp://$ftpUser:$ftpPass@$ftpServer";
$cp = curl_init();
$fp = fopen($local, "w");
curl_setopt($cp, CURLOPT_URL,$url);
curl_setopt($cp, CURLOPT_FILE, $fp);
curl_setopt($cp, CURLOPT_HEADER, 0);

curl_exec($cp);
curl_close($cp);
fclose($fp);

Hope this saves someone hours of time researching.

Tuesday, November 3, 2009

Setting Sitewide URL Prefix in Zend

So recently I came across the need to put a site into a test folder. Now I have done this in the past and it is very easy using a global domain name variable to change your domain from http://something.com/ to http://something.com/test/. If you have you own routing class you can just tell it to ignore the first parameter in the URI.

But here is the problem: I was trying to do this with the Zend routing class on a site that was already configured at setup with all its routing rules. Originally I tried just prepending 'test/' to all of the existing rules but that caused more complications than I had time to fix. I tried Googling a quick fix for this but could find nothing other than how to reroute one rule to another or forward to another controller. While it was useful information and I may need it in the future it was unrelated to my issue.

What I ended up doing was digging through the Zend_Controller_Front class to see what I could find. And voila I came across a class variable _baseUrl. Looking through the class methods I quickly found the setBaseUrl() method. After smacking myself on the head for not thinking of this earlier I then set called the already set controller class to call
Zend_Controller_Front::setBaseUrl('/test/');
And like magic the Zend controller started recognizing all my URL's that were prepended with '/test/'.

Hope this saves someone else a couple hours of searching.

Monday, March 23, 2009

Ticket Broker Software

Recently at SEO Webowrks I have finished designing a small package that quickly creates a database-driven, SEO friendly website for ticket brokers who are trying to get started or having bad luck with their current website. This package can be uploaded in 5 minutes and with little changes to the code the site can be made to behave differently than the other sites. What makes the sites unique from each other is that each site comes with an admin panel so that the site owner can add any artist or event they want with any information they want about that subject. When they add an artist a page will be created for that artist with a link to their checkout (through ticket network or other ticket company providers).

Designed using the MVC model any site can be personalized based on request with little effort. Most of the design is CSS based and will soon be implemented with divs instead of tables (i know, yuck!).

For more information check out the article at Ticket News or the site at Ticket Website HQ

Thursday, November 20, 2008

Pulling Variables From Database

Recently I was working with a database and needed a way to have variables on each page but each page needed different content. i know this can be done with templating but I didn't want to have to import a big templating software for this one thing. I did a few searches online and after a while of searching saw mention of PhP's eval function.

It was a bit tricky to get working but here is the result:

eval("\$string = \"$string\";");
echo $string;

$string is the result from the database and can contain a string like "we have $variable1 for your $variable2!". The eval function takes car of parsing the PhP variable...very useful.

Thought this might be useful to anyone caring to read =)