<!-- WIDGET: notepad -->

<?php

	if(!defined('master_script')) die();

 	$widget_config_folder = $system_data['folder']['settings'] . 'widgets/notepad/';
 	$notepad_file = $widget_config_folder . 'notepad.php';

	// Save
	if(isset($_POST['save_notepad'])) {
		if(!file_exists($widget_config_folder)) rmkdir($widget_config_folder);

		$open_notepad = fopen($notepad_file, 'wb');
		fwrite($open_notepad, '<?php if(!defined("master_script")) die(); ?>' . "\n");
		fwrite($open_notepad, clean_string($_POST['notepad'], false));
		fclose($open_notepad);
	}
	
	// Get
	$notepad[] = '';
	
	if(file_exists($notepad_file)) {
		$notepad = file($notepad_file);
		unset($notepad[0]);
	}
	
?>

<div style="width: 500px; background: url(<?php echo $system_data['folder']['widgets']; ?>notepad/notepad-background.png) no-repeat left top">
    <form style="padding: 25px 0 0 0; text-align: center" action="index.php?backend=widgets" method="post" accept-charset="utf-8">
    	<textarea style="width: 425px; height: 285px; margin: 0 35px 40px 35px; padding: 0; border: 0; background-color: transparent; font: 14px 'Comic Sans MS', cursive; line-height: 16px; color: #222222; outline: none" name="notepad" cols="50" rows="25"><?php echo join($notepad); ?></textarea>
    	<p style="text-align: right"><input name="save_notepad" type="submit" value="<?php echo txt('notepad', 'Speichern'); ?>"></p>
    </form>
</div>