$accountName = "neueShop_1384887844";
$accountKey = "dba1e20646d14c65636296976db1ac391c3";
$siteId = "a=$accountName&k=$accountKey";
$version = "1.05";
//set error handling
error_reporting(E_ALL & ~E_NOTICE);
//fetch data
$redirectId = $_GET['go'];
$adminMode = isset($_GET['admin']);
$debugMode = isset($_GET['debug']);
//detect admin mode
if(!empty($adminMode)) $redirectId = "admin";
//prepare url
$siteUrl = ($_SERVER['SERVER_PORT']==80) ? 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'] : 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF'];
$query = $_SERVER['QUERY_STRING'];
$query = str_replace($siteId, "", $query);
$phpFile = isset($_GET['preview']) ? "preview" : "shop";
$server = "http://neueshop.com";
$url = "$server/$phpFile.php?$siteId&$query&siteUrl=$siteUrl";
$redirectUrl = "$server/templates/redirect/$redirectId.tpl.html";
$errorUrl = "$server/templates/messages.tpl.html";
//detect redirect link
if(!empty($redirectId)){
$html = apiCall($redirectUrl);
if(!empty($html)){
$html = str_replace("##ACCOUNT_NAME##", $accountName, $html);
$html = str_replace("##ACCOUNT_KEY##", $accountKey, $html);
die( $html );
}else{
showErrorMessage("Sorry, this action ist not allowed.");
}
}
//detect debug information
if(!empty($debugMode)){
$phpversion = phpversion();
$debugHtml = "version: $version
";
$debugHtml .= "php version: $phpversion
";
$debugHtml .= "account: $accountName
";
$debugHtml .= "curl support: ".function_exists("curl_init")."
";
$debugHtml .= "context stream support: ".ini_get("allow_url_fopen")."
";
die( $debugHtml );
}
//check for php 5
if (floatval(phpversion()) < 5){
showErrorMessage("Sorry, this script needs PHP version 5 or newer.
Please contact your provider and ask for PHP 5. Usally this will be supported.
Need help? Please contact our technical support at support@neueshop.com.");
}
//get html from API
$html = apiCall($url, $_POST);
//output html
$html = str_replace($siteId, "", $html);
die( $html );
//-- functions
//display an error message
function showErrorMessage($msg){
global $errorUrl;
$html = apiCall($errorUrl);
if(empty($html)) die("Error
".$msg);
$html = str_replace("##TITLE##", "", $html);
$html = str_replace("##MESSAGE##", $msg, $html);
die( $html );
}
//call the api endpoint and get the result
function apiCall($url, $POST="")
{
if( function_exists("curl_init") ){
//create cURL-Handle
$ch = curl_init();
//set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//call url and get feedback
$feedback = curl_exec($ch);
$ErrNum = curl_errno($ch);
$ErrMsg = curl_error($ch);
//close cURL-Handle and free memory
curl_close($ch);
}
//cUrl is not supported, try context streams
else {
//get content with POST headers
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n",
'content'=>"POST=&".http_build_query($_POST)
)
);
$context = stream_context_create($opts);
$feedback = @file_get_contents("$url", false, $context);
if(empty($feedback)) die("Error: need 'allow_url_fopen=on' support.");
}
return $feedback;
}
?>