function nv_set_layout_site() { global $db, $global_config; $array_layout_func_data = array(); $fnsql = "SELECT `func_id`, `layout`, `theme` FROM `" . NV_PREFIXLANG . "_modthemes`"; $fnresult = $db->sql_query($fnsql); while (list($func_id, $layout, $theme) = $db->sql_fetchrow($fnresult)) { $array_layout_func_data[$theme][$func_id] = $layout; } $func_id_mods = array(); $sql = "SELECT `func_id`, `in_module` FROM `" . NV_MODFUNCS_TABLE . "` WHERE `show_func`='1' ORDER BY `in_module` ASC, `subweight` ASC"; $result = $db->sql_query($sql); while (list($func_id, $in_module) = $db->sql_fetchrow($result)) { $func_id_mods[$in_module][] = $func_id; } $sql = "SELECT title, theme FROM `" . NV_MODULES_TABLE . "` ORDER BY `weight` ASC"; $result = $db->sql_query($sql); $is_delCache = false; while (list($title, $theme) = $db->sql_fetchrow($result)) { if (isset($func_id_mods[$title])) { if (empty($theme)) { $theme = $global_config['site_theme']; } foreach ($func_id_mods[$title] as $func_id) { $layout = isset($array_layout_func_data[$theme][$func_id]) ? $array_layout_func_data[$theme][$func_id] : $array_layout_func_data[$theme][0]; $db->sql_query("UPDATE `" . NV_MODFUNCS_TABLE . "` SET `layout`=" . $db->dbescape($layout) . " WHERE `func_id`=" . $func_id . ""); $is_delCache = true; } } } if ($is_delCache) { nv_del_moduleCache('modules'); } }
/** * nv_del_cat() * * @param mixed $catid * @return */ function nv_del_cat($catid) { global $db, $module_name, $module_data, $admin_info; $sql = 'SELECT parentid, title FROM ' . NV_PREFIXLANG . '_' . $module_data . '_categories WHERE id=' . $catid; list($p, $title) = $db->query($sql)->fetch(3); $sql = 'SELECT id, fileupload, fileimage FROM ' . NV_PREFIXLANG . '_' . $module_data . ' WHERE catid=' . $catid; $result = $db->query($sql); $ids = array(); while (list($id, $fileupload, $fileimage) = $result->fetch(3)) { $ids[] = $id; } if (!empty($ids)) { $ids = implode(',', $ids); $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_comment WHERE module=' . $db->quote($module_name) . ' AND id IN (' . $ids . ')'; $db->query($sql); $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_report WHERE fid IN (' . $ids . ')'; $db->query($sql); } $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . ' WHERE catid=' . $catid; $db->query($sql); $sql = 'SELECT id FROM ' . NV_PREFIXLANG . '_' . $module_data . '_categories WHERE parentid=' . $catid; $result = $db->query($sql); while (list($id) = $result->fetch(3)) { nv_del_cat($id); } $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_categories WHERE id=' . $catid; $db->query($sql); nv_del_moduleCache($module_name); nv_insert_logs(NV_LANG_DATA, $module_data, 'Delete Category', $title, $admin_info['userid']); }
function nv_fix_subweight($mod) { global $db; $sql = "SELECT `func_id` FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($mod) . " AND `show_func`='1' ORDER BY `subweight` ASC"; $result = $db->sql_query($sql); $subweight = 0; while ($row = $db->sql_fetchrow($result)) { $subweight++; $sql = "UPDATE `" . NV_MODFUNCS_TABLE . "` SET `subweight`=" . $subweight . " WHERE `func_id`=" . $row['func_id']; $db->sql_query($sql); nv_del_moduleCache('modules'); } }
/** * nv_set_status_module() * * @return */ function nv_set_status_module() { global $db, $module_name, $module_data, $global_config; $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt'; $p = NV_CURRENTTIME - 300; if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) { return; } file_put_contents($check_run_cronjobs, ''); //status_0 = "Cho duyet"; //status_1 = "Xuat ban"; //status_2 = "Hen gio dang"; //status_3= "Het han"; // Dang cai bai cho kich hoat theo thoi gian $query = $db->query('SELECT id, listcatid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=2 AND publtime < ' . NV_CURRENTTIME . ' ORDER BY publtime ASC'); while (list($id, $listcatid) = $query->fetch(3)) { $array_catid = explode(',', $listcatid); foreach ($array_catid as $catid_i) { $catid_i = intval($catid_i); if ($catid_i > 0) { $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_' . $catid_i . ' SET status=1 WHERE id=' . $id); } } $db->query('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET status=1 WHERE id=' . $id); } // Ngung hieu luc cac bai da het han $query = $db->query('SELECT id, listcatid, archive FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 AND exptime > 0 AND exptime <= ' . NV_CURRENTTIME . ' ORDER BY exptime ASC'); while (list($id, $listcatid, $archive) = $query->fetch(3)) { if (intval($archive) == 0) { nv_del_content_module($id); } else { nv_archive_content_module($id, $listcatid); } } // Tim kiem thoi gian chay lan ke tiep $time_publtime = $db->query('SELECT min(publtime) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=2 AND publtime > ' . NV_CURRENTTIME)->fetchColumn(); $time_exptime = $db->query('SELECT min(exptime) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE status=1 AND exptime > ' . NV_CURRENTTIME)->fetchColumn(); $timecheckstatus = min($time_publtime, $time_exptime); if (!$timecheckstatus) { $timecheckstatus = max($time_publtime, $time_exptime); } $sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang = '" . NV_LANG_DATA . "' AND module = :module_name AND config_name = 'timecheckstatus'"); $sth->bindValue(':module_name', $module_name, PDO::PARAM_STR); $sth->bindValue(':config_value', intval($timecheckstatus), PDO::PARAM_STR); $sth->execute(); nv_del_moduleCache('settings'); nv_del_moduleCache($module_name); unlink($check_run_cronjobs); clearstatcache(); }
/** * nv_set_status_module() * * @return */ function nv_set_status_module() { global $db, $module_name, $module_data, $global_config; $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt'; $p = NV_CURRENTTIME - 300; if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) { return; } file_put_contents($check_run_cronjobs, ''); //status_0 = "Cho duyet"; //status_1 = "Xuat ban"; //status_2 = "Hen gio dang"; //status_3= "Het han"; // Dang cai bai cho kich hoat theo thoi gian $query = $db->sql_query("SELECT `id`, `listcatid` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=2 AND `publtime` < " . NV_CURRENTTIME . " ORDER BY `publtime` ASC"); while (list($id, $listcatid) = $db->sql_fetchrow($query)) { $array_catid = explode(",", $listcatid); foreach ($array_catid as $catid_i) { $catid_i = intval($catid_i); if ($catid_i > 0) { $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_" . $catid_i . "` SET `status`='1' WHERE `id`=" . $id . ""); } } $db->sql_query("UPDATE `" . NV_PREFIXLANG . "_" . $module_data . "_rows` SET `status`='1' WHERE `id`=" . $id . ""); } // Ngung hieu luc cac bai da het han $query = $db->sql_query("SELECT `id`, `listcatid`, `archive` FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=1 AND `exptime` > 0 AND `exptime` <= " . NV_CURRENTTIME . " ORDER BY `exptime` ASC"); while (list($id, $listcatid, $archive) = $db->sql_fetchrow($query)) { if (intval($archive) == 0) { nv_del_content_module($id); } else { nv_archive_content_module($id, $listcatid); } } // Tim kiem thoi gian chay lan ke tiep list($time_publtime) = $db->sql_fetchrow($db->sql_query("SELECT min(publtime) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=2 AND `publtime` > " . NV_CURRENTTIME)); list($time_exptime) = $db->sql_fetchrow($db->sql_query("SELECT min(exptime) FROM `" . NV_PREFIXLANG . "_" . $module_data . "_rows` WHERE `status`=1 AND `exptime` > " . NV_CURRENTTIME)); $timecheckstatus = min($time_publtime, $time_exptime); if (!$timecheckstatus) { $timecheckstatus = max($time_publtime, $time_exptime); } $db->sql_query("REPLACE INTO `" . NV_CONFIG_GLOBALTABLE . "` (`lang`, `module`, `config_name`, `config_value`) VALUES('" . NV_LANG_DATA . "', " . $db->dbescape($module_name) . ", 'timecheckstatus', '" . intval($timecheckstatus) . "')"); nv_del_moduleCache('settings'); nv_del_moduleCache($module_name); unlink($check_run_cronjobs); clearstatcache(); }
* @Copyright (C) 2014 VINADES.,JSC. All rights reserved * @License GNU/GPL version 2 or any later version * @Createdate 2-10-2010 18:49 */ if (!defined('NV_IS_FILE_ADMIN')) { die('Stop!!!'); } $payment = $nv_Request->get_string('oid', 'post', ''); $new_weight = $nv_Request->get_int('w', 'post', 0); $content = "NO_" . $payment; $table = $db_config['prefix'] . "_" . $module_data . "_payment"; $stmt = $db->prepare("SELECT payment, weight FROM " . $table . " WHERE payment= :payment"); $stmt->bindParam(':payment', $payment, PDO::PARAM_STR); $stmt->execute(); list($payment, $weight_old) = $stmt->fetch(3); if (!empty($payment)) { $sql = "SELECT payment FROM " . $table . " WHERE weight = " . intval($new_weight); $result = $db->query($sql); $payment_swap = $result->fetchColumn(); $stmt = $db->prepare("UPDATE " . $table . " SET weight=" . $new_weight . " WHERE payment= :payment"); $stmt->bindParam(':payment', $payment, PDO::PARAM_STR); $stmt->execute(); $stmt = $db->prepare("UPDATE " . $table . " SET weight=" . $weight_old . " WHERE payment= :payment"); $stmt->bindParam(':payment', $payment, PDO::PARAM_STR); $stmt->execute(); $content = "OK_" . $payment; nv_del_moduleCache($payment); } include NV_ROOTDIR . '/includes/header.php'; echo $content; include NV_ROOTDIR . '/includes/footer.php';
/** * nv_groups_list_pub() * * @return */ function nv_groups_list_pub() { global $db; $query = "SELECT `group_id`, `title`, `exp_time`, `public` FROM `" . NV_GROUPS_GLOBALTABLE . "` WHERE `act`=1 ORDER BY `weight`"; $list = nv_db_cache($query, '', 'users'); if (empty($list)) { return array(); } $groups = array(); $reload = array(); for ($i = 0, $count = sizeof($list); $i < $count; ++$i) { if ($list[$i]['exp_time'] != 0 and $list[$i]['exp_time'] <= NV_CURRENTTIME) { $reload[] = $list[$i]['group_id']; } elseif ($list[$i]['public']) { $groups[$list[$i]['group_id']] = $list[$i]['title']; } } if ($reload) { $sql = "UPDATE `" . NV_GROUPS_GLOBALTABLE . "` SET `act`='0' WHERE `group_id` IN (" . implode(",", $reload) . ")"; $db->sql_query($sql); nv_del_moduleCache('users'); } return $groups; }
<?php /** * @Project NUKEVIET 3.x * @Author VINADES.,JSC (contact@vinades.vn) * @Copyright (C) 2012 VINADES.,JSC. All rights reserved * @Createdate 2-10-2010 17:30 */ if (!defined('NV_IS_FILE_MODULES')) { die('Stop!!!'); } $mod = filter_text_input('mod', 'post'); if (empty($mod) or !preg_match($global_config['check_module'], $mod)) { die("NO_" . $mod); } $sql = "SELECT `submenu` FROM `" . NV_MODULES_TABLE . "` WHERE `title`=" . $db->dbescape($mod); $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows != 1) { die('NO_' . $mod); } $row = $db->sql_fetchrow($result); $submenu = $row['submenu'] ? 0 : 1; $sql = "UPDATE `" . NV_MODULES_TABLE . "` SET `submenu`=" . $submenu . " WHERE `title`=" . $db->dbescape($mod); $db->sql_query($sql); nv_del_moduleCache('modules'); include NV_ROOTDIR . "/includes/header.php"; echo 'OK_' . $mod; include NV_ROOTDIR . "/includes/footer.php";
if (!$db->sql_query($sql)) { die('NO_' . $modname); } } } } // Xoa du lieu tai bang nv3_vi_blocks $sql = "DELETE FROM `" . NV_BLOCKS_TABLE . "_weight` WHERE `bid` in (SELECT `bid` FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE `module`=" . $db->dbescape($modname) . ")"; if (!$db->sql_query($sql)) { die('NO_' . $modname); } $sql = "DELETE FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE `module`=" . $db->dbescape($modname); if (!$db->sql_query($sql)) { die('NO_' . $modname); } nv_del_moduleCache("themes"); $sql = "DELETE FROM `" . NV_PREFIXLANG . "_modthemes` WHERE `func_id` IN (SELECT `func_id` FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($modname) . ")"; if (!$db->sql_query($sql)) { die('NO_' . $modname); } // Xoa du lieu tai bang nv3_vi_modfuncs $sql = "DELETE FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($modname); if (!$db->sql_query($sql)) { die('NO_' . $modname); } // Xoa du lieu tai bang nv3_vi_modules $sql = "DELETE FROM `" . NV_MODULES_TABLE . "` WHERE `title`=" . $db->dbescape($modname); if (!$db->sql_query($sql)) { die('NO_' . $modname); } // Xoa du lieu tai bang nv3_config
$sth->bindParam(':theme', $theme, PDO::PARAM_STR); $sth->bindParam(':position', $pos_new, PDO::PARAM_STR); $sth->execute(); $weight = 0; while (list($bid_i) = $sth->fetch(3)) { ++$weight; $db->query('UPDATE ' . NV_BLOCKS_TABLE . '_groups SET weight=' . $weight . ' WHERE bid=' . $bid_i); } if ($weight) { $func_id_old = $weight = 0; $sth = $db->prepare('SELECT t1.bid, t1.func_id FROM ' . NV_BLOCKS_TABLE . '_weight t1 INNER JOIN ' . NV_BLOCKS_TABLE . '_groups t2 ON t1.bid = t2.bid WHERE t2.theme=:theme AND t2.position=:position ORDER BY t1.func_id ASC, t1.weight ASC'); $sth->bindParam(':theme', $theme, PDO::PARAM_STR); $sth->bindParam(':position', $pos_new, PDO::PARAM_STR); $sth->execute(); while (list($bid_i, $func_id_i) = $sth->fetch(3)) { if ($func_id_i == $func_id_old) { ++$weight; } else { $weight = 1; $func_id_old = $func_id_i; } $db->query('UPDATE ' . NV_BLOCKS_TABLE . '_weight SET weight=' . $weight . ' WHERE bid=' . $bid_i . ' AND func_id=' . $func_id_i); } } nv_del_moduleCache('themes'); $db->query('OPTIMIZE TABLE ' . NV_BLOCKS_TABLE . '_groups'); $db->query('OPTIMIZE TABLE ' . NV_BLOCKS_TABLE . '_weight'); echo $lang_module['block_update_success']; } else { echo 'ERROR'; }
$property['background_repeat'] = $nv_Request->get_title('block_heading_background_repeat', 'post', ''); $property['background_position'] = $nv_Request->get_title('block_heading_background_position', 'post', ''); $config_theme['block_heading'] = $property; unset($property); // General css $config_theme['generalcss'] = nv_unhtmlspecialchars($nv_Request->get_textarea('generalcss', 'post', '')); $config_value = serialize($config_theme); if (isset($module_config['themes'][$selectthemes])) { $sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value= :config_value WHERE config_name = :config_name AND lang = '" . NV_LANG_DATA . "' AND module='themes'"); } else { $sth = $db->prepare("INSERT INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES ('" . NV_LANG_DATA . "', 'themes', :config_name, :config_value)"); } $sth->bindParam(':config_name', $selectthemes, PDO::PARAM_STR); $sth->bindParam(':config_value', $config_value, PDO::PARAM_STR, strlen($config_value)); $sth->execute(); nv_del_moduleCache('settings'); if (file_exists(NV_ROOTDIR . "/" . SYSTEM_FILES_DIR . "/css/theme_" . $selectthemes . "_" . $global_config['idsite'] . ".css")) { nv_deletefile(NV_ROOTDIR . "/" . SYSTEM_FILES_DIR . "/css/theme_" . $selectthemes . "_" . $global_config['idsite'] . ".css"); } Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&selectthemes=' . $selectthemes . '&rand=' . nv_genpass()); die; } elseif (isset($module_config['themes'][$selectthemes])) { $config_theme = unserialize($module_config['themes'][$selectthemes]); } else { require NV_ROOTDIR . '/themes/' . $selectthemes . '/config_default.php'; } $xtpl = new XTemplate('config.tpl', NV_ROOTDIR . '/themes/' . $selectthemes . '/system/'); $xtpl->assign('LANG', $lang_module); $xtpl->assign('NV_LANG_VARIABLE', NV_LANG_VARIABLE); $xtpl->assign('NV_LANG_DATA', NV_LANG_DATA); $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
/** * nv_setup_block_module() * * @param mixed $mod * @param integer $func_id * @return */ function nv_setup_block_module($mod, $func_id = 0) { global $db; if (empty($func_id)) { //xoa du lieu tai bang blocks $sth = $db->prepare('DELETE FROM ' . NV_BLOCKS_TABLE . '_weight WHERE bid in (SELECT bid FROM ' . NV_BLOCKS_TABLE . '_groups WHERE module= :module)'); $sth->bindParam(':module', $mod, PDO::PARAM_STR); $sth->execute(); $sth = $db->prepare('DELETE FROM ' . NV_BLOCKS_TABLE . '_groups WHERE module= :module'); $sth->bindParam(':module', $mod, PDO::PARAM_STR); $sth->execute(); $sth = $db->prepare('DELETE FROM ' . NV_BLOCKS_TABLE . '_weight WHERE func_id in (SELECT func_id FROM ' . NV_MODFUNCS_TABLE . ' WHERE in_module= :module)'); $sth->bindParam(':module', $mod, PDO::PARAM_STR); $sth->execute(); } $array_funcid = array(); $sth = $db->prepare('SELECT func_id FROM ' . NV_MODFUNCS_TABLE . ' WHERE show_func = 1 AND in_module= :module ORDER BY subweight ASC'); $sth->bindParam(':module', $mod, PDO::PARAM_STR); $sth->execute(); while (list($func_id_i) = $sth->fetch(3)) { if ($func_id == 0 or $func_id == $func_id_i) { $array_funcid[] = $func_id_i; } } $weight = 0; $old_theme = $old_position = ''; $sql = 'SELECT bid, theme, position FROM ' . NV_BLOCKS_TABLE . '_groups WHERE all_func= 1 ORDER BY theme ASC, position ASC, weight ASC'; $result = $db->query($sql); while ($row = $result->fetch()) { if ($old_theme == $row['theme'] and $old_position == $row['position']) { ++$weight; } else { $weight = 1; $old_theme = $row['theme']; $old_position = $row['position']; } foreach ($array_funcid as $func_id) { $db->query('INSERT INTO ' . NV_BLOCKS_TABLE . '_weight (bid, func_id, weight) VALUES (' . $row['bid'] . ', ' . $func_id . ', ' . $weight . ')'); } } nv_del_moduleCache('themes'); }
/** * nv_block_voting() * * @return */ function nv_block_voting() { global $db, $my_footer, $site_mods, $global_config, $client_info; $content = ''; if (!isset($site_mods['voting'])) { return ''; } $sql = 'SELECT vid, question, link, acceptcm, groups_view, publ_time, exp_time FROM ' . NV_PREFIXLANG . '_' . $site_mods['voting']['module_data'] . ' WHERE act=1'; $list = nv_db_cache($sql, 'vid', 'voting'); if (empty($list)) { return ''; } $allowed = array(); $is_update = array(); $a = 0; foreach ($list as $row) { if ($row['exp_time'] > 0 and $row['exp_time'] < NV_CURRENTTIME) { $is_update[] = $row['vid']; } elseif ($row['publ_time'] <= NV_CURRENTTIME and nv_user_in_groups($row['groups_view'])) { $allowed[$a] = $row; ++$a; } } if (!empty($is_update)) { $is_update = implode(',', $is_update); $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $site_mods['voting']['module_data'] . ' SET act=0 WHERE vid IN (' . $is_update . ')'; $db->query($sql); nv_del_moduleCache('voting'); } if ($allowed) { --$a; $rand = rand(0, $a); $current_voting = $allowed[$rand]; $sql = 'SELECT id, vid, title, url FROM ' . NV_PREFIXLANG . '_' . $site_mods['voting']['module_data'] . '_rows WHERE vid = ' . $current_voting['vid'] . ' ORDER BY id ASC'; $list = nv_db_cache($sql, '', 'voting'); if (empty($list)) { return ''; } include NV_ROOTDIR . '/modules/' . $site_mods['voting']['module_file'] . '/language/' . NV_LANG_INTERFACE . '.php'; if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $site_mods['voting']['module_file'] . '/global.voting.tpl')) { $block_theme = $global_config['module_theme']; } elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/' . $site_mods['voting']['module_file'] . '/global.voting.tpl')) { $block_theme = $global_config['site_theme']; } else { $block_theme = 'default'; } if (file_exists(NV_ROOTDIR . '/themes/' . $block_theme . '/js/voting.js')) { $my_footer .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "themes/" . $block_theme . "/js/voting.js\"></script>\n"; } $action = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=voting'; $voting_array = array('checkss' => md5($current_voting['vid'] . $client_info['session_id'] . $global_config['sitekey']), 'accept' => (int) $current_voting['acceptcm'], 'errsm' => (int) $current_voting['acceptcm'] > 1 ? sprintf($lang_module['voting_warning_all'], (int) $current_voting['acceptcm']) : $lang_module['voting_warning_accept1'], 'vid' => $current_voting['vid'], 'question' => empty($current_voting['link']) ? $current_voting['question'] : '<a target="_blank" href="' . $current_voting['link'] . '">' . $current_voting['question'] . '</a>', 'action' => $action, 'langresult' => $lang_module['voting_result'], 'langsubmit' => $lang_module['voting_hits']); $xtpl = new XTemplate('global.voting.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/' . $site_mods['voting']['module_file']); $xtpl->assign('VOTING', $voting_array); foreach ($list as $row) { if (!empty($row['url'])) { $row['title'] = '<a target="_blank" href="' . $row['url'] . '">' . $row['title'] . '</a>'; } $xtpl->assign('RESULT', $row); if ((int) $current_voting['acceptcm'] > 1) { $xtpl->parse('main.resultn'); } else { $xtpl->parse('main.result1'); } } $xtpl->parse('main'); $content = $xtpl->text('main'); } return $content; }
/** * nv_setup_block_module() * * @param mixed $mod * @param integer $func_id * @return */ function nv_setup_block_module($mod, $func_id = 0) { global $db; if (empty($func_id)) { //xoa du lieu tai bang blocks $db->sql_query("DELETE FROM `" . NV_BLOCKS_TABLE . "_weight` WHERE `bid` in (SELECT `bid` FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE `module`=" . $db->dbescape($mod) . ")"); $db->sql_query("DELETE FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE `module`=" . $db->dbescape($mod)); $db->sql_query("DELETE FROM `" . NV_BLOCKS_TABLE . "_weight` WHERE `func_id` in (SELECT `func_id` FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($mod) . ")"); } $array_funcid = array(); $func_result = $db->sql_query("SELECT `func_id` FROM `" . NV_MODFUNCS_TABLE . "` WHERE `show_func` = '1' AND `in_module`=" . $db->dbescape($mod) . " ORDER BY `subweight` ASC"); while (list($func_id_i) = $db->sql_fetchrow($func_result)) { if ($func_id == 0 or $func_id == $func_id_i) { $array_funcid[] = $func_id_i; } } $weight = 0; $old_theme = $old_position = ""; $sql = "SELECT `bid`, `theme`, `position` FROM `" . NV_BLOCKS_TABLE . "_groups` WHERE `all_func`='1' ORDER BY `theme` ASC, `position` ASC, `weight` ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { if ($old_theme == $row['theme'] and $old_position == $row['position']) { ++$weight; } else { $weight = 1; $old_theme = $row['theme']; $old_position = $row['position']; } foreach ($array_funcid as $func_id) { $db->sql_query("INSERT INTO `" . NV_BLOCKS_TABLE . "_weight` (`bid`, `func_id`, `weight`) VALUES ('" . $row['bid'] . "', '" . $func_id . "', '" . $weight . "')"); } } nv_del_moduleCache("themes"); }
/** * nv_mod_blog::del_cache() * * @param mixed $module_name * @return */ private function del_cache($module_name) { return nv_del_moduleCache($module_name); }
/** * nv_show_funcs() * * @return void */ function nv_show_funcs() { global $db, $lang_module, $global_config, $site_mods; $mod = filter_text_input('mod', 'get', ''); if (empty($mod) or !preg_match($global_config['check_module'], $mod)) { die; } $sql = "SELECT `module_file`, `custom_title`, `admin_file` FROM `" . NV_MODULES_TABLE . "` WHERE `title`=" . $db->dbescape($mod); $result = $db->sql_query($sql); $numrows = $db->sql_numrows($result); if ($numrows != 1) { die; } $row = $db->sql_fetchrow($result); $custom_title = $row['custom_title']; $module_file = $db->unfixdb($row['module_file']); $admin_file = (file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/admin.functions.php") and file_exists(NV_ROOTDIR . "/modules/" . $module_file . "/admin/main.php")) ? 1 : 0; $is_delCache = false; if ($admin_file != intval($row['admin_file'])) { $sql = "UPDATE `" . NV_MODULES_TABLE . "` SET `admin_file`=" . $admin_file . " WHERE `title`=" . $db->dbescape($mod); $db->sql_query($sql); $is_delCache = true; } $local_funcs = nv_scandir(NV_ROOTDIR . '/modules/' . $module_file . '/funcs', $global_config['check_op_file']); if (!empty($local_funcs)) { $local_funcs = preg_replace($global_config['check_op_file'], "\\1", $local_funcs); $local_funcs = array_flip($local_funcs); } $module_version = array(); $version_file = NV_ROOTDIR . "/modules/" . $module_file . "/version.php"; if (file_exists($version_file)) { $module_name = $mod; require_once $version_file; } if (empty($module_version)) { $timestamp = NV_CURRENTTIME - date('Z', NV_CURRENTTIME); $module_version = array("name" => $mod, "modfuncs" => "main", "is_sysmod" => 0, "virtual" => 0, "version" => "3.0.01", "date" => date('D, j M Y H:i:s', $timestamp) . ' GMT', "author" => "", "note" => ""); } $module_version['submenu'] = isset($module_version['submenu']) ? trim($module_version['submenu']) : ""; $modfuncs = array_map("trim", explode(",", $module_version['modfuncs'])); $arr_in_submenu = array_map("trim", explode(",", $module_version['submenu'])); $data_funcs = array(); $weight_list = array(); $sql = "SELECT * FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($mod) . " ORDER BY `subweight` ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $func = $db->unfixdb($row['func_name']); $show_func = in_array($func, $modfuncs) ? 1 : 0; if ($row['show_func'] != $show_func) { $row['show_func'] = $show_func; $sql = "UPDATE `" . NV_MODFUNCS_TABLE . "` SET `show_func`=" . $show_func . " WHERE `func_id`=" . $row['func_id']; $db->sql_query($sql); $is_delCache = true; } $data_funcs[$func]['func_id'] = $row['func_id']; $data_funcs[$func]['layout'] = empty($row['layout']) ? '' : $row['layout']; $data_funcs[$func]['show_func'] = $row['show_func']; $data_funcs[$func]['func_custom_name'] = $row['func_custom_name']; $data_funcs[$func]['in_submenu'] = $row['in_submenu']; $data_funcs[$func]['subweight'] = $row['subweight']; if ($show_func) { $weight_list[] = $row['subweight']; } } $act_funcs = array_intersect_key($data_funcs, $local_funcs); $old_funcs = array_diff_key($data_funcs, $local_funcs); $new_funcs = array_diff_key($local_funcs, $data_funcs); $is_refresh = false; if (!empty($old_funcs)) { foreach ($old_funcs as $func => $values) { $sql = "DELETE FROM `" . NV_BLOCKS_TABLE . "_weight` WHERE `func_id` = " . $values['func_id']; $db->sql_query($sql); $sql = "DELETE FROM `" . NV_MODFUNCS_TABLE . "` WHERE `func_id` = " . $values['func_id']; $db->sql_query($sql); $sql = "DELETE FROM `" . NV_PREFIXLANG . "_modthemes` WHERE `func_id` = " . $values['func_id']; $db->sql_query($sql); $is_delCache = true; } $db->sql_query("OPTIMIZE TABLE `" . NV_BLOCKS_TABLE . "_weight`"); $db->sql_query("OPTIMIZE TABLE `" . NV_MODFUNCS_TABLE . "`"); $db->sql_query("OPTIMIZE TABLE `" . NV_PREFIXLANG . "_modthemes`"); $is_refresh = true; } if (!empty($new_funcs)) { $mod_theme = "default"; if (!empty($site_mods[$mod]['theme']) and file_exists(NV_ROOTDIR . '/themes/' . $site_mods[$mod]['theme'] . '/config.ini')) { $mod_theme = $site_mods[$mod]['theme']; } if (!empty($global_config['site_theme']) and file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini')) { $mod_theme = $global_config['site_theme']; } $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $mod_theme . '/config.ini'); $layoutdefault = (string) $xml->layoutdefault; $array_keys = array_keys($new_funcs); foreach ($array_keys as $func) { $show_func = in_array($func, $modfuncs) ? 1 : 0; $sql = "INSERT INTO `" . NV_MODFUNCS_TABLE . "` (`func_id`, `func_name`, `func_custom_name`, `in_module`, `show_func`, `in_submenu`, `subweight`, `setting`) VALUES (NULL, " . $db->dbescape($func) . ", " . $db->dbescape(ucfirst($func)) . ", " . $db->dbescape($mod) . ", " . $show_func . ", 0, 0, '')"; $func_id = $db->sql_query_insert_id($sql); if ($show_func) { $db->sql_query("INSERT INTO `" . NV_PREFIXLANG . "_modthemes` (`func_id`, `layout`, `theme`) VALUES ('" . $func_id . "'," . $db->dbescape($layoutdefault) . ", " . $db->dbescape($mod_theme) . ")"); nv_setup_block_module($mod, $func_id); } } $is_refresh = true; $is_delCache = true; } if ($is_refresh) { nv_fix_subweight($mod); $act_funcs = array(); $weight_list = array(); $sql = "SELECT * FROM `" . NV_MODFUNCS_TABLE . "` WHERE `in_module`=" . $db->dbescape($mod) . " AND `show_func`='1' ORDER BY `subweight` ASC"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $func = $db->unfixdb($row['func_name']); $act_funcs[$func]['func_id'] = $row['func_id']; $act_funcs[$func]['layout'] = empty($row['layout']) ? "" : $row['layout']; $act_funcs[$func]['show_func'] = $row['show_func']; $act_funcs[$func]['func_custom_name'] = $row['func_custom_name']; $act_funcs[$func]['in_submenu'] = $row['in_submenu']; $act_funcs[$func]['subweight'] = $row['subweight']; $weight_list[] = $row['subweight']; } } if ($is_delCache) { nv_del_moduleCache('modules'); nv_del_moduleCache('themes'); } $contents = array(); $contents['caption'] = sprintf($lang_module['funcs_list'], $custom_title); $contents['thead'] = array($lang_module['funcs_subweight'], $lang_module['funcs_in_submenu'], $lang_module['funcs_title'], $lang_module['custom_title'], $lang_module['funcs_layout']); $contents['weight_list'] = $weight_list; foreach ($act_funcs as $funcs => $values) { if ($values['show_func']) { $func_id = $values['func_id']; $contents['rows'][$func_id]['weight'] = array($values['subweight'], "nv_chang_func_weight(" . $func_id . ");"); $contents['rows'][$func_id]['name'] = array($funcs, $values['func_custom_name'], "nv_change_custom_name(" . $values['func_id'] . ",'action');"); $contents['rows'][$func_id]['layout'] = array($values['layout'], "nv_chang_func_layout(" . $func_id . ");"); $contents['rows'][$func_id]['in_submenu'] = array($values['in_submenu'], "nv_chang_func_in_submenu(" . $func_id . ");"); $contents['rows'][$func_id]['disabled'] = in_array($funcs, $arr_in_submenu) ? "" : " disabled"; } } include NV_ROOTDIR . "/includes/header.php"; echo aj_show_funcs_theme($contents); include NV_ROOTDIR . "/includes/footer.php"; }
/** * nv_block_freecontent() * * @return */ function nv_block_freecontent($block_config) { global $global_config, $site_mods, $module_config, $db; $module = $block_config['module']; // Set content status if (!empty($module_config[$module]['next_execute']) and $module_config[$module]['next_execute'] <= NV_CURRENTTIME) { $sql = 'UPDATE ' . NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'] . '_rows SET status = 2 WHERE end_time > 0 AND end_time < ' . NV_CURRENTTIME; $db->query($sql); // Get next execute $sql = 'SELECT MIN(end_time) next_execute FROM ' . NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'] . '_rows WHERE end_time > 0 AND status = 1'; $result = $db->query($sql); $next_execute = intval($result->fetchColumn()); $sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang = '" . NV_LANG_DATA . "' AND module = :module_name AND config_name = 'next_execute'"); $sth->bindParam(':module_name', $module, PDO::PARAM_STR); $sth->bindParam(':config_value', $next_execute, PDO::PARAM_STR); $sth->execute(); nv_del_moduleCache('settings'); nv_del_moduleCache($module); unset($next_execute); } if (!isset($site_mods[$module]) or empty($block_config['blockid'])) { return ''; } $sql = 'SELECT id, title, description, image, link, target FROM ' . NV_PREFIXLANG . '_' . $site_mods[$module]['module_data'] . '_rows WHERE status = 1 AND bid = ' . $block_config['blockid']; $list = nv_db_cache($sql, 'id', $module); if (!empty($list)) { if (file_exists(NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $site_mods[$module]['module_file'] . '/block.free_content.tpl')) { $block_theme = $global_config['module_theme']; } elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/modules/' . $site_mods[$module]['module_file'] . '/block.free_content.tpl')) { $block_theme = $global_config['site_theme']; } else { $block_theme = 'default'; } $xtpl = new XTemplate('block.free_content.tpl', NV_ROOTDIR . '/themes/' . $block_theme . '/modules/' . $site_mods[$module]['module_file']); shuffle($list); if ($block_config['numrows'] <= sizeof($list)) { $list = array_slice($list, 0, $block_config['numrows']); } foreach ($list as $row) { if (!empty($row['image'])) { $row['image'] = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $site_mods[$module]['module_upload'] . '/' . $row['image']; } $xtpl->assign('ROW', $row); if (!empty($row['link'])) { if (!empty($row['target'])) { $xtpl->parse('main.loop.title_link.target'); } $xtpl->parse('main.loop.title_link'); } else { $xtpl->parse('main.loop.title_text'); } if (!empty($row['image'])) { if (!empty($row['link'])) { if (!empty($row['target'])) { $xtpl->parse('main.loop.image_link.target'); } $xtpl->parse('main.loop.image_link'); } else { $xtpl->parse('main.loop.image_only'); } } $xtpl->parse('main.loop'); } $xtpl->parse('main'); return $xtpl->text('main'); } return ''; }
/** * nv_set_status_module() * * @return */ function nv_set_status_module() { global $db, $module_name, $module_data, $global_config, $db_config; $check_run_cronjobs = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/data_logs/cronjobs_' . md5($module_data . 'nv_set_status_module' . $global_config['sitekey']) . '.txt'; $p = NV_CURRENTTIME - 300; if (file_exists($check_run_cronjobs) and @filemtime($check_run_cronjobs) > $p) { return; } file_put_contents($check_run_cronjobs, ''); // status_0 = "Cho duyet"; // status_1 = "Xuat ban"; // status_2 = "Hen gio dang"; // status_3= "Het han"; // Dang cac san pham cho kich hoat theo thoi gian $result = $db->query('SELECT id FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =2 AND publtime < ' . NV_CURRENTTIME . ' ORDER BY publtime ASC'); while (list($id) = $result->fetch(3)) { $db->query('UPDATE ' . $db_config['prefix'] . '_' . $module_data . '_rows SET status =1 WHERE id=' . $id); } // Ngung hieu luc cac san pham da het han $result = $db->query('SELECT id, archive FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =1 AND exptime > 0 AND exptime <= ' . NV_CURRENTTIME . ' ORDER BY exptime ASC'); while (list($id, $archive) = $result->fetch(3)) { if (intval($archive) == 0) { nv_del_content_module($id); } else { nv_archive_content_module($id); } } // Tim kiem thoi gian chay lan ke tiep $time_publtime = $db->query('SELECT MIN(publtime) FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =2 AND publtime > ' . NV_CURRENTTIME)->fetchColumn(); $time_exptime = $db->query('SELECT MIN(exptime) FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE status =1 AND exptime > ' . NV_CURRENTTIME)->fetchColumn(); $timecheckstatus = min($time_publtime, $time_exptime); if (!$timecheckstatus) { $timecheckstatus = max($time_publtime, $time_exptime); } $db->query("REPLACE INTO " . NV_CONFIG_GLOBALTABLE . " (lang, module, config_name, config_value) VALUES('" . NV_LANG_DATA . "', " . $db->quote($module_name) . ", 'timecheckstatus', '" . intval($timecheckstatus) . "')"); nv_del_moduleCache('settings'); nv_del_moduleCache($module_name); unlink($check_run_cronjobs); clearstatcache(); }
} else { $content = $nv_Request->get_textarea('content', '', NV_ALLOWED_HTML_TAGS, 1); $active = $nv_Request->get_int('active', 'post', 0); $active = $active == 1 ? 1 : 0; $stmt = $db->prepare('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . ' SET content= :content, status=' . $active . ' WHERE cid=' . $cid); $stmt->bindParam(':content', $content, PDO::PARAM_STR); $stmt->execute(); $count = $stmt->rowCount(); } if ($count) { nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['edit_title'] . ': ' . $row['module'] . ', id: ' . $row['id'] . ', cid: ' . $row['cid'], $row['content'], $admin_info['userid']); if (isset($site_mods[$row['module']])) { $mod_info = $site_mods[$row['module']]; if (file_exists(NV_ROOTDIR . '/modules/' . $mod_info['module_file'] . '/comment.php')) { include NV_ROOTDIR . '/modules/' . $mod_info['module_file'] . '/comment.php'; nv_del_moduleCache($row['module']); } } } header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name); die; } $row['content'] = nv_htmlspecialchars(nv_br2nl($row['content'])); $row['status'] = $row['status'] ? 'checked="checked"' : ''; $xtpl = new XTemplate('edit.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); $xtpl->assign('GLANG', $lang_global); $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);
/** * nv_insert_logs() * * @param string $lang * @param string $module_name * @param string $name_key * @param string $note_action * @param integer $userid * @param string $link_acess * @return */ function nv_insert_logs($lang = "", $module_name = "", $name_key = "", $note_action = "", $userid = 0, $link_acess = "") { global $db_config, $db; $sql = "INSERT INTO `" . $db_config['prefix'] . "_logs` (`id` ,`lang`,`module_name`,`name_key`,`note_action` ,`link_acess` ,`userid` ,`log_time` ) VALUES ( NULL , " . $db->dbescape($lang) . ", " . $db->dbescape($module_name) . ", " . $db->dbescape($name_key) . ", " . $db->dbescape($note_action) . ", " . $db->dbescape($note_action) . ", " . intval($userid) . ", " . NV_CURRENTTIME . ");"; if ($db->sql_query_insert_id($sql)) { nv_del_moduleCache('siteinfo'); return true; } return false; }
/** * nv_groups_list_pub() * * @return */ function nv_groups_list_pub() { global $db, $db_config, $global_config; $query = 'SELECT group_id, title, exp_time, publics FROM ' . NV_GROUPS_GLOBALTABLE . ' WHERE act=1 AND (idsite = ' . $global_config['idsite'] . ' OR (idsite =0 AND siteus = 1)) ORDER BY idsite, weight'; $list = nv_db_cache($query, '', 'users'); if (empty($list)) { return array(); } $groups = array(); $reload = array(); for ($i = 0, $count = sizeof($list); $i < $count; ++$i) { if ($list[$i]['exp_time'] != 0 and $list[$i]['exp_time'] <= NV_CURRENTTIME) { $reload[] = $list[$i]['group_id']; } elseif ($list[$i]['publics']) { $groups[$list[$i]['group_id']] = $list[$i]['title']; } } if ($reload) { $db->query('UPDATE ' . NV_GROUPS_GLOBALTABLE . ' SET act=0 WHERE group_id IN (' . implode(',', $reload) . ')'); nv_del_moduleCache('users'); } return $groups; }
/** * nv_block_voting() * * @return */ function nv_block_voting() { global $db, $my_head, $site_mods, $global_config, $client_info; $content = ""; if (!isset($site_mods['voting'])) { return ""; } $sql = "SELECT `vid`, `question`, `link`, `acceptcm`, `who_view`, `groups_view`, `publ_time`, `exp_time` \n FROM `" . NV_PREFIXLANG . "_" . $site_mods['voting']['module_data'] . "` \n WHERE `act`=1"; $list = nv_db_cache($sql, 'vid', 'voting'); if (empty($list)) { return ""; } $allowed = array(); $is_update = array(); $a = 0; foreach ($list as $row) { if ($row['exp_time'] > 0 and $row['exp_time'] < NV_CURRENTTIME) { $is_update[] = $row['vid']; } elseif ($row['publ_time'] <= NV_CURRENTTIME and nv_set_allow($row['who_view'], $row['groups_view'])) { $allowed[$a] = $row; ++$a; } } if (!empty($is_update)) { $is_update = implode(",", $is_update); $sql = "UPDATE `" . NV_PREFIXLANG . "_" . $site_mods['voting']['module_data'] . "` SET `act`=0 WHERE `vid` IN (" . $is_update . ")"; $db->sql_query($sql); nv_del_moduleCache('voting'); } if ($allowed) { --$a; $rand = rand(0, $a); $current_voting = $allowed[$rand]; $sql = "SELECT `id`, `vid`, `title`, `url` FROM `" . NV_PREFIXLANG . "_" . $site_mods['voting']['module_data'] . "_rows` \n WHERE `vid` = " . $current_voting['vid'] . " ORDER BY `id` ASC"; $list = nv_db_cache($sql, '', 'voting'); if (empty($list)) { return ""; } include NV_ROOTDIR . "/modules/" . $site_mods['voting']['module_file'] . "/language/" . NV_LANG_INTERFACE . ".php"; if (file_exists(NV_ROOTDIR . "/themes/" . $global_config['module_theme'] . "/modules/" . $site_mods['voting']['module_file'] . "/global.voting.tpl")) { $block_theme = $global_config['module_theme']; } elseif (file_exists(NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/modules/" . $site_mods['voting']['module_file'] . "/global.voting.tpl")) { $block_theme = $global_config['site_theme']; } else { $block_theme = "default"; } if (!defined('SHADOWBOX')) { $my_head .= "<link rel=\"Stylesheet\" href=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.css\" />\n"; $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/shadowbox/shadowbox.js\"></script>\n"; $my_head .= "<script type=\"text/javascript\">Shadowbox.init();</script>"; define('SHADOWBOX', true); } $my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "modules/" . $site_mods['voting']['module_file'] . "/js/user.js\"></script>\n"; $action = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&" . NV_NAME_VARIABLE . "=voting"; $voting_array = array("checkss" => md5($current_voting['vid'] . $client_info['session_id'] . $global_config['sitekey']), "accept" => (int) $current_voting['acceptcm'], "errsm" => (int) $current_voting['acceptcm'] > 1 ? sprintf($lang_module['voting_warning_all'], (int) $current_voting['acceptcm']) : $lang_module['voting_warning_accept1'], "vid" => $current_voting['vid'], "question" => empty($current_voting['link']) ? $current_voting['question'] : '<a target="_blank" href="' . $current_voting['link'] . '">' . $current_voting['question'] . '</a>', "action" => $action, "langresult" => $lang_module['voting_result'], "langsubmit" => $lang_module['voting_hits']); $xtpl = new XTemplate("global.voting.tpl", NV_ROOTDIR . "/themes/" . $block_theme . "/modules/" . $site_mods['voting']['module_file']); $xtpl->assign('VOTING', $voting_array); foreach ($list as $row) { if (!empty($row['url'])) { $row['title'] = '<a target="_blank" href="' . $row['url'] . '">' . $row['title'] . '</a>'; } $xtpl->assign('RESULT', $row); if ((int) $current_voting['acceptcm'] > 1) { $xtpl->parse('main.resultn'); } else { $xtpl->parse('main.result1'); } } $xtpl->parse('main'); $content = $xtpl->text('main'); } return $content; }
$bid = $nv_Request->get_int('bid', 'get,post', $cookie_bid); if (!in_array($bid, array_keys($array_block))) { $bid_array_id = array_keys($array_block); $bid = $bid_array_id[0]; } if ($cookie_bid != $bid) { $nv_Request->set_Cookie('int_bid', $bid, NV_LIVE_COOKIE_TIME); } $page_title = $array_block[$bid]; if ($nv_Request->isset_request('checkss,idcheck', 'post') and $nv_Request->get_string('checkss', 'post') == md5(session_id())) { $id_array = array_map('intval', $nv_Request->get_array('idcheck', 'post')); foreach ($id_array as $id) { $db->query("INSERT INTO " . $db_config['prefix'] . "_" . $module_data . "_block (bid, id, weight) VALUES ('" . $bid . "', '" . $id . "', '0')"); } nv_news_fix_block($bid); nv_del_moduleCache($module_name); Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&bid=' . $bid); die; } $xtpl = new XTemplate('block.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); $xtpl->assign('GLANG', $lang_global); $xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL); $xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE); $xtpl->assign('NV_OP_VARIABLE', NV_OP_VARIABLE); $xtpl->assign('MODULE_NAME', $module_name); $xtpl->assign('OP', $op); $xtpl->assign('CHECKSESS', md5(session_id())); $xtpl->assign('BLOCK_LIST', nv_show_block_list($bid)); $id_array = array(); $listid = $nv_Request->get_string('listid', 'get', '');
/** * nv_show_funcs() * * @return void */ function nv_show_funcs() { global $db, $lang_module, $global_config, $site_mods, $nv_Request, $module_file; $mod = $nv_Request->get_title('mod', 'get', ''); if (empty($mod) or !preg_match($global_config['check_module'], $mod)) { die; } $sth = $db->prepare('SELECT module_file, custom_title, admin_file FROM ' . NV_MODULES_TABLE . ' WHERE title= :mod'); $sth->bindParam(':mod', $mod, PDO::PARAM_STR); $sth->execute(); $row = $sth->fetch(); if (empty($row)) { die; } $custom_title = $row['custom_title']; $mod_file = $row['module_file']; $admin_file = (file_exists(NV_ROOTDIR . '/modules/' . $mod_file . '/admin.functions.php') and file_exists(NV_ROOTDIR . '/modules/' . $mod_file . '/admin/main.php')) ? 1 : 0; $is_delCache = false; if ($admin_file != intval($row['admin_file'])) { $sth = $db->prepare('UPDATE ' . NV_MODULES_TABLE . ' SET admin_file=' . $admin_file . ' WHERE title= :title'); $sth->bindParam(':title', $mod, PDO::PARAM_STR); $sth->execute(); $is_delCache = true; } $local_funcs = nv_scandir(NV_ROOTDIR . '/modules/' . $mod_file . '/funcs', $global_config['check_op_file']); if (!empty($local_funcs)) { $local_funcs = preg_replace($global_config['check_op_file'], '\\1', $local_funcs); $local_funcs = array_flip($local_funcs); } $module_version = array(); $version_file = NV_ROOTDIR . '/modules/' . $mod_file . '/version.php'; if (file_exists($version_file)) { $module_name = $mod; require_once $version_file; } if (empty($module_version)) { $timestamp = NV_CURRENTTIME - date('Z', NV_CURRENTTIME); $module_version = array('name' => $mod, 'modfuncs' => 'main', 'is_sysmod' => 0, 'virtual' => 0, 'version' => '4.0.00', 'date' => date('D, j M Y H:i:s', $timestamp) . ' GMT', 'author' => '', 'note' => ''); } $module_version['submenu'] = isset($module_version['submenu']) ? trim($module_version['submenu']) : ''; $modfuncs = array_map('trim', explode(',', $module_version['modfuncs'])); $arr_in_submenu = array_map('trim', explode(',', $module_version['submenu'])); $data_funcs = array(); $weight_list = array(); $sth = $db->prepare('SELECT * FROM ' . NV_MODFUNCS_TABLE . ' WHERE in_module= :in_module ORDER BY subweight ASC'); $sth->bindParam(':in_module', $mod, PDO::PARAM_STR); $sth->execute(); while ($row = $sth->fetch()) { $func = $row['func_name']; $show_func = in_array($func, $modfuncs) ? 1 : 0; if ($row['show_func'] != $show_func) { $row['show_func'] = $show_func; $db->query('UPDATE ' . NV_MODFUNCS_TABLE . ' SET show_func=' . $show_func . ' WHERE func_id=' . $row['func_id']); $is_delCache = true; } $data_funcs[$func]['func_id'] = $row['func_id']; $data_funcs[$func]['layout'] = empty($row['layout']) ? '' : $row['layout']; $data_funcs[$func]['show_func'] = $row['show_func']; $data_funcs[$func]['alias'] = $row['alias']; $data_funcs[$func]['func_custom_name'] = $row['func_custom_name']; $data_funcs[$func]['in_submenu'] = $row['in_submenu']; $data_funcs[$func]['subweight'] = $row['subweight']; if ($show_func) { $weight_list[] = $row['subweight']; } } $act_funcs = array_intersect_key($data_funcs, $local_funcs); $old_funcs = array_diff_key($data_funcs, $local_funcs); $new_funcs = array_diff_key($local_funcs, $data_funcs); $is_refresh = false; if (!empty($old_funcs)) { foreach ($old_funcs as $func => $values) { $db->query('DELETE FROM ' . NV_BLOCKS_TABLE . '_weight WHERE func_id = ' . $values['func_id']); $db->query('DELETE FROM ' . NV_MODFUNCS_TABLE . ' WHERE func_id = ' . $values['func_id']); $db->query('DELETE FROM ' . NV_PREFIXLANG . '_modthemes WHERE func_id = ' . $values['func_id']); $is_delCache = true; } $db->query('OPTIMIZE TABLE ' . NV_BLOCKS_TABLE . '_weight'); $db->query('OPTIMIZE TABLE ' . NV_MODFUNCS_TABLE); $db->query('OPTIMIZE TABLE ' . NV_PREFIXLANG . '_modthemes'); $is_refresh = true; } if (!empty($new_funcs)) { $mod_theme = 'default'; if (!empty($site_mods[$mod]['theme']) and file_exists(NV_ROOTDIR . '/themes/' . $site_mods[$mod]['theme'] . '/config.ini')) { $mod_theme = $site_mods[$mod]['theme']; } elseif (!empty($global_config['site_theme']) and file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini')) { $mod_theme = $global_config['site_theme']; } $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $mod_theme . '/config.ini'); $layoutdefault = (string) $xml->layoutdefault; $array_keys = array_keys($new_funcs); $sth2 = $db->prepare('INSERT INTO ' . NV_PREFIXLANG . '_modthemes (func_id, layout, theme) VALUES (:func_id, :layout, :theme)'); foreach ($array_keys as $func) { $show_func = in_array($func, $modfuncs) ? 1 : 0; try { $data = array(); $data['func_name'] = $func; $data['alias'] = $func; $data['func_custom_name'] = ucfirst($func); $data['in_module'] = $mod; $_sql = "INSERT INTO " . NV_MODFUNCS_TABLE . " (func_name, alias, func_custom_name, in_module, show_func, in_submenu, subweight, setting) VALUES ( :func_name, :alias, :func_custom_name, :in_module, " . $show_func . ", 0, 0, '')"; $func_id = $db->insert_id($_sql, 'func_id', $data); if ($show_func) { $sth2->bindParam(':func_id', $func_id, PDO::PARAM_INT); $sth2->bindParam(':layout', $layoutdefault, PDO::PARAM_STR); $sth2->bindParam(':theme', $mod_theme, PDO::PARAM_STR); $sth2->execute(); nv_setup_block_module($mod, $func_id); } } catch (PDOException $e) { } } $is_refresh = true; $is_delCache = true; } if ($is_refresh) { nv_fix_subweight($mod); $act_funcs = array(); $weight_list = array(); $sth = $db->prepare('SELECT * FROM ' . NV_MODFUNCS_TABLE . ' WHERE in_module= :in_module AND show_func=1 ORDER BY subweight ASC'); $sth->bindParam(':in_module', $mod, PDO::PARAM_STR); $sth->execute(); while ($row = $sth->fetch()) { $func = $row['func_name']; $act_funcs[$func]['func_id'] = $row['func_id']; $act_funcs[$func]['layout'] = empty($row['layout']) ? '' : $row['layout']; $act_funcs[$func]['show_func'] = $row['show_func']; $act_funcs[$func]['alias'] = $row['alias']; $act_funcs[$func]['func_custom_name'] = $row['func_custom_name']; $act_funcs[$func]['in_submenu'] = $row['in_submenu']; $act_funcs[$func]['subweight'] = $row['subweight']; $weight_list[] = $row['subweight']; } } if ($is_delCache) { nv_del_moduleCache('modules'); nv_del_moduleCache('themes'); } $fun_change_alias = isset($module_version['change_alias']) ? explode(',', $module_version['change_alias']) : array(); if (empty($fun_change_alias)) { $module_version['virtual'] = 0; } $xtpl = new XTemplate('aj_show_funcs_theme.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file); $xtpl->assign('LANG', $lang_module); foreach ($act_funcs as $funcs => $values) { if ($values['show_func']) { $values['func_name'] = $funcs; $values['in_submenu_checked'] = $values['in_submenu'] ? 'checked="checked" ' : ''; $values['disabled'] = in_array($funcs, $arr_in_submenu) ? '' : ' disabled'; $xtpl->assign('ROW', $values); foreach ($weight_list as $new_weight) { $xtpl->assign('WEIGHT', array('key' => $new_weight, 'selected' => $new_weight == $values['subweight'] ? ' selected="selected"' : '')); $xtpl->parse('main.loop.weight'); } if ($module_version['virtual']) { if ($funcs != 'main' and in_array($funcs, $fun_change_alias)) { $xtpl->parse('main.loop.change_alias'); } else { $xtpl->parse('main.loop.show_alias'); } } $xtpl->parse('main.loop'); } } if ($module_version['virtual']) { $xtpl->parse('main.change_alias_head'); } $xtpl->parse('main'); include NV_ROOTDIR . '/includes/header.php'; echo $xtpl->text('main'); include NV_ROOTDIR . '/includes/footer.php'; }