Example #1
0
/**
 * 栏目URL
 */
function getCaturl($data, $page = 0)
{
    if (is_numeric($data)) {
        $cats = get_category_data();
        $data = $cats[$data];
        unset($cats);
    }
    if ($data['typeid'] == 3) {
        return $data['urlpath'];
    }
    $url = url('content/list', array('catid' => $data['catid']));
    if (!is_array($data['setting'])) {
        $data['setting'] = string2array($data['setting']);
    }
    if (isset($data['setting']['url']['use']) && $data['setting']['url']['use'] == 1 && $data['setting']['url']['list']) {
        $data['id'] = $data['catid'];
        $data['dir'] = $data['catdir'];
        $data['pdir'] = getParentDir($data['catid'], $data['setting']['url']['catjoin']);
        $data['page'] = $page;
        if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
            $rep = new php5replace($data);
            $url = !is_numeric($page) || $page > 1 ? preg_replace_callback('#{([a-z_0-9]+)}#Ui', array($rep, 'php55_replace_data'), $data['setting']['url']['list_page']) : preg_replace_callback('#{([a-z_0-9]+)}#Ui', array($rep, 'php55_replace_data'), $data['setting']['url']['list']);
        } else {
            $url = !is_numeric($page) || $page > 1 ? preg_replace('#{([a-z_0-9]+)}#Uei', "\$data[\\1]", $data['setting']['url']['list_page']) : preg_replace('#{([a-z_0-9]+)}#Uei', "\$data[\\1]", $data['setting']['url']['list']);
        }
        if ($data['setting']['url']['tohtml'] && $data['setting']['url']['htmldir']) {
            $url = $data['setting']['url']['htmldir'] . '/' . $url;
        }
        if (version_compare(PHP_VERSION, '5.5.0') >= 0) {
            $rep = new php5replace($data);
            $url = preg_replace_callback('#{([a-z_0-9]+)\\((.*)\\)}#U', array($rep, 'php55_replace_function'), $url);
        } else {
            $url = preg_replace('#{([a-z_0-9]+)\\((.*)\\)}#Uie', "\\1(safe_replace('\\2'))", $url);
        }
        return SITE_PATH . $url;
    }
    if ($page) {
        $url = url('content/list', array('catid' => $data['catid'], 'page' => $page));
    }
    return $url;
}
Example #2
0
function instAdaptPathInDB(&$session, &$message)
{
    $path = getParentDir($session, $session->fScriptBase);
    if (empty($path)) {
        $path = PATH_DELIM;
    }
    instUpdateMacro($session, 'base:BaseModule', $path . "index.php/", $message);
    instUpdateMacro($session, 'forum:ForumModule', $path . "forum.php/", $message);
    instUpdateMacro($session, 'base:ScriptBase', $path, $message);
    $count = sqlUpdate($session, 'param', " text='" . $path . "css/phpwiki.css'", "pos=152", true);
    if ($count == 0) {
        $message .= "\n<br>+++ Parameter 152 (CSS-Datei) nicht gefunden.";
    } else {
        $message .= "<br>\n" . 'CSS wurde auf ' . $path . "css/phpwiki.css gesetzt. ({$count} mal)";
    }
}
Example #3
0
function copyFiles()
{
    // As there is no PHP function to copy files by FTP on a remote server, the files
    // need to be downloaded to the client server and then uploaded to the copy location.
    global $conn_id;
    global $serverTmp;
    global $lang_folder_exists;
    global $lang_file_exists;
    global $lang_server_error_down;
    global $lang_server_error_up;
    // Check for a right-clicked folder (else it's current)
    if (isset($_POST["rightClickFolder"])) {
        $folderMoveTo = quotesUnescape($_POST["rightClickFolder"]);
    } else {
        $folderMoveTo = $_SESSION["dir_current"];
    }
    // Folders
    foreach ($_SESSION["clipboard_folders"] as $folder) {
        $folder_name = getFileFromPath($folder);
        $dir_source = getParentDir($folder);
        // Check if folder exists
        if (checkFileExists("f", $folder_name, $folderMoveTo) == 1) {
            recordFileError("folder", tidyFolderPath($folderMoveTo, $folder_name), $lang_folder_exists);
        } else {
            copyFolder($folder_name, $folderMoveTo, $dir_source);
        }
    }
    // Files
    foreach ($_SESSION["clipboard_files"] as $file) {
        $isError = 0;
        $file_name = getFileFromPath($file);
        $fp1 = tempnam($serverTmp, $file_name);
        $fp2 = $file;
        $fp3 = $folderMoveTo . "/" . $file_name;
        // Check if file exists
        if (checkFileExists("f", $file_name, $folderMoveTo) == 1) {
            recordFileError("file", tidyFolderPath($folderMoveTo, $file_name), $lang_file_exists);
        } else {
            ensureFtpConnActive();
            // Download file to client server
            if (!@ftp_get($conn_id, $fp1, $fp2, FTP_BINARY)) {
                if (checkFirstCharTilde($fp2) == 1) {
                    if (!@ftp_get($conn_id, $fp1, replaceTilde($fp2), FTP_BINARY)) {
                        recordFileError("file", $file_name, $lang_server_error_down);
                        $isError = 1;
                    }
                } else {
                    recordFileError("file", $file_name, $lang_server_error_down);
                    $isError = 1;
                }
            }
            if ($isError == 0) {
                ensureFtpConnActive();
                // Upload file to remote server
                if (!@ftp_put($conn_id, $fp3, $fp1, FTP_BINARY)) {
                    if (checkFirstCharTilde($fp3) == 1) {
                        if (!@ftp_put($conn_id, replaceTilde($fp3), $fp1, FTP_BINARY)) {
                            recordFileError("file", $file_name, $lang_server_error_up);
                        }
                    } else {
                        recordFileError("file", $file_name, $lang_server_error_up);
                    }
                }
            }
            // Delete tmp file
            unlink($fp1);
        }
    }
}
Example #4
0
function openFolder()
{
    global $conn_id;
    global $lang_folder_doesnt_exist;
    $isError = 0;
    if ($_SESSION["loggedin"] == 1) {
        // Set the folder to open
        if ($_SESSION["dir_current"] != "") {
            $dir = $_SESSION["dir_current"];
        }
        if (isset($_POST["openFolder"]) && $_POST["openFolder"] != "") {
            $dir = quotesUnescape($_POST["openFolder"]);
        }
        // Check dir is set
        if (empty($dir)) {
            // No folder set (must be first login), so set home dir
            if ($_SESSION["win_lin"] == "lin" || $_SESSION["win_lin"] == "mac") {
                $dir = "~";
            }
            if ($_SESSION["win_lin"] == "win") {
                $dir = "/";
            }
        }
        // Attempt to change directory
        if (!@ftp_chdir($conn_id, $dir)) {
            if (checkFirstCharTilde($dir) == 1) {
                if (!@ftp_chdir($conn_id, replaceTilde($dir))) {
                    recordFileError("folder", replaceTilde($dir), $lang_folder_doesnt_exist);
                    $isError = 1;
                }
            } else {
                recordFileError("folder", $dir, $lang_folder_doesnt_exist);
                $isError = 1;
            }
        }
        if ($isError == 0) {
            // Set new directory
            $_SESSION["dir_current"] = $dir;
            // Record new directory to history
            if (!is_array($_SESSION["dir_history"])) {
                // array check
                $_SESSION["dir_history"] = array();
            }
            if (!in_array($dir, $_SESSION["dir_history"])) {
                $_SESSION["dir_history"][] = $dir;
                asort($_SESSION["dir_history"]);
                // sort array
            }
            return 1;
        } else {
            // Delete item from history
            deleteFtpHistory($dir);
            // Change to previous directory (if folder to open is currently open)
            if ($_POST["openFolder"] == $_SESSION["dir_current"] || $_POST["openFolder"] == "") {
                $_SESSION["dir_current"] = getParentDir();
            }
            return 0;
        }
    }
}
Example #5
0
function openFolder()
{
    global $conn_id;
    global $lang_folder_doesnt_exist;
    if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] == 1) {
        // Set the folder to open
        if (isset($_SESSION["dir_current"]) && $_SESSION["dir_current"] != "") {
            $dir = $_SESSION["dir_current"];
        }
        if (isset($_POST["openFolder"]) && $_POST["openFolder"] != "") {
            $dir = quotesUnescape($_POST["openFolder"]);
        }
        // Check dir is set
        if ($dir == "") {
            // No folder set (must be first login), so set home dir
            if (isset($_SESSION["win_lin"]) && $_SESSION["win_lin"] == "lin") {
                $dir = "~";
            }
            // ~ denotes user's home directory
            if (isset($_SESSION["win_lin"]) && $_SESSION["win_lin"] == "win") {
                $dir = "/";
            }
        }
        // Attempt to change directory
        if (@ftp_chdir($conn_id, $dir)) {
            // Set new directory
            $_SESSION["dir_current"] = $dir;
            // Record new directory to history
            if (isset($_SESSION["dir_history"]) && !is_array($_SESSION["dir_history"])) {
                // array check
                $_SESSION["dir_history"] = array();
            }
            if (isset($_SESSION["dir_history"]) && !in_array($dir, $_SESSION["dir_history"])) {
                $_SESSION["dir_history"][] = $dir;
                asort($_SESSION["dir_history"]);
                // sort array
            }
            return 1;
        } else {
            // If $dir was ~ (Linux) and it failed, try / as the home folder and run this function again before returning an error
            if ($dir == "~") {
                $_SESSION["dir_current"] = "/";
                openFolder();
            } else {
                $_SESSION["errors"][] = str_replace("[folder]", $dir, $lang_folder_doesnt_exist);
                // Delete item from history
                deleteFtpHistory($dir);
                // Change to previous directory (if folder to open is currently open)
                if (isset($_SESSION["dir_current"]) && isset($_POST["openFolder"]) && ($_POST["openFolder"] == $_SESSION["dir_current"] || $_POST["openFolder"] == "")) {
                    $_SESSION["dir_current"] = getParentDir();
                }
                return 0;
            }
        }
    }
}