<?php require_once '../admin/configuration.php'; require_once '../admin/authentication.php'; require_once 'common.php'; // Update last used file type $_SESSION['last_type'] = 'http'; // Handle request for external document, into temp file if (isset($_POST['url'])) { $temp_name = date('YmdHis') . '.wp'; // Attempt to parse remote file into a string if ($string = parse_remote_file($_POST['url'])) { // If possible, open a handle to a temp file and write the string to it. $th = fopen('../temp/' . $temp_name, 'w'); if ($th) { fwrite($th, $string); fclose($th); // Trigger webpad to load the file from the server temp dir $_SESSION['display_filename'] = $_POST['url']; $_SESSION['filename'] = './temp/' . $temp_name; $_SESSION['server_pwd'] = './temp/'; $_SESSION['operation'] = 'open'; $_SESSION['open_type'] = 'server'; // Reload webpad and get out reload_webpad_and_close(); } else { $msg = 'Could not create temporary file on the server, check permissions on the temp directory.'; } } else { $msg = 'Could not retrieve remote file. It may be secured, dynamically generated or the URL is wrong.'; }
verify_secure_file($_SESSION['filename'], $config['home_dir']); $wp_document = open_from_server($_SESSION['filename']); break; case 'ftp': require_once 'locations/ftp.php'; $server = $config['ftp_servers'][$_SESSION['ftp']]; $wp_document = open_from_ftp($server['host'], $server['port'], $server['pasv'], $server['username'], $server['password'], $_SESSION['filename']); break; case 'plugin': if (is_readable('plugins/' . $config['plugins'][$_SESSION['plugin']]['type'] . '/code.php')) { require_once 'plugins/' . $config['plugins'][$_SESSION['plugin']]['type'] . '/code.php'; eval('$wp_document = ' . $config['plugins'][$_SESSION['plugin']]['type'] . '_open();'); } break; case 'http': $wp_document = parse_remote_file($_SESSION['filename']); $_SESSION['display_filename'] = $_SESSION['filename']; break; case 'template': require_once 'locations/server.php'; $wp_document = open_from_server('templates/' . $_SESSION['filename']); $javascript_msg = 'New file created from template.'; $_SESSION['filename'] = 'new_webpad_document'; $_SESSION['operation'] = 'new'; break; } } else { if ($_SESSION['operation'] == 'save') { switch ($_SESSION['save_type']) { case 'client': require_once 'locations/server.php';