In meinem vorherigen Beitrag habe ich eine Lizenz für Snow Leopard verlost. Inzwischen steht der Gewinner fest und wurde von mir kontaktiert. Der Gewinner ist Dani!
Die Lizenz wird per Post verschickt.
Für alle, die nicht gewonnen haben: Viel glück beim nächsten Mal. Ich überlege bereits was ich als nächstes verlosen könnte.
Für alle, welche sich fragen, wie ich den Gewinner erkoren habe. Ich habe dazu folgendes PHP-Script geschrieben, welches mir die Arbeit abgenommen hat
< ?php
/*
* Define settings
*/
define("POST_ID", 731);
define("ALLOW_ONLY_ONE_PARTICIPATION", true);
define("EXCLUDED_PARTICIPANT_MAILS", "mirkos@ma.il,meinemail@addres.se"); //Comma separated list
define("LAST_PARTICIPATION_TIME", "2009-09-06 12:00:00");
/*
* Include the wordpress configuration, connect to database and do the magic
*/
require_once "wp-config.php";
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
mysql_select_db(DB_NAME);
// Prepare query
$query = "SELECT comment_author, comment_author_email FROM ".$table_prefix."comments WHERE comment_post_id = ".POST_ID;
// Filter excluded participants
$excluded_participants = split(",", EXCLUDED_PARTICIPANT_MAILS);
if(count($excluded_participants) != 0){
$query .= " AND comment_author_email NOT IN (";
for($i = 0; $i < count($excluded_participants); $i++){
if($i != 0){
$query .= ", ";
}
$query .= "'".$excluded_participants[$i]."'";
}
$query .= ")";
}
$query .= " AND comment_date <= '".LAST_PARTICIPATION_TIME."'";
// Filter duplicate participiants if wished
if(ALLOW_ONLY_ONE_PARTICIPATION){
$query .= " GROUP BY comment_author_email";
}
$res = mysql_query($query);
// Fill participants into array with names and mails
$participants = array();
while($row = @mysql_fetch_object($res)){
$participants[] = $row->comment_author." <".$row->comment_author_email.">";
}
//Find winner
$winner = rand(1, count($participants) - 1);
echo "The winner is: ".$participants[$winner];
?>




