<?php
/*
SHOPPERPRESS DEVELOPED BY MARK FAIL
Premium Wordpress Themes - PremiumPress
Wordpress Shopping Cart - ShopperPress
Follow on twitter:
Mark Fail (markfail) on Twitter
Follow on twitter:
http://www.twitter.com/shopperpress
*/
//ini_set( 'display_errors', 1 );
//error_reporting( E_WARNING );
//$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME'];
/* ============================= PREMIUM PRESS SESSIONS ========================= */
if(!session_id())session_start();
if(isset($_GET['emptyCart'])){ foreach($_SESSION as $key => $value){ unset($_SESSION[$key]); }}
if(!isset($_SESSION['ddc']['cartqty'])) $_SESSION['ddc']['cartqty'] = 0;
if(!isset($_SESSION['ddc']['price'])) $_SESSION['ddc']['price'] = 0.00;
/* ============================= PREMIUM PRESS CONSTANTS ========================= */
define("PREMIUMPRESS_SYSTEM","ShopperPress");
define("PREMIUMPRESS_VERSION","5.0f");
define("PREMIUMPRESS_VERSION_DATE","12th Nov, 2010");
/* ============================= PREMIUM PRESS INCLUDES ========================= */
$functions_path = TEMPLATEPATH . '/functions/';
define("THEME_PATH","".$functions_path."");
if(defined('TEMPLATEPATH')){
if(!defined('PREMIUMPRESS_PLUGIN')){
include($functions_path ."premiumpress/premiumpress.php");
include($functions_path ."premiumpress/premiumpress_funcs.php");
include($functions_path ."premiumpress/premiumpress_class.php");
include($functions_path ."premiumpress/premiumpress_class1.php");
}
include($functions_path ."premiumpress/premiumpress_customfields.php");
include($functions_path ."admin-options.php");
include($functions_path ."custom-options.php");
include($functions_path ."func_general.php");
include($functions_path ."func_download.php");
include($functions_path ."func_cart.php");
include($functions_path ."func_image.php");
require($functions_path ."func_callback.php");
require($functions_path ."func_display.php");
$PPT = new PremiumPressTheme();
}
/* ============================= PREMIUM PRESS REGISTER WIDGETS ========================= */
if ( function_exists('register_sidebar') ){
register_sidebar(array('name'=>'Left Sidebar',
'before_widget' => '<div style="clear:both;"></div><div class="menubox_box">',
'after_widget' => '</div>',
'before_title' => '<h2><span>',
'after_title' => '</span></h2>',
));
register_sidebar(array('name'=>'Right Sidebar',
'before_widget' => '<div style="clear:both;"></div><div class="menubox_box">',
'after_widget' => '</div>',
'before_title' => '<h2><span>',
'after_title' => '</span></h2>',
));
register_sidebar(array('name'=>'Right Sidebar (Product Page)',
'before_widget' => '<div style="clear:both;"></div><div class="menubox_box">',
'after_widget' => '</div>',
'before_title' => '<h2><span>',
'after_title' => '</span></h2>',
));
register_sidebar(array('name'=>'Right Sidebar (Article Page)',
'before_widget' => '<div style="clear:both;"></div><div class="menubox_box">',
'after_widget' => '</div>',
'before_title' => '<h2><span>',
'after_title' => '</span></h2>',
));
register_sidebar(array('name'=>'Footer',
'before_widget' => '<div class="Footer_Widget">',
'after_widget' => '</div>',
'before_title' => '<div style="" class="bar3"><h2>',
'after_title' => '</h2></div>',
));
register_sidebar(array('name'=>'Home Page (Left Column)',
'before_widget' => '<div style="clear:both;"></div><div class="menubox_box">',
'after_widget' => '</div>',
'before_title' => '<h2><span>',
'after_title' => '</span></h2>',
));
}
/* =================== PREMIUM PRESS AMAZON DELETE SEARCH ====================== */
if(isset($_GET['delf']) && !isset($_POST['feed'])){
$PPT->AmazonDeleteSearch($_GET['delf']);
$GLOBALS['error'] = 1;
$GLOBALS['error_type'] = "ok"; //ok,warn,error,info
$GLOBALS['error_msg'] = "Schedule Deleted Successfully";
}elseif(isset($_POST['feed'])){
if($_POST['schedule']['name'] != ""){
if(isset($_POST['cat'][0])){
$PPT->AmazonSavedSearch();
$GLOBALS['error'] = 1;
$GLOBALS['error_type'] = "ok"; //ok,warn,error,info
$GLOBALS['error_msg'] = "Schedule Search Saved Successfully";
}else{
$GLOBALS['error'] = 1;
$GLOBALS['error_type'] = "error"; //ok,warn,error,info
$GLOBALS['error_msg'] = "No category selected, scheduled search NOT saved";
}
}else{
include_once("functions/amazon/amazon_api_class.php");
$GLOBALS['amazonsearch'] =1;
}
}
/* ========================= SHOPPERPRESS AMAZON SCHEDUALE ========================= */
//amazon_hourly();
function amazon_hourly() { global $wpdb; if(get_option('enabled_amazon_updater') == "yes"){ AmazonAutoUpdater(); } amazon_dreepfeed($ActionTime="hourly"); }
function amazon_daily() { amazon_dreepfeed($ActionTime="daily"); }
function amazon_twicedaily() { amazon_dreepfeed($ActionTime="twicedaily"); }
function amazon_dreepfeed($ActionTime="hourly") {
global $wpdb;
$PTH = TEMPLATEPATH . '/functions/';
$ASS = get_option("AmazonSavedSearch_Data");
$ACC = 0;
include_once($PTH ."amazon/amazon_api_class.php");
$obj = new AmazonProductAPI();
foreach($ASS as $SearchArray){
if($SearchArray['time'] == $ActionTime){
if($SearchArray['keyword'] != ""){
$importcounter = 0;
$_POST['amazon'] = $SearchArray;
$_POST['amazon']['keyword'] = $SearchArray['keyword'];
$_POST['amazon']['keyword_cat'] = $SearchArray['keyword_cat'];
$_POST['amazon']['cat'] = $SearchArray['cat'];
try
{
$result = $obj->searchProducts($_POST['amazon']['keyword'],$_POST['amazon']['keyword_cat'],$_POST['amazon']);
$SEARCHSTATUS = "Running";
//print_r($result->Items->TotalResults);
}
catch(Exception $e)
{
$SEARCHSTATUS = "Finished (".$e->getMessage().")";
}
$importcounter = AmazonSearchSave($result);
}else{
$SEARCHSTATUS = "Finished (No Keyword Entered)";
}
}
foreach($SearchArray as $key => $val){
if($key == "last" && ( $SearchArray['time'] == $ActionTime ) ) {
$val = date('l jS \of F Y h:i:s A');
}elseif($key == "total" && ( $SearchArray['time'] == $ActionTime ) ){
$val += $importcounter;
}elseif($key == "status" && ( $SearchArray['time'] == $ActionTime ) ){
$val = $SEARCHSTATUS;
}elseif($key == "start_page" && ( $SearchArray['time'] == $ActionTime ) ){
if(!is_numeric($val)){ $val = 1; }else{ $val++; }
}
$ASS_NEW[$ACC][$key] = $val;
}
$ACC++;
}
update_option("AmazonSavedSearch_Data",$ASS_NEW);