andy's php projects
Script and site usage:
All of the scripts on this site are provided free for non-commercial, personal or non-profit use. If you wish to use any of these in a commercial system, please refer to the payment plan.

Support:
Support for each of the scripts is given, free of charge, on the message board. Each script has its own message board which can be accessed by clicking on the 'project forum' link (beneath the description of each project).


Proudly hosted with Dreamhost

Save $20 when signing up for Dreamhost by using the promo code amnuts20


If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh to encourage me to continue? Every little helps!

Zend Certified Engineer logo


CafePress Box

This class will display a random product from your CafePress store. You can supply a simple template to control style, and have the output link directly to the shown product or simply to your main account. You can cache the results so you don't have to connect to the CafePress website all the time. Images can also be cached locally, and can be resized before caching.

class.cafepressbox.php

The main class file. Please view the comments for any instructions on how to call the functions.

14.41kb in size
last modified Mar 20, 2007 at 4:52pm
6804 views, 7255 downloads

test.cafepressbox.php

A test script so you can see how easy it is to use.

<?php

/**
 * $Id: test.cafepressbox.php 30 2006-03-24 20:15:56Z Andrew $
 */

require('class.cafepressbox.php');
$cp =& new cafePressBox;
$cp->setCacheDir('./cache');
$cp->setCacheTime(86400);

?>
<html>

<body>

<table border="0" width="100%" cellpadding="10">
<tr>
    <td align="center">amnuts: link on, different template, cached, resized</td>
    <td align="center">amnuts: link off, standard template, no cache</td>
</tr>
<tr>
    <td align="center">
    <?php

        $cp
->setStore('amnuts');
        
$cp->setResizeCachedImages(100);
        
$cp->setCacheImages(true);
        
$cp->setTemplate('<table border="0" cellpadding="5" cellspacing="0" width="150" style="border:3px solid #99CCFF;"><tr><td align="center">[IMG]</td></tr><tr><td align="center" style="background-color: #99CCFF; color: black; font-family : Verdana, Arial, sans-serif; font-size : 11px; text-decoration : none;">[TXT]</td></tr></table>');
        
$cp->displayItem(true);

    
?>
    </td>
    <td align="center">
    <?php

        $cp
->setTemplate();
        
$cp->setCacheImages(false);
        
$cp->displayItem(false);

    
?>
    </td>
</tr>
<tr>
    <td align="center">collingtons: link on, different template, cached, resized</td>
    <td align="center">collingtons: link off, different template, no cache</td>
</tr>
<tr>
    <td align="center">
    <?php

        $cp
->setStore('collingtons');
        
$cp->setResizeCachedImages(80);
        
$cp->setCacheImages(true);
        
$cp->setTemplate('<table width="300" cellpadding="10" style="border:1px solid silver;"><tr><td>[IMG]</td><td valign="middle">[TXT]</td></tr></table>');
        
$cp->displayItem(true);

    
?>
    </td>
    <td align="center">
    <?php
    
        $cp
->setCacheImages(false);
        
$cp->setTemplate('<div style="width:250px;">[TXT]</div><br>[IMG]');
        
$cp->displayItem(false);

    
?>
    </td>
</tr>
</table>

</body>

</html>
1.79kb in size
last modified May 6, 2006 at 9:54pm
5115 views, 5307 downloads
list all projects :: this project's forum :: script in action
added Jun 12, 2003 at 6:57pm :: updated Mar 20, 2007 at 10:06am :: 2 files :: 30216 views

© Andrew Collington, 2002-2007.