2002 yhteensa-laskuriin minuutteihin nolla, jos < 10 Täydennetty 4.6.2003 /minna - tuntien kirjaaminen tapahtuman tyypin (luokan) mukaan Lisätty viikottainen tuntien laskeminen 27.1.2003 / minna 1.9.2004 minna PHP-verison päivitys: request-muuttujiin ei voi viitata pelkällä nimellä muuttujankäsittely muutettu muotoon $username --> $username = $_REQUEST["username"] lisäksi terra on poistuva kone ==> kaikki smbmountit pitää ohjata (julkiselle) w:lle 23.9.2004 otettu sessio käyttöön salasanan tallennuspaikkana riskejä: pitää ainakin katsoa, että ip on sama kuin alkuperisessä pyynnössä, muuten nillitään sessio logoutissa pitäis joka tapauksessa nilliä sessio ja tangon autentikointi vaihtunut kinitiksi. Huom: ei vastetta, siirtyikö tiedostoja!! + lisätty outputin kirjoitus tiedostoon, ja tiedoston siirto käyttäjän kotihakemistoon + todo: jospa tarkastettaisiin, ettei lisättäisi kahta tasan samanlaista riviä?? done ********************************************************************* */ ini_set("display_errors", "1"); ini_set("output_handler", "duplicate_output"); ini_set("implicit_flush", "0"); if (! is_dir("/tmp/raportti")) { exec("mkdir /tmp/raportti/"); } ob_start("duplicate_output"); session_start(); // if your session wasn't started yet if (isset( $_REQUEST["sid"])) { session_id($_REQUEST["sid"]); } /* -- Käytetyt funktiot ------------------------------------------------- */ function mylog($user, $msg) { $f = fopen("/var/www/virtual.hosts/www.mit.jyu.fi-https/raportit/mylog", "ab"); if ($f) { fwrite($f, "$user $msg \n"); fclose($f); } } /* lopettaa outputin tiedostoon kirjoittamisen - ohjelma ei saisi päättyä ilman tätä! */ function page_finish($move, $share, $username, $pw, $uploaddir) { ob_end_flush(); ini_set("output_handler", NULL); // get output from file $fr = fopen("/tmp/raportti/".session_id().".html", "rb"); if ($fr ) { while ( ! feof($fr) ) { print( fgets($fr, 1024)); } } fclose($fr); // siirretäänkös käyttäjälle? if ($move) { command($share, $username, $pw, "put /tmp/raportti/".session_id().".html ".$uploaddir."index.html"); } unlink("/tmp/raportti/".session_id().".html"); } function page_begin($title) { print( "\n"); ?> <? echo $title ?>
 

 
Toteutus ja ylläpito Minna Hillebrand, mmhilleb@mit.jyu.fi
Viimeksi päivitetty

Apua tuntikirjanpitoon!

Tällä ohjelmalla voit raportoida mm. sovellusprojektissa kuluneet työtuntisi. Helppiä käytöstä...

HUOM! Raportointi on siirtynyt käyttämään w-asemaa kotiaseman (u:n) sijaan. Vanhat u:lla olevat kirjanpidot pitää käsin siirtää w:lle vastaavaan hakemistoon.

Käyttäjätunnus " />   JYUNET
Salasana   JYUNET
Hakemistosi w:llä
$year2 ) return 1; if ( $month1 < $month2 ) return 0; if ( $month1 > $month2 ) return 1; if ( $day1 < $day2 ) return 0; if ( $day1 > $day2 ) return 1; $pos = strpos($t1, "$separate"); if ($pos === false) return 1; $h1 = substr($t1, 0, $pos); $m1 = substr($t1, $pos+1, 1024); $pos = strpos($t2, "$separate"); if ($pos === false) return 1; $h2 = substr($t2, 0, $pos); $m2 = substr($t2, $pos+1, 1024); if ( $h1 < $h2 ) return 0; if ( $h1 > $h2 ) return 1; if ( $m1 < $m2 ) return 0; return 1; } function calculate_hours($old, $time, $separ) { $total = ""; $hours = 0; $minutes = 0; if ($old=="") { $oldh=0; $oldm=0; } else { $endchar = strpos($old, "$separ"); if ($endchar === false) $endchar = 1024; $oldh = substr($old, 0, $endchar); $oldm = substr($old, $endchar+1, 1024); } $endchar = strpos($time, "$separ"); if ($endchar === false) $endchar = 1024; $newh = substr($time, 0, $endchar); $newm = substr($time, $endchar+1, 1024); $minutes = $oldm + $newm; $count = 0; while ($minutes >= 60 ) { $minutes -= 60; $count++; } $hours = $oldh + $newh + $count; $add=""; if ($minutes < 10 && $minutes != "00") $add="0"; $total = "$hours" ."$separ" .$add ."$minutes"; if ($minutes == 0) $total .= "0"; // muutettu 23.10. return $total; } function print_html_row($rowcalc, $paiva, $alku, $loppu, $kesto, $tyyppi, $kuvaus) { $rowcolor = "#F3F9FE"; if ($rowcalc % 2 == 0) $rowcolor="#F3F3F3"; echo " \n"; echo " ". $paiva ." \n"; echo " ". $alku ."-". $loppu ." \n"; echo " ". $kesto ." \n"; echo " ". $tyyppi ." \n"; echo " ".$kuvaus ."\n"; echo " \n"; } function print_txt_row($paiva, $alku, $loppu, $kesto, $tyyppi, $id, $kuvaus) { echo $paiva ."|". $alku ."|". $loppu ."|". $kesto ."|" . $tyyppi ."|" .$id ."|" .$kuvaus ."\n"; } // format dd.mm.yyyy into yyyy-mm-dd function formatDate($pvm) { $pos = strpos($pvm, "."); $day = substr($pvm, 0, $pos); $pvm = substr($pvm, $pos+1); $pos = strpos($pvm, "."); $month = substr($pvm, 0, $pos); $year = substr($pvm, $pos+1); return $year ."-". $month ."-". $day; } function updateWeekCounters($week_counters, $pvm, $duration, $separate) { if (($timestamp = strtotime(formatDate($pvm))) === -1) { // check validity //echo "$pvm ei kelpaa"; return $week_counters; } $weeknro = date("W", $timestamp); if ($weeknro > 0) $week_counters[$weeknro] = calculate_hours( $week_counters[$weeknro], $duration, $separate); return $week_counters; } function report($share, $user, $pw, $encodedPw, $path, $pvm, $alkaa, $paattyy, $tyyppi, $kuvaus, $print, $typelist, $showtypes, $showweeks) { /* ---- Logitetaan käyttäjä ja asetetaan muuttujia --------------------------------------*/ /* $f = fopen("mylog", "ab"); if ($f) { fwrite($f, "$user, "Logged in " .date("M j Y, G:i:s") ); fclose($f); } */ mylog($user, "Logged in " .date("M j Y, G:i:s")); if ( (strlen($path) != 0) && $path{strlen($path)-1} != "/" ) $path .= "/"; $up_path = substr($user, 0, 1) ."\\". $user ."\\" .str_replace("/", "\\", $path); // $up_path = str_replace("/", "\\", $path); aha, taas oli muuttunu // $url_path = $url . substr($user, 0, 1) ."/" .$user ."/" .$path; /* ---- Luodaan oikea hakemistorakenne ---------------------------------------------------*/ $token = strtok($up_path, "\\"); $wpath = ""; while ($token!="" && $token!="\\") { $wpath .= $token ."\\\\"; // kesti aika kauan hokasta, ett? tarvii 2 kpl kenoja... $com = "mkdir $wpath"; command($share, $user, $pw, $com); $token = strtok("\\"); } /* ---- Haetaan ajat.txt ---------------------------------------------------------------- */ $txtfile = "/tmp/" .$user ."ajat.txt"; // => /tmp/mmhillebajat.txt $tmptxtfile = "/tmp/" .$user ."tmpajat.txt"; // => /tmp/mmhillebtmpajat.txt $tmptexfile = "/tmp/" .$user ."tmpajat.tex"; // => /tmp/mmhillebtmpajat.tex $com = "get $up_path"."ajat.txt " .$txtfile; $result = command($share, $user, $pw, $com); if (! is_file($txtfile)) touch("$txtfile"); /* //if ( strpos($result, "getting file")===false ) { // tiedostoa ei ollut olemassa //echo $result; touch ("$txtfile"); $fw = fopen("$txtfile", "wb"); if ($fw) { // fwrite($fw, "= Projektiin käytetyt tunnit\n"); fclose($fw); } } */ /* ---- Haetaan username.ini-tiedosto ------------------------------------------------- */ $wholename = ""; // default values $subtitle = ""; $separate = ":"; $inifile = "/tmp/" .$user .".ini"; $com = "get $up_path$user".".ini " .$inifile; $result = command($share, $user, $pw, $com); if ( ! (strpos($result, "getting file")===false) ) { // read stuff from ini $fr= fopen("$inifile", "rb"); if ($fr) { $wholename = trim(fgets($fr, 1024)); $subtitle = trim(fgets($fr, 1024)); $separate = trim(fgets($fr, 1024)); if ($separate=="") $separate=":"; fclose($fr); } unlink("$inifile"); } /* ---- Luodaan tyyppilistat ja -laskurit -------------------------------------------- */ $type_names = array(); $type_counters = array(); $week_counters = array(); $fr= fopen("$typelist", "rb"); if ($fr) { while (! feof($fr)) { $newname = trim(fgets($fr, 1024)); if ( strlen($newname) <= 0) continue; $type_names[] = $newname; // adds to the end of array $type_counters[] = "0"; } } /* ---- Tarkastetaan kesto ja pvm - formaatit ----------------------------------------- */ // sallii syötön 17 => 17:00 if (strpos($alkaa, "$separate")===false) $alkaa = "$alkaa$separate" ."00"; if (strpos($paattyy, "$separate")===false) $paattyy = "$paattyy$separate" ."00"; // sallii syötöt 5.2 ja 5.2. => 5.2.2002 if (substr_count($pvm, ".") == 1) $pvm .= "."; if ($pvm{strlen($pvm)-1}==".") $pvm .= date("Y"); $kesto = duration($alkaa, $paattyy, $separate); //if (! ctype_digit($tyyppi)) $tyyppi=0; /* ---- Luetaan ajat.txt ja päivitetään samalla .txt ja .tex -tiedostot --------------- */ if ($print!="txt") page_begin("Raportoi tuntisi!"); if ($print!="makeprint" && $print!="txt") { ?>

Help!

Projektiin käytetyt tunnit

\n  
\n"; echo "\n" ?>
PÄIVÄMÄÄRÄ ALKAA - PÄÄTTYY KESTO LUOKKA KUVAUS
 
\n"; echo "\n"; echo "\n \n \n"; echo " \n"; echo "
\n"; if ($showtypes) { echo " \n \n"; for ($i=0; $i < count($type_names); $i++) { if (strlen($type_names[$i]) <= 0) continue; echo " \n "; echo " \n"; } echo " \n \n"; echo " \n"; } echo "
Luokittain:
". $type_names[$i] ."  " .$type_counters[$i]. "
Yhteensä:". $counter ."
   \n"; if ($showweeks) { echo "\n "; for ($i=0; $i < 53; $i++) { if (strlen($week_counters[$i]) <= 0) continue; echo " \n "; echo " \n"; } echo " \n \n"; echo " \n"; } echo "
Viikoittain:
Viikko $i  " .$week_counters[$i]. "
Yhteensä:". $counter ."
 
  Yhteensä:    0) { ?>

 

Lisää uusi aika [help!]

PVM Alku(hh:mm) Loppu(hh:mm) Luokka Tehtävä
 
Näytä tulostettava versio ja siirrä html-tiedosto kotilevyllesi
Näytä txt-versio
name="printtypes" value="types" /> Näytä tunnit luokitteluiden mukaan
name="printweeks" value="weeks" /> Näytä tunnit viikkojen mukaan
0) $_SESSION['pw'] = $pw; $pw = $_SESSION['pw']; $encodedPw = htmlentities(stripslashes($pw)); // txt-versio ajaa tulostettavan rastin yli $print = trim($_REQUEST["print"]); if (isset($printtxt) && $printtxt != "") $print = trim($printtxt); $typelist = trim($typelist); if ( (! isset($typelist)) || ($typelist == "") ) $typelist = "sovproj.list"; /* -- Yleisiä ympäristöriippuvaisia muuttujia ------------------------- */ //$destination_url = "http://www.it.jyu.fi/users/"; //$remoteserver = "//terra.it.jyu.fi/$username"; //$remoteserver = "//kilix.it.jyu.fi/MyWWW"; $remoteserver = "//tango.ad.jyu.fi/MyWWW"; if ( $username=="" || !authenticate($remoteserver, $username, $pw) ) log_in($username, $path, $typelist); else report($remoteserver, $username, $pw, $encodedPw, $path, $pvm, $alkaa, $paattyy, $tyyppi, $kuvaus, $print, $typelist, $showtypes, $showweeks); page_finish(false, null, null, null, null); ?>