小型 Twitter 的系统 流碼+註釋,PHP
小型 Twitter 的系统 源碼+註釋,PHP
?
今天重新吧 小型twitter系統的源碼 認真研究了一邊 算是熟悉php把?
爲今後一個月的畢業設計做打算
?
下載
http://dl.vmall.com/c0nkwafdqz
?
index
?
<?phpsession_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><?phpif (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用戶的五條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 id="Users-you-re-following">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 id="Sorry-could-not-connect-to-database">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 id="List-of-Users">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 ) {//=>指的是获取数组内某一个单元内的元素的内容, echo "<tr valign='top'>\n"; echo "<td>" . $key . "</td>\n";//顯示id echo "<td>" . $value;//顯示id對應的值也就是value if (in_array ( $key, $following )) {//檢查key是否在following中 然后根据状态显示不同的值显示不同的信息 生成不同的指向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 ) ) {//把結果作爲一個對象傳入 array_push ( $follow, $f->user_id );//把f中的user_id字段放到follow中 } if (count ( $follow )) { $id_string = implode ( ',', $follow );//以","作爲分割符來加工這個字符串,爲了拼接後面的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动作 */$id = $_GET ['id'];//获取get 方法传来的值 $_POST是post$do = $_GET ['do'];switch ($do) { case "follow" : follow_user ( $_SESSION ['userid'], $id ); $msg = "You have followed a user!";//设置信息 break; case "unfollow" : unfollow_user ( $_SESSION ['userid'], $id ); $msg = "You have unfollowed a user!"; break;}$_SESSION ['message'] = $msg;//在session中发送信息header ( "Location:index.php" );?>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

許多用戶在選擇智慧型手錶的時候都會選擇的華為的品牌,其中華為GT3pro和GT4都是非常熱門的選擇,不少用戶都很好奇華為GT3pro和GT4有什麼區別,下面就給大家介紹一下二者。華為GT3pro和GT4有什麼差別一、外觀GT4:46mm和41mm,材質是玻璃鏡板+不鏽鋼機身+高分纖維後殼。 GT3pro:46.6mm和42.9mm,材質是藍寶石玻璃鏡+鈦金屬機身/陶瓷機身+陶瓷後殼二、健康GT4:採用最新的華為Truseen5.5+演算法,結果會更加的精準。 GT3pro:多了ECG心電圖和血管及安

為什麼截圖工具在Windows11上不起作用了解問題的根本原因有助於找到正確的解決方案。以下是截圖工具可能無法正常工作的主要原因:對焦助手已開啟:這可以防止截圖工具開啟。應用程式損壞:如果截圖工具在啟動時崩潰,則可能已損壞。過時的圖形驅動程式:不相容的驅動程式可能會幹擾截圖工具。來自其他應用程式的干擾:其他正在運行的應用程式可能與截圖工具衝突。憑證已過期:升級過程中的錯誤可能會導致此issu簡單的解決方案這些適合大多數用戶,不需要任何特殊的技術知識。 1.更新視窗與Microsoft應用程式商店應用程

users是電腦中的一個包含使用者使用過程中產生的資料、程式內容以及文件、音樂等內容的資料夾。我們打開電腦中的資源管理器,就可以找到users資料夾了,有的電腦中也叫用戶資料夾。

第1部分:初始故障排除步驟檢查蘋果的系統狀態:在深入研究複雜的解決方案之前,讓我們先從基礎知識開始。問題可能不在於您的設備;蘋果的伺服器可能會關閉。造訪Apple的系統狀態頁面,查看AppStore是否正常運作。如果有問題,您所能做的就是等待Apple修復它。檢查您的網路連接:確保您擁有穩定的網路連接,因為「無法連接到AppStore」問題有時可歸因於連接不良。嘗試在Wi-Fi和行動數據之間切換或重置網路設定(「常規」>「重置」>「重置網路設定」>設定)。更新您的iOS版本:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

在Docker中,掛載目錄的權限問題通常可以透過以下方法解決:使用-v參數指定掛載目錄時新增權限相關的選項。可以透過在掛載的目錄後面新增:ro或:rw來指定掛載目錄的權限,分別表示只讀和讀寫權限。例如:dockerrun-v/host/path:/container/path:roimage_name在Dockerfile中定義USER指令來指定容器中執行的用戶,以確保容器內部的操作符合權限要求。例如:FROMimage_name#CreateanewuserRUNuseradd-ms/bin/

watch4pro和gt各自具有不使用的特點和適用場景,如果注重功能的全面性、高性能和時尚外觀,同時願意承擔較高的價格,那麼Watch 4 Pro可能更適合。如果對功能要求不高,更注重電池續航力和價格的合理性,那麼GT系列可能更適合。最終的選擇應根據個人需求、預算和喜好來決定,建議在購買前仔細考慮自己的需求,並參考各種產品的評測和比較,以做出更明智的選擇。

如何使用iPadOS17.4优化iPad电池寿命延长电池续航时间是移动设备体验的关键,iPad是一个很好的例子。如果您觉得iPad电池消耗速度过快,不用担心,在iPadOS17.4中有许多技巧和调整可以显著延长设备的运行时间。本深入指南的目标不仅仅是提供信息,而是改变您使用iPad的方式,增强您的整体电池管理,并确保您可以在无需充电的情况下更长时间地依赖您的设备。通过采用此处概述的做法,您朝着更高效、更谨慎地使用技术迈出了一步,这些技术是根据您的个人需求和使用模式量身定制的。识别主要的能量消耗者
