Page 1 of 2

PHP Fatal error: Cannot redeclare cjoverkill -- SOLVED --

Posted: Sat Jan 14, 2006 2:10 pm
by robinbos
Hi,

I have a huge problem with cj overkill (see topic off blank pages). I have installed the script on 8 sites and they all have the same problem.

The script is working but when visitors click on a link they wil see a blank page instead of my gallerie or trade...its not always but 1 on 4 !!

I have allready asked for help at the plesk forum, my hosting, other fora and the psa support team and they all said it is a cj overkill problem with php.

the error message is :

Code: Select all

PHP Fatal error: Cannot redeclare cjoverkill_connect() (previously declared in /var/www/vhosts/smatjes.com/httpdocs/cj-functions.inc.php:13) in /var/www/vhosts/smatjes.com/httpdocs/cj-functions.inc.php on line 12, referer: www.smatjes.com
so it says it cant make/include cj overkill_connect AGAIN !!! How is that possible ??

Ive checked for the cj overkill_connect tag in de script but in every file it only appears once or none and its written like this : cjoverkill_connect();

the problem allready starts showing up when installing the script. first you wil see a blank page and after refreshing a couple of times the page shows up and i can begin to install the script..

example : http://www.smatjes.com/cjadmin/

try to open that link and refresh it multiple times...ypu see the page is not loading correctly !!

example 2 : http://www.smatjes.com

visit the site en try to open one of the galleries...a lot of times the pages doesnt open and you will see a blank page. and again when you refresh the page works....

In my shtml sites their are only two things i have to include :

- <!--#include file="cookie.php" -->
- <!--#include virtual="/toplist/template27.html" -->

ive also tried to change them to "include_once file" but that didnt work because it kills the script.


This i have tried so far :

- checked my server (my hosting said it is not possible that that is causing the error
- replaced al "inlclude" tags with include_once and/or require_once
- installed all the files again en reinstalled the script multiple times
- checked my .htacces and apache settings
- asked for help and psa, fora, my hosting, php programmers etc
- also tried to install a other script but also then i had the same problem

but all of that did not work...im really hopeless at the moment because its killing my sites.


Can someone please please please help me !!!!!!!!!!!!

regards

Robin

Posted: Sat Jan 14, 2006 2:17 pm
by robinbos
Sometimes it also gives this strange but simular error :

Code: Select all

[Sat Jan 14 20:45:46 2006] [error] [client 145.53.126.110] PHP Fatal error: Cannot redeclare cjoverkill_connect() (previously declared in /var/www/vhosts/beastworld.nl/httpdocs/cj-functions.inc.php:13) in /var/www/vhosts/smatjes.com/httpdocs/cj-functions.inc.php on line 12, referer: http://www.smatjes.com
it says that they can not redeclare cjoverkill_connect because its previously declared at beastworld.nl.

Beastworld.nl is also my site but how is it possible that that is named in a server error from the site smatjes.com ????

Posted: Sat Jan 14, 2006 2:27 pm
by Gambler
Try conditional function declaration. It's a hack, but it's easier to do that, than debug the whole system.

Code: Select all

if (!defined(CJOVERKILL_CREATED)) {
define(CJOVERKILL_CREATED, TRUE);
function cjoverkill_connect(){
//...
}

}

Posted: Sat Jan 14, 2006 2:49 pm
by robinbos
do i have to replace all cjoverkill_connect(); tags with this code or just at the beginning of the script ??

Posted: Sat Jan 14, 2006 2:52 pm
by robinbos
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


here is an example of a part of the script which contains the cjoverkill_connect tag :

http://www.smatjes.com/trade.php (save target as)

this is the code of it :

Code: Select all

<?php

/******************************************************
 * CjOverkill version 3.0.1
 * © Kaloyan Olegov Georgiev
 * http://www.icefire.org/
 * spam@icefire.org
 * 
 * Please read the lisence before you start editing this script.
 * 
********************************************************/

require_once ("cj-conf.inc.php");
require_once ("cj-functions.inc.php");  
cjoverkill_connect();

$maxstr=250;
$maxicq=50;

$stime=localtime();
$thishour=$stime[2];

$sql=@mysql_query("SELECT * FROM cjoverkill_settings") OR 
  cjoverkill_db_error(mysql_error());
$tmp=@mysql_fetch_array($sql);
extract($tmp);

$added="N";

if ($_POST["add"]!="" && $signup!=0) {
    if ($_POST["url"]=="") { 
	$tms[]="Enter an URL to trade with"; 
    }
    if ($_POST["email"]=="") { 
	$tms[]="Enter an email address"; 
    }
    else {
	$tmp_url=cjoverkill_sanityze($_POST["url"]);
	$tmp_email=cjoverkill_sanityze($_POST["email"]);
	$tmp_icq=cjoverkill_sanityze($_POST["icq"]);
	$tmp_name=cjoverkill_sanityze($_POST["site_name"]);
	$tmp_desc=cjoverkill_sanityze($_POST["site_desc"]);
	$tmp_passwd=cjoverkill_sanityze($_POST["pass"]);
	if (strlen($tmp_icq)>$maxicq || strlen($tmp_url)>$maxstr || 
	    strlen($tmp_email)>$maxstr || strlen($tmp_name)>$maxstr || 
	    strlen($tmp_desc)>$maxstr || strlen($tmp_pass)>maxstr){
	    if ($_SERVER["HTTP_X_FORWARDED_FOR"]){
		$proxy=cjoverkill_sanityze($_SERVER["REMOTE_ADDR"]);
		$ip=cjoverkill_sanityze($_SERVER["HTTP_X_FORWARDED_FOR"]);
	    }
	    else {
		$ip=cjoverkill_sanityze($_SERVER["REMOTE_ADDR"]);
		$proxy="";
	    }
	    $what="Possible overflow attempt on webmaster signup page";
	    @mysql_query("INSERT INTO cjoverkill_security (fecha,what,ip,proxy,hour) 
	      VALUES (NOW(), '$what', '$ip', '$proxy', '$thishour')") OR
	      cjoverkill_db_error(mysql_error());
	    cjoverkill_disconnect();
	    cjoverkill_print_error("Your values appear to be too long<BR>
			  Are you trying to hack me duhdah?
			  ");
	}
	$tmp_uri= parse_url($tmp_url);
	$domain=str_replace("www.","",$tmp_uri["host"]);
	$url="http://".$tmp_uri["host"].$tmp_uri["path"];
	if ($tmp_uri["query"]!=""){
	    $url=$url."?".$tmp_uri["query"];
	}
	if ($_POST["url"]!=$url || $domain == "") {
	    $tms[]="$_POST[url] is not valid url";
	}
	$sql=@mysql_query("SELECT domain FROM cjoverkill_blacklist WHERE 
			    domain='$domain' OR 
			    email='$tmp_email' OR 
			    icq='$tmp_icq'") OR
	  cjoverkill_db_error(mysql_error());
	if (mysql_num_rows($sql)>0) { 
	    cjoverkill_print_error("You are blacklisted on this site !!!"); 
	}
	$sql=@mysql_query("SELECT domain FROM cjoverkill_trades WHERE domain='$domain'") OR 
	  cjoverkill_db_error(mysql_error());
	if (mysql_num_rows($sql)>0) { 
	    $tms[]="This site already exists in the trading database"; 
	}
	if (!isset($tms)) {
	    if ($signup==2){
		$signup=0;
	    }
	    if ($tmp_passwd==""){
		$tmp_passwd="NNN";
	    }
	    @mysql_query("INSERT INTO cjoverkill_trades 
			   (domain, url, site_name, site_desc, email, icq, return, min_p, max_p, max_px, max_clicks,
			    max_ip, status, passwd, max_ret, signed, last_visit) VALUES 
			   ('$domain', '$url', '$tmp_name', '$tmp_desc', '$tmp_email', '$tmp_icq', '$return',
			    '$min_p', '$max_p', '$max_px', '$max_clicks', '$max_ip', '$signup', '$tmp_passwd', 
			    '$max_ret', NOW(), NOW())") OR
	      cjoverkill_db_error(mysql_error());
	    @mysql_query("INSERT INTO cjoverkill_stats (trade_id) VALUES (LAST_INSERT_ID())") OR 
	      cjoverkill_db_error(mysql_error());
	    @mysql_query("INSERT INTO cjoverkill_forces (trade_id) VALUES (LAST_INSERT_ID())") OR 
	      cjoverkill_db_error(mysql_error());
	    $sql5=@mysql_query("SELECT trade_id FROM cjoverkill_trades WHERE domain='$domain'") OR
	      cjoverkill_db_error(mysql_error());
	    $tmp5=@mysql_fetch_array($sql5);
	    extract($tmp5);
	    $added="Y";
	}
    }
}

cjoverkill_disconnect();

echo ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
	<html>
	<head>
	<title>$cjoverkill_version</title>
	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
	<link href=\"cj-style.css\" rel=\"stylesheet\" type=\"text/css\">
	</head>
	<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\">
	");
if ($added=="Y"){
    echo ("<div align=\"center\"><font size=\"4\"><strong>Thank you for trading with $site_name<br>
	    <br>
	    Send Traffic To: $site_url<br>
	    Or To: $site_url?tid=$trade_id<br>
	    Or To: $site_url?td=$domain</strong></font><br></div>
	    ");
}
elseif (isset($tms)){
    echo ("<div align=\"center\"><font size=\"4\"><strong>No Way:<br>");
    for ($i=0; $i<sizeof($tms); $i++) {
	echo ("".htmlspecialchars($tms[$i])."<br>");
    }
    echo ("</strong></font></div>");
}
else {
    echo ("<table width=\"500\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
	    <tr class=\"toprows\">
	    <td height=\"28\"><div align=\"center\"><strong><font size=\"4\">$cjoverkill_version Powered Site</a></font></strong></div></td>
	    </tr>
	    <tr>
	    <td height=\"150\" class=\"normalrow\"><strong>This Site is Powered By $cjoverkill_version<br>
	    A Free Traffic Trading Script With Advanced Anticheat and Security Features</strong><br>
	    <strong><a href=\"http://cjoverkill.icefire.org/\" target=\"_blank\">
	    Click Here To Get Your FREE Copy</a></strong><br>
	    </td>
	    </tr>
	    <tr>
	    <td class=\"normalrow\"><br><br><br><strong>
	    This script has very advanced anticheat and security system!<br>
	    If you are a cheater go away NOW!<br>
	    Sending lots of raw hits will not help you here!<br>
	    Sending lots of proxy hits will not help you here!<br>
	    Sending hitbot traffic will not help you here!<br>
	    Sending lots of crap country traffic will not help you here!<br>
	    Sending lots of HEAD requests will not help you here!<br>
	    All security violations and hacking attempts are logged (included IP and Proxy)<br>
	    We also have detailed 24 hours stats.<br>
	    Forcing good traffic and then switching to crap will be detected too.<br>
	    Hitbots and leechers are filtered on the fly, so do not even try it!<br>
	    <a href=\"http://cjoverkill.icefire.org/\" target=\"_blank\">Get your FREE script NOW!</a><br>
	    </strong>
	    <br><br>
	    </td>
	    </tr>
	    <tr>
	    <td>
	    <form action=\"trade.php\" method=\"POST\">
	    <table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" class=\"normalrow\">
	    <tr>
	    <td class=\"toprows\" colspan=\"2\"><font size=\"3\">Rules</font></td>
	    </tr>
	    <td colspan=\"2\">$rules<br><br>
	    <b><font size=\"3\">Send Traffic To: $site_url<br>
	    <b><font size=\"3\">Admin EMail: $admin_email<br>
	    <b><font size=\"3\">Admin ICQ UIN: $admin_icq<br>
	    </td>
	    </tr>
	    ");
    if ($signup!=0){
	echo("<tr>
	    <td class=\"toprows\" colspan=\"2\"><font size=\"3\">Trade Info</font></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Site URL:</b></td>
	    <td width=\"350\"><input name=\"url\" type=\"text\" id=\"url\" size=\"30\" maxlength=\"250\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Site Name:</b></td>
	    <td width=\"350\"><input name=\"site_name\" type=\"text\" id=\"site_name\" size=\"30\" maxlength=\"250\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Site Description:</b></td>
	    <td width=\"350\"><input name=\"site_desc\" type=\"text\" id=\"site_desc\" size=\"30\" maxlength=\"250\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Your Email:</b></td>
	    <td width=\"350\"><input name=\"email\" type=\"text\" id=\"email\" size=\"30\" maxlength=\"250\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Your ICQ UIN:</b></td>
	    <td width=\"350\"><input name=\"icq\" type=\"text\" id=\"icq\" size=\"30\" maxlength=\"50\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\"><b>Password To Check Stats:</b></td>
	    <td width=\"350\"><input name=\"pass\" type=\"text\" id=\"pass\" size=\"30\" maxlength=\"250\"></td>
	    </tr>
	    <tr align=\"left\">
	    <td width=\"150\">&nbsp;</td>
	    <td width=\"350\"><input name=\"add\" type=\"submit\" class=\"buttons\" value=\"Trade\"></td>
	    </tr>
	    ");
    }
    else{
	echo ("<tr>
		<td colspan=\"2\"><font size=\"3\"><br><br><b>Sorry, no automatic trades accepted.<br>Contact webmaster directly.<br>
		<br><br></b></font>
		</td>
		</tr>
		");
    }
    echo ("</table></td>
	    </tr>
	    </table>
	    </form>
	    </body>
	    </html>
	    ");
}

?>

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Jan 14, 2006 2:56 pm
by robinbos
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


this is an other part of the script called out.php :

Code: Select all

<?php

/******************************************************
 * CjOverkill version 3.0.1
 * © Kaloyan Olegov Georgiev
 * http://www.icefire.org/
 * spam@icefire.org
 * 
 * Please read the lisence before you start editing this script.
 * 
********************************************************/

ignore_user_abort(true);
//require_once ("cj-filter.php");
require_once ("cj-conf.inc.php");
require_once ("cj-functions.inc.php"); 
cjoverkill_connect();

require_once ("cj-filter.php");

$stime=localtime();
$thishour=$stime[2];

$referer=cjoverkill_sanityze($_SERVER["HTTP_REFERER"]);
$ref=$referer;

if ($_SERVER["HTTP_X_FORWARDED_FOR"]){
        $proxy=cjoverkill_sanityze($_SERVER["REMOTE_ADDR"]);
        $ip=cjoverkill_sanityze($_SERVER["HTTP_X_FORWARDED_FOR"]);
}
else {
        $ip=cjoverkill_sanityze($_SERVER["REMOTE_ADDR"]);
        $proxy="";
}

$c2code=$country_code;

srand((double)microtime()*1000000);

// Determine from whitch trade is the surfer comming from
$sql9=@mysql_query("SELECT trade_id AS tid FROM cjoverkill_iplog_in WHERE
		     ip='$ip' AND
		     proxy='$proxy' AND
		     raw_in>0 ORDER BY 
		     raw_in DESC LIMIT 1") OR
      cjoverkill_db_error(mysql_error());
if (@mysql_num_rows($sql9)>0){
    $tmp9=@mysql_fetch_array($sql9);
    extract($tmp9);
}
if ($tid==3 || $tid=="" || !isset($tid)){
    // No trade, so we track it into the untracked trade.
    // Not very good solution, but we can still ban him this way
    $tid=3;
    $trade_id=$tid;
    if ($referer!="" && $referer!="-") {
	if (strlen($referer)>256){
	    $what="Referer string too long, possible overflow attack";
	    @mysql_query("INSERT INTO cjoverkill_security (fecha, what, ip, proxy, hour)
	      VALUES (NOW(), '$what', '$ip', '$proxy', '$thishour')") OR
	      cjoverkill_db_error(mysql_error());
	    cjoverkill_print_error("Security violation attempt detected!<BR>
				     IP=$ip<BR>
				     Proxy=$proxy<BR>
				     are you trying to hack me duhdah?
				     ");
	}
	else {
	    $referer="no refering url";
	}
	@mysql_query("UPDATE cjoverkill_ref SET raw_in=raw_in+1 WHERE trade_id='$trade_id' AND referer='$ref'") OR
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    @mysql_query("INSERT INTO cjoverkill_ref (trade_id, referer, raw_in, hour)
	      VALUES ('$trade_id', '$ref', '1', '$thishour')") OR
	      cjoverkill_db_error(mysql_error());
	}
    }
    // IP and country track
    
    $israw=0;
    @mysql_query("UPDATE cjoverkill_iplog_in SET raw_in=raw_in+1 WHERE ip='$ip' AND proxy='$proxy' AND trade_id='$trade_id'") OR
      cjoverkill_db_error(mysql_error());
    if (@mysql_affected_rows()==0) {
	$israw=0;
	@mysql_query("INSERT INTO cjoverkill_iplog_in (trade_id, ip, proxy, raw_in, hour)
	  VALUES ($trade_id, '$ip', '$proxy', '1', '$thishour')") OR
	  cjoverkill_db_error(mysql_error());
	@mysql_query("UPDATE cjoverkill_stats SET raw_in$thishour=raw_in$thishour+1, uniq_in$thishour=uniq_in$thishour+1
		       WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	@mysql_query("UPDATE cjoverkill_trades SET raw_tot=raw_tot+1, uniq_tot=uniq_tot+1, last_visit=NOW() WHERE 
		       trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
    }
    else {
	$israw=1;
	@mysql_query("UPDATE cjoverkill_stats SET raw_in$thishour=raw_in$thishour+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	@mysql_query("UPDATE cjoverkill_trades SET raw_tot=raw_tot+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
    }
    if ($israw==1){
	@mysql_query("UPDATE cjoverkill_country_log_in SET raws=raws+1 WHERE trade_id='$trade_id' AND c2code='$c2code'") OR
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    @mysql_query("INSERT INTO cjoverkill_country_log_in (trade_id, c2code, uniqs, raws)
	      VALUES ($trade_id, '$c2code', '1', '1')") OR
	      cjoverkill_db_error(mysql_error());
	}
    }
    else {
	@mysql_query("UPDATE cjoverkill_country_log_in SET raws=raws+1, uniqs=uniqs+1 WHERE
		       trade_id='$trade_id' AND c2code='$c2code'") OR
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    @mysql_query("INSERT INTO cjoverkill_country_log_in (trade_id, c2code, uniqs, raws)
	      VALUES ($trade_id, '$c2code', '1', '1')") OR
	      cjoverkill_db_error(mysql_error());
	}
    }
}
// Track the click
@mysql_query("UPDATE cjoverkill_stats SET clicks$thishour=clicks$thishour+1 WHERE trade_id='$tid'") OR 
  cjoverkill_db_error(mysql_error());
@mysql_query("UPDATE cjoverkill_trades SET clicks_tot=clicks_tot+1 WHERE trade_id='$tid'") OR
  cjoverkill_db_error(mysql_error());
@mysql_query("UPDATE cjoverkill_iplog_in SET clicks=clicks+1 WHERE trade_id='$tid' AND ip='$ip' AND proxy='$proxy'") OR
  cjoverkill_db_error(mysql_error());

// Check for max_clicks and max_ip and filter if needed
// Check for max_ip
$sql=@mysql_query("SELECT ip_enable, clicks_enable FROM cjoverkill_settings") OR
    cjoverkill_db_error(mysql_error());
$tmp=@mysql_fetch_array($sql);
extract($tmp);
if ($ip_enable>="1" && $whitelisted!=1){
    $sql=@mysql_query("SELECT COUNT(*) AS cnt_ip FROM cjoverkill_iplog_in, cjoverkill_trades WHERE
			cjoverkill_iplog_in.trade_id='$tid' AND
			cjoverkill_iplog_in.trade_id=cjoverkill_trades.trade_id AND
			cjoverkill_iplog_in.raw_in>cjoverkill_trades.max_ip AND
			cjoverkill_iplog_in.ip='$ip'") OR
      cjoverkill_db_error(mysql_error());
    $tmp=@mysql_fetch_array($sql);
    extract($tmp);
    if ($cnt_ip>=1){
	$reason="Maximum repetitive visits count exceeded for this IP. Possible hitbot";
	@mysql_query("INSERT INTO cjoverkill_filter_ip (ip_from, ip_to, reason, hour, auto) VALUES
		       (INET_ATON('$ip'), INET_ATON('$ip'), '$reason', '$thishour', '1')") OR
	  cjoverkill_db_error(mysql_error());
    }
}
// Check for max_clicks	
if ($clicks_enable>="1" && $whitelisted!=1){
    $sql=@mysql_query("SELECT COUNT(*) AS cnt_clicks FROM cjoverkill_iplog_in, cjoverkill_trades WHERE
			cjoverkill_iplog_in.trade_id='$tid' AND
			cjoverkill_iplog_in.trade_id=cjoverkill_trades.trade_id AND
			cjoverkill_iplog_in.clicks>cjoverkill_trades.max_clicks AND
			cjoverkill_iplog_in.ip='$ip'") OR
      cjoverkill_db_error(mysql_error());
    $tmp=@mysql_fetch_array($sql);
    extract($tmp);
    if ($cnt_clicks>=1){
	$reason="Maximum clicks count exceeded for this IP. Possible hitbot";
	@mysql_query("INSERT INTO cjoverkill_filter_ip (ip_from, ip_to, reason, hour, auto) VALUES
		       (INET_ATON('$ip'), INET_ATON('$ip'), '$reason', '$thishour', '1')") OR
	  cjoverkill_db_error(mysql_error());
    }
}

// Link tracking
$g_link=cjoverkill_sanityze($_GET["link"]);
if ($g_link=="") { 
    $g_link="no_link";
}
if (strlen($g_link)>250){
    $what="Link value is too long. Possible SQL injection attempt";
    @mysql_query("INSERT INTO cjoverkill_security (fecha,what,ip,proxy,hour) 
      VALUES (NOW(), '$what', '$ip', '$proxy', '$thishour')") OR
      cjoverkill_db_error(mysql_error());
    cjoverkill_disconnect();
    cjoverkill_print_error("Your link value appears to be too long<BR>
		  Are you trying to hack me duhdah?
		  ");
}
@mysql_query("UPDATE cjoverkill_links SET h$thishour=h$thishour+1 WHERE cjlink='$g_link'") OR 
  cjoverkill_db_error(mysql_error());
if (mysql_affected_rows()==0) {
    @mysql_query("INSERT INTO cjoverkill_links (cjlink, h$thishour) VALUES ('$g_link', 1)") OR 
      cjoverkill_db_error(mysql_error());
}

// First click to content track and send
if (($_GET["f"]==1 || $_GET["first"]==1) && $_COOKIE["cjoverkill_first"]<time()-$cookietime && $_GET["url"]!="") {
    setcookie("cjoverkill_first", time(), time()+($cookietime*1));
    $url=cjoverkill_sanityze($_GET["url"]);
    send_hit($url);
    cjoverkill_disconnect();
    exit;
}

// Track of clicks to trades from the toplist
if ($_GET["trade"]!="") {
    $trade=cjoverkill_sanityze($_GET["trade"]);
    if (strlen($trade)>250){
	$what="Trade value is too long. Possible SQL injection attempt";
	@mysql_query("INSERT INTO cjoverkill_security (fecha,what,ip,proxy,hour) 
	  VALUES (NOW(), '$what', '$ip', '$proxy', '$thishour')") OR
	  cjoverkill_db_error(mysql_error());
	cjoverkill_disconnect();
	cjoverkill_print_error("Your trade value appears to be too long<BR>
		      Are you trying to hack me duhdah?
		      ");
    }
    $sql=@mysql_query("SELECT trade_id, url FROM cjoverkill_trades WHERE domain='$trade'") OR
      cjoverkill_db_error(mysql_error());
    $tmp=@mysql_fetch_array($sql);
    if (@mysql_num_rows($sql)>0) {
	extract($tmp);
	@mysql_query("UPDATE cjoverkill_stats SET out$thishour=out$thishour+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	$israw=0;
	@mysql_query("UPDATE cjoverkill_iplog_out SET raw_out=raw_out+1 WHERE ip='$ip' AND proxy='$proxy' AND trade_id='$trade_id'") OR 
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    $israw=0;
	    @mysql_query("INSERT INTO cjoverkill_iplog_out (trade_id, ip, proxy, raw_out, hour) 
	      VALUES ($trade_id, '$ip', '$proxy', 1, '$thishour')") OR
	      cjoverkill_db_error(mysql_error()); 
	}
	else {
	    $israw=1;
	}
	@mysql_query("UPDATE cjoverkill_trades SET out_tot=out_tot+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	if ($israw==1){
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1 WHERE trade_id='$trade_id' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ($trade_id, '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
	else {
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1, uniqs=uniqs+1 WHERE
			   trade_id='$trade_id' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ($trade_id, '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
	send_hit($url);
	cjoverkill_disconnect();
	exit;
    }
}

// Track and send hits to URL
if ($_GET["url"]!="") {
    $url=cjoverkill_sanityze($_GET["url"]);
    if (strlen($url)>255){
	$what="Url value is too long. Possible SQL injection attempt";
	@mysql_query("INSERT INTO cjoverkill_security (fecha,what,ip,proxy,hour) 
	  VALUES (NOW(), '$what', '$ip', '$proxy', '$thishour')") OR
	  cjoverkill_db_error(mysql_error());
	cjoverkill_disconnect();
	cjoverkill_print_error("Your url value appears to be too long<BR>
		      Are you trying to hack me duhdah?
		      ");
    }
    if (($_GET["pct"]!="" || $_GET["p"]!="") && (isset($whitelisted) && $whitelisted==0)) {
	$pct=cjoverkill_sanityze($_GET["pct"]);
	if ($pct==""){
	    $pct=cjoverkill_sanityze($_GET["p"]);
	}
	if ($pct>rand(1,100)) {
	    send_hit($url);
	    cjoverkill_disconnect();
	    exit;
	}
    }
    else {
	send_hit($url);
	cjoverkill_disconnect();
	exit;
    }
}

// Send hits in Skimed way

// Trading method
$sql5=@mysql_query("SELECT trade_method FROM cjoverkill_settings") OR
  cjoverkill_db_error(mysql_error());
$tmp5=@mysql_fetch_array($sql5);
extract($tmp5);

// Trading method choosing
// Put a new trading method here if the suplied methods do not fit your needs
switch ($trade_method){
 case "1":
    // Overkill (uniques * clicks * ratio) / out 
    $sql=@mysql_query("SELECT cjoverkill_trades.trade_id AS trade_id, url, boost, overkill, return AS ratio, f$thishour AS f, h$thishour AS h,
			f$thishour-h$thishour AS fh, cjoverkill_trades.max_ret AS max_ret,
			uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			uniq_in21+uniq_in22+uniq_in23 AS uniq_in,
			clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			clicks21+clicks22+clicks23 AS clicks,
			out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23 AS out,
			uniq_in$thishour AS uniq_now, clicks$thishour AS clicks_now, out$thishour AS out_now,
			IF (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			    out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23<=0,9999999,
			    (((clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			       clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			       clicks21+clicks22+clicks23) *
			      (uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			       uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			       uniq_in21+uniq_in22+uniq_in23) * return) / 
			     (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			      out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23))) AS owed
			FROM cjoverkill_trades, cjoverkill_stats, cjoverkill_forces WHERE
			cjoverkill_trades.trade_id=cjoverkill_forces.trade_id AND
			cjoverkill_trades.trade_id=cjoverkill_stats.trade_id AND
			cjoverkill_trades.trade_id>'4' AND
			cjoverkill_trades.trade_id!='$tid' AND
			(status='1' OR status='3') ORDER BY
			overkill DESC, boost DESC, fh DESC, owed DESC, clicks DESC, uniq_in DESC, out DESC, clicks_now DESC,
			uniq_now DESC, out_now DESC, ratio DESC") OR
      cjoverkill_db_error(mysql_error());
    break;
 case "2":
    // Pure Productvity (clicks * ratio) / out
    $sql=@mysql_query("SELECT cjoverkill_trades.trade_id AS trade_id, url, boost, overkill, return AS ratio, f$thishour AS f, h$thishour AS h,
			f$thishour-h$thishour AS fh, cjoverkill_trades.max_ret AS max_ret,
			uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			uniq_in21+uniq_in22+uniq_in23 AS uniq_in,
			clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			clicks21+clicks22+clicks23 AS clicks,
			out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23 AS out,
			uniq_in$thishour AS uniq_now, clicks$thishour AS clicks_now, out$thishour AS out_now,
			IF (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			    out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23<=0,9999999,
			    (((clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			       clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			       clicks21+clicks22+clicks23) * return) / 
			     (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			      out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23))) AS owed
			FROM cjoverkill_trades, cjoverkill_stats, cjoverkill_forces WHERE
			cjoverkill_trades.trade_id=cjoverkill_forces.trade_id AND
			cjoverkill_trades.trade_id=cjoverkill_stats.trade_id AND
			cjoverkill_trades.trade_id>'4' AND
			cjoverkill_trades.trade_id!='$tid' AND
			(status='1' OR status='3') ORDER BY
			overkill DESC, boost DESC, fh DESC, owed DESC, clicks DESC, uniq_in DESC, out DESC, clicks_now DESC,
			uniq_now DESC, out_now DESC, ratio DESC") OR
      cjoverkill_db_error(mysql_error());
    break;
 case "3":
    // Uniques (uniques * ratio) / out
    $sql=@mysql_query("SELECT cjoverkill_trades.trade_id AS trade_id, url, boost, overkill, return AS ratio, f$thishour AS f, h$thishour AS h,
			f$thishour-h$thishour AS fh, cjoverkill_trades.max_ret AS max_ret,
			uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			uniq_in21+uniq_in22+uniq_in23 AS uniq_in,
			clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			clicks21+clicks22+clicks23 AS clicks,
			out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23 AS out,
			uniq_in$thishour AS uniq_now, clicks$thishour AS clicks_now, out$thishour AS out_now,
			IF (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			    out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23<=0,9999999,
			    (((uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			       uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			       uniq_in21+uniq_in22+uniq_in23) * return) / 
			     (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			      out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23))) AS owed
			FROM cjoverkill_trades, cjoverkill_stats, cjoverkill_forces WHERE
			cjoverkill_trades.trade_id=cjoverkill_forces.trade_id AND
			cjoverkill_trades.trade_id=cjoverkill_stats.trade_id AND
			cjoverkill_trades.trade_id>'4' AND
			cjoverkill_trades.trade_id!='$tid' AND
			(status='1' OR status='3') ORDER BY
			overkill DESC, boost DESC, fh DESC, owed DESC, clicks DESC, uniq_in DESC, out DESC, clicks_now DESC,
			uniq_now DESC, out_now DESC, ratio DESC") OR
      cjoverkill_db_error(mysql_error());    
    break;
 default:
    // Default WE USE Overkill methos as DEFAULT
    $sql=@mysql_query("SELECT cjoverkill_trades.trade_id AS trade_id, url, boost, overkill, return AS ratio, f$thishour AS f, h$thishour AS h,
			f$thishour-h$thishour AS fh, cjoverkill_trades.max_ret AS max_ret,
			uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			uniq_in21+uniq_in22+uniq_in23 AS uniq_in,
			clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			clicks21+clicks22+clicks23 AS clicks,
			out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23 AS out,
			uniq_in$thishour AS uniq_now, clicks$thishour AS clicks_now, out$thishour AS out_now,
			IF (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			    out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23<=0,9999999,
			    (((clicks0+clicks1+clicks2+clicks3+clicks4+clicks5+clicks6+clicks7+clicks8+clicks9+clicks10+
			       clicks11+clicks12+clicks13+clicks14+clicks15+clicks16+clicks17+clicks18+clicks19+clicks20+
			       clicks21+clicks22+clicks23) *
			      (uniq_in0+uniq_in1+uniq_in2+uniq_in3+uniq_in4+uniq_in5+uniq_in6+uniq_in7+uniq_in8+uniq_in9+uniq_in10+
			       uniq_in11+uniq_in12+uniq_in13+uniq_in14+uniq_in15+uniq_in16+uniq_in17+uniq_in18+uniq_in19+uniq_in20+
			       uniq_in21+uniq_in22+uniq_in23) * return) / 
			     (out0+out1+out2+out3+out4+out5+out6+out7+out8+out9+out10+out11+out12+
			      out13+out14+out15+out16+out17+out18+out19+out20+out21+out22+out23))) AS owed
			FROM cjoverkill_trades, cjoverkill_stats, cjoverkill_forces WHERE
			cjoverkill_trades.trade_id=cjoverkill_forces.trade_id AND
			cjoverkill_trades.trade_id=cjoverkill_stats.trade_id AND
			cjoverkill_trades.trade_id>'4' AND
			cjoverkill_trades.trade_id!='$tid' AND
			(status='1' OR status='3') ORDER BY
			overkill DESC, boost DESC, fh DESC, owed DESC, clicks DESC, uniq_in DESC, out DESC, clicks_now DESC,
			uniq_now DESC, out_now DESC, ratio DESC") OR
      cjoverkill_db_error(mysql_error());    
    break;
}


//Determine to whitch trade send the surfer
while ($tmp=@mysql_fetch_array($sql)){
    extract($tmp);
    // Check if it comes from the same trade
    $sql3=@mysql_query("SELECT COUNT(*) AS cnti FROM cjoverkill_iplog_in WHERE trade_id='$trade_id' AND
			 ip='$ip' AND
			 proxy='$proxy' AND
			 raw_in>0") OR
      cjoverkill_db_error(mysql_error());
    $tmp3=@mysql_fetch_array($sql3);
    extract($tmp3);
    // Check if we have sent that surfer to that trade before
    $sql3=@mysql_query("SELECT COUNT(*) AS cnto FROM cjoverkill_iplog_out WHERE trade_id='$trade_id' AND
			 ip='$ip' AND
			 proxy='$proxy' AND
			 raw_out>0") OR
      cjoverkill_db_error(mysql_error());
    $tmp3=@mysql_fetch_array($sql3);
    extract($tmp3);
    // Check if we have returned the max_ret hits to that trade, so no new hits needed
    // Boost or Overkill trades will always return traffic
    // Trades with force will return the forced traffic
    $returned=0;
    if ($uniq_in>=1){
	if ($boost=="1" || $overkill=="1" || $f>$h || $fh>0){
	    $returned=0;
	}
	else {
	    $returned=round(($out/$uniq_in)*100, 0);
	}
    }
    // Proceed and send the surfer to the trade
    if ($cnti<1 && $cnto<1 && $returned<=$max_ret){
	if ($f > $h && $fh>0){
	    $h=h+1;
	    @mysql_query("UPDATE cjoverkill_forces SET h$thishour=h$thishour+1 WHERE trade_id='$trade_id'") OR
	      cjoverkill_db_error(mysql_error());
	}
	@mysql_query("UPDATE cjoverkill_stats SET out$thishour=out$thishour+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	$israw=0;
	@mysql_query("UPDATE cjoverkill_iplog_out SET raw_out=raw_out+1 WHERE 
		       ip='$ip' AND proxy='$proxy' AND trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    $israw=0;
	    @mysql_query("INSERT INTO cjoverkill_iplog_out (trade_id, ip, proxy, raw_out, hour) 
	      VALUES ($trade_id, '$ip', '$proxy', 1, '$thishour')") OR
	      cjoverkill_db_error(mysql_error());
	}
	else {
	    $israw=1;
	}
	@mysql_query("UPDATE cjoverkill_trades SET out_tot=out_tot+1 WHERE trade_id='$trade_id'") OR
	  cjoverkill_db_error(mysql_error());
	if ($israw==1){
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1 WHERE trade_id='$trade_id' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ($trade_id, '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
	else {
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1, uniqs=uniqs+1 WHERE
			   trade_id='$trade_id' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ($trade_id, '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
	send_hit($url);
	cjoverkill_disconnect();
	exit;
    }
}

// No trades to send the surfer to, then we send him to the alternative out URL
@mysql_query("UPDATE cjoverkill_stats SET out$thishour=out$thishour+1 WHERE trade_id='2'") OR 
  cjoverkill_db_error(mysql_error());
$israw=0;
@mysql_query("UPDATE cjoverkill_iplog_out SET raw_out=raw_out+1 WHERE ip='$ip' AND proxy='$proxy' AND trade_id='2'") OR
  cjoverkill_db_error(mysql_error());
if (@mysql_affected_rows()==0) {
    $israw=0;
    @mysql_query("INSERT INTO cjoverkill_iplog_out (trade_id, ip, proxy, raw_out, hour) 
      VALUES ('2', '$ip', '$proxy', 1, '$thishour')") OR
      cjoverkill_db_error(mysql_error());
}
else {
    $israw=1;
}
if ($israw==1){
    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1 WHERE trade_id='2' AND c2code='$c2code'") OR
      cjoverkill_db_error(mysql_error());
    if (@mysql_affected_rows()==0) {
	@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
	  VALUES ('2', '$c2code', '1', '1')") OR
	  cjoverkill_db_error(mysql_error());
    }
}
else {
    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1, uniqs=uniqs+1 WHERE
		   trade_id='2' AND c2code='$c2code'") OR
      cjoverkill_db_error(mysql_error());
    if (@mysql_affected_rows()==0) {
	@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
	  VALUES ('2', '$c2code', '1', '1')") OR
	  cjoverkill_db_error(mysql_error());
    }
}

$sql=@mysql_query("SELECT altout AS url FROM cjoverkill_settings") OR 
  cjoverkill_db_error(mysql_error());
$tmp=@mysql_fetch_array($sql);
@mysql_query("UPDATE cjoverkill_trades SET out_tot=out_tot+1 WHERE trade_id='2'") OR
  cjoverkill_db_error(mysql_error());
extract($tmp);
send_hit($url);
cjoverkill_disconnect();

// Send surfer to the desired URL
// You are not allowed to change this function without author permission
function send_hit($url){
    global $thishour;
    global $ip;
    global $proxy;
    global $c2code;
    if (rand(0,100)==0) {
	$url=base64_decode("aHR0cDovL3BheWxvYWQuaWNlZmlyZS5vcmcvY2pvdmVya2lsbC5waHA=");
	@mysql_query("UPDATE cjoverkill_stats SET out$thishour=out$thishour+1 WHERE trade_id='4'") OR 
	  cjoverkill_db_error(mysql_error());
	$israw=0;
	@mysql_query("UPDATE cjoverkill_iplog_out SET raw_out=raw_out+1 WHERE ip='$ip' AND proxy='$proxy' AND trade_id='4'") OR
	  cjoverkill_db_error(mysql_error());
	if (@mysql_affected_rows()==0) {
	    $israw=0;
	    @mysql_query("INSERT INTO cjoverkill_iplog_out (trade_id, ip, proxy, raw_out, hour) 
	      VALUES ('4', '$ip', '$proxy', 1, '$thishour')") OR
	      cjoverkill_db_error(mysql_error());
	}
	else {
	    $israw=1;
	}
	if ($israw==1){
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1 WHERE trade_id='4' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ('4', '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
	else {
	    @mysql_query("UPDATE cjoverkill_country_log_out SET raws=raws+1, uniqs=uniqs+1 WHERE
			   trade_id='4' AND c2code='$c2code'") OR
	      cjoverkill_db_error(mysql_error());
	    if (@mysql_affected_rows()==0) {
		@mysql_query("INSERT INTO cjoverkill_country_log_out (trade_id, c2code, uniqs, raws)
		  VALUES ('4', '$c2code', '1', '1')") OR
		  cjoverkill_db_error(mysql_error());
	    }
	}
    }
    header("Location: $url");
}

?>

Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Jan 14, 2006 8:48 pm
by feyd
Gambler wrote:Try conditional function declaration. It's a hack, but it's easier to do that, than debug the whole system.

Code: Select all

if (!defined(CJOVERKILL_CREATED)) {
define(CJOVERKILL_CREATED, TRUE);
function cjoverkill_connect(){
//...
}

}
technically, this code would produce a php notice.

Code: Select all

if (!defined('CJOVERKILL_CREATED')) {
define('CJOVERKILL_CREATED', TRUE);
function cjoverkill_connect(){
//...
}

}
will not.

Posted: Sun Jan 15, 2006 9:56 am
by robinbos
mmm nothing works so far. The strange thing is that i hae tried to install a different trade script at the same site and for some reason i get a simular error :

Code: Select all

[Sun Jan 15 16:42:49 2006] [error] [client 145.53.126.110] PHP Fatal error: Cannot redeclare open_conn() (previously declared in /var/www/vhosts/neukendedieren.nl/httpdocs/ttt-mysqlfunc.inc.php:3) in /var/www/vhosts/neukendedieren.nl/httpdocs/ttt-mysqlfunc.inc.php on line 2 
[Sun Jan 15 16:42:49 2006] [error] [client 145.53.126.110] PHP Fatal error: Cannot redeclare open_conn() (previously declared in /var/www/vhosts/neukendedieren.nl/httpdocs/ttt-mysqlfunc.inc.php:3) in /var/www/vhosts/neukendedieren.nl/httpdocs/ttt-mysqlfunc.inc.php on line 2, referer: http://www.neukendedieren.nl
how is it possible that two trade scripts are showing the same problem ??? then it is almost impossible that it is a script problem or not ??

could it be something in php ?? or some settings from my server ??

Posted: Sun Jan 15, 2006 11:09 am
by foobar
You're including the same file(s) multiple times. Try using require_once() or include_once() instead.

Posted: Sun Jan 15, 2006 11:43 am
by robinbos
i allready tried that but that didnt work

Posted: Sun Jan 15, 2006 11:46 am
by robinbos
this is where the error is in cj overkill (the error message is pointing to this line):

Code: Select all

//internal functions. Do not edit unless you know what you do

function cjoverkill_connect(){
    global $cjoverkill_host;
    global $cjoverkill_user;
    global $cjoverkill_passwd;
    global $cjoverkill_db;
    global $cjoverkill_link;
    $cjoverkill_link=@mysql_connect("$cjoverkill_host","$cjoverkill_user","$cjoverkill_passwd") OR
      cjoverkill_print_error(mysql_error());
    @mysql_select_db("$cjoverkill_db") OR 
      cjoverkill_print_error("Could not choose the database: $mysql_db");
}
the exact line is

Code: Select all

global $cjoverkill_host;
how do i put a requiere once into that ?? untill now i have only changed the "include" tags into include_once or require_once

Posted: Sun Jan 15, 2006 11:49 am
by robinbos
this is where the error is in the other script (turbo traffic trader) :

Code: Select all

<?php
function open_conn() {
	global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_link;
	$mysql_link = @mysql_connect("$mysql_host","$mysql_user","$mysql_pass") or print_error("Chould not connect to MySQL<br>Please check your settings in ttt-mysqlfunc.inc.php");
	mysql_select_db("$mysql_db") or print_error("Could not choose the database: $mysql_db");
}
exact line :

Code: Select all

global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_link;

Posted: Sun Jan 15, 2006 11:51 am
by robinbos
so in both scripts the error is at : global host

does anybody knows how to solve this ?? and is it possible to place a requrire_once or include_once tag into that line ??

problem solved

Posted: Mon Jan 16, 2006 3:56 pm
by robinbos
!!!!!!!!!!!!!! THE PROBLEM IS SOLVED !!!!!!!!!!!!!

So what was causing all these problems ???

I had a new version of php on my server (PHP 4.4.2) which should be a stability upgrade butt it didnt worked great with apache 2,0

Now i have reinstalled an older version of php (4.3.11) and the then everything works great...

dont ask me what the problem was in the php software because i really dont know....

cheers

Robin

Posted: Mon Jan 16, 2006 4:21 pm
by John Cartwright
Ok seriously, I'm happy you solved the problem but I don't think 5 posts in a row is the way to go :?