<commit_before>﻿<?php
function common_projektneStrane()
{
	//debug mod aktivan
	global $conf_debug, $userid, $user_nastavnik, $user_student, $conf_files_path, $user_siteadmin;
	$predmet 	= intval($_REQUEST['predmet']);
	$projekat 	= intval($_REQUEST['projekat']);
	$action 	= $_GET['action'];
	
	//for project page only:
	$section 	= $_GET['section'];
	$subaction  = $_GET['subaction'];
	$id			= intval($_GET['id']);  //editing links, rss....
	if ($predmet <=0 || $projekat <=0)
	{
		//hijack attempt?
		zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane sa ID predmeta  ili ID projekta koji nije integer ili je <=0", 3);		
		return;
	}
	
	//bad userid
	if (!is_numeric($userid) || $userid <=0)
	{
		zamgerlog("korisnik sa losim ID koji nije integer ili je <=0 pokusao pristupiti modulu common/projektneStrane na predmetu p$predmet", 3);				
		return;	
	}

	if ($user_student && !$user_siteadmin) //ordinary student
	{
		$actualProject = getActualProjectForUserInPredmet($userid, $predmet);
		if ($actualProject[id] != $projekat)
		{
			//user is not in this project in this predmet...hijack attempt?
			zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane i projektu na kojem nije prijavljen ID=$projekat na predmetu p$predmet", 3);				
			return;	
		}
		
	}
	
	$params = getPredmetParams($predmet);
	$project = getProject($projekat);	
	$members = fetchProjectMembers($project[id]);
	
	if ($params[zakljucani_projekti] == 0)
	{
		zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane i projektu iako projektne strane jos nisu otvorene na predmetu p$predmet", 3);				
		return;
	}
	
	
	if ($user_student)
		$linkPrefix = "?sta=student/projekti&action=page&projekat=$projekat&predmet=$predmet";
	elseif ($user_nastavnik)
		$linkPrefix = "?sta=nastavnik/projekti&action=page&projekat=$projekat&predmet=$predmet";
	else
		return;
	
	$conf_debug = 1;
	

	?>   
     <div class="links">
            <ul>
            	<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><a href="<?php echo $linkPrefix . "&section=bb"?>">Grupa za diskusiju</a></li>
            </ul>   
     </div>	
    <?php	
	
	
	
	if (!isset($section))
	{
		//display project start page
	?>
   
    <?php
	
	} //section not set
	else
	{
		if ($section == 'info')
		{
			// display project info
	?>
<table class="projekti" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">Naziv</th>
    <td width="700" align="left" valign="top"><?=filtered_output_string($project['naziv'])?></td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Prijavljeni studenti</th>
    <td width="700" align="left" valign="top">
    	<?php
			if (empty($members))
				echo 'Nema prijavljenih studenata.';
			else
			{
		?>
        <ul>
        <?php
				foreach ($members as $member)
				{
		?>
        	<li><?=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="700" align="left" valign="top"><?=filtered_output_string($project['opis'])?></td>
  </tr>
</table>
    
     
    <?php
		
		} //section -- info
		elseif ($section == 'links')
		{
			//links management
			$linkPrefix .='&section=links';
	?>
<h2>Korisni linkovi</h2>
 <div class="links clearfix" id="link">
    <ul>
        <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($_GET['page']))
				{
					$pageNum = $_GET['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 clearfix" id="link">
    <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="linkovi" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <th width="200" align="left" valign="top" scope="row">URL</th>
    <td width="700" align="left" valign="top">
    <?php
						$url = stripslashes(htmlentities($link[url], ENT_QUOTES));
						$scheme = parse_url($url);
						$scheme  = $scheme['scheme'];
					
						if ($scheme == '') //only www part	
							$url = 'http://' . $url;
						
						
	?><a href="<?=$url ?>" title="<?=stripslashes(htmlentities($link['naziv'], ENT_QUOTES))?>" target="_blank"><?=filtered_output_string($link[naziv]); ?></a>   
    </td><commit_msg>kozmeticke promjene<commit_after>﻿<?php
function common_projektneStrane()
{
	//debug mod aktivan
	global $conf_debug, $userid, $user_nastavnik, $user_student, $conf_files_path, $user_siteadmin;
	$predmet 	= intval($_REQUEST['predmet']);
	$projekat 	= intval($_REQUEST['projekat']);
	$action 	= $_GET['action'];
	
	//for project page only:
	$section 	= $_GET['section'];
	$subaction  = $_GET['subaction'];
	$id			= intval($_GET['id']);  //editing links, rss....
	if ($predmet <=0 || $projekat <=0)
	{
		//hijack attempt?
		zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane sa ID predmeta  ili ID projekta koji nije integer ili je <=0", 3);		
		return;
	}
	
	//bad userid
	if (!is_numeric($userid) || $userid <=0)
	{
		zamgerlog("korisnik sa losim ID koji nije integer ili je <=0 pokusao pristupiti modulu common/projektneStrane na predmetu p$predmet", 3);				
		return;	
	}

	if ($user_student && !$user_siteadmin) //ordinary student
	{
		$actualProject = getActualProjectForUserInPredmet($userid, $predmet);
		if ($actualProject[id] != $projekat)
		{
			//user is not in this project in this predmet...hijack attempt?
			zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane i projektu na kojem nije prijavljen ID=$projekat na predmetu p$predmet", 3);				
			return;	
		}
		
	}
	
	$params = getPredmetParams($predmet);
	$project = getProject($projekat);	
	$members = fetchProjectMembers($project[id]);
	
	if ($params[zakljucani_projekti] == 0)
	{
		zamgerlog("korisnik u$userid pokusao pristupiti modulu common/projektneStrane i projektu iako projektne strane jos nisu otvorene na predmetu p$predmet", 3);				
		return;
	}
	
	
	if ($user_student)
		$linkPrefix = "?sta=student/projekti&action=page&projekat=$projekat&predmet=$predmet";
	elseif ($user_nastavnik)
		$linkPrefix = "?sta=nastavnik/projekti&action=page&projekat=$projekat&predmet=$predmet";
	else
		return;
	
	$conf_debug = 1;
	

	?>   
     <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
	?>
   
    <?php
	
	} //section not set
	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="700" align="left" valign="top"><?=filtered_output_string($project['naziv'])?></td>
  </tr>
  <tr>
    <th width="200" align="left" valign="top" scope="row">Prijavljeni studenti</th>
    <td width="700" align="left" valign="top">
    	<?php
			if (empty($members))
				echo 'Nema prijavljenih studenata.';
			else
			{
		?>
        <ul>
        <?php
				foreach ($members as $member)
				{
		?>
        	<li><?=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="700" align="left" valign="top"><?=filtered_output_string($project['opis'])?></td>
  </tr>
</table>
    
     
    <?php
		
		} //section -- info
		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($_GET['page']))
				{
					$pageNum = $_GET['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="700" align="left" valign="top">
    <?php
						$url = stripslashes(htmlentities($link[url], ENT_QUOTES));
						$scheme = parse_url($url);
						$scheme  = $scheme['scheme'];
					
						if ($scheme == '') //only www part	
							$url = 'http://' . $url;
						
						
	?><a href="<?=$url ?>" title="<?=stripslashes(htmlentities($link['naziv'], ENT_QUOTES))?>" target="_blank"><?=filtered_output_string($link[naziv]); ?></a>   
    </td>
{'fraction_non_alphanumeric': 0.19309051955008033, 'fraction_numerical': 0.00856989823245849, 'mean_word_length': 3.292337164750958, 'pattern_counts': {'":': 0, '<': 251, '<?xml version=': 0, '>': 241, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2942744', 'n_tokens_mistral': 4639, 'n_tokens_neox': 4183, 'n_words': 847}