@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(); ?> 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=' '; $link_c=count($post_link); for($x=0;$x<$link_c;$x++) { $trc=($x & 1) ? $trc2:$trc1; $tbl.=''; } // end for $tbl.='
'.$site_name.' - News
'.$post_icon[$x].$post_date[$x].' '.$post_headline[$x].'
'; //--> 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.='
'; //--> order info header $order_info=mysql_fetch_assoc($r1); $x_order_active=intval($order_info['service_active']); $service_active=($x_order_active) ? 'checked':''; $active_status=($x_order_active) ? 'Active':'Disabled'; $cancel_date=$order_info['cancel_date']; $cancel_status=($cancel_date) ? 'Yes':'No'; $service_canceled=($cancel_date) ? 'checked':''; //--> get csi_file info $fid='oID'.$x_order_id.'_'; $csi_file=find_file_by_unique_id($fid,'../csi_files/'); if($csi_file) { $csi_info=@file_get_contents($csi_file); //--> get account pw //account_password: Retro8lo[khe@d $csi_rows=split("\n",$csi_info); foreach($csi_rows as $csi_line) { $csi_dat=split(':',$csi_line); $k=$csi_dat[0]; // key $v=$csi_dat[1]; // val if($k == 'account_password') { $csi_sec_pw=trim($v); } // end if, find account pw } // end foreach } // end if, get csi info //--> show account pw $rv.=' '; //--> add csi info $rv.=' '; } // end if, query, order_info //--> send return return $rv; //--> end function } function get_mbr_id_by_order_id($x_order_id) { $rv='0'; $q_mbr_dat="SELECT m.mbr_id FROM members m LEFT JOIN dd_orders_info oi ON(oi.mbr_id=m.mbr_id) WHERE (OrderID='$x_order_id') LIMIT 1"; $r_mbr_dat=mysql_query($q_mbr_dat); if( ($r_mbr_dat) && (mysql_num_rows($r_mbr_dat) >0) ) { $a_mbr_dat=mysql_fetch_assoc($r_mbr_dat); $rv=intval($a_mbr_dat['mbr_id']); } // end if, r_mbr_dat return $rv; } //-->@manage tracking number functions function check_mtk_csv($txt_csv,$txt_mtk_csv) { //--> Purpose: return array() to help manage CSV tracking numbers list, per Order // index [0] How many New item(s) found in txt_csv // index [1] CSV text to append to txt_mtk_csv after the email has been sent $c=0; // new csv element count $rv=array(); $rv[0]=0; // default no New item(s) found $rv[1]=''; // default null $sep=($txt_mtk_csv != '') ? ',':''; // default separater comma when txt_mtk_csv isn't null, else default null $new_csv_txt=''; // default null $txt_rows=split(',',$txt_csv); foreach ($txt_rows as $k => $val) { $pad_val='('.trim($val).')'; // pad value of this csv element with parentheses $cmp=stristr($txt_mtk_csv,$pad_val); if( ($val != '') && ($cmp == '') ) { //-->@add to new csv text, when val is not null and val is not found in txt_mtk_csv $new_csv_txt.=$sep.$pad_val; //-->@increment counter $c++; //-->@set comma as separater $sep=','; } // end if, append new csv text } // end foreach //-->@assign values before return $rv[0]=$c; $rv[1]=$new_csv_txt; return $rv; } function detectCarrier($tracking_code) { //--> Purpose: Detect the carrier for a given tracking code (number) // return an array() // [0] Carrier Display Name // [1] Carrier Tracking Link $rv=array(); $rv[0]=''; $rv[1]=''; $carrier_name=''; // default null //---- if (preg_match('/^[0-9]{2}[0-9]{4}[0-9]{4}$/', $tracking_code, $matches)) { $carrier_name = 'DHL'; } elseif (preg_match('/^[1-9]{4}[0-9]{4}[0-9]{4}$/', $tracking_code, $matches)) { $carrier_name = 'FedEx'; } elseif (preg_match('/^1Z[A-Z0-9]{3}[A-Z0-9]{3}[0-9]{2}[0-9]{4}[0-9]{4}$/i', $tracking_code)) { $carrier_name = 'UPS'; } elseif (preg_match('/^[0-9]{4}[0-9]{4}[0-9]{4}[0-9]{4}[0-9]{4}[0-9]{2}$/', $tracking_code)) { $carrier_name = 'USPS'; } // end if, carrier_name //--> return values if($carrier_name) { $rv[0]=$carrier_name; switch($carrier_name) { case 'DHL': break; case 'FedEx': break; case 'UPS': // https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums=1ZRX95040365747475 $rv[1]='Status: UPS Tracking #: '.$tracking_code.''; break; case 'USPS': $rv[1]='Status: USPS Tracking #: '.$tracking_code.''; } } // end if, carrier found //---- return $rv; } //---- function get_order_table($x_order_id,$mbr_id=0,$isAdmin=0) { global $_SESSION; //-->@mod Jun 7, 2016 Added Physical weight and weight units e.g. 28g into order table display //--> make order details table $rv=''; // default to null //-->@get member ID if($mbr_id == 0) { $x_mbr_id=intval($_SESSION['mbr_id']); } else { $x_mbr_id=$mbr_id; } // end if, mbr_id /* Query: SELECT oi.*,spb.TrackingNumber,COUNT(oc.ItemID) as totalItems,SUM(IF(ctlg.f_src='Internal',0,1)) as extItems FROM dd_orders_info oi LEFT JOIN ship_postback spb ON(spb.OrderID=oi.OrderID) LEFT JOIN dd_orders_content oc ON(oc.OrderID=oi.OrderID) LEFT JOIN dd_catalog ctlg ON(ctlg.ItemID=oc.ItemID) WHERE (oi.OrderID='1155') GROUP BY OrderID */ //$q1="SELECT oi.*,spb.TrackingNumber FROM dd_orders_info oi LEFT JOIN ship_postback spb ON(spb.OrderID=oi.OrderID) WHERE (oi.OrderID='$x_order_id')"; //-->@Modified Jun 26, 2018 Altered Query to include totalItems and extItems (total items, and external items count) $q1="SELECT oi.*,spb.TrackingNumber,COUNT(oc.ItemID) as totalItems,SUM(IF(ctlg.f_src='Internal',0,1)) as extItems FROM dd_orders_info oi LEFT JOIN ship_postback spb ON(spb.OrderID=oi.OrderID) LEFT JOIN dd_orders_content oc ON(oc.OrderID=oi.OrderID) LEFT JOIN dd_catalog ctlg ON(ctlg.ItemID=oc.ItemID) WHERE (oi.OrderID='$x_order_id') GROUP BY OrderID"; $r1=mysql_query($q1); if(($r1) && mysql_num_rows($r1)) { $rv.='
account_password:
Service Status:
Cancel Status:
client_info:
'; //--> order info header $order_info=mysql_fetch_assoc($r1); //-->@delivery info $x_ship_cost=$order_info['shipping_cost']; $x_shipping_cost=number_format($order_info['shipping_cost'],2,'.',','); $x_order_paid=$order_info['order_paid']; $x_tracking=$order_info['TrackingNumber']; $f_tracking_csv=$order_info['f_tracking_csv']; $f_tracking_arr=split(',',$f_tracking_csv); $totalItemsCount=intval($order_info['totalItems']); $extItemsCount=intval($order_info['extItems']); $ext_sep=''; // delimiter of external tracking numbers //---- $x_addr_id=intval($order_info['order_addr_id']); $x_deliv_st=intval($order_info['order_deliv_st']); $x_deliv_et=intval($order_info['order_deliv_et']); $delivRequired=false; // default false $addr_div=''; // default null $delivery_details=''; // default null $x_deliv_txt=''; // default null if( ($x_addr_id >0) && ($x_deliv_st >0) ) { $delivRequired=true; //-->@Internal Shipment Status if($totalItemsCount > $extItemsCount) { if( ($x_order_paid == 'y') && ($x_tracking !='') ) { $x_deliv_txt='Status: USPS Tracking #: '.$x_tracking.''; } else if( ($x_order_paid == 'y') && ($x_deliv_st > 0) ) { $x_deliv_txt='Status: Processing for shipment'; } else { $x_deliv_txt='Status: n/a'; } } // end if, Internal shipment Status //-->@External Shipment Status if( ($extItemsCount >0) && ($extItemsCount == $totalItemsCount) ) { //-->@Order contains Only External Items if( is_array($f_tracking_arr) ) { //-->@Show All External Tracking Numbers with links foreach ( $f_tracking_arr as $ext_tracking_num) { // Status: USPS Tracking #: '.$x_tracking.' $ext_tracking_arr=detectCarrier($ext_tracking_num); $ext_tracking_txt=$ext_tracking_arr[1]; $x_deliv_txt.=$ext_sep.$ext_tracking_txt; $ext_sep='
'; // delimiter, html line break } // enf foreach } // end if, tracking numbers array populated } else if( ($extItemsCount >0) && ($extItemsCount < $totalItemsCount) ) { //-->@Order contains Internal and External Items if( is_array($f_tracking_arr) ) { $f_tracking_arr_c=count($f_tracking_arr); if($f_tracking_arr_c >1) { $x_deliv_txt.='
Additional Shipments
'; } else { $x_deliv_txt.='
Additional Shipment
'; } //-->@Show All External Tracking Numbers with links foreach ( $f_tracking_arr as $ext_tracking_num) { // Status: USPS Tracking #: '.$x_tracking.' $ext_tracking_arr=detectCarrier($ext_tracking_num); $ext_tracking_txt=$ext_tracking_arr[1]; $x_deliv_txt.=$ext_sep.$ext_tracking_txt; $ext_sep='
'; // delimiter, html line break } // enf foreach } // end if, tracking numbers array populated } // end if, external shipment(s) } // end if, deliv info //---- $x_order_paid=($order_info['order_paid'] == 'y') ? 'yes':'no'; $x_nrs_flag=intval($order_info['order_nrs']); $x_order_nrs=($x_nrs_flag == 1) ? 'non-recurring subscription':''; $x_currency_sign=$order_info['currency_sign']; $rv.=''; $rv.=''; //-->@physical product when all delivery details are present //-->@show delivery details when needed if( ($delivRequired == true) ) { $deliv_time_rows=''; //-->@Use Order Address ID $q_addr_single="SELECT * from addr_book ab LEFT JOIN members m ON(ab.mbr_id=m.mbr_id) WHERE (m.mbr_id='$x_mbr_id') AND (ab.addr_id='$x_addr_id')"; //---- $r_addr_single=mysql_query($q_addr_single); if( ($r_addr_single) && (mysql_num_rows($r_addr_single) >0) ) { $a_addr_single=mysql_fetch_assoc($r_addr_single); //-->@address components $addr_id=intval($a_addr_single['addr_id']); $addr_first_name=$a_addr_single['first_name']; $addr_last_name=$a_addr_single['last_name']; $addr_country=$a_addr_single['country']; $addr_street1=$a_addr_single['street1']; $addr_street2=$a_addr_single['street2']; $addr_city=$a_addr_single['city']; $addr_state=$a_addr_single['state']; $addr_zip=$a_addr_single['zip']; $addr_p_number=$a_addr_single['p_number']; $addr_p_ext=$a_addr_single['p_ext']; $addr_p_ext_text=($addr_p_ext) ? 'x'.$addr_p_ext.'':''; $addr_p_type_ltr=$a_addr_single['p_type']; switch($addr_p_type_ltr) { case 'M': $addr_p_type_text='Mobile'; break; case 'H': $addr_p_type_text='Home'; break; case 'W': $addr_p_type_text='Work'; break; default: $addr_p_type_text='Mobile'; } // end switch, addr_p_type_ltr //$addr_report=print_r($a_addr_single,true); //---- $addr_div='
Date/Time OrderID Paid
'.date('Y-m-d, h:i a',$order_info['order_date']).' '.$x_order_id.' '.$x_order_paid.'
'.$x_deliv_txt.'
'.$deliv_time_rows.'

Shipping Address


First Name: '.$addr_first_name.' Last Name: '.$addr_last_name.'
Street: '.$addr_street1.'
Street 2: '.$addr_street2.'
City/State: '.$addr_city.', '.$addr_state.'   Zip Code: '.$addr_zip.'
Phone: '.$addr_p_number.' '.$addr_p_ext_text.' Phone Type: ('.$addr_p_type_text.')
'; } // end if, query, q_addr_single //---- $delivery_details='
'.$addr_div.'
'; //---- $rv.=$delivery_details; //---- } // end if, physical product //---- //--> close table $rv.=''; //--> order contents $q2="select * from dd_orders_content where (OrderID='$x_order_id')"; $r2=mysql_query($q2); if(($r2) && mysql_num_rows($r2)) { //--> order content rows $item_names=array(); $item_ids=array(); $f_src=array(); $f_prod_ids=array(); $f_prod_url=array(); $sub_total=0; // default to zero while($order_row=mysql_fetch_assoc($r2)) { $item_ids[]=$order_row['ItemID']; $x_item_title=trim($order_row['ItemTitle']); $item_title[]=($x_item_title) ? '
'.$x_item_title.'
':''; $item_prices[]=$order_row['ItemPrice']; $item_qtys[]=$order_row['ItemQty']; $item_totals[]=$order_row['ItemTotal']; $item_dls[]=($order_row['download_status'] == 'y') ? 'yes':'no'; $sub_dat=unserialize($order_row['subTerms']); $item_sub_terms[]=get_price_struct_table($sub_dat,true); //--> add up item sub total $sub_total+=$order_row['ItemTotal']; } // end while, fetch order contents //--> get item names for item ids $id_c=count($item_ids); for($x=0;$x<$id_c;$x++) { $x_id=$item_ids[$x]; $q_name="select ItemName,ItemImageURL,prodType,priceStruct,weight,weight_units,weight_display,shipping_group,group_units,f_src,f_prod_id,f_prod_url FROM dd_catalog WHERE ItemID='$x_id'"; if( ($item_names[$x_id] != '?') && ($item_names[$x_id] == '')) { $r_name=mysql_query($q_name); if(($r_name) && mysql_num_rows($r_name)) { $item_row=mysql_fetch_assoc($r_name); $item_names[$x_id]=$item_row['ItemName']; $img_row_url=$item_row['ItemImageURL']; $f_src[$x_id]=$item_row['f_src']; $f_prod_id[$x_id]=$item_row['f_prod_id']; $f_prod_url[$x_id]=$item_row['f_prod_url']; //-->@isAdmin if($isAdmin >0) { $img_rp=stripos($img_row_url,'item_images/'); if($img_rp !== false) { $img_rp_str=substr($img_row_url,0,$img_rp); $img_row_url=str_replace($img_rp_str,'../',$img_row_url); } // end if, replace image dir to relative path } $x_item_img_tag[$x_id]=fixedWidthImage($img_row_url,60); //-->@get item details $item_details[$x_id]=get_price_struct_table($item_row,true); // exclude price, already shown beside Quantity //---- $x_price_struct[$x_id]=$item_row['priceStruct']; $x_prod_type[$x_id]=$item_row['prodType']; //--> get priceStruct $priceStruct=$x_price_struct[$x_id]; $prodType=$x_prod_type[$x_id]; switch($priceStruct) { case 0: // single payment $rv.=''; //--> order content header $rv.=''; //--> show item details //-->@Alternate background-color $item_bgc=($x & 1) ? '#ffffff':'#dddddd'; //-->@isAdmin Override background-color if External Product //-->@isAdmin $f_prod_label=''; // default null $f_prod_link=''; // default null if( ($isAdmin >0) && ($f_src[$x_id] != '') && ($f_src[$x_id] != 'Internal') ) { $item_bgc='#ffee00'; $f_prod_link=''.trim($f_prod_url[$x_id]).''; $f_prod_label='
Ext ID: '.trim($f_prod_id[$x_id]).'
'.$f_prod_link; } // end if, isAdmin if($prodType == 1) { //-->@Physical, no download required $rv.=''; } else { //-->@Digital or Service $rv.=''; } // end if, product type //--> close items table $rv.='
Item Name Downloaded Price Qty Total
'.$x_item_img_tag[$x_id].'
'.$item_names[$x_id].'
n/a'.$item_details[$x_id].$f_prod_label.' '.$x_currency_sign.$item_prices[$x].' '.$item_qtys[$x].' '.$x_currency_sign.$item_totals[$x].'
'.$item_names[$x_id].' '.$item_dls[$x].' '.$x_currency_sign.$item_prices[$x].' '.$item_qtys[$x].' '.$x_currency_sign.$item_totals[$x].'
'; break; case 1: // subscription //-->@auto-renew subscription $rv.=''; //--> order content header $rv.=''; //--> show item details $item_bgc=($x & 1) ? '#ffffff':'#dddddd'; $rv.=''; //--> close items table $rv.='
Item Name Terms Initial Price Qty Total
'.$item_names[$x_id].$item_title[$x].' '.$item_sub_terms[$x].' '.$x_currency_sign.$item_prices[$x].' '.$item_qtys[$x].' '.$x_currency_sign.$item_totals[$x].'
'; break; case 2: // installment plan break; default: } // end switch, priceStruct //-------------------------------------- } else { $item_names[$x_id]='?'; } // end if, any name found for item id } // avoid repeat queries } // end for, get item names //--> show order sub total $sub_total=number_format($sub_total,2,'.',','); $rv.=''; $rv.=''; //--> show coupon credit applied if($order_info['coupon_id']) { $x_coupon_id=$order_info['coupon_id']; $q_coupon="select * from coupons where coupon_id='$x_coupon_id'"; $r_coupon=mysql_query($q_coupon); if(($r_coupon) && mysql_num_rows($r_coupon)) { $coupon_info=mysql_fetch_assoc($r_coupon); $x_coupon_code=$coupon_info['coupon_code']; $x_coupon_perc=$coupon_info['coupon_perc']; $x_coupon_savings=($sub_total*0.999)*($x_coupon_perc*0.01); //($sub_total-$order_info['order_total']); $x_coupon_savings=number_format($x_coupon_savings,2,'.',','); $coupon_desc='Coupon: '.$x_coupon_code; switch($priceStruct) { case 0: // single payment $txt_coupon_savings=$x_currency_sign.$x_coupon_savings; break; case 1: // subscription if($x_nrs_flag == 1) { //-->@non-recurring subscription $x_coupon_savings=($item_prices[0]-$order_info['order_total']); $x_coupon_savings=number_format($x_coupon_savings,2,'.',','); $txt_coupon_savings=$x_currency_sign.$x_coupon_savings; } else { //-->@auto-renew subscription $txt_coupon_savings='FREE TRIAL'; } // end if, $x_nrs_flag break; case 2: // installment plan $txt_coupon_savings=''; break; default: } // end switch, price structure $rv.=''; } // end if, query } // end if, any coupon_id //--> show order shipping cost x_shipping_cost $rv.=''; //--> show order grand total $rv.=''; //--> close totals table $rv.='
Sub Total '.$x_currency_sign.$sub_total.'
'.$coupon_desc.' Savings - '.$txt_coupon_savings.'
Shipping '.$x_currency_sign.$x_shipping_cost.'
Order Total '.$x_currency_sign.$order_info['order_total'].'
'; if(($x_order_paid == 'yes') && ($priceStruct == 0) && ($prodType == 0)) { //--> show download links $rv.=''; $rv.=''; $dl_links=get_dl_links($x_order_id); $dl_rows=make_dl_rows($dl_links); $rv.=$dl_rows; //--> close download links table $rv.='
Download Links
'; } // end if, show dl table if order paid for } // end if, any results for order contents } else { $rv.='
[No records were found for OrderID:'.$x_order_id.'
'; } // end if, any records found for x_order_id //--> send return value return $rv; //--> end function } function get_dl_links($x_order_id) { global $site_url; $rv=array(); // default, empty array //--> return array of download links, or empty array $q2 = "select OrderID, ItemID from dd_orders_content where OrderID = '$x_order_id'"; $result = mysql_query($q2); if($result) { while($row = mysql_fetch_row($result)) { $q4 = "select ItemName, downloadURL from dd_catalog where ItemID = '$row[0]'"; $rr = mysql_query($q4); if($rr) { $d = mysql_fetch_row($rr); $rv[]="$d[0]-=-$site_url/dl/index.php?k=$row[0]|$row[1]"; } // end if } // end while fetch } // end if, result //--> send return value return $rv; //--> end function } function make_dl_rows($dl_dat) { //--> make html table row for download link listing $rv=''; // default to null if(!is_array($dl_dat)) return ''; // exit and return null if not array $c=count($dl_dat); for($x=0;$x<$c;$x++) { $val=split("-=-",$dl_dat[$x]); $name=$val[0]; $link=$val[1]; $bgc=($x & 1) ? '#ffffff':'#dddddd'; $rv.=' '.$name.' '.$link.' '; } // end for //--> send return value return $rv; //--> end function } function setcookie_days($name,$val,$days) { //--> Save Cookie $exp_time=time()+(60*60*24*$days); setcookie($name,$val,$exp_time,'/'); } function getRegTableRow() { global $site_url,$num_a,$num_b,$ch_x; $rv=' *Challenge:         '; //--> send return return $rv; } function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } //--> get excerpt from text string //-->@modified Aug 9, 2024 Added Strip HTML Tags function getExcerpt($raw_str, $startPos=0, $maxLength=100) { $str=strip_tags($raw_str); if(strlen($str) > $maxLength) { $excerpt = substr($str, $startPos, $maxLength-3); $lastSpace = strrpos($excerpt, ' '); //--> when no spaces in string if ($lastSpace == 0) $lastSpace=($maxLength-3); $excerpt = substr($excerpt, 0, $lastSpace); $excerpt .= '...'; } else { $excerpt = $str; } return $excerpt; } //--> fix height to 100 and preserve aspect ratio function fixedHeightImage($img_url,$target_height=100,$always_scale=1,$class='',$alt='') { //-->@filter file type, disallow php if( stristr($img_url,'.php') === false ) { global $site_url; $img_file=str_replace($site_url.'/','',$img_url); $path_parts=pathinfo($img_file); $img_path=$path_parts['dirname'].'/'.$path_parts['basename']; //--> get image size info //-->@refactor, made get image size silent (no warning) $img_info=@getimagesize($img_path); $w=$img_info[0]; $h=$img_info[1]; if($h == 0) { $asp_ratio=($target_height/100); } else { $asp_ratio=($target_height/$h); } // end if if($always_scale) { $width=round($w*$asp_ratio); $height=round($h*$asp_ratio); } else { //--> only scale if height is greater than target height if($h > $target_height) { $width=round($w*$asp_ratio); $height=round($h*$asp_ratio); } else { $width=$w; $height=$h; } // end if, is w > target_width } // end if, always_scale $img_tag='@refactor, when getimagesize returns false, return null if($img_info === false) $img_tag=''; //--> return image tag return $img_tag; } // end if, file type filter, disallow php //--> end function } //--> fix width to 100 and preserve aspect ratio function fixedWidthImage($img_url,$target_width=100,$always_scale=1,$class='',$alt='') { //-->@filter file type, disallow php if( stristr($img_url,'.php') === false ) { global $site_url; $img_file=str_replace($site_url.'/','',$img_url); $path_parts=pathinfo($img_file); $img_path=$path_parts['dirname'].'/'.$path_parts['basename']; //--> get image size info //-->@refactor, made get image size silent (no warning) $img_info=@getimagesize($img_path); $w=$img_info[0]; $h=$img_info[1]; if($w == 0) { $asp_ratio=($target_width/100); } else { $asp_ratio=($target_width/$w); } // end if if($always_scale) { $width=round($w*$asp_ratio); $height=round($h*$asp_ratio); } else { //--> only scale if width is greater than target width if($w > $target_width) { $width=round($w*$asp_ratio); $height=round($h*$asp_ratio); } else { $width=$w; $height=$h; } // end if, is w > target_width } // end if, always_scale $img_tag='@refactor, when getimagesize returns false, return null if($img_info === false) $img_tag=''; //--> return image tag return $img_tag; } // end if, file type filter, disallow php //--> end function } //--> replace macro tags, for settings from db function settings_macro_replace($str) { //--> global vars global $aset; //--> macros //--> comment style $str=str_replace('#sitename',$aset[SiteName],$str); $str=str_replace('#sitetitle',$aset[SiteTitle],$str); $str=str_replace('#siteslogan',$aset[SiteSlogan],$str); $str=str_replace('#siteurl',$aset[SiteURL],$str); $str=str_replace('#news',news_headlines_table(),$str); //--> send return return $str; } // Escape string for MySQL query function escape_string($string) { if (get_magic_quotes_gpc()) { $string = stripslashes($string); } if (function_exists("mysql_real_escape_string")) { $string = mysql_real_escape_string($string); } else { $string = addslashes($string); } return $string; } // String cleaning function, prevents mysql injection function clean($string) { $value = mysql_escape_string(stripslashes(htmlspecialchars($string))); return $value; } function CategorySelect($c) { $q1 = "select * from dd_categories order by CategoryName"; $r1 = mysql_query($q1) or die(mysql_error()); if(mysql_num_rows($r1) > '0') { $SelectCategory = "\n\n\n"; return $SelectCategory; } function CategoryTree($c) { //--> only show hidden # category to admin global $_SESSION; //-->@filter category Binary Options Signals $show_hidden_cats=($_SESSION[AdminID]) ? "WHERE (CategoryName NOT LIKE '%Binary Options Signals%')":"WHERE (CategoryName NOT LIKE '#%') && (CategoryName NOT LIKE '%Binary Options Signals%')"; $tree='