Eliminare tip abstime deprecated din PostgreSQL - Inlocuire now()::abstime::int4 cu EXTRACT(EPOCH FROM now())::int4 in toate fisierele - Compatibilitate PostgreSQL 12+ - Reparat Manager1K.sh, appjudge, cservice-1.5.0.sql, sqlFakeClient.cc, manual.html, index.php si toate scripturile SQL de update
This commit is contained in:
1 parent
a479baf68a
commit
28496ecbf8
11 files changed
+85
-85
No files matched your search
@@ -10,7 +10,7 @@ DBHOST="127.0.0.1"
|
||||
|
||||
# default information to put in the db for those .., DO NOT USE a BLANK 'LASTMODIF', use "0".
|
||||
LASTMODIFBY=`basename $0`
|
||||
LASTMODIF="now()::abstime::int4"
|
||||
LASTMODIF="EXTRACT(EPOCH FROM now())::int4"
|
||||
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ if [ "$REP1" == "C" ]; then
|
||||
echo "--> SALT : [$GENSALT]"
|
||||
|
||||
echo "--> Adding user '$FORCEUSERNAME'..."
|
||||
DAQRY="INSERT INTO users (user_name,password,email,url,question_id,verificationdata,language_id,public_key,last_updated_by,last_updated,signup_cookie,signup_ip,tz_setting) VALUES ('$FORCEUSERNAME','$ENCPASS','$UEMAIL','',$UQID,'$UVA',1,'','$LASTMODIFBY',now()::abstime::int4,'Added from the console','127.0.0.1','')"
|
||||
DAQRY="INSERT INTO users (user_name,password,email,url,question_id,verificationdata,language_id,public_key,last_updated_by,last_updated,signup_cookie,signup_ip,tz_setting) VALUES ('$FORCEUSERNAME','$ENCPASS','$UEMAIL','',$UQID,'$UVA',1,'','$LASTMODIFBY',EXTRACT(EPOCH FROM now())::int4,'Added from the console','127.0.0.1','')"
|
||||
echo "--> DB: `echo -n \"$DAQRY\" | $PSQLCMD -h $DBHOST $DBNAME`"
|
||||
FROMC="1"
|
||||
REP1="M"
|
||||
@@ -312,9 +312,9 @@ if [ "$REP1" == "M" ]; then
|
||||
echo "--> NOTICE: We will be running what should be at this moment just like if you ran 'cservice.addme.sql'"
|
||||
echo "--> NOTICE: You will NOT need to run 'cservice.addme.sql' anymore, so don't run it ;P"
|
||||
|
||||
ADDADMCHAN="INSERT into channels (name,flags,channel_ts,registered_ts,last_updated) VALUES ('*',1,now()::abstime::int4,31337,now()::abstime::int4)"
|
||||
ADDCODERCHAN="INSERT into channels (name,flags,channel_ts,registered_ts,last_updated) VALUES ('#coder-com',1,now()::abstime::int4,31337,now()::abstime::int4)"
|
||||
ADDCODERACCESS="INSERT into levels (channel_id,user_id,access,added_by,added,last_modif_by,last_modif,last_updated) VALUES (2,1,500,'$LASTMODIFBY',$LASTMODIF,'$LASTMODIFBY',$LASTMODIF,now()::abstime::int4)"
|
||||
ADDADMCHAN="INSERT into channels (name,flags,channel_ts,registered_ts,last_updated) VALUES ('*',1,EXTRACT(EPOCH FROM now())::int4,31337,EXTRACT(EPOCH FROM now())::int4)"
|
||||
ADDCODERCHAN="INSERT into channels (name,flags,channel_ts,registered_ts,last_updated) VALUES ('#coder-com',1,EXTRACT(EPOCH FROM now())::int4,31337,EXTRACT(EPOCH FROM now())::int4)"
|
||||
ADDCODERACCESS="INSERT into levels (channel_id,user_id,access,added_by,added,last_modif_by,last_modif,last_updated) VALUES (2,1,500,'$LASTMODIFBY',$LASTMODIF,'$LASTMODIFBY',$LASTMODIF,EXTRACT(EPOCH FROM now())::int4)"
|
||||
|
||||
echo "--> Inserting ADMIN (*) channel..."
|
||||
echo "--> DB: `echo -n \"$ADDADMCHAN\" | $PSQLCMD -h $DBHOST $DBNAME`"
|
||||
@@ -337,16 +337,16 @@ if [ "$REP1" == "M" ]; then
|
||||
|
||||
if [ "$ADMINLVL" == "1000" ]; then
|
||||
echo "--> Modifying ADMIN access from $ADMINLVL to 999..."
|
||||
DAQRY="UPDATE levels SET access=999,last_modif_by='$LASTMODIFBY',last_modif=$LASTMODIF,last_updated=now()::abstime::int4 WHERE channel_id=1 AND user_id=$USRID AND access=$ADMINLVL"
|
||||
DAQRY="UPDATE levels SET access=999,last_modif_by='$LASTMODIFBY',last_modif=$LASTMODIF,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=1 AND user_id=$USRID AND access=$ADMINLVL"
|
||||
echo "--> DB: `echo -n \"$DAQRY\" | $PSQLCMD -h $DBHOST $DBNAME`"
|
||||
else
|
||||
if [ "$ADMINLVL" == "(0" ]; then
|
||||
echo "--> Adding ADMIN access at level 1000..."
|
||||
DAQRY="INSERT INTO levels (channel_id,user_id,access,added_by,added,last_modif_by,last_modif,last_updated) VALUES (1,$USRID,1000,'$LASTMODIFBY',$LASTMODIF,'$LASTMODIFBY',$LASTMODIF,now()::abstime::int4)"
|
||||
DAQRY="INSERT INTO levels (channel_id,user_id,access,added_by,added,last_modif_by,last_modif,last_updated) VALUES (1,$USRID,1000,'$LASTMODIFBY',$LASTMODIF,'$LASTMODIFBY',$LASTMODIF,EXTRACT(EPOCH FROM now())::int4)"
|
||||
echo "--> DB: `echo -n \"$DAQRY\" | $PSQLCMD -h $DBHOST $DBNAME`"
|
||||
else
|
||||
echo "--> Modifying ADMIN access from $ADMINLVL to 1000..."
|
||||
DAQRY="UPDATE levels SET access=1000,last_modif_by='$LASTMODIFBY',last_modif=$LASTMODIF,last_updated=now()::abstime::int4 WHERE channel_id=1 AND user_id=$USRID AND access=$ADMINLVL"
|
||||
DAQRY="UPDATE levels SET access=1000,last_modif_by='$LASTMODIFBY',last_modif=$LASTMODIF,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=1 AND user_id=$USRID AND access=$ADMINLVL"
|
||||
echo "--> DB: `echo -n \"$DAQRY\" | $PSQLCMD -h $DBHOST $DBNAME`"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -41,7 +41,7 @@ proc log_channel {hDB channel_id state areason acode} {
|
||||
}
|
||||
set sup_list [string trim $sup_list ", "]
|
||||
set log_msg "\[The Judge\]: Application ${state}. ${areason} Applicant: ${mgr_what}. Supporters: ${sup_list}."
|
||||
pg_exec $hDB "INSERT INTO channellog (ts,channelid,event,message,last_updated) VALUES(now()::abstime::int4,$channel_id,$acode,'\[The Judge\]: Application ${state}. ${areason} Applicant: ${mgr_what}. Supporters: ${sup_list}.',now()::abstime::int4)"
|
||||
pg_exec $hDB "INSERT INTO channellog (ts,channelid,event,message,last_updated) VALUES(EXTRACT(EPOCH FROM now())::int4,$channel_id,$acode,'\[The Judge\]: Application ${state}. ${areason} Applicant: ${mgr_what}. Supporters: ${sup_list}.',EXTRACT(EPOCH FROM now())::int4)"
|
||||
}
|
||||
|
||||
proc get_channel {hDB channel_id} {
|
||||
@@ -52,7 +52,7 @@ proc reject_app {hDB channel_id reason} {
|
||||
global AS_REJECTED REVIEWER_ID
|
||||
puts [format "%s: Rejecting application for channel %s: %s" [clock_stamp] [get_channel $hDB $channel_id] $reason]
|
||||
log_channel $hDB $channel_id "REJECTED" $reason 13
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_REJECTED, last_updated=now()::abstime::int4, reviewed_by_id=$REVIEWER_ID, decision_ts=now()::abstime::int4, decision='Rejected: $reason' WHERE channel_id=$channel_id"
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_REJECTED, last_updated=EXTRACT(EPOCH FROM now())::int4, reviewed_by_id=$REVIEWER_ID, decision_ts=EXTRACT(EPOCH FROM now())::int4, decision='Rejected: $reason' WHERE channel_id=$channel_id"
|
||||
# Need the associated userid
|
||||
pg_select $hDB "SELECT channel_id,manager_id FROM pending WHERE channel_id=$channel_id" res_ch {
|
||||
set notify_user [lindex [array get res_ch "manager_id"] 1]
|
||||
@@ -67,7 +67,7 @@ proc check_comments {hDB channel_id} {
|
||||
set objcount [lindex [array get res_obj "objcount"] 1]
|
||||
if {$objcount} {
|
||||
puts [format "%s: Moving channel %s to status %d (there are %d objections/comments)" [clock_stamp] [get_channel $hDB $channel_id] $AS_PENDREVIEW $objcount]
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=now()::abstime::int4 WHERE channel_id=$channel_id"
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$channel_id"
|
||||
set check_res 1
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ proc check_comments {hDB channel_id} {
|
||||
set comments [string trim [lindex [array get res_cmt "comments"] 1]]
|
||||
if {[string match "REVIEW:*" $comments]} {
|
||||
puts [format "%s: Moving channel %s to status %d (it was labeled for review)" [clock_stamp] [get_channel $hDB $channel_id] $AS_PENDREVIEW]
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW, last_updated=now()::abstime::int4 WHERE channel_id=$channel_id"
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW, last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$channel_id"
|
||||
set check_res 1
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,8 @@ proc check_fraudulous {hDB chan_id mgr_id} {
|
||||
if {$isfraud > 0} {
|
||||
# move it to 'Ready for review' if anyone is fraudulous
|
||||
puts [format "%s: Moving channel %s to status %d (%d fraudulent applicant/supporters found)" [clock_stamp] [get_channel $hDB $chan_id] $AS_PENDREVIEW $isfraud]
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
}
|
||||
pg_exec $hDB "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
}
|
||||
return $isfraud
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ puts [format "%s: The court is now in session." [clock_stamp]]
|
||||
|
||||
# Step 0.5: Reject applications that are still in status 0 after x days.
|
||||
set sup_timeout [expr $DAY * $SUPPORT_DAYS]
|
||||
pg_select $hSQL "SELECT channel_id,status,check_start_ts FROM pending WHERE (status = $AS_PENDING_SUPPORT) AND (now()::abstime::int4 > (created_ts + $sup_timeout))" sup_expired {
|
||||
pg_select $hSQL "SELECT channel_id,status,check_start_ts FROM pending WHERE (status = $AS_PENDING_SUPPORT) AND (EXTRACT(EPOCH FROM now())::int4 > (created_ts + $sup_timeout))" sup_expired {
|
||||
set chan_id [lindex [array get sup_expired "channel_id"] 1]
|
||||
reject_app $hSQL $chan_id "One or more of the supporters did not confirm their support."
|
||||
}
|
||||
@@ -153,7 +153,7 @@ pg_select $hSQL "SELECT channel_id,status,check_start_ts FROM pending WHERE (sta
|
||||
|
||||
# Step 1: reject applications that failed to pass the activity test within the required timeframe
|
||||
set app_timeout [expr $DAY * $MAX_DAYS]
|
||||
pg_select $hSQL "SELECT channel_id,status,check_start_ts,unique_join_count FROM pending WHERE (status = $AS_TRAFFIC_CHECK) AND (now()::abstime::int4 > (check_start_ts + $app_timeout))" t_expired {
|
||||
pg_select $hSQL "SELECT channel_id,status,check_start_ts,unique_join_count FROM pending WHERE (status = $AS_TRAFFIC_CHECK) AND (EXTRACT(EPOCH FROM now())::int4 > (check_start_ts + $app_timeout))" t_expired {
|
||||
set chan_id [lindex [array get t_expired "channel_id"] 1]
|
||||
set joins [lindex [array get t_expired "unique_join_count"] 1]
|
||||
|
||||
@@ -170,7 +170,7 @@ pg_select $hSQL "SELECT channel_id,status,check_start_ts,unique_join_count FROM
|
||||
# get supporter count
|
||||
pg_select $hSQL "SELECT COUNT(*) AS supcount FROM supporters WHERE channel_id=$chan_id" res_supc { set sup_joins [lindex [array get sup_res "supcount"] 1] }
|
||||
puts [format "%s: Moving channel %s to status %d (application labeled for human inspection)" [clock_stamp] [get_channel $hSQL $chan_id] $AS_NOTIFICATION]
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_NOTIFICATION,check_start_ts=now()::abstime::int4,comments='REVIEW: Only $sup_joins supporters have been seen.', last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_NOTIFICATION,check_start_ts=EXTRACT(EPOCH FROM now())::int4,comments='REVIEW: Only $sup_joins supporters have been seen.', last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
} else {
|
||||
# No - Reject
|
||||
reject_app $hSQL $chan_id "Not enough activity in the channel."
|
||||
@@ -188,14 +188,14 @@ pg_select $hSQL "SELECT channel_id,status FROM pending WHERE (status=$AS_TRAFFIC
|
||||
|
||||
if {$sup_joins >= $MIN_SUPPORTERS} {
|
||||
puts [format "%s: Moving channel %s to status %d (traffic check passed)" [clock_stamp] [get_channel $hSQL $chan_id] $AS_NOTIFICATION]
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_NOTIFICATION,check_start_ts=now()::abstime::int4,last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_NOTIFICATION,check_start_ts=EXTRACT(EPOCH FROM now())::int4,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
}
|
||||
}
|
||||
|
||||
# Step 3: check for end of notify period
|
||||
set notify_delay [expr $DAY * $NOTIFY_DAYS]
|
||||
|
||||
pg_select $hSQL "SELECT channel_id,status,manager_id,reviewed FROM pending WHERE (status = $AS_NOTIFICATION) AND ((check_start_ts + $notify_delay) < now()::abstime::int4)" t_notified {
|
||||
pg_select $hSQL "SELECT channel_id,status,manager_id,reviewed FROM pending WHERE (status = $AS_NOTIFICATION) AND ((check_start_ts + $notify_delay) < EXTRACT(EPOCH FROM now())::int4)" t_notified {
|
||||
set chan_id [lindex [array get t_notified "channel_id"] 1]
|
||||
set mgr_id [lindex [array get t_notified "manager_id"] 1]
|
||||
set reviewed [lindex [array get t_notified "reviewed"] 1]
|
||||
@@ -208,24 +208,24 @@ pg_select $hSQL "SELECT channel_id,status,manager_id,reviewed FROM pending WHERE
|
||||
# Register the channel
|
||||
log_channel $hSQL $chan_id "ACCEPTED" "All checks passed." 7
|
||||
puts [format "%s: Moving channel %s to status %d (notify period ended)" [clock_stamp] [get_channel $hSQL $chan_id] $AS_COMPLETED]
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_COMPLETED,reviewed_by_id=$REVIEWER_ID,decision_ts=now()::abstime::int4,decision='Accepted by The Judge', last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_COMPLETED,reviewed_by_id=$REVIEWER_ID,decision_ts=EXTRACT(EPOCH FROM now())::int4,decision='Accepted by The Judge', last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
puts [format "%s: Registering channel %s (all checks passed)" [clock_stamp] [get_channel $hSQL $chan_id]]
|
||||
pg_exec $hSQL "UPDATE channels SET registered_ts=now()::abstime::int4, last_updated = now()::abstime::int4 WHERE id=$chan_id"
|
||||
pg_exec $hSQL "INSERT INTO levels (channel_id,user_id,access,added,added_by,last_modif,last_modif_by,last_updated) VALUES($chan_id,$mgr_id,500,now()::abstime::int4,'The Judge',now()::abstime::int4,'The Judge',now()::abstime::int4)"
|
||||
pg_exec $hSQL "UPDATE channels SET registered_ts=EXTRACT(EPOCH FROM now())::int4, last_updated = EXTRACT(EPOCH FROM now())::int4 WHERE id=$chan_id"
|
||||
pg_exec $hSQL "INSERT INTO levels (channel_id,user_id,access,added,added_by,last_modif,last_modif_by,last_updated) VALUES($chan_id,$mgr_id,500,EXTRACT(EPOCH FROM now())::int4,'The Judge',EXTRACT(EPOCH FROM now())::int4,'The Judge',EXTRACT(EPOCH FROM now())::int4)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# No, label it for review if no one is suspended on it
|
||||
if {![check_suspended $hSQL $chan_id $mgr_id]} {
|
||||
puts [format "%s: Moving channel %s to status %d (it was never reviewed)" [clock_stamp] [get_channel $hSQL $chan_id] $AS_PENDREVIEW]
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Objections found, label it for review if no one is suspended on it ;)
|
||||
if {![check_suspended $hSQL $chan_id $mgr_id]} {
|
||||
puts [format "%s: Moving channel %s to status %d (it was never reviewed)" [clock_stamp] [get_channel $hSQL $chan_id] $AS_PENDREVIEW]
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=now()::abstime::int4 WHERE channel_id=$chan_id"
|
||||
pg_exec $hSQL "UPDATE pending SET status=$AS_PENDREVIEW,last_updated=EXTRACT(EPOCH FROM now())::int4 WHERE channel_id=$chan_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<html>
|
||||
<html>
|
||||
<!-- CMaster Channel Services Website. -->
|
||||
<!-- $Id: manual.html,v 1.3 2001/12/22 22:46:17 gte Exp $ -->
|
||||
|
||||
@@ -295,10 +295,10 @@ You can get info about other values in the conf file itself.<br>
|
||||
<br>
|
||||
<br>
|
||||
INSERT into users (user_name,password,language_id,last_updated)<br>
|
||||
VALUES ('the_user_name','07d976a29bdb3ff42e10c102852151b28097bbad',1,now()::abstime::int4);<br>
|
||||
VALUES ('the_user_name','07d976a29bdb3ff42e10c102852151b28097bbad',1,EXTRACT(EPOCH FROM now())::int4);<br>
|
||||
<br>
|
||||
INSERT into levels (channel_id,user_id,access,last_updated)<br>
|
||||
VALUES (1,the_user_id,1000,now()::abstime::int4);<br>
|
||||
VALUES (1,the_user_id,1000,EXTRACT(EPOCH FROM now())::int4);<br>
|
||||
<br>
|
||||
* the_user_name should be the username will be added with level 1000<br>
|
||||
<br>
|
||||
|
||||
Reference in new issue
Block a user