Exemple #1
0
// magic quotes = ON, filtering it
if (ini_get('magic_quotes_gpc')) {
    cn_filter_magic_quotes();
}
if (!DEV_DEBUG) {
    // catch errors
    set_error_handler("user_error_handler");
}
// create cutenews caches
$_CN_SESS_CACHE = array();
$_CN_cache_block_id = array();
$_CN_cache_block_dt = array();
// Define ALL privileges and behaviors
$_CN_access = array('C' => 'Cd,Cvm,Csc,Cp,Cc,Ct,Ciw,Cmm,Cum,Cg,Cb,Ca,Cbi,Caf,Crw,Csl,Cwp,Cmt,Cpc,Can,Cvn,Ccv,Cen,Clc,Csr,Com', 'N' => 'Nes,Neg,Nea,Nvs,Nvg,Nva,Nua,Nud,Ncd', 'M' => 'Mes,Meg,Mea,Mds,Mdg,Mda,Mac', 'B' => 'Bd,Bs');
// v2.0 init sections
$is_config = cn_config_load();
cn_lang_init();
cn_db_init();
cn_rewrite_load();
cn_parse_url();
cn_detect_user_ip();
cn_load_session();
// 2.0.3 checking existing configuration
if ($is_config) {
    cn_load_plugins();
    cn_online_counter();
}
db_installed_check();
// load modules
include SERVDIR . '/core/modules/init.php';
hook('init/finally');
Exemple #2
0
function dashboard_locale()
{
    list($lang_token, $lang, $create_phrase, $phraseid, $translate, $delete_phrase, $exid) = GET('lang_token, lang, create_phrase, phraseid, translate, delete_phrase, exid');
    $tkn = array();
    $list = scan_dir(SERVDIR . '/core/lang/', '.*\\.txt');
    $updated = FALSE;
    // Load langs
    foreach ($list as $id => $code) {
        if (preg_match('/^(.*)\\.txt/i', $code, $c)) {
            $list[$id] = $c[1];
        }
    }
    // Load symbols
    $lang_token = preg_replace('/[^a-z0-9_\\-]/i', '', $lang_token);
    if ($lang_token) {
        $_tkn = file($cfile = SERVDIR . '/core/lang/' . $lang_token . '.txt');
        foreach ($_tkn as $data) {
            list($TKN, $DAT) = explode(': ', $data, 2);
            $tkn[$TKN] = $DAT;
        }
    }
    // Do submit new data
    if (request_type('POST') && REQ('modifica')) {
        cn_dsi_check();
        // Create new phrase
        if ($create_phrase || !$exid || $exid && $exid !== $phraseid) {
            if ($phraseid && $translate) {
                $exid = $h = hi18n($phraseid);
                if (!isset($tkn[$h])) {
                    $updated = TRUE;
                    $tkn[$h] = str_replace("\n", '', $translate);
                    cn_throw_message('Row added');
                } else {
                    cn_throw_message('Row with same ID already exists', 'e');
                }
            } else {
                cn_throw_message('Fill required fields', 'e');
            }
        } elseif ($delete_phrase) {
            if (isset($tkn[$exid])) {
                $updated = TRUE;
                unset($tkn[$exid]);
                cn_throw_message('Row deleted');
            } else {
                cn_throw_message('Phrase not deleted: not exists');
            }
        } else {
            $updated = TRUE;
            $tkn[$exid] = str_replace("\n", '', $translate);
            cn_throw_message('Row edited');
        }
    }
    // Updated? Try save
    if ($updated && isset($cfile)) {
        $w = fopen($cfile, 'w+');
        foreach ($tkn as $I => $T) {
            fwrite($w, "{$I}: " . trim($T) . "\n");
        }
        fclose($w);
        // Reinitialize skin
        cn_lang_init();
        cn_load_skin();
    }
    // Select
    if ($exid && isset($tkn[$exid])) {
        $phraseid = $exid;
        $translate = $tkn[$exid];
    }
    cn_assign('lang_token, lang, list, tkn, phraseid, translate', $lang_token, $lang, $list, $tkn, $phraseid, $translate);
    echoheader('-@dashboard/style.css', 'Localization');
    echo exec_tpl('dashboard/locale');
    echofooter();
}