Esempio n. 1
0
function con_config_tpl_save($idtpl, $idlay, $idcatlang, $idsidelang, $idtplconf, $have_perm_save_configdata = true)
{
    global $db, $cms_db, $cfg_client, $configtpl;
    if (!(is_numeric($idtpl) || is_int($idtpl))) {
        return;
    }
    if (!(is_numeric($idtplconf) || is_int($idtplconf))) {
        return;
    }
    $is_new_tpl = false;
    // Array der alten Container erstellen
    $used_container = browse_template_for_module('0', $idtplconf);
    if (!is_array($used_container['id'])) {
        $used_container['id']['0'] = '0';
    }
    // Eintrag in 'tpl_conf' Tabelle
    if ($idtplconf == '0') {
        if ($idtpl != '0') {
            // Template erstellen
            $sql = "INSERT INTO {$cms_db['tpl_conf']} (idtpl) VALUES ('{$idtpl}')";
            mysql_query($sql);
            //print_r($db);
            $idtplconf = mysql_insert_id();
            //echo mysql_insert_id();
            $is_new_tpl = true;
            //echo "<br>new tpl idtpl: $idtpl idtplconf: $idtplconf<br>";
        } else {
            return;
        }
    } else {
        if ($idtpl != '0' && $idtpl != $configtpl) {
            // Template ändern
            $sql = "UPDATE {$cms_db['tpl_conf']} SET idtpl='{$idtpl}' WHERE idtplconf='{$idtplconf}'";
            $db->query($sql);
            $is_new_tpl = true;
        } elseif ($idtpl == '0') {
            // Template löschen
            $sql = "DELETE FROM {$cms_db['container_conf']} WHERE idtplconf='{$idtplconf}'";
            $db->query($sql);
            $sql = "DELETE FROM {$cms_db['tpl_conf']} WHERE idtplconf='{$idtplconf}'";
            $db->query($sql);
            // Status der 'code' Tabelle ändern
            $list = get_idcode_by_idtplconf($idtplconf);
            change_code_status($list, '1');
            unset($list);
            // Containerinhalt löschen
            $list = get_idsidelang_by_idtplconf($idtplconf);
            $sql = "DELETE FROM {$cms_db['content']} WHERE idsidelang IN(" . implode(',', $list) . ")";
            $db->query($sql);
            $sql = "DELETE FROM {$cms_db['content_external']} WHERE idsidelang IN(" . implode(',', $list) . ")";
            $db->query($sql);
            unset($list);
            $idtplconf = '0';
        }
    }
    // Content aus Cache löschen
    sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content'));
    // Template bei Seite oder Ordner eintragen
    if ($idcatlang) {
        $sql = "UPDATE {$cms_db['cat_lang']} SET idtplconf='{$idtplconf}' WHERE idcatlang='{$idcatlang}'";
    } else {
        $sql = "UPDATE {$cms_db['side_lang']} SET idtplconf='{$idtplconf}' WHERE idsidelang='{$idsidelang}'";
    }
    if ($idcatlang || $idsidelang) {
        //print_r($GLOBALS);
        //echo $lang."zzy"; exit;
        $db->query($sql);
    }
    if ($idtplconf == '0') {
        return;
    }
    // Array der neuen Container erstellen
    // ein vorhandenes template wird neu konfiguriert und benutzer hat das recht dazu
    if ($idlay && $have_perm_save_configdata) {
        $list = browse_layout_for_containers($idlay);
        if (is_array($list['id'])) {
            foreach ($list['id'] as $i) {
                global ${'C' . $i . 'MOD_VAR'}, ${'c' . $i}, ${'cview' . $i}, ${'cedit' . $i};
                if (${'c' . $i}) {
                    $container['id'][] = $i;
                }
                if (${'C' . $i . 'MOD_VAR'}) {
                    $cconfig[$i] = make_array_to_urlstring(${'C' . $i . 'MOD_VAR'});
                }
            }
        }
        //Ein neues Template wird angelegt - recht des benutzers ist egal
    } else {
        if (!$idlay) {
            //idlay ist bei zu wenig rechten nicht vorhanden, prüfen ob neues Template
            if (!$is_new_tpl && !$have_perm_save_configdata) {
                return;
            }
            // Templatevorlage kopieren
            $sql = "SELECT container, config, view, edit FROM {$cms_db['container']} A LEFT JOIN {$cms_db['container_conf']} B\n                USING(idcontainer) WHERE A.idtpl='{$idtpl}' AND B.idtplconf='0'";
            $db->query($sql);
            while ($db->next_record()) {
                $container['id'][] = $db->f('container');
                $cconfig[$db->f('container')] = $db->f('config');
                ${'cview' . $db->f('container')} = $db->f('view');
                ${'cedit' . $db->f('container')} = $db->f('edit');
            }
            //es wurde kein neues template angelegt -> benutzer hat nicht das recht weiterzumachen
        } else {
            return;
        }
    }
    if (!is_array($container['id'])) {
        $container['id']['0'] = '0';
    }
    foreach ($container['id'] as $value) {
        if ($value != '0') {
            // neue Container hinzufügen
            if (!in_array($value, $used_container['id'])) {
                $sql = "SELECT idcontainer FROM {$cms_db['container']} WHERE idtpl='{$idtpl}' AND container='{$value}'";
                $db->query($sql);
                $db->next_record();
                $sql = "INSERT INTO {$cms_db['container_conf']} (idtplconf, idcontainer, config, view, edit)\n                        VALUES ('{$idtplconf}', '" . $db->f('idcontainer') . "', '{$cconfig[$value]}', '" . ${'cview' . $value} . "', '" . ${'cedit' . $value} . "')";
                $db->query($sql);
                $change = 'true';
            }
            // geänderte Container updaten
            if (in_array($value, $used_container['id'])) {
                // Modulkonfiguration hat sich geändert
                if ($used_container[$value]['config'] != $cconfig[$value] || $used_container[$value]['view'] != ${'cview' . $value} || $used_container[$value]['edit'] != ${'cedit' . $value}) {
                    $sql = "UPDATE {$cms_db['container_conf']} SET config='" . $cconfig[$value] . "', view='" . ${'cview' . $value} . "', edit='" . ${'cedit' . $value} . "' WHERE idcontainer='" . $used_container[$value]['idcontainer'] . "' AND idtplconf='{$idtplconf}'";
                    $db->query($sql);
                    $change = 'true';
                }
                // Modul hat sich durch Templatewechsel geändert
                if ($idtpl != $configtpl) {
                    $sql = "SELECT idcontainer FROM {$cms_db['container']} WHERE idtpl='{$idtpl}' AND container='{$value}'";
                    $db->query($sql);
                    $db->next_record();
                    $sql = "UPDATE {$cms_db['container_conf']} SET idcontainer='" . $db->f('idcontainer') . "'\n                            WHERE idcontainer='" . $used_container[$value]['idcontainer'] . "' AND idtplconf='{$idtplconf}'";
                    $db->query($sql);
                    if ($used_container[$value]['idmod'] != ${'c' . $value}) {
                        $empty_container[] = $value;
                    }
                }
            }
        }
    }
    // alte Container löschen
    foreach ($used_container['id'] as $value) {
        if ($value != '0') {
            if (!in_array($value, $container['id'])) {
                $sql = "DELETE FROM {$cms_db['container_conf']} WHERE idcontainer='" . $used_container[$value]['idcontainer'] . "'\n                        AND idtplconf='{$idtplconf}'";
                $db->query($sql);
                $change = 'true';
                $empty_container[] = $value;
            }
        }
    }
    // Status der 'code' Tabelle ändern
    if ($change) {
        $list = get_idcode_by_idtplconf($idtplconf);
        change_code_status($list, '1');
        unset($list);
    }
    // Containerinhalt löschen
    if (is_array($empty_container)) {
        $list = get_idsidelang_by_idtplconf($idtplconf);
        if (is_array($list)) {
            $sql = "DELETE FROM {$cms_db['content']} WHERE idsidelang IN(" . implode(',', $list) . ")\n                    AND container IN(" . implode(',', $empty_container) . ")";
            $db->query($sql);
            $sql = "DELETE FROM {$cms_db['content_external']} WHERE idsidelang IN(" . implode(',', $list) . ")\n                    AND container IN(" . implode(',', $empty_container) . ")";
            $db->query($sql);
            unset($list);
        }
    }
}
Esempio n. 2
0
echo "    <h5>" . $cms_lang['area_mod_config'] . "</h5>";
if ($errno) {
    echo "<p class=\"errormsg\">" . $cms_lang["err_{$errno}"] . "</p>";
}
// get modconfig
$modul = $rep->mod_data($idmod, $idclient);
if (is_array($modul)) {
    $modname = empty($modul['verbose']) ? htmlspecialchars($modul['name'], ENT_COMPAT, 'UTF-8') : htmlspecialchars($modul['verbose'], ENT_COMPAT, 'UTF-8');
    $modversion = !empty($modul['version']) ? ' (' . htmlspecialchars($modul['version'], ENT_COMPAT, 'UTF-8') . ')' : '';
    $modcat = htmlspecialchars($modul['cat'], ENT_COMPAT, 'UTF-8');
    $description = htmlspecialchars($modul['description'], ENT_COMPAT, 'UTF-8');
    $default = $modul['input'];
    $input = $modul['input'];
    $output = $modul['output'];
    if ($action == 'change' && !$resetmod) {
        $modconfig = make_array_to_urlstring($MOD_VAR);
    } elseif (!$resetmod) {
        $modconfig = $modul['config'];
    }
}
$reset = '';
$list['id'][] = '';
$s_default = array(NULL);
if ($sess->is_registered('s_default')) {
    $sess->unregister('s_default');
}
mip_forms_ob_start();
eval(' ?>' . $default);
$default_arr = mip_forms_get_array();
$default_arr = array_merge($cms_mod, $default_arr);
mip_forms_ob_end();
Esempio n. 3
0
     if (empty($root_name) || $root_name == '' || in_array($root_name, $oldliste)) {
         $errno = in_array($root_name, $oldliste) ? '1624' : '1623';
         $idclient = $client;
         break;
     }
     //ATTENTION!!! plug_save(...) set global $idplug/ necessary for apply header
     $errno = plug_save($idplug, $plugname, $description, $plugversion, $plugcat, $idclient, $repid, $install_sql, $uninstall_sql, $update_sql, $root_name, $index_file);
     if (isset($_REQUEST['sf_apply'])) {
         header('Location:' . $sess->urlRaw("main.php?area=plug_edit&idplug={$idplug}&idclient={$idclient}&editsql={$editsql}&errno={$errno}"));
         exit;
     }
     break;
 case 'save_config':
     // Konfiguration speichern
     $perm->check(4, 'plug', $idplug);
     $config = make_array_to_urlstring($PLUG_VAR);
     $errno = plug_save_config($idplug, $config, $plug_config_overwrite_all);
     if (isset($_REQUEST['sf_apply'])) {
         header('Location:' . $sess->urlRaw("main.php?area=plug_config&idplug={$idplug}&idclient={$idclient}"));
         exit;
     }
     break;
 case 'download':
     // Plugin downloaden
     $perm->check(10, 'plug', $idplug);
     $gzip = !$nogzip && $type != 'tar' ? true : false;
     $name = empty($name) ? false : urldecode($name);
     $type = empty($type) ? false : trim($type);
     $errno = plug_download($idplug, $idclient, $gzip, $name, $type);
     break;
 case 'upload':
Esempio n. 4
0
             $sess->register('s_modul');
             // merke:erst ein value kann gespeichert werden ;)
             $sess->freeze();
             header('Location:' . $sess->urlRaw("main.php?area=mod_edit&idmod=" . $idmod . "&idclient=" . $idclient));
             exit;
         }
     }
     if ($sess->is_registered('s_modul')) {
         $sess->unregister('s_modul');
     }
     break;
 case 'save_config':
     // Konfiguration speichern
     $perm->check(4, 'mod', $idmod);
     $config = make_array_to_urlstring($MOD_VAR);
     $default = make_array_to_urlstring($s_default);
     // übernahme von 0A hexadecimal (US-ASCII character LF), und 0D (US-ASCII character CR)
     if (strpos($config, '%0D%0A') && !strpos($default, '%0D%0A')) {
         $default = preg_replace('/(?<!%0D)%0A/', '%0D%0A', $default);
     }
     // übernahme von 5C hexadecimal (US-ASCII character \), und 22 (US-ASCII character ")
     if (strpos($config, '%5C%22') && !strpos($default, '%5C%22')) {
         $default = preg_replace('/(?<!%5C)%22/', '%5C%22', $default);
     }
     // übernahme von 5C hexadecimal (US-ASCII character \), und 27 (US-ASCII character ')
     if (strpos($config, '%5C%27') && !strpos($default, '%5C%27')) {
         $default = preg_replace('/(?<!%5C)%27/', '%5C%27', $default);
     }
     if ($config == $default) {
         $config = '';
     }