RuneAd

The Modern RuneScape Private Server Toplist

Incentive Voting

Incentive Voting

RuneAd utilizes a callback feature that will send a GET request to the callback url you specify when adding your server. It is a string, usually an IP Address, username, or randomly generated string. This string comes from your voting script which is appended at the end of the vote url.

Vote URL

https://www.runead.com/vote/site_id/identifier

site_id Integer Your site ID. Can be found in your profile page.
identifier String Something your site uses to identify the voter.

Example Callback

For developer use. If you're just setting up your server, this is not relevant.

Your voting script should have a callback feature already built in. If you need it, here's some example php code to handle callbacks. This will most likely not work for any toplist, but the principal is there :)

PHP

                                <?php
                                    $log_file = "callbacks.log";

                                    $db_host = 'localhost';
                                    $db_name = 'voting';
                                    $db_user = 'root';
                                    $db_pass = 'password';

                                    if (isset($_POST['callback']) && !empty($_POST['callback']) {
                                        $callback = filter_var($_POST['callback'], FILTER_SANITIZE_STRING);

                                        #Connect to database
                                        try {
                                            $pdo = new PDO("mysql:host=" . $db_host . ";dbname=" . $db_name, $db_user, $db_pass);
                                            $pdo->exec("SET CHARACTER SET utf8");
                                            $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                                            $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                                        } catch (PDOException $e) {
                                            error_log(date('[Y-m-d H:i] ')."[Error] Connection failed: {$e->getMessage()} ".PHP_EOL, 3, $log_file);
                                            exit;
                                        }

                                        # prepare query for execution
                                        $stmt = $pdo->prepare("UPDATE votes SET callback_date = UNIX_TIMESTAMP() WHERE code = :code");
                                        $stmt->bindParam(":code", $callback); # bind the parameters
                                        $stmt->execute(); # now execute the prepared statement
                                        $count = $stmt->rowCount(); # counts modified rows

                                        # counts modified rows. if 0, then nothing was changed, Log it to log file.
                                        if ($stmt->rowCount() > 0) {
                                            error_log(date('[Y-m-d H:i] ')."[Error] Update query failed! ".PHP_EOL, 3, $log_file);
                                            exit;
                                        }

                                        # update successful!
                                        error_log(date('[Y-m-d H:i] ')."[Success] Callback received and updated! $callback ".PHP_EOL, 3, $log_file);
                                    }
                                ?>