0) { $premium_store = explode("/", $store); $store = $premium_store[0]; } $item_url = "/$store.$item"; // WRITE CAFEPRESS JAVASCRIPT TO PAGE // echo ''; // connect to CP $start = ''; //$end = ''; $end = ''; $cafepress_address = 'www.cafepress.com'; $reqheader = "GET /$item_url HTTP/1.0\r\nHost: $cafepress_address\r\nUser-Agent: MS Internet Explorer\r\n\r\n"; $socket = fsockopen($cafepress_address, 80, &$errno, &$errstr); if ($socket) { fputs($socket, $reqheader); while (!feof($socket)) { $remote_content .= fgets($socket, 4096); } } fclose($socket); eregi("$start(.*)$end", $remote_content, $item_content); // $item_content array now contains just the content we want // Adjust the imported data to change any URLs from relative to absolute $pattern = "/\/cp/"; $replacement = "http://www.cafepress.com/cp"; $item_detail = preg_replace($pattern, $replacement, $item_content[0]); $pattern = "/src=\"\/content\//"; $replacement = "src=\"http://www.cafepress.com/content/"; $item_detail = preg_replace($pattern, $replacement, $item_detail); if ($config_img_local == "yes") { $img = $config_img_path_large . $item . "_lg.jpg"; $pattern = "/name=\"mainimg\" src=\"(.*)\" height=\"240\"/"; $replacement = "name=\"mainimg\" src=\"$img\" height=\"240\""; $item_detail = preg_replace($pattern, $replacement, $item_detail); } if ($config_show_breadcrumb != "yes") { $item_detail = ereg_replace("(.*)", "", $item_detail); // Removes CP breadcrumb menu } if ($config_show_cpitemnum != "yes") { $item_detail = ereg_replace("(.*)", "", $item_detail); // Removes CP product number } if ($config_show_tellafriend != "yes") { $item_detail = ereg_replace("(.*)", "", $item_detail); // Removes CP tell-a-friend } if ($config_keep_logs) { $item_detail = preg_replace("/
/i", "", $item_detail); } else { $item_detail = preg_replace("//i", "", $item_detail); } $item_detail = preg_replace("//", "alt=\"Add to Cart\">   ", $item_detail); $item_detail = preg_replace("/Value=\"Add to Cart\">/", "Value=\"Add to Cart\">   ", $item_detail); $item_detail = preg_replace("/launchHelp\('\/content\/help\/html\//", "launchHelp('http://www.cafepress.com/content/help/html/", $item_detail); // $item_detail = preg_replace("/law. load("templates/$config_template_detail"); if ($config_status == "closed" Or $config_status == "maintenance") { $status_message = "Our store is currently unavailable. Please check back later. We apologize for any inconvenience."; $template->replace("item_detail", $status_message); $template->replace("back_link", ""); $template->replace("cart_link", ""); $template->replace("search_bar", ""); $template->replace("parent_menu", ""); $template->replace("banner", ""); $template->replace("datetime", date("m/d/y")); } else { $template->replace("item_detail", $item_detail); $template->replace("back_link", back_link()); $template->replace("cart_link", cart_link()); $template->replace("search_bar", search_bar()); $template->replace("parent_menu", parent_menu()); $template->replace("banner", banner()); $template->replace("datetime", date("m/d/y")); } $template->publish(); // TEMPLATE END //////////////////////////////////////////////////////// function back_link() { $str = "« Back To Store"; return $str; } function cart_link() { $str = "View Cart"; return $str; } function search_bar() { $result = ''; $result .= '
'; return $result; } function parent_menu() { global $parent_row; global $current_cat; // Call function to build parent menu if ($_GET[cat] != 0) { $foo = build_parent_menu($_GET[cat]); } $result = $foo . "$current_cat[0]
"; return $result; } function build_parent_menu($pid) { // Recursive function to build parent menu global $parent_menu_string; global $parent_menu_array; global $table_prefix; // query for the name, id and parent_id of the $pid // add name & id to array // if $parent_id != 0 then // call function again with new parent_id // else return array $pid_query = "SELECT id, name, parent_id FROM " . $table_prefix . "categories WHERE id = '$pid'"; $pid_result = mysql_query($pid_query) or die("PID Query failed"); $pid_row = mysql_fetch_row($pid_result); $parent_menu_array[$pid_row[0]] = $pid_row[1]; $parent_menu_string = "$pid_row[1] » " . $parent_menu_string; if ($pid_row[2] != 0) { build_parent_menu($pid_row[2]); } return $parent_menu_string; } function banner() { global $config_show_promo_banner; global $config_show_referral_banner; global $config_show_special_banner; global $config_special_banner_code; srand((double)microtime()*1000000); if ($config_show_promo_banner == "yes" And $config_show_referral_banner == "yes" And $config_show_special_banner == "yes") // (3) pick one of the three at random { $pick = rand(1,3); if ($pick == 1) { $result = ""; $result .= "\"Sale"; } elseif ($pick == 2) { $result .= ""; $result .= "\"Design"; } else { $result .= "$config_special_banner_code"; } } elseif ($config_show_promo_banner == "yes" And $config_show_referral_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= ""; $result .= "\"Sale"; } else { $result .= ""; $result .= "\"Design"; } } elseif ($config_show_promo_banner == "yes" And $config_show_special_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= ""; $result .= "\"Sale"; } else { $result .= "$config_special_banner_code"; } } elseif ($config_show_special_banner == "yes" And $config_show_referral_banner == "yes") // (2) pick one of the two at random { $pick = rand(1,2); if ($pick == 1) { $result .= "$config_special_banner_code"; } else { $result .= ""; $result .= "\"Design"; } } elseif ($config_show_promo_banner == "yes") // (1) show only promo banner { $result .= ""; $result .= "\"Sale"; } elseif ($config_show_referral_banner == "yes") // (1) show only referral banner { $result .= ""; $result .= "\"Design"; } elseif ($config_show_special_banner == "yes") // (1) show only special banner { $result .= "$config_special_banner_code"; } else { $result .= " "; } return $result; } ?>