function mod_save($idmod_in, $name, $verbose, $description, $modversion, $modcat, $input, $output, $idclient, $repid = '', $sql_install = '', $sql_uninstall = '', $sql_update = '', $mod_rebuild_sql = false, $source_id = '0', $mod_no_wedding = false, $stripe = false, $mod_config_takeover = false) { global $db, $auth, $cms_db, $cfg_cms, $cms_lang, $cfg_client, $rep, $perm; global $idmod; //make global for header redirect $idmod = $idmod_in; // Eintrag in 'mod' Tabelle if (empty($name) || $name == '') { $name = $cms_lang['mod_defaultname']; } if (empty($modversion) || $modversion == '') { $modversion = '1.0'; } if ($stripe == 1) { $name = make_string_dump($name); $verbose = make_string_dump($verbose); $description = make_string_dump($description); $modversion = make_string_dump($modversion); $modcat = make_string_dump($modcat); $input = make_string_dump($input); $output = make_string_dump($output); } elseif ($stripe != 2) { set_magic_quotes_gpc($name); set_magic_quotes_gpc($verbose); set_magic_quotes_gpc($description); set_magic_quotes_gpc($modversion); set_magic_quotes_gpc($modcat); set_magic_quotes_gpc($input); set_magic_quotes_gpc($output); } $checked = ($err_i = $rep->mod_test(cms_stripslashes($input), $idmod)) || ($err_0 = $rep->mod_test(cms_stripslashes($output), $idmod)) ? '0' : '1'; $modverbose = $verbose == '-1' ? $name : $verbose; $mod_sql_uninstall = $sql_uninstall; $mod_sql_install = $sql_install; $sql_install = mysql_escape_string($rep->decode_sql($sql_install)); $sql_uninstall = mysql_escape_string($rep->decode_sql($sql_uninstall)); $sql_update = mysql_escape_string($rep->decode_sql($sql_update)); if ($mod_no_wedding == true) { $source_id = 0; $repositoryid = $rep->gen_new_mod($name); $update_source = ", source_id='0'"; } elseif ($source_id) { $repositoryid = $rep->gen_new_mod($name, true); } elseif ($repid == '') { $repositoryid = $rep->gen_new_mod($name); if ($errno = $rep->error(true)) { return $errno; } } else { $repositoryid = $rep->gen_new_mod($name, true); } if ($errno = $rep->error(true)) { return $errno; } elseif (empty($input) && empty($output)) { return '0424'; } if (!$idmod) { // Modul existiert noch nicht $sql = "INSERT INTO\r\n\t\t\t\t" . $cms_db['mod'] . "\r\n\t\t\t\t(name, description, version, cat, input, output, idclient, author, created, lastmodified,\r\n\t\t\t\trepository_id, install_sql, uninstall_sql, update_sql, source_id, verbose, checked)\r\n\t\t\t\tVALUES\r\n\t\t\t\t('{$name}', '{$description}', '{$modversion}', '{$modcat}', '{$input}', '{$output}', '{$idclient}',\r\n\t\t\t\t'" . $auth->auth['uid'] . "', '" . time() . "', '" . time() . "', '{$repositoryid}', '{$sql_install}', '{$sql_uninstall}', '{$sql_update}', '{$source_id}', '{$modverbose}', '{$checked}')"; $affect = $db->query($sql); if (!$affect || $affect < 1) { return '0400'; } $idmod = $last_id = $db->insert_id(); if ($mod_config_takeover == true) { $modul = $rep->mod_data($source_id, $idclient); mod_save_config($idmod, make_string_dump($modul['config'])); } // Event fire_event('mod_new', array('idmod' => $idmod, 'name' => $name)); } else { // hat sich das Modul geändert? $sql = "SELECT output FROM " . $cms_db['mod'] . " WHERE idmod='{$idmod}'"; $db->query($sql); $db->next_record(); $output_old = $db->f('output'); set_magic_quotes_gpc($output_old); //don't change verbose name by sql update if ($verbose == '-2') { $sql_verbose_name = ''; } else { $sql_verbose_name = "verbose = '{$modverbose}',"; } if ($output != $output_old) { $sql = "UPDATE " . $cms_db['mod'] . "\r\n\t\t\t\t\tSET\r\n\t\t\t\t\tname='{$name}', description='{$description}', version = '{$modversion}', cat = '{$modcat}',\r\n\t\t\t\t\tinput='{$input}', output='{$output}', author='" . $auth->auth['uid'] . "', lastmodified='" . time() . "',\r\n\t\t\t\t\tinstall_sql ='{$sql_install}', uninstall_sql ='{$sql_uninstall}', update_sql ='{$sql_update}' {$update_source}, repository_id = '{$repositoryid}', {$sql_verbose_name} checked = '{$checked}'\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\tidmod='{$idmod}'"; $db->query($sql); $change = 'true'; } else { $sql = "UPDATE " . $cms_db['mod'] . "\r\n\t\t\t\t\tSET\r\n\t\t\t\t\tname='{$name}', description='{$description}', version = '{$modversion}', cat = '{$modcat}', input='{$input}',\r\n\t\t\t\t\tauthor='" . $auth->auth['uid'] . "', lastmodified='" . time() . "', install_sql='{$sql_install}',\r\n\t\t\t\t\tuninstall_sql='{$sql_uninstall}', update_sql='{$sql_update}' {$update_source}, repository_id = '{$repositoryid}', {$sql_verbose_name} checked = '{$checked}'\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\tidmod='{$idmod}'"; $db->query($sql); } // Event fire_event('mod_edit', array('idmod' => $idmod, 'name' => $name)); } if ($idclient > 0 && $mod_sql_install != '' && $mod_rebuild_sql == true) { if ($mod_sql_uninstall != '') { $error = $rep->bulk_sql($mod_sql_uninstall); } if (!$error) { $error = $rep->bulk_sql($mod_sql_install); } if (!$error) { $sql = "UPDATE " . $cms_db['mod'] . " SET is_install='1', lastmodified='" . time() . "' WHERE idmod='{$idmod}'"; $db->query($sql); } // Event fire_event('mod_install_sql', array('idmod' => $idmod, 'name' => $name)); } if ($change) { // Status der 'code' Tabelle ändern $list = get_idtplconf_by_using_type($idmod, 'mod'); $list = get_idcode_by_idtplconf($list); change_code_status($list, '1'); unset($list); } // Rechte setzen if ($perm->have_perm('6', 'mod', $idmod)) { global $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben; $perm->set_group_rights('mod', $idmod, $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben, '', 0xafd); } return !$error ? '0412' : $error; }
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); } } }
function lay_edit_layout($idlay, $name, $description, $code, $doctype, $doctype_autoinsert, $idclient) { global $db, $client, $auth, $cms_db, $cfg_cms, $css, $js, $cms_lang, $cfg_client, $perm; // Eintrag in 'lay' Tabelle if ($name == '') { $name = $cms_lang['lay_defaultname']; } set_magic_quotes_gpc($name); set_magic_quotes_gpc($description); set_magic_quotes_gpc($code); // Layout existiert noch nicht - neu erzeugen if (!$idlay) { $sql = "INSERT INTO\n\t\t\t\t\t" . $cms_db['lay'] . "\n\t\t\t\t\t(name, description, deletable, code, doctype, doctype_autoinsert, idclient, author, created, lastmodified)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$name}', '{$description}', '1', '{$code}', '{$doctype}', '{$doctype_autoinsert}', \n\t\t\t\t\t\t'{$idclient}', '" . $auth->auth['uid'] . "', '" . time() . "', '" . time() . "')"; $db->query($sql); // neue Layout-ID suchen $sql = "SELECT MAX(idlay) AS idlay FROM " . $cms_db['lay']; $db->query($sql); $db->next_record(); $idlay = $db->f('idlay'); // Event neues Layout fire_event('lay_new', array('idlay' => $idlay, 'name' => $name)); // Layout existiert - updaten } else { // hat sich das Layout geändert? $sql = "SELECT code FROM " . $cms_db['lay'] . " WHERE idlay='{$idlay}'"; $db->query($sql); $db->next_record(); $code_old = $db->f('code'); set_magic_quotes_gpc($code_old); $sql = "UPDATE " . $cms_db['lay'] . "\n\t\t\t\tSET\n\t\t\t\t\tname='{$name}', \n\t\t\t\t\tdescription='{$description}', \n\t\t\t\t\tcode='{$code}',\n\t\t\t\t\tdoctype='{$doctype}',\n\t\t\t\t\tdoctype_autoinsert='{$doctype_autoinsert}',\n\t\t\t\t\tauthor='" . $auth->auth['uid'] . "', lastmodified='" . time() . "'\n\t\t\t\tWHERE\n\t\t\t\t\tidlay='{$idlay}'"; $db->query($sql); $change = 'true'; //rechte setzen if ($perm->have_perm('6', 'lay', $idlay)) { global $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben; $perm->set_group_rights('lay', $idlay, $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben, '', 0xf5); } // Event fire_event('lay_edit', array('idlay' => $idlay, 'name' => $name)); } // welche CSS-Dateien werden benutzt? $sql = "SELECT B.idupl FROM {$cms_db['lay_upl']} A LEFT JOIN {$cms_db['upl']} B USING(idupl) LEFT JOIN {$cms_db['filetype']} C ON B.idfiletype=C.idfiletype WHERE idlay='{$idlay}' AND C.filetype='css'"; $db->query($sql); while ($db->next_record()) { $tmp_files['css'][] = $db->f('idupl'); } if (!is_array($tmp_files['css'])) { $tmp_files['css']['0'] = '0'; } if (!is_array($css)) { $css['0'] = '0'; } // benutzte CSS-Dateien in lay_upl schreiben foreach ($css as $value) { if (!in_array($value, $tmp_files['css'])) { if ($value != '0') { $sql = "INSERT INTO {$cms_db['lay_upl']} (idlay, idupl) VALUES ('{$idlay}', '{$value}')"; $db->query($sql); $change = 'true'; } } } // unbenutze CSS-Dateien aus lay_upl löschen foreach ($tmp_files['css'] as $value) { if (!in_array($value, $css)) { $sql = "DELETE FROM {$cms_db['lay_upl']} WHERE idupl='{$value}' AND idlay='{$idlay}'"; $db->query($sql); $change = 'true'; } } // welche JS-Dateien werden benutzt? $sql = "SELECT B.idupl FROM {$cms_db['lay_upl']} A LEFT JOIN {$cms_db['upl']} B USING(idupl) LEFT JOIN {$cms_db['filetype']} C ON B.idfiletype=C.idfiletype WHERE idlay='{$idlay}' AND C.filetype='js'"; $db->query($sql); while ($db->next_record()) { $tmp_files['js'][] = $db->f('idupl'); } if (!is_array($tmp_files['js'])) { $tmp_files['js']['0'] = '0'; } if (!is_array($js)) { $js['0'] = '0'; } // benutzte JS-Dateien in lay_upl schreiben foreach ($js as $value) { if (!in_array($value, $tmp_files['js'])) { if ($value != '0') { $sql = "INSERT INTO {$cms_db['lay_upl']} (idlay, idupl) VALUES ('{$idlay}', '{$value}')"; $db->query($sql); $change = 'true'; } } } // unbenutze JS-Dateien aus lay_upl löschen foreach ($tmp_files['js'] as $value) { if (!in_array($value, $js)) { $sql = "DELETE FROM {$cms_db['lay_upl']} WHERE idupl='{$value}' AND idlay='{$idlay}'"; $db->query($sql); $change = 'true'; } } if ($change) { // Status der 'code' Tabelle ändern $list = get_idtplconf_by_using_type($idlay, 'lay'); $list = get_idcode_by_idtplconf($list); change_code_status($list, '1'); unset($list); } return $idlay; }