Exemplo n.º 1
0
function create_special_feed($db, $type)
{
    require 'CPoem.php';
    $cPoem = new CPoem($db, $_SESSION);
    if ($type == 'newest') {
        $poems = $cPoem->getNewestPoems(10);
        create_rss($poems, 'Uusimmat runot', 'http://www.runosydan.net/rss.php?special=newest');
    }
}
Exemplo n.º 2
0
function show_poet_information($db, $data)
{
    $cUsers = new CUsers($db);
    echo '<div class="poet_info">';
    echo '<div class="textblock">';
    echo '<h3>Runoilijan tiedot</h3>';
    echo '</div>';
    // Get user ID.
    if (isset($data['id'])) {
        $id = mysql_real_escape_string($data['id']);
    } else {
        echo 'Käyttäjän ID:tä ei olla annettu!';
    }
    $ret = $cUsers->getUserInfo($id);
    // Fields to add in form
    $fields = array('username' => 'Käyttäjätunnus', 'firstname' => 'Etunimi', 'lastname' => 'Sukunimi', 'city' => 'Kaupunki', 'homepage' => 'Kotisivu', 'birthdate' => 'Syntymäpäivä', 'email' => 'Sähköposti', 'num_poems' => 'Runoja');
    // Count number of poems
    $cPoem = new CPoem($db, $_SESSION);
    if ($_SESSION['id'] == $id) {
        $ret[0]['num_poems'] = $cPoem->numPoems($ret[0]['id'], true);
    } else {
        $ret[0]['num_poems'] = $cPoem->numPoems($ret[0]['id'], false);
    }
    echo '<table>';
    foreach ($ret[0] as $key => $value) {
        // Convert birthdate to correct format
        if ($key == 'birthdate' && $value != '') {
            $tmp = explode('-', $value);
            $value = $tmp[2] . '.' . $tmp[1] . '.' . $tmp[0];
        }
        // Show only fields what are listed in array $fiels
        if (isset($fields[$key])) {
            echo '<tr>';
            echo '<td>';
            echo $fields[$key];
            echo '</td>';
            echo '<td>';
            echo $value;
            echo '</td>';
            echo '</tr>';
        }
    }
    echo '</table>';
    // Link back to poems
    echo '<div class="back_to_poems">';
    echo '<a href="poet.php?id=' . $ret[0]['id'] . '">' . 'Takaisin runoilijan runoihin</a>';
    echo '</div>';
    echo '</div>';
}
Exemplo n.º 3
0
if (!isset($_GET['num_poems'])) {
    $_GET['num_poems'] = 50;
}
// Maximum is 100 poems per page. We do not want
// to make whole server lag because of this.
if ($_GET['num_poems'] > 100) {
    $_GET['num_poems'] = 100;
}
echo '<div class="poems">';
echo '<table width="100%">';
echo '<tr><td><h3>' . $_GET['num_poems'] . ' uusinta runoa</h3></td>';
echo '<td>';
echo '<a href="rss.php?special=newest"><img src="graphics/rss.gif" class="rss">';
echo '</a></td></tr></table>';
// Get 50 newest poems
$cPoem = new CPoem($db, $_SESSION);
$cUsers = new CUsers($db, $_SESSION);
$poems = $cPoem->getNewestPoems($_GET['num_poems']);
echo '<table>';
echo '<tr>';
echo '<td><b>Runoilija</b></td>';
echo '<td><b>Runon nimi</b></td>';
echo '<td><b>Lisätty</b></td>';
echo '</tr>';
$poems_per_page = $cPoem->getPoemsPerPage();
foreach ($poems as $poem) {
    echo '<tr>';
    echo '<td>';
    echo '<a href="poet.php?id=' . $poem['user_id'] . '">';
    echo $cUsers->getUsername($poem['user_id']);
    echo '</a>';
Exemplo n.º 4
0
You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
// This site cannot be seen if user is not logged in.
if (!isset($_SESSION['username'])) {
    header('Location: index.php');
}
require 'general_functions.php';
// If user has selected to show poems with or without comments
if (isset($_GET['action'])) {
    // By default do not show comments
    $com = false;
    // This is required when we want to get comments
    require 'CPoem.php';
    $cPoem = new CPoem($db, $_SESSION);
    if ($_GET['action'] == 'with_comments') {
        $com = true;
    }
    // Select all poems by this writer.
    $q = 'SELECT id, title, poem FROM rs_poem WHERE user_id="' . $_SESSION['id'] . '"';
    try {
        $ret = $db->query($q);
    } catch (Exception $e) {
        echo 'Tietokantavirhe!';
        die;
    }
    $num = $db->numRows($ret);
    if ($num > 0) {
        header('Content-Type: text/plain; charset=UTF-8');
        $ret = $db->fetchAssoc($ret);
Exemplo n.º 5
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require 'general_functions.php';
require 'CPoem.php';
// This site cannot be seen if user is not logged in.
if (!isset($_SESSION['username'])) {
    header('Location: index.php');
}
$cPoem = new CPoem($db, $_SESSION);
// First we must check if POST-data is given. If there is POST-data,
// then we have shown this page already and user has pressed button
// what will send (possible) modified data here again.
if (isset($_POST)) {
    // Get poem ID from POST-values.
    $id = mysql_real_escape_string($_POST['id']);
    // Check that this poem really belongs to logged user.
    // This should be done here also, because otherwise it
    // would be possible that someone just sends POST-data
    // and then he/she could edit any poem he wants to.
    $owner_id = $cPoem->getPoemWriterID($id);
    // Is poem owner really the same than the user who is logged in?
    if ($owner_id == $_SESSION['id']) {
        $cPoem->editPoem($_POST);
        $_SESSION['message'] = 'Runo päivitetty!';
Exemplo n.º 6
0
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
require 'general_functions.php';
require 'CPoem.php';
create_site_top();
create_top_menu();
$cPoem = new CPoem($db, $_SESSION);
$cUsers = new CUsers($db, $_SESSION);
if (isset($_GET['date'])) {
    $date = $_GET['date'];
} else {
    $date = date('Y-m-d');
}
// Get poems by day needs to get date in YYYY-MM-DD format
// so get poems before change date format.
$poems = $cPoem->getPoemsByDay($date);
// Convert to finnish time format, day.month.year
$date = date('d.m.Y', strtotime($date));
echo '<div class="poems_by_day">';
echo '<div class="header_div">';
echo '<a href="poems_by_day.php?date=' . date('Y-m-d', strtotime("-1 day", strtotime($date))) . '">&lt;&lt;</a>';
echo '<span class="header">' . $date . ' kirjoitetut runot</span>';
Exemplo n.º 7
0
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
require 'general_functions.php';
require 'CPoem.php';
create_site_top();
create_top_menu();
echo '<div class="poems">';
echo '<h3>Runot</h3>';
echo '<table class="title_table">';
echo '<tr><td><h3><a href="newest_poems.php">10 uusinta runoa</a></h3></td>';
echo '<td>';
echo '<a href="rss.php?special=newest"><img src="graphics/rss.gif" class="rss" alt="rss">';
echo '</a></td></tr></table>';
// Get 10 newest poems
$cPoem = new CPoem($db, $_SESSION);
$cUsers = new CUsers($db, $_SESSION);
$poems = $cPoem->getNewestPoems(10);
echo '<table>';
echo '<tr>';
echo '<td><b>Runoilija</b></td>';
echo '<td><b>Runon nimi</b></td>';
echo '<td><b>Lisätty</b></td>';
echo '</tr>';
$poems_per_page = $cPoem->getPoemsPerPage();
foreach ($poems as $poem) {
    echo '<tr>';
    echo '<td>';
    echo '<a href="poet.php?id=' . $poem['user_id'] . '">';
    echo $cUsers->getUsername($poem['user_id']);
    echo '</a>';
Exemplo n.º 8
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require 'general_functions.php';
require 'CPoem.php';
// This site cannot be seen if user is not logged in.
if (!isset($_SESSION['username'])) {
    header('Location: index.php');
}
$cPoem = new CPoem($db, $_SESSION);
// Get poem ID and get its writer.
$id = mysql_real_escape_string($_GET['id']);
$owner_id = $cPoem->getPoemWriterID($id);
// If this poem does NOT belong to logged user,
// then we cannot hide it.
if ($owner_id != $_SESSION['id']) {
    header('Location: index.php');
}
$cPoem->togglePoemVisibility($id);
$_SESSION['message_icon'] = 'graphics/32px-Crystal_Clear' . '_app_clean.png';
$_SESSION['message'] = 'Runo piilotettu.';
if (isset($_GET['page']) && !empty($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
Exemplo n.º 9
0
<?php

/*
Add a poem to database. Part of Runosydan.net.
Copyright (C) 2009	Aleksi Räsänen <*****@*****.**>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
require 'general_functions.php';
require 'CPoem.php';
// Create new Poem-class instance and add poem.
$cPoem = new CPoem($db, $_SESSION);
$cPoem->addPoem($_POST);
// Icon to show.
$_SESSION['message_icon'] = 'graphics/32px-Crystal_Clear' . '_app_clean.png';
// Message to show on own page.
$_SESSION['message'] = 'Runo lisätty!';
// Forward user to own page.
header('Location: ownpage.php');
Exemplo n.º 10
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
require 'general_functions.php';
require 'CPoem.php';
create_site_top();
create_top_menu();
echo '<div class="random_poem">';
// Get random poem
$cPoem = new CPoem($db, $_SESSION);
$random = $cPoem->getRandomPoem();
// If array of random poem is empty, just show information
// that there is no data.
if (empty($random)) {
    echo 'Tietokannasta ei löydy vielä yhtään runoa.';
} else {
    echo '<p class="poem_header">';
    echo stripslashes($random[0]['title']);
    echo '</p>';
    echo '<p class="poem">';
    $random[0]['poem'] = str_replace('<br />', '<br>', $random[0]['poem']);
    echo nl2br(stripslashes($random[0]['poem']));
    echo '<p class="poem_added">';
    echo $random[0]['added'];
    echo '<br><a href="poet.php?id=' . $random[0]['user_id'] . '">';
Exemplo n.º 11
0
function show_poet_info($db, $id)
{
    require_once 'CPoem.php';
    $cPoem = new CPoem($db, $_SESSION);
    echo '<div>';
    $id = mysql_real_escape_string($id);
    // Show correct number of poems, eg. show total number
    // of poems in own page, others should see only number
    // of visible poems.
    if ($_SESSION['id'] == $id) {
        $numPoems = $cPoem->numPoems($id, true);
    } else {
        $numPoems = $cPoem->numPoems($id, false);
    }
    $q = 'SELECT firstname, lastname, city, homepage FROM rs_users ' . 'WHERE id="' . $id . '"';
    $ret = $db->query($q);
    if ($db->numRows($ret) > 0) {
        $ret = $db->fetchAssoc($ret);
        echo '<p class="own_info">';
        if (isset($ret[0]['firstname'])) {
            echo $ret[0]['firstname'];
        }
        if (isset($ret[0]['lastname'])) {
            echo ' ' . $ret[0]['lastname'];
        }
        if (isset($ret[0]['city'])) {
            echo '<br>' . $ret[0]['city'];
        }
        if (isset($ret[0]['homepage']) && $ret[0]['homepage'] != '') {
            echo '<br><a href="' . $ret[0]['homepage'];
            echo '">' . $ret[0]['homepage'] . '</a>';
        }
        echo '<br>Runoja: ' . $numPoems . '<br>';
        echo '<a href="rss.php?poet_id=' . $id . '">';
        echo '<img src="graphics/rss.gif" class="rss"></a>';
        echo '<br>';
        // If we are on own page, then we show some useful
        // links too, eg. possibility to change our informations.
        if ($_SESSION['id'] == $id) {
            echo '<a href="edit_profile.php">Muuta tietoja</a>';
            echo ' / ';
            echo '<a href="download.php">Lataa runot</a>';
            echo ' / ';
            echo '<a href="remove_profile.php">Poista käyttäjätunnus</a>';
        }
    }
    echo '</div>';
}
Exemplo n.º 12
0
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
// This site cannot be seen if user is not logged in
// or there is no any unseen comments.
if (!isset($_SESSION['username']) || $_SESSION['unseen_comments'] == 0) {
    header('Location: index.php');
}
// create_site_top and create_site_menu is defined in
// file general_functions.php
require 'general_functions.php';
require 'CPoem.php';
$cPoem = new CPoem($db, $_SESSION);
// Update session variable before we create top menu
// so it will be updated and no unseen poems will be
// shown on menu after we have arrived on this page.
$_SESSION['unseen_comments'] = 0;
create_site_top();
create_top_menu();
// Get poem ID's where we have unseen comments.
$q = 'select p.id as poem_id, p.poem, p.title FROM rs_comments c LEFT JOIN ' . 'rs_poem p ON c.poem_id = p.id WHERE p.user_id=' . $_SESSION['id'] . ' AND c.is_seen IS NULL OR c.is_seen != 1';
try {
    $ret = $db->query($q);
    // Found unseen comments
    if ($db->numRows($ret) > 0) {
        $ret = $db->fetchAssoc($ret);
    }
} catch (Exception $e) {
Exemplo n.º 13
0
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require 'general_functions.php';
require 'CPoem.php';
// This site cannot be seen if user is not logged in.
if (!isset($_SESSION['username'])) {
    header('Location: index.php');
}
$cPoem = new CPoem($db, $_SESSION);
// First we want to check if we have GET-parameter "accept".
// If we have, then we have shown this page already and user
// has made his decision to remove or not.
if (isset($_GET['accept'])) {
    if ($_GET['accept'] == 'yes' && isset($_GET['id'])) {
        $id = mysql_real_escape_string($_GET['id']);
        // User wanted to remove poem. All right. Now we
        // must check if this poem really REALLY belongs to
        // logged user. Otherwise users could remove any poem
        // they want if they just edit URL. That is not
        // ideal solution :)
        $owner_id = $cPoem->getPoemWriterID($id);
        if ($owner_id == $_SESSION['id']) {
            $cPoem->removePoem($id);
            // Icon to show