Exemple #1
0
 if (isset($_POST['submitform']) && $all_ok == true) {
     if (isset($_POST['r']) && $_POST['r'] >= -3 && $_POST['r'] <= 3 && $mark_as_rated == true) {
         //mark_as_rated to avoid possbility to set rate to 0,1,2 then change to Comment log type and actually give score (what could take place before!)!
         // oceniono skrzynkę
         $is_scored_query = XDb::xMultiVariableQueryValue("SELECT count(*) FROM scores WHERE user_id= :1 AND cache_id= :2 ", -1, $usr['userid'], $cache_id);
         if ($is_scored_query == 0 && $usr['userid'] != $record['user_id']) {
             XDb::xSql("UPDATE caches SET score=(score*votes+" . XDb::xEscape(floatval($_POST['r'])) . ")/(votes+1), votes=votes+1\n                            WHERE cache_id= ?", $cache_id);
             XDb::xSql("INSERT INTO scores (user_id, cache_id, score) VALUES( ? , ? , ? )", $usr['userid'], $cache_id, $_POST['r']);
         }
     } else {
         // nie wybrano opcji oceny
     }
     $log_date = date('Y-m-d H:i:s', mktime($log_date_hour, $log_date_min, 0, $log_date_month, $log_date_day, $log_date_year));
     $log_uuid = create_uuid();
     $logDateTime = new DateTime($log_date);
     if (!compareTime($logDateTime, "PT1H")) {
         //if logging time is older then now-one_hour
         $_SESSION["lastLogDateTime"] = $logDateTime;
         //we store the time
         $_SESSION["lastLogSendTime"] = new DateTime("now");
     } else {
         unset($_SESSION["lastLogSendTime"]);
         //next time we log with "now" datetime
         unset($_SESSION["lastLogDateTime"]);
     }
     //add logentry to db
     if ($log_type < 0) {
         // nie wybrano typu logu
     } elseif (!($log_type == 3 && $log_text == "")) {
         if ($log_type == 1) {
             /* GeoKretyApi: call method logging selected Geokrets  (by Łza) */
<?php

session_start();
$email = $_SESSION['user'];
$scheduleName = $_POST['name'];
$startTime = $_POST['startTime'];
$endTime = $_POST['endTime'];
if (compareTime($startTime, $endTime) !== "Invalid Time") {
    require_once "config.php";
    $db = loadDatabase();
    $userId = getUserId($db, $email);
    insertIntoSchedule($db, $userId, $scheduleName, $startTime, $endTime);
} else {
    echo "Invalid Time";
}
function compareTime($startTime, $endTime)
{
    $startTime = explode(':', $startTime);
    $endTime = explode(':', $endTime);
    if ($endTime[0] >= $startTime[0] || $endTime[0] >= $startTime[0] && $endTime[1] > $startTime[1]) {
        return true;
    } else {
        return "Invalid Time";
    }
}
function getUserId($db, $email)
{
    $userIdQuery = "SELECT id FROM user WHERE email=?";
    $userIdQuery = $db->prepare($userIdQuery);
    $userIdQuery->execute(array($email));
    return $userIdQuery->fetchColumn();