#
# MAIN
#
+declare -a nam
if [ "$1" = "chk" ]; then
set -e
oldifs="$IFS"
done
taggit="$(git describe --tags | sed 's/^v//g')"
- tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')"
+ tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')" # ' emacs hell
if [ "$taggit" != "$tagphp" ]; then
echo
echo "WARNING: taggit: [$taggit] tagphp: [$tagphp]"
# before all check errors on the sources
$0 chk || exit 3
-
if [ "$1" = "pkg" ]; then
if [ "$2" != "" ]; then
tag="$2"
else
tag="$(git describe)"
fi
- nam1="brisk_${tag}.tgz"
- nam2="brisk-img_${tag}.tgz"
- echo "Build packages ${nam1} and ${nam2}."
+ nam_idx=0
+ nam[$nam_idx]="brisk_${tag}.tgz"
+ nam_idx=$((nam_idx + 1))
+ nam[$nam_idx]="brisk-img_${tag}.tgz"
+
+ if [ -d ../curl-de-sac ]; then
+ nam_idx=$((nam_idx + 1))
+ nam[$nam_idx]="curl-de-sac_${tag}.tgz"
+ fi
+ pkg_list=""
+ sep=""
+ for i in ${nam[@]}; do
+ pkg_list="${pkg_list}${sep}${i}"
+ sep=", "
+ done
+ echo "Build packages ${pkg_list}."
read -p "Proceed [y/n]: " a
if [ "$a" != "y" -a "$a" != "Y" ]; then
exit 1
cd ../brisk-img
git archive --format=tar --prefix=brisk-${tag}/brisk-img/ $tag | gzip > ../$nam2
cd -
+ if [ -d ../curl-de-sac ]; then
+ cd ../curl-de-sac
+ git archive --format=tar --prefix=brisk-${tag}/curl-de-sac/ $tag | gzip > ../$nam3
+ cd -
+ fi
exit 0
fi
if [ -f "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
+ conffile_in="$CONFIG_FILE"
fi
if [ "x$prefix_path" = "x" ]; then
exit 1
fi
. "$conffile"
+ conffile_in="$conffile"
fi
shift $sh
done
fi
install -d ${web_path}__
-for i in $(find web -type d | sed 's/^....//g'); do
+for i in $(find web -type d | grep '/' | sed 's/^....//g'); do
install -d ${web_path}__/$i
done
document_root="$(grep DocumentRoot "${apache_conf}" | grep -v '^[ ]*#' | awk '{ print $2 }')"
sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}__/spush/*.ph*
-if [ -d ${web_path} ]; then
- mv ${web_path} ${web_path}.old
-fi
-
if [ -d ../brisk-img ]; then
cd ../brisk-img
./INSTALL.sh -w ${web_path}__
cd - >/dev/null 2>&1
fi
+if [ -d ../curl-de-sac ]; then
+ cd ../curl-de-sac
+ if [ ! -z "$conffile_in" ]; then
+ ./INSTALL.sh -f "$conffile_in" -w ${web_path}__
+ else
+ ./INSTALL.sh -w ${web_path}__
+ fi
+ cd - >/dev/null 2>&1
+fi
# config file installation or diff
if [ -f "$etc_path/$brisk_conf" ]; then
cp "${web_path}__""/Obj/brisk.conf-templ.pho" "$etc_path/$brisk_conf"
fi
+if [ -d ${web_path} ]; then
+ mv ${web_path} ${web_path}.old
+fi
+
mv ${web_path}__ ${web_path}
if [ -d ${web_path}.old ]; then
rm -rf ${web_path}.old
--- /dev/null
+#!/bin/bash
+# set -x
+cd "$PWD" 2>/dev/null
+dirnm="$PWD"
+cwd_old="$(ls -i -d "$dirnm" | cut -d ' ' -f 1)"
+pid_exe=""
+while true; do
+ if [ "$pid_exe" = "" ]; then
+ sleep 2
+ cd "$dirnm" 2>/dev/null
+ "$@" &
+ pid_exe="$!"
+ fi
+ sleep 1
+ kill -0 $pid_exe >/dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo "Process not present"
+ exit 0
+ fi
+ for tloop in 1 2 3 4 5; do
+ cwd_cur="$(ls -i -d "$dirnm" 2>/dev/null | cut -d ' ' -f 1)"
+ if [ "$cwd_cur" ]; then
+ break
+ fi
+ sleep 1
+ done
+ if [ $tloop -eq 5 ]; then
+ echo "Unavailable current working directory"
+ exit 1
+ fi
+ if [ "$cwd_cur" != "$cwd_old" ]; then
+ kill $pid_exe
+ wait $pid_exe
+ echo "WAIT EXIT: $?"
+ pid_exe=""
+ fi
+ cwd_old="$cwd_cur"
+done
+
/*
* brisk - brisk.phh
*
- * Copyright (C) 2006-2013 Matteo Nastasi
+ * Copyright (C) 2006-2014 Matteo Nastasi
* mailto: nastasi@alternativeoutput.it
* matteo.nastasi@milug.org
* web: http://www.alternativeoutput.it
define('DBG_TRAC', 0x1000);
define('DBG_SHME', 0x2000);
define('DBG_ENGI', 0x4000);
+define('DBG_CDS', 0x8000);
// NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols
define('BRISK_DEBUG', 0x0800);
var $delay_mgr;
+ var $cds;
+
public static $sess_cur;
function Brisk()
{
+ $this->cds = NULL;
}
// constructor
fprintf(STDERR, "ROOM FROM FILE\n");
rename($crystal_filename, $crystal_filename.".old");
- $brisk->reload($ban_list, $black_list);
+ $brisk->reload(TRUE, $ban_list, $black_list);
return($brisk);
}
$thiz->ban_list = NULL;
$thiz->black_list = NULL;
- fprintf(STDERR, "PRE IPCLASS_UPDATE (%d, %d)\n", count($ban_list), count($black_list));
- $thiz->ipclass_update('ban_list', $ban_list);
- $thiz->ipclass_update('black_list', $black_list);
- fprintf(STDERR, "POST IPCLASS_UPDATE %d %d\n", count($thiz->ban_list), count($thiz->black_list));
-
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
$thiz->user[$i] = User::create($thiz, $i, "", "");
}
static::$sess_cur = FALSE;
+ $thiz->reload(TRUE, $ban_list, $black_list);
+
return ($thiz);
}
}
}
- function reload($ban_list, $black_list)
+ function reload($is_first, $ban_list, $black_list)
{
fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list));
+ if (defined('CURL_DE_SAC_VERS')) {
+ if (brisk_cds_reload($this) == FALSE) {
+ exit(12);
+ }
+ }
$this->ipclass_update("ban_list", $ban_list);
$this->ipclass_update("black_list", $black_list);
- $this->banned_kickoff();
- $this->garbage_manager(TRUE);
+ if (!$is_first) {
+ $this->banned_kickoff();
+ $this->garbage_manager(TRUE);
+ }
}
function banned_kickoff()
}
$idx = $ghost;
+ if (defined('CURL_DE_SAC_VERS')) {
+ brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate);
+ }
return ($this->user[$ghost]);
}
else if ($idx != -1 && $i == MAX_PLAYERS) {
log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s] count [%d] name [%s] code [%s]", $idx, $sess, $name_new, count($this->user),$this->user[$real_idx]->name, $this->user[$real_idx]->code));
$ret = $this->user[$real_idx];
+ if (defined('CURL_DE_SAC_VERS')) {
+ brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate);
+ }
return ($ret);
}
}
+function log_cds($log)
+{
+ GLOBAL $PHP_SELF;
+
+ if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CDS) == 0)
+ return;
+
+ $sess = Brisk::sess_cur_get();
+ if (isset($sess) == FALSE)
+ $ssess = "XXXX";
+ else
+ $ssess = $sess;
+
+ if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CDS) == 0)
+ return;
+
+ if ((BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC)
+ $btrace = btrace_line(debug_backtrace());
+ else
+ $btrace = "";
+ if (($fp = @fopen(LEGAL_PATH."/cds.log", 'a')) != FALSE) {
+ fwrite($fp, sprintf("CDS: [%f] [%s] [%s]\n", gettimeofday(TRUE), $log, $btrace));
+ fclose($fp);
+ }
+}
+
+
function log_only2($log)
{
GLOBAL $PHP_SELF;
$line = trim($buf);
if ($line == "reload") {
require("$DOCUMENT_ROOT/Etc/".BRISK_CONF);
- $this->app->reload($G_ban_list, $G_black_list);
+ $this->app->reload(FALSE, $G_ban_list, $G_black_list);
global_dump();
}
else if ($line == "shutdown" || $line == "sd") {
} // if (isset($this->s2u[$id]...
} // foreach ($this->socks...
printf("\n");
+ if (defined('CURL_DE_SAC_VERS')) {
+ $this->app->cds->process();
+ }
} // while (...
} // function run(...
return(FALSE);
}
- $fname = sprintf("%s%s.pdf", $G_doc_path, basename($_GET['doc']));
+ $ext = "pdf";
+ $cont_type = "application/octet-stream";
+ if (isset($_GET['ext']) && ($_GET['ext'] == "txt")) {
+ $cont_type = "plain/text";
+ $ext = $_GET['ext'];
+ }
+
+ $fname = sprintf("%s%s.%s", $G_doc_path, basename($_GET['doc']), $ext);
if (! file_exists($fname)) {
return(FALSE);
}
- header("Content-Type: application/octet-stream");
+ header(sprintf("Content-Type: %s", $cont_type));
header(sprintf("Content-Disposition: attachment; filename=brisk_%s", basename($fname)));
readfile($fname);
return(TRUE);
}
main();
-?>
\ No newline at end of file
+?>
}
}
+ $banned = FALSE;
if ($ACTION == "login" && isset($name)) {
log_main("pre garbage_manager DUE");
if (isset($pass_private) == FALSE || $pass_private == "") {
$pass_private = FALSE;
- $banned = FALSE;
if ($brisk->ban_check($remote_addr)) {
// TODO: find a way to add a nonblocking sleep(5) here
$banned = TRUE;
require_once($G_base."Obj/sac-a-push.phh");
require_once("./brisk-spush.phh");
require_once($G_base."Obj/user.phh");
+@include_once($G_base."Obj/curl-de-brisk.phh");
require_once($G_base."Obj/brisk.phh");
require_once($G_base."Obj/auth.phh");
require_once($G_base."Obj/zlibstream.phh");
require_once($G_base."Obj/mail.phh");
-// require_once("../Obj/proxyscan.phh");
require_once($G_base."index.php");
require_once($G_base."index_wr.php");
require_once($G_base."briskin5/Obj/briskin5.phh");