function getHandler($name = "file", $path = false, $create = false, $mode = null) { $handler = null; XoopsFile::load($name); $class = "Xoops" . ucfirst($name) . "Handler"; if (class_exists($class)) { $handler = new $class($path, $create, $mode); } else { trigger_error("Class '{$class}' not exist", E_USER_WARNING); } return $handler; }
/** * XoopsFile::getHandler() * * @param string $name * @param mixed $path * @param mixed $create * @param mixed $mode * @return */ public static function getHandler($name = 'file', $path = false, $create = false, $mode = null) { $handler = null; XoopsFile::load($name); $class = 'Xoops' . ucfirst($name) . 'Handler'; if (class_exists($class)) { $handler = new $class($path, $create, $mode); } else { trigger_error('Class ' . $class . ' not exist in File ' . __FILE__ . ' at Line ' . __LINE__, E_USER_WARNING); } return $handler; }
if ($uploader->fetchMedia('upload_file')) { if (!$uploader->upload()) { $err[] =& $uploader->getErrors(); } } if (isset($err)) { foreach ($err as $line) { echo $line; } } redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_UPLOAD_FILE); break; case 'filemanager_add_dir_save': $path = system_CleanVars($_REQUEST, 'path', XOOPS_ROOT_PATH . '/', 'string'); xoops_load('XoopsFile'); XoopsFile::load('folder'); $folder = XoopsFile::getHandler('folder'); if ($folder->create($path . $_REQUEST['dir_name'], 0777)) { $indexFile = XOOPS_ROOT_PATH . '/modules/system/index.html'; copy($indexFile, $path . $_REQUEST['dir_name'] . '/index.html'); redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_DIR_SUCCESS); } else { redirect_header('admin.php?fct=filemanager', 2, _AM_SYSTEM_FILEMANAGER_DIR_ERROR); } break; case 'filemanager_add_file_save': $path = system_CleanVars($_REQUEST, 'path', XOOPS_ROOT_PATH . '/', 'string'); if ($path == '') { $path = XOOPS_ROOT_PATH . '/'; } $open = fopen($path . $_REQUEST['file_name'], 'w+');
} break; // Edit File // Edit File case 'tpls_edit_file': $path_file = XOOPS_ROOT_PATH . '/themes' . trim($_REQUEST['path_file']); //Button restore if (file_exists($path_file . '.back')) { $restore = '<button class="ui-corner-all tooltip" type="button" onclick="tpls_restore(\'' . $path_file . '\')" value="' . _AM_SYSTEM_TEMPLATES_RESTORE . '" title="' . _AM_SYSTEM_TEMPLATES_RESTORE . '"> <img src="' . system_AdminIcons('revert.png') . '" alt="' . _AM_SYSTEM_TEMPLATES_RESTORE . '" /> </button>'; } else { $restore = ''; } xoops_load('XoopsFile'); XoopsFile::load('file'); $file = XoopsFile::getHandler('file', $path_file); $content = $file->read(); if (empty($content)) { echo _AM_SYSTEM_TEMPLATES_EMPTY_FILE; } $ext = preg_replace('/^.*\\./', '', $_REQUEST['path_file']); echo '<form name="back" action="admin.php?fct=tplsets&op=tpls_save" method="POST"> <table border="0"> <tr> <td> <div class="xo-btn-actions"> <div class="xo-buttons"> <button class="ui-corner-all tooltip" type="submit" value="' . _AM_SYSTEM_TEMPLATES_SAVE . '" title="' . _AM_SYSTEM_TEMPLATES_SAVE . '"> <img src="' . system_AdminIcons('save.png') . '" alt="' . _AM_SYSTEM_TEMPLATES_SAVE . '" /> </button>