Exemplo n.º 1
0
function m_va()
{
    // Calls new view article function, rest of code should be dumped
    va();
    return;
    global $anyone_comments;
    if (isset($_REQUEST['c'])) {
        $skip_chars = $_REQUEST['c'];
    } else {
        $skip_chars = 0;
    }
    echo "<!-- start view article -->";
    global $article_author;
    $articleid = $_REQUEST['articleid'];
    echo '<div class="articles"><table><tr><td class="articlescell">';
    if (!$articleid) {
        echo "Ingen artikkel er valgt.";
    } else {
        $query = "SELECT * FROM articles WHERE articleid =" . $articleid . " AND is_deleted IS NULL  AND (is_draft IS NULL OR is_draft=0);";
        $result = DB_get_table($query);
        $num_results = DB_rows_affected($query);
        if ($num_results == 0) {
            echo "Fant ikke ønsket artikkel.";
        } else {
            increment_view_count($articleid);
            $row = DB_next_row($result);
            echo '<div class="header2">' . stripslashes($row['title']) . '</div>';
            echo '<div class="metatext">' . $article_author;
            echo '<span class="author">: ';
            if (isset($row['author_username'])) {
                echo '<a href="index.php?m_c=mvp&amp;username='******'author_username'] . '">' . stripslashes($row['author']) . '</a>';
            } else {
                echo stripslashes($row['author']);
            }
            echo '</span>';
            echo ', postet <span class="date">' . make_date($row['date_posted']) . '</span><span class="time"> ' . make_time($row['time_posted']) . '</span></div>';
            echo '<div class="textbody">';
            $body = stripslashes(nl2br($row['body']));
            /* If reader continues an article read partly on front page, we 
             * insert anchor tag that the browser can skip to
             */
            if ($skip_chars == 0) {
                echo $body;
            } else {
                echo substr($body, 0, $skip_chars);
                echo '<a name="continue"></a>';
                echo substr($body, $skip_chars, strlen($body) - $skip_chars);
            }
            echo '</div>';
            $edit_ok = false;
            // hvis admin
            if (isset($_SESSION['valid_admin'])) {
                if ($_SESSION['valid_admin']) {
                    $edit_ok = true;
                }
            }
            // hvis valid user, og forfatter av den.
            if (isset($_SESSION['valid_user']) && isset($row['author_username'])) {
                if ($row['author_username'] == $_SESSION['valid_user']) {
                    $edit_ok = true;
                }
            }
            if ($edit_ok) {
                echo '<div class="editarticle">';
                echo '<a href="index.php?articleid=' . $row['articleid'] . '&m_c=module_delete_article">Slett</a> ';
                echo '<a href="index.php?articleid=' . $row['articleid'] . '&m_c=module_enter_article&edit=1">Rediger</a>';
                echo '</div>';
            }
            $comments_query = "SELECT * FROM articles WHERE comment_to=" . $articleid . " AND is_deleted IS NULL ORDER BY date_posted, time_posted ASC;";
            $comments_results = DB_get_table($comments_query);
            $num_comments = DB_rows_affected($comments_results);
            if ($num_comments != 0) {
                echo '</td></tr><tr><td class="header4"><a name="comments">Kommentarer</a></tr></td>';
                display_comments_rows($comments_results);
            } else {
                echo '</td></tr>';
            }
            // End DIV articles
            echo '</table></div>';
            if ($anyone_comments || isset($_SESSION["valid_user"])) {
                echo '<div class="default_header"><a name="commentform">Legg til en kommentar</a></div>';
                do_comment_form();
            } else {
                echo '<div class="default_text">Du må være en <a href="index.php?m_c=module_register_form&amp;page_title=Register<+new+user">registrert bruker</a>';
                echo " og <span id='loginlink''><a href=\"javascript:showDiv('loginform', 'errorandlogout')\">logget inn</a> for å kunne kommentere.</span></div>";
            }
        }
    }
}
Exemplo n.º 2
0
function viewArticle()
{
    $articleid = $_REQUEST['articleid'];
    $article = getValidArticle($articleid);
    if (!$article) {
        h3("Fant ikke artikkelen.");
    } else {
        increment_view_count($articleid);
        table_open();
        tr_open();
        td_open(1);
        printArticle($article[0]);
        div_open("showarticlelink");
        if (isset($_SESSION['valid_admin'])) {
            echo printAdminArticlesMenu($article[0]['articleid']);
        } else {
            if (isset($_SESSION['valid_user'])) {
                if ($_SESSION['valid_user'] == $article[0]['author_username']) {
                    echo printAuthorArticlesMenu($article[0]['articleid']);
                }
            }
        }
        div_close();
        td_close();
        tr_close();
        table_close();
        makeAnchor("comments");
        listComments($article[0]['articleid']);
        if (isset($_SESSION['valid_user'])) {
            makeAnchor("entercomment");
            enterComment($article[0]['articleid']);
        } else {
            echo '<a href="javascript:viewLogin()">Logg inn for å legge inn kommentar</a>';
        }
    }
}