Skip to content

Commit

Permalink
Merge pull request #91 from nukeviet/develop
Browse files Browse the repository at this point in the history
Update Code
  • Loading branch information
vuthao committed Sep 10, 2016
2 parents bfcf669 + 61b62bb commit 7b74d49
Show file tree
Hide file tree
Showing 24 changed files with 405 additions and 146 deletions.
31 changes: 31 additions & 0 deletions admin/language/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,35 @@ function nv_admin_add_field_lang($dirlang)
}
}

/**
* nv_update_config_allow_sitelangs()
*
* @param mixed $allow_sitelangs
* @return void
*/
function nv_update_config_allow_sitelangs($allow_sitelangs = array())
{
global $global_config, $db_config, $db;

if (defined('NV_IS_GODADMIN') or ($global_config['idsite'] > 0 and defined('NV_IS_SPADMIN'))) {
if (empty($allow_sitelangs)) {
$allow_sitelangs = $global_config['allow_sitelangs'];
}

$sql = 'SELECT lang FROM ' . $db_config['prefix'] . '_setup_language ORDER BY weight ASC';
$result = $db->query($sql);

$sitelangs = array();
while ($row = $result->fetch()) {
if (in_array($row['lang'], $allow_sitelangs)) {
$sitelangs[] = $row['lang'];
}
}

$sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang='sys' AND module = 'global' AND config_name = 'allow_sitelangs'");
$sth->bindValue(':config_value', implode(',', $sitelangs), PDO::PARAM_STR);
$sth->execute();
}
}

$language_array = nv_parse_ini_file(NV_ROOTDIR . '/includes/ini/langs.ini', true);
137 changes: 110 additions & 27 deletions admin/language/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,54 @@
$xtpl->assign('GLANG', $lang_global);

$array_lang_setup = array();
$result = $db->query('SELECT lang, setup FROM ' . $db_config['prefix'] . '_setup_language');
$db->sqlreset()->select('*')->from($db_config['prefix'] . '_setup_language')->order('weight ASC');
$result = $db->query($db->sql());
while ($row = $result->fetch()) {
$array_lang_setup[$row['lang']] = intval($row['setup']);
}

if (defined('NV_IS_GODADMIN') or ($global_config['idsite'] > 0 and defined('NV_IS_SPADMIN'))) {
// Change weight
if ($nv_Request->isset_request('changeweight', 'post')) {
if (!defined('NV_IS_AJAX')) {
die('NO_Access denied!!!');
}

$keylang = $nv_Request->get_title('keylang', 'post', '');

if (!isset($array_lang_setup[$keylang])) {
die('NO_Access denied!!!');
}

$new_weight = $nv_Request->get_int('new_weight', 'post', 0);
if (empty($new_weight)) {
die('NO_Access denied!!!');
}

$sql = 'SELECT lang FROM ' . $db_config['prefix'] . '_setup_language WHERE lang!=' . $db->quote($keylang) . ' ORDER BY weight ASC';
$result = $db->query($sql);

$weight = 0;
while ($row = $result->fetch()) {
++$weight;
if ($weight == $new_weight)
++$weight;

$sql = 'UPDATE ' . $db_config['prefix'] . '_setup_language SET weight=' . $weight . ' WHERE lang=' . $db->quote($row['lang']);
$db->query($sql);
}

$sql = 'UPDATE ' . $db_config['prefix'] . '_setup_language SET weight=' . $new_weight . ' WHERE lang=' . $db->quote($keylang);
$db->query($sql);

nv_update_config_allow_sitelangs();
nv_save_file_config_global();

include NV_ROOTDIR . '/includes/header.php';
echo 'OK_' . $keylang;
include NV_ROOTDIR . '/includes/footer.php';
}

$checksess = $nv_Request->get_title('checksess', 'get', '');
$keylang = $nv_Request->get_title('keylang', 'get', '', 1);
$deletekeylang = $nv_Request->get_title('deletekeylang', 'get', '', 1);
Expand All @@ -82,13 +124,8 @@
$keylang
));
}

$allow_sitelangs = array_unique($allow_sitelangs);

$sth = $db->prepare("UPDATE " . NV_CONFIG_GLOBALTABLE . " SET config_value = :config_value WHERE lang='sys' AND module = 'global' AND config_name = 'allow_sitelangs'");
$sth->bindValue(':config_value', implode(',', $allow_sitelangs), PDO::PARAM_STR);
$sth->execute();


nv_update_config_allow_sitelangs(array_unique($allow_sitelangs));
nv_save_file_config_global();

$xtpl->assign('URL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op);
Expand Down Expand Up @@ -312,6 +349,19 @@

$db->query("DELETE FROM " . NV_CONFIG_GLOBALTABLE . " WHERE lang = '" . $deletekeylang . "'");
$db->query("DELETE FROM " . $db_config['prefix'] . "_setup_language WHERE lang = '" . $deletekeylang . "'");

$sql = 'SELECT lang FROM ' . $db_config['prefix'] . '_setup_language ORDER BY weight ASC';
$result = $db->query($sql);

$weight = 0;
while ($row = $result->fetch()) {
++$weight;
if ($weight == $new_weight)
++$weight;

$sql = 'UPDATE ' . $db_config['prefix'] . '_setup_language SET weight=' . $weight . ' WHERE lang=' . $db->quote($row['lang']);
$db->query($sql);
}

$nv_Cache->delAll();

Expand All @@ -320,24 +370,37 @@
}
}

$a = 0;
foreach ($lang_array_exit as $keylang) {
$delete = '';
$allow_sitelangs = '';

$xtpl->assign('ROW', array(
'keylang' => $keylang,
'name' => $language_array[$keylang]['name']
));

if (defined('NV_IS_GODADMIN') or ($global_config['idsite'] > 0 and defined('NV_IS_SPADMIN'))) {
if (isset($array_lang_setup[$keylang]) and $array_lang_setup[$keylang] == 1) {
$array_lang_installed = array();
$num = sizeof($array_lang_setup);
$weight = 0;
foreach ($array_lang_setup as $keylang => $setup) {
if (in_array($keylang, $lang_array_exit)) {
$weight ++;
$xtpl->assign('ROW', array(
'keylang' => $keylang,
'name' => $language_array[$keylang]['name']
));

if ($setup == 1) {
$array_lang_installed[$keylang] = $keylang;
}

for ($i = 1; $i <= $num; ++$i) {
$xtpl->assign('WEIGHT', array(
'w' => $i,
'selected' => ($i == $weight) ? ' selected="selected"' : ''
));

$xtpl->parse('main.installed_loop.weight');
}

if (defined('NV_IS_GODADMIN') or ($global_config['idsite'] > 0 and defined('NV_IS_SPADMIN')) and $setup == 1) {
if (!in_array($keylang, $global_config['allow_sitelangs'])) {
$xtpl->assign('DELETE', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $op . '&amp;deletekeylang=' . $keylang . '&amp;checksess=' . md5($keylang . NV_CHECK_SESSION . 'deletekeylang'));

$xtpl->parse('main.loop.setup_delete');
$xtpl->parse('main.installed_loop.setup_delete');
} else {
$xtpl->parse('main.loop.setup_note');
$xtpl->parse('main.installed_loop.setup_note');
}

if ($keylang != $global_config['site_lang']) {
Expand All @@ -356,16 +419,36 @@
'url_no' => NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $op . '&amp;keylang=' . $keylang . '&amp;activelang=0&amp;checksess=' . md5('activelang_' . $keylang . NV_CHECK_SESSION)
));

$xtpl->parse('main.loop.allow_sitelangs');
$xtpl->parse('main.installed_loop.allow_sitelangs');
} else {
$xtpl->parse('main.loop.allow_sitelangs_note');
$xtpl->parse('main.installed_loop.allow_sitelangs_note');
}
} else {
}

$xtpl->parse('main.installed_loop');
}
}

$lang_can_install = false;
foreach ($lang_array_exit as $keylang) {
if (!isset($array_lang_installed[$keylang])) {
$lang_can_install = true;

$xtpl->assign('ROW', array(
'keylang' => $keylang,
'name' => $language_array[$keylang]['name']
));

if (defined('NV_IS_GODADMIN') or ($global_config['idsite'] > 0 and defined('NV_IS_SPADMIN'))) {
$xtpl->assign('INSTALL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=' . $op . '&amp;keylang=' . $keylang . '&amp;checksess=' . md5($keylang . NV_CHECK_SESSION));
$xtpl->parse('main.loop.setup_new');
$xtpl->parse('main.can_install.loop.setup_new');
}
$xtpl->parse('main.can_install.loop');
}
$xtpl->parse('main.loop');
}

if ($lang_can_install) {
$xtpl->parse('main.can_install');
}

$xtpl->parse('main');
Expand Down
8 changes: 5 additions & 3 deletions includes/action_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function nv_delete_table_sys($lang)

function nv_create_table_sys($lang)
{
global $db_config, $global_config;
global $db_config, $global_config, $db;

$xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini');
$layoutdefault = ( string )$xml->layoutdefault;
Expand Down Expand Up @@ -191,8 +191,10 @@ function nv_create_table_sys($lang)
('" . $lang . "', 'global', 'disable_site_content', 'For technical reasons Web site temporary not available. we are very sorry for any inconvenience!'),
('" . $lang . "', 'global', 'ssl_https_modules', ''),
('" . $lang . "', 'seotools', 'prcservice', '')";

$sql_create_table[] = "INSERT INTO " . $db_config['prefix'] . "_setup_language (lang, setup) VALUES('" . $lang . "', 1)";

$lang_weight = $db->query('SELECT MAX(weight) FROM ' . $db_config['prefix'] . '_setup_language')->fetchColumn() + 1;

$sql_create_table[] = "INSERT INTO " . $db_config['prefix'] . "_setup_language (lang, setup, weight) VALUES('" . $lang . "', 1, " . $lang_weight . ")";

$sql_create_table[] = "INSERT INTO " . $db_config['prefix'] . "_" . $lang . "_modthemes (func_id, layout, theme) VALUES ('0', '" . $layoutdefault . "', '" . $global_config['site_theme'] . "')";
$sql_create_table[] = "ALTER TABLE " . $db_config['prefix'] . "_cronjobs ADD " . $lang . "_cron_name VARCHAR( 255 ) NOT NULL DEFAULT ''";
Expand Down
3 changes: 3 additions & 0 deletions includes/language/vi/admin_language.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$lang_translator['info'] = '';
$lang_translator['langtype'] = 'lang_module';

$lang_module['order'] = 'Thứ tự';
$lang_module['nv_lang_data'] = 'Ngôn ngữ data';
$lang_module['site_lang'] = 'Ngôn ngữ mặc định';
$lang_module['nv_lang_interface'] = 'Ngôn ngữ giao diện';
Expand Down Expand Up @@ -80,3 +81,5 @@
$lang_module['nv_lang_check_title'] = 'Kiểm tra các ngôn ngữ chưa được dịch';
$lang_module['countries'] = 'Ngôn ngữ theo quốc gia';
$lang_module['countries_name'] = 'Tên quốc gia';
$lang_module['lang_installed'] = 'Ngôn ngữ đã cài đặt';
$lang_module['lang_can_install'] = 'Ngôn ngữ chưa cài đặt';
1 change: 1 addition & 0 deletions install/action_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
$sql_create_table[] = "CREATE TABLE " . $db_config['prefix'] . "_setup_language (
lang char(2) NOT NULL,
setup tinyint(1) NOT NULL DEFAULT '0',
weight smallint(4) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (lang)
) ENGINE=MyISAM";

Expand Down
1 change: 1 addition & 0 deletions install/data_by_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
$company['company_maplat'] = (float)20.9845159999999992805896908976137638092041015625;
$company['company_maplng'] = (float)105.7954750000000103682396002113819122314453125;
$company['company_mapzoom'] = 17;
$company['company_mapapikey'] = 'AIzaSyC8ODAzZ75hsAufVBSffnwvKfTOT6TnnNQ';
$company['company_phone'] = "+84-4-85872007[+84485872007]|+84-904762534[+84904762534]";
$company['company_fax'] = "+84-4-35500914";
$company['company_email'] = "contact@vinades.vn";
Expand Down
6 changes: 3 additions & 3 deletions modules/news/funcs/rating.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

if ($id > 0 and in_array($point, $array_point) and $checkss == md5($id . NV_CHECK_SESSION)) {
if (! empty($time_set)) {
die($lang_module['rating_error2']);
die($lang_module['rating_error2'] . '|0|0');
}

$nv_Request->set_Session($module_data . '_' . $op . '_' . $id, NV_CURRENTTIME);
Expand All @@ -41,8 +41,8 @@
$db->query($query);
}
$contents = sprintf($lang_module['stringrating'], $row['total_rating'] + $point, $row['click_rating'] + 1);
die($contents);
die($contents . '|' . round(($row['total_rating'] + $point) / ($row['click_rating'] + 1), 1) . '|' . ($row['click_rating'] + 1));
}
}

die($lang_module['rating_error1']);
die($lang_module['rating_error1'] . '|0|0');
88 changes: 88 additions & 0 deletions modules/two-step-verification/funcs/confirm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

/**
* @Project NUKEVIET 4.x
* @Author VINADES.,JSC (contact@vinades.vn)
* @Copyright (C) 2014 VINADES.,JSC. All rights reserved
* @License GNU/GPL version 2 or any later version
* @Createdate 10/03/2010 10:51
*/

if (! defined('NV_MOD_2STEP_VERIFICATION')) {
die('Stop!!!');
}

$page_title = $module_info['custom_title'];
$key_words = $module_info['keywords'];

$nv_redirect = '';
if ($nv_Request->isset_request('nv_redirect', 'post,get')) {
$nv_redirect = nv_get_redirect();
}

/**
* nv_json_result()
*
* @param mixed $array
* @return
*/
function nv_json_result($array)
{
global $nv_redirect;

$array['redirect'] = $nv_redirect ? nv_redirect_decrypt($nv_redirect) : '';
$string = json_encode($array);
return $string;
}

if ($tokend_confirm_password != $tokend) {
$checkss = $nv_Request->get_title('checkss', 'post', '');

$blocker = new NukeViet\Core\Blocker(NV_ROOTDIR . '/' . NV_LOGS_DIR . '/ip_logs', NV_CLIENT_IP);
$rules = array($global_config['login_number_tracking'], $global_config['login_time_tracking'], $global_config['login_time_ban']);
$blocker->trackLogin($rules);

if ($checkss == NV_CHECK_SESSION) {
if ($global_config['login_number_tracking'] and $blocker->is_blocklogin($user_info['username'])) {
die(nv_json_result(array(
'status' => 'error',
'input' => '',
'mess' => sprintf($lang_global['userlogin_blocked'], $global_config['login_number_tracking'], nv_date('H:i d/m/Y', $blocker->login_block_end)) )));
}

$nv_password = $nv_Request->get_title('password', 'post', '');
$db_password = $db->query('SELECT password FROM ' . $db_config['prefix'] . '_' . $site_mods[NV_BRIDGE_USER_MODULE]['module_data'] . ' WHERE userid=' . $user_info['userid'])->fetchColumn();

if ($crypt->validate_password($nv_password, $db_password)) {
$blocker->reset_trackLogin($user_info['username']);
$nv_Request->set_Session($tokend_key, $tokend);
die(nv_json_result(array(
'status' => 'ok',
'input' => '',
'mess' => '' )));
}

if ($global_config['login_number_tracking'] and !empty($nv_password)) {
$blocker->set_loginFailed($user_info['username'], NV_CURRENTTIME);
}

die(nv_json_result(array(
'status' => 'error',
'input' => 'password',
'mess' => $lang_global['incorrect_password'] )));
}

$contents = nv_theme_confirm_password();
} else {
if (empty($nv_redirect)) {
header('Location: ' . nv_url_rewrite(NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name, true));
die();
} else {
header('Location: ' . nv_redirect_decrypt($nv_redirect));
die();
}
}

include NV_ROOTDIR . '/includes/header.php';
echo nv_site_theme($contents);
include NV_ROOTDIR . '/includes/footer.php';
Loading

0 comments on commit 7b74d49

Please sign in to comment.