Exemplo n.º 1
0
function process_filter_to_query($filter)
{
    $generic_query = DEFAULT_LISTING;
    $user_id = fetch_current_user_id();
    $generic_query = $user_id == false ? $generic_query . " and public=1 " : $generic_query . " and owner={$user_id}";
    if ($filter == "clear" || $filter == "default" || empty($filter)) {
        return $generic_query;
    }
    $query = $generic_query;
    if (isset($filter['show_only'])) {
        foreach ($filter['show_only'] as $show) {
            $query = $query . process_show_only_to_query($show);
        }
    }
    if (isset($filter["filter_tags"])) {
        foreach ($filter["filter_tags"] as $tag) {
            $tag = fetch_tag($tag);
            $tag_filter = !isset($tag_filter) ? "(name=\"{$tag->name}\"" : $tag_filter . " or name=\"{$tag->name}\"";
        }
        $tag_filter = $tag_filter . "))";
        $query = $query . " and \n                id in (select distinct achievement_id from tags where active=1 and {$tag_filter}";
    }
    if ($filter["required"]) {
        $query = $query . " and id not in (select distinct required_for from requirements where active=1)";
    }
    return $query;
}
Exemplo n.º 2
0
function list_completed_achievements()
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    echo "<h3 style='text-align:center;'>Completed Achievements</h3>";
    $query = "select count(*) from achievements where active=0 and completed!=0";
    $user_id = fetch_current_user_id();
    $query = $user_id == false ? $query . " and public=1" : $query . " and owner={$user_id}";
    $statement = $connection->query($query);
    if ((int) $statement->fetchColumn() == 0) {
        echo "<div>None.</div>";
        return;
    }
    $statement = $connection->query("select * from achievements where completed!=0");
    while ($achievement = $statement->fetchObject()) {
        echo "  <div>\n                    \n                    <span style='font-weight:bold'>\n                        <a href='" . SITE_ROOT . "/?rla={$achievement->id}' style='text-decoration:none;'>\n                        {$achievement->name}                             \n                        </a>\n                    </span>\n                        <div>\n                            <span>Created:" . date("m/d/y", strtotime($achievement->created)) . "</span>            \n                            <span>Completed:" . date("m/d/y", strtotime($achievement->completed)) . "</span>\n                            <input id='cancel{$achievement->id}' class='cancel_completion_button' type='button' value='Cancel' />                                \n                        </div>\n                </div>";
    }
}
Exemplo n.º 3
0
    ?>
        <body id="AchievementsList">
            <div id="error"></div>
                <div style='float:right;font-size:12px;'>
                    <?php 
    if (!isset($_SESSION['user'])) {
        ?>
                    Not logged in.
                    <a href='signup/' class='text-button' style='margin-left:2px;font-size:12px;float:right;'>[ Sign Up ]</a> 
                    <a href='login/' class='text-button' style='margin-left:4px;font-size:12px;float:right;'>[ Login ]</a>
                    
                    <?php 
    } elseif (fetch_current_user_id() != false) {
        ?>
                        Logged in as <?php 
        echo fetch_username(fetch_current_user_id()) . ". (" . fetch_user_points(fetch_current_user_id()) . ")";
        ?>
 
                        <span id='logout' class='hand text-button'> [ Logout ] </span>
                    <?php 
    }
    ?>
                </div>
            <?php 
    if (isset($_SESSION['user'])) {
        ?>
            <div>
                <input id="new_achievement_text_input" type='text' maxlength="255" />          
                <input id="new_achievement_button" type="button" value="Quick Create" />
            </div>
            <?php 
Exemplo n.º 4
0
function fetch_random_achievement_id($user_id)
{
    if ($user_id != 0 && fetch_current_user_id() == $user_id) {
        $query = "select id from achievements where deleted=0 and owner=? order by rand() limit 1";
    } else {
        if ($user_id == 0) {
            $query = "select id from achievements where deleted=0 and abandoned=0 and public=1 order by rand() limit 1";
        }
    }
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $statement = $connection->prepare($query);
    if ($user_id == 0) {
        $statement->bindValue(1, $user_id, PDO::PARAM_INT);
    }
    $statement->execute();
    return $statement->fetchColumn();
}
Exemplo n.º 5
0
            width:90px;
            float:left;
        }
    </style>
    <script src="<?php 
echo SITE_ROOT;
?>
/js/jquery-2.1.4.min.js"></script>
    <script src="<?php 
echo SITE_ROOT;
?>
/js/user.js"></script>
    <script src="<?php 
echo SITE_ROOT;
?>
/js/login.js"></script>
</head>
<body>
    <?php 
$user_id = fetch_current_user_id();
if ($user_id == false) {
    require_once "login.htm";
} else {
    if ($user_id != false) {
        echo "Logged in as " . fetch_username(fetch_current_user_id()) . ".";
    }
}
?>
</body></html>