changeset 756:a4523e15dfd6 feature-world

s/annex/world/
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 06 Jun 2020 11:43:42 +0900
parents 1a8291d7fa3d
children 2d45b0478d45
files examples/common/default/default.css s4-annex.sh s4-funcs.sh s4-world.sh
diffstat 4 files changed, 77 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/examples/common/default/default.css	Sat Jun 06 11:21:01 2020 +0900
+++ b/examples/common/default/default.css	Sat Jun 06 11:43:42 2020 +0900
@@ -343,8 +343,6 @@
 li.casmenu:hover div, li.casmenu:active div,
 li.casmenu div:hover, li.casmenu div:active
 {display: block;}
- 
-
 
 /*
  * PR Web
--- a/s4-annex.sh	Sat Jun 06 11:21:01 2020 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-if [ -z "$S4MASTERDB" -o ! -s "$S4MASTERDB" ]; then
-  return
-fi
-if [ "$db" -ef "$S4MASTERDB" ]; then
-  return		# Points to the same file
-fi
-
-# Now S4ANNEX mode is ACTIVE
-# sessdb=`dirname $S4MASTERDB`/sess.sq3
-## skey="skey-`basename $mydir`"
-S4NAME="[$S4WORLD]$S4NAME"
-syncflag=${db%.*}.synctime
-userupdateflag=`dirname $S4MASTERDB`/`basename $userupdateflag`
-test ! -e "$userupdateflag"		&& return
-test "$syncflag" -nt "$userupdateflag"	&& return
-
-#  for sub.sq3
-# 
-#  main: user: 'taro', 'hanako', 'shige'
-#  sub:  user: 'taro', 'hanako', 'shige'
-#  sub2: user_s: ('taro', 't'), ('hanako', 'h'), ('shige', 's')
-#  then update
-# 
-
-## sqlite3 -cmd '.timer 1' -cmd '.echo 1' $db <<EOF
-err "Starting account synchronization"
-err "db=$db mas=$S4MASTERDB sessdb=$sessdb"
-num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF
-ATTACH DATABASE "$S4MASTERDB" AS m;
-CREATE TABLE IF NOT EXISTS user(name, primary key(name));
-BEGIN;
-DElETE FROM main.user WHERE rowid NOT IN (SELECT rowid FROM m.user);
-INSERT INTO main.user(rowid, name)
-       SELECT rowid, name FROM m.user
-       WHERE m.user.rowid NOT IN (SELECT rowid FROM user);
-UPDATE user SET name = (SELECT name FROM m.user WHERE main.user.rowid=m.user.rowid);
-DELETE FROM main.user_s WHERE rowid NOT IN (SELECT rowid FROM m.user_s);
-REPLACE INTO main.user_s(rowid, name, key, type, val, bin)
-	SELECT rowid,* FROM m.user_s;
-DELETE FROM main.user_m WHERE rowid NOT IN (SELECT rowid FROM m.user_m);
-REPLACE INTO main.user_m(rowid, name, key, type, val, bin)
-	SELECT rowid,* FROM m.user_m
-	WHERE key NOT LIKE '%cache%';
-END;
-
-/* Compare user tables */
-WITH master AS (
-  SELECT p.rowid,* FROM m.user p
-  	 NATURAL LEFT JOIN m.user_s
-	 NATURAL LEFT JOIN m.user_m
-), annex AS (
-  SELECT p.rowid,* FROM user p
-  	 NATURAL LEFT JOIN user_s
- 	 NATURAL LEFT JOIN user_m
-), m_a AS (
-  SELECT * FROM master EXCEPT SELECT * FROM annex
-), a_m AS (
-  SELECT * FROM annex EXCEPT SELECT * FROM master
-) SELECT (SELECT count(*) FROM m_a) + (SELECT count(*) FROM a_m);
-
--- SELECT * FROM annex;
--- SELECT rowid,* FROM m.user LIMIT 10;
--- SELECT rowid,* FROM user WHERE rowid NOT IN (SELECT rowid FROM m.user);
-DETACH DATABASE m;
-EOF
-)
-if [ $num -eq 0 ]; then
-  touch $syncflag
-fi
-return $num
--- a/s4-funcs.sh	Sat Jun 06 11:21:01 2020 +0900
+++ b/s4-funcs.sh	Sat Jun 06 11:43:42 2020 +0900
@@ -87,10 +87,9 @@
   *)				touchpanel="" ;;
 esac
 
-# If S4MASTERDB is set, behave as ANNEX s4
+# If S4MASTERDB is set, behave in another world
 if [ -n "$S4MASTERDB" -a -s "$S4MASTERDB" ]; then
-  # $S4ANNEX is set after s4-annex setup
-  . ./s4-annex.sh 2>> tmp/debug.out
+  . ./s4-world.sh 2>> tmp/debug.out
 fi
 v=""
 for i in $S4WORLDS; do
@@ -1238,10 +1237,10 @@
   for kv in `echo $HTTP_COOKIE|sed 's/[;, ]/ /g'`; do
     k="${kv%%=*}"
     v="`echo ${kv#*=}|nkf -Ww -mQ|sed -e 's/\"/\"\"/g'`"
-err "GetCookie: $k=[$v]"
+    ## err "GetCookie: $k=[$v]"
     case "$k" in
       user)	_user="$v" ;;
-      skey)	_skey="$v"; k=skey ;;
+      skey)	_skey="$v" ;;
     esac
     query "replace into cookie values('$session', '$k', 'string', \"$v\");"
   done
@@ -1348,7 +1347,7 @@
   # $1=passwd
   dbpswd=`getpwfield $user pswd`
   encpswd=`mycrypt "$1" "$dbpswd"`
-  # err user=$user, pswd=$1, db=$dbpswd, enc=$encpswd
+  ## err user=$user, pswd=$1, db=$dbpswd, enc=$encpswd
   [ x"$dbpswd" = x"$encpswd" ]
 }
 mypwhash() {
@@ -1401,7 +1400,6 @@
     newsession=`genrandom 34`
     if setskey "$user" "$newsession" &&
 	dbsetbyid user "$user" login "`date '+%F %T'`"; then
-      # err gencookie "user=$user" "skey=$newsession"
       gencookie "user=$user" "skey=$newsession"
       return 0
     else
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/s4-world.sh	Sat Jun 06 11:43:42 2020 +0900
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+if [ -z "$S4MASTERDB" -o ! -s "$S4MASTERDB" ]; then
+  return
+fi
+if [ "$db" -ef "$S4MASTERDB" ]; then
+  return		# Points to the same file
+fi
+
+# Now Another world is ACTIVE
+# sessdb=`dirname $S4MASTERDB`/sess.sq3
+## skey="skey-`basename $mydir`"
+S4NAME="[$S4WORLD]$S4NAME"
+syncflag=${db%.*}.synctime
+userupdateflag=`dirname $S4MASTERDB`/`basename $userupdateflag`
+test ! -e "$userupdateflag"		&& return
+test "$syncflag" -nt "$userupdateflag"	&& return
+
+#  for sub.sq3
+# 
+#  main: user: 'taro', 'hanako', 'shige'
+#  sub:  user: 'taro', 'hanako', 'shige'
+#  sub2: user_s: ('taro', 't'), ('hanako', 'h'), ('shige', 's')
+#  then update
+# 
+
+## sqlite3 -cmd '.timer 1' -cmd '.echo 1' $db <<EOF
+err "Starting account synchronization"
+err "db=$db mas=$S4MASTERDB sessdb=$sessdb"
+num=$(sqlite3 -bail -cmd 'PRAGMA FOREIGN_KEYS=on' $db <<EOF
+ATTACH DATABASE "$S4MASTERDB" AS m;
+CREATE TABLE IF NOT EXISTS user(name, primary key(name));
+BEGIN;
+DElETE FROM main.user WHERE rowid NOT IN (SELECT rowid FROM m.user);
+INSERT INTO main.user(rowid, name)
+       SELECT rowid, name FROM m.user
+       WHERE m.user.rowid NOT IN (SELECT rowid FROM user);
+UPDATE user SET name = (SELECT name FROM m.user WHERE main.user.rowid=m.user.rowid);
+DELETE FROM main.user_s WHERE rowid NOT IN (SELECT rowid FROM m.user_s);
+REPLACE INTO main.user_s(rowid, name, key, type, val, bin)
+	SELECT rowid,* FROM m.user_s;
+DELETE FROM main.user_m WHERE rowid NOT IN (SELECT rowid FROM m.user_m);
+REPLACE INTO main.user_m(rowid, name, key, type, val, bin)
+	SELECT rowid,* FROM m.user_m
+	WHERE key NOT LIKE '%cache%';
+END;
+
+/* Compare user tables */
+WITH master AS (
+  SELECT p.rowid,* FROM m.user p
+  	 NATURAL LEFT JOIN m.user_s
+	 NATURAL LEFT JOIN m.user_m
+), thisworld AS (
+  SELECT p.rowid,* FROM user p
+  	 NATURAL LEFT JOIN user_s
+ 	 NATURAL LEFT JOIN user_m
+), m_a AS (
+  SELECT * FROM master EXCEPT SELECT * FROM thisworld
+), a_m AS (
+  SELECT * FROM thisworld EXCEPT SELECT * FROM master
+) SELECT (SELECT count(*) FROM m_a) + (SELECT count(*) FROM a_m);
+
+-- SELECT * FROM thisworld;
+-- SELECT rowid,* FROM m.user LIMIT 10;
+-- SELECT rowid,* FROM user WHERE rowid NOT IN (SELECT rowid FROM m.user);
+DETACH DATABASE m;
+EOF
+)
+if [ $num -eq 0 ]; then
+  touch $syncflag
+fi
+return $num

yatex.org