User Tools

Site Tools


blog:spring2016:cjann:journal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
blog:spring2016:cjann:journal [2016/05/02 16:32] – [May 2nd 2016] cjannblog:spring2016:cjann:journal [2016/05/02 17:44] (current) – [May 2nd 2016] cjann
Line 700: Line 700:
 Well, half of my dream has been realized. I've successfully used openssl encryption to encrypt a string and output it to an existing file. Using all the same output functions previously covered: open_sslencrypt and file_put_contents. As it stands, the new string overtires the old. If one were so inclined there is probably a constant or different method that appends new text after the text that was previously there. Well, half of my dream has been realized. I've successfully used openssl encryption to encrypt a string and output it to an existing file. Using all the same output functions previously covered: open_sslencrypt and file_put_contents. As it stands, the new string overtires the old. If one were so inclined there is probably a constant or different method that appends new text after the text that was previously there.
  
 +Yep, after looking at the documentation there is a parameter constant that can be used to append data to the file instead of overwriting it (the documentation calls it a "flag"). The flags are added after the other parameters (file object and data). The flag used to append data instead of overwriting is FILE_APPEND.
  
 +Interestingly, file_put_contents is a simplified method to interact with files. A different method would be to use the three functions fopen, fwrite, and fclose. All of these take their own parameters, but it's essentially a longer way to do exactly what file_put_contents does (I think).
 +
 +I did throw down some quick php code in windows to test fopen outside of our unix environment. I wasn't able to use php to create a file because of write permissions. So I whipped up some fast code to create a file with fopen and dump some plain text into it. There must be something more to writing and interpreting php code in windows. When I use the file address in the address bar of a browser all I see is a text version of the file. No output file is created.
 +
 +I did attempt to use the command here http://php.net/manual/en/install.windows.commandline.php
 +To execute the code from the command line. I got the error message "php.exe" is not recognized as an internal or external command, operable program or batch file". So I assume there needs to be some installation required for this command to work. More research to follow.
 +
 +Well obviously there's an installation required. Right above the command to run the file is a link that says "You should read the manual installation steps first!". I've done a great job at ignoring that crucial piece of direction.
 +
 +I'll have to attempt to install required PHP tools when I get home.
 +
 +Also, I may have potentially found a solution to my file permissions issue. There is a PHP function that changes the chmod values of a file! So, potentially, I could use this function to change the permissions of the file I am creating as it is being created. I whipped up some quick code but I can't test it because I forget how to access my files from a browser. I'm super great at this. I'll debug and test the code once I get to class.
blog/spring2016/cjann/journal.1462206732.txt.gz · Last modified: 2016/05/02 16:32 by cjann