Exemplo n.º 1
0
function check_tag_integrity()
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $statement = $connection->query("select * from tags where active=1 and achievement_id!=0");
    while ($tag = $statement->fetchObject()) {
        $achievement = fetch_achievement($tag->achievement_id);
        if ($achievement->deleted) {
            error_log("Line #" . __LINE__ . " " . __FUNCTION__ . "(): Tag should have been deleted.");
            deactivate_tag($tag->id);
        }
    }
    $statement = $connection->query("select * from tags where active=1 and achievement_id=0");
    while ($top_tag = $statement->fetchObject()) {
        if ($top_tag->tally == 0) {
            error_log("Line #" . __LINE__ . " " . __FUNCTION__ . "(): Top tag id #{$top_tag->id}'s tally is 0.");
            deactivate_tag($top_tag->id);
        } else {
            if ($top_tag->tally > 0) {
                $statement = $connection->prepare("select count(*) from tags where active=1 and achievement_id!=0 and name=?");
                $statement->bindValue(1, $top_tag->name, PDO::PARAM_STR);
                $statement->execute();
                $num_of_associated_tags = (int) $statement->fetchColumn();
                if ($num_of_associated_tags == 0) {
                    error_log("Line #" . __LINE__ . " " . __FUNCTION__ . "(): No tags associated with top tag id #{$top_tag->id}");
                    deactivate_tag($top_tag->id);
                }
                if ((int) $top_tag->tally != $num_of_associated_tags) {
                    error_log("Line #" . __LINE__ . " " . __FUNCTION__ . "(): Top tag #{$top_tag->id}'s tally does not match number of associated tags.");
                    $connection->exec("update tags set tally={$num_of_associated_tags} where id={$top_tag->id}");
                }
            }
        }
    }
}
Exemplo n.º 2
0
function check_item_achievement($nn, $i, $ie, $is, $ik, $isk)
{
    global $gamecfg, $name, $db, $tablepre, $now, $starttime, $gamestate;
    //28. 死斗成就
    if ($gamestate == 50 && $i == "杏仁豆腐的ID卡") {
        $t = $now - $starttime;
        $besttime = (int) fetch_achievement(28, $nn);
        if ($t < $besttime || $besttime == 0) {
            update_achievement(28, $nn, $t);
        }
        if (!check_achievement(28, $nn) && $t <= 1800) {
            done_achievement(28, 999, $nn);
            $db->query("UPDATE {$tablepre}users SET credits=credits+250 WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2 WHERE username='******'");
            include_once GAME_ROOT . './include/game/titles.func.php';
            get_title("神触", $nn);
        }
    }
    //29. 美食成就
    if ($ik == 'HS' || $ik == 'HH' || $ik == 'HB') {
        $heal = $ie;
        if ($ik == 'HB') {
            $heal += $ie;
        }
        $uu = (int) fetch_achievement(29, $nn) + $heal;
        if ($uu > 9999999) {
            $uu = 9999999;
        }
        update_achievement(29, $nn, $uu);
        if ((int) fetch_achievement(29, $nn) >= 999983 && check_achievement(29, $nn) < 999) {
            done_achievement(29, 999, $nn);
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+200 WHERE username='******'");
            include_once GAME_ROOT . './include/game/titles.func.php';
            get_title("补给掠夺者", $nn);
        } elseif ((int) fetch_achievement(29, $nn) >= 142857 && check_achievement(29, $nn) < 2) {
            done_achievement(29, 2, $nn);
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+50 WHERE username='******'");
            include_once GAME_ROOT . './include/game/titles.func.php';
            get_title("美食家", $nn);
        } elseif ((int) fetch_achievement(29, $nn) >= 32767 && check_achievement(29, $nn) < 1) {
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+5 WHERE username='******'");
            done_achievement(29, 1, $nn);
        }
    }
    //30. 贝爷成就
    $kk = substr($ik, 0, 1);
    if ($kk == 'P' && $ie >= 30) {
        update_achievement(30, $nn, (int) fetch_achievement(30, $nn) + 1);
        if ((int) fetch_achievement(30, $nn) >= 365 && check_achievement(30, $nn) < 999) {
            done_achievement(30, 999, $nn);
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+200 WHERE username='******'");
            include_once GAME_ROOT . './include/game/titles.func.php';
            get_title("贝爷", $nn);
        } elseif ((int) fetch_achievement(30, $nn) >= 133 && check_achievement(30, $nn) < 2) {
            done_achievement(30, 2, $nn);
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+50 WHERE username='******'");
            include_once GAME_ROOT . './include/game/titles.func.php';
            get_title("神农", $nn);
        } elseif ((int) fetch_achievement(30, $nn) >= 5 && check_achievement(30, $nn) < 1) {
            $db->query("UPDATE {$tablepre}users SET credits=credits WHERE username='******'");
            $db->query("UPDATE {$tablepre}users SET credits2=credits2+5 WHERE username='******'");
            done_achievement(30, 1, $nn);
        }
    }
}
Exemplo n.º 3
0
require_once "../php/config.php";
require_once "../php/work.php";
require_once "../php/actions.php";
require_once "../php/achievements.php";
$connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
$today = 0;
$last_time = 0;
if (!has_work_been_checked()) {
    check_work();
}
$statement = $connection->query("select * from work where action_id!=0 and active=1 order by created desc");
$statement->execute();
while ($work = $statement->fetchObject()) {
    $action = fetch_action($work->action_id);
    $achievement = fetch_achievement($action->achievement_id);
    if ($today != date("m/d/y", strtotime($work->created))) {
        echo "<h2>" . date("m/d/y l", strtotime($work->created)) . "</h2>";
        $today = date("m/d/y", strtotime($work->created));
    }
    if ($last_time != date("H:i", strtotime($work->created))) {
        echo "<div style='margin-top:24px'>" . date("H:i", strtotime($work->created)) . "</div>";
        $last_time = date("H:i", strtotime($work->created));
    }
    echo "<div style='margin-top:8px'>";
    if (!strtotime($work->updated) && $work->worked) {
        echo " <input style='margin-right:8px;' type='button' value='X' onclick=\"cancelWork({$action->id});\" />";
    }
    echo $work->worked ? "Finished " : "<span style='color:red;'>Incompleted </span> ";
    echo strtolower(convert_work_num_to_caption($work->work)) . " work on \"{$action->name}\"";
    if (strtotime($work->updated)) {
Exemplo n.º 4
0
<?php

require_once "achievements.php";
require_once "config.php";
require_once "string.php";
require_once "work.php";
$pref_date_format = "F j, Y g:i:s";
//There could be an issue where users spoof this to see other people's achievements.
//Be sure to check user's session data and page reference before commencing.
$connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
$achievement = fetch_achievement(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
?>

<div id="navbar" style='text-align:center'>
    <div style="margin:5px;">
        <a href="<?php 
echo SITE_ROOT;
?>
">Achievements List</a>
    </div><div style="margin-bottom:10px;">

        <a href="<?php 
echo SITE_ROOT;
?>
/?rla=<?php 
echo fetch_random_achievement_id();
?>
">Random</a>
    </div>
    <div>
        <?php 
Exemplo n.º 5
0
} else {
    $uname = $_REQUEST["playerID"];
    $result = $db->query("SELECT * FROM {$tablepre}users WHERE username='******'");
    if (!$db->num_rows($result)) {
        gexit($_ERROR['user_not_exists'], __FILE__, __LINE__);
    }
    $udata = $db->fetch_array($result);
    extract($udata);
    $curuser = false;
    if ($uname == $cuser) {
        $curuser = true;
    }
}
$iconarray = get_iconlist($icon);
$select_icon = $icon;
$winning_rate = $validgames ? round($wingames / $validgames * 100) . "%" : '0%';
include_once GAME_ROOT . './include/game/achievement.func.php';
$ach = $udata['achievement'];
$n = $udata['username'];
if (!valid_achievement($ach)) {
    $ach = init_achievement($ach);
    $db->query("UPDATE {$tablepre}users SET achievement='{$ach}' WHERE username='******'");
}
//解析成就的完成情况
global $gamecfg;
require config("gamecfg", $gamecfg);
for ($i = 0; $i < $achievement_count; $i++) {
    $cpl[$i] = check_achievement($i, $n);
    $prc[$i] = fetch_achievement($i, $n);
}
include template('user_profile');
Exemplo n.º 6
0
function user_owns_achievement($id)
{
    if (!isset($_SESSION['user']->id)) {
        return false;
    }
    $achievement = fetch_achievement($id);
    if ($achievement->owner == $_SESSION['user']->id) {
        return true;
    }
    return false;
}
Exemplo n.º 7
0
$connection->exec("update achievements set power_adj=power where active=1");
$statement = $connection->query("select * from achievements where parent=0");
$statement->execute();
while ($achievement = $statement->fetchObject()) {
    echo "<div>{$achievement->id} {$achievement->name} {$achievement->power} ";
    $statement2 = $connection->query("select required_by from requirements where active=1 and required_for={$achievement->id} order by required_by");
    $statement2->execute();
    while ($required_by = $statement2->fetchColumn()) {
        $requirement = fetch_achievement($required_by);
        echo "<div style='background-color:gray;margin-left:32px'>{$requirement->id} {$requirement->name} ->{$requirement->power}</div>";
        $connection->exec("update achievements set power_adj=power_adj+{$requirement->power} where id={$requirement->id}");
    }
    $statement2 = $connection->query("select required_for from requirements where active=1 and required_by={$achievement->id} order by required_for");
    $statement2->execute();
    while ($required_for = $statement2->fetchColumn()) {
        $requirement = fetch_achievement($required_for);
        echo "<div style='background-color:red;margin-left:32px'>{$requirement->id} {$requirement->name} ->{$requirement->power}</div>";
        $connection->exec("update achievements set power_adj=power_adj-{$requirement->power_adj} where id={$requirement->id}");
    }
    echo "</div>";
}
function fetch_achievement($id)
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $statement = $connection->prepare("select * from achievements where id=?");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
    return $statement->fetchObject();
}
?>
    </body></html>