国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial 小型 Twitter 的系統(tǒng) 流碼+註釋,PHP

小型 Twitter 的系統(tǒng) 流碼+註釋,PHP

Jun 13, 2016 am 10:58 AM
gt lt user users

小型 Twitter 的系統(tǒng) 源碼+註釋,PHP

?

今天重新吧 小型twitter系統(tǒng)的源碼 認(rèn)真研究了一邊 算是熟悉php把?

爲(wèi)今後一個(gè)月的畢業(yè)設(shè)計(jì)做打算

?

下載

http://dl.vmall.com/c0nkwafdqz

?

index

?

<?phpsession_start ();include_once ('header.php');include_once ('functions.php');$_SESSION ['userid'] = 1;//設(shè)置session真正情況是在登錄的時(shí)候設(shè)置?><!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><?phpif (isset ( $_SESSION ['message'] )) {//如果session中設(shè)置了message就顯示出來(lái).然后釋放	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);//返回?cái)?shù)組中所有的key}else{	$myusers = array();}$myusers[] = $_SESSION['userid'];//應(yīng)該在myusers數(shù)據(jù)末尾添加用戶自己$posts = show_posts($myusers,5);//顯示用戶follow用戶的五條postif (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

<?phpsession_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-8" /><title>Microblogging Application - Users</title></head><body>	<h1>List of Users</h1><?php$users = show_users ();$following = following(1);if (count ( $users )) {	?><table border='1' cellspacing='0' cellpadding='5' width='500'><?php	foreach ( $users as $key => $value ) {//=>指的是獲取數(shù)組內(nèi)某一個(gè)單元內(nèi)的元素的內(nèi)容,		echo "<tr valign='top'>\n";		echo "<td>" . $key . "</td>\n";//顯示id		echo "<td>" . $value;//顯示id對(duì)應(yīng)的值也就是value					if (in_array ( $key, $following )) {//檢查key是否在following中 然后根據(jù)狀態(tài)顯示不同的值顯示不同的信息 生成不同的指向action的鏈接			echo " <small>		<a href='action.php?id=$key&do=unfollow'>unfollow</a>		</small>";		} else {			echo " <small>		<a href='action.php?id=$key&do=follow'>follow</a>		</small>";		}		echo "</td>\n";		echo "</tr>\n";	}	?></table><?php} else {	?><p>		<b>There are no users in the system!</b>	</p><?php}?></body></html>



?

?

<?phpfunction add_post($userid, $body) {	$sql = "insert into posts (user_id, body, stamp) 			values ($userid, '" . mysql_real_escape_string ( $body ) . "',now())";		$result = mysql_query ( $sql );}function show_posts($userid, $limit = 0) {	$posts = array ();		$user_string = implode ( ',', $userid );	$extra = " and id in ($user_string)";		if ($limit > 0) {		$extra = "limit $limit";	} else {		$extra = '';	}		$sql = "select user_id,body, stamp from posts 		where user_id in ($user_string) 		order by stamp desc $extra";	echo $sql;	$result = mysql_query ( $sql );		while ( $data = mysql_fetch_object ( $result ) ) {		$posts [] = array (				'stamp' => $data->stamp,				'userid' => $data->user_id,				'body' => $data->body 		);	}	return $posts;}/** * 顯示用戶 * 如果user_id =0,直接顯示所有用戶 * 如果user id >0,顯示改用戶follow的用戶id * @param unknown_type $user_id * @return multitype:|multitype:NULL */function show_users($user_id = 0) {	if ($user_id > 0) {		$follow = array ();		$fsql = "select user_id from following				where follower_id='$user_id'";//從follow中選出該id的follower		$fresult = mysql_query ( $fsql );						while ( $f = mysql_fetch_object ( $fresult ) ) {//把結(jié)果作爲(wèi)一個(gè)對(duì)象傳入					array_push ( $follow, $f->user_id );//把f中的user_id字段放到follow中		}					if (count ( $follow )) {			$id_string = implode ( ',', $follow );//以","作爲(wèi)分割符來(lái)加工這個(gè)字符串,爲(wèi)了拼接後面的sql			$extra = " and id in ($id_string)";					} else {			return array ();		}	}		$users = array ();	$sql = "select id, username from users 		where status='active' 		$extra order by username";//從user表中選出follower的 id 和 name		$result = mysql_query ( $sql );		while ( $data = mysql_fetch_object ( $result ) ) {		$users [$data->id] = $data->username;//想user中填入用戶名	}	return $users;}/** * 搜索出用戶follow的用戶的id * @param unknown_type $userid * @return multitype: */function following($userid) {	$users = array ();		$sql = "select distinct user_id from following	where follower_id = '$userid'";	$result = mysql_query ( $sql );		while ( $data = mysql_fetch_object ( $result ) ) {		array_push ( $users, $data->user_id );	}		return $users;}function check_count($first, $second) {	$sql = "select count(*) from following	where user_id='$second' and follower_id='$first'";	$result = mysql_query ( $sql );		$row = mysql_fetch_row ( $result );	return $row [0];}function follow_user($me, $them) {	$count = check_count ( $me, $them );		if ($count == 0) {		$sql = "insert into following (user_id, follower_id)		values ($them,$me)";				$result = mysql_query ( $sql );	}}function unfollow_user($me, $them) {	$count = check_count ( $me, $them );		if ($count != 0) {		$sql = "delete from following		where user_id='$them' and follower_id='$me'		limit 1";				$result = mysql_query ( $sql );	}}?>


add

?

?

<?phpsession_start ();include_once ("header.php");include_once ("functions.php");$userid = $_SESSION ['userid'];$body = substr ( $_POST ['body'], 0, 140 );add_post ( $userid, $body );$_SESSION ['message'] = "Your post has been added!";header ( "Location:index.php" );?>


<?phpsession_start ();include_once ("header.php");include_once ("functions.php");/**  處理follow動(dòng)作 */$id = $_GET ['id'];//獲取get 方法傳來(lái)的值 $_POST是post$do = $_GET ['do'];switch ($do) {	case "follow" :		follow_user ( $_SESSION ['userid'], $id );		$msg = "You have followed a user!";//設(shè)置信息		break;		case "unfollow" :		unfollow_user ( $_SESSION ['userid'], $id );		$msg = "You have unfollowed a user!";		break;}$_SESSION ['message'] = $msg;//在session中發(fā)送信息header ( "Location:index.php" );?>



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

What folder is users? What folder is users? May 28, 2021 pm 03:33 PM

Users is a folder in the computer that contains data, program content, documents, music and other content generated during the user's use. When we open the resource manager in our computer, we can find the users folder, which is also called the users folder in some computers.

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出,該如何解決 php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出,該如何解決 Jun 13, 2016 am 10:23 AM

php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出php提交表單通過(guò)后,彈出的對(duì)話框怎樣在當(dāng)前頁(yè)彈出而不是在空白頁(yè)彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁(yè)彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

Is watch4pro better or gt? Is watch4pro better or gt? Sep 26, 2023 pm 02:45 PM

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

How to solve the problem of docker mounting directory permissions How to solve the problem of docker mounting directory permissions Feb 29, 2024 am 10:04 AM

In Docker, the permission problem of the mounting directory can usually be solved by the following method: adding permission-related options when using the -v parameter to specify the mounting directory. You can specify the permissions of the mounted directory by adding: ro or :rw after the mounted directory, indicating read-only and read-write permissions respectively. For example: dockerrun-v/host/path:/container/path:roimage_name Define the USER directive in the Dockerfile to specify the user running in the container to ensure that operations inside the container comply with permission requirements. For example: FROMimage_name#CreateanewuserRUNuseradd-ms/bin/

How to optimize iPad battery life with iPadOS 17.4 How to optimize iPad battery life with iPadOS 17.4 Mar 21, 2024 pm 10:31 PM

How to Optimize iPad Battery Life with iPadOS 17.4 Extending battery life is key to the mobile device experience, and the iPad is a good example. If you feel like your iPad's battery is draining too quickly, don't worry, there are a number of tricks and tweaks in iPadOS 17.4 that can significantly extend the run time of your device. The goal of this in-depth guide is not just to provide information, but to change the way you use your iPad, enhance your overall battery management, and ensure you can rely on your device for longer without having to charge it. By adopting the practices outlined here, you take a step toward more efficient and mindful use of technology that is tailored to your individual needs and usage patterns. Identify major energy consumers

See all articles