"; if (!isset($_SESSION)) { session_start(); } //print_r($_SESSION);exit; $_SESSION['tabs'] = 1; $request = $_SERVER['REQUEST_URI']; //echo $request."

";print_r($_SERVER);exit; /* if (!isset($_SESSION['GOOGLE_A_B_TEST'])) { // GOOGLE A/B? if (preg_match("@googabtest@", $request)) { $_SESSION['GOOGLE_A_B_TEST'] = true; } else { $_SESSION['GOOGLE_A_B_TEST'] = false; } }*/ $_SESSION['GOOGLE_A_B_TEST'] = false; /* if (!isset($_SESSION['include_google_experiment_code_in_header'])) { $_SESSION['include_google_experiment_code_in_header'] = false; } */ /* Google 'experiment': testing index.epl... any url with index2.epl and a pid in the required list(array) is in. the google experiment js needs to be included in the "original" page. That is and index2.epl page $_SESSION['include_google_experiment_code_in_header'] is set below to true only for index2.epl WITHOUT pfmt=2 so it gets included in whatever page comes next - but onlly once - the header scripts st it to false after using it once. Then, google might redirect to index2.epl but add pfmt=2 for the variation page. When that comes through you get $_SESSION['page_format'] = 2 below, and that enables showing format 2 pages (but only fo those which have a rpinter set up for format 2. */ if (preg_match("@^/omni@", $request)) { //echo $request;exit; switch ($request) { case "/omni": //echo "omni";exit; $_SESSION['add_omni_landing_code'] = $_SESSION['add_omni_conversion_code'] = 1; $_SESSION['omni_type'] = "non-OEM"; $_SESSION['omni_params'] = $params[1]; require "index_nav4.php"; exit; break; case "/omniOEM": ///echo "omniOEM";exit; $_SESSION['add_omniOEM_landing_code'] = $_SESSION['add_omni_conversion_code'] = 1; $_SESSION['omni_type'] = "OEM"; $_SESSION['omni_params'] = $params[1]; require "index_nav4.php"; exit; break; } } if (!isset($_SESSION['HTTP_REFERER']) && isset($_SERVER['HTTP_REFERER'])) { $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER']; if (empty($_SERVER['REQUEST_URI']) || ($_SERVER['REQUEST_URI']=='/')) { $_SESSION['REQUEST_URI'] = ''; } else { $_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI']; } if (strstr($_SERVER['HTTP_REFERER'],"https://www.google.com") && !empty($_SESSION['REQUEST_URI']) && !strstr($request,'.epl')) { //if (strstr($_SERVER['HTTP_REFERER'],"ww4.ocens.com") && !empty($_SESSION['REQUEST_URI']) && !strstr($request,'.epl')) { $_SESSION['promocode'] = "QQ9"; $_SESSION['referer'] = "GOOGLE_SEARCH:" . $request; setcookie("promocode", "QQ9", time()+60*60*24*2,'/'); } } if (($request!="/") && preg_match("@/$@", $request)) { //echo preg_replace("@/$@","", $request);exit; header('Location: ' . preg_replace("@/$@","", $request)); exit; } /* is this a redirect for 1306? 'ab1306=Ctrl' for control 'ab1306=A' for variant A 'ab1306=B' for variant D 'ab1306=D' for variant D if (($request!="/") && preg_match("@ab1306=(.*)\b@", $request, $matches) ) { $_SESSION['ab1306var']= $matches[1]; } */ // is there a PROMO CODE anywhere in the URL? if (($request!="/") && preg_match("@referer=(.*)\b@", $request, $matches) ) { $_SESSION['promocode']= $matches[1]; setcookie("promocode", $matches[1], time()+60*60*24*2,'/'); if (preg_match("@^/referer=@", $request)) { // // // // // // if the URL is inkfarm.com/referer=PROMOCODE relocate to index header('Location: /'); exit; } } // PARSE THE ERROR URL // // // // // // // // // // // // // // // // // // // // // // // // $params = explode("/",$request); //print_r($params);exit; if (isset($params[2]) && preg_match('/3D-Printer-Filament$/',$params[2])) { //print_r($params);exit; //list($in_mfg,$in_line,$in_model) = explode("-",$params[1]); //echo $params[1];exit; db_connect(); //legacy: "my history" may have urls with spaces //$sql_index_find_printer = "SELECT printerid,mfg,line,model,page_format FROM printers WHERE SEO_URL='".str_replace(" ","-",urldecode($params[1]."/".$params[2]))."'"; // the query above removed plus signs, so: $input_seo_url_non_decoded = str_replace(" ","-",$params[1]."/".$params[2]); $input_seo_url = str_replace(" ","-",urldecode($params[1]."/".$params[2])); $sql_index_find_printer = "SELECT printerid,mfg,line,model,page_format,SEO_URL FROM printers WHERE (SEO_URL='".$input_seo_url."') AND (Field6=1)"; // Field6 is show/hide //echo $sql_index_find_printer;exit; $result_index_find_printer = mysql_query($sql_index_find_printer) or die("Select Failed!
"); if (mysql_num_rows($result_index_find_printer) == 0) { require "error_404.php"; exit; } $rec_printer_SQL_index = mysql_fetch_assoc($result_index_find_printer); $in_mfg = $rec_printer_SQL_index['mfg']; $in_line = !empty($rec_printer_SQL_index['line']) ? $rec_printer_SQL_index['line'] : ''; // could be '0' in db $in_model = $rec_printer_SQL_index['model']; $in_pid = $rec_printer_SQL_index['printerid']; $in_page_format = $rec_printer_SQL_index['page_format']; $dbSEO_URL = $rec_printer_SQL_index['SEO_URL']; //echo "??:
$dbSEO_URL
$input_seo_url
$input_seo_url_non_decoded
";exit; if (($dbSEO_URL !== $input_seo_url)||($dbSEO_URL !== $input_seo_url_non_decoded)) { // some are coming in with lower-case in the URL //echo "redirect: $dbSEO_UR
";exit; header('Location: /' . $dbSEO_URL, true, 301); exit; } //echo "dbSEO_URL:".$dbSEO_URL."
input:".str_replace(" ","-",$params[1]."/".$params[2])."
==".($dbSEO_URL === $input_seo_url);exit; /* this was abandoned with the requirement that urls must deal with spaces in names without using '+' or "%10" if (strstr($params[1],"~") !== false) { $input_names = explode("~",$params[1]); $in_mfg = urldecode(array_shift($input_names)); $in_line = ""; $in_model = urldecode(implode("-",$input_names)); // some names have dashes in them... } else { $input_names = explode("-",$params[1]); $in_mfg = urldecode(array_shift($input_names)); if ($in_mfg == "Konica") { $junk = array_shift($input_names); $in_mfg = "Konica-Minolta"; } // is line blank? $in_model_test = urldecode(implode("-",$input_names)); if (is_printer_with_blank_model_name($in_mfg,$in_model_test)) { $in_line = ""; $in_model = $in_model_test; } else { $in_line = urldecode(array_shift($input_names)); $in_model = urldecode(implode("-",$input_names)); // some names have dashes in them... } } */ //print_r($params);echo "params1: ".$params[1]."
($in_mfg,$in_line,$in_model)
";//exit; send_OK_header(); /*if (isset($params[3]) && ($params[3] == 'nav4')) { $_SESSION['site_version'] = 4; } else if (isset($params[3]) && ($params[3] == 'nav3')) { $_SESSION['site_version'] = 3; }*/ require "cartridges_redesign.php";//"cartridges1006.php"; } else if (isset($params[1]) && preg_match('/.+-3d-printer-filaments/i',$params[1])) { //echo "c match params1: ".$params[1]."
";exit; //list($in_mfg,$in_line,$in_model) = explode("-",$params[1]); $input_names = explode("-",$params[1]); $manufacturer = urldecode(array_shift($input_names)); if ($manufacturer == "Z") { $zcorp = array_shift($input_names); if ($zcorp == 'Corp') { $manufacturer = "Z-Corp"; } } if (preg_match('/Konica|Minolta/',$manufacturer)) { $manufacturer = "Konica-Minolta"; } //print_r($params);print_r($input_names);echo "zcorp:$zcorp
";echo "manufacturer:$manufacturer
";exit; // is there junk at end of URL? /*if (!preg_match('/.+-3d-printer-filaments$/i',$params[1])) { preg_match('/^(.+-3d-printer-filaments)/i',$params[1],$matches); Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: ".$matches[1] ); exit; // EXIT POINT // }*/ //echo "params1: ".$params[1]."
($in_mfg,$in_line,$in_model)
";//exit; send_OK_header(); if (isset($params[2]) && ($params[2] == "classic")) { $classic = '1'; } //print_r($params);exit; if (strtolower($params[1]) == 'plastic-3d-printer-filaments') { unset($input_names);unset($manufacturer); if (strstr($params[2],"?")) { // google link... no file, just starts with '?' list($fn,$epl_params) = explode("?",$request); //echo "list($fn,$epl_params)
"; $eparams = explode("&",$epl_params); //echo "
eparams:
";print_r($eparams); foreach ($eparams AS $_eparam) { //echo "
eparam: ".$_eparam."
"; list($key,$val) = explode("=",$_eparam); //echo "list($key,$val)
"; $input[$key] = $val; //$_GET[$key] = $val; ${'rv_'.$key} = $val; } $PARSED_INPUT = true; } require "landing.php"; } else { require "printers_redesign.php"; } } else if (isset($params[1]) && preg_match('/.+-pixma-ink/',$params[1])) { //echo "c match params1: ".$params[1]."
";exit; //list($in_mfg,$in_line,$in_model) = explode("-",$params[1]); $input_names = explode("-",$params[1]); //print_r($params);exit; $manufacturer = urldecode(array_shift($input_names)); // is there junk at end of URL? if (!preg_match('/.+-pixma-ink$/',$params[1])) { preg_match('/^(.+-pixma-ink)/',$params[1],$matches); Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: ".$matches[1] ); exit; /************ EXIT POINT ********************/ } //echo "params1: ".$params[1]."
($in_mfg,$in_line,$in_model)
";//exit; send_OK_header(); $pixma = 1; require "printers_redesign.php"; } else { $test_param = preg_replace("/^\//","",$params[1]); $test_param = preg_replace("/\?.+$/","",$test_param); $test_param = strtolower($test_param); switch ($test_param) { case "shopping_cart": //http://www.inkfarm.com/products/printers.epl?mfg=Canon send_OK_header(); require "cart.php"; break; case "plastic3dprinterfilaments": send_OK_header(); require "landing.php"; break; case "coz": print_r($params); print_r($_SESSION); exit; break; case "affiliates": send_OK_header(); require "affiliates.php"; break; /*case "canon-printer-ink": //http://www.inkfarm.com/products/printers.epl?mfg=Canon $rv_mfg = 'Canon'; send_OK_header(); require "printers.php"; break;*/ case "index.php": header('Location: /'); exit; break; case "/": case "": case "index10.php": // ad referal URL send_OK_header(); //echo $_SESSION['index_page_version'];exit; $index_page_version = !empty($_SESSION['index_page_version']) ? $_SESSION['index_page_version'] : 'A'; switch ($index_page_version) { default: case 'A': require "index_nav4.php"; //"index_redesign.php";//"index1.php";//"index_general.php"; break; case 'B': require "index_redesign.php"; break; } break; case "index2.epl": /* if (preg_match("@pid=(\d{1,5})&@", $request, $matches)) { //echo $request;exit; require_once("_globals.php"); //send_email('cozmotionjazz@yahoo.com',"Mike",'test@inkfarm.com',"google test index - Zero","testing","body"); require_once "pids_for_a_b_test.php"; //echo $matches[1]."($ct)
"; if (!empty($matches[1]) && in_array($matches[1],$pids_for_test)) { //require_once("_globals.php"); //send_email('cozmotionjazz@yahoo.com',"Mike",'test@inkfarm.com',"google test index - 1","testing","body"); $_SESSION['ABtest'] = 1; setcookie("ABtest", 'ABtest', time()+60*60*24*2,'/'); if (preg_match("@pfmt=2@", $request)) { $_SESSION['page_format'] = 2; $_SESSION['suppress_AB_redirect'] = 3; setcookie("page_format", '2', time()+60*60*24*2,'/'); //$_SESSION['include_google_experiment_code_in_header'] = false; //send_email('cozmotionjazz@yahoo.com',"Mike",'test@inkfarm.com',"google test index - 2 - ".$_SERVER['REMOTE_ADDR'],"testing:".$request,$request); //echo "index22222222";exit; } else { $_SESSION['include_google_experiment_code_in_header'] = true; if (!isset($_SESSION['suppress_AB_redirect'])) { $_SESSION['suppress_AB_redirect'] = 1; } else { $_SESSION['suppress_AB_redirect']++; } //send_email('cozmotionjazz@yahoo.com',"Mike",'test@inkfarm.com',"google test index - set header ses var - ".$_SERVER['REMOTE_ADDR'],"testing:".$request,$request); } } } */ case "index5.epl": case "index7.epl": case "index9.epl": case "printerlanding.epl": //echo "
request:$request
"; list($fn,$epl_params) = explode("?",$request); //echo "list($fn,$epl_params)
"; $eparams = explode("&",$epl_params); //echo "
eparams:
";print_r($eparams); foreach ($eparams AS $_eparam) { //echo "
eparam: ".$_eparam."
"; list($key,$val) = explode("=",$_eparam); //echo "list($key,$val)
"; $input[$key] = $val; //$_GET[$key] = $val; ${'rv_'.$key} = $val; } //print_r($_GET);exit; //pid=4852&referer=QQ9ADWORDS8089&source=adwords&campaign=canon220/221s&adgroup=mp620&keyword={keyword}&ad={creative} //print_r($input);print_r($params);exit; $PARSED_INPUT = true; //echo "params[1]: ".$params[1]."
request: $request
test_param: $test_param
"; send_OK_header(); require "index2.php";//"index_general.php"; break; case "blog": send_OK_header(); unset($blogID); require "blog.php";//"index_general.php"; break; default: //Is this a blog URL? require_once "_globals.php"; db_connect(); $sql = "SELECT ID,title,url FROM blog3D"; $result = mysql_query($sql) or die("Select Failed!
$sql
"); while ($rec = mysql_fetch_array($result)) { //echo create_blog_URL($rec['title'])."
"; $real_blog_url = create_blog_URL($rec['url']); if ($test_param == strtolower($real_blog_url)) { if ($params[1] != $real_blog_url) { // URLs are coming from somewhere as al lowercase - redirect to the right ones for SEO header('Location: ' . $real_blog_url, true, 301); exit; } //echo $params[1]."
";echo $test_param;echo "
";echo $real_blog_url;echo "
";echo ($test_param == $real_blog_url)?'y':'n';//exit; send_OK_header(); $blog_url = $test_param; $blogID = $rec['ID']; require "blog.php";//"index_general.php"; exit; break; } else { //echo "not matched: ".$test_param."
"; } } //Is this a blog-category URL? $sql = "SELECT ID,cat_name FROM blog_categories3D WHERE online=1"; $result = mysql_query($sql) or die("Select Failed!
$sql
"); while ($rec = mysql_fetch_array($result)) { //echo create_blog_URL($rec['title'])."
"; if ($test_param == strtolower(create_blog_URL($rec['cat_name']))) { send_OK_header(); $blog_url = $test_param; $blog_catID = $rec['ID']; require "blog.php"; exit; break; } else { //echo "not matched: ".$test_param."
"; } } // REALLY NO SUCH PAGE... //echo "really not found - 404
params[1]: ".$params[1]."
request: $request
test_param: $test_param
"; //$missing_URL = $params[1]; $missing_URL = $request; require "error_404.php"; break; } } ////////////////////////////////////////////////////////////////////////////////// function send_OK_header() { Header("HTTP/1.1 301 Moved Permanently" ); header('HTTP/1.1 200 OK'); } function send_redir_header($loc) { Header("HTTP/1.1 301 Moved Permanently" ); header("Location: ".$loc); } function is_printer_with_blank_model_name($mfg,$model) { require_once("_globals.php"); db_connect(); $sql = "SELECT printerid FROM printers WHERE ((printers.line='0' OR printers.line='' OR printers.line IS NULL) AND printers.mfg='".$mfg."' AND printers.model='".urldecode($model)."')"; //echo $sql; $result = mysql_query($sql) or die("Select Failed!
"); return mysql_num_rows($result) > 0; } /* http://www.inkfarm.com/canon-MultiPASS-mp370/ink-cartridge (for inkjet printers) http://www.inkfarm.com/HP-Laserjet-P2015d/toner-cartridge (for laser printers) */ ?>