$result = $db->query("SELECT COUNT(*) FROM " . $db_config['prefix'] . "_" . NV_LANG_DATA . "_modules where title='news'"); if ($result->fetchColumn()) { $global_config['rewrite_op_mod'] = 'news'; $db->query("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = 'news' WHERE lang='sys' AND module = 'global' AND config_name = 'rewrite_op_mod'"); } } } catch (PDOException $e) { trigger_error($e->getMessage()); die($e->getMessage()); } nv_save_file_config(); $array_config_rewrite = array('rewrite_optional' => $global_config['rewrite_optional'], 'rewrite_endurl' => $global_config['rewrite_endurl'], 'rewrite_exturl' => $global_config['rewrite_exturl'], 'rewrite_op_mod' => $global_config['rewrite_op_mod'], 'ssl_https' => 0); $rewrite = nv_rewrite_change($array_config_rewrite); if (empty($rewrite[0])) { $error .= sprintf($lang_module['file_not_writable'], $rewrite[1]); } elseif (nv_save_file_config_global()) { ++$step; $nv_Request->set_Session('maxstep', $step); nv_save_file_config(); @rename(NV_ROOTDIR . '/' . $file_config_temp, NV_ROOTDIR . '/' . NV_TEMP_DIR . '/' . NV_CONFIG_FILENAME); if (is_writable(NV_ROOTDIR . '/robots.txt')) { $contents = file_get_contents(NV_ROOTDIR . '/robots.txt'); $check_rewrite_file = nv_check_rewrite_file(); if ($check_rewrite_file) { $content_sitemap = 'Sitemap: ' . NV_MY_DOMAIN . NV_BASE_SITEURL . 'sitemap.xml'; } else { $content_sitemap = 'Sitemap: ' . NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php/SitemapIndex' . $global_config['rewrite_endurl']; } $contents = str_replace('Sitemap: http://yousite.com/?nv=SitemapIndex', $content_sitemap, $contents); file_put_contents(NV_ROOTDIR . '/robots.txt', $contents, LOCK_EX); }
$sth->bindValue(':config_name', 'upload_alt_require', PDO::PARAM_STR); $sth->bindValue(':config_value', $array_config_define['upload_alt_require'], PDO::PARAM_STR); $sth->execute(); $sth->bindValue(':config_name', 'upload_auto_alt', PDO::PARAM_STR); $sth->bindValue(':config_value', $array_config_define['upload_auto_alt'], PDO::PARAM_STR); $sth->execute(); $array_config_define = array(); $array_config_define['nv_max_width'] = $nv_Request->get_int('nv_max_width', 'post'); $array_config_define['nv_max_height'] = $nv_Request->get_int('nv_max_height', 'post'); $sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang = 'sys' AND module = 'define' AND config_name = :config_name"); foreach ($array_config_define as $config_name => $config_value) { $sth->bindParam(':config_name', $config_name, PDO::PARAM_STR, 30); $sth->bindParam(':config_value', $config_value, PDO::PARAM_STR); $sth->execute(); } nv_save_file_config_global(); Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&rand=' . nv_genpass()); die; } $page_title = $lang_module['uploadconfig']; $xtpl = new XTemplate('uploadconfig.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL); $xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE); $xtpl->assign('MODULE_NAME', $module_name); $xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE); $xtpl->assign('OP', $op); $xtpl->assign('LANG', $lang_module); $xtpl->assign('NV_MAX_WIDTH', NV_MAX_WIDTH); $xtpl->assign('NV_MAX_HEIGHT', NV_MAX_HEIGHT); $sys_max_size = min(nv_converttoBytes(ini_get('upload_max_filesize')), nv_converttoBytes(ini_get('post_max_size'))); $p_size = $sys_max_size / 100;
function nv_setup_data_module($lang, $module_name) { global $db, $db_config, $global_config; $return = 'NO_' . $module_name; $sql = "SELECT `module_file`, `module_data` FROM `" . $db_config['prefix'] . "_" . $lang . "_modules` WHERE `title`=" . $db->dbescape($module_name); $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows == 1) { list($module_file, $module_data) = $db->sql_fetchrow($result); $module_version = array(); $version_file = NV_ROOTDIR . "/modules/" . $module_file . "/version.php"; if (file_exists($version_file)) { include $version_file; } $arr_modfuncs = (isset($module_version['modfuncs']) and !empty($module_version['modfuncs'])) ? array_map("trim", explode(",", $module_version['modfuncs'])) : array(); //xoa du lieu tai bang _config $sql = "DELETE FROM `" . NV_CONFIG_GLOBALTABLE . "` WHERE `lang`=" . $db->dbescape($lang) . " AND `module`=" . $db->dbescape($module_name); $db->sql_query($sql); nv_save_file_config_global(); if (file_exists(NV_ROOTDIR . '/modules/' . $module_file . '/action.php')) { $sql_recreate_module = array(); include NV_ROOTDIR . '/modules/' . $module_file . '/action.php'; if (!empty($sql_create_module)) { foreach ($sql_create_module as $sql) { if (!$db->sql_query($sql)) { return $return; } } } } $arr_func_id = array(); $arr_show_func = array(); $new_funcs = nv_scandir(NV_ROOTDIR . '/modules/' . $module_file . '/funcs', $global_config['check_op_file']); if (!empty($new_funcs)) { // get default layout $layout_array = nv_scandir(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/layout', $global_config['check_op_layout']); if (!empty($layout_array)) { $layout_array = preg_replace($global_config['check_op_layout'], "\\1", $layout_array); } $array_layout_func_default = array(); $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini'); $layoutdefault = (string) $xml->layoutdefault; $layout = $xml->xpath('setlayout/layout'); for ($i = 0; $i < count($layout); $i++) { $layout_name = (string) $layout[$i]->name; if (in_array($layout_name, $layout_array)) { $layout_funcs = $layout[$i]->xpath('funcs'); for ($j = 0; $j < count($layout_funcs); $j++) { $mo_funcs = (string) $layout_funcs[$j]; $mo_funcs = explode(":", $mo_funcs); $m = $mo_funcs[0]; $arr_f = explode(",", $mo_funcs[1]); foreach ($arr_f as $f) { $array_layout_func_default[$m][$f] = $layout_name; } } } } // end get default layout $arr_func_id_old = array(); $sql = "SELECT `func_id`, `func_name` FROM `" . $db_config['prefix'] . "_" . $lang . "_modfuncs` WHERE `in_module`=" . $db->dbescape($module_name); $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $arr_func_id_old[$row['func_name']] = $row['func_id']; } $new_funcs = preg_replace($global_config['check_op_file'], "\\1", $new_funcs); $new_funcs = array_flip($new_funcs); foreach (array_keys($new_funcs) as $func) { $show_func = 0; $weight = 0; $layout = isset($array_layout_func_default[$module_name][$func]) ? $array_layout_func_default[$module_name][$func] : $layoutdefault; if (isset($arr_func_id_old[$func]) and isset($arr_func_id_old[$func]) > 0) { $arr_func_id[$func] = $arr_func_id_old[$func]; $db->sql_query("UPDATE `" . $db_config['prefix'] . "_" . $lang . "_modfuncs` SET `layout`=" . $db->dbescape($layout) . ", `show_func`= " . $show_func . ", `subweight`='0' WHERE `func_id`=" . $arr_func_id[$func] . ""); } else { $sql = "INSERT INTO `" . $db_config['prefix'] . "_" . $lang . "_modfuncs` (`func_id`, `func_name`, `func_custom_name`, `in_module`, `show_func`, `in_submenu`, `subweight`, `layout`, `setting`) VALUES (NULL, " . $db->dbescape($func) . ", " . $db->dbescape(ucfirst($func)) . ", " . $db->dbescape($module_name) . ", " . $show_func . ", 0, " . $weight . ", " . $db->dbescape($layout) . ", '')"; $arr_func_id[$func] = $db->sql_query_insert_id($sql); } } $subweight = 0; foreach ($arr_modfuncs as $func) { if (isset($arr_func_id[$func])) { $func_id = $arr_func_id[$func]; $arr_show_func[] = $func_id; $show_func = 1; $subweight++; $sql = "UPDATE `" . $db_config['prefix'] . "_" . $lang . "_modfuncs` SET `subweight`=" . $subweight . ", show_func=" . $show_func . " WHERE `func_id`=" . $db->dbescape($func_id); $db->sql_query($sql); } } } else { //xoa du lieu tai bang _modfuncs $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . $lang . "_modfuncs` WHERE `in_module`=" . $db->dbescape($module_name); $db->sql_query($sql); } if (isset($module_version['uploads_dir']) and !empty($module_version['uploads_dir'])) { foreach ($module_version['uploads_dir'] as $path) { $cp = ''; $arr_p = explode("/", $path); foreach ($arr_p as $p) { if (trim($p) != "") { if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $cp . $p)) { nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $cp, $p); } $cp .= $p . '/'; } } } } $return = 'OK_' . $module_name; nv_save_file_config_global(); } return $return; }