$root_nn = $root . preg_replace('![^A-Za-z0-9_]!', '_', $_POST['newname']); $u = umask(0); if (!@is_dir($root_nn) && !@mkdir($root_nn, 0777)) { exit('can\'t create (' . $root_nn . ')<br>'); } $ts = $_POST['base_template_set'] == 'path_info' ? 'path_info/' : 'default/'; fudcopy($root . $ts, $root_nn, '!.*!', true); umask($u); } if (isset($_POST['thm_theme']) && !$edit) { $thm = new fud_theme(); $thm->add(); compile_all($thm->theme, $thm->lang, $thm->name); } else { if (isset($_POST['edit'])) { $thm = new fud_theme(); if ($edit == 1) { $thm->name = 'default'; } $thm->sync((int) $_POST['edit']); compile_all($thm->theme, $thm->lang, $thm->name); $edit = ''; } else { if (isset($_GET['rebuild']) && ($data = db_saq('SELECT theme, lang, name FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . (int) $_GET['rebuild']))) { compile_all($data[0], $data[1], $data[2]); } else { if (isset($_GET['edit']) && ($c = db_arr_assoc('SELECT * FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . $edit))) { foreach ($c as $k => $v) { ${'thm_' . $k} = $v; } $thm_t_default = $c['theme_opt'] & 2;
function init_user() { $o1 =& $GLOBALS['FUD_OPT_1']; $o2 =& $GLOBALS['FUD_OPT_2']; $phpgw =& $GLOBALS['phpgw_info']['user']; /* delete old sessions */ if (!(rand() % 10)) { q("DELETE FROM phpgw_fud_ses WHERE time_sec+" . $GLOBALS['phpgw_info']['server']['sessions_timeout'] . " < " . __request_timestamp__); } $u = db_sab("SELECT \n\t\t\ts.id AS sid, s.data, s.returnto, \n\t\t\tt.id AS theme_id, t.lang, t.name AS theme_name, t.locale, t.theme, t.pspell_lang, t.theme_opt, \n\t\t\tu.alias, u.posts_ppg, u.time_zone, u.sig, u.last_visit, u.last_read, u.cat_collapse_status, u.users_opt, u.ignore_list, u.ignore_list, u.buddy_list, u.id, u.group_leader_list, u.email, u.login \n\t\t\tFROM phpgw_fud_ses s\n\t\t\tINNER JOIN phpgw_fud_users u ON u.id=(CASE WHEN s.user_id>2000000000 THEN 1 ELSE s.user_id END) \n\t\t\tINNER JOIN phpgw_fud_themes t ON t.id=u.theme WHERE s.ses_id='" . s . "'"); if (!$u) { /* registered user */ if ($phpgw['account_lid'] != $GLOBALS['ANON_NICK']) { /* this means we do not have an entry for this user in the sessions table */ $uid = q_singleval("SELECT id FROM phpgw_fud_users WHERE egw_id=" . (int) $phpgw['account_id']); $id = db_qid("INSERT INTO phpgw_fud_ses (user_id, ses_id, time_sec) VALUES(" . $uid . ", '" . s . "', " . __request_timestamp__ . ")"); $u = db_sab('SELECT s.id AS sid, s.data, s.returnto, t.id AS theme_id, t.lang, t.name AS theme_name, t.locale, t.theme, t.pspell_lang, t.theme_opt, u.alias, u.posts_ppg, u.time_zone, u.sig, u.last_visit, u.last_read, u.cat_collapse_status, u.users_opt, u.ignore_list, u.ignore_list, u.buddy_list, u.id, u.group_leader_list, u.email, u.login FROM phpgw_fud_ses s INNER JOIN phpgw_fud_users u ON u.id=s.user_id INNER JOIN phpgw_fud_themes t ON t.id=u.theme WHERE s.id=' . $id); } else { /* anonymous user */ do { $uid = 2000000000 + mt_rand(1, 147483647); } while (!($id = db_li("INSERT INTO phpgw_fud_ses (time_sec, ses_id, user_id) VALUES (" . __request_timestamp__ . ", '" . s . "', " . $uid . ")", $ef, 1))); $u = db_sab('SELECT s.id AS sid, s.data, s.returnto, t.id AS theme_id, t.lang, t.name AS theme_name, t.locale, t.theme, t.pspell_lang, t.theme_opt, u.alias, u.posts_ppg, u.time_zone, u.sig, u.last_visit, u.last_read, u.cat_collapse_status, u.users_opt, u.ignore_list, u.ignore_list, u.buddy_list, u.id, u.group_leader_list, u.email, u.login FROM phpgw_fud_ses s INNER JOIN phpgw_fud_users u ON u.id=1 INNER JOIN phpgw_fud_themes t ON t.id=u.theme WHERE s.id=' . $id); } } /* grant admin access */ if (!empty($phpgw['apps']['admin'])) { $u->users_opt |= 1048576; } /* this is ugly, very ugly, but there is no way around it, we need to see if the * user's language had changed and we can only do it this way. */ $langl = array('bg' => 'bulgarian', 'zh' => 'chinese_big5', 'cs' => 'czech', 'nl' => 'dutch', 'fr' => 'french', 'de' => 'german', 'it' => 'italian', 'lv' => 'latvian', 'no' => 'norwegian', 'pl' => 'polish', 'pt' => 'portuguese', 'ro' => 'romanian', 'ru' => 'russian', 'sk' => 'slovak', 'es' => 'spanish', 'sv' => 'swedish', 'tr' => 'turkish', 'en' => 'english'); $lang =& $phpgw['preferences']['common']['lang']; if (isset($langl[$lang]) && $langl[$lang] != $u->lang) { if (!($o = db_sab("SELECT * FROM phpgw_fud_themes WHERE lang='{$langl[$lang]}'"))) { fud_use('compiler.inc', true); fud_use('theme.inc', true); $thm = new fud_theme(); $thm->name = $thm->lang = $langl[$lang]; $thm->theme = 'default'; $thm->pspell_lang = file_get_contents($GLOBALS['DATA_DIR'] . 'thm/default/i18n/' . $langl[$lang] . '/pspell_lang'); $thm->locale = file_get_contents($GLOBALS['DATA_DIR'] . 'thm/default/i18n/' . $langl[$lang] . '/locale'); $thm->theme_opt = 1; $thm->add(); compile_all('default', $langl[$lang], $langl[$lang]); $o = db_sab("SELECT * FROM phpgw_fud_themes WHERE lang='{$langl[$lang]}'"); } $u->lang = $o->lang; $u->theme_name = $o->name; $u->locale = $o->locale; $u->theme_id = $o->id; $u->theme = $o->theme; $u->pspell_lang = $o->pspell_lang; $u->theme_opt = $o->theme_opt; q("UPDATE phpgw_fud_users SET theme=" . $u->theme_id . " WHERE id=" . $u->id); } if ($u->data) { $u->data = @unserialize($u->data); } $u->users_opt = (int) $u->users_opt; /* set timezone */ @putenv('TZ=' . $u->time_zone); /* set locale */ setlocale(LC_ALL, $u->locale); /* view format for threads & messages */ define('d_thread_view', $u->users_opt & 256 ? 'msg' : 'tree'); define('t_thread_view', $u->users_opt & 128 ? 'thread' : 'threadt'); /* theme path */ @define('fud_theme', 'theme/' . ($u->theme_name ? $u->theme_name : 'default') . '/'); /* define _uid, which, will tell us if this is a 'real' user or not */ define('__fud_real_user__', $u->id != 1 ? $u->id : 0); define('_uid', __fud_real_user__); if (__fud_real_user__) { q('UPDATE phpgw_fud_users SET last_visit=' . __request_timestamp__ . ' WHERE id=' . $u->id); } return $u; }