├── 文件说明.txt ├── README.md ├── php ├── imgs │ ├── 不能忍.gif │ ├── 吃饭.gif │ ├── 大哭.gif │ ├── 大笑.gif │ ├── 好吃.gif │ ├── 干杯.gif │ ├── 开心.gif │ ├── 拜拜.gif │ ├── 汗.gif │ └── 衰.gif ├── files │ ├── images │ │ ├── 1418615233244.gif │ │ └── 1418616592831.jpg │ ├── musics │ │ └── 1418617363236.mp3 │ └── headpictures │ │ ├── 1418608702874.jpg │ │ ├── 1418609284882.jpg │ │ └── 1418610638777.jpg ├── SqlTool.class.php ├── action.php └── index.php ├── images └── background.jpg ├── index.html ├── privatelatter.html ├── register.html ├── discover.html ├── js ├── myjs.js ├── privatelatter.js ├── discover.js ├── homepage.js ├── jquery.form.js └── jquery-1.11.1.min.js ├── homepage.html ├── weibo.sql └── style.css /文件说明.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/文件说明.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/README.md -------------------------------------------------------------------------------- /php/imgs/不能忍.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/不能忍.gif -------------------------------------------------------------------------------- /php/imgs/吃饭.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/吃饭.gif -------------------------------------------------------------------------------- /php/imgs/大哭.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/大哭.gif -------------------------------------------------------------------------------- /php/imgs/大笑.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/大笑.gif -------------------------------------------------------------------------------- /php/imgs/好吃.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/好吃.gif -------------------------------------------------------------------------------- /php/imgs/干杯.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/干杯.gif -------------------------------------------------------------------------------- /php/imgs/开心.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/开心.gif -------------------------------------------------------------------------------- /php/imgs/拜拜.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/拜拜.gif -------------------------------------------------------------------------------- /php/imgs/汗.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/汗.gif -------------------------------------------------------------------------------- /php/imgs/衰.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/imgs/衰.gif -------------------------------------------------------------------------------- /images/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/images/background.jpg -------------------------------------------------------------------------------- /php/files/images/1418615233244.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/images/1418615233244.gif -------------------------------------------------------------------------------- /php/files/images/1418616592831.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/images/1418616592831.jpg -------------------------------------------------------------------------------- /php/files/musics/1418617363236.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/musics/1418617363236.mp3 -------------------------------------------------------------------------------- /php/files/headpictures/1418608702874.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/headpictures/1418608702874.jpg -------------------------------------------------------------------------------- /php/files/headpictures/1418609284882.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/headpictures/1418609284882.jpg -------------------------------------------------------------------------------- /php/files/headpictures/1418610638777.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jocelynthink/weibo/master/php/files/headpictures/1418610638777.jpg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 登录 6 | 7 | 8 | 9 | 10 | 11 |
12 |

微博

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
昵称:

密码:

注册账号
27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /php/SqlTool.class.php: -------------------------------------------------------------------------------- 1 | conn=mysql_connect($this->host,$this->user,$this->password); 13 | 14 | if(!$this->conn) 15 | { 16 | die("连接数据库失败".mysql_error); 17 | } 18 | mysql_select_db($this->db,$this->conn); 19 | mysql_query("set names utf8"); 20 | } 21 | 22 | //完成select 23 | public function execute_dql($sql){ 24 | $res = mysql_query($sql,$this->conn) or die(mysql_error()); 25 | // echo "添加的id=".mysql_insert_id($this->conn); 26 | return $res; 27 | } 28 | 29 | //完成upadate delete insert 30 | function execute_dml($sql) 31 | { 32 | $b=mysql_query($sql,$this->conn); 33 | if(!$b) 34 | { 35 | return 0; 36 | }else{ 37 | if(mysql_affected_rows($this->conn)>0) 38 | { 39 | return 1;//表示成功 40 | }else{ 41 | return 2;//没有影响行数 42 | } 43 | } 44 | } 45 | } 46 | 47 | ?> -------------------------------------------------------------------------------- /privatelatter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 主页 6 | 7 | 8 | 9 | 10 | 11 | 23 | 24 | 25 |
26 | 27 |
28 | 首页
29 | 发现
30 | 31 | 32 | 私信 33 |
34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 | jocelyn 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
关注粉丝微博
56 |
57 | 58 |
59 | 60 | 61 | 62 |
63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 注册微博账号 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
头像:
19 | 上传头像 20 | 21 |
22 |
23 | 0% 24 |
25 |
26 |
27 |
用户名:
密码:
确认密码:
电子邮件:
52 | 53 |
54 | 55 | 58 |
59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /discover.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 主页 6 | 7 | 8 | 9 | 10 | 11 | 23 | 24 | 25 |
26 | 27 |
28 | 首页
29 | 发现
30 | 31 | 32 | 私信 33 |
34 | 35 |
36 | 37 | 38 |
39 |
40 | 41 |
42 |
43 | jocelyn 44 |
45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
关注粉丝微博
58 |
59 |
60 | 61 | 62 | 63 | 68 | 69 |
70 | 71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /js/myjs.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | var bar = $('.bar'); 3 | var percent = $('.percent'); 4 | var showimg = $('#showimg_register'); 5 | var progress = $(".progress"); 6 | var files = $(".files"); 7 | var btn = $(".btn span"); 8 | console.log("sskkk"); 9 | $("#fileupload").wrap("
"); 10 | $("#fileupload").change(function(){ 11 | $("#myupload").ajaxSubmit({ 12 | dataType: 'json', 13 | url:"php/action.php?act=register", 14 | beforeSend: function() { 15 | showimg.empty(); 16 | progress.show(); 17 | var percentVal = '0%'; 18 | bar.width(percentVal); 19 | percent.html(percentVal); 20 | btn.html("上传中..."); 21 | }, 22 | uploadProgress: function(event, position, total, percentComplete) { 23 | var percentVal = percentComplete + '%'; 24 | bar.width(percentVal); 25 | percent.html(percentVal); 26 | }, 27 | success: function(data) { 28 | files.html(""+data.name+"("+data.size+"k) 删除"); 29 | var img = "/weibo2/php/files/headpictures/"+data.pic; 30 | showimg.html(""); 31 | btn.html("上传头像"); 32 | }, 33 | error:function(xhr){ 34 | btn.html("上传失败"); 35 | bar.width('0') 36 | files.html(xhr.responseText); 37 | } 38 | }); 39 | }); 40 | 41 | $(document).on("click",".delimg_REG",function(){ 42 | var pic = $(this).attr("rel"); 43 | $.post("php/action.php?act=delimg_register",{imagename:pic},function(msg){ 44 | if(msg==1){ 45 | files.html("删除成功!"); 46 | showimg.empty(); 47 | progress.hide(); 48 | }else{ 49 | alert(msg); 50 | } 51 | }); 52 | }); 53 | }); 54 | //注册 55 | $('#register').on("click",function(){ 56 | console.log("register"); 57 | console.log($('.username').val()); 58 | console.log($('.email').val()); 59 | 60 | // 发送,获取json数据 61 | $.getJSON("php/index.php?action=register&c=?",{ 62 | username : $('.username').val(), 63 | password:$('.password').val(), 64 | password_re:$('.password_re').val(), 65 | email:$('.email').val(), 66 | headpicture:$('#showimg_register').find('img').attr('src') 67 | },function(result){ 68 | $('.result').text(result['result']); 69 | if(result['res']=='1'){ 70 | window.open("index.html","_self"); 71 | } 72 | 73 | }) 74 | }); 75 | // 登录 76 | $('#login').on("click",function(){ 77 | $.getJSON("php/index.php?action=login&l=?",{username:$('.username').val(), 78 | password:$('.password').val()},function(result){ 79 | window.alert(result['result']); 80 | if(result['result']=="登录成功"){ 81 | window.open("homepage.html","_self"); 82 | } 83 | }) 84 | }); 85 | 86 | $('#logout').on("click",function(){ 87 | // console.log("logout"); 88 | $.getJSON("php/index?action=logout&lout=?", 89 | function(result){ 90 | if(result['result']=="退出成功"){ 91 | console.log("退出成功"); 92 | window.open("index.html","_self"); 93 | } 94 | }) 95 | }) -------------------------------------------------------------------------------- /js/privatelatter.js: -------------------------------------------------------------------------------- 1 | // var getParam = function(name){ 2 | // var search = document.location.search; 3 | // var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g"); 4 | // var matcher = pattern.exec(search); 5 | // var items = null; 6 | // if(null != matcher){ 7 | // try{ 8 | // items = decodeURIComponent(decodeURIComponent(matcher[1])); 9 | // }catch(e){ 10 | // try{ 11 | // items = decodeURIComponent(matcher[1]); 12 | // }catch(e){ 13 | // items = matcher[1]; 14 | // } 15 | // } 16 | // } 17 | // return items; 18 | // }; 19 | // private_latter(); 20 | // username=getParam('username'); 21 | 22 | $.getJSON("php/index.php?action=private&p=?",function(result){ 23 | // window.alert(username); 24 | // window.alert(result['attentions']); 25 | $('#username').html(result['username']); 26 | $('#attentions').html(result['attentions']); 27 | $('#fans').html(result['fans']); 28 | $('#microblog').html(result['microblog']); 29 | username=result['username']; 30 | $('.discover_info .mf_picture').find('img').attr('src',result['picture']); 31 | $('#weibo_name').text(result['username']); 32 | picture=result['picture']; 33 | // 拿到它发布的微博 34 | if(result['html']==""){ 35 | $('.discover_info').after("你没有收到私信!"); 36 | }else{ 37 | $('.discover_info').after(result['html']); 38 | } 39 | 40 | private_latter(); 41 | 42 | }); 43 | 44 | 45 | 46 | 47 | function private_latter(){ 48 | $('.latter_button').on("click",function(){ 49 | console.log("latter_button"); 50 | str='
\ 51 |
\ 52 | \ 53 |
\ 54 |
\ 55 | '+username+'\ 56 |
\ 57 | \ 58 | \ 59 |
'; 60 | $(this).parent().after(str); 61 | 62 | $('.latter_buttonc').on("click",function(){ 63 | console.log("latter_buttonc"); 64 | console.log($(this).prev().val()); 65 | button=$(this); 66 | 67 | //发消息发送给服务器 68 | $.getJSON("php/index.php?action=lattermeg&la=?",{ 69 | latter_name:button.parent().parent().find('.username1').text(), 70 | latter_content:button.prev().val() 71 | },function(result){ 72 | console.log(result['result']); 73 | if(result['result']=="ok"){ 74 | str='
\ 75 |
\ 76 | \ 77 |
\ 78 |
\ 79 | '+username+'\ 80 |
\ 81 |
\ 82 | '+button.prev().val()+'
'; 83 | 84 | button.parent().prev().after(str); 85 | button.prev().val(""); 86 | } 87 | }); 88 | 89 | }); 90 | 91 | }); 92 | 93 | } -------------------------------------------------------------------------------- /homepage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 主页 6 | 7 | 8 | 9 | 10 | 11 | 22 | 23 | 24 |
25 | 26 |
27 | 首页
28 | 发现
29 | 30 | 31 | 私信 32 |
33 | 34 |
35 | 36 |
37 |
38 | 39 |
40 |
41 | 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
关注粉丝微博
56 |
57 | 58 |
59 | 60 | 61 | 62 |
63 |
有什么新鲜事和大家分享吗?
64 | 65 |
66 | 你还可以输入120个字 67 |
68 |
69 | 73 |
74 | 75 | 表情 76 |
77 |
78 | 图片 79 | 80 |
81 |
82 | 视频 83 | 84 |
85 |
86 | 音乐 87 | 88 |
89 | 92 |
93 |
94 | 95 | 96 |
97 |
98 | 99 | 100 |
101 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /php/action.php: -------------------------------------------------------------------------------- 1 | 1024000) { 25 | echo '图片大小不能超过1M'; 26 | exit; 27 | } 28 | $type = strstr($picname, '.'); 29 | if ($type != ".gif" && $type != ".jpg") { 30 | echo '图片格式不对!,请重新选择图片!'; 31 | exit; 32 | } 33 | $rand = rand(100, 999); 34 | $pics = time() . $rand . $type; 35 | //上传路径 36 | $pic_path = "files/images/". $pics; 37 | 38 | move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path); 39 | // move_uploaded_file($picname, $pic_path); 40 | 41 | // $_SESSION['path']=; 42 | } 43 | $size = round($picsize/1024,2); 44 | $arr = array( 45 | 'name'=>$picname, 46 | 'pic'=>$pics, 47 | 'size'=>$size 48 | ); 49 | 50 | $_SESSION['pic_path']="php/".$pic_path; 51 | echo json_encode($arr); 52 | 53 | }else if($action=='vedios'){ 54 | $picname = $_FILES['mypic']['name']; 55 | $picsize = $_FILES['mypic']['size']; 56 | if ($picname != "") { 57 | if ($picsize > 1024000*50) { 58 | echo '视频大小不能超过50M'; 59 | exit; 60 | } 61 | $type = strstr($picname, '.'); 62 | if ($type != ".flv" && $type != ".avi" && $type != ".mp4" && $type != ".rmvb" && $type != ".mov") { 63 | echo '视频格式不对!,请重新选择视频!'; 64 | exit; 65 | } 66 | $rand = rand(100, 999); 67 | 68 | $pics = time() . $rand . $type; 69 | 70 | //上传路径 71 | $pic_path = "files/vedios/". $pics; 72 | move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path); 73 | } 74 | $size = round($picsize/1024,2); 75 | $arr = array( 76 | 'name'=>$picname, 77 | 'pic'=>$pics, 78 | 'size'=>$size 79 | ); 80 | $_SESSION['vedio_path']="php/".$pic_path; 81 | echo json_encode($arr); 82 | 83 | }else if($action=='musics'){ 84 | $picname = $_FILES['mypic']['name']; 85 | $picsize = $_FILES['mypic']['size']; 86 | if ($picname != "") { 87 | if ($picsize > 1024000*4) { 88 | echo '音乐大小不能超过4M'; 89 | exit; 90 | } 91 | $type = strstr($picname, '.'); 92 | if ($type != ".mp3" && $type != ".wma") { 93 | echo '音乐格式不对!,请重新选择视频!'; 94 | exit; 95 | } 96 | $rand = rand(100, 999); 97 | 98 | $pics = time() . $rand . $type; 99 | 100 | //上传路径 101 | $pic_path = "files/musics/". $pics; 102 | move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path); 103 | } 104 | $size = round($picsize/1024,2); 105 | $arr = array( 106 | 'name'=>$picname, 107 | 'pic'=>$pics, 108 | 'size'=>$size 109 | ); 110 | $_SESSION['music_path']="php/".$pic_path; 111 | echo json_encode($arr); 112 | }else if($action=="register"){ 113 | //上传注册头像 114 | $picname = $_FILES['mypic']['name']; 115 | $picsize = $_FILES['mypic']['size']; 116 | if ($picname != "") { 117 | if ($picsize > 1024000) { 118 | echo '图片大小不能超过1M'; 119 | exit; 120 | } 121 | $type = strstr($picname, '.'); 122 | if ($type != ".gif" && $type != ".jpg") { 123 | echo '图片格式不对!,请重新选择图片!'; 124 | exit; 125 | } 126 | $rand = rand(100, 999); 127 | $pics = time() . $rand . $type; 128 | //上传路径 129 | $pic_path = "files/headpictures/". $pics; 130 | 131 | move_uploaded_file($_FILES['mypic']['tmp_name'], $pic_path); 132 | // move_uploaded_file($picname, $pic_path); 133 | 134 | // $_SESSION['path']=; 135 | } 136 | $size = round($picsize/1024,2); 137 | $arr = array( 138 | 'name'=>$picname, 139 | 'pic'=>$pics, 140 | 'size'=>$size 141 | ); 142 | 143 | // $_SESSION['pic_path']="php/".$pic_path; 144 | echo json_encode($arr); 145 | } 146 | ?> -------------------------------------------------------------------------------- /js/discover.js: -------------------------------------------------------------------------------- 1 | $.getJSON("php/index.php?action=discover&d=?",function(result){ 2 | // window.alert(username); 3 | // window.alert(result['attentions']); 4 | // $('#username').html(username); 5 | username=result['username']; 6 | $('#username').html(result['username']); 7 | $('#attentions').html(result['attentions']); 8 | $('#fans').html(result['fans']); 9 | $('#weibo_name').text(username); 10 | picture=result['picture']; 11 | console.log("hhhh"); 12 | $('#microblog').html(result['microblog']); 13 | // 拿到它发布的微博 14 | console.log("hhhh"); 15 | $('.search').after(result['html']); 16 | $('.myinfomation .mf_picture').find('img').attr('src',result['picture']); 17 | myfunction(); 18 | private_latter() 19 | }); 20 | 21 | function myfunction(){ 22 | $('.attention_button').on("click",function(){ 23 | console.log("attention_button"); 24 | 25 | console.log($(this).prev().text()); 26 | 27 | var att=$(this).prev().text(); 28 | button = $(this); 29 | console.log($(this).text()); 30 | $.getJSON("php/index.php?action=attention&att=?",{ 31 | attentionname:att 32 | },function(result){ 33 | console.log(result['result']); 34 | if(result['result']=="ok"){ 35 | // console.log("关注成功"); 36 | // 37 | // $('.attention_button').text("已关注"); 38 | // $('.attention_button').attr("disabled",true); 39 | $('#attentions').html(result['attentions']); 40 | $('#fans').html(result['fans']); 41 | if(button.text()=="关注"){ 42 | window.alert("关注成功"); 43 | button.text("取消关注"); 44 | }else{ 45 | window.alert("取消关注成功"); 46 | button.text("关注"); 47 | } 48 | 49 | // button.attr("disabled",true); 50 | 51 | } 52 | }) 53 | }); 54 | } 55 | 56 | function private_latter(){ 57 | $('.latter_button').on("click",function(){ 58 | console.log("latter_button"); 59 | str='
\ 60 |
\ 61 | \ 62 |
\ 63 |
\ 64 | '+username+'\ 65 |
\ 66 | \ 67 | \ 68 |
'; 69 | $(this).parent().after(str); 70 | 71 | $('.latter_buttonc').on("click",function(){ 72 | console.log("latter_buttonc"); 73 | console.log($(this).prev().val()); 74 | button=$(this); 75 | console.log(button.parent().prev().find('.username1').text()); 76 | //发消息发送给服务器 77 | $.getJSON("php/index.php?action=lattermeg&la=?",{ 78 | username:username, 79 | latter_name:button.parent().prev().find('.username1').text(), 80 | latter_content:button.prev().val() 81 | },function(result){ 82 | console.log(result['result']); 83 | if(result['result']=="ok"){ 84 | // console.log("back_latter2"); 85 | // str='
\ 86 | //
\ 87 | // \ 88 | //
\ 89 | //
\ 90 | // '+username+'\ 91 | //
\ 92 | //
\ 93 | // '+button.prev().val()+'
'; 94 | 95 | // button.parent().prev().after(str); 96 | button.prev().val(""); 97 | button.parent().remove(); 98 | window.alert("私信发送成功"); 99 | } 100 | }); 101 | 102 | }); 103 | 104 | }); 105 | 106 | } -------------------------------------------------------------------------------- /weibo.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Version : 60004 6 | Source Host : localhost:3306 7 | Source Database : weibo 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 60004 11 | File Encoding : 65001 12 | 13 | Date: 2014-12-15 15:59:57 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | -- ---------------------------- 18 | -- Table structure for `comments` 19 | -- ---------------------------- 20 | DROP TABLE IF EXISTS `comments`; 21 | CREATE TABLE `comments` ( 22 | `id` int(11) NOT NULL AUTO_INCREMENT, 23 | `weibo_id` int(11) DEFAULT NULL, 24 | `com_owner` varchar(200) DEFAULT NULL, 25 | `content` varchar(200) DEFAULT NULL, 26 | `com_person` varchar(200) DEFAULT NULL, 27 | `com_time` varchar(200) DEFAULT NULL, 28 | PRIMARY KEY (`id`) 29 | ) ENGINE=MyISAM AUTO_INCREMENT=78 DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of comments 33 | -- ---------------------------- 34 | INSERT INTO `comments` VALUES ('75', '225', '杨幂', '好美呀', '美美', '2014-12-15 14:55:16'); 35 | INSERT INTO `comments` VALUES ('76', '225', '杨幂', '很爱很爱', '美美', '2014-12-15 14:55:34'); 36 | INSERT INTO `comments` VALUES ('77', '225', '杨幂', '哈哈,我龙马!', '龙马', '2014-12-15 14:57:38'); 37 | 38 | -- ---------------------------- 39 | -- Table structure for `microblog` 40 | -- ---------------------------- 41 | DROP TABLE IF EXISTS `microblog`; 42 | CREATE TABLE `microblog` ( 43 | `id` int(11) NOT NULL AUTO_INCREMENT, 44 | `owner` varchar(300) DEFAULT NULL, 45 | `content` varchar(200) DEFAULT NULL, 46 | `publishtime` datetime DEFAULT NULL, 47 | `picture` varchar(255) DEFAULT NULL, 48 | `trans_owner` varchar(255) DEFAULT NULL, 49 | `vedio` varchar(255) DEFAULT NULL, 50 | `music` varchar(255) DEFAULT NULL, 51 | PRIMARY KEY (`id`) 52 | ) ENGINE=MyISAM AUTO_INCREMENT=228 DEFAULT CHARSET=utf8; 53 | 54 | -- ---------------------------- 55 | -- Records of microblog 56 | -- ---------------------------- 57 | INSERT INTO `microblog` VALUES ('224', '美美', '上传音乐', '2014-12-15 12:26:02', null, null, null, 'php/files/musics/1418617363236.mp3'); 58 | INSERT INTO `microblog` VALUES ('219', '龙马', '今天去打球了!', '2014-12-15 11:45:30', null, null, null, null); 59 | INSERT INTO `microblog` VALUES ('220', '龙马', '哈哈,我很高兴!', '2014-12-15 11:47:26', 'php/files/images/1418615233244.gif', null, null, null); 60 | INSERT INTO `microblog` VALUES ('221', '美美', '大家好,我是美美!', '2014-12-15 11:57:05', null, null, null, null); 61 | INSERT INTO `microblog` VALUES ('222', '美美', '这是一个图片微博', '2014-12-15 12:10:03', 'php/files/images/1418616592831.jpg', null, null, null); 62 | INSERT INTO `microblog` VALUES ('223', '美美', '上传视频', '2014-12-15 12:15:17', null, null, 'php/files/vedios/1418616833228.mp4', null); 63 | INSERT INTO `microblog` VALUES ('225', '杨幂', '哈哈,我是杨幂', '2014-12-15 12:50:01', null, null, null, null); 64 | INSERT INTO `microblog` VALUES ('226', '美美', '哈哈,我是杨幂', '2014-12-15 15:29:09', null, '杨幂', null, null); 65 | INSERT INTO `microblog` VALUES ('227', '美美', '今天去打球了!', '2014-12-15 15:32:16', null, '龙马', null, null); 66 | 67 | -- ---------------------------- 68 | -- Table structure for `privatelatter` 69 | -- ---------------------------- 70 | DROP TABLE IF EXISTS `privatelatter`; 71 | CREATE TABLE `privatelatter` ( 72 | `id` int(11) NOT NULL AUTO_INCREMENT, 73 | `fromperson` varchar(255) DEFAULT NULL, 74 | `lattercontent` varchar(1000) DEFAULT NULL, 75 | `toperson` varchar(255) DEFAULT NULL, 76 | `lattertime` datetime DEFAULT NULL, 77 | PRIMARY KEY (`id`) 78 | ) ENGINE=MyISAM AUTO_INCREMENT=59 DEFAULT CHARSET=utf8; 79 | 80 | -- ---------------------------- 81 | -- Records of privatelatter 82 | -- ---------------------------- 83 | INSERT INTO `privatelatter` VALUES ('57', '龙马', '你好呀!', '美美', '2014-12-15 12:33:59'); 84 | INSERT INTO `privatelatter` VALUES ('58', '美美', '你好,很高兴认识你!', '龙马', '2014-12-15 12:45:36'); 85 | 86 | -- ---------------------------- 87 | -- Table structure for `relationship` 88 | -- ---------------------------- 89 | DROP TABLE IF EXISTS `relationship`; 90 | CREATE TABLE `relationship` ( 91 | `id` int(11) NOT NULL AUTO_INCREMENT, 92 | `owner` varchar(200) DEFAULT NULL, 93 | `attentions` varchar(200) DEFAULT NULL, 94 | PRIMARY KEY (`id`) 95 | ) ENGINE=MyISAM AUTO_INCREMENT=68 DEFAULT CHARSET=utf8; 96 | 97 | -- ---------------------------- 98 | -- Records of relationship 99 | -- ---------------------------- 100 | INSERT INTO `relationship` VALUES ('65', '美美', '杨幂'); 101 | INSERT INTO `relationship` VALUES ('66', '美美', '龙马'); 102 | INSERT INTO `relationship` VALUES ('67', '龙马', '杨幂'); 103 | 104 | -- ---------------------------- 105 | -- Table structure for `userinfo` 106 | -- ---------------------------- 107 | DROP TABLE IF EXISTS `userinfo`; 108 | CREATE TABLE `userinfo` ( 109 | `username` varchar(30) NOT NULL, 110 | `password` varchar(100) DEFAULT NULL, 111 | `email` varchar(100) DEFAULT NULL, 112 | `datetime` date DEFAULT NULL, 113 | `headpicture` varchar(200) DEFAULT NULL, 114 | PRIMARY KEY (`username`) 115 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 116 | 117 | -- ---------------------------- 118 | -- Records of userinfo 119 | -- ---------------------------- 120 | INSERT INTO `userinfo` VALUES ('杨幂', 'cdcdb3bf0e1b87bf97d1a198210bef3b', 'ym@qq.com', '2014-12-15', '/weibo2/php/files/headpictures/1418609284882.jpg'); 121 | INSERT INTO `userinfo` VALUES ('龙马', '6512bd43d9caa6e02c990b0a82652dca', 'longma@hotmail.com', '2014-12-15', '/weibo2/php/files/headpictures/1418608702874.jpg'); 122 | INSERT INTO `userinfo` VALUES ('美美', '6512bd43d9caa6e02c990b0a82652dca', 'meimei@qq.com', '2014-12-15', '/weibo2/php/files/headpictures/1418610638777.jpg'); 123 | -------------------------------------------------------------------------------- /js/homepage.js: -------------------------------------------------------------------------------- 1 | var bar = $('.bar'); 2 | var percent = $('.percent'); 3 | var showimg = $('#showimg'); 4 | var progress = $(".progress"); 5 | var files = $(".files"); 6 | // var btn = $(".btn span"); 7 | 8 | $(".fileupload").wrap("
"); 9 | 10 | $(document).on("click",".delimg",function(){ 11 | var pic = $(this).attr("rel"); 12 | $.post("php/action.php?act=delimg",{imagename:pic},function(msg){ 13 | if(msg==1){ 14 | files.html("删除成功!"); 15 | showimg.empty(); 16 | progress.hide(); 17 | }else{ 18 | alert(msg); 19 | } 20 | }); 21 | }); 22 | 23 | $('.fileupload').on("change",function(){ 24 | button=$(this); 25 | str=button.parent().prev().html(); 26 | if(str=="图片"){ 27 | type="picture"; 28 | path="/weibo2/php/files/images/"; 29 | }else if(str=="视频"){ 30 | type="vedios"; 31 | path="/weibo2/php/files/vedios/"; 32 | }else if(str="音乐"){ 33 | type="musics"; 34 | path="/weibo2/php/files/musics/"; 35 | } 36 | $(this).parent().ajaxSubmit({ 37 | 38 | dataType: 'json', 39 | url:"php/action.php?act="+type, 40 | beforeSend: function() { 41 | showimg.empty(); 42 | progress.show(); 43 | var percentVal = '0%'; 44 | bar.width(percentVal); 45 | percent.html(percentVal); 46 | button.parent().prev().html("上传中..."); 47 | }, 48 | uploadProgress: function(event, position, total, percentComplete) { 49 | var percentVal = percentComplete + '%'; 50 | bar.width(percentVal); 51 | percent.html(percentVal); 52 | }, 53 | success: function(data) { 54 | files.html(""+data.name+"("+data.size+"k) 删除"); 55 | var img = path +data.pic; 56 | if(type=="picture"){ 57 | showimg.html(""); 58 | }else if(type=="musics"){ 59 | showimg.html(""); 60 | }else if(type=="vedios"){ 61 | showimg.html( ' '); 63 | } 64 | 65 | button.parent().prev().html(str); 66 | }, 67 | error:function(xhr){ 68 | // button.parent().prev().html("上传失败"); 69 | bar.width('0') 70 | files.html(xhr.responseText); 71 | button.parent().prev().html(str); 72 | } 73 | }); 74 | }) 75 | // 获取用户的信息 76 | $.getJSON("php/index.php?action=homepage&h=?",function(result){ 77 | // window.alert(username); 78 | // window.alert(result['attentions']); 79 | $('#username').html(result['username']); 80 | username=result['username']; 81 | $('#attentions').html(result['attentions']); 82 | $('#fans').html(result['fans']); 83 | $('#microblog').html(result['microblog']); 84 | // 拿到它发布的微博 85 | $('.publish').after(result['html']); 86 | $('#weibo_name').text(username); 87 | console.log(result['picture']); 88 | $('.myinfomation .mf_picture').find('img').attr('src',result['picture']); 89 | mypicture=result['picture']; 90 | transmit_function(); 91 | comments_function(); 92 | }); 93 | 94 | // 检查字数 95 | $('#publish_content').on("keyup",function(){ 96 | var words = $('#publish_content').val(); 97 | $('#leftwords').html(120-words.length); 98 | 99 | }); 100 | // 发布信息 101 | $('.publish_submit').on("click",function(){ 102 | var content = $("#publish_content").val(); 103 | if(content==""){ 104 | window.alert("请输入发布内容!"); 105 | }else{ 106 | console.log("publish"); 107 | $.getJSON("php/index?action=publish&p=?",{ 108 | content:$("#publish_content").val() 109 | },function(result){ 110 | // 显示信息 111 | console.log(result['center']); 112 | if(result['result']=="ok1" || result['result']=="ok2" || result['result']=="ok3" || result['result']=="ok4"){ 113 | window.alert("发布成功"); 114 | $('#microblog').html(result['microblog']); 115 | $('.publish').after(result['html']); 116 | // $('#publish_content').val(""); 117 | // document.getElementById("leftwords").value="120"; 118 | $('#leftwords').html("120"); 119 | document.getElementById("publish_content").value=""; 120 | files.html(""); 121 | showimg.html(""); 122 | }else if(result['result']="failed"){ 123 | window.alert("发布失败"); 124 | } 125 | transmit_function(); 126 | comments_function(); 127 | }) 128 | } 129 | 130 | }); 131 | 132 | function transmit_function(){ 133 | //转发信息 134 | $('.transmit').on("click",function(){ 135 | console.log("transmit"); 136 | this_tran=$(this); 137 | console.log($(this).parent().parent().find('.username').text()); 138 | console.log($(this).parent().parent().find('.main_content').text()); 139 | $.getJSON("php/index?action=transmit&tr=?",{ 140 | tran_content:this_tran.parent().parent().find('.main_content').find('.ccontent').text(), 141 | tran_username:this_tran.parent().parent().find('.username').text(), 142 | tran_content_pic:this_tran.parent().prev().find('img').attr('src') 143 | },function(result){ 144 | console.log(result['result']); 145 | if(result['result']=="ok"){ 146 | $('#microblog').html(result['microblog']); 147 | $('.publish').after(result['html']); 148 | window.alert("转发成功!!!"); 149 | 150 | } 151 | }); 152 | }); 153 | 154 | } 155 | 156 | 157 | 158 | //评论 159 | function comments_function(){ 160 | $('.pub_comments').on("click",function(){ 161 | 162 | str ='
\ 163 |
\ 164 | \ 165 |
\ 166 |
\ 167 | \ 168 | \ 169 |
\ 170 |
'; 171 | console.log($(this).parent().parent()); 172 | 173 | $(this).parent().parent().after(str); 174 | // content=$(this); 175 | console.log($('.com_content').parent().parent().prev().find('.main_content').text()); 176 | button = $(this); 177 | 178 | $.getJSON("php/index?action=show_comments&sh=?",{ 179 | weibo_content:$('.com_content').parent().parent().prev().find('.main_content').find('.ccontent').text() 180 | },function(result){ 181 | console.log(result['result']); 182 | if(result['result']=="ok"){ 183 | console.log(button); 184 | button.parent().parent().next().append(result['html']); 185 | } 186 | }); 187 | 188 | $('.com_publish').on("click",function(){ 189 | console.log("com_publish"); 190 | button=$(this); 191 | console.log($('.com_content').val()); 192 | console.log(button.parent().parent().prev().find('.main_content').text()); 193 | console.log(button.parent().parent().prev().find('.username').text()); 194 | 195 | console.log("内容"); 196 | console.log($(this).prev().val()); 197 | if($(this).prev().val()==""){ 198 | window.alert("请填写评论内容!!"); 199 | }else{ 200 | $.getJSON("php/index?action=comments&c=?",{ 201 | weibo_content:button.parent().parent().prev().find('.main_content').find('.ccontent').text(), 202 | com_owner:button.parent().parent().prev().find('.username').text(), 203 | com_content:$("#com_content").val() 204 | },function(result){ 205 | console.log(result['result']); 206 | if(result['result']=="ok"){ 207 | console.log(button.parent().parent()); 208 | button.parent().after(result['html']); 209 | 210 | }else{ 211 | console.log("failed"); 212 | } 213 | }); 214 | } 215 | window.alert("评论成功!"); 216 | $('.com_content').val(""); 217 | 218 | }); 219 | }); 220 | } 221 | 222 | $('.biaoqing').bind('click',function(){ 223 | var x = $(this).position().left,y = $(this).position().top + $(this).outerHeight(); 224 | 225 | var html = '
\ 226 | \ 227 | \ 228 | \ 229 | \ 230 | \ 231 | \ 232 | \ 233 | \ 234 | '; 235 | 236 | $('body').append(html); 237 | $('.biao').css({'position':'absolute','left':'300px','top':'240px'}); 238 | $('.biao img').css({'width':'40px','height':'40px'}); 239 | 240 | // var arr=['开心','大笑','汗','好吃','大哭'] 241 | // for(var i=0;i0){ 257 | $('.biao').hide(); 258 | } 259 | }) -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body{ 2 | width:100%; 3 | height:100%; 4 | margin: 0 auto; 5 | font-size: 26px; 6 | margin-left: auto; 7 | margin-right:auto; 8 | text-align:center; 9 | /*background: #9F9;*/ 10 | background-image: url("images/background.jpg"); 11 | } 12 | .login_main{ 13 | background-image: url("images/background.jpg"); 14 | background-repeat: no-repeat ; 15 | background-attachment:fixed; 16 | background-size: 100%; 17 | font-family:"\5FAE\8F6F\96C5\9ED1"; 18 | 19 | } 20 | .login{ 21 | position: absolute; 22 | left:400px; 23 | top:300px; 24 | width: 400px; 25 | height: 200px; 26 | text-align: center; 27 | font-size: 26px; 28 | 29 | } 30 | .login input{ 31 | font-size: 26px; 32 | 33 | } 34 | 35 | /*//发布图片按钮*/ 36 | .btn{ 37 | position: relative; 38 | overflow: hidden; 39 | margin-right: 4px; 40 | display:inline-block; 41 | *display:inline; 42 | padding:4px 10px 4px; 43 | font-size:14px; 44 | line-height:18px; 45 | *line-height:20px; 46 | color:#fff; 47 | text-align:center; 48 | vertical-align:middle; 49 | cursor:pointer; 50 | background:#5bb75b; 51 | border:1px solid #cccccc; 52 | border-color:#e6e6e6 #e6e6e6 #bfbfbf; 53 | border-bottom-color:#b3b3b3; 54 | -webkit-border-radius:4px; 55 | -moz-border-radius:4px; 56 | border-radius:4px; 57 | } 58 | .btn input{ 59 | position: absolute; 60 | top: 0; 61 | right: 0; 62 | margin: 0; 63 | border:solid transparent; 64 | opacity: 0; 65 | filter:alpha(opacity=0); 66 | cursor: pointer; 67 | } 68 | .progress{ 69 | position:relative; 70 | /*margin-left:100px; */ 71 | /*margin-top:-24px; */ 72 | width:200px; 73 | padding: 1px; 74 | border-radius:3px; 75 | display:none 76 | } 77 | .bar { 78 | background-color: green; 79 | display:block; 80 | width:0%; 81 | height:20px; 82 | border-radius:3px; 83 | } 84 | .percent{ 85 | position:absolute; 86 | height:20px; 87 | display:inline-block; 88 | top:3px; 89 | left:2%; 90 | color:#fff 91 | } 92 | .files{ 93 | /*height:22px; */ 94 | line-height:22px; 95 | margin:10px 0 96 | } 97 | .delimg{ 98 | margin-left:20px; 99 | color:#090; 100 | cursor:pointer 101 | } 102 | /*发布图片按钮结束*/ 103 | 104 | .main{ 105 | /*overflow-y: scroll;*/ 106 | width: 1000px; 107 | /*height: 100%;*/ 108 | 109 | /*border:1px solid red;*/ 110 | text-align:center; 111 | margin:0 auto; 112 | } 113 | a{ 114 | color:#000000; 115 | text-decoration:none 116 | } 117 | a:hover{ 118 | color:#BA2636 119 | } 120 | /*导航栏*/ 121 | nav{ 122 | width:100%; 123 | height:60px; 124 | background:#00A2CA; 125 | /*background: #000000;*/ 126 | margin:0 auto; 127 | opacity:0.5; 128 | } 129 | nav li{ 130 | display:inline; 131 | height:60px; 132 | } 133 | nav li a{ 134 | display:inline-block; 135 | padding:0 20px; 136 | height:60px; 137 | line-height:60px; 138 | color:#FFF; 139 | font-family:"\5FAE\8F6F\96C5\9ED1"; 140 | font-size:26px; 141 | } 142 | nav li a:hover{ 143 | background:#0095BB 144 | } 145 | 146 | /*发表微博*/ 147 | .publish{ 148 | width: 550px; 149 | /*height: 250px;*/ 150 | background-color: #fff; 151 | margin: -270px 2px 2px 165px; 152 | position: relative; 153 | font-size:26px; 154 | text-align: left; 155 | /*float: left;*/ 156 | } 157 | /*.publish_title{ 158 | float: left; 159 | }*/ 160 | #publish_content{ 161 | width: 550px; 162 | } 163 | .publish_input{ 164 | width: 400px; 165 | height: 150px; 166 | } 167 | .words{ 168 | margin-top:8px; 169 | /*margin-left: 400px;*/ 170 | float: right; 171 | font-size: 16px; 172 | } 173 | .publish_publish{ 174 | /*float: left;*/ 175 | 176 | margin-top: 10px; 177 | 178 | } 179 | .publish_submit{ 180 | margin: 0px 0px 0px 480px; 181 | font-size: 24px; 182 | } 183 | /*发表微博*/ 184 | 185 | /*我的信息*/ 186 | .myinfomation{ 187 | width: 270px; 188 | height: 250px; 189 | background-color: #9BEAP7; 190 | margin: 0px 2px 20px 720px; 191 | position: relative; 192 | /*float: left;*/ 193 | /*opacity:0.5;*/ 194 | } 195 | .mf_picture img{ 196 | /*margin-top: 20px;*/ 197 | width:100px; 198 | height:100px; 199 | } 200 | .mf_username{ 201 | margin-top: 20px; 202 | } 203 | /*.mf_info{ 204 | margin-top: 20px; 205 | }*/ 206 | .weibo_table{ 207 | /*border="1"*/ 208 | width: 280px; 209 | /*height: 200px;*/ 210 | text-align:center; 211 | font-size: 26px; 212 | 213 | } 214 | /*我的信息*/ 215 | 216 | /*微博内容*/ 217 | .content{ 218 | width: 550px; 219 | /*height: 300px;*/ 220 | background-color: #fff; 221 | /*margin: 20px 2px 2px 160px;*/ 222 | margin:10px 160px 0px 165px; 223 | /*position: relative;*/ 224 | 225 | } 226 | .head_picture{ 227 | /*border:1px solid red;*/ 228 | margin:2px 2px 2px 2px; 229 | position: relative; 230 | width:50px; 231 | height:50px; 232 | } 233 | .head_picture img{ 234 | width:50px; 235 | height:50px; 236 | } 237 | .content .username{ 238 | /*border:1px solid red;*/ 239 | width: 490px; 240 | margin:-50px 2px 2px 56px; 241 | font-size: 24px; 242 | text-align: left; 243 | position: relative; 244 | } 245 | .content .main_content{ 246 | /*border:1px solid red;*/ 247 | width: 490px; 248 | margin:0px 2px 2px 56px; 249 | font-size: 20px; 250 | text-align: left; 251 | 252 | } 253 | .content .main_content img{ 254 | width: 90px; 255 | height: 90px; 256 | /*border:1px solid red;*/ 257 | } 258 | .content .opt{ 259 | 260 | } 261 | /*页面分割*/ 262 | #rightcontent{ 263 | float:left; 264 | width:15%; 265 | height: 100%; 266 | /*background:#fff;*/ 267 | /*border-right: 2px solid #000;*/ 268 | /*border-bottom: 2px solid #000;*/ 269 | margin-right: 15px; 270 | padding-bottom: 20px; 271 | font-size: 26px; 272 | } 273 | #leftcontent{ 274 | /*float: left;*/ 275 | /*overflow-y: scroll;*/ 276 | 277 | width:750px; 278 | font-size: 30px; 279 | margin-left: 0px; 280 | } 281 | 282 | /*注册界面*/ 283 | .register{ 284 | /*border:1px solid red;*/ 285 | text-align: left; 286 | width: 500px; 287 | height: 400px; 288 | margin:20px 0px 0px 400px; 289 | /*background-color: #fff;*/ 290 | text-align: center; 291 | font-size: 30px; 292 | } 293 | 294 | /*评论*/ 295 | .comments{ 296 | /*border:1px solid red;*/ 297 | width: 550px; 298 | /*height: 200px;*/ 299 | margin:0px 0px 0px 165px; 300 | 301 | } 302 | .head_picture2 { 303 | /*border:1px solid red;*/ 304 | margin:8px 8px 2px 8px; 305 | position: relative; 306 | width:30px; 307 | height:30px; 308 | } 309 | .head_picture2 img{ 310 | width:30px; 311 | height:30px; 312 | } 313 | .com{ 314 | /*border:1px solid red;*/ 315 | width: 500px; 316 | height: 80px; 317 | margin:-34px 0px 0px 50px; 318 | } 319 | /*.com_content{ 320 | 321 | }*/ 322 | .com_publish{ 323 | width: 50px; 324 | height: 30px; 325 | margin-top: 8px; 326 | margin-right: 8px; 327 | float:right; 328 | font-size: 16px; 329 | } 330 | 331 | .other{ 332 | /*border:1px solid red;*/ 333 | width: 500px; 334 | 335 | margin:0px 0px 0px 50px; 336 | } 337 | .other .username{ 338 | /*border:1px solid red;*/ 339 | /*width: 100px;*/ 340 | margin:-30px 2px 2px 50px; 341 | font-size: 16px; 342 | text-align: left; 343 | position: relative; 344 | } 345 | .com_com{ 346 | /*border:1px solid red;*/ 347 | width: 430px; 348 | font-size: 16px; 349 | text-align: left; 350 | margin:0px 2px 2px 50px; 351 | } 352 | 353 | 354 | /*发现*/ 355 | .discover_info{ 356 | width: 270px; 357 | height: 250px; 358 | background-color: #9BEAP7; 359 | margin: 0px 2px 20px 720px; 360 | position: absolute; 361 | } 362 | .discover{ 363 | 364 | width: 450px; 365 | background-color: rgb(243, 205, 217); 366 | margin:0px 20px 20px 200px; 367 | } 368 | 369 | .head_picture3 { 370 | /*border:1px solid red;*/ 371 | margin:2px 2px 2px 2px; 372 | position: relative; 373 | width:50px; 374 | height:50px; 375 | } 376 | .head_picture3 img{ 377 | width:50px; 378 | height:50px; 379 | } 380 | .username1{ 381 | /*border:1px solid red;*/ 382 | /*width: 400px;*/ 383 | margin: -38px 2px 2px 56px; 384 | font-size: 26px; 385 | text-align: left; 386 | position: relative; 387 | } 388 | 389 | 390 | /*私信*/ 391 | 392 | .private{ 393 | width: 550px; 394 | min-height: 100px; 395 | background-color: rgb(243, 205, 217); 396 | margin:0px 20px 20px 160px; 397 | } 398 | 399 | .latter{ 400 | width: 460px; 401 | /*background-color: #fff;*/ 402 | margin:0px 20px 20px 10px; 403 | } 404 | 405 | .latter_content{ 406 | /*border:1px solid red;*/ 407 | /*width: 388px;*/ 408 | margin:0px 2px 2px 54px; 409 | font-size: 20px; 410 | text-align: left; 411 | } 412 | .head_picture5 { 413 | /*border:1px solid red;*/ 414 | margin:2px 2px 2px 2px; 415 | position: relative; 416 | width:50px; 417 | height:50px; 418 | } 419 | .head_picture5 img{ 420 | width:50px; 421 | height:50px; 422 | } 423 | .latter .username1{ 424 | /*border:1px solid red;*/ 425 | /*width: 400px;*/ 426 | margin: -45px 2px 2px 56px; 427 | font-size: 20px; 428 | text-align: left; 429 | position: relative; 430 | } 431 | .latter .latter_button{ 432 | float: left; 433 | margin-left:3px; 434 | } 435 | 436 | .back_latter{ 437 | width: 460px; 438 | background-color: #fff; 439 | margin:0px 20px 20px 80px; 440 | } 441 | .back_latter .head_picture { 442 | /*border:1px solid red;*/ 443 | margin:2px 2px 2px 410px; 444 | position: relative; 445 | width:50px; 446 | height:50px; 447 | } 448 | .back_latter .head_picture img{ 449 | width:50px; 450 | height:50px; 451 | } 452 | 453 | .back_latter .username{ 454 | /*border:1px solid red;*/ 455 | width: 100px; 456 | margin: -45px 2px 2px 306px; 457 | font-size: 20px; 458 | text-align: right; 459 | position: relative; 460 | } 461 | .back_latter .latter_cont{ 462 | /*border:1px solid red;*/ 463 | width: 380px; 464 | /*margin:0px 45px 2px 0px;*/ 465 | font-size: 20px; 466 | text-align: left; 467 | /*float: left;*/ 468 | } 469 | .back_latter .latter_buttonc{ 470 | /*float: right;*/ 471 | /*margin: -30px 3px 0px 0px;*/ 472 | } 473 | .back_latter .latter_content2{ 474 | /*border:1px solid red;*/ 475 | width: 400px; 476 | margin:0px 2px 2px 6px; 477 | font-size: 20px; 478 | text-align: left; 479 | } 480 | 481 | .back_latter .latter_content1{ 482 | text-align: left; 483 | font-size: 20px; 484 | } 485 | 486 | .search { 487 | margin: -270px 0px 0px 0px; 488 | } 489 | .back_latter2{ 490 | width: 460px; 491 | background-color: #fff; 492 | margin: 0px 20px 20px 200px; 493 | } 494 | .back_latter2 .head_picture { 495 | /*border:1px solid red;*/ 496 | margin:2px 2px 2px 410px; 497 | position: relative; 498 | width:50px; 499 | height:50px; 500 | } 501 | .back_latter2 .head_picture img{ 502 | width:50px; 503 | height:50px; 504 | } 505 | 506 | .back_latter2 .username{ 507 | /*border:1px solid red;*/ 508 | width: 100px; 509 | margin: -45px 2px 2px 306px; 510 | font-size: 20px; 511 | text-align: right; 512 | position: relative; 513 | } 514 | .back_latter2 .latter_cont{ 515 | /*border:1px solid red;*/ 516 | width: 380px; 517 | /*margin:0px 45px 2px 0px;*/ 518 | font-size: 20px; 519 | text-align: left; 520 | /*float: left;*/ 521 | } 522 | .back_latter2 .latter_buttonc{ 523 | /*float: right;*/ 524 | /*margin: -30px 3px 0px 0px;*/ 525 | } 526 | .back_latter2 .latter_content2{ 527 | /*border:1px solid red;*/ 528 | width: 400px; 529 | margin:0px 2px 2px 6px; 530 | font-size: 20px; 531 | text-align: left; 532 | } 533 | 534 | .back_latter2 .latter_content1{ 535 | text-align: left; 536 | font-size: 20px; 537 | } 538 | .lattertime{ 539 | text-align: left; 540 | margin-left:10px; 541 | float: left; 542 | font-size: 12px; 543 | } 544 | .publishtime{ 545 | text-align: left; 546 | /*margin-left:10px;*/ 547 | float: left; 548 | font-size: 12px; 549 | } 550 | #showimg_register { 551 | /*border:1px solid red;*/ 552 | width: 60px; 553 | height: 60px; 554 | } 555 | #showimg_register img{ 556 | 557 | width: 60px; 558 | height: 60px; 559 | } 560 | .com_time{ 561 | text-align: left; 562 | /*margin-left:10px;*/ 563 | /*float: left;*/ 564 | font-size: 12px; 565 | } 566 | .biao{ 567 | width: 300px; 568 | height: 300px; 569 | background-color: #fff; 570 | } 571 | .cont img{ 572 | width: 30px; 573 | height: 30px; 574 | } 575 | 576 | .content .username a{ 577 | font-size: 26px; 578 | font-weight:bold; 579 | } 580 | 581 | form { 582 | margin-bottom:0px; 583 | } -------------------------------------------------------------------------------- /php/index.php: -------------------------------------------------------------------------------- 1 | 1,'b'=>2 ); 9 | 10 | $okay=TRUE; 11 | if(empty($_REQUEST['headpicture'])){ 12 | $array['result']="请上传头像"; 13 | $okay=FALSE; 14 | } 15 | if(empty($_REQUEST['username'])){ 16 | $array['result']=" 请填写用户名!"; 17 | $okay=FALSE; 18 | } 19 | if(empty($_REQUEST['password'])){ 20 | $array['result']=" 请填写密码!"; 21 | $okay=FALSE; 22 | } 23 | if(empty($_REQUEST['password_re'])){ 24 | $array['result']=" 请填写密码!"; 25 | $okay=FALSE; 26 | } 27 | if(empty($_REQUEST['email'])){ 28 | $array['result']=" 请填写电子邮件!"; 29 | $okay=FALSE; 30 | } 31 | if($_REQUEST['password'] != $_REQUEST['password_re']){ 32 | $array['result']="两次输入的密码不匹配,请重新输入!"; 33 | $okay=FALSE; 34 | } 35 | 36 | if($okay){ 37 | // 插入数据库中 38 | $username=trim($_REQUEST['username']); 39 | $password=md5(trim($_REQUEST['password'])); 40 | $headpicture=trim($_REQUEST['headpicture']); 41 | $email=trim($_REQUEST['email']); 42 | 43 | // 查询该用户名注册没有 44 | $sqlTool=new SqlTool(); 45 | $sql="SELECT * FROM userinfo where username='$username'"; 46 | $res=$sqlTool->execute_dql($sql); 47 | if($res=mysql_fetch_row($res)){ 48 | $array['result']="该用户已经有人注册过了".$_REQUEST['username']; 49 | $array['res']="2"; 50 | }else{ 51 | $sql="INSERT INTO userinfo value('$username','$password','$email',NOW(),'$headpicture')"; 52 | $res=$sqlTool->execute_dml($sql); 53 | if($res==1){ 54 | $array['res']="1"; 55 | $array['result']=$_REQUEST['username']."注册成功!点击登录页面,进行登录。"; 56 | 57 | }else{ 58 | $array['res']="0"; 59 | $array['result']=$_REQUEST['username']."注册失败!"; 60 | } 61 | } 62 | } 63 | 64 | 65 | 66 | $json=json_encode($array); 67 | echo $_REQUEST['c'].'('.$json.')'; 68 | } 69 | if($_REQUEST['action']=='login'){ 70 | 71 | $array = array('result' => 1); 72 | 73 | $okay=TRUE; 74 | 75 | if(empty($_REQUEST['username'])){ 76 | $array['result']=" 请填写用户名!"; 77 | $okay=FALSE; 78 | } 79 | if(empty($_REQUEST['password'])){ 80 | $array['result']=" 请填写密码!"; 81 | $okay=FALSE; 82 | } 83 | 84 | $_SESSION['username']=$_REQUEST['username']; 85 | 86 | if($okay){ 87 | // 插入数据库中 88 | $username=trim($_REQUEST['username']); 89 | $password=md5(trim($_REQUEST['password'])); 90 | 91 | // 查询该用户名 92 | $sqlTool=new SqlTool(); 93 | $sql="SELECT * FROM userinfo where username='$username'"; 94 | $res=$sqlTool->execute_dql($sql); 95 | if($row=mysql_fetch_array($res)){ 96 | if($row['password']==$password){ 97 | $array['result']="登录成功"; 98 | $_SESSION['headpicture']=$row['headpicture']; 99 | } 100 | else{ 101 | $array['result']="密码不正确,请重新输入密码"; 102 | } 103 | 104 | }else{ 105 | $array['result']="没有该用户的注册信息,请先注册!"; 106 | } 107 | } 108 | 109 | update_info(); 110 | 111 | $json=json_encode($array); 112 | echo $_REQUEST['l'].'('.$json.')'; 113 | } 114 | 115 | if($_REQUEST['action']=='homepage'){ 116 | $array = array('result' => 1); 117 | // 查询该用户名 118 | $sqlTool=new SqlTool(); 119 | $username=$_SESSION['username']; 120 | 121 | if(!isset($_SESSION['username'])){ 122 | $array['result']="failed"; 123 | } 124 | $array['result']="ok"; 125 | 126 | $array['html'] =""; 127 | $sql="SELECT * FROM microblog where owner='$username' order by publishtime desc"; 128 | $res=$sqlTool->execute_dql($sql); 129 | while ($row=mysql_fetch_array($res)) { 130 | 131 | $sql1="SELECT * FROM userinfo WHERE username='".$row['owner']."'"; 132 | $res1=$sqlTool->execute_dql($sql1); 133 | $row1=mysql_fetch_array($res1); 134 | 135 | if($row['trans_owner'] == ""){ 136 | // 自己发的微博 137 | if($row['picture'] != ""){ 138 | $array['html'] =$array['html'].'
139 |
140 | 141 |
142 |
143 | '.$username.' 144 |
145 |
146 |
'.$row['content'].'
147 |
148 | '.$row['publishtime'].' 149 |
150 |
151 | 收藏 152 | 转发 153 | 评论 154 |
155 |
'; 156 | 157 | }else if($row['vedio'] != ""){ 158 | $array['html'] =$array['html'].'
159 |
160 | 161 |
162 |
163 | '.$username.' 164 |
165 |
166 | '.$row['content'].'
167 |
170 | '.$row['publishtime'].' 171 |
172 |
173 | 收藏 174 | 转发 175 | 评论 176 |
177 |
'; 178 | 179 | }else if($row['music'] != ""){ 180 | $array['html'] =$array['html'].'
181 |
182 | 183 |
184 |
185 | '.$username.' 186 |
187 |
188 | '.$row['content'].'
189 |
190 | '.$row['publishtime'].' 191 | 192 |
193 | 收藏 194 | 转发 195 | 评论 196 |
197 | '; 198 | }else{ 199 | $array['html'] =$array['html'].'
200 |
201 | 202 |
203 |
204 | '.$username.' 205 |
206 |
207 |
'.$row['content'].'
208 | '.$row['publishtime'].' 209 |
210 |
211 | 收藏 212 | 转发 213 | 评论 214 |
215 |
'; 216 | 217 | } 218 | }else{ 219 | //转发的微博 220 | if($row['picture'] != ""){ 221 | $array['html'] =$array['html'].'
222 |
223 | 224 |
225 |
226 | '.$username.' 227 |
228 |
229 | 230 |
@'.$row['content'].'
231 |
232 | '.$row['publishtime'].' 233 |
234 |
235 | 收藏 236 | 转发 237 | 评论 238 |
239 |
'; 240 | }else if($row['vedio'] != ""){ 241 | 242 | }else if($row['music'] != ""){ 243 | 244 | }else{ 245 | $array['html'] =$array['html'].'
246 |
247 | 248 |
249 |
250 | '.$username.' 251 |
252 |
253 |
@'.$row['content'].'
254 | 255 | '.$row['publishtime'].' 256 |
257 |
258 | 收藏 259 | 转发 260 | 评论 261 |
262 |
'; 263 | 264 | } 265 | 266 | } 267 | 268 | } 269 | 270 | $sql="SELECT * FROM relationship where owner='$username'"; 271 | $res=$sqlTool->execute_dql($sql); 272 | while($row=mysql_fetch_array($res)){ 273 | $sql2="SELECT * FROM microblog where owner='".$row['attentions']."'"; 274 | $res2=$sqlTool->execute_dql($sql2); 275 | //关注人的微博 276 | while ($row2=mysql_fetch_array($res2)) { 277 | 278 | $sql3="SELECT * FROM userinfo where username='".$row2['owner']."'"; 279 | $res3=$sqlTool->execute_dql($sql3); 280 | $row3=mysql_fetch_array($res3); 281 | 282 | if($row2['picture'] != ""){ 283 | $array['html'] =$array['html'].'
284 |
285 | 286 |
287 |
288 | '.$row2['owner'].' 289 |
290 |
291 |
'.$row2['content'].'
292 |
293 | '.$row2['publishtime'].' 294 |
295 |
296 | 收藏 297 | 转发 298 | 评论 299 |
300 |
'; 301 | }else{ 302 | $array['html'] =$array['html'].'
303 |
304 | 305 |
306 |
307 | '.$row2['owner'].' 308 |
309 |
310 |
'.$row2['content'].'
311 | '.$row2['publishtime'].' 312 |
313 |
314 | 收藏 315 | 转发 316 | 评论 317 |
318 |
'; 319 | } 320 | 321 | } 322 | } 323 | 324 | $array['username']=$_SESSION['username']; 325 | $array['attentions']=$_SESSION['attentions']; 326 | $array['fans']=$_SESSION['fans']; 327 | $array['microblog']=$_SESSION['microblog']; 328 | $array['picture']=$_SESSION['headpicture']; 329 | 330 | 331 | $json=json_encode($array); 332 | echo $_REQUEST['h'].'('.$json.')'; 333 | } 334 | 335 | if($_REQUEST['action']=='publish'){ 336 | $array = array('result' => 1); 337 | // 查询该用户名 338 | $sqlTool=new SqlTool(); 339 | $username=$_SESSION['username']; 340 | if(!isset($_SESSION['username'])){ 341 | $array['result']="failed"; 342 | } 343 | $array['result']="ok"; 344 | 345 | $content=trim($_REQUEST['content']); 346 | $pic_path=$_SESSION['pic_path']; 347 | $vedio_path=$_SESSION['vedio_path']; 348 | $music_path=$_SESSION['music_path']; 349 | 350 | $sql="SELECT * FROM userinfo WHERE username='$username'"; 351 | $res=$sqlTool->execute_dql($sql); 352 | $row=mysql_fetch_array($res); 353 | 354 | date_default_timezone_set("Asia/Shanghai"); 355 | $pub_time=date('Y-m-d h:m:s'); 356 | 357 | $biaoqing = array("拜拜","不能忍","吃饭","大哭","大笑","干杯","汗","好吃","开心","衰"); 358 | $count=count($biaoqing); 359 | for($i=0;$i<$count;$i++){ 360 | $content=str_replace('['.$biaoqing[$i].']', '', $content); 361 | } 362 | //插入微博 363 | if(isset($_SESSION['pic_path'])){ 364 | 365 | //图片消息 366 | $sql="INSERT INTO microblog(owner,content,publishtime,picture) value('$username','$content',NOW(),'$pic_path')"; 367 | // $sql="SELECT * FROM userinfo where username='$username'"; 368 | $res=$sqlTool->execute_dml($sql); 369 | if($res==1){ 370 | $array['result']="ok1"; 371 | $array['html']='
372 |
373 | 374 |
375 |
376 | '.$username.' 377 |
378 |
379 | '.$content.'
380 |
381 | '.$pub_time.' 382 |
383 |
384 | 收藏 385 | 转发 386 | 评论 387 |
388 |
'; 389 | 390 | }else{ 391 | $array['result']="failed"; 392 | } 393 | unset($_SESSION['pic_path']); 394 | }else if(isset($_SESSION['vedio_path'])){ 395 | //视频消息 396 | $sql="INSERT INTO microblog(owner,content,publishtime,vedio) value('$username','$content',NOW(),'$vedio_path')"; 397 | // $sql="SELECT * FROM userinfo where username='$username'"; 398 | $res=$sqlTool->execute_dml($sql); 399 | if($res==1){ 400 | $array['result']="ok1"; 401 | $array['html']='
402 |
403 | 404 |
405 |
406 | '.$username.' 407 |
408 |
409 | '.$content.'
410 |
413 | '.$pub_time.' 414 |
415 |
416 | 收藏 417 | 转发 418 | 评论 419 |
420 |
'; 421 | 422 | }else{ 423 | $array['result']="failed"; 424 | } 425 | unset($_SESSION['vedio_path']); 426 | }else if(isset($_SESSION['music_path'])){ 427 | //音乐消息 428 | $sql="INSERT INTO microblog(owner,content,publishtime,music) value('$username','$content',NOW(),'$music_path')"; 429 | // $sql="SELECT * FROM userinfo where username='$username'"; 430 | $res=$sqlTool->execute_dml($sql); 431 | if($res==1){ 432 | $array['result']="ok1"; 433 | $array['html']='
434 |
435 | 436 |
437 |
438 | '.$username.' 439 |
440 |
441 | '.$content.'
442 |
443 | '.$pub_time.' 444 | 445 |
446 | 收藏 447 | 转发 448 | 评论 449 |
450 | '; 451 | 452 | }else{ 453 | $array['result']="failed"; 454 | } 455 | unset($_SESSION['music_path']); 456 | }else{ 457 | $sql="INSERT INTO microblog(owner,content,publishtime) value('$username','$content',NOW())"; 458 | // $sql="SELECT * FROM userinfo where username='$username'"; 459 | $res=$sqlTool->execute_dml($sql); 460 | if($res==1){ 461 | $array['result']="ok4"; 462 | $array['html']='
463 |
464 | 465 |
466 |
467 | '.$username.' 468 |
469 |
470 | '.$content.'
471 | '.$pub_time.' 472 |
473 |
474 | 收藏 475 | 转发 476 | 评论 477 |
478 |
'; 479 | }else{ 480 | $array['result']="failed"; 481 | } 482 | 483 | } 484 | //微博数量更新 485 | update_info(); 486 | 487 | $array['microblog']=$_SESSION['microblog']; 488 | 489 | $json=json_encode($array); 490 | echo $_REQUEST['p'].'('.$json.')'; 491 | } 492 | 493 | if($_REQUEST['action']=="comments"){ 494 | $array = array('result' => 1); 495 | // 查询该用户名 496 | $sqlTool=new SqlTool(); 497 | 498 | $com_owner=trim($_REQUEST['com_owner']); 499 | $content=trim($_REQUEST['com_content']); 500 | $com_person=$_SESSION['username']; 501 | $weibo_content=trim($_REQUEST['weibo_content']); 502 | 503 | // 找到该微博 504 | $sql="SELECT * FROM microblog WHERE content='$weibo_content';"; 505 | $res=$sqlTool->execute_dql($sql); 506 | if($row=mysql_fetch_array($res)){ 507 | $weibo_id=$row['id']; 508 | $array['result']="weibo".$weibo_id; 509 | }else{ 510 | $array['result']="failed".$weibo_id.$weibo_content; 511 | } 512 | 513 | date_default_timezone_set("Asia/Shanghai"); 514 | $com_time=date('Y-m-d H:i:s'); 515 | 516 | // 插入微博 517 | $sql="INSERT INTO comments(weibo_id,com_owner,content,com_person,com_time) value('$weibo_id','$com_owner','$content','$com_person',NOW())"; 518 | // $sql="SELECT * FROM userinfo where username='$username'"; 519 | // $sql="UPDATE comments SET com_owner='$com_owner',content='$content',com_person='$com_person',com_time=NOW() WHERE weibo_id='$weibo_id'"; 520 | $res=$sqlTool->execute_dml($sql); 521 | if($res==1){ 522 | $array['result']="ok"; 523 | $array['html']='
524 |
525 | 526 |
527 |
528 | '.$com_person.': 529 |
530 |
531 | '.$content.'
532 | '.$com_time.' 533 |
534 |
'; 535 | 536 | }else{ 537 | $array['result']="failedddd"; 538 | } 539 | 540 | $json=json_encode($array); 541 | echo $_REQUEST['c'].'('.$json.')'; 542 | } 543 | 544 | if($_REQUEST['action']=="show_comments"){ 545 | $array = array('result' => 1); 546 | // 查询该用户名 547 | $sqlTool=new SqlTool(); 548 | $weibo_content=trim($_REQUEST['weibo_content']); 549 | date_default_timezone_set("Asia/Shanghai"); 550 | $com_time=date('Y-m-d H:i:s'); 551 | // 找到该微博 552 | $sql="SELECT * FROM microblog WHERE content='$weibo_content';"; 553 | $res=$sqlTool->execute_dql($sql); 554 | if($row=mysql_fetch_array($res)){ 555 | $weibo_id=$row['id']; 556 | $array['result']="weibo".$weibo_id; 557 | }else{ 558 | $array['result']="failed".$weibo_id.$weibo_content; 559 | } 560 | 561 | $sql="SELECT * FROM comments WHERE weibo_id='$weibo_id'"; 562 | $res=$sqlTool->execute_dql($sql); 563 | 564 | while($row=mysql_fetch_array($res)){ 565 | $sql2="SELECT * FROM userinfo WHERE username='".$row['com_person']."'"; 566 | $res2=$sqlTool->execute_dql($sql2); 567 | $row2=mysql_fetch_array($res2); 568 | $array['result']="ok"; 569 | $array['html'] .= '
570 |
571 | 572 |
573 | 576 |
577 | '.$row['content'].'
578 | '.$com_time.' 579 |
580 |
'; 581 | 582 | } 583 | 584 | $json=json_encode($array); 585 | echo $_REQUEST['sh'].'('.$json.')'; 586 | } 587 | 588 | 589 | if($_REQUEST['action']=="discover"){ 590 | $array = array('result' => 1); 591 | // 查询该用户名 592 | $sqlTool=new SqlTool(); 593 | $username=$_REQUEST['username']; 594 | // $content=$_REQUEST['content']; 595 | //插入微博 596 | // $sql="INSERT INTO microblog(owner,content,publishtime,comments) value('$username','$content',NOW(),0)"; 597 | $sql="SELECT * FROM userinfo "; 598 | $res=$sqlTool->execute_dql($sql); 599 | while($row=mysql_fetch_array($res)){ 600 | // $array['result']="ok"; 601 | if($row['username']==$username){ 602 | $array['username']=$username; 603 | // $array['attentions']=$row['attentions']; 604 | // $array['fans']=$row['fans']; 605 | // $array['microblog']=$row['microblog']; 606 | 607 | }else{ 608 | $array['html']=$array['html'].'
609 |
610 | 611 |
612 |
613 | '.$row['username'].' 614 |
615 | 616 | 617 |
'; 618 | } 619 | } 620 | update_info(); 621 | $array['username']=$_SESSION['username']; 622 | $array['attentions']=$_SESSION['attentions']; 623 | $array['fans']=$_SESSION['fans']; 624 | $array['microblog']=$_SESSION['microblog']; 625 | $array['picture']=$_SESSION['headpicture']; 626 | $json=json_encode($array); 627 | echo $_REQUEST['d'].'('.$json.')'; 628 | } 629 | 630 | 631 | if($_REQUEST['action']=="attention"){ 632 | $array = array('result' => 1); 633 | // 查询该用户名 634 | $sqlTool=new SqlTool(); 635 | $username=$_SESSION['username']; 636 | $attentionname=trim($_REQUEST['attentionname']); 637 | 638 | $sql="SELECT * FROM relationship WHERE owner='$username' and attentions='$attentionname'"; 639 | $res=$sqlTool->execute_dql($sql); 640 | $row=mysql_fetch_array($res); 641 | if($row>0){ 642 | //取消关注 643 | $sql="DELETE FROM relationship WHERE owner='$username' and attentions='$attentionname'"; 644 | // $sql="SELECT * FROM userinfo "; 645 | $res=$sqlTool->execute_dml($sql); 646 | if($res==1){ 647 | $array['result']="ok"; 648 | }else{ 649 | $array['result']="failed1"; 650 | } 651 | }else{ 652 | //关注 653 | $sql="INSERT INTO relationship(owner,attentions) value('$username','$attentionname')"; 654 | // $sql="SELECT * FROM userinfo "; 655 | $res=$sqlTool->execute_dml($sql); 656 | if($res==1){ 657 | $array['result']="ok".$row; 658 | }else{ 659 | $array['result']="failed"; 660 | } 661 | } 662 | 663 | $sql1="SELECT count(*) FROM relationship WHERE owner='$username'"; 664 | $res1=$sqlTool->execute_dql($sql1); 665 | $row1=mysql_fetch_array($res1); 666 | $_SESSION['attentions']=$row1[0]; 667 | // update_info(); 668 | $array['attentions']=$_SESSION['attentions']; 669 | 670 | $json=json_encode($array); 671 | echo $_REQUEST['att'].'('.$json.')'; 672 | } 673 | 674 | //转发信息 675 | if($_REQUEST['action']=="transmit"){ 676 | $array = array('result' =>'1'); 677 | $tran_content=trim($_REQUEST['tran_content']); 678 | $tran_username=trim($_REQUEST['tran_username']); 679 | $tran_content_pic=trim($_REQUEST['tran_content_pic']); 680 | $username=trim($_SESSION['username']); 681 | date_default_timezone_set('Asia/Shanghai'); 682 | $tran_time=date('Y-m-d H:i:s'); 683 | //将该微博插入到用户的微博下 684 | $sqlTool = new SqlTool(); 685 | if($tran_content_pic == ""){ 686 | $sql = "INSERT INTO microblog(owner,content,publishtime,trans_owner) value('$username','$tran_content',NOW(),'$tran_username')"; 687 | $res=$sqlTool->execute_dml($sql); 688 | if($res==1){ 689 | $array['result']="ok"; 690 | $array['html']='
691 |
692 | 693 |
694 |
695 | '.$username.' 696 |
697 |
698 |
@转发'.$tran_username.'
'.$tran_content.'
699 | '.$tran_time.' 700 |
701 |
702 | 收藏 703 | 转发 704 | 评论 705 |
706 |
'; 707 | }else{ 708 | $array['result']="failed"; 709 | } 710 | }else{ 711 | $sql = "INSERT INTO microblog(owner,content,publishtime,trans_owner,picture) value('$username','$tran_content',NOW(),'$tran_username','$tran_content_pic')"; 712 | $res=$sqlTool->execute_dml($sql); 713 | if($res==1){ 714 | $array['result']="ok"; 715 | $array['html']='
716 |
717 | 718 |
719 |
720 | '.$username.' 721 |
722 |
723 |
@转发'.$tran_username.'
'.$tran_content.'
724 |
725 | '.$tran_time.' 726 |
727 |
728 | 收藏 729 | 转发 730 | 评论 731 |
732 |
'; 733 | }else{ 734 | $array['result']="failed"; 735 | } 736 | } 737 | update_info(); 738 | $array['microblog']=$_SESSION['microblog']; 739 | 740 | $json=json_encode($array); 741 | echo $_REQUEST['tr'].'('.$json.')'; 742 | } 743 | 744 | if($_REQUEST['action']=="private"){ 745 | $array = array('result'=>'1'); 746 | $sqlTool=new SqlTool(); 747 | $username=$_SESSION['username']; 748 | $sql1="SELECT * FROM privatelatter WHERE toperson='$username'"; 749 | $res1=$sqlTool->execute_dql($sql1); 750 | 751 | while ($row1=mysql_fetch_array($res1)) { 752 | $sql="SELECT * FROM userinfo WHERE username='".$row1['fromperson']."'"; 753 | $res=$sqlTool->execute_dql($sql); 754 | $row=mysql_fetch_array($res); 755 | $array['html']=$array['html'].'
756 |
757 |
758 | 759 |
760 | 761 |
762 | '.$row['username'].' 763 |
764 |
765 | '.$row1['lattercontent'].' 766 |
767 |
'; 768 | } 769 | 770 | 771 | $array['username']=$_SESSION['username']; 772 | $array['attentions']=$_SESSION['attentions']; 773 | $array['fans']=$_SESSION['fans']; 774 | $array['microblog']=$_SESSION['microblog']; 775 | $array['picture']=$_SESSION['headpicture']; 776 | $json=json_encode($array); 777 | echo $_REQUEST['p'].'('.$json.')'; 778 | 779 | } 780 | 781 | if($_REQUEST['action']=="lattermeg"){ 782 | $array = array('result'=>'1'); 783 | $username=$_SESSION['username']; 784 | $latter_name=trim($_REQUEST['latter_name']); 785 | $latter_content=trim($_REQUEST['latter_content']); 786 | // $content=$_REQUEST['content']; 787 | //插入微博 788 | $sqlTool=new SqlTool(); 789 | $sql="INSERT INTO privatelatter(fromperson,lattercontent,toperson,lattertime) value('$username','$latter_content','$latter_name',NOW())"; 790 | // $sql="SELECT * FROM userinfo "; 791 | $res=$sqlTool->execute_dml($sql); 792 | if($res==1){ 793 | $array['result']="ok"; 794 | }else{ 795 | $array['result']="failed"; 796 | } 797 | $json=json_encode($array); 798 | echo $_REQUEST['la'].'('.$json.')'; 799 | 800 | } 801 | 802 | if($_REQUEST['action']=="logout"){ 803 | $array = array('result'=>'1'); 804 | $array['result']="退出成功"; 805 | $json=json_encode($array); 806 | echo $_REQUEST['la'].'('.$json.')'; 807 | 808 | unset($_SESSION); 809 | session_destroy(); 810 | } 811 | 812 | function update_info(){ 813 | $username=$_SESSION['username']; 814 | $sqlTool=new SqlTool(); 815 | $sql1="SELECT count(*) FROM relationship WHERE owner='$username'"; 816 | $res1=$sqlTool->execute_dql($sql1); 817 | $row1=mysql_fetch_array($res1); 818 | $_SESSION['attentions']=$row1[0]; 819 | 820 | $sql2="SELECT count(*) FROM relationship WHERE attentions='$username'"; 821 | $res2=$sqlTool->execute_dql($sql2); 822 | $row2=mysql_fetch_array($res2); 823 | $_SESSION['fans']=$row2[0]; 824 | 825 | $sql3="SELECT count(*) FROM microblog WHERE owner='$username'"; 826 | $res3=$sqlTool->execute_dql($sql3); 827 | $row3=mysql_fetch_array($res3); 828 | $_SESSION['microblog']=$row3[0]; 829 | 830 | } 831 | ?> -------------------------------------------------------------------------------- /js/jquery.form.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery Form Plugin 3 | * version: 3.15 (09-SEP-2012) 4 | * @requires jQuery v1.3.2 or later 5 | * 6 | * Examples and documentation at: http://malsup.com/jquery/form/ 7 | * Project repository: https://github.com/malsup/form 8 | * Dual licensed under the MIT and GPL licenses: 9 | * http://malsup.github.com/mit-license.txt 10 | * http://malsup.github.com/gpl-license-v2.txt 11 | */ 12 | /*global ActiveXObject alert */ 13 | ;(function($) { 14 | "use strict"; 15 | 16 | /* 17 | Usage Note: 18 | ----------- 19 | Do not use both ajaxSubmit and ajaxForm on the same form. These 20 | functions are mutually exclusive. Use ajaxSubmit if you want 21 | to bind your own submit handler to the form. For example, 22 | 23 | $(document).ready(function() { 24 | $('#myForm').on('submit', function(e) { 25 | e.preventDefault(); // <-- important 26 | $(this).ajaxSubmit({ 27 | target: '#output' 28 | }); 29 | }); 30 | }); 31 | 32 | Use ajaxForm when you want the plugin to manage all the event binding 33 | for you. For example, 34 | 35 | $(document).ready(function() { 36 | $('#myForm').ajaxForm({ 37 | target: '#output' 38 | }); 39 | }); 40 | 41 | You can also use ajaxForm with delegation (requires jQuery v1.7+), so the 42 | form does not have to exist when you invoke ajaxForm: 43 | 44 | $('#myForm').ajaxForm({ 45 | delegation: true, 46 | target: '#output' 47 | }); 48 | 49 | When using ajaxForm, the ajaxSubmit function will be invoked for you 50 | at the appropriate time. 51 | */ 52 | 53 | /** 54 | * Feature detection 55 | */ 56 | var feature = {}; 57 | feature.fileapi = $("").get(0).files !== undefined; 58 | feature.formdata = window.FormData !== undefined; 59 | 60 | /** 61 | * ajaxSubmit() provides a mechanism for immediately submitting 62 | * an HTML form using AJAX. 63 | */ 64 | $.fn.ajaxSubmit = function(options) { 65 | /*jshint scripturl:true */ 66 | 67 | // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) 68 | if (!this.length) { 69 | log('ajaxSubmit: skipping submit process - no element selected'); 70 | return this; 71 | } 72 | 73 | var method, action, url, $form = this; 74 | 75 | if (typeof options == 'function') { 76 | options = { success: options }; 77 | } 78 | 79 | method = this.attr('method'); 80 | action = this.attr('action'); 81 | url = (typeof action === 'string') ? $.trim(action) : ''; 82 | url = url || window.location.href || ''; 83 | if (url) { 84 | // clean url (don't include hash vaue) 85 | url = (url.match(/^([^#]+)/)||[])[1]; 86 | } 87 | 88 | options = $.extend(true, { 89 | url: url, 90 | success: $.ajaxSettings.success, 91 | type: method || 'GET', 92 | iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' 93 | }, options); 94 | 95 | // hook for manipulating the form data before it is extracted; 96 | // convenient for use with rich editors like tinyMCE or FCKEditor 97 | var veto = {}; 98 | this.trigger('form-pre-serialize', [this, options, veto]); 99 | if (veto.veto) { 100 | log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); 101 | return this; 102 | } 103 | 104 | // provide opportunity to alter form data before it is serialized 105 | if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { 106 | log('ajaxSubmit: submit aborted via beforeSerialize callback'); 107 | return this; 108 | } 109 | 110 | var traditional = options.traditional; 111 | if ( traditional === undefined ) { 112 | traditional = $.ajaxSettings.traditional; 113 | } 114 | 115 | var elements = []; 116 | var qx, a = this.formToArray(options.semantic, elements); 117 | if (options.data) { 118 | options.extraData = options.data; 119 | qx = $.param(options.data, traditional); 120 | } 121 | 122 | // give pre-submit callback an opportunity to abort the submit 123 | if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { 124 | log('ajaxSubmit: submit aborted via beforeSubmit callback'); 125 | return this; 126 | } 127 | 128 | // fire vetoable 'validate' event 129 | this.trigger('form-submit-validate', [a, this, options, veto]); 130 | if (veto.veto) { 131 | log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); 132 | return this; 133 | } 134 | 135 | var q = $.param(a, traditional); 136 | if (qx) { 137 | q = ( q ? (q + '&' + qx) : qx ); 138 | } 139 | if (options.type.toUpperCase() == 'GET') { 140 | options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; 141 | options.data = null; // data is null for 'get' 142 | } 143 | else { 144 | options.data = q; // data is the query string for 'post' 145 | } 146 | 147 | var callbacks = []; 148 | if (options.resetForm) { 149 | callbacks.push(function() { $form.resetForm(); }); 150 | } 151 | if (options.clearForm) { 152 | callbacks.push(function() { $form.clearForm(options.includeHidden); }); 153 | } 154 | 155 | // perform a load on the target only if dataType is not provided 156 | if (!options.dataType && options.target) { 157 | var oldSuccess = options.success || function(){}; 158 | callbacks.push(function(data) { 159 | var fn = options.replaceTarget ? 'replaceWith' : 'html'; 160 | $(options.target)[fn](data).each(oldSuccess, arguments); 161 | }); 162 | } 163 | else if (options.success) { 164 | callbacks.push(options.success); 165 | } 166 | 167 | options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg 168 | var context = options.context || this ; // jQuery 1.4+ supports scope context 169 | for (var i=0, max=callbacks.length; i < max; i++) { 170 | callbacks[i].apply(context, [data, status, xhr || $form, $form]); 171 | } 172 | }; 173 | 174 | // are there files to upload? 175 | var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) 176 | var hasFileInputs = fileInputs.length > 0; 177 | var mp = 'multipart/form-data'; 178 | var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); 179 | 180 | var fileAPI = feature.fileapi && feature.formdata; 181 | log("fileAPI :" + fileAPI); 182 | var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; 183 | 184 | // options.iframe allows user to force iframe mode 185 | // 06-NOV-09: now defaulting to iframe mode if file input is detected 186 | if (options.iframe !== false && (options.iframe || shouldUseFrame)) { 187 | // hack to fix Safari hang (thanks to Tim Molendijk for this) 188 | // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d 189 | if (options.closeKeepAlive) { 190 | $.get(options.closeKeepAlive, function() { 191 | fileUploadIframe(a); 192 | }); 193 | } 194 | else { 195 | fileUploadIframe(a); 196 | } 197 | } 198 | else if ((hasFileInputs || multipart) && fileAPI) { 199 | fileUploadXhr(a); 200 | } 201 | else { 202 | $.ajax(options); 203 | } 204 | 205 | // clear element array 206 | for (var k=0; k < elements.length; k++) 207 | elements[k] = null; 208 | 209 | // fire 'notify' event 210 | this.trigger('form-submit-notify', [this, options]); 211 | return this; 212 | 213 | // utility fn for deep serialization 214 | function deepSerialize(extraData){ 215 | var serialized = $.param(extraData).split('&'); 216 | var len = serialized.length; 217 | var result = {}; 218 | var i, part; 219 | for (i=0; i < len; i++) { 220 | part = serialized[i].split('='); 221 | result[decodeURIComponent(part[0])] = decodeURIComponent(part[1]); 222 | } 223 | return result; 224 | } 225 | 226 | // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) 227 | function fileUploadXhr(a) { 228 | var formdata = new FormData(); 229 | 230 | for (var i=0; i < a.length; i++) { 231 | formdata.append(a[i].name, a[i].value); 232 | } 233 | 234 | if (options.extraData) { 235 | var serializedData = deepSerialize(options.extraData); 236 | for (var p in serializedData) 237 | if (serializedData.hasOwnProperty(p)) 238 | formdata.append(p, serializedData[p]); 239 | } 240 | 241 | options.data = null; 242 | 243 | var s = $.extend(true, {}, $.ajaxSettings, options, { 244 | contentType: false, 245 | processData: false, 246 | cache: false, 247 | type: 'POST' 248 | }); 249 | 250 | if (options.uploadProgress) { 251 | // workaround because jqXHR does not expose upload property 252 | s.xhr = function() { 253 | var xhr = jQuery.ajaxSettings.xhr(); 254 | if (xhr.upload) { 255 | xhr.upload.onprogress = function(event) { 256 | var percent = 0; 257 | var position = event.loaded || event.position; /*event.position is deprecated*/ 258 | var total = event.total; 259 | if (event.lengthComputable) { 260 | percent = Math.ceil(position / total * 100); 261 | } 262 | options.uploadProgress(event, position, total, percent); 263 | }; 264 | } 265 | return xhr; 266 | }; 267 | } 268 | 269 | s.data = null; 270 | var beforeSend = s.beforeSend; 271 | s.beforeSend = function(xhr, o) { 272 | o.data = formdata; 273 | if(beforeSend) 274 | beforeSend.call(this, xhr, o); 275 | }; 276 | $.ajax(s); 277 | } 278 | 279 | // private function for handling file uploads (hat tip to YAHOO!) 280 | function fileUploadIframe(a) { 281 | var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; 282 | var useProp = !!$.fn.prop; 283 | 284 | if ($(':input[name=submit],:input[id=submit]', form).length) { 285 | // if there is an input with a name or id of 'submit' then we won't be 286 | // able to invoke the submit fn on the form (at least not x-browser) 287 | alert('Error: Form elements must not have name or id of "submit".'); 288 | return; 289 | } 290 | 291 | if (a) { 292 | // ensure that every serialized input is still enabled 293 | for (i=0; i < elements.length; i++) { 294 | el = $(elements[i]); 295 | if ( useProp ) 296 | el.prop('disabled', false); 297 | else 298 | el.removeAttr('disabled'); 299 | } 300 | } 301 | 302 | s = $.extend(true, {}, $.ajaxSettings, options); 303 | s.context = s.context || s; 304 | id = 'jqFormIO' + (new Date().getTime()); 305 | if (s.iframeTarget) { 306 | $io = $(s.iframeTarget); 307 | n = $io.attr('name'); 308 | if (!n) 309 | $io.attr('name', id); 310 | else 311 | id = n; 312 | } 313 | else { 314 | $io = $('