Thread: Cafe Press mod
View Single Post
  #16  
Old 01-29-2005, 02:26 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by base
i can't find that line of code in the script at all. maybe you have an error between the computer and your seat? :ermm:

This is obviously something he has control of and changed IMO cause he got busted hijacking peoples links. This is the script that was there yesterday...

Every Link was hijacked with...

http://www.sealfans.net/store.php??target=

The other possibility is that they got the script and posted it not having any real clue what the code did. Not for me to judge I guess, but the facts are the facts, that script was changed overnight.

PHP Code:
<?

/*
------------------------------------------
RANDOM CafePress ITEM DISPLAY SCRIPT 1.0.9
------------------------------------------
This script is designed to allow CafePress store owners to feature a random item from
any of their CafePress stores on any page of their own web site.

Created and copyright by admin@notonebit.com Feb-16-2003
Last modified: Sept-29-2004

This code is released under the terms of the GNU General Public License
A copy of the GPL can be found at http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

Please retain this message at the top of this script if you modify it in any way.
---------------------------------------------------------------------------------
INSTRUCTIONS:

1. First, your web server must have PHP 4.1.0 or later installed for this script to function properly.
You must also be able to run the fsockopen function.

2. This script has three functions. First, the update function will create a text file on your web
server that contains a list of items from the stores you specify. Run this script like
http://www.yourserver.com/cprand.php?update to update the text file anytime you add/change/delete
an item from any of the stores you've setup the script to use. I used a local text file to greatly
increase the speed of the script. By storing the file locally it saves several seconds on the execution
by reading a local text file versus having to contact CafePress each time the script gets called.
Trust me, it helps.

3. To run the script as a PHP file, comment out the line after "//for javascript use:" that begins
with echo, and uncomment the line after "//for php use:". You can then drop this code in an existing
PHP page, or use the PHP include function.

4. To run the script as a JavaScript comment out the line after "//for php use:" that begins
with echo, and uncomment the line after "//for javascript use:". Then in your HTML page, use the following
code: <script src="cprand.php"></script> making sure that the path to the file is correct.

5. You may need to create a blank text file named cpitemfile.inc (the file that stores the data) and also 
change its permissions to 666. Some servers will need this, others won't. Try skipping this step first and
if you get an error during the update, then create the file with these permissions.

6. Finally, make sure to rename this file with a .php extension.

A few notes:
The script was designed to let you put a product's image and description on any page of your web site.
I have designed it to change the image dimensions from CafePress' 150x150 to 100x100. Feel free to 
change this by either modifying, deleting, or commenting out the line, "$line = ereg_replace("150","100",$line);". I also
designed it to not display the price of a product. To have the script display the price, delete or comment
out the line, "$line = ereg_replace("<b>(.*)</b>","",$line);". For those of you using fbomb's custom CP store script,
you can have this script link the random item to the detail page for that item on fbomb's script, in fact this is this
scripts default behavior. To have the random item linked to your CafePress store, delete or comment out the line:
"$line = ereg_replace("prod.aspx\?","prod&",$line);" and change the line "$line = ereg_replace("<a href=\"","<a href=\"http://
www.yourwebsite.com/store.php?target=http://www.cafepress.com",$line);" to "$line = ereg_replace("<a href=\"","<a href=\"http://www.cafepress.com",$line);
".

-Scanman20

-------------- SCRIPT BEGINS AFTER THIS LINE -----------------------------------------------*/

// SET VARIABLES //
srand ((float) microtime() * 10000000);
$start = '<!-- ### Items ### -->';
$end = '<!-- ### end of ITEMS ### -->';
$stores = 'riderinfo';
$url = 'http://www.cafepress.com/' . $stores;
$itemfile = '/home/lakecs/vbg_photos/cpitemfile.inc';
$mode = $_SERVER['QUERY_STRING'];

if ($mode == "update") {
    echo "Beginning CP item file update...<br>\n";

    // connect to CP
    $reqheader = "GET /$stores HTTP/1.0\r\nHost: www.cafepress.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n"; 
    $socket = @fsockopen("www.cafepress.com", 80, &$errno, &$errstr); 
    if ($socket) 
    { 
        fputs($socket, $reqheader); 
        while (!feof($socket)) 
        { 
            $cpfile .= fgets($socket, 4096); 
        } 
    } 
    fclose($socket);


    $items = eregi("$start(.*)$end", $cpfile, $cparray);

    $newcparray = split ("\n", $cparray[1]);

    foreach ($newcparray as $line) {
    if (strlen($line) > 100)
        {
        $newestcparray[] = $line;
        }
    }

    $handle = fopen($itemfile, "w");
    foreach ($newestcparray as $line) {
    $line = ereg_replace("<td align=\"center\" valign=\"top\"><p>","",$line);
    $line = ereg_replace("</td>","",$line);
    $line = ereg_replace("150","100",$line);
    $line = ereg_replace("<b>(.*)</b>","",$line);
//    $line = ereg_replace("\\$(.*)\r", "\r", $line);  // Uncomment to hide prices
    $line = ereg_replace("prod.aspx\?","prod&",$line); //this line is just used to integrate with custom store. delete to use regular cp store.
    if (eregi("<td colspan=3>",$line)) {unset ($line);}
    if (eregi("<tr>",$line)) {unset ($line);}
    $line = ereg_replace("<a href=\"","<a href=\"http://www.sealfans.net/store.php?target=http://www.cafepress.com",$line);
    $line = ereg_replace("src=\"/cp/img","src=\"http://www.cafepress.com/cp/img",$line);
    if (!empty($line)) {
        $lastcparray[] = $line;
        fwrite($handle, $line);
        }
    }
    fclose($handle);
    echo "CP item file update completed.\n";
}
else {
    $itemhandle = fopen($itemfile, "r");
    $itemarray = fread($itemhandle,filesize("$itemfile")); 
    fclose($itemhandle);
    $lastcparray = split ("\r", $itemarray);

    $item = $lastcparray[rand(0,count($lastcparray)-2)];
    $item = ereg_replace("[\x27]",'',$item);
    $item = trim($item);

    //for javascript use:
    //echo "document.write('<div align=\"center\">" . $item . "</div>');";

    //for php use:
    echo $item;
}
?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01167 seconds
  • Memory Usage 1,825KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete