Pages

Thursday, August 28, 2008

100 blogs?

I mentioned in an earlier post that I was going to see if I could make and update 100 blogs. I haven't even been able to keep up with 10. Maybe I'll work on that. LOL.

My hat is off to those who have a life, and still manage to keep their blog(s) current.

Thursday, August 7, 2008

Rant

I hate coding behing myself!

My skills have improved so much in the last 2 years that I make myself crazy when I have to edit code that I wrote a year and a half to 2 years ago. My whole style has changed, and my code is just so much neater (more consise) now.

That's it, just a little rant.

Monday, April 21, 2008

New Blog

I started writing a new blog this evening. ("This evening" being a relative terms since it is now 12:29am my time.) It is tec's christian blog where I will write about my christian faith, and my experiences at church or whatever else I feel is appropriate for a blog of that title.

This is the beginning of my goal of creating and keeping up 100 different blogs. That's quite a goal, but I want to see if it can be done. In no way do I expect to post to all 100 blogs every day, but if I can come up with 100 different types of blog and post to them once or twice a week, I'll be doing good.

Check out tecchristian.blogspot.com

Tuesday, April 15, 2008

Grab images from a menalto gallery

I needed to grab images, 3 at a time, from a menalto gallery and put them on the bottom of other pages. This could be an include were $dir is specified and "albumname" could be changed to $albumname. I judge my own code to be a bit sloppy, but it works. Maybe this will point someone in the right direction.

It detects going too far previous or too far "next". It allows for counted pages. If the number of pages is not divisible by 3, the last page is handled correctly. The numbered page you are on is not a link. There is a previous and next link that appear only when applicable. The links have the rel="nofollow" attribute so that the S.E.s don't find a bunch of basically duplicate pages.

Admittedly this would be better with colorized text, but here's a quick rendering of it. (if you copy this, be sure to paste it into a text only editor.)

<?php

$dir = 'gallery/albums/albumname';



$photosdb=@file($dir.'/photos.dat');

$count=0;

foreach($photosdb as $line){

$newphotosdb.=$line;

//echo $photosdb[$count];



$count++;

}



$newphotosdb=explode('"emailMe";N;}',$newphotosdb);



$counta=0;

foreach($newphotosdb as $photo){

list($null,$name,$null2)=explode('"name"',$photo);

list($null,$name,$null2)=explode('"',$name);





list($null,$caption)=explode('caption";s',$photo);

list($null,$caption,$null2)=explode('"',$caption);

//list($caption,$null)=explode('";s',$caption);

//echo("$counta $photo<br><br>");

$captions[$name]=$caption;

$counta++;

}



// open specified directory

$dirHandle = opendir($dir);

$count = -1;

$returnstr = "";

while ($file = readdir($dirHandle)) {

// if not a subdirectory and if filename contains the string '.jpg' or '.jpeg'

if(!is_dir($file) && (strpos($file, '.jpg')>0 strpos($file, '.jpeg')>0)&&
ereg('thumb',$file)) {

// update count and string of files to be returned

$count++;



$returnstr[$count]=$file;

}

}

//$returnstr .= '&';

//echo $returnstr;

closedir($dirHandle);

//echo("begin corry test");

$countb=0;

// foreach ($returnstr as $link){

// $countb++;

// $unthumb=str_replace('.thumb.jpg','',$link);

// $unthumb=str_replace('.thumb.jpeg','',$link);

// echo('<a target="_blank" href="http://www.mysite.com/gallery/albumname/'.$unthumb.'"><img
border="0" src="'.$dir.'/'.$link.'"></a> '.$countb.'<br>');

// }

//echo count($returnstr);

$num_of_images=count($returnstr)-1; // I actually mis-named this variable, but
it made sense (to me) at the time. It is actually the highest index number in
the array.

if($_GET['startimage']=="" $_GET['startimage']<0){$startimage="0";}else{$startimage=$_GET['startimage'];}

if($startimage > $num_of_images){$startimage=$num_of_images;}

// full size images are loaded with a SEFU. Take out "thumb" for full size image
and ".jpg" for SEFU.

$unthumb1=str_replace('.thumb.jpg','',$returnstr[$startimage]);$unthumb1=str_replace('.thumb.jpeg','',$unthumb1);

if(count($returnstr)>=$startimage+1){$unthumb2=str_replace('.thumb.jpg','',$returnstr[$startimage+1]);$unthumb2=str_replace('.thumb.jpeg','',$unthumb2);}

if(count($returnstr)>=$startimage+2){$unthumb3=str_replace('.thumb.jpg','',$returnstr[$startimage+2]);$unthumb3=str_replace('.thumb.jpeg','',$unthumb3);}

?>

<table border="1" cellpadding="3" cellspacing="0" style="border-collapse:
collapse" bordercolor="#111111" width="500" id="AutoNumber1">

<tr>

<td width="33%" align="center">

<p align="center"><?php echo('<a target="_blank" href="http://www.mysite.com/gallery/ambumname/'.$unthumb1.'"><img
border="0" src="'.$dir.'/'.$returnstr[$startimage].'"></a>');?></td>

<?php if($num_of_images>=$startimage+1){ ?>

<td width="33%" align="center"><?php echo('<a target="_blank" href="http://www.mysite.com/gallery/albumname/'.$unthumb2.'"><img
border="0" src="'.$dir.'/'.$returnstr[$startimage+1].'"></a>');?></td>

<?php }?>

<?php if($num_of_images>=$startimage+2){ ?>

<td width="34%" align="center"><?php echo('<a target="_blank" href="http://www.mysite.com/gallery/albumname/'.$unthumb3.'"><img
border="0" src="'.$dir.'/'.$returnstr[$startimage+2].'"></a>');?></td>

<?php }?>

</tr>

<tr>

<?php // the $unthumb variable happen to have the filname without extension,
which I need here as an array index.

?>

<td width="33%" align="center"><?php echo($captions[$unthumb1]); ?></td>

<?php if($num_of_images>=$startimage+1){ ?>

<td width="33%" align="center"><?php echo($captions[$unthumb2]); ?></td>

<?php }?>

<?php if($num_of_images>=$startimage+2){ ?>

<td width="34%" align="center"><?php echo($captions[$unthumb3]); ?></td>

<?php }?>

</tr>

</table>

<?php

if ($startimage > 0){$previmage=$startimage-3;

echo ("<a rel=\"nofollow\" href=\"http://www.mysite.com/image_grabber.php?startimage=$previmage\">previous</a>&nbsp;");

}

$pages=ceil(($num_of_images+1)/3);

$pagenum=1;

$start=0;

while($pagenum<=$pages)

{

if($start==$startimage){echo("$pagenum \n");}else{

echo ("<a rel=\"nofollow\" href=\"http://www.mysite.com/image_grabber.php?startimage=$start\">$pagenum</a>\n");

}

$pagenum++;

$start=$start+3;

}

if($num_of_images > $startimage+2){

$nextimage=$startimage+3;

echo ("<a href=\"http://www.mysite.com/image_grabber.php?startimage=$nextimage\">next</a>\n");

}

?>

Friday, March 7, 2008

Promotional Products

I have finished another huge cURL scraping project. The cURL really isn't the hard part now, it's all the string replacement it takes to make the other site look good inside my site. (For those that are going "OH NO, HE CAN'T DO THAT!", they both belong to my boss, so it's okay.)

This is a section of a site to help small businesses or even large corporations find the logo imprinted or logo imprintable promotional products. These are often given away at trade shows, or as employee incentives. We have also had inquiries about ordering branded items for resale such as movie merchandising or other memorabilia You can see it here: Promotional Products

There is a search feature here:Stress Relievers I defaulted the search to "stress relievers" because they are so popular.