示例#1
0
function toggle_locked_status($id)
{
    if (!user_owns_achievement($id)) {
        //BAD
        return;
    }
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $achievement = fetch_achievement($id);
    $status = $achievement->locked == 0 ? "now()" : "0";
    $statement = $connection->prepare("update achievements set locked={$status} where id=?");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
    $message = $achievement->locked ? "Achievement is now unlocked." : "Achievement is now locked.";
    create_history($id, $message);
}
示例#2
0
function fitnesslog_menu_logdata()
{
    $yearmoday = explode("-", $_SESSION["nav_month"]);
    // See if the users is trying to display a month other than the current month.
    if ($yearmoday != NULL) {
        $display_mo = new Date();
        $display_mo->setDayMonthYear($yearmoday[2], $yearmoday[1], $yearmoday[0]);
    } else {
        $display_mo = new Date();
    }
    //Set the date to the first day of the month.
    $display_mo->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear());
    // Get the previous day from the displayed month.
    $prevDay = $display_mo->getPrevDay();
    $prevDay->setDayMonthYear(1, $prevDay->getMonth(), $prevDay->getYear());
    // Get the next day in from the diplayed month.
    $display_mo->setDayMonthYear($display_mo->getDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear());
    $nextDay = $display_mo->getNextDay();
    echo '<div class="wrap">';
    echo '<h2>' . $display_mo->getMonthName() . " " . $display_mo->getYear() . " Totals</h2>";
    $nav_prev = '<a href="' . get_bloginfo('url') . '/wp-content/plugins/fitnesslog/ftnav.php?month=' . $prevDay->format("%Y-%m-%d") . '&source=summary">Previous Month</a>';
    echo '<p>' . $nav_prev . '&nbsp&nbsp&nbsp&nbsp&nbsp';
    $nav_cur = '<a href="' . get_bloginfo('url') . '/wp-content/plugins/fitnesslog/ftnav.php?source=summary">Current Month</a>';
    echo $nav_cur . '&nbsp&nbsp&nbsp&nbsp&nbsp';
    $display_mo->setDayMonthYear(1, $display_mo->getMonth() + 1, $display_mo->getYear());
    $nav_next = '<a href="' . get_bloginfo('url') . '/wp-content/plugins/fitnesslog/ftnav.php?month=' . $nextDay->format("%Y-%m-%d") . '&source=summary">Next Month</a>';
    echo $nav_next . '</p>';
    create_history();
    echo '</div>';
}
示例#3
0
    }
    //Set the date to the first day of the month.
    $display_mo->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear());
    // Get the previous day from the displayed month.
    $prevDay = $display_mo->getPrevDay();
    $prevDay->setDayMonthYear(1, $prevDay->getMonth(), $prevDay->getYear());
    // Get the next day in from the diplayed month.
    $display_mo->setDayMonthYear($display_mo->getDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear());
    $nextDay = $display_mo->getNextDay();
    $template->setCurrentBlock("NAVIGATION");
    $template->setVariable("MONTH", "{$display_mo->getMonthName()} {$display_mo->getYear()} Totals");
    $template->setVariable("PREVIOUS", $prevDay->format("%Y-%m-%d"));
    $template->setVariable("NEXT", $nextDay->format("%Y-%m-%d"));
    $template->parseCurrentBlock();
    //Display the current month's data.
    create_history($connection, $template);
} else {
    //Seems the user has attempted to navigate directly to the dashboard without
    //logging in. Send them to the logout page with an error message.
    $_SESSION["headerMessage"] = "Error!!";
    $_SESSION["message"] = "You must first log into the system before you can view the page.";
    // Send user to the logout page.
    header("Location: logout.php");
    exit;
}
//Show the user's Dashboard page.
$template->show();
/************************************* Helper functions *****************************************************/
function create_history($connection, $template)
{
    $userid = getUserID($connection);