function getCountRepliesToFirstPostInThread($id) { $nPosts = getCountPostsInThread($id); if ($nPosts == 0) { return 0; } else { return $nPosts - 1; } }
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 . "§ion=info"; ?> ">Informacije o projektu</a></li> <li><a href="<?php echo $linkPrefix . "§ion=links"; ?> ">Korisni linkovi</a></li> <li><a href="<?php echo $linkPrefix . "§ion=rss"; ?> ">RSS feedovi</a></li> <li><a href="<?php echo $linkPrefix . "§ion=bl"; ?> ">Članci</a></li> <li><a href="<?php echo $linkPrefix . "§ion=file"; ?> ">Fajlovi</a></li> <li class="last"><a href="<?php echo $linkPrefix . "§ion=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 . "§ion=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 . "§ion=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 . "§ion=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 . "§ion=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 . "§ion=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 . "§ion=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 . "§ion=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 .= '§ion=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 .= '§ion=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 .= '§ion=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 . '&subaction=del&id=' . $id . '&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 .= '§ion=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 .= '§ion=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 . '&subaction=del&tid=' . $threadID . '&id=' . $id . '&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 }