Exemplo n.º 1
0
function student_zadaca()
{
    global $userid, $conf_files_path;
    require "lib/autotest.php";
    // Akcije
    if ($_REQUEST['akcija'] == "slanje") {
        akcijaslanje();
        return;
    }
    // Poslani parametri
    $zadaca = intval($_REQUEST['zadaca']);
    $predmet = intval($_REQUEST['predmet']);
    $ag = intval($_REQUEST['ag']);
    $q10 = myquery("select naziv from predmet where id={$predmet}");
    if (mysql_num_rows($q10) < 1) {
        zamgerlog("nepoznat predmet {$predmet}", 3);
        // nivo 3: greska
        zamgerlog2("nepoznat predmet", $predmet);
        biguglyerror("Nepoznat predmet");
        return;
    }
    $q15 = myquery("select naziv from akademska_godina where id={$ag}");
    if (mysql_num_rows($q10) < 1) {
        zamgerlog("nepoznata akademska godina {$ag}", 3);
        // nivo 3: greska
        zamgerlog2("nepoznata akademska godina", $ag);
        // nivo 3: greska
        biguglyerror("Nepoznata akademska godina");
        return;
    }
    // Da li student slusa predmet?
    $q17 = myquery("select sp.predmet from student_predmet as sp, ponudakursa as pk where sp.student={$userid} and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag}");
    if (mysql_num_rows($q17) < 1) {
        zamgerlog("student ne slusa predmet pp{$predmet}", 3);
        zamgerlog2("student ne slusa predmet", $predmet, $ag);
        biguglyerror("Niste upisani na ovaj predmet");
        return;
    }
    $ponudakursa = mysql_result($q17, 0, 0);
    //  IMA LI AKTIVNIH?
    // TODO: provjeriti da li je aktivan modul...
    $q10 = myquery("select count(*) from zadaca where predmet={$predmet} and akademska_godina={$ag} and aktivna=1");
    if (mysql_result($q10, 0, 0) == 0) {
        zamgerlog("nijedna zadaća nije aktivna, predmet pp{$predmet}", 3);
        zamgerlog2("nijedna zadaca nije aktivna", $predmet);
        niceerror("Nijedna zadaća nije aktivna");
        return;
    }
    //  ODREĐIVANJE ID ZADAĆE
    // Da li neko pokušava da spoofa zadaću?
    if ($zadaca != 0) {
        $q20 = myquery("SELECT count(*) FROM zadaca as z, student_predmet as sp, ponudakursa as pk\n\tWHERE sp.student={$userid} and sp.predmet=pk.id and pk.predmet=z.predmet and pk.akademska_godina=z.akademska_godina and z.id={$zadaca}");
        if (mysql_result($q20, 0, 0) == 0) {
            zamgerlog("student nije upisan na predmet (zadaca z{$zadaca})", 3);
            zamgerlog2("student ne slusa predmet za zadacu", $zadaca);
            biguglyerror("Ova zadaća nije iz vašeg predmeta");
            return;
        }
    }
    // Ili predmet
    if ($ponudakursa != 0) {
        $q25 = myquery("select count(*) from student_predmet where student={$userid} and predmet={$ponudakursa}");
        if (mysql_result($q25, 0, 0) == 0) {
            zamgerlog("student nije upisan na predmet (predmet p{$ponudakursa})", 3);
            zamgerlog2("student ne slusa ponudukursa", $ponudakursa);
            biguglyerror("Niste upisani na ovaj predmet");
            return;
        }
        // Odgovarajuci predmet i zadaca
        if ($zadaca != 0) {
            $q27 = myquery("select count(*) from zadaca where id={$zadaca} and predmet={$predmet} and akademska_godina={$ag}");
            if (mysql_result($q27, 0, 0) == 0) {
                zamgerlog("zadaca i predmet ne odgovaraju (predmet p{$ponudakursa}, zadaca z{$zadaca})", 3);
                zamgerlog2("zadaca i ponudakursa ne odgovaraju", $ponudakursa, $zadaca);
                biguglyerror("Ova zadaća nije iz vašeg predmeta");
                return;
            }
        }
    }
    // Nije izabrana konkretna zadaca
    if ($zadaca == 0) {
        // Zadnja zadaca na kojoj je radio/la
        $q30 = myquery("SELECT z.id FROM zadatak as zk, zadaca as z\n\tWHERE z.id=zk.zadaca and z.aktivna=1 and z.rok>curdate() and z.predmet={$predmet} and z.akademska_godina={$ag} and zk.student={$userid}\n\tORDER BY z.id DESC LIMIT 1");
        if (mysql_num_rows($q30) > 0) {
            $zadaca = mysql_result($q30, 0, 0);
        } else {
            // Nije radio ni na jednoj od aktivnih zadaca$predmet_id
            // Daj najstariju aktivnu zadacu
            $q40 = myquery("select id from zadaca where predmet={$predmet} and akademska_godina={$ag} and rok>curdate() and aktivna=1 order by id limit 1");
            if (mysql_num_rows($q40) > 0) {
                $zadaca = mysql_result($q40, 0, 0);
            } else {
                // Ako ni ovdje nema rezultata, znači da je svim
                // zadaćama istekao rok. Daćemo zadnju zadaću.
                // Da li ima aktivnih provjerili smo u $q10
                $q50 = myquery("select id from zadaca where predmet={$predmet} and akademska_godina={$ag} and aktivna=1 order by id desc limit 1");
                $zadaca = mysql_result($q50, 0, 0);
            }
        }
    }
    // Standardna lokacija zadaca:
    $lokacijazadaca = "{$conf_files_path}/zadace/{$predmet}-{$ag}/{$userid}/";
    // Ove vrijednosti će nam trebati kasnije
    $q60 = myquery("select naziv,zadataka,UNIX_TIMESTAMP(rok),programskijezik,attachment,dozvoljene_ekstenzije from zadaca where id={$zadaca}");
    $naziv = mysql_result($q60, 0, 0);
    $brojzad = mysql_result($q60, 0, 1);
    $rok = mysql_result($q60, 0, 2);
    $jezik = mysql_result($q60, 0, 3);
    $attachment = mysql_result($q60, 0, 4);
    $zadaca_dozvoljene_ekstenzije = mysql_result($q60, 0, 5);
    //  ODREĐIVANJE ZADATKA
    // Poslani parametar:
    $zadatak = intval($_REQUEST['zadatak']);
    if ($zadatak == 0) {
        // Prvi neurađeni zadatak u datoj zadaći
        // NOTE: subquery
        $q70 = myquery("select zk.redni_broj from zadatak as zk where zk.student={$userid} and zk.zadaca={$zadaca} and (select count(*) from zadatak as zk2 where zk2.student={$userid} and zk2.zadaca={$zadaca} and zk2.redni_broj=zk.redni_broj)=0 order by zk.redni_broj limit 1");
        if (mysql_num_rows($q70) > 0) {
            $zadatak = mysql_result($q70, 0, 0);
        } else {
            $zadatak = $brojzad;
        }
    }
    // Akcije vezane za autotest
    if ($_REQUEST['akcija'] == "test_detalji") {
        $test = intval($_REQUEST['test']);
        // Provjera spoofinga testa
        $q10 = myquery("SELECT COUNT(*) FROM autotest WHERE id={$test} AND zadaca={$zadaca} AND zadatak={$zadatak}");
        if (mysql_result($q10, 0, 0) == 0) {
            niceerror("Odabrani test nije sa odabrane zadaće.");
            return;
        }
        autotest_detalji($test, $userid, false);
        return;
    }
    if ($_REQUEST['akcija'] == "test_sa_kodom") {
        if ($attachment) {
            niceerror("Download zadaće poslane kao attachment sa ugrađenim testnim kodom trenutno nije podržano.");
            return;
        }
        $test = intval($_REQUEST['test']);
        // Provjera spoofinga testa
        $q10 = myquery("SELECT COUNT(*) FROM autotest WHERE id={$test} AND zadaca={$zadaca} AND zadatak={$zadatak}");
        if (mysql_result($q10, 0, 0) == 0) {
            niceerror("Odabrani test nije sa odabrane zadaće.");
            return;
        }
        $kod = autotest_sa_kodom($test, $userid, false);
        ?>
	<textarea rows="20" cols="80" name="program" wrap="off"><?php 
        echo $kod;
        ?>
</textarea>
	<?php 
        return;
    }
    //  NAVIGACIJA
    print "<br/><br/><center><h1>{$naziv}, Zadatak: {$zadatak}</h1></center>\n";
    // Statusne ikone:
    $stat_icon = array("zad_bug", "zad_preg", "zad_copy", "zad_bug", "zad_preg", "zad_ok");
    $stat_tekst = array("Bug u programu", "Pregled u toku", "Zadaća prepisana", "Bug u programu", "Pregled u toku", "Zadaća OK");
    ?>


<!-- zadace -->
<center>
<table cellspacing="0" cellpadding="2" border="0" id="zadace">
	<thead>
		<tr>
<?php 
    ?>
	<td>&nbsp;</td>
<?php 
    // Zaglavlje tabele - potreban nam je max. broj zadataka u zadaci
    $q20 = myquery("select zadataka from zadaca where predmet={$predmet} and akademska_godina={$ag} order by zadataka desc limit 1");
    $broj_zadataka = mysql_result($q20, 0, 0);
    for ($i = 1; $i <= $broj_zadataka; $i++) {
        ?>
<td>Zadatak <?php 
        echo $i;
        ?>
.</td><?php 
    }
    ?>
		<td>Rok za slanje</td>
		</tr>
	</thead>
<tbody>
<?php 
    // Tijelo tabele
    // LEGENDA STATUS POLJA:
    // 0 - nepoznat status
    // 1 - nova zadaća
    // 2 - prepisana
    // 3 - ne može se kompajlirati
    // 4 - prošla test, predstoji kontrola
    // 5 - pregledana
    /* Ovo se sve moglo kroz SQL rijesiti, ali necu iz razloga:
    1. PHP je citljiviji
    2. MySQL <4.1 ne podrzava subqueries */
    $bodova_sve_zadace = 0;
    $q21 = myquery("select id, naziv, bodova, zadataka, UNIX_TIMESTAMP(rok) from zadaca where predmet={$predmet} and akademska_godina={$ag} order by komponenta, id");
    while ($r21 = mysql_fetch_row($q21)) {
        $m_zadaca = $r21[0];
        $m_mogucih += $r21[2];
        $m_maxzadataka = $r21[3];
        ?>
<tr>
	<th><?php 
        echo $r21[1];
        ?>
</th>
	<?php 
        for ($m_zadatak = 1; $m_zadatak <= $broj_zadataka; $m_zadatak++) {
            // Ako tekuća zadaća nema toliko zadataka, ispisujemo blank polje
            if ($m_zadatak > $m_maxzadataka) {
                ?>
<td>&nbsp;</td><?php 
                continue;
            }
            // Uzmi samo rjesenje sa zadnjim IDom
            $q22 = myquery("select status,bodova,komentar from zadatak where student={$userid} and zadaca={$m_zadaca} and redni_broj={$m_zadatak} order by id desc limit 1");
            if ($m_zadaca == $zadaca && $m_zadatak == $zadatak) {
                $bgcolor = ' bgcolor="#DDDDFF"';
            } else {
                $bgcolor = "";
            }
            if (mysql_num_rows($q22) < 1) {
                ?>
<td <?php 
                echo $bgcolor;
                ?>
><a href="?sta=student/zadaca&predmet=<?php 
                echo $predmet;
                ?>
&ag=<?php 
                echo $ag;
                ?>
&zadaca=<?php 
                echo $m_zadaca;
                ?>
&zadatak=<?php 
                echo $m_zadatak;
                ?>
"><img src="images/16x16/zad_novi.png" width="16" height="16" border="0" align="center" title="Novi zadatak" alt="Novi zadatak"></a></td><?php 
            } else {
                $status = mysql_result($q22, 0, 0);
                $bodova_zadatak = mysql_result($q22, 0, 1);
                if (strlen(mysql_result($q22, 0, 2)) > 2) {
                    $imakomentar = "<img src=\"images/16x16/komentar.png\"  width=\"15\" height=\"14\" border=\"0\" title=\"Ima komentar\" alt=\"Ima komentar\" align=\"center\">";
                } else {
                    $imakomentar = "";
                }
                ?>
<td <?php 
                echo $bgcolor;
                ?>
><a href="?sta=student/zadaca&predmet=<?php 
                echo $predmet;
                ?>
&ag=<?php 
                echo $ag;
                ?>
&zadaca=<?php 
                echo $m_zadaca;
                ?>
&zadatak=<?php 
                echo $m_zadatak;
                ?>
"><img src="images/16x16/<?php 
                echo $stat_icon[$status];
                ?>
.png" width="16" height="16" border="0" align="center" title="<?php 
                echo $stat_tekst[$status];
                ?>
" alt="<?php 
                echo $stat_tekst[$status];
                ?>
"> <?php 
                echo $bodova_zadatak;
                ?>
 <?php 
                echo $imakomentar;
                ?>
</a></td>
	<?php 
            }
        }
        ?>
		<td><?php 
        if ($r21[4] < time()) {
            print "<font color=\"red\">";
        }
        print date("d. m. Y. H:i:s", $r21[4]);
        if ($r21[4] < time()) {
            print "</font>";
        }
        ?>
</td>
	</tr>
	<?php 
    }
    ?>
</tbody>
</table>
</center>
<?php 
    //  PORUKE I KOMENTARI
    // Upit za izvjestaj skripte i komentar tutora
    ?>
<br/><br/>
<center>
<table width="600" border="0"><tr><td>
<?php 
    $q110 = myquery("select izvjestaj_skripte, komentar, userid, status, bodova from zadatak where student={$userid} and zadaca={$zadaca} and redni_broj={$zadatak} order by id desc limit 1");
    if (mysql_num_rows($q110) > 0) {
        $poruka = mysql_result($q110, 0, 0);
        $komentar = mysql_result($q110, 0, 1);
        $tutor = mysql_result($q110, 0, 2);
        $status_zadace = mysql_result($q110, 0, 3);
        $bodova = mysql_result($q110, 0, 4);
        // Statusni ekran
        autotest_status_display($userid, $zadaca, $zadatak, false);
        // Vrijeme slanja - to neće biti isti slog kao onaj koji vraća $q110 jer taj je možda status koji je upisao tutor
        $q113 = myquery("SELECT UNIX_TIMESTAMP(vrijeme) FROM zadatak WHERE student={$userid} AND userid={$userid} AND zadaca={$zadaca} AND redni_broj={$zadatak} ORDER BY id DESC LIMIT 1");
        if (mysql_num_rows($q113) > 0) {
            ?>
		<p>Zadatak poslan: <?php 
            echo date("d.m.Y. H:i:s", mysql_result($q113, 0, 0));
            ?>
</p>
		<?php 
        } else {
            ?>
		<p>Zadatak nije poslan (tutor upisao/la bodove)</p>
		<?php 
        }
        // Rezultati automatskog testiranja
        $nalaz_autotesta = autotest_tabela($userid, $zadaca, $zadatak, false);
        if ($nalaz_autotesta != "") {
            print "<p>Rezultati testiranja:</p>\n{$nalaz_autotesta}\n";
        }
        // Poruke i komentari tutora
        if (preg_match("/\\w/", $poruka)) {
            $poruka = str_replace("\n", "<br/>\n", $poruka);
            ?>
<p>Poruka kod kompajliranja:<br/><b><?php 
            echo $poruka;
            ?>
</b></p><?php 
        }
        if (preg_match("/\\w/", $komentar)) {
            $komentar = str_replace("\n", "<br/>\n", $komentar);
            // Link za odgovor na komentar
            $link = "";
            if ($tutor > 0) {
                $q115 = myquery("select a.login,o.ime,o.prezime from auth as a, osoba as o where o.id={$tutor} and a.id=o.id");
                $naslov = urlencode("Odgovor na komentar ({$naziv}, Zadatak {$zadatak})");
                $tekst = urlencode("> {$komentar}");
                $primalac = urlencode(mysql_result($q115, 0, 0) . " (" . mysql_result($q115, 0, 1) . " " . mysql_result($q115, 0, 2) . ")");
                $link = " (<a href=\"?sta=common/inbox&akcija=compose&naslov={$naslov}&tekst={$tekst}&primalac={$primalac}\">odgovor</a>)";
            }
            ?>
<p>Komentar tutora: <b><?php 
            echo $komentar;
            ?>
</b><?php 
            echo $link;
        }
    }
    // Istek roka za slanje zadace
    if ($rok <= time()) {
        print "<p><b>Vrijeme za slanje ove zadaće je isteklo.</b></p>";
        // Ovo je onemogućavalo copy&paste u Firefoxu :(
        //$readonly = "DISABLED";
    } else {
        $readonly = "";
    }
    //  FORMA ZA SLANJE
    if ($attachment) {
        print "</td></tr></table>\n";
        // Attachment
        $q120 = myquery("select filename,UNIX_TIMESTAMP(vrijeme) from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$userid} order by id desc limit 1");
        if (mysql_num_rows($q120) > 0) {
            $filename = mysql_result($q120, 0, 0);
            $the_file = "{$lokacijazadaca}/{$zadaca}/{$filename}";
            if ($filename && file_exists("{$conf_files_path}/zadace/{$predmet}-{$ag}") && file_exists($the_file)) {
                // Utvrđujemo stvarno vrijeme slanja
                $q130 = myquery("SELECT UNIX_TIMESTAMP(vrijeme) from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$userid} and userid={$userid} order by id desc limit 1");
                if (mysql_num_rows($q130) > 0) {
                    $vrijeme = mysql_result($q130, 0, 0);
                } else {
                    $vrijeme = mysql_result($q120, 0, 1);
                }
                $vrijeme = date("d. m. Y. H:i:s", $vrijeme);
                $velicina = nicesize(filesize($the_file));
                $icon = "images/mimetypes/" . getmimeicon($the_file);
                $dllink = "index.php?sta=common/attachment&zadaca={$zadaca}&zadatak={$zadatak}";
                ?>
			<center><table width="75%" border="1" cellpadding="6" cellspacing="0" bgcolor="#CCCCCC"><tr><td>
			<a href="<?php 
                echo $dllink;
                ?>
"><img src="<?php 
                echo $icon;
                ?>
" border="0"></a>
			</td><td>
			<p>Poslani fajl: <b><a href="<?php 
                echo $dllink;
                ?>
"><?php 
                echo $filename;
                ?>
</a></b><br/>
			Datum slanja: <b><?php 
                echo $vrijeme;
                ?>
</b><br/>
			Veličina: <b><?php 
                echo $velicina;
                ?>
</b></p>
			</td></tr></table></center>
			<?php 
                print "<p>Ako želite promijeniti datoteku iznad, izaberite novu i kliknite na dugme za slanje:</p>";
            }
        } else {
            print "<p>Izaberite datoteku koju želite poslati i kliknite na dugme za slanje.";
            if ($zadaca_dozvoljene_ekstenzije != "") {
                print " Dozvoljeni su sljedeći tipovi datoteka: <b>{$zadaca_dozvoljene_ekstenzije}</b>.";
            }
            print "</p>\n";
        }
        ?>

	<form action="index.php" method="POST" enctype="multipart/form-data">
	<input type="hidden" name="sta" value="student/zadaca">
	<input type="hidden" name="akcija" value="slanje">
	<input type="hidden" name="predmet" value="<?php 
        echo $predmet;
        ?>
">
	<input type="hidden" name="ag" value="<?php 
        echo $ag;
        ?>
">
	<input type="hidden" name="zadaca" value="<?php 
        echo $zadaca;
        ?>
">
	<input type="hidden" name="zadatak" value="<?php 
        echo $zadatak;
        ?>
">
	<input type="hidden" name="labgrupa" value="<?php 
        echo $labgrupa;
        ?>
">
	<input type="file" name="attachment" size="50">
	</center>
	<p>&nbsp;</p>
	<?php 
    } else {
        // Forma
        $q130 = myquery("select ekstenzija from programskijezik where id={$jezik}");
        $ekst = mysql_result($q130, 0, 0);
        if ($status_zadace == 2) {
            ?>
<p>Zadaća je prepisana i ne može se ponovo poslati</p><?php 
        } else {
            if ($rok > time()) {
                ?>
<p>Kopirajte vaš zadatak u tekstualno polje ispod:</p>
		</td></tr></table>

		<?php 
            }
        }
        // Moze li se izbaciti labgrupa ispod?
        ?>
	
		</td></tr></table>
	<center>
	<?php 
        echo genform("POST");
        ?>
	<input type="hidden" name="zadaca" value="<?php 
        echo $zadaca;
        ?>
">
	<input type="hidden" name="zadatak" value="<?php 
        echo $zadatak;
        ?>
">
	<input type="hidden" name="akcija" value="slanje">
	<input type="hidden" name="labgrupa" value="<?php 
        echo $labgrupa;
        ?>
">
	
	<textarea rows="20" cols="80" name="program" <?php 
        echo $readonly;
        ?>
 wrap="off"><?php 
        $the_file = "{$lokacijazadaca}{$zadaca}/{$zadatak}{$ekst}";
        $tekst_zadace = "";
        if (file_exists("{$conf_files_path}/zadace/{$predmet}-{$ag}") && file_exists($the_file)) {
            $tekst_zadace = join("", file($the_file));
        }
        $tekst_zadace = htmlspecialchars($tekst_zadace);
        print $tekst_zadace;
        ?>
</textarea>
	</center>	

	<?php 
    }
    ?>

<center><input type="submit" value=" Pošalji zadatak! "></center>
</form>
<?php 
}
Exemplo n.º 2
0
         $pi = pathinfo($linkTarget);
         $scriptDir = dirname($_SERVER["SCRIPT_FILENAME"]);
         if (strpos($pi["dirname"], $scriptDir) === 0) {
             $f["type"] = "&lt;LINK&gt;";
             // links have no date, so take the target's date
             $f["date"] = filemtime($linkTarget);
             $f["link"] = $path . urlencode(substr($linkTarget, strlen($scriptDir) + 1));
         } else {
             // link target is outside of script directory, so skip it
             continue;
         }
     } else {
         $fSize = @filesize($entry);
         $f["size"] = $fSize;
         $f["fullSize"] = number_format($fSize, 0, ".", ",");
         $f["niceSize"] = nicesize($fSize);
         $pi = pathinfo($entry);
         $f["type"] = $pi["extension"];
         $f["link"] = myEncode($path, $entry);
         if (in_array("cvsversion", $displayColumns)) {
             $f["cvsversion"] = getVersion($entry);
         }
     }
 }
 if (!$f["isBack"]) {
     $f["displayName"] = htmlentities(iTrunc($f["name"], $truncateLength));
 }
 $f["filetype"] = getFileType($f);
 $f["icon"] = getIcon($f["filetype"]);
 if ($useAutoThumbnails && $f["filetype"] == "image") {
     $f["thumbnail"] = "<a href=\"" . urldecode($f["link"]) . "\"><img src=\"" . $PHP_SELF . "?thumbnail=" . urlencode($path . $f["name"]) . "\" style=\"text-align: left;\" alt=\"\"/></a>";
Exemplo n.º 3
0
					</tr>	
					</table>
			</td>
		</tr>
		<?php 
        $total += filesize(BACKUP_DBPATH . $dbFiles[$i]);
    }
    ?>
		<tr  bgcolor="#FFFFFF">
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align="center">
			<?php 
    $totalSizeDB = explode(" ", nicesize($total));
    ?>
				<table  border="0" width="15%">
				<tr>
					<td align="right" width="30%"><b><?php 
    echo $totalSizeDB[0];
    ?>
</b></td>
					<td width="25%" align="left"><b><?php 
    echo $totalSizeDB[1];
    ?>
</b></td>
				</tr>	
				</table>
			</td>
		</tr>		
Exemplo n.º 4
0
}
?>

			<tr bgcolor="#CCCCCC">
				<td valign="top"><b><?php 
echo $_lang['database_table_totals'];
?>
</b></td>
				<td colspan="2">&nbsp;</td>
				<td dir="ltr" align="right" valign="top"><?php 
echo $totaloverhead > 0 ? '<b style="color:#990033">' . nicesize($totaloverhead) . '</b><br />(' . number_format($totaloverhead) . ' B)' : '-';
?>
</td>
				<td colspan="2">&nbsp;</td>
				<td dir="ltr" align="right" valign="top"><?php 
echo "<b>" . nicesize($total) . "</b><br />(" . number_format($total) . " B)";
?>
</td>
			</tr>
		</tbody>
	</table>
<?php 
if ($totaloverhead > 0) {
    echo '<p>' . $_lang['database_overhead'] . '</p>';
}
?>
</form>
</div>
<!-- This iframe is used when downloading file backup file -->
<iframe name="fileDownloader" width="1" height="1" style="display:none; width:1px; height:1px;"></iframe>
Exemplo n.º 5
0
				<td align="right" width="30%"><?php 
    echo $IndexSize[0];
    ?>
</td>
				<td width="25%" align="left"><?php 
    echo $IndexSize[1];
    ?>
</td>
			</tr>
			</table>
			
			 </td>
			<td width="9%" class="indent-left" >
				<!-- DATA LENGTH +  INDEX_LENGTH + DATA_FREE -->
				<?php 
    $TotaltableSize = explode(" ", nicesize($db_sql[$j]['Index_length'] + $db_sql[$j]['Data_length'] + $db_sql[$j]['Data_free']));
    ?>
				<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td align="right" width="30%"><?php 
    echo $TotaltableSize[0];
    ?>
</td>
					<td width="25%" align="left"><?php 
    echo $TotaltableSize[1];
    ?>
</td>
				</tr>
				</table>
			 </td>
			 <td width="9%" align="center" class="border-right"><?php 
Exemplo n.º 6
0
					</table>
			</td>
		</tr>
		<?php 
}
if (is_dir($path . $AlldataFile[$x])) {
    $total = getUserDirectorySize($path . $AlldataFile[$x]);
} else {
    $total = filesize($path . $AlldataFile[$x]);
}
$totalSize += $total;
?>
		<tr bgcolor="#EFEFEF">
			<td colspan="6" align="right"><b>
			<?php 
$totalSize = explode(" ", nicesize($totalSize));
?>
				<table  border="0" width="15%">
				<tr>
					<td align="right" width="48%"><b><?php 
echo $totalSize[0];
?>
</b></td>
					<td width="25%" align="left"><b><?php 
echo $totalSize[1];
?>
</b></td>
				</tr>
				</table>
			</td>
		</tr>	
Exemplo n.º 7
0
function files($dir)
{
    // File manipulator function
    style();
    global $self, $curdir;
    if ($dir == "") {
        $dir = $curdir;
    }
    $dirx = explode("/", $dir);
    $files = array();
    $folders = array();
    echo "<form method='GET'>";
    echo "<input type='text' name='dir' value='" . $dir . "' size='40'>";
    echo "<input type='submit' value='Go'>";
    echo "</form>";
    echo "<h4>File list for ";
    for ($i = 0; $i < count($dirx); $i++) {
        $totalpath .= $dirx[$i] . "/";
        echo "<a href='?dir=" . $totalpath . "'>{$dirx[$i]}</a>" . "/";
    }
    echo "</h4>";
    echo "<table>";
    echo "<th>File Name<th>File Size</th>";
    if ($handle = opendir($dir)) {
        while (false != ($link = readdir($handle))) {
            if (is_dir($dir . '/' . $link)) {
                $file = array();
                if (is_writable($dir . '/' . $link)) {
                    $file['perm'] = 'write';
                } elseif (is_readable($dir . '/' . $link)) {
                    $file['perm'] = 'read';
                } else {
                    $file['perm'] = 'none';
                }
                switch ($file['perm']) {
                    case "write":
                        @($file['link'] = "<a href='?dir={$dir}/{$link}'><font color='green'>{$link}</font></a>");
                        break;
                    case "read":
                        @($file['link'] = "<a href='?dir={$dir}/{$link}'><font color='yellow'>{$link}</font></a>");
                        break;
                    case "none":
                        @($file['link'] = "<a href='?dir={$dir}/{$link}'><font color='red'>{$link}</font></a>");
                        break;
                    default:
                        @($file['link'] = "<a href='?dir={$dir}/{$link}'><font color='red'>{$link}</font></a>");
                        break;
                }
                @($file['icon'] = "folder");
                if ($_SERVER['QUERY_STRING']) {
                    $folder = "<img src='?" . $_SERVER['QUERY_STRING'] . "&img=" . $file['icon'] . "'> " . $file['link'];
                } else {
                    $folder = "<img src='?img=" . $file['icon'] . "'> " . $file['link'];
                }
                array_push($folders, $folder);
            } else {
                $file = array();
                $ext = strtolower(end(explode(".", $link)));
                if (!($file['size'] = nicesize(@filesize($dir . '/' . $link)))) {
                    $file['size'] = "0B";
                }
                if (is_writable($dir . '/' . $link)) {
                    $file['perm'] = 'write';
                } elseif (is_readable($dir . '/' . $link)) {
                    $file['perm'] = 'read';
                } else {
                    $file['perm'] = 'none';
                }
                switch ($file['perm']) {
                    case "write":
                        @($file['link'] = "<a href='?act=view&f=" . $link . "&dir={$dir}'><font color='green'>{$link}</font></a>");
                        break;
                    case "read":
                        @($file['link'] = "<a href='?act=view&f=" . $link . "&dir={$dir}'><font color='yellow'>{$link}</font></a>");
                        break;
                    case "none":
                        @($file['link'] = "<a href='?act=view&f=" . $link . "&dir={$dir}'><font color='red'>{$link}</font></a>");
                        break;
                    default:
                        @($file['link'] = "<a href='?act=view&f=" . $link . "&dir={$dir}'><font color='red'>{$link}</a></font>");
                        break;
                }
                switch ($ext) {
                    case "exe":
                    case "com":
                    case "jar":
                    case "":
                        $file['icon'] = "binary";
                        break;
                    case "jpg":
                    case "gif":
                    case "png":
                    case "bmp":
                        $file['icon'] = "image";
                        break;
                    case "zip":
                    case "tar":
                    case "rar":
                    case "gz":
                    case "cab":
                    case "bz2":
                    case "gzip":
                        $file['icon'] = "compressed";
                        break;
                    case "txt":
                    case "doc":
                    case "pdf":
                    case "htm":
                    case "html":
                    case "rtf":
                        $file['icon'] = "text";
                        break;
                    case "wav":
                    case "mp3":
                    case "mp4":
                    case "wma":
                        $file['icon'] = "sound";
                        break;
                    case "js":
                    case "vbs":
                    case "c":
                    case "h":
                    case "sh":
                    case "pl":
                    case "py":
                    case "php":
                    case "h":
                        $file['icon'] = "script";
                        break;
                    default:
                        $file['icon'] = "unknown";
                        break;
                }
                if ($_SERVER['QUERY_STRING']) {
                    $file = "<tr><td><img src='?" . $_SERVER['QUERY_STRING'] . "&img=" . $file['icon'] . "' height='18' width='18'> " . $file['link'] . "</td><td>" . $file['size'] . "</td></tr>\n";
                } else {
                    $file = "<tr><td><img src='?img=" . $file['icon'] . "' height='18' width='18'> " . $file['link'] . "<td>" . $file['size'] . "</td></tr>\n";
                }
                array_push($files, $file);
            }
        }
        foreach ($folders as $folder) {
            echo "<tr><td>{$folder}</td><td>DIR</td></tr>\n";
        }
        foreach ($files as $file) {
            echo $file;
        }
        echo "</table>";
        closedir($handle);
    }
}
Exemplo n.º 8
0
function saradnik_zadaca()
{
    global $conf_files_path, $userid, $user_siteadmin;
    require "lib/autotest.php";
    require "lib/manip.php";
    // radi update_komponente
    // --------------------
    // Standardni ulazni podaci i potrebne varijable
    $stud_id = intval($_REQUEST['student']);
    $zadaca = intval($_REQUEST['zadaca']);
    $zadatak = intval($_REQUEST['zadatak']);
    // Prava pristupa
    if (!$user_siteadmin) {
        // Da li je nastavnik na predmetu?
        $q10 = myquery("select count(*) from nastavnik_predmet as np, zadaca as z where z.id={$zadaca} and z.predmet=np.predmet and z.akademska_godina=np.akademska_godina and np.nastavnik={$userid}");
        if (mysql_result($q10, 0, 0) < 1) {
            zamgerlog("privilegije (student u{$stud_id} zadaca z{$zadaca})", 3);
            // nivo 3: greska
            niceerror("Nemate pravo izmjene ove zadaće");
            return;
        }
        // Ogranicenja (tabela: ogranicenje) ne provjeravamo jer bi to bilo prekomplikovano,
        // a pitanje je da li ima smisla
    }
    // Podaci o zadaci
    $q20 = myquery("select p.geshi, p.ekstenzija, z.attachment, z.naziv, z.zadataka, z.komponenta, z.predmet, z.akademska_godina, z.programskijezik from zadaca as z, programskijezik as p where z.id={$zadaca} and z.programskijezik=p.id");
    if (mysql_num_rows($q20) < 1) {
        zamgerlog("nepostojeca zadaca {$zadaca}", 3);
        niceerror("Neispravna zadaća.");
        exit;
    }
    $jezik = mysql_result($q20, 0, 0);
    $ekst = mysql_result($q20, 0, 1);
    $attach = mysql_result($q20, 0, 2);
    $naziv_zadace = mysql_result($q20, 0, 3);
    $komponenta = mysql_result($q20, 0, 5);
    $predmet = mysql_result($q20, 0, 6);
    $ag = mysql_result($q20, 0, 7);
    $id_jezika = mysql_result($q20, 0, 8);
    if (mysql_result($q20, 0, 4) < $zadatak || $zadatak < 1) {
        zamgerlog("pokusao pristupiti nepostojecem zadatku {$zadatak} u zadaci z{$zadaca}", 3);
        niceerror("Neispravan broj zadatka.");
        exit;
    }
    // Podaci o studentu
    $q50 = myquery("select ime, prezime from osoba where id={$stud_id}");
    if (mysql_num_rows($q50) < 1) {
        zamgerlog("nepostojeci student {$stud_id}", 3);
        niceerror("Neispravan student.");
        exit;
    }
    $ime_studenta = mysql_result($q50, 0, 0);
    $prezime_studenta = mysql_result($q50, 0, 1);
    $lokacijazadaca = "{$conf_files_path}/zadace/{$predmet}-{$ag}/{$stud_id}/";
    // --------------------
    // AKCIJE
    // Akcija: Ispis diffa
    if ($_GET['akcija'] == "diff") {
        $diff_id = intval($_GET['diff_id']);
        $q60 = myquery("select diff from zadatakdiff where zadatak={$diff_id}");
        $diff = mysql_result($q60, 0, 0);
        // Ovo ispod nema potrebe jer je diff već escapovan prilikom
        // inserta u bazu (stud_zadaca.php)
        // $diff = str_replace("\n\n","\n",$diff);
        // $diff = htmlspecialchars($diff);
        print "<pre>{$diff}</pre>\n\n";
        return;
    }
    // Akcija: Izvršenje programa
    if ($_POST['akcija'] == "izvrsi" && check_csrf_token()) {
        // čuvamo poslane podatke u bazi (ako ih nema)
        function izvrsi($stdin, $jezik, $lokacijazadaca, $zadaca, $zadatak, $ekst)
        {
            global $conf_files_path;
            // priprema fajlova
            $tstdin = str_replace('\\n', "\n", $stdin);
            // više nije dvostruki escape
            $tstdin = str_replace('\\N', "\n", $tstdin);
            $tstdin .= "\n";
            $result = file_put_contents("{$conf_files_path}/tmp/zamger-gdb.txt", "run\nbt\n");
            if ($result) {
                $result = file_put_contents("{$conf_files_path}/tmp/zamger-input.txt", $tstdin);
            }
            if (!$result) {
                zamgerlog("nije uspjelo kreiranje datoteka", 3);
                niceerror("Ne mogu kreirati potrebne datoteke u direktoriju /tmp");
                return;
            }
            // kompajliranje - FIXME: nema podrške za jezike?
            if ($jezik == "C++") {
                $kompajler = "g++";
            } else {
                $kompajler = "gcc";
            }
            $the_file = "{$lokacijazadaca}{$zadaca}/{$zadatak}{$ekst}";
            $stdout = array();
            exec("{$kompajler} -lm  -ggdb {$the_file} -o {$conf_files_path}/tmp/zamger.out 2>&1", $stdout, $retvar);
            if ($retvar != 0) {
                niceerror("Kompajliranje nije uspjelo! Slijedi ispis");
                print "<pre>" . join("\n", $stdout) . "</pre>\n\n";
                // čišćenje
                unlink("{$conf_files_path}/tmp/zamger-gdb.txt");
                unlink("{$conf_files_path}/tmp/zamger-input.txt");
                unlink("{$conf_files_path}/tmp/zamger.out");
                return;
            }
            // izvršenje
            unset($stdout);
            chmod("{$conf_files_path}/tmp/zamger.out", 0755);
            exec("gdb --batch --command={$conf_files_path}/tmp/zamger-gdb.txt {$conf_files_path}/tmp/zamger.out <{$conf_files_path}/tmp/zamger-input.txt 2>&1", $stdout, $retvar);
            // Čistimo viškove iz stdout-a
            $ispis = join("\n", $stdout);
            $ispis = preg_replace("/^Using .*? library .*?\n/", "", $ispis);
            $ok = strpos($ispis, "\nProgram exited normally.\n");
            if ($ok) {
                $ispis = substr($ispis, 0, $ok);
            } else {
                $greska = strpos($ispis, "\nProgram received signal SIGABRT, Aborted.\n");
                $backtrace = substr($ispis, $greska + 42);
                $ispis = substr($ispis, 0, $greska);
            }
            ?>
		<center><table width="95%" style="border:1px solid silver;" bgcolor="#FFF3F3"><tr><td>
		<pre><?php 
            echo $ispis;
            ?>
</pre>
		</td></tr></table></center><br/><?php 
            if ($ok) {
                ?>
<p><img src="images/16x16/zad_ok.png" width="16" height="16"> 
			Program se izvršio bez problema.</p><?php 
            } else {
                ?>
<p><img src="images/16x16/zad_bug.png" width="16" height="16">
			Program se krahirao. Backtrace (obratiti pažnju na zadnje linije):</p>
			<pre><?php 
                echo $backtrace;
                ?>
</pre>
			<?php 
            }
            // čišćenje
            unlink("{$conf_files_path}/tmp/zamger-gdb.txt");
            unlink("{$conf_files_path}/tmp/zamger-input.txt");
            unlink("{$conf_files_path}/tmp/zamger.out");
        }
        ?>
	<h1>Rezultat izvršenja:</h1>
	<?php 
        if ($_POST['sve']) {
            $q70 = myquery("select ulaz from stdin where zadaca={$zadaca} and redni_broj={$zadatak}");
            while ($r70 = mysql_fetch_row($q70)) {
                print "<h2>Ulaz: '{$r70['0']}'</h2>";
                izvrsi($r70[0], $jezik, $lokacijazadaca, $zadaca, $zadatak, $ekst);
            }
        } else {
            $stdin = $_POST['stdin'];
            $mstdin = my_escape($stdin);
            $q70 = myquery("select count(*) from stdin where ulaz='{$mstdin}' and zadaca={$zadaca} and redni_broj={$zadatak}");
            if (mysql_result($q70, 0, 0) == 0) {
                $q80 = myquery("insert into stdin set ulaz='{$mstdin}', zadaca={$zadaca}, redni_broj={$zadatak}");
            }
            izvrsi($stdin, $jezik, $lokacijazadaca, $zadaca, $zadatak, $ekst);
        }
        ?>
	<p><a href="javascript:history.go(-1)">Nazad</a></p>
	<?php 
        return;
    }
    // Akcija: Izmjena statusa
    if ($_POST['akcija'] == "slanje" && check_csrf_token()) {
        $komentar = my_escape($_POST['komentar']);
        $status = intval($_POST['status']);
        $bodova = floatval(str_replace(",", ".", $_POST['bodova']));
        // Osiguravamo da se filename prenese u svaku sljedeću instancu zadatka
        $filename = $izvjestaj_skripte = '';
        $q90 = myquery("select filename, izvjestaj_skripte from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$stud_id}  order by id desc limit 1");
        if (mysql_num_rows($q90) > 0) {
            $filename = mysql_real_escape_string(mysql_result($q90, 0, 0));
            $izvjestaj_skripte = mysql_real_escape_string(mysql_result($q90, 0, 1));
            // Već je sanitiziran HTML
        }
        $q100 = myquery("insert into zadatak set zadaca={$zadaca}, redni_broj={$zadatak}, student={$stud_id}, status={$status}, bodova={$bodova}, vrijeme=now(), komentar='{$komentar}', filename='{$filename}', izvjestaj_skripte='{$izvjestaj_skripte}', userid={$userid}");
        // Odredjujemo ponudu kursa (za update komponente)
        $q110 = myquery("select pk.id from student_predmet as sp, ponudakursa as pk where sp.student={$stud_id} and sp.predmet=pk.id and pk.predmet={$predmet} and pk.akademska_godina={$ag}");
        update_komponente($stud_id, mysql_result($q110, 0, 0), $komponenta);
        zamgerlog("izmjena zadace (student u{$stud_id} zadaca z{$zadaca} zadatak {$zadatak})", 2);
        // Nakon izmjene statusa, nastavljamo normalno sa prikazom zadatka
    }
    if ($_REQUEST["akcija"] == "test_detalji") {
        $test = intval($_REQUEST['test']);
        // Provjera spoofinga testa
        $q10 = myquery("SELECT COUNT(*) FROM autotest WHERE id={$test} AND zadaca={$zadaca} AND zadatak={$zadatak}");
        if (mysql_result($q10, 0, 0) == 0) {
            niceerror("Odabrani test nije sa odabrane zadaće.");
            return;
        }
        autotest_detalji($test, $stud_id, true);
        return;
    }
    if ($_REQUEST["akcija"] == "brisi_testove" && check_csrf_token()) {
        autotest_brisi_rezultate($stud_id, $zadaca, $zadatak);
        nicemessage("Rezultati testova obrisani.");
        ?>
	<p><a href="?sta=saradnik/zadaca&amp;student=<?php 
        echo $stud_id;
        ?>
&amp;zadaca=<?php 
        echo $zadaca;
        ?>
&amp;zadatak=<?php 
        echo $zadatak;
        ?>
">Nazad</a></p>
	<?php 
        return;
    }
    // --------------------
    // PRIKAZ ZADATKA
    // Header
    ?>
<h1><a href="?sta=saradnik/student&amp;student=<?php 
    echo $stud_id;
    ?>
&amp;predmet=<?php 
    echo $predmet;
    ?>
&amp;ag=<?php 
    echo $ag;
    ?>
" onclick="window.opener.open(this.href); return false;"><?php 
    echo $ime_studenta . " " . $prezime_studenta;
    ?>
</a>, <?php 
    echo $naziv_zadace . ", Zadatak " . $zadatak . ".";
    ?>
</h1>
<?php 
    // Da li ispisati zadatak ili dugme za download attachmenta?
    if ($attach == 0) {
        // Nije attachment
        $src = "";
        $the_file = "{$lokacijazadaca}{$zadaca}/{$zadatak}{$ekst}";
        $no_lines = 0;
        if (file_exists($the_file)) {
            if ($_REQUEST["akcija"] == "test_sa_kodom") {
                $test = intval($_REQUEST['test']);
                // Provjera spoofinga testa
                $q10 = myquery("SELECT COUNT(*) FROM autotest WHERE id={$test} AND zadaca={$zadaca} AND zadatak={$zadatak}");
                if (mysql_result($q10, 0, 0) == 0) {
                    niceerror("Odabrani test nije sa odabrane zadaće.");
                    return;
                }
                $src = autotest_sa_kodom($test, $stud_id, true);
            } else {
                $src = file_get_contents($the_file);
            }
            $no_lines = count(explode("\n", $src));
            // geshi - biblioteka za syntax highlighting
            include_once 'lib/geshi/geshi.php';
            $geshi = new GeSHi($src, $jezik);
            ?>
		<center><table width="95%" style="border:1px solid silver;"><tr>
		<!-- Brojevi linija -->
		<td bgcolor="#CCCCCC" align="left"><pre><?php 
            for ($i = 1; $i <= $no_lines; $i++) {
                print "{$i}\n";
            }
            ?>
</pre></td>
		<td  bgcolor="#F3F3F3" align="left">
		<?php 
            print $geshi->parse_code();
            ?>
</td></tr></table></center><br/><?php 
            if ($_REQUEST["akcija"] == "test_sa_kodom") {
                return;
            }
            // Formular za izvršavanje programa
            if ($id_jezika > 0) {
                ?>
			<script type="text/javascript" src="js/combo-box.js"></script>
			<center><table style="border:1px solid silver;" cellspacing="0" cellpadding="6"><tr><td>
			Izvrši program sa sljedećim parametrima (kucajte \n za tipku enter):<br/>
			<?php 
                echo genform("POST");
                ?>
			<input type="hidden" name="akcija" value="izvrsi">
			<select name="stdin" onKeyPress="edit(event)" onBlur="this.editing = false;">
			<?php 
                // Zadnje korišteni stdin se čuva u bazi
                $q120 = myquery("select ulaz from stdin where zadaca={$zadaca} and redni_broj={$zadatak} order by id desc");
                if (mysql_num_rows($q120) < 1) {
                    print "<option></option>";
                }
                // bez ovoga nije moguće upisati novi tekst
                while ($r120 = mysql_fetch_row($q120)) {
                    print "<option value=\"{$r120['0']}\">{$r120['0']}</option>\n";
                }
                ?>
			</select><br/>
		
			<b>Pažnja!</b> Prije pokretanja provjerite da li program sadrži opasne naredbe.<br/>
			<input type="submit" value=" Izvrši program "> <input type="submit" name="sve" value=" Izvrši sve primjere odjednom ">
			</form></table></center><br/>&nbsp;<br/>
			<?php 
            }
        }
    } else {
        // Attachment
        $q130 = myquery("select filename,UNIX_TIMESTAMP(vrijeme) from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$stud_id} order by id desc limit 1");
        if (mysql_num_rows($q130) > 0) {
            $filename = mysql_result($q130, 0, 0);
            $the_file = "{$lokacijazadaca}{$zadaca}/{$filename}";
            if ($filename && file_exists($the_file)) {
                $vrijeme = date("d. m. Y. h:i:s", mysql_result($q130, 0, 1));
                $velicina = nicesize(filesize($the_file));
                $icon = "images/mimetypes/" . getmimeicon($the_file);
                $dllink = "index.php?sta=common/attachment&student={$stud_id}&zadaca={$zadaca}&zadatak={$zadatak}";
                ?>
			<center><table width="75%" border="1" cellpadding="6" cellspacing="0" bgcolor="#CCCCCC"><tr><td>
			<a href="<?php 
                echo $dllink;
                ?>
"><img src="<?php 
                echo $icon;
                ?>
" border="0"></a>
			</td><td>
			<p>Poslani fajl: <b><a href="<?php 
                echo $dllink;
                ?>
"><?php 
                echo $filename;
                ?>
</a></b><br/>
			Veličina: <b><?php 
                echo $velicina;
                ?>
</b></p>
			</td></tr></table></center><br/>
			<?php 
            } else {
                ?>
			<center><table width="75%" border="1" cellpadding="6" cellspacing="0" bgcolor="#CCCCCC"><tr><td>
			<b><font color="red">Student je zaboravio priložiti datoteku.</font></b>
			</td></tr></table></center><br/>
			<?php 
            }
        }
    }
    // Prikaz statusa sa log-om i izmjena
    $q140 = myquery("select status,bodova,izvjestaj_skripte,komentar from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$stud_id} order by id desc limit 1");
    if (mysql_num_rows($q140) > 0) {
        $status = mysql_result($q140, 0, 0);
        $bodova = mysql_result($q140, 0, 1);
        $izvjestaj_skripte = str_replace("\n", "<br/>", mysql_result($q140, 0, 2));
        $komentar = mysql_result($q140, 0, 3);
        $komentar = str_replace("\"", "&quot;", $komentar);
        // Koristimo poseban upit da bismo odredili vrijeme slanja prve verzije
        $q150 = myquery("select UNIX_TIMESTAMP(vrijeme) from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$stud_id} order by id limit 1");
        $vrijeme_slanja = date("d. m. Y. H:i:s", mysql_result($q150, 0, 0));
        ?>
	
	<table border="0">
	<tr>
		<td>Vrijeme slanja:</td>
		<td><b><?php 
        echo $vrijeme_slanja;
        ?>
</b></td>
	</tr>
	<?php 
        // Autotest nalaz
        $nalaz_autotesta = autotest_tabela($stud_id, $zadaca, $zadatak, true);
        if ($nalaz_autotesta != "") {
            ?>
	<tr>
		<td>Rezultati testiranja:</td>
		<td>
		<p><?php 
            echo genform("POST");
            ?>
		<input type="hidden" name="akcija" value="brisi_testove">
		<input type="submit" value=" Obriši sve rezultate testiranja ">
		</form></p>
		<?php 
            print $nalaz_autotesta;
        }
        if ($id_jezika > 0) {
            ?>
	<tr>
		<td>Izvještaj skripte:</td>
		<td><i><?php 
            echo $izvjestaj_skripte;
            ?>
</i></td>
	</tr>
		<?php 
        }
        if ($status == 1 && !$user_siteadmin) {
            // nema mijenjanja ako je status 1 = ceka se automatska provjera
            print "Izmjena zadaće nije moguća jer se čeka automatsko testiranje";
        } else {
            print genform("POST");
        }
        ?>
	<input type="hidden" name="akcija" value="slanje">
	<?php 
    } else {
        print genform("POST");
        ?>
	<input type="hidden" name="akcija" value="slanje">

	<table border="0">
	<tr>
		<td>&nbsp;</td>
		<td><b>Unos bodova za zadaću koja nije poslana:</b></td>
	</tr>
	<?php 
    }
    // Dio forme koji se prikazuje bez obzira da li je u pitanju kreiranje nove zadaće ili promjena postojeće
    ?>
<tr>
	<td>Status</td>
	<td><select id="status" name="status"><?php 
    function myoption($nr, $tx, $sel)
    {
        print "{$sel}";
        print "<option value={$nr}";
        if ($nr == $sel) {
            print " selected";
        }
        print ">{$tx}</option>";
    }
    // tabela status kodova
    $statusi_array = array("nepoznat status", "sačekati automatsko testiranje!", "prepisana", "ne može se kompajlirati", "nova zadaća, potrebno pregledati", "pregledana");
    $brstatusa = 6;
    for ($i = 0; $i < $brstatusa; $i++) {
        myoption($i, $statusi_array[$i], $status);
    }
    ?>
</select></td>
</tr>
<tr>
	<td>Bodova:</td>
	<td><input type="text" size="20" name="bodova" value="<?php 
    echo $bodova;
    ?>
" onchange="javascript:document.getElementById('status').value=5;"></td>
</tr>
<tr>
	<td valign="top">Komentar:</td>
	<td><textarea cols="50" rows="5" name="komentar"><?php 
    echo $komentar;
    ?>
</textarea></td>
</tr>
<tr>
	<td colspan="2" align="center"><?php 
    if ($status != 1 || $user_siteadmin) {
        ?>
<input type="submit" value="Izmijeni vrijednosti"><?php 
    }
    ?>
</td>
</tr>
</table>
</form>



<?php 
    ##### HISTORIJA IZMJENA ######
    $q160 = myquery("select id,UNIX_TIMESTAMP(vrijeme),status,bodova,komentar,userid from zadatak where zadaca={$zadaca} and redni_broj={$zadatak} and student={$stud_id} order by vrijeme");
    if (mysql_num_rows($q160) > 1) {
        ?>

<p>Historija izmjena:</p>
<ul><?php 
        while ($r160 = mysql_fetch_row($q160)) {
            $imeprezime = "";
            if ($r160[5] > 0) {
                $q165 = myquery("select ime, prezime from osoba where id={$r160['5']}");
                if (mysql_num_rows($q165) > 0) {
                    $imeprezime = mysql_result($q165, 0, 0) . " " . mysql_result($q165, 0, 1);
                }
            }
            $vrijeme_slanja = date("d. m. Y. H:i:s", $r160[1]);
            print "<li><b>{$vrijeme_slanja}";
            if ($imeprezime != "") {
                print " ({$imeprezime})";
            }
            print ":</b> " . $statusi_array[$r160[2]];
            if ($r160[3] > 0) {
                print " (" . $r160[3] . " bodova)";
            }
            if (strlen($r160[4]) > 0) {
                print " - &quot;" . $r160[4] . "&quot;";
            }
            $q170 = myquery("select count(zadatak) from zadatakdiff where zadatak={$r160['0']}");
            if (mysql_result($q170, 0, 0) > 0) {
                print " (<a href=\"index.php?sta=saradnik/zadaca&akcija=diff&zadaca={$zadaca}&zadatak={$zadatak}&student={$stud_id}&diff_id={$r160['0']}\">diff</a>)";
            }
            print "</li>";
        }
        ?>
</ul><?php 
    }
    // Kraj historije izmjena
}
Exemplo n.º 9
0
function common_projektneStrane()
{
    //debug mod aktivan
    global $userid, $user_nastavnik, $user_student, $conf_files_path, $user_siteadmin;
    $predmet = intval($_REQUEST['predmet']);
    $ag = intval($_REQUEST['ag']);
    $projekat = intval($_REQUEST['projekat']);
    $action = $_REQUEST['action'];
    //for project page only:
    $section = $_REQUEST['section'];
    $subaction = $_REQUEST['subaction'];
    $id = intval($_REQUEST['id']);
    //editing links, rss....
    if ($user_student && !$user_siteadmin) {
        $actualProject = getActualProjectForUserInPredmet($userid, $predmet, $ag);
        if ($actualProject[id] != $projekat) {
            //user is not in this project in this predmet...hijack attempt?
            zamgerlog("projektne strane: korisnik nije na projektu {$projekat} (pp{$predmet}, ag{$ag})", 3);
            zamgerlog2("nije na projektu", $projekat);
            return;
        }
    }
    $params = getPredmetParams($predmet, $ag);
    $project = getProject($projekat);
    $members = fetchProjectMembers($project[id]);
    if ($params[zakljucani_projekti] == 0) {
        zamgerlog("projektne strane: jos nisu otvorene! (pp{$predmet}, ag{$ag})", 3);
        zamgerlog2("svi projekti su jos otkljucani", $predmet, $ag);
        return;
    }
    if ($user_student && !$user_siteadmin) {
        $linkPrefix = "?sta=student/projekti&akcija=projektnastranica&projekat={$projekat}&predmet={$predmet}&ag={$ag}";
    } elseif ($user_nastavnik) {
        $linkPrefix = "?sta=nastavnik/projekti&akcija=projektna_stranica&projekat={$projekat}&predmet={$predmet}&ag={$ag}";
    } else {
        return;
    }
    ?>
  
     <h2><?php 
    echo filtered_output_string($project[naziv]);
    ?>
</h2>
     <div class="links">
            <ul class="clearfix">
            	<li><a href="<?php 
    echo $linkPrefix;
    ?>
">Početna strana</a></li>
            	<li><a href="<?php 
    echo $linkPrefix . "&section=info";
    ?>
">Informacije o projektu</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=links";
    ?>
">Korisni linkovi</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=rss";
    ?>
">RSS feedovi</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=bl";
    ?>
">Članci</a></li>
                <li><a href="<?php 
    echo $linkPrefix . "&section=file";
    ?>
">Fajlovi</a></li>
                <li class="last"><a href="<?php 
    echo $linkPrefix . "&section=bb";
    ?>
">Grupa za diskusiju</a></li>
            </ul>   
     </div>	
    <?php 
    if (!isset($section)) {
        //display project start page
        ?>
  	    <div id="mainWrapper" class="clearfix">
			<div id="leftBlocks">
                <div class="blockRow clearfix">
                     <div class="block" id="latestPosts">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=bb";
        ?>
" title="Grupa za diskusiju">Najnoviji postovi</a>
                        <div class="items">
                        <?php 
        $latestPosts = fetchLatestPostsForProject($project[id], 4);
        foreach ($latestPosts as $post) {
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($post[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo $linkPrefix . "&section=bb&subaction=view&tid={$post['tema']}#p{$post['id']}";
            ?>
" title="<?php 
            echo $post['naslov'];
            ?>
" target="_blank"><?php 
            $maxLen = 100;
            $len = strlen($post[naslov]);
            echo filtered_output_string(substr($post['naslov'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($post[osoba][prezime] . ' ' . $post[osoba][ime]);
            ?>
</span>
                                <div class="desc"><?php 
            $maxLen = 200;
            $len = strlen($post[tekst]);
            echo filtered_output_string(substr($post['tekst'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</div><!--desc-->
                            </div><!--item-->	
                        <?php 
        }
        ?>
                        
                        
                        </div><!--items-->
                    </div><!--block-->
                    
                    
                </div><!--blockRow-->
                
                <div class="blockRow clearfix">
                     <div class="block" id="latestArticles">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=bl";
        ?>
" title="Članci">Najnoviji članci</a>
                        <div class="items">
                        <?php 
        $latestArticles = fetchArticlesForProject($project[id], 0, 4);
        foreach ($latestArticles as $article) {
            $author = getAuthorOfArticle($article[id]);
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($article[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo $linkPrefix . "&section=bl&subaction=view&id={$article['id']}";
            ?>
" title="<?php 
            echo $article['naslov'];
            ?>
" target="_blank"><?php 
            $maxLen = 100;
            $len = strlen($article[naslov]);
            echo filtered_output_string(substr($article['naslov'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
                                <div class="desc"><?php 
            $maxLen = 200;
            $len = strlen($article[tekst]);
            echo filtered_output_string(substr($article['tekst'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</div><!--desc-->
                            </div><!--item-->	
                        <?php 
        }
        ?>
                        
                        
                        </div><!--items-->
                    </div><!--block-->
                    
                    
                </div><!--blockRow-->

            </div><!--leftBlocks-->
            <div id="rightBlocks" class="clearfix">
            	<div class="blockRow">
                    <div class="block" id="latestLinks">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=links";
        ?>
" title="Korisni linkovi">Korisni linkovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $links = fetchLinksForProject($project[id], 0, 4);
        foreach ($links as $link) {
            $url = $link[url];
            $scheme = parse_url($url);
            $scheme = $scheme['scheme'];
            if ($scheme == '') {
                //only www part
                $url = 'http://' . $url;
            }
            $maxLen = 150;
            $len = strlen($link[naziv]);
            if ($len > $maxLen) {
                echo '...';
            }
            $author = getAuthorOfLink($link[id]);
            ?>
                            <div class="item">
                                <a href="<?php 
            echo $url;
            ?>
" title="<?php 
            echo $link['naziv'];
            ?>
" target="_blank"><?php 
            $maxLen = 35;
            $len = strlen($link[naziv]);
            echo filtered_output_string(substr($link['naziv'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
        <?php 
            if ($link[opis] != '') {
                ?>
                   
                                <div class="desc"><?php 
                $maxLen = 200;
                $len = strlen($link[opis]);
                echo filtered_output_string(substr($link['opis'], 0, $maxLen - 1));
                if ($len > $maxLen) {
                    echo '...';
                }
                ?>
</div><!--desc-->
        <?php 
            }
            ?>
                 
                            </div><!--item-->   		
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block--> 
				</div><!--blockRow-->            
            	<div class="blockRow">
                    <div class="block" id="latestRSS">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=rss";
        ?>
" title="RSS feedovi">RSS feedovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $links = fetchRSSForProject($project[id], 0, 4);
        foreach ($links as $link) {
            $url = $link[url];
            $scheme = parse_url($url);
            $scheme = $scheme['scheme'];
            if ($scheme == '') {
                //only www part
                $url = 'http://' . $url;
            }
            $maxLen = 150;
            $len = strlen($link[naziv]);
            if ($len > $maxLen) {
                echo '...';
            }
            $author = getAuthorOfRSS($link[id]);
            ?>
                            <div class="item">
                                <a href="<?php 
            echo $url;
            ?>
" title="<?php 
            echo $link['naziv'];
            ?>
" target="_blank"><?php 
            $maxLen = 35;
            $len = strlen($link[naziv]);
            echo filtered_output_string(substr($link['naziv'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
        <?php 
            if ($link[opis] != '') {
                ?>
                   
                                <div class="desc"><?php 
                $maxLen = 200;
                $len = strlen($link[opis]);
                echo filtered_output_string(substr($link['opis'], 0, $maxLen - 1));
                if ($len > $maxLen) {
                    echo '...';
                }
                ?>
</div><!--desc-->
        <?php 
            }
            ?>
                 
                            </div><!--item-->   		
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block-->
                </div><!--blockRow-->  
            	<div class="blockRow">
                    <div class="block" id="latestFiles">
                        <a class="blockTitle" href="<?php 
        echo $linkPrefix . "&section=file";
        ?>
" title="Fajlovi">Fajlovi</a>
                        <div class="items">
                       
        <?php 
        //get latest entries
        $files = fetchFilesForProjectLatestRevisions($project[id], 0, 4);
        foreach ($files as $file) {
            $author = getAuthorOfFile($file[id]);
            ?>
                            <div class="item">
                                <span class="date"><?php 
            echo date('d.m H:i  ', mysql2time($file[vrijeme]));
            ?>
</span>
                                <a href="<?php 
            echo "index.php?sta=common/attachment&tip=projekat&projekat={$projekat}&id={$file['id']}";
            ?>
" title="<?php 
            echo $file['filename'];
            ?>
" ><?php 
            $maxLen = 100;
            $len = strlen($file[filename]);
            echo filtered_output_string(substr($file['filename'], 0, $maxLen - 1));
            if ($len > $maxLen) {
                echo '...';
            }
            ?>
</a>
                                <span class="author"> - <?php 
            echo filtered_output_string($author[prezime] . ' ' . $author[ime]);
            ?>
</span>
                               
                            </div><!--item-->	
        <?php 
        }
        //foreach
        ?>
     
                        </div><!--items-->   
                    </div><!--block-->
                </div><!--blockRow-->            
                          
            </div><!--rightBlocks-->
        </div><!--mainWrapper-->    
    <?php 
    } else {
        if ($section == 'info') {
            // display project info
            ?>
    	<h2>Informacije o projektu</h2>

<table class="projekti" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">Naziv</th>
    <td width="490" align="left" valign="top"><?php 
            echo filtered_output_string($project['naziv']);
            ?>
</td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Prijavljeni studenti</th>
    <td width="490" align="left" valign="top">
    	<?php 
            if (empty($members)) {
                echo 'Nema prijavljenih studenata.';
            } else {
                ?>
        <ul>
        <?php 
                foreach ($members as $member) {
                    ?>
        	<li><?php 
                    echo filtered_output_string($member[prezime] . ' ' . $member[ime] . ', ' . $member[brindexa]);
                    ?>
</li>
		<?php 
                }
                ?>
        </ul>	
		<?php 
            }
            ?>
    
    </td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
            echo filtered_output_string($project['opis']);
            ?>
</td>
  </tr>
</table>
    
     
    <?php 
        } elseif ($section == 'links') {
            //links management
            $linkPrefix .= '&section=links';
            ?>
<h2>Korisni linkovi</h2>
 <div class="links" id="link">
    <ul class="clearfix">
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista linkova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi link</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display links for this project, with links to edit and delete
                $links = fetchLinksForProject($project[id], $offset, $rowsPerPage);
                foreach ($links as $link) {
                    if (isUserAuthorOfLink($link[id], $userid)) {
                        ?>
<div class="links" id="link">
    <ul class="clearfix">
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$link['id']}";
                        ?>
">Uredi</a></li>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$link['id']}";
                        ?>
">Briši</a></li>
    </ul>   
</div>	
	<?php 
                    }
                    //if user is author of this item
                    ?>

<table class="linkovi" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">URL</th>
    <td width="490" align="left" valign="top">
    <?php 
                    $url = $link[url];
                    $scheme = parse_url($url);
                    $scheme = $scheme['scheme'];
                    if ($scheme == '') {
                        //only www part
                        $url = 'http://' . $url;
                    }
                    ?>
<a href="<?php 
                    echo $url;
                    ?>
" title="<?php 
                    echo $link['naziv'];
                    ?>
" target="_blank"><?php 
                    echo filtered_output_string($link[naziv]);
                    ?>
</a>   
    </td>
  </tr>
 <?php 
                    if ($link['opis'] != '') {
                        ?>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
                        echo filtered_output_string($link['opis']);
                        ?>
</td>
  </tr>
  <?php 
                    }
                    //opis
                    ?>
</table>
    <?php 
                }
                //foreach link
                $numrows = getCountLinksForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi link</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							
                            <div class="row">
								<span class="label">Naziv *</span>
								<span class="formw"><input name="naziv" type="text" id="naziv" size="70" /></span> 
							</div>
	
							<div class="row">
								<span class="label">URL *</span>
								<span class="formw"><input name="url" type="text" id="url" size="70" /></span> 
							</div>
							<div class="row">
								<span class="label">Opis</span>
								<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"></textarea></span>
							</div> 
							
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_links('add');
                        if ($errorText == '') {
                            nicemessage('Novi link uspješno dodan.');
                            zamgerlog("dodao link na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao link na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfLink($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getLink($id);
                        ?>
					 <h3>Uredi link</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
                	
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						
						<div class="row">
							<span class="label">Naziv *</span>
							<span class="formw"><input name="naziv" type="text" id="naziv" size="70" value="<?php 
                        echo $entry['naziv'];
                        ?>
" /></span> 
						</div>

						<div class="row">
							<span class="label">URL *</span>
							<span class="formw"><input name="url" type="text" id="url" size="70" value="<?php 
                        echo $entry['url'];
                        ?>
" /></span> 
						</div>
						<div class="row">
							<span class="label">Opis</span>
							<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"><?php 
                        echo $entry['opis'];
                        ?>
</textarea></span>
						</div> 
						
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
							
						
		<?php 
                    } else {
                        $errorText = formProcess_links('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili link.');
                            zamgerlog("uredio link na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio link na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfLink($id, $userid)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj link?<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteLink($id)) {
                                    nicemessage('Uspješno ste obrisali link.');
                                    zamgerlog("obrisao link na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao link na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja linka. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'rss') {
            //links management
            $linkPrefix .= '&section=rss';
            ?>
<h2>RSS feedovi</h2>
 <div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista RSS feedova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi RSS feed</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display links for this project, with links to edit and delete
                $feeds = fetchRSSForProject($project[id], $offset, $rowsPerPage);
                foreach ($feeds as $link) {
                    if (isUserAuthorOfRSS($link[id], $userid)) {
                        ?>
<div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$link['id']}";
                        ?>
">Uredi</a></li>
        <li><a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$link['id']}";
                        ?>
">Briši</a></li>
    </ul>   
</div>	
	<?php 
                    }
                    //if user is author of this item
                    ?>
<table class="rss" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">URL</th>
    <td width="490" align="left" valign="top">
    <?php 
                    $url = $link[url];
                    $scheme = parse_url($url);
                    $scheme = $scheme['scheme'];
                    if ($scheme == '') {
                        //only www part
                        $url = 'http://' . $url;
                    }
                    ?>
<a href="<?php 
                    echo $url;
                    ?>
" title="<?php 
                    echo $link['naziv'];
                    ?>
" target="_blank"><?php 
                    echo filtered_output_string($link[naziv]);
                    ?>
</a>   
    </td>
  </tr>
 <?php 
                    if ($link['opis'] != '') {
                        ?>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Opis</th>
    <td width="490" align="left" valign="top"><?php 
                        echo filtered_output_string($link['opis']);
                        ?>
</td>
  </tr>
 <?php 
                    }
                    //opis
                    ?>

 <tr>
 	<td colspan="2">
 	<?php 
                    global $conf_files_path;
                    //Ukljucimo koristenje globalne varijable koja pokazuje na privatni direktorij sa datotekama koji nije dostupan preko weba
                    $hashfromURL = hash("md5", $url);
                    $cachefile = "";
                    //Provjeri postojanost $conf_files_path/cache/rss direktorija
                    if (file_exists($conf_files_path . "/cache")) {
                        if (!file_exists($conf_files_path . "/cache/rss")) {
                            mkdir($conf_files_path . "/cache/rss");
                        }
                        $cachefile = $conf_files_path . "/cache/rss/" . $hashfromURL . ".html";
                    } else {
                        if (mkdir($conf_files_path . "/cache")) {
                            if (mkdir($conf_files_path . "/cache/rss/")) {
                                $cachefile = $conf_files_path . "/cache/rss/" . $hashfromURL . ".html";
                            }
                        }
                    }
                    $cachetime = 5 * 60;
                    //5 minuta TODO:Pri deployment-u povecati na sat-dva.
                    //Serviraj is kesha ako je mladji od $cachetime
                    if (file_exists($cachefile) && time() - filemtime($cachefile) < $cachetime) {
                        include $cachefile;
                        print "RSS ucitan iz kesha!";
                    } else {
                        //Ucitaj RSS ponovo
                        $XMLfilename = $url;
                        //Pocni dump buffera
                        ob_start();
                        include "lib/rss2html.php";
                        //HTML parsiran sadrzaj RSS-a
                        //Otvori kesh fajl za pisanje
                        $fp = fopen($cachefile, 'w');
                        //Sacuvaj sadrzaj izlaznog buffer-a u fajl
                        fwrite($fp, ob_get_contents());
                        //zatvori fajl
                        fclose($fp);
                        //Posalji izlaz na browser
                        ob_end_flush();
                        print "RSS osvjezen - feed ponovo ucitan!";
                    }
                    ?>
 	</td>
</tr>
 
</table>
    <?php 
                }
                //foreach link
                $numrows = getCountRSSForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi RSS feed</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							
                            <div class="row">
								<span class="label">Naziv *</span>
								<span class="formw"><input name="naziv" type="text" id="naziv" size="70" /></span> 
							</div>
	
							<div class="row">
								<span class="label">URL *</span>
								<span class="formw"><input name="url" type="text" id="url" size="70" /></span> 
							</div>
							<div class="row">
								<span class="label">Opis</span>
								<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"></textarea></span>
							</div> 
							
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_rss('add');
                        if ($errorText == '') {
                            nicemessage('Novi RSS feed uspješno dodan.');
                            zamgerlog("dodao novi rss feed na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao rss feed na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfRSS($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getRSS($id);
                        ?>
					 <h3>Uredi RSS feed</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
                	
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						
						<div class="row">
							<span class="label">Naziv *</span>
							<span class="formw"><input name="naziv" type="text" id="naziv" size="70" value="<?php 
                        echo $entry['naziv'];
                        ?>
" /></span> 
						</div>

						<div class="row">
							<span class="label">URL *</span>
							<span class="formw"><input name="url" type="text" id="url" size="70" value="<?php 
                        echo $entry['url'];
                        ?>
" /></span> 
						</div>
						<div class="row">
							<span class="label">Opis</span>
							<span class="formw"><textarea name="opis" cols="60" rows="15" wrap="physical" id="opis"><?php 
                        echo $entry['opis'];
                        ?>
</textarea></span>
						</div> 
						
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
							
						
		<?php 
                    } else {
                        $errorText = formProcess_rss('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili RSS feed.');
                            zamgerlog("uredio rss feed na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio rss feed na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfRSS($id, $userid)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj RSS feed?<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteRSS($id)) {
                                    nicemessage('Uspješno ste obrisali RSS feed.');
                                    zamgerlog("obrisao rss feed na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao rss feed na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja RSS feeda. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'bl') {
            //links management
            $linkPrefix .= '&section=bl';
            ?>
<h2>Članci</h2>
 <div class="links clearfix" id="bl">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista članaka</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi članak</a></li>
    </ul>   
</div>	
    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                $articles = fetchArticlesForProject($project[id], $offset, $rowsPerPage);
                foreach ($articles as $article) {
                    ?>
    
   <div class="article_summary clearfix">
   	<?php 
                    if (!empty($article[slika])) {
                        ?>
    	<div class="imgCont">
        	<a href="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" target="_blank">
    			<img src="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" />
        	</a>
        </div>
	<?php 
                    }
                    ?>
    	<div class="contentCont" <?php 
                    if (empty($article[slika])) {
                        echo 'style="margin-left: 0;"';
                    }
                    ?>
>
            <h1>
                <a href="<?php 
                    echo $linkPrefix . "&subaction=view&id={$article['id']}";
                    ?>
" 
                title="<?php 
                    echo $article['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($article['naslov']);
                    ?>
                </a>
            </h1>
            <div class="details">
        <?php 
                    $author = getAuthorOfArticle($article[id]);
                    ?>
                Autor: <?php 
                    echo filtered_output_string($author[ime] . ' ' . $author[prezime]);
                    ?>
<br />
                Datum: <?php 
                    echo date('d.m.Y', strtotime($article[vrijeme]));
                    ?>
            </div><!--details-->
   <?php 
                    if (isUserAuthorOfArticle($article[id], $userid) == true) {
                        ?>
	
            <div class="buttons">
                <a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$article['id']}";
                        ?>
" title="Uredi ovaj članak">Uredi</a> | 
                <a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$article['id']}";
                        ?>
" title="Briši ovaj članak">Briši</a>
            </div><!--buttons-->	
	<?php 
                    }
                    ?>

<div class="text">
                                <?php 
                    $len = strlen($article[tekst]);
                    if (!empty($article[slika])) {
                        $maxLen = 400;
                    } else {
                        $maxLen = 800;
                    }
                    echo filtered_output_string(substr($article['tekst'], 0, $maxLen - 1));
                    if ($len > $maxLen) {
                        echo '...';
                    }
                    ?>
            </div><!--text-->
        </div><!--contentCont-->
   </div><!--article_summary--> 
    
    <?php 
                }
                //foreach article
                $numrows = getCountArticlesForProject($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'view') {
                    $article = getArticle($id);
                    if (empty($article)) {
                        zamgerlog("projektne strane: nepostojeci clanak sa IDom {$id}, projekat {$projekat} (pp{$predmet}, ag{$ag})", 3);
                        zamgerlog2("nepostojeci clanak na projektu", $id, $projekat);
                        return;
                    }
                    ?>
		
	   <div class="article_full clearfix">
			<div class="contentCont clearfix">
				<h1>
					<a href="<?php 
                    echo $linkPrefix . "?subaction=view&id={$article['id']}";
                    ?>
" 
					title="<?php 
                    echo $article['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($article['naslov']);
                    ?>
					</a>
				</h1>
				<div class="details">
			<?php 
                    $author = getAuthorOfArticle($article[id]);
                    ?>
					Autor: <?php 
                    echo filtered_output_string($author[ime] . ' ' . $author[prezime]);
                    ?>
<br />
					Datum: <?php 
                    echo date('d.m.Y', strtotime($article[vrijeme]));
                    ?>
				</div><!--details-->
	   <?php 
                    if (isUserAuthorOfArticle($article[id], $userid) == true) {
                        ?>
	
				<div class="buttons">
					<a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id={$article['id']}";
                        ?>
" title="Uredi ovaj članak">Uredi</a> | 
					<a href="<?php 
                        echo $linkPrefix . "&subaction=del&id={$article['id']}";
                        ?>
" title="Briši ovaj članak">Briši</a>
				</div><!--buttons-->	
		<?php 
                    }
                    ?>
		<?php 
                    if (!empty($article[slika])) {
                        ?>
			<div class="imgCont">
            	<a href="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" target="_blank">
            		<img src="<?php 
                        echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$article['osoba']}&i={$article['slika']}";
                        ?>
" />
                </a>     
            </div>
	  <?php 
                    }
                    ?>
				<div class="text"><?php 
                    echo filtered_output_string($article['tekst']);
                    ?>
</div><!--text-->
			</div><!--contentCont-->
	   </div><!--article_full--> 
       <a id="backLink" href="<?php 
                    echo $linkPrefix;
                    ?>
">Povratak na listu članaka</a>

		
		<?php 
                } elseif ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
	
    		
				 <h3>Novi članak</h3>
				<?php 
                        print genform("POST", "addForm\" enctype=\"multipart/form-data\" ");
                        ?>
                
                <div id="formDiv">
                	Polja sa * su obavezna. <br />
                
                	<div class="row">
                        <span class="label">Naslov *</span>
                        <span class="formw"><input name="naslov" type="text" id="naslov" size="70" /></span> 
                  	</div>
                    <div class="row">
                        <span class="label">Tekst</span>
                        <span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
                   	</div> 
                   
                    <div class="row">
                        <span class="label">Slika</span>
                        <span class="formw">
                            <input name="image" type="file" id="image" size="60" />
                        </span><br /><br />
                        Dozvoljeni tipovi slike: jpg, jpeg, gif, png <br />
                    </div> 
                    
                    <div class="row">	
                      	<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
                    </div>
                
                </div><!--formDiv-->
               
                </form>
                
			
	<?php 
                    } else {
                        $errorText = formProcess_bl('add');
                        if ($errorText == '') {
                            nicemessage('Novi članak uspješno dodan.');
                            zamgerlog("dodao novi clanak na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao clanak na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfArticle($id, $userid)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getArticle($id);
                        ?>
				 <h3>Uredi članak</h3>
				<?php 
                        print genform("POST", "editForm\" enctype=\"multipart/form-data\" ");
                        ?>
				
				<div id="formDiv">
					Polja sa * su obavezna. <br />
				
					<div class="row">
						<span class="label">Naslov *</span>
						<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
                        echo $entry['naslov'];
                        ?>
" /></span> 
					</div>
					<div class="row">
						<span class="label">Tekst</span>
						<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"><?php 
                        echo $entry['tekst'];
                        ?>
</textarea></span>
					</div> 

<?php 
                        if ($entry['slika'] != '') {
                            //if the image exists, display it
                            ?>
				   <div class="row">
						<span class="label">Trenutna slika</span>
						<span class="formw"><img src="<?php 
                            echo "index.php?sta=common/articleImageDownload&projekat={$projekat}&predmet={$predmet}&ag={$ag}&a={$article['id']}&u={$entry['osoba']}&i={$entry['slika']}";
                            ?>
" />
						</span>
				   </div> 
				   
				   <div class="row">
						<span class="label">Briši sliku</span>
						<span class="formw"><input name="delete" type="checkbox" id="delete" value="delete" /></span>
				   </div> 
			   
<?php 
                        }
                        //if image is present
                        ?>
					<div class="row">
					  <span class="label"><?php 
                        if ($entry['slika'] != '') {
                            echo "ILI: Zamijeni sliku";
                        } else {
                            echo "Slika";
                        }
                        ?>
</span>
						<span class="formw">
							<input name="image" type="file" id="image" size="50" />
						</span><br /><br />
						Dozvoljeni tipovi slike: jpg, jpeg, gif, png <br />
					</div>                         
					
					<div class="row">	
						<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
					</div>
				
				</div><!--formDiv-->
				
				
				</form>
				
				
<?php 
                    } else {
                        $errorText = formProcess_bl('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili članak.');
                            zamgerlog("uredio clanak na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio clanak na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (isUserAuthorOfArticle($id, $userid) == false) {
                            return;
                        }
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj članak? <br />";
                            echo '<a href="' . $linkPrefix . '&amp;subaction=del&amp;id=' . $id . '&amp;c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteArticle($id)) {
                                    nicemessage('Uspješno ste obrisali članak.');
                                    zamgerlog("obrisao clanak na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao clanak na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Došlo je do greske prilikom brisanja članka. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'file') {
            //files management
            $linkPrefix .= '&section=file';
            ?>
<h2>Fajlovi</h2>
 <div class="links clearfix" id="rss">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista fajlova</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Novi fajl</a></li>
    </ul>   
</div>	

    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                //display files for this project, with links to edit and delete
                $files = fetchFilesForProjectAllRevisions($project[id], $offset, $rowsPerPage);
                ?>
<table class="files_table" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col" class="creation_date">Datum kreiranja</th>
    <th scope="col" class="author">Autor</th>
    <th scope="col" class="revision">Revizija</th>
    <th scope="col" class="name">Naziv</th>
    <th scope="col" class="filesize">Veličina</th>
    <th scope="col" class="options">Opcije</th>
  </tr>
	<?php 
                foreach ($files as $file) {
                    $lastRevisionId = 0;
                    $firstRevisionId = count($file) > 0 ? count($file) - 1 : 0;
                    $author = getAuthorOfFile($file[$lastRevisionId][id]);
                    ?>
				
    <tr>
    	<td class="creation_date"><?php 
                    echo date('d.m.Y H:i:s', mysql2time($file[$lastRevisionId][vrijeme]));
                    ?>
</td><!--vrijeme-->
    	<td class="author"><?php 
                    echo filtered_output_string($author['ime'] . ' ' . $author['prezime']);
                    ?>
</td><!--author-->
        <td class="revision">v<?php 
                    echo $file[$lastRevisionId][revizija];
                    ?>
</td><!--revizija-->
        <td class="filename"><?php 
                    if (count($file) > 1) {
                        ?>
		<a href="#" onclick="toggleFileRevisions('file_<?php 
                        echo $file[$lastRevisionId][id];
                        ?>
_revisions')"><?php 
                        echo filtered_output_string($file[$lastRevisionId][filename]);
                        ?>
</a>		
   	<?php 
                    } else {
                        ?>
    	<?php 
                        echo filtered_output_string($file[$lastRevisionId][filename]);
                        ?>
    <?php 
                    }
                    ?>
        </td><!--filename-->
        <td class="filesize"><?php 
                    $lokacijafajlova = "{$conf_files_path}/projekti/fajlovi/{$projekat}/" . $file[$lastRevisionId][osoba] . "/" . $file[$lastRevisionId][filename] . '/v' . $file[$lastRevisionId][revizija] . '/';
                    $filepath = $lokacijafajlova . $file[$lastRevisionId][filename];
                    $filesize = filesize($filepath);
                    echo nicesize($filesize);
                    ?>
        </td><!--filesize-->
        <td class="options">
			<a href="<?php 
                    echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $file[$lastRevisionId][id];
                    ?>
">Snimi</a>        
	<?php 
                    if (isUserAuthorOfFile($file[$lastRevisionId][id], $userid)) {
                        ?>
           <a href="<?php 
                        echo $linkPrefix . "&subaction=edit&id=" . $file[$firstRevisionId]['id'];
                        ?>
">Uredi</a>
           <a href="<?php 
                        echo $linkPrefix . "&subaction=del&id=" . $file[$firstRevisionId]['id'];
                        ?>
">Briši</a>
	<?php 
                    }
                    //if user is author of this item
                    ?>
        </td><!--options-->
    </tr><!--file_leading-->
    <?php 
                    if (count($file) > 1) {
                        for ($i = 1; $i < count($file); $i++) {
                            $revision = $file[$i];
                            $author = getAuthorOfFile($revision[id]);
                            ?>
            <tr class="file_<?php 
                            echo $file[$lastRevisionId][id];
                            ?>
_revisions" style="display: none;" id="file_revisions">
                <td class="creation_date"><?php 
                            echo date('d.m.Y H:i:s', mysql2time($revision[vrijeme]));
                            ?>
</td><!--vrijeme-->
                <td class="author"><?php 
                            echo filtered_output_string($author['ime'] . ' ' . $author['prezime']);
                            ?>
</td><!--author-->
                <td class="revision">v<?php 
                            echo $revision[revizija];
                            ?>
</td><!--revizija-->
                <td class="filename"><?php 
                            echo filtered_output_string($revision[filename]);
                            ?>
</td><!--filename-->
                <td class="filesize"><?php 
                            $lokacijafajlova = "{$conf_files_path}/projekti/fajlovi/{$projekat}/" . $revision[osoba] . "/" . $revision[filename] . '/v' . $revision[revizija] . '/';
                            $filepath = $lokacijafajlova . $revision[filename];
                            $filesize = filesize($filepath);
                            echo nicesize($filesize);
                            ?>
                </td><!--filesize-->
                <td class="options">
                    <a href="<?php 
                            echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $revision[id];
                            ?>
">Snimi</a>        
                </td><!--options-->
            </tr><!--file_revision-->	
    <?php 
                        }
                        //foreach revision
                    }
                    //if count files > 1
                }
                //foreach file
                ?>
    </table>
<!--files_table-->
<?php 
                $numrows = getCountFilesForProjectWithoutRevisions($project[id]);
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
                ?>
    <script type="text/javascript">
		function getElementsByClassName( strClassName, obj ) 
		{
			var ar = arguments[2] || new Array();
			var re = new RegExp("\\b" + strClassName + "\\b", "g");
		
			if ( re.test(obj.className) ) 
			{
				ar.push( obj );
			}
			for ( var i = 0; i < obj.childNodes.length; i++ )
				getElementsByClassName( strClassName, obj.childNodes[i], ar );
			
			return ar;
		}
		
		function toggleFileRevisions(divID)
		{
			 var aryClassElements = getElementsByClassName( divID, document.body );
			for ( var i = 0; i < aryClassElements.length; i++ ) 
			{
				if (aryClassElements[i].style.display == '')
					aryClassElements[i].style.display = 'none';
				else
					aryClassElements[i].style.display = '';	
			}
		}
	
	</script>
    <?php 
            } else {
                if ($subaction == 'add') {
                    if (!isset($_REQUEST['submit'])) {
                        ?>
						 <h3>Novi fajl</h3>
				<?php 
                        print genform("POST", "addForm\" enctype=\"multipart/form-data\" ");
                        ?>
						
						<div id="formDiv">
							Polja sa * su obavezna. <br />
							<b>Limit za upload je 20MB.</b> <br />
                            <div class="row">
                                <span class="label">Fajl *</span>
                                <span class="formw">
                                    <input name="filename" type="file" id="filename" size="60" />
                                    <input type="hidden" name="MAX_FILE_SIZE" value="20971520">
                                </span>
                            </div> 
                            
							<div class="row">	
								<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
							</div>
						
						</div><!--formDiv-->
						</form>
							
	<?php 
                    } else {
                        $errorText = formProcess_file('add');
                        if ($errorText == '') {
                            nicemessage('Novi fajl uspješno dodan.');
                            zamgerlog("dodao novi fajl na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("dodao fajl na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    if (!isUserAuthorOfFile($id, $userid)) {
                        return;
                    }
                    if (!isThisFileFirstRevision($id)) {
                        return;
                    }
                    //edit item
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getFileFirstRevision($id);
                        $lastRevisionEntry = getFileLastRevision($id);
                        ?>
					 <h3>Uredi fajl</h3>
				<?php 
                        print genform("POST", "editForm\" enctype=\"multipart/form-data\" ");
                        ?>
					
					<div id="formDiv">
						Polja sa * su obavezna. <br />
						<b>Limit za upload je 20MB.</b> <br />							
					   <div class="row">
							<span class="label">Trenutni fajl</span>
							<span class="formw"><a href="<?php 
                        echo 'index.php?sta=common/attachment' . "&tip=projekat&projekat={$projekat}&id=" . $lastRevisionEntry[id];
                        ?>
" >
								<?php 
                        echo filtered_output_string($lastRevisionEntry[filename]);
                        ?>
							</a>
							</span>
					   </div> 

						<div class="row">
						  <span class="label">Zamijeni fajl</span>
							<span class="formw">
								<input name="filename" type="file" id="filename" size="50" />
								<input type="hidden" name="MAX_FILE_SIZE" value="20971520">
							</span>
						</div>                         
						<div class="row">	
							<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
						</div>
					
					</div><!--formDiv-->
					</form>
	
		<?php 
                    } else {
                        $errorText = formProcess_file('edit');
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili fajl.');
                            zamgerlog("uredio fajl na projektu {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio fajl na projektu", $projekat);
                            $link = $linkPrefix;
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    if (!isUserAuthorOfFile($id, $userid)) {
                        return;
                    }
                    if (!isThisFileFirstRevision($id)) {
                        return;
                    }
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj fajl? Obrisacete sve revizije fajla sa servera.<br />";
                            echo '<a href="' . $linkPrefix . '&subaction=del&id=' . $id . '&c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deleteFile($id)) {
                                    nicemessage('Uspješno ste obrisali fajl.');
                                    zamgerlog("obrisao fajl na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao fajl na projektu", $projekat);
                                    $link = $linkPrefix;
                                } else {
                                    niceerror('Doslo je do greske prilikom brisanja fajla. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        } elseif ($section == 'bb') {
            //links management
            $linkPrefix .= '&section=bb';
            ?>
<h2>Grupa za diskusiju</h2>
 <div class="links clearfix" id="bl">
    <ul>
        <li><a href="<?php 
            echo $linkPrefix;
            ?>
">Lista tema</a></li>
        <li><a href="<?php 
            echo $linkPrefix . "&subaction=add";
            ?>
">Nova tema</a></li>
    </ul>   
</div>	
    <?php 
            if (!isset($subaction)) {
                $rowsPerPage = 20;
                $pageNum = 1;
                if (isset($_REQUEST['page'])) {
                    $pageNum = $_REQUEST['page'];
                }
                // counting the offset
                $offset = ($pageNum - 1) * $rowsPerPage;
                $threads = fetchThreadsForProject($project[id], $offset, $rowsPerPage);
                $numrows = getCountThreadsForProject($project[id]);
                ?>
<div id="threadList">
	<div class="threadRow caption clearfix">
        <div class="threadInfo">
        	<div class="views">Pregleda</div><!--views-->
        	<div class="lastReply">Zadnji odgovor</div><!--lastReply-->
            <div class="replies">Odgovora</div><!--replies-->
        </div><!--threadInfo-->
    	<div class="title">Teme (<?php 
                echo $numrows;
                ?>
)</div><!--title-->		
    </div><!--threadRow caption-->
    <?php 
                foreach ($threads as $key => $thread) {
                    ?>
	<div class="threadRow clearfix<?php 
                    if ($key % 2) {
                        echo ' pattern';
                    }
                    ?>
">
        <div class="threadInfo">
        	<div class="views"><?php 
                    echo intval($thread[pregleda]);
                    ?>
</div><!--views-->
        	<div class="lastReply"><?php 
                    echo date('d.m.Y H:i:s', mysql2time($thread[zadnji_post][vrijeme]));
                    ?>
<br /><?php 
                    echo filtered_output_string($thread[zadnji_post][osoba][prezime] . ' ' . $thread[zadnji_post][osoba][ime]);
                    ?>
</div><!--lastReply-->
            <div class="replies"><?php 
                    echo intval($thread[broj_odgovora]);
                    ?>
</div><!--replies-->
        </div><!--threadInfo-->
    	<div class="title"><a href="<?php 
                    echo $linkPrefix . "&subaction=view&tid={$thread['id']}";
                    ?>
" title="<?php 
                    echo $thread['naslov'];
                    ?>
"><?php 
                    echo filtered_output_string($thread[naslov]);
                    ?>
</a></div><!--title-->
        <div class="author"><?php 
                    echo filtered_output_string($thread[prvi_post][osoba][prezime] . ' ' . $thread[prvi_post][osoba][ime]);
                    ?>
</div><!--author-->		
    </div><!--threadRow caption-->
    <?php 
                }
                //foreach thread
                ?>
</div><!--threadList-->
    <?php 
                $maxPage = ceil($numrows / $rowsPerPage);
                $self = $linkPrefix;
                if ($maxPage > 0) {
                    echo "<span class=\"newsPages\">";
                    if ($pageNum > 1) {
                        $page = $pageNum - 1;
                        $prev = " <a href=\"{$self}&page={$page}\">[Prethodna]</a> ";
                        $first = " <a href=\"{$self}&page=1\">[Prva]</a> ";
                    }
                    if ($pageNum < $maxPage) {
                        $page = $pageNum + 1;
                        $next = " <a href=\"{$self}&page={$page}\">[Sljedeća]</a> ";
                        $last = " <a href=\"{$self}&page={$maxPage}\">[Zadnja]</a> ";
                    }
                    echo $first . $prev . " Strana <strong>{$pageNum}</strong> od ukupno <strong>{$maxPage}</strong> " . $next . $last;
                    echo "</span>";
                    //newsPages span
                }
            } else {
                if ($subaction == 'view') {
                    $tid = intval($_REQUEST[tid]);
                    $thread = getThreadAndPosts($tid);
                    if (empty($thread)) {
                        zamgerlog("projektne strane: nepostojeci thread sa IDom {$id}, projekat {$projekat} (pp{$predmet}, ag{$ag})", 3);
                        zamgerlog2("nepostojeci thread na projektu", $id, $projekat);
                        return;
                    }
                    incrementThreadViewCount($thread[id]);
                    ?>
    <div id="fullThread">
    <?php 
                    foreach ($thread[posts] as $post) {
                        ?>
				
		<div class="post"><a name="p<?php 
                        echo $post[id];
                        ?>
">
        	<div id="post_<?php 
                        echo $post[id];
                        ?>
_header" class="header clearfix" onclick="toggleShowPost('post_<?php 
                        echo $post[id];
                        ?>
')">
                <div class="buttons">
                	<a href="<?php 
                        echo $linkPrefix . "&subaction=add&tid={$post['tema']}&id={$post['id']}";
                        ?>
" title="Odgovori na ovaj post">Odgovori</a>
    <?php 
                        if (isUserAuthorOfPost($post[id], $userid) == true) {
                            ?>
    				| <a href="<?php 
                            echo $linkPrefix . "&subaction=edit&tid={$post['tema']}&id={$post['id']}";
                            ?>
" title="Uredi vlastiti post">Uredi</a>
    				| <a href="<?php 
                            echo $linkPrefix . "&subaction=del&tid={$post['tema']}&id={$post['id']}";
                            ?>
" title="Obriši vlastiti post">Obriši</a>		
    <?php 
                        }
                        ?>
                </div>
                <div class="maininfo">
                	<div class="date"><?php 
                        echo date('d.m.Y H:i:s', mysql2time($post[vrijeme]));
                        ?>
</div>
                    <div class="author"><?php 
                        echo filtered_output_string($post[osoba][prezime] . ' ' . $post[osoba][ime]);
                        ?>
</div> - 
                    <div class="title"><?php 
                        echo filtered_output_string($post[naslov]);
                        ?>
</div>
                </div>
            </div><!--header-->
            <div class="text" id="post_<?php 
                        echo $post[id];
                        ?>
_text"><?php 
                        echo filtered_output_string($post[tekst]);
                        ?>
</div><!--text-->

        </div><!--post-->				
					
	<?php 
                    }
                    //foreach post
                    ?>
    
    
    </div><!--fullThread-->
        <script type="text/javascript">
		function toggleShowPost(divID)
		{
			header = document.getElementById(divID + '_header');
			text = document.getElementById(divID + '_text');
			if (text.style.display == 'block' || text.style.display == '')
			{
				text.style.display = 'none';
				header.style.backgroundColor = '#F5F5F5';
				header.style.color = 'black';
			}
			else
			{
				text.style.display = 'block';
				header.style.backgroundColor = '#EEEEEE';
			}	
				
		}
	
		</script>
	
    <?php 
                } elseif ($subaction == 'add') {
                    $threadID = intval($_REQUEST['tid']);
                    if ($threadID <= 0) {
                        $thread = false;
                    } else {
                        $thread = true;
                    }
                    if ($thread == true) {
                        $postInfo = getPostInfoForThread($threadID, $id);
                        $extendedThreadInfo = array();
                        getExtendedInfoForThread($threadID, $extendedThreadInfo);
                        if (empty($postInfo)) {
                            zamgerlog("projektne strane: odgovor na nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("odgovor na nepostojeci post na projektu", $id, $projekat);
                            return;
                        }
                    }
                    if (!isset($_REQUEST['submit'])) {
                        ?>
	
    		
				 <h3><?php 
                        if ($thread == true) {
                            echo 'Novi odgovor';
                        } else {
                            echo 'Nova tema';
                        }
                        ?>
</h3>
				<?php 
                        print genform("POST", "addForm");
                        ?>
                <?php 
                        if ($thread == true) {
                            ?>
 
					<input type="hidden" name="tid" value="<?php 
                            echo $threadID;
                            ?>
"  />
				<?php 
                        }
                        ?>
                <div id="formDiv">
                	Polja sa * su obavezna. <br />
                
                	<div class="row">
                        <span class="label">Naslov *</span>
                        <span class="formw"><input name="naslov" type="text" id="naslov" size="70" <?php 
                        if ($thread == true) {
                            ?>
 value="RE: <?php 
                            echo $extendedThreadInfo['naslov'];
                            ?>
"<?php 
                        }
                        ?>
/></span> 
                  	</div>
                    <div class="row">
                        <span class="label">Tekst *</span>
                        <span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
                   	</div> 
                                      
                    <div class="row">	
                      	<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
                    </div>
                
                </div><!--formDiv-->
               
                </form>
               
	<?php 
                    } else {
                        $errorText = formProcess_bb('add', $thread, $threadID);
                        if ($errorText == '') {
                            if ($thread == true) {
                                nicemessage('Novi odgovor uspješno dodan.');
                                zamgerlog("dodao novi odgovor na diskusiju ID {$threadID}, projekat {$projekat} (pp{$predmet})", 2);
                                zamgerlog2("dodao odgovor na diskusiju", $threadID, $projekat);
                            } else {
                                nicemessage('Nova tema uspješno dodana.');
                                zamgerlog("dodao novu temu na projektu {$projekat} (pp{$predmet})", 2);
                                zamgerlog2("dodao temu na projektu", $projekat);
                            }
                            if (!empty($_REQUEST[tid])) {
                                $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                            } else {
                                $link = $linkPrefix;
                            }
                        } else {
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'edit') {
                    //edit item
                    if (isUserAuthorOfPost($id, $userid) == false) {
                        zamgerlog("pokusava urediti post {$id} a nije autor, projekat {$projekat} (pp{$predmet})", 3);
                        zamgerlog2("pokusava urediti post a nije autor", $id, $projekat);
                        return;
                    }
                    $threadID = intval($_REQUEST[tid]);
                    if ($threadID <= 0) {
                        zamgerlog("pokusava urediti nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                        zamgerlog2("pokusava urediti nepostojeci post", $id, $projekat);
                        return;
                    }
                    if (!isset($_REQUEST['submit'])) {
                        $entry = getPost($id);
                        if (empty($entry)) {
                            zamgerlog("pokusava urediti nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava urediti nepostojeci post", $id, $projekat);
                            return;
                        }
                        ?>
				 <h3>Uredi post</h3>
				<?php 
                        print genform("POST", "editForm");
                        ?>
				<div id="formDiv">
					Polja sa * su obavezna. <br />
				
					<div class="row">
						<span class="label">Naslov *</span>
						<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
                        echo $entry['naslov'];
                        ?>
" /></span> 
					</div>
					<div class="row">
						<span class="label">Tekst *</span>
						<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"><?php 
                        echo $entry['tekst'];
                        ?>
</textarea></span>
					</div> 
					
					<div class="row">	
						<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
					</div>
				
				</div><!--formDiv-->
				
				
				</form>
				
				
<?php 
                    } else {
                        $errorText = formProcess_bb('edit', $thread, $threadID);
                        if ($errorText == '') {
                            nicemessage('Uspješno ste uredili post.');
                            zamgerlog("uredio vlastiti BB post {$id}, projekat {$projekat} (pp{$predmet})", 2);
                            zamgerlog2("uredio vlastiti post", $id, $projekat);
                            $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                        } else {
                            //an error occured trying to process the form
                            niceerror($errorText);
                            $link = "javascript:history.back();";
                        }
                        nicemessage('<a href="' . $link . '">Povratak.</a>');
                    }
                    //submitted the form
                } elseif ($subaction == 'del') {
                    //delete item
                    if (isset($id) && is_int($id) && $id > 0) {
                        if (isUserAuthorOfPost($id, $userid) == false) {
                            zamgerlog("pokusava izbrisati post {$id} a nije autor, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava izbrisati post a nije autor", $id, $projekat);
                            return;
                        }
                        $threadID = intval($_REQUEST[tid]);
                        if ($threadID <= 0) {
                            zamgerlog("pokusava izbrisati nepostojeci post {$id}, projekat {$projekat} (pp{$predmet})", 3);
                            zamgerlog2("pokusava izbrisati nepostojeci post", $id, $projekat);
                            return;
                        }
                        if (!isset($_REQUEST['c'])) {
                            echo "Da li ste sigurni da zelite obrisati ovaj post? <br />";
                            echo '<a href="' . $linkPrefix . '&amp;subaction=del&tid=' . $threadID . '&id=' . $id . '&amp;c=true">Da</a> | <a href="' . $linkPrefix . '">Odustani</a>';
                        } else {
                            if ($_REQUEST['c'] == 'true') {
                                //delete the record
                                if (deletePost($id)) {
                                    nicemessage('Uspješno ste obrisali post.');
                                    zamgerlog("obrisao post na projektu {$projekat} (pp{$predmet})", 2);
                                    zamgerlog2("obrisao post na projektu", $projekat);
                                    if (getCountPostsInThread($threadID) > 0) {
                                        $link = $linkPrefix . "&subaction=view&tid={$_REQUEST['tid']}";
                                    } else {
                                        $link = $linkPrefix;
                                    }
                                } else {
                                    niceerror('Došlo je do greske prilikom brisanja posta. Molimo kontaktirajte administratora.');
                                    $link = "javascript:history.back();";
                                }
                                nicemessage('<a href="' . $link . '">Povratak.</a>');
                            }
                        }
                        //else isset c get parameter
                    }
                    //id is okay
                }
                //subaction == del
            }
            //subaction set
        }
        //section == bb (forum)
    }
    //else - section is set
}
Exemplo n.º 10
0
function common_zavrsniStrane()
{
    //debug mod aktivan
    global $userid, $user_nastavnik, $user_student, $conf_files_path, $user_siteadmin;
    $predmet = intval($_REQUEST['predmet']);
    $ag = intval($_REQUEST['ag']);
    $zavrsni = intval($_REQUEST['zavrsni']);
    $subakcija = $_REQUEST['subakcija'];
    $id = intval($_REQUEST['id']);
    $sta = $_REQUEST['sta'];
    $linkPrefix = "?sta={$sta}&akcija=zavrsni_stranica&zavrsni={$zavrsni}&predmet={$predmet}&ag={$ag}";
    $lokacijafajlova = "{$conf_files_path}/zavrsni/fajlovi/{$zavrsni}/";
    // Osnovne informacije o radu
    $q10 = myquery("SELECT z.naslov, o.ime, o.prezime, o.naucni_stepen, z.student, z.sazetak, z.summary FROM zavrsni AS z, osoba AS o WHERE z.id={$zavrsni} AND z.mentor=o.id");
    if (mysql_num_rows($q10) < 1) {
        niceerror("Nepostojeći rad");
        zamgerlog("zavrsniStrane: nepostojeci rad {$zavrsni}", 3);
        zamgerlog2("nepostojeci rad", $zavrsni);
        return;
    }
    // Cache naučnog stepena
    $q20 = myquery("select id, titula from naucni_stepen");
    while ($r20 = mysql_fetch_row($q20)) {
        $naucni_stepen[$r20[0]] = $r20[1];
    }
    $naslov_rada = mysql_result($q10, 0, 0);
    $mentor = mysql_result($q10, 0, 2) . " " . $naucni_stepen[mysql_result($q10, 0, 3)] . " " . mysql_result($q10, 0, 1);
    $id_studenta = mysql_result($q10, 0, 4);
    if (substr($sta, 0, 7) != "student" || substr($sta, 0, 10) == "studentska") {
        $q30 = myquery("select ime,prezime,brindexa from osoba where id={$id_studenta}");
        $student = "Student: " . mysql_result($q30, 0, 1) . " " . mysql_result($q30, 0, 0) . " (" . mysql_result($q30, 0, 2) . ")";
    }
    // Naslov stranice
    ?>
	<h2><?php 
    echo $naslov_rada;
    ?>
</h2>
	<p>Mentor: <?php 
    echo $mentor;
    ?>
<br>
	<?php 
    echo $student;
    ?>
</p>
	<?php 
    // Prikaz ako nije odabrana subakcija
    if (!isset($subakcija)) {
        // Da li je definisan sazetak?
        $sazetak = mysql_result($q10, 0, 5);
        $summary = mysql_result($q10, 0, 6);
        if ($userid == $id_studenta) {
            if (!preg_match("/\\w/", $sazetak) || !preg_match("/\\w/", $summary)) {
                ?>
			<p><b><font color="red">Nije definisan sažetak teme</font></b></p>
			<p>Molimo vas da prije slanja finalne verzije rada definišete sažetak.</p>
			<?php 
            }
            ?>
		<p><a href="<?php 
            echo $linkPrefix;
            ?>
&subakcija=sazetak">Kliknite ovdje da definišete sažetak</a></p>
		<?php 
        }
        // Spisak fajlova
        ?>
	<center><table border="0"><tr><td>
	<p><b>Poslani fajlovi</b></p>
	<table border="1" cellspacing="0" cellpadding="4">
		<tr bgcolor="#CCCCCC">
			<td><b>Naziv</b></th>
			<td><b>Datum kreiranja</b></th>
			<td><b>Revizija</b></th>
			<td><b>Veličina</b></th>
			<td><b>Opcije</b></th>
		</tr>
	<?php 
        $q100 = myquery("SELECT id, osoba, filename, UNIX_TIMESTAMP(vrijeme), revizija FROM zavrsni_file WHERE zavrsni={$zavrsni} ORDER BY vrijeme");
        if (mysql_num_rows($q100) < 1) {
            ?>
		<tr><td colspan="5">Nije poslan niti jedan fajl</td></tr>
		<?php 
        }
        while ($r100 = mysql_fetch_row($q100)) {
            $id_fajla = $r100[0];
            $id_osobe = $r100[1];
            $filename = $r100[2];
            $datum = date("d. m. Y.", $r100[3]);
            $revizija = $r100[4];
            $filepath = $lokacijafajlova . $filename . "/v" . $revizija . "/" . $filename;
            $filesize = nicesize(filesize($filepath));
            ?>
		<tr>
			<td><a href="?sta=common/attachment&tip=zavrsni&zavrsni=<?php 
            echo $zavrsni;
            ?>
&id=<?php 
            echo $id_fajla;
            ?>
"><?php 
            echo $filename;
            ?>
</a></td>
			<td><?php 
            echo $datum;
            ?>
</td>
			<td><?php 
            echo $revizija;
            ?>
</td>
			<td><?php 
            echo $filesize;
            ?>
</td>
			<td>
				<a href="?sta=common/attachment&tip=zavrsni&zavrsni=<?php 
            echo $zavrsni;
            ?>
&id=<?php 
            echo $id_fajla;
            ?>
">Preuzmi</a>        
				<a href="<?php 
            echo $linkPrefix;
            ?>
&subakcija=izmijeni_fajl&id=<?php 
            echo $id_fajla;
            ?>
">Izmijeni</a>
				<a href="<?php 
            echo $linkPrefix;
            ?>
&subakcija=obrisi_fajl&id=<?php 
            echo $id_fajla;
            ?>
">Obriši</a>
			</td>
		</tr>
		<?php 
        }
        ?>
	</table>
	
	<p><a href="<?php 
        echo $linkPrefix;
        ?>
&subakcija=dodaj_fajl">Novi fajl</a></p>
	<?php 
        // Forum
        ?>
	<hr>
	
	<p><b>Komentari i diskusija</b></p>

	<p><a href="<?php 
        echo $linkPrefix;
        ?>
&subakcija=nova_tema">Dodajte novu temu za diskusiju</a></p>
	<?php 
        // Stylesheet za forum se nažalost nalazi u projekti.css - izbaciti...
        ?>
	<LINK href="css/projekti.css" rel="stylesheet" type="text/css">
	<?php 
        $tema_po_stranici = 20;
        $stranica = 1;
        if (isset($_REQUEST['stranica'])) {
            $stranica = $_REQUEST['stranica'];
        }
        // izračun offseta
        $offset = ($stranica - 1) * $tema_po_stranici;
        $q200 = myquery("SELECT t.id, t.pregleda, UNIX_TIMESTAMP(p.vrijeme), o.ime, o.prezime FROM zavrsni_bb_tema AS t, zavrsni_bb_post AS p, osoba AS o WHERE t.zavrsni={$zavrsni} AND t.zadnji_post=p.id AND p.osoba=o.id ORDER BY p.vrijeme DESC LIMIT {$offset}, {$tema_po_stranici}");
        $broj_tema = mysql_num_rows($q200);
        ?>
	<div id="threadList">
		<div class="threadRow caption clearfix">
			<div class="threadInfo">
				<div class="views">Pregleda</div><!--views-->
				<div class="lastReply">Zadnji odgovor</div><!--lastReply-->
				<div class="replies">Odgovora</div><!--replies-->
			</div><!--threadInfo-->
		<div class="title">Teme (<?php 
        echo $broj_tema;
        ?>
)</div><!--title-->		
		</div><!--threadRow caption-->
	<?php 
        $parni = true;
        while ($r200 = mysql_fetch_row($q200)) {
            $parni = !$parni;
            $id_teme = $r200[0];
            $broj_pregleda = $r200[1];
            $zadnji_odgovor = date('d.m.Y H:i:s', $r200[2]) . "<br />" . $r200[4] . ' ' . $r200[3];
            $q210 = myquery("SELECT COUNT(*) FROM zavrsni_bb_post WHERE tema = {$id_teme}");
            $broj_odgovora = mysql_result($q210, 0, 0);
            $q220 = myquery("SELECT p.naslov, o.ime, o.prezime FROM zavrsni_bb_post AS p, osoba AS o WHERE p.tema={$id_teme} AND p.osoba=o.id ORDER BY p.id LIMIT 1");
            $naslov = mysql_result($q220, 0, 0);
            $autor = mysql_result($q220, 0, 2) . " " . mysql_result($q220, 0, 1);
            ?>
		<div class="threadRow clearfix<?php 
            if ($parni) {
                echo ' pattern';
            }
            ?>
">
		<div class="threadInfo">
			<div class="views"><?php 
            echo $broj_pregleda;
            ?>
</div><!--views-->
			<div class="lastReply"><?php 
            echo $zadnji_odgovor;
            ?>
</div><!--lastReply-->
		<div class="replies"><?php 
            echo $broj_odgovora;
            ?>
</div><!--replies-->
		</div><!--threadInfo-->
		<div class="title"><a href="<?php 
            echo $linkPrefix . "&subakcija=vidi_temu&tema={$id_teme}";
            ?>
" title="<?php 
            echo $naslov;
            ?>
"><?php 
            echo $naslov;
            ?>
</a></div><!--title-->
		<div class="author"><?php 
            echo $autor;
            ?>
</div><!--author-->		
		</div><!--threadRow caption-->
		<?php 
        }
        //foreach thread
        ?>
	</div><!--threadList-->
	<?php 
        $brstranica = ceil($broj_tema / $tema_po_stranici);
        if ($brstranica > 0) {
            echo "<span class=\"newsPages\">";
            if ($stranica > 1) {
                $str = $stranica - 1;
                $prev = " <a href=\"{$linkPrefix}&stranica={$str}\">[Prethodna]</a> ";
                $prva = " <a href=\"{$linkPrefix}&stranica=1\">[Prva]</a> ";
            }
            if ($stranica < $brstranica) {
                $str = $stranica + 1;
                $next = " <a href=\"{$linkPrefix}&stranica={$str}\">[Sljedeća]</a> ";
                $zadnja = " <a href=\"{$linkPrefix}&stranica={$str}\">[Zadnja]</a> ";
            }
            echo $prva . $prev . " Strana <strong>{$stranica}</strong> od ukupno <strong>{$brstranica}</strong> " . $next . $zadnja;
            echo "</span>";
            //newsPages span
        }
        // Kraj foruma
        ?>
	</td></tr></table></center>
	<?php 
    }
    // if (!isset($subakcija))
    // SUBAKCIJE
    // Akcija dodavanje fajla
    if ($subakcija == 'dodaj_fajl') {
        if (isset($_REQUEST['submit'])) {
            if (!check_csrf_token()) {
                zamgerlog("csrf token nije dobar", 3);
                zamgerlog2("csrf token nije dobar");
                niceerror("Poslani podaci nisu ispravni. Vratite se nazad, ponovo popunite formu i kliknite na dugme Pošalji");
                return;
            }
            // ulazni parametri
            $filename = $_FILES['filename'];
            $revizija = 1;
            $file = '';
            $errorText = "";
            $zavrsni = intval($_REQUEST['zavrsni']);
            $predmet = intval($_REQUEST['predmet']);
            if ($filename['error'] == 4) {
                $errorText = 'Unesite sva obavezna polja.';
            } else {
                if ($filename['error'] == 1 || $filename['error'] == 2) {
                    $errorText .= 'Pokušavate poslati fajl koji je veci od dozvoljene velicine. Probajte sa manjim fajlom.<br />';
                } else {
                    if ($filename['error'] > 0) {
                        $errorText .= 'Vaš fajl nije poslan korektno. Molimo pokušajte ponovo.<br />';
                    } else {
                        $uploadFile = trim($filename['name']);
                        $uploadDir = $lokacijafajlova . $uploadFile . "/v{$revizija}/";
                        if (!file_exists($uploadDir)) {
                            mkdir($uploadDir, 0777, true);
                        }
                        if (move_uploaded_file($filename['tmp_name'], $uploadDir . $uploadFile)) {
                            chmod($uploadDir . $uploadFile, 0777);
                        } else {
                            $errorText .= 'Desila se greška prilikom uploada fajla. Molimo kontaktirajte administratora.<br />AA';
                        }
                    }
                }
            }
            if ($errorText != "") {
                niceerror($errorText);
                zamgerlog("greska prilikom slanja fajla na zavrsni {$zavrsni}", 3);
                zamgerlog2("greska prilikom slanja fajla na zavrsni", $zavrsni);
            } else {
                $q500 = myquery("SELECT id FROM zavrsni_file ORDER BY id DESC LIMIT 1");
                if (mysql_num_rows($q500) > 0) {
                    $id = mysql_result($q500, 0, 0) + 1;
                } else {
                    $id = 1;
                }
                $filename = my_escape($uploadFile);
                $q510 = myquery("INSERT INTO zavrsni_file SET id={$id}, filename='{$uploadFile}', revizija={$revizija}, osoba={$userid}, zavrsni={$zavrsni}, file=0");
                nicemessage("Fajl uspješno poslan");
                zamgerlog("dodao novi fajl na temu zavrsnog rada {$zavrsni} (pp{$predmet})", 2);
                zamgerlog2("dodao fajl na zavrsni", $zavrsni);
            }
            nicemessage('<a href="' . $linkPrefix . '">Povratak.</a>');
        } else {
            ?>
			<h3>Novi fajl</h3>
			<?php 
            echo genform("POST", "addForm\" enctype=\"multipart/form-data\" ");
            ?>

			<div id="formDiv">
				Polja sa * su obavezna. <br />
				<b>Limit za upload je 20MB.</b> <br />
				<div class="row">
					<span class="label">Fajl *</span>
					<span class="formw">
						<input name="filename" type="file" id="filename" size="60" />
						<input type="hidden" name="MAX_FILE_SIZE" value="20971520">
					</span>
				</div> 

				<div class="row">	
					<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
				</div>

			</div><!--formDiv-->
			</form>

			<?php 
        }
        // prikaz forme za slanje
    }
    // subakcija "add"
    // Akcija izmjena fajla
    if ($subakcija == 'izmijeni_fajl') {
        niceerror("Trenutno nije implementirano.");
        return;
    }
    // Subakcija brisanje fajla
    if ($subakcija == 'obrisi_fajl') {
        // Pošto nismo implementirali podršku za editovanje (revizije) brišemo samo jednu reviziju
        $q600 = myquery("SELECT zavrsni, filename, revizija FROM zavrsni_file WHERE id={$id}");
        if (mysql_num_rows($q600) < 1 || $zavrsni != mysql_result($q600, 0, 0)) {
            niceerror("Ilegalan završni rad");
            zamgerlog("spoofing fajla {$id} za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("id fajla nepostojeci ili ne odgovara zavrsnom", $id, $zavrsni);
            return;
        }
        $filename = mysql_result($q600, 0, 1);
        $revizija = mysql_result($q600, 0, 2);
        $lokacijarevizije = $lokacijafajlova . $filename . "/v{$revizija}";
        $lokacijafajla = $lokacijarevizije . "/" . $filename;
        if (!unlink($lokacijafajla) || !rmdir($lokacijarevizije)) {
            niceerror("Brisanje datoteke sa datotečnog sistema nije uspjelo.");
            print "Kontaktirajte administratora da vam obriše ovu datoteku.";
            zamgerlog("nije uspjelo brisanje fajla {$id} za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("nije uspjelo brisanje fajla za zavrsni", $id);
            return;
        }
        $q610 = myquery("DELETE FROM zavrsni_file WHERE id={$id}");
        nicemessage("Brisanje fajla uspjelo");
        zamgerlog("obrisan fajl {$id} za zavrsni rad {$zavrsni}", 2);
        zamgerlog2("obrisan fajl za zavrsni rad", $id, $zavrsni);
        nicemessage('<a href="' . $linkPrefix . '">Povratak.</a>');
        return;
    }
    // Subakcija čitanje teme na forumu
    if ($subakcija == 'vidi_temu') {
        $id_teme = intval($_REQUEST['tema']);
        $q700 = myquery("SELECT zavrsni FROM zavrsni_bb_tema WHERE id={$id_teme}");
        if (mysql_num_rows($q700) < 1 || $zavrsni != mysql_result($q700, 0, 0)) {
            niceerror("Nepostojeća tema.");
            zamgerlog("spoofing forum teme {$id_teme} za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("nepostojeca forum tema ili ne odgovara zavrsnom", $id_teme, $zavrsni);
            return;
        }
        // Stylesheet za forum se nažalost nalazi u projekti.css - izbaciti...
        ?>
		<LINK href="css/projekti.css" rel="stylesheet" type="text/css">
		<?php 
        $q710 = myquery("SELECT p.id, p.naslov, UNIX_TIMESTAMP(p.vrijeme), o.id, o.prezime, o.ime, pt.tekst FROM zavrsni_bb_post AS p, osoba AS o, zavrsni_bb_post_text AS pt WHERE p.tema={$id_teme} AND p.osoba=o.id AND p.id=pt.post");
        ?>
		<h3>Prikaz teme</h3>
		<p><a href="<?php 
        echo $linkPrefix;
        ?>
">Nazad na početnu stranicu</a></p>
		<div id="fullThread">
		<?php 
        while ($r710 = mysql_fetch_row($q710)) {
            $id_posta = $r710[0];
            $naslov = $r710[1];
            $vrijeme = date("d.m.Y. H:i:s", $r710[2]);
            $editabilno = $userid == $r710[3];
            $autor = $r710[4] . " " . $r710[5];
            $tekst = $r710[6];
            ?>
			<div class="post"><a name="p<?php 
            echo $id_posta;
            ?>
">
			<div id="post_<?php 
            echo $post[id];
            ?>
_header" class="header clearfix" onClick="toggleShowPost('post_<?php 
            echo $id_posta;
            ?>
')">
			<div class="buttons">
				<a href="<?php 
            echo $linkPrefix . "&subakcija=nova_poruka&tema={$id_teme}&post={$id_posta}";
            ?>
" title="Odgovori na ovaj post">Odgovori</a>
				<?php 
            if ($editabilno) {
                ?>
					| <a href="<?php 
                echo $linkPrefix . "&subakcija=izmijeni_poruku&tema={$id_teme}&post={$id_posta}";
                ?>
" title="Izmijeni vlastiti post">Izmijeni</a>
					| <a href="<?php 
                echo $linkPrefix . "&subakcija=obrisi_poruku&tema={$id_teme}&post={$id_posta}";
                ?>
" title="Obriši vlastiti post">Obriši</a>		
					<?php 
            }
            ?>
			</div>
			<div class="maininfo">
				<div class="date"><?php 
            echo $vrijeme;
            ?>
</div>
				<div class="author"><?php 
            echo $autor;
            ?>
</div> - 
				<div class="title"><?php 
            echo $naslov;
            ?>
</div>
			</div>
			</div><!--header-->
			<div class="text" id="post_<?php 
            echo $id_posta;
            ?>
_text"><?php 
            echo $tekst;
            ?>
</div><!--text-->
		
			</div><!--post-->
			<?php 
        }
        //foreach post
        // Povecavamo view counter
        $q720 = myquery("UPDATE zavrsni_bb_tema SET pregleda=pregleda+1 WHERE id={$id_teme}");
        ?>
		</div> <!-- fullthread -->
		<?php 
    }
    // Subakcija nova tema na forumu
    if ($subakcija == 'nova_tema') {
        if (isset($_REQUEST['submit'])) {
            if (!check_csrf_token()) {
                zamgerlog("csrf token nije dobar", 3);
                zamgerlog2("csrf token nije dobar");
                niceerror("Poslani podaci nisu ispravni. Vratite se nazad, ponovo popunite formu i kliknite na dugme Pošalji");
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            //get variables
            $naslov = my_escape(trim($_REQUEST['naslov']));
            $tekst = my_escape(trim($_REQUEST['tekst']));
            if (empty($naslov) || empty($tekst)) {
                niceerror('Unesite sva obavezna polja.');
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            $q800 = myquery("SELECT id FROM zavrsni_bb_tema ORDER BY id DESC LIMIT 1");
            if (mysql_num_rows($q800) > 0) {
                $id_teme = mysql_result($q800, 0, 0) + 1;
            } else {
                $id_teme = 1;
            }
            $q810 = myquery("INSERT INTO zavrsni_bb_tema SET id={$id_teme}, osoba={$userid}, zavrsni={$zavrsni}");
            $q820 = myquery("SELECT id FROM zavrsni_bb_post ORDER BY id DESC LIMIT 1");
            if (mysql_num_rows($q820) > 0) {
                $id_posta = mysql_result($q820, 0, 0) + 1;
            } else {
                $id_posta = 1;
            }
            $q830 = myquery("INSERT INTO zavrsni_bb_post SET id={$id_posta}, naslov='{$naslov}', osoba={$userid}, tema={$id_teme}");
            $q840 = myquery("INSERT INTO zavrsni_bb_post_text SET post={$id_posta}, tekst='{$tekst}'");
            $q850 = myquery("UPDATE zavrsni_bb_tema SET prvi_post={$id_posta}, zadnji_post={$id_posta} WHERE id={$id_teme}");
            nicemessage('Nova tema uspješno dodana.');
            zamgerlog("dodao novu temu na zavrsni rad {$zavrsni} (pp{$predmet})", 2);
            zamgerlog2("dodao novu temu na zavrsni rad", $zavrsni);
            nicemessage('<a href="' . $linkPrefix . '">Povratak.</a>');
            return;
        }
        ?>
	
		<h3>Nova tema</h3>
		<?php 
        echo genform("POST", "addForm");
        ?>
		<div id="formDiv">
			Polja sa * su obavezna. <br />
		
			<div class="row">
				<span class="label">Naslov *</span>
				<span class="formw"><input name="naslov" type="text" id="naslov" size="70" /></span> 
			</div>
			<div class="row">
				<span class="label">Tekst *</span>
				<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
			</div> 
					
			<div class="row">	
				<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
			</div>
		
		</div><!--formDiv-->
		
		</form>
		<?php 
    }
    // Subakcija odogovor na temu na forumu
    if ($subakcija == 'nova_poruka') {
        $id_teme = intval($_REQUEST['tema']);
        $id_posta = intval($_REQUEST['post']);
        $q900 = myquery("SELECT t.zavrsni, p.naslov FROM zavrsni_bb_post AS p, zavrsni_bb_tema AS t WHERE p.tema={$id_teme} AND t.id={$id_teme} ORDER BY p.id LIMIT 1");
        if (mysql_num_rows($q900) == 0 || $zavrsni != mysql_result($q900, 0, 0)) {
            niceerror("Nepostojeća tema.");
            zamgerlog("spoofing forum teme {$id_teme} za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("nepostojeca forum tema ili ne odgovara zavrsnom (odgovor)", $id_teme, $zavrsni);
            return;
        }
        // Submit akcija
        if (isset($_REQUEST['submit'])) {
            if (!check_csrf_token()) {
                zamgerlog("csrf token nije dobar", 3);
                zamgerlog2("csrf token nije dobar");
                niceerror("Poslani podaci nisu ispravni. Vratite se nazad, ponovo popunite formu i kliknite na dugme Pošalji");
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            //get variables
            $naslov = my_escape(trim($_REQUEST['naslov']));
            $tekst = my_escape(trim($_REQUEST['tekst']));
            if (empty($naslov) || empty($tekst)) {
                niceerror('Unesite sva obavezna polja.');
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            $q820 = myquery("SELECT id FROM zavrsni_bb_post ORDER BY id DESC LIMIT 1");
            if (mysql_num_rows($q820) > 0) {
                $id_posta = mysql_result($q820, 0, 0) + 1;
            } else {
                $id_posta = 1;
            }
            $q830 = myquery("INSERT INTO zavrsni_bb_post SET id={$id_posta}, naslov='{$naslov}', osoba={$userid}, tema={$id_teme}");
            $q840 = myquery("INSERT INTO zavrsni_bb_post_text SET post={$id_posta}, tekst='{$tekst}'");
            $q850 = myquery("UPDATE zavrsni_bb_tema SET zadnji_post={$id_posta} WHERE id={$id_teme}");
            nicemessage('Novi odgovor uspješno dodan.');
            zamgerlog("dodao novi odgovor na diskusiju ID {$id_teme}, tema zavrsnog rada {$zavrsni} (pp{$predmet})", 2);
            zamgerlog2("dodao novi odgovor na diskusiju za zavrsni rad", $id_teme, $zavrsni);
            nicemessage('<a href="' . $linkPrefix . "&subakcija=vidi_temu&tema={$id_teme}" . '">Povratak.</a>');
            return;
        }
        // Naslov poruke je "Re: $naslov"
        $novi_naslov = "Re: " . mysql_result($q900, 0, 1);
        ?>
	
		<h3>Novi odgovor</h3>
		<?php 
        echo genform("POST", "addForm");
        ?>
		<div id="formDiv">
			Polja sa * su obavezna. <br />
		
			<div class="row">
				<span class="label">Naslov *</span>
				<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
        echo $novi_naslov;
        ?>
" /></span> 
			</div>
			<div class="row">
				<span class="label">Tekst *</span>
				<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"></textarea></span>
			</div> 
					
			<div class="row">	
				<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
			</div>
		
		</div><!--formDiv-->
		
		</form>
		<?php 
    }
    // Subakcija izmjena poruke na forumu
    if ($subakcija == 'izmijeni_poruku') {
        $id_teme = intval($_REQUEST['tema']);
        // Samo se koristi za backlink
        $id_posta = intval($_REQUEST['post']);
        $q400 = myquery("SELECT p.osoba, p.naslov, pt.tekst FROM zavrsni_bb_post AS p, zavrsni_bb_post_text AS pt WHERE p.id={$id_posta} AND pt.post={$id_posta} AND p.tema={$id_teme}");
        // ujedno provjeravamo i temu
        if (mysql_num_rows($q400) < 1 || $userid != mysql_result($q400, 0, 0)) {
            niceerror("Niste autor ove poruke.");
            zamgerlog("spoofing forum poruke {$id_posta},{$id_teme} prilikom editovanja za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("nepostojeca forum poruka ili ne odgovara temi ili zavrsnom", $id_posta, $id_teme, $zavrsni);
            return;
        }
        // Submit akcija
        if (isset($_REQUEST['submit'])) {
            if (!check_csrf_token()) {
                zamgerlog("csrf token nije dobar", 3);
                zamgerlog2("csrf token nije dobar");
                niceerror("Poslani podaci nisu ispravni. Vratite se nazad, ponovo popunite formu i kliknite na dugme Pošalji");
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            //get variables
            $naslov = my_escape(trim($_REQUEST['naslov']));
            $tekst = my_escape(trim($_REQUEST['tekst']));
            if (empty($naslov) || empty($tekst)) {
                niceerror('Unesite sva obavezna polja.');
                nicemessage('<a href="javascript:history.back();">Povratak.</a>');
                return;
            }
            $q410 = myquery("UPDATE zavrsni_bb_post SET naslov='{$naslov}' WHERE id={$id_posta}");
            $q420 = myquery("UPDATE zavrsni_bb_post_text SET tekst='{$tekst}' WHERE post={$id_posta}");
            nicemessage('Uspješno ste izmijenili poruku.');
            zamgerlog("izmijenio vlastiti post {$id_posta}, tema zavrsnog rada {$zavrsni} (pp{$predmet})", 2);
            zamgerlog2("izmijenio vlastiti post za zavrsni rad", $id_posta, $zavrsni);
            nicemessage('<a href="' . $linkPrefix . "&subakcija=vidi_temu&tema={$id_teme}" . '">Povratak.</a>');
            return;
        }
        $naslov = mysql_result($q400, 0, 1);
        $tekst = mysql_result($q400, 0, 2);
        ?>
	
		<h3>Izmijeni poruku </h3>
		<?php 
        echo genform("POST", "addForm");
        ?>
		<div id="formDiv">
			Polja sa * su obavezna. <br />
		
			<div class="row">
				<span class="label">Naslov *</span>
				<span class="formw"><input name="naslov" type="text" id="naslov" size="70" value="<?php 
        echo $naslov;
        ?>
" /></span> 
			</div>
			<div class="row">
				<span class="label">Tekst *</span>
				<span class="formw"><textarea name="tekst" cols="60" rows="15" wrap="physical" id="tekst"><?php 
        echo $tekst;
        ?>
</textarea></span>
			</div> 
					
			<div class="row">	
				<span class="formw" style="margin-left:150px;"><input name="submit" type="submit" id="submit" value="Potvrdi"/></span>
			</div>
		
		</div><!--formDiv-->
		
		</form>
		<?php 
    }
    // Subakcija brisanje poruke na forumu
    if ($subakcija == 'obrisi_poruku') {
        $id_teme = intval($_REQUEST['tema']);
        // Samo se koristi za backlink
        $id_posta = intval($_REQUEST['post']);
        $q300 = myquery("SELECT osoba FROM zavrsni_bb_post WHERE id={$id_posta} AND tema={$id_teme}");
        // ujedno provjeravamo i temu
        if (mysql_num_rows($q300) < 1 || $userid != mysql_result($q300, 0, 0)) {
            niceerror("Niste autor ove poruke.");
            zamgerlog("spoofing forum poruke {$id_posta},{$id_teme} prilikom brisanja za zavrsni rad {$zavrsni}", 3);
            zamgerlog2("nepostojeca forum poruka ili ne odgovara temi ili zavrsnom (brisanje)", $id_posta, $id_teme, $zavrsni);
            return;
        }
        // Da li je ovo početna tema threada?
        $q310 = myquery("SELECT COUNT(*) FROM zavrsni_bb_post WHERE tema={$id_teme} AND id<{$id_posta}");
        if (mysql_result($q310, 0, 0) < 1) {
            $pocetna = true;
        } else {
            $pocetna = false;
        }
        // Submit akcija
        if (isset($_REQUEST['potvrda'])) {
            $q320 = myquery("DELETE FROM zavrsni_bb_post WHERE id={$id_posta}");
            $q330 = myquery("DELETE FROM zavrsni_bb_post_text WHERE post={$id_posta}");
            // Ako je početna poruka, brišemo kompletnu temu
            if ($pocetna) {
                $q340 = myquery("SELECT id FROM zavrsni_bb_post WHERE tema={$id_teme}");
                while ($r340 = mysql_fetch_row($q340)) {
                    $drugi_id = $r340[0];
                    $q350 = myquery("DELETE FROM zavrsni_bb_post WHERE id={$drugi_id}");
                    $q360 = myquery("DELETE FROM zavrsni_bb_post_text WHERE post={$drugi_id}");
                }
                $q370 = myquery("DELETE FROM zavrsni_bb_tema WHERE id={$id_teme}");
                nicemessage('Uspješno ste obrisali kompletnu temu.');
                zamgerlog("obrisao temu na forumu zavrsnog rada {$zavrsni} (pp{$predmet})", 2);
                zamgerlog2("obrisao temu na forumu zavrsnog rada", $id_teme, $zavrsni);
                nicemessage('<a href="' . $linkPrefix . '">Povratak.</a>');
            } else {
                nicemessage('Uspješno ste obrisali poruku.');
                zamgerlog("obrisao poruku na forumu zavrsnog rada {$zavrsni} (pp{$predmet})", 2);
                zamgerlog2("obrisao poruku na forumu zavrsnog rada", $id_posta, $zavrsni);
                nicemessage('<a href="' . $linkPrefix . "&subakcija=vidi_temu&tema={$id_teme}" . '">Povratak.</a>');
            }
            return;
        }
        // Ekran za potvrdu
        if ($pocetna) {
            ?>
			<p><b>Da li ste sigurni da želite kompletnu temu i sve poruke na njoj?</b> <br />
			<?php 
        } else {
            ?>
			<p><b>Da li ste sigurni da želite obrisati ovu poruku?</b> <br />
			<?php 
        }
        ?>
		Napominjemo da ne postoji opcija za povratak obrisanog (undelete)!<br />
		<a href="<?php 
        echo $linkPrefix . "&subakcija=obrisi_poruku&tema={$id_teme}&post={$id_posta}";
        ?>
 &potvrda=1">Da</a> | <a href="<?php 
        echo $linkPrefix . "&subakcija=vidi_temu&tema={$id_teme}";
        ?>
">Odustani</a></p>
		<?php 
    }
    // Subakcija za sažetak / summary
    if ($subakcija == 'sazetak') {
        if ($_REQUEST['potvrda'] && check_csrf_token()) {
            $sazetak = my_escape($_REQUEST['sazetak']);
            $summary = my_escape($_REQUEST['summary']);
            $q1000 = myquery("UPDATE zavrsni SET sazetak='{$sazetak}', summary='{$summary}' WHERE id={$zavrsni}");
            nicemessage("Sažetak ažuriran");
            zamgerlog("azuriran sazetak zavrsnog rada {$zavrsni}", 2);
            zamgerlog2("azuriran sazetak zavrsnog rada", $zavrsni);
            ?>
<a href="<?php 
            echo $linkPrefix;
            ?>
">Nazad</a><?php 
            return;
        }
        $sazetak = mysql_result($q10, 0, 5);
        $summary = mysql_result($q10, 0, 6);
        ?>
		<?php 
        echo genform("POST");
        ?>
		<input type="hidden" name="potvrda" value="da">
		<p>Sažetak (lokalni jezik):<br>
		<textarea rows="15" cols="60" name="sazetak"><?php 
        echo $sazetak;
        ?>
</textarea><br>
		&nbsp;<br>
		Sažetak (engleski jezik) - Summary:<br>
		<textarea rows="15" cols="60" name="summary"><?php 
        echo $summary;
        ?>
</textarea><br>
		&nbsp;<br>
		<input type="submit" value=" Pošalji izmjene ">
		<input type="button" value=" Nazad " onclick="javascript:history.go(-1);">
		</form>
		<?php 
    }
}
Exemplo n.º 11
0
    /* calculations first */
    if ($modx->hasPermission('settings') && $row['Name'] == $modx->getOption('table_prefix') . 'event_log' && $row['Data_length'] + $row['Data_free'] > 0) {
        $row['Data_size'] = '<a href="javascript:;" onclick="truncate(\'' . $row['Name'] . '\');" title="' . $modx->lexicon('truncate_table') . '">' . nicesize($row['Data_length'] + $row['Data_free']) . '</a>';
    } else {
        $row['Data_size'] = nicesize($row['Data_length'] + $row['Data_free']);
    }
    $row['Effective_size'] = nicesize($row['Data_length'] - $row['Data_free']);
    $row['Total_size'] = nicesize($row['Index_length'] + $row['Data_length'] + $row['Data_free']);
    /* now the non-calculated fields */
    $row['Data_length'] = nicesize($row['Data_length']);
    if ($modx->hasPermission('settings') && $row['Data_free'] > 0) {
        $row['Data_free'] = '<a href="javascript:;" onclick="optimize(\'' . $row['Name'] . '\');" title="' . $modx->lexicon('optimize_table') . '">' . nicesize($row['Data_free']) . '</a>';
    } else {
        $row['Data_free'] = nicesize($row['Data_free']);
    }
    $row['Index_length'] = nicesize($row['Index_length']);
    $dt[] = $row;
}
return $this->outputArray($dt);
function nicesize($size)
{
    if (!isset($size) || !is_numeric($size) || $size == 0) {
        return '0 B';
    }
    $a = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
    $pos = 0;
    while ($size >= 1024) {
        $size /= 1024;
        $pos++;
    }
    return $size == 0 ? '-' : round($size, 2) . ' ' . $a[$pos];
		<tr bgcolor="EFEFEF">
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td align="center">
				<b><?php 
echo nicesize($totaloverhead) . "<br>(" . number_format($totaloverhead) . " B)";
?>
 </b>
			</td>
			<td></td>
			<td></td>
			<td align="center">
				<b> <?php 
$TotalDBSize = explode(" ", nicesize($total));
?>
					<table border="0" width="100%">
						<tr>
							<td align="right" width="30%">
								<b><?php 
echo $TotalDBSize[0];
?>
 </b>
							</td>
							<td width="25%" align="left">
								<b><?php 
echo $TotalDBSize[1];
?>
 </b>
							</td>