function cron_ref_expired_del()
{
    $log_path = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/ref_logs';
    if (!is_dir($log_path)) {
        @nv_mkdir(NV_ROOTDIR . '/' . NV_LOGS_DIR, 'ref_logs', true);
    }
    $log_start = mktime(0, 0, 0, date("n", NV_CURRENTTIME), 1, date("Y", NV_CURRENTTIME));
    $logfiles = nv_scandir($log_path, "/^[0-9]{10,12}\\." . preg_quote(NV_LOGS_EXT) . "\$/");
    $result = true;
    if (!empty($logfiles)) {
        foreach ($logfiles as $logfile) {
            unset($matches);
            preg_match("/^([0-9]{10,12})\\." . preg_quote(NV_LOGS_EXT) . "\$/", $logfile, $matches);
            $d = (int) $matches[1];
            if ($d < $log_start) {
                if (!@unlink($log_path . '/' . $logfile)) {
                    $result = false;
                }
            }
        }
    }
    return $result;
}
Exemplo n.º 2
0
/**
 * nv_set_cache()
 *
 * @param mixed $module_name
 * @param mixed $filename
 * @param mixed $content
 * @return
 */
function nv_set_cache($module_name, $filename, $content)
{
    if (empty($filename) or !preg_match('/([a-z0-9\\_]+)\\.cache/', $filename)) {
        return false;
    }
    nv_mkdir(NV_ROOTDIR . '/' . NV_CACHEDIR, $module_name);
    return nv_gz_put_contents(NV_ROOTDIR . '/' . NV_CACHEDIR . '/' . $module_name . '/' . $filename, $content);
}
Exemplo n.º 3
0
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2015 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate Tue, 14 Jul 2015 04:17:56 GMT
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
if ($nv_Request->isset_request('get_alias_title', 'post')) {
    $alias = $nv_Request->get_title('get_alias_title', 'post', '');
    $alias = change_alias($alias);
    die($alias);
}
if (!file_exists(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $module_upload)) {
    nv_mkdir(NV_ROOTDIR . '/' . NV_FILES_DIR, $module_upload);
}
if (defined('NV_EDITOR')) {
    require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
}
$row = array();
$error = array();
$row['id'] = $nv_Request->get_int('id', 'post,get', 0);
if ($nv_Request->isset_request('submit', 'post')) {
    $row['catid'] = $nv_Request->get_int('catid', 'post', 0);
    $row['title'] = $nv_Request->get_title('title', 'post', '');
    if (empty($row['title'])) {
        $row['title'] = $admin_info['username'] . '-' . nv_genpass(6);
    }
    $row['alias'] = $nv_Request->get_title('alias', 'post', '');
    $row['alias'] = empty($row['alias']) ? change_alias($row['title']) : change_alias($row['alias']);
Exemplo n.º 4
0
     $albdata['imgfolder'] = strtolower($albdata['alias']);
     $newalbid = $np->addItem('album', $albdata);
     if ((int) $newalbid > 0) {
         $np->setAdminRoll($newAdminArray, '', 'admins', 'listalbid', 'userid', $newalbid);
         $log_action = "Thêm album";
     }
 }
 if (!empty($log_action)) {
     $imgpath = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name . '/' . $albdata['image'];
     $thumbpath = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name . '/thumbs/album/';
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/album/' . $albdata['alias'])) {
         nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/album/', $albdata['alias']);
         nv_loadUploadDirList(false);
     }
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/album/' . $albdata['alias'] . '/thumbs')) {
         nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/album/' . $albdata['alias'] . '/', 'thumbs');
         nv_loadUploadDirList(false);
     }
     $albdata['imgfolder'] = strtolower($albdata['alias']);
     if ($albdata['image'] != '' and !file_exists($thumbpath . '/' . $albdata['image'])) {
         $albdata['thumbpath'] = createthumb($imgpath, $thumbpath, '', 180, 180);
     }
     $np->updateItem('album', $albdata, 'albid');
     nv_insert_logs(NV_LANG_DATA, $module_name, $log_action, $albdata['title'], $admin_info['userid']);
 }
 nv_del_moduleCache($module_name);
 if (empty($np->error) and empty($np->warning)) {
     //Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op );
     //die();
     $np->success[] = "Lưu album thành công";
     $np->status();
Exemplo n.º 5
0
    //Buoc admin khai bao lai pass neu khong online trong khoang thoi gian nhat dinh
    if (empty($admin_info['checkpass'])) {
        if ($nv_Request->isset_request(NV_ADMINRELOGIN_VARIABLE, 'get') and $nv_Request->get_int(NV_ADMINRELOGIN_VARIABLE, 'get') == 1) {
            require_once NV_ROOTDIR . "/includes/core/admin_relogin.php";
            exit;
        }
    }
} elseif (!in_array(NV_LANG_DATA, $global_config['allow_sitelangs'])) {
    $global_config['disable_site'] = 1;
}
//Dinh chi hoat dong cua site
if (!defined('NV_ADMIN') and !defined("NV_IS_ADMIN")) {
    if ($global_config['disable_site']) {
        $disable_site_content = (isset($global_config['disable_site_content']) and !empty($global_config['disable_site_content'])) ? $global_config['disable_site_content'] : $lang_global['disable_site_content'];
        nv_info_die($global_config['site_description'], $global_config['disable_site_title'], $disable_site_content);
    } elseif (!in_array(NV_LANG_DATA, $global_config['allow_sitelangs'])) {
        Header("Location: " . NV_BASE_SITEURL);
        exit;
    } elseif (empty($global_config['lang_multi']) and NV_LANG_DATA != $global_config['site_lang']) {
        Header("Location: " . NV_BASE_SITEURL);
        exit;
    }
}
$month_upload_dir = nv_mkdir(NV_UPLOADS_REAL_DIR, date("Y_m"));
//Thu muc uploads theo thang
if (!empty($month_upload_dir[0])) {
    define("NV_MONTH_UPLOADS_DIR", date("Y_m"));
    define("NV_MONTH_UPLOADS_REAL_DIR", NV_UPLOADS_REAL_DIR . '/' . NV_MONTH_UPLOADS_DIR);
}
define('PCLZIP_TEMPORARY_DIR', NV_ROOTDIR . '/' . NV_TEMP_DIR . '/');
unset($month_upload_dir);
Exemplo n.º 6
0
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$page_title = $lang_module['cat_title'];
$table_name = $db_config['prefix'] . '_' . $module_data . '_catalogs';
$error = $admins = '';
$savecat = 0;
$data = array();
$groups_list = nv_groups_list();
if (defined('NV_EDITOR')) {
    require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
}
$currentpath = NV_UPLOADS_DIR . '/' . $module_upload . '/' . date('Y_m');
if (!file_exists($currentpath)) {
    nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_upload, date('Y_m'), true);
}
list($data['catid'], $data['parentid'], $data['title'], $data['title_custom'], $data['alias'], $data['description'], $data[NV_LANG_DATA . '_descriptionhtml'], $data['keywords'], $data['groups_view'], $data['cat_allow_point'], $data['cat_number_point'], $data['cat_number_product'], $data['image'], $data['form'], $data['group_price'], $data['viewdescriptionhtml'], $data['newday'], $data['typeprice']) = array(0, 0, '', '', '', '', '', '', '6', 0, 0, 0, '', '', $pro_config['group_price'], 0, 7, 1);
$savecat = $nv_Request->get_int('savecat', 'post', 0);
$cat_form_exit = array();
$_form_exit = scandir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_file . '/files_tpl');
foreach ($_form_exit as $_form) {
    if (preg_match('/^cat\\_form\\_([a-zA-Z0-9\\-\\_]+)\\.tpl$/', $_form, $m)) {
        $cat_form_exit[] = $m[1];
    }
}
if (!empty($savecat)) {
    $field_lang = nv_file_table($table_name);
    $data['catid'] = $nv_Request->get_int('catid', 'post', 0);
    $data['typeprice'] = $nv_Request->get_int('typeprice', 'post', 2);
    $data['parentid_old'] = $nv_Request->get_int('parentid_old', 'post', 0);
Exemplo n.º 7
0
        $xtpl->assign('INCLUDE_LANG', str_replace(NV_ROOTDIR, '', str_replace('\\', '/', $include_lang)));
        $xtpl->assign('URL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=interface');
        $xtpl->parse('main.complete');
    } else {
        $xtpl->assign('CONTENT', $content);
        $xtpl->parse('main.error');
    }
    $xtpl->parse('main');
    $contents = $xtpl->text('main');
    include NV_ROOTDIR . '/includes/header.php';
    echo nv_admin_theme($contents);
    include NV_ROOTDIR . '/includes/footer.php';
} elseif ($nv_Request->isset_request('checksess', 'get') and $nv_Request->get_string('checksess', 'get') == md5('writeallfile' . NV_CHECK_SESSION)) {
    $dirlang = $nv_Request->get_string('dirlang', 'get', '');
    if ($dirlang != '' and preg_match("/^([a-z]{2})\$/", $dirlang)) {
        nv_mkdir(NV_ROOTDIR . '/includes/language/', $dirlang);
        $content = '';
        $array_filename = array();
        $result = $db->query('SELECT idfile, author_' . $dirlang . ' FROM ' . NV_LANGUAGE_GLOBALTABLE . '_file ORDER BY idfile ASC');
        while (list($idfile, $author_lang) = $result->fetch(3)) {
            $content = nv_admin_write_lang($dirlang, $idfile);
            if (!empty($content)) {
                break;
            } else {
                $array_filename[] = str_replace(NV_ROOTDIR, '', str_replace('\\', '/', $include_lang));
            }
        }
        if (empty($content)) {
            $xtpl->assign('URL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=setting');
            $i = 0;
            foreach ($array_filename as $name) {
Exemplo n.º 8
0
        $xtpl->assign('INCLUDE_LANG', str_replace(NV_ROOTDIR, "", str_replace('\\', '/', $include_lang)));
        $xtpl->assign('URL', NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&amp;" . NV_OP_VARIABLE . "=interface");
        $xtpl->parse('main.complete');
    } else {
        $xtpl->assign('CONTENT', $content);
        $xtpl->parse('main.error');
    }
    $xtpl->parse('main');
    $contents = $xtpl->text('main');
    include NV_ROOTDIR . "/includes/header.php";
    echo nv_admin_theme($contents);
    include NV_ROOTDIR . "/includes/footer.php";
} elseif ($nv_Request->isset_request('checksess', 'get') and $nv_Request->get_string('checksess', 'get') == md5("writeallfile" . session_id())) {
    $dirlang = $nv_Request->get_string('dirlang', 'get', '');
    if ($dirlang != "") {
        nv_mkdir(NV_ROOTDIR . "/language/", $dirlang);
        $sql = "SELECT `idfile`, `author_" . $dirlang . "` FROM `" . NV_LANGUAGE_GLOBALTABLE . "_file` ORDER BY `idfile` ASC";
        $result = $db->sql_query($sql);
        $content = "";
        $array_filename = array();
        while (list($idfile, $author_lang) = $db->sql_fetchrow($result)) {
            $content = nv_admin_write_lang($dirlang, $idfile);
            if (!empty($content)) {
                break;
            } else {
                $array_filename[] = str_replace(NV_ROOTDIR, "", str_replace('\\', '/', $include_lang));
            }
        }
        if (empty($content)) {
            // Tam thoi bo qua cai nay
            // $array_lang_no_check = array_unique( $array_lang_no_check );
Exemplo n.º 9
0
function nv_referer_update()
{
    global $nv_Request, $client_info, $global_config, $db, $prefix;
    if ($client_info['is_myreferer'] == 0) {
        $host = $nv_Request->referer_host;
        $host = str_replace('www.', '', $host);
        $host = explode('/', $host);
        $host = reset($host);
        $host = strtolower($host);
        $log_path = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/ref_logs';
        if (!is_dir($log_path)) {
            @nv_mkdir(NV_ROOTDIR . '/' . NV_LOGS_DIR, 'ref_logs', true);
        }
        $log_current = mktime(0, 0, 0, date("n", NV_CURRENTTIME), date("j", NV_CURRENTTIME), date("Y", NV_CURRENTTIME));
        $content = '[' . date("r", NV_CURRENTTIME) . ']';
        $content .= ' [' . $client_info['ip'] . ']';
        $content .= ' [' . $client_info['referer'] . ']';
        $content .= ' [' . $client_info['selfurl'] . ']';
        $content .= "\r\n";
        $md5 = md5($client_info['referer'] . $client_info['selfurl']);
        $is_save = true;
        $referer_blocker = array();
        if (file_exists(NV_ROOTDIR . '/' . NV_DATADIR . '/referer_blocker.php')) {
            include NV_ROOTDIR . '/' . NV_DATADIR . '/referer_blocker.php';
        }
        if (!empty($referer_blocker)) {
            foreach ($referer_blocker as $blocker) {
                if (preg_match("/" . preg_quote($blocker) . "/i", $host)) {
                    $is_save = false;
                    break;
                }
            }
        }
        if ($is_save) {
            $tmp = $log_path . '/tmp.' . NV_LOGS_EXT;
            if (file_exists($tmp)) {
                $ct = file_get_contents($tmp);
                if (!empty($ct)) {
                    $ct = trim($ct);
                    $ct = explode("|", $ct);
                    $p = NV_CURRENTTIME - 60;
                    if ($ct[0] > $p and $ct[1] == $md5) {
                        $is_save = false;
                    }
                }
            }
        }
        if ($is_save) {
            file_put_contents($log_path . '/' . $log_current . '.' . NV_LOGS_EXT, $content, FILE_APPEND);
            file_put_contents($tmp, NV_CURRENTTIME . '|' . $md5);
            $sql = "UPDATE `" . NV_REFSTAT_TABLE . "` SET \n            total=total+1, \n            month" . date('m', NV_CURRENTTIME) . "=month" . date('m', NV_CURRENTTIME) . "+1, \n            last_update=" . NV_CURRENTTIME . " \n            WHERE `host`=" . $db->dbescape($host);
            $db->sql_query($sql);
            $mysql_info = @mysql_info();
            unset($matches);
            preg_match("/^\\D+(\\d+)/", $mysql_info, $matches);
            if ($matches[1] == 0) {
                $sql = "INSERT INTO `" . NV_REFSTAT_TABLE . "` \n                (`host`, `total`, `month" . date('m', NV_CURRENTTIME) . "`, `last_update`) \n                VALUES (" . $db->dbescape($host) . ",1, 1," . NV_CURRENTTIME . ")";
                $db->sql_query($sql);
            }
            if (!empty($nv_Request->search_engine)) {
                if (isset($global_config['engine_allowed'][$nv_Request->search_engine]['query_param']) and !empty($global_config['engine_allowed'][$nv_Request->search_engine]['query_param'])) {
                    $key = $global_config['engine_allowed'][$nv_Request->search_engine]['query_param'];
                    $key = $nv_Request->referer_queries[$key];
                    $key = str_replace("+", " ", $key);
                    $key = nv_strtolower($key);
                    $key = nv_substr($key, 0, 100);
                    $key = trim($key);
                    $id = md5($key);
                    if (!empty($key)) {
                        $sql = "UPDATE `" . NV_SEARCHKEYS_TABLE . "` \n                        SET total=total+1 WHERE `id`=" . $db->dbescape($id) . " \n                        AND `search_engine`=" . $db->dbescape($nv_Request->search_engine);
                        $db->sql_query($sql);
                        $mysql_info = @mysql_info();
                        unset($matches);
                        preg_match("/^\\D+(\\d+)/", $mysql_info, $matches);
                        if ($matches[1] == 0) {
                            $sql = "INSERT INTO `" . NV_SEARCHKEYS_TABLE . "` \n                            VALUES (" . $db->dbescape($id) . "," . $db->dbescape($key) . ",1," . $db->dbescape($nv_Request->search_engine) . ")";
                            $db->sql_query($sql);
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 10
0
function nv_get_viewImage($fileName)
{
    global $array_thumb_config;
    if (preg_match('/^' . nv_preg_quote(NV_UPLOADS_DIR) . '\\/(([a-z0-9\\-\\_\\/]+\\/)*([a-z0-9\\-\\_\\.]+)(\\.(gif|jpg|jpeg|png)))$/i', $fileName, $m)) {
        $viewFile = NV_FILES_DIR . '/' . $m[1];
        if (file_exists(NV_ROOTDIR . '/' . $viewFile)) {
            $size = @getimagesize(NV_ROOTDIR . '/' . $viewFile);
            return array($viewFile, $size[0], $size[1]);
        } else {
            $m[2] = rtrim($m[2], '/');
            if (isset($array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]])) {
                $thumb_config = $array_thumb_config[NV_UPLOADS_DIR . '/' . $m[2]];
            } else {
                $thumb_config = $array_thumb_config[''];
                $_arr_path = explode('/', NV_UPLOADS_DIR . '/' . $m[2]);
                while (sizeof($_arr_path) > 1) {
                    array_pop($_arr_path);
                    $_path = implode('/', $_arr_path);
                    if (isset($array_thumb_config[$_path])) {
                        $thumb_config = $array_thumb_config[$_path];
                        break;
                    }
                }
            }
            $viewDir = NV_FILES_DIR;
            if (!empty($m[2])) {
                if (!is_dir(NV_ROOTDIR . '/' . $m[2])) {
                    $e = explode('/', $m[2]);
                    $cp = NV_FILES_DIR;
                    foreach ($e as $p) {
                        if (is_dir(NV_ROOTDIR . '/' . $cp . '/' . $p)) {
                            $viewDir .= '/' . $p;
                        } else {
                            $mk = nv_mkdir(NV_ROOTDIR . '/' . $cp, $p);
                            if ($mk[0] > 0) {
                                $viewDir .= '/' . $p;
                            }
                        }
                        $cp .= '/' . $p;
                    }
                }
            }
            $image = new image(NV_ROOTDIR . '/' . $fileName, NV_MAX_WIDTH, NV_MAX_HEIGHT);
            if ($thumb_config['thumb_type'] == 4) {
                $thumb_width = $thumb_config['thumb_width'];
                $thumb_height = $thumb_config['thumb_height'];
                $maxwh = max($thumb_width, $thumb_height);
                if ($image->fileinfo['width'] > $image->fileinfo['height']) {
                    $thumb_config['thumb_width'] = 0;
                    $thumb_config['thumb_height'] = $maxwh;
                } else {
                    $thumb_config['thumb_width'] = $maxwh;
                    $thumb_config['thumb_height'] = 0;
                }
            }
            $image->resizeXY($thumb_config['thumb_width'], $thumb_config['thumb_height']);
            if ($thumb_config['thumb_type'] == 4) {
                $image->cropFromCenter($thumb_width, $thumb_height);
            }
            $image->save(NV_ROOTDIR . '/' . $viewDir, $m[3] . $m[4], $thumb_config['thumb_quality']);
            $create_Image_info = $image->create_Image_info;
            $error = $image->error;
            $image->close();
            if (empty($error)) {
                return array($viewDir . '/' . basename($create_Image_info['src']), $create_Image_info['width'], $create_Image_info['height']);
            }
        }
    } else {
        $size = @getimagesize(NV_ROOTDIR . '/' . $fileName);
        return array($viewFile, $size[0], $size[1]);
    }
    return false;
}
Exemplo n.º 11
0
 * @Copyright (C) 2012 VINADES.,JSC. All rights reserved
 * @Createdate 2-2-2010 12:55
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$path = nv_check_path_upload($nv_Request->get_string('path', 'post'));
$newname = nv_string_to_filename(htmlspecialchars(trim($nv_Request->get_string('newname', 'post')), ENT_QUOTES));
$check_allow_upload_dir = nv_check_allow_upload_dir($path);
if (!isset($check_allow_upload_dir['create_dir']) or $check_allow_upload_dir['create_dir'] !== true) {
    die("ERROR_" . $lang_module['notlevel']);
}
if (empty($path)) {
    die("ERROR_" . $lang_module['notlevel']);
}
if (empty($newname)) {
    die("ERROR_" . $lang_module['name_nonamefolder']);
}
$newpath = $path . '/' . $newname;
if (is_dir(NV_ROOTDIR . '/' . $newpath)) {
    die("ERROR_" . $lang_module['folder_exists']);
}
$n_dir = nv_mkdir(NV_ROOTDIR . '/' . $path, $newname);
if (!empty($n_dir[0])) {
    nv_loadUploadDirList(false);
    nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['createfolder'], $newpath, $admin_info['userid']);
    echo $path . '/' . $newname;
    exit;
} else {
    die("ERROR_" . $n_dir[1]);
}
Exemplo n.º 12
0
/**
 * nv_setup_data_module()
 *
 * @param mixed $lang
 * @param mixed $module_name
 * @return
 */
function nv_setup_data_module($lang, $module_name)
{
    global $db, $db_config, $global_config;
    $return = 'NO_' . $module_name;
    $sth = $db->prepare('SELECT module_file, module_data, module_upload, theme FROM ' . $db_config['prefix'] . '_' . $lang . '_modules WHERE title= :title');
    $sth->bindParam(':title', $module_name, PDO::PARAM_STR);
    $sth->execute();
    list($module_file, $module_data, $module_upload, $module_theme) = $sth->fetch(3);
    if (!empty($module_file)) {
        $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
        $sth = $db->prepare("DELETE FROM " . NV_CONFIG_GLOBALTABLE . " WHERE lang= '" . $lang . "' AND module= :module");
        $sth->bindParam(':module', $module_name, PDO::PARAM_STR);
        $sth->execute();
        nv_delete_all_cache();
        if (file_exists(NV_ROOTDIR . '/modules/' . $module_file . '/action_' . $db->dbtype . '.php')) {
            $sql_recreate_module = array();
            try {
                $db->exec('ALTER DATABASE ' . $db_config['dbname'] . ' DEFAULT CHARACTER SET utf8 COLLATE ' . $db_config['collation']);
            } catch (PDOException $e) {
                trigger_error($e->getMessage());
            }
            include NV_ROOTDIR . '/modules/' . $module_file . '/action_' . $db->dbtype . '.php';
            if (!empty($sql_create_module)) {
                foreach ($sql_create_module as $sql) {
                    try {
                        $db->query($sql);
                    } catch (PDOException $e) {
                        trigger_error($e->getMessage());
                        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);
            }
            $selectthemes = 'default';
            if (!empty($module_theme) and file_exists(NV_ROOTDIR . '/themes/' . $module_theme . '/config.ini')) {
                $selectthemes = $module_theme;
            } elseif (file_exists(NV_ROOTDIR . '/themes/' . $global_config['site_theme'] . '/config.ini')) {
                $selectthemes = $global_config['site_theme'];
            }
            $xml = simplexml_load_file(NV_ROOTDIR . '/themes/' . $selectthemes . '/config.ini');
            $layoutdefault = (string) $xml->layoutdefault;
            $layout = $xml->xpath('setlayout/layout');
            $array_layout_func_default = array();
            for ($i = 0, $count = sizeof($layout); $i < $count; ++$i) {
                $layout_name = (string) $layout[$i]->name;
                if (in_array($layout_name, $layout_array)) {
                    $layout_funcs = $layout[$i]->xpath('funcs');
                    for ($j = 0, $count2 = sizeof($layout_funcs); $j < $count2; ++$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
            $_layoutdefault = isset($module_version['layoutdefault']) ? $module_version['layoutdefault'] : '';
            if (!empty($_layoutdefault)) {
                $_layout_mod = explode(';', $_layoutdefault);
                foreach ($_layout_mod as $_layout_fun) {
                    list($layout_name, $_func) = explode(':', trim($_layout_fun));
                    $arr_f = explode(',', trim($_func));
                    foreach ($arr_f as $f) {
                        if (!isset($array_layout_func_default[$module_name][$f])) {
                            $array_layout_func_default[$module_name][$f] = $layout_name;
                        }
                    }
                }
            }
            $arr_func_id_old = array();
            $sth = $db->prepare('SELECT func_id, func_name FROM ' . $db_config['prefix'] . '_' . $lang . '_modfuncs WHERE in_module= :in_module');
            $sth->bindParam(':in_module', $module_name, PDO::PARAM_STR);
            $sth->execute();
            while ($row = $sth->fetch()) {
                $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);
            $array_keys = array_keys($new_funcs);
            $array_submenu = isset($module_version['submenu']) ? explode(',', $module_version['submenu']) : array();
            foreach ($array_keys as $func) {
                $show_func = 0;
                $weight = 0;
                $in_submenu = in_array($func, $array_submenu) ? 1 : 0;
                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->query('UPDATE ' . $db_config['prefix'] . '_' . $lang . '_modfuncs SET show_func= ' . $show_func . ', in_submenu=' . $in_submenu . ', subweight=0 WHERE func_id=' . $arr_func_id[$func]);
                } else {
                    $data = array();
                    $data['func_name'] = $func;
                    $data['alias'] = $func;
                    $data['func_custom_name'] = ucfirst($func);
                    $data['in_module'] = $module_name;
                    $arr_func_id[$func] = $db->insert_id("INSERT INTO " . $db_config['prefix'] . "_" . $lang . "_modfuncs\n\t\t\t\t\t\t(func_name, alias, func_custom_name, in_module, show_func, in_submenu, subweight, setting) VALUES\n\t\t\t\t\t \t(:func_name, :alias, :func_custom_name, :in_module, " . $show_func . ", " . $in_submenu . ", " . $weight . ", '')", "func_id", $data);
                    if ($arr_func_id[$func]) {
                        -($layout = $layoutdefault);
                        if (isset($array_layout_func_default[$module_name][$func])) {
                            if (file_exists(NV_ROOTDIR . '/themes/' . $selectthemes . '/layout/layout.' . $array_layout_func_default[$module_name][$func] . '.tpl')) {
                                $layout = $array_layout_func_default[$module_name][$func];
                            }
                        }
                        $db->query('INSERT INTO ' . $db_config['prefix'] . '_' . $lang . '_modthemes (`func_id`, `layout`, `theme`) VALUES (' . $arr_func_id[$func] . ', ' . $db->quote($layout) . ', ' . $db->quote($selectthemes) . ')');
                    }
                }
            }
            $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;
                    $db->query('UPDATE ' . $db_config['prefix'] . '_' . $lang . '_modfuncs SET subweight=' . $subweight . ', show_func=' . $show_func . ' WHERE func_id=' . $func_id);
                }
            }
        } else {
            // Xoa du lieu tai bang _modfuncs
            $sth = $db->prepare('DELETE FROM ' . $db_config['prefix'] . '_' . $lang . '_modfuncs WHERE in_module= :in_module');
            $sth->bindParam(':in_module', $module_name, PDO::PARAM_STR);
            $sth->execute();
        }
        if (isset($module_version['uploads_dir']) and !empty($module_version['uploads_dir'])) {
            $sth_dir = $db->prepare('INSERT INTO ' . NV_UPLOAD_GLOBALTABLE . '_dir (dirname, time, thumb_type, thumb_width, thumb_height, thumb_quality) VALUES (:dirname, 0, 0, 0, 0, 0)');
            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)) {
                            $mk = nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $cp, $p);
                            if ($mk[0]) {
                                try {
                                    $sth_dir->bindValue(':dirname', NV_UPLOADS_DIR . '/' . $cp . $p, PDO::PARAM_STR);
                                    $sth_dir->execute();
                                } catch (PDOException $e) {
                                }
                            }
                        }
                        $cp .= $p . '/';
                    }
                }
            }
        }
        if (isset($module_version['files_dir']) and !empty($module_version['files_dir'])) {
            foreach ($module_version['files_dir'] as $path) {
                $cp = '';
                $arr_p = explode('/', $path);
                foreach ($arr_p as $p) {
                    if (trim($p) != '') {
                        if (!is_dir(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $cp . $p)) {
                            nv_mkdir(NV_ROOTDIR . '/' . NV_FILES_DIR . '/' . $cp, $p);
                        }
                        $cp .= $p . '/';
                    }
                }
            }
        }
        $return = 'OK_' . $module_name;
        nv_delete_all_cache();
    }
    return $return;
}
Exemplo n.º 13
0
<?php

/**
 * @Project NUKEVIET 3.0
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
 * @Createdate 2-2-2010 12:55
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
$path = htmlspecialchars(trim($nv_Request->get_string('path', 'post')), ENT_QUOTES);
$newname = htmlspecialchars(trim($nv_Request->get_string('newname', 'post')), ENT_QUOTES);
if (!empty($newname) && !file_exists(NV_ROOTDIR . '/' . $path . '/' . change_alias($newname)) && $admin_info['allow_create_subdirectories'] && nv_check_allow_upload_dir($path)) {
    $n_dir = nv_mkdir(NV_ROOTDIR . '/' . $path, change_alias($newname));
    if (!empty($n_dir[0])) {
        echo $path . '/' . change_alias($newname);
    }
}
Exemplo n.º 14
0
/**
 * nv_create_form_file()
 *
 * @param mixed $array_template_id
 * @return
 */
function nv_create_form_file($array_template_id)
{
    global $db, $db_config, $module_name, $module_data, $module_file, $array_template, $lang_module;
    foreach ($array_template_id as $templateids_i) {
        $array_views = array();
        $result = $db->query("SELECT fid, field, field_type, listtemplate FROM " . $db_config['prefix'] . '_' . $module_data . "_field");
        while ($column = $result->fetch()) {
            $column['listtemplate'] = explode('|', $column['listtemplate']);
            if (in_array($templateids_i, $column['listtemplate'])) {
                $array_views[$column['fid']] = $column['field_type'];
            }
        }
        $array_field_js = array();
        $content_2 = "<!-- BEGIN: main -->\n";
        $content_2 .= "\t<div class=\"panel panel-default\">\n\t\t<div class=\"panel-heading\">{LANG.tabs_content_customdata}</div>\n";
        $content_2 .= "\t\t<div class=\"panel-body\">\n";
        foreach ($array_views as $key => $input_type_i) {
            $content_2 .= "\t\t\t<div class=\"form-group\">\n";
            $content_2 .= "\t\t\t\t<label class=\"col-md-4 control-label\"> {CUSTOM_LANG." . $key . ".title} </label>\n";
            $content_2 .= "\t\t\t\t<div class=\"col-md-20\">";
            if ($input_type_i == 'time') {
                $content_2 .= "<input class=\"form-control\" type=\"text\" pattern=\"^[0-9]{2,2}\$\" name=\"custom[" . $key . "_hour]\" value=\"{ROW." . $key . "_hour}\" >:";
                $content_2 .= "<input class=\"form-control\" type=\"text\" pattern=\"^[0-9]{2,2}\$\" name=\"custom[" . $key . "_min]\" value=\"{ROW." . $key . "_min}\" >&nbsp;";
            }
            if ($input_type_i == 'textarea') {
                $content_2 .= "<textarea class=\"form-control\" style=\"width: 98%; height:100px;\" cols=\"75\" rows=\"5\" name=\"custom[" . $key . "]\">{ROW." . $key . "}</textarea>";
            } elseif ($input_type_i == 'editor') {
                $content_2 .= "{ROW." . $key . "}";
            } elseif ($input_type_i == 'select') {
                $content_2 .= "<select class=\"form-control\" name=\"custom[" . $key . "]\">\n";
                $content_2 .= "\t\t\t\t\t\t\t<option value=\"\"> --- </option>\n";
                $content_2 .= "\t\t\t\t\t\t<!-- BEGIN: select_" . $key . " -->\n";
                $content_2 .= "\t\t\t\t\t\t\t<option value=\"{OPTION.key}\" {OPTION.selected}>{OPTION.title}</option>\n";
                $content_2 .= "\t\t\t\t\t\t\t<!-- END: select_" . $key . " -->\n";
                $content_2 .= "\t\t\t\t\t</select>";
            } elseif ($input_type_i == 'radio' or $input_type_i == 'checkbox') {
                $type_html = $input_type_i == 'radio' ? 'radio' : 'checkbox';
                $content_2 .= "\n\t\t\t\t\t<!-- BEGIN: " . $type_html . "_" . $key . " -->\n";
                $content_2 .= "\t\t\t\t\t<label><input class=\"form-control\" type=\"" . $type_html . "\" name=\"custom[" . $key . "]\" value=\"{OPTION.key}\" {OPTION.checked}";
                if (isset($array_requireds[$key])) {
                    $content_2 .= 'required="required" ';
                    if ($oninvalid) {
                        $content_2 .= "oninvalid=\"setCustomValidity( nv_required )\" oninput=\"setCustomValidity('')\" ";
                    }
                }
                $content_2 .= ">{OPTION.title} &nbsp;</label>\n";
                $content_2 .= "\t\t\t\t\t<!-- END: " . $type_html . "_" . $key . " -->\n";
                $content_2 .= "\t\t\t\t";
            } elseif ($input_type_i == 'multiselect') {
                $content_2 .= "\n\t\t\t\t\t<select class=\"form-control\" name=\"custom[" . $key . "][]\" multiple=\"multiple\" >\n";
                $content_2 .= "\t\t\t\t\t\t\t<option value=\"\"> --- </option>\n";
                $content_2 .= "\n\t\t\t\t\t<!-- BEGIN: " . $key . " -->\n";
                $content_2 .= "\t\t\t\t\t\t<option value=\"{OPTION.key}\" {OPTION.selected}>{OPTION.title}</option\n>";
                $content_2 .= "\t\t\t\t\t<!-- END: " . $key . " -->\n";
                $content_2 .= "\t\t\t\t\t</select>\n";
                $content_2 .= "\t\t\t\t";
            } else {
                switch ($input_type_i) {
                    case 'email':
                        $type_html = 'email';
                        break;
                    case 'url':
                        $type_html = 'url';
                        break;
                    case 'password':
                        $type_html = 'password';
                        break;
                    default:
                        $type_html = 'text';
                }
                $oninvalid = true;
                $content_2 .= "<input class=\"form-control\" type=\"" . $type_html . "\" name=\"custom[" . $key . "]\" value=\"{ROW." . $key . "}\" ";
                if ($input_type_i == 'date' or $input_type_i == 'time') {
                    $content_2 .= 'id="' . $key . '" pattern="^[0-9]{2,2}\\/[0-9]{2,2}\\/[0-9]{1,4}$" ';
                    $array_field_js['date'][] = '#' . $key;
                } elseif ($input_type_i == 'textfile') {
                    $content_2 .= 'id="id_' . $key . '" ';
                    $array_field_js['file'][] = $key;
                } elseif ($input_type_i == 'textalias') {
                    $content_2 .= 'id="id_' . $key . '" ';
                } elseif ($input_type_i == 'email') {
                    $content_2 .= "oninvalid=\"setCustomValidity( nv_email )\" oninput=\"setCustomValidity('')\" ";
                    $oninvalid = false;
                } elseif ($input_type_i == 'url') {
                    $content_2 .= "oninvalid=\"setCustomValidity( nv_url )\" oninput=\"setCustomValidity('')\" ";
                    $oninvalid = false;
                } elseif ($input_type_i == 'number_int') {
                    $content_2 .= "pattern=\"^[0-9]*\$\"  oninvalid=\"setCustomValidity( nv_digits )\" oninput=\"setCustomValidity('')\" ";
                    $oninvalid = false;
                } elseif ($input_type_i == 'number_float') {
                    $content_2 .= "pattern=\"^([0-9]*)(\\.*)([0-9]+)\$\" oninvalid=\"setCustomValidity( nv_number )\" oninput=\"setCustomValidity('')\" ";
                    $oninvalid = false;
                }
                if (isset($array_requireds[$key])) {
                    $content_2 .= 'required="required" ';
                    if ($oninvalid) {
                        $content_2 .= "oninvalid=\"setCustomValidity( nv_required )\" oninput=\"setCustomValidity('')\" ";
                    }
                }
                $content_2 .= "/>";
                if ($input_type_i == 'textfile') {
                    $content_2 .= '&nbsp;<button type="button" class="btn btn-info" id="img_' . $key . '"><i class="fa fa-folder-open-o">&nbsp;</i> Browse server </button>';
                }
                if ($input_type_i == 'textalias' and $array_field_js['textalias'] == $key) {
                    $content_2 .= "&nbsp;<i class=\"fa fa-refresh fa-lg icon-pointer\" onclick=\"nv_get_alias('id_" . $key . "');\">&nbsp;</i>";
                }
            }
            $content_2 .= "</div>\n";
            $content_2 .= "\t\t\t</div>\n";
        }
        $content_2 .= "\t\t</div>\n";
        $content_2 .= "\t</div>\n";
        if (!empty($array_field_js['date'])) {
            $array_field_js['date'] = implode(',', $array_field_js['date']);
            $content_2 .= "\n<script type=\"text/javascript\">\n";
            $content_2 .= "\$(document).ready(function() {\n";
            $content_2 .= "\t\$(\"" . $array_field_js['date'] . "\").datepicker({\n";
            $content_2 .= "\t\tshowOn : \"both\",\n";
            $content_2 .= "\t\tdateFormat : \"dd/mm/yy\",\n";
            $content_2 .= "\t\tchangeMonth : true,\n";
            $content_2 .= "\t\tchangeYear : true,\n";
            $content_2 .= "\t\tshowOtherMonths : true,\n";
            $content_2 .= "\t\tbuttonImage : nv_base_siteurl + \"assets/images/calendar.gif\",\n";
            $content_2 .= "\t\tbuttonImageOnly : true\n";
            $content_2 .= "\t});\n";
            $content_2 .= "});\n";
            $content_2 .= "</script>\n";
        }
        $content_2 .= "<!-- END: main -->";
        if (!file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl')) {
            nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl');
        }
        $file = NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl/cat_form_' . preg_replace('/[\\-]/', '_', $array_template[$templateids_i]['alias']) . '.tpl';
        file_put_contents($file, $content_2, LOCK_EX);
    }
}
Exemplo n.º 15
0
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;
}
Exemplo n.º 16
0
 if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\_]*\$/", $array_config['upload_dir'])) {
     $array_config['upload_dir'] = "files";
 } else {
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $array_config['upload_dir'])) {
         $mkdir = nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name, $array_config['upload_dir']);
         nv_loadUploadDirList(false);
         if ($mkdir[0] == 0) {
             $array_config['upload_dir'] = "files";
         }
     }
 }
 if (!preg_match("/^[a-zA-Z][a-zA-Z0-9\\_]*\$/", $array_config['temp_dir'])) {
     $array_config['temp_dir'] = "temp";
 } else {
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/' . $array_config['temp_dir'])) {
         $mkdir = nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name, $array_config['temp_dir']);
         nv_loadUploadDirList(false);
         if ($mkdir[0] == 0) {
             $array_config['temp_dir'] = "temp";
         }
     }
 }
 foreach ($array_config as $config_name => $config_value) {
     if ($config_name != 'readme') {
         $query = "REPLACE INTO `" . NV_PREFIXLANG . "_" . $module_data . "_config` VALUES (" . $db->dbescape($config_name) . "," . $db->dbescape($config_value) . ")";
         $db->sql_query($query);
     }
 }
 if (!empty($array_config['readme'])) {
     file_put_contents($readme_file, $array_config['readme']);
 } else {
Exemplo n.º 17
0
     if ((int) $newcatid > 0) {
         $catdata['catid'] = $newcatid;
         np_create_CatDataTable($newcatid);
         $np->setAdminRoll($newAdminArray, '', 'admins', 'listcatid', 'userid', $newcatid);
         $log_action = "Thêm chủ đề";
     }
 }
 if (!empty($log_action)) {
     $imgpath = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name . '/' . $catdata['image'];
     $thumbpath = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $module_name . '/thumbs/category/';
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/category/' . $catdata['alias'])) {
         nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/category/', $catdata['alias']);
         nv_loadUploadDirList(false);
     }
     if (!is_dir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/category/' . $catdata['alias'] . '/thumbs')) {
         nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name . '/category/' . $catdata['alias'] . '/', 'thumbs');
         nv_loadUploadDirList(false);
     }
     $catdata['imgfolder'] = strtolower($catdata['alias']);
     if ($catdata['image'] != '' and !file_exists($thumbpath . '/' . $catdata['image'])) {
         $catdata['thumbpath'] = createthumb($imgpath, $thumbpath, '', 80, 80);
     }
     $np->updateItem('category', $catdata, 'catid');
     nv_fix_cat_order();
     nv_insert_logs(NV_LANG_DATA, $module_name, $log_action, $catdata['title'], $admin_info['userid']);
 }
 nv_del_moduleCache($module_name);
 if (empty($np->error) and empty($np->warning)) {
     //Header( "Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=" . $op );
     //die();
     $np->success[] = "Lưu chủ đề thành công";
Exemplo n.º 18
0
        $xtpl->assign('INCLUDE_LANG', str_replace(NV_ROOTDIR, '', str_replace('\\', '/', $include_lang)));
        $xtpl->assign('URL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=interface');
        $xtpl->parse('main.complete');
    } else {
        $xtpl->assign('CONTENT', $content);
        $xtpl->parse('main.error');
    }
    $xtpl->parse('main');
    $contents = $xtpl->text('main');
    include NV_ROOTDIR . '/includes/header.php';
    echo nv_admin_theme($contents);
    include NV_ROOTDIR . '/includes/footer.php';
} elseif ($nv_Request->isset_request('checksess', 'get') and $nv_Request->get_string('checksess', 'get') == md5('writeallfile' . session_id())) {
    $dirlang = $nv_Request->get_string('dirlang', 'get', '');
    if ($dirlang != '') {
        nv_mkdir(NV_ROOTDIR . '/language/', $dirlang);
        $content = '';
        $array_filename = array();
        $result = $db->query('SELECT idfile, author_' . $dirlang . ' FROM ' . NV_LANGUAGE_GLOBALTABLE . '_file ORDER BY idfile ASC');
        while (list($idfile, $author_lang) = $result->fetch(3)) {
            $content = nv_admin_write_lang($dirlang, $idfile);
            if (!empty($content)) {
                break;
            } else {
                $array_filename[] = str_replace(NV_ROOTDIR, '', str_replace('\\', '/', $include_lang));
            }
        }
        if (empty($content)) {
            $xtpl->assign('URL', NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=setting');
            $i = 0;
            foreach ($array_filename as $name) {
Exemplo n.º 19
0
function filter_images($folder, $linkanh)
{
    global $global_config, $module;
    if (!file_exists(NV_UPLOADS_REAL_DIR . '/' . $module . "/" . $folder)) {
        nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module, $folder);
    }
    $path = NV_UPLOADS_DIR . "/" . $module . "/" . $folder . "";
    require_once NV_ROOTDIR . "/includes/class/upload.class.php";
    $upload = new upload(array('images'), $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
    $upload_info = $upload->save_urlfile($linkanh, NV_ROOTDIR . '/' . $path, false);
    $home_file = $folder . "/" . $upload_info['basename'];
    sleep(1);
    return $home_file;
}
Exemplo n.º 20
0
function nv_referer_update()
{
    global $nv_Request, $client_info, $global_config, $db, $prefix;
    if ($client_info['is_myreferer'] == 0) {
        $host = $nv_Request->referer_host;
        $host = str_replace('www.', '', $host);
        $host = explode('/', $host);
        $host = reset($host);
        $host = strtolower($host);
        $log_path = NV_ROOTDIR . '/' . NV_LOGS_DIR . '/ref_logs';
        if (!is_dir($log_path)) {
            @nv_mkdir(NV_ROOTDIR . '/' . NV_LOGS_DIR, 'ref_logs', true);
        }
        $log_current = mktime(0, 0, 0, date('n', NV_CURRENTTIME), date('j', NV_CURRENTTIME), date('Y', NV_CURRENTTIME));
        $content = '[' . date('r', NV_CURRENTTIME) . ']';
        $content .= ' [' . NV_CLIENT_IP . ']';
        $content .= ' [' . $client_info['referer'] . ']';
        $content .= ' [' . $client_info['selfurl'] . ']';
        $content .= "\r\n";
        $md5 = md5($client_info['referer'] . $client_info['selfurl']);
        $is_save = true;
        $referer_blocker = array();
        if (file_exists(NV_ROOTDIR . '/' . NV_DATADIR . '/referer_blocker.php')) {
            include NV_ROOTDIR . '/' . NV_DATADIR . '/referer_blocker.php';
        }
        if (!empty($referer_blocker)) {
            foreach ($referer_blocker as $blocker) {
                if (preg_match('/' . preg_quote($blocker) . '/i', $host)) {
                    $is_save = false;
                    break;
                }
            }
        }
        if ($is_save) {
            $tmp = $log_path . '/tmp.' . NV_LOGS_EXT;
            if (file_exists($tmp)) {
                $ct = file_get_contents($tmp);
                if (!empty($ct)) {
                    $ct = trim($ct);
                    $ct = explode('|', $ct);
                    $p = NV_CURRENTTIME - 60;
                    if ($ct[0] > $p and $ct[1] == $md5) {
                        $is_save = false;
                    }
                }
            }
        }
        if ($is_save) {
            file_put_contents($log_path . '/' . $log_current . '.' . NV_LOGS_EXT, $content, FILE_APPEND);
            file_put_contents($tmp, NV_CURRENTTIME . '|' . $md5);
            $_numrow = $db->query('SELECT COUNT(*) FROM ' . NV_REFSTAT_TABLE . ' WHERE host=' . $db->quote($host))->fetchColumn();
            if ($_numrow > 0) {
                $sth = $db->prepare('UPDATE ' . NV_REFSTAT_TABLE . ' SET
    				total=total+1,
    				month' . date('m', NV_CURRENTTIME) . '=month' . date('m', NV_CURRENTTIME) . '+1,
    				last_update=' . NV_CURRENTTIME . '
    				WHERE host= :host');
                $sth->bindParam(':host', $host, PDO::PARAM_STR);
                $sth->execute();
            } else {
                $sth = $db->prepare('INSERT INTO ' . NV_REFSTAT_TABLE . '
					(host, total, month' . date('m', NV_CURRENTTIME) . ', last_update)
					VALUES ( :host, 1, 1,' . NV_CURRENTTIME . ')');
                $sth->bindParam(':host', $host, PDO::PARAM_STR);
                $sth->execute();
            }
            unset($_numrow);
            if (!empty($nv_Request->search_engine)) {
                if (isset($global_config['engine_allowed'][$nv_Request->search_engine]['query_param']) and !empty($global_config['engine_allowed'][$nv_Request->search_engine]['query_param'])) {
                    $key = $global_config['engine_allowed'][$nv_Request->search_engine]['query_param'];
                    $key = !empty($nv_Request->referer_queries[$key]) ? $nv_Request->referer_queries[$key] : '';
                    $key = str_replace('+', ' ', $key);
                    $key = nv_strtolower($key);
                    $key = nv_substr($key, 0, 100);
                    $key = trim($key);
                    $id = md5($key);
                    if (!empty($key)) {
                        $sth = $db->prepare('UPDATE ' . NV_SEARCHKEYS_TABLE . ' SET total=total+1 WHERE id= :id AND search_engine= :search_engine');
                        $sth->bindParam(':id', $id, PDO::PARAM_STR);
                        $sth->bindParam(':search_engine', $nv_Request->search_engine, PDO::PARAM_STR);
                        $update = $sth->execute();
                        if (empty($update)) {
                            $sth = $db->prepare('INSERT INTO ' . NV_SEARCHKEYS_TABLE . ' VALUES ( :id, :key, 1, :search_engine)');
                            $sth->bindParam(':id', $id, PDO::PARAM_STR);
                            $sth->bindParam(':key', $key, PDO::PARAM_STR);
                            $sth->bindParam(':search_engine', $nv_Request->search_engine, PDO::PARAM_STR);
                            $sth->execute();
                        }
                    }
                }
            }
        }
    }
}
Exemplo n.º 21
0
 * @Update to 4.x webvang (hoang.nguyen@webvang.vn)
 * @License GNU/GPL version 2 or any later version
 * @Createdate Fri, 29 May 2015 07:49:53 GMT

 if ( ! defined( 'NV_IS_ADMIN' ) ) {
 
				$nv_redirect = NV_BASE_SITEURL . "index.php?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=" . $module_name;
              redict_link ( 'ban khong co quyen han', '', $nv_redirect );
 };
*/
if (!defined('NV_IS_MOD_ARCHIVES')) {
    die('Stop!!!');
}
check_upload();
$page_title = $lang_module['content'];
$month_dir_module = nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $module_name, date("Y_m"), true);
if (defined('NV_EDITOR')) {
    require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
} else {
    if (!function_exists('nv_aleditor') and file_exists(NV_ROOTDIR . '/' . NV_EDITORSDIR . '/ckeditor/ckeditor_php5.php')) {
        define('NV_EDITOR', TRUE);
        define('NV_IS_CKEDITOR', TRUE);
        require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/ckeditor/ckeditor_php5.php';
        function nv_aleditor($textareaname, $width = "100%", $height = '450px', $val = '')
        {
            // Create class instance.
            $editortoolbar = array(array('Link', 'Unlink', 'Image', 'Table', 'Font', 'FontSize', 'RemoveFormat'), array('Bold', 'Italic', 'Underline', 'StrikeThrough', '-', 'Subscript', 'Superscript', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', 'OrderedList', 'UnorderedList', '-', 'Outdent', 'Indent', 'TextColor', 'BGColor', 'Source'));
            $CKEditor = new CKEditor();
            // Do not print the code directly to the browser, return it instead
            $CKEditor->returnOutput = true;
            $CKEditor->config['skin'] = 'v2';
Exemplo n.º 22
0
        if (empty($data['folder'])) {
            $error['folder'] = $lang_module['album_error_folder'];
        }
        if (empty($data['category_id'])) {
            $error['category'] = $lang_module['album_error_category'];
        }
        if (!empty($error) && !isset($error['warning'])) {
            $error['warning'] = $lang_module['album_error_warning'];
        }
        $_groups_post = $nv_Request->get_array('groups_view', 'post', array());
        $data['groups_view'] = !empty($_groups_post) ? implode(',', nv_groups_post(array_intersect($_groups_post, array_keys($groups_list)))) : '';
        $data['author'] = $admin_info['userid'];
        $_allow_cmm = $nv_Request->get_array('allow_comment', 'post', array());
        $data['allow_comment'] = !empty($_allow_cmm) ? implode(',', nv_groups_post(array_intersect($_allow_cmm, array_keys($groups_list)))) : '';
        if (!empty($data['folder']) && !is_dir(NV_ROOTDIR . '/' . $currentpath . '/' . $data['folder'])) {
            $mkdir = nv_mkdir(NV_ROOTDIR . '/' . $currentpath, $data['folder']);
            if ($mkdir[0] == 0) {
                $error['warning'] = $lang_module['album_error_create_folder'];
            } else {
                $db->query("INSERT IGNORE INTO " . NV_UPLOAD_GLOBALTABLE . "_dir (dirname, time) VALUES ('" . $currentpath . '/' . $data['folder'] . "', 0)");
            }
        }
        $data['alias'] = strtolower($data['alias']);
        if (empty($error)) {
            $mime = nv_parse_ini_file(NV_ROOTDIR . '/includes/ini/mime.ini', true);
            if ($data['album_id'] == 0) {
                $stmt = $db->prepare('INSERT INTO ' . TABLE_PHOTO_NAME . '_album SET 
					category_id = ' . intval($data['category_id']) . ', 
					status=' . intval($data['status']) . ', 
					date_added=' . intval($data['date_added']) . ',  
					date_modified=' . intval($data['date_modified']) . ', 
Exemplo n.º 23
0
$array_structure_file['username_Y'] = $module_upload . '/vid/' . $username_alias . '/' . date('Y');
$array_structure_file['username_Ym'] = $module_upload . '/vid/' . $username_alias . '/' . date('Y_m');
$array_structure_file['username_Y_m'] = $module_upload . '/vid/' . $username_alias . '/' . date('Y/m');
$array_structure_file['username_Ym_d'] = $module_upload . '/vid/' . $username_alias . '/' . date('Y_m/d');
$array_structure_file['username_Y_m_d'] = $module_upload . '/vid/' . $username_alias . '/' . date('Y/m/d');
$file_path = isset($array_structure_file[$structure_upload]) ? $array_structure_file[$structure_upload] : '';
if (file_exists(NV_UPLOADS_REAL_DIR . '/' . $file_path)) {
    $real_file_path = NV_UPLOADS_REAL_DIR . '/' . $file_path;
} else {
    $real_file_path = NV_UPLOADS_REAL_DIR . '/' . $module_upload;
    $e = explode('/', $file_path);
    if (!empty($e)) {
        $cp = '';
        foreach ($e as $p) {
            if (!empty($p) and !is_dir(NV_UPLOADS_REAL_DIR . '/' . $cp . $p)) {
                $mk = nv_mkdir(NV_UPLOADS_REAL_DIR . '/' . $cp, $p);
                if ($mk[0] > 0) {
                    $real_file_path = $mk[2];
                    $db->query("INSERT INTO " . NV_UPLOAD_GLOBALTABLE . "_dir (dirname, time) VALUES ('" . NV_UPLOADS_DIR . "/" . $cp . $p . "', 0)");
                }
            } elseif (!empty($p)) {
                $real_file_path = NV_UPLOADS_REAL_DIR . '/' . $cp . $p;
            }
            $cp .= $p . '/';
        }
    }
    $real_file_path = str_replace('\\', '/', $real_file_path);
}
$currentpath = str_replace(NV_ROOTDIR . '/', '', $upload_real_dir_page);
$file_path = str_replace(NV_ROOTDIR . '/', '', $real_file_path);
$uploads_dir_user = NV_UPLOADS_DIR . '/' . $module_upload . '/img/';
Exemplo n.º 24
0
 foreach ($ziplistContent as $zipCt) {
     if ($zipCt['filename'] == 'SCORM.htm' or $zipCt['filename'] == 'index.htm' or $zipCt['filename'] == 'viewer.swf') {
         $num_check++;
     }
     if ($num_check >= 3) {
         break;
     }
 }
 if ($num_check >= 3) {
     $scorm_dir = substr($file_name, 0, 0 - (strlen($file_ext) + 1));
     $scorm_path = $file_path . '/' . $scorm_dir;
     if (is_dir(NV_UPLOADS_REAL_DIR . $scorm_path) and file_exists(NV_UPLOADS_REAL_DIR . $scorm_path . '/SCORM.htm')) {
         $array['fileupload_new'][$fileuploadkey]['scorm_path'] = $scorm_path;
     } else {
         nv_deletefile(NV_UPLOADS_REAL_DIR . $scorm_path, true);
         $mkdir = nv_mkdir(NV_UPLOADS_REAL_DIR . $file_path, $scorm_dir);
         if ($mkdir[0] == 1) {
             nv_deletefile(NV_UPLOADS_REAL_DIR . $scorm_path . '/index.html');
             // Kiem tra FTP
             $ftp_check_login = 0;
             if ($sys_info['ftp_support'] and intval($global_config['ftp_check_login']) == 1) {
                 $ftp_server = nv_unhtmlspecialchars($global_config['ftp_server']);
                 $ftp_port = intval($global_config['ftp_port']);
                 $ftp_user_name = nv_unhtmlspecialchars($global_config['ftp_user_name']);
                 $ftp_user_pass = nv_unhtmlspecialchars($global_config['ftp_user_pass']);
                 $ftp_path = nv_unhtmlspecialchars($global_config['ftp_path']);
                 // set up basic connection
                 $conn_id = ftp_connect($ftp_server, $ftp_port, 10);
                 // login with username and password
                 $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
                 if (!$conn_id || !$login_result) {
Exemplo n.º 25
0
if (isset($check_allow_upload_dir['upload_file']) and in_array('images', $admin_info['allow_files_type']) and preg_match_all('/<\\s*img [^\\>]*src\\s*=\\s*[\\""\']?([^\\""\'\\s>]*)/i', $data, $matches)) {
    $imageMatch = array_unique($matches[1]);
    $mod_name = $nv_Request->get_title('module_name', 'post', '');
    $pathsave = $nv_Request->get_title('pathsave', 'post', '');
    $upload_real_dir_page = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $mod_name;
    if (!empty($pathsave)) {
        if (!preg_match('/^[a-z0-9\\-\\_]+$/i', $module_name)) {
            $pathsave = change_alias($pathsave);
        }
        $pathsave = $mod_name . '/' . $pathsave;
        $e = explode('/', $pathsave);
        if (!empty($e)) {
            $cp = '';
            foreach ($e as $p) {
                if (!empty($p) and !is_dir(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $cp . $p)) {
                    $mk = nv_mkdir(NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $cp, $p);
                    if ($mk[0] > 0) {
                        $upload_real_dir_page = $mk[2];
                    }
                } elseif (!empty($p)) {
                    $upload_real_dir_page = NV_ROOTDIR . '/' . NV_UPLOADS_DIR . '/' . $cp . $p;
                }
                $cp .= $p . '/';
            }
        }
    }
    $currentpath = str_replace(NV_ROOTDIR . '/', '', $upload_real_dir_page);
    require_once NV_ROOTDIR . "/includes/class/image.class.php";
    foreach ($imageMatch as $imageSrc) {
        if (nv_check_url($imageSrc)) {
            $_image = new image($imageSrc);
Exemplo n.º 26
0
 // Tao file tpl
 $sql = 'SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_field';
 $result = $db->query($sql);
 while ($row = $result->fetch()) {
     $row['tab'] = unserialize($row['tab']);
     foreach ($row['tab'] as $key => $value) {
         foreach ($value as $val) {
             $arr[$val][] = $row['field'];
         }
     }
 }
 foreach ($arr as $key => $value) {
     $arr_tab_tpl[$key] = array_unique($value);
 }
 if (!file_exists(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl')) {
     nv_mkdir(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name, 'files_tpl');
 }
 foreach ($arr_tab_tpl as $key => $value) {
     $name_file = 'tab-' . strtolower(change_alias($arr_tab[$key])) . '.tpl';
     $html_tpl = "<!-- BEGIN: main -->\n";
     $html_tpl .= "\t<ul>\n";
     foreach ($value as $key => $val) {
         $html_tpl .= "\t\t<!-- BEGIN: " . $val . " -->\n";
         $html_tpl .= "\t\t\t<li>\n";
         $html_tpl .= "\t\t\t\t<p> <strong>{CUSTOM_LANG." . $val . "}:</strong> {CUSTOM_DATA." . $val . "}</p>\n";
         $html_tpl .= "\t\t\t</li>\n";
         $html_tpl .= "\t\t<!-- END: " . $val . " -->\n";
     }
     $html_tpl .= "\t</ul>\n";
     $html_tpl .= "<!-- END: main -->";
     file_put_contents(NV_ROOTDIR . '/' . NV_ASSETS_DIR . '/' . $module_name . '/files_tpl/' . $name_file, $html_tpl, LOCK_EX);