Exemple #1
0
<?php

include "db.php";
include "templates.php";
session_start();
if (isset($_SESSION['user_id'])) {
    if (isset($_GET['Exit'])) {
        unset($_SESSION['user_id']);
        session_destroy();
        header('Location:/index.php');
    }
    echo $logo;
    echo 'Welcome, ' . pick_users_data($_SESSION['user_id'], 'FIRSTNAME', $conn) . '!';
    echo $profile_menu;
    echo '<form action="profile.php" method="post" enctype="multipart/form-data">
            <input type="file" accept="image/jpeg" name="picture">
            <input type="text" name="name">
            <input type="submit" value="Опубликовать" name="upload">
            </form>';
    echo '<h4>Публикации:</h4>';
    if (isset($_POST['upload'])) {
        $name = $_POST['name'];
        $picture = $_FILES['picture']['tmp_name'];
        publish($conn, $_SESSION['user_id'], $name, $picture);
        header('Location: published.php');
    }
    $pub = show_publications($_SESSION['user_id'], $conn);
    for ($i = count($pub['PDATE']) - 1; $i >= 0; $i--) {
        echo substr($pub['PDATE'][$i], 0, -15) . '</br>' . substr($pub['PDATE'][$i], 9, -7) . ' <b>' . $pub['NAME'][$i] . '</b>
        <a href="profile.php?d_p_id=' . $pub['ID'][$i] . '">(удалить)</a></br>';
        #$row = show_picture($pub['ID'][$i], $conn);
Exemple #2
0
include "db.php";
include "templates.php";
session_start();
if (isset($_SESSION['user_id'])) {
    if (isset($_GET['Exit'])) {
        unset($_SESSION['user_id']);
        session_destroy();
        header('Location:/index.php');
    }
    echo $logo;
    echo 'Welcome, ' . pick_users_data($_SESSION['user_id'], 'FIRSTNAME', $conn) . '!';
    echo $profile_menu;
    echo '<h3>Сообщения</h3>';
    $id = $_GET['id'];
    if (isset($_GET['id'])) {
        echo '<h4>' . pick_users_data($id, 'FIRSTNAME', $conn) . ' ' . pick_users_data($id, 'LASTNAME', $conn) . '</h4>
        <form action="messages.php?id=' . $_GET['id'] . '" method="post">
        <textarea cols="40" rows ="4" name="message"></textarea>
        <p><input type="submit" value="Отправить" name="send"></p>
        </form>';
        if (isset($_POST['send'])) {
            $message = $_POST['message'];
            if ($message != '') {
                send($id, $message, $conn);
            }
            $_POST['message'] = '';
            header('Location:/sent.php');
        }
        $messages = show_messages($_SESSION['user_id'], $_GET['id'], $conn);
        for ($i = count($messages['MDATE']) - 1; $i >= 0; $i--) {
            if ($messages['AUTHOR'][$i] !== $_SESSION['user_id']) {
Exemple #3
0
        <form action="admin_p.php?id=' . $_GET['id'] . '" method ="post">
        <input type="submit" name="delete" value="DELETE THIS USER">
        <input type="submit" name="show_messages" value="Show messages">
        </form>
    ';
    }
    if (isset($_POST['delete'])) {
        delete($_GET['id'], $conn);
        #header('Location/admin.php');
    }
    if (isset($_POST['show_messages'])) {
        $messages = show_all_messages($_GET['id'], $conn);
        for ($i = count($messages['MDATE']) - 1; $i >= 0; $i--) {
            echo '</br><b>' . substr($messages['MDATE'][$i], 0, -15) . '</br>' . substr($messages['MDATE'][$i], 9, -7) . '</b></br>
            from: ' . pick_users_data($messages['AUTHOR'][$i], 'FIRSTNAME', $conn) . '
            , to: ' . pick_users_data($messages['RECEPIENT'][$i], 'FIRSTNAME', $conn) . '
            <i>' . $messages['MESSAGE'][$i] . '</i></br></br>';
        }
    }
    if (isset($_POST['exit'])) {
        session_destroy();
        header('Location:/admin.php');
    }
    echo '

    ';
} else {
    echo 'Go back!';
}
?>
Exemple #4
0
<?php

include "db.php";
include "templates.php";
session_start();
if (isset($_SESSION['user_id'])) {
    echo $logo;
    echo 'Добро пожаловать, ' . pick_users_data($_SESSION['user_id'], 'FIRSTNAME', $conn) . '!';
    echo $profile_menu;
    if (isset($_GET['id'])) {
        echo pick_users_data($_GET['id'], 'FIRSTNAME', $conn) . '  ';
        echo pick_users_data($_GET['id'], 'LASTNAME', $conn) . '</br>';
        echo 'Кртакая биография: ' . pick_users_data($_GET['id'], 'BIO', $conn);
        if (!check_subscribe($_GET['id'], $conn)) {
            echo '<form action="people.php?id=' . $_GET['id'] . '" method="post"><input type="submit" value="Добавить в друзья" name="subscribe"></form>';
            if (isset($_POST['subscribe'])) {
                if (subscribe($_GET['id'], false, $conn)) {
                    echo 'Добавлено!';
                }
            }
        } else {
            echo '</br><i>У вас в друзьях</i>';
            echo '<form action="people.php?id=' . $_GET['id'] . '" method="post"><input type="submit" value="Удалить из друзей" name="unsubscribe"></form>';
            if (isset($_POST['unsubscribe'])) {
                if (subscribe($_GET['id'], true, $conn)) {
                    echo 'Удалено!';
                }
            }
        }
        echo '</br><a href="messages.php?id=' . $_GET['id'] . '">Написать сообщение</a></br>';
        $pub = show_publications($_GET['id'], $conn);
Exemple #5
0
<?php

include "db.php";
include "templates.php";
session_start();
if (isset($_SESSION['user_id'])) {
    $subscribes = find_subscribes($_SESSION['user_id'], $conn);
    $subscribed = find_subscribed($_SESSION['user_id'], $conn);
    echo $logo;
    echo 'Добро пожаловать, ' . pick_users_data($_SESSION['user_id'], 'FIRSTNAME', $conn) . '!';
    echo $profile_menu;
    echo '<table><tr><td>Вас добавили в друзья</td><td>Вы добавили в друзья</td></tr><tr><td><table>';
    foreach ($subscribes['FOLLOWER'] as $s) {
        #echo $s;
        echo '<tr><td><a href="people.php?id=' . $s . '">' . pick_users_data($s, 'FIRSTNAME', $conn) . ' ' . pick_users_data($s, 'LASTNAME', $conn) . '</a></td></tr>';
    }
    echo '</table></td><td><table class="left-table">';
    foreach ($subscribed['ID'] as $s) {
        echo '<tr><td><a href="people.php?id=' . $s . '">' . pick_users_data($s, 'FIRSTNAME', $conn) . ' ' . pick_users_data($s, 'LASTNAME', $conn) . '</a></td></tr>';
    }
    echo '</table></td></table>';
} else {
    echo '

<h1>SOCIAL NETWORK</h1>
<a href="index.php">Sign In</a>
';
}
Exemple #6
0
session_start();
if (isset($_SESSION['user_id'])) {
    if (isset($_GET['Exit'])) {
        unset($_SESSION['user_id']);
        session_destroy();
        header('Location:/index.php');
    }
    echo $logo;
    echo 'Welcome, ' . pick_users_data($_SESSION['user_id'], 'FIRSTNAME', $conn) . '!';
    echo $profile_menu;
    echo '<h3>Недавние сообщения</h3>';
    $messages = show_messages($_SESSION['user_id'], $_SESSION['user_id'], $conn);
    $k = 0;
    for ($i = count($messages['MDATE']) - 1; $i >= 0; $i--) {
        $k++;
        echo '</br>От: <a href="people.php?id=' . $messages['AUTHOR'][$i] . '">' . pick_users_data($messages['AUTHOR'][$i], 'FIRSTNAME', $conn) . '</a></br>
        <b>' . substr($messages['MDATE'][$i], 0, -15) . '</br>' . substr($messages['MDATE'][$i], 9, -7) . '</b></br><i>' . $messages['MESSAGE'][$i] . '</i></br>    </br>';
        if ($k == 10) {
            break;
        }
    }
} else {
    echo '
<html>
<body>
<h1>Социальная сеть</h1>
<a href="index.php">Войти</a>
</body>
</html>';
}
?>