aber was oder wie kann ich es finden normaleweise beendet es cron.php diese datei aber das macht es nicht
PHP-Code:
<?php
/
##########################################################*/
include("./includes/messages.inc.php");
include("./includes/auction_types.inc.php");
include("./includes/config.inc.php");
include("./secure/passwd.inc.php");
function openLogFile ()
{
global $logFileHandle,$logFileName;
global $cronScriptHTMLOutput;
$logFileHandle = @fopen ( $logFileName, "w" );
if ( $cronScriptHTMLOutput==true )
print "<PRE>\n";
}
function closeLogFile ()
{
global $logFileHandle;
global $cronScriptHTMLOutput;
if ( $logFileHandle )
fclose ( $logFileHandle );
if ( $cronScriptHTMLOutput )
print "</PRE>\n";
}
function printLog ($str)
{
global $logFileHandle;
global $cronScriptHTMLOutput;
if($logFileHandle)
{
if ( substr($str,strlen($str)-1,1)!="\n" )
$str .= "\n";
fwrite ( $logFileHandle, $str );
if ( $cronScriptHTMLOutput )
print "".$str;
}
}
function printLogL ( $str,$level )
{
for($i=1;$i<=$level;++$i)
$str = "\t".$str;
printLog($str);
}
function errorLog ($str)
{
global $logFileHandle, $adminEmail;
printLog ($str);
closeLogFile();
exit;
}
function errorLogSQL ()
{
global $query;
errorLog (
"SQL query error: $query\n".
"Error: ".mysql_error()
);
}
// initialize cron script
openLogFile();
printLog("=============== STARTING CRON SCRIPT: ".date("d m Y H:i:s"));
/* ------------------------------------------------------------
1) "close" expired auctions
closing auction means:
a) update database:
+ "auctions" table
+ "categories" table - for counters
+ "counters" table
b) send email to winner (if any) - passing seller's data
c) send email to seller (reporting if there was a winner)
*/
printLog("++++++ Schließe abgelaufene Auktionen");
$now = date ( "YmdHis" );
$query = "SELECT * FROM auctions WHERE ends<='$now' AND closed='0'";
printLog ($query);
$result = mysql_query($query);
if (!$result)
errorLogSQL();
else
{
$num = mysql_num_rows($result);
printLog($num." Auktionen geschlossen");
$resultAUCTIONS = $result;
while ($row=mysql_fetch_array($resultAUCTIONS))
{
$Auction = $row;
printLog( "\nBearbeite Auktion: ".$row["id"] );
/* ***********************************
update Datenbanktabelle AG 2010
************************************* */
// update "auctions" table
// $query = "UPDATE auctions SET closed='1',starts=$row[starts],ends=$row[ends] WHERE id=\'$row[id]\'"; //auktion schließen
//$query = "UPDATE auctions SET closed='1',starts=$row[starts],ends=$row[ends] WHERE id=\"$row[id]\"";
$query = "UPDATE auctions SET closed='1',starts='$row[starts]',ends='$row[ends]' WHERE id=\'$row[id]\'";
$result = mysql_query($query);
if (!result)
errorLogSQL();
mysql_query($query);
printLogL($query,1);
// update "categories" table - fuer counters
$cat_id = $row["category"];
$root_cat = $cat_id;
$bm_auction_id = $row["id"];
// BEGIN BM - Watchlist löschen
printLogL ("Watchlist-Eintag gelöscht...",1);
$query = "DELETE FROM watchlist WHERE auction_id=\"$bm_auction_id\"";
$result = mysql_query($query);
if ( !$result )
errorLogSQL();
// END BM - Watchlist löschen
do
{
// update counter for this category
$query = "SELECT * FROM categories WHERE cat_id=\"$cat_id\"";
$result = mysql_query($query);
if ( $result )
{
if ( mysql_num_rows($result)>0 )
{
$R_parent_id = mysql_result($result,0,"parent_id");
$R_cat_id = mysql_result($result,0,"cat_id");
$R_counter = intval(mysql_result($result,0,"counter"));
$R_sub_counter = intval(mysql_result($result,0,"sub_counter"));
$R_sub_counter--;
if ( $cat_id == $root_cat )
--$R_counter;
if($R_counter < 0) $R_counter = 0;
if($R_sub_counter < 0) $R_sub_counter = 0;
$query = "UPDATE categories SET counter='$R_counter', sub_counter='$R_sub_counter' WHERE cat_id=\"$cat_id\"";
if ( !mysql_query($query) )
errorLogSQL();
printLogL($query,1);
$cat_id = $R_parent_id;
}
}
else
errorLogSQL();
}
while ($cat_id!=0);
// update "counters" table - decrease number of auctions
$query = "SELECT * FROM counters";
$result = mysql_query($query);
if ( $result )
{
if ( mysql_num_rows($result)>0 )
{
$auctions = mysql_result($result,0,"auctions");
if($auctions > 0) --$auctions;
$query = "UPDATE counters SET auctions=$auctions";
printLogL($query,1);
if ( !mysql_query($query) )
errorLogSQL();
/*
if ( !mysql_query($query) )
die (mysql_error());
*/
}
else
{
$query = "INSERT INTO counters VALUES (0,0)";
printLogL($query,1);
if ( !mysql_query($query) )
errorLogSQL();
}
}
else
errorLogSQL();
/* retrieve seller info */
$query = "SELECT * FROM users WHERE id='".$Auction["user"]."'";
printLogL($query,1);
$result = mysql_query ($query);
if ($result)
{
if ( mysql_num_rows($result)>0 )
{
mysql_data_seek ($result,0 );
$Seller = mysql_fetch_array($result);
}
else
$Seller = array();
}
else
errorLogSQL();
/* ***********************************
check if there is a winner - and get his info
************************************* */
$winner_present = false;
$query = "SELECT * FROM bids WHERE auction='".$row["id"]."' ORDER BY bid ASC";
printLogL($query,1);
$result = mysql_query ( $query );
if ( $result )
{
if ( mysql_num_rows($result)>0 and ( $row["current_bid"] > $row["reserve_price"] ))
{
mysql_data_seek($result,0);
$WinnerBid = mysql_fetch_array($result);
$winner_present = true;
/* get winner info */
$query = "SELECT * FROM users WHERE id='".$WinnerBid["bidder"]."'";
$result = mysql_query ($query);
if ( $result )
{
if ( mysql_num_rows($result)>0 )
{
mysql_data_seek ( $result,0 );
$Winner = mysql_fetch_array($result);
}
else
$Winner = array ();
}
else
errorLogSQL();
}
}
else
errorLogSQL();
/* ****************************************
Nachricht an Verkäufer
****************************************** */
/* create a "report" to seller depending of what kind auction is */
$atype = intval($Auction["auction_type"]);
if ( $atype==1 )
{
/* Standard auction */
if ( $winner_present )
$report_text = $Winner["nick"]." [ ".$Winner["email"]." ]\n";
else
$report_text = "Keine Gebote";
}
else
{
/* Dutch auction */
$report_text = "";
// find out if there is a winner in this auction
$query = "SELECT * FROM bids WHERE auction='".$Auction["id"]."' ORDER BY bid ASC";
$res = mysql_query ($query);
if ( $res )
{
$numDbids = mysql_num_rows($res);
if ( $numDbids==0 )
$report_text = "Keine Gebote";
else
{
$report_text = "";
$items_count = $Auction["quantity"];
$row = mysql_fetch_array($res);
do
{
$items_wanted = $row["quantity"];
$items_got = 0;
if ( $items_wanted<=$items_count )
{
$items_got = $items_wanted;
$items_count -= $items_got;
}
else
{
$items_got = $items_count;
$items_count -= $items_got;
}
$report_text .= " Bieter ".$row["bidder"].": ".$items_got." Artikel, ".$row["bid"]." EUR\n";
$row = mysql_fetch_array($res);
}
while ( ($items_count>0) && ($row) );
printLog($report_text);
}
}
else
errorLogSQL();
}
// nur, wenn ein Gewinner feststeht...
if ($winner_present)
{
// Benutzergruppe feststellen
$benutzergruppe = $Seller["status"];
// Wer wird berechnet? Private und/oder Gewerbliche?
$bill_query = "SELECT * FROM settings";
$bill_result = mysql_query($bill_query);
if (!$bill_result)
{
print "<H1>Fehler beim Lesen von Tabelle Settings!</H1>";
exit;
}
else
{
$bill_privat = mysql_result($bill_result,0,"privat");
$bill_gewerbe = mysql_result($bill_result,0,"gewerbe");
}
// Wird der User berechnet?
if (intval($benutzergruppe) == 0)
{
if ($bill_privat == 1)
$berechnen = 1;
else
$berechnen = 0;
}
if (intval($benutzergruppe) == 1)
{
if ($bill_gewerbe == 1)
$berechnen = 1;
else
$berechnen = 0;
}
if ($berechnen == 1)
{
printLogL ( "Eintrag des Rechnungspostens: Verkaufsprovision.", 1 );
$time = time();
$pos_time = date("YmdHis",$time);
// Verkaufsprovision ermitteln
$last_bid = $Auction["current_bid"];
$my_query = "SELECT * FROM provisions WHERE".
"((min_val<=$last_bid AND max_val>=$last_bid) OR".
"(min_val<$last_bid AND max_val<$last_bid)) ORDER BY id DESC";
$my_result = mysql_query($my_query);
$provision_value = mysql_result($my_result,0,"provision");
$provision = ($Auction["current_bid"]/100) * $provision_value;
// Rechnungsposten schreiben
if (doubleval($provision) > 0)
{
$query = "INSERT INTO accountpos VALUES ('','','".$pos_time."','".
$Seller["id"]."','".$Auction["id"]."','".
$Auction["title"].
"','Verkaufsprovision','".
doubleval($provision).
"','0')";
$result = mysql_query($query);
if (!$result)
{
printLogL ("Fehler beim Schreiben des Rechnungspostens!!", 1);
}
}
}
}
printLogL ( "eMail an Verkäufer: ".$Seller["email"], 1 );
$i_title = $Auction["title"];
$year = substr($Auction['ends'],0,4);
$month = substr($Auction['ends'],5,2);
$day = substr($Auction['ends'],8,2);
$hours = substr($Auction['ends'],11,2);
$minutes = substr($Auction['ends'],14,2);
$ends_string = $day . "." . $month . "." . $year . " " . $hours . ":" . $minutes;
//-- Send e-mail message
if ($winner_present) {
include('./includes/endauction_winner.inc.php');
} else {
include('./includes/endauction_nowinner.inc.php');
}
/* ****************************************
send email to winner (if any)
****************************************** */
if ( $winner_present )
{
printLogL ( "eMail an den Niedrigstbieter: ".$Winner["email"], 1 );
include('./includes/endauction_youwin.inc.php');
}
}
}
/* ************************************************************************
"remove" alte auktionen (archive them)
********************************************************************* */
printLog("\n");
printLog("++++++ Archiviere alte Auktionen");
$expiredTime = date ( "YmdHis", time()-$expireAuction );
$query = "SELECT * FROM auctions WHERE ends<='$expiredTime'";
printLog($query);
$result = mysql_query($query);
if ( $result )
{
$num = mysql_num_rows($result);
printLog($num." auctions to archive");
if ($num>0)
{
$resultCLOSEDAUCTIONS = $result;
while ( $row = mysql_fetch_array($resultCLOSEDAUCTIONS,MYSQL_ASSOC) )
{
$AuctionInfo = $row;
printLogL("Bearbeite Auktion: ".$AuctionInfo["id"],0);
// #########################################################################################
// Wenn Upload-Bilder zu dieser Auktion vorhanden, dann diese löschen:
if ($AuctionInfo["photo_uploaded"] == "1")
{
if (file_exists($image_upload_path.$AuctionInfo["pict_url"]))
{
unlink($image_upload_path.$AuctionInfo["pict_url"]);
printLog("Bild 1 gelöscht.");
}
else
printLog("Bild 1 nicht gefunden...");
if($AuctionInfo["pict_url2"]<>"")
{
if (file_exists($image_upload_path.$AuctionInfo["pict_url2"]))
{
unlink($image_upload_path.$AuctionInfo["pict_url2"]);
printLog("Bild 2 gelöscht.");
}
else
printLog("Bild 2 nicht gefunden...");
}
if($AuctionInfo["pict_url3"]<>"")
{
if (file_exists($image_upload_path.$AuctionInfo["pict_url3"]))
{
unlink($image_upload_path.$AuctionInfo["pict_url3"]);
printLog("Bild 3 gelöscht.");
}
else
printLog("Bild 3 nicht gefunden...");
}
}
// #########################################################################################
// Auktion aus DB löschen
$query= "DELETE FROM auctions WHERE id='".$AuctionInfo["id"]."'";
if ( !mysql_query($query) )
errorLogSQL();
/* delete bids for this auction */
$query = "SELECT * FROM bids WHERE auction='".$AuctionInfo["id"]."'";
$result = mysql_query($query);
if ( $result )
{
$num = mysql_num_rows($result);
if ( $num>0 )
{
printLogL ($num." Gebote für diese Auktion zu löschen",1);
$resultBIDS = $result;
while ( $row = mysql_fetch_array($resultBIDS,MYSQL_ASSOC) )
{
/* archive this bid */
$query = "delete from bids where auction='".$row["auction"]."'";
$res = mysql_query($query);
if ( !$res )
errorLogSQL();
}
}
}
else
errorLogSQL();
}
}
}
else
errorLogSQL();
// Bezahlte Rechnungen samt Posten löschen
$re_query = "SELECT * FROM invoices where closed='1'";
$re_result = mysql_query($re_query);
if ($re_result)
{
$num_rech = mysql_num_rows($re_result);
$b = 0;
while ($b < $num_rech)
{
$rechnungsnummer = mysql_result($re_result,$b,"id");
printLog("Lösche bezahlte Rechnung Nr. $rechnungsnummer");
$pos_query = "DELETE FROM accountpos WHERE re_nr='$rechnungsnummer'";
$pos_result = mysql_query($pos_query);
if (!$pos_result)
{
print "Positionen der Rechnung Nr. $rechnungsnummer konnten nicht gelöscht werden!";
}
$kill_query = "DELETE FROM invoices WHERE id='$rechnungsnummer'";
$kill_result = mysql_query($kill_query);
if (!$kill_result)
{
print "Fehler beim Löschen der Rechnung Nr. $rechnungsnummer";
}
$b++;
}
}
// Alte Sessions löschen
$sessionTime = date ( "YmdHis", time()-$sessionLifeTime );
$query = "SELECT * FROM sessions WHERE last_visit<='$sessionTime'";
printLog($query);
$result = mysql_query ($query);
if ( $result )
{
$num = mysql_num_rows ($result);
printLog($num." alte Sessions zu archivieren");
if ( $num>0 )
{
$resultSESSIONS = $result;
while ( $row=mysql_fetch_array($resultSESSIONS) )
{
$Session = $row;
/* delete this session */
$query = "DELETE FROM sessions WHERE id='".$Session["id"]."'";
if ( !mysql_query($query) )
errorLogSQL();
}
}
}
else
errorLogSQL();
printLog ( "=========================== ENDING CRON");
closeLogFile();
?>