Callback |
---|
1. Alter the voting link for your site by adding /USER at end like:
http://rsps100.com/vote/YOURSERVERID/USER
YOURSERVERID (part already included in voting code). 3. Enter your Callback URL on Edit Server. Only in case of a valid vote we send response with parameters USER to your defined Callback URL like:
http://yourdomain/callback.php?user=USER
Custom callback.php define("TEST", 0); //set to 1 to make logs define("LOG_FILE", "voting.log"); //if TEST is 1 will create this file as logs $user = preg_replace('/[^A-Za-z0-9_]{1,64}/','',trim($_GET['user'])); //clean USER 1 to 64 letters, numbers and _ if(!$user || empty($user)) { if(TEST == true) { error_log(date('[Y-m-d H:i] '). "[Invalid USER] No USER or invalid." . PHP_EOL, 3, LOG_FILE); } } else { //Connect to DB $user = mysql_escape_string($user); //prevent SQL injection //(1) check if $user exists //(2) check if $user voted in last 12 hours //(3) insert new record, user vote + time //(4) run query to give reward to $user //Close DB connection if(TEST == true) { error_log(date('[Y-m-d H:i] '). "[OK] Vote from USER: $user" . PHP_EOL, 3, LOG_FILE); } } |