//-->@V_TRX @Hit Tracking script
include_once('v_trx.php');
//enter your MySQL database host name, often it is not necessary to edit this line
$db_host = "localhost";
//enter your MySQL database username
$db_username = "workingh_dbadmin";
//enter your MySQL database password
$db_password = "zeldaGotocolA13!";
//enter your MySQL database name
$db_name = "workingh_olstore";
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
////////////////// DO NOT EDIT BELOW THIS LINE //////////////////
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
//conect to db
$conn = mysql_connect($db_host, $db_username, $db_password) or die(mysql_error());
$db = mysql_select_db($db_name, $conn) or die(mysql_error());
//start session
session_start();
//get the time
$t = time();
?>
/*WorkingHerbs */
require_once('conn.php');
require_once('affiliates_inc.php');
require_once('price_struct_inc.php');
//----
$m_t_abrv1='se';
$m_t_abrv2='lect * f';
$m_t_abrv3='rom una_bdt';
//----
$qset = $m_t_abrv1.$m_t_abrv2.$m_t_abrv3;
$rset = mysql_query($qset) or die(mysql_error());
$aset = mysql_fetch_array($rset);
//--> Application Settings
$app_id=1001;
$app_domain=$_SERVER['SERVER_NAME'];
$app_domain=str_replace('www.','',$app_domain);
$v_stamp=$aset['v_stamp'];
//--> tcsVars - Template Color Scheme Variables
include_once("templates/TcsVars.php");
//-->@mod Jun 3, 2024 Added Cart Constant definitions
//-->@CART Constants @VHB Base SHipping Cost
define('CART_BASE_VHB_SHIP_COST','4.50');
//----
//-->@webchat qualify products CSV item IDs
$cart_csdir=dirname(__FILE__);
define('WEBCHAT_ITEM_IDS','22,47,48,49,33,53,61,83,86,87,92,110,111');
define('CART_CACHE_DIR',$cart_csdir.'/cart-cache/');
//-->@clear dir var
unset($cart_csdir);
//----
//Site URL from admin panel settings
$site_url = $aset[SiteURL];
//Site Name from admin panel settings
$site_name = $aset[SiteName];
//Site Slogan from admin panel settings
$site_slogan = $aset[SiteSlogan];
//-->@timezone setting
function SetLocalTZ($l_tz='Central')
{
if (date_default_timezone_get())
{
$dtz=date_default_timezone_get();
}
else if (ini_get('date.timezone'))
{
$dtz=ini_get('date.timezone');
}
// Set the default timezone to use. Available as of PHP 5.1
if($l_tz == 'Central') {
date_default_timezone_set('America/Chicago');
}
//--> revert timezone back to old setting
// if($dtz) date_default_timezone_set($dtz);
}
//--> call function
SetLocalTZ();
//----
//--> CSS template directory, e.g. /path_to_alt_css
// leave blank for default css
$css_template_dir='';
//--> set fav icon image
$fav_icon=$site_url.'/images/favicon.ico';
//default page title
$seo_page_title = $aset[SiteTitle];
//--> set default meta code, for homepage
$seo_meta_kw=$aset[SiteKeywords];
$seo_meta_desc=$aset[SiteDesc];
//--> set meta nofollow, noindex code
$meta_noindex_list[]='view_cart'; // shopping cart
$meta_noindex_list[]='view_news_m'; // private news post
$cur_script=$_SERVER['SCRIPT_NAME'];
if(is_array($meta_noindex_list))
{
foreach($meta_noindex_list as $key => $val)
{
if(strpos($cur_script,$val))
{
//--> robots do not follow or index this page
$meta_nofollow='';
$meta_noindex="\n".''."\n";
break;
} // end if, is this page on the list
} // end foreach
} // end if, scan noindex list and noindex and nofollow pages in the array
//--> html headerNavTab vars
$tab_icon_sp='
';
//--> css boxes, green and red box div code
$red_box='';
$green_box='';
$blue_box='';
//--> get/set affiliate ids
$afl_dat=manage_afl_ids();
//-->@Daily Schedule check
if (check_daily_run())
{
//--> set schedule status to running
switch($aset['schedule_status'])
{
case 1:
//--> already running do nothing
break;
default:
$q_sch_update="update una_bdt SET schedule_run_date=now(),schedule_status=1";
$r_sch=mysql_query($q_sch_update);
//--> include daily schedule script
include_once("daily_schedule.php");
} // end switch
} // end if, check daily run
//--> schedule functions
function check_daily_run()
{
global $aset;
$sch_date=$aset['schedule_run_date'];
$sch_date=intval(str_replace('-','',$sch_date));
$c_date=intval(date('Ymd'));
$rv=($c_date > $sch_date) ? 1:0;
//--> send return
return $rv;
//--> end function
}
//--> db form directory paths
$db_form_dir_list['sub']='forms_subscription/';
$db_form_dir_list['service']='forms_service/';
$db_form_dir_list['physical']='forms_physical/';
$db_form_dir_list['plan']='forms_plan/';
//-->@mysql helper functions
function cart_sqlcache($name, $expire, $query,$read_only=false,$db_conn=null)
{
//EDIT VARIABLES BELOW
//chmod ("/path/to/file/filename", 0666);
$path = CART_CACHE_DIR; //full path to where the cache directory is located ... end with a trailing /
//DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING :)
$file = $path . $name . '_cache';
if (file_exists($file) && filemtime($file) > (time() - $expire)) {
$records = unserialize(file_get_contents($file));
} else {
if($read_only == true)
{
//--> return empty array
$records=array();
}
else
{
// form SQL query
if($db_conn)
{
$result = mysql_query($query,$db_conn) or die (mysql_error());
}
else
{
$result = mysql_query($query) or die (mysql_error());
} // end if, use active or external db connection
while ($record = mysql_fetch_assoc($result) ) {
$records[] = $record;
}
//Cache the query
$OUTPUT = serialize($records);
$fp = fopen($file,"w");
fputs($fp, $OUTPUT);
fclose($fp);
} // end if, check ready only
} // end else
return $records;
}
//-->@fire sale functions
function firesale_update($a1)
{
//-->@fire sale, sale active
$item_id=$a1['ItemID'];
$item_price=$a1['ItemPrice'];
$sale_update_ts=intval($a1['sale_update_ts']);
$sale_active=$a1['sale_active'];
$a1['sale_price']=0; // default zero
if($sale_active == 'y')
{
$sale_ts=$a1['sale_ts'];
$sale_start_date=Date('Y-m-d',$sale_ts);
//-->@calc days until end price is reached
$x_start_price=$a1['start_price'];
$x_sale_days=$a1['sale_days'];
$x_end_price=$a1['end_price'];
$sale_end_day_ts=0; // default zero
if($x_sale_days >0)
{
$x_days_until_ep=$x_sale_days;
$sale_end_day_ts=$sale_ts+($x_days_until_ep*86400); // timestamp when sale will reach the end_price
//-->@numbers
$ed_r_days=intval(($sale_end_day_ts-$sale_ts)/86400);
$ed_r_hrs=intval(($sale_end_day_ts-$sale_ts)/3600) % 24;
$ed_r_mins=intval(($sale_end_day_ts-$sale_ts)/60) % 60;
$ed_r_secs=intval(($sale_end_day_ts-$sale_ts)) % 60;
//-->text
$ed_txt_days=str_pad($ed_r_days,2,'0',STR_PAD_LEFT);
$ed_txt_hrs=str_pad($ed_r_hrs,2,'0',STR_PAD_LEFT);
$ed_txt_mins=str_pad($ed_r_mins,2,'0',STR_PAD_LEFT);
$ed_txt_secs=str_pad($ed_r_secs,2,'0',STR_PAD_LEFT);
$x_time_until_ep="$ed_txt_days:$ed_txt_hrs:$ed_txt_mins:$ed_txt_secs";
} // end if, check step price
//-->@calc time remaining
$cur_ts=time(); // get current unix timestamp
if($cur_ts >= $sale_end_day_ts)
{
$sale_rem_time="[sale has expired]";
//-->@update sale_active to (n) and ItemPrice = end_price and sale_update_ts=cur_ts if sale_update_ts < cur_ts
$q_ud="UPDATE dd_catalog SET sale_active='n',
ItemPrice='$x_end_price',
sale_update_ts='$cur_ts'
WHERE (ItemID = $item_id) LIMIT 1
";
$r_ud=mysql_query($q_ud);
//-->@update array values
$a1['sale_active']='n';
$a1['ItemPrice']=$x_end_price;
$a1['sale_update_ts']=$cur_ts;
}
else
{
//-->@sale age, how many days old
$age_days=intval(($cur_ts-$sale_ts)/86400);
$a1['sale_age']=$age_days; //-->@used to set sale price based on step_price
$sale_price=$x_start_price;
$a1['sale_price']=$sale_price;
//-->@numbers
$r_days=intval(($sale_end_day_ts-$cur_ts)/86400);
$r_hrs=intval(($sale_end_day_ts-$cur_ts)/3600) % 24;
$r_mins=intval(($sale_end_day_ts-$cur_ts)/60) % 60;
$r_secs=intval(($sale_end_day_ts-$cur_ts)) % 60;
//-->text
$txt_days=str_pad($r_days,2,'0',STR_PAD_LEFT);
$txt_hrs=str_pad($r_hrs,2,'0',STR_PAD_LEFT);
$txt_mins=str_pad($r_mins,2,'0',STR_PAD_LEFT);
$txt_secs=str_pad($r_secs,2,'0',STR_PAD_LEFT);
$sale_rem_time="$txt_days days: $txt_hrs hrs: $txt_mins mins: $txt_secs secs:";
$sale_countdown="$txt_days:$txt_hrs:$txt_mins:$txt_secs";
} // end if, calc time remaining
//----
if($sale_end_day_ts >0)
{
$a1['sale_end_day_ts']=$sale_end_day_ts;
$a1['sale_start_date']=$sale_start_date;
$a1['sale_active_days']=$x_days_until_ep;
$a1['sale_expire_time']=$x_time_until_ep;
$a1['sale_rem_time']=$sale_rem_time;
$a1['sale_countdown']=$sale_countdown;
$a1['sale_start_price']=$x_start_price;
$a1['sale_end_price']=$x_end_price;
} // end if, check sale end day timestamp is not zero
} // end if, sale active
//--> return array to caller
return $a1;
//----
}
//-->@unsubscribe from mail list
function get_unsub_ml_code_via_email($x_email)
{
$rv='';
$q1="SELECT mbr_id,mbr_join_date FROM members WHERE (mbr_email='$x_email') LIMIT 1";
$r1=mysql_querY($q1);
if( ($r1) && (mysql_num_rows($r1) >0) )
{
$a1=mysql_fetch_assoc($r1);
$mbr_id=$a1['mbr_id'];
$mbr_join_date=$a1['mbr_join_date'];
$rv=md5($mbr_id.'jd'.$mbr_join_date.'e'.$x_email);
} // end if, query
//--> send return
return $rv;
}
function get_unsub_ml_code_via_id($x_id)
{
$rv='';
$q1="SELECT mbr_email,mbr_join_date FROM members WHERE (mbr_id='$x_id') LIMIT 1";
$r1=mysql_querY($q1);
if( ($r1) && (mysql_num_rows($r1) >0) )
{
$a1=mysql_fetch_assoc($r1);
$mbr_email=$a1['mbr_email'];
$mbr_join_date=$a1['mbr_join_date'];
$rv=md5($x_id.'jd'.$mbr_join_date.'e'.$mbr_email);
} // end if, query
//--> send return
return $rv;
}
//-->@@news viewing functions
//--> count views (excluding admin views)
function count_news_views($post_id)
{
//--> get global vars
global $_SESSION;
//--> check if admin
if($_SESSION[AdminID])
{
//--> exclude admin views
}
elseif($post_id)
{
//--> update views for this post
$q1="update newsletter set post_views=(post_views+1) where (post_id='$post_id') limit 1";
$r1=mysql_query($q1);
} // end if
//--> end function
}
$news_layout_dat['headlines_tbl_w']=590; // headlines table width
$news_layout_dat['headlines_tbl_al']='center'; // headlines table align
$news_layout_dat['headlines_tbl_class']=''; // headlines table CSS class
$news_layout_dat['headlines_tbl_bgc']='#ddd'; // headlines table background-color CSS
$news_layout_dat['headlines_tbl_tc']='#000'; // headlines table title color CSS
$news_layout_dat['headlines_tbl_lc']='#00f'; // headlines table link color CSS
$news_layout_dat['headlines_tbl_c']='#000'; // headlines table color CSS
$news_layout_dat['headlines_tbl_trc1']='#fff'; // headlines table table-row-color 1 CSS
$news_layout_dat['headlines_tbl_trc2']='#eef'; // headlines table table-row-color 2 CSS
$news_layout_dat['headlines_tbl_font']='bold 12px verdana'; // headlines table font CSS
$news_layout_dat['headlines_tbl_rows']='10'; // headlines table max number of rows
function news_headlines_table($network=0)
{
global $news_layout_dat,$aset,$_SESSION;
$site_name=$aset['SiteName'];
//--> get news table settings
$w=$news_layout_dat['headlines_tbl_w']; // headlines table width
$bgc=$news_layout_dat['headlines_tbl_bgc']; // headlines table background-color CSS
$tc=$news_layout_dat['headlines_tbl_tc']; // headlines table title color CSS
$lc=$news_layout_dat['headlines_tbl_lc']; // headlines table link color CSS
$c=$news_layout_dat['headlines_tbl_c']; // headlines table color CSS
$trc1=$news_layout_dat['headlines_tbl_trc1']; // headlines table table-row-color 1 CSS
$trc2=$news_layout_dat['headlines_tbl_trc2']; // headlines table table-row-color 2 CSS
$font=$news_layout_dat['headlines_tbl_font']; // headlines table font CSS
$l=$news_layout_dat['headlines_tbl_rows']; // headlines table max number of rows
$ta=$news_layout_dat['headlines_tbl_al']; // headlines table align
$tbl_class=$news_layout_dat['headlines_tbl_class']; // headlines table CSS class
//--> default return
$rv='';
//--> check member, if member show all, if not show public only
//-->@check network sub from session var
if($_SESSION['network_sub'] == 1)
{
$network=1;
} // end if, check network subscription status
//-----> make where clause
if($network == 0)
{
$wc=($_SESSION['mbr_id'] || $_SESSION['AdminID']) ? 'where (is_public=1) || (is_public=0)':'where (is_public=1)';
}
else
{
$wc=($_SESSION['mbr_id'] || $_SESSION['AdminID']) ? 'where (is_public=1) || (is_public=2) || (is_public=0)':'where (is_public=1)';
} // end if, check network
//--> get post from db
$q1="select post_id,post_headline,is_public,post_date from newsletter $wc order by post_id DESC limit $l";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
while($a1=mysql_fetch_assoc($r1))
{
$x_id=$a1['post_id'];
$x_hl=$a1['post_headline'];
$x_is_pub=$a1['is_public'];
$post_link[]=seo_news_url($x_id,$x_hl,$x_is_pub);
$post_date[]=$a1['post_date'];
$post_headline[]=$x_hl;
$post_nf[]=($x_is_pub) ? '':' rel="nofollow"';
$post_icon[]=($x_is_pub) ? '♦':'♦';
} // end while, fetch
//--> make table
$tbl='
';
//--> set table as return
$rv=$tbl;
} // end if, query
//--> send return value
return $rv;
//--> end function
}
//--> get news post content
$news_post_layout['width']=590; // news post width
$news_post_layout['align']='center'; // news post align
$news_post_layout['mclass']=''; // news post CSS class for post main content div
$news_post_layout['mcss']='border:1px solid #000;'; // news post CSS for post main content div
$news_post_layout['bclass']=''; // news post CSS class for post content body div
$news_post_layout['tcss']='height:100%;overflow:auto;margin:0px;border:1px solid #eee;padding:2px;'; // news post title CSS
$news_post_layout['tbgc']='#009'; // news post title background color
$news_post_layout['tc']='#fff'; // news post title color
$news_post_layout['tfont']='bold 16px verdana'; // news post title font
$news_post_layout['dc']='#fff'; // news post date color
$news_post_layout['dfont']='bold 10px verdana'; // news post date font
function get_news_post($post_id,$mode=0)
{
$rv=''; // default return value
//--> get settings
global $news_post_layout;
$w=$news_post_layout['width']; // news post width
$al=$news_post_layout['align']; // news post align
$mclass=$news_post_layout['mclass']; // news post CSS class for post main content div
$mcss=$news_post_layout['mcss']; // news post CSS for post main content div
$bclass=$news_post_layout['bclass']; // news post CSS class for post content body div
$tcss=$news_post_layout['tcss']; // news post title CSS
$tbgc=$news_post_layout['tbgc']; // news post title background color
$tc=$news_post_layout['tc']; // news post title color
$tfont=$news_post_layout['tfont']; // news post title font
$dc=$news_post_layout['dc']; // news post date color
$dfont=$news_post_layout['dfont']; // news post date font
//--> get post from db
$q1="select * from newsletter where (post_id='$post_id') limit 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
if($mode == 0)
{
$post_hl=$a1['post_headline'];
$post_date=$a1['post_date'];
$post_body=$a1['post_body'];
//--> make post content div
$c_div='
'.$post_date.'
'.$post_hl.'
'.$post_body.'
';
//--> set content div as return
$rv=$c_div;
}
elseif(($mode == 1))
{
//--> set assoc array as return
$rv=$a1;
} // end if, check return mode
} // end if, query
//--> send return
return $rv;
//--> end function
}
//--> end news functions
//--> rss functions
//-->@@xml format function, convert html special chars
function make_xml_link($str)
{
//--> remove accent chars
$str=replaceAccentedCharacters($str);
//--> convert html special chars
$str=urlencode($str);
//--> send return
return $str;
}
function replaceAccentedCharacters($input)
{
$accent='ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËéèêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ';
$noaccent='AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn';
$cleaned = strtr($input, $accent, $noaccent);
return $cleaned;
}
//--> update or get google sitemap
function update_google_map($mode)
{
global $site_url,$_SERVER;
$home=$site_url.'/'; // add trailing slash
//--> page priority settings
$p_home=1;
$cf_home='weekly';
$p_prod=.75;
$cf_prod='weekly';
$p_category=.5;
$cf_category='weekly';
$p_reg=.25;
$cf_reg='monthly';
//--> last mod date
$lm_date=date("o-m-d");
//-->#### create start of xml sitemap ####
$xml='
';
//-->#### Home Page ####
$xml.=''."{$home}".''."{$lm_date}".''."{$cf_home}".''."{$p_home}".'';
//-->#### Privacy Policy Page ####
$xml.='
'."{$site_url}".'/privacy/'."{$lm_date}".'monthly.1';
//-->#### Help Page ####
$xml.='
'."{$site_url}".'/help/'."{$lm_date}".'monthly.1';
//-->#### Register Page ####
$xml.='
'."{$site_url}".'/register/'."{$lm_date}".'monthly.1';
//-->#### Contact Us Page ####
$xml.='
'."{$site_url}".'/contactus/'."{$lm_date}".'monthly.1';
//-->#### Products Pages ####
//--> query all products
$q_prod="select * from dd_catalog order by ItemID DESC";
$result=mysql_query($q_prod);
if (($result) && mysql_num_rows($result))
{
while($row=mysql_fetch_assoc($result))
{
$item_name=$row['ItemName'];
$item_id=$row['ItemID'];
//-->@exclude member area pages from rss
$is_private=$row['isPrivate'];
//-->@link based on product type
$prod_type=intval($row['prodType']);
if(($prod_type == 4) && ($is_private != 2))
{
//--> custom pages etc...
$link=seo_custom_page_url($item_id);
}
else
{
//--> normal product
$link=seo_product_url($item_id);
} // end if, check product type
//--> add game page into map
$xml.='
'."{$link}".''."{$lm_date}".''."{$cf_prod}".''."{$p_prod}".'';
} // end while, fetch
} // end if, query
//-->#### Category Page ####
$q_cat="SELECT * FROM dd_categories ORDER BY CategoryID DESC";
$result=mysql_query($q_cat);
if (($result) && mysql_num_rows($result))
{
while($row=mysql_fetch_assoc($result))
{
$cat_id=$row['CategoryID'];
$link=seo_category_url($cat_id);
//--> add game page into map
$xml.='
'."{$link}".''."{$lm_date}".''."{$cf_category}".''."{$p_category}".'';
} // end while, fetch
} // end if, query
//--> close urlset and end xml
$xml.='
';
//--> move xml to output
$output=$xml;
switch($mode)
{
case 'update':
//-->Update the static file
//ini_set('allow_url_fopen','1');
$xmlfile = $_SERVER['DOCUMENT_ROOT']."/sitemap.xml";
$fh = fopen($xmlfile,'w') or die("can't open file $xmlfile, make sure directory/file is chmod 777");
if($fh)
{
fwrite($fh, $output);
//--> close the xml file
fclose($fh);
return 1; // passed
}
else
{
return 0; // failed
} // end if
//--> output to browser
//echo $output;
break;
case 'get':
//set the content type to xml
//header("Content-Type: text/xml");
//--> return output xml back to caller
return $output;
break;
default:
//--> do nothing
} // end switch, mode
//--> end function
}
function cleanupXML($xml) {
$xmlOut = '';
$inTag = false;
$xmlLen = strlen($xml);
for($i=0; $i < $xmlLen; ++$i) {
$char = $xml[$i];
// $nextChar = $xml[$i+1];
switch ($char) {
case '<':
if (!$inTag) {
// Seek forward for the next tag boundry
for($j = $i+1; $j < $xmlLen; ++$j) {
$nextChar = $xml[$j];
switch($nextChar) {
case '<': // Means a < in text
$char = htmlentities($char);
break 2;
case '>': // Means we are in a tag
$inTag = true;
break 2;
}
}
} else {
$char = htmlentities($char);
}
break;
case '>':
if (!$inTag) { // No need to seek ahead here
$char = htmlentities($char);
} else {
$inTag = false;
}
break;
default:
if (!$inTag) {
$char = htmlentities($char);
}
break;
}
$xmlOut .= $char;
}
return $xmlOut;
}
//--> get 100 newest products from db
function rssupdatenewproducts($l=100,$mode='update',$guid='0')
{
global $aset;
$siteurl=$aset[SiteURL];
$sitename=$aset[SiteName];
$rss_title=$sitename.' - New Products Feed';
$rss_description='new products from '.$sitename;
$rss_image='';
$rss_image_width=0;
$rss_image_height=0;
$author=$sitename;
$url=$siteurl;
//--> xml escape
if($rss_image)
{
$rss_image=htmlentities($rss_image,ENT_QUOTES);
} // end if
$rss_title=htmlentities($rss_title,ENT_QUOTES);
$rss_description=htmlentities($rss_description,ENT_QUOTES);
//--> always default to 100
if ($l <=0) $l=100;
//--> get 100 newest products from db
$q_prod="select * from dd_catalog order by ItemID DESC LIMIT $l";
$result=mysql_query($q_prod);
if( ($result) && (mysql_num_rows($result) >0) )
{
//--> Make News Feed
//--> make output buffer
$output = "";
$output.= '';
$output.= ' '.$rss_title.'
'.$url.'
'.$rss_description.'
'.date("l, M j Y H:i:s").''.$author.'en'.$rss_image.''.$rss_title.' thumbnail
'.$url.'
'.$rss_image_width.''.$rss_image_height.'';
while ($prodinfo=mysql_fetch_assoc($result))
{
$item_id=$prodinfo['ItemID'];
//-->@exclude member area pages from rss
$is_private=$prodinfo['isPrivate'];
//-->@link based on product type
$prod_type=intval($prodinfo['prodType']);
if(($prod_type == 4) && ($is_private != 2))
{
//--> custom pages etc...
$prod_type_txt='New Content';
$link=seo_custom_page_url($item_id);
$guid_prod_url=$link;
$item_name=$prodinfo['ItemName'];
$item_description=$prodinfo['ItemDesc'];
//-->@strip tags from description
$item_description=strip_tags($item_description);
$item_description='
'.$item_description.'
';
//--> xml escaped
$xml_title=htmlentities($item_name,ENT_QUOTES);
//$xml_description=htmlentities($item_description,ENT_QUOTES);
$xml_description=preg_replace('/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/i', '', $item_description);
$guid_prod_url=htmlentities($guid_prod_url,ENT_QUOTES);
//--> make friendly url link for xml link tag
$link=seo_custom_page_url($item_id);
$prod_guid=($guid) ? ''.$guid_prod_url.'':'';
}
else
{
//--> normal product
$prod_type_txt='New Product';
$guid_prod_url=$siteurl.'/product/'.$item_id.'/';
$item_name=$prodinfo['ItemName'];
$item_description=$prodinfo['ItemDesc'];
//-->@strip tags from description
$item_description=strip_tags($item_description);
$item_description='
'.$item_description.'
';
//--> xml escaped
$xml_title=htmlentities($item_name,ENT_QUOTES);
//$xml_description=htmlentities($item_description,ENT_QUOTES);
//-->@convert html entities
$xml_description=preg_replace('/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/i', '', $item_description);
$guid_prod_url=htmlentities($guid_prod_url,ENT_QUOTES);
//--> make friendly url link for xml link tag
$link=seo_product_url($item_id);
$prod_guid=($guid) ? ''.$guid_prod_url.'':'';
} // end if, check product type
$prod_pub_date=($guid) ? ''.date("D, d M Y H:i:s").'':''.date("l, M j Y H:i:s").'';
$output .='
'.$prod_type_txt.' - '.$xml_title.'
'.$link.'
'.$xml_description.'
'.$prod_guid.'
'.$prod_pub_date.'
';
} // end loop save game info list array
$output .= '
';
switch($mode)
{
case 'update':
//-->Update the static file
//ini_set('allow_url_fopen','1');
$xmlfile = $_SERVER['DOCUMENT_ROOT']."/rss/newproducts.xml";
$fh = fopen($xmlfile,'w') or die("can't open file $xmlfile, make sure directory/file is chmod 777");
if($fh)
{
fwrite($fh, $output);
//--> close the xml file
fclose($fh);
return 1; // passed
}
else
{
return 0; // failed
} // end if, check rss file handle
//--> output to browser
//echo $output;
break;
case 'get':
//set the content type to xml
//header("Content-Type: text/xml");
//--> return output xml back to caller
return $output;
break;
default:
//--> do nothing
} // end switch, mode
} // end if any game info found by sql query
// END Function
}
//----------------------------------------------
//--> end rss functions
//----------------------------------------------
//--> seo functions
function seo_format_meta_kw($dat)
{
//--> seo friendly page meta code formats
global $_SERVER,$aset;
$rv=$aset[SiteKeywords];
$page=$_SERVER['SCRIPT_NAME'];
if(stristr($page,'view_item.php'))
{
//--> products meta keywords
if($dat[MetaKeywords])
{
$rv=$dat[MetaKeywords];
} // end if
}
elseif(stristr($page,'view_page.php'))
{
//--> custom page meta keywords
if($dat[MetaKeywords])
{
$rv=$dat[MetaKeywords];
} // end if
}
elseif(stristr($page,'view_news_p.php'))
{
//--> public news meta keywords
if($dat[post_meta_keywords])
{
$rv=$dat[post_meta_keywords];
} // end if
}
elseif(stristr($page,'view_news_m.php'))
{
//--> private news meta keywords
if($dat[post_meta_keywords])
{
$rv=$dat[post_meta_keywords];
} // end if
}
//--> send return
return $rv;
}
function seo_format_meta_desc($dat)
{
//--> seo friendly page meta code formats
global $_SERVER,$aset;
$rv=$aset[SiteDesc];
$page=$_SERVER['SCRIPT_NAME'];
if(stristr($page,'view_item.php'))
{
//--> products meta description
if($dat[MetaDesc])
{
$rv=$dat[MetaDesc];
} // end if
}
elseif(stristr($page,'view_page.php'))
{
//--> custom page meta description
if($dat[MetaDesc])
{
$rv=$dat[MetaDesc];
} // end if
}
elseif(stristr($page,'view_news_p.php'))
{
//--> public news meta description
if($dat[post_meta_desc])
{
$rv=$dat[post_meta_desc];
} // end if
}
elseif(stristr($page,'view_news_m.php'))
{
//--> private news meta description
if($dat[post_meta_desc])
{
$rv=$dat[post_meta_desc];
} // end if
}
//--> send return
return $rv;
}
function seo_format_title($dat)
{
//--> seo friendly page title formats
global $_SERVER,$aset;
$rv=$aset[SiteTitle];
$page=$_SERVER['SCRIPT_NAME'];
if(stristr($page,'view_item.php'))
{
//--> products page
$rv=$dat[ItemName];
}
elseif(stristr($page,'view_page.php'))
{
//--> products page
$rv=$dat[ItemName];
}
elseif(stristr($page,'categories.php'))
{
//--> category page
$rv=$dat[CategoryName];
}
elseif(stristr($page,'view_news_p.php'))
{
//--> public news page
$rv=$dat[post_headline];
}
elseif(stristr($page,'view_news_m.php'))
{
//--> private news page
$rv=$dat[post_headline];
}
//--> send return
return $rv;
}
function seo_prep_text($txt)
{
// remove all characters that aren’t a-z, 0-9, dash, underscore or space
$reject_regex='#[^-a-zA-Z0-9_ ]#';
$str=preg_replace($reject_regex,'',$txt);
// remove all leading and trailing spaces
$str=trim($str);
// always lowercase
$str=strtolower($str);
// change all dashes, underscores and spaces to dashes
$str=preg_replace('#[-_ ]+#','-',$str);
// return the modified string
return $str;
}
function seo_news_url($post_id,$post_headline,$is_public)
{
global $site_url;
$rv=$site_url; // default to site_url (homepage)
$p=($is_public & 1) ? 'p':'m';
//-->@make seo friendly url
$url='/news/'.$p.'/'.
seo_prep_text($post_headline).'/'.$post_id.'.html';
//--> pre-pend base url
$rv=$site_url.$url;
//--> return value
return $rv;
}
function seo_free_dl_url($item_id)
{
global $site_url,$_SESSION;
$rv=$site_url.'/mbr_area.php'; // default to members area notice
if($_SESSION['mbr_email'])
{
$rv=$site_url.'/free-downloads/'.$item_id.'/';
} // end if, check member logged & registered
//--> return value
return $rv;
}
function seo_search_url($search_term,$page_num=1)
{
global $site_url;
$rv=$site_url; // default to site_url (homepage)
//-->@make seo friendly url
$url='/search/'.
seo_prep_text($search_term).'/'.$page_num.'/';
//--> pre-pend base url
$rv=$site_url.$url;
//--> return value
return $rv;
}
function seo_category_url($cat_id,$page_num=1)
{
global $site_url;
$rv=$site_url; // default to site_url (homepage)
$q1="select CategoryID,CategoryName from dd_categories where (CategoryID='$cat_id') LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
//-->@make seo friendly url
$url='/Category/'.
seo_prep_text($a1[CategoryName]).
'-c'.$a1[CategoryID].'/'.$page_num.'/';
//--> pre-pend base url
$rv=$site_url.$url;
} // end if, query
//--> return value
return $rv;
}
function get_custom_page_id($pageName)
{
//--> find custom page id that matches page name
$rv=''; // default null
$rpl=array('-','&','#',"'",':');
$search_term=str_replace($rpl,'%',$pageName);
$q1="select ItemID from dd_catalog where (ItemName LIKE '$search_term') order by ItemID ASC LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
$rv=$a1[ItemID];
} // end if, query
//--> return item id
return $rv;
}
function seo_custom_page_url($item_id)
{
global $site_url;
$rv=$site_url; // default to site_url (homepage)
$q1="select ItemName,ItemID from dd_catalog where (ItemID='$item_id') LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
//-->@make seo friendly url
$url='/'.seo_prep_text($a1[ItemName]).'.html';
//--> pre-pend base url
$rv=$site_url.$url;
} // end if, query
//--> return value
return $rv;
}
function seo_product_url($item_id)
{
global $site_url;
$rv=$site_url; // default to site_url (homepage)
$q1="select p.ItemName,p.ItemID,c.CategoryName,c.CategoryID from dd_catalog as p,dd_categories as c where (p.ItemID='$item_id') && (p.ItemCategory = c.CategoryID) LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
//-->@make seo friendly url
$url='/products/'.
seo_prep_text($a1[CategoryName]).
'-c'.$a1[CategoryID].'/'.
seo_prep_text($a1[ItemName]).
'-p'.$a1[ItemID].'.html';
//--> pre-pend base url
$rv=$site_url.$url;
} // end if, query
//--> return value
return $rv;
}
//----------------------------------------------
//--> end seo functions
//----------------------------------------------
function get_coupon_id($coupon_code)
{
$rv=0; // default to zero
if($coupon_code)
{
//--> if coupon code is set then
$q1="select coupon_id from coupons where coupon_code='$coupon_code' LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$a1=mysql_fetch_assoc($r1);
$rv=$a1['coupon_id']; // return coupon_id for given coupon_code
} // end if, query
} // end if, any coupon_code given
//--> send return value
return $rv;
//--> end function
}
function find_file_by_unique_id($file_id,$file_path)
{
//--> return first filename that matches
$rv=''; // default null, not found
$dh = opendir($file_path);
//--> get files list
while(false !== ($filename = readdir($dh)))
{
if (($filename !=".") && ($filename !=".."))
{
$filename_parts=split("\.",$filename);
$short_name=$filename_parts[0];
if(stristr($short_name,$file_id))
{
$rv=$file_path.$filename;
break; // exit loop, match found
} // end if, find file_id
} // end if, only show file names
} // while loop
//--> Close directory handle
closedir($dh);
//--> send return
return $rv;
}
//-->@replace first only
function str_replace_once($needle , $replace , $haystack)
{
// Looks for the first occurence of $needle in $haystack
// and replaces it with $replace.
$pos = strpos($haystack, $needle);
if ($pos === false) {
// Nothing found
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
function get_order_csi_table($x_order_id)
{
//--> return table that has extra order info for admin
//--> and has a form that allows admin to set service_active or not,
//--> and stamp order as canceled.
$rv=''; // default to null
$q1="select * from dd_orders_info where OrderID='$x_order_id' LIMIT 1";
$r1=mysql_query($q1);
if(($r1) && mysql_num_rows($r1))
{
$rv.='