Commit 5d4505d1 authored by Christoph Zysik's avatar Christoph Zysik

some changes to reload tables, may change, sql / install not updated yet. do...

some changes to reload tables, may change, sql / install not updated yet. do not use this code in production anyway until some sort of stable tag
parent 65b700c5
......@@ -80,7 +80,8 @@ foot();
db_query ('DELETE FROM '.$db_prefix.'_admin_abuse WHERE uid = '.$row['uid']);
db_query ('DELETE FROM '.$db_prefix.'_adscan_userblacklist WHERE uid = '.$row['uid']);
db_query ('DELETE FROM vms_buchungen WHERE uid = '.$row['uid']);
db_query ('DELETE FROM vms_reloads WHERE uid = '.$row['uid']);
db_query ('DELETE FROM `'.DB_PREFIX.'_campaign_reloads` WHERE uid = '.$row['uid']);
db_query ('DELETE FROM `'.DB_PREFIX.'_content_reloads` WHERE uid = '.$row['uid']);
db_query ('DELETE FROM vms_schnittstelle_anfragen WHERE uid = '.$row['uid']);
echo '<font color="#00d000">User Gel&ouml;scht</font><br />';
......@@ -122,4 +123,4 @@ foot();
}
foot();
}
\ No newline at end of file
}
......@@ -14,33 +14,32 @@ class Campaigns
$this->database = $database;
}
public function decreaseAvailCountById( $id, $value = 1 )
public function decreaseAvailCountById( $cid, $value = 1 )
{
$sql = 'UPDATE `'. DB_PREFIX . '_gebuchte_werbung` SET `menge` = GREATEST(0, `menge` - :value ) WHERE `id`= :id';
$sql_params = array(
':id' => $id,
':id' => $cid,
':value' => $value
);
return $this->database->sqlUpdate($sql, $sql_params);
}
public function getIsClickableByTanAndType( $tan, $type, $ip, $uid, $zeit )
public function getIsClickableById( $cid, $ip, $uid, $time )
{
$sql = self::FIELDS_gebuchte_werbung .'
FROM `'. DB_PREFIX .'_gebuchte_werbung` AS `t1`
LEFT JOIN `'. DB_PREFIX .'_reloads` AS `t2` ON
LEFT JOIN `'. DB_PREFIX .'_campaign_reloads` AS `t2` ON
(
`t1`.`tan` = `t2`.`tan` AND
`t1`.`id` = `t2`.`cid` AND
(
`t2`.`uid` = :t2uid OR
`t2`.`ip` = :t2ip
) AND
`t2`.`bis` > :t2bis
`t2`.`until` > :t2until
)
WHERE
`t1`.`tan` = :t1tan AND
`t2`.`tan` IS NULL AND
`t1`.`werbeart` = :t1type AND
`t1`.`id` = :t1cid AND
`t2`.`id` IS NULL AND
`t1`.`menge` >= 1 AND
`t1`.`status` = 1 AND
`t1`.`sponsor` != :t1uid
......@@ -49,10 +48,44 @@ class Campaigns
$sql_params = array(
':t2uid' => $uid,
':t2ip' => $ip,
':t2bis' => $zeit,
':t1tan' => $tan,
':t1type' => $type,
':t2until'=> $time,
':t1cid' => $cid,
':t1uid' => $uid,
);
$result = $this->database->select( $sql, $sql_params );
return ( isset($result[0]) ) ? $result[0] : false;
}
public function getIsClickableByTanAndType( $tan, $type, $ip, $uid, $zeit )
{
$sql = self::FIELDS_gebuchte_werbung .'
FROM `'. DB_PREFIX .'_gebuchte_werbung` AS `t1`
LEFT JOIN `'. DB_PREFIX .'_campaign_reloads` AS `t2` ON
(
`t1`.`id` = `t2`.`cid` AND
(
`t2`.`uid` = :t2uid OR
`t2`.`ip` = :t2ip
) AND
`t2`.`until` > :t2until
)
WHERE
`t1`.`tan` = :t1tan AND
`t2`.`cid` IS NULL AND
`t1`.`werbeart` = :t1type AND
`t1`.`menge` >= 1 AND
`t1`.`status` = 1 AND
`t1`.`sponsor` != :t1uid
LIMIT 1';
$sql_params = array(
':t2uid' => $uid,
':t2ip' => $ip,
':t2until' => $zeit,
':t1tan' => $tan,
':t1type' => $type,
':t1uid' => $uid,
);
$result = $this->database->select( $sql, $sql_params );
return ( isset($result[0]) ) ? $result[0] : false;
......@@ -85,12 +118,12 @@ class Campaigns
$sql = self::FIELDS_gebuchte_werbung .'
FROM `' . DB_PREFIX . '_gebuchte_werbung` AS `t1`
LEFT JOIN `' . DB_PREFIX . '_reloads` AS `t2` ON (`t1`.`tan` = `t2`.`tan` AND ( `t2`.`uid` = :ruid OR `t2`.`ip` = :ip ) AND t2.bis >= :zeit)
LEFT JOIN `' . DB_PREFIX . '_campaign_reloads` AS `t2` ON (`t1`.`id` = `t2`.`cid` AND ( `t2`.`uid` = :ruid OR `t2`.`ip` = :ip ) AND `t2`.`until` >= :until)
LEFT JOIN `' . DB_PREFIX . '_fb_blacklist` AS `t3` ON `t3`.`kid` = `t1`.`kid` AND `t3`.`werbeart`=`t1`.`werbeart`
LEFT JOIN `' . DB_PREFIX . '_userblacklist` AS `t4` ON `t4`.`uid` = :ubuid
WHERE
(`t3`.`kid` IS NULL OR LOCATE(`t3`.`sponsor`, `t1`.`ziel`) = 0) AND
`t2`.`tan` IS NULL AND
`t2`.`cid` IS NULL AND
`t1`.`werbeart` = :wart AND
`t1`.`menge` > 0 AND
`t1`.`status` = 1 AND
......@@ -99,12 +132,12 @@ class Campaigns
ORDER BY `t1`.`verdienst` DESC LIMIT '.$num_limit;
$sql_params = array(
':ruid' => $uid,
':ip' => $ip,
':zeit' => $zeit,
':ubuid'=> $uid,
':wart' => $art,
':spuid'=> $uid,
':ruid' => $uid,
':ip' => $ip,
':until' => $zeit,
':ubuid' => $uid,
':wart' => $art,
':spuid' => $uid,
);
$result['data'] = $this->database->select($sql, $sql_params);
......@@ -164,22 +197,22 @@ class Campaigns
$zeit = time();
$retval = NULL;
$sql = ' `r`.`bis` FROM `'.DB_PREFIX.'_reloads` AS `r`
LEFT JOIN `'.DB_PREFIX.'_gebuchte_werbung` AS `ad` ON (`ad`.`tan` = `r`.`tan` AND `ad`.`status` = 1 AND `ad`.`werbeart` = :wart AND `ad`.`sponsor` != :spuid)
$sql = ' `r`.`until` FROM `'.DB_PREFIX.'_campaign_reloads` AS `r`
LEFT JOIN `'.DB_PREFIX.'_gebuchte_werbung` AS `ad` ON (`ad`.`id` = `r`.`cid` AND `ad`.`status` = 1 AND `ad`.`werbeart` = :wart AND `ad`.`sponsor` != :spuid)
WHERE
`r`.`uid` = :ruid AND `ad`.`tan` IS NOT NULL AND `r`.`bis` > :zeit
ORDER BY `r`.`bis` ASC LIMIT 1';
`r`.`uid` = :ruid AND `ad`.`id` IS NOT NULL AND `r`.`until` > :until
ORDER BY `r`.`until` ASC LIMIT 1';
$sql_params = array(
':wart' => $art,
':spuid' => $uid,
':ruid' => $uid,
':zeit' => $zeit,
':wart' => $art,
':spuid' => $uid,
':ruid' => $uid,
':until' => $zeit,
);
$result = $this->database->select($sql, $sql_params);
if( isset($result[0]) )
{
$res = $result[0];
$retval = (($res->bis - $zeit ) >= 0) ? ($res->bis - $zeit) : NULL;
$retval = (($res->until - $zeit ) >= 0) ? ($res->until - $zeit) : NULL;
}
return $retval;
......
......@@ -268,6 +268,19 @@ class Database extends DaveDatabase
}
public function rawInsert( $sql, $data )
{
$stmt = $this->prepare($sql);
foreach ($data as $key => $value) {
$stmt->bindValue("$key", $value);
}
$stmt->execute();
return $this->lastInsertId();
}
/*
* $db->select("`username` FROM `members` WHERE `memberID` = :id and `email` = :email", array(':id' => 1, ':email' => 'someone@domain.com'));
* $db->selectAll("members", "WHERE `memberID` = :id and `email` = :email", array(':id' => 1, ':email' => 'someone@domain.com'));
......
<?php
/*
* TODO
* nothing checks wether user landed on blacklist...
* blacklist check is broken currently anyway
* please fix me
*/
class Ptc
{
private $database;
private $campaigns;
public function __construct($database, $campaigns)
{
$this->database = $database;
$this->campaigns = $campaigns;
}
public function addCampaignToReload( $cid, $uid, $ip, $until )
{
$sql = 'INSERT INTO `'.DB_PREFIX.'_campaign_reloads`
(`ip`, `uid`, `cid`, `until`) VALUES
(:aip, :auid, :acid, :auntil) ON DUPLICATE KEY UPDATE
`until` = :buntil ';
$sql_params = array(
':aip' => $ip,
':auid' => $uid,
':acid' => $cid,
':auntil'=> $until,
':buntil'=> $until,
);
return $this->database->rawInsert( $sql, $sql_params );
}
public function invalidateAlreadyRunningAd( $uid, $ip )
{
$result = false;
if( isset($_SESSION['current_ad']) )
{
$tan = ( isset($_SESSION['current_ad']['tan']) ) ? $_SESSION['current_ad']['tan'] : false;
$art = ( isset($_SESSION['current_ad']['art']) ) ? $_SESSION['current_ad']['art'] : '';
$id = ( isset($_SESSION['current_ad']['id']) ) ? $_SESSION['current_ad']['id'] : 0;
if( 0 !== $id )
{
$kamp = $this->campaigns->getById( $id );
if( 0 < $kamp['count'] )
{
$until = time() + $kamp['data']->reload;
$this->addCampaignToReload( $id, $uid, $ip, $until );
}
}
unset( $_SESSION['current_ad'] );
$result = true;
}
return $result;
}
public function setCurrentRunningAd( $art, $cid, $tan )
{
$_SESSION['current_ad']['art'] = $art;
$_SESSION['current_ad']['id'] = $cid;
$_SESSION['current_ad']['tan'] = $tan;
$_SESSION['current_ad']['time'] = time();
$_SESSION['current_ad']['paid'] = false;
}
public function handleAdPayout( $cid, $adtype, $uid, $ip, $preis, $verdienst, $msg = 'Paid4Action', $billanzcat = 'Werbebereich' )
{
$result = true;
// TODO adtype dependent counter table
db_query("UPDATE `".DB_PREFIX."_kontodaten` SET `klicks` = `klicks` + 1, `kv` = `kv` + ".$verdienst.", `fc_klicks` = `fc_klicks` + 1 WHERE `uid` = ".$uid); // Hier Zusatz für Fakeschutz
kontobuchung ('+', $verdienst, create_code(14), $uid, 1, $msg);
refumsatz ($verdienst, $uid);
// TODO add handler $adtype dependent
rallysystem ($uid, '1', $verdienst);
bilanz($preis, $verdienst, $billanzcat, $msg);
return $result;
}
function checkAdOkAndPay( $cid, $uid, $ip )
{
$result = false;
$time = time();
$data = $this->campaigns->getIsClickableById( $cid, $ip, $uid, $time );
if ( false !== $data )
{
$timepassed = ( $time - $_SESSION['current_ad']['time'] ) +1;
if( $timepassed >= $data->aufendhalt )
{
$until = $time + $data->reload;
$this->handleAdPayout( $cid, $data->werbeart, $uid, $ip, $data->preis, $data->verdienst );
$this->addCampaignToReload( $cid, $uid, $ip, $until );
$this->campaigns->decreaseAvailCountById( $cid, 1 );
$_SESSION['current_ad']['paid'] = true;
$result = true;
}
}
return $result;
}
}
......@@ -48,12 +48,12 @@ class Stats
{
$zeit = time();
$sql = ' COUNT(`t1`.`tan`) AS `uanzahl`, SUM(`t1`.`verdienst`) AS `uverdienst` FROM `'.DB_PREFIX.'_gebuchte_werbung` AS `t1`
LEFT JOIN `'.DB_PREFIX.'_reloads` AS `t2` ON (`t1`.`tan` = `t2`.`tan` AND ( `t2`.`uid` = :ruid OR `t2`.`ip` = :ip ) AND t2.bis >= :zeit )
LEFT JOIN `'.DB_PREFIX.'_campaign_reloads` AS `t2` ON (`t1`.`id` = `t2`.`cid` AND ( `t2`.`uid` = :ruid OR `t2`.`ip` = :ip ) AND `t2`.`until` >= :until )
LEFT JOIN `'.DB_PREFIX.'_fb_blacklist` AS `t3` ON `t3`.`kid` = `t1`.`kid` AND `t3`.`werbeart`=`t1`.`werbeart`
LEFT JOIN `'.DB_PREFIX.'_userblacklist` AS `t4` ON `t4`.`uid` = :buid
WHERE
( `t3`.`kid` IS NULL OR LOCATE(`t3`.`sponsor`, `t1`.`ziel`) = 0) AND
`t2`.`tan` IS NULL AND
`t2`.`cid` IS NULL AND
`t1`.`werbeart` = :wart AND
`t1`.`reload` >= 100 AND
`t1`.`menge` > 0 AND
......@@ -61,12 +61,12 @@ class Stats
`t1`.`verdienst` >= 0 AND
`t1`.`sponsor` != :spuid ';
$sql_params = array(
':ruid' => $uid,
':ip' => $ip,
':zeit' => $zeit,
':buid' => $uid,
':spuid'=> $uid,
':wart' => $art,
':ruid' => $uid,
':ip' => $ip,
':until' => $zeit,
':buid' => $uid,
':spuid' => $uid,
':wart' => $art,
);
$result = $this->database->select( $sql, $sql_params );
return ( isset($result[0]) ) ? $result[0] : false;
......
......@@ -7,7 +7,7 @@ if ($pageconfig['reload_betteln'] == 0) {
if ($_SESSION['uid'] == $_GET['ref'] || $_GET['ref'] == $_COOKIE['uid']) {
$betteltext = '<b><font color="#FF0000">Du kannst dich nicht selbst anbetteln!</font></b>';
} else {
$reloadcheck = db_query("SELECT bis FROM " . $db_prefix . "_reloads WHERE ip = '" . $ip . "' and tan = 'bettelaufruf' and bis >= " . time() . " LIMIT 1");
$reloadcheck = db_query("SELECT `until` FROM " . $db_prefix . "_content_reloads WHERE ip = '" . $ip . "' and cid = 3 and `until` >= " . time() . " LIMIT 1");
if (!mysqli_num_rows($reloadcheck)) {
$sperre = mysqli_fetch_array(db_query("SELECT bettel_sperre FROM ".$db_prefix."_kontodaten WHERE uid = '".$_GET['ref']."' "));
......@@ -17,7 +17,7 @@ if ($pageconfig['reload_betteln'] == 0) {
srand((double)microtime() * 1000000);
$bettelsumme = rand($minimum * 100, $maximum * 100) / 100;
$new_reload = time() + $pageconfig['reload_betteln'];
db_query("INSERT INTO " . $db_prefix . "_reloads (ip,uid,tan,bis) VALUES ('" . $ip . "','" . $_GET['ref'] . "','bettelaufruf','" . $new_reload . "')");
db_query("INSERT INTO " . $db_prefix . "_content_reloads (ip,uid,cid,`until`) VALUES ('" . $ip . "','" . $_GET['ref'] . "',3,'" . $new_reload . "')");
db_query("UPDATE " . $db_prefix . "_kontodaten SET angebettelt =angebettelt + 1, bv = bv + " . $bettelsumme . ", kontostand = kontostand + '" . $bettelsumme . "' WHERE uid = '" . $_GET['ref'] . "'");
db_query("INSERT INTO ".$db_prefix."_bettel_buchung (zeit,betrag,refferer,uid) VALUES ('". time() ."', '".$bettelsumme."', '".$_SERVER['HTTP_REFERER']."', '".$_GET['ref']."' )");
......@@ -31,7 +31,7 @@ if ($pageconfig['reload_betteln'] == 0) {
} else {
$reloadcheck = mysqli_fetch_array($reloadcheck);
$betteltext = '<b><font color="#FF0000">Du bist noch für ' . round((($reloadcheck['bis'] - time()) / 60), 0) . ' Minuten fürs Betteln gesperrt</font></b>';
$betteltext = '<b><font color="#FF0000">Du bist noch f&uuml;r ' . round((($reloadcheck['until'] - time()) / 60), 0) . ' Minuten fürs Betteln gesperrt</font></b>';
}
}
}
......
......@@ -29,7 +29,8 @@ if ($_POST['acc_del'] == 'Jetzt löschen!' && $_POST['del_passwort']) {
db_query ('DELETE FROM ' . $db_prefix . '_admin_abuse WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM ' . $db_prefix . '_adscan_userblacklist WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM vms_buchungen WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM vms_reloads WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM `'.DB_PREFIX.'_content_reloads` WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM `'.DB_PREFIX.'_campaign_reloads` WHERE uid = ' . $_SESSION['uid']);
db_query ('DELETE FROM vms_schnittstelle_anfragen WHERE uid = ' . $_SESSION['uid']);
echo '<meta http-equiv="refresh" content="0; URL=http://' . $_SERVER['HTTP_HOST'] . '/?content=/intern/startseite&logout=true">';
}
......
......@@ -2,20 +2,20 @@
userstatus();
if ($pageconfig['popup_start'] == 0) {
$reloadcheck = db_query("SELECT * FROM ".$db_prefix."_reloads WHERE uid = '".$_SESSION['uid']."' and tan = 'startseitenaufruf' and bis >= '".time()."'");
$reloadcheck = db_query("SELECT * FROM ".$db_prefix."_content_reloads WHERE uid = '".$_SESSION['uid']."' and cid = 1 and `until` >= '".time()."'");
if (!mysqli_num_rows($reloadcheck)) {
// Reload setzen und Umstze schreiben
$new_reload = time()+$pageconfig['reload_start'];
db_query("INSERT INTO ".$db_prefix."_reloads (ip,uid,tan,bis) VALUES ('".$ip."','".$_SESSION['uid']."','startseitenaufruf','".$new_reload."')");
db_query("INSERT INTO ".$db_prefix."_content_reloads (ip,uid,tan,`until`) VALUES ('".$ip."','".$_SESSION['uid']."',1,'".$new_reload."')");
db_query("UPDATE ".$db_prefix."_kontodaten SET s_aufrufe = s_aufrufe + 1, s_verdienst = s_verdienst + ".$pageconfig['verdienst_start']." WHERE uid = '".$_SESSION['uid']."'");
kontobuchung ('+', $pageconfig['verdienst_start'], create_code(14), $_SESSION['uid'], 1, 'System Startseitenverg&uuml;tung');
refumsatz ($pageconfig['verdienst_start'],$_SESSION['uid']);
aktivralley ($pageconfig['verdienst_start'],$_SESSION['uid']);
$starttext = '<b>Du hast gerade '.number_format($pageconfig['verdienst_start'],2,',','.').' '.$waehrung.' fr diesen Aufruf erhalten!</b>';
$starttext = '<b>Du hast gerade '.number_format($pageconfig['verdienst_start'],2,',','.').' '.$waehrung.' f&uuml;r diesen Aufruf erhalten!</b>';
} else {
$reloadcheck = mysqli_fetch_array($reloadcheck);
$starttext = '<b><font color="#FF0000">Du bist noch fr '. round((($reloadcheck['bis'] - time())/60),0) .' Minuten fr den Startseitenaufruf gesperrt</font></b>';
$starttext = '<b><font color="#FF0000">Du bist noch f&uuml;r '. round((($reloadcheck['until'] - time())/60),0) .' Minuten f&uuml;r den Startseitenaufruf gesperrt</font></b>';
}
head("");
echo '
......@@ -34,4 +34,4 @@ $text = mysqli_fetch_array(db_query("SELECT text FROM ".$db_prefix."_texte WHERE
head("Willkomen auf der Pay4Start von ".$seitenname);
echo nl2br($text['text']);
foot();
?>
\ No newline at end of file
?>
......@@ -8,21 +8,21 @@ require_once ('../lib/session.lib.php');
require_once ('../lib/layout.lib.php');
userstatus();
if ( md5($_SESSION['uid']."-".date("H:i")) == $_GET['key']) {
$reloadcheck = db_query("SELECT * FROM ".$db_prefix."_reloads WHERE uid = '".$_SESSION['uid']."' and tan = 'startseitenaufruf' and bis >= '".time()."'");
$reloadcheck = db_query("SELECT * FROM ".$db_prefix."_content_reloads WHERE uid = '".$_SESSION['uid']."' and cid = 1 and `until` >= '".time()."'");
if (!mysqli_num_rows($reloadcheck)) {
// Reload setzen und Umstze schreiben
$new_reload = time()+$pageconfig['reload_start'];
db_query("INSERT INTO ".$db_prefix."_reloads (ip,uid,tan,bis) VALUES ('".$ip."','".$_SESSION['uid']."','startseitenaufruf','".$new_reload."')");
db_query("INSERT INTO ".$db_prefix."_content_reloads (ip,uid,tan,`until`) VALUES ('".$ip."','".$_SESSION['uid']."',1,'".$new_reload."')");
db_query("UPDATE ".$db_prefix."_kontodaten SET s_aufrufe = s_aufrufe + 1, s_verdienst = s_verdienst + ".$pageconfig['verdienst_start']." WHERE uid = '".$_SESSION['uid']."'");
kontobuchung ('+', $pageconfig['verdienst_start'], create_code(14), $_SESSION['uid'], 1, 'System Startseitenverg&uuml;tung');
refumsatz ($pageconfig['verdienst_start'],$_SESSION['uid']);
$starttext = '<b>Du hast gerade '.number_format($pageconfig['verdienst_start'],2,',','.').' '.$waehrung.' fr diesen Aufruf erhalten!</b>';
$starttext = '<b>Du hast gerade '.number_format($pageconfig['verdienst_start'],2,',','.').' '.$waehrung.' f&uuml;r diesen Aufruf erhalten!</b>';
} else {
$reloadcheck = mysqli_fetch_array($reloadcheck);
$bis = (($reloadcheck['bis'] - time())/60);
$bis = (($reloadcheck['until'] - time())/60);
$starttext = '<b><font color="#FF0000">Du bist noch f&uuml;r '. round($bis,0) .' Minuten f&uuml;r den Startseitenaufruf gesperrt</font></b>';
}
head("");
......@@ -40,4 +40,4 @@ echo '
<br>
';
foot();
}
\ No newline at end of file
}
......@@ -20,7 +20,8 @@ if($setting['buchungen_loeschen'] == 1){
}
## Alte Reloads löschen
db_query('DELETE FROM '.$db_prefix.'_reloads WHERE bis <= '.time().'');
db_query('DELETE FROM '.$db_prefix.'_content_reloads WHERE `until` <= '.time().'');
db_query('DELETE FROM '.$db_prefix.'_campaign_reloads WHERE `until` <= '.time().'');
## Abgelaufene Paidmails löschen
db_query('DELETE FROM '.$db_prefix.'_paidmails_empfaenger WHERE
status = 1 || status = 2 || gueltig < '.time().'');
......
<?php
$adArten = array('forcedbanner' => 'forcedbanner',
);
/*
* TODO
* nothing checks wether user landed on blacklist...
* blacklist check is broken currently anyway
* please fix me
*/
function invalidateAlreadyRunningAd()
{
global $adArten,$ip,$db_prefix;
$result = false;
if( isset($_SESSION['current_ad']) )
{
$tan = ( isset($_SESSION['current_ad']['tan']) ) ? $_SESSION['current_ad']['tan'] : false;
$art = ( isset($_SESSION['current_ad']['art']) ) ? $_SESSION['current_ad']['art'] : '';
if( false !== $tan && in_array($art, $adArten) )
{
$dbArt = $adArten[$art];
$kamp = db_query ("SELECT `t1`.* FROM `" . $db_prefix . "_gebuchte_werbung` AS `t1`
LEFT JOIN `" . $db_prefix . "_reloads` AS `t2` ON (`t1`.`tan`=`t2`.`tan` AND (`t2`.`uid`=" . $_SESSION['uid'] . " OR `t2`.`ip`='" . $ip . "') AND `t2`.`bis` > " . time() . ")
WHERE `t1`.`tan` = '" . $tan . "' AND `t2`.`tan` IS NULL AND `t1`.`werbeart` = '".$dbArt."' LIMIT 1");
if ( mysqli_num_rows( $kamp ) )
{
$result = true;
$forced = mysqli_fetch_assoc( $kamp );
$new_reload = time() + $forced['reload'];
db_query("INSERT INTO `" . $db_prefix . "_reloads`
(`ip`,`uid`,`tan`,`bis`) VALUES
('" . $ip . "'," . $_SESSION['uid'] . ",'" . $tan . "'," . $new_reload . ")");
}
}
unset( $_SESSION['current_ad'] );
}
return $result;
}
function setCurrentRunningAd( $art, $tan )
{
$_SESSION['current_ad']['tan'] = $tan;
$_SESSION['current_ad']['art'] = $art;
$_SESSION['current_ad']['time'] = time();
$_SESSION['current_ad']['paid'] = false;
}
function handleAdPayout( $forced )
{
global $dbArten, $ip, $db_prefix;
db_query("UPDATE ".$db_prefix."_kontodaten SET klicks = klicks + 1, kv = kv + ".$forced['verdienst'].", fc_klicks = fc_klicks + 1 WHERE uid = '".$_SESSION['uid']."'"); // Hier Zusatz für Fakeschutz
kontobuchung ('+', $forced['verdienst'], create_code(14), $_SESSION['uid'], 1, 'Forcedbannerverdienst');
refumsatz ($forced['verdienst'], $_SESSION['uid']);
rallysystem ($_SESSION['uid'], '1', $forced['verdienst']);
bilanz($forced['preis'], $forced['verdienst'],'Werbebereich','Forcedbannerklick');
$new_reload = time() + $forced['reload'];
db_query("INSERT INTO " . $db_prefix . "_reloads (ip,uid,tan,bis) VALUES ('" . $ip . "'," . $_SESSION['uid'] . ",'" . $forced['tan'] . "'," . $new_reload . ")");
db_query("UPDATE " . $db_prefix . "_gebuchte_werbung SET menge = menge - 1 WHERE tan='" . $forced['tan'] . "'");
}
function checkAdOk( $art, $tan )
{
global $dbArten, $ip, $db_prefix, $sql_open;
$result = array('checkResult' => false);
$sql = "SELECT `t1`.* FROM `" . $db_prefix . "_gebuchte_werbung` AS `t1`
LEFT JOIN `" . $db_prefix . "_reloads` AS `t2` ON (`t1`.`tan`=`t2`.`tan` AND (`t2`.`uid`=" . $_SESSION['uid'] . " OR `t2`.`ip`='" . $ip . "') AND `t2`.`bis` > " . time() . ")
WHERE `t1`.`tan` = ? AND `t2`.`tan` IS NULL AND `t1`.`werbeart` = ? LIMIT 1";
$statement = mysqli_stmt_init( $sql_open );
mysqli_stmt_prepare( $statement, $sql );
mysqli_stmt_bind_param( $statement, "ss", $tan, $art );
if( mysqli_stmt_execute( $statement ) )
{
mysqli_stmt_store_result( $statement );
if ( mysqli_stmt_num_rows( $statement ) > 0 )
{
$timepassed = ( time() - $_SESSION['current_ad']['time'] ) +1;
$rows = db_fetch( $statement );
$forced = $row[0];
$result['data'] = $forced;
if( $timepassed >= $forced['aufendhalt'] )
{
handleAdPayout( $forced );
$_SESSION['current_ad']['paid'] = true;
$result['checkResult'] = true;
}
}
}
mysqli_stmt_close( $statement );
return $result;
}
......@@ -4,7 +4,6 @@ require ('../../lib/datenbank.inc.php');
require ('../../lib/functions.lib.php');
require ('../../lib/session.lib.php');
userstatus();
require ('ads.inc.php');
$sperre_sql = "SELECT `forced_sperre` FROM `".$db_prefix."_kontodaten` WHERE `uid` = ".$_SESSION['uid'];
$sperre_res = db_query($sperre_sql);
......@@ -20,7 +19,7 @@ if( 0 == $sperre['forced_sperre'] )
switch( $_POST['action'] )
{
case 'getNewAdData':
invalidateAlreadyRunningAd();
$ptc->invalidateAlreadyRunningAd( $_SESSION['uid'], $ip );
if( isset($_POST['adArt']) )
{
$result = $campaigns->getNewAdData( $_POST['adArt'], $_SESSION['uid'], $ip );
......@@ -28,12 +27,12 @@ if( 0 == $sperre['forced_sperre'] )
break;
case 'checkAdOk':
if( isset( $_POST['art'] ) && isset( $_POST['tan'] ) )
$result = checkAdOk( $_POST['art'], $_POST['tan'] );
if( isset( $_SESSION['current_ad']['id'] ) )
$result = $ptc->checkAdOkAndPay( $_SESSION['current_ad']['id'], $_SESSION['uid'], $ip );
break;
case 'invalidateAd':
$result = invalidateAlreadyRunningAd();
$result = invalidateAlreadyRunningAd( $_SESSION['uid'], $ip );
break;
}
}
......
......@@ -27,10 +27,10 @@ if (!file_exists('content' . $_GET['content'] . '.php')) $_GET['content'] = '/er
if ($_GET['content'] == '/intern/startseite') @require_once ('lib/texte/alt_startseitenpopup.txt');
if ($_GET['content'] == '/betteln') @require_once ('lib/texte/alt_bettelseitenpopup.txt');
$start_reload = db_query("SELECT * FROM ".$db_prefix."_reloads WHERE uid = '".$_SESSION['uid']."' and tan = 'startseitenaufruf' and bis >= '".time()."'");
$start_reload = db_query("SELECT * FROM ".$db_prefix."_content_reloads WHERE uid = '".$_SESSION['uid']."' and cid = 1 and `until` >= '".time()."'");
if (mysqli_num_rows($start_reload) != 0) {
$start = mysqli_fetch_array($start_reload);
$datetime = date("Y-m-d H:i:s", $start['bis']);
$datetime = date("Y-m-d H:i:s", $start['until']);
}else{
$datetime = "2014-09-21 20:33:28";
}
......
......@@ -4,8 +4,10 @@ if( isset($database) )
{
require_once( __DIR__ . '/../class/campaigns.php' );
require_once( __DIR__ . '/../class/stats.php' );
require_once( __DIR__ . '/../class/ptc.php' );
$campaigns = new Campaigns($database);
$stats = new Stats($database);
$ptc = new Ptc($database, $campaigns);
} else {
throw new Exception( 'Please include lib/datenbank.inc.php before lib/functions.lib.php' );
......
......@@ -10,14 +10,14 @@ if(empty($_POST['inhalt'])){ $error = 1; $meldung = 'Bitte Text eingeben.';}
if($_SESSION['uid'] <= 0){ $error = 1; $meldung = 'Ung&uuml;ltige User-ID.';}
if($error == 0){
$reload = mysqli_fetch_array(db_query("SELECT bis FROM ".$db_prefix."_reloads WHERE uid = '".$_SESSION['uid']."' AND tan = 'sb_reload' "));
$reload = mysqli_fetch_array(db_query("SELECT `until` FROM ".$db_prefix."_content_reloads WHERE uid = '".$_SESSION['uid']."' AND cid = 2 "));
$zeit = time();
$text = $_POST['inhalt'];
$user = mysqli_fetch_array(db_query("SELECT nickname FROM ".$db_prefix."_userdaten WHERE uid = '".$_SESSION['uid']."' "));
db_query("INSERT INTO ".$db_prefix."_chat (absender, nachricht, time) VALUES ('".$user['nickname']."', '". mysqli_real_escape_string($sql_open,$text) ."', '".$zeit."')");
db_query("UPDATE ".$db_prefix."_kontodaten SET sb_texte = sb_texte + '1' WHERE uid = '".$_SESSION['uid']."' ");
if( time() >= $reload['bis']){
if( time() >= $reload['until']){
$daten = mysqli_fetch_array(db_query("SELECT sb_reload,sb_verguetung FROM ".$db_prefix."_chat_einstellungen "));
if($_COOKIE['adblocker'] == 1){
$verguetung = $daten['sb_verguetung']/2;
......@@ -31,7 +31,7 @@ if($error == 0){
db_query("UPDATE ".$db_prefix."_kontodaten SET sb_verdienst = sb_verdienst + '".$daten['sb_verguetung']."' WHERE uid = '".$_SESSION['uid']."' ");
$sperre = time() + $daten['sb_reload'];
db_query("INSERT INTO ".$db_prefix."_reloads (uid,bis,tan) VALUES ('".$_SESSION['uid']."','".$sperre."','sb_reload') ");
db_query("INSERT INTO ".$db_prefix."_content_reloads (uid,`until`,`cid`) VALUES ('".$_SESSION['uid']."','".$sperre."',2) ");
}
}
......
<?php
ini_set('display_errors', 1);
require_once ( __DIR__ . '/lib/datenbank.inc.php' );
require_once ( __DIR__ . '/lib/functions.lib.php' );
require_once ( __DIR__ . '/lib/session.lib.php' );
......@@ -42,18 +43,15 @@ else
// User bezahlen und Reload schreiben
if ( $_GET['auszahlen'] == 'true' && $force_error != 'true' && $_GET['puk'] == md5($_SESSION['uid'] . $kampdaten->aufendhalt . date("d.m.Y", $zeit) . $percode) && $zeit >= $_SESSION['earlies_payout' . $_GET['tan']] )
{
db_query("UPDATE ".$db_prefix."_kontodaten SET klicks = klicks + 1, kv = kv + ".$kampdaten->verdienst.", fc_klicks = fc_klicks + 1 WHERE uid = '".$_SESSION['uid']."'"); // Hier Zusatz für Fakeschutz
kontobuchung ('+', $kampdaten->verdienst, create_code(14), $_SESSION['uid'], 1, 'Forcedbannerverdienst');
refumsatz ($kampdaten->verdienst, $_SESSION['uid']);
rallysystem ($_SESSION['uid'], '1', $kampdaten->verdienst);
bilanz($kampdaten->preis, $kampdaten->verdienst,'Werbebereich','Forcedbannerklick');
$new_reload = $zeit + $kampdaten->reload;
$ptc->handleAdPayout( $kampdaten->id, $kampdaten->werbeart, $_SESSION['uid'], $ip, $kampdaten->preis, $kampdaten->verdienst, 'Paidlink', $billanzcat = 'Werbebereich' );
$new_reload = $zeit+$kampdaten->reload;
$ptc->addCampaignToReload( $kampdaten->id, $_SESSION['uid'], $ip, $new_reload );
$campaigns->decreaseAvailCountById( $kampdaten->id, 1 );
$_SESSION['earlies_payout' . $_GET['tan']] = '';
$headmsg = $kampdaten->verdienst . ' '. $pageconfig['waehrung'].' erhalten!';
db_query("INSERT INTO " . $db_prefix . "_reloads (ip,uid,tan,bis) VALUES ('" . $ip . "'," . $_SESSION['uid'] . ",'" . $kampdaten->tan . "'," . $new_reload . ")");
$campaigns->decreaseAvailCountById( $kampdaten->id, 1 );
$_SESSION['earlies_payout' . $_GET['tan']] = '';
$headmsg = $kampdaten->verdienst . ' ' . $pageconfig['waehrung'] . ' erhalten!';
db_query("UPDATE ".$db_prefix."_kontodaten SET klicks = klicks + 1, kv = kv + ".$kampdaten->verdienst.", fc_klicks = fc_klicks + 1 WHERE uid = '".$_SESSION['uid']."'"); // Hier Zusatz für Fakeschutz
}
elseif( $_GET['auszahlen'] == 'true' && $zeit < $_SESSION['earlies_payout' . $_GET['tan']] )
......
......@@ -41,15 +41,9 @@ if ( $_GET['auszahlen'] == 'true' && $force_error != 'true' && $_GET['puk'] == m
{
if ($_SESSION['uid'] >= 1)
{
kontobuchung( '+', $kampdaten->verdienst, create_code(14), $_SESSION['uid'], 1, 'Textlinkklickverdienst' );
refumsatz( $kampdaten->verdienst, $_SESSION['uid'] );
aktivralley( $kampdaten->verdienst, $_SESSION['uid'] );
bilanz( $kampdaten->preis, $kampdaten->verdienst, 'Werbebereich', 'Textlinkklick' );
klickralley();
$ptc->handleAdPayout( $kampdaten->id, $kampdaten->werbeart, $_SESSION['uid'], $ip, $kampdaten->preis, $kampdaten->verdienst, 'Paidlink', $billanzcat = 'Werbebereich' );
$new_reload = $zeit+$kampdaten->reload;
db_query("INSERT INTO ".$db_prefix."_reloads (ip,uid,tan,bis) VALUES ('" . $ip . "','" . $_SESSION['uid'] . "','" . $kampdaten->tan . "','" . $new_reload . "')");
$ptc->addCampaignToReload( $kampdaten->id, $_SESSION['uid'], $ip, $new_reload );
$campaigns->decreaseAvailCountById( $kampdaten->id, 1 );
db_query("UPDATE ".$db_prefix."_kontodaten SET textlinks = textlinks + 1, tlv = tlv + ". $kampdaten->verdienst ." WHERE uid = '".$_SESSION['uid']."'");
$_SESSION['earlies_payout' . $_GET['tan']] = '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment