Changeset 383233
- Timestamp:
- 05/10/2011 02:48:52 PM (15 years ago)
- Location:
- mblog/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
mblog/trunk/BProc.php
r383035 r383233 1 1 <?php 2 2 error_reporting(E_ALL ^ E_NOTICE); 3 session_start(); 3 4 4 5 $fname = "wall.txt"; … … 34 35 $log = fopen($fname,"a+"); 35 36 $text = htmlspecialchars($_POST['msg']); 36 //avatar37 $new_avt = str_replace("\'","",$_COOKIE['avatar']);38 $new_avt = str_replace('alt=','',$new_avt);39 37 40 38 if (filesize($fname) > 0){ 41 $ftext = '|'.$_ POST['u'].':::'.$text.':::'.$new_avt;39 $ftext = '|'.$_SESSION['user'].':::'.$text.':::'.$_SESSION['avatar']; 42 40 } 43 41 else{ 44 $ftext = $_ POST['u'].':::'.$text.':::'.$new_avt;42 $ftext = $_SESSION['user'].':::'.$text.':::'.$_SESSION['avatar']; 45 43 } 46 44 fwrite($log, $ftext); 47 45 fclose($log); 48 echo $text; 46 $reply = array('Name'=>$_SESSION['user'],'Msg'=>$text,'Avt'=>$_SESSION['avatar']); 47 echo json_encode($reply); 49 48 } 50 49 … … 62 61 else $nrec[$i] = $rec[$i+1]; 63 62 } 64 file_put_contents($fname, $nrec);63 file_put_contents($fname, $nrec); 65 64 } 66 65 ?> -
mblog/trunk/mblog.js
r383035 r383233 6 6 type:"POST", 7 7 url:'wp-content/plugins/mblog/BProc.php', 8 data:'m=0 &msg=0&u=0',8 data:'m=0', 9 9 dataType: 'json', 10 10 success: function(rsp){ … … 22 22 var msg = $("#mblog-input").val(); 23 23 var uname = Get_Cookie('user'); 24 var avatar = Get_Cookie('avatar');25 avatar = avatar.replaceAll('+',' ');26 avatar = avatar.replaceAll('&','&');27 28 24 var entries = $('.mblog-entry').length; 29 25 $.ajax({ 30 26 type:"POST", 31 27 url:'wp-content/plugins/mblog/BProc.php', 32 data:'m=1&msg='+msg+'&u='+uname +'&a='+avatar,33 dataType: ' text',28 data:'m=1&msg='+msg+'&u='+uname, 29 dataType: 'json', 34 30 success: function(rsp){ 35 31 if (entries > 5){ 36 32 $('.mblog-entry').first().slideUp(800, function(){ $(this).remove();}); 37 33 } 38 $("#mblog-window").append('<div class="mblog-entry"><span class="mblog-avt">'+ avatar+'</span>'+'<p><span class="mblog-uname">'+uname+"</span>:"+rsp+'</p></div><div style="clear:both"></div>');34 $("#mblog-window").append('<div class="mblog-entry"><span class="mblog-avt">'+rsp.Avt+'</span>'+'<p><span class="mblog-uname">'+rsp.Name+"</span>:"+rsp.Msg+'</p></div><div style="clear:both"></div>'); 39 35 $("#mblog-input").val(""); 40 36 } … … 44 40 45 41 //Helper functions 46 47 String.prototype.replaceAll = function(stringToFind,stringToReplace){48 var temp = this;49 var index = temp.indexOf(stringToFind);50 while(index != -1){51 temp = temp.replace(stringToFind,stringToReplace);52 index = temp.indexOf(stringToFind);53 }54 return temp;55 }56 42 57 43 function Get_Cookie( check_name ) { -
mblog/trunk/mblog.php
r383035 r383233 4 4 Plugin URI: http://code.google.com/p/wordpress-mblog/ 5 5 Description: The microblog widget, that allows blog authors/contributors to cooperate. Can be made invisible to unregistered users. 6 Version:0.3 26 Version:0.35 7 7 Author:Nordvind 8 8 Author URI: www.arttupeka.eu … … 51 51 wp_enqueue_script('mblog',plugins_url().'/mblog/mblog.js',false,null); 52 52 } 53 54 53 } 55 54 … … 96 95 97 96 function load_mblog(){ 97 session_start(); 98 98 register_widget('mblog'); 99 99 … … 102 102 $avatar = get_avatar($current_user->ID,$size='30'); 103 103 setcookie("user",$current_user->display_name, time()+60); 104 setcookie("avatar",$avatar,time()+60); 104 $_SESSION['user'] = $current_user->display_name; 105 $_SESSION['avatar'] = $avatar; 105 106 106 107 $new_avt = str_replace("\'","",$_COOKIE['avatar']);108 $new_avt = str_replace('alt=','',$new_avt);109 107 } 110 108 … … 133 131 //Post form 134 132 if ($is_user){ 135 global $current_user;136 133 echo'<div id="mblog-window"></div>'; 137 134 -
mblog/trunk/readme.txt
r383038 r383233 5 5 Requires at least: 2.8 6 6 Tested up to: 3.1.2 7 Stable tag: 2.0 7 Stable tag: 2.0.1 8 8 9 9 A chatroom for blog authors … … 27 27 == Upgrade Notice == 28 28 29 = 0.35 = 30 31 Sessions used instead of cookies, for security and effectivity reasons. 32 29 33 = 0.32 = 30 34 … … 33 37 == Changelog == 34 38 39 = 0.35 = 40 41 Unnecessary code removed. Sessions used instead of cookies. 42 35 43 = 0.32 = 36 44
Note: See TracChangeset
for help on using the changeset viewer.