<?php

#######################################################
# SETTINGS - you can modify these setting to your needs

$mode = 'standard'; # please select mode: standard, fopen, curl, iframe
$frame_height = 1400; # applied to iframe type only

#######################################################
# SPORTSCAPPING content STARTS here
# Do not modify unless you 100% about what you're doing

$sportscapping_site_path = 'https://www.sportscapping.com/';
$your_partner_code = 'AF111_140';
$params_string = getenv('QUERY_STRING');
$params_array = explode('/', $params_string);

if (is_array($params_array))
foreach ($params_array as $one_param) {
unset($temp_params_array);
$temp_params_array = explode(',', $one_param);
$named_param[$temp_params_array[0]] = $temp_params_array[1];
}

if (!$params_array[0]) $params_array[0] = 'premium_picks';

if($params_array[0] != 'registration_module')
{
$current_url = curPageURL();
$user_reg_text = file_get_contents($sportscapping_site_path . '/new/export/?'.$your_partner_code.'/export/aff_user_reg_text');
if(!$user_reg_text)
{
$user_reg_link .= '<p><div class="aff_user_reg_link" align="center"><a href="'.$current_url.'?registration_module/'.$your_partner_code.'/">Register</a> for an Account Now for Free Picks and More Special Offers!</div></p>';
}
else
{
$link_start = '<a href="'.$current_url.'?registration_module/'.$your_partner_code.'/">';
$link_end = '</a>';
$user_reg_text = preg_replace('/%%/', $link_start, $user_reg_text,1);
$user_reg_text = preg_replace('/%%/', $link_end, $user_reg_text,1);
$user_reg_link .= '<p><div class="aff_user_reg_link" align="center">'.$user_reg_text.'</div></p>';
}
}
if ($params_array[0] == 'trends') {
$url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/trends';
$url .= ($params_array[2])? '/'.$params_array[2]:'';
$url .= ($params_array[4])? '/'.$params_array[4]:'';
$url .= ($params_array[6])? '/'.$params_array[6]:'';
$url .= ($params_array[8])? '/'.$params_array[8]:'';
$url .= ($params_array[10])? '/'.$params_array[10]:'';
$url .= ($params_array[12])? '/'.$params_array[12]:'';
}
if ($params_array[0] == 'schedule') {
$url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/schedule';
if($named_param['league_id']!='') {
$url .= '/league_id,'.$named_param['league_id'];
}
if($named_param['event_date']!='') {
$url .= '/event_date,'.$named_param['event_date'];
}
if($named_param['game_id']!='') {
$url .= '/game_id,'.$named_param['game_id'];
}
if($named_param['picks_type']!='') {
$url .= '/picks_type,'.$named_param['picks_type'];
}

}
if ($params_array[0] == 'premium_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/premium_picks/menu/' . $named_param['leg'] . '/' . $params_array[1];
if ($params_array[0] == 'free_picks')
{
$url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/free_picks';
$url .= ($params_array[2])? '/'.$params_array[2]:'';
}
if ($params_array[0] == 'leaderboard') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/leaderboard/menu/20/' . $named_param['leg'];
if ($params_array[0] == 'capper') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/capper/' . $params_array[2] . '/overall';
if ($params_array[0] == 'top_trends') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_trends/menu/' . $named_param['leg'] . '/10';
if ($params_array[0] == 'top_cappers') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/top_cappers/full/menu/' . $named_param['leg'];
if ($params_array[0] == 'registration_module') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/export/registration_module/';

if ( $mode == 'standard' ) echo $user_reg_link.file_get_contents( $url );
if ( $mode == 'fopen' ) echo $user_reg_link.get_file( $url );
if ( $mode == 'curl' ) echo $user_reg_link.get_file_curl( $url );

if ( $mode == 'iframe' )
{
if ($params_array[0] == 'schedule') {
$url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/schedule';
if($named_param['league_id']!='') {
$url .= '/league_id,'.$named_param['league_id'];
}
if($named_param['event_date']!='') {
$url .= '/event_date,'.$named_param['event_date'];
}
if($named_param['game_id']!='') {
$url .= '/game_id,'.$named_param['game_id'];
}
if($named_param['picks_type']!='') {
$url .= '/picks_type,'.$named_param['picks_type'];
}

}

if ($params_array[0] == 'premium_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/premium_picks/menu/' . $named_param['leg'] . '/' . $params_array[1];
if ($params_array[0] == 'free_picks') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/free_picks';
if ($params_array[0] == 'leaderboard') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/leaderboard/menu/5/' . $named_param['leg'];
if ($params_array[0] == 'capper') $url = $sportscapping_site_path . '/new/export/?' . $params_array[4] . '/iframe/capper/' . $params_array[2] . '/overall';
if ($params_array[0] == 'top_trends') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/top_trends/menu/' . $named_param['leg'] . '/10';
if ($params_array[0] == 'top_cappers') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/top_cappers/full/menu/' . $named_param['leg'];
if ($params_array[0] == 'registration_module') $url = $sportscapping_site_path . '/new/export/?' . $your_partner_code . '/iframe/registration_module/';

echo
'<script language="javascript" type="text/javascript">

function iFrameHeight() {
var h = 0;
if ( !document.all ) {
h = document.getElementById(\'blockrandom\').contentDocument.height;
document.getElementById(\'blockrandom\').style.height = h + 60 + \'px\';
} else if( document.all ) {
h = document.frames(\'blockrandom\').document.body.scrollHeight;
document.all.blockrandom.style.height = h + 20 + \'px\';
}
}
</script>
'.$user_reg_link.'
<iframe onload="iFrameHeight()" id="blockrandom" name="iframe" src="' . $url . '" width="100%" height="' . $frame_height . '" scrolling="auto" align="top" frameborder="0" class="wrapper">This option will not work correctly. Unfortunately, your browser does not support Inline Frames</iframe>';
}

function get_file_curl($url)
{
$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)';

# start CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // base page
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); // user agent
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return result to variable
# get actual result to variable
$content = curl_exec ($ch);
# close CURL
curl_close ($ch);

return $content;
}

function get_file($url)
{
$data = fopen($url,"rb");
$content = '';
if ($data)
{
while (!feof($data))
{
$content .= @fread($data, 100000);
}
@fclose($data);
}
return($content);
}

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["PHP_SELF"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["PHP_SELF"];
}
return $pageURL;
}

# SPORTSCAPPING content ENDS here
##################################################

?>