Jump to content

iwato

Members
  • Content Count

    1,506
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by iwato

  1. iwato

    Reflexive Identification

    Yeah, I had already seen this page. This is how I learned about the term "magical constant" that I used in my reply to Synook. It took me a whlie to find it by the way, as magical constant implies something very special -- more special than just a self-reference. Are you suggesting that the symbolic link is treating my fwrite.php as an include? Surely not.Did you see the note from csaba?Roddy
  2. iwato

    Reflexive Identification

    You are a wise fellow, but I must say, this is the first time that I have ever encountered double-adjacent underscores as a definition of anything. This created a significant problem for me. In any case, here is what I discovered after echoing the results from dirname(__FILE__) in the file targeted by the symbolic link.Targeted File Run Independently of the Symbolic Link:This file's filepath: /Applications/MAMP/htdocs/php-practice/functions/filesystem/fwrite.Targeted File Run Via the Symbolic Link:This file's filepath: /Applications/MAMP/htdocs/php-practice/functions/filesystem/is_link. Notice that ../fwrite is the folder that contains the file to which the symbolic link points and that ../is_link is the folder that contains the symbolic link generated by the symlink( ) function.So, I opened the file created by the symlink( ) function. All that I found in the file was a relative path to the targeted file -- namely, ../fwrite/fwrite.php.Adding all of this up, does it make sense that the symlink( ) function copies the contents of the file to which it points and replaces itself momentarily with the copied file? I say momentarily, because when I open the symbolic link after the procedure has been run it only contains the aforementioned relative path.Roddy
  3. QUESTION: How does one identify a file to itself?BACKGROUND: Recently I stumbled on a very basic but daunting problem: how to specify a file containing a function whose parameter is the file that contains the function? In jQuery this problem is solved with the THIS property. How is it done in PHP?Roddy
  4. iwato

    The symlink( ) Function

    You appear to be correct on this point, because the warning message disappears when I delete File C and run File A again. We have made important progress. Unfortunately, the problem is not completely resolved. Please consider the following.As you suggested, I changed the name of the symlink( ) function's link parameter by adding the .php file extension to it. I then changed the hyperlink to the same name and clicked on it after File A was run. This is what occurred:File B produced a result exactly opposite to what is produced when the file is run independent of the symbolic link. Independent Run: Success, wrote to practice.txt the following text: "Add this text to the file."Run with Symbolic Link: practice.txt is not writable.Roddy
  5. iwato

    The symlink( ) Function

    My comment with regard to disregarding the warning was simply to say that the PHP code in the target file ( File B ) is not preventing the file from opening, as is often the case when PHP code fails. Simply, the output differs depending on whether the target file is opened unto itself or accessed via the symbolic link. Because the directory path "blah, blah, blah" in the warning message points directly to it, and because a readlink() function contained in File A reveals the correct relative path to the symbolic link. The name of the targeted file is fwrite.php, and it is contained in a different folder from fwrite which is the name of the file which is the symbolic link.Perhaps I should start over: There are three files in play: there is File A that creates the symbolic link , there is File C created by the symlink( ) function, and there is File B -- the target file. Please find below the code that produces the symbolic link ( File C ) and the hyperlink that I click on to produce the unexpected result. This code includes the entire PHP script contained in File A. <?php $target = '../fwrite/fwrite.php'; $link = 'fwrite'; symlink($target, $link); if (is_link($link)) { echo "The link corresponding to the symlink " . $link . " is: " . readlink($link); } else { echo $link . " is not a symbolic link"; } ?> <a href="fwrite">symbol</a> Please find below the code that does not produce the desired result when opened via the hyperlink pointing to the aforementioned File C. This code includes the entire PHP script contained in File B. <?php $filename = 'practice.txt'; $someContent = 'Add this text to the file.'; if (is_writable($filename)) { $referenceVariable = fopen($filename, 'a'); if (!$referenceVariable) { echo 'Cannot open ' . $filename; exit; } if (fwrite($referenceVariable, $someContent) === FALSE) { echo 'Cannot write to file ($filename)'; exit; } echo 'Success, wrote to ' . $filename . ' the following text: "' . $someContent . '"'; fclose($referenceVariable); } else { echo $filename . ' is not writable'; } ?> Roddy
  6. Alas, I need them all and with CSS added on I can use AJAX.My journey shall be long. So, I must dig in.Thanks everyone!Roddy
  7. If I have understood correctly, I can do everything with Javascript, XML, and PHP that I can do with PHP and MySQL, but I cannot do everything with PHP and MySQL that I can do with Javascript, XML, and PHP. Is this what you are saying?Roddy
  8. QUESTION: Can one achieve everything with PHP and MySQL that one could ever want to achieve with Javascript and the XML DOM object? If not, what does the XML DOM object offer that MySQL does not and how are these complementary? Then too, maybe I am posing the wrong questions altogether. Please see below.BACKGROUND: When I first started learning PHP is was with the idea of building a webserver with dynamic webpages. Knowing that I would eventually want to add a database to my server I downloaded MAMP, purchased MAMP-Pro, and prepared for the inevitable -- learning how to use write in still another program language, namely, MySQL. Along the way, however, and even much before, I encountered XML. It would appear that learning both MySQL and XML are somewhat redundant. This said, XML does not appear to be very difficult, and I envision having to access all different kinds of databases to fill my own as time passes.Roddy
  9. iwato

    Good PHP tutorial book

    If these are what Barebones used to produce its software, then I can highly recommend them.Roddy
  10. iwato

    The symlink( ) Function

    In order to encourage further interest in this seemingly erudite topic please see the very practical application proposed by Olszewski Marek's entry on the PHP website.Roddy
  11. iwato

    The symlink( ) Function

    Firstly, please see the PHP website entry for the symlink function. My understanding of a target parameter is the pre-existence of a targeted file. If this were the case, then it is unlikely that the file would open at all, is it not? Clearly it opens.Roddy
  12. iwato

    The symlink( ) Function

    In answer to your probably more important second question, the two files are only separated by the folders in which they are contained, and the folder that contains these folders is well within the root folder.Let File A be the file in which the symbol resides, and let File B be the target file to which the symbolic link points. Both files are PHP files.TEST PROCEDURE:1) When I call File A I receive the following message: Warning: symlink() [function.symlink]: File exists in blah,blah,blah on line 37. Disregarding the warning everything performs as it should, and blah,blah,blah points correctly to File A2) I click on the symbol in File A. This in turn opens File B, as one might expect. However, what is displayed in File B when it is opened by the symbolic link, and what is displayed by File B when it is opened unto itself without the link result in two different outputs.a) When File B is opened unto itself, both the HTML and the file's PHP generated output appear. When File B is opened by File A via the symbolic link, however, only the HTML of File B appears. No error message is produced. In fact, if I did not know that there were PHP script in File B, I would think that everything worked just fine.Roddy
  13. QUESTION: I have been experimenting with the symlink( ) function and have witnessed a somewhat bizarre phenomenon that I do not know how to explain. Although I am able to create s symbolic link, when the target file is opened, the PHP code within it does not appear to run. How might one explain this?Roddy
  14. iwato

    Phishing at W3Schools

    ADVISORY: Recently I discovered an email to a forum topic in Javascript that I was following. When I clicked on it, it took me to an unidentified forbidden location. When I examined the email I found a phony address.Beware fellow users.Roddy
  15. iwato

    The fileatime( ) Function

    The following is a nifty piece of code. I did not know that what came after the as-word in the foreach loop expression was so flexible.foreach ($statArray as $key => $val) { echo '$statArray[' . $key . '] = "' . $val . '"<br>';} My silly file error has turned into a treasure trove of new knowledge. The hydra has been killed. Well, at least until another appears . . . .W3Schools: My nomination for the internet's best teacher award!Roddy
  16. iwato

    The fileatime( ) Function

    Yes, my two important lessons from this topic besides paying more attention to filenames and directories are:1) Warnings and notices are not fatal, and 2) Return values can play deceptive tricks. So, in this case 0 is 1/1/70. Understood.Many thanks to you and Boen Robot!Roddy
  17. iwato

    The fileatime( ) Function

    <?php print_r(stat("../fileatime/fileatime.php")); ?> and later in the same file: <?php clearstatcache(); $statArray = stat("../fileatime/fileatime.php"); foreach ($statArray as $statArrayElement) { echo $statArrayElement . "<br />"; } ?> Roddy
  18. iwato

    The fileatime( ) Function

    Yes, it works. Please find below the contents of the data array generated by the stat( ) function.Curiously, the same content is reproduced twice (not shown) when echoed in a foreach loop.23488102669707633216150120018921274137385 [atime]1274066367 [mtime]1274066367 [ctime]4096Having followed your suggestion and shown to myself that the a-time differs from both the m- and c-times in the file I came to realize that the problem may lie elsewhere. A little further exploration revealed that I had mis-specified the location of the file to which the PHP script was pointing. When I adjusted the location, the script did as would be normally expected.Now, I am left with trying to understand . . .1) why the script ran at all, and more importantly why it generated the false date, and2) why the data array generated by the stat( ) function is echoed twice in a foreach loop.Maybe I should stop here and be thankful that my initial problem was not caused by mis-specified permissions in my MAMP-Pro interface. Then too, my goal is to understand PHP in my current environment, so that I can eventually make effective use of it. For the moment, it is like the ancient Greek Hydra (well this is one version of the story, anyway). You chop off one or more heads grow in its place.Thanks everyone for your great help!Roddy
  19. iwato

    The fileatime( ) Function

    I did as you suggested and can now clearly understand why my browser was unable to open the PHP file as part of my webserver. Thank you for the suggestion. I feel a little silly now for not having thought of it myself. In any case, Dreamweaver does not appear to be the source of the problem, as the resulting reported date was the same both with and without the application.By the way, I like the way you spell Dreamweaver. It does some nice things, but happy dreams are not one of them.Roddy
  20. iwato

    The fileatime( ) Function

    Being the novice that I am I do not know how to run PHP files without Dreamweaver. When I go to the folder and try to open the file with Firefox or Safari while the webserver is turned on the PHP script fails to run at all. At least through Dreamweaver a date is returned.Roddy
  21. iwato

    The fileatime( ) Function

    The same phenomenon occurs for both the fileatime( ) and filemtime( ) functions. I checked the filemtime( ) function just after posting about the fileatime( ) function for the same reason that you appear to be suggesting.Also, among my MacOS Finder View options both the date a file was created and last modified are available for all of my files. So what I see in the Dreamweaver File window is probably just a reflection of what can be seen in my Finder. In short, my access times have not been disabled within the UNIX framework.Roddy
  22. The PROBLEM:According to W3Schools the following block of code is suppose to tell when the last time a particular file was accessed: <?php clearstatcache(); $timestamp = fileatime("../include_and_require/footer.php"); echo "<br />"; echo "Last access: " . date("d M Y h:i:s.",$timestamp); ?> Unfortunately, when I run the PHP script it produces the following: Last access: 01 Jan 1970 09:00:00. The PHP file renders accurately except for the date and time. My MAMP-Pro error log does reveal the following error, however: "[17-May-2010 12:48:23] PHP Warning: fileatime() [<a href='function.fileatime'>function.fileatime</a>]: stat failed for ../include_and_require/footer.php in /Applications/MAMP/htdocs/php-practice/functions/filesystem/fileatime/fileatime.php on line 37".Line 37 corresponds to the following PHP code line: $timestamp = fileatime("../include_and_require/footer.php"); BACKGROUND:Also, according to W3Schools, "Some Unix systems have access time updates disabled, because this function reduces performance for applications that regularly accesses a large number of files." Since Dreamweaver provides the last date of access of all the files that it manages surely this is not the source of the problem.Several weeks ago I zeroed out and rebuilt my entire machine. This is my first day back at PHP after a several week "Let's get acquainted period with TextWrangler" period. Well, I am now pretty well-acquainted and eager to return to PHP.All of the software that went into the creation of this file was freshly installed when I rebuilt my machine. Even my MAMP-Pro software appears to be running well now. However, I did change the factory settings for permissions. Of the three sets of permissions including owner, group, and other, I have squelched all permissions but for those related to the two owner/administrators of my machine. Have I blocked the system from doing its work? What could be the problem? This is not a fun way to restart with PHP . . . .Roddy
  23. iwato

    Regular Expression

    For right now the problem is to extract the matches -- not place them. Already, with Synook's helpful hint, I have demonstrated that it can be done for a known number of paired delimiters. Perhaps I could count the number of delimiters present, divide by two, and then write a script that would create a match pattern for the resulting number of paired delimiters. This seems like a lot of work for something that I thought possible solely with regular expression quantifiers.Perhaps I should be satisfied with the progress that I have already made.Certainly, it has taught be quite a lot about regular expressions.Maybe I have exhausted this forum's knowledge of regular expressions.Roddy
  24. iwato

    Regular Expression

    Firstly the above code does not produce a useful result, but thank you for trying anyway.Secondly, when I break it up into its sub-patterns I obtain the following:1) ([\w]+)[", ]+ // This captures the first entity.2) ((([\w]+)[", ]+)*([\w]+))[", ]+)* // What is this one suppose to do?3) ([\w]+) // This captures the last entity.MY GOAL: To be able to 1) capture the content of each set of paired delimiters, as it is, without its delimiters, and2) perform Item 1 for an unknown number of paired delimiters.By the way, I am glad that you were able to resolve your migration problem.Roddy
  25. iwato

    Regular Expression

    This code will capture everything that I want for this particular string, but it is string-specificFind: "([\w]+)[", ]+(([\w]+)[", ]+([\w]+)[", ]+([\w]+))[", ]+([\w]+)"Replace: \NResult \1: applesResult \2: oranges, kiwis, mangosResult \6: penquinsRoddy
×
×
  • Create New...