Lavalair How Can User Edit Their Own Posts

Started on the old forum in November 2008 · view the original in the archive · old links redirect here

40 replies · 2,322 views · started 18 years ago · 1 min read

TL;DR · summary of 40 replies
  • - The fix was found by removing the ismod function, allowing all users to edit their own posts.
  • - A solution was proposed to create a custom BB code that includes the session ID in the URL instead of hardcoding it directly into links, enhancing security without requiring extensive modifications to the script.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

5 participants
monk77 Junior · 30 posts #1

Hi Guys,

I have a very trivial problem. I want, that my users can edit their own posts. In Lavalair is this by default not possible. Only mods can edit posts. I found in index.php this code, which must be edited.

Here ist the code (index.php): CODEif(ismod(getuid_sid($sid))) { echo " title: "; echo "<form action="modproc.php?action=rentpc&sid=$sid&tid=$tid" method="post">"; echo "<input name="tname" value="$tname" maxlength="250"/>"; echo " <input type="Submit" Name="Rename" Value="edit"></form>"; echo " message: "; echo "<form action="modproc.php?action=edttpc&sid=$sid&tid=$tid" method="post">"; echo "<input name="ttext" value="$ttext" maxlength="5000"/>"; echo " <input type="Submit" Name="Edit" Value="edit"></form>";

Can someone help me. I'm only a php-learner, not pro.Thanks

ionutxp Developer · 137 posts #3

if u remove ismod .... all users can edit this post

Hate romains that take codes from here and tell to all that they had made that External image (may be gone)

monk77 Junior · 30 posts #5

QUOTE (learner @ Nov 24 2008, 05:47 AM) <{POST_SNAPBACK}>

remove ismod simple 🤔

No, that's no good. If I do that, a user can edit every post in my community. I want to give my users a way to edit their own posts, not the posts of others members. 🙄

learner

Can you give me an example for a function like that?

monk77 Junior · 30 posts #6

I try something like that, but it doesn't work.

index.php

$trnick = getnick_uid($trid);
  echo "[b]1 [/b]<a accesskey=\"1\" href=\"inbox.php?action=sendpm&sid=$sid&who=$trid\">»PM an $trnick senden</a>
";
  echo "[b]2 [/b]<a accesskey=\"2\" href=\"index.php?action=viewuser&sid=$sid&who=$trid\">»Betrachte $trnick's Profil</a>
";
  //echo "[b]3 [/b]<a accesskey=\"3\" href=\"index.php?action=post&sid=$sid&tid=$tid&qut=$pid\">»Quote</a>
";
  echo "[b]4 [/b]<a accesskey=\"4\" href=\"genproc.php?action=rpost&sid=$sid&pid=$pid\">»Melden</a>
";
  echo "[b]5 [/b]<a accesskey=\"5\" href=\"index.php?action=viewtpc&sid=$sid&tid=$tid&page=$page\">«zum Thema</a>
";
  if(ismod(getuid_sid($sid)))
  {
    echo "
Text: ";
    echo "<form action=\"modproc.php?action=edtpst&sid=$sid&pid=$pid\" method=\"post\">";
    echo "<textarea name=\"ptext\" maxlength=\"5000\" style=\"background:#fff;border-color:#c9c9c9;border-width:1px;border-style:solid;width:600px;height:350px;\">$ptext</textarea>";
    echo "
<input type=\"Submit\" Value=\"Editieren\" name=\"Edit\"></form>";

echo "
[b]6 [/b]<a accesskey=\"6\" href=\"modproc.php?action=delp&sid=$sid&pid=$pid\">»Entfernen</a>
";
  }
  else if(author(getuid_pid($pid)) == uid(getuid_sid($sid)))
  {
      echo "
Text: ";
    echo "<form action=\"modproc.php?action=edtpst&sid=$sid&pid=$pid\" method=\"post\">";
    echo "<textarea name=\"ptext\" maxlength=\"5000\" style=\"background:#fff;border-color:#c9c9c9;border-width:1px;border-style:solid;width:600px;height:350px;\">$ptext</textarea>";
    echo "
<input type=\"Submit\" Value=\"Editieren\" name=\"Edit\"></form>";
  }
something else Fellow · 2,296 posts #7
else if($trid ==$uid){
echo "
Text: ";
    echo "<form action=\"genproc.php?action=edtpst&sid=$sid&pid=$pid\" method=\"post\">";
    echo "<textarea name=\"ptext\" maxlength=\"5000\" style=\"background:#fff;border-color:#c9c9c9;border-width:1px;border-style:solid;width:600px;height:350px;\">$ptext</textarea>";
    echo "
<input type=\"Submit\" Value=\"Editieren\" name=\"Edit\"></form>";
  }
monk77 Junior · 30 posts #8

QUOTE (inca @ Nov 24 2008, 04:21 PM) <{POST_SNAPBACK}>

else if($trid ==$uid){
echo "
Text: ";
    echo "<form action=\"genproc.php?action=edtpst&sid=$sid&pid=$pid\" method=\"post\">";
    echo "<textarea name=\"ptext\" maxlength=\"5000\" style=\"background:#fff;border-color:#c9c9c9;border-width:1px;border-style:solid;width:600px;height:350px;\">$ptext</textarea>";
    echo "
<input type=\"Submit\" Value=\"Editieren\" name=\"Edit\"></form>";
  }

Thanks Inca. Now it works. As a simple Member the post can be edited. But now I have another problem. After I submit my edited posted, I get a "Permission Denied". The Problem ist modproc.php

modproc.php

<?php
header("Cache-Control: no-cache, must-revalidate");            // Prevent caching, HTTP/1.1
header("Pragma: no-cache");
//header('Content-type: application/vnd.wap.xhtml+xml'); 
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\" \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<?php
include("config.php");
include("core.php");
connectdb();
$action = $_GET["action"];
$sid = $_GET["sid"];
$uid = getuid_sid($sid);
$theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'"));
$sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'"));
$sitename = $sitename[0];

if(!ismod(getuid_sid($sid)))
{
  echo "<head>";
  echo "<title>Error!!!</title>";
  echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
  echo "</head>";
  echo "<body>";
  echo "<p align=\"center\">";
  echo "[b]Permission Denied![/b]
";
  echo "
Only mod/admin can use this page...
";
  echo "<a href=\"index.php\">Home</a>";
  echo "</p>";
  echo "</body>";
  echo "</html>";
  exit();
}
something else Fellow · 2,296 posts #9

thats why i changed it genproc.php (see my above post) 😛 just copy the script over and make sure script is safe in the same way so only the user who posted it can edit it 🙂

metulj Super moderator Principal · 1,726 posts #10

CODE //////////////////////////////////View Topic

else if($action=="viewtpc")

{ $tid = $_GET["tid"]; $go = $_GET["go"];

$tinfo = mysql_fetch_array(mysql_query("SELECT name, text, authorid, crdate, views, fid, pollid from ibwf_topics WHERE id='".$tid."'")); $tnm = htmlspecialchars($tinfo[0]);

addonline(getuid_sid($sid),"Viewing Topic->$tnm","");

$tfid = mysql_fetch_array(mysql_query("SELECT fid FROM ibwf_topics WHERE id='".$tid."'")); if(!canaccess(getuid_sid($sid), $tfid[0])) { echo "<card id="main" title="nicechat">"; echo " "; echo "You Don't Have A Permission To View The Contents Of This Forum

"; echo "<a href="index.php?action=main&sid=$sid">Home</a>"; echo " "; echo "</card>"; echo "</wml>"; exit(); }

$tinfo = mysql_fetch_array(mysql_query("SELECT name, text, authorid, crdate, views, fid, pollid from ibwf_topics WHERE id='".$tid."'"));
$tnm = htmlspecialchars($tinfo[0]);
echo "<card id=\"main\" title=\"$tnm\">";
echo "

"; $num_pages = getnumpages($tid); if($page==""||$page<1)$page=1; if($go!="")$page=getpage_go($go,$tid); $posts_per_page = 5; if($page>$num_pages)$page=$num_pages; $limit_start = $posts_per_page *($page-1); echo "<a href="index.php?action=post&sid=$sid&tid=$tid">Post reply</a>"; $lastlink = "<a href="index.php?action=$action&tid=$tid&sid=$sid&go=last">Last Page</a>"; $firstlink = "<a href="index.php?action=$action&tid=$tid&sid=$sid&page=1">First Page</a> "; $golink = ""; if($page>1) { $golink = $firstlink; } if($page<$num_pages) { $golink .= $lastlink; } if($golink !="") { echo " $golink"; } echo " "; echo "

"; $vws = $tinfo[4]+1; $rpls = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_posts WHERE tid='".$tid."'")); echo "Replies: $rpls[0] - Views: $vws "; ///fm here

if($page==1)
{
  $posts_per_page=4;
  mysql_query("UPDATE ibwf_topics SET views='".$vws."' WHERE  id='".$tid."'");
  $ttext = mysql_fetch_array(mysql_query("SELECT authorid, text, crdate, pollid FROM ibwf_topics WHERE id='".$tid."'"));
  $unick = getnick_uid($ttext[0]);
  if(isonline($ttext[0]))
{
  $iml = "<img src=\"images/onl.gif\" alt=\"+\"/>";
}else{
	$iml = "<img src=\"images/ofl.gif\" alt=\"-\"/>";
}
$usl = "

<a href="index.php?action=viewuser&sid=$sid&who=$ttext[0]">$iml$unick</a>"; $topt = "<a href="index.php?action=tpcopt&sid=$sid&tid=$tid"></a>"; if($go==$tid) { $fli = "<img src="images/flag.gif" alt="!"/>"; }else{ $fli =""; } $pst = parsemsg($ttext[1],$sid); echo "$usl: $fli$pst $topt "; $dtot = date("d-m-y - H:i:s",$ttext[2]); echo $dtot; echo " "; if($ttext[3]>0) { echo "<a href="index.php?action=viewtpl&sid=$sid&who=$tid">POLL</a> "; } } if($page>1) { $limit_start--; } $sql = "SELECT id, text, uid, dtpost, quote,tid FROM ibwf_posts WHERE tid='".$tid."' ORDER BY dtpost LIMIT $limit_start, $posts_per_page"; $posts = mysql_query($sql); while($post = mysql_fetch_array($posts)) { $unick = getnick_uid($post[2]); if(isonline($post[2])) { $iml = "<img src="images/onl.gif" alt="+"/>"; }else{ $iml = "<img src="images/ofl.gif" alt="-"/>"; } $usl = " <a href="index.php?action=viewuser&sid=$sid&who=$post[2]">$iml$unick</a>"; $pst = parsemsg($post[1], $sid); $topt = "<a href="index.php?action=pstopt&sid=$sid&pid=$post[0]&page=$page&fid=$tinfo[5]&tid=$post[5]"></a>"; if($post[4]>0) { $qtl = "<a href="index.php?action=viewtpc&sid=$sid&tid=$tid&pst=">(quote:p=blaze,d=16-04-2006)</a>"; } if($go==$post[0]) { $fli = "<img src="images/flag.gif" alt="!"/>"; }else{ $fli =""; } echo "$usl: $fli$pst $topt "; $dtot = date("d-m-y - H:i:s",$post[3]); echo $dtot; echo " "; } ///to here echo " "; echo " "; $tmsg = getpmcount(getuid_sid($sid)); $umsg = getunreadpm(getuid_sid($sid)); if($umsg>0) { echo "<a href="inbox.php?action=main&sid=$sid">Inbox($umsg/$tmsg)</a> "; } if($page>1) { $ppage = $page-1; echo "<a href="index.php?action=viewtpc&page=$ppage&sid=$sid&tid=$tid">«PREV</a> "; } if($page<$num_pages) { $npage = $page+1; echo "<a href="index.php?action=viewtpc&page=$npage&sid=$sid&tid=$tid">Next»</a>"; } echo " $page/$num_pages "; if($num_pages>2) { $rets = "Jump to page<input name="pg" format="*N" size="3"/>"; $rets .= "<anchor>[GO]"; $rets .= "<go href="index.php" method="get">"; $rets .= "<postfield name="action" value="$action"/>"; $rets .= "<postfield name="tid" value="$tid"/>"; $rets .= "<postfield name="sid" value="$sid"/>"; $rets .= "<postfield name="page" value="$(pg)"/>"; $rets .= "</go></anchor>";

	echo $rets;
}

echo " "; echo "<a href="index.php?action=post&sid=$sid&tid=$tid">Post reply</a>"; echo " "; echo "

"; $fid = $tinfo[5]; $fname = getfname($fid); $cid = mysql_fetch_array(mysql_query("SELECT cid FROM ibwf_forums WHERE id='".$fid."'")); $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_fcats WHERE id='".$cid[0]."'")); $cname = $cinfo[0];

echo "<a href=\"index.php?action=main&amp;sid=$sid\">";

echo "Home</a>>"; $cid = mysql_fetch_array(mysql_query("SELECT cid FROM ibwf_forums WHERE id='".$fid."'")); if($cid[0]>0) { $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_fcats WHERE id='".$cid[0]."'")); $cname = htmlspecialchars($cinfo[0]); echo "<a href="index.php?action=viewcat&sid=$sid&cid=$cid[0]">"; echo "$cname</a> "; }else{ $cid = mysql_fetch_array(mysql_query("SELECT clubid FROM ibwf_forums WHERE id='".$fid."'")); $cinfo = mysql_fetch_array(mysql_query("SELECT name FROM ibwf_clubs WHERE id='".$cid[0]."'")); $cname = htmlspecialchars($cinfo[0]); echo "<a href="index.php?action=gocl&sid=$sid&clid=$cid[0]">"; echo "$cname Club</a> "; } $fname = htmlspecialchars($fname); echo "><a href="index.php?action=viewfrm&sid=$sid&fid=$fid">$fname</a>>$tnm"; echo " "; echo "</card>";

//////////////////////////////////////////Post Options

else if($action=="pstopt") { $pid = $_GET["pid"]; $page = $_GET["page"]; $fid = $_GET["fid"]; $tid = $_GET["tid"]; addonline(getuid_sid($sid),"Post Options",""); $pinfo= mysql_fetch_array(mysql_query("SELECT uid,tid, text FROM ibwf_posts WHERE id='".$pid."'")); $trid = $pinfo[0]; $tid = $pinfo[1]; $ptext = htmlspecialchars($pinfo[2]); echo "<card id="main" title="nicechat">"; echo "<onevent type="onenterforward">"; echo "<refresh> <setvar name="ptext" value="$ptext"/>"; echo "</refresh></onevent>"; echo " "; echo "Post Options";

echo " "; echo "

"; $trnick = getnick_uid($trid); echo "<a href="inbox.php?action=sendpm&sid=$sid&who=$trid">»Send PM to $trnick</a> "; echo "<a href="index.php?action=viewuser&sid=$sid&who=$trid">»View $trnick's Profile</a> "; //echo "<a href="index.php?action=post&sid=$sid&tid=$tid&qut=$pid">»Quote</a> "; echo "<a href="genproc.php?action=rpost&sid=$sid&pid=$pid">»Report</a> "; echo "<a href="index.php?action=viewtpc&sid=$sid&tid=$tid&page=$page">«Back to topic</a> "; if(ismod(getuid_sid($sid))) { $tinfo= mysql_fetch_array(mysql_query("SELECT authorid FROM ibwf_topics WHERE id='".$tid."'")); if($uid==$tinfo[0]) { echo " Text: "; echo "<input name="ptext" value="$ptext" maxlength="500"/> "; echo " <anchor>Edit"; echo "<go href="modproc.php?action=edtpst&sid=$sid&pid=$pid" method="post">"; echo "<postfield name="ptext" value="$(ptext)"/>"; echo "</go>";

echo "</anchor>";

} echo " <a href="modproc.php?action=delp&sid=$sid&pid=$pid">»DELETE</a> "; } echo " "; echo " "; echo "<a href="index.php?action=main&sid=$sid"><img src="images/home.gif" alt="*"/>"; echo "Home</a>"; echo " "; echo "</card>"; }

credits for code goes to rukiya

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

monk77 Junior · 30 posts #11

QUOTE (inca @ Nov 24 2008, 07:08 PM) <{POST_SNAPBACK}>

thats why i changed it genproc.php (see my above post) 😛 just copy the script over and make sure script is safe in the same way so only the user who posted it can edit it :)

Thanks. Now it work great. 🙄

metulj Super moderator Principal · 1,726 posts #12

QUOTE (monk77 @ Nov 24 2008, 09:27 PM) <{POST_SNAPBACK}>

I have a big problem with lavalair wapdesire. A few minutes ago I want to test something: I created two testpersons "man" and "joker". I logged in with joker und make a post in forums. In this post I copy the whole browserlink (incl. the session-id) und submit my post. Then I logged out und logged in with man. After he clicked on that url in the post, that made by joker, man become joker. I could:

  1. edit all jokers post
  2. edit jokers profil
  3. could post as joker

and so on.

Is their a way to stop this?

Another example: If a logged in as admin und would post here in this forum a link of a post on my side, everyone could klick on this link and would be directly admin of my side. I hope everyone can help me with this problem.

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

metulj Super moderator Principal · 1,726 posts #13

QUOTE (inca @ Nov 24 2008, 09:45 PM) <{POST_SNAPBACK}>

you either didnt log out properly as joker or your logout page isnt working properly and didnt delete session id :)

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

metulj Super moderator Principal · 1,726 posts #14

monk77 please use the right topic for your querys

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

something else Fellow · 2,296 posts #15

or if you want to protect against peple giving there session id you could change your url bb code in core.php to something like this

if(substr_count($text,"sid=")>0){
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","This Type of Link Is Banned!",$text);
}else{
$text = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/is","<a href=\"$1\">$2</a>",$text);
}

🙂

something else Fellow · 2,296 posts #16

or maybee the simpler way would be to just to add

$text = str_replace("sid=","penguins gonna get you",$text);
monk77 Junior · 30 posts #17

thanks Inca. I will try it soon. But there is no other way to hide the session-ID? A want to run lavalair as community-board with a lot of members on my own server. Now I'm in trouble with this security lag. Other boards hide this id from url. Is there no way. I love lavalair. It's has by default a nice bridge from wap to web and from web to wap. But this problem makes me headache.;-)

something else Fellow · 2,296 posts #18

unless you use cookies but not all phones support cookies 🙁

monk77 Junior · 30 posts #19

QUOTE (inca @ Nov 24 2008, 10:48 PM) <{POST_SNAPBACK}>

unless you use cookies but not all phones support cookies :(

Is it hard work to edit my script, so does it works with cookies?

something else Fellow · 2,296 posts #20

yeah whole script would need editing i take it you want to link anywhere into your site and not give your session id away?

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close