[php] online notepad

Results 1 to 1 of 1
  1. #1
    The Omega Superfun is offline
    MemberRank
    Dec 2006 Join Date
    The NetherlandsLocation
    5,223Posts

    [php] online notepad

    my email got messed up with too many things i had to remind so i made this

    PHP Code:
    <?php
    $file 
    'note.txt';

    if(isset(
    $_GET['info'])){
        
    $files fopen($file,'w');
        
    fwrite($files$_GET['info']);
        
    fclose($files);
    }
    ?>
    <html>
    <body>

    <script language="javascript" type="text/javascript">
    <!-- 
    //Browser Support Code
    function ajaxFunction(){
        var ajaxRequest;
        try{
            
            ajaxRequest = new XMLHttpRequest();
        } catch (e){
            
            try{
                ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try{
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e){
                    
                    alert("Sorry, Notepad will not work with your browser.");
                    return false;
                }
            }
        }


        ajaxRequest.onreadystatechange = function(){
            if(ajaxRequest.readyState == 4){
                
            }
        }
        var info = nl2br(document.notepad.textarea.value, false);
        ajaxRequest.open("GET", "<?php echo $_SERVER['PHP_SELF']; ?>?info=" + info, true);
        ajaxRequest.send(null); 
        
    }

    function nl2br (str, is_xhtml) {
        var breakTag = '';
        var extra = true;

        breakTag = '<br />';
        if (typeof is_xhtml != 'undefined' && !is_xhtml) {
            breakTag = '<br>';
        }
        
        if(extra == true){
            breakTag = '%br%';
        }

        return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
    }

    //-->
    </script>


    <div align='center'>
    <form name='notepad'>
    <textarea onKeyUp="ajaxFunction();" name='textarea' cols='150' rows='40'>
    <?php
    $a 
    file_get_contents($file);
    echo 
    str_replace('%br%''
    '
    $a);
    ?>
    </textarea>
    </form>
    </div>
    </body>
    </html>
    (sorry if there is any useless code, my own website uses it with mysql)

    The funny thing is, no save buttum due ajax = great!
    Last edited by Superfun; 02-10-09 at 10:37 PM.




Advertisement