Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1000602 // update-comment.php

Document

1  
<?
2  
header("Content-type: text/plain");
3  
4  
include('../tb/tb.inc.php');
5  
6  
$username = $_REQUEST['user'];
7  
$password = $_REQUEST['pass'];
8  
$ip = $_SERVER['REMOTE_ADDR'];
9  
10  
$id = intval($_REQUEST['id']);
11  
$progid = intval($_REQUEST['progid']);
12  
$text = $_REQUEST['text'];
13  
14  
if ($username)
15  
  quicklogin($username, $password);
16  
17  
echo "user_id=$user_id\n";
18  
19  
if (!$id) die("Nothing to do.");
20  
if (!$progid) die("Need prog ID.");
21  
22  
$where = "c_snippetid=$id and c_programid=$progid";
23  
dbDo("start transaction");
24  
$oldText = dbSingleValue("select c_text from tb_comment where $where");
25  
if (!strcmp($oldText, $text)) die ("Text unchanged!");
26  
27  
# save old comment
28  
dbUpdate("insert into tb_comment_old
29  
  (c_snippetid, c_programid, c_author, c_modified, c_text)
30  
  select c_snippetid, c_programid, c_author, c_modified, c_text
31  
  from tb_comment where $where");
32  
33  
# delete
34  
dbDo("delete from tb_comment where $where");
35  
36  
# update
37  
$commentID = dbInsert("insert into tb_comment set
38  
  c_snippetid=$id,
39  
  c_programid=$progid,
40  
  c_clientip=".dbQuote($clientIP).",
41  
  c_created=now(),
42  
  c_modified=now(),
43  
  c_text=".dbQuote($text).",
44  
  c_author=$user_id");
45  
46  
dbDo("commit");
47  
48  
echo "Done. Comment ID: $commentID";
49  
50  
?>

Author comment

Actual PHP code from web site. (tb-int/...)

download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
278 #1000604 (pitcher) 2015-08-18 00:54:00
232 #1000610 (pitcher) Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
<?
header("Content-type: text/plain");

include('../tb/tb.inc.php');

$username = $_REQUEST['user'];
$password = $_REQUEST['pass'];
$ip = $_SERVER['REMOTE_ADDR'];

$id = intval($_REQUEST['id']);
$progid = intval($_REQUEST['progid']);
$text = $_REQUEST['text'];

if ($username)
quicklogin($username, $password);

echo "user_id=$user_id\n";

if (!$id) die("Nothing to do.");
if (!$progid) die("Need prog ID.");

$where = "c_snippetid=$id and c_programid=$progid";
dbDo("start transaction");
$oldText = dbSingleValue("select c_text from tb_comment where $where");
if (!strcmp($oldText, $text)) die ("Text unchanged!");

# save old comment
dbUpdate("insert into tb_comment_old
(c_snippetid, c_programid, c_author, c_modified, c_text)
select c_snippetid, c_programid, c_author, c_modified, c_text
from tb_comment where $where");

# delete
dbDo("delete from tb_comment where $where");

# update
$commentID = dbInsert("insert into tb_comment set
c_snippetid=$id,
c_programid=$progid,
c_clientip=".dbQuote($clientIP).",
c_created=now(),
c_modified=now(),
c_text=".dbQuote($text).",
c_author=$user_id");

dbDo("commit");

echo "Done. Comment ID: $commentID";

?>
}}
2015-08-18 00:52:14

add comment

Snippet ID: #1000602
Snippet name: update-comment.php
Eternal ID of this version: #1000602/1
Text MD5: 7bc579c1adbf886c74512a205fc3a35d
Author: stefan
Category:
Type: Document
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-15 23:49:12
Source code size: 1224 bytes / 50 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 937 / 170
Referenced in: [show references]