Esempio n. 1
0
/**
 * Deletes a category in a channel and all its articles and clusters.
 * @param integer ID of the Channel Category to delete
 */
function deleteChannelCategory($categoryId)
{
    global $db;
    $sql = "SELECT ARTICLE_ID FROM channel_articles WHERE CH_CAT_ID={$categoryId}";
    $query = new query($db, $sql);
    while ($query->getrow()) {
        deleteArticle($query->field("ARTICLE_ID"));
    }
    deleteRow("channel_categories", "CH_CAT_ID = {$categoryId}");
}
function deleteCategory($id)
{
    global $REX, $I18N;
    $KAT = new sql();
    $KAT->setQuery("select * from rex_category where id='{$id}'");
    if ($KAT->getRows() == 1) {
        $re_id = $KAT->getValue("re_category_id");
        $KAT->setQuery("select * from rex_article where category_id='{$id}'");
        for ($i = 0; $i < $KAT->getRows(); $i++) {
            deleteArticle($KAT->getValue("id"));
            $KAT->next();
        }
        $KAT->query("delete from rex_article where category_id='{$id}'");
        $KAT->query("delete from rex_category where id='{$id}'");
        @unlink($REX[INCLUDE_PATH] . "/generated/categories/" . $id . ".category");
        @unlink($REX[INCLUDE_PATH] . "/generated/categories/" . $id . ".list.category");
        generateCategoryList($re_id);
        $message = $I18N->msg('category_deleted');
    } else {
        $message = $I18N->msg('category_doesnt_exist');
    }
    return $message;
}
Esempio n. 3
0
    $amessage = $I18N->msg("article_status_updated");
    $KAT->query("update rex_article set status='0' where id='{$article_id}'");
    generateArticle($article_id);
}
if ($function == "online_article" && $STRUCTURE_PERM) {
    $amessage = $I18N->msg("article_status_updated");
    $KAT->query("update rex_article set status='1' where id='{$article_id}'");
    generateArticle($article_id);
}
if ($function == "edit_article" && ($STRUCTURE_PERM || $REX_USER->isValueOf("rights", "article[{$article_id}]"))) {
    $amessage = $I18N->msg("article_updated");
    $KAT->query("update rex_article set name='{$article_name}',template_id='{$template_id}' where id='{$article_id}'");
    generateArticle($article_id);
}
if ($function == "delete_article" && $STRUCTURE_PERM) {
    $message = deleteArticle($article_id);
}
if ($function == "add_article" and $STRUCTURE_PERM) {
    $amessage = $I18N->msg("article_added");
    $AART = new sql();
    // vscope prior script
    $article_prior = $AART->new_order('rex_article', 'prior', 'category_id', $category_id);
    $AART->setTable("rex_article");
    $AART->setValue("name", $article_name);
    $AART->setValue("category_id", $category_id);
    $AART->setValue("prior", $article_prior);
    $AART->setValue("path", $KATSQLpath);
    $AART->setValue("startpage", 0);
    $AART->setValue("status", 0);
    $AART->setValue("online_von", date("YmdHis"));
    $AART->setValue("online_bis", "20100101");
Esempio n. 4
0
<?php

include '../../settings.php';
include '../../inc/login_functions.php';
include '../../inc/helper.php';
include 'functions.php';
$logedIn = access($mysqli);
/* Berechtigung den Artikel zu bearbeiten */
if (isset($_GET['article'])) {
    $articleId = trim(htmlentities($_GET['article'], ENT_QUOTES, "UTF-8"));
    $articleId = $mysqli->real_escape_string($articleId);
    $article = getArticle($mysqli, $articleId);
    if ($article['userId'] != $_SESSION['userId']) {
        header("Location: ../../404.php");
        exit;
    }
}
if (deleteArticle($mysqli, $articleId) == 1) {
    header("Location: ../Account/account.php");
    exit;
} else {
    header("Location: ../../404.php");
    exit;
}
Esempio n. 5
0
                        break;
                }
            }
        } else {
            $result = new ZenpageNews('');
            $result->setPermalink(1);
            $result->setDateTime(date('Y-m-d H:i:s'));
        }
    }
    if (isset($_GET['save'])) {
        XSRFdefender('save');
        $result = updateArticle($reports, true);
    }
    if (isset($_GET['delete'])) {
        XSRFdefender('delete');
        $msg = deleteArticle(sanitize($_GET['delete']));
        if (!empty($msg)) {
            $reports[] = $msg;
        }
    }
}
if (is_AdminEditPage('newscategory')) {
    $tab = 'news';
    $_GET['tab'] = 'categories';
    if (isset($_GET['save'])) {
        XSRFdefender('save');
        updateCategory($reports, true);
    }
    if (isset($_GET['titlelink'])) {
        $result = new ZenpageCategory(urldecode(sanitize($_GET['titlelink'])));
    } else {
Esempio n. 6
0
                        break;
                }
            }
        } else {
            $result = new ZenpageNews('');
            $result->setPermalink(1);
            $result->setDateTime(date('Y-m-d H:i:s'));
        }
    }
    if (isset($_GET['save'])) {
        XSRFdefender('save');
        $result = addArticle($reports);
    }
    if (isset($_GET['delete'])) {
        XSRFdefender('delete');
        $msg = deleteArticle($_GET['delete']);
        if (!empty($msg)) {
            $reports[] = $msg;
        }
    }
}
if (is_AdminEditPage('category')) {
    $tab = 'news';
    $_GET['tab'] = 'categories';
    if (isset($_GET['save'])) {
        XSRFdefender('save');
        addCategory($reports);
    }
    if (isset($_GET['titlelink'])) {
        $result = new ZenpageCategory(urldecode($_GET['titlelink']));
    } else {
Esempio n. 7
0
<?
require_once('articleModel.php');

$id = trim( 10 );

$result = deleteArticle( $id );
if( $result ){
	echo 'Новость успешно удалена';
}else echo 'Ошибка удаления новости';
Esempio n. 8
0
    $json = file_get_contents('php://input');
    $data = json_decode($json, true);
    var_dump($data);
    $tinyurl = "";
    if (!empty($data["link"])) {
        get_tiny_url($data["link"]);
    }
    return insertArticle($data["title"], $data["body"], $tinyurl);
} elseif ($_SERVER["REQUEST_METHOD"] == "DELETE") {
    $json = file_get_contents('php://input');
    $data = json_decode($json, true);
    $articleID = $data["articleId"];
    if (empty($articleID)) {
        return;
    }
    deleteArticle($articleID);
    log_info("Delete Article: " . $articleID);
} else {
    error("unknown verb");
}
//Functions
//gets the data from a URL
function get_tiny_url($url)
{
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url=' . $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $data = curl_exec($ch);
    curl_close($ch);
Esempio n. 9
0
 * the following disclaimer in the documentation and/or other materials
 * provided with the distribution. Neither the name of the University of
 * Massachusetts Lowell nor the names of its contributors may be used to
 * endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 */
require_once '../includes/config.php';
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case "delete":
            deleteArticle($_GET['id']);
            echo "worked!";
            break;
        case "publish":
            publishArticle($_GET['id']);
            echo "worked!";
            break;
    }
}
Esempio n. 10
0
?>
            </div>
            <div id="menu-bottom" />
        </div>

        <div id="content">
            <?php 
if (isset($_POST['chosenArticle'])) {
    /* show input fields to mod article */
    showModArticle($_POST['chosenArticle']);
} elseif (isset($_POST['articleToModId'])) {
    /* submit article mod */
    submitModArticle($_POST['modArticleTitle'], $_SESSION['username'], $_POST['modArticleText'], $_POST['articleToModId']);
} elseif (isset($_POST['articleToDeleteId'])) {
    /* id of admin to delete */
    deleteArticle($_POST['articleToDeleteId']);
} elseif (isset($_POST['addNewArticle'])) {
    /* show addNewAdmin form */
    addNewArticleForm();
} elseif (isset($_POST['submitNewArticle'])) {
    /* insert new article to database */
    insertNewArticle($_POST['newTitle'], $_SESSION['username'], $_POST['newArticle']);
} else {
    /* show news selection form */
    showNewsList();
}
?>
        </div>

        <div class="separate sfondo-footer"><?php 
bottomPageInfo();
Esempio n. 11
0
<?php

require_once "../../config.inc.php";
$auth = new auth("CHANNEL_EDIT");
$page = new Page("Edit Channels");
require_once $c["path"] . "modules/channels/article_select_form.php";
if (value("action") == "deletearticle" && $auth->checkAccessToFunction("CHANNEL_DELETE")) {
    $article = value("article", "NUMERIC");
    deleteArticle($article);
}
if (value("action") == "launcharticle" && $auth->checkAccessToFunction("CHANNEL_LAUNCH")) {
    $article = value("article", "NUMERIC");
    launchArticle($article, 10, variation());
}
if (value("action") == "expirearticle" && $auth->checkAccessToFunction("CHANNEL_LAUNCH")) {
    $article = value("article", "NUMERIC");
    expireArticle($article, 10, variation());
}
$selch = new SelectMenu($lang->get("channel_select", "Select Channel"), "chsel", "channels", "NAME", "CHID", "1");
$lang->delete("help_articles");
$selch->tipp = $lang->get("help_articles", "The form displays articles.<br><br>The color codes are:<li>red: article not published<li>grey: article not translated<li>green: article published");
$rowOrderFilter = "VERSION=0 AND CHID=" . $selch->selected;
if (value("action") == "up") {
    $article = value("article", "NUMERIC");
    moveRowUp("channel_articles", "ARTICLE_ID", $article, "POSITION", $rowOrderFilter);
} else {
    if (value("action") == "down") {
        $article = value("article", "NUMERIC");
        moveRowDown("channel_articles", "ARTICLE_ID", $article, "POSITION", $rowOrderFilter);
    }
}
Esempio n. 12
0
         addArticle($_POST);
     }
     break;
 case "edit_article":
     if (notNull($_POST)) {
         editArticle($_POST);
     }
     break;
 case "update_articles":
     if (notNull($_POST)) {
         updateArticles($_POST['order']);
     }
     break;
 case "delete_article":
     if (notNull($_POST)) {
         deleteArticle($_POST['id']);
     }
     break;
 case "shout":
     if (notNull($_POST)) {
         shout($_POST['message'], $_POST['dest']);
     }
     break;
 case "upshout":
     updateShoutbox();
     break;
 case "classUpdate":
     getClassCombo($_POST['id'], $_POST['i'], $_POST['className']);
     break;
 case "specUpdate":
     getSpecCombo($_POST['class'], $_POST['id'], $_POST['i'], $_POST['spec']);
Esempio n. 13
0
// Check for the submit
$edit = filter_input(INPUT_POST, 'edit', FILTER_DEFAULT);
$saveEdit = filter_input(INPUT_POST, 'saveEdit', FILTER_DEFAULT);
$cancelEdit = filter_input(INPUT_POST, 'cancelEdit', FILTER_DEFAULT);
$pageLocation = PageLocation::Article;
if ($edit != "") {
    $pageLocation = PageLocation::EditArticle;
} else {
    if ($saveEdit != "") {
        updateArticle($saveEdit);
    }
}
include_once __ROOT__ . '/admin/index.php';
$delete = filter_input(INPUT_POST, 'delete', FILTER_DEFAULT);
if ($delete != "") {
    deleteArticle($delete);
} else {
    //showAllArticles();
}
function editArticle($edit)
{
    // Create DB connection
    require_once __ROOT__ . '/admin/include/DBclass.php';
    $sqlConn = new DBclass("nazmarket");
    $query = "SELECT * FROM article, category, company, unit " . "     WHERE ((article.idcategory = category.idcategory) AND " . "             (article.idcompany = company.idcompany) AND " . "             (article.idunit = unit.idunit) AND (article.idarticle=" . $edit . "))";
    $article = $sqlConn->exeQuery($query);
    $article = $article->fetch_assoc();
    $category = $sqlConn->exeQuery("SELECT * FROM category");
    $company = $sqlConn->exeQuery("SELECT * FROM company");
    $unit = $sqlConn->exeQuery("SELECT * FROM unit");
    // Errors:
Esempio n. 14
0
}
switch ($action) {
    case 'login':
        login();
        break;
    case 'logout':
        logout();
        break;
    case 'newArticle':
        newArticle();
        break;
    case 'editArticle':
        editArticle();
        break;
    case 'deleteArticle':
        deleteArticle();
        break;
    default:
        listArticles();
}
function login()
{
    $results = array();
    $results['pageTitle'] = "Admin Login | Falcon";
    if (isset($_POST['login'])) {
        // User has posted the login form: attempt to log the user in
        if ($_POST['username'] == ADMIN_USERNAME && $_POST['password'] == ADMIN_PASSWORD) {
            // Login successful: Create a session and redirect to the admin homepage
            $_SESSION['username'] = ADMIN_USERNAME;
            header("Location: admin.php");
        } else {
Esempio n. 15
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
}
Esempio n. 16
0
     sleep(3);
     continue;
 }
 /* Read available */
 if (count($r) > 0) {
     $hdrs = false;
     if (takethisclean($hdrs, $fp) && $hdrs !== false && is_array($hdrs) && isset($hdrs['message-id'])) {
         /* Cancel */
         if (isset($hdrs['control'])) {
             /* Example:
                   Control: cancel <*****@*****.**>
                */
             if (substr($hdrs['control'], 0, 8) == 'cancel <') {
                 $mid = substr($hdrs['control'], 7, strlen($hdrs['control']) - 7);
                 echo "Deleting " . $mid . ": ";
                 if (!deleteArticle($papi, $mid)) {
                     /* Ignored */
                 }
                 echo "DONE\n";
             }
         } else {
             echo "Adding " . $hdrs['message-id'] . ": ";
             if (!processArticle($papi, $hdrs)) {
                 throw new Exception("Unable to push article to PAPI");
             }
             echo "DONE\n";
         }
         $seen++;
     } else {
         echo "Error: closing socket\n";
         fclose($fp);
function showArticleAdministration()
{
    require_once ROOT . "includes/items.php";
    require_once ROOT . "DBInterface/articleDB.php";
    require_once ROOT . "DBInterface/languageDB.php";
    require_once ROOT . "DBInterface/articleTranslationDB.php";
    if (isset($_POST['action'])) {
        if ($_POST['action'] == 'add') {
            $articleDB = new ArticleDB();
            $res = $articleDB->addArticle($_POST['artSystemName'], $_POST['artSystemDescription'], $_POST['artPrice'], $_POST['artImagePath']);
            $resID = $res->fetch_object();
            $artID = $resID->Article_ID;
            saveCategory($artID);
            saveLanguages($artID);
        } else {
            if ($_POST['action'] == 'update') {
                $articleDB = new ArticleDB();
                $artID = $_POST['artId'];
                $res = $articleDB->updateArticle($_POST['artId'], $_POST['artSystemName'], $_POST['artSystemDescription'], $_POST['artPrice'], $_POST['artImagePath']);
                saveCategory($artID);
                saveLanguages($artID);
            } else {
                if ($_POST['action'] == 'delete') {
                    $artID = $_POST['artId'];
                    deleteArticle($artID);
                }
            }
        }
    }
    $lang = $_COOKIE["lang"];
    include ROOT . "resources/{$lang}.php";
    $items = array();
    $article = null;
    $articleDB = new ArticleDB();
    echo "<table  class=\"basket-table\" border=\"1px\">";
    echo "<thead>";
    echo "<tr>";
    echo "<th>{$adminArticleId}</th>";
    echo "<th>{$adminArticleName}</th>";
    echo "<th>{$adminArticleDescription}</th>";
    echo "<th>{$adminArticlePrice}</th>";
    echo "<th>{$adminArticleImage}</th>";
    echo "<th>&nbsp;</th>";
    echo "<th>&nbsp;</th>";
    echo "</tr>";
    echo "</thead>";
    echo "<tbody>";
    $res = $articleDB->getAllArticles();
    while ($items = $res->fetch_object()) {
        $articleId = $items->Article_ID;
        $articleName = $items->ArticleName;
        $articleDescription = $items->ArticleDescription;
        $articlePrice = $items->ArticlePrice;
        $articleImage = $items->ArticleImage;
        $article = new article($articleId, $articleName, $articlePrice, $articleDescription, $articleImage, null);
        echo "<tr>";
        echo "<td>" . $article->getId() . "</td>";
        echo "<td>" . $article->getName() . "</td>";
        echo "<td>" . $article->getDescription() . "</td>";
        echo "<td>" . $article->getPrice() . "</td>";
        echo "<td>" . $article->getImage() . "</td>";
        echo "<form action=\"index.php?site=changeArticle\" method=\"get\">";
        echo "<input type=\"hidden\" name=\"artId\" value=\"" . $article->getId() . "\" /input>";
        echo "<input type=\"hidden\" name=\"site\" value=\"changeArticle\" /input>";
        echo "<input type=\"hidden\" name=\"origin\" value=\"update\" /input>";
        echo "<td> <input class=\"basket-update-button\" type=\"submit\" value=\"{$adminArticleUpdateLabel}\"/></td>";
        echo "</form>";
        echo "<form action=\"index.php?" . $_SERVER['QUERY_STRING'] . "\" method=\"post\">";
        echo "<input type=\"hidden\" name=\"artId\" value=\"" . $article->getId() . "\" /input>";
        echo "<input type=\"hidden\" name=\"action\" value=\"delete\" /input>";
        echo "<td> <input class=\"basket-delete-button\" name=\"delete\" type=\"submit\" value=\"{$adminArticleDeleteLabel}\"/></td>";
        echo "</form>";
        echo "</tr>";
        echo "</form>";
    }
    // last line to add a new article
    echo "<form action=\"index.php?site=changeArticle\" method=\"get\">";
    // echo "<input type=\"hidden\" name=\"articleId\" value=\"" . $articleId . "\" /input>";
    echo "<tr>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<td></td>";
    echo "<input type=\"hidden\" name=\"site\" value=\"changeArticle\" /input>";
    echo "<input type=\"hidden\" name=\"origin\" value=\"add\" /input>";
    echo "<td> <input class=\"basket-update-button\"  type=\"submit\" value=\"{$adminArticleAddLabel}\"/></td>";
    echo "</tr>";
    echo "</form>";
    echo "</tbody>";
    echo "</table>";
}