Beispiel #1
0
            file_put_contents($tempFile, serialize($results));
        } else {
            if (!empty($newFile)) {
                $info = nv_getFileInfo($pathimg, $newFile);
                $info[8] = $admin_info['userid'];
                $info[9] = NV_CURRENTTIME;
                $results[$newFile] = $info;
                ksort($results);
                file_put_contents($tempFile, serialize($results));
            }
            if (!empty($delFile)) {
                unset($results[$delFile]);
                file_put_contents($tempFile, serialize($results));
            }
        }
    }
    return $results;
}
$allow_upload_dir = array('images', NV_UPLOADS_DIR);
$array_hidefolders = array(".svn", "CVS", ".", "..", "index.html", ".htaccess", ".tmp");
$array_images = array("gif", "jpg", "jpeg", "pjpeg", "png");
$array_flash = array('swf', 'swc', 'flv');
$array_archives = array('rar', 'zip', 'tar');
$array_documents = array('doc', 'xls', 'chm', 'pdf', 'docx', 'xlsx');
$dirlistCache = NV_ROOTDIR . "/" . NV_FILES_DIR . "/dcache/dirlist-" . md5(implode($allow_upload_dir));
if (!file_exists($dirlistCache) or $nv_Request->isset_request('dirListRefresh', 'get') and filemtime($dirlistCache) < NV_CURRENTTIME - 30) {
    $dirlist = nv_loadUploadDirList();
} else {
    $dirlist = file_get_contents($dirlistCache);
    $dirlist = unserialize($dirlist);
}
Beispiel #2
0
 * @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['rename_dir']) or $check_allow_upload_dir['rename_dir'] !== true) {
    die("ERROR_" . $lang_module['notlevel']);
}
if (empty($path) or $path == NV_UPLOADS_DIR) {
    die("ERROR_" . $lang_module['notlevel']);
}
if (empty($newname)) {
    die("ERROR_" . $lang_module['rename_nonamefolder']);
}
unset($matches);
preg_match("/(.*)\\/(.*)\$/", $path, $matches);
if (!isset($matches) or empty($matches)) {
    die("ERROR_" . $lang_module['notlevel']);
}
$newpath = $matches[1] . '/' . $newname;
if (is_dir(NV_ROOTDIR . '/' . $newpath)) {
    die("ERROR_" . $lang_module['folder_exists']);
}
nv_delete_cache_upload($path);
@rename(NV_ROOTDIR . '/' . $path, NV_ROOTDIR . '/' . $newpath);
nv_loadUploadDirList(false);
nv_insert_logs(NV_LANG_DATA, $module_name, $lang_module['renamefolder'], $path . " -> " . $newpath, $admin_info['userid']);
echo $newpath;
Beispiel #3
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;
     $sql = "SELECT `module_file`, `module_data`, `theme` 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, $module_theme) = $db->sql_fetchrow($result);
         // Unfixdb
         $module_file = $db->unfixdb($module_file);
         $module_data = $db->unfixdb($module_data);
         $module_theme = $db->unfixdb($module_theme);
         $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_delete_all_cache();
         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);
             }
             $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
             $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[$db->unfixdb($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);
             foreach ($array_keys 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 `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`, `setting`) VALUES (NULL, " . $db->dbescape($func) . ", " . $db->dbescape(ucfirst($func)) . ", " . $db->dbescape($module_name) . ", " . $show_func . ", 0, " . $weight . ", '')";
                     $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);
                             nv_loadUploadDirList(false);
                         }
                         $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;
 }