日期:2014-05-17  浏览次数:20535 次

小型 Twitter 的系统 源碼+註釋,PHP

?

今天重新吧 小型twitter系統的源碼 認真研究了一邊 算是熟悉php把?

爲今後一個月的畢業設計做打算

?

下載

http://dl.vmall.com/c0nkwafdqz

?

index

?

<?php
session_start ();
include_once ('header.php');
include_once ('functions.php');

$_SESSION ['userid'] = 1;//设置session真正情况是在登录的时候设置
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Microblogging Application</title>
</head>
<p>
	<a href='users.php'>see list of users</a>
</p>
<?php

if (isset ( $_SESSION ['message'] )) {//如果session中设置了message就显示出来.然后释放
	echo "<b>" . $_SESSION ['message'] . "</b>";
	unset ( $_SESSION ['message'] );
}
?>
<form method='post' action='add.php'>
	<p>Your status:</p>
	<textarea name='body' rows='5' cols='40' wrap=VIRTUAL></textarea>
	<p>
		<input type='submit' value='submit' />
	</p>

<?php
$users = show_users($_SESSION['userid']);//显示用户follow的用戶
if (count($users)){
	$myusers = array_keys($users);//返回數組中所有的key
}else{
	$myusers = array();
}
$myusers[] = $_SESSION['userid'];//應該在myusers數據末尾添加用戶自己



$posts = show_posts($myusers,5);//顯示用戶follow用戶的五條post




if (count ( $posts )) {
	?>
<table border='1' cellspacing='0' cellpadding='5' width='500'>
<?php
	foreach ( $posts as $key => $list ) {
		echo "<tr valign='top'>\n";
		echo "<td>" . $list ['userid'] . "</td>\n";
		echo "<td>" . $list ['body'] . "<br/>\n";
		echo "<small>" . $list ['stamp'] . "</small></td>\n";
		echo "</tr>\n";
	}
	?>
</table>
<?php
} else {
	?>
<p>
		<b>You haven't posted anything yet!</b>
	</p>
<?php
}
?>
<h2>Users you're following</h2>

<?php
$users = show_users ( $_SESSION ['userid'] );

if (count ( $users )) {
	?>
<ul>
<?php
	foreach ( $users as $key => $value ) {
		echo "<li>" . $value . "</li>\n";
	}
	?>
</ul>
<?php
} else {
	?>
<p>
		<b>You're not following anyone yet!</b>
	</p>
<?php
}
?>
</form>

</body>
</html>


headers

?

?

<?php
$SERVER = 'localhost:3306';
$USER = 'root';
$PASS = 'root';
$DATABASE = 'tweet';

if (! ($mylink = mysql_connect ( $SERVER, $USER, $PASS ))) {
	echo "<h3>Sorry, could not connect to database.</h3><br/>
	Please contact your system's admin for more help\n";
	exit ();
}

mysql_select_db ( $DATABASE );

?>

users

<?php
session_start ();
include_once ("header.php");
include_once ("functions.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-