Example #1
0
/**
 * @return String/FALSE on error
 * @param String $file
 * @desc Parses a file and returns it as a string.
 */
function open_from_server($file)
{
    global $javascript_msg, $config;
    // Confirm we should be opening this, or die
    verify_secure_file($file, $config['home_dir']);
    // Make sure that the file parsing function exists, or grab code for it
    if (!function_exists('parse_file')) {
        require_once 'common.php';
    }
    // Get the file and return it if we can
    $contents = parse_file($file);
    // If there's something there (even if it's an empty string)
    if ($contents !== false) {
        $javascript_msg = 'File opened successfully.';
        return $contents;
    } else {
        $javascript_msg = '@Could not open file \'' . stripslashes(basename($file)) . '\'.';
        $_SESSION['filename'] = '';
        $_SESSION['display_filename'] = '';
        return false;
    }
}
Example #2
0
             $_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';
                 require_once 'locations/client.php';
                 save_to_client($_SESSION['display_filename'], $_POST['wp_document']);
                 $wp_document = $_POST['wp_document'];
                 break;
             case 'server':
                 require_once 'locations/server.php';
                 verify_secure_file($_SESSION['filename'], $config['home_dir']);
                 save_to_server($_SESSION['filename'], $_POST['wp_document']);
                 $wp_document = $_POST['wp_document'];
                 break;
             case 'ftp':
                 require_once 'locations/ftp.php';
                 $server = $config['ftp_servers'][$_SESSION['ftp']];
                 save_to_ftp($server['host'], $server['port'], $server['pasv'], $server['username'], $server['password'], $_SESSION['filename'], $_POST['wp_document']);
                 $wp_document = $_POST['wp_document'];
                 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($config['plugins'][$_SESSION['plugin']]['type'] . '_save($_POST[\'filename\'], $_POST[\'wp_document\']);');
                 }
                 $wp_document = $_POST['wp_document'];