예제 #1
0
파일: settings.php 프로젝트: Nicolai-/Hours
<?php 
// Hvis der er trykket gem, gemmer vi indstillinger i db og viser en OK-besked. Ellers viser vi 'Gem'-knappen.
if ($_POST['save']) {
    // Gem 'Forventede arbejdstider'
    mysql_query("UPDATE users SET expMondayFrom='" . $_POST['expMondayFrom'] . "', expTuesdayFrom='" . $_POST['expTuesdayFrom'] . "', expWednesdayFrom='" . $_POST['expWednesdayFrom'] . "', expThursdayFrom='" . $_POST['expThursdayFrom'] . "', expFridayFrom='" . $_POST['expFridayFrom'] . "' WHERE username='******'");
    mysql_query("UPDATE users SET expMondayTo='" . $_POST['expMondayTo'] . "', expTuesdayTo='" . $_POST['expTuesdayTo'] . "', expWednesdayTo='" . $_POST['expWednesdayTo'] . "', expThursdayTo='" . $_POST['expThursdayTo'] . "', expFridayTo='" . $_POST['expFridayTo'] . "' WHERE username='******'");
    mysql_query("UPDATE users SET expMondayPause='" . $_POST['expMondayPause'] . "', expTuesdayPause='" . $_POST['expTuesdayPause'] . "', expWednesdayPause='" . $_POST['expWednesdayPause'] . "', expThursdayPause='" . $_POST['expThursdayPause'] . "', expFridayPause='" . $_POST['expFridayPause'] . "' WHERE username='******'");
    // Vis at ændringer er gemt.
    echo "<center><i>Dine ændringer er gemt!</i></center><br>";
    // Hent nye data fra db
    $sql = mysql_query("SELECT * FROM users WHERE username = '******'");
    $settings = mysql_fetch_assoc($sql);
}
// Udregn totale antal forventede timer.
$totalExpectedTime = hoursToSeconds($settings['expMondayTo']) - hoursToSeconds($settings['expMondayFrom']) + (hoursToSeconds($settings['expTuesdayTo']) - hoursToSeconds($settings['expTuesdayFrom'])) + (hoursToSeconds($settings['expWednesdayTo']) - hoursToSeconds($settings['expWednesdayFrom'])) + (hoursToSeconds($settings['expThursdayTo']) - hoursToSeconds($settings['expThursdayFrom'])) + (hoursToSeconds($settings['expFridayTo']) - hoursToSeconds($settings['expFridayFrom']));
$totalExpectedTime = $totalExpectedTime - ($settings['expMondayPause'] + $settings['expTuesdayPause'] + $settings['expWednesdayPause'] + $settings['expThursdayPause'] + $settings['expFridayPause']) * 60;
if ($totalExpectedTime < 133200) {
    $diff = secondsToHours(133200 - $totalExpectedTime);
    $totalExpectedTime = "<font color='red'>" . secondsToHours($totalExpectedTime) . " ( -" . $diff . " )</font>";
} else {
    if ($totalExpectedTime == 133200) {
        $totalExpectedTime = "<font color='green'>" . secondsToHours($totalExpectedTime) . "</font>";
    } else {
        $diff = secondsToHours($totalExpectedTime - 133200);
        $totalExpectedTime = "<font color='green'>" . secondsToHours($totalExpectedTime) . " ( +" . $diff . " )</font>";
    }
}
// Udskriv indstillinger.
echo "<form method='POST' action='settings.php'>";
echo "<tr><th colspan='2' class='title'>Forventede arbejdstider</th></tr>";
예제 #2
0
 public function completeFileUpload($fileData = array())
 {
     extract($fileData);
     $sendTo = explode(',', $fileData['recipients']);
     $randlib = new random();
     $tempPath = BASEDIR . '/data/temp/' . $uuid;
     $files = glob($tempPath . '/*');
     $fileList = $files;
     if (!empty($files)) {
         $fileDetails = array();
         $totalFilesize = array();
         foreach ($files as $key => $value) {
             $fileSizeInBytes = filesize($value);
             $totalFilesize[] = $fileSizeInBytes;
             $fileDetails[$key]['name'] = basename($value);
             $fileDetails[$key]['size'] = bytesToHumanReadable($fileSizeInBytes);
             $fileDetails[$key]['bytes'] = $fileSizeInBytes;
             $fileDetails[$key]['path'] = $value;
             $files[$key] = array();
             $files[$key] = $fileDetails[$key];
             $files[$key]['size'] = $fileSizeInBytes;
         }
     }
     $data = array();
     $data['uuid'] = $uuid;
     $data['token'] = $randlib->generateRandomString(rand(SITE_TOKEN_MIN_LENGTH, SITE_TOKEN_MAX_LENGTH));
     if (strlen(trim($fileMessage))) {
         $data['comment'] = $fileMessage;
     }
     $data['upload_date'] = time();
     $data['expiration_date'] = time() + hoursToSeconds(SITE_GUEST_UPLOAD_RETENTION);
     $data['uploader_ip'] = $_SERVER['REMOTE_ADDR'];
     if (!$this->_WeTransfer_Users->usernameExists($email)) {
         $userData = array();
         $userData['email'] = $email;
         $createUser = $this->_WeTransfer_Users->createUser($userData);
     }
     $user = $this->_WeTransfer_Users->fetchUserDetailsByUsername($email);
     if (!empty($user)) {
         $data['uploader'] = $user['id'];
         $data['direct_url'] = PROTOCOL_RELATIVE_URL . '/transfer/' . $data['token'];
         $destination = BASEDIR . '/' . SITE_UPLOAD_DIR_USERS . '/' . $user['id'] . '/' . $uuid;
         $data['file_path'] = $destination . '/' . SITE_ARCHIVE_PREFIX . $data['token'] . '.zip';
         $data['total_file_size'] = array_sum($totalFilesize);
         if (!file_exists($destination)) {
             mkdir($destination, 0777, true);
         }
         if (file_exists($destination)) {
             if ((int) SITE_ZIP_VIA_BASH == 1) {
                 $zip = $this->zipFilesViaBash($data['token'], $destination, $fileList, $tempPath);
             } else {
                 $zip = $this->zipFiles($data['token'], $destination, $fileList);
             }
         }
         if ($zip) {
             if (file_exists($tempPath)) {
                 $delete = deltree($tempPath);
                 if (!$delete) {
                     error_log("[" . date("m-d-Y, H:i:s") . "] ERROR:  failed to delete files in " . $tempPath . "\n");
                 }
             }
             // insert in the DB
             $dbId = (int) $this->addFiles($data, $files);
             if ($dbId > 0) {
                 // START:	add recipients to DB
                 $this->addRecipients($sendTo, $dbId);
                 // END:		add recipients to DB
                 $notify = $this->notifyUploader($email, $data['token'], $fileDetails, $sendTo);
                 if (!$notify) {
                     error_log("[" . date("m-d-Y, H:i:s") . "] ERROR:  failed to notify " . $email . " about upload success of " . $uuid . "\n");
                 }
                 $notify = $this->notifyRecipients($dbId, $email, $fileDetails, $sendTo);
                 if (!$notify) {
                     error_log("[" . date("m-d-Y, H:i:s") . "] ERROR:  failed to notify recipients about available download of " . $uuid . "\n");
                 }
                 $json = array();
                 $json['status'] = 'OK';
                 // return JSON
                 return json_encode($json);
             }
         } else {
             $json = array();
             $json['status'] = 'ERROR';
             $json['error'] = 'FILE_ZIP';
             // return JSON
             return json_encode($json);
         }
     }
 }
예제 #3
0
    } else {
        echo "<tr>";
    }
    echo "<td>" . $row['week'] . "</td>";
    echo "<td>" . $row['day'] . "</td>";
    echo "<td>" . $row['date'] . "</td>";
    echo "<td>" . $row['checkin'] . "</td>";
    if ($row['checkout'] == "00:00:00") {
        $row['checkout'] = "-";
    }
    echo "<td>" . $row['checkout'] . "</td>";
    echo "<td>" . $row['pause'] . " min</td>";
    if ($row['worktime'] == "00:00:00") {
        $worktime = "-";
    } else {
        $worktime = hoursToSeconds($row['worktime']) - $row['pause'] * 60;
        $worktime = secondsToHours($worktime);
    }
    echo "<td>" . $worktime . "</td>";
    echo "<td>" . $row['comment'] . "</td>";
    echo "</tr>";
}
?>
		</table><br><br>
	<form action="deleteEntry.php" method="POST">
	<input type="hidden" name="deleteID" value="<?php 
echo $id;
?>
">
	<input type="submit" name="ja" value="Ja" />
	<a href="overview.php"><input type="submit" name="nej" value="Nej" /></a>
예제 #4
0
            if ($result['date'] == date("Y-m-d") && $day['worktime'] == date('00:00:00') && $status == 1) {
                $worktimeThisCheck = hoursToSeconds(tid()) - hoursToSeconds($day['checkin']) - $day['pause'] * 60;
            } else {
                $worktimeThisCheck = hoursToSeconds($day['worktime']) - $day['pause'] * 60;
            }
            $worktimeThisDay += $worktimeThisCheck;
        }
        $balanceToday = $worktimeThisDay - 26640;
        $balance += $balanceToday;
        array_push($DatesCalculated, $result['date']);
    } else {
        if ($entriesThisDay == 1) {
            if ($result['date'] == date("Y-m-d") && $result['worktime'] == date('00:00:00') && $status == 1) {
                $worktimeThisDay = hoursToSeconds(tid()) - hoursToSeconds($result['checkin']) - $result['pause'] * 60;
            } else {
                $worktimeThisDay = hoursToSeconds($result['worktime']) - $result['pause'] * 60;
            }
            $balanceToday = $worktimeThisDay - 26640;
            $balance += $balanceToday;
        }
    }
}
// Formater balance
if ($balance >= 26640) {
    $feriedage = mround($balance / 26640, 0);
    $balance -= $feriedage * 26640;
}
if ($balance < 0) {
    $image = "negative";
    $color = "red";
} else {