<?php
include_once ( 'init.php' ) ;
$mysqli = new mysqli( $db [ 'host' ] , $db [ 'user' ] , $db [ 'pass' ] , $db [ 'name' ] ) ;
if ( $mysqli -> connect_errno ) {
echo "Не удалось подключиться к MySQL: " . $mysqli -> connect_error ;
}
if ( ! ( $stmt = $mysqli -> prepare ( "SELECT posts.post_id, posts.user_id, users.user_login, posts.post_text, posts.post_time, posts.is_deleted
FROM posts JOIN users on users.user_id = posts.user_id ORDER BY post_id" ) ) ) {
echo "Не удалось подготовить запрос: (" . $mysqli -> errno . ") " . $mysqli -> error ;
}
if ( ! $stmt -> execute ( ) ) {
echo "Не удалось выполнить запрос: (" . $stmt -> errno . ") " . $stmt -> error ;
}
$queryResult = $stmt -> get_result ( ) ;
$posts = $queryResult -> fetch_all ( MYSQLI_ASSOC) ;
//echo "<pre>";
//var_dump($posts);
if ( isset ( $_SESSION [ 'user_login' ] ) ) { $userName = $_SESSION [ 'user_login' ] ;
$userId = $_SESSION [ 'user_id' ] ;
} else {
$userId = 'null' ;
}
include ( 'view.php' ) ;
?>
PD9waHAKaW5jbHVkZV9vbmNlKCdpbml0LnBocCcpOwoKJG15c3FsaSA9IG5ldyBteXNxbGkoJGRiWydob3N0J10sICRkYlsndXNlciddLCAkZGJbJ3Bhc3MnXSwgJGRiWyduYW1lJ10pOwppZiAoJG15c3FsaS0+Y29ubmVjdF9lcnJubykgewogICAgZWNobyAi0J3QtSDRg9C00LDQu9C+0YHRjCDQv9C+0LTQutC70Y7Rh9C40YLRjNGB0Y8g0LogTXlTUUw6ICIgLiAkbXlzcWxpLT5jb25uZWN0X2Vycm9yOwp9CgppZiAoISgkc3RtdCA9ICRteXNxbGktPnByZXBhcmUoIlNFTEVDVCBwb3N0cy5wb3N0X2lkLCBwb3N0cy51c2VyX2lkLCB1c2Vycy51c2VyX2xvZ2luLCBwb3N0cy5wb3N0X3RleHQsIHBvc3RzLnBvc3RfdGltZSwgcG9zdHMuaXNfZGVsZXRlZAoJCQkJCQkJCUZST00gc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