Пример #1
0
        exit('Couldn\'t locate template "' . $tmpl . '" inside "' . $f_path . '"<br>');
    }
    if (!isset($_POST['submitted'])) {
        $tmpl_data = $sdata['data'];
    } else {
        $tmpl_data = $_POST['tmpl_data'];
        $data = substr_replace($data, str_replace("\r", '', $tmpl_data), $sdata['offset'], $sdata['len']);
        if (!($fp = fopen($f_path, 'wb'))) {
            exit('unable to save modifications to "' . $f_path . '"');
        }
        fwrite($fp, $data);
        fclose($fp);
        fud_use('compiler.inc', true);
        $c = q("SELECT theme FROM " . $GLOBALS['DBHOST_TBL_PREFIX'] . "themes WHERE theme='" . addslashes($tname) . "' AND lang='" . addslashes($tlang) . "'");
        while ($r = db_rowarr($c)) {
            compile_all($tname, $tlang, $r[0]);
        }
        unset($c);
        $update_ok = 1;
    }
    $p = 0;
    while (($p = strpos($tmpl_data, '{MSG: ', $p)) !== false) {
        $p += 6;
        $e = strpos($tmpl_data, '}', $p);
        $msg_list[] = substr($tmpl_data, $p, $e - $p);
        $p = $e;
    }
    if (isset($msg_list)) {
        $msg_list = ' <font size="-1">[ <a href="#" onClick="javascript: window_open(\'msglist.php?tname=' . $tname . '&tlang=' . $tlang . '&' . _rsidl . '&NO_TREE_LIST=1&msglist=' . urlencode(implode(':', $msg_list)) . '\', \'tmpl_msg\', 600,300);">Edit Text Messages</a> ]</font>';
    }
}
Пример #2
0
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;
                $thm_enabled = $c['theme_opt'] & 1;
            } else {
                if (isset($_GET['del']) && (int) $_GET['del'] > 1) {
                    fud_theme::delete((int) $_GET['del']);
                } else {
                    if (isset($_GET['optimize']) && $is_tok && ($t_name = q_singleval('SELECT name FROM ' . $DBHOST_TBL_PREFIX . 'themes WHERE id=' . (int) $_GET['optimize']))) {
                        /* optimize *.php files */
                        $path = $WWW_ROOT_DISK . 'theme/' . $t_name;
                        $dir = opendir($path);
Пример #3
0
                    copy("{$base}{$d}/{$f}", "{$dest}{$d}/{$f}");
                    chmod("{$dest}{$d}/{$f}", 0600);
                } else {
                    if ($f != 'CVS') {
                        $dir_ar[] = "{$d}/{$f}";
                    }
                }
            }
            closedir($dir);
        }
    }
}
require $WWW_ROOT_DISK . 'adm/admpanel.php';
echo "Syncronizing FUDforum sources!<br />\n";
/* data directories */
copy_dir(PHPGW_SERVER_ROOT . "/fudforum/setup/base/", $DATA_DIR, array('include', 'src', 'thm', 'sql'));
/* web directories */
copy_dir(PHPGW_SERVER_ROOT . "/fudforum/setup/base/www_root/", $WWW_ROOT_DISK, array('adm', 'images'));
copy(PHPGW_SERVER_ROOT . "/fudforum/setup/base/www_root/lib.js", $WWW_ROOT_DISK . "lib.js");
$remove_list = array('thm/default/tmpl/admincp.tmpl', 'thm/default/tmpl/curtime.tmpl', 'src/admincp.inc.t');
/* remove old files */
foreach ($remove_list as $f) {
    @unlink($DATA_DIR . $f);
}
/* recompile all enabled themes */
$c = uq("SELECT theme, lang, name FROM " . $DBHOST_TBL_PREFIX . "themes WHERE (theme_opt > 0) AND (theme_opt & 1) > 0");
while ($r = db_rowobj($c)) {
    compile_all($r->theme, $r->lang, $r->name);
}
echo "FUDforum sources are now syncronized!<br />\n";
require $WWW_ROOT_DISK . 'adm/admclose.php';
Пример #4
0
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;
}
Пример #5
0
$pspell_lang = trim(fread(fopen("{$DATA_DIR}/thm/default/i18n/{$lang}/pspell_lang", "r"), 1024));
$GLOBALS['phpgw']->db->query("DELETE FROM phpgw_fud_themes");
$GLOBALS['phpgw']->db->query("INSERT INTO phpgw_fud_themes(name, theme, lang, locale, theme_opt, pspell_lang) VALUES('default', 'default', '{$lang}', '{$locale}', 3, '{$pspell_lang}')");
$theme = $GLOBALS['phpgw']->db->get_last_insert_id('phpgw_fud_themes', 'id');
/* this is a little tricky, basically it makes sure that any users created before the forum
 * was activated with the default theme of 1, have the correct theme, in case the primary theme
 * id != 1
 */
if ($theme != 1) {
    $GLOBALS['phpgw']->db->query("UPDATE phpgw_fud_users SET theme={$theme}");
}
/* compile default theme */
define('__dbtype__', !empty($GLOBALS['phpgw']->db->type) ? $GLOBALS['phpgw']->db->type : $GLOBALS['phpgw']->db->Type);
$DBHOST_TBL_PREFIX = "phpgw_fud_";
require "{$INCLUDE}/compiler.inc";
compile_all('default', $lang);
/* Create an Acccount for every existing eGW user in the forum */
$GLOBALS['phpgw']->db->query("DELETE FROM phpgw_fud_users WHERE id>1");
$users = $GLOBALS['phpgw']->accounts->get_list('accounts', '', 'ASC');
foreach ($users as $row) {
    $preferences = CreateObject('phpgwapi.preferences', $row['account_id']);
    $preferences->read_repository();
    $email = $preferences->email_address($row['account_id']);
    $email = $GLOBALS['phpgw']->db->db_addslashes($email);
    $name = $GLOBALS['phpgw']->db->db_addslashes($row['account_firstname'] . ' ' . $row['account_lastname']);
    $egw_id = $row['account_id'];
    $alias = $GLOBALS['phpgw']->db->db_addslashes(htmlspecialchars($row['account_lid']));
    $login = $GLOBALS['phpgw']->db->db_addslashes($row['account_lid']);
    $users_opt = 2 | 4 | 16 | 32 | 64 | 128 | 256 | 512 | 2048 | 4096 | 8192 | 16384 | 131072 | 4194304;
    if ($row['account_status'] != 'A') {
        $user_opts |= 2097152;