/*************************************************************************
* *
* WebReflow - Website Statistik and Tracking Tool *
* ---------------------------------------------------------------- *
* *
* File: counter.php *
* Copyright: (C) 2004 Visolon GmbH *
* EMail: service@webreflow.com *
* Web: http://www.webreflow.com *
* Scriptversion: 1.2.4 *
* *
**************************************************************************
* *
* You don't need to edit anything in this script. *
* *
* This script is NOT freeware! Please read the Copyright Notice *
* (licence.txt) for further information. *
* *
*************************************************************************/
if(!defined('WRF_DIR')){
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR .'inc' . DIRECTORY_SEPARATOR . 'common_s.inc.php');
}
require_once(WRF_DIR . 'classes' . DIR_SEP . 'counter.class.php');
require_once(WRF_DIR . 'classes' . DIR_SEP . 'common2.class.php');
require_once(WRF_DIR . 'classes' . DIR_SEP . 'text_loader.class.php');
$TextLoader = new TextLoader();
class WebReflow
{
var $co = null;
var $ja = null;
var $re = null;
var $cd = null;
var $wi = null;
var $js = null;
var $pn = null;
var $pu = null;
var $al = null;
var $ct = null;
var $it = null;
var $page_name_server = null;
var $page_name_client = null;
var $form_name = null;
var $submit_func = null;
var $reset_func = null;
var $count_id = null;
function WebReflow($page_name, $form_name="", $submit_func="")
{
$this->re = $_SERVER['HTTP_REFERER'];
$this->ct = time();
$this->it = 0;
if(!empty($page_name)){
$this->page_name_server = $page_name;
$this->page_name_client = $page_name;
}
else {
$arr_filename = preg_split('!/!',str_replace('//','/', str_replace('\\','/', Common2::envVars('SCRIPT_NAME'))));
if(count($arr_filename) > 0)
{
$this->page_name_server = $arr_filename[count($arr_filename) - 1];
}
else
{
$this->page_name_server = Common2::envVars('SCRIPT_NAME');
}
}
$this->form_name = $form_name;
$this->submit_func = $submit_func;
$this->reset_func = "null";
}
function write_integration_code()
{
$Database = new Database();
$Database->open();
if($Database->table_exists("_servercount") != true){
$this->create_table_servercount();
}
$Counter = new Counter($this->co, $this->ja, $this->re, $this->cd, $this->wi, $this->js, $this->page_name_server, $this->pu, $this->al, $this->ct, $this->it);
switch ($Counter->check_ip_hash())
{
case 0: //new count
{
$Counter->insert_count();
$Counter->insert_tracking($Counter->count_id);
if(!empty($Counter->count_id)){
$this->count_id = $Counter->count_id;
$sql_query = "INSERT INTO `" . $Database->tabprefix . "_servercount` ( `count_id`,`count_time` ) VALUES ('" . $this->count_id . "','" . time() . "')";
$Database->query($sql_query);
}
break;
}
case 1: //counted->insert tracking or formular
{
$Counter->insert_viewTime($Counter->count_id);
$Counter->insert_tracking($Counter->count_id);
$this->count_id = $Counter->count_id;
break;
}
case 2: // IP is on IP-Lock Table
{
// do nothing ...
break;
}
}
$this->write_new_configfile();
echo $this->integration_code();
}
function write_integration_code_q()
{
$Database = new Database();
$Database->open();
if($Database->table_exists("_servercount") != true){
$this->create_table_servercount();
}
$Counter = new Counter($this->co, $this->ja, $this->re, $this->cd, $this->wi, $this->js, $this->page_name_server, $this->pu, $this->al, $this->ct, $this->it);
switch ($Counter->check_ip_hash())
{
case 0: //new count
{
$Counter->insert_count();
$Counter->insert_tracking($Counter->count_id);
if(!empty($Counter->count_id)){
$this->count_id = $Counter->count_id;
$sql_query = "INSERT INTO `" . $Database->tabprefix . "_servercount` ( `count_id`,`count_time` ) VALUES ('" . $this->count_id . "','" . time() . "')";
$Database->query($sql_query);
}
break;
}
case 1: //counted->insert tracking or formular
{
$Counter->insert_viewTime($Counter->count_id);
$Counter->insert_tracking($Counter->count_id);
$this->count_id = $Counter->count_id;
break;
}
case 2: // IP is on IP-Lock Table
{
// do nothing ...
break;
}
}
$this->write_new_configfile();
}
function create_table_servercount()
{
$Database = new Database();
$Database->open();
$sql_query = "CREATE TABLE IF NOT EXISTS `" . $Database->tabprefix . "_servercount` (".
"`count_id` int(11) unsigned NOT NULL default '0',".
"`count_time` int(11) unsigned NOT NULL default '0',".
" PRIMARY KEY (`count_id`))";
$Database->query($sql_query);
}
function integration_code()
{
if($this->page_name_client==""){
$this->page_name_client="null";
$this->page_name_noscript = "";
}
else{
$this->page_name_client="\"" .str_replace("\"","",$this->page_name_client). "\"";
$this->page_name_noscript = urlencode(str_replace("\"","",$this->page_name_client));
}
if($this->form_name==""){
$this->form_name="null";
}
else{
$this->form_name = "\"" . str_replace("\"","",$this->form_name) . "\"";
}
preg_match('/(^[_a-zA-Z]{1}[_a-zA-Z0-9]*(\(.*\)){0,1})\;{0,1}/', $this->submit_func, $m);
if(empty($m)){
$this->submit_func="null";
}
else{
if(!empty($m[2])){
$this->submit_func=$m[1];
$this->submit_func = "\"" . str_replace("\"","'",$this->submit_func) . "\"";
}
else if(!empty($m[1])){
$this->submit_func=$m[1]+"\(\)";
$this->submit_func = "\"" . str_replace("\"","'",$this->submit_func) . "\"";
}
else{
$this->submit_func="null";
}
}
global $ConfigFile;
global $TextLoader;
return
"\n" .
"\n" .
"\n" .
"\n";
}
function write_new_configfile()
{
if(!file_exists(WRF_DIR . 'application_data' . DIR_SEP . 'configs' . DIR_SEP . 'vc_include_124.js')){
global $ConfigFile;
global $TextLoader;
$handle = fopen(WRF_DIR . 'application_data' . DIR_SEP . 'configs' . DIR_SEP . 'vc_include_124.js', "wb");
if ($handle){
$vc_include =
"/*************************************************************************\n" .
"* WebReflow *\n" .
"* Copyright: (C) 2002 - 2005 Visolon GmbH *\n" .
"* Web: http://www.visolon.com/".$ConfigFile->language." *\n" .
"* Scriptversion: ".$ConfigFile->version." *\n" .
"**************************************************************************\n" .
"* This script is NOT freeware! Please read the Copyright Notice *\n" .
"* (licence.txt) for further information. *\n" .
"*************************************************************************/\n\n\n".
"function getUrlValue(queryvar, value)\n" .
"{\n" .
"\turlText=location.search;\n" .
"\tfc=urlText.slice(0,1);\n" .
"\tif(fc==\"?\")\n" .
"\t{\n" .
"\t\tl=urlText.length;\n" .
"\t\turlText=urlText.slice(1,l);\n" .
"\t\tArgSet=urlText.split(\"&\");\n" .
"\t\tfor(i=0;ipath_url . $ConfigFile->app_dir . "/counter.php?co=\"+cookie+\"&ja=\"+java+\"&re=\"+referrer+\"&pn=\"+store_var+\"&pu=\"+page_url+\"&wi=\"+width+\"&cd=\"+color_depth+\"&js=1\"+\"&al=\"+agent_language+\"&ct=\"+form_time+\"&it=1\";\n" .
"\treturn true;\n" .
"}\n" .
"\n" .
"\n" .
"function checkInputSubmit()\n" .
"{\n" .
"\tif(flag == false)\n" .
"\t{\t\t\n" .
"\t\tif(fs_func)\n" .
"\t\t{\n" .
"\t\t\teval(\"func_s_val = \" + fs_func);\n" .
"\t\t}\n" .
"\t\tif(func_s_val==true)\n" .
"\t\t{\n" .
"\t\t\treadFormEl(\"true\");\n" .
"\t\t\tcheckFormImg(true,0);\n" .
"\t\t}\n" .
"\t\treturn false;\n" .
"\t}\n" .
"\telse\n" .
"\t{\n" .
"\t\tflag = false;\n" .
"\t\tpuffer = new Image();\n" .
"\t\treturn true;\n" .
"\t}\n" .
"}\n" .
"\n" .
"\n" .
"function checkFormImg(do_submit, time_run) \n" .
"{\n" .
"\t_do_submit = do_submit;\n" .
"\tif(!puffer.complete && time_run < 1250) \n" .
"\t{\n" .
"\t\t_time_run = time_run + 50;\n" .
"\t\tsetTimeout(\"checkFormImg(_do_submit, _time_run)\", 50);\n" .
"\t}\n" .
"\telse\n" .
"\t{\n" .
"\t\tflag = true;\n" .
"\t\tif(_do_submit == true)\n" .
"\t\t{\n" .
"\t\t\tdocument.forms[f_index].submit();\n" .
"\t\t}\n" .
"\t\telse\n" .
"\t\t{\n" .
"\t\t\tdocument.forms[f_index].reset();\n" .
"\t\t}\n" .
"\t}\n" .
"}\n" .
"\n" .
"\n" .
"function compEncode(url)\n" .
"{\n" .
"\t_url = escape(url);\n" .
"\t_url = _url.replace(/\//g,\"%2F\");\n" .
"\t_url = _url.replace(/@/g,\"%40\");\n" .
"\t_url = _url.replace(/\+/g,\"%2B\");\n" .
"\treturn _url;\n" .
"}\n" .
"\n" .
"\n" .
"function getCookie(name)\n" .
"{\n" .
"\tvar i=0;\n" .
"\tvar suche = name+\"=\";\n" .
"\twhile (i-1) ? ende : document.cookie.length;\n" .
"\t\t\tvar cook = document.cookie.substring(i+suche.length, ende);\n" .
"\t\t\treturn unescape(cook);\n" .
"\t\t}\n" .
"\t\ti++;\n" .
"\t}\n" .
"\treturn null;\n" .
"}\n" .
"\n" .
"\n" .
"function timeout() \n" .
"{\n" .
"\tsetTimeout(\"checkImage()\", 1250);\n" .
"}\n" .
"\n" .
"\n" .
"function checkImage() \n" .
"{\n" .
"\tif(!document.images['WebReflow'].complete) \n" .
"\t{\n" .
"\t\tdocument.images['WebReflow'].src = \"" . $ConfigFile->path_url . $ConfigFile->app_dir . "/pics/transparent.gif\";\n" .
"\t}\n" .
"}\n" .
"\n" .
"\n" .
"function pr(nc,server_count) \n" .
"{\n" .
"\tdocument.write(\"
\");\n" .
"}\n" .
"\n" .
"\n" .
"function vc_go(_page_name, form_name, submit_func, reset_func, server_count)\n" .
"{\n" .
"\tif(!getCookie(\"webreflow\") && !getUrlValue(\"webreflow\",\"nocount\"))\n" .
"\t{\n" .
"\t\tif(_page_name)\n" .
"\t\t{\n" .
"\t\t\tpage_name=compEncode(_page_name);\n" .
"\t\t}\n" .
"\t\telse\n" .
"\t\t{\t\n" .
"\t\t\tif(document.title)\n" .
"\t\t\t\tpage_name=document.title;\n" .
"\t\t\telse\n" .
"\t\t\t\tpage_name=\"\";\n" .
"\t\t}\n" .
"\t\t\t\t\n" .
"\t\tif(document.forms[form_name] && form_name) \n" .
"\t\t{\t\t\n" .
"\t\t\tfs_func = submit_func;\n" .
"\t\t\tf_index=form_name;\n" .
"\t\t\tdocument.forms[form_name].onsubmit = checkInputSubmit;\n" .
"\t\t}\t\n" .
"\t\tpr(0,server_count?server_count:0);\n" .
"\t\ttimeout();\n" .
"\t}\n" .
"\telse\n" .
"\t{\n" .
"\t\tif(document.forms[form_name] && form_name) \n" .
"\t\t{\n" .
"\t\t\tfs_func = submit_func;\n" .
"\t\t\tf_index=form_name;\n" .
"\t\t\tdocument.forms[form_name].onsubmit = function()\n" .
"\t\t\t{\n" .
"\t\t\t\tif(fs_func)\t{\n" .
"\t\t\t\t\teval(\"func_s_val = \" + fs_func);\n" .
"\t\t\t\t}\n" .
"\t\t\t\tif(func_s_val==true) {\n" .
"\t\t\t\t\treturn true;\n" .
"\t\t\t\t}else {\n" .
"\t\t\t\t\treturn false;\n" .
"\t\t\t\t}\n" .
"\t\t\t};\n" .
"\t\t}\n".
"\t\tpr(1,server_count?server_count:0);\n" .
"\t\ttimeout();\n" .
"\t}\n" .
"}\n" .
"\n" .
"\n" .
"var f_index = \"\";\n" .
"var fs_func = null;\n" .
"var fr_func = null;\n" .
"var func_s_val = true;\n" .
"var func_r_val = true;\n" .
"var store_var = \"\";\n" .
"var flag = false;\n" .
"var puffer = new Image();\n" .
"\n" .
"var cookie=\"2\";\n" .
"var java=\"2\";\n" .
"var referrer=\"\";\n" .
"var width=\"\";\n" .
"var color_depth=\"\";\n" .
"var agent_language=\"\";\n" .
"var page_name=\"\";\n" .
"var page_url=\"\";\n" .
"\n" .
"var now = new Date();\n" .
"var client_time = Math.round(now.getTime()/1000);\n" .
"\n" .
"if(navigator.cookieEnabled == true)\n" .
"\tcookie=\"1\";\n" .
"else if(navigator.cookieEnabled == false) \n" .
"\tcookie=\"0\";\n" .
"else \n" .
"\tcookie=\"2\";\n" .
"\n" .
"if(navigator.javaEnabled() == true)\n" .
"\tjava=\"1\";\n" .
"else if(navigator.javaEnabled() == false)\n" .
"\tjava=\"0\"\n" .
"else\n" .
"\tjava=\"2\"\n" .
"\t\n" .
"if(document.referrer)\n" .
"\treferrer = compEncode(document.referrer);\n" .
"\t\n" .
"if ((screen.width) && (screen.height))\n" .
"\twidth = screen.width + \"x\" + screen.height;\n" .
"\t\n" .
"if(screen.colorDepth)\n" .
"\tcolor_depth = screen.colorDepth;\n" .
"\n" .
"if(navigator.language)\n" .
"\t agent_language = navigator.language;\n" .
"else if(navigator.userLanguage)\n" .
"\t agent_language = navigator.userLanguage;\n\n" .
"if(window.location.href)\n" .
"\t page_url = compEncode(window.location.href);";
fputs($handle, $vc_include);
fclose($handle);
}
}
}
}
?>